summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/VERSION4
-rw-r--r--source4/auth/auth.c41
-rw-r--r--source4/auth/auth_developer.c2
-rw-r--r--source4/auth/auth_sam.c19
-rw-r--r--source4/auth/auth_server.c20
-rw-r--r--source4/auth/auth_simple.c2
-rw-r--r--source4/auth/auth_unix.c11
-rw-r--r--source4/auth/auth_util.c34
-rw-r--r--source4/auth/auth_winbind.c2
-rw-r--r--source4/auth/credentials/credentials.c159
-rw-r--r--source4/auth/credentials/credentials.h2
-rw-r--r--source4/auth/credentials/credentials_files.c35
-rw-r--r--source4/auth/gensec/cyrus_sasl.c17
-rw-r--r--source4/auth/gensec/gensec.c36
-rw-r--r--source4/auth/gensec/gensec.h3
-rw-r--r--source4/auth/gensec/gensec_gssapi.c61
-rw-r--r--source4/auth/gensec/gensec_krb5.c53
-rw-r--r--source4/auth/gensec/schannel.c22
-rw-r--r--source4/auth/gensec/schannel_sign.c1
-rw-r--r--source4/auth/gensec/schannel_state.c8
-rw-r--r--source4/auth/gensec/socket.c20
-rw-r--r--source4/auth/gensec/spnego.c56
-rw-r--r--source4/auth/gensec/spnego_parse.c30
-rw-r--r--source4/auth/kerberos/config.mk2
-rw-r--r--source4/auth/kerberos/gssapi_parse.c14
-rw-r--r--source4/auth/kerberos/kerberos_util.c12
-rw-r--r--source4/auth/kerberos/krb5_init_context.c15
-rw-r--r--source4/auth/ntlm_check.c87
-rw-r--r--source4/auth/ntlmssp/ntlmssp.c32
-rw-r--r--source4/auth/ntlmssp/ntlmssp.h3
-rw-r--r--source4/auth/ntlmssp/ntlmssp_client.c41
-rw-r--r--source4/auth/ntlmssp/ntlmssp_parse.c40
-rw-r--r--source4/auth/ntlmssp/ntlmssp_server.c117
-rw-r--r--source4/auth/ntlmssp/ntlmssp_sign.c16
-rw-r--r--source4/auth/sam.c21
-rwxr-xr-xsource4/autogen.sh5
-rw-r--r--source4/build/m4/public.m435
-rw-r--r--source4/build/smb_build/input.pm10
-rw-r--r--source4/build/smb_build/makefile.pm40
-rw-r--r--source4/build/smb_build/output.pm6
-rw-r--r--source4/build/smb_build/summary.pm13
-rw-r--r--source4/cldap_server/cldap_server.c7
-rw-r--r--source4/cldap_server/netlogon.c21
-rw-r--r--source4/client/cifsdd.c21
-rw-r--r--source4/client/cifsddio.c60
-rw-r--r--source4/client/client.c158
-rw-r--r--source4/client/config.mk3
-rw-r--r--source4/client/smbmount.c50
-rw-r--r--source4/client/smbspool.c2
-rw-r--r--source4/cluster/cluster.c1
-rw-r--r--source4/cluster/ctdb/brlock_ctdb.c26
-rw-r--r--source4/cluster/ctdb/client/ctdb_client.c35
-rw-r--r--source4/cluster/ctdb/common/ctdb_io.c11
-rw-r--r--source4/cluster/ctdb/common/ctdb_ltdb.c4
-rw-r--r--source4/cluster/ctdb/common/ctdb_util.c2
-rw-r--r--source4/cluster/ctdb/ctdb_cluster.c14
-rw-r--r--source4/cluster/ctdb/opendb_ctdb.c19
-rw-r--r--source4/cluster/local.c4
-rw-r--r--source4/configure.ac65
-rw-r--r--source4/dsdb/common/flags.h5
-rw-r--r--source4/dsdb/common/sidmap.c35
-rw-r--r--source4/dsdb/config.mk2
-rw-r--r--source4/dsdb/repl/drepl_service.c7
-rw-r--r--source4/dsdb/samdb/cracknames.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/entryUUID.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/extended_dn.c46
-rw-r--r--source4/dsdb/samdb/ldb_modules/kludge_acl.c4
-rw-r--r--source4/dsdb/samdb/ldb_modules/local_password.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition.c9
-rw-r--r--source4/dsdb/samdb/ldb_modules/password_hash.c25
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/schema.c6
-rw-r--r--source4/dsdb/samdb/ldb_modules/update_keytab.c15
-rw-r--r--source4/dsdb/samdb/samdb.c49
-rw-r--r--source4/dsdb/schema/schema_constructed.c4
-rw-r--r--source4/dsdb/schema/schema_init.c130
-rw-r--r--source4/dynconfig.c7
-rw-r--r--source4/dynconfig.h3
-rw-r--r--source4/dynconfig.mk5
-rw-r--r--source4/headermap.txt6
-rw-r--r--source4/heimdal/lib/asn1/lex.c33
-rw-r--r--source4/heimdal/lib/com_err/lex.c33
-rw-r--r--source4/heimdal_build/config.m473
-rw-r--r--source4/heimdal_build/config.mk44
-rw-r--r--source4/include/includes.h86
-rwxr-xr-x[-rw-r--r--]source4/install-sh0
-rw-r--r--source4/kdc/hdb-ldb.c3
-rw-r--r--source4/kdc/kdc.c19
-rw-r--r--source4/kdc/kpasswdd.c72
-rw-r--r--source4/ldap_server/ldap_backend.c9
-rw-r--r--source4/ldap_server/ldap_server.c22
-rw-r--r--source4/lib/appweb/ejs/ejsLib.c2
-rw-r--r--source4/lib/basic.mk2
-rw-r--r--source4/lib/charset/charcnv.c39
-rw-r--r--source4/lib/charset/charset.h7
-rw-r--r--source4/lib/charset/iconv.c5
-rw-r--r--source4/lib/charset/util_unistr.c12
-rw-r--r--source4/lib/cmdline/credentials.c9
-rw-r--r--source4/lib/cmdline/popt_common.c43
-rw-r--r--source4/lib/cmdline/popt_credentials.c9
-rw-r--r--source4/lib/crypto/hmacmd5test.c6
-rw-r--r--source4/lib/crypto/hmacsha1test.c6
-rw-r--r--source4/lib/crypto/md4test.c6
-rw-r--r--source4/lib/crypto/md5test.c6
-rw-r--r--source4/lib/crypto/sha1test.c4
-rw-r--r--source4/lib/db_wrap.c13
-rw-r--r--source4/lib/db_wrap.h1
-rw-r--r--source4/lib/dbwrap/dbwrap.c5
-rw-r--r--source4/lib/dbwrap/dbwrap_tdb.c3
-rw-r--r--source4/lib/events/events.c9
-rw-r--r--source4/lib/events/events_epoll.c2
-rw-r--r--source4/lib/events/events_signal.c4
-rw-r--r--source4/lib/gencache/gencache.c51
-rw-r--r--source4/lib/ldb-samba/README (renamed from source4/lib/ldb/samba/README)0
-rw-r--r--source4/lib/ldb-samba/config.mk (renamed from source4/lib/ldb/samba/config.mk)0
-rw-r--r--source4/lib/ldb-samba/ldif_handlers.c (renamed from source4/lib/ldb/samba/ldif_handlers.c)18
-rw-r--r--source4/lib/ldb/Makefile.in5
-rw-r--r--source4/lib/ldb/common/attrib_handlers.c29
-rw-r--r--source4/lib/ldb/common/ldb.c1
-rw-r--r--source4/lib/ldb/common/ldb_attributes.c111
-rw-r--r--source4/lib/ldb/common/ldb_dn.c20
-rw-r--r--source4/lib/ldb/common/ldb_modules.c24
-rw-r--r--source4/lib/ldb/config.mk110
-rw-r--r--source4/lib/ldb/configure.ac9
-rw-r--r--source4/lib/ldb/include/ldb.h25
-rw-r--r--source4/lib/ldb/include/ldb_private.h2
-rw-r--r--source4/lib/ldb/ldb.pc.in3
-rw-r--r--source4/lib/ldb/ldb_ildap/config.mk14
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c2
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_cache.c83
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c76
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c6
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c42
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.h11
-rw-r--r--source4/lib/ldb/modules/paged_searches.c13
-rwxr-xr-xsource4/lib/ldb/setup.py8
-rw-r--r--source4/lib/ldb/swig/ldb.i12
-rw-r--r--source4/lib/ldb/tests/schema-tests/schema.ldif12
-rw-r--r--source4/lib/ldb/tests/test-tdb-features.sh10
-rw-r--r--source4/lib/ldb/tools/ad2oLschema.c5
-rw-r--r--source4/lib/ldb/tools/cmdline.c2
-rw-r--r--source4/lib/ldb/tools/config.mk84
-rw-r--r--source4/lib/messaging/irpc.h7
-rw-r--r--source4/lib/messaging/messaging.c20
-rw-r--r--source4/lib/policy/lex.c4
-rw-r--r--source4/lib/policy/lex.l4
-rw-r--r--source4/lib/policy/parse_adm.c34
-rw-r--r--source4/lib/policy/parse_adm.h8
-rw-r--r--source4/lib/policy/parse_adm.y6
-rw-r--r--source4/lib/registry/dir.c116
-rw-r--r--source4/lib/registry/hive.c77
-rw-r--r--source4/lib/registry/hive.h168
-rw-r--r--source4/lib/registry/interface.c154
-rw-r--r--source4/lib/registry/ldb.c163
-rw-r--r--source4/lib/registry/local.c196
-rw-r--r--source4/lib/registry/patchfile.c231
-rw-r--r--source4/lib/registry/patchfile.h47
-rw-r--r--source4/lib/registry/patchfile_dotreg.c79
-rw-r--r--source4/lib/registry/patchfile_preg.c102
-rw-r--r--source4/lib/registry/regf.c722
-rw-r--r--source4/lib/registry/registry.h292
-rw-r--r--source4/lib/registry/rpc.c175
-rw-r--r--source4/lib/registry/samba.c49
-rw-r--r--source4/lib/registry/tests/hive.c27
-rw-r--r--source4/lib/registry/tests/registry.c96
-rw-r--r--source4/lib/registry/tools/common.c1
-rw-r--r--source4/lib/registry/tools/regshell.c6
-rw-r--r--source4/lib/registry/util.c133
-rw-r--r--source4/lib/registry/wine.c10
-rw-r--r--source4/lib/replace/README6
-rw-r--r--source4/lib/replace/configure.ac2
-rw-r--r--source4/lib/replace/dlfcn.m42
-rw-r--r--source4/lib/replace/getaddrinfo.c502
-rw-r--r--source4/lib/replace/getaddrinfo.h158
-rw-r--r--source4/lib/replace/inet_ntop.c191
-rw-r--r--source4/lib/replace/inet_ntop.m41
-rw-r--r--source4/lib/replace/inet_pton.c213
-rw-r--r--source4/lib/replace/inet_pton.m41
-rw-r--r--source4/lib/replace/libreplace.m465
-rw-r--r--source4/lib/replace/replace.h98
-rw-r--r--source4/lib/replace/system/network.h16
-rw-r--r--source4/lib/samba3/config.mk1
-rw-r--r--source4/lib/smbreadline/smbreadline.c1
-rw-r--r--source4/lib/socket/access.c96
-rw-r--r--source4/lib/socket/config.m45
-rw-r--r--source4/lib/socket/config.mk19
-rw-r--r--source4/lib/socket/connect.c5
-rw-r--r--source4/lib/socket/connect_multi.c6
-rw-r--r--source4/lib/socket/interface.c26
-rw-r--r--source4/lib/socket/netif.h2
-rw-r--r--source4/lib/socket/socket.c15
-rw-r--r--source4/lib/socket/socket.h3
-rw-r--r--source4/lib/socket/socket_ip.c981
-rw-r--r--source4/lib/socket/socket_ipv4.c539
-rw-r--r--source4/lib/socket/socket_ipv6.c527
-rw-r--r--source4/lib/socket/socket_unix.c6
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.c2
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.h2
-rw-r--r--source4/lib/stream/packet.c24
-rw-r--r--source4/lib/talloc/config.mk2
-rw-r--r--source4/lib/talloc/configure.ac2
-rw-r--r--source4/lib/talloc/talloc.c239
-rw-r--r--source4/lib/talloc/talloc.h24
-rw-r--r--source4/lib/talloc/talloc_guide.txt19
-rw-r--r--source4/lib/talloc/testsuite.c8
-rw-r--r--source4/lib/tdb/swig/Tdb.py6
-rw-r--r--source4/lib/tdb/swig/tdb.i45
-rw-r--r--source4/lib/tdb/tools/tdbtorture.c2
-rw-r--r--source4/lib/tls/tls.c94
-rw-r--r--source4/lib/tls/tlscert.c2
-rw-r--r--source4/lib/util/attr.h92
-rw-r--r--source4/lib/util/config.mk3
-rw-r--r--source4/lib/util/data_blob.c10
-rw-r--r--source4/lib/util/data_blob.h1
-rw-r--r--source4/lib/util/dprintf.c2
-rw-r--r--source4/lib/util/fault.c4
-rw-r--r--source4/lib/util/fault.m47
-rw-r--r--source4/lib/util/ms_fnmatch.c5
-rw-r--r--source4/lib/util/tests/file.c4
-rw-r--r--source4/lib/util/tests/str.c121
-rw-r--r--source4/lib/util/tests/strlist.c2
-rw-r--r--source4/lib/util/time.c10
-rw-r--r--source4/lib/util/time.h4
-rw-r--r--source4/lib/util/util.c13
-rw-r--r--source4/lib/util/util.h40
-rw-r--r--source4/lib/util/util_pw.c45
-rw-r--r--source4/lib/util/util_str.c82
-rw-r--r--source4/lib/util/util_strlist.c28
-rw-r--r--source4/lib/util/util_tdb.c5
-rw-r--r--source4/lib/util/xfile.c2
-rw-r--r--source4/libcli/auth/credentials.c12
-rw-r--r--source4/libcli/auth/session.c10
-rw-r--r--source4/libcli/auth/smbencrypt.c56
-rw-r--r--source4/libcli/cldap/cldap.c24
-rw-r--r--source4/libcli/cliconnect.c35
-rw-r--r--source4/libcli/clideltree.c10
-rw-r--r--source4/libcli/clifile.c9
-rw-r--r--source4/libcli/clilist.c38
-rw-r--r--source4/libcli/climessage.c19
-rw-r--r--source4/libcli/clireadwrite.c9
-rw-r--r--source4/libcli/clitrans2.c1
-rw-r--r--source4/libcli/composite/composite.c14
-rw-r--r--source4/libcli/config.mk16
-rw-r--r--source4/libcli/dgram/browse.c3
-rw-r--r--source4/libcli/dgram/mailslot.c3
-rw-r--r--source4/libcli/dgram/netlogon.c3
-rw-r--r--source4/libcli/dgram/ntlogon.c3
-rw-r--r--source4/libcli/finddcs.c6
-rw-r--r--source4/libcli/ldap/ldap.c38
-rw-r--r--source4/libcli/ldap/ldap.h1
-rw-r--r--source4/libcli/ldap/ldap_bind.c2
-rw-r--r--source4/libcli/ldap/ldap_client.c6
-rw-r--r--source4/libcli/ldap/ldap_controls.c530
-rw-r--r--source4/libcli/ldap/ldap_ildap.c6
-rw-r--r--source4/libcli/ldap/ldap_msg.c18
-rw-r--r--source4/libcli/libcli.h2
-rw-r--r--source4/libcli/nbt/namequery.c9
-rw-r--r--source4/libcli/nbt/namerefresh.c10
-rw-r--r--source4/libcli/nbt/nameregister.c21
-rw-r--r--source4/libcli/nbt/namerelease.c5
-rw-r--r--source4/libcli/nbt/nbtname.c6
-rw-r--r--source4/libcli/nbt/nbtsocket.c14
-rw-r--r--source4/libcli/raw/clierror.c (renamed from source4/libcli/util/clierror.c)2
-rw-r--r--source4/libcli/raw/clioplock.c6
-rw-r--r--source4/libcli/raw/clisession.c2
-rw-r--r--source4/libcli/raw/clisocket.c5
-rw-r--r--source4/libcli/raw/clitransport.c27
-rw-r--r--source4/libcli/raw/clitree.c7
-rw-r--r--source4/libcli/raw/interfaces.h1
-rw-r--r--source4/libcli/raw/raweas.c7
-rw-r--r--source4/libcli/raw/rawfile.c4
-rw-r--r--source4/libcli/raw/rawfileinfo.c2
-rw-r--r--source4/libcli/raw/rawlpq.c1
-rw-r--r--source4/libcli/raw/rawnegotiate.c11
-rw-r--r--source4/libcli/raw/rawreadwrite.c10
-rw-r--r--source4/libcli/raw/rawrequest.c40
-rw-r--r--source4/libcli/raw/rawsetfileinfo.c40
-rw-r--r--source4/libcli/raw/rawshadow.c2
-rw-r--r--source4/libcli/raw/rawtrans.c12
-rw-r--r--source4/libcli/raw/smb_signing.c93
-rw-r--r--source4/libcli/resolve/bcast.c2
-rw-r--r--source4/libcli/resolve/nbtlist.c9
-rw-r--r--source4/libcli/resolve/resolve.c6
-rw-r--r--source4/libcli/resolve/wins.c12
-rw-r--r--source4/libcli/security/dom_sid.c15
-rw-r--r--source4/libcli/security/privilege.c11
-rw-r--r--source4/libcli/security/sddl.c48
-rw-r--r--source4/libcli/security/security_descriptor.c78
-rw-r--r--source4/libcli/security/security_token.c32
-rw-r--r--source4/libcli/smb2/cancel.c2
-rw-r--r--source4/libcli/smb2/close.c4
-rw-r--r--source4/libcli/smb2/connect.c8
-rw-r--r--source4/libcli/smb2/create.c10
-rw-r--r--source4/libcli/smb2/find.c4
-rw-r--r--source4/libcli/smb2/flush.c4
-rw-r--r--source4/libcli/smb2/getinfo.c4
-rw-r--r--source4/libcli/smb2/ioctl.c4
-rw-r--r--source4/libcli/smb2/keepalive.c4
-rw-r--r--source4/libcli/smb2/lock.c4
-rw-r--r--source4/libcli/smb2/logoff.c4
-rw-r--r--source4/libcli/smb2/negprot.c4
-rw-r--r--source4/libcli/smb2/notify.c4
-rw-r--r--source4/libcli/smb2/read.c4
-rw-r--r--source4/libcli/smb2/request.c27
-rw-r--r--source4/libcli/smb2/session.c6
-rw-r--r--source4/libcli/smb2/setinfo.c4
-rw-r--r--source4/libcli/smb2/tcon.c6
-rw-r--r--source4/libcli/smb2/tdis.c4
-rw-r--r--source4/libcli/smb2/transport.c2
-rw-r--r--source4/libcli/smb2/write.c4
-rw-r--r--source4/libcli/smb_composite/appendacl.c2
-rw-r--r--source4/libcli/smb_composite/connect.c20
-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/loadfile.c4
-rw-r--r--source4/libcli/smb_composite/savefile.c2
-rw-r--r--source4/libcli/smb_composite/sesssetup.c21
-rw-r--r--source4/libcli/swig/libcli_nbt.i23
-rw-r--r--source4/libcli/swig/libcli_smb.i18
-rw-r--r--source4/libcli/util/asn1.c303
-rw-r--r--source4/libcli/util/clilsa.c3
-rw-r--r--source4/libcli/util/doserr.c3
-rw-r--r--source4/libcli/util/doserr.h125
-rw-r--r--source4/libcli/util/error.h29
-rw-r--r--source4/libcli/util/errormap.c5
-rw-r--r--source4/libcli/util/nt_status.h122
-rw-r--r--source4/libcli/util/nterr.c3
-rw-r--r--source4/libcli/util/ntstatus.h (renamed from source4/libcli/util/nterr.h)93
-rw-r--r--source4/libcli/util/werror.h193
-rw-r--r--source4/libcli/wrepl/winsrepl.c18
-rw-r--r--source4/libcli/wrepl/winsrepl.h2
-rw-r--r--source4/libnet/config.mk1
-rw-r--r--source4/libnet/groupman.c138
-rw-r--r--source4/libnet/groupman.h35
-rw-r--r--source4/libnet/libnet.c3
-rw-r--r--source4/libnet/libnet.h3
-rw-r--r--source4/libnet/libnet_become_dc.c7
-rw-r--r--source4/libnet/libnet_group.c2
-rw-r--r--source4/libnet/libnet_join.c12
-rw-r--r--source4/libnet/libnet_lookup.c7
-rw-r--r--source4/libnet/libnet_samdump.c7
-rw-r--r--source4/libnet/libnet_samdump_keytab.c3
-rw-r--r--source4/libnet/libnet_samsync_ldb.c39
-rw-r--r--source4/libnet/libnet_unbecome_dc.c5
-rw-r--r--source4/libnet/libnet_user.c17
-rw-r--r--source4/libnet/libnet_user.h6
-rw-r--r--source4/libnet/libnet_vampire.c7
-rw-r--r--source4/libnet/prereq_domain.c24
-rw-r--r--source4/libnet/userman.c579
-rw-r--r--source4/libnet/userman.h2
-rw-r--r--source4/librpc/idl/dcerpc.idl40
-rw-r--r--source4/librpc/idl/dfs.idl2
-rw-r--r--source4/librpc/idl/dssetup.idl2
-rw-r--r--source4/librpc/idl/epmapper.idl2
-rw-r--r--source4/librpc/idl/notify.idl2
-rw-r--r--source4/librpc/idl/orpc.idl2
-rw-r--r--source4/librpc/idl/security.idl12
-rw-r--r--source4/librpc/ndr/libndr.h7
-rw-r--r--source4/librpc/ndr/ndr.c21
-rw-r--r--source4/librpc/ndr/ndr_compression.c1
-rw-r--r--source4/librpc/ndr/ndr_drsuapi.c8
-rw-r--r--source4/librpc/ndr/ndr_string.c4
-rw-r--r--source4/librpc/ndr/ndr_table.c4
-rw-r--r--source4/librpc/ndr/uuid.c15
-rw-r--r--source4/librpc/rpc/dcerpc.c24
-rw-r--r--source4/librpc/rpc/dcerpc_auth.c6
-rw-r--r--source4/librpc/rpc/dcerpc_connect.c12
-rw-r--r--source4/librpc/rpc/dcerpc_smb.c29
-rw-r--r--source4/librpc/rpc/dcerpc_smb2.c14
-rw-r--r--source4/librpc/rpc/dcerpc_sock.c22
-rw-r--r--source4/librpc/rpc/dcerpc_util.c24
-rw-r--r--source4/librpc/tests/binding_string.c37
-rw-r--r--source4/librpc/tools/ndrdump.c14
-rw-r--r--source4/main.mk21
-rw-r--r--source4/nbt_server/config.mk14
-rw-r--r--source4/nbt_server/dgram/netlogon.c20
-rw-r--r--source4/nbt_server/dgram/ntlogon.c8
-rw-r--r--source4/nbt_server/dgram/request.c11
-rw-r--r--source4/nbt_server/interfaces.c24
-rw-r--r--source4/nbt_server/irpc.c4
-rw-r--r--source4/nbt_server/packet.c19
-rw-r--r--source4/nbt_server/query.c3
-rw-r--r--source4/nbt_server/register.c38
-rw-r--r--source4/nbt_server/wins/wins_hook.c8
-rw-r--r--source4/nbt_server/wins/wins_ldb.c3
-rw-r--r--source4/nbt_server/wins/winsclient.c7
-rw-r--r--source4/nbt_server/wins/winsdb.c43
-rw-r--r--source4/nbt_server/wins/winsserver.c49
-rw-r--r--source4/nbt_server/wins/winswack.c18
-rw-r--r--source4/nsswitch/nsstest.c12
-rw-r--r--source4/nsswitch/wb_common.c242
-rw-r--r--source4/nsswitch/wbinfo.c243
-rw-r--r--source4/nsswitch/winbind_client.h29
-rw-r--r--source4/nsswitch/winbind_nss.h10
-rw-r--r--source4/nsswitch/winbind_nss_config.h47
-rw-r--r--source4/nsswitch/winbind_nss_irix.h4
-rw-r--r--source4/nsswitch/winbind_nss_linux.c277
-rw-r--r--source4/nsswitch/winbind_nss_solaris.h30
-rw-r--r--source4/nsswitch/winbind_struct_protocol.h (renamed from source4/nsswitch/winbindd_nss.h)160
-rw-r--r--source4/ntptr/ntptr_base.c3
-rw-r--r--source4/ntptr/simple_ldb/ntptr_simple_ldb.c9
-rw-r--r--source4/ntvfs/cifs/vfs_cifs.c33
-rw-r--r--source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c8
-rw-r--r--source4/ntvfs/common/brlock_tdb.c26
-rw-r--r--source4/ntvfs/common/notify.c4
-rw-r--r--source4/ntvfs/common/opendb.c9
-rw-r--r--source4/ntvfs/common/opendb_tdb.c19
-rw-r--r--source4/ntvfs/ipc/vfs_ipc.c4
-rw-r--r--source4/ntvfs/nbench/vfs_nbench.c4
-rw-r--r--source4/ntvfs/ntvfs_base.c21
-rw-r--r--source4/ntvfs/ntvfs_generic.c10
-rw-r--r--source4/ntvfs/ntvfs_interface.c8
-rw-r--r--source4/ntvfs/ntvfs_util.c2
-rw-r--r--source4/ntvfs/posix/pvfs_acl.c22
-rw-r--r--source4/ntvfs/posix/pvfs_dirlist.c38
-rw-r--r--source4/ntvfs/posix/pvfs_lock.c4
-rw-r--r--source4/ntvfs/posix/pvfs_notify.c14
-rw-r--r--source4/ntvfs/posix/pvfs_open.c60
-rw-r--r--source4/ntvfs/posix/pvfs_resolve.c28
-rw-r--r--source4/ntvfs/posix/pvfs_search.c18
-rw-r--r--source4/ntvfs/posix/pvfs_setfileinfo.c2
-rw-r--r--source4/ntvfs/posix/pvfs_shortname.c69
-rw-r--r--source4/ntvfs/posix/pvfs_streams.c6
-rw-r--r--source4/ntvfs/posix/pvfs_util.c8
-rw-r--r--source4/ntvfs/posix/pvfs_xattr.c4
-rw-r--r--source4/ntvfs/posix/vfs_posix.c4
-rw-r--r--source4/ntvfs/posix/vfs_posix.h4
-rw-r--r--source4/ntvfs/print/vfs_print.c3
-rw-r--r--source4/ntvfs/simple/vfs_simple.c8
-rw-r--r--source4/ntvfs/sysdep/inotify.c17
-rw-r--r--source4/ntvfs/sysdep/sys_notify.c7
-rw-r--r--source4/ntvfs/unixuid/vfs_unixuid.c4
-rw-r--r--source4/param/config.mk1
-rw-r--r--source4/param/generic.c62
-rw-r--r--source4/param/loadparm.c2126
-rw-r--r--source4/param/loadparm.h9
-rw-r--r--source4/param/param.h21
-rw-r--r--source4/param/params.c62
-rw-r--r--source4/param/secrets.c18
-rw-r--r--source4/param/secrets.h15
-rw-r--r--source4/param/share.c16
-rw-r--r--source4/param/share.h22
-rw-r--r--source4/param/share_classic.c157
-rw-r--r--source4/param/share_ldb.c54
-rw-r--r--source4/param/util.c95
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm23
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Header.pm4
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm2
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm2
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm5
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm2
-rwxr-xr-xsource4/pidl/tests/ndr.pl19
-rwxr-xr-xsource4/pidl/tests/ndr_represent.pl4
-rw-r--r--source4/rpc_server/common/server_info.c29
-rw-r--r--source4/rpc_server/config.mk10
-rw-r--r--source4/rpc_server/dcerpc_server.c120
-rw-r--r--source4/rpc_server/dcesrv_auth.c75
-rw-r--r--source4/rpc_server/drsuapi/dcesrv_drsuapi.c8
-rw-r--r--source4/rpc_server/lsa/dcesrv_lsa.c873
-rw-r--r--source4/rpc_server/lsa/lsa.h69
-rw-r--r--source4/rpc_server/lsa/lsa_init.c248
-rw-r--r--source4/rpc_server/lsa/lsa_lookup.c928
-rw-r--r--source4/rpc_server/netlogon/dcerpc_netlogon.c30
-rw-r--r--source4/rpc_server/remote/dcesrv_remote.c35
-rw-r--r--source4/rpc_server/samr/dcesrv_samr.c34
-rw-r--r--source4/rpc_server/samr/samr_password.c10
-rw-r--r--source4/rpc_server/service_rpc.c (renamed from source4/rpc_server/dcerpc_sock.c)126
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c90
-rw-r--r--source4/rpc_server/srvsvc/dcesrv_srvsvc.c5
-rw-r--r--source4/rpc_server/winreg/rpc_winreg.c358
-rw-r--r--source4/samba4-knownfail15
-rw-r--r--source4/samba4-skip29
-rwxr-xr-xsource4/script/gdb_run1
-rwxr-xr-x[-rw-r--r--]source4/script/installbin.sh0
-rwxr-xr-xsource4/script/installjsonrpc.sh32
-rwxr-xr-x[-rw-r--r--]source4/script/installman.sh0
-rwxr-xr-xsource4/script/installmisc.sh7
-rwxr-xr-x[-rw-r--r--]source4/script/installmodules.sh0
-rwxr-xr-x[-rw-r--r--]source4/script/installscripts.sh0
-rwxr-xr-xsource4/script/installswat.sh37
-rwxr-xr-xsource4/script/installwebapps.sh51
-rwxr-xr-xsource4/script/lex_compile.sh8
-rwxr-xr-xsource4/script/mkproto.pl37
-rwxr-xr-xsource4/script/mkversion.sh2
-rwxr-xr-x[-rw-r--r--]source4/script/revert.sh0
-rwxr-xr-x[-rw-r--r--]source4/script/uninstallbin.sh0
-rwxr-xr-x[-rw-r--r--]source4/script/uninstallman.sh0
-rwxr-xr-x[-rw-r--r--]source4/script/uninstallmodules.sh0
-rwxr-xr-x[-rw-r--r--]source4/script/uninstallscripts.sh0
-rw-r--r--source4/scripting/ejs/ejsnet/net_ctx.c16
-rw-r--r--source4/scripting/ejs/ejsnet/net_user.c14
-rw-r--r--source4/scripting/ejs/ejsrpc.c18
-rw-r--r--source4/scripting/ejs/ejsrpc.h4
-rw-r--r--source4/scripting/ejs/literal.c24
-rw-r--r--source4/scripting/ejs/mprutil.c2
-rw-r--r--source4/scripting/ejs/smbcalls.c51
-rw-r--r--source4/scripting/ejs/smbcalls.h1
-rw-r--r--source4/scripting/ejs/smbcalls_auth.c26
-rw-r--r--source4/scripting/ejs/smbcalls_cli.c25
-rw-r--r--source4/scripting/ejs/smbcalls_config.c49
-rw-r--r--source4/scripting/ejs/smbcalls_creds.c18
-rw-r--r--source4/scripting/ejs/smbcalls_data.c12
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c6
-rw-r--r--source4/scripting/ejs/smbcalls_param.c18
-rw-r--r--source4/scripting/ejs/smbcalls_reg.c2
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c9
-rw-r--r--source4/scripting/ejs/smbcalls_samba3.c2
-rw-r--r--source4/scripting/ejs/smbcalls_string.c14
-rw-r--r--source4/scripting/ejs/smbcalls_sys.c4
-rw-r--r--source4/scripting/ejs/smbscript.c8
-rw-r--r--source4/scripting/libjs/provision.js53
-rw-r--r--source4/scripting/swig/config.mk2
-rw-r--r--source4/selftest/README26
-rw-r--r--source4/selftest/Subunit.pm22
-rw-r--r--source4/selftest/TODO1
-rw-r--r--source4/selftest/env/Samba3.pm193
-rw-r--r--source4/selftest/env/Samba4.pm31
-rw-r--r--source4/selftest/output/buildfarm.pm25
-rw-r--r--source4/selftest/output/html.pm66
-rw-r--r--source4/selftest/output/plain.pm34
-rw-r--r--source4/selftest/output/testresults.css5
-rwxr-xr-xsource4/selftest/selftest.pl189
-rwxr-xr-xsource4/selftest/test_binding_string.sh18
-rwxr-xr-xsource4/selftest/test_cifs.sh6
-rwxr-xr-xsource4/selftest/test_echo.sh6
-rwxr-xr-xsource4/selftest/test_ejs.sh9
-rwxr-xr-xsource4/selftest/test_functions.sh3
-rwxr-xr-xsource4/selftest/test_ldap.sh12
-rwxr-xr-xsource4/selftest/test_local.sh8
-rwxr-xr-xsource4/selftest/test_member.sh9
-rwxr-xr-xsource4/selftest/test_nbt.sh7
-rwxr-xr-xsource4/selftest/test_net.sh20
-rwxr-xr-xsource4/selftest/test_nss.sh4
-rwxr-xr-xsource4/selftest/test_pidl.sh4
-rwxr-xr-xsource4/selftest/test_posix.sh8
-rwxr-xr-xsource4/selftest/test_quick.sh21
-rwxr-xr-xsource4/selftest/test_rpc.sh36
-rwxr-xr-xsource4/selftest/test_rpc_quick.sh24
-rwxr-xr-xsource4/selftest/test_s3upgrade.sh16
-rwxr-xr-xsource4/selftest/test_session_key.sh26
-rwxr-xr-xsource4/selftest/test_simple.sh2
-rwxr-xr-xsource4/selftest/test_winbind.sh28
-rwxr-xr-xsource4/selftest/tests_all.sh37
-rwxr-xr-xsource4/selftest/tests_quick.sh42
-rw-r--r--source4/setup/named.conf7
-rwxr-xr-xsource4/setup/provision32
-rw-r--r--source4/setup/provision.smb.conf.dc (renamed from source4/setup/provision.smb.conf)6
-rw-r--r--source4/setup/provision.smb.conf.member5
-rw-r--r--source4/setup/provision.smb.conf.standalone5
-rw-r--r--source4/setup/provision_configuration.ldif23
-rw-r--r--source4/setup/provision_init.ldif11
-rw-r--r--source4/setup/provision_partitions.ldif1
-rw-r--r--source4/setup/provision_self_join.ldif41
-rw-r--r--source4/setup/provision_users.ldif16
-rw-r--r--source4/setup/secrets.ldif44
-rw-r--r--source4/setup/secrets_dc.ldif44
-rw-r--r--source4/setup/slapd.conf6
-rw-r--r--source4/smb_server/smb/negprot.c65
-rw-r--r--source4/smb_server/smb/receive.c7
-rw-r--r--source4/smb_server/smb/reply.c6
-rw-r--r--source4/smb_server/smb/request.c16
-rw-r--r--source4/smb_server/smb/search.c8
-rw-r--r--source4/smb_server/smb/service.c4
-rw-r--r--source4/smb_server/smb/sesssetup.c9
-rw-r--r--source4/smb_server/smb/signing.c43
-rw-r--r--source4/smb_server/smb/trans2.c6
-rw-r--r--source4/smb_server/smb2/fileinfo.c8
-rw-r--r--source4/smb_server/smb2/fileio.c32
-rw-r--r--source4/smb_server/smb2/find.c10
-rw-r--r--source4/smb_server/smb2/keepalive.c2
-rw-r--r--source4/smb_server/smb2/negprot.c7
-rw-r--r--source4/smb_server/smb2/receive.c12
-rw-r--r--source4/smb_server/smb2/sesssetup.c8
-rw-r--r--source4/smb_server/smb2/tcon.c13
-rw-r--r--source4/smb_server/smb_server.c14
-rw-r--r--source4/smb_server/smb_server.h6
-rw-r--r--source4/smbd/pidfile.c8
-rw-r--r--source4/smbd/process_model.c3
-rw-r--r--source4/smbd/process_model.h2
-rw-r--r--source4/smbd/process_single.c2
-rw-r--r--source4/smbd/process_standard.c2
-rw-r--r--source4/smbd/server.c37
-rw-r--r--source4/smbd/service_stream.c20
-rw-r--r--source4/smbd/service_stream.h2
-rw-r--r--source4/smbd/service_task.c5
-rw-r--r--source4/smbd/service_task.h2
-rw-r--r--source4/static_deps.mk1
-rw-r--r--source4/torture/auth/ntlmssp.c4
-rw-r--r--source4/torture/basic/aliases.c4
-rw-r--r--source4/torture/basic/attr.c4
-rw-r--r--source4/torture/basic/base.c275
-rw-r--r--source4/torture/basic/charset.c160
-rw-r--r--source4/torture/basic/delaywrite.c90
-rw-r--r--source4/torture/basic/delete.c172
-rw-r--r--source4/torture/basic/denytest.c67
-rw-r--r--source4/torture/basic/dir.c28
-rw-r--r--source4/torture/basic/disconnect.c26
-rw-r--r--source4/torture/basic/locking.c119
-rw-r--r--source4/torture/basic/mangle_test.c55
-rw-r--r--source4/torture/basic/misc.c81
-rw-r--r--source4/torture/basic/properties.c8
-rw-r--r--source4/torture/basic/rename.c4
-rw-r--r--source4/torture/basic/scanner.c58
-rw-r--r--source4/torture/basic/secleak.c19
-rw-r--r--source4/torture/basic/unlink.c4
-rw-r--r--source4/torture/basic/utable.c2
-rw-r--r--source4/torture/config.mk8
-rw-r--r--source4/torture/gentest.c242
-rw-r--r--source4/torture/ldap/basic.c54
-rw-r--r--source4/torture/ldap/cldap.c14
-rw-r--r--source4/torture/ldap/cldapbench.c2
-rw-r--r--source4/torture/ldap/schema.c56
-rw-r--r--source4/torture/ldap/uptodatevector.c10
-rw-r--r--source4/torture/libnet/domain.c25
-rw-r--r--source4/torture/libnet/groupinfo.c182
-rw-r--r--source4/torture/libnet/groupman.c93
-rw-r--r--source4/torture/libnet/grouptest.h20
-rw-r--r--source4/torture/libnet/libnet.c1
-rw-r--r--source4/torture/libnet/libnet_BecomeDC.c46
-rw-r--r--source4/torture/libnet/libnet_domain.c75
-rw-r--r--source4/torture/libnet/libnet_group.c57
-rw-r--r--source4/torture/libnet/libnet_lookup.c41
-rw-r--r--source4/torture/libnet/libnet_rpc.c59
-rw-r--r--source4/torture/libnet/libnet_share.c42
-rw-r--r--source4/torture/libnet/libnet_user.c143
-rw-r--r--source4/torture/libnet/userinfo.c231
-rw-r--r--source4/torture/libnet/userman.c302
-rw-r--r--source4/torture/libnet/utils.c313
-rw-r--r--source4/torture/libnet/utils.h42
-rw-r--r--source4/torture/local/config.mk1
-rw-r--r--source4/torture/local/dbspeed.c26
-rw-r--r--source4/torture/local/event.c6
-rw-r--r--source4/torture/local/iconv.c13
-rw-r--r--source4/torture/local/irpc.c25
-rw-r--r--source4/torture/local/local.c1
-rw-r--r--source4/torture/local/messaging.c14
-rw-r--r--source4/torture/local/sddl.c2
-rw-r--r--source4/torture/local/share.c18
-rw-r--r--source4/torture/locktest.c52
-rw-r--r--source4/torture/locktest2.c50
-rw-r--r--source4/torture/masktest.c26
-rw-r--r--source4/torture/nbench/nbench.c18
-rw-r--r--source4/torture/nbench/nbio.c90
-rw-r--r--source4/torture/nbt/browse.c4
-rw-r--r--source4/torture/nbt/dgram.c23
-rw-r--r--source4/torture/nbt/nbt.c19
-rw-r--r--source4/torture/nbt/query.c9
-rw-r--r--source4/torture/nbt/register.c14
-rw-r--r--source4/torture/nbt/wins.c13
-rw-r--r--source4/torture/nbt/winsbench.c7
-rw-r--r--source4/torture/nbt/winsreplication.c39
-rw-r--r--source4/torture/ndr/lsa.c2
-rw-r--r--source4/torture/ndr/ndr.c2
-rw-r--r--source4/torture/ndr/winreg.c8
-rw-r--r--source4/torture/rap/rap.c38
-rw-r--r--source4/torture/raw/acls.c66
-rw-r--r--source4/torture/raw/chkpath.c28
-rw-r--r--source4/torture/raw/close.c2
-rw-r--r--source4/torture/raw/composite.c117
-rw-r--r--source4/torture/raw/context.c105
-rw-r--r--source4/torture/raw/eas.c55
-rw-r--r--source4/torture/raw/ioctl.c22
-rw-r--r--source4/torture/raw/lock.c107
-rw-r--r--source4/torture/raw/lockbench.c13
-rw-r--r--source4/torture/raw/mkdir.c15
-rw-r--r--source4/torture/raw/mux.c30
-rw-r--r--source4/torture/raw/notify.c170
-rw-r--r--source4/torture/raw/open.c229
-rw-r--r--source4/torture/raw/openbench.c15
-rw-r--r--source4/torture/raw/oplock.c67
-rwxr-xr-xsource4/torture/raw/pingpong.c34
-rw-r--r--source4/torture/raw/qfileinfo.c114
-rw-r--r--source4/torture/raw/qfsinfo.c22
-rw-r--r--source4/torture/raw/raw.c5
-rw-r--r--source4/torture/raw/read.c95
-rw-r--r--source4/torture/raw/rename.c12
-rw-r--r--source4/torture/raw/samba3hide.c82
-rw-r--r--source4/torture/raw/samba3misc.c143
-rw-r--r--source4/torture/raw/search.c204
-rw-r--r--source4/torture/raw/seek.c18
-rw-r--r--source4/torture/raw/setfileinfo.c43
-rw-r--r--source4/torture/raw/streams.c30
-rw-r--r--source4/torture/raw/unlink.c24
-rw-r--r--source4/torture/raw/write.c78
-rw-r--r--source4/torture/rpc/alter_context.c63
-rw-r--r--source4/torture/rpc/async_bind.c20
-rw-r--r--source4/torture/rpc/atsvc.c11
-rw-r--r--source4/torture/rpc/autoidl.c29
-rw-r--r--source4/torture/rpc/bench.c23
-rw-r--r--source4/torture/rpc/bind.c12
-rw-r--r--source4/torture/rpc/countcalls.c31
-rw-r--r--source4/torture/rpc/dfs.c130
-rw-r--r--source4/torture/rpc/drsuapi.c264
-rw-r--r--source4/torture/rpc/drsuapi_cracknames.c126
-rw-r--r--source4/torture/rpc/dssetup.c54
-rw-r--r--source4/torture/rpc/dssync.c95
-rw-r--r--source4/torture/rpc/echo.c28
-rw-r--r--source4/torture/rpc/epmapper.c12
-rw-r--r--source4/torture/rpc/eventlog.c15
-rw-r--r--source4/torture/rpc/initshutdown.c19
-rw-r--r--source4/torture/rpc/join.c12
-rw-r--r--source4/torture/rpc/lsa.c657
-rw-r--r--source4/torture/rpc/lsa_lookup.c107
-rw-r--r--source4/torture/rpc/mgmt.c63
-rw-r--r--source4/torture/rpc/netlogon.c1164
-rw-r--r--source4/torture/rpc/rpc.c210
-rw-r--r--source4/torture/rpc/rpc.h14
-rw-r--r--source4/torture/rpc/samba3rpc.c323
-rw-r--r--source4/torture/rpc/samlogon.c389
-rw-r--r--source4/torture/rpc/samr.c904
-rw-r--r--source4/torture/rpc/samr_accessmask.c658
-rw-r--r--source4/torture/rpc/samsync.c277
-rw-r--r--source4/torture/rpc/scanner.c32
-rw-r--r--source4/torture/rpc/schannel.c345
-rw-r--r--source4/torture/rpc/session_key.c192
-rw-r--r--source4/torture/rpc/spoolss.c1539
-rw-r--r--source4/torture/rpc/spoolss_notify.c296
-rw-r--r--source4/torture/rpc/srvsvc.c432
-rw-r--r--source4/torture/rpc/svcctl.c2
-rw-r--r--source4/torture/rpc/testjoin.c16
-rw-r--r--source4/torture/rpc/unixinfo.c6
-rw-r--r--source4/torture/rpc/winreg.c244
-rw-r--r--source4/torture/smb2/connect.c29
-rw-r--r--source4/torture/smb2/dir.c12
-rw-r--r--source4/torture/smb2/find.c26
-rw-r--r--source4/torture/smb2/getinfo.c28
-rw-r--r--source4/torture/smb2/lock.c18
-rw-r--r--source4/torture/smb2/maxwrite.c8
-rw-r--r--source4/torture/smb2/notify.c16
-rw-r--r--source4/torture/smb2/scan.c36
-rw-r--r--source4/torture/smb2/setinfo.c22
-rw-r--r--source4/torture/smb2/util.c20
-rw-r--r--source4/torture/smbtorture.c148
-rw-r--r--source4/torture/torture.c9
-rw-r--r--source4/torture/ui.c137
-rw-r--r--source4/torture/ui.h2
-rw-r--r--source4/torture/unix/unix_info2.c42
-rw-r--r--source4/torture/unix/whoami.c25
-rw-r--r--source4/torture/util.c19
-rw-r--r--source4/torture/util_smb.c78
-rw-r--r--source4/torture/winbind/config.mk15
-rw-r--r--source4/torture/winbind/struct_based.c1051
-rw-r--r--source4/torture/winbind/winbind.c35
-rw-r--r--source4/utils/getntacl.c2
-rw-r--r--source4/utils/net/net_join.c3
-rw-r--r--source4/utils/nmblookup.c58
-rw-r--r--source4/utils/ntlm_auth.c88
-rw-r--r--source4/utils/testparm.c74
-rw-r--r--source4/web_server/http.c174
-rw-r--r--source4/web_server/web_server.c9
-rw-r--r--source4/winbind/wb_cmd_getpwent.c1
-rw-r--r--source4/winbind/wb_cmd_getpwnam.c7
-rw-r--r--source4/winbind/wb_cmd_getpwuid.c7
-rw-r--r--source4/winbind/wb_cmd_list_users.c3
-rw-r--r--source4/winbind/wb_cmd_setpwent.c1
-rw-r--r--source4/winbind/wb_dom_info.c4
-rw-r--r--source4/winbind/wb_dom_info_trusted.c3
-rw-r--r--source4/winbind/wb_init_domain.c11
-rw-r--r--source4/winbind/wb_irpc.c2
-rw-r--r--source4/winbind/wb_pam_auth.c9
-rw-r--r--source4/winbind/wb_samba3_cmd.c17
-rw-r--r--source4/winbind/wb_samba3_protocol.c6
-rw-r--r--source4/winbind/wb_server.c13
-rw-r--r--source4/winbind/wb_server.h2
-rw-r--r--source4/winbind/wb_sid2domain.c3
-rw-r--r--source4/winbind/wb_utils.c7
-rw-r--r--source4/wrepl_server/wrepl_apply_records.c112
-rw-r--r--source4/wrepl_server/wrepl_in_call.c8
-rw-r--r--source4/wrepl_server/wrepl_in_connection.c5
-rw-r--r--source4/wrepl_server/wrepl_out_helpers.c24
-rw-r--r--source4/wrepl_server/wrepl_out_push.c6
-rw-r--r--source4/wrepl_server/wrepl_scavenging.c66
-rw-r--r--source4/wrepl_server/wrepl_server.c25
773 files changed, 22464 insertions, 18803 deletions
diff --git a/source4/VERSION b/source4/VERSION
index 7441b7421b..18daa5163d 100644
--- a/source4/VERSION
+++ b/source4/VERSION
@@ -57,7 +57,7 @@ SAMBA_VERSION_TP_RELEASE=
# e.g. SAMBA_VERSION_ALPHA_RELEASE=1 #
# -> "4.0.0alpha1" #
########################################################
-SAMBA_VERSION_ALPHA_RELEASE=1
+SAMBA_VERSION_ALPHA_RELEASE=2
########################################################
# For 'pre' releases the version will be #
@@ -89,7 +89,7 @@ SAMBA_VERSION_RC_RELEASE=
# e.g. SAMBA_VERSION_IS_SVN_SNAPSHOT=yes #
# -> "3.0.0-SVN-build-199" #
########################################################
-SAMBA_VERSION_IS_SVN_SNAPSHOT=no
+SAMBA_VERSION_IS_SVN_SNAPSHOT=yes
########################################################
# This is for specifying a release nickname #
diff --git a/source4/auth/auth.c b/source4/auth/auth.c
index 57e2c050c1..1dc55de61e 100644
--- a/source4/auth/auth.c
+++ b/source4/auth/auth.c
@@ -23,6 +23,7 @@
#include "auth/auth.h"
#include "lib/events/events.h"
#include "build.h"
+#include "param/param.h"
/***************************************************************************
Set a fixed challenge
@@ -41,7 +42,7 @@ NTSTATUS auth_context_set_challenge(struct auth_context *auth_ctx, const uint8_t
/***************************************************************************
Set a fixed challenge
***************************************************************************/
-BOOL auth_challenge_may_be_modified(struct auth_context *auth_ctx)
+bool auth_challenge_may_be_modified(struct auth_context *auth_ctx)
{
return auth_ctx->challenge.may_be_modified;
}
@@ -92,7 +93,7 @@ _PUBLIC_ NTSTATUS auth_get_challenge(struct auth_context *auth_ctx, const uint8_
NT_STATUS_HAVE_NO_MEMORY(auth_ctx->challenge.data.data);
auth_ctx->challenge.set_by = "random";
- auth_ctx->challenge.may_be_modified = True;
+ auth_ctx->challenge.may_be_modified = true;
}
DEBUG(10,("auth_get_challenge: challenge set by %s\n",
@@ -103,7 +104,7 @@ _PUBLIC_ NTSTATUS auth_get_challenge(struct auth_context *auth_ctx, const uint8_
}
struct auth_check_password_sync_state {
- BOOL finished;
+ bool finished;
NTSTATUS status;
struct auth_serversupplied_info *server_info;
};
@@ -114,7 +115,7 @@ static void auth_check_password_sync_callback(struct auth_check_password_request
struct auth_check_password_sync_state *s = talloc_get_type(private_data,
struct auth_check_password_sync_state);
- s->finished = True;
+ s->finished = true;
s->status = auth_check_password_recv(req, s, &s->server_info);
}
@@ -375,7 +376,7 @@ NTSTATUS auth_context_create_methods(TALLOC_CTX *mem_ctx, const char **methods,
ctx = talloc(mem_ctx, struct auth_context);
NT_STATUS_HAVE_NO_MEMORY(ctx);
ctx->challenge.set_by = NULL;
- ctx->challenge.may_be_modified = False;
+ ctx->challenge.may_be_modified = false;
ctx->challenge.data = data_blob(NULL, 0);
ctx->methods = NULL;
ctx->event_ctx = ev;
@@ -416,15 +417,15 @@ NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx,
struct auth_context **auth_ctx)
{
const char **auth_methods = NULL;
- switch (lp_server_role()) {
+ switch (lp_server_role(global_loadparm)) {
case ROLE_STANDALONE:
- auth_methods = lp_parm_string_list(-1, "auth methods", "standalone", NULL);
+ auth_methods = lp_parm_string_list(global_loadparm, NULL, "auth methods", "standalone", NULL);
break;
case ROLE_DOMAIN_MEMBER:
- auth_methods = lp_parm_string_list(-1, "auth methods", "member server", NULL);
+ auth_methods = lp_parm_string_list(global_loadparm, NULL, "auth methods", "member server", NULL);
break;
case ROLE_DOMAIN_CONTROLLER:
- auth_methods = lp_parm_string_list(-1, "auth methods", "domain controller", NULL);
+ auth_methods = lp_parm_string_list(global_loadparm, NULL, "auth methods", "domain controller", NULL);
break;
}
return auth_context_create_methods(mem_ctx, auth_methods, ev, msg, auth_ctx);
@@ -443,9 +444,8 @@ static int num_backends;
The 'name' can be later used by other backends to find the operations
structure for this backend.
*/
-NTSTATUS auth_register(const void *_ops)
+NTSTATUS auth_register(const struct auth_operations *ops)
{
- const struct auth_operations *ops = _ops;
struct auth_operations *new_ops;
if (auth_backend_byname(ops->name) != NULL) {
@@ -455,13 +455,14 @@ NTSTATUS auth_register(const void *_ops)
return NT_STATUS_OBJECT_NAME_COLLISION;
}
- backends = realloc_p(backends, struct auth_backend, num_backends+1);
- if (!backends) {
- return NT_STATUS_NO_MEMORY;
- }
+ backends = talloc_realloc(talloc_autofree_context(), backends,
+ struct auth_backend, num_backends+1);
+ NT_STATUS_HAVE_NO_MEMORY(backends);
- new_ops = smb_xmemdup(ops, sizeof(*ops));
- new_ops->name = smb_xstrdup(ops->name);
+ new_ops = talloc_memdup(backends, ops, sizeof(*ops));
+ NT_STATUS_HAVE_NO_MEMORY(new_ops);
+ new_ops->name = talloc_strdup(new_ops, ops->name);
+ NT_STATUS_HAVE_NO_MEMORY(new_ops->name);
backends[num_backends].ops = new_ops;
@@ -510,15 +511,15 @@ const struct auth_critical_sizes *auth_interface_version(void)
NTSTATUS auth_init(void)
{
- static BOOL initialized = False;
+ static bool initialized = false;
init_module_fn static_init[] = STATIC_auth_MODULES;
init_module_fn *shared_init;
if (initialized) return NT_STATUS_OK;
- initialized = True;
+ initialized = true;
- shared_init = load_samba_modules(NULL, "auth");
+ shared_init = load_samba_modules(NULL, global_loadparm, "auth");
run_init_functions(static_init);
run_init_functions(shared_init);
diff --git a/source4/auth/auth_developer.c b/source4/auth/auth_developer.c
index a28cf4a590..cc5e79631f 100644
--- a/source4/auth/auth_developer.c
+++ b/source4/auth/auth_developer.c
@@ -122,7 +122,7 @@ static NTSTATUS name_to_ntstatus_check_password(struct auth_method_context *ctx,
server_info->acct_flags = ACB_NORMAL;
- server_info->authenticated = False;
+ server_info->authenticated = false;
*_server_info = server_info;
diff --git a/source4/auth/auth_sam.c b/source4/auth/auth_sam.c
index 840db3ede6..da1ffb5c85 100644
--- a/source4/auth/auth_sam.c
+++ b/source4/auth/auth_sam.c
@@ -29,6 +29,7 @@
#include "dsdb/samdb/samdb.h"
#include "libcli/security/security.h"
#include "libcli/ldap/ldap.h"
+#include "param/param.h"
extern const char *user_attrs[];
extern const char *domain_ref_attrs[];
@@ -150,7 +151,7 @@ static NTSTATUS authsam_password_ok(struct auth_context *auth_context,
NTSTATUS status;
if (acct_flags & ACB_PWNOTREQ) {
- if (lp_null_passwords()) {
+ if (lp_null_passwords(global_loadparm)) {
DEBUG(3,("Account for user '%s' has no password and null passwords are allowed.\n",
user_info->mapped.account_name));
return NT_STATUS_OK;
@@ -341,17 +342,19 @@ static NTSTATUS authsam_want_check(struct auth_method_context *ctx,
TALLOC_CTX *mem_ctx,
const struct auth_usersupplied_info *user_info)
{
- BOOL is_local_name, is_my_domain;
+ bool is_local_name, is_my_domain;
if (!user_info->mapped.account_name || !*user_info->mapped.account_name) {
return NT_STATUS_NOT_IMPLEMENTED;
}
- is_local_name = is_myname(user_info->mapped.domain_name);
- is_my_domain = strequal(user_info->mapped.domain_name, lp_workgroup());
+ is_local_name = lp_is_myname(global_loadparm,
+ user_info->mapped.domain_name);
+ is_my_domain = lp_is_mydomain(global_loadparm,
+ user_info->mapped.domain_name);
/* check whether or not we service this domain/workgroup name */
- switch (lp_server_role()) {
+ switch (lp_server_role(global_loadparm)) {
case ROLE_STANDALONE:
return NT_STATUS_OK;
@@ -387,14 +390,14 @@ static NTSTATUS authsam_check_password(struct auth_method_context *ctx,
const char *domain;
/* check whether or not we service this domain/workgroup name */
- switch (lp_server_role()) {
+ switch (lp_server_role(global_loadparm)) {
case ROLE_STANDALONE:
case ROLE_DOMAIN_MEMBER:
- domain = lp_netbios_name();
+ domain = lp_netbios_name(global_loadparm);
break;
case ROLE_DOMAIN_CONTROLLER:
- domain = lp_workgroup();
+ domain = lp_workgroup(global_loadparm);
break;
default:
diff --git a/source4/auth/auth_server.c b/source4/auth/auth_server.c
index 5d4c33969f..abc052c9ea 100644
--- a/source4/auth/auth_server.c
+++ b/source4/auth/auth_server.c
@@ -31,13 +31,13 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
struct ipv4_addr dest_ip;
const char *p;
char *pserver;
- BOOL connected_ok = False;
+ bool connected_ok = false;
if (!(cli = smbcli_initialise(cli)))
return NULL;
/* security = server just can't function with spnego */
- cli->use_spnego = False;
+ cli->use_spnego = false;
pserver = talloc_strdup(mem_ctx, lp_passwordserver());
p = pserver;
@@ -66,7 +66,7 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
if (smbcli_connect(cli, desthost, &dest_ip)) {
DEBUG(3,("connected to password server %s\n",desthost));
- connected_ok = True;
+ connected_ok = true;
break;
}
}
@@ -195,10 +195,10 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
struct smbcli_state *cli;
static uint8_t badpass[24];
static fstring baduser;
- static BOOL tested_password_server = False;
- static BOOL bad_password_server = False;
+ static bool tested_password_server = false;
+ static bool bad_password_server = false;
NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
- BOOL locally_made_cli = False;
+ bool locally_made_cli = false;
/*
* Check that the requested domain is not our own machine name.
@@ -206,7 +206,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
* password file.
*/
- if(is_myname(user_info->domain.str)) {
+ if (lp_is_myname(global_loadparm, user_info->domain.str)) {
DEBUG(3,("check_smbserver_security: Requested domain was for this machine.\n"));
return NT_STATUS_LOGON_FAILURE;
}
@@ -216,7 +216,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
if (cli) {
} else {
cli = server_cryptkey(mem_ctx);
- locally_made_cli = True;
+ locally_made_cli = true;
}
if (!cli || !cli->initialised) {
@@ -273,7 +273,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
* We connected to the password server so we
* can say we've tested it.
*/
- tested_password_server = True;
+ tested_password_server = true;
if ((SVAL(cli->inbuf,smb_vwv2) & 1) == 0) {
DEBUG(0,("server_validate: password server %s allows users as non-guest \
@@ -285,7 +285,7 @@ use this machine as the password server.\n"));
/*
* Password server has the bug.
*/
- bad_password_server = True;
+ bad_password_server = true;
return NT_STATUS_LOGON_FAILURE;
}
smbcli_ulogoff(cli);
diff --git a/source4/auth/auth_simple.c b/source4/auth/auth_simple.c
index add45268d4..3e07adcb6a 100644
--- a/source4/auth/auth_simple.c
+++ b/source4/auth/auth_simple.c
@@ -61,7 +61,7 @@ _PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- user_info->mapped_state = True;
+ user_info->mapped_state = true;
user_info->client.account_name = nt4_username;
user_info->mapped.account_name = nt4_username;
user_info->client.domain_name = nt4_domain;
diff --git a/source4/auth/auth_unix.c b/source4/auth/auth_unix.c
index 61e004f592..8b4e23a2c4 100644
--- a/source4/auth/auth_unix.c
+++ b/source4/auth/auth_unix.c
@@ -24,6 +24,7 @@
#include "system/passwd.h" /* needed by some systems for struct passwd */
#include "lib/socket/socket.h"
#include "auth/pam_errors.h"
+#include "param/param.h"
/* TODO: look at how to best fill in parms retrieveing a struct passwd info
* except in case USER_INFO_DONT_CHECK_UNIX_ACCOUNT is set
@@ -52,7 +53,7 @@ static NTSTATUS authunix_make_server_info(TALLOC_CTX *mem_ctx,
server_info = talloc(mem_ctx, struct auth_serversupplied_info);
NT_STATUS_HAVE_NO_MEMORY(server_info);
- server_info->authenticated = True;
+ server_info->authenticated = true;
server_info->account_name = talloc_steal(server_info, pwd->pw_name);
NT_STATUS_HAVE_NO_MEMORY(server_info->account_name);
@@ -318,7 +319,7 @@ static NTSTATUS smb_pam_auth(pam_handle_t *pamh, const char *user)
DEBUG(4,("smb_pam_auth: PAM: Authenticate User: %s\n", user));
- pam_error = pam_authenticate(pamh, PAM_SILENT | lp_null_passwords() ? 0 : PAM_DISALLOW_NULL_AUTHTOK);
+ pam_error = pam_authenticate(pamh, PAM_SILENT | lp_null_passwords(global_loadparm) ? 0 : PAM_DISALLOW_NULL_AUTHTOK);
switch( pam_error ){
case PAM_AUTH_ERR:
DEBUG(2, ("smb_pam_auth: PAM: Authentication Error for user %s\n", user));
@@ -498,7 +499,7 @@ core of password checking routine
static NTSTATUS password_check(const char *username, const char *password,
const char *crypted, const char *salt)
{
- BOOL ret;
+ bool ret;
#ifdef WITH_AFS
if (afs_auth(username, password))
@@ -598,7 +599,7 @@ static NTSTATUS check_unix_password(TALLOC_CTX *ctx, const struct auth_usersuppl
char *crypted;
struct passwd *pws;
NTSTATUS nt_status;
- int level = lp_passwordlevel();
+ int level = lp_passwordlevel(global_loadparm);
*ret_passwd = NULL;
@@ -701,7 +702,7 @@ static NTSTATUS check_unix_password(TALLOC_CTX *ctx, const struct auth_usersuppl
#endif
if (crypted[0] == '\0') {
- if (!lp_null_passwords()) {
+ if (!lp_null_passwords(global_loadparm)) {
DEBUG(2, ("Disallowing %s with null password\n", username));
return NT_STATUS_LOGON_FAILURE;
}
diff --git a/source4/auth/auth_util.c b/source4/auth/auth_util.c
index 693ec35f86..60ba043479 100644
--- a/source4/auth/auth_util.c
+++ b/source4/auth/auth_util.c
@@ -27,6 +27,7 @@
#include "libcli/auth/libcli_auth.h"
#include "dsdb/samdb/samdb.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
/* this default function can be used by mostly all backends
* which don't want to set a challenge
@@ -72,7 +73,7 @@ NTSTATUS map_user_info(TALLOC_CTX *mem_ctx,
d++;
domain = d;
} else {
- domain = lp_workgroup();
+ domain = lp_workgroup(global_loadparm);
}
*user_info_mapped = talloc(mem_ctx, struct auth_usersupplied_info);
@@ -81,7 +82,7 @@ NTSTATUS map_user_info(TALLOC_CTX *mem_ctx,
}
talloc_reference(*user_info_mapped, user_info);
**user_info_mapped = *user_info;
- (*user_info_mapped)->mapped_state = True;
+ (*user_info_mapped)->mapped_state = true;
(*user_info_mapped)->mapped.domain_name = talloc_strdup(*user_info_mapped, domain);
(*user_info_mapped)->mapped.account_name = talloc_strdup(*user_info_mapped, account_name);
talloc_free(account_name);
@@ -137,8 +138,8 @@ NTSTATUS map_user_info(TALLOC_CTX *mem_ctx,
}
chall_blob = data_blob_talloc(mem_ctx, challenge, 8);
- if (lp_client_ntlmv2_auth()) {
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(), lp_workgroup());
+ if (lp_client_ntlmv2_auth(global_loadparm)) {
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(global_loadparm), lp_workgroup(global_loadparm));
DATA_BLOB lmv2_response, ntlmv2_response, lmv2_session_key, ntlmv2_session_key;
if (!SMBNTLMv2encrypt_hash(user_info_temp,
@@ -162,7 +163,7 @@ NTSTATUS map_user_info(TALLOC_CTX *mem_ctx,
SMBOWFencrypt(user_info_in->password.hash.nt->hash, challenge, blob.data);
user_info_temp->password.response.nt = blob;
- if (lp_client_lanman_auth() && user_info_in->password.hash.lanman) {
+ if (lp_client_lanman_auth(global_loadparm) && user_info_in->password.hash.lanman) {
DATA_BLOB lm_blob = data_blob_talloc(mem_ctx, NULL, 24);
SMBOWFencrypt(user_info_in->password.hash.lanman->hash, challenge, blob.data);
user_info_temp->password.response.lanman = lm_blob;
@@ -341,7 +342,7 @@ NTSTATUS make_server_info_netlogon_validation(TALLOC_CTX *mem_ctx,
server_info->bad_password_count = base->bad_password_count;
server_info->acct_flags = base->acct_flags;
- server_info->authenticated = True;
+ server_info->authenticated = true;
/* ensure we are never given NULL session keys */
@@ -412,7 +413,7 @@ NTSTATUS auth_anonymous_server_info(TALLOC_CTX *mem_ctx, struct auth_serversuppl
server_info->home_drive = talloc_strdup(server_info, "");
NT_STATUS_HAVE_NO_MEMORY(server_info->home_drive);
- server_info->logon_server = talloc_strdup(server_info, lp_netbios_name());
+ server_info->logon_server = talloc_strdup(server_info, lp_netbios_name(global_loadparm));
NT_STATUS_HAVE_NO_MEMORY(server_info->logon_server);
server_info->last_logon = 0;
@@ -427,7 +428,7 @@ NTSTATUS auth_anonymous_server_info(TALLOC_CTX *mem_ctx, struct auth_serversuppl
server_info->acct_flags = ACB_NORMAL;
- server_info->authenticated = False;
+ server_info->authenticated = false;
*_server_info = server_info;
@@ -482,7 +483,7 @@ NTSTATUS auth_system_server_info(TALLOC_CTX *mem_ctx, struct auth_serversupplied
server_info->home_drive = talloc_strdup(server_info, "");
NT_STATUS_HAVE_NO_MEMORY(server_info->home_drive);
- server_info->logon_server = talloc_strdup(server_info, lp_netbios_name());
+ server_info->logon_server = talloc_strdup(server_info, lp_netbios_name(global_loadparm));
NT_STATUS_HAVE_NO_MEMORY(server_info->logon_server);
server_info->last_logon = 0;
@@ -497,7 +498,7 @@ NTSTATUS auth_system_server_info(TALLOC_CTX *mem_ctx, struct auth_serversupplied
server_info->acct_flags = ACB_NORMAL;
- server_info->authenticated = True;
+ server_info->authenticated = true;
*_server_info = server_info;
@@ -561,7 +562,7 @@ NTSTATUS auth_anonymous_session_info(TALLOC_CTX *parent_ctx,
return NT_STATUS_NO_MEMORY;
}
- cli_credentials_set_conf(session_info->credentials);
+ cli_credentials_set_conf(session_info->credentials, global_loadparm);
cli_credentials_set_anonymous(session_info->credentials);
*_session_info = session_info;
@@ -581,7 +582,7 @@ struct auth_session_info *anonymous_session(TALLOC_CTX *mem_ctx)
}
static NTSTATUS _auth_system_session_info(TALLOC_CTX *parent_ctx,
- BOOL anonymous_credentials,
+ bool anonymous_credentials,
struct auth_session_info **_session_info)
{
NTSTATUS nt_status;
@@ -607,7 +608,7 @@ static NTSTATUS _auth_system_session_info(TALLOC_CTX *parent_ctx,
return NT_STATUS_NO_MEMORY;
}
- cli_credentials_set_conf(session_info->credentials);
+ cli_credentials_set_conf(session_info->credentials, global_loadparm);
if (anonymous_credentials) {
cli_credentials_set_anonymous(session_info->credentials);
@@ -622,8 +623,9 @@ static NTSTATUS _auth_system_session_info(TALLOC_CTX *parent_ctx,
_PUBLIC_ NTSTATUS auth_system_session_info(TALLOC_CTX *parent_ctx,
struct auth_session_info **_session_info)
{
- return _auth_system_session_info(parent_ctx, lp_parm_bool(-1,"system","anonymous", False),
- _session_info);
+ return _auth_system_session_info(parent_ctx,
+ lp_parm_bool(global_loadparm, NULL, "system", "anonymous", false),
+ _session_info);
}
/*
@@ -648,7 +650,7 @@ _PUBLIC_ struct auth_session_info *system_session_anon(TALLOC_CTX *mem_ctx)
{
NTSTATUS nt_status;
struct auth_session_info *session_info = NULL;
- nt_status = _auth_system_session_info(mem_ctx, False, &session_info);
+ nt_status = _auth_system_session_info(mem_ctx, false, &session_info);
if (!NT_STATUS_IS_OK(nt_status)) {
return NULL;
}
diff --git a/source4/auth/auth_winbind.c b/source4/auth/auth_winbind.c
index 95636d7843..2ec0dc7a56 100644
--- a/source4/auth/auth_winbind.c
+++ b/source4/auth/auth_winbind.c
@@ -109,7 +109,7 @@ static NTSTATUS winbind_check_password_samba3(struct auth_method_context *ctx,
memcpy(request.data.auth_crap.nt_resp, user_info->password.response.nt.data,
request.data.auth_crap.nt_resp_len);
- result = winbindd_request(WINBINDD_PAM_AUTH_CRAP, &request, &response);
+ result = winbindd_request_response(WINBINDD_PAM_AUTH_CRAP, &request, &response);
nt_status = NT_STATUS(response.data.auth.nt_status);
NT_STATUS_NOT_OK_RETURN(nt_status);
diff --git a/source4/auth/credentials/credentials.c b/source4/auth/credentials/credentials.c
index c32efb045f..d6c0bbc0ba 100644
--- a/source4/auth/credentials/credentials.c
+++ b/source4/auth/credentials/credentials.c
@@ -27,6 +27,7 @@
#include "auth/credentials/credentials_krb5.h"
#include "libcli/auth/libcli_auth.h"
#include "lib/events/events.h"
+#include "param/param.h"
/**
* Create a new credentials structure
@@ -40,7 +41,7 @@ struct cli_credentials *cli_credentials_init(TALLOC_CTX *mem_ctx)
}
cred->netlogon_creds = NULL;
- cred->machine_account_pending = False;
+ cred->machine_account_pending = false;
cred->workstation_obtained = CRED_UNINITIALISED;
cred->username_obtained = CRED_UNINITIALISED;
cred->password_obtained = CRED_UNINITIALISED;
@@ -58,12 +59,12 @@ struct cli_credentials *cli_credentials_init(TALLOC_CTX *mem_ctx)
cred->old_password = NULL;
cred->smb_krb5_context = NULL;
cred->salt_principal = NULL;
- cred->machine_account = False;
+ cred->machine_account = false;
cred->bind_dn = NULL;
cred->tries = 3;
- cred->callback_running = False;
+ cred->callback_running = false;
cred->ev = NULL;
cli_credentials_set_kerberos_state(cred, CRED_AUTO_USE_KERBEROS);
@@ -81,7 +82,7 @@ struct cli_credentials *cli_credentials_init_anon(TALLOC_CTX *mem_ctx)
struct cli_credentials *anon_credentials;
anon_credentials = cli_credentials_init(mem_ctx);
- cli_credentials_set_conf(anon_credentials);
+ cli_credentials_set_conf(anon_credentials, global_loadparm);
cli_credentials_set_anonymous(anon_credentials);
return anon_credentials;
@@ -123,9 +124,9 @@ const char *cli_credentials_get_username(struct cli_credentials *cred)
if (cred->username_obtained == CRED_CALLBACK &&
!cred->callback_running) {
- cred->callback_running = True;
+ cred->callback_running = true;
cred->username = cred->username_cb(cred);
- cred->callback_running = False;
+ cred->callback_running = false;
cred->username_obtained = CRED_SPECIFIED;
cli_credentials_invalidate_ccache(cred, cred->username_obtained);
}
@@ -133,36 +134,36 @@ const char *cli_credentials_get_username(struct cli_credentials *cred)
return cred->username;
}
-BOOL cli_credentials_set_username(struct cli_credentials *cred,
+bool cli_credentials_set_username(struct cli_credentials *cred,
const char *val, enum credentials_obtained obtained)
{
if (obtained >= cred->username_obtained) {
cred->username = talloc_strdup(cred, val);
cred->username_obtained = obtained;
cli_credentials_invalidate_ccache(cred, cred->username_obtained);
- return True;
+ return true;
}
- return False;
+ return false;
}
-BOOL cli_credentials_set_username_callback(struct cli_credentials *cred,
+bool cli_credentials_set_username_callback(struct cli_credentials *cred,
const char *(*username_cb) (struct cli_credentials *))
{
if (cred->username_obtained < CRED_CALLBACK) {
cred->username_cb = username_cb;
cred->username_obtained = CRED_CALLBACK;
- return True;
+ return true;
}
- return False;
+ return false;
}
-BOOL cli_credentials_set_bind_dn(struct cli_credentials *cred,
+bool cli_credentials_set_bind_dn(struct cli_credentials *cred,
const char *bind_dn)
{
cred->bind_dn = talloc_strdup(cred, bind_dn);
- return True;
+ return true;
}
/**
@@ -191,9 +192,9 @@ const char *cli_credentials_get_principal(struct cli_credentials *cred, TALLOC_C
if (cred->principal_obtained == CRED_CALLBACK &&
!cred->callback_running) {
- cred->callback_running = True;
+ cred->callback_running = true;
cred->principal = cred->principal_cb(cred);
- cred->callback_running = False;
+ cred->callback_running = false;
cred->principal_obtained = CRED_SPECIFIED;
cli_credentials_invalidate_ccache(cred, cred->principal_obtained);
}
@@ -212,7 +213,7 @@ const char *cli_credentials_get_principal(struct cli_credentials *cred, TALLOC_C
return talloc_reference(mem_ctx, cred->principal);
}
-BOOL cli_credentials_set_principal(struct cli_credentials *cred,
+bool cli_credentials_set_principal(struct cli_credentials *cred,
const char *val,
enum credentials_obtained obtained)
{
@@ -220,53 +221,53 @@ BOOL cli_credentials_set_principal(struct cli_credentials *cred,
cred->principal = talloc_strdup(cred, val);
cred->principal_obtained = obtained;
cli_credentials_invalidate_ccache(cred, cred->principal_obtained);
- return True;
+ return true;
}
- return False;
+ return false;
}
/* Set a callback to get the principal. This could be a popup dialog,
* a terminal prompt or similar. */
-BOOL cli_credentials_set_principal_callback(struct cli_credentials *cred,
+bool cli_credentials_set_principal_callback(struct cli_credentials *cred,
const char *(*principal_cb) (struct cli_credentials *))
{
if (cred->principal_obtained < CRED_CALLBACK) {
cred->principal_cb = principal_cb;
cred->principal_obtained = CRED_CALLBACK;
- return True;
+ return true;
}
- return False;
+ return false;
}
/* Some of our tools are 'anonymous by default'. This is a single
* function to determine if authentication has been explicitly
* requested */
-BOOL cli_credentials_authentication_requested(struct cli_credentials *cred)
+bool cli_credentials_authentication_requested(struct cli_credentials *cred)
{
if (cred->bind_dn) {
- return True;
+ return true;
}
if (cli_credentials_is_anonymous(cred)){
- return False;
+ return false;
}
if (cred->principal_obtained >= CRED_SPECIFIED) {
- return True;
+ return true;
}
if (cred->username_obtained >= CRED_SPECIFIED) {
- return True;
+ return true;
}
if (cli_credentials_get_kerberos_state(cred) == CRED_MUST_USE_KERBEROS) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/**
@@ -282,9 +283,9 @@ const char *cli_credentials_get_password(struct cli_credentials *cred)
if (cred->password_obtained == CRED_CALLBACK &&
!cred->callback_running) {
- cred->callback_running = True;
+ cred->callback_running = true;
cred->password = cred->password_cb(cred);
- cred->callback_running = False;
+ cred->callback_running = false;
cred->password_obtained = CRED_CALLBACK_RESULT;
cli_credentials_invalidate_ccache(cred, cred->password_obtained);
}
@@ -295,7 +296,7 @@ const char *cli_credentials_get_password(struct cli_credentials *cred)
/* Set a password on the credentials context, including an indication
* of 'how' the password was obtained */
-BOOL cli_credentials_set_password(struct cli_credentials *cred,
+bool cli_credentials_set_password(struct cli_credentials *cred,
const char *val,
enum credentials_obtained obtained)
{
@@ -305,23 +306,23 @@ BOOL cli_credentials_set_password(struct cli_credentials *cred,
cli_credentials_invalidate_ccache(cred, cred->password_obtained);
cred->nt_hash = NULL;
- return True;
+ return true;
}
- return False;
+ return false;
}
-BOOL cli_credentials_set_password_callback(struct cli_credentials *cred,
+bool cli_credentials_set_password_callback(struct cli_credentials *cred,
const char *(*password_cb) (struct cli_credentials *))
{
if (cred->password_obtained < CRED_CALLBACK) {
cred->password_cb = password_cb;
cred->password_obtained = CRED_CALLBACK;
cli_credentials_invalidate_ccache(cred, cred->password_obtained);
- return True;
+ return true;
}
- return False;
+ return false;
}
/**
@@ -338,12 +339,12 @@ const char *cli_credentials_get_old_password(struct cli_credentials *cred)
return cred->old_password;
}
-BOOL cli_credentials_set_old_password(struct cli_credentials *cred,
+bool cli_credentials_set_old_password(struct cli_credentials *cred,
const char *val,
enum credentials_obtained obtained)
{
cred->old_password = talloc_strdup(cred, val);
- return True;
+ return true;
}
/**
@@ -374,7 +375,7 @@ const struct samr_Password *cli_credentials_get_nt_hash(struct cli_credentials *
}
}
-BOOL cli_credentials_set_nt_hash(struct cli_credentials *cred,
+bool cli_credentials_set_nt_hash(struct cli_credentials *cred,
const struct samr_Password *nt_hash,
enum credentials_obtained obtained)
{
@@ -386,10 +387,10 @@ BOOL cli_credentials_set_nt_hash(struct cli_credentials *cred,
} else {
cred->nt_hash = NULL;
}
- return True;
+ return true;
}
- return False;
+ return false;
}
/**
@@ -406,9 +407,9 @@ const char *cli_credentials_get_domain(struct cli_credentials *cred)
if (cred->domain_obtained == CRED_CALLBACK &&
!cred->callback_running) {
- cred->callback_running = True;
+ cred->callback_running = true;
cred->domain = cred->domain_cb(cred);
- cred->callback_running = False;
+ cred->callback_running = false;
cred->domain_obtained = CRED_SPECIFIED;
cli_credentials_invalidate_ccache(cred, cred->domain_obtained);
}
@@ -417,7 +418,7 @@ const char *cli_credentials_get_domain(struct cli_credentials *cred)
}
-BOOL cli_credentials_set_domain(struct cli_credentials *cred,
+bool cli_credentials_set_domain(struct cli_credentials *cred,
const char *val,
enum credentials_obtained obtained)
{
@@ -428,22 +429,22 @@ BOOL cli_credentials_set_domain(struct cli_credentials *cred,
cred->domain = strupper_talloc(cred, val);
cred->domain_obtained = obtained;
cli_credentials_invalidate_ccache(cred, cred->domain_obtained);
- return True;
+ return true;
}
- return False;
+ return false;
}
-BOOL cli_credentials_set_domain_callback(struct cli_credentials *cred,
+bool cli_credentials_set_domain_callback(struct cli_credentials *cred,
const char *(*domain_cb) (struct cli_credentials *))
{
if (cred->domain_obtained < CRED_CALLBACK) {
cred->domain_cb = domain_cb;
cred->domain_obtained = CRED_CALLBACK;
- return True;
+ return true;
}
- return False;
+ return false;
}
/**
@@ -460,9 +461,9 @@ const char *cli_credentials_get_realm(struct cli_credentials *cred)
if (cred->realm_obtained == CRED_CALLBACK &&
!cred->callback_running) {
- cred->callback_running = True;
+ cred->callback_running = true;
cred->realm = cred->realm_cb(cred);
- cred->callback_running = False;
+ cred->callback_running = false;
cred->realm_obtained = CRED_SPECIFIED;
cli_credentials_invalidate_ccache(cred, cred->realm_obtained);
}
@@ -474,7 +475,7 @@ const char *cli_credentials_get_realm(struct cli_credentials *cred)
* Set the realm for this credentials context, and force it to
* uppercase for the sainity of our local kerberos libraries
*/
-BOOL cli_credentials_set_realm(struct cli_credentials *cred,
+bool cli_credentials_set_realm(struct cli_credentials *cred,
const char *val,
enum credentials_obtained obtained)
{
@@ -482,22 +483,22 @@ BOOL cli_credentials_set_realm(struct cli_credentials *cred,
cred->realm = strupper_talloc(cred, val);
cred->realm_obtained = obtained;
cli_credentials_invalidate_ccache(cred, cred->realm_obtained);
- return True;
+ return true;
}
- return False;
+ return false;
}
-BOOL cli_credentials_set_realm_callback(struct cli_credentials *cred,
+bool cli_credentials_set_realm_callback(struct cli_credentials *cred,
const char *(*realm_cb) (struct cli_credentials *))
{
if (cred->realm_obtained < CRED_CALLBACK) {
cred->realm_cb = realm_cb;
cred->realm_obtained = CRED_CALLBACK;
- return True;
+ return true;
}
- return False;
+ return false;
}
/**
@@ -511,38 +512,38 @@ const char *cli_credentials_get_workstation(struct cli_credentials *cred)
{
if (cred->workstation_obtained == CRED_CALLBACK &&
!cred->callback_running) {
- cred->callback_running = True;
+ cred->callback_running = true;
cred->workstation = cred->workstation_cb(cred);
- cred->callback_running = False;
+ cred->callback_running = false;
cred->workstation_obtained = CRED_SPECIFIED;
}
return cred->workstation;
}
-BOOL cli_credentials_set_workstation(struct cli_credentials *cred,
+bool cli_credentials_set_workstation(struct cli_credentials *cred,
const char *val,
enum credentials_obtained obtained)
{
if (obtained >= cred->workstation_obtained) {
cred->workstation = talloc_strdup(cred, val);
cred->workstation_obtained = obtained;
- return True;
+ return true;
}
- return False;
+ return false;
}
-BOOL cli_credentials_set_workstation_callback(struct cli_credentials *cred,
+bool cli_credentials_set_workstation_callback(struct cli_credentials *cred,
const char *(*workstation_cb) (struct cli_credentials *))
{
if (cred->workstation_obtained < CRED_CALLBACK) {
cred->workstation_cb = workstation_cb;
cred->workstation_obtained = CRED_CALLBACK;
- return True;
+ return true;
}
- return False;
+ return false;
}
/**
@@ -620,12 +621,13 @@ const char *cli_credentials_get_unparsed_name(struct cli_credentials *credential
*
* @param cred Credentials structure to fill in
*/
-void cli_credentials_set_conf(struct cli_credentials *cred)
+void cli_credentials_set_conf(struct cli_credentials *cred,
+ struct loadparm_context *lp_ctx)
{
cli_credentials_set_username(cred, "", CRED_UNINITIALISED);
- cli_credentials_set_domain(cred, lp_workgroup(), CRED_UNINITIALISED);
- cli_credentials_set_workstation(cred, lp_netbios_name(), CRED_UNINITIALISED);
- cli_credentials_set_realm(cred, lp_realm(), CRED_UNINITIALISED);
+ cli_credentials_set_domain(cred, lp_workgroup(lp_ctx), CRED_UNINITIALISED);
+ cli_credentials_set_workstation(cred, lp_netbios_name(lp_ctx), CRED_UNINITIALISED);
+ cli_credentials_set_realm(cred, lp_realm(lp_ctx), CRED_UNINITIALISED);
}
/**
@@ -638,7 +640,7 @@ void cli_credentials_guess(struct cli_credentials *cred)
{
char *p;
- cli_credentials_set_conf(cred);
+ cli_credentials_set_conf(cred, global_loadparm);
if (getenv("LOGNAME")) {
cli_credentials_set_username(cred, getenv("LOGNAME"), CRED_GUESS_ENV);
@@ -656,7 +658,8 @@ void cli_credentials_guess(struct cli_credentials *cred)
}
if (getenv("PASSWD_FD")) {
- cli_credentials_parse_password_fd(cred, atoi(getenv("PASSWD_FD")), CRED_GUESS_FILE);
+ cli_credentials_parse_password_fd(cred, atoi(getenv("PASSWD_FD")),
+ CRED_GUESS_FILE);
}
p = getenv("PASSWD_FILE");
@@ -719,10 +722,10 @@ void cli_credentials_set_anonymous(struct cli_credentials *cred)
/**
* Describe a credentials context as anonymous or authenticated
- * @retval True if anonymous, False if a username is specified
+ * @retval true if anonymous, false if a username is specified
*/
-BOOL cli_credentials_is_anonymous(struct cli_credentials *cred)
+bool cli_credentials_is_anonymous(struct cli_credentials *cred)
{
const char *username;
@@ -736,10 +739,10 @@ BOOL cli_credentials_is_anonymous(struct cli_credentials *cred)
* here - anonymous is "", not NULL, which is 'never specified,
* never guessed', ie programmer bug */
if (!username[0]) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/**
@@ -750,10 +753,10 @@ BOOL cli_credentials_is_anonymous(struct cli_credentials *cred)
*
* @retval whether the credentials struct is finished
*/
-BOOL cli_credentials_wrong_password(struct cli_credentials *cred)
+bool cli_credentials_wrong_password(struct cli_credentials *cred)
{
if (cred->password_obtained != CRED_CALLBACK_RESULT) {
- return False;
+ return false;
}
cred->password_obtained = CRED_CALLBACK;
diff --git a/source4/auth/credentials/credentials.h b/source4/auth/credentials/credentials.h
index 1cecb97055..7ea37e40d1 100644
--- a/source4/auth/credentials/credentials.h
+++ b/source4/auth/credentials/credentials.h
@@ -22,6 +22,7 @@
#ifndef __CREDENTIALS_H__
#define __CREDENTIALS_H__
+#include "util/data_blob.h"
#include "librpc/gen_ndr/misc.h"
struct ccache_container;
@@ -126,6 +127,7 @@ struct cli_credentials {
};
struct ldb_context;
+struct loadparm_context;
#include "auth/credentials/credentials_proto.h"
#endif /* __CREDENTIALS_H__ */
diff --git a/source4/auth/credentials/credentials_files.c b/source4/auth/credentials/credentials_files.c
index 2b6bc4f9d6..1708fa5841 100644
--- a/source4/auth/credentials/credentials_files.c
+++ b/source4/auth/credentials/credentials_files.c
@@ -29,6 +29,7 @@
#include "db_wrap.h"
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
+#include "param/param.h"
/**
* Read a file descriptor, and parse it for a password (eg from a file or stdin)
@@ -38,7 +39,7 @@
* @param obtained This enum describes how 'specified' this password is
*/
-BOOL cli_credentials_parse_password_fd(struct cli_credentials *credentials,
+bool cli_credentials_parse_password_fd(struct cli_credentials *credentials,
int fd, enum credentials_obtained obtained)
{
char *p;
@@ -60,18 +61,18 @@ BOOL cli_credentials_parse_password_fd(struct cli_credentials *credentials,
break;
} else {
fprintf(stderr, "Error reading password from file descriptor %d: %s\n", fd, "empty password\n");
- return False;
+ return false;
}
default:
fprintf(stderr, "Error reading password from file descriptor %d: %s\n",
fd, strerror(errno));
- return False;
+ return false;
}
}
cli_credentials_set_password(credentials, pass, obtained);
- return True;
+ return true;
}
/**
@@ -82,15 +83,15 @@ BOOL cli_credentials_parse_password_fd(struct cli_credentials *credentials,
* @param obtained This enum describes how 'specified' this password is
*/
-BOOL cli_credentials_parse_password_file(struct cli_credentials *credentials, const char *file, enum credentials_obtained obtained)
+bool cli_credentials_parse_password_file(struct cli_credentials *credentials, const char *file, enum credentials_obtained obtained)
{
int fd = open(file, O_RDONLY, 0);
- BOOL ret;
+ bool ret;
if (fd < 0) {
fprintf(stderr, "Error opening password file %s: %s\n",
file, strerror(errno));
- return False;
+ return false;
}
ret = cli_credentials_parse_password_fd(credentials, fd, obtained);
@@ -108,7 +109,7 @@ BOOL cli_credentials_parse_password_file(struct cli_credentials *credentials, co
* @param obtained This enum describes how 'specified' this password is
*/
-BOOL cli_credentials_parse_file(struct cli_credentials *cred, const char *file, enum credentials_obtained obtained)
+bool cli_credentials_parse_file(struct cli_credentials *cred, const char *file, enum credentials_obtained obtained)
{
uint16_t len = 0;
char *ptr, *val, *param;
@@ -121,7 +122,7 @@ BOOL cli_credentials_parse_file(struct cli_credentials *cred, const char *file,
{
/* fail if we can't open the credentials file */
d_printf("ERROR: Unable to open credentials file!\n");
- return False;
+ return false;
}
for (i = 0; i < numlines; i++) {
@@ -157,7 +158,7 @@ BOOL cli_credentials_parse_file(struct cli_credentials *cred, const char *file,
talloc_free(lines);
- return True;
+ return true;
}
@@ -202,10 +203,10 @@ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
const char *keytab;
/* ok, we are going to get it now, don't recurse back here */
- cred->machine_account_pending = False;
+ cred->machine_account_pending = false;
/* some other parts of the system will key off this */
- cred->machine_account = True;
+ cred->machine_account = true;
mem_ctx = talloc_named(cred, 0, "cli_credentials fetch machine password");
@@ -307,7 +308,7 @@ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
} 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, keytab));
+ keytab = talloc_asprintf(mem_ctx, "FILE:%s", private_path(mem_ctx, global_loadparm, keytab));
if (keytab) {
cli_credentials_set_keytab_name(cred, keytab, CRED_SPECIFIED);
}
@@ -330,7 +331,7 @@ NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cred)
/* Bleh, nasty recursion issues: We are setting a machine
* account here, so we don't want the 'pending' flag around
* any more */
- cred->machine_account_pending = False;
+ cred->machine_account_pending = false;
filter = talloc_asprintf(cred, SECRETS_PRIMARY_DOMAIN_FILTER,
cli_credentials_get_domain(cred));
return cli_credentials_set_secrets(cred, NULL, SECRETS_PRIMARY_DOMAIN_DN,
@@ -349,7 +350,7 @@ NTSTATUS cli_credentials_set_krbtgt(struct cli_credentials *cred)
/* Bleh, nasty recursion issues: We are setting a machine
* account here, so we don't want the 'pending' flag around
* any more */
- cred->machine_account_pending = False;
+ cred->machine_account_pending = false;
filter = talloc_asprintf(cred, SECRETS_KRBTGT_SEARCH,
cli_credentials_get_realm(cred),
cli_credentials_get_domain(cred));
@@ -370,7 +371,7 @@ NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *cred,
/* Bleh, nasty recursion issues: We are setting a machine
* account here, so we don't want the 'pending' flag around
* any more */
- cred->machine_account_pending = False;
+ cred->machine_account_pending = false;
filter = talloc_asprintf(cred, SECRETS_PRINCIPAL_SEARCH,
cli_credentials_get_realm(cred),
cli_credentials_get_domain(cred),
@@ -390,7 +391,7 @@ NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *cred,
*/
void cli_credentials_set_machine_account_pending(struct cli_credentials *cred)
{
- cred->machine_account_pending = True;
+ cred->machine_account_pending = true;
}
diff --git a/source4/auth/gensec/cyrus_sasl.c b/source4/auth/gensec/cyrus_sasl.c
index db77ed13a7..0bce35e1c5 100644
--- a/source4/auth/gensec/cyrus_sasl.c
+++ b/source4/auth/gensec/cyrus_sasl.c
@@ -248,6 +248,7 @@ static NTSTATUS gensec_sasl_unwrap_packets(struct gensec_security *gensec_securi
return sasl_nt_status(sasl_ret);
}
+
static NTSTATUS gensec_sasl_wrap_packets(struct gensec_security *gensec_security,
TALLOC_CTX *out_mem_ctx,
const DATA_BLOB *in,
@@ -271,7 +272,7 @@ static NTSTATUS gensec_sasl_wrap_packets(struct gensec_security *gensec_security
}
/* Try to figure out what features we actually got on the connection */
-static BOOL gensec_sasl_have_feature(struct gensec_security *gensec_security,
+static bool gensec_sasl_have_feature(struct gensec_security *gensec_security,
uint32_t feature)
{
struct gensec_sasl_state *gensec_sasl_state = talloc_get_type(gensec_security->private_data,
@@ -279,25 +280,25 @@ static BOOL gensec_sasl_have_feature(struct gensec_security *gensec_security,
sasl_ssf_t ssf;
int sasl_ret = sasl_getprop(gensec_sasl_state->conn, SASL_SSF, &ssf);
if (sasl_ret != SASL_OK) {
- return False;
+ return false;
}
if (feature & GENSEC_FEATURE_SIGN) {
if (ssf == 0) {
- return False;
+ return false;
}
if (ssf >= 1) {
- return True;
+ return true;
}
}
if (feature & GENSEC_FEATURE_SEAL) {
if (ssf <= 1) {
- return False;
+ return false;
}
if (ssf > 1) {
- return True;
+ return true;
}
}
- return False;
+ return false;
}
/* This could in theory work with any SASL mech */
@@ -309,7 +310,7 @@ static const struct gensec_security_ops gensec_sasl_security_ops = {
.wrap_packets = gensec_sasl_wrap_packets,
.unwrap_packets = gensec_sasl_unwrap_packets,
.have_feature = gensec_sasl_have_feature,
- .enabled = True,
+ .enabled = true,
.priority = GENSEC_SASL
};
diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c
index 25366dc246..4821e6a19b 100644
--- a/source4/auth/gensec/gensec.c
+++ b/source4/auth/gensec/gensec.c
@@ -27,6 +27,7 @@
#include "librpc/rpc/dcerpc.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
/* the list of currently registered GENSEC backends */
static struct gensec_security_ops **generic_security_ops;
@@ -46,10 +47,15 @@ struct gensec_security_ops **gensec_security_all(void)
struct gensec_security_ops **gensec_use_kerberos_mechs(TALLOC_CTX *mem_ctx,
struct gensec_security_ops **old_gensec_list,
- enum credentials_use_kerberos use_kerberos)
+ struct cli_credentials *creds)
{
struct gensec_security_ops **new_gensec_list;
int i, j, num_mechs_in;
+ enum credentials_use_kerberos use_kerberos = CRED_AUTO_USE_KERBEROS;
+
+ if (creds) {
+ use_kerberos = cli_credentials_get_kerberos_state(creds);
+ }
if (use_kerberos == CRED_AUTO_USE_KERBEROS) {
if (!talloc_reference(mem_ctx, old_gensec_list)) {
@@ -79,13 +85,13 @@ struct gensec_security_ops **gensec_use_kerberos_mechs(TALLOC_CTX *mem_ctx,
}
switch (use_kerberos) {
case CRED_DONT_USE_KERBEROS:
- if (old_gensec_list[i]->kerberos == False) {
+ if (old_gensec_list[i]->kerberos == false) {
new_gensec_list[j] = old_gensec_list[i];
j++;
}
break;
case CRED_MUST_USE_KERBEROS:
- if (old_gensec_list[i]->kerberos == True) {
+ if (old_gensec_list[i]->kerberos == true) {
new_gensec_list[j] = old_gensec_list[i];
j++;
}
@@ -111,7 +117,6 @@ struct gensec_security_ops **gensec_security_mechs(struct gensec_security *gense
}
return backends;
} else {
- enum credentials_use_kerberos use_kerberos;
struct cli_credentials *creds = gensec_get_credentials(gensec_security);
if (!creds) {
if (!talloc_reference(mem_ctx, backends)) {
@@ -119,8 +124,7 @@ struct gensec_security_ops **gensec_security_mechs(struct gensec_security *gense
}
return backends;
}
- use_kerberos = cli_credentials_get_kerberos_state(creds);
- return gensec_use_kerberos_mechs(mem_ctx, backends, use_kerberos);
+ return gensec_use_kerberos_mechs(mem_ctx, backends, creds);
}
}
@@ -485,7 +489,7 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
ZERO_STRUCT((*gensec_security)->peer_addr);
ZERO_STRUCT((*gensec_security)->my_addr);
- (*gensec_security)->subcontext = False;
+ (*gensec_security)->subcontext = false;
(*gensec_security)->want_features = 0;
if (ev == NULL) {
@@ -521,7 +525,7 @@ _PUBLIC_ NTSTATUS gensec_subcontext_start(TALLOC_CTX *mem_ctx,
(*gensec_security)->ops = NULL;
(*gensec_security)->private_data = NULL;
- (*gensec_security)->subcontext = True;
+ (*gensec_security)->subcontext = true;
(*gensec_security)->event_ctx = parent->event_ctx;
(*gensec_security)->msg_ctx = parent->msg_ctx;
@@ -1026,11 +1030,11 @@ _PUBLIC_ void gensec_want_feature(struct gensec_security *gensec_security,
*
*/
-_PUBLIC_ BOOL gensec_have_feature(struct gensec_security *gensec_security,
+_PUBLIC_ bool gensec_have_feature(struct gensec_security *gensec_security,
uint32_t feature)
{
if (!gensec_security->ops->have_feature) {
- return False;
+ return false;
}
/* We might 'have' features that we don't 'want', because the
@@ -1104,7 +1108,7 @@ _PUBLIC_ NTSTATUS gensec_set_target_hostname(struct gensec_security *gensec_secu
_PUBLIC_ const char *gensec_get_target_hostname(struct gensec_security *gensec_security)
{
/* We allow the target hostname to be overriden for testing purposes */
- const char *target_hostname = lp_parm_string(-1, "gensec", "target_hostname");
+ const char *target_hostname = lp_parm_string(global_loadparm, NULL, "gensec", "target_hostname");
if (target_hostname) {
return target_hostname;
}
@@ -1202,7 +1206,7 @@ const char *gensec_get_target_principal(struct gensec_security *gensec_security)
*/
NTSTATUS gensec_register(const struct gensec_security_ops *ops)
{
- if (!lp_parm_bool(-1, "gensec", ops->name, ops->enabled)) {
+ if (!lp_parm_bool(global_loadparm, NULL, "gensec", ops->name, ops->enabled)) {
DEBUG(2,("gensec subsystem %s is disabled\n", ops->name));
return NT_STATUS_OK;
}
@@ -1222,7 +1226,7 @@ NTSTATUS gensec_register(const struct gensec_security_ops *ops)
return NT_STATUS_NO_MEMORY;
}
- generic_security_ops[gensec_num_backends] = discard_const(ops);
+ generic_security_ops[gensec_num_backends] = discard_const_p(struct gensec_security_ops, ops);
gensec_num_backends++;
generic_security_ops[gensec_num_backends] = NULL;
@@ -1257,15 +1261,15 @@ static int sort_gensec(struct gensec_security_ops **gs1, struct gensec_security_
*/
NTSTATUS gensec_init(void)
{
- static BOOL initialized = False;
+ static bool initialized = false;
init_module_fn static_init[] = STATIC_gensec_MODULES;
init_module_fn *shared_init;
if (initialized) return NT_STATUS_OK;
- initialized = True;
+ initialized = true;
- shared_init = load_samba_modules(NULL, "gensec");
+ shared_init = load_samba_modules(NULL, global_loadparm, "gensec");
run_init_functions(static_init);
run_init_functions(shared_init);
diff --git a/source4/auth/gensec/gensec.h b/source4/auth/gensec/gensec.h
index 48a2903513..bda740cc86 100644
--- a/source4/auth/gensec/gensec.h
+++ b/source4/auth/gensec/gensec.h
@@ -39,8 +39,6 @@ enum gensec_priority {
GENSEC_OTHER = 0
};
-enum credentials_use_kerberos;
-
struct gensec_security;
struct gensec_target {
const char *principal;
@@ -63,6 +61,7 @@ enum gensec_role
};
struct auth_session_info;
+struct cli_credentials;
struct gensec_update_request {
struct gensec_security *gensec_security;
diff --git a/source4/auth/gensec/gensec_gssapi.c b/source4/auth/gensec/gensec_gssapi.c
index 3c66a032d5..dceb10e7b6 100644
--- a/source4/auth/gensec/gensec_gssapi.c
+++ b/source4/auth/gensec/gensec_gssapi.c
@@ -34,6 +34,7 @@
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
enum gensec_gssapi_sasl_state
{
@@ -64,7 +65,7 @@ struct gensec_gssapi_state {
gss_cred_id_t delegated_cred_handle;
- BOOL sasl; /* We have two different mechs in this file: One
+ bool sasl; /* We have two different mechs in this file: One
* for SASL wrapped GSSAPI and another for normal
* GSSAPI */
enum gensec_gssapi_sasl_state sasl_state;
@@ -154,9 +155,9 @@ static NTSTATUS gensec_gssapi_start(struct gensec_security *gensec_security)
gensec_gssapi_state->gss_exchange_count = 0;
gensec_gssapi_state->max_wrap_buf_size
- = lp_parm_int(-1, "gensec_gssapi", "max wrap buf size", 65536);
+ = lp_parm_int(global_loadparm, NULL, "gensec_gssapi", "max wrap buf size", 65536);
- gensec_gssapi_state->sasl = False;
+ gensec_gssapi_state->sasl = false;
gensec_gssapi_state->sasl_state = STAGE_GSS_NEG;
gensec_security->private_data = gensec_gssapi_state;
@@ -169,16 +170,16 @@ static NTSTATUS gensec_gssapi_start(struct gensec_security *gensec_security)
gensec_gssapi_state->input_chan_bindings = GSS_C_NO_CHANNEL_BINDINGS;
gensec_gssapi_state->want_flags = 0;
- if (lp_parm_bool(-1, "gensec_gssapi", "mutual", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "gensec_gssapi", "mutual", true)) {
gensec_gssapi_state->want_flags |= GSS_C_MUTUAL_FLAG;
}
- if (lp_parm_bool(-1, "gensec_gssapi", "delegation", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "gensec_gssapi", "delegation", true)) {
gensec_gssapi_state->want_flags |= GSS_C_DELEG_FLAG;
}
- if (lp_parm_bool(-1, "gensec_gssapi", "replay", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "gensec_gssapi", "replay", true)) {
gensec_gssapi_state->want_flags |= GSS_C_REPLAY_FLAG;
}
- if (lp_parm_bool(-1, "gensec_gssapi", "sequence", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "gensec_gssapi", "sequence", true)) {
gensec_gssapi_state->want_flags |= GSS_C_SEQUENCE_FLAG;
}
@@ -212,10 +213,10 @@ static NTSTATUS gensec_gssapi_start(struct gensec_security *gensec_security)
talloc_free(gensec_gssapi_state);
return NT_STATUS_INTERNAL_ERROR;
}
- if (lp_realm() && *lp_realm()) {
- char *upper_realm = strupper_talloc(gensec_gssapi_state, lp_realm());
+ if (lp_realm(global_loadparm) && *lp_realm(global_loadparm)) {
+ char *upper_realm = strupper_talloc(gensec_gssapi_state, lp_realm(global_loadparm));
if (!upper_realm) {
- DEBUG(1,("gensec_krb5_start: could not uppercase realm: %s\n", lp_realm()));
+ DEBUG(1,("gensec_krb5_start: could not uppercase realm: %s\n", lp_realm(global_loadparm)));
talloc_free(gensec_gssapi_state);
return NT_STATUS_NO_MEMORY;
}
@@ -229,7 +230,7 @@ static NTSTATUS gensec_gssapi_start(struct gensec_security *gensec_security)
}
/* don't do DNS lookups of any kind, it might/will fail for a netbios name */
- ret = gsskrb5_set_dns_canonicalize(lp_parm_bool(-1, "krb5", "set_dns_canonicalize", false));
+ ret = gsskrb5_set_dns_canonicalize(lp_parm_bool(global_loadparm, NULL, "krb5", "set_dns_canonicalize", false));
if (ret) {
DEBUG(1,("gensec_krb5_start: gsskrb5_set_dns_canonicalize failed\n"));
talloc_free(gensec_gssapi_state);
@@ -290,7 +291,7 @@ static NTSTATUS gensec_gssapi_sasl_server_start(struct gensec_security *gensec_s
if (NT_STATUS_IS_OK(nt_status)) {
gensec_gssapi_state = talloc_get_type(gensec_security->private_data, struct gensec_gssapi_state);
- gensec_gssapi_state->sasl = True;
+ gensec_gssapi_state->sasl = true;
}
return nt_status;
}
@@ -331,7 +332,7 @@ static NTSTATUS gensec_gssapi_client_start(struct gensec_security *gensec_securi
gensec_gssapi_state->gss_oid = gss_mech_krb5;
principal = gensec_get_target_principal(gensec_security);
- if (principal && lp_client_use_spnego_principal()) {
+ if (principal && lp_client_use_spnego_principal(global_loadparm)) {
name_type = GSS_C_NULL_OID;
} else {
principal = talloc_asprintf(gensec_gssapi_state, "%s@%s",
@@ -385,7 +386,7 @@ static NTSTATUS gensec_gssapi_sasl_client_start(struct gensec_security *gensec_s
if (NT_STATUS_IS_OK(nt_status)) {
gensec_gssapi_state = talloc_get_type(gensec_security->private_data, struct gensec_gssapi_state);
- gensec_gssapi_state->sasl = True;
+ gensec_gssapi_state->sasl = true;
}
return nt_status;
}
@@ -631,7 +632,7 @@ static NTSTATUS gensec_gssapi_update(struct gensec_security *gensec_security,
maj_stat = gss_wrap(&min_stat,
gensec_gssapi_state->gssapi_context,
- False,
+ false,
GSS_C_QOP_DEFAULT,
&input_token,
&conf_state,
@@ -696,7 +697,7 @@ static NTSTATUS gensec_gssapi_update(struct gensec_security *gensec_security,
maj_stat = gss_wrap(&min_stat,
gensec_gssapi_state->gssapi_context,
- False,
+ false,
GSS_C_QOP_DEFAULT,
&input_token,
&conf_state,
@@ -1109,7 +1110,7 @@ static NTSTATUS gensec_gssapi_check_packet(struct gensec_security *gensec_securi
}
/* Try to figure out what features we actually got on the connection */
-static BOOL gensec_gssapi_have_feature(struct gensec_security *gensec_security,
+static bool gensec_gssapi_have_feature(struct gensec_security *gensec_security,
uint32_t feature)
{
struct gensec_gssapi_state *gensec_gssapi_state
@@ -1135,7 +1136,7 @@ static BOOL gensec_gssapi_have_feature(struct gensec_security *gensec_security,
if (feature & GENSEC_FEATURE_SESSION_KEY) {
/* Only for GSSAPI/Krb5 */
if (gss_oid_equal(gensec_gssapi_state->gss_oid, gss_mech_krb5)) {
- return True;
+ return true;
}
}
if (feature & GENSEC_FEATURE_DCE_STYLE) {
@@ -1143,9 +1144,9 @@ static BOOL gensec_gssapi_have_feature(struct gensec_security *gensec_security,
}
/* We can always do async (rather than strict request/reply) packets. */
if (feature & GENSEC_FEATURE_ASYNC_REPLIES) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
@@ -1229,7 +1230,9 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi
return NT_STATUS_FOOBAR;
}
- principal_string = talloc_strndup(mem_ctx, name_token.value, name_token.length);
+ principal_string = talloc_strndup(mem_ctx,
+ (const char *)name_token.value,
+ name_token.length);
gss_release_buffer(&min_stat, &name_token);
@@ -1314,7 +1317,7 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi
talloc_free(mem_ctx);
return nt_status;
}
- } else if (!lp_parm_bool(-1, "gensec", "require_pac", False)) {
+ } else if (!lp_parm_bool(global_loadparm, 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, principal_string,
@@ -1356,7 +1359,7 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi
}
cli_credentials_set_event_context(session_info->credentials, gensec_security->event_ctx);
- cli_credentials_set_conf(session_info->credentials);
+ cli_credentials_set_conf(session_info->credentials, global_loadparm);
/* Just so we don't segfault trying to get at a username */
cli_credentials_set_anonymous(session_info->credentials);
@@ -1411,8 +1414,8 @@ static const struct gensec_security_ops gensec_gssapi_spnego_security_ops = {
.wrap = gensec_gssapi_wrap,
.unwrap = gensec_gssapi_unwrap,
.have_feature = gensec_gssapi_have_feature,
- .enabled = False,
- .kerberos = True,
+ .enabled = false,
+ .kerberos = true,
.priority = GENSEC_GSSAPI
};
@@ -1434,8 +1437,8 @@ static const struct gensec_security_ops gensec_gssapi_krb5_security_ops = {
.wrap = gensec_gssapi_wrap,
.unwrap = gensec_gssapi_unwrap,
.have_feature = gensec_gssapi_have_feature,
- .enabled = True,
- .kerberos = True,
+ .enabled = true,
+ .kerberos = true,
.priority = GENSEC_GSSAPI
};
@@ -1453,8 +1456,8 @@ static const struct gensec_security_ops gensec_gssapi_sasl_krb5_security_ops = {
.wrap = gensec_gssapi_wrap,
.unwrap = gensec_gssapi_unwrap,
.have_feature = gensec_gssapi_have_feature,
- .enabled = True,
- .kerberos = True,
+ .enabled = true,
+ .kerberos = true,
.priority = GENSEC_GSSAPI
};
diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c
index 87ce571fc0..ca48e85089 100644
--- a/source4/auth/gensec/gensec_krb5.c
+++ b/source4/auth/gensec/gensec_krb5.c
@@ -36,6 +36,7 @@
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
enum GENSEC_KRB5_STATE {
GENSEC_KRB5_SERVER_START,
@@ -53,7 +54,7 @@ struct gensec_krb5_state {
krb5_data enc_ticket;
krb5_keyblock *keyblock;
krb5_ticket *ticket;
- BOOL gssapi;
+ bool gssapi;
};
static int gensec_krb5_destroy(struct gensec_krb5_state *gensec_krb5_state)
@@ -111,7 +112,7 @@ static NTSTATUS gensec_krb5_start(struct gensec_security *gensec_security)
gensec_krb5_state->keyblock = NULL;
gensec_krb5_state->session_key = data_blob(NULL, 0);
gensec_krb5_state->pac = data_blob(NULL, 0);
- gensec_krb5_state->gssapi = False;
+ gensec_krb5_state->gssapi = false;
talloc_set_destructor(gensec_krb5_state, gensec_krb5_destroy);
@@ -191,7 +192,7 @@ static NTSTATUS gensec_krb5_server_start(struct gensec_security *gensec_security
return nt_status;
}
- gensec_krb5_state = gensec_security->private_data;
+ gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
gensec_krb5_state->state_position = GENSEC_KRB5_SERVER_START;
return NT_STATUS_OK;
@@ -203,8 +204,8 @@ static NTSTATUS gensec_fake_gssapi_krb5_server_start(struct gensec_security *gen
if (NT_STATUS_IS_OK(nt_status)) {
struct gensec_krb5_state *gensec_krb5_state;
- gensec_krb5_state = gensec_security->private_data;
- gensec_krb5_state->gssapi = True;
+ gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
+ gensec_krb5_state->gssapi = true;
}
return nt_status;
}
@@ -240,7 +241,7 @@ static NTSTATUS gensec_krb5_client_start(struct gensec_security *gensec_security
return nt_status;
}
- gensec_krb5_state = gensec_security->private_data;
+ gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
gensec_krb5_state->state_position = GENSEC_KRB5_CLIENT_START;
principal = gensec_get_target_principal(gensec_security);
@@ -260,7 +261,7 @@ static NTSTATUS gensec_krb5_client_start(struct gensec_security *gensec_security
}
in_data.length = 0;
- if (principal && lp_client_use_spnego_principal()) {
+ if (principal && lp_client_use_spnego_principal(global_loadparm)) {
krb5_principal target_principal;
ret = krb5_parse_name(gensec_krb5_state->smb_krb5_context->krb5_context, principal,
&target_principal);
@@ -327,8 +328,8 @@ static NTSTATUS gensec_fake_gssapi_krb5_client_start(struct gensec_security *gen
if (NT_STATUS_IS_OK(nt_status)) {
struct gensec_krb5_state *gensec_krb5_state;
- gensec_krb5_state = gensec_security->private_data;
- gensec_krb5_state->gssapi = True;
+ gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
+ gensec_krb5_state->gssapi = true;
}
return nt_status;
}
@@ -368,7 +369,7 @@ static NTSTATUS gensec_krb5_update(struct gensec_security *gensec_security,
TALLOC_CTX *out_mem_ctx,
const DATA_BLOB in, DATA_BLOB *out)
{
- struct gensec_krb5_state *gensec_krb5_state = gensec_security->private_data;
+ struct gensec_krb5_state *gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
krb5_error_code ret = 0;
NTSTATUS nt_status;
@@ -416,7 +417,7 @@ static NTSTATUS gensec_krb5_update(struct gensec_security *gensec_security,
if (ret) {
DEBUG(1,("krb5_rd_rep (mutual authentication) failed (%s)\n",
smb_get_krb5_error_message(gensec_krb5_state->smb_krb5_context->krb5_context, ret, out_mem_ctx)));
- dump_data_pw("Mutual authentication message:\n", inbuf.data, inbuf.length);
+ dump_data_pw("Mutual authentication message:\n", (uint8_t *)inbuf.data, inbuf.length);
nt_status = NT_STATUS_ACCESS_DENIED;
} else {
*out = data_blob(NULL, 0);
@@ -477,7 +478,7 @@ static NTSTATUS gensec_krb5_update(struct gensec_security *gensec_security,
if (ret) {
return NT_STATUS_LOGON_FAILURE;
}
- unwrapped_out.data = outbuf.data;
+ unwrapped_out.data = (uint8_t *)outbuf.data;
unwrapped_out.length = outbuf.length;
gensec_krb5_state->state_position = GENSEC_KRB5_DONE;
/* wrap that up in a nice GSS-API wrapping */
@@ -500,7 +501,7 @@ static NTSTATUS gensec_krb5_update(struct gensec_security *gensec_security,
static NTSTATUS gensec_krb5_session_key(struct gensec_security *gensec_security,
DATA_BLOB *session_key)
{
- struct gensec_krb5_state *gensec_krb5_state = gensec_security->private_data;
+ struct gensec_krb5_state *gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
krb5_context context = gensec_krb5_state->smb_krb5_context->krb5_context;
krb5_auth_context auth_context = gensec_krb5_state->auth_context;
krb5_keyblock *skey;
@@ -539,7 +540,7 @@ static NTSTATUS gensec_krb5_session_info(struct gensec_security *gensec_security
struct auth_session_info **_session_info)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- struct gensec_krb5_state *gensec_krb5_state = gensec_security->private_data;
+ struct gensec_krb5_state *gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
krb5_context context = gensec_krb5_state->smb_krb5_context->krb5_context;
struct auth_serversupplied_info *server_info = NULL;
struct auth_session_info *session_info = NULL;
@@ -581,7 +582,7 @@ static NTSTATUS gensec_krb5_session_info(struct gensec_security *gensec_security
KRB5_AUTHDATA_WIN2K_PAC,
&pac_data);
- if (ret && lp_parm_bool(-1, "gensec", "require_pac", False)) {
+ if (ret && lp_parm_bool(global_loadparm, NULL, "gensec", "require_pac", false)) {
DEBUG(1, ("Unable to find PAC in ticket from %s, failing to allow access: %s \n",
principal_string,
smb_get_krb5_error_message(context,
@@ -666,7 +667,7 @@ static NTSTATUS gensec_krb5_wrap(struct gensec_security *gensec_security,
const DATA_BLOB *in,
DATA_BLOB *out)
{
- struct gensec_krb5_state *gensec_krb5_state = gensec_security->private_data;
+ struct gensec_krb5_state *gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
krb5_context context = gensec_krb5_state->smb_krb5_context->krb5_context;
krb5_auth_context auth_context = gensec_krb5_state->auth_context;
krb5_error_code ret;
@@ -696,7 +697,7 @@ static NTSTATUS gensec_krb5_unwrap(struct gensec_security *gensec_security,
const DATA_BLOB *in,
DATA_BLOB *out)
{
- struct gensec_krb5_state *gensec_krb5_state = gensec_security->private_data;
+ struct gensec_krb5_state *gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
krb5_context context = gensec_krb5_state->smb_krb5_context->krb5_context;
krb5_auth_context auth_context = gensec_krb5_state->auth_context;
krb5_error_code ret;
@@ -722,19 +723,19 @@ static NTSTATUS gensec_krb5_unwrap(struct gensec_security *gensec_security,
return NT_STATUS_OK;
}
-static BOOL gensec_krb5_have_feature(struct gensec_security *gensec_security,
+static bool gensec_krb5_have_feature(struct gensec_security *gensec_security,
uint32_t feature)
{
- struct gensec_krb5_state *gensec_krb5_state = gensec_security->private_data;
+ struct gensec_krb5_state *gensec_krb5_state = (struct gensec_krb5_state *)gensec_security->private_data;
if (feature & GENSEC_FEATURE_SESSION_KEY) {
- return True;
+ return true;
}
if (!gensec_krb5_state->gssapi &&
(feature & GENSEC_FEATURE_SEAL)) {
- return True;
+ return true;
}
- return False;
+ return false;
}
static const char *gensec_krb5_oids[] = {
@@ -754,8 +755,8 @@ static const struct gensec_security_ops gensec_fake_gssapi_krb5_security_ops = {
.session_key = gensec_krb5_session_key,
.session_info = gensec_krb5_session_info,
.have_feature = gensec_krb5_have_feature,
- .enabled = False,
- .kerberos = True,
+ .enabled = false,
+ .kerberos = true,
.priority = GENSEC_KRB5
};
@@ -769,8 +770,8 @@ static const struct gensec_security_ops gensec_krb5_security_ops = {
.have_feature = gensec_krb5_have_feature,
.wrap = gensec_krb5_wrap,
.unwrap = gensec_krb5_unwrap,
- .enabled = True,
- .kerberos = True,
+ .enabled = true,
+ .kerberos = true,
.priority = GENSEC_KRB5
};
diff --git a/source4/auth/gensec/schannel.c b/source4/auth/gensec/schannel.c
index 5dc5c287ec..4d2c9cfee3 100644
--- a/source4/auth/gensec/schannel.c
+++ b/source4/auth/gensec/schannel.c
@@ -44,7 +44,7 @@ static NTSTATUS schannel_session_key(struct gensec_security *gensec_security,
static NTSTATUS schannel_update(struct gensec_security *gensec_security, TALLOC_CTX *out_mem_ctx,
const DATA_BLOB in, DATA_BLOB *out)
{
- struct schannel_state *state = gensec_security->private_data;
+ struct schannel_state *state = (struct schannel_state *)gensec_security->private_data;
NTSTATUS status;
struct schannel_bind bind_schannel;
struct schannel_bind_ack bind_schannel_ack;
@@ -207,8 +207,8 @@ static NTSTATUS schannel_server_start(struct gensec_security *gensec_security)
return status;
}
- state = gensec_security->private_data;
- state->initiator = False;
+ state = (struct schannel_state *)gensec_security->private_data;
+ state->initiator = false;
return NT_STATUS_OK;
}
@@ -223,27 +223,27 @@ static NTSTATUS schannel_client_start(struct gensec_security *gensec_security)
return status;
}
- state = gensec_security->private_data;
- state->initiator = True;
+ state = (struct schannel_state *)gensec_security->private_data;
+ state->initiator = true;
return NT_STATUS_OK;
}
-static BOOL schannel_have_feature(struct gensec_security *gensec_security,
+static bool schannel_have_feature(struct gensec_security *gensec_security,
uint32_t feature)
{
if (feature & (GENSEC_FEATURE_SIGN |
GENSEC_FEATURE_SEAL)) {
- return True;
+ return true;
}
if (feature & GENSEC_FEATURE_DCE_STYLE) {
- return True;
+ return true;
}
if (feature & GENSEC_FEATURE_ASYNC_REPLIES) {
- return True;
+ return true;
}
- return False;
+ return false;
}
@@ -261,7 +261,7 @@ static const struct gensec_security_ops gensec_schannel_security_ops = {
.session_info = schannel_session_info,
.sig_size = schannel_sig_size,
.have_feature = schannel_have_feature,
- .enabled = True,
+ .enabled = true,
.priority = GENSEC_SCHANNEL
};
diff --git a/source4/auth/gensec/schannel_sign.c b/source4/auth/gensec/schannel_sign.c
index 43de328c9e..1e57beba08 100644
--- a/source4/auth/gensec/schannel_sign.c
+++ b/source4/auth/gensec/schannel_sign.c
@@ -26,6 +26,7 @@
#include "auth/gensec/schannel.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
+#include "auth/gensec/schannel_proto.h"
#define NETSEC_SIGN_SIGNATURE { 0x77, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 }
#define NETSEC_SEAL_SIGNATURE { 0x77, 0x00, 0x7a, 0x00, 0xff, 0xff, 0x00, 0x00 }
diff --git a/source4/auth/gensec/schannel_state.c b/source4/auth/gensec/schannel_state.c
index a911ed9288..808240c4f4 100644
--- a/source4/auth/gensec/schannel_state.c
+++ b/source4/auth/gensec/schannel_state.c
@@ -26,6 +26,7 @@
#include "db_wrap.h"
#include "libcli/auth/libcli_auth.h"
#include "auth/auth.h"
+#include "param/param.h"
/**
connect to the schannel ldb
@@ -34,20 +35,21 @@ struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx)
{
char *path;
struct ldb_context *ldb;
- BOOL existed;
+ bool existed;
const char *init_ldif =
"dn: @ATTRIBUTES\n" \
"computerName: CASE_INSENSITIVE\n" \
"flatname: CASE_INSENSITIVE\n";
- path = smbd_tmp_path(mem_ctx, "schannel.ldb");
+ path = smbd_tmp_path(mem_ctx, global_loadparm, "schannel.ldb");
if (!path) {
return NULL;
}
existed = file_exist(path);
- ldb = ldb_wrap_connect(mem_ctx, path, system_session(mem_ctx),
+ ldb = ldb_wrap_connect(mem_ctx, global_loadparm, path,
+ system_session(mem_ctx),
NULL, LDB_FLG_NOSYNC, NULL);
talloc_free(path);
if (!ldb) {
diff --git a/source4/auth/gensec/socket.c b/source4/auth/gensec/socket.c
index 9bd97109fb..4dc05e8cc4 100644
--- a/source4/auth/gensec/socket.c
+++ b/source4/auth/gensec/socket.c
@@ -34,13 +34,13 @@ struct gensec_socket {
struct packet_context *packet;
DATA_BLOB read_buffer; /* SASL packets are turned into liniarlised data here, for reading */
size_t orig_send_len;
- BOOL eof;
+ bool eof;
NTSTATUS error;
- BOOL interrupted;
+ bool interrupted;
void (*recv_handler)(void *, uint16_t);
void *recv_private;
int in_extra_read;
- BOOL wrap; /* Should we be wrapping on this socket at all? */
+ bool wrap; /* Should we be wrapping on this socket at all? */
};
static NTSTATUS gensec_socket_init_fn(struct socket_context *sock)
@@ -190,7 +190,7 @@ static void gensec_socket_error_handler(void *private, NTSTATUS status)
{
struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket);
if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
- gensec_socket->eof = True;
+ gensec_socket->eof = true;
} else {
gensec_socket->error = status;
}
@@ -331,7 +331,7 @@ static NTSTATUS gensec_socket_unwrap(void *private, DATA_BLOB blob)
static void send_callback(void *private)
{
struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket);
- gensec_socket->interrupted = False;
+ gensec_socket->interrupted = false;
}
/*
@@ -384,7 +384,7 @@ static NTSTATUS gensec_socket_send(struct socket_context *sock,
return nt_status;
}
- gensec_socket->interrupted = True;
+ gensec_socket->interrupted = true;
gensec_socket->error = NT_STATUS_OK;
nt_status = packet_send_callback(gensec_socket->packet,
@@ -446,17 +446,17 @@ NTSTATUS gensec_socket_init(struct gensec_security *gensec_security,
if (!gensec_have_feature(gensec_security, GENSEC_FEATURE_SEAL) &&
!gensec_have_feature(gensec_security, GENSEC_FEATURE_SIGN)) {
- gensec_socket->wrap = False;
+ gensec_socket->wrap = false;
*new_socket = new_sock;
return NT_STATUS_OK;
}
gensec_socket->gensec_security = gensec_security;
- gensec_socket->wrap = True;
- gensec_socket->eof = False;
+ gensec_socket->wrap = true;
+ gensec_socket->eof = false;
gensec_socket->error = NT_STATUS_OK;
- gensec_socket->interrupted = False;
+ gensec_socket->interrupted = false;
gensec_socket->in_extra_read = 0;
gensec_socket->read_buffer = data_blob(NULL, 0);
diff --git a/source4/auth/gensec/spnego.c b/source4/auth/gensec/spnego.c
index 88521b912c..5c1c15935f 100644
--- a/source4/auth/gensec/spnego.c
+++ b/source4/auth/gensec/spnego.c
@@ -41,7 +41,7 @@ struct spnego_state {
enum spnego_message_type expected_packet;
enum spnego_state_position state_position;
struct gensec_security *sub_sec_security;
- BOOL no_response_expected;
+ bool no_response_expected;
const char *neg_oid;
};
@@ -59,7 +59,7 @@ static NTSTATUS gensec_spnego_client_start(struct gensec_security *gensec_securi
spnego_state->expected_packet = SPNEGO_NEG_TOKEN_INIT;
spnego_state->state_position = SPNEGO_CLIENT_START;
spnego_state->sub_sec_security = NULL;
- spnego_state->no_response_expected = False;
+ spnego_state->no_response_expected = false;
gensec_security->private_data = spnego_state;
return NT_STATUS_OK;
@@ -77,7 +77,7 @@ static NTSTATUS gensec_spnego_server_start(struct gensec_security *gensec_securi
spnego_state->expected_packet = SPNEGO_NEG_TOKEN_INIT;
spnego_state->state_position = SPNEGO_SERVER_START;
spnego_state->sub_sec_security = NULL;
- spnego_state->no_response_expected = False;
+ spnego_state->no_response_expected = false;
gensec_security->private_data = spnego_state;
return NT_STATUS_OK;
@@ -92,7 +92,7 @@ static NTSTATUS gensec_spnego_unseal_packet(struct gensec_security *gensec_secur
const uint8_t *whole_pdu, size_t pdu_length,
const DATA_BLOB *sig)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -112,7 +112,7 @@ static NTSTATUS gensec_spnego_check_packet(struct gensec_security *gensec_securi
const uint8_t *whole_pdu, size_t pdu_length,
const DATA_BLOB *sig)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -132,7 +132,7 @@ static NTSTATUS gensec_spnego_seal_packet(struct gensec_security *gensec_securit
const uint8_t *whole_pdu, size_t pdu_length,
DATA_BLOB *sig)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -152,7 +152,7 @@ static NTSTATUS gensec_spnego_sign_packet(struct gensec_security *gensec_securit
const uint8_t *whole_pdu, size_t pdu_length,
DATA_BLOB *sig)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -171,7 +171,7 @@ static NTSTATUS gensec_spnego_wrap(struct gensec_security *gensec_security,
const DATA_BLOB *in,
DATA_BLOB *out)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -188,7 +188,7 @@ static NTSTATUS gensec_spnego_unwrap(struct gensec_security *gensec_security,
const DATA_BLOB *in,
DATA_BLOB *out)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -206,7 +206,7 @@ static NTSTATUS gensec_spnego_wrap_packets(struct gensec_security *gensec_securi
DATA_BLOB *out,
size_t *len_processed)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -222,7 +222,7 @@ static NTSTATUS gensec_spnego_wrap_packets(struct gensec_security *gensec_securi
static NTSTATUS gensec_spnego_packet_full_request(struct gensec_security *gensec_security,
DATA_BLOB blob, size_t *size)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -240,7 +240,7 @@ static NTSTATUS gensec_spnego_unwrap_packets(struct gensec_security *gensec_secu
DATA_BLOB *out,
size_t *len_processed)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -255,7 +255,7 @@ static NTSTATUS gensec_spnego_unwrap_packets(struct gensec_security *gensec_secu
static size_t gensec_spnego_sig_size(struct gensec_security *gensec_security, size_t data_size)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -267,7 +267,7 @@ static size_t gensec_spnego_sig_size(struct gensec_security *gensec_security, si
static size_t gensec_spnego_max_input_size(struct gensec_security *gensec_security)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -279,7 +279,7 @@ static size_t gensec_spnego_max_input_size(struct gensec_security *gensec_securi
static size_t gensec_spnego_max_wrapped_size(struct gensec_security *gensec_security)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (spnego_state->state_position != SPNEGO_DONE
&& spnego_state->state_position != SPNEGO_FALLBACK) {
@@ -292,7 +292,7 @@ static size_t gensec_spnego_max_wrapped_size(struct gensec_security *gensec_secu
static NTSTATUS gensec_spnego_session_key(struct gensec_security *gensec_security,
DATA_BLOB *session_key)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (!spnego_state->sub_sec_security) {
return NT_STATUS_INVALID_PARAMETER;
}
@@ -304,7 +304,7 @@ static NTSTATUS gensec_spnego_session_key(struct gensec_security *gensec_securit
static NTSTATUS gensec_spnego_session_info(struct gensec_security *gensec_security,
struct auth_session_info **session_info)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (!spnego_state->sub_sec_security) {
return NT_STATUS_INVALID_PARAMETER;
}
@@ -329,16 +329,16 @@ static NTSTATUS gensec_spnego_server_try_fallback(struct gensec_security *gensec
struct gensec_security_ops **all_ops
= gensec_security_mechs(gensec_security, out_mem_ctx);
for (i=0; all_ops[i]; i++) {
- BOOL is_spnego;
+ bool is_spnego;
NTSTATUS nt_status;
if (!all_ops[i]->oid) {
continue;
}
- is_spnego = False;
+ is_spnego = false;
for (j=0; all_ops[i]->oid[j]; j++) {
if (strcasecmp(GENSEC_OID_SPNEGO,all_ops[i]->oid[j]) == 0) {
- is_spnego = True;
+ is_spnego = true;
}
}
if (is_spnego) {
@@ -622,7 +622,7 @@ static NTSTATUS gensec_spnego_create_negTokenInit(struct gensec_security *gensec
spnego_state->neg_oid = all_sec[i].oid;
if (NT_STATUS_IS_OK(nt_status)) {
- spnego_state->no_response_expected = True;
+ spnego_state->no_response_expected = true;
}
return NT_STATUS_MORE_PROCESSING_REQUIRED;
@@ -685,7 +685,7 @@ static NTSTATUS gensec_spnego_server_negTokenTarg(struct gensec_security *gensec
static NTSTATUS gensec_spnego_update(struct gensec_security *gensec_security, TALLOC_CTX *out_mem_ctx,
const DATA_BLOB in, DATA_BLOB *out)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
DATA_BLOB null_data_blob = data_blob(NULL, 0);
DATA_BLOB unwrapped_out = data_blob(NULL, 0);
struct spnego_data spnego_out;
@@ -820,7 +820,7 @@ static NTSTATUS gensec_spnego_update(struct gensec_security *gensec_security, TA
spnego_state->state_position = SPNEGO_CLIENT_TARG;
if (NT_STATUS_IS_OK(nt_status)) {
- spnego_state->no_response_expected = True;
+ spnego_state->no_response_expected = true;
}
spnego_free_data(&spnego);
@@ -947,7 +947,7 @@ static NTSTATUS gensec_spnego_update(struct gensec_security *gensec_security, TA
&unwrapped_out);
if (NT_STATUS_IS_OK(nt_status)) {
- spnego_state->no_response_expected = True;
+ spnego_state->no_response_expected = true;
}
}
@@ -999,12 +999,12 @@ static NTSTATUS gensec_spnego_update(struct gensec_security *gensec_security, TA
return NT_STATUS_INVALID_PARAMETER;
}
-static BOOL gensec_spnego_have_feature(struct gensec_security *gensec_security,
+static bool gensec_spnego_have_feature(struct gensec_security *gensec_security,
uint32_t feature)
{
- struct spnego_state *spnego_state = gensec_security->private_data;
+ struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
if (!spnego_state->sub_sec_security) {
- return False;
+ return false;
}
return gensec_have_feature(spnego_state->sub_sec_security,
@@ -1039,7 +1039,7 @@ static const struct gensec_security_ops gensec_spnego_security_ops = {
.session_key = gensec_spnego_session_key,
.session_info = gensec_spnego_session_info,
.have_feature = gensec_spnego_have_feature,
- .enabled = True,
+ .enabled = true,
.priority = GENSEC_SPNEGO
};
diff --git a/source4/auth/gensec/spnego_parse.c b/source4/auth/gensec/spnego_parse.c
index bb674a7aad..37f4f12278 100644
--- a/source4/auth/gensec/spnego_parse.c
+++ b/source4/auth/gensec/spnego_parse.c
@@ -25,7 +25,7 @@
#include "auth/gensec/gensec.h"
#include "libcli/util/asn_1.h"
-static BOOL read_negTokenInit(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
+static bool read_negTokenInit(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
struct spnego_negTokenInit *token)
{
ZERO_STRUCTP(token);
@@ -37,7 +37,7 @@ static BOOL read_negTokenInit(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
int i;
uint8_t context;
if (!asn1_peek_uint8(asn1, &context)) {
- asn1->has_error = True;
+ asn1->has_error = true;
break;
}
@@ -79,7 +79,7 @@ static BOOL read_negTokenInit(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
uint8_t type_peek;
asn1_start_tag(asn1, ASN1_CONTEXT(3));
if (!asn1_peek_uint8(asn1, &type_peek)) {
- asn1->has_error = True;
+ asn1->has_error = true;
break;
}
if (type_peek == ASN1_OCTET_STRING) {
@@ -101,7 +101,7 @@ static BOOL read_negTokenInit(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
break;
}
default:
- asn1->has_error = True;
+ asn1->has_error = true;
break;
}
}
@@ -112,7 +112,7 @@ static BOOL read_negTokenInit(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
return !asn1->has_error;
}
-static BOOL write_negTokenInit(struct asn1_data *asn1, struct spnego_negTokenInit *token)
+static bool write_negTokenInit(struct asn1_data *asn1, struct spnego_negTokenInit *token)
{
asn1_push_tag(asn1, ASN1_CONTEXT(0));
asn1_push_tag(asn1, ASN1_SEQUENCE(0));
@@ -175,7 +175,7 @@ static BOOL write_negTokenInit(struct asn1_data *asn1, struct spnego_negTokenIni
return !asn1->has_error;
}
-static BOOL read_negTokenTarg(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
+static bool read_negTokenTarg(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
struct spnego_negTokenTarg *token)
{
ZERO_STRUCTP(token);
@@ -186,7 +186,7 @@ static BOOL read_negTokenTarg(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
while (!asn1->has_error && 0 < asn1_tag_remaining(asn1)) {
uint8_t context;
if (!asn1_peek_uint8(asn1, &context)) {
- asn1->has_error = True;
+ asn1->has_error = true;
break;
}
@@ -214,7 +214,7 @@ static BOOL read_negTokenTarg(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
asn1_end_tag(asn1);
break;
default:
- asn1->has_error = True;
+ asn1->has_error = true;
break;
}
}
@@ -225,7 +225,7 @@ static BOOL read_negTokenTarg(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
return !asn1->has_error;
}
-static BOOL write_negTokenTarg(struct asn1_data *asn1, struct spnego_negTokenTarg *token)
+static bool write_negTokenTarg(struct asn1_data *asn1, struct spnego_negTokenTarg *token)
{
asn1_push_tag(asn1, ASN1_CONTEXT(1));
asn1_push_tag(asn1, ASN1_SEQUENCE(0));
@@ -282,7 +282,7 @@ ssize_t spnego_read_data(TALLOC_CTX *mem_ctx, DATA_BLOB data, struct spnego_data
asn1_load(asn1, data);
if (!asn1_peek_uint8(asn1, &context)) {
- asn1->has_error = True;
+ asn1->has_error = true;
} else {
switch (context) {
case ASN1_APPLICATION(0):
@@ -299,7 +299,7 @@ ssize_t spnego_read_data(TALLOC_CTX *mem_ctx, DATA_BLOB data, struct spnego_data
}
break;
default:
- asn1->has_error = True;
+ asn1->has_error = true;
break;
}
}
@@ -330,7 +330,7 @@ ssize_t spnego_write_data(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct spnego_da
write_negTokenTarg(asn1, &spnego->negTokenTarg);
break;
default:
- asn1->has_error = True;
+ asn1->has_error = true;
break;
}
@@ -343,9 +343,9 @@ ssize_t spnego_write_data(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct spnego_da
return ret;
}
-BOOL spnego_free_data(struct spnego_data *spnego)
+bool spnego_free_data(struct spnego_data *spnego)
{
- BOOL ret = True;
+ bool ret = true;
if (!spnego) goto out;
@@ -366,7 +366,7 @@ BOOL spnego_free_data(struct spnego_data *spnego)
data_blob_free(&spnego->negTokenTarg.mechListMIC);
break;
default:
- ret = False;
+ ret = false;
break;
}
ZERO_STRUCTP(spnego);
diff --git a/source4/auth/kerberos/config.mk b/source4/auth/kerberos/config.mk
index f75fd99323..87c62fb6ed 100644
--- a/source4/auth/kerberos/config.mk
+++ b/source4/auth/kerberos/config.mk
@@ -10,6 +10,6 @@ OBJ_FILES = kerberos.o \
gssapi_parse.o \
krb5_init_context.o
PUBLIC_DEPENDENCIES = HEIMDAL_KRB5 NDR_KRB5PAC samba-socket LIBCLI_RESOLVE
-PRIVATE_DEPENDENCIES = ASN1_UTIL HEIMDAL_ROKEN_ADDRINFO auth_sam CREDENTIALS_KRB5
+PRIVATE_DEPENDENCIES = ASN1_UTIL auth_sam CREDENTIALS_KRB5
# End SUBSYSTEM KERBEROS
#################################
diff --git a/source4/auth/kerberos/gssapi_parse.c b/source4/auth/kerberos/gssapi_parse.c
index 27c96770a6..4b1b178238 100644
--- a/source4/auth/kerberos/gssapi_parse.c
+++ b/source4/auth/kerberos/gssapi_parse.c
@@ -64,14 +64,14 @@ DATA_BLOB gensec_gssapi_gen_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *tick
/*
parse a krb5 GSS-API wrapper packet giving a ticket
*/
-BOOL gensec_gssapi_parse_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, DATA_BLOB *ticket, uint8_t tok_id[2])
+bool gensec_gssapi_parse_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, DATA_BLOB *ticket, uint8_t tok_id[2])
{
- BOOL ret;
+ bool ret;
struct asn1_data *data = asn1_init(mem_ctx);
int data_remaining;
if (!data) {
- return False;
+ return false;
}
asn1_load(data, *blob);
@@ -81,7 +81,7 @@ BOOL gensec_gssapi_parse_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, D
data_remaining = asn1_tag_remaining(data);
if (data_remaining < 3) {
- data->has_error = True;
+ data->has_error = true;
} else {
asn1_read(data, tok_id, 2);
data_remaining -= 2;
@@ -102,12 +102,12 @@ BOOL gensec_gssapi_parse_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, D
/*
check a GSS-API wrapper packet givin an expected OID
*/
-BOOL gensec_gssapi_check_oid(const DATA_BLOB *blob, const char *oid)
+bool gensec_gssapi_check_oid(const DATA_BLOB *blob, const char *oid)
{
- BOOL ret;
+ bool ret;
struct asn1_data *data = asn1_init(NULL);
- if (!data) return False;
+ if (!data) return false;
asn1_load(data, *blob);
asn1_start_tag(data, ASN1_APPLICATION(0));
diff --git a/source4/auth/kerberos/kerberos_util.c b/source4/auth/kerberos/kerberos_util.c
index 918c28cf33..70e2961d55 100644
--- a/source4/auth/kerberos/kerberos_util.c
+++ b/source4/auth/kerberos/kerberos_util.c
@@ -343,7 +343,7 @@ static int create_keytab(TALLOC_CTX *parent_ctx,
struct smb_krb5_context *smb_krb5_context,
const char **enctype_strings,
krb5_keytab keytab,
- BOOL add_old)
+ bool add_old)
{
krb5_error_code ret;
const char *password_s;
@@ -484,7 +484,7 @@ static int create_keytab(TALLOC_CTX *parent_ctx,
static krb5_error_code remove_old_entries(TALLOC_CTX *parent_ctx,
struct cli_credentials *machine_account,
struct smb_krb5_context *smb_krb5_context,
- krb5_keytab keytab, BOOL *found_previous)
+ krb5_keytab keytab, bool *found_previous)
{
krb5_error_code ret, ret2;
krb5_kt_cursor cursor;
@@ -496,7 +496,7 @@ static krb5_error_code remove_old_entries(TALLOC_CTX *parent_ctx,
return ENOMEM;
}
- *found_previous = False;
+ *found_previous = false;
princ_string = cli_credentials_get_principal(machine_account, mem_ctx);
/* Get the principal we will store the new keytab entries under */
@@ -575,7 +575,7 @@ static krb5_error_code remove_old_entries(TALLOC_CTX *parent_ctx,
}
} else {
- *found_previous = True;
+ *found_previous = true;
}
/* Free the entry, we don't need it any more */
@@ -609,7 +609,7 @@ int smb_krb5_update_keytab(TALLOC_CTX *parent_ctx,
struct keytab_container *keytab_container)
{
krb5_error_code ret;
- BOOL found_previous;
+ bool found_previous;
TALLOC_CTX *mem_ctx = talloc_new(parent_ctx);
if (!mem_ctx) {
return ENOMEM;
@@ -629,7 +629,7 @@ int smb_krb5_update_keytab(TALLOC_CTX *parent_ctx,
ret = create_keytab(mem_ctx, machine_account, smb_krb5_context,
enctype_strings,
keytab_container->keytab,
- found_previous ? False : True);
+ found_previous ? false : true);
talloc_free(mem_ctx);
return ret;
}
diff --git a/source4/auth/kerberos/krb5_init_context.c b/source4/auth/kerberos/krb5_init_context.c
index c11d93f44a..68e60dcdc5 100644
--- a/source4/auth/kerberos/krb5_init_context.c
+++ b/source4/auth/kerberos/krb5_init_context.c
@@ -29,6 +29,7 @@
#include "system/network.h"
#include "lib/events/events.h"
#include "roken.h"
+#include "param/param.h"
/*
context structure for operations on cldap packets
@@ -249,12 +250,12 @@ krb5_error_code smb_krb5_send_and_recv_func(krb5_context context,
status = NT_STATUS_INVALID_PARAMETER;
switch (hi->proto) {
case KRB5_KRBHST_UDP:
- if (lp_parm_bool(-1, "krb5", "udp", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "krb5", "udp", true)) {
status = socket_create(name, SOCKET_TYPE_DGRAM, &smb_krb5->sock, 0);
}
break;
case KRB5_KRBHST_TCP:
- if (lp_parm_bool(-1, "krb5", "tcp", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "krb5", "tcp", true)) {
status = socket_create(name, SOCKET_TYPE_STREAM, &smb_krb5->sock, 0);
}
break;
@@ -392,7 +393,7 @@ krb5_error_code smb_krb5_init_context(void *parent_ctx,
talloc_set_destructor(*smb_krb5_context, smb_krb5_context_destroy_1);
- config_file = config_path(tmp_ctx, "krb5.conf");
+ config_file = config_path(tmp_ctx, global_loadparm, "krb5.conf");
if (!config_file) {
talloc_free(tmp_ctx);
return ENOMEM;
@@ -417,10 +418,10 @@ krb5_error_code smb_krb5_init_context(void *parent_ctx,
return ret;
}
- if (lp_realm() && *lp_realm()) {
- char *upper_realm = strupper_talloc(tmp_ctx, lp_realm());
+ if (lp_realm(global_loadparm) && *lp_realm(global_loadparm)) {
+ char *upper_realm = strupper_talloc(tmp_ctx, lp_realm(global_loadparm));
if (!upper_realm) {
- DEBUG(1,("gensec_krb5_start: could not uppercase realm: %s\n", lp_realm()));
+ DEBUG(1,("gensec_krb5_start: could not uppercase realm: %s\n", lp_realm(global_loadparm)));
talloc_free(tmp_ctx);
return ENOMEM;
}
@@ -472,7 +473,7 @@ krb5_error_code smb_krb5_init_context(void *parent_ctx,
/* Set options in kerberos */
krb5_set_dns_canonicalize_hostname((*smb_krb5_context)->krb5_context,
- lp_parm_bool(-1, "krb5", "set_dns_canonicalize", false));
+ lp_parm_bool(global_loadparm, NULL, "krb5", "set_dns_canonicalize", false));
return 0;
}
diff --git a/source4/auth/ntlm_check.c b/source4/auth/ntlm_check.c
index 5c5ad1f3ca..5214c46e0e 100644
--- a/source4/auth/ntlm_check.c
+++ b/source4/auth/ntlm_check.c
@@ -23,12 +23,13 @@
#include "lib/crypto/crypto.h"
#include "librpc/gen_ndr/netlogon.h"
#include "libcli/auth/libcli_auth.h"
+#include "param/param.h"
/****************************************************************************
Core of smb password checking routine.
****************************************************************************/
-static BOOL smb_pwd_check_ntlmv1(TALLOC_CTX *mem_ctx,
+static bool smb_pwd_check_ntlmv1(TALLOC_CTX *mem_ctx,
const DATA_BLOB *nt_response,
const uint8_t *part_passwd,
const DATA_BLOB *sec_blob,
@@ -40,19 +41,19 @@ static BOOL smb_pwd_check_ntlmv1(TALLOC_CTX *mem_ctx,
if (part_passwd == NULL) {
DEBUG(10,("No password set - DISALLOWING access\n"));
/* No password set - always false ! */
- return False;
+ return false;
}
if (sec_blob->length != 8) {
DEBUG(0, ("smb_pwd_check_ntlmv1: incorrect challenge size (%lu)\n",
(unsigned long)sec_blob->length));
- return False;
+ return false;
}
if (nt_response->length != 24) {
DEBUG(0, ("smb_pwd_check_ntlmv1: incorrect password length (%lu)\n",
(unsigned long)nt_response->length));
- return False;
+ return false;
}
SMBOWFencrypt(part_passwd, sec_blob->data, p24);
@@ -72,9 +73,9 @@ static BOOL smb_pwd_check_ntlmv1(TALLOC_CTX *mem_ctx,
*user_sess_key = data_blob_talloc(mem_ctx, NULL, 16);
SMBsesskeygen_ntv1(part_passwd, user_sess_key->data);
}
- return True;
+ return true;
}
- return False;
+ return false;
}
/****************************************************************************
@@ -82,12 +83,12 @@ static BOOL smb_pwd_check_ntlmv1(TALLOC_CTX *mem_ctx,
Note: The same code works with both NTLMv2 and LMv2.
****************************************************************************/
-static BOOL smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx,
+static bool smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx,
const DATA_BLOB *ntv2_response,
const uint8_t *part_passwd,
const DATA_BLOB *sec_blob,
const char *user, const char *domain,
- BOOL upper_case_domain, /* should the domain be transformed into upper case? */
+ bool upper_case_domain, /* should the domain be transformed into upper case? */
DATA_BLOB *user_sess_key)
{
/* Finish the encryption of part_passwd. */
@@ -97,14 +98,14 @@ static BOOL smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx,
if (part_passwd == NULL) {
DEBUG(10,("No password set - DISALLOWING access\n"));
- /* No password set - always False */
- return False;
+ /* No password set - always false */
+ return false;
}
if (sec_blob->length != 8) {
DEBUG(0, ("smb_pwd_check_ntlmv2: incorrect challenge size (%lu)\n",
(unsigned long)sec_blob->length));
- return False;
+ return false;
}
if (ntv2_response->length < 24) {
@@ -113,7 +114,7 @@ static BOOL smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx,
for LMv2, let alone NTLMv2. */
DEBUG(0, ("smb_pwd_check_ntlmv2: incorrect password length (%lu)\n",
(unsigned long)ntv2_response->length));
- return False;
+ return false;
}
client_key_data = data_blob_talloc(mem_ctx, ntv2_response->data+16, ntv2_response->length-16);
@@ -123,7 +124,7 @@ static BOOL smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx,
*/
if (!ntv2_owf_gen(part_passwd, user, domain, upper_case_domain, kr)) {
- return False;
+ return false;
}
SMBOWFencrypt_ntv2(kr, sec_blob, &client_key_data, value_from_encryption);
@@ -146,9 +147,9 @@ static BOOL smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx,
*user_sess_key = data_blob_talloc(mem_ctx, NULL, 16);
SMBsesskeygen_ntv2(kr, value_from_encryption, user_sess_key->data);
}
- return True;
+ return true;
}
- return False;
+ return false;
}
/****************************************************************************
@@ -156,12 +157,12 @@ static BOOL smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx,
Note: The same code works with both NTLMv2 and LMv2.
****************************************************************************/
-static BOOL smb_sess_key_ntlmv2(TALLOC_CTX *mem_ctx,
+static bool smb_sess_key_ntlmv2(TALLOC_CTX *mem_ctx,
const DATA_BLOB *ntv2_response,
const uint8_t *part_passwd,
const DATA_BLOB *sec_blob,
const char *user, const char *domain,
- BOOL upper_case_domain, /* should the domain be transformed into upper case? */
+ bool upper_case_domain, /* should the domain be transformed into upper case? */
DATA_BLOB *user_sess_key)
{
/* Finish the encryption of part_passwd. */
@@ -171,14 +172,14 @@ static BOOL smb_sess_key_ntlmv2(TALLOC_CTX *mem_ctx,
if (part_passwd == NULL) {
DEBUG(10,("No password set - DISALLOWING access\n"));
- /* No password set - always False */
- return False;
+ /* No password set - always false */
+ return false;
}
if (sec_blob->length != 8) {
DEBUG(0, ("smb_sess_key_ntlmv2: incorrect challenge size (%lu)\n",
(unsigned long)sec_blob->length));
- return False;
+ return false;
}
if (ntv2_response->length < 24) {
@@ -187,19 +188,19 @@ static BOOL smb_sess_key_ntlmv2(TALLOC_CTX *mem_ctx,
for LMv2, let alone NTLMv2. */
DEBUG(0, ("smb_sess_key_ntlmv2: incorrect password length (%lu)\n",
(unsigned long)ntv2_response->length));
- return False;
+ return false;
}
client_key_data = data_blob_talloc(mem_ctx, ntv2_response->data+16, ntv2_response->length-16);
if (!ntv2_owf_gen(part_passwd, user, domain, upper_case_domain, kr)) {
- return False;
+ return false;
}
SMBOWFencrypt_ntv2(kr, sec_blob, &client_key_data, value_from_encryption);
*user_sess_key = data_blob_talloc(mem_ctx, NULL, 16);
SMBsesskeygen_ntv2(kr, value_from_encryption, user_sess_key->data);
- return True;
+ return true;
}
/**
@@ -239,7 +240,7 @@ NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
}
} else if (client_lanman && stored_lanman) {
- if (!lp_lanman_auth()) {
+ if (!lp_lanman_auth(global_loadparm)) {
DEBUG(3,("ntlm_password_check: Interactive logon: only LANMAN password supplied for user %s, and LM passwords are disabled!\n",
username));
return NT_STATUS_WRONG_PASSWORD;
@@ -310,7 +311,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
struct samr_Password client_nt;
struct samr_Password client_lm;
char *unix_pw = NULL;
- BOOL lm_ok;
+ bool lm_ok;
DEBUG(4,("ntlm_password_check: checking plaintext passwords for user %s\n",
username));
@@ -321,12 +322,12 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
lm_response->data, lm_response->length,
(void **)&unix_pw) != -1)) {
if (E_deshash(unix_pw, client_lm.hash)) {
- lm_ok = True;
+ lm_ok = true;
} else {
- lm_ok = False;
+ lm_ok = false;
}
} else {
- lm_ok = False;
+ lm_ok = false;
}
return hash_password_check(mem_ctx,
lm_ok ? &client_lm : NULL,
@@ -350,7 +351,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
stored_nt->hash, challenge,
client_username,
client_domain,
- False,
+ false,
user_sess_key)) {
*lm_sess_key = *user_sess_key;
if (user_sess_key->length) {
@@ -365,7 +366,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
stored_nt->hash, challenge,
client_username,
client_domain,
- True,
+ true,
user_sess_key)) {
*lm_sess_key = *user_sess_key;
if (user_sess_key->length) {
@@ -380,7 +381,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
stored_nt->hash, challenge,
client_username,
"",
- False,
+ false,
user_sess_key)) {
*lm_sess_key = *user_sess_key;
if (user_sess_key->length) {
@@ -391,7 +392,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
DEBUG(3,("ntlm_password_check: NTLMv2 password check failed\n"));
}
} else if (nt_response->length == 24 && stored_nt) {
- if (lp_ntlm_auth()) {
+ if (lp_ntlm_auth(global_loadparm)) {
/* We have the NT MD4 hash challenge available - see if we can
use it (ie. does it exist in the smbpasswd file).
*/
@@ -403,7 +404,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
/* The LM session key for this response is not very secure,
so use it only if we otherwise allow LM authentication */
- if (lp_lanman_auth() && stored_lanman) {
+ if (lp_lanman_auth(global_loadparm) && stored_lanman) {
*lm_sess_key = data_blob_talloc(mem_ctx, stored_lanman->hash, 8);
}
return NT_STATUS_OK;
@@ -431,7 +432,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
return NT_STATUS_WRONG_PASSWORD;
}
- if (!lp_lanman_auth()) {
+ if (!lp_lanman_auth(global_loadparm)) {
DEBUG(3,("ntlm_password_check: Lanman passwords NOT PERMITTED for user %s\n",
username));
} else if (!stored_lanman) {
@@ -450,7 +451,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
It not very secure, so use it only if we otherwise
allow LM authentication */
- if (lp_lanman_auth() && stored_lanman) {
+ if (lp_lanman_auth(global_loadparm) && stored_lanman) {
uint8_t first_8_lm_hash[16];
memcpy(first_8_lm_hash, stored_lanman->hash, 8);
memset(first_8_lm_hash + 8, '\0', 8);
@@ -475,7 +476,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
stored_nt->hash, challenge,
client_username,
client_domain,
- False,
+ false,
&tmp_sess_key)) {
if (nt_response->length > 24) {
/* If NTLMv2 authentication has preceeded us
@@ -487,7 +488,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
stored_nt->hash, challenge,
client_username,
client_domain,
- False,
+ false,
user_sess_key);
} else {
/* Otherwise, use the LMv2 session key */
@@ -506,7 +507,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
stored_nt->hash, challenge,
client_username,
client_domain,
- True,
+ true,
&tmp_sess_key)) {
if (nt_response->length > 24) {
/* If NTLMv2 authentication has preceeded us
@@ -518,7 +519,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
stored_nt->hash, challenge,
client_username,
client_domain,
- True,
+ true,
user_sess_key);
} else {
/* Otherwise, use the LMv2 session key */
@@ -537,7 +538,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
stored_nt->hash, challenge,
client_username,
"",
- False,
+ false,
&tmp_sess_key)) {
if (nt_response->length > 24) {
/* If NTLMv2 authentication has preceeded us
@@ -549,7 +550,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
stored_nt->hash, challenge,
client_username,
"",
- False,
+ false,
user_sess_key);
} else {
/* Otherwise, use the LMv2 session key */
@@ -566,7 +567,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
- I think this is related to Win9X pass-though authentication
*/
DEBUG(4,("ntlm_password_check: Checking NT MD4 password in LM field\n"));
- if (lp_ntlm_auth()) {
+ if (lp_ntlm_auth(global_loadparm)) {
if (smb_pwd_check_ntlmv1(mem_ctx,
lm_response,
stored_nt->hash, challenge,
@@ -575,7 +576,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
It not very secure, so use it only if we otherwise
allow LM authentication */
- if (lp_lanman_auth() && stored_lanman) {
+ if (lp_lanman_auth(global_loadparm) && stored_lanman) {
uint8_t first_8_lm_hash[16];
memcpy(first_8_lm_hash, stored_lanman->hash, 8);
memset(first_8_lm_hash + 8, '\0', 8);
diff --git a/source4/auth/ntlmssp/ntlmssp.c b/source4/auth/ntlmssp/ntlmssp.c
index a2d2d22170..f957ac9dbd 100644
--- a/source4/auth/ntlmssp/ntlmssp.c
+++ b/source4/auth/ntlmssp/ntlmssp.c
@@ -199,7 +199,7 @@ static NTSTATUS gensec_ntlmssp_update(struct gensec_security *gensec_security,
TALLOC_CTX *out_mem_ctx,
const DATA_BLOB input, DATA_BLOB *out)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
NTSTATUS status;
uint32_t i;
@@ -229,7 +229,7 @@ static NTSTATUS gensec_ntlmssp_update(struct gensec_security *gensec_security,
NTSTATUS gensec_ntlmssp_session_key(struct gensec_security *gensec_security,
DATA_BLOB *session_key)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
if (!gensec_ntlmssp_state->session_key.data) {
return NT_STATUS_NO_USER_SESSION_KEY;
@@ -240,16 +240,16 @@ NTSTATUS gensec_ntlmssp_session_key(struct gensec_security *gensec_security,
}
void ntlmssp_handle_neg_flags(struct gensec_ntlmssp_state *gensec_ntlmssp_state,
- uint32_t neg_flags, BOOL allow_lm)
+ uint32_t neg_flags, bool allow_lm)
{
if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_UNICODE;
gensec_ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_OEM;
- gensec_ntlmssp_state->unicode = True;
+ gensec_ntlmssp_state->unicode = true;
} else {
gensec_ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_UNICODE;
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_OEM;
- gensec_ntlmssp_state->unicode = False;
+ gensec_ntlmssp_state->unicode = false;
}
if ((neg_flags & NTLMSSP_NEGOTIATE_LM_KEY) && allow_lm && !gensec_ntlmssp_state->use_ntlmv2) {
@@ -341,40 +341,40 @@ DATA_BLOB ntlmssp_weakend_key(struct gensec_ntlmssp_state *gensec_ntlmssp_state,
return weakened_key;
}
-static BOOL gensec_ntlmssp_have_feature(struct gensec_security *gensec_security,
+static bool gensec_ntlmssp_have_feature(struct gensec_security *gensec_security,
uint32_t feature)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
if (feature & GENSEC_FEATURE_SIGN) {
if (!gensec_ntlmssp_state->session_key.length) {
- return False;
+ return false;
}
if (gensec_ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN) {
- return True;
+ return true;
}
}
if (feature & GENSEC_FEATURE_SEAL) {
if (!gensec_ntlmssp_state->session_key.length) {
- return False;
+ return false;
}
if (gensec_ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL) {
- return True;
+ return true;
}
}
if (feature & GENSEC_FEATURE_SESSION_KEY) {
if (gensec_ntlmssp_state->session_key.length) {
- return True;
+ return true;
}
}
if (feature & GENSEC_FEATURE_DCE_STYLE) {
- return True;
+ return true;
}
if (feature & GENSEC_FEATURE_ASYNC_REPLIES) {
if (gensec_ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
- return True;
+ return true;
}
}
- return False;
+ return false;
}
NTSTATUS gensec_ntlmssp_start(struct gensec_security *gensec_security)
@@ -418,7 +418,7 @@ static const struct gensec_security_ops gensec_ntlmssp_security_ops = {
.session_key = gensec_ntlmssp_session_key,
.session_info = gensec_ntlmssp_session_info,
.have_feature = gensec_ntlmssp_have_feature,
- .enabled = True,
+ .enabled = true,
.priority = GENSEC_NTLMSSP
};
diff --git a/source4/auth/ntlmssp/ntlmssp.h b/source4/auth/ntlmssp/ntlmssp.h
index 282fcbc510..e39e2d9407 100644
--- a/source4/auth/ntlmssp/ntlmssp.h
+++ b/source4/auth/ntlmssp/ntlmssp.h
@@ -93,7 +93,7 @@ struct gensec_ntlmssp_state
style 'challenge caching' */
char *user;
- char *domain;
+ const char *domain;
const char *workstation;
char *server_domain;
@@ -156,7 +156,6 @@ struct gensec_ntlmssp_state
DATA_BLOB *nt_session_key, DATA_BLOB *lm_session_key);
const char *server_name;
- const char *(*get_domain)(void);
bool doing_ntlm2;
diff --git a/source4/auth/ntlmssp/ntlmssp_client.c b/source4/auth/ntlmssp/ntlmssp_client.c
index 3f507908f2..61d6f1b25f 100644
--- a/source4/auth/ntlmssp/ntlmssp_client.c
+++ b/source4/auth/ntlmssp/ntlmssp_client.c
@@ -28,6 +28,7 @@
#include "libcli/auth/libcli_auth.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
/*********************************************************************
Client side NTLMSSP
@@ -47,7 +48,7 @@ NTSTATUS ntlmssp_client_initial(struct gensec_security *gensec_security,
TALLOC_CTX *out_mem_ctx,
DATA_BLOB in, DATA_BLOB *out)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
if (gensec_ntlmssp_state->unicode) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_UNICODE;
@@ -65,7 +66,7 @@ NTSTATUS ntlmssp_client_initial(struct gensec_security *gensec_security,
"NTLMSSP",
NTLMSSP_NEGOTIATE,
gensec_ntlmssp_state->neg_flags,
- gensec_ntlmssp_state->get_domain(),
+ gensec_ntlmssp_state->domain,
cli_credentials_get_workstation(gensec_security->credentials));
gensec_ntlmssp_state->expected_state = NTLMSSP_CHALLENGE;
@@ -87,7 +88,7 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
TALLOC_CTX *out_mem_ctx,
const DATA_BLOB in, DATA_BLOB *out)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
uint32_t chal_flags, ntlmssp_command, unkn1, unkn2;
DATA_BLOB server_domain_blob;
DATA_BLOB challenge_blob;
@@ -180,7 +181,7 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
if (gensec_ntlmssp_state->use_nt_response) {
flags |= CLI_CRED_NTLM_AUTH;
}
- if (lp_client_lanman_auth()) {
+ if (lp_client_lanman_auth(global_loadparm)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
@@ -205,7 +206,7 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
}
if ((gensec_ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_LM_KEY)
- && lp_client_lanman_auth() && lm_session_key.length == 16) {
+ && lp_client_lanman_auth(global_loadparm) && lm_session_key.length == 16) {
DATA_BLOB new_session_key = data_blob_talloc(mem_ctx, NULL, 16);
if (lm_response.length == 24) {
SMBsesskeygen_lm_sess_key(lm_session_key.data, lm_response.data,
@@ -292,21 +293,21 @@ NTSTATUS gensec_ntlmssp_client_start(struct gensec_security *gensec_security)
nt_status = gensec_ntlmssp_start(gensec_security);
NT_STATUS_NOT_OK_RETURN(nt_status);
- gensec_ntlmssp_state = gensec_security->private_data;
+ gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
gensec_ntlmssp_state->role = NTLMSSP_CLIENT;
- gensec_ntlmssp_state->get_domain = lp_workgroup;
+ gensec_ntlmssp_state->domain = lp_workgroup(global_loadparm);
- gensec_ntlmssp_state->unicode = lp_parm_bool(-1, "ntlmssp_client", "unicode", True);
+ gensec_ntlmssp_state->unicode = lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "unicode", true);
- gensec_ntlmssp_state->use_nt_response = lp_parm_bool(-1, "ntlmssp_client", "send_nt_reponse", True);
+ gensec_ntlmssp_state->use_nt_response = lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "send_nt_reponse", true);
- gensec_ntlmssp_state->allow_lm_key = (lp_client_lanman_auth()
- && (lp_parm_bool(-1, "ntlmssp_client", "allow_lm_key", False)
- || lp_parm_bool(-1, "ntlmssp_client", "lm_key", False)));
+ gensec_ntlmssp_state->allow_lm_key = (lp_client_lanman_auth(global_loadparm)
+ && (lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "allow_lm_key", false)
+ || lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "lm_key", false)));
- gensec_ntlmssp_state->use_ntlmv2 = lp_client_ntlmv2_auth();
+ gensec_ntlmssp_state->use_ntlmv2 = lp_client_ntlmv2_auth(global_loadparm);
gensec_ntlmssp_state->expected_state = NTLMSSP_INITIAL;
@@ -314,31 +315,31 @@ NTSTATUS gensec_ntlmssp_client_start(struct gensec_security *gensec_security)
NTLMSSP_NEGOTIATE_NTLM |
NTLMSSP_REQUEST_TARGET;
- if (lp_parm_bool(-1, "ntlmssp_client", "128bit", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "128bit", true)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_128;
}
- if (lp_parm_bool(-1, "ntlmssp_client", "56bit", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "56bit", false)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_56;
}
- if (lp_parm_bool(-1, "ntlmssp_client", "lm_key", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "lm_key", false)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_LM_KEY;
}
- if (lp_parm_bool(-1, "ntlmssp_client", "keyexchange", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "keyexchange", true)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_KEY_EXCH;
}
- if (lp_parm_bool(-1, "ntlmssp_client", "alwayssign", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "alwayssign", true)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_ALWAYS_SIGN;
}
- if (lp_parm_bool(-1, "ntlmssp_client", "ntlm2", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_client", "ntlm2", true)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_NTLM2;
} else {
/* apparently we can't do ntlmv2 if we don't do ntlm2 */
- gensec_ntlmssp_state->use_ntlmv2 = False;
+ gensec_ntlmssp_state->use_ntlmv2 = false;
}
if (gensec_security->want_features & GENSEC_FEATURE_SESSION_KEY) {
diff --git a/source4/auth/ntlmssp/ntlmssp_parse.c b/source4/auth/ntlmssp/ntlmssp_parse.c
index 98594f1fc3..ea9b52e432 100644
--- a/source4/auth/ntlmssp/ntlmssp_parse.c
+++ b/source4/auth/ntlmssp/ntlmssp_parse.c
@@ -40,7 +40,7 @@
d = word (4 bytes)
C = constant ascii string
*/
-BOOL msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
+bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
const char *format, ...)
{
int i;
@@ -66,7 +66,7 @@ BOOL msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
head_size += 8;
n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s);
if (n == -1) {
- return False;
+ return false;
}
pointers[i].length = n;
pointers[i].length -= 2;
@@ -77,7 +77,7 @@ BOOL msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
head_size += 8;
n = push_ascii_talloc(pointers, (char **)&pointers[i].data, s);
if (n == -1) {
- return False;
+ return false;
}
pointers[i].length = n;
pointers[i].length -= 1;
@@ -89,7 +89,7 @@ BOOL msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
s = va_arg(ap, char *);
n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s);
if (n == -1) {
- return False;
+ return false;
}
pointers[i].length = n;
pointers[i].length -= 2;
@@ -175,14 +175,14 @@ BOOL msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
talloc_free(pointers);
- return True;
+ return true;
}
/* a helpful macro to avoid running over the end of our blob */
#define NEED_DATA(amount) \
if ((head_ofs + amount) > blob->length) { \
- return False; \
+ return false; \
}
/*
@@ -198,7 +198,7 @@ if ((head_ofs + amount) > blob->length) { \
C = constant ascii string
*/
-BOOL msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
+bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
const char *format, ...)
{
int i;
@@ -226,21 +226,21 @@ BOOL msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
} else {
/* make sure its in the right format - be strict */
if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) {
- return False;
+ return false;
}
if (len1 & 1) {
/* if odd length and unicode */
- return False;
+ return false;
}
if (blob->data + ptr < (uint8_t *)ptr || blob->data + ptr < blob->data)
- return False;
+ return false;
if (0 < len1) {
pull_string(p, blob->data + ptr, sizeof(p),
len1, STR_UNICODE|STR_NOALIGN);
(*ps) = talloc_strdup(mem_ctx, p);
if (!(*ps)) {
- return False;
+ return false;
}
} else {
(*ps) = "";
@@ -259,18 +259,18 @@ BOOL msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
*ps = "";
} else {
if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) {
- return False;
+ return false;
}
if (blob->data + ptr < (uint8_t *)ptr || blob->data + ptr < blob->data)
- return False;
+ return false;
if (0 < len1) {
pull_string(p, blob->data + ptr, sizeof(p),
len1, STR_ASCII|STR_NOALIGN);
(*ps) = talloc_strdup(mem_ctx, p);
if (!(*ps)) {
- return False;
+ return false;
}
} else {
(*ps) = "";
@@ -289,11 +289,11 @@ BOOL msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
} else {
/* make sure its in the right format - be strict */
if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) {
- return False;
+ return false;
}
if (blob->data + ptr < (uint8_t *)ptr || blob->data + ptr < blob->data)
- return False;
+ return false;
*b = data_blob_talloc(mem_ctx, blob->data + ptr, len1);
}
@@ -304,7 +304,7 @@ BOOL msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
/* make sure its in the right format - be strict */
NEED_DATA(len1);
if (blob->data + head_ofs < (uint8_t *)head_ofs || blob->data + head_ofs < blob->data)
- return False;
+ return false;
*b = data_blob_talloc(mem_ctx, blob->data + head_ofs, len1);
head_ofs += len1;
@@ -318,18 +318,18 @@ BOOL msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
s = va_arg(ap, char *);
if (blob->data + head_ofs < (uint8_t *)head_ofs || blob->data + head_ofs < blob->data)
- return False;
+ return false;
head_ofs += pull_string(p, blob->data+head_ofs, sizeof(p),
blob->length - head_ofs,
STR_ASCII|STR_TERMINATE);
if (strcmp(s, p) != 0) {
- return False;
+ return false;
}
break;
}
}
va_end(ap);
- return True;
+ return true;
}
diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c
index 18e38cf6bf..79a17e5733 100644
--- a/source4/auth/ntlmssp/ntlmssp_server.c
+++ b/source4/auth/ntlmssp/ntlmssp_server.c
@@ -25,12 +25,12 @@
#include "auth/ntlmssp/ntlmssp.h"
#include "auth/ntlmssp/msrpc_parse.h"
#include "lib/crypto/crypto.h"
-#include "pstring.h"
#include "system/filesys.h"
#include "libcli/auth/libcli_auth.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
#include "auth/auth.h"
+#include "param/param.h"
/**
* Set a username on an NTLMSSP context - ensures it is talloc()ed
@@ -98,66 +98,13 @@ static const char *ntlmssp_target_name(struct gensec_ntlmssp_state *gensec_ntlms
return gensec_ntlmssp_state->server_name;
} else {
*chal_flags |= NTLMSSP_TARGET_TYPE_DOMAIN;
- return gensec_ntlmssp_state->get_domain();
+ return gensec_ntlmssp_state->domain;
};
} else {
return "";
}
}
-/*
- Andrew, please remove these totally bogus calls when you get time
-*/
-static BOOL get_myfullname(char *my_name)
-{
- pstring hostname;
-
- *hostname = 0;
-
- /* get my host name */
- if (gethostname(hostname, sizeof(hostname)) == -1) {
- DEBUG(0,("gethostname failed\n"));
- return False;
- }
-
- /* Ensure null termination. */
- hostname[sizeof(hostname)-1] = '\0';
-
- if (my_name)
- fstrcpy(my_name, hostname);
- return True;
-}
-
-static BOOL get_mydomname(char *my_domname)
-{
- pstring hostname;
- char *p;
-
- /* arrgh! relies on full name in system */
-
- *hostname = 0;
- /* get my host name */
- if (gethostname(hostname, sizeof(hostname)) == -1) {
- DEBUG(0,("gethostname failed\n"));
- return False;
- }
-
- /* Ensure null termination. */
- hostname[sizeof(hostname)-1] = '\0';
-
- p = strchr_m(hostname, '.');
-
- if (!p)
- return False;
-
- p++;
-
- if (my_domname)
- fstrcpy(my_domname, p);
-
- return True;
-}
-
/**
@@ -174,9 +121,10 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
TALLOC_CTX *out_mem_ctx,
const DATA_BLOB in, DATA_BLOB *out)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
DATA_BLOB struct_blob;
- fstring dnsname, dnsdomname;
+ char dnsname[MAXHOSTNAMELEN], dnsdomname[MAXHOSTNAMELEN];
+ const char *p;
uint32_t neg_flags = 0;
uint32_t ntlmssp_command, chal_flags;
const uint8_t *cryptkey;
@@ -227,13 +175,20 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
gensec_ntlmssp_state->chal = data_blob_talloc(gensec_ntlmssp_state, cryptkey, 8);
gensec_ntlmssp_state->internal_chal = data_blob_talloc(gensec_ntlmssp_state, cryptkey, 8);
- /* This should be a 'netbios domain -> DNS domain' mapping */
- dnsdomname[0] = '\0';
- get_mydomname(dnsdomname);
- strlower_m(dnsdomname);
-
dnsname[0] = '\0';
- get_myfullname(dnsname);
+ if (gethostname(dnsname, sizeof(dnsname)) == -1) {
+ DEBUG(0,("gethostname failed\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ /* This should be a 'netbios domain -> DNS domain' mapping */
+ p = strchr(dnsname, '.');
+ if (p != NULL) {
+ safe_strcpy(dnsdomname, p+1, sizeof(dnsdomname));
+ strlower_m(dnsdomname);
+ } else {
+ dnsdomname[0] = '\0';
+ }
/* This creates the 'blob' of names that appears at the end of the packet */
if (chal_flags & NTLMSSP_CHAL_TARGET_INFO)
@@ -404,7 +359,7 @@ static NTSTATUS ntlmssp_server_preauth(struct gensec_ntlmssp_state *gensec_ntlms
SMB_ASSERT(gensec_ntlmssp_state->internal_chal.data
&& gensec_ntlmssp_state->internal_chal.length == 8);
- gensec_ntlmssp_state->doing_ntlm2 = True;
+ gensec_ntlmssp_state->doing_ntlm2 = true;
memcpy(gensec_ntlmssp_state->crypt.ntlm2.session_nonce, gensec_ntlmssp_state->internal_chal.data, 8);
memcpy(&gensec_ntlmssp_state->crypt.ntlm2.session_nonce[8], gensec_ntlmssp_state->lm_resp.data, 8);
@@ -447,7 +402,7 @@ static NTSTATUS ntlmssp_server_postauth(struct gensec_security *gensec_security,
DATA_BLOB *user_session_key,
DATA_BLOB *lm_session_key)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
NTSTATUS nt_status;
DATA_BLOB session_key = data_blob(NULL, 0);
@@ -594,7 +549,7 @@ NTSTATUS ntlmssp_server_auth(struct gensec_security *gensec_security,
TALLOC_CTX *out_mem_ctx,
const DATA_BLOB in, DATA_BLOB *out)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
DATA_BLOB user_session_key = data_blob(NULL, 0);
DATA_BLOB lm_session_key = data_blob(NULL, 0);
NTSTATUS nt_status;
@@ -662,7 +617,7 @@ static const uint8_t *auth_ntlmssp_get_challenge(const struct gensec_ntlmssp_sta
*
* @return If the effective challenge used by the auth subsystem may be modified
*/
-static BOOL auth_ntlmssp_may_set_challenge(const struct gensec_ntlmssp_state *gensec_ntlmssp_state)
+static bool auth_ntlmssp_may_set_challenge(const struct gensec_ntlmssp_state *gensec_ntlmssp_state)
{
return auth_challenge_may_be_modified(gensec_ntlmssp_state->auth_context);
}
@@ -706,7 +661,7 @@ static NTSTATUS auth_ntlmssp_check_password(struct gensec_ntlmssp_state *gensec_
user_info->logon_parameters = MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT | MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT;
user_info->flags = 0;
- user_info->mapped_state = False;
+ user_info->mapped_state = false;
user_info->client.account_name = gensec_ntlmssp_state->user;
user_info->client.domain_name = gensec_ntlmssp_state->domain;
user_info->workstation_name = gensec_ntlmssp_state->workstation;
@@ -760,7 +715,7 @@ NTSTATUS gensec_ntlmssp_session_info(struct gensec_security *gensec_security,
struct auth_session_info **session_info)
{
NTSTATUS nt_status;
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ 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_ntlmssp_state->server_info, session_info);
NT_STATUS_NOT_OK_RETURN(nt_status);
@@ -784,21 +739,21 @@ NTSTATUS gensec_ntlmssp_server_start(struct gensec_security *gensec_security)
nt_status = gensec_ntlmssp_start(gensec_security);
NT_STATUS_NOT_OK_RETURN(nt_status);
- gensec_ntlmssp_state = gensec_security->private_data;
+ gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
gensec_ntlmssp_state->role = NTLMSSP_SERVER;
gensec_ntlmssp_state->workstation = NULL;
- gensec_ntlmssp_state->server_name = lp_netbios_name();
+ gensec_ntlmssp_state->server_name = lp_netbios_name(global_loadparm);
- gensec_ntlmssp_state->get_domain = lp_workgroup;
+ gensec_ntlmssp_state->domain = lp_workgroup(global_loadparm);
gensec_ntlmssp_state->expected_state = NTLMSSP_NEGOTIATE;
- gensec_ntlmssp_state->allow_lm_key = (lp_lanman_auth()
- && lp_parm_bool(-1, "ntlmssp_server", "allow_lm_key", False));
+ gensec_ntlmssp_state->allow_lm_key = (lp_lanman_auth(global_loadparm)
+ && lp_parm_bool(global_loadparm, NULL, "ntlmssp_server", "allow_lm_key", false));
- gensec_ntlmssp_state->server_multiple_authentications = False;
+ gensec_ntlmssp_state->server_multiple_authentications = false;
gensec_ntlmssp_state->neg_flags =
NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_UNKNOWN_02000000;
@@ -807,23 +762,23 @@ NTSTATUS gensec_ntlmssp_server_start(struct gensec_security *gensec_security)
gensec_ntlmssp_state->nt_resp = data_blob(NULL, 0);
gensec_ntlmssp_state->encrypted_session_key = data_blob(NULL, 0);
- if (lp_parm_bool(-1, "ntlmssp_server", "128bit", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_server", "128bit", true)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_128;
}
- if (lp_parm_bool(-1, "ntlmssp_server", "56bit", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_server", "56bit", true)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_56;
}
- if (lp_parm_bool(-1, "ntlmssp_server", "keyexchange", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_server", "keyexchange", true)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_KEY_EXCH;
}
- if (lp_parm_bool(-1, "ntlmssp_server", "alwayssign", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_server", "alwayssign", true)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_ALWAYS_SIGN;
}
- if (lp_parm_bool(-1, "ntlmssp_server", "ntlm2", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ntlmssp_server", "ntlm2", true)) {
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_NTLM2;
}
@@ -844,7 +799,7 @@ NTSTATUS gensec_ntlmssp_server_start(struct gensec_security *gensec_security)
gensec_ntlmssp_state->may_set_challenge = auth_ntlmssp_may_set_challenge;
gensec_ntlmssp_state->set_challenge = auth_ntlmssp_set_challenge;
gensec_ntlmssp_state->check_password = auth_ntlmssp_check_password;
- gensec_ntlmssp_state->server_role = lp_server_role();
+ gensec_ntlmssp_state->server_role = lp_server_role(global_loadparm);
return NT_STATUS_OK;
}
diff --git a/source4/auth/ntlmssp/ntlmssp_sign.c b/source4/auth/ntlmssp/ntlmssp_sign.c
index 4eb6156deb..dd8dd450c8 100644
--- a/source4/auth/ntlmssp/ntlmssp_sign.c
+++ b/source4/auth/ntlmssp/ntlmssp_sign.c
@@ -65,7 +65,7 @@ static NTSTATUS ntlmssp_make_packet_signature(struct gensec_ntlmssp_state *gense
const uint8_t *data, size_t length,
const uint8_t *whole_pdu, size_t pdu_length,
enum ntlmssp_direction direction,
- DATA_BLOB *sig, BOOL encrypt_sig)
+ DATA_BLOB *sig, bool encrypt_sig)
{
if (gensec_ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
@@ -137,12 +137,12 @@ _PUBLIC_ NTSTATUS gensec_ntlmssp_sign_packet(struct gensec_security *gensec_secu
const uint8_t *whole_pdu, size_t pdu_length,
DATA_BLOB *sig)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
return ntlmssp_make_packet_signature(gensec_ntlmssp_state, sig_mem_ctx,
data, length,
whole_pdu, pdu_length,
- NTLMSSP_SEND, sig, True);
+ NTLMSSP_SEND, sig, true);
}
/**
@@ -156,7 +156,7 @@ NTSTATUS gensec_ntlmssp_check_packet(struct gensec_security *gensec_security,
const uint8_t *whole_pdu, size_t pdu_length,
const DATA_BLOB *sig)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
DATA_BLOB local_sig;
NTSTATUS nt_status;
@@ -169,7 +169,7 @@ NTSTATUS gensec_ntlmssp_check_packet(struct gensec_security *gensec_security,
nt_status = ntlmssp_make_packet_signature(gensec_ntlmssp_state, sig_mem_ctx,
data, length,
whole_pdu, pdu_length,
- NTLMSSP_RECEIVE, &local_sig, True);
+ NTLMSSP_RECEIVE, &local_sig, true);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("NTLMSSP packet check failed with %s\n", nt_errstr(nt_status)));
@@ -220,7 +220,7 @@ NTSTATUS gensec_ntlmssp_seal_packet(struct gensec_security *gensec_security,
const uint8_t *whole_pdu, size_t pdu_length,
DATA_BLOB *sig)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
NTSTATUS nt_status;
if (!gensec_ntlmssp_state->session_key.length) {
DEBUG(3, ("NO session key, cannot seal packet\n"));
@@ -236,7 +236,7 @@ NTSTATUS gensec_ntlmssp_seal_packet(struct gensec_security *gensec_security,
nt_status = ntlmssp_make_packet_signature(gensec_ntlmssp_state, sig_mem_ctx,
data, length,
whole_pdu, pdu_length,
- NTLMSSP_SEND, sig, False);
+ NTLMSSP_SEND, sig, false);
arcfour_crypt_sbox(gensec_ntlmssp_state->crypt.ntlm2.send_seal_arcfour_state, data, length);
if (gensec_ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH) {
arcfour_crypt_sbox(gensec_ntlmssp_state->crypt.ntlm2.send_seal_arcfour_state, sig->data+4, 8);
@@ -281,7 +281,7 @@ NTSTATUS gensec_ntlmssp_unseal_packet(struct gensec_security *gensec_security,
const uint8_t *whole_pdu, size_t pdu_length,
const DATA_BLOB *sig)
{
- struct gensec_ntlmssp_state *gensec_ntlmssp_state = gensec_security->private_data;
+ struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
if (!gensec_ntlmssp_state->session_key.length) {
DEBUG(3, ("NO session key, cannot unseal packet\n"));
return NT_STATUS_NO_USER_SESSION_KEY;
diff --git a/source4/auth/sam.c b/source4/auth/sam.c
index 6e160941d8..ad8d77ecf8 100644
--- a/source4/auth/sam.c
+++ b/source4/auth/sam.c
@@ -27,6 +27,7 @@
#include "libcli/security/security.h"
#include "libcli/ldap/ldap.h"
#include "librpc/gen_ndr/ndr_netlogon.h"
+#include "param/param.h"
const char *user_attrs[] = {
/* required for the krb5 kdc */
@@ -75,7 +76,7 @@ const char *domain_ref_attrs[] = {"nETBIOSName", "nCName",
bitmask.
****************************************************************************/
-static BOOL logon_hours_ok(struct ldb_message *msg, const char *name_for_logs)
+static bool logon_hours_ok(struct ldb_message *msg, const char *name_for_logs)
{
/* In logon hours first bit is Sunday from 12AM to 1AM */
const struct ldb_val *hours;
@@ -87,12 +88,12 @@ static BOOL logon_hours_ok(struct ldb_message *msg, const char *name_for_logs)
hours = ldb_msg_find_ldb_val(msg, "logonHours");
if (!hours) {
DEBUG(5,("logon_hours_ok: No hours restrictions for user %s\n", name_for_logs));
- return True;
+ return true;
}
if (hours->length != 168/8) {
DEBUG(5,("logon_hours_ok: malformed logon hours restrictions for user %s\n", name_for_logs));
- return True;
+ return true;
}
lasttime = time(NULL);
@@ -100,7 +101,7 @@ static BOOL logon_hours_ok(struct ldb_message *msg, const char *name_for_logs)
if (!utctime) {
DEBUG(1, ("logon_hours_ok: failed to get gmtime. Failing logon for user %s\n",
name_for_logs));
- return False;
+ return false;
}
/* find the corresponding byte and bit */
@@ -121,14 +122,14 @@ static BOOL logon_hours_ok(struct ldb_message *msg, const char *name_for_logs)
DEBUG(1, ("logon_hours_ok: Account for user %s not allowed to "
"logon at this time (%s).\n",
name_for_logs, asct ));
- return False;
+ return false;
}
asct = asctime(utctime);
DEBUG(5,("logon_hours_ok: user %s allowed to logon at this time (%s)\n",
name_for_logs, asct ? asct : "UNKNOWN TIME" ));
- return True;
+ return true;
}
/****************************************************************************
@@ -204,7 +205,7 @@ _PUBLIC_ NTSTATUS authsam_account_ok(TALLOC_CTX *mem_ctx,
/* Test workstation. Workstation list is comma separated. */
if (logon_workstation && workstation_list && *workstation_list) {
- BOOL invalid_ws = True;
+ bool invalid_ws = true;
int i;
const char **workstations = str_list_make(mem_ctx, workstation_list, ",");
@@ -213,7 +214,7 @@ _PUBLIC_ NTSTATUS authsam_account_ok(TALLOC_CTX *mem_ctx,
workstations[i], logon_workstation));
if (strequal(workstations[i], logon_workstation)) {
- invalid_ws = False;
+ invalid_ws = false;
break;
}
}
@@ -343,7 +344,7 @@ _PUBLIC_ NTSTATUS authsam_make_server_info(TALLOC_CTX *mem_ctx, struct ldb_conte
server_info->home_drive = talloc_strdup(server_info, str);
NT_STATUS_HAVE_NO_MEMORY(server_info->home_drive);
- server_info->logon_server = talloc_strdup(server_info, lp_netbios_name());
+ server_info->logon_server = talloc_strdup(server_info, lp_netbios_name(global_loadparm));
NT_STATUS_HAVE_NO_MEMORY(server_info->logon_server);
server_info->last_logon = samdb_result_nttime(msg, "lastLogon", 0);
@@ -370,7 +371,7 @@ _PUBLIC_ NTSTATUS authsam_make_server_info(TALLOC_CTX *mem_ctx, struct ldb_conte
server_info->user_session_key = user_sess_key;
server_info->lm_session_key = lm_sess_key;
- server_info->authenticated = True;
+ server_info->authenticated = true;
*_server_info = server_info;
diff --git a/source4/autogen.sh b/source4/autogen.sh
index 984831bf90..e5aa69776f 100755
--- a/source4/autogen.sh
+++ b/source4/autogen.sh
@@ -63,11 +63,6 @@ $AUTOCONF $IPATHS || exit 1
rm -rf autom4te*.cache
-if test x"${AUTOGEN_SKIP_SWAT}" != x"yes"; then
- echo "$0: building Web Application Framework (SWAT)"
- (cd ../webapps/swat && make distclean build || exit 1)
-fi
-
echo "Now run ./configure and then make."
exit 0
diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4
index 41600986c8..9e82e6aaf1 100644
--- a/source4/build/m4/public.m4
+++ b/source4/build/m4/public.m4
@@ -67,21 +67,14 @@ AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG],
echo "*** The pkg-config script could not be found. Make sure it is"
echo "*** in your path, or set the PKG_CONFIG environment variable"
echo "*** to the full path to pkg-config."
- echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
- SMB_EXT_LIB($1)
- SMB_ENABLE($1, NO)
- $4
-
+ echo "*** Or see http://pkg-config.freedesktop.org/ to get pkg-config."
+ ac_cv_$1_found=no
else
if $PKG_CONFIG --atleast-pkgconfig-version 0.9.0; then
AC_MSG_CHECKING(for $2)
- if test "$SMB_$1"x = "NO"x ; then
- SMB_ENABLE($1, NO)
- AC_MSG_RESULT(disabled)
- $4
- elif $PKG_CONFIG --exists '$2' ; then
- AC_MSG_RESULT(yes)
+ if $PKG_CONFIG --exists '$2' ; then
+ AC_MSG_RESULT(yes)
$1_CFLAGS="`$PKG_CONFIG --cflags '$2'`"
@@ -101,23 +94,27 @@ AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG],
[`$PKG_CONFIG --cflags-only-other '$2'`],
[`$PKG_CONFIG --cflags-only-I '$2'`],
[`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`])
- $3
+ ac_cv_$1_found=yes
else
- SMB_EXT_LIB($1)
- SMB_ENABLE($1, NO)
AC_MSG_RESULT(no)
$PKG_CONFIG --errors-to-stdout --print-errors '$2'
- $4
+ ac_cv_$1_found=no
fi
else
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
- echo "*** See http://www.freedesktop.org/software/pkgconfig"
- SMB_EXT_LIB($1)
- SMB_ENABLE($1, NO)
- $4
+ echo "*** See http://pkg-config.freedesktop.org/"
+ ac_cv_$1_found=no
fi
fi
+ if test x$ac_cv_$1_found = x"yes"; then
+ ifelse([$3], [], [echo -n ""], [$3])
+ else
+ ifelse([$4], [], [
+ SMB_EXT_LIB($1)
+ SMB_ENABLE($1, NO)
+ ], [$4])
+ fi
])
dnl SMB_INCLUDE_MK(file)
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index 77b497d25c..a96aad2271 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -91,11 +91,17 @@ sub check_module($$$)
}
if (not defined($mod->{OUTPUT_TYPE})) {
- $mod->{OUTPUT_TYPE} = $default_ot;
+ if ($INPUT->{$mod->{SUBSYSTEM}}->{TYPE} eq "EXT_LIB") {
+ $mod->{OUTPUT_TYPE} = ["SHARED_LIBRARY"];
+ } else {
+ $mod->{OUTPUT_TYPE} = $default_ot;
+ }
}
if (grep(/SHARED_LIBRARY/, @{$mod->{OUTPUT_TYPE}})) {
- $mod->{INSTALLDIR} = "MODULESDIR/$mod->{SUBSYSTEM}";
+ my $sane_subsystem = lc($mod->{SUBSYSTEM});
+ $sane_subsystem =~ s/^lib//;
+ $mod->{INSTALLDIR} = "MODULESDIR/$sane_subsystem";
push (@{$mod->{PRIVATE_DEPENDENCIES}}, $mod->{SUBSYSTEM});
}
if (grep(/INTEGRATED/, @{$mod->{OUTPUT_TYPE}})) {
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index b88a1ea72e..b1bd215af1 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -88,8 +88,7 @@ MODULESDIR = $self->{config}->{modulesdir}
INCLUDEDIR = $self->{config}->{includedir}
CONFIGDIR = $self->{config}->{sysconfdir}
DATADIR = $self->{config}->{datadir}
-WEBAPPSDIR = \$(DATADIR)/webapps
-SERVICESDIR = \$(DATADIR)/services
+SWATDIR = \$(DATADIR)/swat
JSDIR = \$(DATADIR)/js
SETUPDIR = \$(DATADIR)/setup
VARDIR = $self->{config}->{localstatedir}
@@ -115,17 +114,19 @@ sub _prepare_suffix_rules($)
}
$self->output(<< "__EOD__"
+FIRST_PREREQ = $first_prereq
+
# Dependencies command
DEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.o) -MT \$@ \\
`\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(CFLAGS) $first_prereq -o \$@
+ \$(CFLAGS) \$(FIRST_PREREQ) -o \$@
# Dependencies for host objects
HDEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.ho) -MT \$@ \\
`\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(HOSTCC_CFLAGS) $first_prereq -o \$@
+ \$(HOSTCC_CFLAGS) \$(FIRST_PREREQ) -o \$@
# Dependencies for precompiled headers
PCHDEPENDS = \$(CC) -M -MG -MT include/includes.h.gch -MT \$@ \\
- \$(CFLAGS) $first_prereq -o \$@
+ \$(CFLAGS) \$(FIRST_PREREQ) -o \$@
# \$< is broken in older BSD versions:
# when \$@ is foo/bar.o, \$< could be torture/foo/bar.c
@@ -137,20 +138,20 @@ PCHDEPENDS = \$(CC) -M -MG -MT include/includes.h.gch -MT \$@ \\
# Run a static analysis checker
CHECK = \$(CC_CHECKER) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(CFLAGS) \$(PICFLAG) -c $first_prereq -o \$@
+ \$(CFLAGS) \$(PICFLAG) -c \$(FIRST_PREREQ) -o \$@
# Run the configured compiler
COMPILE = \$(CC) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(CFLAGS) \$(PICFLAG) -c $first_prereq -o \$@
+ \$(CFLAGS) \$(PICFLAG) -c \$(FIRST_PREREQ) -o \$@
# Run the compiler for the build host
HCOMPILE = \$(HOSTCC) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(HOSTCC_CFLAGS) -c $first_prereq -o \$@
+ \$(HOSTCC_CFLAGS) -c \$(FIRST_PREREQ) -o \$@
# Precompile headers
PCHCOMPILE = @\$(CC) -Ilib/replace \\
`\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(CFLAGS) \$(PICFLAG) -c $first_prereq -o \$@
+ \$(CFLAGS) \$(PICFLAG) -c \$(FIRST_PREREQ) -o \$@
__EOD__
);
@@ -284,24 +285,27 @@ sub SharedLibrary($$)
my $init_obj = "";
my $has_static_lib = 0;
-
+
if ($ctx->{TYPE} eq "LIBRARY") {
push (@{$self->{shared_libs}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
push (@{$self->{installable_shared_libs}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
} elsif ($ctx->{TYPE} eq "MODULE") {
+ my $sane_subsystem = lc($ctx->{SUBSYSTEM});
+ $sane_subsystem =~ s/^lib//;
+
push (@{$self->{shared_modules}}, "$ctx->{TARGET_SHARED_LIBRARY}");
push (@{$self->{plugins}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
- $self->{install_plugins} .= "\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
- $self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/\n";
- $self->{install_plugins} .= "\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
- $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
- $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
+ $self->{install_plugins} .= "\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
+ $self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/\n";
+ $self->{install_plugins} .= "\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
+ $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
+ $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
if (defined($ctx->{ALIASES})) {
foreach (@{$ctx->{ALIASES}}) {
- $self->{install_plugins} .= "\t\@rm -f \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$_.\$(SHLIBEXT)\n";
- $self->{install_plugins} .= "\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$_.\$(SHLIBEXT)\n";
- $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$_.\$(SHLIBEXT)\n";
+ $self->{install_plugins} .= "\t\@rm -f \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
+ $self->{install_plugins} .= "\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
+ $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
}
}
}
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index ec273b894a..42e68abec9 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -55,9 +55,11 @@ sub generate_shared_library($)
$lib->{SHAREDDIR} = $lib->{BASEDIR};
} else {
if ($lib->{TYPE} eq "MODULE") {
- $lib->{SHAREDDIR} = "bin/modules/$lib->{SUBSYSTEM}";
+ my $sane_subsystem = lc($lib->{SUBSYSTEM});
+ $sane_subsystem =~ s/^lib//;
+ $lib->{SHAREDDIR} = "bin/modules/$sane_subsystem";
$lib->{LIBRARY_REALNAME} = $link_name;
- $lib->{LIBRARY_REALNAME} =~ s/^$lib->{SUBSYSTEM}_//g;
+ $lib->{LIBRARY_REALNAME} =~ s/^$sane_subsystem\_//g;
$lib->{LIBRARY_REALNAME}.= ".\$(SHLIBEXT)";
} else {
$lib->{SHAREDDIR} = "bin/shared";
diff --git a/source4/build/smb_build/summary.pm b/source4/build/smb_build/summary.pm
index 7b84266d62..541a569a3b 100644
--- a/source4/build/smb_build/summary.pm
+++ b/source4/build/smb_build/summary.pm
@@ -34,6 +34,13 @@ sub showitem($$$)
}
}
+sub showisexternal($$$)
+{
+ my ($output, $desc, $name) = @_;
+ print "Using external $desc: ".
+ (($output->{$name}->{TYPE} eq "EXT_LIB")?"yes":"no")."\n";
+}
+
sub show($$)
{
my ($output,$config) = @_;
@@ -47,8 +54,10 @@ sub show($$)
showitem($output, "using libblkid", ["BLKID"]);
showitem($output, "using iconv", ["ICONV"]);
showitem($output, "using pam", ["PAM"]);
- print "Using external popt: ".
- (($output->{LIBPOPT}->{TYPE} eq "EXT_LIB")?"yes":"no")."\n";
+ showisexternal($output, "popt", "LIBPOPT");
+ showisexternal($output, "talloc", "LIBTALLOC");
+ showisexternal($output, "tdb", "LIBTDB");
+ showisexternal($output, "ldb", "LIBLDB");
print "Developer mode: ".(enabled($config->{developer})?"yes":"no")."\n";
print "Automatic dependencies: ".
(enabled($config->{automatic_dependencies})
diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c
index a1a1414c98..466444ace8 100644
--- a/source4/cldap_server/cldap_server.c
+++ b/source4/cldap_server/cldap_server.c
@@ -33,6 +33,7 @@
#include "dsdb/samdb/samdb.h"
#include "db_wrap.h"
#include "auth/auth.h"
+#include "param/param.h"
/*
handle incoming cldap requests
@@ -94,7 +95,7 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *addr
NT_STATUS_HAVE_NO_MEMORY(cldapsock);
socket_address = socket_address_from_strings(cldapsock, cldapsock->sock->backend_name,
- address, lp_cldap_port());
+ address, lp_cldap_port(global_loadparm));
if (!socket_address) {
talloc_free(cldapsock);
return NT_STATUS_NO_MEMORY;
@@ -103,7 +104,7 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *addr
status = socket_listen(cldapsock->sock, socket_address, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to bind to %s:%d - %s\n",
- address, lp_cldap_port(), nt_errstr(status)));
+ address, lp_cldap_port(global_loadparm), nt_errstr(status)));
talloc_free(cldapsock);
return status;
}
@@ -127,7 +128,7 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd)
/* if we are allowing incoming packets from any address, then
we need to bind to the wildcard address */
- if (!lp_bind_interfaces_only()) {
+ if (!lp_bind_interfaces_only(global_loadparm)) {
status = cldapd_add_socket(cldapd, "0.0.0.0");
NT_STATUS_NOT_OK_RETURN(status);
} else {
diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c
index 1dec279905..6b398a4144 100644
--- a/source4/cldap_server/netlogon.c
+++ b/source4/cldap_server/netlogon.c
@@ -33,6 +33,7 @@
#include "db_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
@@ -50,7 +51,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
const char *dom_attrs[] = {"objectGUID", NULL};
struct ldb_message **ref_res, **dom_res;
int ret, count = 0;
- const char **services = lp_server_services();
+ const char **services = lp_server_services(global_loadparm);
uint32_t server_type;
const char *pdc_name;
struct GUID domain_uuid;
@@ -135,15 +136,17 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
server_type |= NBT_SERVER_KDC;
}
- pdc_name = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
+ pdc_name = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name(global_loadparm));
domain_uuid = samdb_result_guid(dom_res[0], "objectGUID");
- realm = samdb_result_string(ref_res[0], "dnsRoot", lp_realm());
- dns_domain = samdb_result_string(ref_res[0], "dnsRoot", lp_realm());
+ realm = samdb_result_string(ref_res[0], "dnsRoot", lp_realm(global_loadparm));
+ dns_domain = samdb_result_string(ref_res[0], "dnsRoot", lp_realm(global_loadparm));
pdc_dns_name = talloc_asprintf(mem_ctx, "%s.%s",
- strlower_talloc(mem_ctx, lp_netbios_name()),
+ strlower_talloc(mem_ctx,
+ lp_netbios_name(global_loadparm)),
dns_domain);
- flatname = samdb_result_string(ref_res[0], "nETBIOSName", lp_workgroup());
+ flatname = samdb_result_string(ref_res[0], "nETBIOSName",
+ lp_workgroup(global_loadparm));
server_site = "Default-First-Site-Name";
client_site = "Default-First-Site-Name";
pdc_ip = iface_best_ip(src_address);
@@ -187,7 +190,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
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();
+ netlogon->logon5.pdc_name = lp_netbios_name(global_loadparm);
netlogon->logon5.user_name = user;
netlogon->logon5.server_site = server_site;
netlogon->logon5.client_site = client_site;
@@ -202,7 +205,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
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();
+ netlogon->logon13.pdc_name = lp_netbios_name(global_loadparm);
netlogon->logon13.user_name = user;
netlogon->logon13.server_site = server_site;
netlogon->logon13.client_site = client_site;
@@ -286,7 +289,7 @@ void cldapd_netlogon_request(struct cldap_socket *cldap,
}
if (domain_guid == NULL && domain == NULL) {
- domain = lp_realm();
+ domain = lp_realm(global_loadparm);
}
if (version == -1) {
diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c
index 28c9059efa..5735d127e4 100644
--- a/source4/client/cifsdd.c
+++ b/source4/client/cifsdd.c
@@ -24,6 +24,7 @@
#include "lib/cmdline/popt_common.h"
#include "cifsdd.h"
+#include "param/param.h"
const char * const PROGNAME = "cifsdd";
@@ -102,7 +103,7 @@ static struct argdef args[] =
*/
};
-struct argdef * find_named_arg(const char * arg)
+static struct argdef * find_named_arg(const char * arg)
{
int i;
@@ -218,7 +219,7 @@ fail:
return;
}
-BOOL check_arg_bool(const char * name)
+bool check_arg_bool(const char * name)
{
struct argdef * arg;
@@ -229,7 +230,7 @@ BOOL check_arg_bool(const char * name)
DEBUG(0, ("invalid argument name: %s", name));
SMB_ASSERT(0);
- return(False);
+ return(false);
}
uint64_t check_arg_numeric(const char * name)
@@ -394,7 +395,7 @@ static void set_max_xmit(uint64_t iomax)
char buf[64];
snprintf(buf, sizeof(buf), "%llu", (unsigned long long)iomax);
- lp_set_cmdline("max xmit", buf);
+ lp_set_cmdline(global_loadparm, "max xmit", buf);
}
static int copy_files(void)
@@ -418,7 +419,7 @@ static int copy_files(void)
* could accumulate a remainder if ibs and obs don't match.
*/
iomax = 2 * MAX(ibs, obs);
- if ((iobuf = malloc(iomax)) == NULL) {
+ if ((iobuf = malloc_array_p(uint8_t, iomax)) == NULL) {
fprintf(stderr,
"%s: failed to allocate IO buffer of %llu bytes\n",
PROGNAME, (unsigned long long)iomax);
@@ -428,7 +429,7 @@ static int copy_files(void)
set_max_xmit(MAX(ibs, obs));
DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n",
- (unsigned long long)iomax, lp_max_xmit()));
+ (unsigned long long)iomax, lp_max_xmit(global_loadparm)));
if (!(ifile = open_file("if"))) {
return(FILESYS_EXIT_CODE);
@@ -442,7 +443,7 @@ static int copy_files(void)
ifile->io_seek(ifile, check_arg_numeric("skip") * ibs);
ofile->io_seek(ofile, check_arg_numeric("seek") * obs);
- DEBUG(4, ("max xmit was negotiated to be %d\n", lp_max_xmit()));
+ DEBUG(4, ("max xmit was negotiated to be %d\n", lp_max_xmit(global_loadparm)));
for (data_size = 0;;) {
@@ -548,9 +549,9 @@ int main(int argc, const char ** argv)
set_arg_val("if", NULL);
set_arg_val("of", NULL);
/* Options. */
- set_arg_val("direct", False);
- set_arg_val("sync", False);
- set_arg_val("oplock", False);
+ set_arg_val("direct", false);
+ set_arg_val("sync", false);
+ set_arg_val("oplock", false);
pctx = poptGetContext(PROGNAME, argc, argv, poptions, 0);
while ((i = poptGetNextOpt(pctx)) != -1) {
diff --git a/source4/client/cifsddio.c b/source4/client/cifsddio.c
index 7dc9b8d081..5cea8cf305 100644
--- a/source4/client/cifsddio.c
+++ b/source4/client/cifsddio.c
@@ -38,7 +38,7 @@ struct fd_handle
#define IO_HANDLE_TO_FD(h) (((struct fd_handle *)(h))->fd)
-static BOOL fd_seek_func(void * handle, uint64_t offset)
+static bool fd_seek_func(void * handle, uint64_t offset)
{
ssize_t ret;
@@ -46,13 +46,13 @@ static BOOL fd_seek_func(void * handle, uint64_t offset)
if (ret < 0) {
fprintf(stderr, "%s: seek failed: %s\n",
PROGNAME, strerror(errno));
- return(False);
+ return(false);
}
- return(True);
+ return(true);
}
-static BOOL fd_read_func(void * handle,
+static bool fd_read_func(void * handle,
uint8_t * buf,
uint64_t wanted,
uint64_t * actual)
@@ -64,14 +64,14 @@ static BOOL fd_read_func(void * handle,
fprintf(stderr, "%s: %llu byte read failed: %s\n",
PROGNAME, (unsigned long long)wanted,
strerror(errno));
- return(False);
+ return(false);
}
*actual = (uint64_t)ret;
- return(True);
+ return(true);
}
-static BOOL fd_write_func(void * handle,
+static bool fd_write_func(void * handle,
uint8_t * buf,
uint64_t wanted,
uint64_t * actual)
@@ -83,11 +83,11 @@ static BOOL fd_write_func(void * handle,
fprintf(stderr, "%s: %llu byte write failed: %s\n",
PROGNAME, (unsigned long long)wanted,
strerror(errno));
- return(False);
+ return(false);
}
*actual = (uint64_t)ret;
- return(True);
+ return(true);
}
static struct dd_iohandle * open_fd_handle(const char * path,
@@ -149,16 +149,14 @@ struct cifs_handle
#define IO_HANDLE_TO_SMB(h) ((struct cifs_handle *)(h))
-BOOL smb_seek_func(void * handle, uint64_t offset)
+static bool smb_seek_func(void * handle, uint64_t offset)
{
IO_HANDLE_TO_SMB(handle)->offset = offset;
- return(True);
+ return(true);
}
-BOOL smb_read_func(void * handle,
- uint8_t * buf,
- uint64_t wanted,
- uint64_t * actual)
+static bool smb_read_func(void * handle, uint8_t * buf, uint64_t wanted,
+ uint64_t * actual)
{
NTSTATUS ret;
union smb_read r;
@@ -182,7 +180,7 @@ BOOL smb_read_func(void * handle,
fprintf(stderr, "%s: %llu byte read failed: %s\n",
PROGNAME, (unsigned long long)wanted,
nt_errstr(ret));
- return(False);
+ return(false);
}
/* Trap integer wrap. */
@@ -190,13 +188,11 @@ BOOL smb_read_func(void * handle,
*actual = r.readx.out.nread;
smbh->offset += r.readx.out.nread;
- return(True);
+ return(true);
}
-BOOL smb_write_func(void * handle,
- uint8_t * buf,
- uint64_t wanted,
- uint64_t * actual)
+static bool smb_write_func(void * handle, uint8_t * buf, uint64_t wanted,
+ uint64_t * actual)
{
NTSTATUS ret;
union smb_write w;
@@ -216,12 +212,12 @@ BOOL smb_write_func(void * handle,
fprintf(stderr, "%s: %llu byte write failed: %s\n",
PROGNAME, (unsigned long long)wanted,
nt_errstr(ret));
- return(False);
+ return(false);
}
*actual = w.writex.out.nwritten;
smbh->offset += w.writex.out.nwritten;
- return(True);
+ return(true);
}
static struct smbcli_state * init_smb_session(const char * host,
@@ -363,7 +359,7 @@ struct dd_iohandle * dd_open_path(const char * path,
* NOTE: The IO buffer is guaranteed to be big enough to fit
* need_size + block_size bytes into it.
*/
-BOOL dd_fill_block(struct dd_iohandle * h,
+bool dd_fill_block(struct dd_iohandle * h,
uint8_t * buf,
uint64_t * buf_size,
uint64_t need_size,
@@ -377,7 +373,7 @@ BOOL dd_fill_block(struct dd_iohandle * h,
while (*buf_size < need_size) {
if (!h->io_read(h, buf + (*buf_size), block_size, &read_size)) {
- return(False);
+ return(false);
}
if (read_size == 0) {
@@ -402,14 +398,14 @@ BOOL dd_fill_block(struct dd_iohandle * h,
}
}
- return(True);
+ return(true);
}
/* Flush a buffer that contains buf_size bytes. Use writes of block_size to do it,
* and shift any remaining bytes back to the head of the buffer when there are
* no more block_size sized IOs left.
*/
-BOOL dd_flush_block(struct dd_iohandle * h,
+bool dd_flush_block(struct dd_iohandle * h,
uint8_t * buf,
uint64_t * buf_size,
uint64_t block_size)
@@ -423,13 +419,13 @@ BOOL dd_flush_block(struct dd_iohandle * h,
if ((*buf_size) < block_size) {
if (!h->io_write(h, buf, *buf_size, &write_size)) {
- return(False);
+ return(false);
}
if (write_size == 0) {
fprintf(stderr, "%s: unexpectedly wrote 0 bytes\n",
PROGNAME);
- return(False);
+ return(false);
}
total_size += write_size;
@@ -441,13 +437,13 @@ BOOL dd_flush_block(struct dd_iohandle * h,
while (((*buf_size) - total_size) >= block_size) {
if (!h->io_write(h, buf + total_size, block_size, &write_size)) {
- return(False);
+ return(false);
}
if (write_size == 0) {
fprintf(stderr, "%s: unexpectedly wrote 0 bytes\n",
PROGNAME);
- return(False);
+ return(false);
}
if (write_size == block_size) {
@@ -489,7 +485,7 @@ BOOL dd_flush_block(struct dd_iohandle * h,
(unsigned long long)(*buf_size)));
}
- return(True);
+ return(true);
}
/* vim: set sw=8 sts=8 ts=8 tw=79 : */
diff --git a/source4/client/client.c b/source4/client/client.c
index 1fdbec4bfd..4415361602 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -20,6 +20,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/*
+ * TODO: remove this ... and don't use talloc_append_string()
+ *
+ * NOTE: I'm not changing the code yet, because I assume there're
+ * some bugs in the existing code and I'm not sure how to fix
+ * them correctly.
+ */
+#define TALLOC_DEPRECATED 1
+
#include "includes.h"
#include "version.h"
#include "libcli/libcli.h"
@@ -40,6 +49,7 @@
#include "libcli/security/security.h"
#include "lib/smbreadline/smbreadline.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
static int io_bufsize = 64512;
@@ -48,12 +58,12 @@ struct smbclient_context {
struct smbcli_state *cli;
char *fileselection;
time_t newer_than;
- BOOL prompt;
- BOOL recurse;
+ bool prompt;
+ bool recurse;
int archive_level;
- BOOL lowercase;
+ bool lowercase;
int printmode;
- BOOL translation;
+ bool translation;
};
/* timing globals */
@@ -71,7 +81,7 @@ static double dir_total;
/*******************************************************************
Reduce a file name, removing .. elements.
********************************************************************/
-void dos_clean_name(char *s)
+static void dos_clean_name(char *s)
{
char *p=NULL,*r;
@@ -95,9 +105,9 @@ void dos_clean_name(char *s)
write to a local file with CR/LF->LF translation if appropriate. return the
number taken from the buffer. This may not equal the number written.
****************************************************************************/
-static int writefile(int f, const void *_b, int n, BOOL translation)
+static int writefile(int f, const void *_b, int n, bool translation)
{
- const uint8_t *b = _b;
+ const uint8_t *b = (const uint8_t *)_b;
int i;
if (!translation) {
@@ -123,9 +133,9 @@ static int writefile(int f, const void *_b, int n, BOOL translation)
read from a file with LF->CR/LF translation if appropriate. return the
number read. read approx n bytes.
****************************************************************************/
-static int readfile(void *_b, int n, XFILE *f, BOOL translation)
+static int readfile(void *_b, int n, XFILE *f, bool translation)
{
- uint8_t *b = _b;
+ uint8_t *b = (uint8_t *)_b;
int i;
int c;
@@ -280,16 +290,16 @@ static int cmd_cd(struct smbclient_context *ctx, const char **args)
}
-BOOL mask_match(struct smbcli_state *c, const char *string, const char *pattern,
- BOOL is_case_sensitive)
+static bool mask_match(struct smbcli_state *c, const char *string,
+ const char *pattern, bool is_case_sensitive)
{
char *p2, *s2;
- BOOL ret;
+ bool ret;
if (ISDOTDOT(string))
string = ".";
if (ISDOT(pattern))
- return False;
+ return false;
if (is_case_sensitive)
return ms_fnmatch(pattern, string,
@@ -309,27 +319,27 @@ BOOL mask_match(struct smbcli_state *c, const char *string, const char *pattern,
/*******************************************************************
decide if a file should be operated on
********************************************************************/
-static BOOL do_this_one(struct smbclient_context *ctx, struct clilist_file_info *finfo)
+static bool do_this_one(struct smbclient_context *ctx, struct clilist_file_info *finfo)
{
- if (finfo->attrib & FILE_ATTRIBUTE_DIRECTORY) return(True);
+ if (finfo->attrib & FILE_ATTRIBUTE_DIRECTORY) return(true);
if (ctx->fileselection &&
- !mask_match(ctx->cli, finfo->name,ctx->fileselection,False)) {
+ !mask_match(ctx->cli, finfo->name,ctx->fileselection,false)) {
DEBUG(3,("mask_match %s failed\n", finfo->name));
- return False;
+ return false;
}
if (ctx->newer_than && finfo->mtime < ctx->newer_than) {
DEBUG(3,("newer_than %s failed\n", finfo->name));
- return(False);
+ return(false);
}
if ((ctx->archive_level==1 || ctx->archive_level==2) && !(finfo->attrib & FILE_ATTRIBUTE_ARCHIVE)) {
DEBUG(3,("archive %s failed\n", finfo->name));
- return(False);
+ return(false);
}
- return(True);
+ return(true);
}
/****************************************************************************
@@ -361,8 +371,8 @@ static void do_du(struct smbclient_context *ctx, struct clilist_file_info *finfo
}
}
-static BOOL do_list_recurse;
-static BOOL do_list_dirs;
+static bool do_list_recurse;
+static bool do_list_dirs;
static char *do_list_queue = 0;
static long do_list_queue_size = 0;
static long do_list_queue_start = 0;
@@ -396,7 +406,7 @@ static void init_do_list_queue(void)
{
reset_do_list_queue();
do_list_queue_size = 1024;
- do_list_queue = malloc(do_list_queue_size);
+ do_list_queue = malloc_array_p(char, do_list_queue_size);
if (do_list_queue == 0) {
d_printf("malloc fail for size %d\n",
(int)do_list_queue_size);
@@ -490,7 +500,7 @@ a helper for do_list
****************************************************************************/
static void do_list_helper(struct clilist_file_info *f, const char *mask, void *state)
{
- struct smbclient_context *ctx = state;
+ struct smbclient_context *ctx = (struct smbclient_context *)state;
if (f->attrib & FILE_ATTRIBUTE_DIRECTORY) {
if (do_list_dirs && do_this_one(ctx, f)) {
@@ -506,7 +516,7 @@ static void do_list_helper(struct clilist_file_info *f, const char *mask, void *
p = strrchr_m(mask2,'\\');
if (!p) return;
p[1] = 0;
- mask2 = talloc_asprintf_append(mask2, "%s\\*", f->name);
+ mask2 = talloc_asprintf_append_buffer(mask2, "%s\\*", f->name);
add_to_do_list_queue(mask2);
}
return;
@@ -522,7 +532,7 @@ static void do_list_helper(struct clilist_file_info *f, const char *mask, void *
a wrapper around smbcli_list that adds recursion
****************************************************************************/
static void do_list(struct smbclient_context *ctx, const char *mask,uint16_t attribute,
- void (*fn)(struct smbclient_context *, struct clilist_file_info *),BOOL rec, BOOL dirs)
+ void (*fn)(struct smbclient_context *, struct clilist_file_info *),bool rec, bool dirs)
{
static int in_do_list = 0;
@@ -618,7 +628,7 @@ static int cmd_dir(struct smbclient_context *ctx, const char **args)
}
}
- do_list(ctx, mask, attribute, display_finfo, ctx->recurse, True);
+ do_list(ctx, mask, attribute, display_finfo, ctx->recurse, true);
rc = do_dskattr(ctx);
@@ -649,7 +659,7 @@ static int cmd_du(struct smbclient_context *ctx, const char **args)
mask = talloc_asprintf(ctx, "%s\\*", ctx->remote_cur_dir);
}
- do_list(ctx, mask, attribute, do_du, ctx->recurse, True);
+ do_list(ctx, mask, attribute, do_du, ctx->recurse, true);
talloc_free(mask);
@@ -664,10 +674,10 @@ static int cmd_du(struct smbclient_context *ctx, const char **args)
/****************************************************************************
get a file from rname to lname
****************************************************************************/
-static int do_get(struct smbclient_context *ctx, char *rname, const char *lname, BOOL reget)
+static int do_get(struct smbclient_context *ctx, char *rname, const char *lname, bool reget)
{
int handle = 0, fnum;
- BOOL newhandle = False;
+ bool newhandle = false;
uint8_t *data;
struct timeval tp_start;
int read_size = io_bufsize;
@@ -705,7 +715,7 @@ static int do_get(struct smbclient_context *ctx, char *rname, const char *lname,
} else {
handle = open(lname, O_WRONLY|O_CREAT|O_TRUNC, 0644);
}
- newhandle = True;
+ newhandle = true;
}
if (handle < 0) {
d_printf("Error opening local file %s\n",lname);
@@ -808,24 +818,24 @@ static int cmd_get(struct smbclient_context *ctx, const char **args)
dos_clean_name(rname);
- return do_get(ctx, rname, lname, False);
+ return do_get(ctx, rname, lname, false);
}
/****************************************************************************
Put up a yes/no prompt.
****************************************************************************/
-static BOOL yesno(char *p)
+static bool yesno(char *p)
{
char ans[4];
printf("%s",p);
if (!fgets(ans,sizeof(ans)-1,stdin))
- return(False);
+ return(false);
if (*ans == 'y' || *ans == 'Y')
- return(True);
+ return(true);
- return(False);
+ return(false);
}
/****************************************************************************
@@ -852,7 +862,7 @@ static void do_mget(struct smbclient_context *ctx, struct clilist_file_info *fin
if (!(finfo->attrib & FILE_ATTRIBUTE_DIRECTORY)) {
asprintf(&rname, "%s%s",ctx->remote_cur_dir,finfo->name);
- do_get(ctx, rname, finfo->name, False);
+ do_get(ctx, rname, finfo->name, false);
SAFE_FREE(rname);
return;
}
@@ -860,7 +870,7 @@ static void do_mget(struct smbclient_context *ctx, struct clilist_file_info *fin
/* handle directories */
saved_curdir = talloc_strdup(NULL, ctx->remote_cur_dir);
- ctx->remote_cur_dir = talloc_asprintf_append(NULL, "%s\\", finfo->name);
+ ctx->remote_cur_dir = talloc_asprintf_append_buffer(NULL, "%s\\", finfo->name);
string_replace(discard_const_p(char, finfo->name), '\\', '/');
if (ctx->lowercase) {
@@ -880,7 +890,7 @@ static void do_mget(struct smbclient_context *ctx, struct clilist_file_info *fin
mget_mask = talloc_asprintf(NULL, "%s*", ctx->remote_cur_dir);
- do_list(ctx, mget_mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,do_mget,False, True);
+ do_list(ctx, mget_mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,do_mget,false, true);
chdir("..");
talloc_free(ctx->remote_cur_dir);
@@ -916,7 +926,7 @@ static int cmd_more(struct smbclient_context *ctx, const char **args)
rname = talloc_asprintf(ctx, "%s%s", ctx->remote_cur_dir, args[1]);
dos_clean_name(rname);
- rc = do_get(ctx, rname, lname, False);
+ rc = do_get(ctx, rname, lname, false);
pager=getenv("PAGER");
@@ -949,14 +959,14 @@ static int cmd_mget(struct smbclient_context *ctx, const char **args)
mget_mask = talloc_strdup(ctx, args[i]);
if (mget_mask[0] != '\\')
mget_mask = talloc_append_string(ctx, mget_mask, "\\");
- do_list(ctx, mget_mask, attribute,do_mget,False,True);
+ do_list(ctx, mget_mask, attribute,do_mget,false,true);
talloc_free(mget_mask);
}
if (mget_mask == NULL) {
mget_mask = talloc_asprintf(ctx, "%s\\*", ctx->remote_cur_dir);
- do_list(ctx, mget_mask, attribute,do_mget,False,True);
+ do_list(ctx, mget_mask, attribute,do_mget,false,true);
talloc_free(mget_mask);
}
@@ -1046,7 +1056,7 @@ static int cmd_altname(struct smbclient_context *ctx, const char **args)
if (!NT_STATUS_IS_OK(smbcli_qpathinfo_alt_name(ctx->cli->tree, name, &altname))) {
d_printf("%s getting alt name for %s\n",
smbcli_errstr(ctx->cli->tree),name);
- return(False);
+ return(false);
}
d_printf("%s\n", altname);
@@ -1057,7 +1067,7 @@ static int cmd_altname(struct smbclient_context *ctx, const char **args)
/****************************************************************************
put a single file
****************************************************************************/
-static int do_put(struct smbclient_context *ctx, char *rname, char *lname, BOOL reput)
+static int do_put(struct smbclient_context *ctx, char *rname, char *lname, bool reput)
{
int fnum;
XFILE *f;
@@ -1214,7 +1224,7 @@ static int cmd_put(struct smbclient_context *ctx, const char **args)
return 1;
}
- return do_put(ctx, rname, lname, False);
+ return do_put(ctx, rname, lname, false);
}
/*************************************
@@ -1224,7 +1234,7 @@ static int cmd_put(struct smbclient_context *ctx, const char **args)
static struct file_list {
struct file_list *prev, *next;
char *file_path;
- BOOL isdir;
+ bool isdir;
} *file_list;
/****************************************************************************
@@ -1248,17 +1258,17 @@ static void free_file_list (struct file_list * list)
seek in a directory/file list until you get something that doesn't start with
the specified name
****************************************************************************/
-static BOOL seek_list(struct file_list *list, char *name)
+static bool seek_list(struct file_list *list, char *name)
{
while (list) {
trim_string(list->file_path,"./","\n");
if (strncmp(list->file_path, name, strlen(name)) != 0) {
- return(True);
+ return(true);
}
list = list->next;
}
- return(False);
+ return(false);
}
/****************************************************************************
@@ -1311,17 +1321,17 @@ static const char *readdirname(DIR *p)
/****************************************************************************
Recursive file matching function act as find
- match must be always set to True when calling this function
+ match must be always set to true when calling this function
****************************************************************************/
static int file_find(struct smbclient_context *ctx, struct file_list **list, const char *directory,
- const char *expression, BOOL match)
+ const char *expression, bool match)
{
DIR *dir;
struct file_list *entry;
struct stat statbuf;
int ret;
char *path;
- BOOL isdir;
+ bool isdir;
const char *dname;
dir = opendir(directory);
@@ -1336,14 +1346,14 @@ static int file_find(struct smbclient_context *ctx, struct file_list **list, con
continue;
}
- isdir = False;
+ isdir = false;
if (!match || !gen_fnmatch(expression, dname)) {
if (ctx->recurse) {
ret = stat(path, &statbuf);
if (ret == 0) {
if (S_ISDIR(statbuf.st_mode)) {
- isdir = True;
- ret = file_find(ctx, list, path, expression, False);
+ isdir = true;
+ ret = file_find(ctx, list, path, expression, false);
}
} else {
d_printf("file_find: cannot stat file %s\n", path);
@@ -1389,7 +1399,7 @@ static int cmd_mput(struct smbclient_context *ctx, const char **args)
file_list = NULL;
- ret = file_find(ctx, &file_list, ".", args[i], True);
+ ret = file_find(ctx, &file_list, ".", args[i], true);
if (ret) {
free_file_list(file_list);
continue;
@@ -1445,7 +1455,7 @@ static int cmd_mput(struct smbclient_context *ctx, const char **args)
dos_format(rname);
- do_put(ctx, rname, lname, False);
+ do_put(ctx, rname, lname, false);
}
free_file_list(file_list);
SAFE_FREE(quest);
@@ -1482,7 +1492,7 @@ static int cmd_print(struct smbclient_context *ctx, const char **args)
slprintf(rname, sizeof(rname)-1, "stdin-%d", (int)getpid());
}
- return do_put(ctx, rname, lname, False);
+ return do_put(ctx, rname, lname, false);
}
@@ -2460,7 +2470,7 @@ static int cmd_reget(struct smbclient_context *ctx, const char **args)
else
local_name = talloc_strdup(ctx, args[1]);
- return do_get(ctx, remote_name, local_name, True);
+ return do_get(ctx, remote_name, local_name, true);
}
/****************************************************************************
@@ -2489,7 +2499,7 @@ static int cmd_reput(struct smbclient_context *ctx, const char **args)
dos_clean_name(remote_name);
- return do_put(ctx, remote_name, local_name, True);
+ return do_put(ctx, remote_name, local_name, true);
}
@@ -2535,7 +2545,7 @@ static void display_share_result(struct srvsvc_NetShareCtr1 *ctr1)
/****************************************************************************
try and browse available shares on a host
****************************************************************************/
-static BOOL browse_host(const char *query_host)
+static bool browse_host(const char *query_host)
{
struct dcerpc_pipe *p;
char *binding;
@@ -2554,7 +2564,7 @@ static BOOL browse_host(const char *query_host)
d_printf("Failed to connect to %s - %s\n",
binding, nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
@@ -2584,19 +2594,19 @@ static BOOL browse_host(const char *query_host)
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
d_printf("Failed NetShareEnumAll %s - %s/%s\n",
binding, nt_errstr(status), win_errstr(r.out.result));
- return False;
+ return false;
}
- return False;
+ return false;
}
/****************************************************************************
try and browse available connections on a host
****************************************************************************/
-static BOOL list_servers(const char *wk_grp)
+static bool list_servers(const char *wk_grp)
{
d_printf("REWRITE: list servers not implemented\n");
- return False;
+ return false;
}
/* Some constants for completing filename arguments */
@@ -2830,7 +2840,7 @@ static char **remote_completion(const char *text, int len)
if (info.count == 2)
info.matches[0] = strdup(info.matches[1]);
else {
- info.matches[0] = malloc(info.samelen+1);
+ info.matches[0] = malloc_array_p(char, info.samelen+1);
if (!info.matches[0])
goto cleanup;
strncpy(info.matches[0], info.matches[1], info.samelen);
@@ -2912,7 +2922,7 @@ static char **completion_fn(const char *text, int start, int end)
matches[0] = strdup(matches[1]);
break;
default:
- matches[0] = malloc(samelen+1);
+ matches[0] = malloc_array_p(char, samelen+1);
if (!matches[0])
goto cleanup;
strncpy(matches[0], matches[1], samelen);
@@ -3045,10 +3055,10 @@ static struct smbclient_context *do_connect(TALLOC_CTX *mem_ctx,
/****************************************************************************
handle a -L query
****************************************************************************/
-static int do_host_query(const char *query_host)
+static int do_host_query(const char *query_host, const char *workgroup)
{
browse_host(query_host);
- list_servers(lp_workgroup());
+ list_servers(workgroup);
return(0);
}
@@ -3062,7 +3072,7 @@ static int do_message_op(const char *desthost, const char *destip, int name_type
const char *server_name;
struct smbcli_state *cli;
- make_nbt_name_client(&calling, lp_netbios_name());
+ make_nbt_name_client(&calling, lp_netbios_name(global_loadparm));
nbt_choose_called_name(NULL, &called, desthost, name_type);
@@ -3095,7 +3105,7 @@ static int do_message_op(const char *desthost, const char *destip, int name_type
const char *dest_ip = NULL;
int opt;
const char *query_host = NULL;
- BOOL message = False;
+ bool message = false;
const char *desthost = NULL;
#ifdef KANJI
const char *term_code = KANJI;
@@ -3150,7 +3160,7 @@ static int do_message_op(const char *desthost, const char *destip, int name_type
name_type = 0x03;
desthost = strdup(poptGetOptArg(pc));
if( 0 == port ) port = 139;
- message = True;
+ message = true;
break;
case 'I':
dest_ip = poptGetOptArg(pc);
@@ -3209,7 +3219,7 @@ static int do_message_op(const char *desthost, const char *destip, int name_type
}
if (query_host) {
- return do_host_query(query_host);
+ return do_host_query(query_host, lp_workgroup(global_loadparm));
}
if (message) {
diff --git a/source4/client/config.mk b/source4/client/config.mk
index ebac2a4bb0..9f785004a0 100644
--- a/source4/client/config.mk
+++ b/source4/client/config.mk
@@ -15,7 +15,8 @@ PRIVATE_DEPENDENCIES = \
LIBCLI_LSA \
LIBPOPT \
POPT_SAMBA \
- POPT_CREDENTIALS
+ POPT_CREDENTIALS \
+ LIBCLI_RAW
# End BINARY smbclient
#################################
diff --git a/source4/client/smbmount.c b/source4/client/smbmount.c
index f15b1f7030..31e7628fcd 100644
--- a/source4/client/smbmount.c
+++ b/source4/client/smbmount.c
@@ -34,18 +34,18 @@ static pstring service;
static pstring options;
static struct ipv4_addr dest_ip;
-static BOOL have_ip;
+static bool have_ip;
static int smb_port = 0;
-static BOOL got_user;
-static BOOL got_pass;
+static bool got_user;
+static bool got_pass;
static uid_t mount_uid;
static gid_t mount_gid;
static int mount_ro;
static uint_t mount_fmask;
static uint_t mount_dmask;
-static BOOL use_kerberos;
+static bool use_kerberos;
/* TODO: Add code to detect smbfs version in kernel */
-static BOOL status32_smbfs = False;
+static bool status32_smbfs = false;
static void usage(void);
@@ -155,10 +155,10 @@ static struct smbcli_state *do_connection(char *the_service)
/* SPNEGO doesn't work till we get NTSTATUS error support */
/* But it is REQUIRED for kerberos authentication */
- if(!use_kerberos) c->use_spnego = False;
+ if(!use_kerberos) c->use_spnego = false;
/* The kernel doesn't yet know how to sign it's packets */
- c->sign_info.allow_smb_signing = False;
+ c->sign_info.allow_smb_signing = false;
/* Use kerberos authentication if specified */
c->use_kerberos = use_kerberos;
@@ -204,7 +204,7 @@ static struct smbcli_state *do_connection(char *the_service)
c->capabilities &= ~(CAP_UNICODE | CAP_LARGE_FILES | CAP_NT_SMBS |
CAP_NT_FIND | CAP_STATUS32 |
CAP_LEVEL_II_OPLOCKS);
- c->force_dos_errors = True;
+ c->force_dos_errors = true;
}
if (!smbcli_session_setup(c, username,
@@ -234,7 +234,7 @@ static struct smbcli_state *do_connection(char *the_service)
DEBUG(4,("%d: tconx ok\n", sys_getpid()));
- got_pass = True;
+ got_pass = true;
return c;
}
@@ -539,7 +539,7 @@ static void get_password_file(void)
{
int fd = -1;
char *p;
- BOOL close_it = False;
+ bool close_it = false;
pstring spec;
char pass[128];
@@ -547,7 +547,7 @@ static void get_password_file(void)
pstrcpy(spec, "descriptor ");
pstrcat(spec, p);
sscanf(p, "%d", &fd);
- close_it = False;
+ close_it = false;
} else if ((p = getenv("PASSWD_FILE")) != NULL) {
fd = open(p, O_RDONLY, 0);
pstrcpy(spec, p);
@@ -556,7 +556,7 @@ static void get_password_file(void)
spec, strerror(errno));
exit(1);
}
- close_it = True;
+ close_it = true;
}
for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */
@@ -637,7 +637,7 @@ static void read_credentials_file(char *filename)
if (strwicmp("password", param) == 0)
{
pstrcpy(password, val);
- got_pass = True;
+ got_pass = true;
}
else if (strwicmp("username", param) == 0) {
pstrcpy(username, val);
@@ -750,12 +750,12 @@ static void parse_mount_smb(int argc, char **argv)
if (!strcmp(opts, "username") ||
!strcmp(opts, "logon")) {
char *lp;
- got_user = True;
+ got_user = true;
pstrcpy(username,opteq+1);
if ((lp=strchr_m(username,'%'))) {
*lp = 0;
pstrcpy(password,lp+1);
- got_pass = True;
+ got_pass = true;
memset(strchr_m(opteq+1,'%')+1,'X',strlen(password));
}
if ((lp=strchr_m(username,'/'))) {
@@ -765,7 +765,7 @@ static void parse_mount_smb(int argc, char **argv)
} else if(!strcmp(opts, "passwd") ||
!strcmp(opts, "password")) {
pstrcpy(password,opteq+1);
- got_pass = True;
+ got_pass = true;
memset(opteq+1,'X',strlen(password));
} else if(!strcmp(opts, "credentials")) {
pstrcpy(credentials,opteq+1);
@@ -789,7 +789,7 @@ static void parse_mount_smb(int argc, char **argv)
fprintf(stderr,"Can't resolve address %s\n", opteq+1);
exit(1);
}
- have_ip = True;
+ have_ip = true;
} else if(!strcmp(opts, "workgroup")) {
pstrcpy(workgroup,opteq+1);
} else if(!strcmp(opts, "sockopt")) {
@@ -807,11 +807,11 @@ static void parse_mount_smb(int argc, char **argv)
exit(1);
} else if(!strcmp(opts, "guest")) {
*password = '\0';
- got_pass = True;
+ got_pass = true;
} else if(!strcmp(opts, "krb")) {
#ifdef HAVE_KRB5
- use_kerberos = True;
+ use_kerberos = true;
if(!status32_smbfs)
fprintf(stderr, "Warning: kerberos support will only work for samba servers\n");
#else
@@ -873,7 +873,7 @@ static void parse_mount_smb(int argc, char **argv)
if ((p=strchr_m(username,'%'))) {
*p = 0;
pstrcpy(password,p+1);
- got_pass = True;
+ got_pass = true;
memset(strchr_m(getenv("USER"),'%')+1,'X',strlen(password));
}
strupper(username);
@@ -881,19 +881,19 @@ static void parse_mount_smb(int argc, char **argv)
if (getenv("PASSWD")) {
pstrcpy(password,getenv("PASSWD"));
- got_pass = True;
+ got_pass = true;
}
if (getenv("PASSWD_FD") || getenv("PASSWD_FILE")) {
get_password_file();
- got_pass = True;
+ got_pass = true;
}
if (*username == 0 && getenv("LOGNAME")) {
pstrcpy(username,getenv("LOGNAME"));
}
- if (!lp_load()) {
+ if (!lp_load(dyn_CONFIGFILE)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
lp_config_file());
}
@@ -901,7 +901,7 @@ static void parse_mount_smb(int argc, char **argv)
parse_mount_smb(argc, argv);
if (use_kerberos && !got_user) {
- got_pass = True;
+ got_pass = true;
}
if (*credentials != 0) {
@@ -911,7 +911,7 @@ static void parse_mount_smb(int argc, char **argv)
DEBUG(3,("mount.smbfs started (version %s)\n", VERSION));
if (*workgroup == 0) {
- pstrcpy(workgroup,lp_workgroup());
+ pstrcpy(workgroup, lp_workgroup());
}
if (!*my_netbios_name) {
diff --git a/source4/client/smbspool.c b/source4/client/smbspool.c
index 45407b1acc..7270942037 100644
--- a/source4/client/smbspool.c
+++ b/source4/client/smbspool.c
@@ -176,7 +176,7 @@ static int smb_print(struct smbcli_state *, char *, FILE *);
setup_logging(argv[0], DEBUG_STDOUT);
- if (!lp_load()) {
+ if (!lp_load(dyn_CONFIGFILE)) {
fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file());
return (1);
}
diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c
index 606ca9b8b1..673ce2be4e 100644
--- a/source4/cluster/cluster.c
+++ b/source4/cluster/cluster.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "cluster/cluster.h"
#include "cluster/cluster_private.h"
+#include "librpc/gen_ndr/misc.h"
static struct cluster_ops *ops;
diff --git a/source4/cluster/ctdb/brlock_ctdb.c b/source4/cluster/ctdb/brlock_ctdb.c
index fecc88da45..8b633358a3 100644
--- a/source4/cluster/ctdb/brlock_ctdb.c
+++ b/source4/cluster/ctdb/brlock_ctdb.c
@@ -148,7 +148,7 @@ static struct brl_handle *brl_ctdb_create_handle(TALLOC_CTX *mem_ctx, struct ntv
/*
see if two locking contexts are equal
*/
-static BOOL brl_ctdb_same_context(struct lock_context *ctx1, struct lock_context *ctx2)
+static bool brl_ctdb_same_context(struct lock_context *ctx1, struct lock_context *ctx2)
{
return (cluster_id_equal(&ctx1->server, &ctx2->server) &&
ctx1->smbpid == ctx2->smbpid &&
@@ -158,7 +158,7 @@ static BOOL brl_ctdb_same_context(struct lock_context *ctx1, struct lock_context
/*
see if lck1 and lck2 overlap
*/
-static BOOL brl_ctdb_overlap(struct lock_struct *lck1,
+static bool brl_ctdb_overlap(struct lock_struct *lck1,
struct lock_struct *lck2)
{
/* this extra check is not redundent - it copes with locks
@@ -166,35 +166,35 @@ static BOOL brl_ctdb_overlap(struct lock_struct *lck1,
if (lck1->size != 0 &&
lck1->start == lck2->start &&
lck1->size == lck2->size) {
- return True;
+ return true;
}
if (lck1->start >= (lck2->start+lck2->size) ||
lck2->start >= (lck1->start+lck1->size)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
See if lock2 can be added when lock1 is in place.
*/
-static BOOL brl_ctdb_conflict(struct lock_struct *lck1,
+static bool brl_ctdb_conflict(struct lock_struct *lck1,
struct lock_struct *lck2)
{
/* pending locks don't conflict with anything */
if (lck1->lock_type >= PENDING_READ_LOCK ||
lck2->lock_type >= PENDING_READ_LOCK) {
- return False;
+ return false;
}
if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK) {
- return False;
+ return false;
}
if (brl_ctdb_same_context(&lck1->context, &lck2->context) &&
lck2->lock_type == READ_LOCK && lck1->ntvfs == lck2->ntvfs) {
- return False;
+ return false;
}
return brl_ctdb_overlap(lck1, lck2);
@@ -205,16 +205,16 @@ static BOOL brl_ctdb_conflict(struct lock_struct *lck1,
Check to see if this lock conflicts, but ignore our own locks on the
same fnum only.
*/
-static BOOL brl_ctdb_conflict_other(struct lock_struct *lck1, struct lock_struct *lck2)
+static bool brl_ctdb_conflict_other(struct lock_struct *lck1, struct lock_struct *lck2)
{
/* pending locks don't conflict with anything */
if (lck1->lock_type >= PENDING_READ_LOCK ||
lck2->lock_type >= PENDING_READ_LOCK) {
- return False;
+ return false;
}
if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK)
- return False;
+ return false;
/*
* note that incoming write calls conflict with existing READ
@@ -224,7 +224,7 @@ static BOOL brl_ctdb_conflict_other(struct lock_struct *lck1, struct lock_struct
if (brl_ctdb_same_context(&lck1->context, &lck2->context) &&
lck1->ntvfs == lck2->ntvfs &&
(lck2->lock_type == READ_LOCK || lck1->lock_type == WRITE_LOCK)) {
- return False;
+ return false;
}
return brl_ctdb_overlap(lck1, lck2);
diff --git a/source4/cluster/ctdb/client/ctdb_client.c b/source4/cluster/ctdb/client/ctdb_client.c
index b569a69c8d..84c095ec8a 100644
--- a/source4/cluster/ctdb/client/ctdb_client.c
+++ b/source4/cluster/ctdb/client/ctdb_client.c
@@ -79,7 +79,7 @@ int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
c->key = call->key;
c->call_data = &call->call_data;
- c->record_data.dptr = talloc_memdup(c, data->dptr, data->dsize);
+ c->record_data.dptr = (unsigned char *)talloc_memdup(c, data->dptr, data->dsize);
c->record_data.dsize = data->dsize;
CTDB_NO_MEMORY(ctdb, c->record_data.dptr);
c->new_data = NULL;
@@ -311,9 +311,10 @@ int ctdb_call_recv(struct ctdb_client_call_state *state, struct ctdb_call *call)
}
if (state->call.reply_data.dsize) {
- call->reply_data.dptr = talloc_memdup(state->ctdb_db,
- state->call.reply_data.dptr,
- state->call.reply_data.dsize);
+ call->reply_data.dptr = (unsigned char *)talloc_memdup(
+ state->ctdb_db,
+ state->call.reply_data.dptr,
+ state->call.reply_data.dsize);
call->reply_data.dsize = state->call.reply_data.dsize;
} else {
call->reply_data.dptr = NULL;
@@ -484,7 +485,7 @@ int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
/*
tell the daemon we no longer want a srvid
*/
-int ctdb_remove_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data)
+static int ctdb_remove_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data)
{
int res;
int32_t status;
@@ -580,7 +581,7 @@ struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TALL
h->ctdb_db = ctdb_db;
h->key = key;
- h->key.dptr = talloc_memdup(h, key.dptr, key.dsize);
+ h->key.dptr = (unsigned char *)talloc_memdup(h, key.dptr, key.dsize);
if (h->key.dptr == NULL) {
talloc_free(h);
return NULL;
@@ -812,7 +813,7 @@ int ctdb_control(struct ctdb_context *ctdb, uint32_t destnode, uint64_t srvid,
if (outdata) {
*outdata = state->outdata;
- outdata->dptr = talloc_memdup(mem_ctx, outdata->dptr, outdata->dsize);
+ outdata->dptr = (unsigned char *)talloc_memdup(mem_ctx, outdata->dptr, outdata->dsize);
}
*status = state->status;
@@ -1156,10 +1157,10 @@ int ctdb_ctrl_pulldb(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid
rec = (struct ctdb_rec_data *)&reply->data[0];
for (i=0;i<reply->count;i++) {
- keys->keys[i].dptr = talloc_memdup(mem_ctx, &rec->data[0], rec->keylen);
+ keys->keys[i].dptr = (unsigned char *)talloc_memdup(mem_ctx, &rec->data[0], rec->keylen);
keys->keys[i].dsize = rec->keylen;
- keys->data[i].dptr = talloc_memdup(mem_ctx, &rec->data[keys->keys[i].dsize], rec->datalen);
+ keys->data[i].dptr = (unsigned char *)talloc_memdup(mem_ctx, &rec->data[keys->keys[i].dsize], rec->datalen);
keys->data[i].dsize = rec->datalen;
if (keys->data[i].dsize < sizeof(struct ctdb_ltdb_header)) {
@@ -1333,7 +1334,7 @@ int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32
int32_t res;
TDB_DATA data;
- data.dptr = discard_const(name);
+ data.dptr = (unsigned char *)discard_const(name);
data.dsize = strlen(name)+1;
ret = ctdb_control(ctdb, destnode, 0,
@@ -1468,7 +1469,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name)
ctdb_db->db_name = talloc_strdup(ctdb_db, name);
CTDB_NO_MEMORY_NULL(ctdb, ctdb_db->db_name);
- data.dptr = discard_const(name);
+ data.dptr = (unsigned char *)discard_const(name);
data.dsize = strlen(name)+1;
/* tell ctdb daemon to attach */
@@ -1557,7 +1558,7 @@ static void traverse_handler(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA
if (data.dsize < sizeof(uint32_t) ||
d->length != data.dsize) {
DEBUG(0,("Bad data size %u in traverse_handler\n", (unsigned)data.dsize));
- state->done = True;
+ state->done = true;
return;
}
@@ -1568,12 +1569,12 @@ static void traverse_handler(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA
if (key.dsize == 0 && data.dsize == 0) {
/* end of traverse */
- state->done = True;
+ state->done = true;
return;
}
if (state->fn(ctdb, key, data, state->private_data) != 0) {
- state->done = True;
+ state->done = true;
}
state->count++;
@@ -1593,7 +1594,7 @@ int ctdb_traverse(struct ctdb_db_context *ctdb_db, ctdb_traverse_func fn, void *
uint64_t srvid = (getpid() | 0xFLL<<60);
struct traverse_state state;
- state.done = False;
+ state.done = false;
state.count = 0;
state.private_data = private_data;
state.fn = fn;
@@ -1929,7 +1930,7 @@ int ctdb_ctrl_get_tunable(struct ctdb_context *ctdb,
int ret;
data.dsize = offsetof(struct ctdb_control_get_tunable, name) + strlen(name) + 1;
- data.dptr = talloc_size(ctdb, data.dsize);
+ data.dptr = (unsigned char *)talloc_size(ctdb, data.dsize);
CTDB_NO_MEMORY(ctdb, data.dptr);
t = (struct ctdb_control_get_tunable *)data.dptr;
@@ -1970,7 +1971,7 @@ int ctdb_ctrl_set_tunable(struct ctdb_context *ctdb,
int ret;
data.dsize = offsetof(struct ctdb_control_set_tunable, name) + strlen(name) + 1;
- data.dptr = talloc_size(ctdb, data.dsize);
+ data.dptr = talloc_array(ctdb, unsigned char, data.dsize);
CTDB_NO_MEMORY(ctdb, data.dptr);
t = (struct ctdb_control_set_tunable *)data.dptr;
diff --git a/source4/cluster/ctdb/common/ctdb_io.c b/source4/cluster/ctdb/common/ctdb_io.c
index 3cc522b58a..ca9c635878 100644
--- a/source4/cluster/ctdb/common/ctdb_io.c
+++ b/source4/cluster/ctdb/common/ctdb_io.c
@@ -73,8 +73,9 @@ static void queue_io_read(struct ctdb_queue *queue)
}
- queue->partial.data = talloc_realloc_size(queue, queue->partial.data,
- num_ready + queue->partial.length);
+ queue->partial.data = talloc_realloc(queue, queue->partial.data,
+ uint8_t,
+ num_ready + queue->partial.length);
if (queue->partial.data == NULL) {
DEBUG(0,("read error alloc failed for %u\n",
@@ -114,7 +115,7 @@ static void queue_io_read(struct ctdb_queue *queue)
DEBUG(0,("Invalid packet of length 0\n"));
goto failed;
}
- d2 = talloc_memdup(queue, data, len);
+ d2 = (uint8_t *)talloc_memdup(queue, data, len);
if (d2 == NULL) {
DEBUG(0,("read error memdup failed for %u\n", len));
/* sigh */
@@ -131,7 +132,7 @@ static void queue_io_read(struct ctdb_queue *queue)
queue->partial.data = data;
queue->partial.length = nread;
} else {
- queue->partial.data = talloc_memdup(queue, data, nread);
+ queue->partial.data = (uint8_t *)talloc_memdup(queue, data, nread);
if (queue->partial.data == NULL) {
DEBUG(0,("read error memdup partial failed for %u\n",
(unsigned)nread));
@@ -265,7 +266,7 @@ int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length)
pkt = talloc(queue, struct ctdb_queue_pkt);
CTDB_NO_MEMORY(queue->ctdb, pkt);
- pkt->data = talloc_memdup(pkt, data, length2);
+ pkt->data = (uint8_t *)talloc_memdup(pkt, data, length2);
CTDB_NO_MEMORY(queue->ctdb, pkt->data);
pkt->length = length2;
diff --git a/source4/cluster/ctdb/common/ctdb_ltdb.c b/source4/cluster/ctdb/common/ctdb_ltdb.c
index 7db1523ca1..8d8b4fd24a 100644
--- a/source4/cluster/ctdb/common/ctdb_ltdb.c
+++ b/source4/cluster/ctdb/common/ctdb_ltdb.c
@@ -106,7 +106,7 @@ int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
if (data) {
data->dsize = rec.dsize - sizeof(struct ctdb_ltdb_header);
- data->dptr = talloc_memdup(mem_ctx,
+ data->dptr = (unsigned char *)talloc_memdup(mem_ctx,
sizeof(struct ctdb_ltdb_header)+rec.dptr,
data->dsize);
}
@@ -144,7 +144,7 @@ int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
}
rec.dsize = sizeof(*header) + data.dsize;
- rec.dptr = talloc_size(ctdb, rec.dsize);
+ rec.dptr = (unsigned char *)talloc_size(ctdb, rec.dsize);
CTDB_NO_MEMORY(ctdb, rec.dptr);
memcpy(rec.dptr, header, sizeof(*header));
diff --git a/source4/cluster/ctdb/common/ctdb_util.c b/source4/cluster/ctdb/common/ctdb_util.c
index 54b1e4e7ff..f11388331d 100644
--- a/source4/cluster/ctdb/common/ctdb_util.c
+++ b/source4/cluster/ctdb/common/ctdb_util.c
@@ -51,7 +51,7 @@ void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...)
/*
a fatal internal error occurred - no hope for recovery
*/
-void ctdb_fatal(struct ctdb_context *ctdb, const char *msg)
+_NORETURN_ void ctdb_fatal(struct ctdb_context *ctdb, const char *msg)
{
DEBUG(0,("ctdb fatal error: %s\n", msg));
abort();
diff --git a/source4/cluster/ctdb/ctdb_cluster.c b/source4/cluster/ctdb/ctdb_cluster.c
index 8acb794251..d8860aabd0 100644
--- a/source4/cluster/ctdb/ctdb_cluster.c
+++ b/source4/cluster/ctdb/ctdb_cluster.c
@@ -28,6 +28,8 @@
#include "include/ctdb.h"
#include "db_wrap.h"
#include "lib/util/dlinklist.h"
+#include "param/param.h"
+#include "librpc/gen_ndr/misc.h"
/* a linked list of messaging handlers, allowing incoming messages
to be directed to the right messaging context */
@@ -52,7 +54,7 @@ struct cluster_state {
*/
static struct server_id ctdb_id(struct cluster_ops *ops, uint32_t id)
{
- struct cluster_state *state = ops->private;
+ struct cluster_state *state = (struct cluster_state *)ops->private;
struct ctdb_context *ctdb = state->ctdb;
struct server_id server_id;
server_id.node = ctdb_get_vnn(ctdb);
@@ -80,7 +82,7 @@ static struct tdb_wrap *ctdb_tdb_tmp_open(struct cluster_ops *ops,
TALLOC_CTX *mem_ctx, const char *dbname,
int flags)
{
- const char *dir = lp_parm_string(-1, "ctdb", "shared data");
+ const char *dir = lp_parm_string(global_loadparm, NULL, "ctdb", "shared data");
char *path;
struct tdb_wrap *w;
if (dir == NULL) {
@@ -100,7 +102,7 @@ static struct tdb_wrap *ctdb_tdb_tmp_open(struct cluster_ops *ops,
*/
static void *ctdb_backend_handle(struct cluster_ops *ops)
{
- struct cluster_state *state = ops->private;
+ struct cluster_state *state = (struct cluster_state *)ops->private;
return (void *)state->ctdb;
}
@@ -138,7 +140,7 @@ static NTSTATUS ctdb_message_init(struct cluster_ops *ops,
struct server_id server,
cluster_message_fn_t handler)
{
- struct cluster_state *state = ops->private;
+ struct cluster_state *state = (struct cluster_state *)ops->private;
struct ctdb_handler_state *h;
int ret;
@@ -169,7 +171,7 @@ static NTSTATUS ctdb_message_init(struct cluster_ops *ops,
static NTSTATUS ctdb_message_send(struct cluster_ops *ops,
struct server_id server, DATA_BLOB *data)
{
- struct cluster_state *state = ops->private;
+ struct cluster_state *state = (struct cluster_state *)ops->private;
struct ctdb_context *ctdb = state->ctdb;
TDB_DATA tdata;
int ret;
@@ -200,7 +202,7 @@ void cluster_ctdb_init(struct event_context *ev, const char *model)
struct cluster_state *state;
int ret;
- if (!lp_parm_bool(-1, "ctdb", "enable", False)) {
+ if (!lp_parm_bool(global_loadparm, NULL, "ctdb", "enable", false)) {
return;
}
diff --git a/source4/cluster/ctdb/opendb_ctdb.c b/source4/cluster/ctdb/opendb_ctdb.c
index f894af839e..7753992df8 100644
--- a/source4/cluster/ctdb/opendb_ctdb.c
+++ b/source4/cluster/ctdb/opendb_ctdb.c
@@ -49,12 +49,13 @@
#include "ntvfs/common/ntvfs_common.h"
#include "cluster/cluster.h"
#include "include/ctdb.h"
+#include "param/param.h"
struct odb_context {
struct ctdb_context *ctdb;
struct ctdb_db_context *ctdb_db;
struct ntvfs_context *ntvfs_ctx;
- BOOL oplocks;
+ bool oplocks;
};
/*
@@ -96,7 +97,7 @@ static struct odb_context *odb_ctdb_init(TALLOC_CTX *mem_ctx,
odb->ntvfs_ctx = ntvfs_ctx;
/* leave oplocks disabled by default until the code is working */
- odb->oplocks = lp_parm_bool(-1, "opendb", "oplocks", False);
+ odb->oplocks = lp_parm_bool(global_loadparm, NULL, "opendb", "oplocks", false);
return odb;
}
@@ -263,7 +264,7 @@ static NTSTATUS odb_oplock_break_send(struct odb_context *odb, struct opendb_ent
*/
static NTSTATUS odb_ctdb_open_file(struct odb_lock *lck, void *file_handle,
uint32_t stream_id, uint32_t share_access,
- uint32_t access_mask, BOOL delete_on_close,
+ uint32_t access_mask, bool delete_on_close,
const char *path,
uint32_t oplock_level, uint32_t *oplock_granted)
{
@@ -273,7 +274,7 @@ static NTSTATUS odb_ctdb_open_file(struct odb_lock *lck, void *file_handle,
struct opendb_file file;
NTSTATUS status;
- if (odb->oplocks == False) {
+ if (odb->oplocks == false) {
oplock_level = OPLOCK_NONE;
}
@@ -404,7 +405,7 @@ static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle)
if (file_handle == file.entries[i].file_handle &&
cluster_id_equal(&odb->ntvfs_ctx->server_id, &file.entries[i].server)) {
if (file.entries[i].delete_on_close) {
- file.delete_on_close = True;
+ file.delete_on_close = true;
}
if (i < file.num_entries-1) {
memmove(file.entries+i, file.entries+i+1,
@@ -491,7 +492,7 @@ static NTSTATUS odb_ctdb_rename(struct odb_lock *lck, const char *path)
/*
update delete on close flag on an open file
*/
-static NTSTATUS odb_ctdb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_close)
+static NTSTATUS odb_ctdb_set_delete_on_close(struct odb_lock *lck, bool del_on_close)
{
NTSTATUS status;
struct opendb_file file;
@@ -509,7 +510,7 @@ static NTSTATUS odb_ctdb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_c
people still have the file open
*/
static NTSTATUS odb_ctdb_get_delete_on_close(struct odb_context *odb,
- DATA_BLOB *key, BOOL *del_on_close,
+ DATA_BLOB *key, bool *del_on_close,
int *open_count, char **path)
{
NTSTATUS status;
@@ -522,7 +523,7 @@ static NTSTATUS odb_ctdb_get_delete_on_close(struct odb_context *odb,
status = odb_pull_record(lck, &file);
if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
talloc_free(lck);
- (*del_on_close) = False;
+ (*del_on_close) = false;
return NT_STATUS_OK;
}
if (!NT_STATUS_IS_OK(status)) {
@@ -538,7 +539,7 @@ static NTSTATUS odb_ctdb_get_delete_on_close(struct odb_context *odb,
*path = talloc_strdup(odb, file.path);
NT_STATUS_HAVE_NO_MEMORY(*path);
if (file.num_entries == 1 && file.entries[0].delete_on_close) {
- (*del_on_close) = True;
+ (*del_on_close) = true;
}
}
diff --git a/source4/cluster/local.c b/source4/cluster/local.c
index dc4759ebae..2abe422d5a 100644
--- a/source4/cluster/local.c
+++ b/source4/cluster/local.c
@@ -25,6 +25,8 @@
#include "lib/tdb/include/tdb.h"
#include "db_wrap.h"
#include "system/filesys.h"
+#include "param/param.h"
+#include "librpc/gen_ndr/misc.h"
/*
server a server_id for the local node
@@ -56,7 +58,7 @@ static struct tdb_wrap *local_tdb_tmp_open(struct cluster_ops *ops,
TALLOC_CTX *mem_ctx, const char *dbname,
int flags)
{
- char *path = smbd_tmp_path(mem_ctx, dbname);
+ char *path = smbd_tmp_path(mem_ctx, global_loadparm, dbname);
struct tdb_wrap *w;
w = tdb_wrap_open(mem_ctx, path, 0, flags,
O_RDWR|O_CREAT, 0600);
diff --git a/source4/configure.ac b/source4/configure.ac
index c947a1629a..52be29c022 100644
--- a/source4/configure.ac
+++ b/source4/configure.ac
@@ -27,26 +27,53 @@ m4_include(lib/charset/config.m4)
m4_include(lib/socket/config.m4)
m4_include(nsswitch/nsstest.m4)
-#SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.0,
-# [samba_cv_internal_talloc=no],
-# [samba_cv_internal_talloc=yes])
-samba_cv_internal_talloc=yes
-if test x"$samba_cv_internal_talloc" = x"yes"; then
- m4_include(lib/talloc/libtalloc.m4)
- SMB_INCLUDE_MK(lib/talloc/config.mk)
-fi
-
-#SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.0,
-# [samba_cv_internal_tdb=no],
-# [samba_cv_internal_tdb=yes])
-samba_cv_internal_tdb=yes
-if test x"$samba_cv_internal_tdb" = x"yes"; then
- m4_include(lib/tdb/libtdb.m4)
- SMB_INCLUDE_MK(lib/tdb/config.mk)
-fi
+SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.1.0,
+ [],
+ [
+ m4_include(lib/talloc/libtalloc.m4)
+ SMB_INCLUDE_MK(lib/talloc/config.mk)
+ ]
+)
+
+SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.0,
+ [],
+ [
+ m4_include(lib/tdb/libtdb.m4)
+ SMB_INCLUDE_MK(lib/tdb/config.mk)
+ ]
+)
+
+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
+ ],
+ [
+ # Here we need to do some tricks
+ # with AC_CONFIG_COMMANDS_PRE
+ # as that's the deferrs the commands
+ # to location after $prefix and $exec_prefix
+ # have usefull values and directly before
+ # creating config.status.
+ #
+ # The 'eval eval echo' trick is used to
+ # actually get the raw absolute directory
+ # path as this is needed in config.h
+ define_ldb_modulesdir=yes
+ AC_CONFIG_COMMANDS_PRE([
+ if test x"$define_ldb_modulesdir" = x"yes";then
+ LDB_MODULESDIR=`eval eval echo ${modulesdir}/ldb`
+ AC_DEFINE_UNQUOTED(LDB_MODULESDIR, "${LDB_MODULESDIR}" , [ldb Modules directory])
+ fi
+ ])
+ m4_include(lib/ldb/sqlite3.m4)
+ m4_include(lib/ldb/libldb.m4)
+ SMB_INCLUDE_MK(lib/ldb/config.mk)
+ ]
+)
-m4_include(lib/ldb/sqlite3.m4)
-m4_include(lib/ldb/libldb.m4)
m4_include(lib/tls/config.m4)
m4_include(lib/events/config.m4)
diff --git a/source4/dsdb/common/flags.h b/source4/dsdb/common/flags.h
index 8de3f6dc19..36111418e2 100644
--- a/source4/dsdb/common/flags.h
+++ b/source4/dsdb/common/flags.h
@@ -91,6 +91,11 @@
GROUP_TYPE_ACCOUNT_GROUP| \
GROUP_TYPE_SECURITY_ENABLED \
)
+#define GTYPE_SECURITY_UNIVERSAL_GROUP ( \
+ /* 0x80000008 -2147483656 */ \
+ GROUP_TYPE_UNIVERSAL_GROUP| \
+ GROUP_TYPE_SECURITY_ENABLED \
+ )
#define GTYPE_DISTRIBUTION_GLOBAL_GROUP 0x00000002 /* 2 */
#define GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP 0x00000004 /* 4 */
#define GTYPE_DISTRIBUTION_UNIVERSAL_GROUP 0x00000008 /* 8 */
diff --git a/source4/dsdb/common/sidmap.c b/source4/dsdb/common/sidmap.c
index 8a594f3fc7..de1f3f3c7a 100644
--- a/source4/dsdb/common/sidmap.c
+++ b/source4/dsdb/common/sidmap.c
@@ -68,26 +68,26 @@ _PUBLIC_ struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx)
check the sAMAccountType field of a search result to see if
the account is a user account
*/
-static BOOL is_user_account(struct ldb_message *res)
+static bool is_user_account(struct ldb_message *res)
{
uint_t atype = samdb_result_uint(res, "sAMAccountType", 0);
if (atype && (!(atype & ATYPE_ACCOUNT))) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
check the sAMAccountType field of a search result to see if
the account is a group account
*/
-static BOOL is_group_account(struct ldb_message *res)
+static bool is_group_account(struct ldb_message *res)
{
uint_t atype = samdb_result_uint(res, "sAMAccountType", 0);
if (atype && atype == ATYPE_NORMAL_ACCOUNT) {
- return False;
+ return false;
}
- return True;
+ return true;
}
@@ -217,7 +217,7 @@ allocated_sid:
/*
see if a sid is a group - very inefficient!
*/
-_PUBLIC_ BOOL sidmap_sid_is_group(struct sidmap_context *sidmap, struct dom_sid *sid)
+_PUBLIC_ bool sidmap_sid_is_group(struct sidmap_context *sidmap, struct dom_sid *sid)
{
const char *attrs[] = { "sAMAccountType", NULL };
int ret;
@@ -225,7 +225,7 @@ _PUBLIC_ BOOL sidmap_sid_is_group(struct sidmap_context *sidmap, struct dom_sid
struct ldb_message **res;
NTSTATUS status;
struct dom_sid *domain_sid;
- BOOL is_group;
+ bool is_group;
tmp_ctx = talloc_new(sidmap);
@@ -240,19 +240,19 @@ _PUBLIC_ BOOL sidmap_sid_is_group(struct sidmap_context *sidmap, struct dom_sid
status = sidmap_primary_domain_sid(sidmap, tmp_ctx, &domain_sid);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
if (dom_sid_in_domain(domain_sid, sid)) {
uint32_t rid = sid->sub_auths[sid->num_auths-1];
if (rid >= SIDMAP_LOCAL_GROUP_BASE) {
talloc_free(tmp_ctx);
- return True;
+ return true;
}
}
talloc_free(tmp_ctx);
- return False;
+ return false;
}
/*
@@ -550,13 +550,13 @@ _PUBLIC_ NTSTATUS sidmap_allocated_sid_lookup(struct sidmap_context *sidmap,
TALLOC_CTX *mem_ctx,
const struct dom_sid *sid,
const char **name,
- uint32_t *atype)
+ enum lsa_SidType *rtype)
{
NTSTATUS status;
struct dom_sid *domain_sid;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
- uint32_t rid;
-
+ uint32_t rid, atype;
+
status = sidmap_primary_domain_sid(sidmap, tmp_ctx, &domain_sid);
if (!NT_STATUS_IS_OK(status)) {
return NT_STATUS_NO_SUCH_DOMAIN;
@@ -577,7 +577,9 @@ _PUBLIC_ NTSTATUS sidmap_allocated_sid_lookup(struct sidmap_context *sidmap,
if (rid < SIDMAP_LOCAL_GROUP_BASE) {
struct passwd *pwd;
uid_t uid = rid - SIDMAP_LOCAL_USER_BASE;
- *atype = ATYPE_NORMAL_ACCOUNT;
+ atype = ATYPE_NORMAL_ACCOUNT;
+ *rtype = samdb_atype_map(atype);
+
pwd = getpwuid(uid);
if (pwd == NULL) {
*name = talloc_asprintf(mem_ctx, "uid%u", uid);
@@ -587,7 +589,8 @@ _PUBLIC_ NTSTATUS sidmap_allocated_sid_lookup(struct sidmap_context *sidmap,
} else {
struct group *grp;
gid_t gid = rid - SIDMAP_LOCAL_GROUP_BASE;
- *atype = ATYPE_LOCAL_GROUP;
+ atype = ATYPE_LOCAL_GROUP;
+ *rtype = samdb_atype_map(atype);
grp = getgrgid(gid);
if (grp == NULL) {
*name = talloc_asprintf(mem_ctx, "gid%u", gid);
diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk
index 9555afd5cb..defe089ce2 100644
--- a/source4/dsdb/config.mk
+++ b/source4/dsdb/config.mk
@@ -8,7 +8,7 @@ include samdb/ldb_modules/config.mk
PUBLIC_PROTO_HEADER = samdb/samdb_proto.h
PUBLIC_HEADERS = samdb/samdb.h
PUBLIC_DEPENDENCIES = LIBCLI_LDAP HEIMDAL_KRB5
-PRIVATE_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI
+PRIVATE_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI NDR_DRSBLOBS
LDFLAGS = $(LIBRARY_ldb_OUTPUT)
OBJ_FILES = \
samdb/samdb.o \
diff --git a/source4/dsdb/repl/drepl_service.c b/source4/dsdb/repl/drepl_service.c
index b26358b3a5..e56e2e179c 100644
--- a/source4/dsdb/repl/drepl_service.c
+++ b/source4/dsdb/repl/drepl_service.c
@@ -31,6 +31,7 @@
#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/ndr_drsuapi.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"
+#include "param/param.h"
static WERROR dreplsrv_init_creds(struct dreplsrv_service *service)
{
@@ -117,7 +118,7 @@ static void dreplsrv_task_init(struct task_server *task)
struct dreplsrv_service *service;
uint32_t periodic_startup_interval;
- switch (lp_server_role()) {
+ switch (lp_server_role(global_loadparm)) {
case ROLE_STANDALONE:
task_server_terminate(task, "dreplsrv: no DSDB replication required in standalone configuration");
return;
@@ -164,8 +165,8 @@ static void dreplsrv_task_init(struct task_server *task)
return;
}
- periodic_startup_interval = lp_parm_int(-1, "dreplsrv", "periodic_startup_interval", 15); /* in seconds */
- service->periodic.interval = lp_parm_int(-1, "dreplsrv", "periodic_interval", 300); /* in seconds */
+ periodic_startup_interval = lp_parm_int(global_loadparm, NULL, "dreplsrv", "periodic_startup_interval", 15); /* in seconds */
+ service->periodic.interval = lp_parm_int(global_loadparm, NULL, "dreplsrv", "periodic_interval", 300); /* in seconds */
status = dreplsrv_periodic_schedule(service, periodic_startup_interval);
if (!W_ERROR_IS_OK(status)) {
diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c
index aa5d221fd8..3754be2e96 100644
--- a/source4/dsdb/samdb/cracknames.c
+++ b/source4/dsdb/samdb/cracknames.c
@@ -348,7 +348,7 @@ WERROR DsCrackNameOneName(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx,
struct smb_krb5_context *smb_krb5_context;
ret = smb_krb5_init_context(mem_ctx,
- ldb_get_opaque(sam_ctx, "EventContext"),
+ (struct event_context *)ldb_get_opaque(sam_ctx, "EventContext"),
&smb_krb5_context);
if (ret) {
diff --git a/source4/dsdb/samdb/ldb_modules/entryUUID.c b/source4/dsdb/samdb/ldb_modules/entryUUID.c
index f5de138b52..1a16cb8321 100644
--- a/source4/dsdb/samdb/ldb_modules/entryUUID.c
+++ b/source4/dsdb/samdb/ldb_modules/entryUUID.c
@@ -693,7 +693,7 @@ static int nsuniqueid_init(struct ldb_module *module)
static int get_seq(struct ldb_context *ldb, void *context,
struct ldb_reply *ares)
{
- unsigned long long *max_seq = context;
+ unsigned long long *max_seq = (unsigned long long *)context;
unsigned long long seq;
if (ares->type == LDB_REPLY_ENTRY) {
struct ldb_message_element *el = ldb_msg_find_element(ares->message, "contextCSN");
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c
index 6f32d22d26..d64673fdd5 100644
--- a/source4/dsdb/samdb/ldb_modules/extended_dn.c
+++ b/source4/dsdb/samdb/ldb_modules/extended_dn.c
@@ -41,16 +41,16 @@
#include <time.h>
-static BOOL is_attr_in_list(const char * const * attrs, const char *attr)
+static bool is_attr_in_list(const char * const * attrs, const char *attr)
{
int i;
for (i = 0; attrs[i]; i++) {
if (strcasecmp(attrs[i], attr) == 0)
- return True;
+ return true;
}
- return False;
+ return false;
}
static char **copy_attrs(void *mem_ctx, const char * const * attrs)
@@ -75,7 +75,7 @@ static char **copy_attrs(void *mem_ctx, const char * const * attrs)
return new;
}
-static BOOL add_attrs(void *mem_ctx, char ***attrs, const char *attr)
+static bool add_attrs(void *mem_ctx, char ***attrs, const char *attr)
{
char **new;
int num;
@@ -83,23 +83,23 @@ static BOOL add_attrs(void *mem_ctx, char ***attrs, const char *attr)
for (num = 0; (*attrs)[num]; num++);
new = talloc_realloc(mem_ctx, *attrs, char *, num + 2);
- if (!new) return False;
+ if (!new) return false;
*attrs = new;
new[num] = talloc_strdup(new, attr);
- if (!new[num]) return False;
+ if (!new[num]) return false;
new[num + 1] = NULL;
- return True;
+ return true;
}
-static BOOL inject_extended_dn(struct ldb_message *msg,
+static bool inject_extended_dn(struct ldb_message *msg,
struct ldb_context *ldb,
int type,
- BOOL remove_guid,
- BOOL remove_sid)
+ bool remove_guid,
+ bool remove_sid)
{
const struct ldb_val *val;
struct GUID guid;
@@ -112,7 +112,7 @@ static BOOL inject_extended_dn(struct ldb_message *msg,
guid = samdb_result_guid(msg, "objectGUID");
object_guid = GUID_string(msg, &guid);
if (!object_guid)
- return False;
+ return false;
if (remove_guid)
ldb_msg_remove_attr(msg, "objectGUID");
@@ -123,7 +123,7 @@ static BOOL inject_extended_dn(struct ldb_message *msg,
if (sid) {
object_sid = dom_sid_string(msg, sid);
if (!object_sid)
- return False;
+ return false;
if (remove_sid)
ldb_msg_remove_attr(msg, "objectSID");
@@ -144,24 +144,24 @@ static BOOL inject_extended_dn(struct ldb_message *msg,
}
break;
default:
- return False;
+ return false;
}
if (!new_dn)
- return False;
+ return false;
msg->dn = ldb_dn_new(msg, ldb, new_dn);
if (! ldb_dn_validate(msg->dn))
- return False;
+ return false;
val = ldb_msg_find_ldb_val(msg, "distinguishedName");
if (val) {
ldb_msg_remove_attr(msg, "distinguishedName");
if (ldb_msg_add_steal_string(msg, "distinguishedName", new_dn))
- return False;
+ return false;
}
- return True;
+ return true;
}
/* search */
@@ -172,8 +172,8 @@ struct extended_context {
int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
const char * const *attrs;
- BOOL remove_guid;
- BOOL remove_sid;
+ bool remove_guid;
+ bool remove_sid;
int extended_type;
};
@@ -229,8 +229,8 @@ static int extended_search(struct ldb_module *module, struct ldb_request *req)
ac->up_context = req->context;
ac->up_callback = req->callback;
ac->attrs = req->op.search.attrs;
- ac->remove_guid = False;
- ac->remove_sid = False;
+ ac->remove_guid = false;
+ ac->remove_sid = false;
ac->extended_type = extended_ctrl->type;
down_req = talloc_zero(req, struct ldb_request);
@@ -246,10 +246,10 @@ static int extended_search(struct ldb_module *module, struct ldb_request *req)
/* check if attrs only is specified, in that case check wether we need to modify them */
if (req->op.search.attrs) {
if (! is_attr_in_list(req->op.search.attrs, "objectGUID")) {
- ac->remove_guid = True;
+ ac->remove_guid = true;
}
if (! is_attr_in_list(req->op.search.attrs, "objectSID")) {
- ac->remove_sid = True;
+ ac->remove_sid = true;
}
if (ac->remove_guid || ac->remove_sid) {
new_attrs = copy_attrs(down_req, req->op.search.attrs);
diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c
index 2d6d8a2d80..27c13ddf60 100644
--- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c
+++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c
@@ -60,7 +60,7 @@ struct kludge_private_data {
static enum user_is what_is_user(struct ldb_module *module)
{
struct auth_session_info *session_info
- = ldb_get_opaque(module->ldb, "sessionInfo");
+ = (struct auth_session_info *)ldb_get_opaque(module->ldb, "sessionInfo");
if (!session_info) {
return ANONYMOUS;
}
@@ -87,7 +87,7 @@ static enum user_is what_is_user(struct ldb_module *module)
static const char *user_name(TALLOC_CTX *mem_ctx, struct ldb_module *module)
{
struct auth_session_info *session_info
- = ldb_get_opaque(module->ldb, "sessionInfo");
+ = (struct auth_session_info *)ldb_get_opaque(module->ldb, "sessionInfo");
if (!session_info) {
return "UNKNOWN (NULL)";
}
diff --git a/source4/dsdb/samdb/ldb_modules/local_password.c b/source4/dsdb/samdb/ldb_modules/local_password.c
index 573d2e27b9..350434df51 100644
--- a/source4/dsdb/samdb/ldb_modules/local_password.c
+++ b/source4/dsdb/samdb/ldb_modules/local_password.c
@@ -75,8 +75,8 @@ struct lpdb_context {
struct ldb_message *local_message;
- BOOL added_objectGUID;
- BOOL added_objectClass;
+ bool added_objectGUID;
+ bool added_objectClass;
struct ldb_reply *search_res;
};
@@ -660,7 +660,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request *
if (req->op.search.attrs && !ldb_attr_in_list(req->op.search.attrs, "*")) {
if (!ldb_attr_in_list(req->op.search.attrs, "objectGUID")) {
search_attrs = ldb_attr_list_copy_add(req, req->op.search.attrs, "objectGUID");
- ac->added_objectGUID = True;
+ ac->added_objectGUID = true;
if (!search_attrs) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -669,7 +669,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request *
}
if (!ldb_attr_in_list(search_attrs, "objectClass")) {
search_attrs = ldb_attr_list_copy_add(req, search_attrs, "objectClass");
- ac->added_objectClass = True;
+ ac->added_objectClass = true;
if (!search_attrs) {
return LDB_ERR_OPERATIONS_ERROR;
}
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index 0675f38c56..76e8578573 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -678,8 +678,10 @@ static int partition_extended(struct ldb_module *module, struct ldb_request *req
static int sort_compare(void *void1,
void *void2, void *opaque)
{
- struct dsdb_control_current_partition **pp1 = void1;
- struct dsdb_control_current_partition **pp2 = void2;
+ struct dsdb_control_current_partition **pp1 =
+ (struct dsdb_control_current_partition **)void1;
+ struct dsdb_control_current_partition **pp2 =
+ (struct dsdb_control_current_partition **)void2;
struct dsdb_control_current_partition *partition1 = talloc_get_type(*pp1,
struct dsdb_control_current_partition);
struct dsdb_control_current_partition *partition2 = talloc_get_type(*pp2,
@@ -692,7 +694,8 @@ static const char *relative_path(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
const char *name)
{
- const char *base_url = ldb_get_opaque(module->ldb, "ldb_url");
+ const char *base_url =
+ (const char *)ldb_get_opaque(module->ldb, "ldb_url");
char *path, *p, *full_name;
if (name == NULL) {
return NULL;
diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c
index 98061570c8..090cce2719 100644
--- a/source4/dsdb/samdb/ldb_modules/password_hash.c
+++ b/source4/dsdb/samdb/ldb_modules/password_hash.c
@@ -48,6 +48,7 @@
#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "lib/crypto/crypto.h"
+#include "param/param.h"
/* If we have decided there is reason to work on this request, then
* setup all the password hash types correctly.
@@ -91,7 +92,7 @@ struct ph_context {
};
struct domain_data {
- BOOL store_cleartext;
+ bool store_cleartext;
uint_t pwdProperties;
uint_t pwdHistoryLength;
char *netbios_domain;
@@ -340,17 +341,17 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io,
return LDB_ERR_OPERATIONS_ERROR;
}
-if (lp_parm_bool(-1, "password_hash", "create_aes_key", false)) {
-/*
- * TODO:
- *
- * w2k and w2k3 doesn't support AES, so we'll not include
- * the AES key here yet.
- *
- * Also we don't have an example supplementalCredentials blob
- * from Windows Longhorn Server with AES support
- *
- */
+ if (lp_parm_bool(global_loadparm, NULL, "password_hash", "create_aes_key", false)) {
+ /*
+ * TODO:
+ *
+ * w2k and w2k3 doesn't support AES, so we'll not include
+ * the AES key here yet.
+ *
+ * Also we don't have an example supplementalCredentials blob
+ * from Windows Longhorn Server with AES support
+ *
+ */
/*
* create ENCTYPE_AES256_CTS_HMAC_SHA1_96 key out of
* the salt and the cleartext password
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 5342c14967..8f80b5cd55 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -44,7 +44,7 @@
int samldb_notice_sid(struct ldb_module *module,
TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
-static BOOL samldb_msg_add_sid(struct ldb_module *module, struct ldb_message *msg, const char *name, const struct dom_sid *sid)
+static bool samldb_msg_add_sid(struct ldb_module *module, struct ldb_message *msg, const char *name, const struct dom_sid *sid)
{
struct ldb_val v;
NTSTATUS status;
diff --git a/source4/dsdb/samdb/ldb_modules/schema.c b/source4/dsdb/samdb/ldb_modules/schema.c
index 21e93e1715..cf923d673b 100644
--- a/source4/dsdb/samdb/ldb_modules/schema.c
+++ b/source4/dsdb/samdb/ldb_modules/schema.c
@@ -319,7 +319,7 @@ static int schema_init_attrs(struct ldb_module *module, struct schema_private_da
data->attrs[i]->max = ldb_msg_find_attr_as_int(res->msgs[i], "rangeUpper", INT_MAX);
data->attrs[i]->systemflag = ldb_msg_find_attr_as_int(res->msgs[i], "systemFlag", 0);
data->attrs[i]->searchflag = ldb_msg_find_attr_as_int(res->msgs[i], "searchFlag", 0);
- data->attrs[i]->isdefunct = ldb_msg_find_attr_as_bool(res->msgs[i], "isDefunct", False);
+ data->attrs[i]->isdefunct = ldb_msg_find_attr_as_bool(res->msgs[i], "isDefunct", false);
}
done:
@@ -397,9 +397,9 @@ static int schema_init_classes(struct ldb_module *module, struct schema_private_
*/
/* the following attributes are all optional */
- data->class[i]->systemOnly = ldb_msg_find_attr_as_bool(res->msgs[i], "systemOnly", False);
+ data->class[i]->systemOnly = ldb_msg_find_attr_as_bool(res->msgs[i], "systemOnly", false);
data->class[i]->systemflag = ldb_msg_find_attr_as_int(res->msgs[i], "systemFlag", 0);
- data->class[i]->isdefunct = ldb_msg_find_attr_as_bool(res->msgs[i], "isDefunct", False);
+ data->class[i]->isdefunct = ldb_msg_find_attr_as_bool(res->msgs[i], "isDefunct", false);
/* attributes are loaded first, so we can just go an query the attributes repo */
diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c
index 2b6a0152f5..f193731900 100644
--- a/source4/dsdb/samdb/ldb_modules/update_keytab.c
+++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c
@@ -32,6 +32,7 @@
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
#include "system/kerberos.h"
+#include "param/param.h"
struct dn_list {
struct cli_credentials *creds;
@@ -42,7 +43,7 @@ struct update_kt_private {
struct dn_list *changed_dns;
};
-static int add_modified(struct ldb_module *module, struct ldb_dn *dn, BOOL delete) {
+static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delete) {
struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private);
struct dn_list *item;
char *filter;
@@ -88,7 +89,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, BOOL delet
return LDB_ERR_OPERATIONS_ERROR;
}
- cli_credentials_set_conf(item->creds);
+ cli_credentials_set_conf(item->creds, global_loadparm);
status = cli_credentials_set_secrets(item->creds, module->ldb, NULL, filter);
talloc_free(filter);
if (NT_STATUS_IS_OK(status)) {
@@ -112,7 +113,7 @@ static int update_kt_add(struct ldb_module *module, struct ldb_request *req)
if (ret != LDB_SUCCESS) {
return ret;
}
- return add_modified(module, req->op.add.message->dn, False);
+ return add_modified(module, req->op.add.message->dn, false);
}
/* modify */
@@ -123,7 +124,7 @@ static int update_kt_modify(struct ldb_module *module, struct ldb_request *req)
if (ret != LDB_SUCCESS) {
return ret;
}
- return add_modified(module, req->op.mod.message->dn, False);
+ return add_modified(module, req->op.mod.message->dn, false);
}
/* delete */
@@ -131,7 +132,7 @@ static int update_kt_delete(struct ldb_module *module, struct ldb_request *req)
{
int ret;
/* Before we delete it, record the details */
- ret = add_modified(module, req->op.del.dn, True);
+ ret = add_modified(module, req->op.del.dn, true);
if (ret != LDB_SUCCESS) {
return ret;
}
@@ -146,7 +147,7 @@ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req)
if (ret != LDB_SUCCESS) {
return ret;
}
- return add_modified(module, req->op.rename.newdn, False);
+ return add_modified(module, req->op.rename.newdn, false);
}
/* end a transaction */
@@ -179,7 +180,7 @@ static int update_kt_del_trans(struct ldb_module *module)
talloc_free(data->changed_dns);
data->changed_dns = NULL;
- return ldb_next_end_trans(module);
+ return ldb_next_del_trans(module);
}
static int update_kt_init(struct ldb_module *module)
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index 17c40dd30d..7de873d77d 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -35,6 +35,7 @@
#include "db_wrap.h"
#include "dsdb/samdb/samdb.h"
#include "dsdb/common/flags.h"
+#include "param/param.h"
/*
connect to the SAM database
@@ -44,7 +45,8 @@ struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx,
struct auth_session_info *session_info)
{
struct ldb_context *ldb;
- ldb = ldb_wrap_connect(mem_ctx, lp_sam_url(), session_info,
+ ldb = ldb_wrap_connect(mem_ctx, global_loadparm,
+ lp_sam_url(global_loadparm), session_info,
NULL, 0, NULL);
if (!ldb) {
return NULL;
@@ -449,9 +451,7 @@ struct dom_sid *samdb_result_sid_prefix(TALLOC_CTX *mem_ctx, const struct ldb_me
*/
NTTIME samdb_result_nttime(struct ldb_message *msg, const char *attr, NTTIME default_value)
{
- const char *str = ldb_msg_find_attr_as_string(msg, attr, NULL);
- if (!str) return default_value;
- return nttime_from_string(str);
+ return ldb_msg_find_attr_as_uint64(msg, attr, default_value);
}
/*
@@ -637,17 +637,13 @@ struct ldb_message_element *samdb_find_attribute(struct ldb_context *ldb,
{
int i;
struct ldb_message_element *el = ldb_msg_find_element(msg, name);
- struct ldb_val v;
-
- v.data = discard_const_p(uint8_t, value);
- v.length = strlen(value);
if (!el) {
return NULL;
}
for (i=0;i<el->num_values;i++) {
- if (strcasecmp(value, (char *)el->values[i].data) == 0) {
+ if (ldb_attr_cmp(value, (char *)el->values[i].data) == 0) {
return el;
}
}
@@ -1072,7 +1068,7 @@ const struct dom_sid *samdb_domain_sid(struct ldb_context *ldb)
struct dom_sid *domain_sid;
/* see if we have a cached copy */
- domain_sid = ldb_get_opaque(ldb, "cache.domain_sid");
+ domain_sid = (struct dom_sid *)ldb_get_opaque(ldb, "cache.domain_sid");
if (domain_sid) {
return domain_sid;
}
@@ -1139,7 +1135,7 @@ struct ldb_dn *samdb_ntds_settings_dn(struct ldb_context *ldb)
struct ldb_dn *settings_dn;
/* see if we have a cached copy */
- settings_dn = ldb_get_opaque(ldb, "cache.settings_dn");
+ settings_dn = (struct ldb_dn *)ldb_get_opaque(ldb, "cache.settings_dn");
if (settings_dn) {
return settings_dn;
}
@@ -1192,7 +1188,7 @@ const struct GUID *samdb_ntds_invocation_id(struct ldb_context *ldb)
struct GUID *invocation_id;
/* see if we have a cached copy */
- invocation_id = ldb_get_opaque(ldb, "cache.invocation_id");
+ invocation_id = (struct GUID *)ldb_get_opaque(ldb, "cache.invocation_id");
if (invocation_id) {
return invocation_id;
}
@@ -1242,7 +1238,8 @@ bool samdb_set_ntds_invocation_id(struct ldb_context *ldb, const struct GUID *in
struct GUID *invocation_id_old;
/* see if we have a cached copy */
- invocation_id_old = ldb_get_opaque(ldb, "cache.invocation_id");
+ invocation_id_old = (struct GUID *)ldb_get_opaque(ldb,
+ "cache.invocation_id");
tmp_ctx = talloc_new(ldb);
if (tmp_ctx == NULL) {
@@ -1285,7 +1282,7 @@ const struct GUID *samdb_ntds_objectGUID(struct ldb_context *ldb)
struct GUID *ntds_guid;
/* see if we have a cached copy */
- ntds_guid = ldb_get_opaque(ldb, "cache.ntds_guid");
+ ntds_guid = (struct GUID *)ldb_get_opaque(ldb, "cache.ntds_guid");
if (ntds_guid) {
return ntds_guid;
}
@@ -1335,7 +1332,7 @@ bool samdb_set_ntds_objectGUID(struct ldb_context *ldb, const struct GUID *ntds_
struct GUID *ntds_guid_old;
/* see if we have a cached copy */
- ntds_guid_old = ldb_get_opaque(ldb, "cache.ntds_guid");
+ ntds_guid_old = (struct GUID *)ldb_get_opaque(ldb, "cache.ntds_guid");
tmp_ctx = talloc_new(ldb);
if (tmp_ctx == NULL) {
@@ -1394,19 +1391,19 @@ struct ldb_dn *samdb_server_site_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx
/*
work out if we are the PDC for the domain of the current open ldb
*/
-BOOL samdb_is_pdc(struct ldb_context *ldb)
+bool samdb_is_pdc(struct ldb_context *ldb)
{
const char *dom_attrs[] = { "fSMORoleOwner", NULL };
int ret;
struct ldb_result *dom_res;
TALLOC_CTX *tmp_ctx;
- BOOL is_pdc;
+ bool is_pdc;
struct ldb_dn *pdc;
tmp_ctx = talloc_new(ldb);
if (tmp_ctx == NULL) {
DEBUG(1, ("talloc_new failed in samdb_is_pdc"));
- return False;
+ return false;
}
ret = ldb_search(ldb, ldb_get_default_basedn(ldb), LDB_SCOPE_BASE, NULL, dom_attrs, &dom_res);
@@ -1424,9 +1421,9 @@ BOOL samdb_is_pdc(struct ldb_context *ldb)
pdc = ldb_msg_find_attr_as_dn(ldb, tmp_ctx, dom_res->msgs[0], "fSMORoleOwner");
if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), pdc) == 0) {
- is_pdc = True;
+ is_pdc = true;
} else {
- is_pdc = False;
+ is_pdc = false;
}
talloc_free(tmp_ctx);
@@ -1436,7 +1433,7 @@ BOOL samdb_is_pdc(struct ldb_context *ldb)
failed:
DEBUG(1,("Failed to find if we are the PDC for this ldb\n"));
talloc_free(tmp_ctx);
- return False;
+ return false;
}
@@ -1477,7 +1474,7 @@ struct ldb_dn *samdb_search_for_parent_domain(struct ldb_context *ldb, TALLOC_CT
/*
check that a password is sufficiently complex
*/
-static BOOL samdb_password_complexity_ok(const char *pass)
+static bool samdb_password_complexity_ok(const char *pass)
{
return check_password_quality(pass);
}
@@ -1503,7 +1500,7 @@ _PUBLIC_ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ct
const char *new_pass,
struct samr_Password *lmNewHash,
struct samr_Password *ntNewHash,
- BOOL user_change,
+ bool user_change,
enum samr_RejectReason *reject_reason,
struct samr_DomInfo1 **_dominfo)
{
@@ -1524,7 +1521,7 @@ _PUBLIC_ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ct
int sambaLMPwdHistory_len, sambaNTPwdHistory_len;
struct dom_sid *domain_sid;
struct ldb_message **res;
- BOOL restrictions;
+ bool restrictions;
int count;
time_t now = time(NULL);
NTTIME now_nt;
@@ -1741,7 +1738,7 @@ _PUBLIC_ NTSTATUS samdb_set_password_sid(struct ldb_context *ctx, TALLOC_CTX *me
const char *new_pass,
struct samr_Password *lmNewHash,
struct samr_Password *ntNewHash,
- BOOL user_change,
+ bool user_change,
enum samr_RejectReason *reject_reason,
struct samr_DomInfo1 **_dominfo)
{
@@ -1814,7 +1811,7 @@ NTSTATUS security_token_create(TALLOC_CTX *mem_ctx,
struct dom_sid *group_sid,
int n_groupSIDs,
struct dom_sid **groupSIDs,
- BOOL is_authenticated,
+ bool is_authenticated,
struct security_token **token)
{
struct security_token *ptoken;
diff --git a/source4/dsdb/schema/schema_constructed.c b/source4/dsdb/schema/schema_constructed.c
index 3ded84c184..51343817b0 100644
--- a/source4/dsdb/schema/schema_constructed.c
+++ b/source4/dsdb/schema/schema_constructed.c
@@ -38,10 +38,6 @@ static char *dsdb_subSchema_list_append(char *v, const char *list_name)
NULL
};
- if (!attrs) {
- return v;
- }
-
v = talloc_asprintf_append(v, "%s ( ", list_name);
if (!v) return NULL;
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 41b53be977..e8c8d49f5e 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -358,12 +358,12 @@ WERROR dsdb_map_int2oid(const struct dsdb_schema *schema, uint32_t in, TALLOC_CT
d_printf("%s: %s == NULL\n", __location__, attr); \
return WERR_INVALID_PARAM; \
} else { \
- (p)->elem = False; \
+ (p)->elem = false; \
} \
} else if (strcasecmp("TRUE", str) == 0) { \
- (p)->elem = True; \
+ (p)->elem = true; \
} else if (strcasecmp("FALSE", str) == 0) { \
- (p)->elem = False; \
+ (p)->elem = false; \
} else { \
d_printf("%s: %s == %s\n", __location__, attr, str); \
return WERR_INVALID_PARAM; \
@@ -396,9 +396,9 @@ WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema,
{
WERROR status;
- GET_STRING_LDB(msg, "cn", mem_ctx, attr, cn, False);
- GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, True);
- GET_STRING_LDB(msg, "attributeID", mem_ctx, attr, attributeID_oid, True);
+ GET_STRING_LDB(msg, "cn", mem_ctx, attr, cn, false);
+ GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, true);
+ GET_STRING_LDB(msg, "attributeID", mem_ctx, attr, attributeID_oid, true);
if (schema->num_prefixes == 0) {
/* set an invalid value */
attr->attributeID_id = 0xFFFFFFFF;
@@ -418,10 +418,10 @@ WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema,
GET_UINT32_LDB(msg, "searchFlags", attr, searchFlags);
GET_UINT32_LDB(msg, "systemFlags", attr, systemFlags);
- GET_BOOL_LDB(msg, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, False);
+ GET_BOOL_LDB(msg, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, false);
GET_UINT32_LDB(msg, "linkID", attr, linkID);
- GET_STRING_LDB(msg, "attributeSyntax", mem_ctx, attr, attributeSyntax_oid, True);
+ GET_STRING_LDB(msg, "attributeSyntax", mem_ctx, attr, attributeSyntax_oid, true);
if (schema->num_prefixes == 0) {
/* set an invalid value */
attr->attributeSyntax_id = 0xFFFFFFFF;
@@ -437,21 +437,21 @@ WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema,
GET_UINT32_LDB(msg, "oMSyntax", attr, oMSyntax);
GET_BLOB_LDB(msg, "oMObjectClass", mem_ctx, attr, oMObjectClass);
- GET_BOOL_LDB(msg, "isSingleValued", attr, isSingleValued, True);
+ GET_BOOL_LDB(msg, "isSingleValued", attr, isSingleValued, true);
GET_UINT32_LDB(msg, "rangeLower", attr, rangeLower);
GET_UINT32_LDB(msg, "rangeUpper", attr, rangeUpper);
- GET_BOOL_LDB(msg, "extendedCharsAllowed", attr, extendedCharsAllowed, False);
+ GET_BOOL_LDB(msg, "extendedCharsAllowed", attr, extendedCharsAllowed, false);
GET_UINT32_LDB(msg, "schemaFlagsEx", attr, schemaFlagsEx);
GET_BLOB_LDB(msg, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions);
- GET_BOOL_LDB(msg, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, False);
- GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, attr, adminDisplayName, False);
- GET_STRING_LDB(msg, "adminDescription", mem_ctx, attr, adminDescription, False);
- GET_STRING_LDB(msg, "classDisplayName", mem_ctx, attr, classDisplayName, False);
- GET_BOOL_LDB(msg, "isEphemeral", attr, isEphemeral, False);
- GET_BOOL_LDB(msg, "isDefunct", attr, isDefunct, False);
- GET_BOOL_LDB(msg, "systemOnly", attr, systemOnly, False);
+ GET_BOOL_LDB(msg, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, false);
+ GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, attr, adminDisplayName, false);
+ GET_STRING_LDB(msg, "adminDescription", mem_ctx, attr, adminDescription, false);
+ GET_STRING_LDB(msg, "classDisplayName", mem_ctx, attr, classDisplayName, false);
+ GET_BOOL_LDB(msg, "isEphemeral", attr, isEphemeral, false);
+ GET_BOOL_LDB(msg, "isDefunct", attr, isDefunct, false);
+ GET_BOOL_LDB(msg, "systemOnly", attr, systemOnly, false);
attr->syntax = dsdb_syntax_for_attribute(attr);
if (!attr->syntax) {
@@ -468,9 +468,9 @@ WERROR dsdb_class_from_ldb(const struct dsdb_schema *schema,
{
WERROR status;
- GET_STRING_LDB(msg, "cn", mem_ctx, obj, cn, False);
- GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, True);
- GET_STRING_LDB(msg, "governsID", mem_ctx, obj, governsID_oid, True);
+ GET_STRING_LDB(msg, "cn", mem_ctx, obj, cn, false);
+ GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, true);
+ GET_STRING_LDB(msg, "governsID", mem_ctx, obj, governsID_oid, true);
if (schema->num_prefixes == 0) {
/* set an invalid value */
obj->governsID_id = 0xFFFFFFFF;
@@ -486,36 +486,36 @@ WERROR dsdb_class_from_ldb(const struct dsdb_schema *schema,
GET_GUID_LDB(msg, "schemaIDGUID", obj, schemaIDGUID);
GET_UINT32_LDB(msg, "objectClassCategory", obj, objectClassCategory);
- GET_STRING_LDB(msg, "rDNAttID", mem_ctx, obj, rDNAttID, False);
- GET_STRING_LDB(msg, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, True);
+ GET_STRING_LDB(msg, "rDNAttID", mem_ctx, obj, rDNAttID, false);
+ GET_STRING_LDB(msg, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, true);
- GET_STRING_LDB(msg, "subClassOf", mem_ctx, obj, subClassOf, True);
+ GET_STRING_LDB(msg, "subClassOf", mem_ctx, obj, subClassOf, true);
obj->systemAuxiliaryClass = NULL;
obj->auxiliaryClass = NULL;
- GET_STRING_LIST_LDB(msg, "systemMustContain", mem_ctx, obj, systemMustContain, False);
- GET_STRING_LIST_LDB(msg, "systemMayContain", mem_ctx, obj, systemMayContain, False);
- GET_STRING_LIST_LDB(msg, "mustContain", mem_ctx, obj, mustContain, False);
- GET_STRING_LIST_LDB(msg, "mayContain", mem_ctx, obj, mayContain, False);
+ GET_STRING_LIST_LDB(msg, "systemMustContain", mem_ctx, obj, systemMustContain, false);
+ GET_STRING_LIST_LDB(msg, "systemMayContain", mem_ctx, obj, systemMayContain, false);
+ GET_STRING_LIST_LDB(msg, "mustContain", mem_ctx, obj, mustContain, false);
+ GET_STRING_LIST_LDB(msg, "mayContain", mem_ctx, obj, mayContain, false);
- GET_STRING_LIST_LDB(msg, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors, False);
- GET_STRING_LIST_LDB(msg, "possSuperiors", mem_ctx, obj, possSuperiors, False);
- GET_STRING_LIST_LDB(msg, "possibleInferiors", mem_ctx, obj, possibleInferiors, False);
+ GET_STRING_LIST_LDB(msg, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors, false);
+ GET_STRING_LIST_LDB(msg, "possSuperiors", mem_ctx, obj, possSuperiors, false);
+ GET_STRING_LIST_LDB(msg, "possibleInferiors", mem_ctx, obj, possibleInferiors, false);
- GET_STRING_LDB(msg, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, False);
+ GET_STRING_LDB(msg, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);
GET_UINT32_LDB(msg, "schemaFlagsEx", obj, schemaFlagsEx);
GET_BLOB_LDB(msg, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions);
- GET_BOOL_LDB(msg, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, False);
- GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, obj, adminDisplayName, False);
- GET_STRING_LDB(msg, "adminDescription", mem_ctx, obj, adminDescription, False);
- GET_STRING_LDB(msg, "classDisplayName", mem_ctx, obj, classDisplayName, False);
- GET_BOOL_LDB(msg, "defaultHidingValue", obj, defaultHidingValue, False);
- GET_BOOL_LDB(msg, "isDefunct", obj, isDefunct, False);
- GET_BOOL_LDB(msg, "systemOnly", obj, systemOnly, False);
+ GET_BOOL_LDB(msg, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, false);
+ GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, obj, adminDisplayName, false);
+ GET_STRING_LDB(msg, "adminDescription", mem_ctx, obj, adminDescription, false);
+ GET_STRING_LDB(msg, "classDisplayName", mem_ctx, obj, classDisplayName, false);
+ GET_BOOL_LDB(msg, "defaultHidingValue", obj, defaultHidingValue, false);
+ GET_BOOL_LDB(msg, "isDefunct", obj, isDefunct, false);
+ GET_BOOL_LDB(msg, "systemOnly", obj, systemOnly, false);
return WERR_OK;
}
@@ -689,9 +689,9 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb
if (_a && _a->value_ctr.num_values >= 1 \
&& _a->value_ctr.values[0].blob \
&& _a->value_ctr.values[0].blob->length == 4) { \
- (p)->elem = (IVAL(_a->value_ctr.values[0].blob->data,0)?True:False);\
+ (p)->elem = (IVAL(_a->value_ctr.values[0].blob->data,0)?true:false);\
} else { \
- (p)->elem = False; \
+ (p)->elem = false; \
} \
} while (0)
@@ -744,8 +744,8 @@ WERROR dsdb_attribute_from_drsuapi(struct dsdb_schema *schema,
{
WERROR status;
- GET_STRING_DS(schema, r, "name", mem_ctx, attr, cn, True);
- GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, True);
+ GET_STRING_DS(schema, r, "name", mem_ctx, attr, cn, true);
+ GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, true);
GET_UINT32_DS(schema, r, "attributeID", attr, attributeID_id);
status = dsdb_map_int2oid(schema, attr->attributeID_id, mem_ctx, &attr->attributeID_oid);
if (!W_ERROR_IS_OK(status)) {
@@ -761,7 +761,7 @@ WERROR dsdb_attribute_from_drsuapi(struct dsdb_schema *schema,
GET_UINT32_DS(schema, r, "searchFlags", attr, searchFlags);
GET_UINT32_DS(schema, r, "systemFlags", attr, systemFlags);
- GET_BOOL_DS(schema, r, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, False);
+ GET_BOOL_DS(schema, r, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, false);
GET_UINT32_DS(schema, r, "linkID", attr, linkID);
GET_UINT32_DS(schema, r, "attributeSyntax", attr, attributeSyntax_id);
@@ -775,21 +775,21 @@ WERROR dsdb_attribute_from_drsuapi(struct dsdb_schema *schema,
GET_UINT32_DS(schema, r, "oMSyntax", attr, oMSyntax);
GET_BLOB_DS(schema, r, "oMObjectClass", mem_ctx, attr, oMObjectClass);
- GET_BOOL_DS(schema, r, "isSingleValued", attr, isSingleValued, True);
+ GET_BOOL_DS(schema, r, "isSingleValued", attr, isSingleValued, true);
GET_UINT32_DS(schema, r, "rangeLower", attr, rangeLower);
GET_UINT32_DS(schema, r, "rangeUpper", attr, rangeUpper);
- GET_BOOL_DS(schema, r, "extendedCharsAllowed", attr, extendedCharsAllowed, False);
+ GET_BOOL_DS(schema, r, "extendedCharsAllowed", attr, extendedCharsAllowed, false);
GET_UINT32_DS(schema, r, "schemaFlagsEx", attr, schemaFlagsEx);
GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions);
- GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, False);
- GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, attr, adminDisplayName, False);
- GET_STRING_DS(schema, r, "adminDescription", mem_ctx, attr, adminDescription, False);
- GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, attr, classDisplayName, False);
- GET_BOOL_DS(schema, r, "isEphemeral", attr, isEphemeral, False);
- GET_BOOL_DS(schema, r, "isDefunct", attr, isDefunct, False);
- GET_BOOL_DS(schema, r, "systemOnly", attr, systemOnly, False);
+ GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, false);
+ GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, attr, adminDisplayName, false);
+ GET_STRING_DS(schema, r, "adminDescription", mem_ctx, attr, adminDescription, false);
+ GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, attr, classDisplayName, false);
+ GET_BOOL_DS(schema, r, "isEphemeral", attr, isEphemeral, false);
+ GET_BOOL_DS(schema, r, "isDefunct", attr, isDefunct, false);
+ GET_BOOL_DS(schema, r, "systemOnly", attr, systemOnly, false);
attr->syntax = dsdb_syntax_for_attribute(attr);
if (!attr->syntax) {
@@ -806,8 +806,8 @@ WERROR dsdb_class_from_drsuapi(struct dsdb_schema *schema,
{
WERROR status;
- GET_STRING_DS(schema, r, "name", mem_ctx, obj, cn, True);
- GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, True);
+ GET_STRING_DS(schema, r, "name", mem_ctx, obj, cn, true);
+ GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, true);
GET_UINT32_DS(schema, r, "governsID", obj, governsID_id);
status = dsdb_map_int2oid(schema, obj->governsID_id, mem_ctx, &obj->governsID_oid);
if (!W_ERROR_IS_OK(status)) {
@@ -819,10 +819,10 @@ WERROR dsdb_class_from_drsuapi(struct dsdb_schema *schema,
GET_GUID_DS(schema, r, "schemaIDGUID", mem_ctx, obj, schemaIDGUID);
GET_UINT32_DS(schema, r, "objectClassCategory", obj, objectClassCategory);
- GET_STRING_DS(schema, r, "rDNAttID", mem_ctx, obj, rDNAttID, False);
- GET_DN_DS(schema, r, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, True);
+ GET_STRING_DS(schema, r, "rDNAttID", mem_ctx, obj, rDNAttID, false);
+ GET_DN_DS(schema, r, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, true);
- GET_STRING_DS(schema, r, "subClassOf", mem_ctx, obj, subClassOf, True);
+ GET_STRING_DS(schema, r, "subClassOf", mem_ctx, obj, subClassOf, true);
obj->systemAuxiliaryClass = NULL;
obj->systemPossSuperiors = NULL;
@@ -836,18 +836,18 @@ WERROR dsdb_class_from_drsuapi(struct dsdb_schema *schema,
obj->possibleInferiors = NULL;
- GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, False);
+ GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);
GET_UINT32_DS(schema, r, "schemaFlagsEx", obj, schemaFlagsEx);
GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions);
- GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, False);
- GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, obj, adminDisplayName, False);
- GET_STRING_DS(schema, r, "adminDescription", mem_ctx, obj, adminDescription, False);
- GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, obj, classDisplayName, False);
- GET_BOOL_DS(schema, r, "defaultHidingValue", obj, defaultHidingValue, False);
- GET_BOOL_DS(schema, r, "isDefunct", obj, isDefunct, False);
- GET_BOOL_DS(schema, r, "systemOnly", obj, systemOnly, False);
+ GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, false);
+ GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, obj, adminDisplayName, false);
+ GET_STRING_DS(schema, r, "adminDescription", mem_ctx, obj, adminDescription, false);
+ GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, obj, classDisplayName, false);
+ GET_BOOL_DS(schema, r, "defaultHidingValue", obj, defaultHidingValue, false);
+ GET_BOOL_DS(schema, r, "isDefunct", obj, isDefunct, false);
+ GET_BOOL_DS(schema, r, "systemOnly", obj, systemOnly, false);
return WERR_OK;
}
diff --git a/source4/dynconfig.c b/source4/dynconfig.c
index ddd1f2ab74..6dbbf872d9 100644
--- a/source4/dynconfig.c
+++ b/source4/dynconfig.c
@@ -73,11 +73,8 @@ _PUBLIC_ const char *dyn_PIDDIR = PIDDIR;
/** Private data directory; holds ldb files and the like */
_PUBLIC_ const char *dyn_PRIVATE_DIR = PRIVATE_DIR;
-/** WEBAPPS directory */
-_PUBLIC_ const char *dyn_WEBAPPSDIR = WEBAPPSDIR;
-
-/** JSON-RPC Services script directory */
-_PUBLIC_ const char *dyn_SERVICESDIR = SERVICESDIR;
+/** SWAT directory */
+_PUBLIC_ const char *dyn_SWATDIR = SWATDIR;
/** SETUP files (source files used by the provision) */
_PUBLIC_ const char *dyn_SETUPDIR = SETUPDIR;
diff --git a/source4/dynconfig.h b/source4/dynconfig.h
index cb56bc6514..ac54db63d6 100644
--- a/source4/dynconfig.h
+++ b/source4/dynconfig.h
@@ -34,8 +34,7 @@ extern const char *dyn_MODULESDIR;
extern const char *dyn_LOCKDIR;
extern const char *dyn_PIDDIR;
extern const char *dyn_PRIVATE_DIR;
-extern const char *dyn_WEBAPPSDIR;
-extern const char *dyn_SERVICESDIR;
+extern const char *dyn_SWATDIR;
extern const char *dyn_JSDIR;
extern const char *dyn_SETUPDIR;
extern const char *dyn_WINBINDD_SOCKET_DIR;
diff --git a/source4/dynconfig.mk b/source4/dynconfig.mk
index 873ea5b45a..1840ededac 100644
--- a/source4/dynconfig.mk
+++ b/source4/dynconfig.mk
@@ -13,7 +13,7 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
-DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DDATADIR=\"$(DATADIR)\" \
-DLOGFILEBASE=\"$(LOGFILEBASE)\" \
-DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
- -DWEBAPPSDIR=\"$(WEBAPPSDIR)\" -DSERVICESDIR=\"$(SERVICESDIR)\" \
+ -DSWATDIR=\"$(SWATDIR)\" \
-DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
-DMODULESDIR=\"$(MODULESDIR)\" -DJSDIR=\"$(JSDIR)\" \
-DTORTUREDIR=\"$(TORTUREDIR)\" \
@@ -21,4 +21,5 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
dynconfig.o: dynconfig.c Makefile
@echo Compiling $<
- @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) $(PATH_FLAGS) -c $< -o $@
+ @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) \
+ $(PATH_FLAGS) -c $(FIRST_PREREQ) -o $@
diff --git a/source4/headermap.txt b/source4/headermap.txt
index 30fef21ed2..3f17ee55b8 100644
--- a/source4/headermap.txt
+++ b/source4/headermap.txt
@@ -4,7 +4,7 @@ lib/talloc/talloc.h: talloc.h
lib/util/util.h: util.h
lib/util/debug.h: util/debug.h
lib/util/mutex.h: util/mutex.h
-nt_status.h: core/nt_status.h
+lib/util/attr.h: util/attr.h
lib/util/byteorder.h: util/byteorder.h
lib/util/safe_string.h: util/safe_string.h
lib/util/xfile.h: util/xfile.h
@@ -34,9 +34,9 @@ librpc/ndr/libndr.h: ndr.h
lib/registry/registry.h: registry/registry.h
lib/registry/hive.h: registry/hive.h
lib/registry/patchfile.h: registry/patchfile.h
-libcli/util/nterr.h: core/nterr.h
+libcli/util/werror.h: core/werror.h
libcli/util/doserr.h: core/doserr.h
-libcli/util/nt_status.h: core/ntstatus.h
+libcli/util/ntstatus.h: core/ntstatus.h
libcli/cldap/cldap.h: cldap.h
lib/samba3/samba3.h: samba3.h
librpc/gen_ndr/dcerpc.h: gen_ndr/dcerpc.h
diff --git a/source4/heimdal/lib/asn1/lex.c b/source4/heimdal/lib/asn1/lex.c
index d628e4696f..638b182d13 100644
--- a/source4/heimdal/lib/asn1/lex.c
+++ b/source4/heimdal/lib/asn1/lex.c
@@ -1,5 +1,6 @@
+#include "config.h"
-#line 3 "lex.c"
+#line 3 "heimdal/lib/asn1/lex.c"
#define YY_INT_ALIGNED short int
@@ -342,9 +343,6 @@ 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
@@ -826,7 +824,7 @@ char *yytext;
* SUCH DAMAGE.
*/
-/* $Id: lex.l 18738 2006-10-21 11:57:22Z lha $ */
+/* $Id: lex.l,v 1.31 2006/10/21 11:57:22 lha Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -851,7 +849,7 @@ static unsigned lineno = 1;
static void unterminated(const char *, unsigned);
/* This is for broken old lexes (solaris 10 and hpux) */
-#line 855 "lex.c"
+#line 852 "heimdal/lib/asn1/lex.c"
#define INITIAL 0
@@ -1006,7 +1004,7 @@ YY_DECL
#line 68 "lex.l"
-#line 1010 "lex.c"
+#line 1007 "heimdal/lib/asn1/lex.c"
if ( !(yy_init) )
{
@@ -1675,7 +1673,7 @@ YY_RULE_SETUP
#line 274 "lex.l"
ECHO;
YY_BREAK
-#line 1679 "lex.c"
+#line 1676 "heimdal/lib/asn1/lex.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -2485,15 +2483,6 @@ static void yy_fatal_error (yyconst char* msg )
/* Accessor methods (get/set functions) to struct members. */
-/** Get the current line number.
- *
- */
-int yyget_lineno (void)
-{
-
- return yylineno;
-}
-
/** Get the input stream.
*
*/
@@ -2527,16 +2516,6 @@ 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.
diff --git a/source4/heimdal/lib/com_err/lex.c b/source4/heimdal/lib/com_err/lex.c
index c5af2ead5c..77e79d4eae 100644
--- a/source4/heimdal/lib/com_err/lex.c
+++ b/source4/heimdal/lib/com_err/lex.c
@@ -1,5 +1,6 @@
+#include "config.h"
-#line 3 "lex.c"
+#line 3 "heimdal/lib/com_err/lex.c"
#define YY_INT_ALIGNED short int
@@ -342,9 +343,6 @@ 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
@@ -523,7 +521,7 @@ char *yytext;
#include "parse.h"
#include "lex.h"
-RCSID("$Id: lex.l 15143 2005-05-16 08:52:54Z lha $");
+RCSID("$Id: lex.l,v 1.8 2005/05/16 08:52:54 lha Exp $");
static unsigned lineno = 1;
static int getstring(void);
@@ -532,7 +530,7 @@ static int getstring(void);
#undef ECHO
-#line 536 "lex.c"
+#line 533 "heimdal/lib/com_err/lex.c"
#define INITIAL 0
@@ -687,7 +685,7 @@ YY_DECL
#line 59 "lex.l"
-#line 691 "lex.c"
+#line 688 "heimdal/lib/com_err/lex.c"
if ( !(yy_init) )
{
@@ -851,7 +849,7 @@ YY_RULE_SETUP
#line 75 "lex.l"
ECHO;
YY_BREAK
-#line 855 "lex.c"
+#line 852 "heimdal/lib/com_err/lex.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -1661,15 +1659,6 @@ static void yy_fatal_error (yyconst char* msg )
/* Accessor methods (get/set functions) to struct members. */
-/** Get the current line number.
- *
- */
-int yyget_lineno (void)
-{
-
- return yylineno;
-}
-
/** Get the input stream.
*
*/
@@ -1703,16 +1692,6 @@ 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.
diff --git a/source4/heimdal_build/config.m4 b/source4/heimdal_build/config.m4
index 01a620c1c5..8c0959550b 100644
--- a/source4/heimdal_build/config.m4
+++ b/source4/heimdal_build/config.m4
@@ -71,8 +71,6 @@ AC_CHECK_FUNCS([ \
cgetent \
getprogname \
inet_aton \
- inet_ntop \
- inet_pton \
gethostname \
getnameinfo \
iruserok \
@@ -100,8 +98,6 @@ AC_CHECK_FUNCS([ \
errx \
warnx \
flock \
- getaddrinfo \
- freeaddrinfo \
getipnodebyname \
getipnodebyaddr \
freehostent \
@@ -229,49 +225,6 @@ SMB_ENABLE(KERBEROS_LIB, YES)
SMB_ENABLE(asn1_compile, YES)
SMB_ENABLE(compile_et, YES)
-# only add getaddrinfo and related functions if needed
-SMB_ENABLE(HEIMDAL_ROKEN_ADDRINFO, NO)
-if test t$ac_cv_func_getaddrinfo != tyes; then
- SMB_ENABLE(HEIMDAL_ROKEN_ADDRINFO, YES)
-fi
-
-SMB_ENABLE(HEIMDAL_ROKEN_GETNAMEINFO, NO)
-if test t$ac_cv_func_getnameinfo != tyes; then
- SMB_ENABLE(HEIMDAL_ROKEN_GETNAMEINFO, YES)
-fi
-
-# only add inet_aton if needed
-SMB_ENABLE(HEIMDAL_ROKEN_INET_ATON, NO)
-if test t$ac_cv_func_inet_aton != tyes; then
- SMB_ENABLE(HEIMDAL_ROKEN_INET_ATON, YES)
-fi
-
-SMB_ENABLE(HEIMDAL_ROKEN_INET_NTOP, NO)
-if test x"$ac_cv_func_inet_ntop" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, inet_ntop)
- AC_CHECK_LIB_EXT(nsl, NSL_LIBS, inet_ntop)
- if test x"$ac_cv_lib_ext_nsl_s_inet_ntop" != x"yes" &&
- test x"$ac_cv_lib_ext_nsl_inet_ntop" != x"yes"; then
- SMB_ENABLE(HEIMDAL_ROKEN_INET_NTOP, YES)
- else
- SMB_ENABLE(NSL,YES)
- fi
-fi
-
-SMB_ENABLE(HEIMDAL_ROKEN_INET_PTON, NO)
-if test x"$ac_cv_func_inet_pton" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, inet_pton)
- AC_CHECK_LIB_EXT(nsl, NSL_LIBS, inet_pton)
- if test x"$ac_cv_lib_ext_nsl_s_inet_pton" != x"yes" &&
- test x"$ac_cv_lib_ext_nsl_inet_pton" != x"yes"; then
- SMB_ENABLE(HEIMDAL_ROKEN_INET_PTON, YES)
- else
- SMB_ENABLE(NSL,YES)
- fi
-fi
-
-SMB_EXT_LIB(NSL,[${NSL_LIBS}],[],[],[])
-
# only add closefrom if needed
SMB_ENABLE(HEIMDAL_ROKEN_CLOSEFROM, NO)
if test t$ac_cv_func_closefrom != tyes; then
@@ -285,29 +238,3 @@ if test t$ac_cv_func_getprogname != tyes; then
SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME, YES)
SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME_H, YES)
fi
-
-# only add gai_strerror if needed
-SMB_ENABLE(HEIMDAL_ROKEN_GAI_STRERROR, NO)
-AC_CHECK_FUNC(gai_strerror)
-
-if test t$ac_cv_func_gai_strerror != tyes; then
- AC_CHECK_LIB_EXT(nsl, GAI_LIBS, gai_strerror)
- AC_CHECK_LIB_EXT(socket, GAI_LIBS, gai_strerror)
- AC_CHECK_LIB_EXT(xnet, GAI_LIBS, gai_strerror)
-
- dnl We can't just call AC_CHECK_FUNCS(gai_strerror) here, because the value
- dnl has been cached.
- if test x"$ac_cv_lib_ext_nsl_gai_strerror" = x"yes" ||
- test x"$ac_cv_lib_ext_socket_gai_strerror" = x"yes" ||
- test x"$ac_cv_lib_ext_xnet_gai_strerror" = x"yes"; then
- AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror()])
- SMB_ENABLE(GAI, YES)
- else
- SMB_ENABLE(HEIMDAL_ROKEN_GAI_STRERROR, YES)
- fi
-
-else
- AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether gai_strerror() is available])
-fi
-
-SMB_EXT_LIB(GAI,[${GAI_LIBS}],[${GAI_CFLAGS}],[${GAI_CPPFLAGS}],[${GAI_LDFLAGS}])
diff --git a/source4/heimdal_build/config.mk b/source4/heimdal_build/config.mk
index 940d9cdb9c..ce5fa6e98e 100644
--- a/source4/heimdal_build/config.mk
+++ b/source4/heimdal_build/config.mk
@@ -369,24 +369,6 @@ OBJ_FILES = \
# End SUBSYSTEM HEIMDAL_HX509
#######################
-#######################
-# Start SUBSYSTEM HEIMDAL_ROKEN_GAI_STRERROR
-[SUBSYSTEM::HEIMDAL_ROKEN_GAI_STRERROR]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/roken/gai_strerror.o
-
-[SUBSYSTEM::HEIMDAL_ROKEN_INET_ATON]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/roken/inet_aton.o
-
-[SUBSYSTEM::HEIMDAL_ROKEN_INET_NTOP]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/roken/inet_ntop.o
-
-[SUBSYSTEM::HEIMDAL_ROKEN_INET_PTON]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/roken/inet_pton.o
-
[SUBSYSTEM::HEIMDAL_ROKEN_GETPROGNAME]
CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
OBJ_FILES = ../heimdal/lib/roken/getprogname.o
@@ -399,24 +381,6 @@ OBJ_FILES = ../heimdal/lib/roken/closefrom.o
CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
OBJ_FILES = ../heimdal/lib/roken/getprogname.ho
-[SUBSYSTEM::HEIMDAL_ROKEN_GETNAMEINFO]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/roken/getnameinfo.o
-
-#######################
-# Start SUBSYSTEM HEIMDAL_ROKEN_ADDRINFO
-[SUBSYSTEM::HEIMDAL_ROKEN_ADDRINFO]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken
-OBJ_FILES = \
- ../heimdal/lib/roken/getaddrinfo.o \
- ../heimdal/lib/roken/freeaddrinfo.o \
- ../heimdal/lib/roken/getipnodebyaddr.o \
- ../heimdal/lib/roken/getipnodebyname.o \
- ../heimdal/lib/roken/freehostent.o \
- ../heimdal/lib/roken/copyhostent.o \
- ../heimdal/lib/roken/hostent_find_fqdn.o
-PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN_INET_PTON EXT_SOCKET
-
#######################
# Start SUBSYSTEM HEIMDAL_ROKEN
[SUBSYSTEM::HEIMDAL_ROKEN]
@@ -453,16 +417,8 @@ OBJ_FILES = \
../heimdal/lib/roken/rtbl.o \
replace.o
PUBLIC_DEPENDENCIES = \
- HEIMDAL_ROKEN_ADDRINFO \
- HEIMDAL_ROKEN_GAI_STRERROR \
- HEIMDAL_ROKEN_INET_ATON \
- HEIMDAL_ROKEN_INET_NTOP \
- HEIMDAL_ROKEN_INET_PTON \
HEIMDAL_ROKEN_GETPROGNAME \
HEIMDAL_ROKEN_CLOSEFROM \
- HEIMDAL_ROKEN_GETNAMEINFO \
- GAI \
- NSL \
RESOLV \
EXT_SOCKET
# End SUBSYSTEM HEIMDAL_ROKEN
diff --git a/source4/include/includes.h b/source4/include/includes.h
index 40cb306eb2..1a92e46657 100644
--- a/source4/include/includes.h
+++ b/source4/include/includes.h
@@ -32,98 +32,18 @@
#include "local.h"
-#ifdef __GNUC__
-/** gcc attribute used on function parameters so that it does not emit
- * warnings about them being unused. **/
-# define UNUSED(param) param __attribute__ ((unused))
-#else
-# define UNUSED(param) param
-/** Feel free to add definitions for other compilers here. */
-#endif
-
-#ifndef _PUBLIC_
-#ifdef HAVE_VISIBILITY_ATTR
-# define _PUBLIC_ __attribute__((visibility("default")))
-#else
-# define _PUBLIC_
-#endif
-#endif
-
-#ifndef PRINTF_ATTRIBUTE
-#if __GNUC__ >= 3
-/** Use gcc attribute to check printf fns. a1 is the 1-based index of
- * the parameter containing the format, and a2 the index of the first
- * argument. Note that some gcc 2.x versions don't handle this
- * properly **/
-#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
-#else
-#define PRINTF_ATTRIBUTE(a1, a2)
-#endif
-#endif
-
-#ifndef _DEPRECATED_
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
-#define _DEPRECATED_ __attribute__ ((deprecated))
-#else
-#define _DEPRECATED_
-#endif
-#endif
-
-#ifndef _WARN_UNUSED_RESULT_
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
-#define _WARN_UNUSED_RESULT_ __attribute__ ((warn_unused_result))
-#else
-#define _WARN_UNUSED_RESULT_
-#endif
-#endif
-
-#ifndef _NORETURN_
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
-#define _NORETURN_ __attribute__ ((noreturn))
-#else
-#define _NORETURN_
-#endif
-#endif
-
-#ifndef _PURE_
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
-#define _PURE_ __attribute__((pure))
-#else
-#define _PURE_
-#endif
-#endif
-
-#ifndef NONNULL
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
-#define NONNULL(param) param __attribute__((nonnull))
-#else
-#define NONNULL(param) param
-#endif
-#endif
-
#include "system/time.h"
#include "system/wait.h"
-#ifndef _PRINTF_ATTRIBUTE
-#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
-#endif
-
/* Lists, trees, caching, database... */
#include <stdlib.h>
#include <stdbool.h>
#include <talloc.h>
-#include "libcli/util/nt_status.h"
-#include "charset/charset.h"
+#ifndef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
+#endif
#include "util/util.h"
-#include "param/param.h"
-#include "librpc/gen_ndr/misc.h"
-
-typedef bool BOOL;
-
-#define False false
-#define True true
-struct smbcli_tree;
#include "libcli/util/error.h"
/* String routines */
diff --git a/source4/install-sh b/source4/install-sh
index 58719246f0..58719246f0 100644..100755
--- a/source4/install-sh
+++ b/source4/install-sh
diff --git a/source4/kdc/hdb-ldb.c b/source4/kdc/hdb-ldb.c
index ddee8d19d1..3ef5f9510a 100644
--- a/source4/kdc/hdb-ldb.c
+++ b/source4/kdc/hdb-ldb.c
@@ -49,6 +49,7 @@
#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "libcli/auth/libcli_auth.h"
+#include "param/param.h"
enum hdb_ldb_ent_type
{ HDB_LDB_ENT_TYPE_CLIENT, HDB_LDB_ENT_TYPE_SERVER,
@@ -480,7 +481,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db,
entry_ex->entry.flags.ok_as_delegate = 1;
}
- if (lp_parm_bool(-1, "kdc", "require spn for service", True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "kdc", "require spn for service", true)) {
if (!is_computer && !ldb_msg_find_attr_as_string(msg, "servicePrincipalName", NULL)) {
entry_ex->entry.flags.server = 0;
}
diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c
index c58f738243..d1582215f8 100644
--- a/source4/kdc/kdc.c
+++ b/source4/kdc/kdc.c
@@ -38,6 +38,7 @@
#include "heimdal/kdc/windc_plugin.h"
#include "heimdal/lib/krb5/krb5_locl.h"
#include "heimdal/kdc/kdc_locl.h"
+#include "param/param.h"
/* Disgusting hack to get a mem_ctx into the hdb plugin, when used as a keytab */
@@ -50,7 +51,7 @@ struct kdc_reply {
DATA_BLOB packet;
};
-typedef BOOL (*kdc_process_fn_t)(struct kdc_server *kdc,
+typedef bool (*kdc_process_fn_t)(struct kdc_server *kdc,
TALLOC_CTX *mem_ctx,
DATA_BLOB *input,
DATA_BLOB *reply,
@@ -310,7 +311,7 @@ static void kdc_tcp_send(struct stream_connection *conn, uint16_t flags)
calling conventions
*/
-static BOOL kdc_process(struct kdc_server *kdc,
+static bool kdc_process(struct kdc_server *kdc,
TALLOC_CTX *mem_ctx,
DATA_BLOB *input,
DATA_BLOB *reply,
@@ -336,7 +337,7 @@ static BOOL kdc_process(struct kdc_server *kdc,
datagram_reply);
if (ret == -1) {
*reply = data_blob(NULL, 0);
- return False;
+ return false;
}
if (k5_reply.length) {
*reply = data_blob_talloc(mem_ctx, k5_reply.data, k5_reply.length);
@@ -344,7 +345,7 @@ static BOOL kdc_process(struct kdc_server *kdc,
} else {
*reply = data_blob(NULL, 0);
}
- return True;
+ return true;
}
/*
@@ -407,15 +408,14 @@ static const struct stream_server_ops kpasswdd_tcp_stream_ops = {
/*
start listening on the given address
*/
-static NTSTATUS kdc_add_socket(struct kdc_server *kdc, const char *address)
+static NTSTATUS kdc_add_socket(struct kdc_server *kdc, const char *address,
+ uint16_t kdc_port, uint16_t kpasswd_port)
{
const struct model_ops *model_ops;
struct kdc_socket *kdc_socket;
struct kdc_socket *kpasswd_socket;
struct socket_address *kdc_address, *kpasswd_address;
NTSTATUS status;
- uint16_t kdc_port = lp_krb5_port();
- uint16_t kpasswd_port = lp_kpasswd_port();
kdc_socket = talloc(kdc, struct kdc_socket);
NT_STATUS_HAVE_NO_MEMORY(kdc_socket);
@@ -526,7 +526,8 @@ static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc)
for (i=0; i<num_interfaces; i++) {
const char *address = talloc_strdup(tmp_ctx, iface_n_ip(i));
- status = kdc_add_socket(kdc, address);
+ status = kdc_add_socket(kdc, address, lp_krb5_port(global_loadparm),
+ lp_kpasswd_port(global_loadparm));
NT_STATUS_NOT_OK_RETURN(status);
}
@@ -554,7 +555,7 @@ static void kdc_task_init(struct task_server *task)
NTSTATUS status;
krb5_error_code ret;
- switch (lp_server_role()) {
+ switch (lp_server_role(global_loadparm)) {
case ROLE_STANDALONE:
task_server_terminate(task, "kdc: no KDC required in standalone configuration");
return;
diff --git a/source4/kdc/kpasswdd.c b/source4/kdc/kpasswdd.c
index dc717daa65..5bda85c96e 100644
--- a/source4/kdc/kpasswdd.c
+++ b/source4/kdc/kpasswdd.c
@@ -38,6 +38,7 @@
#include "rpc_server/dcerpc_server.h"
#include "rpc_server/samr/proto.h"
#include "libcli/security/security.h"
+#include "param/param.h"
/* hold information about one kdc socket */
struct kpasswd_socket {
@@ -50,7 +51,7 @@ struct kpasswd_socket {
};
/* Return true if there is a valid error packet formed in the error_blob */
-static BOOL kpasswdd_make_error_reply(struct kdc_server *kdc,
+static bool kpasswdd_make_error_reply(struct kdc_server *kdc,
TALLOC_CTX *mem_ctx,
uint16_t result_code,
const char *error_string,
@@ -63,33 +64,33 @@ static BOOL kpasswdd_make_error_reply(struct kdc_server *kdc,
len = push_utf8_talloc(mem_ctx, &error_string_utf8, error_string);
if (len == -1) {
- return False;
+ return false;
}
*error_blob = data_blob_talloc(mem_ctx, NULL, 2 + len + 1);
if (!error_blob->data) {
- return False;
+ return false;
}
RSSVAL(error_blob->data, 0, result_code);
memcpy(error_blob->data + 2, error_string_utf8, len + 1);
- return True;
+ return true;
}
/* Return true if there is a valid error packet formed in the error_blob */
-static BOOL kpasswdd_make_unauth_error_reply(struct kdc_server *kdc,
+static bool kpasswdd_make_unauth_error_reply(struct kdc_server *kdc,
TALLOC_CTX *mem_ctx,
uint16_t result_code,
const char *error_string,
DATA_BLOB *error_blob)
{
- BOOL ret;
+ bool ret;
int kret;
DATA_BLOB error_bytes;
krb5_data k5_error_bytes, k5_error_blob;
ret = kpasswdd_make_error_reply(kdc, mem_ctx, result_code, error_string,
&error_bytes);
if (!ret) {
- return False;
+ return false;
}
k5_error_bytes.data = error_bytes.data;
k5_error_bytes.length = error_bytes.length;
@@ -97,17 +98,17 @@ static BOOL kpasswdd_make_unauth_error_reply(struct kdc_server *kdc,
result_code, NULL, &k5_error_bytes,
NULL, NULL, NULL, NULL, &k5_error_blob);
if (kret) {
- return False;
+ return false;
}
*error_blob = data_blob_talloc(mem_ctx, k5_error_blob.data, k5_error_blob.length);
krb5_data_free(&k5_error_blob);
if (!error_blob->data) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL kpasswd_make_pwchange_reply(struct kdc_server *kdc,
+static bool kpasswd_make_pwchange_reply(struct kdc_server *kdc,
TALLOC_CTX *mem_ctx,
NTSTATUS status,
enum samr_RejectReason reject_reason,
@@ -168,7 +169,7 @@ static BOOL kpasswd_make_pwchange_reply(struct kdc_server *kdc,
Return true if there is a valid error packet (or sucess) formed in
the error_blob
*/
-static BOOL kpasswdd_change_password(struct kdc_server *kdc,
+static bool kpasswdd_change_password(struct kdc_server *kdc,
TALLOC_CTX *mem_ctx,
struct auth_session_info *session_info,
const char *password,
@@ -196,7 +197,7 @@ static BOOL kpasswdd_change_password(struct kdc_server *kdc,
status = samdb_set_password_sid(samdb, mem_ctx,
session_info->security_token->user_sid,
password, NULL, NULL,
- True, /* this is a user password change */
+ true, /* this is a user password change */
&reject_reason,
&dominfo);
return kpasswd_make_pwchange_reply(kdc, mem_ctx,
@@ -207,7 +208,7 @@ static BOOL kpasswdd_change_password(struct kdc_server *kdc,
}
-static BOOL kpasswd_process_request(struct kdc_server *kdc,
+static bool kpasswd_process_request(struct kdc_server *kdc,
TALLOC_CTX *mem_ctx,
struct gensec_security *gensec_security,
uint16_t version,
@@ -228,7 +229,7 @@ static BOOL kpasswd_process_request(struct kdc_server *kdc,
{
char *password = talloc_strndup(mem_ctx, (const char *)input->data, input->length);
if (!password) {
- return False;
+ return false;
}
return kpasswdd_change_password(kdc, mem_ctx, session_info,
password, reply);
@@ -255,7 +256,7 @@ static BOOL kpasswd_process_request(struct kdc_server *kdc,
msg = ldb_msg_new(mem_ctx);
if (!msg) {
- return False;
+ return false;
}
ret = decode_ChangePasswdDataMS(input->data, input->length,
@@ -267,11 +268,12 @@ static BOOL kpasswd_process_request(struct kdc_server *kdc,
reply);
}
- password = talloc_strndup(mem_ctx, chpw.newpasswd.data,
+ password = talloc_strndup(mem_ctx,
+ (const char *)chpw.newpasswd.data,
chpw.newpasswd.length);
if (!password) {
free_ChangePasswdDataMS(&chpw);
- return False;
+ return false;
}
if ((chpw.targname && !chpw.targrealm)
|| (!chpw.targname && chpw.targrealm)) {
@@ -360,7 +362,7 @@ static BOOL kpasswd_process_request(struct kdc_server *kdc,
status = samdb_set_password(samdb, mem_ctx,
set_password_on_dn, NULL,
msg, password, NULL, NULL,
- False, /* this is not a user password change */
+ false, /* this is not a user password change */
&reject_reason, &dominfo);
}
@@ -399,10 +401,10 @@ static BOOL kpasswd_process_request(struct kdc_server *kdc,
version),
reply);
}
- return True;
+ return true;
}
-BOOL kpasswdd_process(struct kdc_server *kdc,
+bool kpasswdd_process(struct kdc_server *kdc,
TALLOC_CTX *mem_ctx,
DATA_BLOB *input,
DATA_BLOB *reply,
@@ -410,7 +412,7 @@ BOOL kpasswdd_process(struct kdc_server *kdc,
struct socket_address *my_addr,
int datagram_reply)
{
- BOOL ret;
+ bool ret;
const uint16_t header_len = 6;
uint16_t len;
uint16_t ap_req_len;
@@ -426,20 +428,20 @@ BOOL kpasswdd_process(struct kdc_server *kdc,
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
if (!tmp_ctx) {
- return False;
+ return false;
}
/* Be parinoid. We need to ensure we don't just let the
* caller lead us into a buffer overflow */
if (input->length <= header_len) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
len = RSVAL(input->data, 0);
if (input->length != len) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
/* There are two different versions of this protocol so far,
@@ -449,7 +451,7 @@ BOOL kpasswdd_process(struct kdc_server *kdc,
ap_req_len = RSVAL(input->data, 4);
if ((ap_req_len >= len) || (ap_req_len + header_len) >= len) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
krb_priv_len = len - ap_req_len;
@@ -459,19 +461,19 @@ BOOL kpasswdd_process(struct kdc_server *kdc,
nt_status = gensec_server_start(tmp_ctx, kdc->task->event_ctx, kdc->task->msg_ctx, &gensec_security);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
server_credentials = cli_credentials_init(tmp_ctx);
if (!server_credentials) {
DEBUG(1, ("Failed to init server credentials\n"));
- return False;
+ return false;
}
/* We want the credentials subsystem to use the krb5 context
* 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);
+ cli_credentials_set_conf(server_credentials, global_loadparm);
nt_status = cli_credentials_set_stored_principal(server_credentials, "kadmin/changepw");
if (!NT_STATUS_IS_OK(nt_status)) {
ret = kpasswdd_make_unauth_error_reply(kdc, mem_ctx,
@@ -491,7 +493,7 @@ BOOL kpasswdd_process(struct kdc_server *kdc,
nt_status = gensec_set_credentials(gensec_security, server_credentials);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
/* The kerberos PRIV packets include these addresses. MIT
@@ -499,12 +501,12 @@ BOOL kpasswdd_process(struct kdc_server *kdc,
nt_status = gensec_set_peer_addr(gensec_security, peer_addr);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
nt_status = gensec_set_my_addr(gensec_security, my_addr);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
/* We want the GENSEC wrap calls to generate PRIV tokens */
@@ -513,7 +515,7 @@ BOOL kpasswdd_process(struct kdc_server *kdc,
nt_status = gensec_start_mech_by_name(gensec_security, "krb5");
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
/* Accept the AP-REQ and generate teh AP-REP we need for the reply */
@@ -558,7 +560,7 @@ BOOL kpasswdd_process(struct kdc_server *kdc,
&kpasswd_req, &kpasswd_rep);
if (!ret) {
/* Argh! */
- return False;
+ return false;
}
/* And wrap up the reply: This ensures that the error message
@@ -583,7 +585,7 @@ BOOL kpasswdd_process(struct kdc_server *kdc,
reply:
*reply = data_blob_talloc(mem_ctx, NULL, krb_priv_rep.length + ap_rep.length + header_len);
if (!reply->data) {
- return False;
+ return false;
}
RSSVAL(reply->data, 0, reply->length);
diff --git a/source4/ldap_server/ldap_backend.c b/source4/ldap_server/ldap_backend.c
index c8ae293a2a..25d19a5a58 100644
--- a/source4/ldap_server/ldap_backend.c
+++ b/source4/ldap_server/ldap_backend.c
@@ -26,6 +26,7 @@
#include "lib/db_wrap.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
#define VALID_DN_SYNTAX(dn,i) do {\
if (!(dn)) {\
@@ -54,7 +55,9 @@ 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, lp_sam_url(), conn->session_info,
+ conn->ldb = ldb_wrap_connect(conn,
+ global_loadparm,
+ lp_sam_url(global_loadparm), conn->session_info,
NULL, conn->global_catalog ? LDB_FLG_RDONLY : 0, NULL);
if (conn->ldb == NULL) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -63,10 +66,8 @@ NTSTATUS ldapsrv_backend_Init(struct ldapsrv_connection *conn)
if (conn->server_credentials) {
char **sasl_mechs = NULL;
struct gensec_security_ops **backends = gensec_security_all();
- enum credentials_use_kerberos use_kerberos
- = cli_credentials_get_kerberos_state(conn->server_credentials);
struct gensec_security_ops **ops
- = gensec_use_kerberos_mechs(conn, backends, use_kerberos);
+ = gensec_use_kerberos_mechs(conn, backends, conn->server_credentials);
int i, j = 0;
for (i = 0; ops && ops[i]; i++) {
if (ops[i]->sasl_name && ops[i]->server_start) {
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index 0de76052d1..a74d002e9b 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -40,6 +40,7 @@
#include "system/network.h"
#include "lib/socket/netif.h"
#include "dsdb/samdb/samdb.h"
+#include "param/param.h"
/*
close the socket and shutdown a server_context
*/
@@ -368,7 +369,7 @@ static void ldapsrv_accept(struct stream_connection *c)
conn->sockets.tls = tls_socket;
} else if (port == 3268) /* Global catalog */ {
- conn->global_catalog = True;
+ conn->global_catalog = true;
}
conn->packet = packet_init(conn);
if (conn->packet == NULL) {
@@ -395,7 +396,7 @@ static void ldapsrv_accept(struct stream_connection *c)
return;
}
- cli_credentials_set_conf(server_credentials);
+ cli_credentials_set_conf(server_credentials, global_loadparm);
status = cli_credentials_set_machine_account(server_credentials);
if (!NT_STATUS_IS_OK(status)) {
stream_terminate_connection(c, talloc_asprintf(conn, "Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(status)));
@@ -512,6 +513,18 @@ static void ldapsrv_task_init(struct task_server *task)
NTSTATUS status;
const struct model_ops *model_ops;
+ switch (lp_server_role(global_loadparm)) {
+ case ROLE_STANDALONE:
+ task_server_terminate(task, "ldap_server: no LDAP server required in standalone configuration");
+ return;
+ case ROLE_DOMAIN_MEMBER:
+ task_server_terminate(task, "ldap_server: no LDAP server required in member server configuration");
+ return;
+ case ROLE_DOMAIN_CONTROLLER:
+ /* Yes, we want an LDAP server */
+ break;
+ }
+
task_server_set_title(task, "task[ldapsrv]");
/* run the ldap server as a single process */
@@ -524,7 +537,7 @@ static void ldapsrv_task_init(struct task_server *task)
ldap_service->tls_params = tls_initialise(ldap_service);
if (ldap_service->tls_params == NULL) goto failed;
- if (lp_interfaces() && lp_bind_interfaces_only()) {
+ if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) {
int num_interfaces = iface_count();
int i;
@@ -538,7 +551,8 @@ static void ldapsrv_task_init(struct task_server *task)
if (!NT_STATUS_IS_OK(status)) goto failed;
}
} else {
- status = add_socket(task->event_ctx, model_ops, lp_socket_address(), ldap_service);
+ status = add_socket(task->event_ctx, model_ops,
+ lp_socket_address(global_loadparm), ldap_service);
if (!NT_STATUS_IS_OK(status)) goto failed;
}
diff --git a/source4/lib/appweb/ejs/ejsLib.c b/source4/lib/appweb/ejs/ejsLib.c
index 0dfc2e0ed2..67d0a4e760 100644
--- a/source4/lib/appweb/ejs/ejsLib.c
+++ b/source4/lib/appweb/ejs/ejsLib.c
@@ -154,7 +154,7 @@ EjsId ejsOpenEngine(EjsHandle primaryHandle, EjsHandle altHandle)
MprVar *np;
Ejs *ep;
- ep = mprMalloc(sizeof(Ejs));
+ ep = (Ejs *)mprMalloc(sizeof(Ejs));
if (ep == 0) {
return (EjsId) -1;
}
diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk
index e993207b00..266ca6e685 100644
--- a/source4/lib/basic.mk
+++ b/source4/lib/basic.mk
@@ -2,7 +2,7 @@
include samba3/config.mk
include socket/config.mk
include charset/config.mk
-include ldb/config.mk
+include ldb-samba/config.mk
include tls/config.mk
include registry/config.mk
include policy/config.mk
diff --git a/source4/lib/charset/charcnv.c b/source4/lib/charset/charcnv.c
index fcf29d4647..9c794202b2 100644
--- a/source4/lib/charset/charcnv.c
+++ b/source4/lib/charset/charcnv.c
@@ -21,6 +21,7 @@
*/
#include "includes.h"
#include "system/iconv.h"
+#include "param/param.h"
/**
* @file
@@ -37,20 +38,16 @@
* @sa lib/iconv.c
*/
-char *unix_charset = NULL;
-char *dos_charset = NULL;
-char *display_charset = NULL;
-
/**
* Return the name of a charset to give to iconv().
**/
-static const char *charset_name(charset_t ch)
+static const char *charset_name(struct loadparm_context *lp_ctx, charset_t ch)
{
switch (ch) {
case CH_UTF16: return "UTF-16LE";
- case CH_UNIX: return unix_charset;
- case CH_DOS: return dos_charset;
- case CH_DISPLAY: return display_charset;
+ case CH_UNIX: return lp_unix_charset(lp_ctx);
+ case CH_DOS: return lp_dos_charset(lp_ctx);
+ case CH_DISPLAY: return lp_display_charset(lp_ctx);
case CH_UTF8: return "UTF8";
case CH_UTF16BE: return "UTF-16BE";
default:
@@ -108,20 +105,20 @@ static smb_iconv_t get_conv_handle(charset_t from, charset_t to)
return conv_handles[from][to];
}
- n1 = charset_name(from);
- n2 = charset_name(to);
+ n1 = charset_name(global_loadparm, from);
+ n2 = charset_name(global_loadparm, to);
conv_handles[from][to] = smb_iconv_open(n2,n1);
if (conv_handles[from][to] == (smb_iconv_t)-1) {
if ((from == CH_DOS || to == CH_DOS) &&
- strcasecmp(charset_name(CH_DOS), "ASCII") != 0) {
+ strcasecmp(charset_name(global_loadparm, CH_DOS), "ASCII") != 0) {
DEBUG(0,("dos charset '%s' unavailable - using ASCII\n",
- charset_name(CH_DOS)));
- lp_set_cmdline("dos charset", "ASCII");
+ charset_name(global_loadparm, CH_DOS)));
+ lp_set_cmdline(global_loadparm, "dos charset", "ASCII");
- n1 = charset_name(from);
- n2 = charset_name(to);
+ n1 = charset_name(global_loadparm, from);
+ n2 = charset_name(global_loadparm, to);
conv_handles[from][to] = smb_iconv_open(n2,n1);
}
@@ -151,7 +148,7 @@ _PUBLIC_ ssize_t convert_string(charset_t from, charset_t to,
smb_iconv_t descriptor;
if (srclen == (size_t)-1)
- srclen = strlen(src)+1;
+ srclen = strlen(inbuf)+1;
descriptor = get_conv_handle(from, to);
@@ -175,12 +172,12 @@ _PUBLIC_ ssize_t convert_string(charset_t from, charset_t to,
reason="No more room";
if (from == CH_UNIX) {
DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d - '%s'\n",
- charset_name(from), charset_name(to),
+ charset_name(global_loadparm, from), charset_name(global_loadparm, to),
(int)srclen, (int)destlen,
(const char *)src));
} else {
DEBUG(0,("E2BIG: convert_string(%s,%s): srclen=%d destlen=%d\n",
- charset_name(from), charset_name(to),
+ charset_name(global_loadparm, from), charset_name(global_loadparm, to),
(int)srclen, (int)destlen));
}
return -1;
@@ -222,7 +219,7 @@ _PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_
if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) {
/* conversion not supported, return -1*/
DEBUG(3, ("convert_string_talloc: conversion from %s to %s not supported!\n",
- charset_name(from), charset_name(to)));
+ charset_name(global_loadparm, from), charset_name(global_loadparm, to)));
return -1;
}
@@ -350,9 +347,9 @@ static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t s
if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII)) {
if (src_len == (size_t)-1) {
- src_len = strlen(src) + 1;
+ src_len = strlen((const char *)src) + 1;
} else {
- size_t len = strnlen(src, src_len);
+ size_t len = strnlen((const char *)src, src_len);
if (len < src_len)
len++;
src_len = len;
diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h
index 6943a60182..be2705100a 100644
--- a/source4/lib/charset/charset.h
+++ b/source4/lib/charset/charset.h
@@ -49,7 +49,7 @@ typedef uint32_t codepoint_t;
/* generic iconv conversion structure */
-typedef struct {
+typedef struct smb_iconv_s {
size_t (*direct)(void *cd, const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
size_t (*pull)(void *cd, const char **inbuf, size_t *inbytesleft,
@@ -77,9 +77,4 @@ typedef struct {
#define strlower(s) strlower_m(s)
#define strupper(s) strupper_m(s)
-/* from lib/charset */
-extern char *dos_charset;
-extern char *unix_charset;
-extern char *display_charset;
-
#endif /* __CHARSET_H__ */
diff --git a/source4/lib/charset/iconv.c b/source4/lib/charset/iconv.c
index 062b4ddfc8..9b035cd1db 100644
--- a/source4/lib/charset/iconv.c
+++ b/source4/lib/charset/iconv.c
@@ -22,6 +22,7 @@
#include "lib/util/dlinklist.h"
#include "system/iconv.h"
#include "system/filesys.h"
+#include "param/param.h"
/**
@@ -74,7 +75,7 @@ static struct charset_functions *charsets = NULL;
bool charset_register_backend(const void *_funcs)
{
- struct charset_functions *funcs = memdup(_funcs,sizeof(struct charset_functions));
+ struct charset_functions *funcs = (struct charset_functions *)memdup(_funcs,sizeof(struct charset_functions));
struct charset_functions *c;
/* Check whether we already have this charset... */
@@ -198,7 +199,7 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
}
#ifdef HAVE_NATIVE_ICONV
- if ((!from || !to) && !lp_parm_bool(-1, "iconv", "native", true)) {
+ if ((!from || !to) && !lp_parm_bool(global_loadparm, NULL, "iconv", "native", true)) {
goto failed;
}
if (!from) {
diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c
index 6c86b0b899..e9cca090cc 100644
--- a/source4/lib/charset/util_unistr.c
+++ b/source4/lib/charset/util_unistr.c
@@ -393,7 +393,7 @@ _PUBLIC_ char *strchr_m(const char *s, char c)
size_t size;
codepoint_t c2 = next_codepoint(s, &size);
if (c2 == c) {
- return discard_const(s);
+ return discard_const_p(char, s);
}
s += size;
}
@@ -418,7 +418,7 @@ _PUBLIC_ char *strrchr_m(const char *s, char c)
size_t size;
codepoint_t c2 = next_codepoint(s, &size);
if (c2 == c) {
- ret = discard_const(s);
+ ret = discard_const_p(char, s);
}
s += size;
}
@@ -482,7 +482,7 @@ _PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
/* this takes advantage of the fact that upper/lower can't
change the length of a character by more than 1 byte */
- dest = talloc_size(ctx, 2*(strlen(src))+1);
+ dest = talloc_array(ctx, char, 2*(strlen(src))+1);
if (dest == NULL) {
return NULL;
}
@@ -505,7 +505,7 @@ _PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
dest[size] = 0;
/* trim it so talloc_append_string() works */
- dest = talloc_realloc_size(ctx, dest, size+1);
+ dest = talloc_realloc(ctx, dest, char, size+1);
talloc_set_name_const(dest, dest);
@@ -526,7 +526,7 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
/* this takes advantage of the fact that upper/lower can't
change the length of a character by more than 1 byte */
- dest = talloc_size(ctx, 2*(strlen(src))+1);
+ dest = talloc_array(ctx, char, 2*(strlen(src))+1);
if (dest == NULL) {
return NULL;
}
@@ -549,7 +549,7 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
dest[size] = 0;
/* trim it so talloc_append_string() works */
- dest = talloc_realloc_size(ctx, dest, size+1);
+ dest = talloc_realloc(ctx, dest, char, size+1);
talloc_set_name_const(dest, dest);
diff --git a/source4/lib/cmdline/credentials.c b/source4/lib/cmdline/credentials.c
index 36e0504021..2e5c6fd94a 100644
--- a/source4/lib/cmdline/credentials.c
+++ b/source4/lib/cmdline/credentials.c
@@ -38,7 +38,12 @@ static const char *cmdline_get_userpassword(struct cli_credentials *credentials)
return ret;
}
-void cli_credentials_set_cmdline_callbacks(struct cli_credentials *cred)
+bool cli_credentials_set_cmdline_callbacks(struct cli_credentials *cred)
{
- cli_credentials_set_password_callback(cred, cmdline_get_userpassword);
+ if (isatty(fileno(stdout))) {
+ cli_credentials_set_password_callback(cred, cmdline_get_userpassword);
+ return true;
+ }
+
+ return false;
}
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c
index 413c8e7cc3..41eb70094e 100644
--- a/source4/lib/cmdline/popt_common.c
+++ b/source4/lib/cmdline/popt_common.c
@@ -22,6 +22,8 @@
#include "includes.h"
#include "version.h"
#include "lib/cmdline/popt_common.h"
+#include "param/param.h"
+#include "dynconfig.h"
/* Handle command line options:
* -d,--debuglevel
@@ -39,8 +41,6 @@ enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL,OPT_DEBUG_STDERR};
struct cli_credentials *cmdline_credentials = NULL;
-static bool PrintSambaVersionString;
-
static void popt_common_callback(poptContext con,
enum poptCallbackReason reason,
const struct poptOption *opt,
@@ -49,12 +49,12 @@ static void popt_common_callback(poptContext con,
const char *pname;
if (reason == POPT_CALLBACK_REASON_POST) {
- if (PrintSambaVersionString) {
- printf( "Version %s\n", SAMBA_VERSION_STRING );
- exit(0);
+ if (!lp_loaded()) {
+ if (getenv("SMB_CONF_PATH"))
+ lp_load(getenv("SMB_CONF_PATH"));
+ else
+ lp_load(dyn_CONFIGFILE);
}
-
- lp_load();
/* Hook any 'every Samba program must do this, after
* the smb.conf is setup' functions here */
return;
@@ -76,15 +76,12 @@ static void popt_common_callback(poptContext con,
/* and logging */
setup_logging(pname, DEBUG_STDOUT);
- if (getenv("SMB_CONF_PATH")) {
- lp_set_cmdline("config file", getenv("SMB_CONF_PATH"));
- }
return;
}
switch(opt->val) {
case 'd':
- lp_set_cmdline("log level", arg);
+ lp_set_cmdline(global_loadparm, "log level", arg);
break;
case OPT_DEBUG_STDERR:
@@ -92,55 +89,55 @@ static void popt_common_callback(poptContext con,
break;
case 'V':
- PrintSambaVersionString = true;
- break;
+ printf("Version %s\n", SAMBA_VERSION_STRING );
+ exit(0);
case 'O':
if (arg) {
- lp_set_cmdline("socket options", arg);
+ lp_set_cmdline(global_loadparm, "socket options", arg);
}
break;
case 's':
if (arg) {
- lp_set_cmdline("config file", arg);
+ lp_load(arg);
}
break;
case 'l':
if (arg) {
char *new_logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname);
- lp_set_cmdline("log file", new_logfile);
+ lp_set_cmdline(global_loadparm, "log file", new_logfile);
talloc_free(new_logfile);
}
break;
case 'W':
- lp_set_cmdline("workgroup", arg);
+ lp_set_cmdline(global_loadparm, "workgroup", arg);
break;
case 'r':
- lp_set_cmdline("realm", arg);
+ lp_set_cmdline(global_loadparm, "realm", arg);
break;
case 'n':
- lp_set_cmdline("netbios name", arg);
+ lp_set_cmdline(global_loadparm, "netbios name", arg);
break;
case 'i':
- lp_set_cmdline("netbios scope", arg);
+ lp_set_cmdline(global_loadparm, "netbios scope", arg);
break;
case 'm':
- lp_set_cmdline("client max protocol", arg);
+ lp_set_cmdline(global_loadparm, "client max protocol", arg);
break;
case 'R':
- lp_set_cmdline("name resolve order", arg);
+ lp_set_cmdline(global_loadparm, "name resolve order", arg);
break;
case OPT_OPTION:
- if (!lp_set_option(arg)) {
+ if (!lp_set_option(global_loadparm, arg)) {
fprintf(stderr, "Error setting option '%s'\n", arg);
exit(1);
}
diff --git a/source4/lib/cmdline/popt_credentials.c b/source4/lib/cmdline/popt_credentials.c
index 259dbf8ee1..53e214ab22 100644
--- a/source4/lib/cmdline/popt_credentials.c
+++ b/source4/lib/cmdline/popt_credentials.c
@@ -23,6 +23,7 @@
#include "lib/cmdline/credentials.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
/* Handle command line options:
* -U,--user
@@ -36,7 +37,7 @@
*/
-static BOOL dont_ask;
+static bool dont_ask;
enum opt { OPT_SIMPLE_BIND_DN, OPT_PASSWORD, OPT_KERBEROS };
@@ -45,7 +46,7 @@ enum opt { OPT_SIMPLE_BIND_DN, OPT_PASSWORD, OPT_KERBEROS };
*/
void popt_common_dont_ask(void)
{
- dont_ask = True;
+ dont_ask = true;
}
static void popt_common_credentials_callback(poptContext con,
@@ -94,7 +95,7 @@ static void popt_common_credentials_callback(poptContext con,
break;
case 'S':
- lp_set_cmdline("client signing", arg);
+ lp_set_cmdline(global_loadparm, "client signing", arg);
break;
case 'P':
@@ -104,7 +105,7 @@ static void popt_common_credentials_callback(poptContext con,
case OPT_KERBEROS:
{
- BOOL use_kerberos = True;
+ bool use_kerberos = true;
/* Force us to only use kerberos */
if (arg) {
if (!set_boolean(arg, &use_kerberos)) {
diff --git a/source4/lib/crypto/hmacmd5test.c b/source4/lib/crypto/hmacmd5test.c
index 3e277a9232..07ed54c98d 100644
--- a/source4/lib/crypto/hmacmd5test.c
+++ b/source4/lib/crypto/hmacmd5test.c
@@ -31,9 +31,9 @@ static DATA_BLOB data_blob_repeat_byte(uint8_t byte, size_t length)
/*
This uses the test values from rfc 2104, 2202
*/
-BOOL torture_local_crypto_hmacmd5(struct torture_context *torture)
+bool torture_local_crypto_hmacmd5(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
uint32_t i;
struct {
DATA_BLOB key;
@@ -90,7 +90,7 @@ BOOL torture_local_crypto_hmacmd5(struct torture_context *torture)
dump_data(0, testarray[i].data.data, testarray[i].data.length);
dump_data(0, testarray[i].md5.data, testarray[i].md5.length);
dump_data(0, md5, sizeof(md5));
- ret = False;
+ ret = false;
}
}
diff --git a/source4/lib/crypto/hmacsha1test.c b/source4/lib/crypto/hmacsha1test.c
index 9c4662a405..6e53124d21 100644
--- a/source4/lib/crypto/hmacsha1test.c
+++ b/source4/lib/crypto/hmacsha1test.c
@@ -31,9 +31,9 @@ static DATA_BLOB data_blob_repeat_byte(uint8_t byte, size_t length)
/*
This uses the test values from rfc2202
*/
-BOOL torture_local_crypto_hmacsha1(struct torture_context *torture)
+bool torture_local_crypto_hmacsha1(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
uint32_t i;
struct {
DATA_BLOB key;
@@ -89,7 +89,7 @@ BOOL torture_local_crypto_hmacsha1(struct torture_context *torture)
dump_data(0, testarray[i].data.data, testarray[i].data.length);
dump_data(0, testarray[i].sha1.data, testarray[i].sha1.length);
dump_data(0, sha1, sizeof(sha1));
- ret = False;
+ ret = false;
}
}
diff --git a/source4/lib/crypto/md4test.c b/source4/lib/crypto/md4test.c
index fa92668f84..5e0451973c 100644
--- a/source4/lib/crypto/md4test.c
+++ b/source4/lib/crypto/md4test.c
@@ -25,9 +25,9 @@ struct torture_context;
/*
This uses the test values from rfc1320
*/
-BOOL torture_local_crypto_md4(struct torture_context *torture)
+bool torture_local_crypto_md4(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
uint32_t i;
struct {
const char *data;
@@ -74,7 +74,7 @@ BOOL torture_local_crypto_md4(struct torture_context *torture)
dump_data(0, data.data, data.length);
dump_data(0, md4blob.data, md4blob.length);
dump_data(0, md4, sizeof(md4));
- ret = False;
+ ret = false;
}
talloc_free(md4blob.data);
}
diff --git a/source4/lib/crypto/md5test.c b/source4/lib/crypto/md5test.c
index 12645dc045..702e0fcf41 100644
--- a/source4/lib/crypto/md5test.c
+++ b/source4/lib/crypto/md5test.c
@@ -25,9 +25,9 @@ struct torture_context;
/*
This uses the test values from rfc1321
*/
-BOOL torture_local_crypto_md5(struct torture_context *torture)
+bool torture_local_crypto_md5(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
uint32_t i;
struct {
const char *data;
@@ -84,7 +84,7 @@ BOOL torture_local_crypto_md5(struct torture_context *torture)
dump_data(0, data.data, data.length);
dump_data(0, md5blob.data, md5blob.length);
dump_data(0, md5, sizeof(md5));
- ret = False;
+ ret = false;
}
talloc_free(md5blob.data);
}
diff --git a/source4/lib/crypto/sha1test.c b/source4/lib/crypto/sha1test.c
index a37328e328..0e943bd74d 100644
--- a/source4/lib/crypto/sha1test.c
+++ b/source4/lib/crypto/sha1test.c
@@ -57,7 +57,7 @@ bool torture_local_crypto_sha1(struct torture_context *tctx)
struct SHA1Context sha;
int i, j, err;
uint8_t Message_Digest[20];
- BOOL ret = True;
+ bool ret = true;
char tmp[60 + 10];
/*
@@ -94,7 +94,7 @@ bool torture_local_crypto_sha1(struct torture_context *tctx)
torture_comment(tctx, "\n");
torture_comment(tctx, "Should match:\n\t%s\n", resultarray[j]);
if (strcmp(resultarray[j], tmp) != 0) {
- ret = False;
+ ret = false;
}
}
diff --git a/source4/lib/db_wrap.c b/source4/lib/db_wrap.c
index 0e026f84e1..c33786a1e4 100644
--- a/source4/lib/db_wrap.c
+++ b/source4/lib/db_wrap.c
@@ -32,9 +32,10 @@
#include "lib/tdb/include/tdb.h"
#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
-#include "lib/ldb/samba/ldif_handlers.h"
+#include "lib/ldb-samba/ldif_handlers.h"
#include "db_wrap.h"
#include "dsdb/samdb/samdb.h"
+#include "param/param.h"
static struct tdb_wrap *tdb_list;
@@ -102,6 +103,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 loadparm_context *lp_ctx,
const char *url,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
@@ -119,6 +121,9 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
return NULL;
}
+ 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 */
@@ -139,7 +144,7 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
return NULL;
}
- if (strcmp(lp_sam_url(), url) == 0) {
+ if (strcmp(lp_sam_url(lp_ctx), url) == 0) {
dsdb_set_global_schema(ldb);
}
@@ -153,14 +158,14 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
- real_url = private_path(ldb, url);
+ real_url = private_path(ldb, lp_ctx, url);
if (real_url == NULL) {
talloc_free(ldb);
return NULL;
}
/* allow admins to force non-sync ldb for all databases */
- if (lp_parm_bool(-1, "ldb", "nosync", False)) {
+ if (lp_parm_bool(lp_ctx, NULL, "ldb", "nosync", false)) {
flags |= LDB_FLG_NOSYNC;
}
diff --git a/source4/lib/db_wrap.h b/source4/lib/db_wrap.h
index 4ead9f3010..b45a05c24f 100644
--- a/source4/lib/db_wrap.h
+++ b/source4/lib/db_wrap.h
@@ -31,5 +31,6 @@ struct auth_session_info;
struct ldb_message;
struct ldb_dn;
struct cli_credentials;
+struct loadparm_context;
#include "lib/db_wrap_proto.h"
diff --git a/source4/lib/dbwrap/dbwrap.c b/source4/lib/dbwrap/dbwrap.c
index c0bac672aa..9e893b1243 100644
--- a/source4/lib/dbwrap/dbwrap.c
+++ b/source4/lib/dbwrap/dbwrap.c
@@ -23,14 +23,15 @@
#include "includes.h"
#include "lib/tdb/include/tdb.h"
#include "lib/dbwrap/dbwrap.h"
+#include "param/param.h"
/*
open a temporary database
*/
struct db_context *db_tmp_open(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags)
{
- if (lp_parm_bool(-1, "ctdb", "enable", False) &&
- lp_parm_bool(-1, "ctdb", name, True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ctdb", "enable", false) &&
+ lp_parm_bool(global_loadparm, NULL, "ctdb", name, true)) {
return db_tmp_open_ctdb(mem_ctx, name, tdb_flags);
}
diff --git a/source4/lib/dbwrap/dbwrap_tdb.c b/source4/lib/dbwrap/dbwrap_tdb.c
index dedb344e0b..b256b6ccc4 100644
--- a/source4/lib/dbwrap/dbwrap_tdb.c
+++ b/source4/lib/dbwrap/dbwrap_tdb.c
@@ -25,6 +25,7 @@
#include "lib/dbwrap/dbwrap.h"
#include "system/filesys.h"
#include "db_wrap.h"
+#include "param/param.h"
struct db_tdb_ctx {
struct tdb_wrap *wtdb;
@@ -240,7 +241,7 @@ struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, const char *name, int td
/* the name passed in should not be a full path, it should be
just be the db name */
- path = smbd_tmp_path(result, name);
+ path = smbd_tmp_path(result, global_loadparm, name);
db_tdb->wtdb = tdb_wrap_open(db_tdb, path, 0, tdb_flags,
O_CREAT|O_RDWR, 0666);
diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c
index 9ba3254190..2b36c92491 100644
--- a/source4/lib/events/events.c
+++ b/source4/lib/events/events.c
@@ -57,6 +57,7 @@
#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"
#endif
@@ -79,11 +80,11 @@ bool event_register_backend(const char *name, const struct event_ops *ops)
{
struct event_ops_list *e;
e = talloc(talloc_autofree_context(), struct event_ops_list);
- if (e == NULL) return False;
+ if (e == NULL) return false;
e->name = name;
e->ops = ops;
DLIST_ADD(event_backends, e);
- return True;
+ return true;
}
/*
@@ -104,7 +105,7 @@ static void event_backend_init(void)
init_module_fn static_init[] = STATIC_LIBEVENTS_MODULES;
init_module_fn *shared_init;
if (event_backends) return;
- shared_init = load_samba_modules(NULL, "LIBEVENTS");
+ shared_init = load_samba_modules(NULL, global_loadparm, "events");
run_init_functions(static_init);
run_init_functions(shared_init);
#else
@@ -184,7 +185,7 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char
#if _SAMBA_BUILD_
if (name == NULL) {
- name = lp_parm_string(-1, "event", "backend");
+ name = lp_parm_string(global_loadparm, NULL, "event", "backend");
}
#endif
if (name == NULL) {
diff --git a/source4/lib/events/events_epoll.c b/source4/lib/events/events_epoll.c
index acd204c898..e2212e5333 100644
--- a/source4/lib/events/events_epoll.c
+++ b/source4/lib/events/events_epoll.c
@@ -56,7 +56,7 @@ struct epoll_event_context {
called when a epoll call fails, and we should fallback
to using select
*/
-static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason)
+_NORETURN_ static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason)
{
DEBUG(0,("%s (%s) - calling abort()\n", reason, strerror(errno)));
abort();
diff --git a/source4/lib/events/events_signal.c b/source4/lib/events/events_signal.c
index 2f6d499383..aec34339c3 100644
--- a/source4/lib/events/events_signal.c
+++ b/source4/lib/events/events_signal.c
@@ -217,8 +217,8 @@ struct signal_event *common_event_add_signal(struct event_context *ev,
if (sig_state->pipe_hack[0] == 0 &&
sig_state->pipe_hack[1] == 0) {
pipe(sig_state->pipe_hack);
- set_blocking(sig_state->pipe_hack[0], False);
- set_blocking(sig_state->pipe_hack[1], False);
+ set_blocking(sig_state->pipe_hack[0], false);
+ set_blocking(sig_state->pipe_hack[1], false);
}
ev->pipe_fde = event_add_fd(ev, ev, sig_state->pipe_hack[0],
EVENT_FD_READ, signal_pipe_handler, NULL);
diff --git a/source4/lib/gencache/gencache.c b/source4/lib/gencache/gencache.c
index a30f09fefa..949b16cb3b 100644
--- a/source4/lib/gencache/gencache.c
+++ b/source4/lib/gencache/gencache.c
@@ -47,30 +47,31 @@ static struct tdb_wrap *cache;
* false on failure
**/
-BOOL gencache_init(void)
+bool gencache_init(void)
{
char* cache_fname = NULL;
+ TALLOC_CTX *mem_ctx = talloc_autofree_context();
/* skip file open if it's already opened */
- if (cache) return True;
+ if (cache) return true;
- asprintf(&cache_fname, "%s/%s", lp_lockdir(), "gencache.tdb");
- if (cache_fname)
+ cache_fname = lock_path(mem_ctx, global_loadparm, "gencache.tdb");
+ if (cache_fname != NULL) {
DEBUG(5, ("Opening cache file at %s\n", cache_fname));
- else {
+ } else {
DEBUG(0, ("Filename allocation failed.\n"));
- return False;
+ return false;
}
- cache = tdb_wrap_open(NULL, cache_fname, 0, TDB_DEFAULT,
+ cache = tdb_wrap_open(mem_ctx, cache_fname, 0, TDB_DEFAULT,
O_RDWR|O_CREAT, 0644);
- SAFE_FREE(cache_fname);
+ talloc_free(cache_fname);
if (!cache) {
DEBUG(5, ("Attempt to open gencache.tdb has failed.\n"));
- return False;
+ return false;
}
- return True;
+ return true;
}
@@ -81,12 +82,12 @@ BOOL gencache_init(void)
* false on failure during cache shutdown
**/
-BOOL gencache_shutdown(void)
+bool gencache_shutdown(void)
{
- if (!cache) return False;
+ if (!cache) return false;
DEBUG(5, ("Closing cache file\n"));
talloc_free(cache);
- return True;
+ return true;
}
@@ -102,7 +103,7 @@ BOOL gencache_shutdown(void)
* @retval false on failure
**/
-BOOL gencache_set(const char *keystr, const char *value, time_t timeout)
+bool gencache_set(const char *keystr, const char *value, time_t timeout)
{
int ret;
TDB_DATA keybuf, databuf;
@@ -111,11 +112,11 @@ BOOL gencache_set(const char *keystr, const char *value, time_t timeout)
/* fail completely if get null pointers passed */
SMB_ASSERT(keystr && value);
- if (!gencache_init()) return False;
+ if (!gencache_init()) return false;
asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value);
if (!valstr)
- return False;
+ return false;
keybuf.dptr = (uint8_t *)strdup(keystr);
keybuf.dsize = strlen(keystr)+1;
@@ -145,7 +146,7 @@ BOOL gencache_set(const char *keystr, const char *value, time_t timeout)
* @retval false on failure
**/
-BOOL gencache_set_only(const char *keystr, const char *valstr, time_t timeout)
+bool gencache_set_only(const char *keystr, const char *valstr, time_t timeout)
{
int ret = -1;
TDB_DATA keybuf, databuf;
@@ -155,7 +156,7 @@ BOOL gencache_set_only(const char *keystr, const char *valstr, time_t timeout)
/* fail completely if get null pointers passed */
SMB_ASSERT(keystr && valstr);
- if (!gencache_init()) return False;
+ if (!gencache_init()) return false;
/*
* Check whether entry exists in the cache
@@ -163,7 +164,7 @@ BOOL gencache_set_only(const char *keystr, const char *valstr, time_t timeout)
*/
gencache_get(keystr, &old_valstr, &old_timeout);
- if (!(old_valstr && old_timeout)) return False;
+ if (!(old_valstr && old_timeout)) return false;
DEBUG(10, ("Setting cache entry with key = %s; old value = %s and old timeout \
= %s\n", keystr, old_valstr, ctime(&old_timeout)));
@@ -198,7 +199,7 @@ BOOL gencache_set_only(const char *keystr, const char *valstr, time_t timeout)
* @retval false in case of failure
**/
-BOOL gencache_del(const char *keystr)
+bool gencache_del(const char *keystr)
{
int ret;
TDB_DATA keybuf;
@@ -206,7 +207,7 @@ BOOL gencache_del(const char *keystr)
/* fail completely if get null pointers passed */
SMB_ASSERT(keystr);
- if (!gencache_init()) return False;
+ if (!gencache_init()) return false;
keybuf.dptr = (uint8_t *)strdup(keystr);
keybuf.dsize = strlen(keystr)+1;
@@ -228,10 +229,10 @@ BOOL gencache_del(const char *keystr)
* timeout
*
* @retval true when entry is successfuly fetched
- * @retval False for failure
+ * @retval false for failure
**/
-BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout)
+bool gencache_get(const char *keystr, char **valstr, time_t *timeout)
{
TDB_DATA keybuf, databuf;
@@ -239,7 +240,7 @@ BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout)
SMB_ASSERT(keystr);
if (!gencache_init())
- return False;
+ return false;
keybuf.dptr = (uint8_t *)strdup(keystr);
keybuf.dsize = strlen(keystr)+1;
@@ -285,7 +286,7 @@ BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout)
DEBUG(10, ("Cache entry with key = %s couldn't be found\n",
keystr));
- return False;
+ return false;
}
}
diff --git a/source4/lib/ldb/samba/README b/source4/lib/ldb-samba/README
index 3fa47159ca..3fa47159ca 100644
--- a/source4/lib/ldb/samba/README
+++ b/source4/lib/ldb-samba/README
diff --git a/source4/lib/ldb/samba/config.mk b/source4/lib/ldb-samba/config.mk
index d29b3f319c..d29b3f319c 100644
--- a/source4/lib/ldb/samba/config.mk
+++ b/source4/lib/ldb-samba/config.mk
diff --git a/source4/lib/ldb/samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c
index cfd79563d5..928a06ab43 100644
--- a/source4/lib/ldb/samba/ldif_handlers.c
+++ b/source4/lib/ldb-samba/ldif_handlers.c
@@ -78,15 +78,15 @@ static int ldif_write_objectSid(struct ldb_context *ldb, void *mem_ctx,
return 0;
}
-static BOOL ldb_comparision_objectSid_isString(const struct ldb_val *v)
+static bool ldb_comparision_objectSid_isString(const struct ldb_val *v)
{
if (v->length < 3) {
- return False;
+ return false;
}
- if (strncmp("S-", (const char *)v->data, 2) != 0) return False;
+ if (strncmp("S-", (const char *)v->data, 2) != 0) return false;
- return True;
+ return true;
}
/*
@@ -176,22 +176,22 @@ static int ldif_write_objectGUID(struct ldb_context *ldb, void *mem_ctx,
return 0;
}
-static BOOL ldb_comparision_objectGUID_isString(const struct ldb_val *v)
+static bool ldb_comparision_objectGUID_isString(const struct ldb_val *v)
{
struct GUID guid;
NTSTATUS status;
- if (v->length < 33) return False;
+ if (v->length < 33) return false;
/* see if the input if null-terninated (safety check for the below) */
- if (v->data[v->length] != '\0') return False;
+ if (v->data[v->length] != '\0') return false;
status = GUID_from_string((const char *)v->data, &guid);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in
index 4a4585d861..75f1767550 100644
--- a/source4/lib/ldb/Makefile.in
+++ b/source4/lib/ldb/Makefile.in
@@ -30,11 +30,14 @@ POPT_LIBS = @POPT_LIBS@
POPT_CFLAGS = @POPT_CFLAGS@
POPT_OBJ = @POPT_OBJ@
+LDAP_LIBS = @LDAP_LIBS@
+
CFLAGS=-g -I$(srcdir)/include -Iinclude -I$(srcdir) -I$(srcdir)/.. \
$(POPT_CFLAGS) $(TALLOC_CFLAGS) $(TDB_CFLAGS) \
-DLIBDIR=\"$(libdir)\" -DSHLIBEXT=\"@SHLIBEXT@\" -DUSE_MMAP=1 @CFLAGS@
-LIB_FLAGS=@LDFLAGS@ -Llib -lldb @LIBS@ $(POPT_LIBS) $(TALLOC_LIBS) $(TDB_LIBS)
+LIB_FLAGS=@LDFLAGS@ -Llib -lldb @LIBS@ $(POPT_LIBS) $(TALLOC_LIBS) $(TDB_LIBS) \
+ $(LDAP_LIBS)
LDB_TDB_DIR=ldb_tdb
LDB_TDB_OBJ=$(LDB_TDB_DIR)/ldb_tdb.o \
diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c
index b8747c3b95..8ed2763d4d 100644
--- a/source4/lib/ldb/common/attrib_handlers.c
+++ b/source4/lib/ldb/common/attrib_handlers.c
@@ -278,33 +278,6 @@ int ldb_comparison_dn(struct ldb_context *ldb, void *mem_ctx,
}
/*
- compare two objectclasses, looking at subclasses
-*/
-int ldb_comparison_objectclass(struct ldb_context *ldb, void *mem_ctx,
- const struct ldb_val *v1, const struct ldb_val *v2)
-{
- int ret, i;
- const char **subclasses;
- ret = ldb_comparison_fold(ldb, mem_ctx, v1, v2);
- if (ret == 0) {
- return 0;
- }
- subclasses = ldb_subclass_list(ldb, (char *)v1->data);
- if (subclasses == NULL) {
- return ret;
- }
- for (i=0;subclasses[i];i++) {
- struct ldb_val vs;
- vs.data = discard_const(subclasses[i]);
- vs.length = strlen(subclasses[i]);
- if (ldb_comparison_objectclass(ldb, mem_ctx, &vs, v2) == 0) {
- return 0;
- }
- }
- return ret;
-}
-
-/*
compare two utc time values. 1 second resolution
*/
int ldb_comparison_utctime(struct ldb_context *ldb, void *mem_ctx,
@@ -368,7 +341,7 @@ static const struct ldb_schema_syntax ldb_standard_syntaxes[] = {
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldb_handler_copy,
.canonicalise_fn = ldb_handler_fold,
- .comparison_fn = ldb_comparison_objectclass
+ .comparison_fn = ldb_comparison_fold
},
{
.name = LDB_SYNTAX_UTC_TIME,
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index f8085d213a..eb8ff62a0d 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -51,6 +51,7 @@ struct ldb_context *ldb_init(void *mem_ctx)
ldb_set_utf8_default(ldb);
ldb_set_create_perms(ldb, 0666);
+ ldb_set_modules_dir(ldb, LDB_MODULESDIR);
return ldb;
}
diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c
index 358d2f18bd..effd93ae26 100644
--- a/source4/lib/ldb/common/ldb_attributes.c
+++ b/source4/lib/ldb/common/ldb_attributes.c
@@ -204,114 +204,3 @@ int ldb_setup_wellknown_attributes(struct ldb_context *ldb)
return LDB_SUCCESS;
}
-/*
- return the list of subclasses for a class
-*/
-const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname)
-{
- int i;
- for (i=0;i<ldb->schema.num_classes;i++) {
- if (ldb_attr_cmp(classname, ldb->schema.classes[i].name) == 0) {
- return (const char **)ldb->schema.classes[i].subclasses;
- }
- }
- return NULL;
-}
-
-
-/*
- add a new subclass
-*/
-static int ldb_subclass_new(struct ldb_context *ldb, const char *classname, const char *subclass)
-{
- struct ldb_subclass *s, *c;
- s = talloc_realloc(ldb, ldb->schema.classes, struct ldb_subclass, ldb->schema.num_classes+1);
- if (s == NULL) goto failed;
-
- ldb->schema.classes = s;
- c = &s[ldb->schema.num_classes];
- c->name = talloc_strdup(s, classname);
- if (c->name == NULL) goto failed;
-
- c->subclasses = talloc_array(s, char *, 2);
- if (c->subclasses == NULL) goto failed;
-
- c->subclasses[0] = talloc_strdup(c->subclasses, subclass);
- if (c->subclasses[0] == NULL) goto failed;
- c->subclasses[1] = NULL;
-
- ldb->schema.num_classes++;
-
- return 0;
-failed:
- ldb_oom(ldb);
- return -1;
-}
-
-/*
- add a subclass
-*/
-int ldb_subclass_add(struct ldb_context *ldb, const char *classname, const char *subclass)
-{
- int i, n;
- struct ldb_subclass *c;
- char **s;
-
- for (i=0;i<ldb->schema.num_classes;i++) {
- if (ldb_attr_cmp(classname, ldb->schema.classes[i].name) == 0) {
- break;
- }
- }
- if (i == ldb->schema.num_classes) {
- return ldb_subclass_new(ldb, classname, subclass);
- }
- c = &ldb->schema.classes[i];
-
- for (n=0;c->subclasses[n];n++) /* noop */;
-
- s = talloc_realloc(ldb->schema.classes, c->subclasses, char *, n+2);
- if (s == NULL) {
- ldb_oom(ldb);
- return -1;
- }
-
- c->subclasses = s;
- s[n] = talloc_strdup(s, subclass);
- if (s[n] == NULL) {
- ldb_oom(ldb);
- return -1;
- }
- s[n+1] = NULL;
-
- return 0;
-}
-
-/*
- remove a set of subclasses for a class
-*/
-void ldb_subclass_remove(struct ldb_context *ldb, const char *classname)
-{
- int i;
- struct ldb_subclass *c;
-
- for (i=0;i<ldb->schema.num_classes;i++) {
- if (ldb_attr_cmp(classname, ldb->schema.classes[i].name) == 0) {
- break;
- }
- }
- if (i == ldb->schema.num_classes) {
- return;
- }
-
- c = &ldb->schema.classes[i];
- talloc_free(c->name);
- talloc_free(c->subclasses);
- if (ldb->schema.num_classes-(i+1) > 0) {
- memmove(c, c+1, sizeof(*c) * (ldb->schema.num_classes-(i+1)));
- }
- ldb->schema.num_classes--;
- if (ldb->schema.num_classes == 0) {
- talloc_free(ldb->schema.classes);
- ldb->schema.classes = NULL;
- }
-}
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 41e70cffd1..f0bd72e009 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -1279,6 +1279,7 @@ static char *ldb_dn_canonical(void *mem_ctx, struct ldb_dn *dn, int ex_format) {
int i;
TALLOC_CTX *tmpctx;
char *cracked = NULL;
+ const char *format = (ex_format ? "\n" : "/" );
if ( ! ldb_dn_validate(dn)) {
return NULL;
@@ -1305,32 +1306,23 @@ static char *ldb_dn_canonical(void *mem_ctx, struct ldb_dn *dn, int ex_format) {
/* Only domain components? Finish here */
if (i < 0) {
- if (ex_format) {
- cracked = talloc_append_string(tmpctx, cracked, "\n");
- } else {
- cracked = talloc_append_string(tmpctx, cracked, "/");
- }
+ cracked = talloc_strdup_append_buffer(cracked, format);
talloc_steal(mem_ctx, cracked);
goto done;
}
/* Now walk backwards appending remaining components */
for (; i > 0; i--) {
- cracked = talloc_asprintf_append(cracked, "/%s",
- ldb_dn_escape_value(tmpctx, dn->components[i].value));
+ cracked = talloc_asprintf_append_buffer(cracked, "/%s",
+ ldb_dn_escape_value(tmpctx, dn->components[i].value));
if (!cracked) {
goto done;
}
}
/* Last one, possibly a newline for the 'ex' format */
- if (ex_format) {
- cracked = talloc_asprintf_append(cracked, "\n%s",
- ldb_dn_escape_value(tmpctx, dn->components[i].value));
- } else {
- cracked = talloc_asprintf_append(cracked, "/%s",
- ldb_dn_escape_value(tmpctx, dn->components[i].value));
- }
+ cracked = talloc_asprintf_append_buffer(cracked, "%s%s", format,
+ ldb_dn_escape_value(tmpctx, dn->components[i].value));
talloc_steal(mem_ctx, cracked);
done:
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 2c9fba590a..9f94c90c92 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -36,12 +36,17 @@
#if (_SAMBA_BUILD_ >= 4)
#include "includes.h"
#include "build.h"
-#include "dynconfig.h"
#endif
#define LDB_MODULE_PREFIX "modules:"
#define LDB_MODULE_PREFIX_LEN 8
+void ldb_set_modules_dir(struct ldb_context *ldb, const char *path)
+{
+ talloc_free(ldb->modules_dir);
+ ldb->modules_dir = talloc_strdup(ldb, path);
+}
+
static char *ldb_modules_strdup_no_spaces(TALLOC_CTX *mem_ctx, const char *string)
{
int i, len;
@@ -203,21 +208,12 @@ int ldb_try_load_dso(struct ldb_context *ldb, const char *name)
char *path;
void *handle;
int (*init_fn) (void);
- char *modulesdir;
- if (getenv("LD_LDB_MODULE_PATH") != NULL) {
- modulesdir = talloc_strdup(ldb, getenv("LD_LDB_MODULE_PATH"));
- } else {
-#ifdef _SAMBA_BUILD_
- modulesdir = talloc_asprintf(ldb, "%s/ldb", dyn_MODULESDIR);
-#else
- modulesdir = talloc_strdup(ldb, MODULESDIR);
-#endif
- }
-
- path = talloc_asprintf(ldb, "%s/%s.%s", modulesdir, name, SHLIBEXT);
+ if (ldb->modules_dir == NULL)
+ return -1;
- talloc_free(modulesdir);
+ path = talloc_asprintf(ldb, "%s/%s.%s", ldb->modules_dir, name,
+ SHLIBEXT);
ldb_debug(ldb, LDB_DEBUG_TRACE, "trying to load %s from %s\n", name, path);
diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk
index e47bf8ea39..6472612837 100644
--- a/source4/lib/ldb/config.mk
+++ b/source4/lib/ldb/config.mk
@@ -71,24 +71,10 @@ OBJ_FILES = \
################################################
################################################
-# Start MODULE ldb_ildap
-[MODULE::ldb_ildap]
-SUBSYSTEM = LIBLDB
-CFLAGS = -Ilib/ldb/include
-PRIVATE_DEPENDENCIES = LIBTALLOC LIBCLI_LDAP
-INIT_FUNCTION = ldb_ildap_init
-ALIASES = ldapi ldaps ldap
-OBJ_FILES = \
- ldb_ildap/ldb_ildap.o
-# End MODULE ldb_ildap
-################################################
-
-################################################
# Start MODULE ldb_map
-[MODULE::ldb_map]
+[SUBSYSTEM::ldb_map]
PRIVATE_DEPENDENCIES = LIBTALLOC
CFLAGS = -Ilib/ldb/include -Ilib/ldb/ldb_map
-SUBSYSTEM = LIBLDB
OBJ_FILES = \
ldb_map/ldb_map_inbound.o \
ldb_map/ldb_map_outbound.o \
@@ -137,14 +123,6 @@ PRIVATE_DEPENDENCIES = \
# End MODULE ldb_tdb
################################################
-# NOTE: this rule is broken for some systems when $builddir != $srcdir because
-# it hardcodes the use of $<. See smb_build/makefile.pm.
-./lib/ldb/common/ldb_modules.o: lib/ldb/common/ldb_modules.c Makefile
- @echo Compiling $<
- @$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) \
- -DLDBMODULESDIR=\"$(MODULESDIR)/ldb\" -DSHLIBEXT=\"$(SHLIBEXT)\" \
- -c $< -o $@
-
################################################
# Start SUBSYSTEM ldb
[LIBRARY::LIBLDB]
@@ -179,89 +157,6 @@ PUBLIC_HEADERS = include/ldb.h include/ldb_errors.h
################################################
################################################
-# Start SUBSYSTEM LIBLDB_CMDLINE
-[SUBSYSTEM::LIBLDB_CMDLINE]
-CFLAGS = -Ilib/ldb
-OBJ_FILES= \
- tools/cmdline.o
-PUBLIC_DEPENDENCIES = LIBLDB LIBPOPT
-PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL POPT_SAMBA POPT_CREDENTIALS gensec
-# End SUBSYSTEM LIBLDB_CMDLINE
-################################################
-
-################################################
-# Start BINARY ldbadd
-[BINARY::ldbadd]
-INSTALLDIR = BINDIR
-OBJ_FILES = \
- tools/ldbadd.o
-PRIVATE_DEPENDENCIES = \
- LIBLDB_CMDLINE LIBCLI_RESOLVE
-MANPAGE = man/ldbadd.1
-# End BINARY ldbadd
-################################################
-
-################################################
-# Start BINARY ldbdel
-[BINARY::ldbdel]
-INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/ldbdel.o
-PRIVATE_DEPENDENCIES = \
- LIBLDB_CMDLINE
-MANPAGE = man/ldbdel.1
-# End BINARY ldbdel
-################################################
-
-################################################
-# Start BINARY ldbmodify
-[BINARY::ldbmodify]
-INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/ldbmodify.o
-PRIVATE_DEPENDENCIES = \
- LIBLDB_CMDLINE
-MANPAGE = man/ldbmodify.1
-# End BINARY ldbmodify
-################################################
-
-################################################
-# Start BINARY ldbsearch
-[BINARY::ldbsearch]
-INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/ldbsearch.o
-PRIVATE_DEPENDENCIES = \
- LIBLDB_CMDLINE
-MANPAGE = man/ldbsearch.1
-# End BINARY ldbsearch
-################################################
-
-################################################
-# Start BINARY ldbedit
-[BINARY::ldbedit]
-INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/ldbedit.o
-PRIVATE_DEPENDENCIES = \
- LIBLDB_CMDLINE
-MANPAGE = man/ldbedit.1
-# End BINARY ldbedit
-################################################
-
-################################################
-# Start BINARY ldbrename
-[BINARY::ldbrename]
-INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/ldbrename.o
-PRIVATE_DEPENDENCIES = \
- LIBLDB_CMDLINE
-MANPAGE = man/ldbrename.1
-# End BINARY ldbrename
-################################################
-
-################################################
# Start BINARY ldbtest
[BINARY::ldbtest]
OBJ_FILES= \
@@ -306,4 +201,5 @@ OBJ_FILES = swig/ldb_wrap.o
# End LIBRARY swig_ldb
#######################
-include samba/config.mk
+include tools/config.mk
+include ldb_ildap/config.mk
diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac
index 083518474d..6f19d88290 100644
--- a/source4/lib/ldb/configure.ac
+++ b/source4/lib/ldb/configure.ac
@@ -11,7 +11,7 @@ AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""])
AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""])
AC_DEFUN([SMB_EXT_LIB], [echo -n ""])
AC_DEFUN([SMB_ENABLE], [echo -n ""])
-AC_INIT(ldb, 0.9.0)
+AC_INIT(ldb, 0.9.1)
AC_CONFIG_SRCDIR([common/ldb.c])
AC_LIBREPLACE_ALL_CHECKS
@@ -41,8 +41,8 @@ AC_SEARCH_LIBS(dlopen, dl, AC_DEFINE(HAVE_DLOPEN, [1], [have dlopen]))
SHLIBEXT="so" # Should be set based on OS later on
AC_SUBST(SHLIBEXT)
-AC_DEFINE_UNQUOTED(MODULESDIR, LIBDIR "/ldb" , [Modules directory] )
-AC_SUBST(MODULESDIR)
+AC_DEFINE_UNQUOTED(LDB_MODULESDIR, LIBDIR "/ldb" , [Modules directory] )
+AC_SUBST(LDB_MODULESDIR)
TESTS=""
EXTRA_OBJ=""
@@ -53,9 +53,10 @@ m4_include(libtdb.m4)
m4_include(ldap.m4)
if test x"$with_ldap_support" = x"yes"; then
- LIBS="$LIBS -llber -lldap"
CFLAGS="$CFLAGS -DHAVE_LDB_LDAP=1"
EXTRA_OBJ="$EXTRA_OBJ ldb_ldap/ldb_ldap.o"
+ LDAP_LIBS="-llber -lldap"
+ AC_SUBST(LDAP_LIBS)
TESTS="$TESTS test-ldap.sh"
fi
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 8f693309c5..41d23b5d10 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -779,6 +779,7 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type);
int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout);
int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq);
void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms);
+void ldb_set_modules_dir(struct ldb_context *ldb, const char *path);
/**
Initialise ldbs' global information
@@ -876,7 +877,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l
\param ret_req the request structure is returned here (talloced on mem_ctx)
\param ldb the context associated with the database (from ldb_init())
- \param mem_ctx a talloc emmory context (used as parent of ret_req)
+ \param mem_ctx a talloc memory context (used as parent of ret_req)
\param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one)
\param scope the search scope for the query
\param expression the search expression to use for this query
@@ -904,7 +905,7 @@ int ldb_build_search_req(struct ldb_request **ret_req,
\param ret_req the request structure is returned here (talloced on mem_ctx)
\param ldb the context associated with the database (from ldb_init())
- \param mem_ctx a talloc emmory context (used as parent of ret_req)
+ \param mem_ctx a talloc memory context (used as parent of ret_req)
\param message contains the entry to be added
\param controls an array of controls
\param context the callback function context
@@ -926,7 +927,7 @@ int ldb_build_add_req(struct ldb_request **ret_req,
\param ret_req the request structure is returned here (talloced on mem_ctx)
\param ldb the context associated with the database (from ldb_init())
- \param mem_ctx a talloc emmory context (used as parent of ret_req)
+ \param mem_ctx a talloc memory context (used as parent of ret_req)
\param message contains the entry to be modified
\param controls an array of controls
\param context the callback function context
@@ -948,7 +949,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
\param ret_req the request structure is returned here (talloced on mem_ctx)
\param ldb the context associated with the database (from ldb_init())
- \param mem_ctx a talloc emmory context (used as parent of ret_req)
+ \param mem_ctx a talloc memory context (used as parent of ret_req)
\param dn the DN to be deleted
\param controls an array of controls
\param context the callback function context
@@ -970,7 +971,7 @@ int ldb_build_del_req(struct ldb_request **ret_req,
\param ret_req the request structure is returned here (talloced on mem_ctx)
\param ldb the context associated with the database (from ldb_init())
- \param mem_ctx a talloc emmory context (used as parent of ret_req)
+ \param mem_ctx a talloc memory context (used as parent of ret_req)
\param olddn the old DN
\param newdn the new DN
\param controls an array of controls
@@ -1043,15 +1044,6 @@ int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
enum ldb_scope scope, const char * const *attrs,
const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8);
-/*
- like ldb_search() but takes a parse tree
-*/
-int ldb_search_bytree(struct ldb_context *ldb,
- struct ldb_dn *base,
- enum ldb_scope scope,
- struct ldb_parse_tree *tree,
- const char * const *attrs, struct ldb_result **res);
-
/**
Add a record to the database.
@@ -1137,7 +1129,7 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct
\param ret_req the request structure is returned here (talloced on mem_ctx)
\param ldb the context associated with the database (from ldb_init())
- \param mem_ctx a talloc emmory context (used as parent of ret_req)
+ \param mem_ctx a talloc memory context (used as parent of ret_req)
\param oid the OID of the extended operation.
\param data a void pointer a the extended operation specific parameters,
it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it
@@ -1418,9 +1410,6 @@ bool ldb_dn_check_special(struct ldb_dn *dn, const char *check);
bool ldb_dn_is_null(struct ldb_dn *dn);
-/* useful functions for ldb_message structure manipulation */
-int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2);
-
/**
Compare two attributes
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index cac665b5bb..e07083bef7 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -120,6 +120,8 @@ struct ldb_context {
unsigned int flags;
unsigned int create_perms;
+
+ char *modules_dir;
};
#ifndef ARRAY_SIZE
diff --git a/source4/lib/ldb/ldb.pc.in b/source4/lib/ldb/ldb.pc.in
index fb59f82698..248fb05c4f 100644
--- a/source4/lib/ldb/ldb.pc.in
+++ b/source4/lib/ldb/ldb.pc.in
@@ -10,6 +10,7 @@ Version: @PACKAGE_VERSION@
Requires.private: tdb
Requires: talloc
Libs: -L${libdir} -lldb
-Cflags: -I${includedir} @CFLAGS@
+Libs.private: @LDAP_LIBS@
+Cflags: -I${includedir}
Modulesdir: ${modulesdir}
URL: http://ldb.samba.org/
diff --git a/source4/lib/ldb/ldb_ildap/config.mk b/source4/lib/ldb/ldb_ildap/config.mk
new file mode 100644
index 0000000000..71887c14f8
--- /dev/null
+++ b/source4/lib/ldb/ldb_ildap/config.mk
@@ -0,0 +1,14 @@
+################################################
+# Start MODULE ldb_ildap
+[MODULE::ldb_ildap]
+SUBSYSTEM = LIBLDB
+CFLAGS = -Ilib/ldb/include
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBCLI_LDAP
+INIT_FUNCTION = ldb_ildap_init
+ALIASES = ldapi ldaps ldap
+OBJ_FILES = \
+ ldb_ildap.o
+# End MODULE ldb_ildap
+################################################
+
+
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 440686c65e..7b9023958c 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -646,7 +646,7 @@ static int ildb_rename(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_INVALID_DN_SYNTAX;
}
- msg->r.ModifyDNRequest.deleteolddn = True;
+ msg->r.ModifyDNRequest.deleteolddn = true;
return ildb_request_send(ildb, msg, req);
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c
index 6bbf31dee7..de489e3d8b 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_cache.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c
@@ -38,7 +38,6 @@
#define LTDB_FLAG_CASE_INSENSITIVE (1<<0)
#define LTDB_FLAG_INTEGER (1<<1)
#define LTDB_FLAG_HIDDEN (1<<2)
-#define LTDB_FLAG_OBJECTCLASS (1<<3)
/* valid attribute flags */
static const struct {
@@ -58,7 +57,7 @@ static const struct {
*/
static void ltdb_attributes_unload(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
struct ldb_message *msg;
int i;
@@ -105,7 +104,7 @@ static int ltdb_attributes_flags(struct ldb_message_element *el, unsigned *v)
*/
static int ltdb_attributes_load(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
struct ldb_message *msg = ltdb->cache->attributes;
struct ldb_dn *dn;
int i, r;
@@ -168,71 +167,11 @@ failed:
/*
- register any subclasses from @SUBCLASSES
-*/
-static int ltdb_subclasses_load(struct ldb_module *module)
-{
- struct ltdb_private *ltdb = module->private_data;
- struct ldb_message *msg = ltdb->cache->subclasses;
- struct ldb_dn *dn;
- int i, j, r;
-
- dn = ldb_dn_new(module, module->ldb, LTDB_SUBCLASSES);
- if (dn == NULL) goto failed;
-
- r = ltdb_search_dn1(module, dn, msg);
- if (r != LDB_SUCCESS && r != LDB_ERR_NO_SUCH_OBJECT) {
- talloc_free(dn);
- goto failed;
- }
- talloc_free(dn);
-
- for (i=0;i<msg->num_elements;i++) {
- struct ldb_message_element *el = &msg->elements[i];
- for (j=0;j<el->num_values;j++) {
- if (ldb_subclass_add(module->ldb, el->name,
- (char *)el->values[j].data) != 0) {
- goto failed;
- }
- }
- }
-
- return 0;
-failed:
- return -1;
-}
-
-
-/*
- de-register any @SUBCLASSES
-*/
-static void ltdb_subclasses_unload(struct ldb_module *module)
-{
- struct ltdb_private *ltdb = module->private_data;
- struct ldb_message *msg;
- int i;
-
- if (ltdb->cache->subclasses == NULL) {
- /* no previously loaded subclasses */
- return;
- }
-
- msg = ltdb->cache->subclasses;
- for (i=0;i<msg->num_elements;i++) {
- ldb_subclass_remove(module->ldb, msg->elements[i].name);
- }
-
- talloc_free(ltdb->cache->subclasses);
- ltdb->cache->subclasses = NULL;
-}
-
-
-/*
initialise the baseinfo record
*/
static int ltdb_baseinfo_init(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
struct ldb_message *msg;
struct ldb_message_element el;
struct ldb_val val;
@@ -285,7 +224,7 @@ failed:
*/
static void ltdb_cache_free(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
ltdb->sequence_number = 0;
talloc_free(ltdb->cache);
@@ -298,7 +237,6 @@ static void ltdb_cache_free(struct ldb_module *module)
int ltdb_cache_reload(struct ldb_module *module)
{
ltdb_attributes_unload(module);
- ltdb_subclasses_unload(module);
ltdb_cache_free(module);
return ltdb_cache_load(module);
}
@@ -308,7 +246,7 @@ int ltdb_cache_reload(struct ldb_module *module)
*/
int ltdb_cache_load(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
struct ldb_dn *baseinfo_dn = NULL;
struct ldb_dn *indexlist_dn = NULL;
uint64_t seq;
@@ -325,10 +263,8 @@ int ltdb_cache_load(struct ldb_module *module)
ltdb->cache = talloc_zero(ltdb, struct ltdb_cache);
if (ltdb->cache == NULL) goto failed;
ltdb->cache->indexlist = talloc_zero(ltdb->cache, struct ldb_message);
- ltdb->cache->subclasses = talloc_zero(ltdb->cache, struct ldb_message);
ltdb->cache->attributes = talloc_zero(ltdb->cache, struct ldb_message);
if (ltdb->cache->indexlist == NULL ||
- ltdb->cache->subclasses == NULL ||
ltdb->cache->attributes == NULL) {
goto failed;
}
@@ -369,16 +305,12 @@ int ltdb_cache_load(struct ldb_module *module)
memset(&ltdb->cache->last_attribute, 0, sizeof(ltdb->cache->last_attribute));
ltdb_attributes_unload(module);
- ltdb_subclasses_unload(module);
talloc_free(ltdb->cache->indexlist);
- talloc_free(ltdb->cache->subclasses);
ltdb->cache->indexlist = talloc_zero(ltdb->cache, struct ldb_message);
- ltdb->cache->subclasses = talloc_zero(ltdb->cache, struct ldb_message);
ltdb->cache->attributes = talloc_zero(ltdb->cache, struct ldb_message);
if (ltdb->cache->indexlist == NULL ||
- ltdb->cache->subclasses == NULL ||
ltdb->cache->attributes == NULL) {
goto failed;
}
@@ -394,9 +326,6 @@ int ltdb_cache_load(struct ldb_module *module)
if (ltdb_attributes_load(module) == -1) {
goto failed;
}
- if (ltdb_subclasses_load(module) == -1) {
- goto failed;
- }
done:
talloc_free(baseinfo);
@@ -417,7 +346,7 @@ failed:
*/
int ltdb_increase_sequence_number(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
struct ldb_message *msg;
struct ldb_message_element el[2];
struct ldb_val val;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 1fe697f277..cf9380f8c0 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -45,7 +45,7 @@ static int ldb_list_find(const void *needle,
const void *base, size_t nmemb, size_t size,
comparison_fn_t comp_fn)
{
- const char *base_p = base;
+ const char *base_p = (const char *)base;
size_t min_i, max_i, test_i;
if (nmemb == 0) {
@@ -258,67 +258,6 @@ static int ltdb_index_dn_simple(struct ldb_module *module,
static int list_union(struct ldb_context *, struct dn_list *, const struct dn_list *);
/*
- return a list of dn's that might match a simple indexed search on
- the special objectclass attribute
- */
-static int ltdb_index_dn_objectclass(struct ldb_module *module,
- const struct ldb_parse_tree *tree,
- const struct ldb_message *index_list,
- struct dn_list *list)
-{
- struct ldb_context *ldb = module->ldb;
- unsigned int i;
- int ret;
- const char *target = (const char *)tree->u.equality.value.data;
- const char **subclasses;
-
- list->count = 0;
- list->dn = NULL;
-
- ret = ltdb_index_dn_simple(module, tree, index_list, list);
-
- subclasses = ldb_subclass_list(module->ldb, target);
-
- if (subclasses == NULL) {
- return ret;
- }
-
- for (i=0;subclasses[i];i++) {
- struct ldb_parse_tree tree2;
- struct dn_list *list2;
- tree2.operation = LDB_OP_EQUALITY;
- tree2.u.equality.attr = LTDB_OBJECTCLASS;
- if (!tree2.u.equality.attr) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- tree2.u.equality.value.data =
- (uint8_t *)talloc_strdup(list, subclasses[i]);
- if (tree2.u.equality.value.data == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- tree2.u.equality.value.length = strlen(subclasses[i]);
- list2 = talloc(list, struct dn_list);
- if (list2 == NULL) {
- talloc_free(tree2.u.equality.value.data);
- return LDB_ERR_OPERATIONS_ERROR;
- }
- if (ltdb_index_dn_objectclass(module, &tree2,
- index_list, list2) == LDB_SUCCESS) {
- if (list->count == 0) {
- *list = *list2;
- ret = LDB_SUCCESS;
- } else {
- list_union(ldb, list, list2);
- talloc_free(list2);
- }
- }
- talloc_free(tree2.u.equality.value.data);
- }
-
- return ret;
-}
-
-/*
return a list of dn's that might match a leaf indexed search
*/
static int ltdb_index_dn_leaf(struct ldb_module *module,
@@ -326,9 +265,6 @@ static int ltdb_index_dn_leaf(struct ldb_module *module,
const struct ldb_message *index_list,
struct dn_list *list)
{
- if (ldb_attr_cmp(tree->u.equality.attr, LTDB_OBJECTCLASS) == 0) {
- return ltdb_index_dn_objectclass(module, tree, index_list, list);
- }
if (ldb_attr_dn(tree->u.equality.attr) == 0) {
list->dn = talloc_array(list, char *, 1);
if (list->dn == NULL) {
@@ -1014,7 +950,7 @@ static int ltdb_index_add1(struct ldb_module *module, const char *dn,
static int ltdb_index_add0(struct ldb_module *module, const char *dn,
struct ldb_message_element *elements, int num_el)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
int ret;
unsigned int i, j;
@@ -1138,7 +1074,7 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn,
*/
int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
int ret;
const char *dn;
unsigned int i, j;
@@ -1180,7 +1116,7 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
*/
int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
struct ldb_message_element el;
struct ldb_val val;
struct ldb_dn *pdn;
@@ -1244,7 +1180,7 @@ static int delete_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, vo
*/
static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state)
{
- struct ldb_module *module = state;
+ struct ldb_module *module = (struct ldb_module *)state;
struct ldb_message *msg;
const char *dn = NULL;
int ret;
@@ -1309,7 +1245,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
*/
int ltdb_reindex(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
int ret;
if (ltdb_cache_reload(module) != 0) {
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 013b341d42..a195a39391 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -210,7 +210,7 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module,
*/
int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
int ret;
TDB_DATA tdb_key, tdb_data;
@@ -252,7 +252,7 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
*/
static int ltdb_lock_read(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
return tdb_lockall_read(ltdb->tdb);
}
@@ -261,7 +261,7 @@ static int ltdb_lock_read(struct ldb_module *module)
*/
static int ltdb_unlock_read(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
return tdb_unlockall_read(ltdb->tdb);
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 324a8e3881..3461f98d5f 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -145,7 +145,7 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn)
goto failed;
}
- key_str = talloc_append_string(ldb, key_str, dn_folded);
+ key_str = talloc_strdup_append_buffer(key_str, dn_folded);
if (!key_str) {
goto failed;
}
@@ -856,16 +856,38 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
goto done;
}
- ret = ltdb_add_internal(module, msg);
- if (ret != LDB_SUCCESS) {
- goto done;
- }
+ if (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) == 0) {
+ /* The rename operation is apparently only changing case -
+ the DNs are the same. Delete the old DN before adding
+ the new one to avoid a TDB_ERR_EXISTS error.
- tret = ltdb_delete_internal(module, req->op.rename.olddn);
- if (tret != LDB_SUCCESS) {
- ltdb_delete_internal(module, req->op.rename.newdn);
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
+ The only drawback to this is that if the delete
+ succeeds but the add fails, we rely on the
+ transaction to roll this all back. */
+ ret = ltdb_delete_internal(module, req->op.rename.olddn);
+ if (ret != LDB_SUCCESS) {
+ goto done;
+ }
+
+ ret = ltdb_add_internal(module, msg);
+ if (ret != LDB_SUCCESS) {
+ goto done;
+ }
+ } else {
+ /* The rename operation is changing DNs. Try to add the new
+ DN first to avoid clobbering another DN not related to
+ this rename operation. */
+ ret = ltdb_add_internal(module, msg);
+ if (ret != LDB_SUCCESS) {
+ goto done;
+ }
+
+ tret = ltdb_delete_internal(module, req->op.rename.olddn);
+ if (tret != LDB_SUCCESS) {
+ ltdb_delete_internal(module, req->op.rename.newdn);
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
+ }
}
if (ltdb_ac->callback) {
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
index 956f18688b..d4a8ff2fb1 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -1,11 +1,4 @@
-
-#ifdef _SAMBA_BUILD_
-#include "system/filesys.h"
-#endif
-
-#if (_SAMBA_BUILD_ >= 4)
-#include "lib/tdb/include/tdb.h"
-#elif defined(_SAMBA_BUILD_)
+#if (_SAMBA_BUILD_ == 3)
#include "tdb/include/tdb.h"
#else
#include "tdb.h"
@@ -28,7 +21,6 @@ struct ltdb_private {
struct ltdb_cache {
struct ldb_message *indexlist;
struct ldb_message *attributes;
- struct ldb_message *subclasses;
struct {
char *name;
@@ -63,7 +55,6 @@ struct ltdb_context {
#define LTDB_IDXONE "@IDXONE"
#define LTDB_BASEINFO "@BASEINFO"
#define LTDB_ATTRIBUTES "@ATTRIBUTES"
-#define LTDB_SUBCLASSES "@SUBCLASSES"
/* special attribute types */
#define LTDB_SEQUENCE_NUMBER "sequenceNumber"
diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c
index 3e0941357e..749858b49b 100644
--- a/source4/lib/ldb/modules/paged_searches.c
+++ b/source4/lib/ldb/modules/paged_searches.c
@@ -90,7 +90,10 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
ac->up_context = context;
ac->up_callback = callback;
- ac->pending = False;
+ ac->pending = false;
+
+
+
ac->saved_referrals = NULL;
ac->num_referrals = 0;
@@ -110,7 +113,7 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac)
rep_control = talloc_get_type(ares->controls[0]->data, struct ldb_paged_control);
if (rep_control->cookie_len == 0) {
/* we are done */
- ac->pending = False;
+ ac->pending = false;
return LDB_SUCCESS;
}
@@ -135,7 +138,7 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac)
rep_control->cookie_len);
req_control->cookie_len = rep_control->cookie_len;
- ac->pending = True;
+ ac->pending = true;
return LDB_SUCCESS;
}
@@ -395,7 +398,7 @@ static int check_supported_paged(struct ldb_context *ldb, void *context,
if (ldb_msg_check_string_attribute(ares->message,
"supportedControl",
LDB_CONTROL_PAGED_RESULTS_OID)) {
- data->paged_supported = True;
+ data->paged_supported = true;
}
}
return LDB_SUCCESS;
@@ -415,7 +418,7 @@ static int ps_init(struct ldb_module *module)
return LDB_ERR_OTHER;
}
module->private_data = data;
- data->paged_supported = False;
+ data->paged_supported = false;
req = talloc(module, struct ldb_request);
if (req == NULL) {
diff --git a/source4/lib/ldb/setup.py b/source4/lib/ldb/setup.py
new file mode 100755
index 0000000000..e5fcddf0db
--- /dev/null
+++ b/source4/lib/ldb/setup.py
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+from distutils.core import setup
+from distutils.extension import Extension
+setup(name='ldb',
+ version='1.0',
+ ext_modules=[Extension('_ldb', ['swig/ldb.i'], include_dirs=['include'],
+ libraries=['ldb','ldap'])],
+ )
diff --git a/source4/lib/ldb/swig/ldb.i b/source4/lib/ldb/swig/ldb.i
index 6a0adb7bf8..cdf1d66de1 100644
--- a/source4/lib/ldb/swig/ldb.i
+++ b/source4/lib/ldb/swig/ldb.i
@@ -36,9 +36,9 @@ typedef long long int64_t;
/* Include headers */
-#include "lib/replace/replace.h"
-#include "lib/talloc/talloc.h"
-#include "lib/ldb/include/ldb.h"
+#include <stdbool.h>
+#include "talloc.h"
+#include "ldb.h"
%}
@@ -234,6 +234,8 @@ int ldb_msg_sanity_check(struct ldb_context *ldb, const struct ldb_message *msg)
/* DN operations */
-struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn);
+/* struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); */
-char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *dn);
+/* char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *dn); */
+
+%rename(ldb_context) Ldb;
diff --git a/source4/lib/ldb/tests/schema-tests/schema.ldif b/source4/lib/ldb/tests/schema-tests/schema.ldif
index 515408144a..4ab1932839 100644
--- a/source4/lib/ldb/tests/schema-tests/schema.ldif
+++ b/source4/lib/ldb/tests/schema-tests/schema.ldif
@@ -26,18 +26,6 @@ lmPwdHistory: HIDDEN
createTimestamp: HIDDEN
modifyTimestamp: HIDDEN
-dn: @SUBCLASSES
-top: domain
-top: person
-top: group
-domain: domainDNS
-domain: builtinDomain
-person: organizationalPerson
-organizationalPerson: user
-user: computer
-template: userTemplate
-template: groupTemplate
-
dn: @MODULES
@LIST: timestamps,schema
diff --git a/source4/lib/ldb/tests/test-tdb-features.sh b/source4/lib/ldb/tests/test-tdb-features.sh
index 09a46d833e..fc0959c54a 100644
--- a/source4/lib/ldb/tests/test-tdb-features.sh
+++ b/source4/lib/ldb/tests/test-tdb-features.sh
@@ -83,16 +83,6 @@ echo "Testing class search"
checkcount 0 '(objectClass=otherclass)'
checkcount 1 '(objectClass=testclass)'
-echo "Adding subclass"
-cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
-dn: @SUBCLASSES
-changetype: add
-add: otherclass
-otherclass: testclass
-EOF
-checkcount 1 '(objectClass=otherclass)'
-checkcount 1 '(objectClass=testclass)'
-
echo "Adding index"
cat <<EOF | $VALGRIND bin/ldbadd || exit 1
dn: @INDEXLIST
diff --git a/source4/lib/ldb/tools/ad2oLschema.c b/source4/lib/ldb/tools/ad2oLschema.c
index 761339b96f..5fcf752578 100644
--- a/source4/lib/ldb/tools/ad2oLschema.c
+++ b/source4/lib/ldb/tools/ad2oLschema.c
@@ -36,6 +36,7 @@
#include "system/locale.h"
#include "tools/cmdline.h"
#include "tools/convert.h"
+#include "param/param.h"
struct schema_conv {
int count;
@@ -354,7 +355,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
const char *description = ldb_msg_find_attr_as_string(msg, "description", NULL);
const char *oid = ldb_msg_find_attr_as_string(msg, "attributeID", NULL);
const char *syntax = ldb_msg_find_attr_as_string(msg, "attributeSyntax", NULL);
- BOOL single_value = ldb_msg_find_attr_as_bool(msg, "isSingleValued", False);
+ bool single_value = ldb_msg_find_attr_as_bool(msg, "isSingleValued", false);
const struct syntax_map *map = find_syntax_map_by_ad_oid(syntax);
char *schema_entry = NULL;
int j;
@@ -676,7 +677,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
}
}
- target_str = lp_parm_string(-1, "convert", "target");
+ target_str = lp_parm_string(global_loadparm, NULL, "convert", "target");
if (!target_str || strcasecmp(target_str, "openldap") == 0) {
target = TARGET_OPENLDAP;
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c
index 08f5dc721f..2cf8212154 100644
--- a/source4/lib/ldb/tools/cmdline.c
+++ b/source4/lib/ldb/tools/cmdline.c
@@ -27,7 +27,7 @@
#if (_SAMBA_BUILD_ >= 4)
#include "includes.h"
#include "lib/cmdline/popt_common.h"
-#include "lib/ldb/samba/ldif_handlers.h"
+#include "lib/ldb-samba/ldif_handlers.h"
#include "auth/gensec/gensec.h"
#include "auth/auth.h"
#include "db_wrap.h"
diff --git a/source4/lib/ldb/tools/config.mk b/source4/lib/ldb/tools/config.mk
new file mode 100644
index 0000000000..bf6c5f963c
--- /dev/null
+++ b/source4/lib/ldb/tools/config.mk
@@ -0,0 +1,84 @@
+################################################
+# 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
+################################################
+
+################################################
+# Start BINARY ldbadd
+[BINARY::ldbadd]
+INSTALLDIR = BINDIR
+OBJ_FILES = \
+ ldbadd.o
+PRIVATE_DEPENDENCIES = \
+ LIBLDB_CMDLINE LIBCLI_RESOLVE
+MANPAGE = ../man/ldbadd.1
+# End BINARY ldbadd
+################################################
+
+################################################
+# Start BINARY ldbdel
+[BINARY::ldbdel]
+INSTALLDIR = BINDIR
+OBJ_FILES= \
+ ldbdel.o
+PRIVATE_DEPENDENCIES = \
+ LIBLDB_CMDLINE
+MANPAGE = ../man/ldbdel.1
+# End BINARY ldbdel
+################################################
+
+################################################
+# Start BINARY ldbmodify
+[BINARY::ldbmodify]
+INSTALLDIR = BINDIR
+OBJ_FILES= \
+ ldbmodify.o
+PRIVATE_DEPENDENCIES = \
+ LIBLDB_CMDLINE
+MANPAGE = ../man/ldbmodify.1
+# End BINARY ldbmodify
+################################################
+
+################################################
+# Start BINARY ldbsearch
+[BINARY::ldbsearch]
+INSTALLDIR = BINDIR
+OBJ_FILES= \
+ ldbsearch.o
+PRIVATE_DEPENDENCIES = \
+ LIBLDB_CMDLINE
+MANPAGE = ../man/ldbsearch.1
+# End BINARY ldbsearch
+################################################
+
+################################################
+# Start BINARY ldbedit
+[BINARY::ldbedit]
+INSTALLDIR = BINDIR
+OBJ_FILES= \
+ ldbedit.o
+PRIVATE_DEPENDENCIES = \
+ LIBLDB_CMDLINE
+MANPAGE = ../man/ldbedit.1
+# End BINARY ldbedit
+################################################
+
+################################################
+# Start BINARY ldbrename
+[BINARY::ldbrename]
+INSTALLDIR = BINDIR
+OBJ_FILES= \
+ ldbrename.o
+PRIVATE_DEPENDENCIES = \
+ LIBLDB_CMDLINE
+MANPAGE = ../man/ldbrename.1
+# End BINARY ldbrename
+################################################
+
+
diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h
index bcfc1f1ab4..989e5d4255 100644
--- a/source4/lib/messaging/irpc.h
+++ b/source4/lib/messaging/irpc.h
@@ -76,13 +76,12 @@ struct irpc_request {
} async;
};
+struct loadparm_context;
+
typedef void (*msg_callback_t)(struct messaging_context *msg, void *private,
uint32_t msg_type,
struct server_id server_id, DATA_BLOB *data);
-struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
- struct server_id server_id,
- struct event_context *ev);
NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server,
uint32_t msg_type, DATA_BLOB *data);
NTSTATUS messaging_register(struct messaging_context *msg, void *private,
@@ -91,9 +90,11 @@ NTSTATUS messaging_register(struct messaging_context *msg, void *private,
NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private,
msg_callback_t fn, uint32_t *msg_type);
struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
+ const char *dir,
struct server_id server_id,
struct event_context *ev);
struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx,
+ const char *dir,
struct event_context *ev);
NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id server,
uint32_t msg_type, void *ptr);
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index c4c0d0e059..36cf9aa609 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -34,6 +34,7 @@
#include "lib/util/util_tdb.h"
#include "lib/util/util_tdb.h"
#include "cluster/cluster.h"
+#include "param/param.h"
/* change the message version with any incompatible changes in the protocol */
#define MESSAGING_VERSION 1
@@ -136,7 +137,8 @@ static void messaging_dispatch(struct messaging_context *msg, struct messaging_r
/* temporary IDs use an idtree, the rest use a array of pointers */
if (rec->header->msg_type >= MSG_TMP_BASE) {
- d = idr_find(msg->dispatch_tree, rec->header->msg_type);
+ d = (struct dispatch_fn *)idr_find(msg->dispatch_tree,
+ rec->header->msg_type);
} else if (rec->header->msg_type < msg->num_types) {
d = msg->dispatch[rec->header->msg_type];
} else {
@@ -416,7 +418,8 @@ void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void
struct dispatch_fn *d, *next;
if (msg_type >= msg->num_types) {
- d = idr_find(msg->dispatch_tree, msg_type);
+ d = (struct dispatch_fn *)idr_find(msg->dispatch_tree,
+ msg_type);
if (!d) return;
idr_remove(msg->dispatch_tree, msg_type);
talloc_free(d);
@@ -504,7 +507,7 @@ NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id serv
{
DATA_BLOB blob;
- blob.data = (void *)&ptr;
+ blob.data = (uint8_t *)&ptr;
blob.length = sizeof(void *);
return messaging_send(msg, server, msg_type, &blob);
@@ -527,13 +530,13 @@ static int messaging_destructor(struct messaging_context *msg)
create the listening socket and setup the dispatcher
*/
struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
+ const char *dir,
struct server_id server_id,
struct event_context *ev)
{
struct messaging_context *msg;
NTSTATUS status;
struct socket_address *path;
- char *dir;
msg = talloc_zero(mem_ctx, struct messaging_context);
if (msg == NULL) {
@@ -552,11 +555,9 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
}
/* create the messaging directory if needed */
- dir = smbd_tmp_path(msg, "messaging");
mkdir(dir, 0700);
- talloc_free(dir);
- msg->base_path = smbd_tmp_path(msg, "messaging");
+ msg->base_path = talloc_reference(msg, dir);
msg->path = messaging_path(msg, server_id);
msg->server_id = server_id;
msg->idr = idr_init(msg);
@@ -607,12 +608,13 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
A hack, for the short term until we get 'client only' messaging in place
*/
struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx,
+ const char *dir,
struct event_context *ev)
{
struct server_id id;
ZERO_STRUCT(id);
id.id = random() % 0x10000000;
- return messaging_init(mem_ctx, id, ev);
+ return messaging_init(mem_ctx, dir, id, ev);
}
/*
a list of registered irpc server functions
@@ -665,7 +667,7 @@ static void irpc_handler_reply(struct messaging_context *msg_ctx, struct irpc_me
{
struct irpc_request *irpc;
- irpc = idr_find(msg_ctx->idr, m->header.callid);
+ irpc = (struct irpc_request *)idr_find(msg_ctx->idr, m->header.callid);
if (irpc == NULL) return;
/* parse the reply data */
diff --git a/source4/lib/policy/lex.c b/source4/lib/policy/lex.c
index d599c92915..fd4c102142 100644
--- a/source4/lib/policy/lex.c
+++ b/source4/lib/policy/lex.c
@@ -909,7 +909,7 @@ YY_RULE_SETUP
case 13:
YY_RULE_SETUP
#line 61 "lex.l"
-{ return MACHINE; }
+{ return CLASS_MACHINE; }
YY_BREAK
case 14:
YY_RULE_SETUP
@@ -964,7 +964,7 @@ YY_RULE_SETUP
case 24:
YY_RULE_SETUP
#line 72 "lex.l"
-{ return USER; }
+{ return CLASS_USER; }
YY_BREAK
case 25:
YY_RULE_SETUP
diff --git a/source4/lib/policy/lex.l b/source4/lib/policy/lex.l
index 1157bca2f7..199cd228c0 100644
--- a/source4/lib/policy/lex.l
+++ b/source4/lib/policy/lex.l
@@ -58,7 +58,7 @@ END { return END; }
EXPLAIN { return EXPLAIN; }
ITEMLIST { return ITEMLIST; }
KEYNAME { return KEYNAME; }
-MACHINE { return MACHINE; }
+MACHINE { return CLASS_MACHINE; }
MIN { return MINIMUM; }
MAX { return MAXIMUM; }
NAME { return NAME; }
@@ -69,7 +69,7 @@ REQUIRED { return REQUIRED; }
SPIN { return SPIN; }
SUPPORTED { return SUPPORTED; }
TEXT { return TEXT; }
-USER { return USER; }
+USER { return CLASS_USER; }
VALUE { return VALUE; }
VALUENAME { return VALUENAME; }
VALUEON { return VALUEON; }
diff --git a/source4/lib/policy/parse_adm.c b/source4/lib/policy/parse_adm.c
index 91cda1b262..c68e2db814 100644
--- a/source4/lib/policy/parse_adm.c
+++ b/source4/lib/policy/parse_adm.c
@@ -68,8 +68,8 @@
enum yytokentype {
CATEGORY = 258,
CLASS = 259,
- USER = 260,
- MACHINE = 261,
+ CLASS_USER = 260,
+ CLASS_MACHINE = 261,
POLICY = 262,
KEYNAME = 263,
EXPLAIN = 264,
@@ -106,8 +106,8 @@
/* Tokens. */
#define CATEGORY 258
#define CLASS 259
-#define USER 260
-#define MACHINE 261
+#define CLASS_USER 260
+#define CLASS_MACHINE 261
#define POLICY 262
#define KEYNAME 263
#define EXPLAIN 264
@@ -520,19 +520,19 @@ static const yytype_uint8 yyrline[] =
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
- "$end", "error", "$undefined", "CATEGORY", "CLASS", "USER", "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
+ "$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
diff --git a/source4/lib/policy/parse_adm.h b/source4/lib/policy/parse_adm.h
index ba134db19d..372e4b9680 100644
--- a/source4/lib/policy/parse_adm.h
+++ b/source4/lib/policy/parse_adm.h
@@ -41,8 +41,8 @@
enum yytokentype {
CATEGORY = 258,
CLASS = 259,
- USER = 260,
- MACHINE = 261,
+ CLASS_USER = 260,
+ CLASS_MACHINE = 261,
POLICY = 262,
KEYNAME = 263,
EXPLAIN = 264,
@@ -79,8 +79,8 @@
/* Tokens. */
#define CATEGORY 258
#define CLASS 259
-#define USER 260
-#define MACHINE 261
+#define CLASS_USER 260
+#define CLASS_MACHINE 261
#define POLICY 262
#define KEYNAME 263
#define EXPLAIN 264
diff --git a/source4/lib/policy/parse_adm.y b/source4/lib/policy/parse_adm.y
index 450625f58a..1dc21cf1d3 100644
--- a/source4/lib/policy/parse_adm.y
+++ b/source4/lib/policy/parse_adm.y
@@ -37,8 +37,8 @@ extern int yylex (void);
%token CATEGORY
%token CLASS
-%token USER
-%token MACHINE
+%token CLASS_USER
+%token CLASS_MACHINE
%token POLICY
%token KEYNAME
%token EXPLAIN
@@ -73,7 +73,7 @@ admfile: classes strings;
classes: /* empty */ | class classes;
class: CLASS classvalue categories;
-classvalue: USER|MACHINE;
+classvalue: CLASS_USER|CLASS_MACHINE;
categories: /* empty */ | category categories;
diff --git a/source4/lib/registry/dir.c b/source4/lib/registry/dir.c
index 146c5197fd..532770bcaf 100644
--- a/source4/lib/registry/dir.c
+++ b/source4/lib/registry/dir.c
@@ -1,18 +1,18 @@
-/*
+/*
Unix SMB/CIFS implementation.
Registry interface
- Copyright (C) Jelmer Vernooij 2004-2007.
-
+ Copyright (C) Jelmer Vernooij 2004-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/>.
*/
@@ -29,11 +29,11 @@ struct dir_key {
static struct hive_operations reg_backend_dir;
-static WERROR reg_dir_add_key(TALLOC_CTX *mem_ctx,
- const struct hive_key *parent,
- const char *name, const char *classname,
- struct security_descriptor *desc,
- struct hive_key **result)
+static WERROR reg_dir_add_key(TALLOC_CTX *mem_ctx,
+ const struct hive_key *parent,
+ const char *name, const char *classname,
+ struct security_descriptor *desc,
+ struct hive_key **result)
{
struct dir_key *dk = talloc_get_type(parent, struct dir_key);
char *path;
@@ -61,8 +61,8 @@ static WERROR reg_dir_del_key(const struct hive_key *k, const char *name)
char *child = talloc_asprintf(NULL, "%s/%s", dk->path, name);
WERROR ret;
- if (rmdir(child) == 0)
- ret = WERR_OK;
+ if (rmdir(child) == 0)
+ ret = WERR_OK;
else if (errno == ENOENT)
ret = WERR_NOT_FOUND;
else
@@ -73,25 +73,26 @@ static WERROR reg_dir_del_key(const struct hive_key *k, const char *name)
return ret;
}
-static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx,
- const struct hive_key *parent,
- const char *name, struct hive_key **subkey)
+static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx,
+ const struct hive_key *parent,
+ const char *name, struct hive_key **subkey)
{
DIR *d;
char *fullpath;
const struct dir_key *p = talloc_get_type(parent, struct dir_key);
struct dir_key *ret;
-
+
if (name == NULL) {
DEBUG(0, ("NULL pointer passed as directory name!"));
return WERR_INVALID_PARAM;
}
-
+
fullpath = talloc_asprintf(mem_ctx, "%s/%s", p->path, name);
-
+
d = opendir(fullpath);
if (d == NULL) {
- DEBUG(3,("Unable to open '%s': %s\n", fullpath, strerror(errno)));
+ DEBUG(3,("Unable to open '%s': %s\n", fullpath,
+ strerror(errno)));
return WERR_BADFILE;
}
closedir(d);
@@ -102,11 +103,11 @@ static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx,
- const struct hive_key *k, uint32_t idx,
- const char **name,
- const char **classname,
- NTTIME *last_mod_time)
+static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx,
+ const struct hive_key *k, uint32_t idx,
+ const char **name,
+ const char **classname,
+ NTTIME *last_mod_time)
{
struct dirent *e;
const struct dir_key *dk = talloc_get_type(k, struct dir_key);
@@ -115,14 +116,14 @@ static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx,
d = opendir(dk->path);
- if (d == NULL)
+ if (d == NULL)
return WERR_INVALID_PARAM;
-
+
while((e = readdir(d))) {
if(!ISDOT(e->d_name) && !ISDOTDOT(e->d_name)) {
struct stat stbuf;
char *thispath;
-
+
/* Check if file is a directory */
asprintf(&thispath, "%s/%s", dk->path, e->d_name);
stat(thispath, &stbuf);
@@ -153,12 +154,12 @@ static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx,
return WERR_NO_MORE_ITEMS;
}
-WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
- const char *location, struct hive_key **key)
+WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
+ const char *location, struct hive_key **key)
{
struct dir_key *dk;
- if (location == NULL)
+ if (location == NULL)
return WERR_INVALID_PARAM;
dk = talloc(parent_ctx, struct dir_key);
@@ -168,8 +169,8 @@ WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
return WERR_OK;
}
-WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
- const char *location, struct hive_key **key)
+WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
+ const char *location, struct hive_key **key)
{
if (mkdir(location, 0700) != 0) {
*key = NULL;
@@ -179,11 +180,11 @@ WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
return reg_open_directory(parent_ctx, location, key);
}
-static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key,
- const char **classname,
- uint32_t *num_subkeys,
- uint32_t *num_values,
- NTTIME *lastmod)
+static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key,
+ const char **classname,
+ uint32_t *num_subkeys,
+ uint32_t *num_values,
+ NTTIME *lastmod)
{
DIR *d;
const struct dir_key *dk = talloc_get_type(key, struct dir_key);
@@ -196,7 +197,7 @@ static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key,
*classname = NULL;
d = opendir(dk->path);
- if (d == NULL)
+ if (d == NULL)
return WERR_INVALID_PARAM;
if (num_subkeys != NULL)
@@ -207,10 +208,12 @@ static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key,
while((e = readdir(d))) {
if(!ISDOT(e->d_name) && !ISDOTDOT(e->d_name)) {
- char *path = talloc_asprintf(ctx, "%s/%s", dk->path, e->d_name);
+ char *path = talloc_asprintf(ctx, "%s/%s",
+ dk->path, e->d_name);
if (stat(path, &st) < 0) {
- DEBUG(0, ("Error statting %s: %s\n", path, strerror(errno)));
+ DEBUG(0, ("Error statting %s: %s\n", path,
+ strerror(errno)));
continue;
}
@@ -231,8 +234,8 @@ static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key,
return WERR_OK;
}
-static WERROR reg_dir_set_value (struct hive_key *key, const char *name,
- uint32_t type, const DATA_BLOB data)
+static WERROR reg_dir_set_value(struct hive_key *key, const char *name,
+ uint32_t type, const DATA_BLOB data)
{
const struct dir_key *dk = talloc_get_type(key, struct dir_key);
char *path = talloc_asprintf(dk, "%s/%s", dk->path, name);
@@ -245,9 +248,9 @@ static WERROR reg_dir_set_value (struct hive_key *key, const char *name,
return WERR_OK;
}
-static WERROR reg_dir_get_value (TALLOC_CTX *mem_ctx,
- struct hive_key *key, const char *name,
- uint32_t *type, DATA_BLOB *data)
+static WERROR reg_dir_get_value(TALLOC_CTX *mem_ctx,
+ struct hive_key *key, const char *name,
+ uint32_t *type, DATA_BLOB *data)
{
const struct dir_key *dk = talloc_get_type(key, struct dir_key);
char *path = talloc_asprintf(mem_ctx, "%s/%s", dk->path, name);
@@ -256,7 +259,7 @@ static WERROR reg_dir_get_value (TALLOC_CTX *mem_ctx,
contents = file_load(path, &size, mem_ctx);
talloc_free(path);
- if (contents == NULL)
+ if (contents == NULL)
return WERR_NOT_FOUND;
if (type != NULL)
@@ -267,11 +270,11 @@ static WERROR reg_dir_get_value (TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-
-static WERROR reg_dir_enum_value (TALLOC_CTX *mem_ctx,
- const struct hive_key *key, int idx,
- const char **name,
- uint32_t *type, DATA_BLOB *data)
+
+static WERROR reg_dir_enum_value(TALLOC_CTX *mem_ctx,
+ const struct hive_key *key, int idx,
+ const char **name,
+ uint32_t *type, DATA_BLOB *data)
{
const struct dir_key *dk = talloc_get_type(key, struct dir_key);
DIR *d;
@@ -280,19 +283,22 @@ static WERROR reg_dir_enum_value (TALLOC_CTX *mem_ctx,
d = opendir(dk->path);
if (d == NULL) {
- DEBUG(3,("Unable to open '%s': %s\n", dk->path, strerror(errno)));
+ DEBUG(3,("Unable to open '%s': %s\n", dk->path,
+ strerror(errno)));
return WERR_BADFILE;
}
i = 0;
while((e = readdir(d))) {
- if (ISDOT(e->d_name) || ISDOTDOT(e->d_name))
+ if (ISDOT(e->d_name) || ISDOTDOT(e->d_name))
continue;
if (i == idx) {
if (name != NULL)
*name = talloc_strdup(mem_ctx, e->d_name);
- W_ERROR_NOT_OK_RETURN(reg_dir_get_value(mem_ctx, key, *name, type, data));
+ W_ERROR_NOT_OK_RETURN(reg_dir_get_value(mem_ctx, key,
+ *name, type,
+ data));
return WERR_OK;
}
@@ -315,7 +321,7 @@ static WERROR reg_dir_del_value (struct hive_key *key, const char *name)
return WERR_GENERAL_FAILURE;
}
talloc_free(path);
-
+
return WERR_OK;
}
diff --git a/source4/lib/registry/hive.c b/source4/lib/registry/hive.c
index 97ce883e66..16534aac9c 100644
--- a/source4/lib/registry/hive.c
+++ b/source4/lib/registry/hive.c
@@ -1,19 +1,19 @@
-/*
+/*
Unix SMB/CIFS implementation.
Registry hive interface
- Copyright (C) Jelmer Vernooij 2003-2007.
-
+ Copyright (C) Jelmer Vernooij 2003-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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,10 +24,10 @@
#include "system/filesys.h"
/** Open a registry file/host/etc */
-_PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials,
- struct hive_key **root)
+_PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
+ struct auth_session_info *session_info,
+ struct cli_credentials *credentials,
+ struct hive_key **root)
{
int fd, num;
char peek[20];
@@ -54,28 +54,33 @@ _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
return reg_open_regf_file(parent_ctx, location, root);
} else if (!strncmp(peek, "TDB file", 8)) {
close(fd);
- return reg_open_ldb_file(parent_ctx, location, session_info, credentials, root);
+ return reg_open_ldb_file(parent_ctx, location, session_info,
+ credentials, root);
}
return WERR_BADFILE;
}
-_PUBLIC_ WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
- const char **classname, uint32_t *num_subkeys,
- uint32_t *num_values,
- NTTIME *last_change_time)
+_PUBLIC_ WERROR hive_key_get_info(TALLOC_CTX *mem_ctx,
+ const struct hive_key *key,
+ const char **classname, uint32_t *num_subkeys,
+ uint32_t *num_values,
+ NTTIME *last_change_time)
{
- return key->ops->get_key_info(mem_ctx, key, classname, num_subkeys,
- num_values, last_change_time);
+ return key->ops->get_key_info(mem_ctx, key, classname, num_subkeys,
+ num_values, last_change_time);
}
-_PUBLIC_ WERROR hive_key_add_name(TALLOC_CTX *ctx, const struct hive_key *parent_key,
- const char *name, const char *classname, struct security_descriptor *desc,
- struct hive_key **key)
+_PUBLIC_ WERROR hive_key_add_name(TALLOC_CTX *ctx,
+ const struct hive_key *parent_key,
+ const char *name, const char *classname,
+ struct security_descriptor *desc,
+ struct hive_key **key)
{
SMB_ASSERT(strchr(name, '\\') == NULL);
- return parent_key->ops->add_key(ctx, parent_key, name, classname, desc, key);
+ return parent_key->ops->add_key(ctx, parent_key, name, classname,
+ desc, key);
}
_PUBLIC_ WERROR hive_key_del(const struct hive_key *key, const char *name)
@@ -84,20 +89,21 @@ _PUBLIC_ WERROR hive_key_del(const struct hive_key *key, const char *name)
}
_PUBLIC_ WERROR hive_get_key_by_name(TALLOC_CTX *mem_ctx,
- const struct hive_key *key, const char *name,
- struct hive_key **subkey)
+ const struct hive_key *key,
+ const char *name,
+ struct hive_key **subkey)
{
return key->ops->get_key_by_name(mem_ctx, key, name, subkey);
}
WERROR hive_enum_key(TALLOC_CTX *mem_ctx,
- const struct hive_key *key, uint32_t idx,
- const char **name,
- const char **classname,
- NTTIME *last_mod_time)
+ const struct hive_key *key, uint32_t idx,
+ const char **name,
+ const char **classname,
+ NTTIME *last_mod_time)
{
- return key->ops->enum_key(mem_ctx, key, idx, name, classname,
- last_mod_time);
+ return key->ops->enum_key(mem_ctx, key, idx, name, classname,
+ last_mod_time);
}
WERROR hive_set_value(struct hive_key *key, const char *name, uint32_t type,
@@ -109,9 +115,9 @@ WERROR hive_set_value(struct hive_key *key, const char *name, uint32_t type,
return key->ops->set_value(key, name, type, data);
}
-WERROR hive_get_value (TALLOC_CTX *mem_ctx,
- struct hive_key *key, const char *name,
- uint32_t *type, DATA_BLOB *data)
+WERROR hive_get_value(TALLOC_CTX *mem_ctx,
+ struct hive_key *key, const char *name,
+ uint32_t *type, DATA_BLOB *data)
{
if (key->ops->get_value_by_name == NULL)
return WERR_NOT_SUPPORTED;
@@ -119,9 +125,10 @@ WERROR hive_get_value (TALLOC_CTX *mem_ctx,
return key->ops->get_value_by_name(mem_ctx, key, name, type, data);
}
-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_value_by_index(TALLOC_CTX *mem_ctx,
+ struct hive_key *key, uint32_t idx,
+ const char **name,
+ uint32_t *type, DATA_BLOB *data)
{
if (key->ops->enum_value == NULL)
return WERR_NOT_SUPPORTED;
@@ -130,7 +137,7 @@ WERROR hive_get_value_by_index (TALLOC_CTX *mem_ctx,
}
-WERROR hive_del_value (struct hive_key *key, const char *name)
+WERROR hive_del_value(struct hive_key *key, const char *name)
{
if (key->ops->delete_value == NULL)
return WERR_NOT_SUPPORTED;
diff --git a/source4/lib/registry/hive.h b/source4/lib/registry/hive.h
index 36491f149b..2f783dd15d 100644
--- a/source4/lib/registry/hive.h
+++ b/source4/lib/registry/hive.h
@@ -1,18 +1,18 @@
-/*
+/*
Unix SMB/CIFS implementation.
Registry hive interface
Copyright (C) Jelmer Vernooij 2003-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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -23,15 +23,16 @@
#include <talloc.h>
#include "librpc/gen_ndr/security.h"
+#include "libcli/util/ntstatus.h"
/**
- * This file contains the hive API. This API is generally used for
- * reading a specific file that contains just one hive.
+ * This file contains the hive API. This API is generally used for
+ * reading a specific file that contains just one hive.
*
* Good examples are .DAT (NTUSER.DAT) files.
*
- * This API does not have any notification support (that
- * should be provided by the registry implementation), nor
+ * This API does not have any notification support (that
+ * should be provided by the registry implementation), nor
* does it understand what predefined keys are.
*/
@@ -40,31 +41,32 @@ struct hive_key {
};
struct hive_operations {
- const char *name;
+ const char *name;
/**
* Open a specific subkey
*/
WERROR (*enum_key) (TALLOC_CTX *mem_ctx,
- const struct hive_key *key, uint32_t idx,
- const char **name,
- const char **classname,
- NTTIME *last_mod_time);
+ const struct hive_key *key, uint32_t idx,
+ const char **name,
+ const char **classname,
+ NTTIME *last_mod_time);
/**
* Open a subkey by name
*/
WERROR (*get_key_by_name) (TALLOC_CTX *mem_ctx,
- const struct hive_key *key, const char *name,
- struct hive_key **subkey);
-
+ const struct hive_key *key, const char *name,
+ struct hive_key **subkey);
+
/**
* Add a new key.
*/
WERROR (*add_key) (TALLOC_CTX *ctx,
- const struct hive_key *parent_key, const char *name,
- const char *classname, struct security_descriptor *desc,
- struct hive_key **key);
+ const struct hive_key *parent_key, const char *name,
+ const char *classname,
+ struct security_descriptor *desc,
+ struct hive_key **key);
/**
* Remove an existing key.
*/
@@ -79,22 +81,22 @@ struct hive_operations {
* Retrieve a registry value with a specific index.
*/
WERROR (*enum_value) (TALLOC_CTX *mem_ctx,
- const struct hive_key *key, int idx,
- const char **name, uint32_t *type,
- DATA_BLOB *data);
+ const struct hive_key *key, int idx,
+ const char **name, uint32_t *type,
+ DATA_BLOB *data);
/**
* Retrieve a registry value with the specified name
*/
- WERROR (*get_value_by_name) (TALLOC_CTX *mem_ctx,
- struct hive_key *key, const char *name,
- uint32_t *type, DATA_BLOB *data);
-
+ WERROR (*get_value_by_name) (TALLOC_CTX *mem_ctx,
+ struct hive_key *key, const char *name,
+ uint32_t *type, DATA_BLOB *data);
+
/**
* Set a value on the specified registry key.
*/
- WERROR (*set_value) (struct hive_key *key, const char *name,
- uint32_t type, const DATA_BLOB data);
+ WERROR (*set_value) (struct hive_key *key, const char *name,
+ uint32_t type, const DATA_BLOB data);
/**
* Remove a value.
@@ -106,91 +108,93 @@ struct hive_operations {
/**
* Change the security descriptor on a registry key.
*
- * This should return WERR_NOT_SUPPORTED if the underlying
- * format does not have a mechanism for storing
+ * This should return WERR_NOT_SUPPORTED if the underlying
+ * format does not have a mechanism for storing
* security descriptors.
*/
- WERROR (*set_sec_desc) (struct hive_key *key,
- const struct security_descriptor *desc);
+ WERROR (*set_sec_desc) (struct hive_key *key,
+ const struct security_descriptor *desc);
/**
* Retrieve the security descriptor on a registry key.
*
- * This should return WERR_NOT_SUPPORTED if the underlying
- * format does not have a mechanism for storing
+ * This should return WERR_NOT_SUPPORTED if the underlying
+ * format does not have a mechanism for storing
* security descriptors.
*/
WERROR (*get_sec_desc) (TALLOC_CTX *ctx,
- const struct hive_key *key,
- struct security_descriptor **desc);
-
+ const struct hive_key *key,
+ struct security_descriptor **desc);
+
/**
* Retrieve general information about a key.
*/
WERROR (*get_key_info) (TALLOC_CTX *mem_ctx,
- const struct hive_key *key,
- const char **classname,
- uint32_t *num_subkeys,
- uint32_t *num_values,
- NTTIME *last_change_time);
+ const struct hive_key *key,
+ const char **classname,
+ uint32_t *num_subkeys,
+ uint32_t *num_values,
+ NTTIME *last_change_time);
};
struct cli_credentials;
struct auth_session_info;
-WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials,
- struct hive_key **root);
+WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
+ struct auth_session_info *session_info,
+ struct cli_credentials *credentials,
+ struct hive_key **root);
WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
- const char **classname, uint32_t *num_subkeys,
- uint32_t *num_values,
- NTTIME *last_change_time);
+ const char **classname, uint32_t *num_subkeys,
+ uint32_t *num_values,
+ NTTIME *last_change_time);
WERROR hive_key_add_name(TALLOC_CTX *ctx, const struct hive_key *parent_key,
- const char *name, const char *classname, struct security_descriptor *desc,
- struct hive_key **key);
+ const char *name, const char *classname,
+ struct security_descriptor *desc,
+ struct hive_key **key);
WERROR hive_key_del(const struct hive_key *key, const char *name);
WERROR hive_get_key_by_name(TALLOC_CTX *mem_ctx,
- const struct hive_key *key, const char *name,
- struct hive_key **subkey);
+ const struct hive_key *key, const char *name,
+ struct hive_key **subkey);
WERROR hive_enum_key(TALLOC_CTX *mem_ctx,
- const struct hive_key *key, uint32_t idx,
- const char **name,
- const char **classname,
- NTTIME *last_mod_time);
+ const struct hive_key *key, uint32_t idx,
+ const char **name,
+ const char **classname,
+ NTTIME *last_mod_time);
-WERROR hive_set_value (struct hive_key *key, const char *name,
- uint32_t type, const DATA_BLOB data);
+WERROR hive_set_value(struct hive_key *key, const char *name,
+ uint32_t type, const DATA_BLOB data);
-WERROR hive_get_value (TALLOC_CTX *mem_ctx,
- struct hive_key *key, const char *name,
- uint32_t *type, DATA_BLOB *data);
-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_value(TALLOC_CTX *mem_ctx,
+ struct hive_key *key, const char *name,
+ uint32_t *type, DATA_BLOB *data);
+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_del_value (struct hive_key *key, const char *name);
+WERROR hive_del_value(struct hive_key *key, const char *name);
WERROR hive_key_flush(struct hive_key *key);
/* Individual backends */
-WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
- const char *location, struct hive_key **key);
-WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
- const char *location, struct hive_key **key);
-WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials,
- struct hive_key **k);
-
-
-WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
- const char *location, struct hive_key **key);
-WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
- const char *location,
- int major_version,
- struct hive_key **key);
+WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
+ const char *location, struct hive_key **key);
+WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
+ const char *location, struct hive_key **key);
+WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
+ struct auth_session_info *session_info,
+ struct cli_credentials *credentials,
+ struct hive_key **k);
+
+
+WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
+ const char *location, struct hive_key **key);
+WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
+ const char *location,
+ int major_version,
+ struct hive_key **key);
#endif /* __REGISTRY_HIVE_H__ */
diff --git a/source4/lib/registry/interface.c b/source4/lib/registry/interface.c
index 4950e1dacd..8f60a55ae9 100644
--- a/source4/lib/registry/interface.c
+++ b/source4/lib/registry/interface.c
@@ -1,4 +1,4 @@
-/*
+/*
Unix SMB/CIFS implementation.
Transparent registry backend handling
Copyright (C) Jelmer Vernooij 2003-2007.
@@ -47,7 +47,7 @@ _PUBLIC_ const char *reg_get_predef_name(uint32_t hkey)
{
int i;
for (i = 0; reg_predefined_keys[i].name; i++) {
- if (reg_predefined_keys[i].handle == hkey)
+ if (reg_predefined_keys[i].handle == hkey)
return reg_predefined_keys[i].name;
}
@@ -55,40 +55,42 @@ _PUBLIC_ const char *reg_get_predef_name(uint32_t hkey)
}
/** Get predefined key by name. */
-_PUBLIC_ WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
- const char *name,
- struct registry_key **key)
+_PUBLIC_ WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
+ const char *name,
+ struct registry_key **key)
{
int i;
-
+
for (i = 0; reg_predefined_keys[i].name; i++) {
- if (!strcasecmp(reg_predefined_keys[i].name, name))
- return reg_get_predefined_key(ctx, reg_predefined_keys[i].handle,
- key);
+ if (!strcasecmp(reg_predefined_keys[i].name, name))
+ return reg_get_predefined_key(ctx,
+ reg_predefined_keys[i].handle,
+ key);
}
DEBUG(1, ("No predefined key with name '%s'\n", name));
-
+
return WERR_BADFILE;
}
/** Get predefined key by id. */
-_PUBLIC_ WERROR reg_get_predefined_key(const struct registry_context *ctx,
- uint32_t hkey, struct registry_key **key)
+_PUBLIC_ WERROR reg_get_predefined_key(const struct registry_context *ctx,
+ uint32_t hkey, struct registry_key **key)
{
return ctx->ops->get_predefined_key(ctx, hkey, key);
}
/**
- * Open a key
+ * Open a key
* First tries to use the open_key function from the backend
- * then falls back to get_subkey_by_name and later get_subkey_by_index
+ * then falls back to get_subkey_by_name and later get_subkey_by_index
*/
-_PUBLIC_ WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent,
- const char *name, struct registry_key **result)
+_PUBLIC_ WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent,
+ const char *name, struct registry_key **result)
{
if (parent == NULL) {
- DEBUG(0, ("Invalid parent key specified for open of '%s'\n", name));
+ DEBUG(0, ("Invalid parent key specified for open of '%s'\n",
+ name));
return WERR_INVALID_PARAM;
}
@@ -103,71 +105,71 @@ _PUBLIC_ WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent,
/**
* Get value by index
*/
-_PUBLIC_ WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- uint32_t idx,
- const char **name,
- uint32_t *type,
- DATA_BLOB *data)
+_PUBLIC_ WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ uint32_t idx, const char **name,
+ uint32_t *type, DATA_BLOB *data)
{
- if (key == NULL)
+ if (key == NULL)
return WERR_INVALID_PARAM;
if (key->context->ops->enum_value == NULL)
return WERR_NOT_SUPPORTED;
- return key->context->ops->enum_value(mem_ctx, key, idx, name, type,
- data);
+ return key->context->ops->enum_value(mem_ctx, key, idx, name,
+ type, data);
}
-/**
+/**
* Get the number of subkeys.
*/
-_PUBLIC_ WERROR reg_key_get_info(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- const char **classname,
- uint32_t *num_subkeys,
- uint32_t *num_values,
- NTTIME *last_change_time)
+_PUBLIC_ WERROR reg_key_get_info(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ const char **classname,
+ uint32_t *num_subkeys,
+ uint32_t *num_values,
+ NTTIME *last_change_time)
{
- if (key == NULL)
+ if (key == NULL)
return WERR_INVALID_PARAM;
-
+
if (key->context->ops->get_key_info == NULL)
return WERR_NOT_SUPPORTED;
return key->context->ops->get_key_info(mem_ctx,
- key, classname, num_subkeys,
- num_values, last_change_time);
+ key, classname, num_subkeys,
+ num_values, last_change_time);
}
/**
* Get subkey by index.
*/
-_PUBLIC_ WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx,
- const struct registry_key *key, int idx, const char **name,
- const char **keyclass, NTTIME *last_changed_time)
+_PUBLIC_ WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ int idx, const char **name,
+ const char **keyclass,
+ NTTIME *last_changed_time)
{
- if (key == NULL)
+ if (key == NULL)
return WERR_INVALID_PARAM;
if (key->context->ops->enum_key == NULL)
return WERR_NOT_SUPPORTED;
return key->context->ops->enum_key(mem_ctx, key, idx, name,
- keyclass, last_changed_time);
+ keyclass, last_changed_time);
}
/**
* Get value by name.
*/
-_PUBLIC_ WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- const char *name,
- uint32_t *type,
- DATA_BLOB *data)
+_PUBLIC_ WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ const char *name,
+ uint32_t *type,
+ DATA_BLOB *data)
{
- if (key == NULL)
+ if (key == NULL)
return WERR_INVALID_PARAM;
if (key->context->ops->get_value == NULL)
@@ -181,49 +183,49 @@ _PUBLIC_ WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx,
*/
_PUBLIC_ WERROR reg_key_del(struct registry_key *parent, const char *name)
{
- if (parent == NULL)
+ if (parent == NULL)
return WERR_INVALID_PARAM;
-
+
if (parent->context->ops->delete_key == NULL)
return WERR_NOT_SUPPORTED;
-
+
return parent->context->ops->delete_key(parent, name);
}
/**
* Add a key.
*/
-_PUBLIC_ WERROR reg_key_add_name(TALLOC_CTX *mem_ctx,
- struct registry_key *parent,
- const char *name, const char *key_class,
- struct security_descriptor *desc,
- struct registry_key **newkey)
+_PUBLIC_ WERROR reg_key_add_name(TALLOC_CTX *mem_ctx,
+ struct registry_key *parent,
+ const char *name, const char *key_class,
+ struct security_descriptor *desc,
+ struct registry_key **newkey)
{
- if (parent == NULL)
+ if (parent == NULL)
return WERR_INVALID_PARAM;
-
+
if (parent->context->ops->create_key == NULL) {
- DEBUG(1, ("Backend '%s' doesn't support method add_key\n",
+ DEBUG(1, ("Backend '%s' doesn't support method add_key\n",
parent->context->ops->name));
return WERR_NOT_SUPPORTED;
}
- return parent->context->ops->create_key(mem_ctx, parent, name,
- key_class, desc, newkey);
+ return parent->context->ops->create_key(mem_ctx, parent, name,
+ key_class, desc, newkey);
}
/**
* Set a value.
*/
-_PUBLIC_ WERROR reg_val_set(struct registry_key *key, const char *value,
- uint32_t type, const DATA_BLOB data)
+_PUBLIC_ WERROR reg_val_set(struct registry_key *key, const char *value,
+ uint32_t type, const DATA_BLOB data)
{
if (key == NULL)
return WERR_INVALID_PARAM;
/* A 'real' set function has preference */
if (key->context->ops->set_value == NULL) {
- DEBUG(1, ("Backend '%s' doesn't support method set_value\n",
+ DEBUG(1, ("Backend '%s' doesn't support method set_value\n",
key->context->ops->name));
return WERR_NOT_SUPPORTED;
}
@@ -234,15 +236,15 @@ _PUBLIC_ WERROR reg_val_set(struct registry_key *key, const char *value,
/**
* Get the security descriptor on a key.
*/
-_PUBLIC_ WERROR reg_get_sec_desc(TALLOC_CTX *ctx,
- const struct registry_key *key,
- struct security_descriptor **secdesc)
+_PUBLIC_ WERROR reg_get_sec_desc(TALLOC_CTX *ctx,
+ const struct registry_key *key,
+ struct security_descriptor **secdesc)
{
if (key == NULL)
return WERR_INVALID_PARAM;
/* A 'real' set function has preference */
- if (key->context->ops->get_security == NULL)
+ if (key->context->ops->get_security == NULL)
return WERR_NOT_SUPPORTED;
return key->context->ops->get_security(ctx, key, secdesc);
@@ -269,32 +271,32 @@ _PUBLIC_ WERROR reg_key_flush(struct registry_key *key)
{
if (key == NULL)
return WERR_INVALID_PARAM;
-
+
if (key->context->ops->flush_key == NULL)
return WERR_NOT_SUPPORTED;
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)
+_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_security(struct registry_key *key,
+ struct security_descriptor *security)
{
if (key == NULL)
return WERR_INVALID_PARAM;
-
+
if (key->context->ops->set_security == NULL)
return WERR_NOT_SUPPORTED;
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 8a34fa7a54..4a6ef65bc4 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -1,18 +1,18 @@
-/*
+/*
Unix SMB/CIFS implementation.
Registry interface
Copyright (C) Jelmer Vernooij 2004-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/>.
*/
@@ -23,10 +23,11 @@
#include "lib/ldb/include/ldb_errors.h"
#include "db_wrap.h"
#include "librpc/gen_ndr/winreg.h"
+#include "param/param.h"
static struct hive_operations reg_backend_ldb;
-struct ldb_key_data
+struct ldb_key_data
{
struct hive_key key;
struct ldb_context *ldb;
@@ -35,12 +36,15 @@ struct ldb_key_data
int subkey_count, value_count;
};
-static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char **name,
- uint32_t *type, DATA_BLOB *data)
+static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+ const char **name, uint32_t *type,
+ DATA_BLOB *data)
{
const struct ldb_val *val;
if (name != NULL)
- *name = talloc_strdup(mem_ctx, ldb_msg_find_attr_as_string(msg, "value", NULL));
+ *name = talloc_strdup(mem_ctx,
+ ldb_msg_find_attr_as_string(msg, "value",
+ NULL));
if (type != NULL)
*type = ldb_msg_find_attr_as_uint(msg, "type", 0);
@@ -50,8 +54,9 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, c
{
case REG_SZ:
case REG_EXPAND_SZ:
- data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16,
- val->data, val->length, (void **)&data->data);
+ data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16,
+ val->data, val->length,
+ (void **)&data->data);
break;
case REG_DWORD: {
@@ -66,9 +71,10 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, c
}
}
-static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
- TALLOC_CTX *mem_ctx, const char *name,
- uint32_t type, DATA_BLOB data)
+static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *name,
+ uint32_t type, DATA_BLOB data)
{
struct ldb_val val;
struct ldb_message *msg = talloc_zero(mem_ctx, struct ldb_message);
@@ -79,13 +85,17 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
switch (type) {
case REG_SZ:
case REG_EXPAND_SZ:
- val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8,
- (void *)data.data, data.length, (void **)&val.data);
+ val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8,
+ (void *)data.data,
+ data.length,
+ (void **)&val.data);
ldb_msg_add_value(msg, "data", &val, NULL);
break;
case REG_DWORD:
- ldb_msg_add_string(msg, "data", talloc_asprintf(mem_ctx, "0x%x", IVAL(data.data, 0)));
+ ldb_msg_add_string(msg, "data",
+ talloc_asprintf(mem_ctx, "0x%x",
+ IVAL(data.data, 0)));
break;
default:
ldb_msg_add_value(msg, "data", &data, NULL);
@@ -93,7 +103,7 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
type_s = talloc_asprintf(mem_ctx, "%u", type);
- ldb_msg_add_string(msg, "type", type_s);
+ ldb_msg_add_string(msg, "type", type_s);
return msg;
}
@@ -102,20 +112,20 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
static int reg_close_ldb_key(struct ldb_key_data *key)
{
if (key->subkeys != NULL) {
- talloc_free(key->subkeys);
+ talloc_free(key->subkeys);
key->subkeys = NULL;
}
if (key->values != NULL) {
- talloc_free(key->values);
+ talloc_free(key->values);
key->values = NULL;
}
return 0;
}
-static struct ldb_dn *reg_path_to_ldb(TALLOC_CTX *mem_ctx,
- const struct hive_key *from,
- const char *path, const char *add)
+static struct ldb_dn *reg_path_to_ldb(TALLOC_CTX *mem_ctx,
+ const struct hive_key *from,
+ const char *path, const char *add)
{
TALLOC_CTX *local_ctx;
struct ldb_dn *ret;
@@ -172,7 +182,8 @@ static WERROR cache_subkeys(struct ldb_key_data *kd)
ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, "(key=*)", NULL, &res);
if (ret != LDB_SUCCESS) {
- DEBUG(0, ("Error getting subkeys for '%s': %s\n", ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
+ DEBUG(0, ("Error getting subkeys for '%s': %s\n",
+ ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
return WERR_FOOBAR;
}
@@ -189,10 +200,12 @@ static WERROR cache_values(struct ldb_key_data *kd)
struct ldb_result *res;
int ret;
- ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, "(value=*)", NULL, &res);
+ ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL,
+ "(value=*)", NULL, &res);
if (ret != LDB_SUCCESS) {
- DEBUG(0, ("Error getting values for '%s': %s\n", ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
+ DEBUG(0, ("Error getting values for '%s': %s\n",
+ ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
return WERR_FOOBAR;
}
kd->value_count = res->count;
@@ -202,11 +215,11 @@ static WERROR cache_values(struct ldb_key_data *kd)
}
-static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
- const struct hive_key *k, uint32_t idx,
- const char **name,
- const char **classname,
- NTTIME *last_mod_time)
+static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
+ const struct hive_key *k, uint32_t idx,
+ const char **name,
+ const char **classname,
+ NTTIME *last_mod_time)
{
struct ldb_message_element *el;
struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
@@ -214,21 +227,21 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
/* Do a search if necessary */
if (kd->subkeys == NULL) {
W_ERROR_NOT_OK_RETURN(cache_subkeys(kd));
- }
+ }
- if (idx >= kd->subkey_count)
+ if (idx >= kd->subkey_count)
return WERR_NO_MORE_ITEMS;
el = ldb_msg_find_element(kd->subkeys[idx], "key");
SMB_ASSERT(el != NULL);
SMB_ASSERT(el->num_values != 0);
-
+
if (name != NULL)
*name = talloc_strdup(mem_ctx, (char *)el->values[0].data);
if (classname != NULL)
*classname = NULL; /* TODO: Store properly */
-
+
if (last_mod_time != NULL)
*last_mod_time = 0; /* TODO: we need to add this to the
ldb backend properly */
@@ -236,8 +249,9 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, const struct hive_key *k, int idx,
- const char **name, uint32_t *data_type, DATA_BLOB *data)
+static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, const struct hive_key *k,
+ int idx, const char **name,
+ uint32_t *data_type, DATA_BLOB *data)
{
struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
@@ -246,16 +260,18 @@ static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, const struct hive_key *k,
W_ERROR_NOT_OK_RETURN(cache_values(kd));
}
- if(idx >= kd->value_count) return WERR_NO_MORE_ITEMS;
+ if (idx >= kd->value_count)
+ return WERR_NO_MORE_ITEMS;
- reg_ldb_unpack_value(mem_ctx, kd->values[idx],
- name, data_type, data);
+ reg_ldb_unpack_value(mem_ctx, kd->values[idx],
+ name, data_type, data);
return WERR_OK;
}
-static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
- const char *name, uint32_t *data_type, DATA_BLOB *data)
+static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
+ const char *name, uint32_t *data_type,
+ DATA_BLOB *data)
{
struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
struct ldb_context *c = kd->ldb;
@@ -268,7 +284,8 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
talloc_free(query);
if (ret != LDB_SUCCESS) {
- DEBUG(0, ("Error getting values for '%s': %s\n", ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
+ DEBUG(0, ("Error getting values for '%s': %s\n",
+ ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
return WERR_FOOBAR;
}
@@ -280,8 +297,8 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
return WERR_OK;
}
-static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
- const char *name, struct hive_key **key)
+static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
+ const char *name, struct hive_key **key)
{
struct ldb_result *res;
struct ldb_dn *ldap_path;
@@ -295,11 +312,12 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
ret = ldb_search(c, ldap_path, LDB_SCOPE_BASE, "(key=*)", NULL, &res);
if (ret != LDB_SUCCESS) {
- DEBUG(3, ("Error opening key '%s': %s\n",
- ldb_dn_get_linearized(ldap_path), ldb_errstring(c)));
+ DEBUG(3, ("Error opening key '%s': %s\n",
+ ldb_dn_get_linearized(ldap_path), ldb_errstring(c)));
return WERR_FOOBAR;
} else if (res->count == 0) {
- DEBUG(3, ("Key '%s' not found\n", ldb_dn_get_linearized(ldap_path)));
+ DEBUG(3, ("Key '%s' not found\n",
+ ldb_dn_get_linearized(ldap_path)));
talloc_free(res);
return WERR_NOT_FOUND;
}
@@ -307,7 +325,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
newkd = talloc_zero(mem_ctx, struct ldb_key_data);
newkd->key.ops = &reg_backend_ldb;
newkd->ldb = talloc_reference(newkd, kd->ldb);
- newkd->dn = ldb_dn_copy(mem_ctx, res->msgs[0]->dn);
+ newkd->dn = ldb_dn_copy(mem_ctx, res->msgs[0]->dn);
*key = (struct hive_key *)newkd;
@@ -316,19 +334,19 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
return WERR_OK;
}
-WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials,
- struct hive_key **k)
+WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
+ struct auth_session_info *session_info,
+ struct cli_credentials *credentials,
+ struct hive_key **k)
{
struct ldb_key_data *kd;
struct ldb_context *wrap;
- if (location == NULL)
+ if (location == NULL)
return WERR_INVALID_PARAM;
- wrap = ldb_wrap_connect(parent_ctx, location, session_info,
- credentials, 0, NULL);
+ wrap = ldb_wrap_connect(parent_ctx, global_loadparm,
+ location, session_info, credentials, 0, NULL);
if (wrap == NULL) {
DEBUG(1, (__FILE__": unable to connect\n"));
@@ -348,10 +366,10 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
return WERR_OK;
}
-static WERROR ldb_add_key (TALLOC_CTX *mem_ctx, const struct hive_key *parent,
- const char *name, const char *classname,
- struct security_descriptor *sd,
- struct hive_key **newkey)
+static WERROR ldb_add_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
+ const char *name, const char *classname,
+ struct security_descriptor *sd,
+ struct hive_key **newkey)
{
const struct ldb_key_data *parentkd = (const struct ldb_key_data *)parent;
struct ldb_message *msg;
@@ -364,13 +382,14 @@ static WERROR ldb_add_key (TALLOC_CTX *mem_ctx, const struct hive_key *parent,
ldb_msg_add_string(msg, "key", talloc_strdup(mem_ctx, name));
if (classname != NULL)
- ldb_msg_add_string(msg, "classname", talloc_strdup(mem_ctx, classname));
+ ldb_msg_add_string(msg, "classname",
+ talloc_strdup(mem_ctx, classname));
ret = ldb_add(parentkd->ldb, msg);
if (ret < 0) {
DEBUG(1, ("ldb_msg_add: %s\n", ldb_errstring(parentkd->ldb)));
return WERR_FOOBAR;
- }
+ }
DEBUG(2, ("key added: %s\n", ldb_dn_get_linearized(msg->dn)));
@@ -384,7 +403,7 @@ static WERROR ldb_add_key (TALLOC_CTX *mem_ctx, const struct hive_key *parent,
return WERR_OK;
}
-static WERROR ldb_del_key (const struct hive_key *key, const char *child)
+static WERROR ldb_del_key(const struct hive_key *key, const char *child)
{
int ret;
struct ldb_key_data *parentkd = talloc_get_type(key, struct ldb_key_data);
@@ -430,9 +449,9 @@ static WERROR ldb_del_value (struct hive_key *key, const char *child)
return WERR_OK;
}
-static WERROR ldb_set_value(struct hive_key *parent,
- const char *name, uint32_t type,
- const DATA_BLOB data)
+static WERROR ldb_set_value(struct hive_key *parent,
+ const char *name, uint32_t type,
+ const DATA_BLOB data)
{
struct ldb_message *msg;
struct ldb_key_data *kd = talloc_get_type(parent, struct ldb_key_data);
@@ -453,17 +472,17 @@ static WERROR ldb_set_value(struct hive_key *parent,
return WERR_FOOBAR;
}
}
-
+
talloc_free(mem_ctx);
return WERR_OK;
}
-static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
- const struct hive_key *key,
- const char **classname,
- uint32_t *num_subkeys,
- uint32_t *num_values,
- NTTIME *last_change_time)
+static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
+ const struct hive_key *key,
+ const char **classname,
+ uint32_t *num_subkeys,
+ uint32_t *num_values,
+ NTTIME *last_change_time)
{
struct ldb_key_data *kd = talloc_get_type(key, struct ldb_key_data);
diff --git a/source4/lib/registry/local.c b/source4/lib/registry/local.c
index aefb11bde2..b54f0cf30a 100644
--- a/source4/lib/registry/local.c
+++ b/source4/lib/registry/local.c
@@ -1,4 +1,4 @@
-/*
+/*
Unix SMB/CIFS implementation.
Transparent registry backend handling
Copyright (C) Jelmer Vernooij 2003-2007.
@@ -38,7 +38,7 @@ struct registry_local {
struct mountpoint *prev, *next;
} *mountpoints;
- struct auth_session_info *session_info;
+ struct auth_session_info *session_info;
struct cli_credentials *credentials;
};
@@ -50,9 +50,9 @@ struct local_key {
struct registry_key *reg_import_hive_key(struct registry_context *ctx,
- struct hive_key *hive,
- uint32_t predefined_key,
- const char **elements)
+ struct hive_key *hive,
+ uint32_t predefined_key,
+ const char **elements)
{
struct local_key *local_key;
struct reg_key_path parent_path;
@@ -70,25 +70,26 @@ struct registry_key *reg_import_hive_key(struct registry_context *ctx,
static WERROR local_open_key(TALLOC_CTX *mem_ctx,
- struct registry_key *parent,
- const char *path,
- struct registry_key **result)
+ struct registry_key *parent,
+ const char *path,
+ struct registry_key **result)
{
char *orig = talloc_strdup(mem_ctx, path),
- *curbegin = orig,
+ *curbegin = orig,
*curend = strchr(orig, '\\');
- struct local_key *local_parent = talloc_get_type(parent, struct local_key);
+ struct local_key *local_parent = talloc_get_type(parent,
+ struct local_key);
struct hive_key *curkey = local_parent->hive_key;
WERROR error;
const char **elements = NULL;
int el;
if (local_parent->path.elements != NULL) {
- elements = talloc_array(mem_ctx, const char *,
- str_list_length(local_parent->path.elements) + 1);
+ elements = talloc_array(mem_ctx, const char *,
+ str_list_length(local_parent->path.elements) + 1);
for (el = 0; local_parent->path.elements[el] != NULL; el++) {
- elements[el] = talloc_reference(elements,
- local_parent->path.elements[el]);
+ elements[el] = talloc_reference(elements,
+ local_parent->path.elements[el]);
}
elements[el] = NULL;
} else {
@@ -103,94 +104,97 @@ static WERROR local_open_key(TALLOC_CTX *mem_ctx,
elements[el] = talloc_strdup(elements, curbegin);
el++;
elements[el] = NULL;
- error = hive_get_key_by_name(mem_ctx, curkey, curbegin, &curkey);
+ error = hive_get_key_by_name(mem_ctx, curkey,
+ curbegin, &curkey);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(2, ("Opening key %s failed: %s\n", curbegin, win_errstr(error)));
+ DEBUG(2, ("Opening key %s failed: %s\n", curbegin,
+ win_errstr(error)));
talloc_free(orig);
return error;
}
- if (curend == NULL)
+ if (curend == NULL)
break;
curbegin = curend + 1;
curend = strchr(curbegin, '\\');
}
talloc_free(orig);
- *result = reg_import_hive_key(local_parent->global.context, curkey,
- local_parent->path.predefined_key,
- talloc_steal(curkey, elements));
-
+ *result = reg_import_hive_key(local_parent->global.context, curkey,
+ local_parent->path.predefined_key,
+ talloc_steal(curkey, elements));
+
return WERR_OK;
}
-WERROR local_get_predefined_key (const struct registry_context *ctx,
- uint32_t key_id, struct registry_key **key)
-{
- struct registry_local *rctx = talloc_get_type(ctx, struct registry_local);
+WERROR local_get_predefined_key(const struct registry_context *ctx,
+ uint32_t key_id, struct registry_key **key)
+{
+ struct registry_local *rctx = talloc_get_type(ctx,
+ struct registry_local);
struct mountpoint *mp;
for (mp = rctx->mountpoints; mp != NULL; mp = mp->next) {
- if (mp->path.predefined_key == key_id &&
+ if (mp->path.predefined_key == key_id &&
mp->path.elements == NULL)
break;
}
if (mp == NULL)
return WERR_NOT_FOUND;
-
- *key = reg_import_hive_key(ctx, mp->key,
- mp->path.predefined_key,
- mp->path.elements
- );
+
+ *key = reg_import_hive_key(ctx, mp->key,
+ mp->path.predefined_key,
+ mp->path.elements);
return WERR_OK;
}
-WERROR local_enum_key(TALLOC_CTX *mem_ctx,
- const struct registry_key *key, uint32_t idx,
- const char **name,
- const char **keyclass,
- NTTIME *last_changed_time)
+static WERROR local_enum_key(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key, uint32_t idx,
+ const char **name,
+ const char **keyclass,
+ NTTIME *last_changed_time)
{
const struct local_key *local = (const struct local_key *)key;
- return hive_enum_key(mem_ctx, local->hive_key, idx, name, keyclass,
- last_changed_time);
+ return hive_enum_key(mem_ctx, local->hive_key, idx, name, keyclass,
+ last_changed_time);
}
-static WERROR local_create_key (TALLOC_CTX *mem_ctx,
- struct registry_key *parent_key,
- const char *name,
- const char *key_class,
- struct security_descriptor *security,
- struct registry_key **key)
+static WERROR local_create_key(TALLOC_CTX *mem_ctx,
+ struct registry_key *parent_key,
+ const char *name,
+ const char *key_class,
+ struct security_descriptor *security,
+ struct registry_key **key)
{
const struct local_key *local_parent;
struct hive_key *hivekey;
const char **elements;
int i;
- char *last_part;
+ const char *last_part;
last_part = strrchr(name, '\\');
if (last_part == NULL) {
last_part = name;
local_parent = (const struct local_key *)parent_key;
} else {
- W_ERROR_NOT_OK_RETURN(reg_open_key(mem_ctx, parent_key,
- talloc_strndup(mem_ctx, name, last_part-name),
- &local_parent));
+ W_ERROR_NOT_OK_RETURN(reg_open_key(mem_ctx, parent_key,
+ talloc_strndup(mem_ctx, name, last_part-name),
+ &local_parent));
last_part++;
}
- W_ERROR_NOT_OK_RETURN(hive_key_add_name(mem_ctx, local_parent->hive_key,
- last_part, key_class, security, &hivekey));
+ W_ERROR_NOT_OK_RETURN(hive_key_add_name(mem_ctx, local_parent->hive_key,
+ last_part, key_class, security,
+ &hivekey));
if (local_parent->path.elements != NULL) {
- elements = talloc_array(hivekey, const char *,
- str_list_length(local_parent->path.elements)+2);
+ elements = talloc_array(hivekey, const char *,
+ str_list_length(local_parent->path.elements)+2);
for (i = 0; local_parent->path.elements[i] != NULL; i++) {
- elements[i] = talloc_reference(elements,
- local_parent->path.elements[i]);
+ elements[i] = talloc_reference(elements,
+ local_parent->path.elements[i]);
}
} else {
elements = talloc_array(hivekey, const char *, 2);
@@ -200,75 +204,75 @@ static WERROR local_create_key (TALLOC_CTX *mem_ctx,
elements[i] = talloc_strdup(elements, name);
elements[i+1] = NULL;
- *key = reg_import_hive_key(local_parent->global.context, hivekey,
- local_parent->path.predefined_key,
- elements);
+ *key = reg_import_hive_key(local_parent->global.context, hivekey,
+ local_parent->path.predefined_key,
+ elements);
return WERR_OK;
}
-static WERROR local_set_value (struct registry_key *key, const char *name,
- uint32_t type, const DATA_BLOB data)
+static WERROR local_set_value(struct registry_key *key, const char *name,
+ uint32_t type, const DATA_BLOB data)
{
struct local_key *local = (struct local_key *)key;
return hive_set_value(local->hive_key, name, type, data);
}
-static WERROR local_get_value (TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- const char *name, uint32_t *type, DATA_BLOB *data)
+static WERROR local_get_value(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ const char *name, uint32_t *type, DATA_BLOB *data)
{
const struct local_key *local = (const struct local_key *)key;
return hive_get_value(mem_ctx, local->hive_key, name, type, data);
}
-static WERROR local_enum_value (TALLOC_CTX *mem_ctx,
- const struct registry_key *key, uint32_t idx,
- const char **name,
- uint32_t *type,
- DATA_BLOB *data)
+static WERROR local_enum_value(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key, uint32_t idx,
+ const char **name,
+ uint32_t *type,
+ DATA_BLOB *data)
{
const struct local_key *local = (const struct local_key *)key;
- return hive_get_value_by_index(mem_ctx, local->hive_key, idx,
- name, type, data);
+ return hive_get_value_by_index(mem_ctx, local->hive_key, idx,
+ name, type, data);
}
-static WERROR local_delete_key (struct registry_key *key, const char *name)
+static WERROR local_delete_key(struct registry_key *key, const char *name)
{
const struct local_key *local = (const struct local_key *)key;
return hive_key_del(local->hive_key, name);
}
-static WERROR local_delete_value (struct registry_key *key, const char *name)
+static WERROR local_delete_value(struct registry_key *key, const char *name)
{
const struct local_key *local = (const struct local_key *)key;
return hive_del_value(local->hive_key, name);
}
-static WERROR local_flush_key (struct registry_key *key)
+static WERROR local_flush_key(struct registry_key *key)
{
const struct local_key *local = (const struct local_key *)key;
return hive_key_flush(local->hive_key);
}
-static WERROR local_get_key_info (TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- const char **classname,
- uint32_t *num_subkeys,
- uint32_t *num_values,
- NTTIME *last_change_time)
+static WERROR local_get_key_info(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ const char **classname,
+ uint32_t *num_subkeys,
+ uint32_t *num_values,
+ NTTIME *last_change_time)
{
const struct local_key *local = (const struct local_key *)key;
- return hive_key_get_info(mem_ctx, local->hive_key,
- classname, num_subkeys, num_values,
- last_change_time);
+ return hive_key_get_info(mem_ctx, local->hive_key,
+ classname, num_subkeys, num_values,
+ last_change_time);
}
const static struct registry_operations local_ops = {
@@ -286,11 +290,12 @@ const static struct registry_operations local_ops = {
.get_key_info = local_get_key_info,
};
-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 auth_session_info *session_info,
+ struct cli_credentials *credentials)
{
- struct registry_local *ret = talloc_zero(mem_ctx, struct registry_local);
+ struct registry_local *ret = talloc_zero(mem_ctx,
+ struct registry_local);
W_ERROR_HAVE_NO_MEMORY(ret);
@@ -299,16 +304,17 @@ WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx,
ret->credentials = credentials;
*ctx = (struct registry_context *)ret;
-
+
return WERR_OK;
}
-WERROR reg_mount_hive(struct registry_context *rctx,
- struct hive_key *hive_key,
- uint32_t key_id,
- const char **elements)
+WERROR reg_mount_hive(struct registry_context *rctx,
+ struct hive_key *hive_key,
+ uint32_t key_id,
+ const char **elements)
{
- struct registry_local *reg_local = talloc_get_type(rctx, struct registry_local);
+ struct registry_local *reg_local = talloc_get_type(rctx,
+ struct registry_local);
struct mountpoint *mp = talloc(rctx, struct mountpoint);
int i = 0;
@@ -316,11 +322,11 @@ WERROR reg_mount_hive(struct registry_context *rctx,
mp->prev = mp->next = NULL;
mp->key = hive_key;
if (elements != NULL) {
- mp->path.elements = talloc_array(mp, const char *,
- str_list_length(elements));
+ mp->path.elements = talloc_array(mp, const char *,
+ str_list_length(elements));
for (i = 0; elements[i] != NULL; i++) {
- mp->path.elements[i] = talloc_reference(mp->path.elements,
- elements[i]);
+ mp->path.elements[i] = talloc_reference(mp->path.elements,
+ elements[i]);
}
mp->path.elements[i] = NULL;
} else {
diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c
index 8df873d56b..e5d9a26618 100644
--- a/source4/lib/registry/patchfile.c
+++ b/source4/lib/registry/patchfile.c
@@ -1,7 +1,7 @@
-/*
+/*
Unix SMB/CIFS implementation.
Reading registry patch files
-
+
Copyright (C) Jelmer Vernooij 2004-2007
Copyright (C) Wilco Baan Hofman 2006
@@ -9,12 +9,12 @@
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/>.
*/
@@ -25,18 +25,22 @@
#include "system/filesys.h"
-_PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *callbacks, void *callback_data);
+_PUBLIC_ WERROR reg_preg_diff_load(int fd,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data);
-_PUBLIC_ WERROR reg_dotreg_diff_load(int fd, const struct reg_diff_callbacks *callbacks, void *callback_data);
+_PUBLIC_ WERROR reg_dotreg_diff_load(int fd,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data);
/*
* Generate difference between two keys
*/
-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_generate_diff_key(struct registry_key *oldkey,
+ struct registry_key *newkey,
+ const char *path,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data)
{
int i;
struct registry_key *t1, *t2;
@@ -48,11 +52,12 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
new_num_subkeys, new_num_values;
if (oldkey != NULL) {
- error = reg_key_get_info(mem_ctx, oldkey, NULL, &old_num_subkeys, &old_num_values,
- NULL);
+ error = reg_key_get_info(mem_ctx, oldkey, NULL,
+ &old_num_subkeys, &old_num_values,
+ NULL);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Error occured while getting key info: %s\n",
- win_errstr(error)));
+ DEBUG(0, ("Error occured while getting key info: %s\n",
+ win_errstr(error)));
return error;
}
} else {
@@ -62,11 +67,12 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
/* Subkeys that were deleted */
for (i = 0; i < old_num_subkeys; i++) {
- error1 = reg_key_get_subkey_by_index(mem_ctx, oldkey, i, &keyname1,
- NULL, NULL);
+ error1 = reg_key_get_subkey_by_index(mem_ctx, oldkey, i,
+ &keyname1,
+ NULL, NULL);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Error occured while getting subkey by index: %s\n",
- win_errstr(error2)));
+ DEBUG(0, ("Error occured while getting subkey by index: %s\n",
+ win_errstr(error2)));
continue;
}
@@ -81,8 +87,8 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
}
if (!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
- DEBUG(0, ("Error occured while getting subkey by name: %s\n",
- win_errstr(error2)));
+ DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+ win_errstr(error2)));
talloc_free(mem_ctx);
return error2;
}
@@ -90,15 +96,16 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
/* newkey didn't have such a subkey, add del diff */
tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1);
callbacks->del_key(callback_data, tmppath);
- talloc_free(tmppath);
+ talloc_free(tmppath);
}
if (newkey != NULL) {
- error = reg_key_get_info(mem_ctx, newkey, NULL, &new_num_subkeys, &new_num_values,
- NULL);
+ error = reg_key_get_info(mem_ctx, newkey, NULL,
+ &new_num_subkeys, &new_num_values,
+ NULL);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Error occured while getting key info: %s\n",
- win_errstr(error)));
+ DEBUG(0, ("Error occured while getting key info: %s\n",
+ win_errstr(error)));
return error;
}
} else {
@@ -108,28 +115,29 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
/* Subkeys that were added */
for(i = 0; i < new_num_subkeys; i++) {
- error1 = reg_key_get_subkey_by_index(mem_ctx, newkey, i, &keyname1,
- NULL, NULL);
+ error1 = reg_key_get_subkey_by_index(mem_ctx, newkey,
+ i, &keyname1,
+ NULL, NULL);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Error occured while getting subkey by index: %s\n",
- win_errstr(error1)));
+ DEBUG(0, ("Error occured while getting subkey by index: %s\n",
+ win_errstr(error1)));
talloc_free(mem_ctx);
return error1;
}
if (oldkey != NULL) {
error2 = reg_open_key(mem_ctx, oldkey, keyname1, &t1);
-
+
if (W_ERROR_IS_OK(error2))
continue;
} else {
t1 = NULL;
error2 = WERR_DEST_NOT_FOUND;
}
-
+
if (!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
- DEBUG(0, ("Error occured while getting subkey by name: %s\n",
- win_errstr(error2)));
+ DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+ win_errstr(error2)));
talloc_free(mem_ctx);
return error2;
}
@@ -141,7 +149,8 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
W_ERROR_NOT_OK_RETURN(
reg_open_key(mem_ctx, newkey, keyname1, &t2));
- reg_generate_diff_key(t1, t2, tmppath, callbacks, callback_data);
+ reg_generate_diff_key(t1, t2, tmppath,
+ callbacks, callback_data);
talloc_free(tmppath);
}
@@ -151,56 +160,59 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
uint32_t type1, type2;
DATA_BLOB contents1, contents2;
- error1 = reg_key_get_value_by_index(mem_ctx, newkey, i,
- &name, &type1, &contents1);
+ error1 = reg_key_get_value_by_index(mem_ctx, newkey, i,
+ &name, &type1, &contents1);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Unable to get key by index: %s\n",
- win_errstr(error1)));
+ DEBUG(0, ("Unable to get key by index: %s\n",
+ win_errstr(error1)));
talloc_free(mem_ctx);
return error1;
}
if (oldkey != NULL) {
- error2 = reg_key_get_value_by_name(mem_ctx, oldkey, name,
- &type2, &contents2);
- } else
+ error2 = reg_key_get_value_by_name(mem_ctx, oldkey,
+ name, &type2,
+ &contents2);
+ } else
error2 = WERR_DEST_NOT_FOUND;
-
- if(!W_ERROR_IS_OK(error2) &&
+
+ if(!W_ERROR_IS_OK(error2) &&
!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
- DEBUG(0, ("Error occured while getting value by name: %s\n",
- win_errstr(error2)));
+ DEBUG(0, ("Error occured while getting value by name: %s\n",
+ win_errstr(error2)));
talloc_free(mem_ctx);
return error2;
}
- if (W_ERROR_IS_OK(error2) && data_blob_cmp(&contents1, &contents2) == 0)
+ if (W_ERROR_IS_OK(error2) &&
+ data_blob_cmp(&contents1, &contents2) == 0)
continue;
- callbacks->set_value(callback_data, path, name, type1, contents1);
+ callbacks->set_value(callback_data, path, name,
+ type1, contents1);
}
/* Values that were deleted */
for (i = 0; i < old_num_values; i++) {
const char *name;
- error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &name,
- NULL, NULL);
+ error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &name,
+ NULL, NULL);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Error ocurred getting value by index: %s\n",
- win_errstr(error1)));
+ DEBUG(0, ("Error ocurred getting value by index: %s\n",
+ win_errstr(error1)));
talloc_free(mem_ctx);
return error1;
}
- error2 = reg_key_get_value_by_name(mem_ctx, newkey, name, NULL,
- NULL);
+ error2 = reg_key_get_value_by_name(mem_ctx, newkey, name, NULL,
+ NULL);
if (W_ERROR_IS_OK(error2))
continue;
if (!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
- DEBUG(0, ("Error occured while getting value by name: %s\n",
- win_errstr(error2)));
+ DEBUG(0, ("Error occured while getting value by name: %s\n",
+ win_errstr(error2)));
return error2;
}
@@ -212,10 +224,10 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
}
/**
- * Generate diff between two registry contexts
+ * Generate diff between two registry contexts
*/
-_PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
- struct registry_context *ctx2,
+_PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
+ struct registry_context *ctx2,
const struct reg_diff_callbacks *callbacks,
void *callback_data)
{
@@ -225,21 +237,27 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
for(i = HKEY_FIRST; i <= HKEY_LAST; i++) {
struct registry_key *r1 = NULL, *r2 = NULL;
error = reg_get_predefined_key(ctx1, i, &r1);
- if (!W_ERROR_IS_OK(error) && !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
- DEBUG(0, ("Unable to open hive %s for backend 1\n", reg_get_predef_name(i)));
+ if (!W_ERROR_IS_OK(error) &&
+ !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
+ DEBUG(0, ("Unable to open hive %s for backend 1\n",
+ reg_get_predef_name(i)));
}
-
+
error = reg_get_predefined_key(ctx2, i, &r2);
- if (!W_ERROR_IS_OK(error) && !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
- DEBUG(0, ("Unable to open hive %s for backend 2\n", reg_get_predef_name(i)));
+ if (!W_ERROR_IS_OK(error) &&
+ !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
+ DEBUG(0, ("Unable to open hive %s for backend 2\n",
+ reg_get_predef_name(i)));
}
if (r1 == NULL && r2 == NULL)
continue;
- error = reg_generate_diff_key(r1, r2, reg_get_predef_name(i), callbacks, callback_data);
+ error = reg_generate_diff_key(r1, r2, reg_get_predef_name(i),
+ callbacks, callback_data);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Unable to determine diff: %s\n", win_errstr(error)));
+ DEBUG(0, ("Unable to determine diff: %s\n",
+ win_errstr(error)));
return error;
}
}
@@ -252,21 +270,23 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
/**
* Load diff file
*/
-_PUBLIC_ WERROR reg_diff_load(const char *filename,
- const struct reg_diff_callbacks *callbacks,
- void *callback_data)
+_PUBLIC_ WERROR reg_diff_load(const char *filename,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data)
{
int fd;
char hdr[4];
-
+
fd = open(filename, O_RDONLY, 0);
if (fd == -1) {
- DEBUG(0, ("Error opening registry patch file `%s'\n", filename));
+ DEBUG(0, ("Error opening registry patch file `%s'\n",
+ filename));
return WERR_GENERAL_FAILURE;
}
if (read(fd, &hdr, 4) != 4) {
- DEBUG(0, ("Error reading registry patch file `%s'\n", filename));
+ DEBUG(0, ("Error reading registry patch file `%s'\n",
+ filename));
return WERR_GENERAL_FAILURE;
}
@@ -279,8 +299,8 @@ _PUBLIC_ WERROR reg_diff_load(const char *filename,
} else if (strncmp(hdr, "regf", 4) == 0) {
/* Must be a REGF NTConfig.pol file */
return reg_regf_diff_load(diff, fd);
- } else
-#endif
+ } else
+#endif
if (strncmp(hdr, "PReg", 4) == 0) {
/* Must be a GPO Registry.pol file */
return reg_preg_diff_load(fd, callbacks, callback_data);
@@ -293,24 +313,26 @@ _PUBLIC_ WERROR reg_diff_load(const char *filename,
/**
* The reg_diff_apply functions
*/
-static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name)
+static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name)
{
- struct registry_context *ctx = _ctx;
+ struct registry_context *ctx = (struct registry_context *)_ctx;
struct registry_key *tmp;
WERROR error;
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)) {
- DEBUG(0, ("Error adding new key '%s': %s\n", key_name, win_errstr(error)));
+ 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;
}
return WERR_OK;
}
-static WERROR reg_diff_apply_del_key(void *_ctx, const char *key_name)
+static WERROR reg_diff_apply_del_key(void *_ctx, const char *key_name)
{
- struct registry_context *ctx = _ctx;
+ struct registry_context *ctx = (struct registry_context *)_ctx;
WERROR error;
error = reg_key_del_abs(ctx, key_name);
@@ -319,16 +341,18 @@ static WERROR reg_diff_apply_del_key(void *_ctx, const char *key_name)
DEBUG(0, ("Unable to delete key '%s'\n", key_name));
return error;
}
-
+
return WERR_OK;
}
-static WERROR reg_diff_apply_set_value(void *_ctx, const char *path, const char *value_name, uint32_t value_type, DATA_BLOB value)
+static WERROR reg_diff_apply_set_value(void *_ctx, const char *path,
+ const char *value_name,
+ uint32_t value_type, DATA_BLOB value)
{
- struct registry_context *ctx = _ctx;
+ struct registry_context *ctx = (struct registry_context *)_ctx;
struct registry_key *tmp;
WERROR error;
-
+
/* Open key */
error = reg_open_key_abs(ctx, ctx, path, &tmp);
@@ -338,22 +362,23 @@ static WERROR reg_diff_apply_set_value(void *_ctx, const char *path, const char
}
/* Set value */
- error = reg_val_set(tmp, value_name,
+ error = reg_val_set(tmp, value_name,
value_type, value);
if (!W_ERROR_IS_OK(error)) {
DEBUG(0, ("Error setting value '%s'\n", value_name));
return error;
- }
-
+ }
+
return WERR_OK;
}
-static WERROR reg_diff_apply_del_value (void *_ctx, const char *key_name, const char *value_name)
+static WERROR reg_diff_apply_del_value(void *_ctx, const char *key_name,
+ const char *value_name)
{
- struct registry_context *ctx = _ctx;
+ struct registry_context *ctx = (struct registry_context *)_ctx;
struct registry_key *tmp;
WERROR error;
-
+
/* Open key */
error = reg_open_key_abs(ctx, ctx, key_name, &tmp);
@@ -367,14 +392,14 @@ static WERROR reg_diff_apply_del_value (void *_ctx, const char *key_name, const
DEBUG(0, ("Error deleting value '%s'\n", value_name));
return error;
}
-
+
return WERR_OK;
}
static WERROR reg_diff_apply_del_all_values(void *_ctx, const char *key_name)
{
- struct registry_context *ctx = _ctx;
+ struct registry_context *ctx = (struct registry_context *)_ctx;
struct registry_key *key;
WERROR error;
int i;
@@ -387,26 +412,28 @@ static WERROR reg_diff_apply_del_all_values(void *_ctx, const char *key_name)
return error;
}
- W_ERROR_NOT_OK_RETURN(reg_key_get_info(ctx, key,
- NULL,
- NULL,
- &num_values,
- NULL));
+ W_ERROR_NOT_OK_RETURN(reg_key_get_info(ctx, key,
+ NULL,
+ NULL,
+ &num_values,
+ NULL));
for (i = 0; i < num_values; i++) {
const char *name;
- W_ERROR_NOT_OK_RETURN(reg_key_get_value_by_index(ctx, key, i, &name,
- NULL, NULL));
+ W_ERROR_NOT_OK_RETURN(reg_key_get_value_by_index(ctx, key, i,
+ &name,
+ NULL, NULL));
W_ERROR_NOT_OK_RETURN(reg_del_value(key, name));
}
return WERR_OK;
}
-/**
- * Apply diff to a registry context
+/**
+ * Apply diff to a registry context
*/
-_PUBLIC_ WERROR reg_diff_apply (const char *filename, struct registry_context *ctx)
+_PUBLIC_ WERROR reg_diff_apply(const char *filename,
+ struct registry_context *ctx)
{
struct reg_diff_callbacks callbacks;
diff --git a/source4/lib/registry/patchfile.h b/source4/lib/registry/patchfile.h
index 1c0b195a8c..4c0599b2f3 100644
--- a/source4/lib/registry/patchfile.h
+++ b/source4/lib/registry/patchfile.h
@@ -1,52 +1,55 @@
-/*
+/*
Unix SMB/CIFS implementation.
Patchfile interface
Copyright (C) Jelmer Vernooij 2006
Copyright (C) Wilco Baan Hofman 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _PATCHFILE_H
-#define _PATCHFILE_H
+#define _PATCHFILE_H
#include "lib/registry/registry.h"
struct reg_diff_callbacks {
WERROR (*add_key) (void *callback_data, const char *key_name);
- WERROR (*set_value) (void *callback_data, const char *key_name,
- const char *value_name, uint32_t value_type, DATA_BLOB value);
- WERROR (*del_value) (void *callback_data, const char *key_name, const char *value_name);
+ WERROR (*set_value) (void *callback_data, const char *key_name,
+ const char *value_name, uint32_t value_type,
+ DATA_BLOB value);
+ WERROR (*del_value) (void *callback_data, const char *key_name,
+ const char *value_name);
WERROR (*del_key) (void *callback_data, const char *key_name);
WERROR (*del_all_values) (void *callback_data, const char *key_name);
WERROR (*done) (void *callback_data);
};
-WERROR reg_diff_apply (const char *filename,
- struct registry_context *ctx);
-
-WERROR reg_generate_diff(struct registry_context *ctx1,
- struct registry_context *ctx2,
- const struct reg_diff_callbacks *callbacks,
- void *callback_data);
-WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
- 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_apply (const char *filename,
+ struct registry_context *ctx);
+
+WERROR reg_generate_diff(struct registry_context *ctx1,
+ struct registry_context *ctx2,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data);
+WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
+ 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);
#endif /* _PATCHFILE_H */
diff --git a/source4/lib/registry/patchfile_dotreg.c b/source4/lib/registry/patchfile_dotreg.c
index 1b4bffe819..ebcafc92af 100644
--- a/source4/lib/registry/patchfile_dotreg.c
+++ b/source4/lib/registry/patchfile_dotreg.c
@@ -1,7 +1,7 @@
-/*
+/*
Unix SMB/CIFS implementation.
Reading .REG files
-
+
Copyright (C) Jelmer Vernooij 2004-2007
Copyright (C) Wilco Baan Hofman 2006
@@ -9,12 +9,12 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -40,37 +40,39 @@ struct dotreg_data {
static WERROR reg_dotreg_diff_add_key(void *_data, const char *key_name)
{
- struct dotreg_data *data = _data;
+ struct dotreg_data *data = (struct dotreg_data *)_data;
fdprintf(data->fd, "\n[%s]\n", key_name);
-
+
return WERR_OK;
}
static WERROR reg_dotreg_diff_del_key(void *_data, const char *key_name)
{
- struct dotreg_data *data = _data;
+ struct dotreg_data *data = (struct dotreg_data *)_data;
fdprintf(data->fd, "\n[-%s]\n", key_name);
-
+
return WERR_OK;
}
-static WERROR reg_dotreg_diff_set_value(void *_data, const char *path,
- const char *value_name, uint32_t value_type, DATA_BLOB value)
+static WERROR reg_dotreg_diff_set_value(void *_data, const char *path,
+ const char *value_name,
+ uint32_t value_type, DATA_BLOB value)
{
- struct dotreg_data *data = _data;
+ struct dotreg_data *data = (struct dotreg_data *)_data;
fdprintf(data->fd, "\"%s\"=%s:%s\n",
- value_name, str_regtype(value_type),
+ value_name, str_regtype(value_type),
reg_val_data_string(NULL, value_type, value));
-
+
return WERR_OK;
}
-static WERROR reg_dotreg_diff_del_value(void *_data, const char *path, const char *value_name)
+static WERROR reg_dotreg_diff_del_value(void *_data, const char *path,
+ const char *value_name)
{
- struct dotreg_data *data = _data;
+ struct dotreg_data *data = (struct dotreg_data *)_data;
fdprintf(data->fd, "\"%s\"=-\n", value_name);
@@ -79,7 +81,7 @@ static WERROR reg_dotreg_diff_del_value(void *_data, const char *path, const cha
static WERROR reg_dotreg_diff_done(void *_data)
{
- struct dotreg_data *data = _data;
+ struct dotreg_data *data = (struct dotreg_data *)_data;
close(data->fd);
talloc_free(data);
@@ -87,7 +89,8 @@ static WERROR reg_dotreg_diff_done(void *_data)
return WERR_OK;
}
-static WERROR reg_dotreg_diff_del_all_values (void *callback_data, const char *key_name)
+static WERROR reg_dotreg_diff_del_all_values(void *callback_data,
+ const char *key_name)
{
return WERR_NOT_SUPPORTED;
}
@@ -95,8 +98,9 @@ static WERROR reg_dotreg_diff_del_all_values (void *callback_data, const char *k
/**
* Save registry diff
*/
-_PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
- struct reg_diff_callbacks **callbacks, void **callback_data)
+_PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
+ struct reg_diff_callbacks **callbacks,
+ void **callback_data)
{
struct dotreg_data *data;
@@ -125,12 +129,14 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
(*callbacks)->done = reg_dotreg_diff_done;
return WERR_OK;
-}
+}
/**
* Load diff file
*/
-_PUBLIC_ WERROR reg_dotreg_diff_load(int fd, const struct reg_diff_callbacks *callbacks, void *callback_data)
+_PUBLIC_ WERROR reg_dotreg_diff_load(int fd,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data)
{
char *line, *p, *q;
char *curkey = NULL;
@@ -151,8 +157,8 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd, const struct reg_diff_callbacks *ca
/* Ignore comments and empty lines */
if (strlen(line) == 0 || line[0] == ';') {
talloc_free(line);
-
- if (curkey) {
+
+ if (curkey) {
talloc_free(curkey);
}
curkey = NULL;
@@ -170,9 +176,11 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd, const struct reg_diff_callbacks *ca
if (line[1] == '-') {
curkey = talloc_strndup(line, line+2, strlen(line)-3);
- error = callbacks->del_key(callback_data, curkey);
+ error = callbacks->del_key(callback_data,
+ curkey);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0,("Error deleting key %s\n", curkey));
+ DEBUG(0,("Error deleting key %s\n",
+ curkey));
talloc_free(mem_ctx);
return error;
}
@@ -212,9 +220,11 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd, const struct reg_diff_callbacks *ca
/* Delete value */
if (strcmp(p, "-") == 0) {
- error = callbacks->del_value(callback_data, curkey, line);
+ error = callbacks->del_value(callback_data,
+ curkey, line);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Error deleting value %s in key %s\n", line, curkey));
+ DEBUG(0, ("Error deleting value %s in key %s\n",
+ line, curkey));
talloc_free(mem_ctx);
return error;
}
@@ -222,18 +232,21 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd, const struct reg_diff_callbacks *ca
talloc_free(line);
continue;
}
-
+
q = strchr_m(p, ':');
if (q) {
- *q = '\0';
+ *q = '\0';
q++;
}
- reg_string_to_val(line, q?p:"REG_SZ", q?q:p, &value_type, &value);
-
- error = callbacks->set_value(callback_data, curkey, line, value_type, value);
+ reg_string_to_val(line, q?p:"REG_SZ", q?q:p,
+ &value_type, &value);
+
+ error = callbacks->set_value(callback_data, curkey, line,
+ value_type, value);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Error setting value for %s in %s\n", line, curkey));
+ DEBUG(0, ("Error setting value for %s in %s\n",
+ line, curkey));
talloc_free(mem_ctx);
return error;
}
diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c
index 1c8d76538a..90a4f2529a 100644
--- a/source4/lib/registry/patchfile_preg.c
+++ b/source4/lib/registry/patchfile_preg.c
@@ -1,19 +1,19 @@
-/*
+/*
Unix SMB/CIFS implementation.
Reading Registry.pol PReg registry files
-
+
Copyright (C) Wilco Baan Hofman 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -21,6 +21,7 @@
#include "includes.h"
#include "lib/registry/registry.h"
+#include "lib/registry/patchfile.h"
#include "system/filesys.h"
#include "pstring.h"
@@ -42,37 +43,40 @@ static WERROR preg_read_utf16(int fd, char *c)
/* FIXME These functions need to be implemented */
static WERROR reg_preg_diff_add_key(void *_data, const char *key_name)
{
- struct preg_data *data = _data;
+ struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
static WERROR reg_preg_diff_del_key(void *_data, const char *key_name)
{
- struct preg_data *data = _data;
+ struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
-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)
+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;
+ struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
-static WERROR reg_preg_diff_del_value(void *_data, const char *key_name, const char *value_name)
+static WERROR reg_preg_diff_del_value(void *_data, const char *key_name,
+ const char *value_name)
{
- struct preg_data *data = _data;
+ struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
static WERROR reg_preg_diff_del_all_values(void *_data, const char *key_name)
{
- struct preg_data *data = _data;
+ struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
static WERROR reg_preg_diff_done(void *_data)
{
- struct preg_data *data = _data;
+ struct preg_data *data = (struct preg_data *)_data;
close(data->fd);
talloc_free(data);
@@ -82,14 +86,16 @@ static WERROR reg_preg_diff_done(void *_data)
/**
* Save registry diff
*/
-_PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename, struct reg_diff_callbacks **callbacks, void **callback_data)
+_PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
+ struct reg_diff_callbacks **callbacks,
+ void **callback_data)
{
struct preg_data *data;
struct {
char hdr[4];
uint32_t version;
} preg_header;
-
+
data = talloc_zero(ctx, struct preg_data);
*callback_data = data;
@@ -105,23 +111,25 @@ _PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename, struct
}
snprintf(preg_header.hdr, 4, "PReg");
SIVAL(&preg_header, 4, 1);
- write(data->fd, (uint8_t *)&preg_header,8);
+ write(data->fd, (uint8_t *)&preg_header,8);
*callbacks = talloc(ctx, struct reg_diff_callbacks);
-
+
(*callbacks)->add_key = reg_preg_diff_add_key;
(*callbacks)->del_key = reg_preg_diff_del_key;
(*callbacks)->set_value = reg_preg_diff_set_value;
(*callbacks)->del_value = reg_preg_diff_del_value;
(*callbacks)->del_all_values = reg_preg_diff_del_all_values;
(*callbacks)->done = reg_preg_diff_done;
-
+
return WERR_OK;
}
/**
* Load diff file
*/
-_PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *callbacks, void *callback_data)
+_PUBLIC_ WERROR reg_preg_diff_load(int fd,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data)
{
struct {
char hdr[4];
@@ -131,7 +139,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
char *buf_ptr = buf;
TALLOC_CTX *mem_ctx = talloc_init("reg_preg_diff_load");
-
+
/* Read first 8 bytes (the header) */
if (read(fd, &preg_header, 8) != 8) {
DEBUG(0, ("Could not read PReg file: %s\n",
@@ -146,14 +154,14 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
}
if (preg_header.version > 1) {
DEBUG(0, ("Warning: file format version is higher than expected.\n"));
- }
+ }
/* Read the entries */
while(1) {
char *key, *value_name;
uint32_t value_type, length;
DATA_BLOB data;
-
+
if (!W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr))) {
break;
}
@@ -162,17 +170,19 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
close(fd);
return WERR_GENERAL_FAILURE;
}
-
+
/* Get the path */
buf_ptr = buf;
- while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) {
+ while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+ *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) {
buf_ptr++;
}
key = talloc_asprintf(mem_ctx, "\\%s", buf);
-
+
/* Get the name */
buf_ptr = buf;
- while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) {
+ while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+ *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) {
buf_ptr++;
}
value_name = talloc_strdup(mem_ctx, buf);
@@ -185,7 +195,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
}
/* Read past delimiter */
buf_ptr = buf;
- if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
+ if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+ *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
DEBUG(0, ("Error in PReg file.\n"));
close(fd);
return WERR_GENERAL_FAILURE;
@@ -198,40 +209,43 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
}
/* Read past delimiter */
buf_ptr = buf;
- if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
+ if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+ *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
DEBUG(0, ("Error in PReg file.\n"));
close(fd);
return WERR_GENERAL_FAILURE;
- }
+ }
/* Get the data */
buf_ptr = buf;
- if (length < sizeof(buf) && read(fd, buf_ptr, length) != length) {
+ if (length < sizeof(buf) &&
+ read(fd, buf_ptr, length) != length) {
DEBUG(0, ("Error while reading PReg\n"));
close(fd);
return WERR_GENERAL_FAILURE;
}
- data.length = length;
- data.data = talloc_memdup(mem_ctx, buf, length);
-
+ data = data_blob_talloc(mem_ctx, buf, length);
+
/* Check if delimiter is in place (whine if it isn't) */
buf_ptr = buf;
- if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr == ']') && buf_ptr-buf < sizeof(buf)) {
- DEBUG(0, ("Warning: Missing ']' in PReg file, expected ']', got '%c' 0x%x.\n",*buf_ptr, *buf_ptr));
+ if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+ *buf_ptr == ']') && buf_ptr-buf < sizeof(buf)) {
+ DEBUG(0, ("Warning: Missing ']' in PReg file, expected ']', got '%c' 0x%x.\n",
+ *buf_ptr, *buf_ptr));
}
if (strcasecmp(value_name, "**DelVals") == 0) {
callbacks->del_all_values(callback_data, key);
} else if (strncasecmp(value_name, "**Del.",6) == 0) {
char *p = value_name+6;
-
+
callbacks->del_value(callback_data, key, p);
} else if (strcasecmp(value_name, "**DeleteValues") == 0) {
char *p, *q;
p = (char *) data.data;
-
+
while ((q = strchr_m(p, ';'))) {
- *q = '\0';
+ *q = '\0';
q++;
callbacks->del_value(callback_data, key, p);
@@ -243,28 +257,30 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
char *p, *q, *full_key;
p = (char *) data.data;
-
+
while ((q = strchr_m(p, ';'))) {
*q = '\0';
q++;
-
- full_key = talloc_asprintf(mem_ctx, "%s\\%s", key, p);
+
+ full_key = talloc_asprintf(mem_ctx, "%s\\%s",
+ key, p);
callbacks->del_key(callback_data, full_key);
talloc_free(full_key);
- p = q;
+ p = q;
}
full_key = talloc_asprintf(mem_ctx, "%s\\%s", key, p);
callbacks->del_key(callback_data, full_key);
talloc_free(full_key);
} else {
callbacks->add_key(callback_data, key);
- callbacks->set_value(callback_data, key, value_name, value_type, data);
+ callbacks->set_value(callback_data, key, value_name,
+ value_type, data);
}
talloc_free(key);
talloc_free(value_name);
talloc_free(data.data);
}
- close(fd);
+ close(fd);
return WERR_OK;
}
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index d74ffd2b4b..2dd27ca33d 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -8,15 +8,15 @@
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/registry/hive.h"
#include "system/filesys.h"
@@ -28,7 +28,7 @@
static struct hive_operations reg_backend_regf;
/**
- * There are several places on the web where the REGF format is explained;
+ * There are several places on the web where the REGF format is explained;
*
* TODO: Links
*/
@@ -53,18 +53,18 @@ static WERROR regf_save_hbin(struct regf_data *data);
struct regf_key_data {
struct hive_key key;
- struct regf_data *hive;
+ struct regf_data *hive;
uint32_t offset;
struct nk_block *nk;
};
-static struct hbin_block *hbin_by_offset(const struct regf_data *data,
- uint32_t offset, uint32_t *rel_offset)
+static struct hbin_block *hbin_by_offset(const struct regf_data *data,
+ uint32_t offset, uint32_t *rel_offset)
{
int i;
for (i = 0; data->hbins[i]; i++) {
- if (offset >= data->hbins[i]->offset_from_first &&
+ if (offset >= data->hbins[i]->offset_from_first &&
offset < data->hbins[i]->offset_from_first+
data->hbins[i]->offset_to_next) {
if (rel_offset != NULL)
@@ -84,7 +84,7 @@ static uint32_t regf_hdr_checksum(const uint8_t *buffer)
{
uint32_t checksum = 0, x;
int i;
-
+
for (i = 0; i < 0x01FB; i+= 4) {
x = IVAL(buffer, i);
checksum ^= x;
@@ -122,14 +122,14 @@ static DATA_BLOB hbin_get(const struct regf_data *data, uint32_t offset)
ret.length = (ret.length ^ 0xffffffff) + 1;
ret.length -= 4; /* 4 bytes for the length... */
- ret.data = hbin->data +
+ ret.data = hbin->data +
(offset - hbin->offset_from_first - 0x20) + 4;
-
+
return ret;
}
-static bool hbin_get_tdr (struct regf_data *regf, uint32_t offset,
- TALLOC_CTX *ctx, tdr_pull_fn_t pull_fn, void *p)
+static bool hbin_get_tdr(struct regf_data *regf, uint32_t offset,
+ TALLOC_CTX *ctx, tdr_pull_fn_t pull_fn, void *p)
{
struct tdr_pull pull;
@@ -140,9 +140,10 @@ static bool hbin_get_tdr (struct regf_data *regf, uint32_t offset,
DEBUG(1, ("Unable to get data at 0x%04x\n", offset));
return false;
}
-
+
if (NT_STATUS_IS_ERR(pull_fn(&pull, ctx, p))) {
- DEBUG(1, ("Error parsing record at 0x%04x using tdr\n", offset));
+ DEBUG(1, ("Error parsing record at 0x%04x using tdr\n",
+ offset));
return false;
}
@@ -150,8 +151,8 @@ static bool hbin_get_tdr (struct regf_data *regf, uint32_t offset,
}
/* Allocate some new data */
-static DATA_BLOB hbin_alloc(struct regf_data *data, uint32_t size,
- uint32_t *offset)
+static DATA_BLOB hbin_alloc(struct regf_data *data, uint32_t size,
+ uint32_t *offset)
{
DATA_BLOB ret;
uint32_t rel_offset = -1; /* Relative offset ! */
@@ -190,13 +191,15 @@ static DATA_BLOB hbin_alloc(struct regf_data *data, uint32_t size,
my_size = -my_size;
} else if (my_size == size) { /* exact match */
rel_offset = j;
- DEBUG(4, ("Found free block of exact size %d in middle of HBIN\n", size));
+ DEBUG(4, ("Found free block of exact size %d in middle of HBIN\n",
+ size));
break;
} else if (my_size > size) { /* data will remain */
rel_offset = j;
/* Split this block and mark the next block as free */
- SIVAL(hbin->data, rel_offset+size, my_size-size);
- DEBUG(4, ("Found free block of size %d (needing %d) in middle of HBIN\n", my_size, size));
+ SIVAL(hbin->data, rel_offset+size, my_size-size);
+ DEBUG(4, ("Found free block of size %d (needing %d) in middle of HBIN\n",
+ my_size, size));
break;
}
}
@@ -204,12 +207,14 @@ static DATA_BLOB hbin_alloc(struct regf_data *data, uint32_t size,
if (rel_offset != -1)
break;
}
-
- /* No space available in previous hbins,
+
+ /* No space available in previous hbins,
* allocate new one */
- if (data->hbins[i] == NULL) {
- DEBUG(4, ("No space available in other HBINs for block of size %d, allocating new HBIN\n", size));
- data->hbins = talloc_realloc(data, data->hbins, struct hbin_block *, i+2);
+ if (data->hbins[i] == NULL) {
+ DEBUG(4, ("No space available in other HBINs for block of size %d, allocating new HBIN\n",
+ size));
+ data->hbins = talloc_realloc(data, data->hbins,
+ struct hbin_block *, i+2);
hbin = talloc(data->hbins, struct hbin_block);
SMB_ASSERT(hbin != NULL);
@@ -255,11 +260,12 @@ static uint32_t hbin_store (struct regf_data *data, DATA_BLOB blob)
return ret;
}
-static uint32_t hbin_store_tdr (struct regf_data *data, tdr_push_fn_t push_fn, void *p)
+static uint32_t hbin_store_tdr(struct regf_data *data,
+ tdr_push_fn_t push_fn, void *p)
{
struct tdr_push *push = talloc_zero(data, struct tdr_push);
uint32_t ret;
-
+
if (NT_STATUS_IS_ERR(push_fn(push, p))) {
DEBUG(0, ("Error during push\n"));
return -1;
@@ -278,26 +284,27 @@ static void hbin_free (struct regf_data *data, uint32_t offset)
{
int32_t size;
uint32_t rel_offset;
- int32_t next_size;
+ int32_t next_size;
struct hbin_block *hbin;
SMB_ASSERT (offset > 0);
-
+
hbin = hbin_by_offset(data, offset, &rel_offset);
if (hbin == NULL)
return;
-
+
/* Get original size */
size = IVALS(hbin->data, rel_offset);
if (size > 0) {
- DEBUG(1, ("Trying to free already freed block at 0x%04x\n", offset));
+ DEBUG(1, ("Trying to free already freed block at 0x%04x\n",
+ offset));
return;
}
/* Mark as unused */
size = -size;
-
+
/* If the next block is free, merge into big free block */
if (rel_offset + size < hbin->offset_to_next) {
next_size = IVALS(hbin->data, rel_offset+size);
@@ -312,13 +319,14 @@ static void hbin_free (struct regf_data *data, uint32_t offset)
/**
* Store a data blob data was already stored, but has changed in size
- * Will try to save it at the current location if possible, otherwise
+ * Will try to save it at the current location if possible, otherwise
* does a free + store */
-static uint32_t hbin_store_resize(struct regf_data *data,
- uint32_t orig_offset, DATA_BLOB blob)
+static uint32_t hbin_store_resize(struct regf_data *data,
+ uint32_t orig_offset, DATA_BLOB blob)
{
uint32_t rel_offset;
- struct hbin_block *hbin = hbin_by_offset(data, orig_offset, &rel_offset);
+ struct hbin_block *hbin = hbin_by_offset(data, orig_offset,
+ &rel_offset);
int32_t my_size;
int32_t orig_size;
int32_t needed_size;
@@ -343,7 +351,8 @@ static uint32_t hbin_store_resize(struct regf_data *data,
* and free/merge it */
if (orig_size - needed_size > 0x4) {
SIVALS(hbin->data, rel_offset, -needed_size);
- SIVALS(hbin->data, rel_offset + needed_size, needed_size-orig_size);
+ SIVALS(hbin->data, rel_offset + needed_size,
+ needed_size-orig_size);
hbin_free(data, orig_offset + needed_size);
}
return orig_offset;
@@ -357,7 +366,7 @@ static uint32_t hbin_store_resize(struct regf_data *data,
break;
my_size = IVALS(hbin->data, i);
-
+
if (my_size == 0x0) {
DEBUG(0, ("Invalid zero-length block! File is corrupt.\n"));
break;
@@ -367,7 +376,8 @@ static uint32_t hbin_store_resize(struct regf_data *data,
if (possible_size >= blob.length) {
SIVAL(hbin->data, rel_offset, -possible_size);
- memcpy(hbin->data + rel_offset + 0x4, blob.data, blob.length);
+ memcpy(hbin->data + rel_offset + 0x4,
+ blob.data, blob.length);
return orig_offset;
}
}
@@ -376,12 +386,13 @@ static uint32_t hbin_store_resize(struct regf_data *data,
return hbin_store(data, blob);
}
-static uint32_t hbin_store_tdr_resize (struct regf_data *regf, tdr_push_fn_t push_fn,
- uint32_t orig_offset, void *p)
+static uint32_t hbin_store_tdr_resize(struct regf_data *regf,
+ tdr_push_fn_t push_fn,
+ uint32_t orig_offset, void *p)
{
struct tdr_push *push = talloc_zero(regf, struct tdr_push);
uint32_t ret;
-
+
if (NT_STATUS_IS_ERR(push_fn(push, p))) {
DEBUG(0, ("Error during push\n"));
return -1;
@@ -394,13 +405,13 @@ static uint32_t hbin_store_tdr_resize (struct regf_data *regf, tdr_push_fn_t pus
return ret;
}
-static uint32_t regf_create_lh_hash(const char *name)
+static uint32_t regf_create_lh_hash(const char *name)
{
char *hash_name;
uint32_t ret = 0;
uint16_t i;
- hash_name = strupper_talloc(NULL, name);
+ hash_name = strupper_talloc(NULL, name);
for (i = 0; *(hash_name + i) != 0; i++) {
ret *= 37;
ret += *(hash_name + i);
@@ -409,14 +420,14 @@ static uint32_t regf_create_lh_hash(const char *name)
return ret;
}
-static WERROR regf_get_info (TALLOC_CTX *mem_ctx,
- const struct hive_key *key,
- const char **classname,
- uint32_t *num_subkeys,
- uint32_t *num_values,
- NTTIME *last_mod_time)
+static WERROR regf_get_info(TALLOC_CTX *mem_ctx,
+ const struct hive_key *key,
+ const char **classname,
+ uint32_t *num_subkeys,
+ uint32_t *num_values,
+ NTTIME *last_mod_time)
{
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)key;
if (num_subkeys != NULL)
@@ -427,22 +438,23 @@ static WERROR regf_get_info (TALLOC_CTX *mem_ctx,
if (classname != NULL) {
if (private_data->nk->clsname_offset != -1) {
- DATA_BLOB data = hbin_get(private_data->hive,
- private_data->nk->clsname_offset);
- *classname = talloc_strndup(mem_ctx,
- (char*)data.data, private_data->nk->clsname_length);
- } else
+ DATA_BLOB data = hbin_get(private_data->hive,
+ private_data->nk->clsname_offset);
+ *classname = talloc_strndup(mem_ctx,
+ (char*)data.data,
+ private_data->nk->clsname_length);
+ } else
*classname = NULL;
}
/* TODO: Last mod time */
-
+
return WERR_OK;
}
-static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx,
- struct regf_data *regf,
- uint32_t offset)
+static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx,
+ struct regf_data *regf,
+ uint32_t offset)
{
struct nk_block *nk;
struct regf_key_data *ret;
@@ -457,7 +469,8 @@ static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx,
ret->nk = nk;
- if (!hbin_get_tdr(regf, offset, nk, (tdr_pull_fn_t)tdr_pull_nk_block, nk)) {
+ if (!hbin_get_tdr(regf, offset, nk,
+ (tdr_pull_fn_t)tdr_pull_nk_block, nk)) {
DEBUG(0, ("Unable to find HBIN data for offset %d\n", offset));
return NULL;
}
@@ -472,11 +485,11 @@ static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx,
}
-static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
- int idx, const char **name,
- uint32_t *data_type, DATA_BLOB *data)
+static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
+ int idx, const char **name,
+ uint32_t *data_type, DATA_BLOB *data)
{
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)key;
struct vk_block *vk;
struct regf_data *regf = private_data->hive;
@@ -500,8 +513,9 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
vk = talloc(NULL, struct vk_block);
W_ERROR_HAVE_NO_MEMORY(vk);
-
- if (!hbin_get_tdr(regf, vk_offset, vk, (tdr_pull_fn_t)tdr_pull_vk_block, vk)) {
+
+ if (!hbin_get_tdr(regf, vk_offset, vk,
+ (tdr_pull_fn_t)tdr_pull_vk_block, vk)) {
DEBUG(0, ("Unable to get VK block at %d\n", vk_offset));
talloc_free(vk);
return WERR_GENERAL_FAILURE;
@@ -514,7 +528,7 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
if (data_type != NULL)
*data_type = vk->data_type;
- if (vk->data_length & 0x80000000) {
+ if (vk->data_length & 0x80000000) {
vk->data_length &=~0x80000000;
data->data = (uint8_t *)&vk->data_offset;
data->length = vk->data_length;
@@ -527,13 +541,13 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
}
talloc_free(vk);
-
+
return WERR_OK;
}
-static WERROR regf_get_value_by_name (TALLOC_CTX *mem_ctx,
- struct hive_key *key, const char *name,
- uint32_t *type, DATA_BLOB *data)
+static WERROR regf_get_value_by_name(TALLOC_CTX *mem_ctx,
+ struct hive_key *key, const char *name,
+ uint32_t *type, DATA_BLOB *data)
{
int i;
const char *vname;
@@ -541,24 +555,25 @@ static WERROR regf_get_value_by_name (TALLOC_CTX *mem_ctx,
/* FIXME: Do binary search? Is this list sorted at all? */
- for (i = 0; W_ERROR_IS_OK(error = regf_get_value(mem_ctx, key, i,
- &vname, type, data)); i++) {
+ for (i = 0; W_ERROR_IS_OK(error = regf_get_value(mem_ctx, key, i,
+ &vname, type, data));
+ i++) {
if (!strcmp(vname, name))
return WERR_OK;
- }
+ }
if (W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS))
return WERR_NOT_FOUND;
return error;
}
-
-static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
- const struct hive_key *key,
- uint32_t idx, const char **name,
- const char **classname,
- NTTIME *last_mod_time)
+
+static WERROR regf_get_subkey_by_index(TALLOC_CTX *ctx,
+ const struct hive_key *key,
+ uint32_t idx, const char **name,
+ const char **classname,
+ NTTIME *last_mod_time)
{
DATA_BLOB data;
struct regf_key_data *ret;
@@ -594,7 +609,7 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
return WERR_GENERAL_FAILURE;
}
key_off = li.nk_offset[idx];
-
+
} else if (!strncmp((char *)data.data, "lf", 2)) {
struct lf_block lf;
struct tdr_pull pull;
@@ -618,17 +633,17 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
} else if (!strncmp((char *)data.data, "lh", 2)) {
struct lh_block lh;
struct tdr_pull pull;
-
+
DEBUG(10, ("Subkeys in LH list\n"));
ZERO_STRUCT(pull);
pull.data = data;
-
+
if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
DEBUG(0, ("Error parsing LH list\n"));
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(lh.header, "lh", 2));
-
+
if (lh.key_count != nk->num_subkeys) {
DEBUG(0, ("Subkey counts don't match\n"));
return WERR_GENERAL_FAILURE;
@@ -639,41 +654,43 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
struct tdr_pull pull;
uint16_t i;
uint16_t sublist_count = 0;
-
+
DEBUG(10, ("Subkeys in RI list\n"));
ZERO_STRUCT(pull);
pull.data = data;
-
+
if (NT_STATUS_IS_ERR(tdr_pull_ri_block(&pull, nk, &ri))) {
DEBUG(0, ("Error parsing RI list\n"));
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(ri.header, "ri", 2));
-
+
for (i = 0; i < ri.key_count; i++) {
DATA_BLOB list_data;
-
+
/* Get sublist data blob */
list_data = hbin_get(private_data->hive, ri.offset[i]);
if (!list_data.data) {
DEBUG(0, ("Error getting RI list."));
return WERR_GENERAL_FAILURE;
}
-
+
ZERO_STRUCT(pull);
pull.data = list_data;
-
+
if (!strncmp((char *)list_data.data, "li", 2)) {
struct li_block li;
DEBUG(10, ("Subkeys in RI->LI list\n"));
- if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, nk, &li))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull,
+ nk,
+ &li))) {
DEBUG(0, ("Error parsing LI list from RI\n"));
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(li.header, "li", 2));
-
+
/* Advance to next sublist if necessary */
if (idx >= sublist_count + li.key_count) {
sublist_count += li.key_count;
@@ -684,10 +701,12 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
break;
} else if (!strncmp((char *)list_data.data, "lh", 2)) {
struct lh_block lh;
-
+
DEBUG(10, ("Subkeys in RI->LH list\n"));
- if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull,
+ nk,
+ &lh))) {
DEBUG(0, ("Error parsing LH list from RI\n"));
return WERR_GENERAL_FAILURE;
}
@@ -706,15 +725,15 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
return WERR_GENERAL_FAILURE;
}
-
+
}
-
+
if (idx > sublist_count) {
return WERR_NO_MORE_ITEMS;
}
} else {
- DEBUG(0, ("Unknown type for subkey list (0x%04x): %c%c\n",
+ DEBUG(0, ("Unknown type for subkey list (0x%04x): %c%c\n",
nk->subkeys_offset, data.data[0], data.data[1]));
return WERR_GENERAL_FAILURE;
}
@@ -723,11 +742,12 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
if (classname != NULL) {
if (ret->nk->clsname_offset != -1) {
- DATA_BLOB db = hbin_get(ret->hive,
- ret->nk->clsname_offset);
- *classname = talloc_strndup(ctx,
- (char*)db.data, ret->nk->clsname_length);
- } else
+ DATA_BLOB db = hbin_get(ret->hive,
+ ret->nk->clsname_offset);
+ *classname = talloc_strndup(ctx,
+ (char*)db.data,
+ ret->nk->clsname_length);
+ } else
*classname = NULL;
}
@@ -742,16 +762,17 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
return WERR_OK;
}
-static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx,
- const struct hive_key *key, uint32_t offset,
- const char *name, uint32_t *ret)
+static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx,
+ const struct hive_key *key,
+ uint32_t offset,
+ const char *name, uint32_t *ret)
{
DATA_BLOB subkey_data;
struct nk_block subkey;
struct tdr_pull pull;
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)key;
-
+
subkey_data = hbin_get(private_data->hive, offset);
if (!subkey_data.data) {
DEBUG(0, ("Unable to retrieve subkey HBIN\n"));
@@ -760,7 +781,7 @@ static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx,
ZERO_STRUCT(pull);
pull.data = subkey_data;
-
+
if (NT_STATUS_IS_ERR(tdr_pull_nk_block(&pull, ctx, &subkey))) {
DEBUG(0, ("Error parsing NK structure.\n"));
return WERR_GENERAL_FAILURE;
@@ -778,14 +799,14 @@ static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx,
}
return WERR_OK;
}
-
-static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
- const struct hive_key *key,
- const char *name,
- struct hive_key **ret)
+
+static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
+ const struct hive_key *key,
+ const char *name,
+ struct hive_key **ret)
{
DATA_BLOB data;
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)key;
struct nk_block *nk = private_data->nk;
uint32_t key_off = 0;
@@ -804,7 +825,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
DEBUG(10, ("Subkeys in LI list\n"));
ZERO_STRUCT(pull);
pull.data = data;
-
+
if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, nk, &li))) {
DEBUG(0, ("Error parsing LI list\n"));
return WERR_GENERAL_FAILURE;
@@ -815,9 +836,12 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
DEBUG(0, ("Subkey counts don't match\n"));
return WERR_GENERAL_FAILURE;
}
-
+
for (i = 0; i < li.key_count; i++) {
- W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key, li.nk_offset[i], name, &key_off));
+ W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key,
+ li.nk_offset[i],
+ name,
+ &key_off));
if (key_off != 0)
break;
}
@@ -831,7 +855,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
DEBUG(10, ("Subkeys in LF list\n"));
ZERO_STRUCT(pull);
pull.data = data;
-
+
if (NT_STATUS_IS_ERR(tdr_pull_lf_block(&pull, nk, &lf))) {
DEBUG(0, ("Error parsing LF list\n"));
return WERR_GENERAL_FAILURE;
@@ -842,12 +866,16 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
DEBUG(0, ("Subkey counts don't match\n"));
return WERR_GENERAL_FAILURE;
}
-
+
for (i = 0; i < lf.key_count; i++) {
if (strncmp(lf.hr[i].hash, name, 4)) {
continue;
}
- W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key, lf.hr[i].nk_offset, name, &key_off));
+ W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk,
+ key,
+ lf.hr[i].nk_offset,
+ name,
+ &key_off));
if (key_off != 0)
break;
}
@@ -862,7 +890,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
DEBUG(10, ("Subkeys in LH list\n"));
ZERO_STRUCT(pull);
pull.data = data;
-
+
if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
DEBUG(0, ("Error parsing LH list\n"));
return WERR_GENERAL_FAILURE;
@@ -873,16 +901,20 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
DEBUG(0, ("Subkey counts don't match\n"));
return WERR_GENERAL_FAILURE;
}
-
+
hash = regf_create_lh_hash(name);
for (i = 0; i < lh.key_count; i++) {
if (lh.hr[i].base37 != hash) {
continue;
}
- W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key, lh.hr[i].nk_offset, name, &key_off));
+ W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk,
+ key,
+ lh.hr[i].nk_offset,
+ name,
+ &key_off));
if (key_off != 0)
break;
- }
+ }
if (key_off == 0)
return WERR_NOT_FOUND;
} else if (!strncmp((char *)data.data, "ri", 2)) {
@@ -893,46 +925,52 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
DEBUG(10, ("Subkeys in RI list\n"));
ZERO_STRUCT(pull);
pull.data = data;
-
+
if (NT_STATUS_IS_ERR(tdr_pull_ri_block(&pull, nk, &ri))) {
DEBUG(0, ("Error parsing RI list\n"));
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(ri.header, "ri", 2));
-
+
for (i = 0; i < ri.key_count; i++) {
DATA_BLOB list_data;
-
+
/* Get sublist data blob */
list_data = hbin_get(private_data->hive, ri.offset[i]);
if (list_data.data == NULL) {
DEBUG(0, ("Error getting RI list."));
return WERR_GENERAL_FAILURE;
}
-
+
ZERO_STRUCT(pull);
pull.data = list_data;
-
+
if (!strncmp((char *)list_data.data, "li", 2)) {
struct li_block li;
-
- if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, nk, &li))) {
+
+ if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull,
+ nk,
+ &li))) {
DEBUG(0, ("Error parsing LI list from RI\n"));
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(li.header, "li", 2));
-
+
for (j = 0; j < li.key_count; j++) {
- W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key,
- li.nk_offset[j], name, &key_off));
+ W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key,
+ li.nk_offset[j],
+ name,
+ &key_off));
if (key_off)
break;
}
} else if (!strncmp((char *)list_data.data, "lh", 2)) {
struct lh_block lh;
uint32_t hash;
-
- if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
+
+ if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull,
+ nk,
+ &lh))) {
DEBUG(0, ("Error parsing LH list from RI\n"));
return WERR_GENERAL_FAILURE;
}
@@ -943,8 +981,10 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
if (lh.hr[j].base37 != hash) {
continue;
}
- W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key,
- lh.hr[j].nk_offset, name, &key_off));
+ W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key,
+ lh.hr[j].nk_offset,
+ name,
+ &key_off));
if (key_off)
break;
}
@@ -959,14 +999,15 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
return WERR_GENERAL_FAILURE;
}
- *ret = (struct hive_key *)regf_get_key (ctx, private_data->hive, key_off);
+ *ret = (struct hive_key *)regf_get_key(ctx, private_data->hive,
+ key_off);
return WERR_OK;
}
-static WERROR regf_set_sec_desc (struct hive_key *key,
- const struct security_descriptor *sec_desc)
+static WERROR regf_set_sec_desc(struct hive_key *key,
+ const struct security_descriptor *sec_desc)
{
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)key;
struct sk_block cur_sk, sk, new_sk;
struct regf_data *regf = private_data->hive;
@@ -976,47 +1017,51 @@ static WERROR regf_set_sec_desc (struct hive_key *key,
bool update_cur_sk = false;
/* Get the root nk */
- hbin_get_tdr(regf, regf->header->data_offset, regf,
- (tdr_pull_fn_t) tdr_pull_nk_block, &root);
+ hbin_get_tdr(regf, regf->header->data_offset, regf,
+ (tdr_pull_fn_t) tdr_pull_nk_block, &root);
/* Push the security descriptor to a blob */
- if (NT_STATUS_IS_ERR(ndr_push_struct_blob(&data, regf, sec_desc,
- (ndr_push_flags_fn_t)ndr_push_security_descriptor))) {
+ if (NT_STATUS_IS_ERR(ndr_push_struct_blob(&data, regf, sec_desc,
+ (ndr_push_flags_fn_t)ndr_push_security_descriptor))) {
DEBUG(0, ("Unable to push security descriptor\n"));
return WERR_GENERAL_FAILURE;
}
- /* Get the current security descriptor for the key */
- if (!hbin_get_tdr(regf, private_data->nk->sk_offset, regf,
- (tdr_pull_fn_t) tdr_pull_sk_block, &cur_sk)) {
+ /* Get the current security descriptor for the key */
+ if (!hbin_get_tdr(regf, private_data->nk->sk_offset, regf,
+ (tdr_pull_fn_t) tdr_pull_sk_block, &cur_sk)) {
DEBUG(0, ("Unable to find security descriptor for current key\n"));
return WERR_BADFILE;
}
/* If there's no change, change nothing. */
- if (memcmp(data.data, cur_sk.sec_desc, MIN(data.length, cur_sk.rec_size)) == 0) {
+ if (memcmp(data.data, cur_sk.sec_desc,
+ MIN(data.length, cur_sk.rec_size)) == 0) {
return WERR_OK;
}
- /* Delete the current sk if only this key is using it */
+ /* Delete the current sk if only this key is using it */
if (cur_sk.ref_cnt == 1) {
- /* Get the previous security descriptor for the key */
- if (!hbin_get_tdr(regf, cur_sk.prev_offset, regf,
- (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+ /* Get the previous security descriptor for the key */
+ if (!hbin_get_tdr(regf, cur_sk.prev_offset, regf,
+ (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
DEBUG(0, ("Unable to find prev security descriptor for current key\n"));
return WERR_BADFILE;
}
/* Change and store the previous security descriptor */
sk.next_offset = cur_sk.next_offset;
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, cur_sk.prev_offset, &sk);
-
- /* Get the next security descriptor for the key */
- if (!hbin_get_tdr(regf, cur_sk.next_offset, regf, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+ hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block,
+ cur_sk.prev_offset, &sk);
+
+ /* Get the next security descriptor for the key */
+ if (!hbin_get_tdr(regf, cur_sk.next_offset, regf,
+ (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
DEBUG(0, ("Unable to find next security descriptor for current key\n"));
return WERR_BADFILE;
}
/* Change and store the next security descriptor */
sk.prev_offset = cur_sk.prev_offset;
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, cur_sk.next_offset, &sk);
+ hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block,
+ cur_sk.next_offset, &sk);
hbin_free(regf, private_data->nk->sk_offset);
} else {
@@ -1029,20 +1074,26 @@ static WERROR regf_set_sec_desc (struct hive_key *key,
do {
cur_sk_offset = sk_offset;
- if (!hbin_get_tdr(regf, sk_offset, regf, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+ if (!hbin_get_tdr(regf, sk_offset, regf,
+ (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
DEBUG(0, ("Unable to find security descriptor\n"));
return WERR_BADFILE;
}
if (memcmp(data.data, sk.sec_desc, MIN(data.length, sk.rec_size)) == 0) {
private_data->nk->sk_offset = sk_offset;
sk.ref_cnt++;
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, sk_offset, &sk);
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block, private_data->offset, private_data->nk);
+ hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_sk_block,
+ sk_offset, &sk);
+ hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_nk_block,
+ private_data->offset,
+ private_data->nk);
return WERR_OK;
}
sk_offset = sk.next_offset;
} while (sk_offset != root.sk_offset);
-
+
ZERO_STRUCT(new_sk);
new_sk.header = "sk";
new_sk.prev_offset = cur_sk_offset;
@@ -1050,8 +1101,10 @@ static WERROR regf_set_sec_desc (struct hive_key *key,
new_sk.ref_cnt = 1;
new_sk.rec_size = data.length;
new_sk.sec_desc = data.data;
-
- sk_offset = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_sk_block, &new_sk);
+
+ sk_offset = hbin_store_tdr(regf,
+ (tdr_push_fn_t) tdr_push_sk_block,
+ &new_sk);
if (sk_offset == -1) {
DEBUG(0, ("Error storing sk block\n"));
return WERR_GENERAL_FAILURE;
@@ -1059,47 +1112,58 @@ static WERROR regf_set_sec_desc (struct hive_key *key,
private_data->nk->sk_offset = sk_offset;
if (update_cur_sk) {
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, private_data->nk->sk_offset, &cur_sk);
+ hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_sk_block,
+ private_data->nk->sk_offset, &cur_sk);
}
- /* Get the previous security descriptor for the key */
- if (!hbin_get_tdr(regf, new_sk.prev_offset, regf, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+ /* Get the previous security descriptor for the key */
+ if (!hbin_get_tdr(regf, new_sk.prev_offset, regf,
+ (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
DEBUG(0, ("Unable to find security descriptor for previous key\n"));
return WERR_BADFILE;
}
/* Change and store the previous security descriptor */
sk.next_offset = sk_offset;
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, cur_sk.prev_offset, &sk);
-
- /* Get the next security descriptor for the key (always root, as we append) */
- if (!hbin_get_tdr(regf, new_sk.next_offset, regf, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+ hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_sk_block,
+ cur_sk.prev_offset, &sk);
+
+ /* Get the next security descriptor for the key (always root, as we append) */
+ if (!hbin_get_tdr(regf, new_sk.next_offset, regf,
+ (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
DEBUG(0, ("Unable to find security descriptor for current key\n"));
return WERR_BADFILE;
}
/* Change and store the next security descriptor (always root, as we append) */
sk.prev_offset = sk_offset;
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, root.sk_offset, &sk);
+ hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_sk_block,
+ root.sk_offset, &sk);
/* Store the nk. */
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, private_data->offset, private_data->nk);
+ hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_sk_block,
+ private_data->offset, private_data->nk);
return WERR_OK;
}
-static WERROR regf_get_sec_desc(TALLOC_CTX *ctx, const struct hive_key *key,
- struct security_descriptor **sd)
+static WERROR regf_get_sec_desc(TALLOC_CTX *ctx, const struct hive_key *key,
+ struct security_descriptor **sd)
{
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)key;
struct sk_block sk;
struct regf_data *regf = private_data->hive;
DATA_BLOB data;
- if (!hbin_get_tdr(regf, private_data->nk->sk_offset, ctx, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+ if (!hbin_get_tdr(regf, private_data->nk->sk_offset, ctx,
+ (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
DEBUG(0, ("Unable to find security descriptor\n"));
return WERR_GENERAL_FAILURE;
}
-
+
if (strcmp(sk.header, "sk") != 0) {
DEBUG(0, ("Expected 'sk', got '%s'\n", sk.header));
return WERR_GENERAL_FAILURE;
@@ -1110,7 +1174,8 @@ static WERROR regf_get_sec_desc(TALLOC_CTX *ctx, const struct hive_key *key,
data.data = sk.sec_desc;
data.length = sk.rec_size;
- if (NT_STATUS_IS_ERR(ndr_pull_struct_blob(&data, ctx, *sd, (ndr_pull_flags_fn_t)ndr_pull_security_descriptor))) {
+ if (NT_STATUS_IS_ERR(ndr_pull_struct_blob(&data, ctx, *sd,
+ (ndr_pull_flags_fn_t)ndr_pull_security_descriptor))) {
DEBUG(0, ("Error parsing security descriptor\n"));
return WERR_GENERAL_FAILURE;
}
@@ -1118,45 +1183,51 @@ static WERROR regf_get_sec_desc(TALLOC_CTX *ctx, const struct hive_key *key,
return WERR_OK;
}
-static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
- const char *name, uint32_t key_offset, uint32_t *ret)
+static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
+ const char *name,
+ uint32_t key_offset, uint32_t *ret)
{
DATA_BLOB data;
/* Create a new key if necessary */
- if (list_offset == -1) {
+ if (list_offset == -1) {
if (regf->header->version.major != 1) {
DEBUG(0, ("Can't store keys in unknown registry format\n"));
return WERR_NOT_SUPPORTED;
}
- if (regf->header->version.minor < 3) {
+ if (regf->header->version.minor < 3) {
/* Store LI */
struct li_block li;
ZERO_STRUCT(li);
li.header = "li";
- li.key_count = 1;
+ li.key_count = 1;
li.nk_offset = talloc_array(regf, uint32_t, 1);
W_ERROR_HAVE_NO_MEMORY(li.nk_offset);
li.nk_offset[0] = key_offset;
- *ret = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_li_block, &li);
+ *ret = hbin_store_tdr(regf,
+ (tdr_push_fn_t) tdr_push_li_block,
+ &li);
talloc_free(li.nk_offset);
- } else if (regf->header->version.minor == 3 || regf->header->version.minor == 4) {
+ } else if (regf->header->version.minor == 3 ||
+ regf->header->version.minor == 4) {
/* Store LF */
struct lf_block lf;
ZERO_STRUCT(lf);
lf.header = "lf";
lf.key_count = 1;
-
+
lf.hr = talloc_array(regf, struct hash_record, 1);
W_ERROR_HAVE_NO_MEMORY(lf.hr);
lf.hr[0].nk_offset = key_offset;
lf.hr[0].hash = talloc_strndup(lf.hr, name, 4);
W_ERROR_HAVE_NO_MEMORY(lf.hr[0].hash);
- *ret = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_lf_block, &lf);
+ *ret = hbin_store_tdr(regf,
+ (tdr_push_fn_t) tdr_push_lf_block,
+ &lf);
talloc_free(lf.hr);
} else if (regf->header->version.minor == 5) {
@@ -1165,19 +1236,21 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
ZERO_STRUCT(lh);
lh.header = "lh";
lh.key_count = 1;
-
+
lh.hr = talloc_array(regf, struct lh_hash, 1);
W_ERROR_HAVE_NO_MEMORY(lh.hr);
lh.hr[0].nk_offset = key_offset;
lh.hr[0].base37 = regf_create_lh_hash(name);
- *ret = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_lh_block, &lh);
+ *ret = hbin_store_tdr(regf,
+ (tdr_push_fn_t) tdr_push_lh_block,
+ &lh);
talloc_free(lh.hr);
}
return WERR_OK;
- }
-
+ }
+
data = hbin_get(regf, list_offset);
if (!data.data) {
DEBUG(0, ("Unable to find subkey list\n"));
@@ -1187,7 +1260,7 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
if (!strncmp((char *)data.data, "li", 2)) {
struct tdr_pull pull;
struct li_block li;
-
+
ZERO_STRUCT(pull);
pull.data = data;
@@ -1201,13 +1274,16 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
DEBUG(0, ("LI header corrupt\n"));
return WERR_BADFILE;
}
-
- li.nk_offset = talloc_realloc(regf, li.nk_offset, uint32_t, li.key_count+1);
+
+ li.nk_offset = talloc_realloc(regf, li.nk_offset,
+ uint32_t, li.key_count+1);
W_ERROR_HAVE_NO_MEMORY(li.nk_offset);
li.nk_offset[li.key_count] = key_offset;
li.key_count++;
- *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t)tdr_push_li_block, list_offset, &li);
-
+ *ret = hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t)tdr_push_li_block,
+ list_offset, &li);
+
talloc_free(li.nk_offset);
} else if (!strncmp((char *)data.data, "lf", 2)) {
struct tdr_pull pull;
@@ -1221,14 +1297,17 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
return WERR_BADFILE;
}
SMB_ASSERT(!strncmp(lf.header, "lf", 2));
-
- lf.hr = talloc_realloc(regf, lf.hr, struct hash_record, lf.key_count+1);
+
+ lf.hr = talloc_realloc(regf, lf.hr, struct hash_record,
+ lf.key_count+1);
W_ERROR_HAVE_NO_MEMORY(lf.hr);
lf.hr[lf.key_count].nk_offset = key_offset;
lf.hr[lf.key_count].hash = talloc_strndup(lf.hr, name, 4);
W_ERROR_HAVE_NO_MEMORY(lf.hr[lf.key_count].hash);
lf.key_count++;
- *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t)tdr_push_lf_block, list_offset, &lf);
+ *ret = hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t)tdr_push_lf_block,
+ list_offset, &lf);
talloc_free(lf.hr);
} else if (!strncmp((char *)data.data, "lh", 2)) {
@@ -1243,13 +1322,16 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
return WERR_BADFILE;
}
SMB_ASSERT(!strncmp(lh.header, "lh", 2));
-
- lh.hr = talloc_realloc(regf, lh.hr, struct lh_hash, lh.key_count+1);
+
+ lh.hr = talloc_realloc(regf, lh.hr, struct lh_hash,
+ lh.key_count+1);
W_ERROR_HAVE_NO_MEMORY(lh.hr);
lh.hr[lh.key_count].nk_offset = key_offset;
lh.hr[lh.key_count].base37 = regf_create_lh_hash(name);
lh.key_count++;
- *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t)tdr_push_lh_block, list_offset, &lh);
+ *ret = hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t)tdr_push_lh_block,
+ list_offset, &lh);
talloc_free(lh.hr);
} else if (!strncmp((char *)data.data, "ri", 2)) {
@@ -1260,12 +1342,12 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
DEBUG(0, ("Cannot add to unknown subkey list\n"));
return WERR_BADFILE;
}
-
+
return WERR_OK;
}
-static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
- uint32_t key_offset, uint32_t *ret)
+static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
+ uint32_t key_offset, uint32_t *ret)
{
DATA_BLOB data;
@@ -1280,17 +1362,17 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
struct tdr_pull pull;
uint16_t i;
bool found_offset = false;
-
+
DEBUG(10, ("Subkeys in LI list\n"));
-
+
ZERO_STRUCT(pull);
- pull.data = data;
-
+ pull.data = data;
+
if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, regf, &li))) {
DEBUG(0, ("Error parsing LI list\n"));
return WERR_BADFILE;
}
-
+
SMB_ASSERT(!strncmp(li.header, "li", 2));
for (i = 0; i < li.key_count; i++) {
@@ -1315,23 +1397,25 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
}
/* Store li block */
- *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_li_block, list_offset, &li);
+ *ret = hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_li_block,
+ list_offset, &li);
} else if (strncmp((char *)data.data, "lf", 2) == 0) {
struct lf_block lf;
struct tdr_pull pull;
uint16_t i;
bool found_offset = false;
-
+
DEBUG(10, ("Subkeys in LF list\n"));
-
+
ZERO_STRUCT(pull);
- pull.data = data;
-
+ pull.data = data;
+
if (NT_STATUS_IS_ERR(tdr_pull_lf_block(&pull, regf, &lf))) {
DEBUG(0, ("Error parsing LF list\n"));
return WERR_BADFILE;
}
-
+
SMB_ASSERT(!strncmp(lf.header, "lf", 2));
for (i = 0; i < lf.key_count; i++) {
@@ -1349,7 +1433,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
return WERR_NOT_FOUND;
}
lf.key_count--;
-
+
/* If the there are no entries left, free the subkey list */
if (lf.key_count == 0) {
hbin_free(regf, list_offset);
@@ -1358,23 +1442,25 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
}
/* Store lf block */
- *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_lf_block, list_offset, &lf);
+ *ret = hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_lf_block,
+ list_offset, &lf);
} else if (strncmp((char *)data.data, "lh", 2) == 0) {
struct lh_block lh;
struct tdr_pull pull;
uint16_t i;
bool found_offset = false;
-
+
DEBUG(10, ("Subkeys in LH list\n"));
-
+
ZERO_STRUCT(pull);
- pull.data = data;
-
+ pull.data = data;
+
if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, regf, &lh))) {
DEBUG(0, ("Error parsing LF list\n"));
return WERR_BADFILE;
}
-
+
SMB_ASSERT(!strncmp(lh.header, "lh", 2));
for (i = 0; i < lh.key_count; i++) {
@@ -1392,7 +1478,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
return WERR_NOT_FOUND;
}
lh.key_count--;
-
+
/* If the there are no entries left, free the subkey list */
if (lh.key_count == 0) {
hbin_free(regf, list_offset);
@@ -1401,7 +1487,9 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
}
/* Store lh block */
- *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_lh_block, list_offset, &lh);
+ *ret = hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_lh_block,
+ list_offset, &lh);
} else if (strncmp((char *)data.data, "ri", 2) == 0) {
/* FIXME */
DEBUG(0, ("Sorry, deletion from ri block is not supported yet.\n"));
@@ -1415,7 +1503,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
static WERROR regf_del_value (struct hive_key *key, const char *name)
{
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)key;
struct regf_data *regf = private_data->hive;
struct nk_block *nk = private_data->nk;
@@ -1436,11 +1524,13 @@ static WERROR regf_del_value (struct hive_key *key, const char *name)
((uint32_t *)values.data)[i-1] = ((uint32_t *) values.data)[i];
} else {
vk_offset = IVAL(values.data, i * 4);
- if (!hbin_get_tdr(regf, vk_offset, private_data,
- (tdr_pull_fn_t)tdr_pull_vk_block, &vk)) {
- DEBUG(0, ("Unable to get VK block at %d\n", vk_offset));
+ if (!hbin_get_tdr(regf, vk_offset, private_data,
+ (tdr_pull_fn_t)tdr_pull_vk_block,
+ &vk)) {
+ DEBUG(0, ("Unable to get VK block at %d\n",
+ vk_offset));
return WERR_BADFILE;
- }
+ }
if (strcmp(vk.data_name, name) == 0) {
hbin_free(regf, vk_offset);
found_offset = true;
@@ -1458,10 +1548,13 @@ static WERROR regf_del_value (struct hive_key *key, const char *name)
if (nk->num_values == 0) {
hbin_free(regf, nk->values_offset);
nk->values_offset = -1;
- } else {
- nk->values_offset = hbin_store_resize(regf, nk->values_offset, values);
+ } else {
+ nk->values_offset = hbin_store_resize(regf,
+ nk->values_offset,
+ values);
}
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block, private_data->offset, nk);
+ hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block,
+ private_data->offset, nk);
return regf_save_hbin(private_data->hive);
}
@@ -1469,14 +1562,14 @@ static WERROR regf_del_value (struct hive_key *key, const char *name)
static WERROR regf_del_key(const struct hive_key *parent, const char *name)
{
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)parent;
struct regf_key_data *key;
struct nk_block *parent_nk;
WERROR error;
SMB_ASSERT(private_data);
-
+
parent_nk = private_data->nk;
if (parent_nk->subkeys_offset == -1) {
@@ -1485,21 +1578,21 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name)
}
/* Find the key */
- if (!W_ERROR_IS_OK(regf_get_subkey_by_name(parent_nk, parent, name,
- (struct hive_key **)&key))) {
+ if (!W_ERROR_IS_OK(regf_get_subkey_by_name(parent_nk, parent, name,
+ (struct hive_key **)&key))) {
DEBUG(2, ("Key '%s' not found\n", name));
return WERR_NOT_FOUND;
}
-
- if (key->nk->subkeys_offset != -1 ||
+
+ if (key->nk->subkeys_offset != -1 ||
key->nk->values_offset != -1) {
DEBUG(0, ("Key '%s' is not empty.\n", name));
return WERR_FILE_EXISTS;
}
-
+
/* Delete it from the subkey list. */
- error = regf_sl_del_entry(private_data->hive, parent_nk->subkeys_offset,
- key->offset, &parent_nk->subkeys_offset);
+ error = regf_sl_del_entry(private_data->hive, parent_nk->subkeys_offset,
+ key->offset, &parent_nk->subkeys_offset);
if (!W_ERROR_IS_OK(error)) {
DEBUG(0, ("Can't store new subkey list for parent key. Won't delete.\n"));
return error;
@@ -1507,9 +1600,9 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name)
/* Re-store parent key */
parent_nk->num_subkeys--;
- hbin_store_tdr_resize(private_data->hive,
- (tdr_push_fn_t) tdr_push_nk_block,
- private_data->offset, parent_nk);
+ hbin_store_tdr_resize(private_data->hive,
+ (tdr_push_fn_t) tdr_push_nk_block,
+ private_data->offset, parent_nk);
if (key->nk->clsname_offset != -1) {
hbin_free(private_data->hive, key->nk->clsname_offset);
@@ -1519,12 +1612,12 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name)
return regf_save_hbin(private_data->hive);
}
-static WERROR regf_add_key(TALLOC_CTX *ctx, const struct hive_key *parent,
- const char *name, const char *classname,
- struct security_descriptor *sec_desc,
- struct hive_key **ret)
+static WERROR regf_add_key(TALLOC_CTX *ctx, const struct hive_key *parent,
+ const char *name, const char *classname,
+ struct security_descriptor *sec_desc,
+ struct hive_key **ret)
{
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)parent;
struct nk_block *parent_nk = private_data->nk, nk;
struct nk_block *root;
@@ -1547,32 +1640,33 @@ static WERROR regf_add_key(TALLOC_CTX *ctx, const struct hive_key *parent,
nk.clsname_offset = -1; /* FIXME: fill in */
nk.clsname_length = 0;
nk.key_name = name;
-
+
/* Get the security descriptor of the root key */
root = talloc_zero(ctx, struct nk_block);
W_ERROR_HAVE_NO_MEMORY(root);
- if (!hbin_get_tdr(regf, regf->header->data_offset, root,
- (tdr_pull_fn_t)tdr_pull_nk_block, root)) {
+ if (!hbin_get_tdr(regf, regf->header->data_offset, root,
+ (tdr_pull_fn_t)tdr_pull_nk_block, root)) {
DEBUG(0, ("Unable to find HBIN data for offset %d\n", offset));
return WERR_GENERAL_FAILURE;
}
nk.sk_offset = root->sk_offset;
talloc_free(root);
-
+
/* Store the new nk key */
offset = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_nk_block, &nk);
-
- error = regf_sl_add_entry(regf, parent_nk->subkeys_offset, name, offset, &parent_nk->subkeys_offset);
+
+ error = regf_sl_add_entry(regf, parent_nk->subkeys_offset, name, offset,
+ &parent_nk->subkeys_offset);
if (!W_ERROR_IS_OK(error)) {
hbin_free(regf, offset);
return error;
}
-
+
parent_nk->num_subkeys++;
/* Since the subkey offset of the parent can change, store it again */
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block,
+ hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block,
nk.parent_offset, parent_nk);
*ret = (struct hive_key *)regf_get_key(ctx, regf, offset);
@@ -1580,10 +1674,10 @@ static WERROR regf_add_key(TALLOC_CTX *ctx, const struct hive_key *parent,
return regf_save_hbin(private_data->hive);
}
-static WERROR regf_set_value(struct hive_key *key, const char *name,
- uint32_t type, const DATA_BLOB data)
+static WERROR regf_set_value(struct hive_key *key, const char *name,
+ uint32_t type, const DATA_BLOB data)
{
- const struct regf_key_data *private_data =
+ const struct regf_key_data *private_data =
(const struct regf_key_data *)key;
struct regf_data *regf = private_data->hive;
struct nk_block *nk = private_data->nk;
@@ -1600,9 +1694,11 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
for (i = 0; i < nk->num_values; i++) {
tmp_vk_offset = IVAL(values.data, i * 4);
- if (!hbin_get_tdr(regf, tmp_vk_offset, private_data,
- (tdr_pull_fn_t)tdr_pull_vk_block, &vk)) {
- DEBUG(0, ("Unable to get VK block at %d\n", tmp_vk_offset));
+ if (!hbin_get_tdr(regf, tmp_vk_offset, private_data,
+ (tdr_pull_fn_t)tdr_pull_vk_block,
+ &vk)) {
+ DEBUG(0, ("Unable to get VK block at %d\n",
+ tmp_vk_offset));
return WERR_GENERAL_FAILURE;
}
if (strcmp(vk.data_name, name) == 0) {
@@ -1612,7 +1708,7 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
}
/* Free data, if any */
if (!(vk.data_length & 0x80000000)) {
- hbin_free(regf, vk.data_offset);
+ hbin_free(regf, vk.data_offset);
}
}
if (old_vk_offset == -1) {
@@ -1638,15 +1734,21 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
}
if (old_vk_offset == -1) {
/* Store new vk */
- vk_offset = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_vk_block, &vk);
+ vk_offset = hbin_store_tdr(regf,
+ (tdr_push_fn_t) tdr_push_vk_block,
+ &vk);
} else {
/* Store vk at offset */
- vk_offset = hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_vk_block, old_vk_offset ,&vk);
+ vk_offset = hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_vk_block,
+ old_vk_offset ,&vk);
}
/* Re-allocate the value list */
if (nk->values_offset == -1) {
- nk->values_offset = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_uint32, &vk_offset);
+ nk->values_offset = hbin_store_tdr(regf,
+ (tdr_push_fn_t) tdr_push_uint32,
+ &vk_offset);
nk->num_values = 1;
} else {
@@ -1664,17 +1766,23 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
DATA_BLOB value_list;
value_list.length = (nk->num_values+1)*4;
- value_list.data = (void *)talloc_array(private_data, uint32_t, nk->num_values+1);
+ value_list.data = (uint8_t *)talloc_array(private_data,
+ uint32_t,
+ nk->num_values+1);
W_ERROR_HAVE_NO_MEMORY(value_list.data);
memcpy(value_list.data, values.data, nk->num_values * 4);
SIVAL(value_list.data, nk->num_values * 4, vk_offset);
nk->num_values++;
- nk->values_offset = hbin_store_resize(regf, nk->values_offset, value_list);
+ nk->values_offset = hbin_store_resize(regf,
+ nk->values_offset,
+ value_list);
}
-
+
}
- hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block, private_data->offset, nk);
+ hbin_store_tdr_resize(regf,
+ (tdr_push_fn_t) tdr_push_nk_block,
+ private_data->offset, nk);
return regf_save_hbin(private_data->hive);
}
@@ -1698,8 +1806,9 @@ static WERROR regf_save_hbin(struct regf_data *regf)
regf->header->chksum = regf_hdr_checksum(push->data.data);
talloc_free(push);
- if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
- (tdr_push_fn_t)tdr_push_regf_hdr, regf->header))) {
+ if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
+ (tdr_push_fn_t)tdr_push_regf_hdr,
+ regf->header))) {
DEBUG(0, ("Error writing registry file header\n"));
return WERR_GENERAL_FAILURE;
}
@@ -1707,13 +1816,13 @@ static WERROR regf_save_hbin(struct regf_data *regf)
if (lseek(regf->fd, 0x1000, SEEK_SET) == -1) {
DEBUG(0, ("Error lseeking to 0x1000 in regf file\n"));
return WERR_GENERAL_FAILURE;
- }
+ }
for (i = 0; regf->hbins[i]; i++) {
- if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
- (tdr_push_fn_t)tdr_push_hbin_block,
- regf->hbins[i]))) {
- DEBUG(0, ("Error writing HBIN block\n"));
+ if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
+ (tdr_push_fn_t)tdr_push_hbin_block,
+ regf->hbins[i]))) {
+ DEBUG(0, ("Error writing HBIN block\n"));
return WERR_GENERAL_FAILURE;
}
}
@@ -1721,8 +1830,8 @@ static WERROR regf_save_hbin(struct regf_data *regf)
return WERR_OK;
}
-WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
- int minor_version, struct hive_key **key)
+WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
+ int minor_version, struct hive_key **key)
{
struct regf_data *regf;
struct regf_hdr *regf_hdr;
@@ -1754,7 +1863,8 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
regf_hdr->version.major = 1;
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");
+ regf_hdr->description = talloc_strdup(regf_hdr,
+ "registry created by Samba 4");
W_ERROR_HAVE_NO_MEMORY(regf_hdr->description);
regf_hdr->chksum = 0;
@@ -1785,14 +1895,16 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
nk.clsname_offset = -1; /* FIXME: fill in */
nk.clsname_length = 0;
nk.key_name = "";
-
+
nk.sk_offset = -1; /* FIXME: fill in */
-
+
/* Store the new nk key */
- regf->header->data_offset = hbin_store_tdr(regf,
- (tdr_push_fn_t)tdr_push_nk_block, &nk);
-
- *key = (struct hive_key *)regf_get_key(parent_ctx, regf, regf->header->data_offset);
+ regf->header->data_offset = hbin_store_tdr(regf,
+ (tdr_push_fn_t)tdr_push_nk_block,
+ &nk);
+
+ *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);
@@ -1805,8 +1917,8 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
return WERR_OK;
}
-WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
- const char *location, struct hive_key **key)
+WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
+ const char *location, struct hive_key **key)
{
struct regf_data *regf;
struct regf_hdr *regf_hdr;
@@ -1850,7 +1962,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
if (strcmp(regf_hdr->REGF_ID, "regf") != 0) {
DEBUG(0, ("Unrecognized NT registry header id: %s, %s\n",
- regf_hdr->REGF_ID, location));
+ regf_hdr->REGF_ID, location));
talloc_free(regf);
return WERR_GENERAL_FAILURE;
}
@@ -1858,8 +1970,8 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
/* Validate the header ... */
if (regf_hdr_checksum(pull.data.data) != regf_hdr->chksum) {
DEBUG(0, ("Registry file checksum error: %s: %d,%d\n",
- location, regf_hdr->chksum,
- regf_hdr_checksum(pull.data.data)));
+ location, regf_hdr->chksum,
+ regf_hdr_checksum(pull.data.data)));
talloc_free(regf);
return WERR_GENERAL_FAILURE;
}
@@ -1873,8 +1985,10 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
regf->hbins[0] = NULL;
- while (pull.offset < pull.data.length && pull.offset <= regf->header->last_block) {
- struct hbin_block *hbin = talloc(regf->hbins, struct hbin_block);
+ while (pull.offset < pull.data.length &&
+ pull.offset <= regf->header->last_block) {
+ struct hbin_block *hbin = talloc(regf->hbins,
+ struct hbin_block);
W_ERROR_HAVE_NO_MEMORY(hbin);
@@ -1885,21 +1999,23 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
}
if (strcmp(hbin->HBIN_ID, "hbin") != 0) {
- DEBUG(0, ("[%d] Expected 'hbin', got '%s'\n", i, hbin->HBIN_ID));
+ DEBUG(0, ("[%d] Expected 'hbin', got '%s'\n",
+ i, hbin->HBIN_ID));
talloc_free(regf);
return WERR_FOOBAR;
}
regf->hbins[i] = hbin;
i++;
- regf->hbins = talloc_realloc(regf, regf->hbins, struct hbin_block *, i+2);
+ regf->hbins = talloc_realloc(regf, regf->hbins,
+ struct hbin_block *, i+2);
regf->hbins[i] = NULL;
- }
+ }
DEBUG(1, ("%d HBIN blocks read\n", i));
- *key = (struct hive_key *)regf_get_key(parent_ctx, regf,
- regf->header->data_offset);
+ *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);
diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h
index 1d92a9edab..c1159dde2e 100644
--- a/source4/lib/registry/registry.h
+++ b/source4/lib/registry/registry.h
@@ -1,42 +1,43 @@
-/*
+/*
Unix SMB/CIFS implementation.
Registry interface
Copyright (C) Gerald Carter 2002.
Copyright (C) Jelmer Vernooij 2003-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/>.
*/
#ifndef _REGISTRY_H /* _REGISTRY_H */
-#define _REGISTRY_H
+#define _REGISTRY_H
struct registry_context;
#include <talloc.h>
#include "librpc/gen_ndr/security.h"
#include "lib/registry/hive.h"
+#include "libcli/util/ntstatus.h"
/* Handles for the predefined keys */
-#define HKEY_CLASSES_ROOT 0x80000000
-#define HKEY_CURRENT_USER 0x80000001
-#define HKEY_LOCAL_MACHINE 0x80000002
-#define HKEY_USERS 0x80000003
-#define HKEY_PERFORMANCE_DATA 0x80000004
-#define HKEY_CURRENT_CONFIG 0x80000005
-#define HKEY_DYN_DATA 0x80000006
-#define HKEY_PERFORMANCE_TEXT 0x80000050
-#define HKEY_PERFORMANCE_NLSTEXT 0x80000060
+#define HKEY_CLASSES_ROOT 0x80000000
+#define HKEY_CURRENT_USER 0x80000001
+#define HKEY_LOCAL_MACHINE 0x80000002
+#define HKEY_USERS 0x80000003
+#define HKEY_PERFORMANCE_DATA 0x80000004
+#define HKEY_CURRENT_CONFIG 0x80000005
+#define HKEY_DYN_DATA 0x80000006
+#define HKEY_PERFORMANCE_TEXT 0x80000050
+#define HKEY_PERFORMANCE_NLSTEXT 0x80000060
#define HKEY_FIRST HKEY_CLASSES_ROOT
#define HKEY_LAST HKEY_PERFORMANCE_NLSTEXT
@@ -60,18 +61,18 @@ extern const struct reg_predefined_key reg_predefined_keys[];
struct reg_key_operations;
/* structure to store the registry handles */
-struct registry_key
+struct registry_key
{
struct registry_context *context;
};
#include "lib/registry/patchfile.h"
-struct registry_value
+struct registry_value
{
- const char *name;
- unsigned int data_type;
- DATA_BLOB data;
+ const char *name;
+ unsigned int data_type;
+ DATA_BLOB data;
};
/* FIXME */
@@ -85,77 +86,77 @@ struct registry_operations {
const char *name;
WERROR (*get_key_info) (TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- const char **classname,
- uint32_t *numsubkeys,
- uint32_t *numvalues,
- NTTIME *last_change_time);
+ const struct registry_key *key,
+ const char **classname,
+ uint32_t *numsubkeys,
+ uint32_t *numvalues,
+ NTTIME *last_change_time);
WERROR (*flush_key) (struct registry_key *key);
- WERROR (*get_predefined_key) (const struct registry_context *ctx,
- uint32_t key_id,
- struct registry_key **key);
+ WERROR (*get_predefined_key) (const struct registry_context *ctx,
+ uint32_t key_id,
+ struct registry_key **key);
WERROR (*open_key) (TALLOC_CTX *mem_ctx,
- struct registry_key *parent,
- const char *path,
- struct registry_key **key);
+ struct registry_key *parent,
+ const char *path,
+ struct registry_key **key);
- WERROR (*create_key) (TALLOC_CTX *mem_ctx,
- struct registry_key *parent,
- const char *name,
- const char *key_class,
- struct security_descriptor *security,
- struct registry_key **key);
+ WERROR (*create_key) (TALLOC_CTX *mem_ctx,
+ struct registry_key *parent,
+ const char *name,
+ const char *key_class,
+ struct security_descriptor *security,
+ struct registry_key **key);
WERROR (*delete_key) (struct registry_key *key, const char *name);
WERROR (*delete_value) (struct registry_key *key, const char *name);
WERROR (*enum_key) (TALLOC_CTX *mem_ctx,
- const struct registry_key *key, uint32_t idx,
- const char **name,
- const char **keyclass,
- NTTIME *last_changed_time);
+ const struct registry_key *key, uint32_t idx,
+ const char **name,
+ const char **keyclass,
+ NTTIME *last_changed_time);
WERROR (*enum_value) (TALLOC_CTX *mem_ctx,
- const struct registry_key *key, uint32_t idx,
- const char **name,
- uint32_t *type,
- DATA_BLOB *data);
+ const struct registry_key *key, uint32_t idx,
+ const char **name,
+ uint32_t *type,
+ DATA_BLOB *data);
WERROR (*get_security) (TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- struct security_descriptor **security);
+ const struct registry_key *key,
+ struct security_descriptor **security);
WERROR (*set_security) (struct registry_key *key,
- const struct security_descriptor *security);
+ const struct security_descriptor *security);
WERROR (*load_key) (struct registry_key *key,
- const char *key_name,
- const char *path);
+ const char *key_name,
+ const char *path);
WERROR (*unload_key) (struct registry_key *key, const char *name);
WERROR (*notify_value_change) (struct registry_key *key,
- reg_value_notification_function fn);
+ reg_value_notification_function fn);
WERROR (*get_value) (TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- const char *name,
- uint32_t *type,
- DATA_BLOB *data);
+ const struct registry_key *key,
+ const char *name,
+ uint32_t *type,
+ DATA_BLOB *data);
WERROR (*set_value) (struct registry_key *key,
- const char *name,
- uint32_t type,
- const DATA_BLOB data);
-};
+ const char *name,
+ uint32_t type,
+ const DATA_BLOB data);
+};
/**
* Handle to a full registry
- * contains zero or more hives
+ * contains zero or more hives
*/
struct registry_context {
const struct registry_operations *ops;
@@ -167,113 +168,118 @@ struct event_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);
+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_samba (TALLOC_CTX *mem_ctx,
- struct registry_context **ctx,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials);
+WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
+ struct registry_context **ctx,
+ struct auth_session_info *session_info,
+ struct cli_credentials *credentials);
/**
* Open the registry on a remote machine.
*/
-WERROR reg_open_remote(struct registry_context **ctx,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials,
- const char *location, struct event_context *ev);
+WERROR reg_open_remote(struct registry_context **ctx,
+ struct auth_session_info *session_info,
+ struct cli_credentials *credentials,
+ const char *location, struct event_context *ev);
WERROR reg_open_wine(struct registry_context **ctx, const char *path);
const char *reg_get_predef_name(uint32_t hkey);
-WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
- const char *name,
- struct registry_key **key);
-WERROR reg_get_predefined_key(const struct registry_context *ctx,
- uint32_t hkey,
- struct registry_key **key);
-
-WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent,
- const char *name, struct registry_key **result);
-
-WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx,
- const struct registry_key *key, uint32_t idx,
- const char **name,
- uint32_t *type,
- DATA_BLOB *data);
+WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
+ const char *name,
+ struct registry_key **key);
+WERROR reg_get_predefined_key(const struct registry_context *ctx,
+ uint32_t hkey,
+ struct registry_key **key);
+
+WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent,
+ const char *name, struct registry_key **result);
+
+WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key, uint32_t idx,
+ const char **name,
+ uint32_t *type,
+ DATA_BLOB *data);
WERROR reg_key_get_info(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- const char **class_name,
- uint32_t *num_subkeys,
- uint32_t *num_values,
- NTTIME *last_change_time);
-WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- int idx,
- const char **name,
- const char **classname,
- NTTIME *last_mod_time);
-WERROR reg_key_get_subkey_by_name(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- const char *name,
- struct registry_key **subkey);
-WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- const char *name,
- uint32_t *type,
- DATA_BLOB *data);
+ const struct registry_key *key,
+ const char **class_name,
+ uint32_t *num_subkeys,
+ uint32_t *num_values,
+ NTTIME *last_change_time);
+WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ int idx,
+ const char **name,
+ const char **classname,
+ NTTIME *last_mod_time);
+WERROR reg_key_get_subkey_by_name(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ const char *name,
+ struct registry_key **subkey);
+WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ const char *name,
+ uint32_t *type,
+ DATA_BLOB *data);
WERROR reg_key_del(struct registry_key *parent, const char *name);
-WERROR reg_key_add_name(TALLOC_CTX *mem_ctx,
- struct registry_key *parent, const char *name,
- const char *classname,
- struct security_descriptor *desc,
- struct registry_key **newkey);
-WERROR reg_val_set(struct registry_key *key, const char *value,
- uint32_t type, DATA_BLOB data);
-WERROR reg_get_sec_desc(TALLOC_CTX *ctx, const struct registry_key *key, struct security_descriptor **secdesc);
+WERROR reg_key_add_name(TALLOC_CTX *mem_ctx,
+ struct registry_key *parent, const char *name,
+ const char *classname,
+ struct security_descriptor *desc,
+ struct registry_key **newkey);
+WERROR reg_val_set(struct registry_key *key, const char *value,
+ uint32_t type, DATA_BLOB data);
+WERROR reg_get_sec_desc(TALLOC_CTX *ctx, const struct registry_key *key,
+ struct security_descriptor **secdesc);
WERROR reg_del_value(struct registry_key *key, const char *valname);
WERROR reg_key_flush(struct registry_key *key);
-WERROR reg_create_key (TALLOC_CTX *mem_ctx,
- struct registry_key *parent,
-
- const char *name,
- const char *key_class,
- struct security_descriptor *security,
- struct registry_key **key);
+WERROR reg_create_key(TALLOC_CTX *mem_ctx,
+ struct registry_key *parent,
+ const char *name,
+ const char *key_class,
+ struct security_descriptor *security,
+ struct registry_key **key);
/* Utility functions */
const char *str_regtype(int type);
-char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type,
- const DATA_BLOB data);
+char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type,
+ const DATA_BLOB data);
char *reg_val_description(TALLOC_CTX *mem_ctx, const char *name,
- uint32_t type, const DATA_BLOB data);
-bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *data_str, uint32_t *type, DATA_BLOB *data);
-WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle, const char *name, struct registry_key **result);
+ uint32_t type, const DATA_BLOB data);
+bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str,
+ const char *data_str, uint32_t *type, DATA_BLOB *data);
+WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle,
+ const char *name, struct registry_key **result);
WERROR reg_key_del_abs(struct registry_context *ctx, const char *path);
-WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx, const char *path, uint32_t access_mask, struct security_descriptor *sec_desc, struct registry_key **result);
-WERROR reg_load_key(struct registry_context *ctx, struct registry_key *key,
- const char *name, const char *filename);
-
-WERROR reg_mount_hive(struct registry_context *rctx,
- struct hive_key *hive_key,
- uint32_t key_id,
- const char **elements);
+WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx,
+ const char *path, uint32_t access_mask,
+ struct security_descriptor *sec_desc,
+ struct registry_key **result);
+WERROR reg_load_key(struct registry_context *ctx, struct registry_key *key,
+ const char *name, const char *filename);
+
+WERROR reg_mount_hive(struct registry_context *rctx,
+ struct hive_key *hive_key,
+ uint32_t key_id,
+ const char **elements);
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);
+ 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);
#endif /* _REGISTRY_H */
diff --git a/source4/lib/registry/rpc.c b/source4/lib/registry/rpc.c
index e4157fe424..c694223909 100644
--- a/source4/lib/registry/rpc.c
+++ b/source4/lib/registry/rpc.c
@@ -7,15 +7,15 @@
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 "registry.h"
#include "librpc/gen_ndr/ndr_winreg_c.h"
@@ -76,7 +76,8 @@ openhive(HKCC)
static struct {
uint32_t hkey;
- WERROR (*open) (struct dcerpc_pipe *p, TALLOC_CTX *, struct policy_handle *h);
+ WERROR (*open) (struct dcerpc_pipe *p, TALLOC_CTX *,
+ struct policy_handle *h);
} known_hives[] = {
{ HKEY_LOCAL_MACHINE, open_HKLM },
{ HKEY_CURRENT_USER, open_HKCU },
@@ -90,20 +91,20 @@ static struct {
static WERROR rpc_query_key(const struct registry_key *k);
-static WERROR rpc_get_predefined_key(const struct registry_context *ctx,
- uint32_t hkey_type,
- struct registry_key **k)
+static WERROR rpc_get_predefined_key(const struct registry_context *ctx,
+ uint32_t hkey_type,
+ struct registry_key **k)
{
int n;
- struct rpc_registry_context *rctx = talloc_get_type(ctx,
- struct rpc_registry_context);
+ struct rpc_registry_context *rctx = talloc_get_type(ctx,
+ struct rpc_registry_context);
struct rpc_key *mykeydata;
for(n = 0; known_hives[n].hkey; n++) {
- if(known_hives[n].hkey == hkey_type)
+ if(known_hives[n].hkey == hkey_type)
break;
}
-
+
if (known_hives[n].open == NULL) {
DEBUG(1, ("No such hive %d\n", hkey_type));
return WERR_NO_MORE_ITEMS;
@@ -119,7 +120,7 @@ static WERROR rpc_get_predefined_key(const struct registry_context *ctx,
#if 0
static WERROR rpc_key_put_rpc_data(TALLOC_CTX *mem_ctx, struct registry_key *k)
{
- struct winreg_OpenKey r;
+ struct winreg_OpenKey r;
struct rpc_key_data *mykeydata;
k->backend_data = mykeydata = talloc(mem_ctx, struct rpc_key_data);
@@ -129,46 +130,47 @@ static WERROR rpc_key_put_rpc_data(TALLOC_CTX *mem_ctx, struct registry_key *k)
/* Then, open the handle using the hive */
memset(&r, 0, sizeof(struct winreg_OpenKey));
- r.in.handle = &(((struct rpc_key_data *)k->hive->root->backend_data)->pol);
- init_winreg_String(&r.in.keyname, k->path);
- r.in.unknown = 0x00000000;
- r.in.access_mask = 0x02000000;
- r.out.handle = &mykeydata->pol;
+ r.in.handle = &(((struct rpc_key_data *)k->hive->root->backend_data)->pol);
+ init_winreg_String(&r.in.keyname, k->path);
+ r.in.unknown = 0x00000000;
+ r.in.access_mask = 0x02000000;
+ r.out.handle = &mykeydata->pol;
- dcerpc_winreg_OpenKey((struct dcerpc_pipe *)k->hive->backend_data, mem_ctx, &r);
+ dcerpc_winreg_OpenKey((struct dcerpc_pipe *)k->hive->backend_data,
+ mem_ctx, &r);
return r.out.result;
}
#endif
-static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h,
- const char *name, struct registry_key **key)
+static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h,
+ const char *name, struct registry_key **key)
{
struct rpc_key *mykeydata = talloc_get_type(h, struct rpc_key),
- *newkeydata;
- struct winreg_OpenKey r;
+ *newkeydata;
+ struct winreg_OpenKey r;
mykeydata = talloc(mem_ctx, struct rpc_key);
/* Then, open the handle using the hive */
memset(&r, 0, sizeof(struct winreg_OpenKey));
- r.in.parent_handle = &mykeydata->pol;
- init_winreg_String(&r.in.keyname, name);
- r.in.unknown = 0x00000000;
- r.in.access_mask = 0x02000000;
- r.out.handle = &newkeydata->pol;
+ r.in.parent_handle = &mykeydata->pol;
+ init_winreg_String(&r.in.keyname, name);
+ r.in.unknown = 0x00000000;
+ r.in.access_mask = 0x02000000;
+ r.out.handle = &newkeydata->pol;
- dcerpc_winreg_OpenKey(mykeydata->pipe, mem_ctx, &r);
+ dcerpc_winreg_OpenKey(mykeydata->pipe, mem_ctx, &r);
return r.out.result;
}
-static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx,
- const struct registry_key *parent,
- uint32_t n,
- const char **value_name,
- uint32_t *type,
- DATA_BLOB *data)
+static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx,
+ const struct registry_key *parent,
+ uint32_t n,
+ const char **value_name,
+ uint32_t *type,
+ DATA_BLOB *data)
{
struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
WERROR error;
@@ -177,14 +179,14 @@ static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx,
NTSTATUS status;
struct winreg_StringBuf name;
uint8_t u8;
-
+
if (mykeydata->num_values == -1) {
error = rpc_query_key(parent);
if(!W_ERROR_IS_OK(error)) return error;
}
len1 = mykeydata->max_valdatalen;
-
+
name.length = 0;
name.size = mykeydata->max_valnamelen * 2;
name.name = "";
@@ -197,29 +199,29 @@ static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx,
r.in.length = &zero;
r.in.size = &len1;
r.out.name = &name;
-
+
status = dcerpc_winreg_EnumValue(mykeydata->pipe, mem_ctx, &r);
if(NT_STATUS_IS_ERR(status)) {
DEBUG(0, ("Error in EnumValue: %s\n", nt_errstr(status)));
return WERR_GENERAL_FAILURE;
}
-
- if(NT_STATUS_IS_OK(status) &&
+
+ if(NT_STATUS_IS_OK(status) &&
W_ERROR_IS_OK(r.out.result) && r.out.length) {
*value_name = talloc_strdup(mem_ctx, r.out.name->name);
*data = data_blob_talloc(mem_ctx, r.out.value, *r.out.length);
return WERR_OK;
}
-
+
return r.out.result;
}
-static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx,
- const struct registry_key *parent,
- uint32_t n,
- const char **name,
- const char **keyclass,
- NTTIME *last_changed_time)
+static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx,
+ const struct registry_key *parent,
+ uint32_t n,
+ const char **name,
+ const char **keyclass,
+ NTTIME *last_changed_time)
{
struct winreg_EnumKey r;
struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
@@ -242,7 +244,7 @@ static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx,
r.out.name = &namebuf;
status = dcerpc_winreg_EnumKey(mykeydata->pipe, mem_ctx, &r);
- if(NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
+ if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
*name = talloc_strdup(mem_ctx, r.out.name->name);
*keyclass = talloc_strdup(mem_ctx, r.out.keyclass->name);
*last_changed_time = *r.out.last_changed_time;
@@ -251,11 +253,11 @@ static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx,
return r.out.result;
}
-static WERROR rpc_add_key(TALLOC_CTX *mem_ctx,
- struct registry_key *parent, const char *name,
- const char *key_class,
- struct security_descriptor *sec,
- struct registry_key **key)
+static WERROR rpc_add_key(TALLOC_CTX *mem_ctx,
+ struct registry_key *parent, const char *name,
+ const char *key_class,
+ struct security_descriptor *sec,
+ struct registry_key **key)
{
NTSTATUS status;
struct winreg_CreateKey r;
@@ -273,11 +275,11 @@ static WERROR rpc_add_key(TALLOC_CTX *mem_ctx,
status = dcerpc_winreg_CreateKey(parentkd->pipe, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!NT_STATUS_IS_OK(status)) {
talloc_free(rpck);
- DEBUG(1, ("CreateKey failed - %s\n", nt_errstr(status)));
- return ntstatus_to_werror(status);
- }
+ DEBUG(1, ("CreateKey failed - %s\n", nt_errstr(status)));
+ return ntstatus_to_werror(status);
+ }
if (W_ERROR_IS_OK(r.out.result)) {
rpck->pipe = talloc_reference(rpck, parentkd->pipe);
@@ -289,29 +291,29 @@ static WERROR rpc_add_key(TALLOC_CTX *mem_ctx,
static WERROR rpc_query_key(const struct registry_key *k)
{
- NTSTATUS status;
- struct winreg_QueryInfoKey r;
- struct rpc_key *mykeydata = talloc_get_type(k, struct rpc_key);
+ NTSTATUS status;
+ struct winreg_QueryInfoKey r;
+ struct rpc_key *mykeydata = talloc_get_type(k, struct rpc_key);
TALLOC_CTX *mem_ctx = talloc_init("query_key");
r.in.classname = talloc(mem_ctx, struct winreg_String);
- init_winreg_String(r.in.classname, NULL);
- r.in.handle = &mykeydata->pol;
-
- status = dcerpc_winreg_QueryInfoKey(mykeydata->pipe, mem_ctx, &r);
+ init_winreg_String(r.in.classname, NULL);
+ r.in.handle = &mykeydata->pol;
+
+ status = dcerpc_winreg_QueryInfoKey(mykeydata->pipe, mem_ctx, &r);
talloc_free(mem_ctx);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("QueryInfoKey failed - %s\n", nt_errstr(status)));
- return ntstatus_to_werror(status);
- }
-
- if (W_ERROR_IS_OK(r.out.result)) {
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("QueryInfoKey failed - %s\n", nt_errstr(status)));
+ return ntstatus_to_werror(status);
+ }
+
+ if (W_ERROR_IS_OK(r.out.result)) {
mykeydata->num_subkeys = *r.out.num_subkeys;
mykeydata->num_values = *r.out.num_values;
mykeydata->max_valnamelen = *r.out.max_valnamelen;
mykeydata->max_valdatalen = *r.out.max_valbufsize;
- }
+ }
return r.out.result;
}
@@ -322,11 +324,11 @@ static WERROR rpc_del_key(struct registry_key *parent, const char *name)
struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
struct winreg_DeleteKey r;
TALLOC_CTX *mem_ctx = talloc_init("del_key");
-
- r.in.handle = &mykeydata->pol;
- init_winreg_String(&r.in.key, name);
-
- status = dcerpc_winreg_DeleteKey(mykeydata->pipe, mem_ctx, &r);
+
+ r.in.handle = &mykeydata->pol;
+ init_winreg_String(&r.in.key, name);
+
+ status = dcerpc_winreg_DeleteKey(mykeydata->pipe, mem_ctx, &r);
talloc_free(mem_ctx);
@@ -334,19 +336,19 @@ static WERROR rpc_del_key(struct registry_key *parent, const char *name)
}
static WERROR rpc_get_info(TALLOC_CTX *mem_ctx, const struct registry_key *key,
- const char **classname,
+ const char **classname,
uint32_t *numsubkeys,
uint32_t *numvalue,
NTTIME *last_changed_time)
{
struct rpc_key *mykeydata = talloc_get_type(key, struct rpc_key);
WERROR error;
-
- if(mykeydata->num_values == -1) {
+
+ if (mykeydata->num_values == -1) {
error = rpc_query_key(key);
if(!W_ERROR_IS_OK(error)) return error;
}
-
+
/* FIXME: *classname = talloc_strdup(mem_ctx, mykeydata->classname); */
/* FIXME: *last_changed_time = mykeydata->last_changed_time */
@@ -370,10 +372,10 @@ static struct registry_operations reg_backend_rpc = {
.get_predefined_key = rpc_get_predefined_key,
};
-_PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials,
- const char *location, struct event_context *ev)
+_PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx,
+ struct auth_session_info *session_info,
+ struct cli_credentials *credentials,
+ const char *location, struct event_context *ev)
{
NTSTATUS status;
struct dcerpc_pipe *p;
@@ -388,14 +390,15 @@ _PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx,
location = talloc_strdup(ctx, "ncalrpc:");
}
- status = dcerpc_pipe_connect(*ctx /* TALLOC_CTX */,
- &p, location,
+ status = dcerpc_pipe_connect(*ctx /* TALLOC_CTX */,
+ &p, location,
&ndr_table_winreg,
credentials, ev);
rctx->pipe = p;
if(NT_STATUS_IS_ERR(status)) {
- DEBUG(1, ("Unable to open '%s': %s\n", location, nt_errstr(status)));
+ DEBUG(1, ("Unable to open '%s': %s\n", location,
+ nt_errstr(status)));
talloc_free(*ctx);
*ctx = NULL;
return ntstatus_to_werror(status);
diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c
index 6aaaa118d0..2397432f0b 100644
--- a/source4/lib/registry/samba.c
+++ b/source4/lib/registry/samba.c
@@ -1,4 +1,4 @@
-/*
+/*
Unix SMB/CIFS implementation.
Copyright (C) Jelmer Vernooij 2004-2007.
@@ -18,29 +18,32 @@
#include "includes.h"
#include "registry.h"
+#include "param/param.h"
/**
* @file
* @brief Samba-specific registry functions
*/
-WERROR mount_samba_hive(struct registry_context *ctx,
- struct auth_session_info *auth_info,
- struct cli_credentials *creds,
- const char *name,
- uint32_t hive_id)
+static WERROR mount_samba_hive(struct registry_context *ctx,
+ struct auth_session_info *auth_info,
+ struct cli_credentials *creds,
+ const char *name,
+ uint32_t hive_id)
{
WERROR error;
struct hive_key *hive;
const char *location;
- location = talloc_asprintf(ctx, "%s/%s.ldb", lp_private_dir(), name);
-
+ location = talloc_asprintf(ctx, "%s/%s.ldb",
+ lp_private_dir(global_loadparm),
+ name);
error = reg_open_hive(ctx, location, auth_info, creds, &hive);
if (W_ERROR_EQUAL(error, WERR_NOT_FOUND))
- error = reg_open_ldb_file(ctx, location, auth_info, creds, &hive);
+ error = reg_open_ldb_file(ctx, location, auth_info,
+ creds, &hive);
if (!W_ERROR_IS_OK(error))
return error;
@@ -49,10 +52,10 @@ WERROR mount_samba_hive(struct registry_context *ctx,
}
-_PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx,
- struct registry_context **ctx,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials)
+_PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
+ struct registry_context **ctx,
+ struct auth_session_info *session_info,
+ struct cli_credentials *credentials)
{
WERROR result;
@@ -61,19 +64,19 @@ _PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx,
return result;
}
- mount_samba_hive(*ctx, session_info, credentials,
- "hklm", HKEY_LOCAL_MACHINE);
+ mount_samba_hive(*ctx, session_info, credentials,
+ "hklm", HKEY_LOCAL_MACHINE);
- mount_samba_hive(*ctx, session_info, credentials,
- "hkcr", HKEY_CLASSES_ROOT);
+ mount_samba_hive(*ctx, session_info, credentials,
+ "hkcr", HKEY_CLASSES_ROOT);
- /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the
+ /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the
* current user */
- mount_samba_hive(*ctx, session_info, credentials,
- "hkcu", HKEY_CURRENT_USER);
+ mount_samba_hive(*ctx, session_info, credentials,
+ "hkcu", HKEY_CURRENT_USER);
- mount_samba_hive(*ctx, session_info, credentials,
- "hku", HKEY_USERS);
+ mount_samba_hive(*ctx, session_info, credentials,
+ "hku", HKEY_USERS);
/* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes
* and HKEY_CURRENT_USER\Software\Classes */
@@ -85,6 +88,6 @@ _PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx,
/* FIXME: HKEY_LOCAL_MACHINE\Hardware is autogenerated */
/* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */
-
+
return WERR_OK;
}
diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c
index a04bc1168e..dff6d1e829 100644
--- a/source4/lib/registry/tests/hive.c
+++ b/source4/lib/registry/tests/hive.c
@@ -27,13 +27,10 @@
#include "librpc/gen_ndr/winreg.h"
#include "system/filesys.h"
-NTSTATUS torture_temp_dir(struct torture_context *tctx, const char *prefix,
- const char **tempdir);
-
static bool test_del_nonexistant_key(struct torture_context *tctx,
- const void *test_data)
+ const void *test_data)
{
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
WERROR error = hive_key_del(root, "bla");
torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND,
"invalid return code");
@@ -45,7 +42,7 @@ static bool test_keyinfo_root(struct torture_context *tctx,
const void *test_data)
{
uint32_t num_subkeys, num_values;
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
WERROR error;
/* This is a new backend. There should be no subkeys and no
@@ -67,7 +64,7 @@ static bool test_keyinfo_nums(struct torture_context *tctx,
const void *test_data)
{
uint32_t num_subkeys, num_values;
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
WERROR error;
struct hive_key *subkey;
uint32_t data = 42;
@@ -100,7 +97,7 @@ static bool test_add_subkey(struct torture_context *tctx,
{
WERROR error;
struct hive_key *subkey;
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL,
@@ -114,9 +111,9 @@ static bool test_add_subkey(struct torture_context *tctx,
}
static bool test_flush_key(struct torture_context *tctx,
- const void *test_data)
+ const void *test_data)
{
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
torture_assert_werr_ok(tctx, hive_key_flush(root), "flush key");
@@ -127,7 +124,7 @@ static bool test_del_key(struct torture_context *tctx, const void *test_data)
{
WERROR error;
struct hive_key *subkey;
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL,
@@ -148,7 +145,7 @@ static bool test_set_value(struct torture_context *tctx,
{
WERROR error;
struct hive_key *subkey;
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
uint32_t data = 42;
@@ -167,7 +164,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
{
WERROR error;
struct hive_key *subkey;
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
uint32_t data = 42;
uint32_t type;
@@ -200,7 +197,7 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data)
{
WERROR error;
struct hive_key *subkey;
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
uint32_t data = 42;
uint32_t type;
@@ -231,7 +228,7 @@ static bool test_list_values(struct torture_context *tctx,
{
WERROR error;
struct hive_key *subkey;
- const struct hive_key *root = test_data;
+ const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
uint32_t data = 42;
uint32_t type;
diff --git a/source4/lib/registry/tests/registry.c b/source4/lib/registry/tests/registry.c
index fd2e98eac8..962c7fd2b5 100644
--- a/source4/lib/registry/tests/registry.c
+++ b/source4/lib/registry/tests/registry.c
@@ -28,16 +28,14 @@
#include "libcli/security/security.h"
#include "system/filesys.h"
-NTSTATUS torture_temp_dir(struct torture_context *tctx, const char *prefix,
- const char **tempdir);
-
/**
* Test obtaining a predefined key.
*/
static bool test_get_predefined(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root;
WERROR error;
@@ -66,7 +64,8 @@ static bool test_get_predefined_unknown(struct torture_context *tctx,
static bool test_predef_key_by_name(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root;
WERROR error;
@@ -84,7 +83,8 @@ static bool test_predef_key_by_name(struct torture_context *tctx,
static bool test_predef_key_by_name_invalid(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root;
WERROR error;
@@ -100,7 +100,8 @@ static bool test_predef_key_by_name_invalid(struct torture_context *tctx,
static bool test_create_subkey(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *newkey;
WERROR error;
@@ -121,7 +122,8 @@ static bool test_create_subkey(struct torture_context *tctx,
static bool test_create_nested_subkey(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *newkey1, *newkey2;
WERROR error;
@@ -132,7 +134,7 @@ static bool test_create_nested_subkey(struct torture_context *tctx,
error = reg_key_add_name(rctx, root, "Hamburg", NULL, NULL,
&newkey1);
torture_assert_werr_ok(tctx, error, "Creating key return code");
- torture_assert(tctx, newkey2 != NULL, "Creating new key");
+ torture_assert(tctx, newkey1 != NULL, "Creating new key");
error = reg_key_add_name(rctx, root, "Hamburg\\Hamburg", NULL, NULL,
&newkey2);
@@ -148,7 +150,8 @@ static bool test_create_nested_subkey(struct torture_context *tctx,
static bool test_key_add_abs_top(struct torture_context *tctx,
const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root;
WERROR error;
@@ -165,7 +168,8 @@ static bool test_key_add_abs(struct torture_context *tctx,
const void *_data)
{
WERROR error;
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *result1, *result2;
error = reg_key_add_abs(tctx, rctx, "HKEY_CLASSES_ROOT\\bloe", 0, NULL, &result1);
@@ -190,7 +194,8 @@ static bool test_key_add_abs(struct torture_context *tctx,
static bool test_del_key(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *newkey;
WERROR error;
@@ -238,7 +243,8 @@ static bool create_test_key(struct torture_context *tctx,
static bool test_flush_key(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *subkey;
WERROR error;
@@ -256,7 +262,8 @@ static bool test_flush_key(struct torture_context *tctx, const void *_data)
static bool test_query_key(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *subkey;
WERROR error;
NTTIME last_changed_time;
@@ -280,7 +287,8 @@ static bool test_query_key(struct torture_context *tctx, const void *_data)
static bool test_query_key_nums(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *root, *subkey1, *subkey2;
WERROR error;
uint32_t num_subkeys, num_values;
@@ -313,7 +321,8 @@ static bool test_query_key_nums(struct torture_context *tctx, const void *_data)
*/
static bool test_list_subkeys(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
NTTIME last_mod_time;
@@ -351,7 +360,8 @@ static bool test_list_subkeys(struct torture_context *tctx, const void *_data)
*/
static bool test_set_value(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
uint32_t data = 42;
@@ -371,10 +381,10 @@ static bool test_set_value(struct torture_context *tctx, const void *_data)
*/
static bool test_security(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
- uint32_t data = 42;
struct security_descriptor *osd, *nsd;
if (!create_test_key(tctx, rctx, "Düsseldorf", &root, &subkey))
@@ -405,7 +415,8 @@ static bool test_security(struct torture_context *tctx, const void *_data)
*/
static bool test_get_value(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
@@ -440,7 +451,8 @@ static bool test_get_value(struct torture_context *tctx, const void *_data)
*/
static bool test_del_value(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
@@ -474,7 +486,8 @@ static bool test_del_value(struct torture_context *tctx, const void *_data)
*/
static bool test_list_values(struct torture_context *tctx, const void *_data)
{
- const struct registry_context *rctx = _data;
+ const struct registry_context *rctx =
+ (const struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
@@ -511,26 +524,20 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
const char *tempdir;
NTSTATUS status;
struct hive_key *hive_key;
+ const char *filename;
error = reg_open_local(tctx, &rctx, NULL, NULL);
- if (!W_ERROR_IS_OK(error))
- return false;
+ torture_assert_werr_ok(tctx, error, "Opening local registry failed");
status = torture_temp_dir(tctx, "registry-local", &tempdir);
- if (!NT_STATUS_IS_OK(status))
- return false;
+ torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
- error = reg_open_ldb_file(tctx,
- talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir),
- NULL,
- NULL,
- &hive_key);
- if (!W_ERROR_IS_OK(error))
- return false;
+ filename = talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, &hive_key);
+ torture_assert_werr_ok(tctx, error, "Opening classes_root file failed");
error = reg_mount_hive(rctx, hive_key, HKEY_CLASSES_ROOT, NULL);
- if (!W_ERROR_IS_OK(error))
- return false;
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
*data = rctx;
@@ -540,13 +547,10 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
static void tcase_add_tests(struct torture_tcase *tcase)
{
torture_tcase_add_simple_test(tcase, "list_subkeys", test_list_subkeys);
- torture_tcase_add_simple_test(tcase, "get_predefined_key",
- test_get_predefined);
- torture_tcase_add_simple_test(tcase, "get_predefined_key",
- test_get_predefined_unknown);
+ torture_tcase_add_simple_test(tcase, "get_predefined_key", test_get_predefined);
+ torture_tcase_add_simple_test(tcase, "get_predefined_key", test_get_predefined_unknown);
torture_tcase_add_simple_test(tcase, "create_key", test_create_subkey);
- torture_tcase_add_simple_test(tcase, "create_key",
- test_create_nested_subkey);
+ torture_tcase_add_simple_test(tcase, "create_key", test_create_nested_subkey);
torture_tcase_add_simple_test(tcase, "key_add_abs", test_key_add_abs);
torture_tcase_add_simple_test(tcase, "key_add_abs_top", test_key_add_abs_top);
torture_tcase_add_simple_test(tcase, "set_value", test_set_value);
@@ -558,18 +562,16 @@ static void tcase_add_tests(struct torture_tcase *tcase)
torture_tcase_add_simple_test(tcase, "query_key", test_query_key);
torture_tcase_add_simple_test(tcase, "query_key_nums", test_query_key_nums);
torture_tcase_add_simple_test(tcase, "test_predef_key_by_name",
- test_predef_key_by_name);
- torture_tcase_add_simple_test(tcase, "security",
- test_security);
+ test_predef_key_by_name);
+ torture_tcase_add_simple_test(tcase, "security", test_security);
torture_tcase_add_simple_test(tcase, "test_predef_key_by_name_invalid",
- test_predef_key_by_name_invalid);
+ test_predef_key_by_name_invalid);
}
struct torture_suite *torture_registry_registry(TALLOC_CTX *mem_ctx)
{
struct torture_tcase *tcase;
- struct torture_suite *suite = torture_suite_create(mem_ctx,
- "REGISTRY");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "REGISTRY");
tcase = torture_suite_add_tcase(suite, "local");
torture_tcase_set_fixture(tcase, setup_local_registry, NULL);
diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c
index c8b0945c2c..aa11eccbee 100644
--- a/source4/lib/registry/tools/common.c
+++ b/source4/lib/registry/tools/common.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "auth/credentials/credentials.h"
#include "lib/registry/registry.h"
+#include "lib/registry/tools/common.h"
struct registry_context *reg_common_open_remote(const char *remote, struct cli_credentials *creds)
{
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 131d76fff5..cdf688b39e 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -262,8 +262,7 @@ static WERROR cmd_rmval(struct regshell_context *ctx, int argc, char **argv)
return WERR_OK;
}
-static WERROR cmd_exit(struct regshell_context *ctx,
- int argc, char **argv)
+_NORETURN_ static WERROR cmd_exit(struct regshell_context *ctx, int argc, char **argv)
{
exit(0);
return WERR_OK;
@@ -275,8 +274,7 @@ static struct {
const char *name;
const char *alias;
const char *help;
- WERROR (*handle)(struct regshell_context *ctx,
- int argc, char **argv);
+ WERROR (*handle)(struct regshell_context *ctx, int argc, char **argv);
} regshell_cmds[] = {
{"ck", "cd", "Change current key", cmd_ck },
{"info", "i", "Show detailed information of a key", cmd_info },
diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c
index 6afd1bc44c..ca3e3dd619 100644
--- a/source4/lib/registry/util.c
+++ b/source4/lib/registry/util.c
@@ -1,4 +1,4 @@
-/*
+/*
Unix SMB/CIFS implementation.
Transparent registry backend handling
Copyright (C) Jelmer Vernooij 2003-2007.
@@ -43,60 +43,59 @@ _PUBLIC_ const char *str_regtype(int type)
{
int i;
for (i = 0; reg_value_types[i].name; i++) {
- if (reg_value_types[i].id == type)
+ if (reg_value_types[i].id == type)
return reg_value_types[i].name;
}
return "Unknown";
}
-_PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type,
- const DATA_BLOB data)
-{
- char *ret = NULL;
-
- if (data.length == 0)
- return talloc_strdup(mem_ctx, "");
-
- switch (type) {
- case REG_EXPAND_SZ:
- case REG_SZ:
- convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, data.data, data.length,
- (void **)&ret);
- return ret;
-
- case REG_BINARY:
- ret = data_blob_hex_string(mem_ctx, &data);
- return ret;
-
- case REG_DWORD:
- if (*(int *)data.data == 0)
- return talloc_strdup(mem_ctx, "0");
-
- return talloc_asprintf(mem_ctx, "0x%x", *(int *)data.data);
+_PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type,
+ const DATA_BLOB data)
+{
+ char *ret = NULL;
- case REG_MULTI_SZ:
- /* FIXME */
- break;
+ if (data.length == 0)
+ return talloc_strdup(mem_ctx, "");
- default:
- break;
- }
+ switch (type) {
+ case REG_EXPAND_SZ:
+ case REG_SZ:
+ convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
+ data.data, data.length,
+ (void **)&ret);
+ return ret;
+ case REG_BINARY:
+ ret = data_blob_hex_string(mem_ctx, &data);
+ return ret;
+ case REG_DWORD:
+ if (*(int *)data.data == 0)
+ return talloc_strdup(mem_ctx, "0");
+ return talloc_asprintf(mem_ctx, "0x%x",
+ *(int *)data.data);
+ case REG_MULTI_SZ:
+ /* FIXME */
+ break;
+ default:
+ break;
+ }
- return ret;
+ return ret;
}
/** Generate a string that describes a registry value */
-_PUBLIC_ char *reg_val_description(TALLOC_CTX *mem_ctx, const char *name,
- uint32_t data_type,
- const DATA_BLOB data)
+_PUBLIC_ char *reg_val_description(TALLOC_CTX *mem_ctx, const char *name,
+ uint32_t data_type,
+ const DATA_BLOB data)
{
- return talloc_asprintf(mem_ctx, "%s = %s : %s", name?name:"<No Name>",
- str_regtype(data_type),
- reg_val_data_string(mem_ctx, data_type, data));
+ return talloc_asprintf(mem_ctx, "%s = %s : %s", name?name:"<No Name>",
+ str_regtype(data_type),
+ reg_val_data_string(mem_ctx, data_type, data));
}
-_PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *data_str, uint32_t *type, DATA_BLOB *data)
+_PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str,
+ const char *data_str, uint32_t *type,
+ DATA_BLOB *data)
{
int i;
*type = -1;
@@ -109,16 +108,18 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const
}
}
- if (*type == -1)
+ if (*type == -1)
return false;
/* Convert data appropriately */
- switch (*type)
+ switch (*type)
{
case REG_SZ:
case REG_EXPAND_SZ:
- data->length = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, data_str, strlen(data_str), (void **)&data->data);
+ data->length = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16,
+ data_str, strlen(data_str),
+ (void **)&data->data);
break;
case REG_DWORD: {
@@ -130,12 +131,12 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const
case REG_NONE:
ZERO_STRUCTP(data);
break;
-
- case REG_BINARY:
+
+ case REG_BINARY:
*data = strhex_to_data_blob(data_str);
talloc_steal(mem_ctx, data->data);
break;
-
+
default:
/* FIXME */
return false;
@@ -144,16 +145,17 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const
}
/** Open a key by name (including the predefined key name!) */
-WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle, const char *name, struct registry_key **result)
+WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle,
+ const char *name, struct registry_key **result)
{
struct registry_key *predef;
WERROR error;
int predeflength;
char *predefname;
- if (strchr(name, '\\') != NULL)
+ if (strchr(name, '\\') != NULL)
predeflength = strchr(name, '\\')-name;
- else
+ else
predeflength = strlen(name);
predefname = talloc_strndup(mem_ctx, name, predeflength);
@@ -165,31 +167,32 @@ WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle, co
}
if (strchr(name, '\\')) {
- return reg_open_key(mem_ctx, predef, strchr(name, '\\')+1, result);
+ return reg_open_key(mem_ctx, predef, strchr(name, '\\')+1,
+ result);
} else {
*result = predef;
return WERR_OK;
}
}
-static WERROR get_abs_parent(TALLOC_CTX *mem_ctx, struct registry_context *ctx,
- const char *path, struct registry_key **parent,
- const char **name)
+static WERROR get_abs_parent(TALLOC_CTX *mem_ctx, struct registry_context *ctx,
+ const char *path, struct registry_key **parent,
+ const char **name)
{
char *parent_name;
WERROR error;
-
+
if (strchr(path, '\\') == NULL) {
return WERR_FOOBAR;
}
-
+
parent_name = talloc_strndup(mem_ctx, path, strrchr(path, '\\')-path);
error = reg_open_key_abs(mem_ctx, ctx, parent_name, parent);
if (!W_ERROR_IS_OK(error)) {
return error;
}
-
+
*name = talloc_strdup(mem_ctx, strrchr(path, '\\')+1);
return WERR_OK;
@@ -201,11 +204,11 @@ WERROR reg_key_del_abs(struct registry_context *ctx, const char *path)
const char *n;
TALLOC_CTX *mem_ctx = talloc_init("reg_key_del_abs");
WERROR error;
-
+
if (!strchr(path, '\\')) {
return WERR_FOOBAR;
}
-
+
error = get_abs_parent(mem_ctx, ctx, path, &parent, &n);
if (W_ERROR_IS_OK(error)) {
error = reg_key_del(parent, n);
@@ -216,22 +219,22 @@ WERROR reg_key_del_abs(struct registry_context *ctx, const char *path)
return error;
}
-WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx,
- const char *path, uint32_t access_mask,
- struct security_descriptor *sec_desc,
- struct registry_key **result)
+WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx,
+ const char *path, uint32_t access_mask,
+ struct security_descriptor *sec_desc,
+ struct registry_key **result)
{
struct registry_key *parent;
const char *n;
WERROR error;
-
+
if (!strchr(path, '\\')) {
return WERR_ALREADY_EXISTS;
}
-
+
error = get_abs_parent(mem_ctx, ctx, path, &parent, &n);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(2, ("Opening parent of %s failed with %s\n", path,
+ DEBUG(2, ("Opening parent of %s failed with %s\n", path,
win_errstr(error)));
return error;
}
diff --git a/source4/lib/registry/wine.c b/source4/lib/registry/wine.c
index 2cb0b9955e..77d2ce66e9 100644
--- a/source4/lib/registry/wine.c
+++ b/source4/lib/registry/wine.c
@@ -1,18 +1,18 @@
-/*
+/*
Unix SMB/CIFS implementation.
Registry interface
Copyright (C) Jelmer Vernooij 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/>.
*/
@@ -29,7 +29,7 @@ static WERROR wine_open_reg (struct registry_hive *h, struct registry_key **key)
static REG_OPS reg_backend_wine = {
.name = "wine",
.open_hive = wine_open_reg,
-
+
};
NTSTATUS registry_wine_init(void)
diff --git a/source4/lib/replace/README b/source4/lib/replace/README
index 77558b2ca9..c61f78a951 100644
--- a/source4/lib/replace/README
+++ b/source4/lib/replace/README
@@ -50,10 +50,16 @@ pwrite
getpass
readline (the library)
inet_ntoa
+inet_ntop
+inet_pton
strtoll
strtoull
socketpair
strptime
+getaddrinfo
+freeaddrinfo
+getnameinfo
+gai_strerror
Types:
bool
diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac
index 48fb7ce259..beeb77e152 100644
--- a/source4/lib/replace/configure.ac
+++ b/source4/lib/replace/configure.ac
@@ -19,4 +19,6 @@ if test "$ac_cv_prog_gcc" = yes; then
CFLAGS="$CFLAGS -Wno-format-y2k"
fi
+AC_SUBST(LDFLAGS)
+
AC_OUTPUT(Makefile)
diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4
index a1b57d10ec..c5b7597d7a 100644
--- a/source4/lib/replace/dlfcn.m4
+++ b/source4/lib/replace/dlfcn.m4
@@ -12,7 +12,7 @@ AC_VERIFY_C_PROTOTYPE([void *dlopen(const char* filename, unsigned int flags)],
[
return 0;
],[
- AC_DEFINE(DLOPEN_TAKES_UNSIGNED_FLAGS, 1, [Whether dlopen takes unsinged int flags])
+ AC_DEFINE(DLOPEN_TAKES_UNSIGNED_FLAGS, 1, [Whether dlopen takes unsigned int flags])
],[],[
#include <dlfcn.h>
])
diff --git a/source4/lib/replace/getaddrinfo.c b/source4/lib/replace/getaddrinfo.c
new file mode 100644
index 0000000000..519c30066b
--- /dev/null
+++ b/source4/lib/replace/getaddrinfo.c
@@ -0,0 +1,502 @@
+/*
+PostgreSQL Database Management System
+(formerly known as Postgres, then as Postgres95)
+
+Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group
+
+Portions Copyright (c) 1994, The Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose, without fee, and without a written agreement
+is hereby granted, provided that the above copyright notice and this paragraph
+and the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
+LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
+EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
+TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+*/
+
+/*-------------------------------------------------------------------------
+ *
+ * getaddrinfo.c
+ * Support getaddrinfo() on platforms that don't have it.
+ *
+ * We also supply getnameinfo() here, assuming that the platform will have
+ * it if and only if it has getaddrinfo(). If this proves false on some
+ * platform, we'll need to split this file and provide a separate configure
+ * test for getnameinfo().
+ *
+ * Copyright (c) 2003-2007, PostgreSQL Global Development Group
+ *
+ * Copyright (C) 2007 Jeremy Allison.
+ * Modified to return multiple IPv4 addresses for Samba.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "replace.h"
+#include "system/network.h"
+
+#ifndef SMB_MALLOC
+#define SMB_MALLOC(s) malloc(s)
+#endif
+
+#ifndef SMB_STRDUP
+#define SMB_STRDUP(s) strdup(s)
+#endif
+
+static int check_hostent_err(struct hostent *hp)
+{
+ if (!hp) {
+ switch (h_errno) {
+ case HOST_NOT_FOUND:
+ case NO_DATA:
+ return EAI_NONAME;
+ case TRY_AGAIN:
+ return EAI_AGAIN;
+ case NO_RECOVERY:
+ default:
+ return EAI_FAIL;
+ }
+ }
+ if (!hp->h_name || hp->h_addrtype != AF_INET) {
+ return EAI_FAIL;
+ }
+ return 0;
+}
+
+static char *canon_name_from_hostent(struct hostent *hp,
+ int *perr)
+{
+ char *ret = NULL;
+
+ *perr = check_hostent_err(hp);
+ if (*perr) {
+ return NULL;
+ }
+ ret = SMB_STRDUP(hp->h_name);
+ if (!ret) {
+ *perr = EAI_MEMORY;
+ }
+ return ret;
+}
+
+static char *get_my_canon_name(int *perr)
+{
+ char name[HOST_NAME_MAX+1];
+
+ if (gethostname(name, HOST_NAME_MAX) == -1) {
+ *perr = EAI_FAIL;
+ return NULL;
+ }
+ /* Ensure null termination. */
+ name[HOST_NAME_MAX] = '\0';
+ return canon_name_from_hostent(gethostbyname(name), perr);
+}
+
+static char *get_canon_name_from_addr(struct in_addr ip,
+ int *perr)
+{
+ return canon_name_from_hostent(
+ gethostbyaddr(&ip, sizeof(ip), AF_INET),
+ perr);
+}
+
+static struct addrinfo *alloc_entry(const struct addrinfo *hints,
+ struct in_addr ip,
+ unsigned short port)
+{
+ struct sockaddr_in *psin = NULL;
+ struct addrinfo *ai = SMB_MALLOC(sizeof(*ai));
+
+ if (!ai) {
+ return NULL;
+ }
+ memset(ai, '\0', sizeof(*ai));
+
+ psin = SMB_MALLOC(sizeof(*psin));
+ if (!psin) {
+ free(ai);
+ return NULL;
+ }
+
+ memset(psin, '\0', sizeof(*psin));
+
+ psin->sin_family = AF_INET;
+ psin->sin_port = htons(port);
+ psin->sin_addr = ip;
+
+ ai->ai_flags = 0;
+ ai->ai_family = AF_INET;
+ ai->ai_socktype = hints->ai_socktype;
+ ai->ai_protocol = hints->ai_protocol;
+ ai->ai_addrlen = sizeof(*psin);
+ ai->ai_addr = (struct sockaddr *) psin;
+ ai->ai_canonname = NULL;
+ ai->ai_next = NULL;
+
+ return ai;
+}
+
+/*
+ * get address info for a single ipv4 address.
+ *
+ * Bugs: - servname can only be a number, not text.
+ */
+
+static int getaddr_info_single_addr(const char *service,
+ uint32_t addr,
+ const struct addrinfo *hints,
+ struct addrinfo **res)
+{
+
+ struct addrinfo *ai = NULL;
+ struct in_addr ip;
+ unsigned short port = 0;
+
+ if (service) {
+ port = (unsigned short)atoi(service);
+ }
+ ip.s_addr = htonl(addr);
+
+ ai = alloc_entry(hints, ip, port);
+ if (!ai) {
+ return EAI_MEMORY;
+ }
+
+ /* If we're asked for the canonical name,
+ * make sure it returns correctly. */
+ if (!(hints->ai_flags & AI_NUMERICSERV) &&
+ hints->ai_flags & AI_CANONNAME) {
+ int err;
+ if (addr == INADDR_LOOPBACK || addr == INADDR_ANY) {
+ ai->ai_canonname = get_my_canon_name(&err);
+ } else {
+ ai->ai_canonname =
+ get_canon_name_from_addr(ip,&err);
+ }
+ if (ai->ai_canonname == NULL) {
+ freeaddrinfo(ai);
+ return err;
+ }
+ }
+
+ *res = ai;
+ return 0;
+}
+
+/*
+ * get address info for multiple ipv4 addresses.
+ *
+ * Bugs: - servname can only be a number, not text.
+ */
+
+static int getaddr_info_name(const char *node,
+ const char *service,
+ const struct addrinfo *hints,
+ struct addrinfo **res)
+{
+ struct addrinfo *listp = NULL, *prevp = NULL;
+ char **pptr = NULL;
+ int err;
+ struct hostent *hp = NULL;
+ unsigned short port = 0;
+
+ if (service) {
+ port = (unsigned short)atoi(service);
+ }
+
+ hp = gethostbyname(node);
+ err = check_hostent_err(hp);
+ if (err) {
+ return err;
+ }
+
+ for(pptr = hp->h_addr_list; *pptr; pptr++) {
+ struct in_addr ip = *(struct in_addr *)pptr;
+ struct addrinfo *ai = alloc_entry(hints, ip, port);
+
+ if (!ai) {
+ freeaddrinfo(listp);
+ return EAI_MEMORY;
+ }
+
+ if (!listp) {
+ listp = ai;
+ prevp = ai;
+ ai->ai_canonname = SMB_STRDUP(hp->h_name);
+ if (!ai->ai_canonname) {
+ freeaddrinfo(listp);
+ return EAI_MEMORY;
+ }
+ } else {
+ prevp->ai_next = ai;
+ prevp = ai;
+ }
+ }
+ *res = listp;
+ return 0;
+}
+
+/*
+ * get address info for ipv4 sockets.
+ *
+ * Bugs: - servname can only be a number, not text.
+ */
+
+int getaddrinfo(const char *node,
+ const char *service,
+ const struct addrinfo * hintp,
+ struct addrinfo ** res)
+{
+ struct addrinfo hints;
+
+ /* Setup the hints struct. */
+ if (hintp == NULL) {
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ } else {
+ memcpy(&hints, hintp, sizeof(hints));
+ }
+
+ if (hints.ai_family != AF_INET && hints.ai_family != AF_UNSPEC) {
+ return EAI_FAMILY;
+ }
+
+ if (hints.ai_socktype == 0) {
+ hints.ai_socktype = SOCK_STREAM;
+ }
+
+ if (!node && !service) {
+ return EAI_NONAME;
+ }
+
+ if (node) {
+ if (node[0] == '\0') {
+ return getaddr_info_single_addr(service,
+ INADDR_ANY,
+ &hints,
+ res);
+ } else if (hints.ai_flags & AI_NUMERICHOST) {
+ struct in_addr ip;
+ if (!inet_aton(node, &ip)) {
+ return EAI_FAIL;
+ }
+ return getaddr_info_single_addr(service,
+ ntohl(ip.s_addr),
+ &hints,
+ res);
+ } else {
+ return getaddr_info_name(node,
+ service,
+ &hints,
+ res);
+ }
+ } else if (hints.ai_flags & AI_PASSIVE) {
+ return getaddr_info_single_addr(service,
+ INADDR_ANY,
+ &hints,
+ res);
+ }
+ return getaddr_info_single_addr(service,
+ INADDR_LOOPBACK,
+ &hints,
+ res);
+}
+
+
+void freeaddrinfo(struct addrinfo *res)
+{
+ struct addrinfo *next = NULL;
+
+ for (;res; res = next) {
+ next = res->ai_next;
+ if (res->ai_canonname) {
+ free(res->ai_canonname);
+ }
+ if (res->ai_addr) {
+ free(res->ai_addr);
+ }
+ free(res);
+ }
+}
+
+
+const char *gai_strerror(int errcode)
+{
+#ifdef HAVE_HSTRERROR
+ int hcode;
+
+ switch (errcode)
+ {
+ case EAI_NONAME:
+ hcode = HOST_NOT_FOUND;
+ break;
+ case EAI_AGAIN:
+ hcode = TRY_AGAIN;
+ break;
+ case EAI_FAIL:
+ default:
+ hcode = NO_RECOVERY;
+ break;
+ }
+
+ return hstrerror(hcode);
+#else /* !HAVE_HSTRERROR */
+
+ switch (errcode)
+ {
+ case EAI_NONAME:
+ return "Unknown host";
+ case EAI_AGAIN:
+ return "Host name lookup failure";
+#ifdef EAI_BADFLAGS
+ case EAI_BADFLAGS:
+ return "Invalid argument";
+#endif
+#ifdef EAI_FAMILY
+ case EAI_FAMILY:
+ return "Address family not supported";
+#endif
+#ifdef EAI_MEMORY
+ case EAI_MEMORY:
+ return "Not enough memory";
+#endif
+#ifdef EAI_NODATA
+ case EAI_NODATA:
+ return "No host data of that type was found";
+#endif
+#ifdef EAI_SERVICE
+ case EAI_SERVICE:
+ return "Class type not found";
+#endif
+#ifdef EAI_SOCKTYPE
+ case EAI_SOCKTYPE:
+ return "Socket type not supported";
+#endif
+ default:
+ return "Unknown server error";
+ }
+#endif /* HAVE_HSTRERROR */
+}
+
+static int gethostnameinfo(const struct sockaddr *sa,
+ char *node,
+ size_t nodelen,
+ int flags)
+{
+ int ret = -1;
+ char *p = NULL;
+
+ if (!(flags & NI_NUMERICHOST)) {
+ struct hostent *hp = gethostbyaddr(
+ &((struct sockaddr_in *)sa)->sin_addr,
+ sizeof(struct in_addr),
+ sa->sa_family);
+ ret = check_hostent_err(hp);
+ if (ret == 0) {
+ /* Name looked up successfully. */
+ ret = snprintf(node, nodelen, "%s", hp->h_name);
+ if (ret == -1 || ret > nodelen) {
+ return EAI_MEMORY;
+ }
+ if (flags & NI_NOFQDN) {
+ p = strchr(node,'.');
+ if (p) {
+ *p = '\0';
+ }
+ }
+ return 0;
+ }
+
+ if (flags & NI_NAMEREQD) {
+ /* If we require a name and didn't get one,
+ * automatically fail. */
+ return ret;
+ }
+ /* Otherwise just fall into the numeric host code... */
+ }
+ p = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr);
+ ret = snprintf(node, nodelen, "%s", p);
+ if (ret == -1 || ret > nodelen) {
+ return EAI_MEMORY;
+ }
+ return 0;
+}
+
+static int getservicenameinfo(const struct sockaddr *sa,
+ char *service,
+ size_t servicelen,
+ int flags)
+{
+ int ret = -1;
+ int port = ntohs(((struct sockaddr_in *)sa)->sin_port);
+
+ if (!(flags & NI_NUMERICSERV)) {
+ struct servent *se = getservbyport(
+ port,
+ (flags & NI_DGRAM) ? "udp" : "tcp");
+ if (se && se->s_name) {
+ /* Service name looked up successfully. */
+ ret = snprintf(service, servicelen, "%s", se->s_name);
+ if (ret == -1 || ret > servicelen) {
+ return EAI_MEMORY;
+ }
+ return 0;
+ }
+ /* Otherwise just fall into the numeric service code... */
+ }
+ ret = snprintf(service, servicelen, "%d", port);
+ if (ret == -1 || ret > servicelen) {
+ return EAI_MEMORY;
+ }
+ return 0;
+}
+
+/*
+ * Convert an ipv4 address to a hostname.
+ *
+ * Bugs: - No IPv6 support.
+ */
+int getnameinfo(const struct sockaddr *sa, socklen_t salen,
+ char *node, size_t nodelen,
+ char *service, size_t servicelen, int flags)
+{
+
+ /* Invalid arguments. */
+ if (sa == NULL || (node == NULL && service == NULL)) {
+ return EAI_FAIL;
+ }
+
+ if (sa->sa_family != AF_INET) {
+ return EAI_FAIL;
+ }
+
+ if (salen < sizeof(struct sockaddr_in)) {
+ return EAI_FAIL;
+ }
+
+ /* We don't support those. */
+ if ((node && !(flags & NI_NUMERICHOST))
+ || (service && !(flags & NI_NUMERICSERV)))
+ return EAI_FAIL;
+
+ if (node) {
+ return gethostnameinfo(sa, node, nodelen, flags);
+ }
+
+ if (service) {
+ return getservicenameinfo(sa, service, servicelen, flags);
+ }
+ return 0;
+}
diff --git a/source4/lib/replace/getaddrinfo.h b/source4/lib/replace/getaddrinfo.h
new file mode 100644
index 0000000000..ed678bd065
--- /dev/null
+++ b/source4/lib/replace/getaddrinfo.h
@@ -0,0 +1,158 @@
+/*
+PostgreSQL Database Management System
+(formerly known as Postgres, then as Postgres95)
+
+Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group
+
+Portions Copyright (c) 1994, The Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose, without fee, and without a written agreement
+is hereby granted, provided that the above copyright notice and this paragraph
+and the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
+LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
+EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
+TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+*/
+
+/*-------------------------------------------------------------------------
+ *
+ * getaddrinfo.h
+ * Support getaddrinfo() on platforms that don't have it.
+ *
+ * Note: we use our own routines on platforms that don't HAVE_STRUCT_ADDRINFO,
+ * whether or not the library routine getaddrinfo() can be found. This
+ * policy is needed because on some platforms a manually installed libbind.a
+ * may provide getaddrinfo(), yet the system headers may not provide the
+ * struct definitions needed to call it. To avoid conflict with the libbind
+ * definition in such cases, we rename our routines to pg_xxx() via macros.
+ *
+ * This code will also work on platforms where struct addrinfo is defined
+ * in the system headers but no getaddrinfo() can be located.
+ *
+ * Copyright (c) 2003-2007, PostgreSQL Global Development Group
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef GETADDRINFO_H
+#define GETADDRINFO_H
+
+
+/* Various macros that ought to be in <netdb.h>, but might not be */
+
+#ifndef EAI_FAIL
+#define EAI_BADFLAGS (-1)
+#define EAI_NONAME (-2)
+#define EAI_AGAIN (-3)
+#define EAI_FAIL (-4)
+#define EAI_FAMILY (-6)
+#define EAI_SOCKTYPE (-7)
+#define EAI_SERVICE (-8)
+#define EAI_MEMORY (-10)
+#define EAI_SYSTEM (-11)
+#endif /* !EAI_FAIL */
+
+#ifndef AI_PASSIVE
+#define AI_PASSIVE 0x0001
+#endif
+
+#ifndef AI_NUMERICHOST
+/*
+ * some platforms don't support AI_NUMERICHOST; define as zero if using
+ * the system version of getaddrinfo...
+ */
+#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
+#define AI_NUMERICHOST 0
+#else
+#define AI_NUMERICHOST 0x0004
+#endif
+#endif
+
+#ifndef NI_NUMERICHOST
+#define NI_NUMERICHOST 1
+#endif
+
+#ifndef NI_NUMERICSERV
+#define NI_NUMERICSERV 2
+#endif
+
+#ifndef NI_NOFQDN
+#define NI_NOFQDN 4
+#endif
+
+#ifndef NI_NAMEREQD
+#define NI_NAMEREQD 8
+#endif
+
+#ifndef NI_DGRAM
+#define NI_DGRAM 16
+#endif
+
+
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 1025
+#endif
+
+#ifndef NI_MAXSERV
+#define NI_MAXSERV 32
+#endif
+
+#ifndef HAVE_STRUCT_ADDRINFO
+
+struct addrinfo
+{
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ size_t ai_addrlen;
+ struct sockaddr *ai_addr;
+ char *ai_canonname;
+ struct addrinfo *ai_next;
+};
+#endif /* HAVE_STRUCT_ADDRINFO */
+
+
+#ifndef HAVE_GETADDRINFO
+
+/* Rename private copies per comments above */
+#ifdef getaddrinfo
+#undef getaddrinfo
+#endif
+#define getaddrinfo pg_getaddrinfo
+
+#ifdef freeaddrinfo
+#undef freeaddrinfo
+#endif
+#define freeaddrinfo pg_freeaddrinfo
+
+#ifdef gai_strerror
+#undef gai_strerror
+#endif
+#define gai_strerror pg_gai_strerror
+
+#ifdef getnameinfo
+#undef getnameinfo
+#endif
+#define getnameinfo pg_getnameinfo
+
+extern int getaddrinfo(const char *node, const char *service,
+ const struct addrinfo * hints, struct addrinfo ** res);
+extern void freeaddrinfo(struct addrinfo * res);
+extern const char *gai_strerror(int errcode);
+extern int getnameinfo(const struct sockaddr * sa, socklen_t salen,
+ char *node, size_t nodelen,
+ char *service, size_t servicelen, int flags);
+#endif /* HAVE_GETADDRINFO */
+
+#endif /* GETADDRINFO_H */
diff --git a/source4/lib/replace/inet_ntop.c b/source4/lib/replace/inet_ntop.c
new file mode 100644
index 0000000000..fb3d8e90c8
--- /dev/null
+++ b/source4/lib/replace/inet_ntop.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 1996-2001 Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include "replace.h"
+#include "system/network.h"
+
+#define NS_INT16SZ 2
+#define NS_IN6ADDRSZ 16
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static const char *inet_ntop4(const unsigned char *src, char *dst,
+ socklen_t size);
+
+#ifdef AF_INET6
+static const char *inet_ntop6(const unsigned char *src, char *dst,
+ socklen_t size);
+#endif
+
+/* char *
+ * isc_net_ntop(af, src, dst, size)
+ * convert a network format address to presentation format.
+ * return:
+ * pointer to presentation format address (`dst'), or NULL (see errno).
+ * author:
+ * Paul Vixie, 1996.
+ */
+const char *
+rep_inet_ntop(int af, const void *src, char *dst, socklen_t size)
+{
+ switch (af) {
+ case AF_INET:
+ return (inet_ntop4(src, dst, size));
+#ifdef AF_INET6
+ case AF_INET6:
+ return (inet_ntop6(src, dst, size));
+#endif
+ default:
+ errno = EAFNOSUPPORT;
+ return (NULL);
+ }
+ /* NOTREACHED */
+}
+
+/* const char *
+ * inet_ntop4(src, dst, size)
+ * format an IPv4 address
+ * return:
+ * `dst' (as a const)
+ * notes:
+ * (1) uses no statics
+ * (2) takes a unsigned char* not an in_addr as input
+ * author:
+ * Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop4(const unsigned char *src, char *dst, socklen_t size)
+{
+ static const char *fmt = "%u.%u.%u.%u";
+ char tmp[sizeof "255.255.255.255"];
+ size_t len;
+
+ len = snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]);
+ if (len >= size) {
+ errno = ENOSPC;
+ return (NULL);
+ }
+ memcpy(dst, tmp, len + 1);
+
+ return (dst);
+}
+
+/* const char *
+ * isc_inet_ntop6(src, dst, size)
+ * convert IPv6 binary address into presentation (printable) format
+ * author:
+ * Paul Vixie, 1996.
+ */
+#ifdef AF_INET6
+static const char *
+inet_ntop6(const unsigned char *src, char *dst, socklen_t size)
+{
+ /*
+ * Note that int32_t and int16_t need only be "at least" large enough
+ * to contain a value of the specified size. On some systems, like
+ * Crays, there is no such thing as an integer variable with 16 bits.
+ * Keep this in mind if you think this function should have been coded
+ * to use pointer overlays. All the world's not a VAX.
+ */
+ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
+ struct { int base, len; } best, cur;
+ unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
+ int i, inc;
+
+ /*
+ * Preprocess:
+ * Copy the input (bytewise) array into a wordwise array.
+ * Find the longest run of 0x00's in src[] for :: shorthanding.
+ */
+ memset(words, '\0', sizeof words);
+ for (i = 0; i < NS_IN6ADDRSZ; i++)
+ words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
+ best.base = -1;
+ best.len = 0;
+ cur.base = -1;
+ cur.len = 0;
+ for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
+ if (words[i] == 0) {
+ if (cur.base == -1)
+ cur.base = i, cur.len = 1;
+ else
+ cur.len++;
+ } else {
+ if (cur.base != -1) {
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ cur.base = -1;
+ }
+ }
+ }
+ if (cur.base != -1) {
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ }
+ if (best.base != -1 && best.len < 2)
+ best.base = -1;
+
+ /*
+ * Format the result.
+ */
+ tp = tmp;
+ for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
+ /* Are we inside the best run of 0x00's? */
+ if (best.base != -1 && i >= best.base &&
+ i < (best.base + best.len)) {
+ if (i == best.base)
+ *tp++ = ':';
+ continue;
+ }
+ /* Are we following an initial run of 0x00s or any real hex? */
+ if (i != 0)
+ *tp++ = ':';
+ /* Is this address an encapsulated IPv4? */
+ if (i == 6 && best.base == 0 &&
+ (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+ if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
+ return (NULL);
+ tp += strlen(tp);
+ break;
+ }
+ inc = snprintf(tp, 5, "%x", words[i]);
+ if (inc >= 5) {
+ abort();
+ }
+ tp += inc;
+ }
+ /* Was it a trailing run of 0x00's? */
+ if (best.base != -1 && (best.base + best.len) ==
+ (NS_IN6ADDRSZ / NS_INT16SZ))
+ *tp++ = ':';
+ *tp++ = '\0';
+
+ /*
+ * Check for overflow, copy, and we're done.
+ */
+ if ((size_t)(tp - tmp) > size) {
+ errno = ENOSPC;
+ return (NULL);
+ }
+ memcpy(dst, tmp, tp - tmp);
+ return (dst);
+}
+#endif /* AF_INET6 */
diff --git a/source4/lib/replace/inet_ntop.m4 b/source4/lib/replace/inet_ntop.m4
new file mode 100644
index 0000000000..6f39056f1d
--- /dev/null
+++ b/source4/lib/replace/inet_ntop.m4
@@ -0,0 +1 @@
+AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"])
diff --git a/source4/lib/replace/inet_pton.c b/source4/lib/replace/inet_pton.c
new file mode 100644
index 0000000000..80e4865ef4
--- /dev/null
+++ b/source4/lib/replace/inet_pton.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 1996-2001 Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "replace.h"
+#include "system/network.h"
+
+#define NS_INT16SZ 2
+#define NS_INADDRSZ 4
+#define NS_IN6ADDRSZ 16
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static int inet_pton4(const char *src, unsigned char *dst);
+#ifdef AF_INET6
+static int inet_pton6(const char *src, unsigned char *dst);
+#endif
+
+/* int
+ * inet_pton(af, src, dst)
+ * convert from presentation format (which usually means ASCII printable)
+ * to network format (which is usually some kind of binary format).
+ * return:
+ * 1 if the address was valid for the specified address family
+ * 0 if the address wasn't valid (`dst' is untouched in this case)
+ * -1 if some other error occurred (`dst' is untouched in this case, too)
+ * author:
+ * Paul Vixie, 1996.
+ */
+int
+rep_inet_pton(int af,
+ const char *src,
+ void *dst)
+{
+ switch (af) {
+ case AF_INET:
+ return (inet_pton4(src, dst));
+#ifdef AF_INET6
+ case AF_INET6:
+ return (inet_pton6(src, dst));
+#endif
+ default:
+ errno = EAFNOSUPPORT;
+ return (-1);
+ }
+ /* NOTREACHED */
+}
+
+/* int
+ * inet_pton4(src, dst)
+ * like inet_aton() but without all the hexadecimal and shorthand.
+ * return:
+ * 1 if `src' is a valid dotted quad, else 0.
+ * notice:
+ * does not touch `dst' unless it's returning 1.
+ * author:
+ * Paul Vixie, 1996.
+ */
+static int
+inet_pton4(src, dst)
+ const char *src;
+ unsigned char *dst;
+{
+ static const char digits[] = "0123456789";
+ int saw_digit, octets, ch;
+ unsigned char tmp[NS_INADDRSZ], *tp;
+
+ saw_digit = 0;
+ octets = 0;
+ *(tp = tmp) = 0;
+ while ((ch = *src++) != '\0') {
+ const char *pch;
+
+ if ((pch = strchr(digits, ch)) != NULL) {
+ unsigned int new = *tp * 10 + (pch - digits);
+
+ if (new > 255)
+ return (0);
+ *tp = new;
+ if (! saw_digit) {
+ if (++octets > 4)
+ return (0);
+ saw_digit = 1;
+ }
+ } else if (ch == '.' && saw_digit) {
+ if (octets == 4)
+ return (0);
+ *++tp = 0;
+ saw_digit = 0;
+ } else
+ return (0);
+ }
+ if (octets < 4)
+ return (0);
+ memcpy(dst, tmp, NS_INADDRSZ);
+ return (1);
+}
+
+/* int
+ * inet_pton6(src, dst)
+ * convert presentation level address to network order binary form.
+ * return:
+ * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * notice:
+ * (1) does not touch `dst' unless it's returning 1.
+ * (2) :: in a full address is silently ignored.
+ * credit:
+ * inspired by Mark Andrews.
+ * author:
+ * Paul Vixie, 1996.
+ */
+#ifdef AF_INET6
+static int
+inet_pton6(src, dst)
+ const char *src;
+ unsigned char *dst;
+{
+ static const char xdigits_l[] = "0123456789abcdef",
+ xdigits_u[] = "0123456789ABCDEF";
+ unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
+ const char *xdigits, *curtok;
+ int ch, saw_xdigit;
+ unsigned int val;
+
+ memset((tp = tmp), '\0', NS_IN6ADDRSZ);
+ endp = tp + NS_IN6ADDRSZ;
+ colonp = NULL;
+ /* Leading :: requires some special handling. */
+ if (*src == ':')
+ if (*++src != ':')
+ return (0);
+ curtok = src;
+ saw_xdigit = 0;
+ val = 0;
+ while ((ch = *src++) != '\0') {
+ const char *pch;
+
+ if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
+ pch = strchr((xdigits = xdigits_u), ch);
+ if (pch != NULL) {
+ val <<= 4;
+ val |= (pch - xdigits);
+ if (val > 0xffff)
+ return (0);
+ saw_xdigit = 1;
+ continue;
+ }
+ if (ch == ':') {
+ curtok = src;
+ if (!saw_xdigit) {
+ if (colonp)
+ return (0);
+ colonp = tp;
+ continue;
+ }
+ if (tp + NS_INT16SZ > endp)
+ return (0);
+ *tp++ = (unsigned char) (val >> 8) & 0xff;
+ *tp++ = (unsigned char) val & 0xff;
+ saw_xdigit = 0;
+ val = 0;
+ continue;
+ }
+ if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
+ inet_pton4(curtok, tp) > 0) {
+ tp += NS_INADDRSZ;
+ saw_xdigit = 0;
+ break; /* '\0' was seen by inet_pton4(). */
+ }
+ return (0);
+ }
+ if (saw_xdigit) {
+ if (tp + NS_INT16SZ > endp)
+ return (0);
+ *tp++ = (unsigned char) (val >> 8) & 0xff;
+ *tp++ = (unsigned char) val & 0xff;
+ }
+ if (colonp != NULL) {
+ /*
+ * Since some memmove()'s erroneously fail to handle
+ * overlapping regions, we'll do the shift by hand.
+ */
+ const int n = tp - colonp;
+ int i;
+
+ for (i = 1; i <= n; i++) {
+ endp[- i] = colonp[n - i];
+ colonp[n - i] = 0;
+ }
+ tp = endp;
+ }
+ if (tp != endp)
+ return (0);
+ memcpy(dst, tmp, NS_IN6ADDRSZ);
+ return (1);
+}
+#endif
diff --git a/source4/lib/replace/inet_pton.m4 b/source4/lib/replace/inet_pton.m4
new file mode 100644
index 0000000000..51de9275d0
--- /dev/null
+++ b/source4/lib/replace/inet_pton.m4
@@ -0,0 +1 @@
+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 f06d7f83dc..4bdbf3a504 100644
--- a/source4/lib/replace/libreplace.m4
+++ b/source4/lib/replace/libreplace.m4
@@ -137,6 +137,55 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
fi
+dnl test for struct addrinfo
+AC_CACHE_CHECK([for struct addrinfo],samba_cv_HAVE_STRUCT_ADDRINFO,[
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#include <sys/socket.h>
+#include <netdb.h>],
+[
+struct addrinfo ai;
+],
+samba_cv_HAVE_STRUCT_ADDRINFO=yes,samba_cv_HAVE_STRUCT_ADDRINFO=no)])
+if test x"$samba_cv_HAVE_STRUCT_ADDRINFO" = x"yes"; then
+ AC_DEFINE(HAVE_STRUCT_ADDRINFO,1,[Whether the system has struct addrinfo])
+fi
+
+dnl test for getaddrinfo/getnameinfo
+AC_CACHE_CHECK([for getaddrinfo],samba_cv_HAVE_GETADDRINFO,[
+AC_TRY_COMPILE([
+#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);
+
+],
+samba_cv_HAVE_GETADDRINFO=yes,samba_cv_HAVE_GETADDRINFO=no)])
+if test x"$samba_cv_HAVE_GETADDRINFO" = x"yes"; then
+ AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo and getnameinfo])
+ AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo])
+ AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror])
+fi
+
+
dnl Provided by replace.c:
AC_TRY_COMPILE([
#include <sys/types.h>
@@ -152,6 +201,7 @@ 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)
AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair)
+AC_CHECK_FUNCS(isatty)
AC_HAVE_DECL(setresuid, [#include <unistd.h>])
AC_HAVE_DECL(setresgid, [#include <unistd.h>])
AC_HAVE_DECL(errno, [#include <errno.h>])
@@ -303,18 +353,7 @@ AC_TRY_COMPILE([
samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)])
if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then
AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT])
-fi
-
-
-AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [
- dnl Check whether the compiler can generate precompiled headers
- touch conftest.h
- if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then
- precompiled_headers=yes
- else
- precompiled_headers=no
- fi])
-AC_SUBST(precompiled_headers)
+fi
dnl Check if the C compiler understands volatile (it should, being ANSI).
@@ -332,6 +371,8 @@ m4_include(getpass.m4)
m4_include(strptime.m4)
m4_include(win32.m4)
m4_include(timegm.m4)
+m4_include(inet_ntop.m4)
+m4_include(inet_pton.m4)
m4_include(repdir.m4)
AC_CHECK_FUNCS([syslog memset memcpy],,[AC_MSG_ERROR([Required function not found])])
diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h
index 06173bd84b..26e39ac603 100644
--- a/source4/lib/replace/replace.h
+++ b/source4/lib/replace/replace.h
@@ -1,15 +1,16 @@
-/*
+/*
Unix SMB/CIFS implementation.
macros to go along with the lib/replace/ portability layer code
Copyright (C) Andrew Tridgell 2005
Copyright (C) Jelmer Vernooij 2006
+ Copyright (C) Jeremy Allison 2007.
** NOTE! The following LGPL license applies to the replace
** library. This does NOT imply that all of Samba is released
** under the LGPL
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@@ -44,13 +45,6 @@
#include "win32_replace.h"
#endif
-#ifdef __COMPAR_FN_T
-#define QSORT_CAST (__compar_fn_t)
-#endif
-
-#ifndef QSORT_CAST
-#define QSORT_CAST (int (*)(const void *, const void *))
-#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
@@ -78,29 +72,6 @@
#include <stddef.h>
#endif
-/**
- this is a warning hack. The idea is to use this everywhere that we
- get the "discarding const" warning from gcc. That doesn't actually
- fix the problem of course, but it means that when we do get to
- cleaning them up we can do it by searching the code for
- discard_const.
-
- It also means that other error types aren't as swamped by the noise
- of hundreds of const warnings, so we are more likely to notice when
- we get new errors.
-
- Please only add more uses of this macro when you find it
- _really_ hard to fix const warnings. Our aim is to eventually use
- this function in only a very few places.
-
- 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)))
-
-/** Type-safe version of discard_const */
-#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
-
#ifndef HAVE_STRERROR
extern char *sys_errlist[];
#define strerror(i) sys_errlist[i]
@@ -168,7 +139,7 @@ int setenv(const char *name, const char *value, int overwrite);
#ifndef HAVE_UNSETENV
#define unsetenv rep_unsetenv
-int rep_unsetenv(const char *name);
+int rep_unsetenv(const char *name);
#endif
#ifndef HAVE_SETEUID
@@ -192,7 +163,7 @@ char *rep_strcasestr(const char *haystack, const char *needle);
#endif
#ifndef HAVE_STRTOK_R
-#define strtok_r rep_strtok_r
+#define strtok_r rep_strtok_r
char *rep_strtok_r(char *s, const char *delim, char **save_ptr);
#endif
@@ -359,10 +330,25 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset);
ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset);
#endif
+#ifndef HAVE_INET_PTON
+int rep_inet_pton(int af, const char *src, void *dst);
+#define inet_pton rep_inet_pton
+#endif
+
+#ifndef HAVE_INET_NTOP
+#include "system/network.h"
+const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
+#define inet_ntop rep_inet_ntop
+#endif
+
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
/* The extra casts work around common compiler bugs. */
#define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
@@ -375,6 +361,14 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
#define HOST_NAME_MAX 64
#endif
+/*
+ * Some older systems seem not to have MAXHOSTNAMELEN
+ * defined.
+ */
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN HOST_NAME_MAX
+#endif
+
#ifndef UINT16_MAX
#define UINT16_MAX 65535
#endif
@@ -450,9 +444,6 @@ typedef int bool;
#endif
#endif
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
@@ -462,11 +453,34 @@ typedef int bool;
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
+/**
+ this is a warning hack. The idea is to use this everywhere that we
+ get the "discarding const" warning from gcc. That doesn't actually
+ fix the problem of course, but it means that when we do get to
+ cleaning them up we can do it by searching the code for
+ discard_const.
+
+ It also means that other error types aren't as swamped by the noise
+ of hundreds of const warnings, so we are more likely to notice when
+ we get new errors.
+
+ Please only add more uses of this macro when you find it
+ _really_ hard to fix const warnings. Our aim is to eventually use
+ this function in only a very few places.
+
+ 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)))
+
+/** Type-safe version of discard_const */
+#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
+
#ifndef __STRING
#define __STRING(x) #x
#endif
-#ifndef _STRINGSTRING
+#ifndef __STRINGSTRING
#define __STRINGSTRING(x) __STRING(x)
#endif
@@ -511,4 +525,12 @@ typedef int bool;
#undef HAVE_MMAP
#endif
+#ifdef __COMPAR_FN_T
+#define QSORT_CAST (__compar_fn_t)
+#endif
+
+#ifndef QSORT_CAST
+#define QSORT_CAST (int (*)(const void *, const void *))
+#endif
+
#endif /* _LIBREPLACE_REPLACE_H */
diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h
index 13d95a8ba7..02942f9a44 100644
--- a/source4/lib/replace/system/network.h
+++ b/source4/lib/replace/system/network.h
@@ -49,6 +49,10 @@
#include <netinet/tcp.h>
#endif
+#if !defined(HAVE_GETADDRINFO)
+#include "getaddrinfo.h"
+#endif
+
/*
* The next three defines are needed to access the IPTOS_* options
* on some systems.
@@ -98,14 +102,6 @@ char *rep_inet_ntoa(struct in_addr ip);
#define MSG_WAITALL 0
#endif
-/*
- * Some older systems seem not to have MAXHOSTNAMELEN
- * defined.
- */
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 254
-#endif
-
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7f000001
#endif
@@ -114,4 +110,8 @@ char *rep_inet_ntoa(struct in_addr ip);
#define INADDR_NONE 0xffffffff
#endif
+#ifndef INET_ADDRSTRLEN
+#define INET_ADDRSTRLEN 16
+#endif
+
#endif
diff --git a/source4/lib/samba3/config.mk b/source4/lib/samba3/config.mk
index b6441c4dcd..aefb077cf5 100644
--- a/source4/lib/samba3/config.mk
+++ b/source4/lib/samba3/config.mk
@@ -18,7 +18,6 @@ PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBTDB NDR_SECURITY \
# Start SUBSYSTEM LIBSAMBA3
[SUBSYSTEM::SMBPASSWD]
PRIVATE_PROTO_HEADER = samba3_smbpasswd_proto.h
-PUBLIC_HEADERS = samba3.h
OBJ_FILES = smbpasswd.o
# End SUBSYSTEM LIBSAMBA3
################################################
diff --git a/source4/lib/smbreadline/smbreadline.c b/source4/lib/smbreadline/smbreadline.c
index ae9fc4a3b7..2a72750efb 100644
--- a/source4/lib/smbreadline/smbreadline.c
+++ b/source4/lib/smbreadline/smbreadline.c
@@ -23,6 +23,7 @@
#include "system/filesys.h"
#include "system/select.h"
#include "system/readline.h"
+#include "lib/smbreadline/smbreadline.h"
/*******************************************************************
Similar to sys_select() but catch EINTR and continue.
diff --git a/source4/lib/socket/access.c b/source4/lib/socket/access.c
index 2d228c7474..42c42db365 100644
--- a/source4/lib/socket/access.c
+++ b/source4/lib/socket/access.c
@@ -39,7 +39,7 @@
#define ALLONES ((uint32_t)0xFFFFFFFF)
/* masked_match - match address against netnumber/netmask */
-static BOOL masked_match(TALLOC_CTX *mem_ctx, const char *tok, const char *slash, const char *s)
+static bool masked_match(TALLOC_CTX *mem_ctx, const char *tok, const char *slash, const char *s)
{
uint32_t net;
uint32_t mask;
@@ -47,7 +47,7 @@ static BOOL masked_match(TALLOC_CTX *mem_ctx, const char *tok, const char *slash
char *tok_cpy;
if ((addr = interpret_addr(s)) == INADDR_NONE)
- return False;
+ return false;
tok_cpy = talloc_strdup(mem_ctx, tok);
tok_cpy[PTR_DIFF(slash,tok)] = '\0';
@@ -64,14 +64,14 @@ static BOOL masked_match(TALLOC_CTX *mem_ctx, const char *tok, const char *slash
if (net == INADDR_NONE || mask == INADDR_NONE) {
DEBUG(0,("access: bad net/mask access control: %s\n", tok));
- return False;
+ return false;
}
return (addr & mask) == (net & mask);
}
/* string_match - match string against token */
-static BOOL string_match(TALLOC_CTX *mem_ctx, const char *tok,const char *s, char *invalid_char)
+static bool string_match(TALLOC_CTX *mem_ctx, const char *tok,const char *s, char *invalid_char)
{
size_t tok_len;
size_t str_len;
@@ -79,50 +79,50 @@ static BOOL string_match(TALLOC_CTX *mem_ctx, const char *tok,const char *s, cha
*invalid_char = '\0';
- /* Return True if a token has the magic value "ALL". Return
+ /* Return true if a token has the magic value "ALL". Return
* FAIL if the token is "FAIL". If the token starts with a "."
- * (domain name), return True if it matches the last fields of
+ * (domain name), return true if it matches the last fields of
* the string. If the token has the magic value "LOCAL",
- * return True if the string does not contain a "."
+ * return true if the string does not contain a "."
* character. If the token ends on a "." (network number),
- * return True if it matches the first fields of the
+ * return true if it matches the first fields of the
* string. If the token begins with a "@" (netgroup name),
- * return True if the string is a (host) member of the
- * netgroup. Return True if the token fully matches the
+ * return true if the string is a (host) member of the
+ * netgroup. Return true if the token fully matches the
* string. If the token is a netnumber/netmask pair, return
- * True if the address is a member of the specified subnet.
+ * true if the address is a member of the specified subnet.
*/
if (tok[0] == '.') { /* domain: match last fields */
if ((str_len = strlen(s)) > (tok_len = strlen(tok))
&& strcasecmp(tok, s + str_len - tok_len)==0) {
- return True;
+ return true;
}
} else if (tok[0] == '@') { /* netgroup: look it up */
DEBUG(0,("access: netgroup support is not available\n"));
- return False;
+ return false;
} else if (strcmp(tok, "ALL")==0) { /* all: match any */
- return True;
+ return true;
} else if (strcmp(tok, "FAIL")==0) { /* fail: match any */
return FAIL;
} else if (strcmp(tok, "LOCAL")==0) { /* local: no dots */
if (strchr(s, '.') == 0 && strcasecmp(s, "unknown") != 0) {
- return True;
+ return true;
}
} else if (strcasecmp(tok, s)==0) { /* match host name or address */
- return True;
+ return true;
} else if (tok[(tok_len = strlen(tok)) - 1] == '.') { /* network */
if (strncmp(tok, s, tok_len) == 0)
- return True;
+ return true;
} else if ((cut = strchr(tok, '/')) != 0) { /* netnumber/netmask */
if (isdigit((int)s[0]) && masked_match(mem_ctx, tok, cut, s))
- return True;
+ return true;
} else if (strchr(tok, '*') != 0) {
*invalid_char = '*';
} else if (strchr(tok, '?') != 0) {
*invalid_char = '?';
}
- return False;
+ return false;
}
struct client_addr {
@@ -131,9 +131,9 @@ struct client_addr {
};
/* client_match - match host name and address against token */
-static BOOL client_match(TALLOC_CTX *mem_ctx, const char *tok, struct client_addr *client)
+static bool client_match(TALLOC_CTX *mem_ctx, const char *tok, struct client_addr *client)
{
- BOOL match;
+ bool match;
char invalid_char = '\0';
/*
@@ -158,12 +158,12 @@ token '%s' in an allow/deny hosts line.\n", invalid_char, tok ));
}
/* list_match - match an item against a list of tokens with exceptions */
-static BOOL list_match(TALLOC_CTX *mem_ctx, const char **list, struct client_addr *client)
+static bool list_match(TALLOC_CTX *mem_ctx, const char **list, struct client_addr *client)
{
- BOOL match = False;
+ bool match = false;
if (!list)
- return False;
+ return false;
/*
* Process tokens one at a time. We have exhausted all possible matches
@@ -175,18 +175,18 @@ static BOOL list_match(TALLOC_CTX *mem_ctx, const char **list, struct client_add
for (; *list ; list++) {
if (strcmp(*list, "EXCEPT")==0) /* EXCEPT: give up */
break;
- if ((match = client_match(mem_ctx, *list, client))) /* True or FAIL */
+ if ((match = client_match(mem_ctx, *list, client))) /* true or FAIL */
break;
}
- /* Process exceptions to True or FAIL matches. */
- if (match != False) {
+ /* Process exceptions to true or FAIL matches. */
+ if (match != false) {
while (*list && strcmp(*list, "EXCEPT")!=0)
list++;
for (; *list; list++) {
if (client_match(mem_ctx, *list, client)) /* Exception Found */
- return False;
+ return false;
}
}
@@ -194,7 +194,7 @@ static BOOL list_match(TALLOC_CTX *mem_ctx, const char **list, struct client_add
}
/* return true if access should be allowed */
-static BOOL allow_access_internal(TALLOC_CTX *mem_ctx,
+static bool allow_access_internal(TALLOC_CTX *mem_ctx,
const char **deny_list,const char **allow_list,
const char *cname, const char *caddr)
{
@@ -213,15 +213,15 @@ static BOOL allow_access_internal(TALLOC_CTX *mem_ctx,
list_match(mem_ctx, deny_list, &client) &&
(!allow_list ||
!list_match(mem_ctx, allow_list, &client))) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/* if theres no deny list and no allow list then allow access */
if ((!deny_list || *deny_list == 0) &&
(!allow_list || *allow_list == 0)) {
- return True;
+ return true;
}
/* if there is an allow list but no deny list then allow only hosts
@@ -237,27 +237,27 @@ static BOOL allow_access_internal(TALLOC_CTX *mem_ctx,
/* if there are both types of list then allow all hosts on the
allow list */
if (list_match(mem_ctx, allow_list, &client))
- return True;
+ return true;
/* if there are both types of list and it's not on the allow then
allow it if its not on the deny */
if (list_match(mem_ctx, deny_list, &client))
- return False;
+ return false;
- return True;
+ return true;
}
/* return true if access should be allowed */
-BOOL allow_access(TALLOC_CTX *mem_ctx,
+bool allow_access(TALLOC_CTX *mem_ctx,
const char **deny_list, const char **allow_list,
const char *cname, const char *caddr)
{
- BOOL ret;
+ bool ret;
char *nc_cname = talloc_strdup(mem_ctx, cname);
char *nc_caddr = talloc_strdup(mem_ctx, caddr);
if (!nc_cname || !nc_caddr) {
- return False;
+ return false;
}
ret = allow_access_internal(mem_ctx, deny_list, allow_list, nc_cname, nc_caddr);
@@ -271,12 +271,12 @@ BOOL allow_access(TALLOC_CTX *mem_ctx,
/* return true if the char* contains ip addrs only. Used to avoid
gethostbyaddr() calls */
-static BOOL only_ipaddrs_in_list(const char** list)
+static bool only_ipaddrs_in_list(const char** list)
{
- BOOL only_ip = True;
+ bool only_ip = true;
if (!list)
- return True;
+ return true;
for (; *list ; list++) {
/* factor out the special strings */
@@ -293,7 +293,7 @@ static BOOL only_ipaddrs_in_list(const char** list)
* have a '/' in them
*/
if ((strchr(*list, '/')) == NULL) {
- only_ip = False;
+ only_ip = false;
DEBUG(3,("only_ipaddrs_in_list: list has non-ip address (%s)\n", *list));
break;
}
@@ -304,30 +304,30 @@ static BOOL only_ipaddrs_in_list(const char** list)
}
/* return true if access should be allowed to a service for a socket */
-BOOL socket_check_access(struct socket_context *sock,
+bool socket_check_access(struct socket_context *sock,
const char *service_name,
const char **allow_list, const char **deny_list)
{
- BOOL ret;
+ bool ret;
const char *name="";
struct socket_address *addr;
TALLOC_CTX *mem_ctx;
if ((!deny_list || *deny_list==0) &&
(!allow_list || *allow_list==0)) {
- return True;
+ return true;
}
mem_ctx = talloc_init("socket_check_access");
if (!mem_ctx) {
- return False;
+ return false;
}
addr = socket_get_peer_addr(sock, mem_ctx);
if (!addr) {
DEBUG(0,("socket_check_access: Denied connection from unknown host: could not get peer address from kernel\n"));
talloc_free(mem_ctx);
- return False;
+ return false;
}
/* bypass gethostbyaddr() calls if the lists only contain IP addrs */
@@ -342,7 +342,7 @@ BOOL socket_check_access(struct socket_context *sock,
if (!addr) {
DEBUG(0,("socket_check_access: Denied connection from unknown host\n"));
talloc_free(mem_ctx);
- return False;
+ return false;
}
ret = allow_access(mem_ctx, deny_list, allow_list, name, addr->addr);
diff --git a/source4/lib/socket/config.m4 b/source4/lib/socket/config.m4
index e9c194ddc4..3296730c82 100644
--- a/source4/lib/socket/config.m4
+++ b/source4/lib/socket/config.m4
@@ -41,7 +41,7 @@ SMB_EXT_LIB(EXT_SOCKET,[${SOCKET_LIBS}],[${SOCKET_CFLAGS}],[${SOCKET_CPPFLAGS}],
AC_CHECK_FUNCS(gethostbyname)
if test x"$ac_cv_func_gethostbyname" = x"no"; then
AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname)
- AC_CHECK_LIB_EXT(nsl, NSl_LIBS, gethostbyname)
+ AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname)
AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname)
SMB_ENABLE(EXT_NSL,YES)
dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, because the value
@@ -102,8 +102,10 @@ dnl the configure uses --with-static-modules=socket_ipv6
#
# This tests need LIBS="$NSL_LIBS $SOCKET_LIBS"
#
+old_CFLAGS=$CFLAGS
old_LIBS=$LIBS
LIBS="$NSL_LIBS $SOCKET_LIBS"
+CFLAGS="$CFLAGS -Ilib/replace"
iface=no;
AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
AC_TRY_RUN([
@@ -140,4 +142,5 @@ if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
fi
fi
+CFLAGS=$old_CFLAGS
LIBS=$old_LIBS
diff --git a/source4/lib/socket/config.mk b/source4/lib/socket/config.mk
index 22037cd136..d1e0bcfef5 100644
--- a/source4/lib/socket/config.mk
+++ b/source4/lib/socket/config.mk
@@ -10,25 +10,14 @@ PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL EXT_SOCKET EXT_NSL
##############################
################################################
-# Start MODULE socket_ipv4
-[MODULE::socket_ipv4]
+# Start MODULE socket_ip
+[MODULE::socket_ip]
SUBSYSTEM = samba-socket
OUTPUT_TYPE = INTEGRATED
OBJ_FILES = \
- socket_ipv4.o
+ socket_ip.o
PRIVATE_DEPENDENCIES = EXT_SOCKET EXT_NSL LIBSAMBA-ERRORS
-# End MODULE socket_ipv4
-################################################
-
-################################################
-# Start MODULE socket_ipv6
-[MODULE::socket_ipv6]
-SUBSYSTEM = samba-socket
-OUTPUT_TYPE = INTEGRATED
-OBJ_FILES = \
- socket_ipv6.o
-PRIVATE_DEPENDENCIES = EXT_SOCKET EXT_NSL
-# End MODULE socket_ipv6
+# End MODULE socket_ip
################################################
################################################
diff --git a/source4/lib/socket/connect.c b/source4/lib/socket/connect.c
index dd2440b0a8..4a30fa3b92 100644
--- a/source4/lib/socket/connect.c
+++ b/source4/lib/socket/connect.c
@@ -26,6 +26,7 @@
#include "lib/events/events.h"
#include "libcli/composite/composite.h"
#include "libcli/resolve/resolve.h"
+#include "param/param.h"
struct connect_state {
@@ -119,14 +120,14 @@ struct composite_context *socket_connect_send(struct socket_context *sock,
state->flags = flags;
- set_blocking(socket_get_fd(sock), False);
+ set_blocking(socket_get_fd(sock), false);
if (server_address->addr && strcmp(sock->backend_name, "ipv4") == 0) {
struct nbt_name name;
struct composite_context *creq;
make_nbt_name_client(&name, server_address->addr);
creq = resolve_name_send(&name, result->event_ctx,
- lp_name_resolve_order());
+ lp_name_resolve_order(global_loadparm));
if (composite_nomem(creq, result)) return result;
composite_continue(result, creq, continue_resolve_name, result);
return result;
diff --git a/source4/lib/socket/connect_multi.c b/source4/lib/socket/connect_multi.c
index 76e5034a58..6d30141459 100644
--- a/source4/lib/socket/connect_multi.c
+++ b/source4/lib/socket/connect_multi.c
@@ -26,6 +26,7 @@
#include "lib/events/events.h"
#include "libcli/composite/composite.h"
#include "libcli/resolve/resolve.h"
+#include "param/param.h"
#define MULTI_PORT_DELAY 2000 /* microseconds */
@@ -62,7 +63,8 @@ static void continue_one(struct composite_context *creq);
/*
setup an async socket_connect, with multiple ports
*/
-_PUBLIC_ struct composite_context *socket_connect_multi_send(TALLOC_CTX *mem_ctx,
+_PUBLIC_ struct composite_context *socket_connect_multi_send(
+ TALLOC_CTX *mem_ctx,
const char *server_address,
int num_server_ports,
uint16_t *server_ports,
@@ -102,7 +104,7 @@ _PUBLIC_ struct composite_context *socket_connect_multi_send(TALLOC_CTX *mem_ctx
struct composite_context *creq;
make_nbt_name_client(&name, server_address);
creq = resolve_name_send(&name, result->event_ctx,
- lp_name_resolve_order());
+ lp_name_resolve_order(global_loadparm));
if (composite_nomem(creq, result)) goto failed;
composite_continue(result, creq, continue_resolve_name, result);
return result;
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c
index 58d00ba614..9ca4450581 100644
--- a/source4/lib/socket/interface.c
+++ b/source4/lib/socket/interface.c
@@ -23,6 +23,7 @@
#include "system/network.h"
#include "lib/socket/netif.h"
#include "lib/util/dlinklist.h"
+#include "param/param.h"
/** used for network interfaces */
struct interface {
@@ -53,7 +54,7 @@ static struct ipv4_addr tov4(struct in_addr in)
/****************************************************************************
Try and find an interface that matches an ip. If we cannot, return NULL
**************************************************************************/
-static struct interface *iface_find(struct in_addr ip, BOOL CheckMask)
+static struct interface *iface_find(struct in_addr ip, bool CheckMask)
{
struct interface *i;
if (is_zero_ip(tov4(ip))) return local_interfaces;
@@ -74,12 +75,13 @@ static void add_interface(struct in_addr ip, struct in_addr nmask)
{
struct interface *iface;
struct ipv4_addr bcast;
- if (iface_find(ip, False)) {
+
+ if (iface_find(ip, false)) {
DEBUG(3,("not adding duplicate interface %s\n",inet_ntoa(ip)));
return;
}
- iface = talloc(local_interfaces, struct interface);
+ iface = talloc(local_interfaces == NULL ? talloc_autofree_context() : local_interfaces, struct interface);
if (!iface) return;
ZERO_STRUCTPN(iface);
@@ -198,7 +200,7 @@ static void load_interfaces(void)
return;
}
- ptr = lp_interfaces();
+ ptr = lp_interfaces(global_loadparm);
loopback_ip = interpret_addr2("127.0.0.1");
/* probe the kernel for interfaces */
@@ -319,7 +321,7 @@ const char *iface_best_ip(const char *dest)
load_interfaces();
ip.s_addr = interpret_addr(dest);
- iface = iface_find(ip, True);
+ iface = iface_find(ip, true);
if (iface) {
return iface->ip_s;
}
@@ -327,25 +329,25 @@ const char *iface_best_ip(const char *dest)
}
/**
- return True if an IP is one one of our local networks
+ return true if an IP is one one of our local networks
*/
-BOOL iface_is_local(const char *dest)
+bool iface_is_local(const char *dest)
{
struct in_addr ip;
load_interfaces();
ip.s_addr = interpret_addr(dest);
- if (iface_find(ip, True)) {
- return True;
+ if (iface_find(ip, true)) {
+ return true;
}
- return False;
+ return false;
}
/**
- return True if a IP matches a IP/netmask pair
+ return true if a IP matches a IP/netmask pair
*/
-BOOL iface_same_net(const char *ip1, const char *ip2, const char *netmask)
+bool iface_same_net(const char *ip1, const char *ip2, const char *netmask)
{
return same_net(interpret_addr2(ip1),
interpret_addr2(ip2),
diff --git a/source4/lib/socket/netif.h b/source4/lib/socket/netif.h
index dea7476193..4855f4bd73 100644
--- a/source4/lib/socket/netif.h
+++ b/source4/lib/socket/netif.h
@@ -19,6 +19,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "system/network.h"
+
struct iface_struct {
char name[16];
struct in_addr ip;
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c
index a60171ccd1..92f0a44005 100644
--- a/source4/lib/socket/socket.c
+++ b/source4/lib/socket/socket.c
@@ -23,6 +23,7 @@
#include "lib/socket/socket.h"
#include "system/filesys.h"
#include "system/network.h"
+#include "param/param.h"
/*
auto-close sockets on free
@@ -69,14 +70,14 @@ _PUBLIC_ NTSTATUS socket_create_with_ops(TALLOC_CTX *mem_ctx, const struct socke
if (!(flags & SOCKET_FLAG_BLOCK) &&
type == SOCKET_TYPE_STREAM &&
- lp_parm_bool(-1, "socket", "testnonblock", False)) {
+ lp_parm_bool(global_loadparm, NULL, "socket", "testnonblock", false)) {
(*new_sock)->flags |= SOCKET_FLAG_TESTNONBLOCK;
}
/* we don't do a connect() on dgram sockets, so need to set
non-blocking at socket create time */
if (!(flags & SOCKET_FLAG_BLOCK) && type == SOCKET_TYPE_DGRAM) {
- set_blocking(socket_get_fd(*new_sock), False);
+ set_blocking(socket_get_fd(*new_sock), false);
}
talloc_set_destructor(*new_sock, socket_destructor);
@@ -407,7 +408,7 @@ _PUBLIC_ struct socket_address *socket_address_from_sockaddr(TALLOC_CTX *mem_ctx
addr->family = NULL;
addr->addr = NULL;
addr->port = 0;
- addr->sockaddr = talloc_memdup(addr, sockaddr, sockaddrlen);
+ addr->sockaddr = (struct sockaddr *)talloc_memdup(addr, sockaddr, sockaddrlen);
if (!addr->sockaddr) {
talloc_free(addr);
return NULL;
@@ -429,10 +430,6 @@ _PUBLIC_ const struct socket_ops *socket_getops_byname(const char *family, enum
#if HAVE_IPV6
if (strcmp("ipv6", family) == 0) {
- if (lp_parm_bool(-1, "socket", "noipv6", False)) {
- DEBUG(3, ("IPv6 support was disabled in smb.conf"));
- return NULL;
- }
return socket_ipv6_ops(type);
}
#endif
@@ -505,12 +502,12 @@ _PUBLIC_ void set_socket_options(int fd, const char *options)
int ret=0,i;
int value = 1;
char *p;
- BOOL got_value = False;
+ bool got_value = false;
if ((p = strchr(tok,'='))) {
*p = 0;
value = atoi(p+1);
- got_value = True;
+ got_value = true;
}
for (i=0;socket_options[i].name;i++)
diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h
index 0c4fc0bb95..7679db08a1 100644
--- a/source4/lib/socket/socket.h
+++ b/source4/lib/socket/socket.h
@@ -121,6 +121,9 @@ struct socket_context {
void *private_data;
const struct socket_ops *ops;
const char *backend_name;
+
+ /* specific to the ip backend */
+ int family;
};
diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c
new file mode 100644
index 0000000000..499dc93d7b
--- /dev/null
+++ b/source4/lib/socket/socket_ip.c
@@ -0,0 +1,981 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Socket IPv4/IPv6 functions
+
+ Copyright (C) Stefan Metzmacher 2004
+ Copyright (C) Andrew Tridgell 2004-2005
+ Copyright (C) Jelmer Vernooij 2004
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "system/filesys.h"
+#include "lib/socket/socket.h"
+#include "system/network.h"
+
+static NTSTATUS ipv4_init(struct socket_context *sock)
+{
+ int type;
+
+ switch (sock->type) {
+ case SOCKET_TYPE_STREAM:
+ type = SOCK_STREAM;
+ break;
+ case SOCKET_TYPE_DGRAM:
+ type = SOCK_DGRAM;
+ break;
+ default:
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ sock->fd = socket(PF_INET, type, 0);
+ if (sock->fd == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ sock->backend_name = "ipv4";
+ sock->family = AF_INET;
+
+ return NT_STATUS_OK;
+}
+
+static void ip_close(struct socket_context *sock)
+{
+ close(sock->fd);
+}
+
+static NTSTATUS ip_connect_complete(struct socket_context *sock, uint32_t flags)
+{
+ int error=0, ret;
+ socklen_t len = sizeof(error);
+
+ /* check for any errors that may have occurred - this is needed
+ for non-blocking connect */
+ ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &error, &len);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ if (error != 0) {
+ return map_nt_error_from_unix(error);
+ }
+
+ if (!(flags & SOCKET_FLAG_BLOCK)) {
+ ret = set_blocking(sock->fd, false);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
+ sock->state = SOCKET_STATE_CLIENT_CONNECTED;
+
+ return NT_STATUS_OK;
+}
+
+
+static NTSTATUS ipv4_connect(struct socket_context *sock,
+ const struct socket_address *my_address,
+ const struct socket_address *srv_address,
+ uint32_t flags)
+{
+ struct sockaddr_in srv_addr;
+ struct ipv4_addr my_ip;
+ struct ipv4_addr srv_ip;
+ int ret;
+
+ if (my_address && my_address->sockaddr) {
+ ret = bind(sock->fd, my_address->sockaddr, my_address->sockaddrlen);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ } else if (my_address) {
+ my_ip = interpret_addr2(my_address->addr);
+
+ if (my_ip.addr != 0 || my_address->port != 0) {
+ struct sockaddr_in my_addr;
+ ZERO_STRUCT(my_addr);
+#ifdef HAVE_SOCK_SIN_LEN
+ my_addr.sin_len = sizeof(my_addr);
+#endif
+ my_addr.sin_addr.s_addr = my_ip.addr;
+ my_addr.sin_port = htons(my_address->port);
+ my_addr.sin_family = PF_INET;
+
+ ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ }
+ }
+
+ if (srv_address->sockaddr) {
+ ret = connect(sock->fd, srv_address->sockaddr, srv_address->sockaddrlen);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ } else {
+ srv_ip = interpret_addr2(srv_address->addr);
+ if (!srv_ip.addr) {
+ return NT_STATUS_BAD_NETWORK_NAME;
+ }
+
+ ZERO_STRUCT(srv_addr);
+#ifdef HAVE_SOCK_SIN_LEN
+ srv_addr.sin_len = sizeof(srv_addr);
+#endif
+ srv_addr.sin_addr.s_addr= srv_ip.addr;
+ srv_addr.sin_port = htons(srv_address->port);
+ srv_addr.sin_family = PF_INET;
+
+ ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr));
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
+ return ip_connect_complete(sock, flags);
+}
+
+
+/*
+ note that for simplicity of the API, socket_listen() is also
+ use for DGRAM sockets, but in reality only a bind() is done
+*/
+static NTSTATUS ipv4_listen(struct socket_context *sock,
+ const struct socket_address *my_address,
+ int queue_size, uint32_t flags)
+{
+ struct sockaddr_in my_addr;
+ struct ipv4_addr ip_addr;
+ int ret;
+
+ socket_set_option(sock, "SO_REUSEADDR=1", NULL);
+
+ if (my_address->sockaddr) {
+ ret = bind(sock->fd, my_address->sockaddr, my_address->sockaddrlen);
+ } else {
+ ip_addr = interpret_addr2(my_address->addr);
+
+ ZERO_STRUCT(my_addr);
+#ifdef HAVE_SOCK_SIN_LEN
+ my_addr.sin_len = sizeof(my_addr);
+#endif
+ my_addr.sin_addr.s_addr = ip_addr.addr;
+ my_addr.sin_port = htons(my_address->port);
+ my_addr.sin_family = PF_INET;
+
+ ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
+ }
+
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ if (sock->type == SOCKET_TYPE_STREAM) {
+ ret = listen(sock->fd, queue_size);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
+ if (!(flags & SOCKET_FLAG_BLOCK)) {
+ ret = set_blocking(sock->fd, false);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
+ sock->state= SOCKET_STATE_SERVER_LISTEN;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ipv4_accept(struct socket_context *sock, struct socket_context **new_sock)
+{
+ struct sockaddr_in cli_addr;
+ socklen_t cli_addr_len = sizeof(cli_addr);
+ int new_fd;
+
+ if (sock->type != SOCKET_TYPE_STREAM) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ new_fd = accept(sock->fd, (struct sockaddr *)&cli_addr, &cli_addr_len);
+ if (new_fd == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
+ int ret = set_blocking(new_fd, false);
+ if (ret == -1) {
+ close(new_fd);
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
+ /* TODO: we could add a 'accept_check' hook here
+ * which get the black/white lists via socket_set_accept_filter()
+ * or something like that
+ * --metze
+ */
+
+ (*new_sock) = talloc(NULL, struct socket_context);
+ if (!(*new_sock)) {
+ close(new_fd);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* copy the socket_context */
+ (*new_sock)->type = sock->type;
+ (*new_sock)->state = SOCKET_STATE_SERVER_CONNECTED;
+ (*new_sock)->flags = sock->flags;
+
+ (*new_sock)->fd = new_fd;
+
+ (*new_sock)->private_data = NULL;
+ (*new_sock)->ops = sock->ops;
+ (*new_sock)->backend_name = sock->backend_name;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ip_recv(struct socket_context *sock, void *buf,
+ size_t wantlen, size_t *nread)
+{
+ ssize_t gotlen;
+
+ *nread = 0;
+
+ gotlen = recv(sock->fd, buf, wantlen, 0);
+ if (gotlen == 0) {
+ return NT_STATUS_END_OF_FILE;
+ } else if (gotlen == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ *nread = gotlen;
+
+ return NT_STATUS_OK;
+}
+
+
+static NTSTATUS ipv4_recvfrom(struct socket_context *sock, void *buf,
+ size_t wantlen, size_t *nread,
+ TALLOC_CTX *addr_ctx, struct socket_address **_src)
+{
+ ssize_t gotlen;
+ struct sockaddr_in *from_addr;
+ socklen_t from_len = sizeof(*from_addr);
+ struct socket_address *src;
+ char addrstring[INET_ADDRSTRLEN];
+
+ src = talloc(addr_ctx, struct socket_address);
+ if (!src) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ src->family = sock->backend_name;
+
+ from_addr = talloc(src, struct sockaddr_in);
+ if (!from_addr) {
+ talloc_free(src);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ src->sockaddr = (struct sockaddr *)from_addr;
+
+ *nread = 0;
+
+ gotlen = recvfrom(sock->fd, buf, wantlen, 0,
+ src->sockaddr, &from_len);
+ if (gotlen == 0) {
+ talloc_free(src);
+ return NT_STATUS_END_OF_FILE;
+ } else if (gotlen == -1) {
+ talloc_free(src);
+ return map_nt_error_from_unix(errno);
+ }
+
+ src->sockaddrlen = from_len;
+
+ if (inet_ntop(AF_INET, &from_addr->sin_addr, addrstring,
+ sizeof(addrstring)) == NULL) {
+ talloc_free(src);
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ src->addr = talloc_strdup(src, addrstring);
+ if (src->addr == NULL) {
+ talloc_free(src);
+ return NT_STATUS_NO_MEMORY;
+ }
+ src->port = ntohs(from_addr->sin_port);
+
+ *nread = gotlen;
+ *_src = src;
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ip_send(struct socket_context *sock,
+ const DATA_BLOB *blob, size_t *sendlen)
+{
+ ssize_t len;
+
+ *sendlen = 0;
+
+ len = send(sock->fd, blob->data, blob->length, 0);
+ if (len == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ *sendlen = len;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ipv4_sendto(struct socket_context *sock,
+ const DATA_BLOB *blob, size_t *sendlen,
+ const struct socket_address *dest_addr)
+{
+ ssize_t len;
+
+ if (dest_addr->sockaddr) {
+ len = sendto(sock->fd, blob->data, blob->length, 0,
+ dest_addr->sockaddr, dest_addr->sockaddrlen);
+ } else {
+ struct sockaddr_in srv_addr;
+ struct ipv4_addr addr;
+
+ ZERO_STRUCT(srv_addr);
+#ifdef HAVE_SOCK_SIN_LEN
+ srv_addr.sin_len = sizeof(srv_addr);
+#endif
+ addr = interpret_addr2(dest_addr->addr);
+ if (addr.addr == 0) {
+ return NT_STATUS_HOST_UNREACHABLE;
+ }
+ srv_addr.sin_addr.s_addr = addr.addr;
+ srv_addr.sin_port = htons(dest_addr->port);
+ srv_addr.sin_family = PF_INET;
+
+ *sendlen = 0;
+
+ len = sendto(sock->fd, blob->data, blob->length, 0,
+ (struct sockaddr *)&srv_addr, sizeof(srv_addr));
+ }
+ if (len == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ *sendlen = len;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ipv4_set_option(struct socket_context *sock, const char *option, const char *val)
+{
+ set_socket_options(sock->fd, option);
+ return NT_STATUS_OK;
+}
+
+static char *ipv4_get_peer_name(struct socket_context *sock, TALLOC_CTX *mem_ctx)
+{
+ struct sockaddr_in peer_addr;
+ socklen_t len = sizeof(peer_addr);
+ struct hostent *he;
+ int ret;
+
+ ret = getpeername(sock->fd, (struct sockaddr *)&peer_addr, &len);
+ if (ret == -1) {
+ return NULL;
+ }
+
+ he = gethostbyaddr((char *)&peer_addr.sin_addr, sizeof(peer_addr.sin_addr), AF_INET);
+ if (he == NULL) {
+ return NULL;
+ }
+
+ return talloc_strdup(mem_ctx, he->h_name);
+}
+
+static struct socket_address *ipv4_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
+{
+ struct sockaddr_in *peer_addr;
+ socklen_t len = sizeof(*peer_addr);
+ struct socket_address *peer;
+ char addrstring[INET_ADDRSTRLEN];
+ int ret;
+
+ peer = talloc(mem_ctx, struct socket_address);
+ if (!peer) {
+ return NULL;
+ }
+
+ peer->family = sock->backend_name;
+ peer_addr = talloc(peer, struct sockaddr_in);
+ if (!peer_addr) {
+ talloc_free(peer);
+ return NULL;
+ }
+
+ peer->sockaddr = (struct sockaddr *)peer_addr;
+
+ ret = getpeername(sock->fd, peer->sockaddr, &len);
+ if (ret == -1) {
+ talloc_free(peer);
+ return NULL;
+ }
+
+ peer->sockaddrlen = len;
+
+ if (inet_ntop(AF_INET, &peer_addr->sin_addr, addrstring,
+ sizeof(addrstring)) == NULL) {
+ talloc_free(peer);
+ return NULL;
+ }
+ peer->addr = talloc_strdup(peer, addrstring);
+ if (!peer->addr) {
+ talloc_free(peer);
+ return NULL;
+ }
+ peer->port = ntohs(peer_addr->sin_port);
+
+ return peer;
+}
+
+static struct socket_address *ipv4_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
+{
+ struct sockaddr_in *local_addr;
+ socklen_t len = sizeof(*local_addr);
+ struct socket_address *local;
+ char addrstring[INET_ADDRSTRLEN];
+ int ret;
+
+ local = talloc(mem_ctx, struct socket_address);
+ if (!local) {
+ return NULL;
+ }
+
+ local->family = sock->backend_name;
+ local_addr = talloc(local, struct sockaddr_in);
+ if (!local_addr) {
+ talloc_free(local);
+ return NULL;
+ }
+
+ local->sockaddr = (struct sockaddr *)local_addr;
+
+ ret = getsockname(sock->fd, local->sockaddr, &len);
+ if (ret == -1) {
+ talloc_free(local);
+ return NULL;
+ }
+
+ local->sockaddrlen = len;
+
+ if (inet_ntop(AF_INET, &local_addr->sin_addr, addrstring,
+ sizeof(addrstring)) == NULL) {
+ talloc_free(local);
+ return NULL;
+ }
+ local->addr = talloc_strdup(local, addrstring);
+ if (!local->addr) {
+ talloc_free(local);
+ return NULL;
+ }
+ local->port = ntohs(local_addr->sin_port);
+
+ return local;
+}
+static int ip_get_fd(struct socket_context *sock)
+{
+ return sock->fd;
+}
+
+static NTSTATUS ip_pending(struct socket_context *sock, size_t *npending)
+{
+ int value = 0;
+ if (ioctl(sock->fd, FIONREAD, &value) == 0) {
+ *npending = value;
+ return NT_STATUS_OK;
+ }
+ return map_nt_error_from_unix(errno);
+}
+
+static const struct socket_ops ipv4_ops = {
+ .name = "ipv4",
+ .fn_init = ipv4_init,
+ .fn_connect = ipv4_connect,
+ .fn_connect_complete = ip_connect_complete,
+ .fn_listen = ipv4_listen,
+ .fn_accept = ipv4_accept,
+ .fn_recv = ip_recv,
+ .fn_recvfrom = ipv4_recvfrom,
+ .fn_send = ip_send,
+ .fn_sendto = ipv4_sendto,
+ .fn_pending = ip_pending,
+ .fn_close = ip_close,
+
+ .fn_set_option = ipv4_set_option,
+
+ .fn_get_peer_name = ipv4_get_peer_name,
+ .fn_get_peer_addr = ipv4_get_peer_addr,
+ .fn_get_my_addr = ipv4_get_my_addr,
+
+ .fn_get_fd = ip_get_fd
+};
+
+const struct socket_ops *socket_ipv4_ops(enum socket_type type)
+{
+ return &ipv4_ops;
+}
+
+#if HAVE_IPV6
+
+static struct in6_addr interpret_addr6(const char *name)
+{
+ struct hostent *he;
+
+ if (name == NULL) return in6addr_any;
+
+ if (strcasecmp(name, "localhost") == 0) {
+ name = "::1";
+ }
+
+ he = gethostbyname2(name, PF_INET6);
+
+ if (he == NULL) return in6addr_any;
+
+ return *((struct in6_addr *)he->h_addr);
+}
+
+static NTSTATUS ipv6_init(struct socket_context *sock)
+{
+ int type;
+
+ switch (sock->type) {
+ case SOCKET_TYPE_STREAM:
+ type = SOCK_STREAM;
+ break;
+ case SOCKET_TYPE_DGRAM:
+ type = SOCK_DGRAM;
+ break;
+ default:
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ sock->fd = socket(PF_INET6, type, 0);
+ if (sock->fd == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ sock->backend_name = "ipv6";
+ sock->family = AF_INET6;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ipv6_tcp_connect(struct socket_context *sock,
+ const struct socket_address *my_address,
+ const struct socket_address *srv_address,
+ uint32_t flags)
+{
+ int ret;
+
+ if (my_address && my_address->sockaddr) {
+ ret = bind(sock->fd, my_address->sockaddr, my_address->sockaddrlen);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ } else if (my_address) {
+ struct in6_addr my_ip;
+ my_ip = interpret_addr6(my_address->addr);
+
+ if (memcmp(&my_ip, &in6addr_any, sizeof(my_ip)) || my_address->port != 0) {
+ struct sockaddr_in6 my_addr;
+ ZERO_STRUCT(my_addr);
+ my_addr.sin6_addr = my_ip;
+ my_addr.sin6_port = htons(my_address->port);
+ my_addr.sin6_family = PF_INET6;
+
+ ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ }
+ }
+
+ if (srv_address->sockaddr) {
+ ret = connect(sock->fd, srv_address->sockaddr, srv_address->sockaddrlen);
+ } else {
+ struct in6_addr srv_ip;
+ struct sockaddr_in6 srv_addr;
+ srv_ip = interpret_addr6(srv_address->addr);
+ if (memcmp(&srv_ip, &in6addr_any, sizeof(srv_ip)) == 0) {
+ return NT_STATUS_BAD_NETWORK_NAME;
+ }
+
+ ZERO_STRUCT(srv_addr);
+ srv_addr.sin6_addr = srv_ip;
+ srv_addr.sin6_port = htons(srv_address->port);
+ srv_addr.sin6_family = PF_INET6;
+
+ ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr));
+ }
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ return ip_connect_complete(sock, flags);
+}
+
+static NTSTATUS ipv6_listen(struct socket_context *sock,
+ const struct socket_address *my_address,
+ int queue_size, uint32_t flags)
+{
+ struct sockaddr_in6 my_addr;
+ struct in6_addr ip_addr;
+ int ret;
+
+ socket_set_option(sock, "SO_REUSEADDR=1", NULL);
+
+ if (my_address->sockaddr) {
+ ret = bind(sock->fd, my_address->sockaddr, my_address->sockaddrlen);
+ } else {
+ ip_addr = interpret_addr6(my_address->addr);
+
+ ZERO_STRUCT(my_addr);
+ my_addr.sin6_addr = ip_addr;
+ my_addr.sin6_port = htons(my_address->port);
+ my_addr.sin6_family = PF_INET6;
+
+ ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
+ }
+
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ if (sock->type == SOCKET_TYPE_STREAM) {
+ ret = listen(sock->fd, queue_size);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
+ if (!(flags & SOCKET_FLAG_BLOCK)) {
+ ret = set_blocking(sock->fd, false);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
+ sock->state= SOCKET_STATE_SERVER_LISTEN;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ipv6_tcp_accept(struct socket_context *sock, struct socket_context **new_sock)
+{
+ struct sockaddr_in cli_addr;
+ socklen_t cli_addr_len = sizeof(cli_addr);
+ int new_fd;
+
+ if (sock->type != SOCKET_TYPE_STREAM) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ new_fd = accept(sock->fd, (struct sockaddr *)&cli_addr, &cli_addr_len);
+ if (new_fd == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
+ int ret = set_blocking(new_fd, false);
+ if (ret == -1) {
+ close(new_fd);
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
+ /* TODO: we could add a 'accept_check' hook here
+ * which get the black/white lists via socket_set_accept_filter()
+ * or something like that
+ * --metze
+ */
+
+ (*new_sock) = talloc(NULL, struct socket_context);
+ if (!(*new_sock)) {
+ close(new_fd);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* copy the socket_context */
+ (*new_sock)->type = sock->type;
+ (*new_sock)->state = SOCKET_STATE_SERVER_CONNECTED;
+ (*new_sock)->flags = sock->flags;
+
+ (*new_sock)->fd = new_fd;
+
+ (*new_sock)->private_data = NULL;
+ (*new_sock)->ops = sock->ops;
+ (*new_sock)->backend_name = sock->backend_name;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ipv6_recvfrom(struct socket_context *sock, void *buf,
+ size_t wantlen, size_t *nread,
+ TALLOC_CTX *addr_ctx, struct socket_address **_src)
+{
+ ssize_t gotlen;
+ struct sockaddr_in6 *from_addr;
+ socklen_t from_len = sizeof(*from_addr);
+ struct socket_address *src;
+ char addrstring[INET6_ADDRSTRLEN];
+
+ src = talloc(addr_ctx, struct socket_address);
+ if (!src) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ src->family = sock->backend_name;
+
+ from_addr = talloc(src, struct sockaddr_in6);
+ if (!from_addr) {
+ talloc_free(src);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ src->sockaddr = (struct sockaddr *)from_addr;
+
+ *nread = 0;
+
+ gotlen = recvfrom(sock->fd, buf, wantlen, 0,
+ src->sockaddr, &from_len);
+ if (gotlen == 0) {
+ talloc_free(src);
+ return NT_STATUS_END_OF_FILE;
+ } else if (gotlen == -1) {
+ talloc_free(src);
+ return map_nt_error_from_unix(errno);
+ }
+
+ src->sockaddrlen = from_len;
+
+ if (inet_ntop(AF_INET6, &from_addr->sin6_addr, addrstring, sizeof(addrstring)) == NULL) {
+ DEBUG(0, ("Unable to convert address to string: %s\n", strerror(errno)));
+ talloc_free(src);
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ src->addr = talloc_strdup(src, addrstring);
+ if (src->addr == NULL) {
+ talloc_free(src);
+ return NT_STATUS_NO_MEMORY;
+ }
+ src->port = ntohs(from_addr->sin6_port);
+
+ *nread = gotlen;
+ *_src = src;
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ipv6_sendto(struct socket_context *sock,
+ const DATA_BLOB *blob, size_t *sendlen,
+ const struct socket_address *dest_addr)
+{
+ ssize_t len;
+
+ if (dest_addr->sockaddr) {
+ len = sendto(sock->fd, blob->data, blob->length, 0,
+ dest_addr->sockaddr, dest_addr->sockaddrlen);
+ } else {
+ struct sockaddr_in6 srv_addr;
+ struct in6_addr addr;
+
+ ZERO_STRUCT(srv_addr);
+ addr = interpret_addr6(dest_addr->addr);
+ if (addr.s6_addr == 0) {
+ return NT_STATUS_HOST_UNREACHABLE;
+ }
+ srv_addr.sin6_addr = addr;
+ srv_addr.sin6_port = htons(dest_addr->port);
+ srv_addr.sin6_family = PF_INET6;
+
+ *sendlen = 0;
+
+ len = sendto(sock->fd, blob->data, blob->length, 0,
+ (struct sockaddr *)&srv_addr, sizeof(srv_addr));
+ }
+ if (len == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ *sendlen = len;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ipv6_set_option(struct socket_context *sock, const char *option, const char *val)
+{
+ set_socket_options(sock->fd, option);
+ return NT_STATUS_OK;
+}
+
+static char *ipv6_tcp_get_peer_name(struct socket_context *sock, TALLOC_CTX *mem_ctx)
+{
+ struct sockaddr_in6 peer_addr;
+ socklen_t len = sizeof(peer_addr);
+ struct hostent *he;
+ int ret;
+
+ ret = getpeername(sock->fd, (struct sockaddr *)&peer_addr, &len);
+ if (ret == -1) {
+ return NULL;
+ }
+
+ he = gethostbyaddr((char *)&peer_addr.sin6_addr, sizeof(peer_addr.sin6_addr), AF_INET6);
+ if (he == NULL) {
+ return NULL;
+ }
+
+ return talloc_strdup(mem_ctx, he->h_name);
+}
+
+static struct socket_address *ipv6_tcp_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
+{
+ struct sockaddr_in6 *peer_addr;
+ socklen_t len = sizeof(*peer_addr);
+ struct socket_address *peer;
+ int ret;
+ char addr[128];
+ const char *addr_ret;
+
+ peer = talloc(mem_ctx, struct socket_address);
+ if (!peer) {
+ return NULL;
+ }
+
+ peer->family = sock->backend_name;
+ peer_addr = talloc(peer, struct sockaddr_in6);
+ if (!peer_addr) {
+ talloc_free(peer);
+ return NULL;
+ }
+
+ peer->sockaddr = (struct sockaddr *)peer_addr;
+
+ ret = getpeername(sock->fd, peer->sockaddr, &len);
+ if (ret == -1) {
+ talloc_free(peer);
+ return NULL;
+ }
+
+ peer->sockaddrlen = len;
+
+ addr_ret = inet_ntop(AF_INET6, &peer_addr->sin6_addr, addr, sizeof(addr));
+ if (addr_ret == NULL) {
+ talloc_free(peer);
+ return NULL;
+ }
+
+ peer->addr = talloc_strdup(peer, addr_ret);
+ if (peer->addr == NULL) {
+ talloc_free(peer);
+ return NULL;
+ }
+
+ peer->port = ntohs(peer_addr->sin6_port);
+
+ return peer;
+}
+
+static struct socket_address *ipv6_tcp_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
+{
+ struct sockaddr_in6 *local_addr;
+ socklen_t len = sizeof(*local_addr);
+ struct socket_address *local;
+ int ret;
+ char addrstring[INET6_ADDRSTRLEN];
+
+ local = talloc(mem_ctx, struct socket_address);
+ if (!local) {
+ return NULL;
+ }
+
+ local->family = sock->backend_name;
+ local_addr = talloc(local, struct sockaddr_in6);
+ if (!local_addr) {
+ talloc_free(local);
+ return NULL;
+ }
+
+ local->sockaddr = (struct sockaddr *)local_addr;
+
+ ret = getsockname(sock->fd, local->sockaddr, &len);
+ if (ret == -1) {
+ talloc_free(local);
+ return NULL;
+ }
+
+ local->sockaddrlen = len;
+
+ if (inet_ntop(AF_INET6, &local_addr->sin6_addr, addrstring,
+ sizeof(addrstring)) == NULL) {
+ DEBUG(0, ("Unable to convert address to string: %s\n",
+ strerror(errno)));
+ talloc_free(local);
+ return NULL;
+ }
+
+ local->addr = talloc_strdup(mem_ctx, addrstring);
+ if (!local->addr) {
+ talloc_free(local);
+ return NULL;
+ }
+ local->port = ntohs(local_addr->sin6_port);
+
+ return local;
+}
+
+static const struct socket_ops ipv6_tcp_ops = {
+ .name = "ipv6",
+ .fn_init = ipv6_init,
+ .fn_connect = ipv6_tcp_connect,
+ .fn_connect_complete = ip_connect_complete,
+ .fn_listen = ipv6_listen,
+ .fn_accept = ipv6_tcp_accept,
+ .fn_recv = ip_recv,
+ .fn_recvfrom = ipv6_recvfrom,
+ .fn_send = ip_send,
+ .fn_sendto = ipv6_sendto,
+ .fn_pending = ip_pending,
+ .fn_close = ip_close,
+
+ .fn_set_option = ipv6_set_option,
+
+ .fn_get_peer_name = ipv6_tcp_get_peer_name,
+ .fn_get_peer_addr = ipv6_tcp_get_peer_addr,
+ .fn_get_my_addr = ipv6_tcp_get_my_addr,
+
+ .fn_get_fd = ip_get_fd
+};
+
+const struct socket_ops *socket_ipv6_ops(enum socket_type type)
+{
+ return &ipv6_tcp_ops;
+}
+
+#endif
diff --git a/source4/lib/socket/socket_ipv4.c b/source4/lib/socket/socket_ipv4.c
deleted file mode 100644
index d9a4ff0bd1..0000000000
--- a/source4/lib/socket/socket_ipv4.c
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Socket IPv4 functions
-
- Copyright (C) Stefan Metzmacher 2004
- Copyright (C) Andrew Tridgell 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 "system/filesys.h"
-#include "lib/socket/socket.h"
-#include "system/network.h"
-
-static NTSTATUS ipv4_init(struct socket_context *sock)
-{
- int type;
-
- switch (sock->type) {
- case SOCKET_TYPE_STREAM:
- type = SOCK_STREAM;
- break;
- case SOCKET_TYPE_DGRAM:
- type = SOCK_DGRAM;
- break;
- default:
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- sock->fd = socket(PF_INET, type, 0);
- if (sock->fd == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- sock->backend_name = "ipv4";
-
- return NT_STATUS_OK;
-}
-
-static void ipv4_close(struct socket_context *sock)
-{
- close(sock->fd);
-}
-
-static NTSTATUS ipv4_connect_complete(struct socket_context *sock, uint32_t flags)
-{
- int error=0, ret;
- socklen_t len = sizeof(error);
-
- /* check for any errors that may have occurred - this is needed
- for non-blocking connect */
- ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &error, &len);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- if (error != 0) {
- return map_nt_error_from_unix(error);
- }
-
- if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- }
-
- sock->state = SOCKET_STATE_CLIENT_CONNECTED;
-
- return NT_STATUS_OK;
-}
-
-
-static NTSTATUS ipv4_connect(struct socket_context *sock,
- const struct socket_address *my_address,
- const struct socket_address *srv_address,
- uint32_t flags)
-{
- struct sockaddr_in srv_addr;
- struct ipv4_addr my_ip;
- struct ipv4_addr srv_ip;
- int ret;
-
- if (my_address && my_address->sockaddr) {
- ret = bind(sock->fd, my_address->sockaddr, my_address->sockaddrlen);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- } else if (my_address) {
- my_ip = interpret_addr2(my_address->addr);
-
- if (my_ip.addr != 0 || my_address->port != 0) {
- struct sockaddr_in my_addr;
- ZERO_STRUCT(my_addr);
-#ifdef HAVE_SOCK_SIN_LEN
- my_addr.sin_len = sizeof(my_addr);
-#endif
- my_addr.sin_addr.s_addr = my_ip.addr;
- my_addr.sin_port = htons(my_address->port);
- my_addr.sin_family = PF_INET;
-
- ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- }
- }
-
- if (srv_address->sockaddr) {
- ret = connect(sock->fd, srv_address->sockaddr, srv_address->sockaddrlen);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- } else {
- srv_ip = interpret_addr2(srv_address->addr);
- if (!srv_ip.addr) {
- return NT_STATUS_BAD_NETWORK_NAME;
- }
-
- ZERO_STRUCT(srv_addr);
-#ifdef HAVE_SOCK_SIN_LEN
- srv_addr.sin_len = sizeof(srv_addr);
-#endif
- srv_addr.sin_addr.s_addr= srv_ip.addr;
- srv_addr.sin_port = htons(srv_address->port);
- srv_addr.sin_family = PF_INET;
-
- ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr));
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- }
-
- return ipv4_connect_complete(sock, flags);
-}
-
-
-/*
- note that for simplicity of the API, socket_listen() is also
- use for DGRAM sockets, but in reality only a bind() is done
-*/
-static NTSTATUS ipv4_listen(struct socket_context *sock,
- const struct socket_address *my_address,
- int queue_size, uint32_t flags)
-{
- struct sockaddr_in my_addr;
- struct ipv4_addr ip_addr;
- int ret;
-
- socket_set_option(sock, "SO_REUSEADDR=1", NULL);
-
- if (my_address->sockaddr) {
- ret = bind(sock->fd, my_address->sockaddr, my_address->sockaddrlen);
- } else {
- ip_addr = interpret_addr2(my_address->addr);
-
- ZERO_STRUCT(my_addr);
-#ifdef HAVE_SOCK_SIN_LEN
- my_addr.sin_len = sizeof(my_addr);
-#endif
- my_addr.sin_addr.s_addr = ip_addr.addr;
- my_addr.sin_port = htons(my_address->port);
- my_addr.sin_family = PF_INET;
-
- ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
- }
-
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- if (sock->type == SOCKET_TYPE_STREAM) {
- ret = listen(sock->fd, queue_size);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- }
-
- if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- }
-
- sock->state= SOCKET_STATE_SERVER_LISTEN;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv4_accept(struct socket_context *sock, struct socket_context **new_sock)
-{
- struct sockaddr_in cli_addr;
- socklen_t cli_addr_len = sizeof(cli_addr);
- int new_fd;
-
- if (sock->type != SOCKET_TYPE_STREAM) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- new_fd = accept(sock->fd, (struct sockaddr *)&cli_addr, &cli_addr_len);
- if (new_fd == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
- int ret = set_blocking(new_fd, False);
- if (ret == -1) {
- close(new_fd);
- return map_nt_error_from_unix(errno);
- }
- }
-
- /* TODO: we could add a 'accept_check' hook here
- * which get the black/white lists via socket_set_accept_filter()
- * or something like that
- * --metze
- */
-
- (*new_sock) = talloc(NULL, struct socket_context);
- if (!(*new_sock)) {
- close(new_fd);
- return NT_STATUS_NO_MEMORY;
- }
-
- /* copy the socket_context */
- (*new_sock)->type = sock->type;
- (*new_sock)->state = SOCKET_STATE_SERVER_CONNECTED;
- (*new_sock)->flags = sock->flags;
-
- (*new_sock)->fd = new_fd;
-
- (*new_sock)->private_data = NULL;
- (*new_sock)->ops = sock->ops;
- (*new_sock)->backend_name = sock->backend_name;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv4_recv(struct socket_context *sock, void *buf,
- size_t wantlen, size_t *nread)
-{
- ssize_t gotlen;
-
- *nread = 0;
-
- gotlen = recv(sock->fd, buf, wantlen, 0);
- if (gotlen == 0) {
- return NT_STATUS_END_OF_FILE;
- } else if (gotlen == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- *nread = gotlen;
-
- return NT_STATUS_OK;
-}
-
-
-static NTSTATUS ipv4_recvfrom(struct socket_context *sock, void *buf,
- size_t wantlen, size_t *nread,
- TALLOC_CTX *addr_ctx, struct socket_address **_src)
-{
- ssize_t gotlen;
- struct sockaddr_in *from_addr;
- socklen_t from_len = sizeof(*from_addr);
- struct socket_address *src;
- const char *addr;
-
- src = talloc(addr_ctx, struct socket_address);
- if (!src) {
- return NT_STATUS_NO_MEMORY;
- }
-
- src->family = sock->backend_name;
-
- from_addr = talloc(src, struct sockaddr_in);
- if (!from_addr) {
- talloc_free(src);
- return NT_STATUS_NO_MEMORY;
- }
-
- src->sockaddr = (struct sockaddr *)from_addr;
-
- *nread = 0;
-
- gotlen = recvfrom(sock->fd, buf, wantlen, 0,
- src->sockaddr, &from_len);
- if (gotlen == 0) {
- talloc_free(src);
- return NT_STATUS_END_OF_FILE;
- } else if (gotlen == -1) {
- talloc_free(src);
- return map_nt_error_from_unix(errno);
- }
-
- src->sockaddrlen = from_len;
-
- addr = inet_ntoa(from_addr->sin_addr);
- if (addr == NULL) {
- talloc_free(src);
- return NT_STATUS_INTERNAL_ERROR;
- }
- src->addr = talloc_strdup(src, addr);
- if (src->addr == NULL) {
- talloc_free(src);
- return NT_STATUS_NO_MEMORY;
- }
- src->port = ntohs(from_addr->sin_port);
-
- *nread = gotlen;
- *_src = src;
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv4_send(struct socket_context *sock,
- const DATA_BLOB *blob, size_t *sendlen)
-{
- ssize_t len;
-
- *sendlen = 0;
-
- len = send(sock->fd, blob->data, blob->length, 0);
- if (len == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- *sendlen = len;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv4_sendto(struct socket_context *sock,
- const DATA_BLOB *blob, size_t *sendlen,
- const struct socket_address *dest_addr)
-{
- ssize_t len;
-
- if (dest_addr->sockaddr) {
- len = sendto(sock->fd, blob->data, blob->length, 0,
- dest_addr->sockaddr, dest_addr->sockaddrlen);
- } else {
- struct sockaddr_in srv_addr;
- struct ipv4_addr addr;
-
- ZERO_STRUCT(srv_addr);
-#ifdef HAVE_SOCK_SIN_LEN
- srv_addr.sin_len = sizeof(srv_addr);
-#endif
- addr = interpret_addr2(dest_addr->addr);
- if (addr.addr == 0) {
- return NT_STATUS_HOST_UNREACHABLE;
- }
- srv_addr.sin_addr.s_addr = addr.addr;
- srv_addr.sin_port = htons(dest_addr->port);
- srv_addr.sin_family = PF_INET;
-
- *sendlen = 0;
-
- len = sendto(sock->fd, blob->data, blob->length, 0,
- (struct sockaddr *)&srv_addr, sizeof(srv_addr));
- }
- if (len == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- *sendlen = len;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv4_set_option(struct socket_context *sock, const char *option, const char *val)
-{
- set_socket_options(sock->fd, option);
- return NT_STATUS_OK;
-}
-
-static char *ipv4_get_peer_name(struct socket_context *sock, TALLOC_CTX *mem_ctx)
-{
- struct sockaddr_in peer_addr;
- socklen_t len = sizeof(peer_addr);
- struct hostent *he;
- int ret;
-
- ret = getpeername(sock->fd, (struct sockaddr *)&peer_addr, &len);
- if (ret == -1) {
- return NULL;
- }
-
- he = gethostbyaddr((char *)&peer_addr.sin_addr, sizeof(peer_addr.sin_addr), AF_INET);
- if (he == NULL) {
- return NULL;
- }
-
- return talloc_strdup(mem_ctx, he->h_name);
-}
-
-static struct socket_address *ipv4_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
-{
- struct sockaddr_in *peer_addr;
- socklen_t len = sizeof(*peer_addr);
- const char *addr;
- struct socket_address *peer;
- int ret;
-
- peer = talloc(mem_ctx, struct socket_address);
- if (!peer) {
- return NULL;
- }
-
- peer->family = sock->backend_name;
- peer_addr = talloc(peer, struct sockaddr_in);
- if (!peer_addr) {
- talloc_free(peer);
- return NULL;
- }
-
- peer->sockaddr = (struct sockaddr *)peer_addr;
-
- ret = getpeername(sock->fd, peer->sockaddr, &len);
- if (ret == -1) {
- talloc_free(peer);
- return NULL;
- }
-
- peer->sockaddrlen = len;
-
- addr = inet_ntoa(peer_addr->sin_addr);
- if (addr == NULL) {
- talloc_free(peer);
- return NULL;
- }
- peer->addr = talloc_strdup(peer, addr);
- if (!peer->addr) {
- talloc_free(peer);
- return NULL;
- }
- peer->port = ntohs(peer_addr->sin_port);
-
- return peer;
-}
-
-static struct socket_address *ipv4_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
-{
- struct sockaddr_in *local_addr;
- socklen_t len = sizeof(*local_addr);
- const char *addr;
- struct socket_address *local;
- int ret;
-
- local = talloc(mem_ctx, struct socket_address);
- if (!local) {
- return NULL;
- }
-
- local->family = sock->backend_name;
- local_addr = talloc(local, struct sockaddr_in);
- if (!local_addr) {
- talloc_free(local);
- return NULL;
- }
-
- local->sockaddr = (struct sockaddr *)local_addr;
-
- ret = getsockname(sock->fd, local->sockaddr, &len);
- if (ret == -1) {
- talloc_free(local);
- return NULL;
- }
-
- local->sockaddrlen = len;
-
- addr = inet_ntoa(local_addr->sin_addr);
- if (addr == NULL) {
- talloc_free(local);
- return NULL;
- }
- local->addr = talloc_strdup(local, addr);
- if (!local->addr) {
- talloc_free(local);
- return NULL;
- }
- local->port = ntohs(local_addr->sin_port);
-
- return local;
-}
-static int ipv4_get_fd(struct socket_context *sock)
-{
- return sock->fd;
-}
-
-static NTSTATUS ipv4_pending(struct socket_context *sock, size_t *npending)
-{
- int value = 0;
- if (ioctl(sock->fd, FIONREAD, &value) == 0) {
- *npending = value;
- return NT_STATUS_OK;
- }
- return map_nt_error_from_unix(errno);
-}
-
-static const struct socket_ops ipv4_ops = {
- .name = "ipv4",
- .fn_init = ipv4_init,
- .fn_connect = ipv4_connect,
- .fn_connect_complete = ipv4_connect_complete,
- .fn_listen = ipv4_listen,
- .fn_accept = ipv4_accept,
- .fn_recv = ipv4_recv,
- .fn_recvfrom = ipv4_recvfrom,
- .fn_send = ipv4_send,
- .fn_sendto = ipv4_sendto,
- .fn_pending = ipv4_pending,
- .fn_close = ipv4_close,
-
- .fn_set_option = ipv4_set_option,
-
- .fn_get_peer_name = ipv4_get_peer_name,
- .fn_get_peer_addr = ipv4_get_peer_addr,
- .fn_get_my_addr = ipv4_get_my_addr,
- .fn_get_fd = ipv4_get_fd
-};
-
-const struct socket_ops *socket_ipv4_ops(enum socket_type type)
-{
- return &ipv4_ops;
-}
diff --git a/source4/lib/socket/socket_ipv6.c b/source4/lib/socket/socket_ipv6.c
deleted file mode 100644
index 8b86958417..0000000000
--- a/source4/lib/socket/socket_ipv6.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Socket IPv6 functions
- Copyright (C) Stefan Metzmacher 2004
- Copyright (C) Jelmer Vernooij 2004
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "lib/socket/socket.h"
-#include "system/filesys.h" /* needed for close() */
-#include "system/network.h"
-
-static struct in6_addr interpret_addr6(const char *name)
-{
- struct hostent *he;
-
- if (name == NULL) return in6addr_any;
-
- if (strcasecmp(name, "localhost") == 0) {
- name = "::1";
- }
-
- he = gethostbyname2(name, PF_INET6);
-
- if (he == NULL) return in6addr_any;
-
- return *((struct in6_addr *)he->h_addr);
-}
-
-static NTSTATUS ipv6_tcp_init(struct socket_context *sock)
-{
- sock->fd = socket(PF_INET6, SOCK_STREAM, 0);
- if (sock->fd == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- sock->backend_name = "ipv6";
-
- return NT_STATUS_OK;
-}
-
-static void ipv6_tcp_close(struct socket_context *sock)
-{
- close(sock->fd);
-}
-
-static NTSTATUS ipv6_tcp_connect_complete(struct socket_context *sock, uint32_t flags)
-{
- int error=0, ret;
- socklen_t len = sizeof(error);
-
- /* check for any errors that may have occurred - this is needed
- for non-blocking connect */
- ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &error, &len);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- if (error != 0) {
- return map_nt_error_from_unix(error);
- }
-
- if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- }
-
- sock->state = SOCKET_STATE_CLIENT_CONNECTED;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv6_tcp_connect(struct socket_context *sock,
- const struct socket_address *my_address,
- const struct socket_address *srv_address,
- uint32_t flags)
-{
- int ret;
-
- if (my_address && my_address->sockaddr) {
- ret = bind(sock->fd, my_address->sockaddr, my_address->sockaddrlen);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- } else if (my_address) {
- struct in6_addr my_ip;
- my_ip = interpret_addr6(my_address->addr);
-
- if (memcmp(&my_ip, &in6addr_any, sizeof(my_ip)) || my_address->port != 0) {
- struct sockaddr_in6 my_addr;
- ZERO_STRUCT(my_addr);
- my_addr.sin6_addr = my_ip;
- my_addr.sin6_port = htons(my_address->port);
- my_addr.sin6_family = PF_INET6;
-
- ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- }
- }
-
- if (srv_address->sockaddr) {
- ret = connect(sock->fd, srv_address->sockaddr, srv_address->sockaddrlen);
- } else {
- struct in6_addr srv_ip;
- struct sockaddr_in6 srv_addr;
- srv_ip = interpret_addr6(srv_address->addr);
- if (memcmp(&srv_ip, &in6addr_any, sizeof(srv_ip)) == 0) {
- return NT_STATUS_BAD_NETWORK_NAME;
- }
-
- ZERO_STRUCT(srv_addr);
- srv_addr.sin6_addr = srv_ip;
- srv_addr.sin6_port = htons(srv_address->port);
- srv_addr.sin6_family = PF_INET6;
-
- ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr));
- }
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- return ipv6_tcp_connect_complete(sock, flags);
-}
-
-static NTSTATUS ipv6_tcp_listen(struct socket_context *sock,
- const struct socket_address *my_address,
- int queue_size, uint32_t flags)
-{
- struct sockaddr_in6 my_addr;
- struct in6_addr ip_addr;
- int ret;
-
- socket_set_option(sock, "SO_REUSEADDR=1", NULL);
-
- if (my_address->sockaddr) {
- ret = bind(sock->fd, my_address->sockaddr, my_address->sockaddrlen);
- } else {
- ip_addr = interpret_addr6(my_address->addr);
-
- ZERO_STRUCT(my_addr);
- my_addr.sin6_addr = ip_addr;
- my_addr.sin6_port = htons(my_address->port);
- my_addr.sin6_family = PF_INET6;
-
- ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
- }
-
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- if (sock->type == SOCKET_TYPE_STREAM) {
- ret = listen(sock->fd, queue_size);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- }
-
- if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
- if (ret == -1) {
- return map_nt_error_from_unix(errno);
- }
- }
-
- sock->state= SOCKET_STATE_SERVER_LISTEN;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv6_tcp_accept(struct socket_context *sock, struct socket_context **new_sock)
-{
- struct sockaddr_in cli_addr;
- socklen_t cli_addr_len = sizeof(cli_addr);
- int new_fd;
-
- if (sock->type != SOCKET_TYPE_STREAM) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
-
- new_fd = accept(sock->fd, (struct sockaddr *)&cli_addr, &cli_addr_len);
- if (new_fd == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
- int ret = set_blocking(new_fd, False);
- if (ret == -1) {
- close(new_fd);
- return map_nt_error_from_unix(errno);
- }
- }
-
- /* TODO: we could add a 'accept_check' hook here
- * which get the black/white lists via socket_set_accept_filter()
- * or something like that
- * --metze
- */
-
- (*new_sock) = talloc(NULL, struct socket_context);
- if (!(*new_sock)) {
- close(new_fd);
- return NT_STATUS_NO_MEMORY;
- }
-
- /* copy the socket_context */
- (*new_sock)->type = sock->type;
- (*new_sock)->state = SOCKET_STATE_SERVER_CONNECTED;
- (*new_sock)->flags = sock->flags;
-
- (*new_sock)->fd = new_fd;
-
- (*new_sock)->private_data = NULL;
- (*new_sock)->ops = sock->ops;
- (*new_sock)->backend_name = sock->backend_name;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv6_tcp_recv(struct socket_context *sock, void *buf,
- size_t wantlen, size_t *nread)
-{
- ssize_t gotlen;
-
- *nread = 0;
-
- gotlen = recv(sock->fd, buf, wantlen, 0);
- if (gotlen == 0) {
- return NT_STATUS_END_OF_FILE;
- } else if (gotlen == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- *nread = gotlen;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv6_recvfrom(struct socket_context *sock, void *buf,
- size_t wantlen, size_t *nread,
- TALLOC_CTX *addr_ctx, struct socket_address **_src)
-{
- ssize_t gotlen;
- struct sockaddr_in6 *from_addr;
- socklen_t from_len = sizeof(*from_addr);
- struct socket_address *src;
- struct hostent *he;
-
- src = talloc(addr_ctx, struct socket_address);
- if (!src) {
- return NT_STATUS_NO_MEMORY;
- }
-
- src->family = sock->backend_name;
-
- from_addr = talloc(src, struct sockaddr_in6);
- if (!from_addr) {
- talloc_free(src);
- return NT_STATUS_NO_MEMORY;
- }
-
- src->sockaddr = (struct sockaddr *)from_addr;
-
- *nread = 0;
-
- gotlen = recvfrom(sock->fd, buf, wantlen, 0,
- src->sockaddr, &from_len);
- if (gotlen == 0) {
- talloc_free(src);
- return NT_STATUS_END_OF_FILE;
- } else if (gotlen == -1) {
- talloc_free(src);
- return map_nt_error_from_unix(errno);
- }
-
- src->sockaddrlen = from_len;
-
- he = gethostbyaddr((void *)&from_addr->sin6_addr, sizeof(from_addr->sin6_addr), AF_INET6);
- if (he == NULL) {
- talloc_free(src);
- return NT_STATUS_INTERNAL_ERROR;
- }
- src->addr = talloc_strdup(src, he->h_name);
- if (src->addr == NULL) {
- talloc_free(src);
- return NT_STATUS_NO_MEMORY;
- }
- src->port = ntohs(from_addr->sin6_port);
-
- *nread = gotlen;
- *_src = src;
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv6_tcp_send(struct socket_context *sock,
- const DATA_BLOB *blob, size_t *sendlen)
-{
- ssize_t len;
-
- *sendlen = 0;
-
- len = send(sock->fd, blob->data, blob->length, 0);
- if (len == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- *sendlen = len;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv6_sendto(struct socket_context *sock,
- const DATA_BLOB *blob, size_t *sendlen,
- const struct socket_address *dest_addr)
-{
- ssize_t len;
-
- if (dest_addr->sockaddr) {
- len = sendto(sock->fd, blob->data, blob->length, 0,
- dest_addr->sockaddr, dest_addr->sockaddrlen);
- } else {
- struct sockaddr_in6 srv_addr;
- struct in6_addr addr;
-
- ZERO_STRUCT(srv_addr);
- addr = interpret_addr6(dest_addr->addr);
- if (addr.s6_addr == 0) {
- return NT_STATUS_HOST_UNREACHABLE;
- }
- srv_addr.sin6_addr = addr;
- srv_addr.sin6_port = htons(dest_addr->port);
- srv_addr.sin6_family = PF_INET6;
-
- *sendlen = 0;
-
- len = sendto(sock->fd, blob->data, blob->length, 0,
- (struct sockaddr *)&srv_addr, sizeof(srv_addr));
- }
- if (len == -1) {
- return map_nt_error_from_unix(errno);
- }
-
- *sendlen = len;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipv6_tcp_set_option(struct socket_context *sock, const char *option, const char *val)
-{
- set_socket_options(sock->fd, option);
- return NT_STATUS_OK;
-}
-
-static char *ipv6_tcp_get_peer_name(struct socket_context *sock, TALLOC_CTX *mem_ctx)
-{
- struct sockaddr_in6 peer_addr;
- socklen_t len = sizeof(peer_addr);
- struct hostent *he;
- int ret;
-
- ret = getpeername(sock->fd, (struct sockaddr *)&peer_addr, &len);
- if (ret == -1) {
- return NULL;
- }
-
- he = gethostbyaddr((char *)&peer_addr.sin6_addr, sizeof(peer_addr.sin6_addr), AF_INET6);
- if (he == NULL) {
- return NULL;
- }
-
- return talloc_strdup(mem_ctx, he->h_name);
-}
-
-static struct socket_address *ipv6_tcp_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
-{
- struct sockaddr_in6 *peer_addr;
- socklen_t len = sizeof(*peer_addr);
- struct socket_address *peer;
- int ret;
- char addr[128];
- const char *addr_ret;
-
- peer = talloc(mem_ctx, struct socket_address);
- if (!peer) {
- return NULL;
- }
-
- peer->family = sock->backend_name;
- peer_addr = talloc(peer, struct sockaddr_in6);
- if (!peer_addr) {
- talloc_free(peer);
- return NULL;
- }
-
- peer->sockaddr = (struct sockaddr *)peer_addr;
-
- ret = getpeername(sock->fd, peer->sockaddr, &len);
- if (ret == -1) {
- talloc_free(peer);
- return NULL;
- }
-
- peer->sockaddrlen = len;
-
- addr_ret = inet_ntop(AF_INET6, &peer_addr->sin6_addr, addr, sizeof(addr));
- if (addr_ret == NULL) {
- talloc_free(peer);
- return NULL;
- }
-
- peer->addr = talloc_strdup(peer, addr_ret);
- if (peer->addr == NULL) {
- talloc_free(peer);
- return NULL;
- }
-
- peer->port = ntohs(peer_addr->sin6_port);
-
- return peer;
-}
-
-static struct socket_address *ipv6_tcp_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
-{
- struct sockaddr_in6 *local_addr;
- socklen_t len = sizeof(*local_addr);
- struct socket_address *local;
- int ret;
- struct hostent *he;
-
- local = talloc(mem_ctx, struct socket_address);
- if (!local) {
- return NULL;
- }
-
- local->family = sock->backend_name;
- local_addr = talloc(local, struct sockaddr_in6);
- if (!local_addr) {
- talloc_free(local);
- return NULL;
- }
-
- local->sockaddr = (struct sockaddr *)local_addr;
-
- ret = getsockname(sock->fd, local->sockaddr, &len);
- if (ret == -1) {
- talloc_free(local);
- return NULL;
- }
-
- local->sockaddrlen = len;
-
- he = gethostbyaddr((char *)&local_addr->sin6_addr, len, AF_INET6);
-
- if (!he || !he->h_name) {
- talloc_free(local);
- return NULL;
- }
-
- local->addr = talloc_strdup(mem_ctx, he->h_name);
- if (!local->addr) {
- talloc_free(local);
- return NULL;
- }
- local->port = ntohs(local_addr->sin6_port);
-
- return local;
-}
-
-static int ipv6_tcp_get_fd(struct socket_context *sock)
-{
- return sock->fd;
-}
-
-static NTSTATUS ipv6_pending(struct socket_context *sock, size_t *npending)
-{
- int value = 0;
- if (ioctl(sock->fd, FIONREAD, &value) == 0) {
- *npending = value;
- return NT_STATUS_OK;
- }
- return map_nt_error_from_unix(errno);
-}
-
-static const struct socket_ops ipv6_tcp_ops = {
- .name = "ipv6",
- .fn_init = ipv6_tcp_init,
- .fn_connect = ipv6_tcp_connect,
- .fn_connect_complete = ipv6_tcp_connect_complete,
- .fn_listen = ipv6_tcp_listen,
- .fn_accept = ipv6_tcp_accept,
- .fn_recv = ipv6_tcp_recv,
- .fn_recvfrom = ipv6_recvfrom,
- .fn_sendto = ipv6_sendto,
- .fn_send = ipv6_tcp_send,
- .fn_close = ipv6_tcp_close,
- .fn_pending = ipv6_pending,
-
- .fn_set_option = ipv6_tcp_set_option,
-
- .fn_get_peer_name = ipv6_tcp_get_peer_name,
- .fn_get_peer_addr = ipv6_tcp_get_peer_addr,
- .fn_get_my_addr = ipv6_tcp_get_my_addr,
-
- .fn_get_fd = ipv6_tcp_get_fd
-};
-
-const struct socket_ops *socket_ipv6_ops(enum socket_type type)
-{
- return &ipv6_tcp_ops;
-}
diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c
index 7686fea1d8..cac4b8e913 100644
--- a/source4/lib/socket/socket_unix.c
+++ b/source4/lib/socket/socket_unix.c
@@ -82,7 +82,7 @@ static NTSTATUS unixdom_connect_complete(struct socket_context *sock, uint32_t f
}
if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
+ ret = set_blocking(sock->fd, false);
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
@@ -161,7 +161,7 @@ static NTSTATUS unixdom_listen(struct socket_context *sock,
}
if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
+ ret = set_blocking(sock->fd, false);
if (ret == -1) {
return unixdom_error(errno);
}
@@ -190,7 +190,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock,
}
if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
- int ret = set_blocking(new_fd, False);
+ int ret = set_blocking(new_fd, false);
if (ret == -1) {
close(new_fd);
return map_nt_error_from_unix(errno);
diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c
index ec074ecaeb..c13cb6a3b0 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.c
+++ b/source4/lib/socket_wrapper/socket_wrapper.c
@@ -1288,7 +1288,7 @@ _PUBLIC_ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
return -1;
}
- my_addr = malloc(my_addrlen);
+ my_addr = (struct sockaddr *)malloc(my_addrlen);
if (my_addr == NULL) {
return -1;
}
diff --git a/source4/lib/socket_wrapper/socket_wrapper.h b/source4/lib/socket_wrapper/socket_wrapper.h
index fd1e48610b..cc8b937608 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.h
+++ b/source4/lib/socket_wrapper/socket_wrapper.h
@@ -37,6 +37,7 @@
#define __SOCKET_WRAPPER_H__
const char *socket_wrapper_dir(void);
+unsigned int socket_wrapper_default_iface(void);
int swrap_socket(int family, int type, int protocol);
int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t addrlen);
@@ -131,4 +132,5 @@ int swrap_close(int);
#define close(s) swrap_close(s)
#endif
+
#endif /* __SOCKET_WRAPPER_H__ */
diff --git a/source4/lib/stream/packet.c b/source4/lib/stream/packet.c
index e6cfae7bd6..51021c1fc6 100644
--- a/source4/lib/stream/packet.c
+++ b/source4/lib/stream/packet.c
@@ -39,13 +39,13 @@ struct packet_context {
size_t packet_size;
void *private;
struct fd_event *fde;
- BOOL serialise;
+ bool serialise;
int processing;
- BOOL recv_disable;
- BOOL nofree;
+ bool recv_disable;
+ bool nofree;
- BOOL busy;
- BOOL destructor_called;
+ bool busy;
+ bool destructor_called;
struct send_element {
struct send_element *next, *prev;
@@ -63,7 +63,7 @@ struct packet_context {
static int packet_destructor(struct packet_context *pc)
{
if (pc->busy) {
- pc->destructor_called = True;
+ pc->destructor_called = true;
/* now we refuse the talloc_free() request. The free will
happen again in the packet_recv() code */
return -1;
@@ -156,7 +156,7 @@ _PUBLIC_ void packet_set_fde(struct packet_context *pc, struct fd_event *fde)
*/
_PUBLIC_ void packet_set_serialise(struct packet_context *pc)
{
- pc->serialise = True;
+ pc->serialise = true;
}
/*
@@ -173,7 +173,7 @@ _PUBLIC_ void packet_set_initial_read(struct packet_context *pc, uint32_t initia
*/
_PUBLIC_ void packet_set_nofree(struct packet_context *pc)
{
- pc->nofree = True;
+ pc->nofree = true;
}
@@ -373,11 +373,11 @@ next_partial:
pc->processing = 1;
}
- pc->busy = True;
+ pc->busy = true;
status = pc->callback(pc->private, blob);
- pc->busy = False;
+ pc->busy = false;
if (pc->destructor_called) {
talloc_free(pc);
@@ -429,7 +429,7 @@ next_partial:
_PUBLIC_ void packet_recv_disable(struct packet_context *pc)
{
EVENT_FD_NOT_READABLE(pc->fde);
- pc->recv_disable = True;
+ pc->recv_disable = true;
}
/*
@@ -438,7 +438,7 @@ _PUBLIC_ void packet_recv_disable(struct packet_context *pc)
_PUBLIC_ void packet_recv_enable(struct packet_context *pc)
{
EVENT_FD_READABLE(pc->fde);
- pc->recv_disable = False;
+ pc->recv_disable = false;
if (pc->num_read != 0 && pc->packet_size >= pc->num_read) {
event_add_timed(pc->ev, pc, timeval_zero(), packet_next_event, pc);
}
diff --git a/source4/lib/talloc/config.mk b/source4/lib/talloc/config.mk
index 0f138aafcd..714ad72d1c 100644
--- a/source4/lib/talloc/config.mk
+++ b/source4/lib/talloc/config.mk
@@ -5,7 +5,7 @@ VERSION = 0.0.1
SO_VERSION = 0
OBJ_FILES = talloc.o
MANPAGE = talloc.3
-CFLAGS = -I$(srcdir)/lib/talloc
+CFLAGS = -Ilib/talloc
PUBLIC_HEADERS = talloc.h
DESCRIPTION = A hierarchical pool based memory system with destructors
#
diff --git a/source4/lib/talloc/configure.ac b/source4/lib/talloc/configure.ac
index e1e84b25c3..afc2a944f0 100644
--- a/source4/lib/talloc/configure.ac
+++ b/source4/lib/talloc/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ(2.50)
-AC_INIT(talloc, 1.0.1)
+AC_INIT(talloc, 1.1.0)
AC_CONFIG_SRCDIR([talloc.c])
AC_SUBST(datarootdir)
AC_CONFIG_HEADER(config.h)
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c
index c073a8c774..4d72c0e871 100644
--- a/source4/lib/talloc/talloc.c
+++ b/source4/lib/talloc/talloc.c
@@ -1109,64 +1109,132 @@ void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name
return newp;
}
+static inline char *__talloc_strlendup(const void *t, const char *p, size_t len)
+{
+ char *ret;
+
+ ret = (char *)__talloc(t, len + 1);
+ if (unlikely(!ret)) return NULL;
+
+ memcpy(ret, p, len);
+ ret[len] = 0;
+
+ _talloc_set_name_const(ret, ret);
+ return ret;
+}
+
/*
- strdup with a talloc
+ strdup with a talloc
*/
char *talloc_strdup(const void *t, const char *p)
{
+ if (unlikely(!p)) return NULL;
+ return __talloc_strlendup(t, p, strlen(p));
+}
+
+/*
+ strndup with a talloc
+*/
+char *talloc_strndup(const void *t, const char *p, size_t n)
+{
+ if (unlikely(!p)) return NULL;
+ return __talloc_strlendup(t, p, strnlen(p, n));
+}
+
+static inline char *__talloc_strlendup_append(char *s, size_t slen,
+ const char *a, size_t alen)
+{
char *ret;
- if (!p) {
- return NULL;
+
+ ret = talloc_realloc(NULL, s, char, slen + alen + 1);
+ if (unlikely(!ret)) return NULL;
+
+ /* append the string and the trailing \0 */
+ memcpy(&ret[slen], a, alen);
+ ret[slen+alen] = 0;
+
+ _talloc_set_name_const(ret, ret);
+ return ret;
+}
+
+/*
+ * Appends at the end of the string.
+ */
+char *talloc_strdup_append(char *s, const char *a)
+{
+ if (unlikely(!s)) {
+ return talloc_strdup(NULL, a);
}
- ret = (char *)talloc_memdup(t, p, strlen(p) + 1);
- if (likely(ret)) {
- _talloc_set_name_const(ret, ret);
+
+ if (unlikely(!a)) {
+ return s;
}
- return ret;
+
+ return __talloc_strlendup_append(s, strlen(s), a, strlen(a));
}
/*
- append to a talloced string
-*/
-char *talloc_append_string(const void *t, char *orig, const char *append)
+ * Appends at the end of the talloc'ed buffer,
+ * not the end of the string.
+ */
+char *talloc_strdup_append_buffer(char *s, const char *a)
{
- char *ret;
- size_t olen = strlen(orig);
- size_t alenz;
+ size_t slen;
- if (!append)
- return orig;
+ if (unlikely(!s)) {
+ return talloc_strdup(NULL, a);
+ }
- alenz = strlen(append) + 1;
+ if (unlikely(!a)) {
+ return s;
+ }
- ret = talloc_realloc(t, orig, char, olen + alenz);
- if (!ret)
- return NULL;
+ slen = talloc_get_size(s);
+ if (likely(slen > 0)) {
+ slen--;
+ }
- /* append the string with the trailing \0 */
- memcpy(&ret[olen], append, alenz);
+ return __talloc_strlendup_append(s, slen, a, strlen(a));
+}
- _talloc_set_name_const(ret, ret);
+/*
+ * Appends at the end of the string.
+ */
+char *talloc_strndup_append(char *s, const char *a, size_t n)
+{
+ if (unlikely(!s)) {
+ return talloc_strdup(NULL, a);
+ }
- return ret;
+ if (unlikely(!a)) {
+ return s;
+ }
+
+ return __talloc_strlendup_append(s, strlen(s), a, strnlen(a, n));
}
/*
- strndup with a talloc
-*/
-char *talloc_strndup(const void *t, const char *p, size_t n)
+ * Appends at the end of the talloc'ed buffer,
+ * not the end of the string.
+ */
+char *talloc_strndup_append_buffer(char *s, const char *a, size_t n)
{
- size_t len;
- char *ret;
+ size_t slen;
- for (len=0; len<n && p[len]; len++) ;
+ if (unlikely(!s)) {
+ return talloc_strdup(NULL, a);
+ }
- ret = (char *)__talloc(t, len + 1);
- if (!ret) { return NULL; }
- memcpy(ret, p, len);
- ret[len] = 0;
- _talloc_set_name_const(ret, ret);
- return ret;
+ if (unlikely(!a)) {
+ return s;
+ }
+
+ slen = talloc_get_size(s);
+ if (likely(slen > 0)) {
+ slen--;
+ }
+
+ return __talloc_strlendup_append(s, slen, a, strnlen(a, n));
}
#ifndef HAVE_VA_COPY
@@ -1188,18 +1256,18 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
va_copy(ap2, ap);
len = vsnprintf(&c, 1, fmt, ap2);
va_end(ap2);
- if (len < 0) {
+ if (unlikely(len < 0)) {
return NULL;
}
ret = (char *)__talloc(t, len+1);
- if (ret) {
- va_copy(ap2, ap);
- vsnprintf(ret, len+1, fmt, ap2);
- va_end(ap2);
- _talloc_set_name_const(ret, ret);
- }
+ if (unlikely(!ret)) return NULL;
+
+ va_copy(ap2, ap);
+ vsnprintf(ret, len+1, fmt, ap2);
+ va_end(ap2);
+ _talloc_set_name_const(ret, ret);
return ret;
}
@@ -1219,52 +1287,78 @@ char *talloc_asprintf(const void *t, const char *fmt, ...)
return ret;
}
+static inline char *__talloc_vaslenprintf_append(char *s, size_t slen,
+ const char *fmt, va_list ap)
+ PRINTF_ATTRIBUTE(3,0);
-/**
- * Realloc @p s to append the formatted result of @p fmt and @p ap,
- * and return @p s, which may have moved. Good for gradually
- * accumulating output into a string buffer.
- **/
-char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
-{
- struct talloc_chunk *tc;
- int len, s_len;
+static inline char *__talloc_vaslenprintf_append(char *s, size_t slen,
+ const char *fmt, va_list ap)
+{
+ ssize_t alen;
va_list ap2;
char c;
- if (s == NULL) {
- return talloc_vasprintf(NULL, fmt, ap);
- }
-
- tc = talloc_chunk_from_ptr(s);
-
- s_len = tc->size - 1;
-
va_copy(ap2, ap);
- len = vsnprintf(&c, 1, fmt, ap2);
+ alen = vsnprintf(&c, 1, fmt, ap2);
va_end(ap2);
- if (len <= 0) {
+ if (alen <= 0) {
/* Either the vsnprintf failed or the format resulted in
* no characters being formatted. In the former case, we
* ought to return NULL, in the latter we ought to return
- * the original string. Most current callers of this
+ * the original string. Most current callers of this
* function expect it to never return NULL.
*/
return s;
}
- s = talloc_realloc(NULL, s, char, s_len + len+1);
+ s = talloc_realloc(NULL, s, char, slen + alen + 1);
if (!s) return NULL;
va_copy(ap2, ap);
- vsnprintf(s+s_len, len+1, fmt, ap2);
+ vsnprintf(s + slen, alen + 1, fmt, ap2);
va_end(ap2);
- _talloc_set_name_const(s, s);
+ _talloc_set_name_const(s, s);
return s;
}
+/**
+ * Realloc @p s to append the formatted result of @p fmt and @p ap,
+ * and return @p s, which may have moved. Good for gradually
+ * accumulating output into a string buffer. Appends at the end
+ * of the string.
+ **/
+char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
+{
+ if (unlikely(!s)) {
+ return talloc_vasprintf(NULL, fmt, ap);
+ }
+
+ return __talloc_vaslenprintf_append(s, strlen(s), fmt, ap);
+}
+
+/**
+ * Realloc @p s to append the formatted result of @p fmt and @p ap,
+ * and return @p s, which may have moved. Always appends at the
+ * end of the talloc'ed buffer, not the end of the string.
+ **/
+char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap)
+{
+ size_t slen;
+
+ if (unlikely(!s)) {
+ return talloc_vasprintf(NULL, fmt, ap);
+ }
+
+ slen = talloc_get_size(s);
+ if (likely(slen > 0)) {
+ slen--;
+ }
+
+ return __talloc_vaslenprintf_append(s, slen, fmt, ap);
+}
+
/*
Realloc @p s to append the formatted result of @p fmt and return @p
s, which may have moved. Good for gradually accumulating output
@@ -1281,6 +1375,21 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...)
}
/*
+ Realloc @p s to append the formatted result of @p fmt and return @p
+ s, which may have moved. Good for gradually accumulating output
+ into a buffer.
+ */
+char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ s = talloc_vasprintf_append_buffer(s, fmt, ap);
+ va_end(ap);
+ return s;
+}
+
+/*
alloc an array, checking for integer overflow in the array size
*/
void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name)
diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h
index 15130d0d98..e103391681 100644
--- a/source4/lib/talloc/talloc.h
+++ b/source4/lib/talloc/talloc.h
@@ -111,6 +111,7 @@ typedef void TALLOC_CTX;
#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count)
#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count)
#define talloc_destroy(ctx) talloc_free(ctx)
+#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a))
#endif
/* The following definitions come from talloc.c */
@@ -152,13 +153,6 @@ void talloc_enable_leak_report(void);
void talloc_enable_leak_report_full(void);
void *_talloc_zero(const void *ctx, size_t size, const char *name);
void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name);
-char *talloc_strdup(const void *t, const char *p);
-char *talloc_strndup(const void *t, const char *p, size_t n);
-char *talloc_append_string(const void *t, char *orig, const char *append);
-char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
-char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
-char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name);
void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name);
void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name);
@@ -169,4 +163,20 @@ void *talloc_find_parent_byname(const void *ctx, const char *name);
void talloc_show_parents(const void *context, FILE *file);
int talloc_is_parent(const void *context, const void *ptr);
+char *talloc_strdup(const void *t, const char *p);
+char *talloc_strdup_append(char *s, const char *a);
+char *talloc_strdup_append_buffer(char *s, const char *a);
+
+char *talloc_strndup(const void *t, const char *p, size_t n);
+char *talloc_strndup_append(char *s, const char *a, size_t n);
+char *talloc_strndup_append_buffer(char *s, const char *a, size_t n);
+
+char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+
+char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+
#endif
diff --git a/source4/lib/talloc/talloc_guide.txt b/source4/lib/talloc/talloc_guide.txt
index c4634ae19a..18663b370d 100644
--- a/source4/lib/talloc/talloc_guide.txt
+++ b/source4/lib/talloc/talloc_guide.txt
@@ -568,8 +568,23 @@ string. This is equivalent to:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
char *talloc_asprintf_append(char *s, const char *fmt, ...);
+The talloc_asprintf_append() function appends the given formatted
+string to the given string.
+Use this varient when the string in the current talloc buffer may
+have been truncated in length.
+
+This functions sets the name of the new pointer to the new
+string. This is equivalent to:
+ talloc_set_name_const(ptr, ptr)
+
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...);
+
The talloc_asprintf_append() function appends the given formatted
-string to the given string.
+string to the end of the currently allocated talloc buffer.
+Use this varient when the string in the current talloc buffer has
+not been changed.
This functions sets the name of the new pointer to the new
string. This is equivalent to:
@@ -577,7 +592,7 @@ string. This is equivalent to:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(type *)talloc_array(const void *ctx, type, uint_t count);
+((type *)talloc_array(const void *ctx, type, uint_t count);
The talloc_array() macro is equivalent to:
diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c
index ddf6865b1a..e16c91f8b9 100644
--- a/source4/lib/talloc/testsuite.c
+++ b/source4/lib/talloc/testsuite.c
@@ -419,15 +419,15 @@ static bool test_misc(void)
p2 = talloc_strndup(p1, "foo", 2);
torture_assert("misc", strcmp("fo", p2) == 0,
"strndup doesn't work\n");
- p2 = talloc_asprintf_append(p2, "o%c", 'd');
+ p2 = talloc_asprintf_append_buffer(p2, "o%c", 'd');
torture_assert("misc", strcmp("food", p2) == 0,
- "talloc_asprintf_append doesn't work\n");
+ "talloc_asprintf_append_buffer doesn't work\n");
CHECK_BLOCKS("misc", p2, 1);
CHECK_BLOCKS("misc", p1, 3);
- p2 = talloc_asprintf_append(NULL, "hello %s", "world");
+ p2 = talloc_asprintf_append_buffer(NULL, "hello %s", "world");
torture_assert("misc", strcmp("hello world", p2) == 0,
- "talloc_asprintf_append doesn't work\n");
+ "talloc_asprintf_append_buffer doesn't work\n");
CHECK_BLOCKS("misc", p2, 1);
CHECK_BLOCKS("misc", p1, 3);
talloc_free(p2);
diff --git a/source4/lib/tdb/swig/Tdb.py b/source4/lib/tdb/swig/Tdb.py
index 529d0753d1..d1a506e69c 100644
--- a/source4/lib/tdb/swig/Tdb.py
+++ b/source4/lib/tdb/swig/Tdb.py
@@ -69,7 +69,7 @@ class Tdb:
tdb_delete(self.tdb, key)
def has_key(self, key):
- return tdb_exists(self.tdb, key)
+ return tdb_exists(self.tdb, key) != 0
# Tdb iterator
@@ -113,3 +113,7 @@ class Tdb:
def clear(self):
for k in iter(self):
del(self[k])
+
+ # TODO: iterkeys, itervalues, iteritems
+
+ # TODO: any other missing methods for container types
diff --git a/source4/lib/tdb/swig/tdb.i b/source4/lib/tdb/swig/tdb.i
index fbb0f29dec..1ff21f53b5 100644
--- a/source4/lib/tdb/swig/tdb.i
+++ b/source4/lib/tdb/swig/tdb.i
@@ -102,7 +102,21 @@ typedef int mode_t;
#define TDB_CONVERT 16 /* convert endian (internal use) */
#define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */
-/* Throw an IOError exception if tdb_open() or tdb_open_ex() returns NULL */
+enum TDB_ERROR {
+ TDB_SUCCESS=0,
+ TDB_ERR_CORRUPT,
+ TDB_ERR_IO,
+ TDB_ERR_LOCK,
+ TDB_ERR_OOM,
+ TDB_ERR_EXISTS,
+ TDB_ERR_NOLOCK,
+ TDB_ERR_LOCK_TIMEOUT,
+ TDB_ERR_NOEXIST,
+ TDB_ERR_EINVAL,
+ TDB_ERR_RDONLY
+};
+
+/* Throw an IOError exception from errno if tdb_open() returns NULL */
%exception {
$action
@@ -115,19 +129,8 @@ typedef int mode_t;
TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode);
-TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode,
- tdb_log_func log_fn,
- tdb_hash_func hash_fn);
-
%exception;
-int tdb_reopen(TDB_CONTEXT *tdb);
-
-int tdb_reopen_all(int parent_longlived);
-
-void tdb_logging_function(TDB_CONTEXT *tdb, tdb_log_func);
-
enum TDB_ERROR tdb_error(TDB_CONTEXT *tdb);
const char *tdb_errorstr(TDB_CONTEXT *tdb);
@@ -146,22 +149,4 @@ TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb);
TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key);
-int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *state);
-
int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key);
-
-int tdb_lockall(TDB_CONTEXT *tdb);
-
-void tdb_unlockall(TDB_CONTEXT *tdb);
-
-/* Low level locking functions: use with care */
-
-int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key);
-
-int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key);
-
-/* Debug functions. Not used in production. */
-
-void tdb_dump_all(TDB_CONTEXT *tdb);
-
-int tdb_printfreelist(TDB_CONTEXT *tdb);
diff --git a/source4/lib/tdb/tools/tdbtorture.c b/source4/lib/tdb/tools/tdbtorture.c
index 14a2b48cdc..ca71c736ad 100644
--- a/source4/lib/tdb/tools/tdbtorture.c
+++ b/source4/lib/tdb/tools/tdbtorture.c
@@ -238,7 +238,7 @@ static void usage(void)
unlink("torture.tdb");
- pids = calloc(sizeof(pid_t), num_procs);
+ pids = (pid_t *)calloc(sizeof(pid_t), num_procs);
pids[0] = getpid();
for (i=0;i<num_procs-1;i++) {
diff --git a/source4/lib/tls/tls.c b/source4/lib/tls/tls.c
index bfe144a011..4a8357d93b 100644
--- a/source4/lib/tls/tls.c
+++ b/source4/lib/tls/tls.c
@@ -24,6 +24,8 @@
#include "includes.h"
#include "lib/events/events.h"
#include "lib/socket/socket.h"
+#include "lib/tls/tls.h"
+#include "param/param.h"
#if ENABLE_GNUTLS
#include "gnutls/gnutls.h"
@@ -38,7 +40,7 @@ typedef gnutls_datum gnutls_datum_t;
struct tls_params {
gnutls_certificate_credentials x509_cred;
gnutls_dh_params dh_params;
- BOOL tls_enabled;
+ bool tls_enabled;
};
#endif
@@ -46,32 +48,32 @@ struct tls_params {
struct tls_context {
struct socket_context *socket;
struct fd_event *fde;
- BOOL tls_enabled;
+ bool tls_enabled;
#if ENABLE_GNUTLS
gnutls_session session;
- BOOL done_handshake;
- BOOL have_first_byte;
+ bool done_handshake;
+ bool have_first_byte;
uint8_t first_byte;
- BOOL tls_detect;
+ bool tls_detect;
const char *plain_chars;
- BOOL output_pending;
+ bool output_pending;
gnutls_certificate_credentials xcred;
- BOOL interrupted;
+ bool interrupted;
#endif
};
-BOOL tls_enabled(struct socket_context *sock)
+bool tls_enabled(struct socket_context *sock)
{
struct tls_context *tls;
if (!sock) {
- return False;
+ return false;
}
if (strcmp(sock->backend_name, "tls") != 0) {
- return False;
+ return false;
}
tls = talloc_get_type(sock->private_data, struct tls_context);
if (!tls) {
- return False;
+ return false;
}
return tls->tls_enabled;
}
@@ -115,7 +117,7 @@ static ssize_t tls_pull(gnutls_transport_ptr ptr, void *buf, size_t size)
if (tls->have_first_byte) {
*(uint8_t *)buf = tls->first_byte;
- tls->have_first_byte = False;
+ tls->have_first_byte = false;
return 1;
}
@@ -211,7 +213,7 @@ static NTSTATUS tls_handshake(struct tls_context *tls)
DEBUG(0,("TLS gnutls_handshake failed - %s\n", gnutls_strerror(ret)));
return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
}
- tls->done_handshake = True;
+ tls->done_handshake = true;
return NT_STATUS_OK;
}
@@ -233,7 +235,7 @@ static NTSTATUS tls_interrupted(struct tls_context *tls)
if (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN) {
return STATUS_MORE_ENTRIES;
}
- tls->interrupted = False;
+ tls->interrupted = false;
return NT_STATUS_OK;
}
@@ -272,15 +274,15 @@ static NTSTATUS tls_socket_recv(struct socket_context *sock, void *buf,
status = socket_recv(tls->socket, &tls->first_byte, 1, nread);
NT_STATUS_NOT_OK_RETURN(status);
if (*nread == 0) return NT_STATUS_OK;
- tls->tls_detect = False;
+ tls->tls_detect = false;
/* look for the first byte of a valid HTTP operation */
if (strchr(tls->plain_chars, tls->first_byte)) {
/* not a tls link */
- tls->tls_enabled = False;
+ tls->tls_enabled = false;
*(uint8_t *)buf = tls->first_byte;
return NT_STATUS_OK;
}
- tls->have_first_byte = True;
+ tls->have_first_byte = true;
}
if (!tls->tls_enabled) {
@@ -298,7 +300,7 @@ static NTSTATUS tls_socket_recv(struct socket_context *sock, void *buf,
if (gnutls_record_get_direction(tls->session) == 1) {
EVENT_FD_WRITEABLE(tls->fde);
}
- tls->interrupted = True;
+ tls->interrupted = true;
return STATUS_MORE_ENTRIES;
}
if (ret < 0) {
@@ -334,7 +336,7 @@ static NTSTATUS tls_socket_send(struct socket_context *sock,
if (gnutls_record_get_direction(tls->session) == 1) {
EVENT_FD_WRITEABLE(tls->fde);
}
- tls->interrupted = True;
+ tls->interrupted = true;
return STATUS_MORE_ENTRIES;
}
if (ret < 0) {
@@ -355,11 +357,11 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx)
struct tls_params *params;
int ret;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
- const char *keyfile = private_path(tmp_ctx, lp_tls_keyfile());
- const char *certfile = private_path(tmp_ctx, lp_tls_certfile());
- const char *cafile = private_path(tmp_ctx, lp_tls_cafile());
- const char *crlfile = private_path(tmp_ctx, lp_tls_crlfile());
- const char *dhpfile = private_path(tmp_ctx, lp_tls_dhpfile());
+ const char *keyfile = private_path(tmp_ctx, global_loadparm, lp_tls_keyfile(global_loadparm));
+ const char *certfile = private_path(tmp_ctx, global_loadparm, lp_tls_certfile(global_loadparm));
+ const char *cafile = private_path(tmp_ctx, global_loadparm, lp_tls_cafile(global_loadparm));
+ const char *crlfile = private_path(tmp_ctx, global_loadparm, lp_tls_crlfile(global_loadparm));
+ const char *dhpfile = private_path(tmp_ctx, global_loadparm, lp_tls_dhpfile(global_loadparm));
void tls_cert_generate(TALLOC_CTX *, const char *, const char *, const char *);
params = talloc(mem_ctx, struct tls_params);
@@ -368,8 +370,8 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx)
return NULL;
}
- if (!lp_tls_enabled() || keyfile == NULL || *keyfile == 0) {
- params->tls_enabled = False;
+ if (!lp_tls_enabled(global_loadparm) || keyfile == NULL || *keyfile == 0) {
+ params->tls_enabled = false;
talloc_free(tmp_ctx);
return params;
}
@@ -436,14 +438,14 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx)
gnutls_certificate_set_dh_params(params->x509_cred, params->dh_params);
- params->tls_enabled = True;
+ params->tls_enabled = true;
talloc_free(tmp_ctx);
return params;
init_failed:
DEBUG(0,("GNUTLS failed to initialise - %s\n", gnutls_strerror(ret)));
- params->tls_enabled = False;
+ params->tls_enabled = false;
talloc_free(tmp_ctx);
return params;
}
@@ -508,16 +510,16 @@ struct socket_context *tls_init_server(struct tls_params *params,
tls->plain_chars = plain_chars;
if (plain_chars) {
- tls->tls_detect = True;
+ tls->tls_detect = true;
} else {
- tls->tls_detect = False;
+ tls->tls_detect = false;
}
- tls->output_pending = False;
- tls->done_handshake = False;
- tls->have_first_byte = False;
- tls->tls_enabled = True;
- tls->interrupted = False;
+ tls->output_pending = false;
+ tls->done_handshake = false;
+ tls->have_first_byte = false;
+ tls->tls_enabled = true;
+ tls->interrupted = false;
new_sock->state = SOCKET_STATE_SERVER_CONNECTED;
@@ -563,7 +565,7 @@ struct socket_context *tls_init_client(struct socket_context *socket,
}
new_sock->private_data = tls;
- cafile = private_path(tls, lp_tls_cafile());
+ cafile = private_path(tls, global_loadparm, lp_tls_cafile(global_loadparm));
if (!cafile || !*cafile) {
goto failed;
}
@@ -584,13 +586,13 @@ struct socket_context *tls_init_client(struct socket_context *socket,
gnutls_transport_set_pull_function(tls->session, (gnutls_pull_func)tls_pull);
gnutls_transport_set_push_function(tls->session, (gnutls_push_func)tls_push);
gnutls_transport_set_lowat(tls->session, 0);
- tls->tls_detect = False;
+ tls->tls_detect = false;
- tls->output_pending = False;
- tls->done_handshake = False;
- tls->have_first_byte = False;
- tls->tls_enabled = True;
- tls->interrupted = False;
+ tls->output_pending = false;
+ tls->done_handshake = false;
+ tls->have_first_byte = false;
+ tls->tls_enabled = true;
+ tls->interrupted = false;
new_sock->state = SOCKET_STATE_CLIENT_CONNECTED;
@@ -598,7 +600,7 @@ struct socket_context *tls_init_client(struct socket_context *socket,
failed:
DEBUG(0,("TLS init connection failed - %s\n", gnutls_strerror(ret)));
- tls->tls_enabled = False;
+ tls->tls_enabled = false;
return new_sock;
}
@@ -647,7 +649,7 @@ static const struct socket_ops tls_socket_ops = {
.fn_get_fd = tls_socket_get_fd
};
-BOOL tls_support(struct tls_params *params)
+bool tls_support(struct tls_params *params)
{
return params->tls_enabled;
}
@@ -683,9 +685,9 @@ struct socket_context *tls_init_client(struct socket_context *socket,
return NULL;
}
-BOOL tls_support(struct tls_params *params)
+bool tls_support(struct tls_params *params)
{
- return False;
+ return false;
}
#endif
diff --git a/source4/lib/tls/tlscert.c b/source4/lib/tls/tlscert.c
index ad65df0e6c..240ae056c1 100644
--- a/source4/lib/tls/tlscert.c
+++ b/source4/lib/tls/tlscert.c
@@ -153,5 +153,5 @@ failed:
}
#else
- void tls_cert_dummy(void) {}
+void tls_cert_dummy(void) {}
#endif
diff --git a/source4/lib/util/attr.h b/source4/lib/util/attr.h
new file mode 100644
index 0000000000..8f6c4f5d8a
--- /dev/null
+++ b/source4/lib/util/attr.h
@@ -0,0 +1,92 @@
+/*
+ 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/>.
+*/
+
+#ifndef __UTIL_ATTR_H__
+#define __UTIL_ATTR_H__
+
+#ifdef __GNUC__
+/** gcc attribute used on function parameters so that it does not emit
+ * warnings about them being unused. **/
+# define UNUSED(param) param __attribute__ ((unused))
+#else
+# define UNUSED(param) param
+/** Feel free to add definitions for other compilers here. */
+#endif
+
+#ifndef _PUBLIC_
+#ifdef HAVE_VISIBILITY_ATTR
+# define _PUBLIC_ __attribute__((visibility("default")))
+#else
+# define _PUBLIC_
+#endif
+#endif
+
+#ifndef _DEPRECATED_
+#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
+#define _DEPRECATED_ __attribute__ ((deprecated))
+#else
+#define _DEPRECATED_
+#endif
+#endif
+
+#ifndef _WARN_UNUSED_RESULT_
+#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
+#define _WARN_UNUSED_RESULT_ __attribute__ ((warn_unused_result))
+#else
+#define _WARN_UNUSED_RESULT_
+#endif
+#endif
+
+#ifndef _NORETURN_
+#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
+#define _NORETURN_ __attribute__ ((noreturn))
+#else
+#define _NORETURN_
+#endif
+#endif
+
+#ifndef _PURE_
+#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
+#define _PURE_ __attribute__((pure))
+#else
+#define _PURE_
+#endif
+#endif
+
+#ifndef NONNULL
+#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1)
+#define NONNULL(param) param __attribute__((nonnull))
+#else
+#define NONNULL(param) param
+#endif
+#endif
+
+#ifndef PRINTF_ATTRIBUTE
+#if __GNUC__ >= 3
+/** Use gcc attribute to check printf fns. a1 is the 1-based index of
+ * the parameter containing the format, and a2 the index of the first
+ * argument. Note that some gcc 2.x versions don't handle this
+ * properly **/
+#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
+#else
+#define PRINTF_ATTRIBUTE(a1, a2)
+#endif
+#endif
+
+#endif /* __UTIL_ATTR_H__ */
diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk
index 702e3df5aa..0691bd7889 100644
--- a/source4/lib/util/config.mk
+++ b/source4/lib/util/config.mk
@@ -3,6 +3,7 @@
#SO_VERSION = 0
#DESCRIPTION = Generic utility functions
PUBLIC_HEADERS = util.h \
+ attr.h \
byteorder.h \
data_blob.h \
debug.h \
@@ -31,7 +32,7 @@ OBJ_FILES = xfile.o \
PUBLIC_DEPENDENCIES = \
LIBTALLOC LIBCRYPTO \
SOCKET_WRAPPER EXT_NSL \
- CHARSET
+ CHARSET EXECINFO
[SUBSYSTEM::UNIX_PRIVS]
PRIVATE_PROTO_HEADER = unix_privs.h
diff --git a/source4/lib/util/data_blob.c b/source4/lib/util/data_blob.c
index 117043f95c..b258e47bba 100644
--- a/source4/lib/util/data_blob.c
+++ b/source4/lib/util/data_blob.c
@@ -39,9 +39,9 @@ _PUBLIC_ DATA_BLOB data_blob_named(const void *p, size_t length, const char *nam
}
if (p) {
- ret.data = talloc_memdup(NULL, p, length);
+ ret.data = (uint8_t *)talloc_memdup(NULL, p, length);
} else {
- ret.data = talloc_size(NULL, length);
+ ret.data = talloc_array(NULL, uint8_t, length);
}
if (ret.data == NULL) {
ret.length = 0;
@@ -175,7 +175,7 @@ _PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob)
_PUBLIC_ DATA_BLOB data_blob_string_const(const char *str)
{
DATA_BLOB blob;
- blob.data = discard_const(str);
+ blob.data = discard_const_p(uint8_t, str);
blob.length = strlen(str);
return blob;
}
@@ -187,7 +187,7 @@ _PUBLIC_ DATA_BLOB data_blob_string_const(const char *str)
_PUBLIC_ DATA_BLOB data_blob_const(const void *p, size_t length)
{
DATA_BLOB blob;
- blob.data = discard_const(p);
+ blob.data = discard_const_p(uint8_t, p);
blob.length = length;
return blob;
}
@@ -198,7 +198,7 @@ _PUBLIC_ DATA_BLOB data_blob_const(const void *p, size_t length)
**/
_PUBLIC_ bool data_blob_realloc(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, size_t length)
{
- blob->data = talloc_realloc_size(mem_ctx, blob->data, length);
+ blob->data = talloc_realloc(mem_ctx, blob->data, uint8_t, length);
if (blob->data == NULL)
return false;
blob->length = length;
diff --git a/source4/lib/util/data_blob.h b/source4/lib/util/data_blob.h
index e39b2eaf45..1442438dd7 100644
--- a/source4/lib/util/data_blob.h
+++ b/source4/lib/util/data_blob.h
@@ -24,6 +24,7 @@
#endif
#include <talloc.h>
+#include <stdint.h>
/* used to hold an arbitrary blob of data */
typedef struct datablob {
diff --git a/source4/lib/util/dprintf.c b/source4/lib/util/dprintf.c
index a7770f364d..91665e7bdd 100644
--- a/source4/lib/util/dprintf.c
+++ b/source4/lib/util/dprintf.c
@@ -48,7 +48,7 @@ _PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) _PRINTF_ATTRIBU
charset, but beware of it growing */
maxlen = ret*2;
again:
- p2 = malloc(maxlen);
+ p2 = (char *)malloc(maxlen);
if (!p2) {
SAFE_FREE(p);
return -1;
diff --git a/source4/lib/util/fault.c b/source4/lib/util/fault.c
index 5cc9445407..e9cd040ee6 100644
--- a/source4/lib/util/fault.c
+++ b/source4/lib/util/fault.c
@@ -153,7 +153,7 @@ _PUBLIC_ _NORETURN_ void smb_panic(const char *why)
/**
report a fault
**/
-static void fault_report(int sig)
+_NORETURN_ static void fault_report(int sig)
{
static int counter;
@@ -172,7 +172,7 @@ static void fault_report(int sig)
/**
catch serious errors
**/
-static void sig_fault(int sig)
+_NORETURN_ static void sig_fault(int sig)
{
if (fault_handlers.fault_handler) {
/* we have a fault handler, call it. It may not return. */
diff --git a/source4/lib/util/fault.m4 b/source4/lib/util/fault.m4
index 6d2c4f2a6a..b24e63641c 100644
--- a/source4/lib/util/fault.m4
+++ b/source4/lib/util/fault.m4
@@ -1,2 +1,5 @@
-AC_CHECK_HEADER(execinfo.h)
-AC_CHECK_FUNCS(backtrace)
+AC_CHECK_HEADERS(execinfo.h)
+AC_SEARCH_LIBS_EXT(backtrace, [execinfo], EXECINFO_LIBS)
+AC_CHECK_FUNC_EXT(backtrace, $EXECINFO_LIBS)
+SMB_EXT_LIB(EXECINFO,[${EXECINFO_LIBS}])
+SMB_ENABLE(EXECINFO)
diff --git a/source4/lib/util/ms_fnmatch.c b/source4/lib/util/ms_fnmatch.c
index 8e216b0226..73fb0e0966 100644
--- a/source4/lib/util/ms_fnmatch.c
+++ b/source4/lib/util/ms_fnmatch.c
@@ -201,11 +201,10 @@ int ms_fnmatch(const char *pattern, const char *string, enum protocol_types prot
if (pattern[i] == '*' || pattern[i] == '<') count++;
}
- max_n = talloc_array(NULL, struct max_n, count);
- if (!max_n) {
+ max_n = talloc_zero_array(NULL, struct max_n, count);
+ if (max_n == NULL) {
return -1;
}
- memset(max_n, 0, sizeof(struct max_n) * count);
ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'));
diff --git a/source4/lib/util/tests/file.c b/source4/lib/util/tests/file.c
index 0fe117a300..fe87293671 100644
--- a/source4/lib/util/tests/file.c
+++ b/source4/lib/util/tests/file.c
@@ -88,10 +88,10 @@ struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx)
struct torture_suite *suite = torture_suite_create(mem_ctx, "FILE");
torture_suite_add_simple_test(suite, "file_load_save",
- test_file_load_save);
+ test_file_load_save);
torture_suite_add_simple_test(suite, "afdgets",
- test_afdgets);
+ test_afdgets);
return suite;
}
diff --git a/source4/lib/util/tests/str.c b/source4/lib/util/tests/str.c
new file mode 100644
index 0000000000..a219ef0891
--- /dev/null
+++ b/source4/lib/util/tests/str.c
@@ -0,0 +1,121 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ util_str testing
+
+ 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 "torture/ui.h"
+
+static bool test_string_sub_simple(struct torture_context *tctx)
+{
+ char tmp[100];
+ safe_strcpy(tmp, "foobar", sizeof(tmp));
+ string_sub(tmp, "foo", "bar", sizeof(tmp));
+ torture_assert_str_equal(tctx, tmp, "barbar", "invalid sub");
+ return true;
+}
+
+static bool test_string_sub_multiple(struct torture_context *tctx)
+{
+ char tmp[100];
+ safe_strcpy(tmp, "fooblafoo", sizeof(tmp));
+ string_sub(tmp, "foo", "bar", sizeof(tmp));
+ torture_assert_str_equal(tctx, tmp, "barblabar", "invalid sub");
+ return true;
+}
+
+static bool test_string_sub_longer(struct torture_context *tctx)
+{
+ char tmp[100];
+ safe_strcpy(tmp, "foobla", sizeof(tmp));
+ string_sub(tmp, "foo", "blie", sizeof(tmp));
+ torture_assert_str_equal(tctx, tmp, "bliebla", "invalid sub");
+ return true;
+}
+
+static bool test_string_sub_shorter(struct torture_context *tctx)
+{
+ char tmp[100];
+ safe_strcpy(tmp, "foobla", sizeof(tmp));
+ string_sub(tmp, "foo", "bl", sizeof(tmp));
+ torture_assert_str_equal(tctx, tmp, "blbla", "invalid sub");
+ return true;
+}
+
+static bool test_string_sub_special_char(struct torture_context *tctx)
+{
+ char tmp[100];
+ safe_strcpy(tmp, "foobla", sizeof(tmp));
+ string_sub(tmp, "foo", "%b;l", sizeof(tmp));
+ torture_assert_str_equal(tctx, tmp, "_b_lbla", "invalid sub");
+ return true;
+}
+
+static bool test_string_sub_talloc_simple(struct torture_context *tctx)
+{
+ char *t;
+
+ t = string_sub_talloc(tctx, "foobla", "foo", "bl");
+
+ torture_assert_str_equal(tctx, t, "blbla", "invalid sub");
+
+ return true;
+}
+
+static bool test_string_sub_talloc_multiple(struct torture_context *tctx)
+{
+ char *t;
+
+ t = string_sub_talloc(tctx, "fooblafoo", "foo", "aapnootmies");
+
+ torture_assert_str_equal(tctx, t, "aapnootmiesblaaapnootmies",
+ "invalid sub");
+
+ return true;
+}
+
+
+
+struct torture_suite *torture_local_util_str(TALLOC_CTX *mem_ctx)
+{
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "STR");
+
+ torture_suite_add_simple_test(suite, "string_sub_simple",
+ test_string_sub_simple);
+
+ torture_suite_add_simple_test(suite, "string_sub_multiple",
+ test_string_sub_multiple);
+
+ torture_suite_add_simple_test(suite, "string_sub_shorter",
+ test_string_sub_shorter);
+
+ torture_suite_add_simple_test(suite, "string_sub_longer",
+ test_string_sub_longer);
+
+ torture_suite_add_simple_test(suite, "string_sub_special_chars",
+ test_string_sub_special_char);
+
+ torture_suite_add_simple_test(suite, "string_sub_talloc_simple",
+ test_string_sub_talloc_simple);
+
+ torture_suite_add_simple_test(suite, "string_sub_talloc_multiple",
+ test_string_sub_talloc_multiple);
+
+ return suite;
+}
diff --git a/source4/lib/util/tests/strlist.c b/source4/lib/util/tests/strlist.c
index 41accd4bd2..437d9d741a 100644
--- a/source4/lib/util/tests/strlist.c
+++ b/source4/lib/util/tests/strlist.c
@@ -35,7 +35,7 @@ static const char *test_lists_shell_strings[] = {
static bool test_lists_shell(struct torture_context *tctx,
const void *test_data)
{
- const char *data = test_data;
+ const char *data = (const char *)test_data;
const char **ret1, **ret2, *tmp;
bool match = true;
TALLOC_CTX *mem_ctx = tctx;
diff --git a/source4/lib/util/time.c b/source4/lib/util/time.c
index c800fffea0..fc51498009 100644
--- a/source4/lib/util/time.c
+++ b/source4/lib/util/time.c
@@ -269,7 +269,7 @@ _PUBLIC_ time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset)
x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
SIVAL(&x,0,x2);
- return pull_dos_date((void *)&x, zone_offset);
+ return pull_dos_date((const uint8_t *)&x, zone_offset);
}
/**
@@ -374,14 +374,6 @@ _PUBLIC_ NTTIME pull_nttime(uint8_t *base, uint16_t offset)
}
/**
- parse a nttime as a large integer in a string and return a NTTIME
-*/
-_PUBLIC_ NTTIME nttime_from_string(const char *s)
-{
- return strtoull(s, NULL, 0);
-}
-
-/**
return (tv1 - tv2) in microseconds
*/
_PUBLIC_ int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2)
diff --git a/source4/lib/util/time.h b/source4/lib/util/time.h
index a1b3facf24..557c5d4eab 100644
--- a/source4/lib/util/time.h
+++ b/source4/lib/util/time.h
@@ -19,6 +19,10 @@
#ifndef _SAMBA_TIME_H_
#define _SAMBA_TIME_H_
+#ifndef _PUBLIC_
+#define _PUBLIC_
+#endif
+
/* 64 bit time (100 nanosec) 1601 - cifs6.txt, section 3.5, page 30, 4 byte aligned */
typedef uint64_t NTTIME;
diff --git a/source4/lib/util/util.c b/source4/lib/util/util.c
index aa7a571585..624315f99e 100644
--- a/source4/lib/util/util.c
+++ b/source4/lib/util/util.c
@@ -190,28 +190,27 @@ _PUBLIC_ void msleep(unsigned int t)
Get my own name, return in malloc'ed storage.
**/
-_PUBLIC_ char* get_myname(void)
+_PUBLIC_ char *get_myname(void)
{
char *hostname;
- const int host_name_max = 255;
char *p;
- hostname = malloc(host_name_max+1);
+ hostname = (char *)malloc(MAXHOSTNAMELEN+1);
*hostname = 0;
/* get my host name */
- if (gethostname(hostname, host_name_max+1) == -1) {
+ if (gethostname(hostname, MAXHOSTNAMELEN+1) == -1) {
DEBUG(0,("gethostname failed\n"));
return NULL;
}
/* Ensure null termination. */
- hostname[host_name_max] = '\0';
+ hostname[MAXHOSTNAMELEN] = '\0';
/* split off any parts after an initial . */
- p = strchr(hostname,'.');
+ p = strchr(hostname, '.');
- if (p)
+ if (p != NULL)
*p = 0;
return hostname;
diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h
index 8259e08512..1960aa6196 100644
--- a/source4/lib/util/util.h
+++ b/source4/lib/util/util.h
@@ -28,12 +28,12 @@
* @brief Helpful macros
*/
-struct substitute_context;
struct smbsrv_tcon;
extern const char *logfile;
extern const char *panic_action;
+#include "util/attr.h"
#include "util/time.h"
#include "util/data_blob.h"
#include "util/xfile.h"
@@ -73,7 +73,7 @@ extern const char *panic_action;
*/
#define SMB_ASSERT(b) do { if (!(b)) { \
DEBUG(0,("PANIC: assert failed at %s(%d)\n", __FILE__, __LINE__)); \
- smb_panic("assert failed"); abort(); }} while (0)
+ smb_panic("assert failed"); }} while (0)
#ifndef SAFE_FREE /* Oh no this is also defined in tdb.h */
/**
@@ -165,7 +165,7 @@ _PUBLIC_ void do_debug_header(int level, const char *location, const char *func)
@note You should never have to call this function directly. Call the DEBUG()
macro instead.
*/
-_PUBLIC_ void do_debug(const char *format, ...) _PRINTF_ATTRIBUTE(1,2);
+_PUBLIC_ void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1,2);
/**
reopen the log file (usually called because the log file name might have changed)
@@ -313,9 +313,9 @@ _PUBLIC_ char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
/* The following definitions come from lib/util/dprintf.c */
-_PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0);
-_PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) _PRINTF_ATTRIBUTE(2,3);
-_PUBLIC_ int d_printf(const char *format, ...) _PRINTF_ATTRIBUTE(1,2);
+_PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
+_PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
+_PUBLIC_ int d_printf(const char *format, ...) PRINTF_ATTRIBUTE(1,2);
_PUBLIC_ void display_set_stderr(void);
/* The following definitions come from lib/util/util_str.c */
@@ -371,17 +371,6 @@ _PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_he
_PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len);
/**
- Free a string value.
-**/
-_PUBLIC_ void string_free(char **s);
-
-/**
- Set a string value, deallocating any existing space, and allocing the space
- for the string
-**/
-_PUBLIC_ bool string_set(char **dest, const char *src);
-
-/**
Substitute a string for a pattern in another string. Make sure there is
enough room!
@@ -394,6 +383,10 @@ _PUBLIC_ bool string_set(char **dest, const char *src);
**/
_PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t len);
+
+_PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s,
+ const char *pattern, const char *insert);
+
/**
Similar to string_sub() but allows for any character to be substituted.
Use with caution!
@@ -562,11 +555,6 @@ _PUBLIC_ bool str_list_check(const char **list, const char *s);
*/
_PUBLIC_ bool str_list_check_ci(const char **list, const char *s);
-/**
- Check if a string is part of a list.
-**/
-_PUBLIC_ bool in_list(const char *s, const char *list, bool casesensitive);
-
/* The following definitions come from lib/util/util_file.c */
@@ -620,8 +608,8 @@ _PUBLIC_ void file_lines_slashcont(char **lines);
save a lump of data into a file. Mostly used for debugging
*/
_PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length);
-_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0);
-_PUBLIC_ int fdprintf(int fd, const char *format, ...) _PRINTF_ATTRIBUTE(2,3);
+_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
+_PUBLIC_ int fdprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
_PUBLIC_ bool large_file_support(const char *path);
/* The following definitions come from lib/util/util.c */
@@ -790,8 +778,6 @@ enum protocol_types {
PROTOCOL_SMB2
};
-
-
int ms_fnmatch(const char *pattern, const char *string, enum protocol_types protocol);
/** a generic fnmatch function - uses for non-CIFS pattern matching */
@@ -848,6 +834,6 @@ _PUBLIC_ int idr_remove(struct idr_context *idp, int id);
/**
Become a daemon, discarding the controlling terminal.
**/
-_PUBLIC_ void become_daemon(bool Fork);
+_PUBLIC_ void become_daemon(bool fork);
#endif /* _SAMBA_UTIL_H_ */
diff --git a/source4/lib/util/util_pw.c b/source4/lib/util/util_pw.c
index 0e0675571e..11e46ec4e3 100644
--- a/source4/lib/util/util_pw.c
+++ b/source4/lib/util/util_pw.c
@@ -21,37 +21,26 @@
#include "includes.h"
-static struct passwd *alloc_copy_passwd(const struct passwd *from)
+static struct passwd *alloc_copy_passwd(TALLOC_CTX *mem_ctx,
+ const struct passwd *from)
{
- struct passwd *ret = smb_xmalloc_p(struct passwd);
- ZERO_STRUCTP(ret);
- ret->pw_name = smb_xstrdup(from->pw_name);
- ret->pw_passwd = smb_xstrdup(from->pw_passwd);
- ret->pw_uid = from->pw_uid;
- ret->pw_gid = from->pw_gid;
- ret->pw_gecos = smb_xstrdup(from->pw_gecos);
- ret->pw_dir = smb_xstrdup(from->pw_dir);
- ret->pw_shell = smb_xstrdup(from->pw_shell);
- return ret;
-}
+ struct passwd *ret = talloc_zero(mem_ctx, struct passwd);
-void passwd_free (struct passwd **buf)
-{
- if (!*buf) {
- DEBUG(0, ("attempted double-free of allocated passwd\n"));
- return;
- }
+ if (ret == NULL)
+ return NULL;
- SAFE_FREE((*buf)->pw_name);
- SAFE_FREE((*buf)->pw_passwd);
- SAFE_FREE((*buf)->pw_gecos);
- SAFE_FREE((*buf)->pw_dir);
- SAFE_FREE((*buf)->pw_shell);
+ ret->pw_name = talloc_strdup(ret, from->pw_name);
+ ret->pw_passwd = talloc_strdup(ret, from->pw_passwd);
+ ret->pw_uid = from->pw_uid;
+ ret->pw_gid = from->pw_gid;
+ ret->pw_gecos = talloc_strdup(ret, from->pw_gecos);
+ ret->pw_dir = talloc_strdup(ret, from->pw_dir);
+ ret->pw_shell = talloc_strdup(ret, from->pw_shell);
- SAFE_FREE(*buf);
+ return ret;
}
-struct passwd *getpwnam_alloc(const char *name)
+struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
{
struct passwd *temp;
@@ -66,10 +55,10 @@ struct passwd *getpwnam_alloc(const char *name)
return NULL;
}
- return alloc_copy_passwd(temp);
+ return alloc_copy_passwd(mem_ctx, temp);
}
-struct passwd *getpwuid_alloc(uid_t uid)
+struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
{
struct passwd *temp;
@@ -84,5 +73,5 @@ struct passwd *getpwuid_alloc(uid_t uid)
return NULL;
}
- return alloc_copy_passwd(temp);
+ return alloc_copy_passwd(mem_ctx, temp);
}
diff --git a/source4/lib/util/util_str.c b/source4/lib/util/util_str.c
index 67e59474fd..9ea6403c52 100644
--- a/source4/lib/util/util_str.c
+++ b/source4/lib/util/util_str.c
@@ -23,7 +23,6 @@
#include "includes.h"
#include "libcli/raw/smb.h"
-#include "pstring.h"
#include "system/locale.h"
/**
@@ -237,7 +236,7 @@ _PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_he
int i;
char *hex_buffer;
- *out_hex_buffer = smb_xmalloc((len*2)+1);
+ *out_hex_buffer = malloc_array_p(char, (len*2)+1);
hex_buffer = *out_hex_buffer;
for (i = 0; i < len; i++)
@@ -261,39 +260,6 @@ _PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_
}
/**
- Set a string value, allocing the space for the string
-**/
-static bool string_init(char **dest,const char *src)
-{
- if (!src) src = "";
-
- (*dest) = strdup(src);
- if ((*dest) == NULL) {
- DEBUG(0,("Out of memory in string_init\n"));
- return false;
- }
- return true;
-}
-
-/**
- Free a string value.
-**/
-_PUBLIC_ void string_free(char **s)
-{
- if (s) SAFE_FREE(*s);
-}
-
-/**
- Set a string value, deallocating any existing space, and allocing the space
- for the string
-**/
-_PUBLIC_ bool string_set(char **dest, const char *src)
-{
- string_free(dest);
- return string_init(dest,src);
-}
-
-/**
Substitute a string for a pattern in another string. Make sure there is
enough room!
@@ -305,10 +271,10 @@ _PUBLIC_ bool string_set(char **dest, const char *src)
use of len==0 which was for no length checks to be done.
**/
-_PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t len)
+_PUBLIC_ void string_sub(char *s, const char *pattern, const char *insert, size_t len)
{
char *p;
- ssize_t ls,lp,li, i;
+ ssize_t ls, lp, li, i;
if (!insert || !pattern || !*pattern || !s)
return;
@@ -320,7 +286,7 @@ _PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t
if (len == 0)
len = ls + 1; /* len is number of *bytes* */
- while (lp <= ls && (p = strstr(s,pattern))) {
+ while (lp <= ls && (p = strstr(s, pattern))) {
if (ls + (li-lp) >= len) {
DEBUG(0,("ERROR: string overflow by %d in string_sub(%.50s, %d)\n",
(int)(ls + (li-lp) - len),
@@ -351,6 +317,42 @@ _PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t
}
}
+/**
+ * Talloc'ed version of string_sub
+ */
+_PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s,
+ const char *pattern, const char *insert)
+{
+ const char *p;
+ char *ret;
+ size_t len, alloc_len;
+
+ if (insert == NULL || pattern == NULL || !*pattern || s == NULL)
+ return NULL;
+
+ /* determine length needed */
+ len = strlen(s);
+
+ for (p = strstr(s, pattern); p != NULL;
+ p = strstr(p+strlen(pattern), pattern)) {
+ len += strlen(insert) - strlen(pattern);
+ }
+
+ alloc_len = MAX(len, strlen(s))+1;
+ ret = talloc_array(mem_ctx, char, alloc_len);
+ if (ret == NULL)
+ return NULL;
+ strncpy(ret, s, alloc_len);
+ string_sub(ret, pattern, insert, alloc_len);
+
+ ret = talloc_realloc(mem_ctx, ret, char, len+1);
+ if (ret == NULL)
+ return NULL;
+
+ SMB_ASSERT(ret[len] == '\0');
+
+ return ret;
+}
/**
Similar to string_sub() but allows for any character to be substituted.
@@ -457,7 +459,7 @@ _PUBLIC_ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s)
if (!s || !*s) {
return talloc_strdup(mem_ctx, "");
}
- ret = talloc_size(mem_ctx, strlen(s)+2);
+ ret = talloc_array(mem_ctx, char, strlen(s)+2);
if (!ret) {
return ret;
}
@@ -566,7 +568,7 @@ _PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib)
};
char *ret;
- ret = talloc_size(mem_ctx, ARRAY_SIZE(attr_strs)+1);
+ ret = talloc_array(mem_ctx, char, ARRAY_SIZE(attr_strs)+1);
if (!ret) {
return NULL;
}
diff --git a/source4/lib/util/util_strlist.c b/source4/lib/util/util_strlist.c
index ab73fb2d15..1f1cc17d00 100644
--- a/source4/lib/util/util_strlist.c
+++ b/source4/lib/util/util_strlist.c
@@ -19,7 +19,6 @@
*/
#include "includes.h"
-#include "pstring.h"
#include "system/locale.h"
/**
@@ -152,7 +151,7 @@ _PUBLIC_ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char sepera
ret = talloc_strdup(mem_ctx, list[0]);
for (i = 1; list[i]; i++) {
- ret = talloc_asprintf_append(ret, "%c%s", seperator, list[i]);
+ ret = talloc_asprintf_append_buffer(ret, "%c%s", seperator, list[i]);
}
return ret;
@@ -175,9 +174,9 @@ _PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char
for (i = 1; list[i]; i++) {
if (strchr(list[i], ' ') || strlen(list[i]) == 0)
- ret = talloc_asprintf_append(ret, "%c\"%s\"", sep, list[i]);
+ ret = talloc_asprintf_append_buffer(ret, "%c\"%s\"", sep, list[i]);
else
- ret = talloc_asprintf_append(ret, "%c%s", sep, list[i]);
+ ret = talloc_asprintf_append_buffer(ret, "%c%s", sep, list[i]);
}
return ret;
@@ -300,25 +299,4 @@ _PUBLIC_ bool str_list_check_ci(const char **list, const char *s)
return false;
}
-/**
- Check if a string is part of a list.
-**/
-_PUBLIC_ bool in_list(const char *s, const char *list, bool casesensitive)
-{
- pstring tok;
- const char *p=list;
- if (!list)
- return false;
-
- while (next_token(&p,tok,LIST_SEP,sizeof(tok))) {
- if (casesensitive) {
- if (strcmp(tok,s) == 0)
- return true;
- } else {
- if (strcasecmp_m(tok,s) == 0)
- return true;
- }
- }
- return false;
-}
diff --git a/source4/lib/util/util_tdb.c b/source4/lib/util/util_tdb.c
index 1112f1587c..d7bddbde01 100644
--- a/source4/lib/util/util_tdb.c
+++ b/source4/lib/util/util_tdb.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "lib/tdb/include/tdb.h"
#include "pstring.h"
+#include "lib/util/util_tdb.h"
/* these are little tdb utility functions that are meant to make
dealing with a tdb database a little less cumbersome in Samba */
@@ -127,7 +128,7 @@ int tdb_store_int32_byblob(struct tdb_context *tdb, const char *keystr, size_t l
int32_t v_store;
SIVAL(&v_store,0,v);
- data.dptr = (void *)&v_store;
+ data.dptr = (unsigned char *)&v_store;
data.dsize = sizeof(int32_t);
return tdb_store(tdb, key, data, TDB_REPLACE);
@@ -187,7 +188,7 @@ bool tdb_store_uint32_byblob(struct tdb_context *tdb, const char *keystr, size_t
bool ret = true;
SIVAL(&v_store, 0, value);
- data.dptr = (void *)&v_store;
+ data.dptr = (unsigned char *)&v_store;
data.dsize = sizeof(uint32_t);
if (tdb_store(tdb, key, data, TDB_REPLACE) == -1)
diff --git a/source4/lib/util/xfile.c b/source4/lib/util/xfile.c
index 8b90e30868..a016031a77 100644
--- a/source4/lib/util/xfile.c
+++ b/source4/lib/util/xfile.c
@@ -85,7 +85,7 @@ static int x_allocate_buffer(XFILE *f)
{
if (f->buf) return 1;
if (f->bufsize == 0) return 0;
- f->buf = malloc(f->bufsize);
+ f->buf = (char *)malloc(f->bufsize);
if (!f->buf) return 0;
f->next = f->buf;
return 1;
diff --git a/source4/libcli/auth/credentials.c b/source4/libcli/auth/credentials.c
index feb8c92a0b..a6cb17c12e 100644
--- a/source4/libcli/auth/credentials.c
+++ b/source4/libcli/auth/credentials.c
@@ -235,15 +235,15 @@ void creds_client_authenticator(struct creds_CredentialState *creds,
/*
check that a credentials reply from a server is correct
*/
-BOOL creds_client_check(struct creds_CredentialState *creds,
+bool creds_client_check(struct creds_CredentialState *creds,
const struct netr_Credential *received_credentials)
{
if (!received_credentials ||
memcmp(received_credentials->data, creds->server.data, 8) != 0) {
DEBUG(2,("credentials check failed\n"));
- return False;
+ return false;
}
- return True;
+ return true;
}
@@ -278,16 +278,16 @@ void creds_server_init(struct creds_CredentialState *creds,
/*
check that a credentials reply from a server is correct
*/
-BOOL creds_server_check(const struct creds_CredentialState *creds,
+bool creds_server_check(const struct creds_CredentialState *creds,
const struct netr_Credential *received_credentials)
{
if (memcmp(received_credentials->data, creds->client.data, 8) != 0) {
DEBUG(2,("credentials check failed\n"));
dump_data_pw("client creds", creds->client.data, 8);
dump_data_pw("calc creds", received_credentials->data, 8);
- return False;
+ return false;
}
- return True;
+ return true;
}
NTSTATUS creds_server_step_check(struct creds_CredentialState *creds,
diff --git a/source4/libcli/auth/session.c b/source4/libcli/auth/session.c
index 7f44b6b5a9..29af7fafe8 100644
--- a/source4/libcli/auth/session.c
+++ b/source4/libcli/auth/session.c
@@ -30,7 +30,7 @@
as the in blob
*/
static void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key,
- BOOL forward)
+ bool forward)
{
int i, k;
@@ -84,7 +84,7 @@ DATA_BLOB sess_encrypt_string(const char *str, const DATA_BLOB *session_key)
memset(src.data+8, 0, dlen);
memcpy(src.data+8, str, slen);
- sess_crypt_blob(&ret, &src, session_key, True);
+ sess_crypt_blob(&ret, &src, session_key, true);
data_blob_free(&src);
@@ -112,7 +112,7 @@ char *sess_decrypt_string(TALLOC_CTX *mem_ctx,
return NULL;
}
- sess_crypt_blob(&out, blob, session_key, False);
+ sess_crypt_blob(&out, blob, session_key, false);
if (IVAL(out.data, 4) != 1) {
DEBUG(0,("Unexpected revision number %d in session crypted string\n",
@@ -166,7 +166,7 @@ DATA_BLOB sess_encrypt_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob_in, const DATA_
memset(src.data+8, 0, dlen);
memcpy(src.data+8, blob_in->data, blob_in->length);
- sess_crypt_blob(&ret, &src, session_key, True);
+ sess_crypt_blob(&ret, &src, session_key, true);
data_blob_free(&src);
@@ -193,7 +193,7 @@ NTSTATUS sess_decrypt_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const DAT
return NT_STATUS_NO_MEMORY;
}
- sess_crypt_blob(&out, blob, session_key, False);
+ sess_crypt_blob(&out, blob, session_key, false);
if (IVAL(out.data, 4) != 1) {
DEBUG(2,("Unexpected revision number %d in session crypted secret (BLOB)\n",
diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c
index 1f940fb79d..bfac395ef9 100644
--- a/source4/libcli/auth/smbencrypt.c
+++ b/source4/libcli/auth/smbencrypt.c
@@ -34,11 +34,11 @@
It takes a password ('unix' string), a 8 byte "crypt key"
and puts 24 bytes of encrypted password into p24
- Returns False if password must have been truncated to create LM hash
+ Returns false if password must have been truncated to create LM hash
*/
-BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24])
+bool SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24])
{
- BOOL ret;
+ bool ret;
uint8_t p21[21];
memset(p21,'\0',21);
@@ -62,7 +62,7 @@ BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24])
* @param p16 return password hashed with md4, caller allocated 16 byte buffer
*/
-_PUBLIC_ BOOL E_md4hash(const char *passwd, uint8_t p16[16])
+_PUBLIC_ bool E_md4hash(const char *passwd, uint8_t p16[16])
{
int len;
void *wpwd;
@@ -72,27 +72,27 @@ _PUBLIC_ BOOL E_md4hash(const char *passwd, uint8_t p16[16])
/* We don't want to return fixed data, as most callers
* don't check */
mdfour(p16, (const uint8_t *)passwd, strlen(passwd));
- return False;
+ return false;
}
len -= 2;
mdfour(p16, wpwd, len);
talloc_free(wpwd);
- return True;
+ return true;
}
/**
* Creates the DES forward-only Hash of the users password in DOS ASCII charset
* @param passwd password in 'unix' charset.
* @param p16 return password hashed with DES, caller allocated 16 byte buffer
- * @return False if password was > 14 characters, and therefore may be incorrect, otherwise True
+ * @return false if password was > 14 characters, and therefore may be incorrect, otherwise true
* @note p16 is filled in regardless
*/
-_PUBLIC_ BOOL E_deshash(const char *passwd, uint8_t p16[16])
+_PUBLIC_ bool E_deshash(const char *passwd, uint8_t p16[16])
{
- BOOL ret = True;
+ bool ret = true;
fstring dospwd;
ZERO_STRUCT(dospwd);
@@ -103,7 +103,7 @@ _PUBLIC_ BOOL E_deshash(const char *passwd, uint8_t p16[16])
E_P16((const uint8_t *)dospwd, p16);
if (strlen(dospwd) > 14) {
- ret = False;
+ ret = false;
}
ZERO_STRUCT(dospwd);
@@ -112,9 +112,9 @@ _PUBLIC_ BOOL E_deshash(const char *passwd, uint8_t p16[16])
}
/* Does both the NTLMv2 owfs of a user's password */
-BOOL ntv2_owf_gen(const uint8_t owf[16],
+bool ntv2_owf_gen(const uint8_t owf[16],
const char *user_in, const char *domain_in,
- BOOL upper_case_domain, /* Transform the domain into UPPER case */
+ bool upper_case_domain, /* Transform the domain into UPPER case */
uint8_t kr_buf[16])
{
void *user;
@@ -125,7 +125,7 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
HMACMD5Context ctx;
TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in);
if (!mem_ctx) {
- return False;
+ return false;
}
if (!user_in) {
@@ -139,14 +139,14 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
user_in = strupper_talloc(mem_ctx, user_in);
if (user_in == NULL) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (upper_case_domain) {
domain_in = strupper_talloc(mem_ctx, domain_in);
if (domain_in == NULL) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
@@ -154,14 +154,14 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
if (user_byte_len == (ssize_t)-1) {
DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n"));
talloc_free(mem_ctx);
- return False;
+ return false;
}
domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in);
if (domain_byte_len == (ssize_t)-1) {
DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n"));
talloc_free(mem_ctx);
- return False;
+ return false;
}
SMB_ASSERT(user_byte_len >= 2);
@@ -185,7 +185,7 @@ BOOL ntv2_owf_gen(const uint8_t owf[16],
#endif
talloc_free(mem_ctx);
- return True;
+ return true;
}
/* Does the des encryption from the NT or LM MD4 hash. */
@@ -393,7 +393,7 @@ static DATA_BLOB LMv2_generate_response(TALLOC_CTX *mem_ctx,
return final_response;
}
-BOOL SMBNTLMv2encrypt_hash(TALLOC_CTX *mem_ctx,
+bool SMBNTLMv2encrypt_hash(TALLOC_CTX *mem_ctx,
const char *user, const char *domain, const uint8_t nt_hash[16],
const DATA_BLOB *server_chal,
const DATA_BLOB *names_blob,
@@ -406,8 +406,8 @@ BOOL SMBNTLMv2encrypt_hash(TALLOC_CTX *mem_ctx,
the username and domain.
This prevents username swapping during the auth exchange
*/
- if (!ntv2_owf_gen(nt_hash, user, domain, True, ntlm_v2_hash)) {
- return False;
+ if (!ntv2_owf_gen(nt_hash, user, domain, true, ntlm_v2_hash)) {
+ return false;
}
if (nt_response) {
@@ -437,10 +437,10 @@ BOOL SMBNTLMv2encrypt_hash(TALLOC_CTX *mem_ctx,
}
}
- return True;
+ return true;
}
-BOOL SMBNTLMv2encrypt(TALLOC_CTX *mem_ctx,
+bool SMBNTLMv2encrypt(TALLOC_CTX *mem_ctx,
const char *user, const char *domain,
const char *password,
const DATA_BLOB *server_chal,
@@ -460,7 +460,7 @@ BOOL SMBNTLMv2encrypt(TALLOC_CTX *mem_ctx,
encode a password buffer with a unicode password. The buffer
is filled with random data to make it harder to attack.
************************************************************/
-BOOL encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flags)
+bool encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flags)
{
uint8_t new_pw[512];
size_t new_pw_len;
@@ -482,7 +482,7 @@ BOOL encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag
*/
SIVAL(buffer, 512, new_pw_len);
ZERO_STRUCT(new_pw);
- return True;
+ return true;
}
@@ -491,7 +491,7 @@ BOOL encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag
*new_pw_len is the length in bytes of the possibly mulitbyte
returned password including termination.
************************************************************/
-BOOL decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
+bool decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
int new_pwrd_size, uint32_t *new_pw_len,
int string_flags)
{
@@ -517,7 +517,7 @@ BOOL decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
/* Password cannot be longer than the size of the password buffer */
if ( (byte_len < 0) || (byte_len > 512)) {
- return False;
+ return false;
}
/* decode into the return buffer. Buffer length supplied */
@@ -531,5 +531,5 @@ BOOL decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
DEBUG(100,("original char len:%d\n", byte_len/2));
#endif
- return True;
+ return true;
}
diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c
index 33d6e88a30..f2f661acaa 100644
--- a/source4/libcli/cldap/cldap.c
+++ b/source4/libcli/cldap/cldap.c
@@ -39,6 +39,7 @@
#include "lib/socket/socket.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
destroy a pending request
@@ -308,14 +309,15 @@ struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
req->state = CLDAP_REQUEST_SEND;
req->timeout = io->in.timeout;
req->num_retries = io->in.retries;
- req->is_reply = False;
+ req->is_reply = false;
req->asn1 = asn1_init(req);
if (!req->asn1) {
goto failed;
}
req->dest = socket_address_from_strings(req, cldap->sock->backend_name,
- io->in.dest_address, lp_cldap_port());
+ io->in.dest_address,
+ lp_cldap_port(global_loadparm));
if (!req->dest) goto failed;
req->message_id = idr_get_new_random(cldap->idr, req, UINT16_MAX);
@@ -335,7 +337,7 @@ struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
search->deref = LDAP_DEREFERENCE_NEVER;
search->timelimit = 0;
search->sizelimit = 0;
- search->attributesonly = False;
+ search->attributesonly = false;
search->num_attributes = str_list_length(io->in.attributes);
search->attributes = io->in.attributes;
search->tree = ldb_parse_tree(req, io->in.filter);
@@ -376,7 +378,7 @@ NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io)
req->cldap = cldap;
req->state = CLDAP_REQUEST_SEND;
- req->is_reply = True;
+ req->is_reply = true;
req->asn1 = asn1_init(req);
if (!req->asn1) {
goto failed;
@@ -534,26 +536,26 @@ struct cldap_request *cldap_netlogon_send(struct cldap_socket *cldap,
ldap_encode_ndr_uint32(tmp_ctx, io->in.version));
if (filter == NULL) goto failed;
if (io->in.user) {
- filter = talloc_asprintf_append(filter, "(User=%s)", io->in.user);
+ filter = talloc_asprintf_append_buffer(filter, "(User=%s)", io->in.user);
if (filter == NULL) goto failed;
}
if (io->in.host) {
- filter = talloc_asprintf_append(filter, "(Host=%s)", io->in.host);
+ filter = talloc_asprintf_append_buffer(filter, "(Host=%s)", io->in.host);
if (filter == NULL) goto failed;
}
if (io->in.realm) {
- filter = talloc_asprintf_append(filter, "(DnsDomain=%s)", io->in.realm);
+ filter = talloc_asprintf_append_buffer(filter, "(DnsDomain=%s)", io->in.realm);
if (filter == NULL) goto failed;
}
if (io->in.acct_control != -1) {
- filter = talloc_asprintf_append(filter, "(AAC=%s)",
+ filter = talloc_asprintf_append_buffer(filter, "(AAC=%s)",
ldap_encode_ndr_uint32(tmp_ctx, io->in.acct_control));
if (filter == NULL) goto failed;
}
if (io->in.domain_sid) {
struct dom_sid *sid = dom_sid_parse_talloc(tmp_ctx, io->in.domain_sid);
if (sid == NULL) goto failed;
- filter = talloc_asprintf_append(filter, "(domainSid=%s)",
+ filter = talloc_asprintf_append_buffer(filter, "(domainSid=%s)",
ldap_encode_ndr_dom_sid(tmp_ctx, sid));
if (filter == NULL) goto failed;
}
@@ -562,11 +564,11 @@ struct cldap_request *cldap_netlogon_send(struct cldap_socket *cldap,
NTSTATUS status;
status = GUID_from_string(io->in.domain_guid, &guid);
if (!NT_STATUS_IS_OK(status)) goto failed;
- filter = talloc_asprintf_append(filter, "(DomainGuid=%s)",
+ filter = talloc_asprintf_append_buffer(filter, "(DomainGuid=%s)",
ldap_encode_ndr_GUID(tmp_ctx, &guid));
if (filter == NULL) goto failed;
}
- filter = talloc_asprintf_append(filter, ")");
+ filter = talloc_asprintf_append_buffer(filter, ")");
if (filter == NULL) goto failed;
search.in.dest_address = io->in.dest_address;
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index e0f3c598b4..a56100fc80 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -25,28 +25,29 @@
#include "libcli/raw/libcliraw.h"
#include "libcli/auth/libcli_auth.h"
#include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
/*
wrapper around smbcli_sock_connect()
*/
-BOOL smbcli_socket_connect(struct smbcli_state *cli, const char *server)
+bool smbcli_socket_connect(struct smbcli_state *cli, const char *server)
{
struct smbcli_socket *sock;
sock = smbcli_sock_connect_byname(server, 0, NULL, NULL);
- if (sock == NULL) return False;
+ if (sock == NULL) return false;
- cli->transport = smbcli_transport_init(sock, cli, True);
+ cli->transport = smbcli_transport_init(sock, cli, true);
if (!cli->transport) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/* wrapper around smbcli_transport_connect() */
-BOOL smbcli_transport_establish(struct smbcli_state *cli,
+bool smbcli_transport_establish(struct smbcli_state *cli,
struct nbt_name *calling,
struct nbt_name *called)
{
@@ -56,7 +57,8 @@ BOOL smbcli_transport_establish(struct smbcli_state *cli,
/* wrapper around smb_raw_negotiate() */
NTSTATUS smbcli_negprot(struct smbcli_state *cli)
{
- return smb_raw_negotiate(cli->transport, lp_cli_maxprotocol());
+ return smb_raw_negotiate(cli->transport,
+ lp_cli_maxprotocol(global_loadparm));
}
/* wrapper around smb_raw_sesssetup() */
@@ -66,13 +68,13 @@ NTSTATUS smbcli_session_setup(struct smbcli_state *cli,
struct smb_composite_sesssetup setup;
NTSTATUS status;
- cli->session = smbcli_session_init(cli->transport, cli, True);
+ cli->session = smbcli_session_init(cli->transport, cli, true);
if (!cli->session) return NT_STATUS_UNSUCCESSFUL;
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
setup.in.credentials = credentials;
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
status = smb_composite_sesssetup(cli->session, &setup);
@@ -89,7 +91,7 @@ NTSTATUS smbcli_tconX(struct smbcli_state *cli, const char *sharename,
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- cli->tree = smbcli_tree_init(cli->session, cli, True);
+ cli->tree = smbcli_tree_init(cli->session, cli, true);
if (!cli->tree) return NT_STATUS_UNSUCCESSFUL;
mem_ctx = talloc_init("tcon");
@@ -205,7 +207,7 @@ terminate_path_at_separator(char * path)
/*
parse a //server/share type UNC name
*/
-BOOL smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
+bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
char **hostname, char **sharename)
{
char *p;
@@ -214,28 +216,25 @@ BOOL smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
if (strncmp(unc_name, "\\\\", 2) &&
strncmp(unc_name, "//", 2)) {
- return False;
+ return false;
}
*hostname = talloc_strdup(mem_ctx, &unc_name[2]);
p = terminate_path_at_separator(*hostname);
- if (p && *p) {
+ if (p != NULL && *p) {
*sharename = talloc_strdup(mem_ctx, p);
terminate_path_at_separator(*sharename);
- } else {
- *sharename = talloc_strdup(mem_ctx,
- lp_parm_string(-1, "torture", "share"));
}
if (*hostname && *sharename) {
- return True;
+ return true;
}
talloc_free(*hostname);
talloc_free(*sharename);
*hostname = *sharename = NULL;
- return False;
+ return false;
}
diff --git a/source4/libcli/clideltree.c b/source4/libcli/clideltree.c
index 33c39ea093..2c306e501e 100644
--- a/source4/libcli/clideltree.c
+++ b/source4/libcli/clideltree.c
@@ -25,7 +25,7 @@
struct delete_state {
struct smbcli_tree *tree;
int total_deleted;
- BOOL failed;
+ bool failed;
};
/*
@@ -33,7 +33,7 @@ struct delete_state {
*/
static void delete_fn(struct clilist_file_info *finfo, const char *name, void *state)
{
- struct delete_state *dstate = state;
+ struct delete_state *dstate = (struct delete_state *)state;
char *s, *n;
if (ISDOT(finfo->name) || ISDOTDOT(finfo->name)) {
return;
@@ -61,14 +61,14 @@ static void delete_fn(struct clilist_file_info *finfo, const char *name, void *s
if (NT_STATUS_IS_ERR(smbcli_rmdir(dstate->tree, s))) {
DEBUG(2,("Failed to delete %s - %s\n",
s, smbcli_errstr(dstate->tree)));
- dstate->failed = True;
+ dstate->failed = true;
}
dstate->total_deleted++;
} else {
if (NT_STATUS_IS_ERR(smbcli_unlink(dstate->tree, s))) {
DEBUG(2,("Failed to delete %s - %s\n",
s, smbcli_errstr(dstate->tree)));
- dstate->failed = True;
+ dstate->failed = true;
}
dstate->total_deleted++;
}
@@ -87,7 +87,7 @@ int smbcli_deltree(struct smbcli_tree *tree, const char *dname)
dstate.tree = tree;
dstate.total_deleted = 0;
- dstate.failed = False;
+ dstate.failed = false;
/* it might be a file */
if (NT_STATUS_IS_OK(smbcli_unlink(tree, dname))) {
diff --git a/source4/libcli/clifile.c b/source4/libcli/clifile.c
index b30b82bd79..e59b7f9af3 100644
--- a/source4/libcli/clifile.c
+++ b/source4/libcli/clifile.c
@@ -30,7 +30,7 @@
static NTSTATUS smbcli_link_internal(struct smbcli_tree *tree,
const char *fname_src,
- const char *fname_dst, BOOL hard_link)
+ const char *fname_dst, bool hard_link)
{
union smb_setfileinfo parms;
NTSTATUS status;
@@ -84,7 +84,7 @@ uint32_t unix_perms_to_wire(mode_t perms)
NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src,
const char *fname_dst)
{
- return smbcli_link_internal(tree, fname_src, fname_dst, False);
+ return smbcli_link_internal(tree, fname_src, fname_dst, false);
}
/****************************************************************************
@@ -93,7 +93,7 @@ NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src,
NTSTATUS smbcli_unix_hardlink(struct smbcli_tree *tree, const char *fname_src,
const char *fname_dst)
{
- return smbcli_link_internal(tree, fname_src, fname_dst, True);
+ return smbcli_link_internal(tree, fname_src, fname_dst, true);
}
@@ -206,7 +206,8 @@ NTSTATUS smbcli_rmdir(struct smbcli_tree *tree, const char *dname)
/****************************************************************************
Set or clear the delete on close flag.
****************************************************************************/
-NTSTATUS smbcli_nt_delete_on_close(struct smbcli_tree *tree, int fnum, BOOL flag)
+NTSTATUS smbcli_nt_delete_on_close(struct smbcli_tree *tree, int fnum,
+ bool flag)
{
union smb_setfileinfo parms;
NTSTATUS status;
diff --git a/source4/libcli/clilist.c b/source4/libcli/clilist.c
index ba85ec397a..07393a3491 100644
--- a/source4/libcli/clilist.c
+++ b/source4/libcli/clilist.c
@@ -37,7 +37,7 @@ struct search_private {
/****************************************************************************
Interpret a long filename structure.
****************************************************************************/
-static BOOL interpret_long_filename(enum smb_search_data_level level,
+static bool interpret_long_filename(enum smb_search_data_level level,
const union smb_search_data *info,
struct clilist_file_info *finfo)
{
@@ -65,14 +65,14 @@ static BOOL interpret_long_filename(enum smb_search_data_level level,
default:
DEBUG(0,("Unhandled level %d in interpret_long_filename\n", (int)level));
- return False;
+ return false;
}
- return True;
+ return true;
}
/* callback function used for trans2 search */
-static BOOL smbcli_list_new_callback(void *private, const union smb_search_data *file)
+static bool smbcli_list_new_callback(void *private, const union smb_search_data *file)
{
struct search_private *state = (struct search_private*) private;
struct clilist_file_info *tdl;
@@ -83,7 +83,7 @@ static BOOL smbcli_list_new_callback(void *private, const union smb_search_data
struct clilist_file_info,
state->dirlist_len + 1);
if (!tdl) {
- return False;
+ return false;
}
state->dirlist = tdl;
state->dirlist_len++;
@@ -94,7 +94,7 @@ static BOOL smbcli_list_new_callback(void *private, const union smb_search_data
state->total_received++;
state->ff_searchcount++;
- return True;
+ return true;
}
int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
@@ -106,7 +106,7 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
union smb_search_next next_parms;
struct search_private state; /* for callbacks */
int received = 0;
- BOOL first = True;
+ bool first = true;
int num_received = 0;
int max_matches = 512;
char *mask;
@@ -118,7 +118,8 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
state.dirlist_len = 0;
state.total_received = 0;
- state.dirlist = talloc_new(state.mem_ctx);
+ state.dirlist = talloc_array(state.mem_ctx,
+ struct clilist_file_info, 0);
mask = talloc_strdup(state.mem_ctx, Mask);
if (level == RAW_SEARCH_DATA_GENERIC) {
@@ -158,7 +159,7 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
received = first_parms.t2ffirst.out.count;
if (received <= 0) break;
if (ff_eos) break;
- first = False;
+ first = false;
} else {
NTSTATUS status;
@@ -202,7 +203,7 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
Interpret a short filename structure.
The length of the structure is returned.
****************************************************************************/
-static BOOL interpret_short_filename(enum smb_search_data_level level,
+static bool interpret_short_filename(enum smb_search_data_level level,
const union smb_search_data *info,
struct clilist_file_info *finfo)
{
@@ -222,14 +223,14 @@ static BOOL interpret_short_filename(enum smb_search_data_level level,
default:
DEBUG(0,("Unhandled level %d in interpret_short_filename\n", (int)level));
- return False;
+ return false;
}
- return True;
+ return true;
}
/* callback function used for smb_search */
-static BOOL smbcli_list_old_callback(void *private, const union smb_search_data *file)
+static bool smbcli_list_old_callback(void *private, const union smb_search_data *file)
{
struct search_private *state = (struct search_private*) private;
struct clilist_file_info *tdl;
@@ -241,7 +242,7 @@ static BOOL smbcli_list_old_callback(void *private, const union smb_search_data
state->dirlist_len + 1);
if (!tdl) {
- return False;
+ return false;
}
state->dirlist = tdl;
state->dirlist_len++;
@@ -252,7 +253,7 @@ static BOOL smbcli_list_old_callback(void *private, const union smb_search_data
state->ff_searchcount++;
state->id = file->search.id; /* return resume info */
- return True;
+ return true;
}
int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
@@ -264,7 +265,7 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
struct search_private state; /* for callbacks */
const int num_asked = 500;
int received = 0;
- BOOL first = True;
+ bool first = true;
int num_received = 0;
char *mask;
int i;
@@ -275,7 +276,8 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
state.total_received = 0;
state.data_level = RAW_SEARCH_DATA_SEARCH;
- state.dirlist = talloc_new(state.mem_ctx);
+ state.dirlist = talloc_array(state.mem_ctx, struct clilist_file_info,
+ 0);
mask = talloc_strdup(state.mem_ctx, Mask);
while (1) {
@@ -301,7 +303,7 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
received = first_parms.search_first.out.count;
if (received <= 0) break;
- first = False;
+ first = false;
} else {
NTSTATUS status;
diff --git a/source4/libcli/climessage.c b/source4/libcli/climessage.c
index 3d4d9da96c..6002ccfc59 100644
--- a/source4/libcli/climessage.c
+++ b/source4/libcli/climessage.c
@@ -20,12 +20,13 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
/****************************************************************************
start a message sequence
****************************************************************************/
-BOOL smbcli_message_start(struct smbcli_tree *tree, const char *host, const char *username,
+bool smbcli_message_start(struct smbcli_tree *tree, const char *host, const char *username,
int *grp)
{
struct smbcli_request *req;
@@ -37,20 +38,20 @@ BOOL smbcli_message_start(struct smbcli_tree *tree, const char *host, const char
!smbcli_request_receive(req) ||
smbcli_is_error(tree)) {
smbcli_request_destroy(req);
- return False;
+ return false;
}
*grp = SVAL(req->in.vwv, VWV(0));
smbcli_request_destroy(req);
- return True;
+ return true;
}
/****************************************************************************
send a message
****************************************************************************/
-BOOL smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp)
+bool smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp)
{
struct smbcli_request *req;
@@ -63,17 +64,17 @@ BOOL smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp)
!smbcli_request_receive(req) ||
smbcli_is_error(tree)) {
smbcli_request_destroy(req);
- return False;
+ return false;
}
smbcli_request_destroy(req);
- return True;
+ return true;
}
/****************************************************************************
end a message
****************************************************************************/
-BOOL smbcli_message_end(struct smbcli_tree *tree, int grp)
+bool smbcli_message_end(struct smbcli_tree *tree, int grp)
{
struct smbcli_request *req;
@@ -84,10 +85,10 @@ BOOL smbcli_message_end(struct smbcli_tree *tree, int grp)
!smbcli_request_receive(req) ||
smbcli_is_error(tree)) {
smbcli_request_destroy(req);
- return False;
+ return false;
}
smbcli_request_destroy(req);
- return True;
+ return true;
}
diff --git a/source4/libcli/clireadwrite.c b/source4/libcli/clireadwrite.c
index 10a1c75308..f5ba799bbc 100644
--- a/source4/libcli/clireadwrite.c
+++ b/source4/libcli/clireadwrite.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
/****************************************************************************
Read size bytes at offset offset using SMBreadX.
@@ -27,7 +28,7 @@
ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset,
size_t size)
{
- uint8_t *buf = _buf;
+ uint8_t *buf = (uint8_t *)_buf;
union smb_read parms;
int readsize;
ssize_t total = 0;
@@ -55,7 +56,7 @@ ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset
parms.readx.in.mincnt = readsize;
parms.readx.in.maxcnt = readsize;
parms.readx.in.remaining = size - total;
- parms.readx.in.read_for_execute = False;
+ parms.readx.in.read_for_execute = false;
parms.readx.out.data = buf + total;
status = smb_raw_read(tree, &parms);
@@ -87,7 +88,7 @@ ssize_t smbcli_write(struct smbcli_tree *tree,
int fnum, uint16_t write_mode,
const void *_buf, off_t offset, size_t size)
{
- const uint8_t *buf = _buf;
+ const uint8_t *buf = (const uint8_t *)_buf;
union smb_write parms;
int block = (tree->session->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32));
ssize_t total = 0;
@@ -133,7 +134,7 @@ ssize_t smbcli_write(struct smbcli_tree *tree,
ssize_t smbcli_smbwrite(struct smbcli_tree *tree,
int fnum, const void *_buf, off_t offset, size_t size1)
{
- const uint8_t *buf = _buf;
+ const uint8_t *buf = (const uint8_t *)_buf;
union smb_write parms;
ssize_t total = 0;
diff --git a/source4/libcli/clitrans2.c b/source4/libcli/clitrans2.c
index 03deea2e82..5c5ba6585f 100644
--- a/source4/libcli/clitrans2.c
+++ b/source4/libcli/clitrans2.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
/****************************************************************************
send a qpathinfo call
diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c
index 3e21c3823c..67d5885497 100644
--- a/source4/libcli/composite/composite.c
+++ b/source4/libcli/composite/composite.c
@@ -53,7 +53,7 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c)
{
if (c == NULL) return NT_STATUS_NO_MEMORY;
- c->used_wait = True;
+ c->used_wait = true;
while (c->state < COMPOSITE_STATE_DONE) {
if (event_loop_once(c->event_ctx) != 0) {
@@ -69,16 +69,16 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c)
* Some composite helpers that are handy if you write larger composite
* functions.
*/
-_PUBLIC_ BOOL composite_is_ok(struct composite_context *ctx)
+_PUBLIC_ bool composite_is_ok(struct composite_context *ctx)
{
if (NT_STATUS_IS_OK(ctx->status)) {
- return True;
+ return true;
}
ctx->state = COMPOSITE_STATE_ERROR;
if (ctx->async.fn != NULL) {
ctx->async.fn(ctx);
}
- return False;
+ return false;
}
/*
@@ -113,13 +113,13 @@ _PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status)
SMB_ASSERT(!composite_is_ok(ctx));
}
-_PUBLIC_ BOOL composite_nomem(const void *p, struct composite_context *ctx)
+_PUBLIC_ bool composite_nomem(const void *p, struct composite_context *ctx)
{
if (p != NULL) {
- return False;
+ return false;
}
composite_error(ctx, NT_STATUS_NO_MEMORY);
- return True;
+ return true;
}
_PUBLIC_ void composite_done(struct composite_context *ctx)
diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk
index d49fc90ec4..d7aaac0447 100644
--- a/source4/libcli/config.mk
+++ b/source4/libcli/config.mk
@@ -3,12 +3,10 @@ include ldap/config.mk
include security/config.mk
[SUBSYSTEM::LIBSAMBA-ERRORS]
-PUBLIC_PROTO_HEADER = util/proto.h
-PUBLIC_HEADERS = util/error.h util/nterr.h util/doserr.h util/nt_status.h
+PUBLIC_HEADERS = util/error.h util/ntstatus.h util/doserr.h util/werror.h
OBJ_FILES = util/doserr.o \
- util/errormap.o \
- util/clierror.o \
- util/nterr.o \
+ util/errormap.o \
+ util/nterr.o \
[SUBSYSTEM::ASN1_UTIL]
PUBLIC_PROTO_HEADER = util/asn1_proto.h
@@ -60,6 +58,13 @@ PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT LIBCLI_COMPOSITE LIBEVENTS \
LIBRARY_REALNAME = swig/_libcli_nbt.$(SHLIBEXT)
OBJ_FILES = swig/libcli_nbt_wrap.o
PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-CONFIG
+ENABLE = NO
+
+[LIBRARY::swig_libcli_smb]
+LIBRARY_REALNAME = swig/_libcli_smb.$(SHLIBEXT)
+OBJ_FILES = swig/libcli_smb_wrap.o
+PUBLIC_DEPENDENCIES = LIBCLI_SMB DYNCONFIG LIBSAMBA-CONFIG
+ENABLE = NO
[SUBSYSTEM::LIBCLI_DGRAM]
OBJ_FILES = \
@@ -133,6 +138,7 @@ OBJ_FILES = raw/rawfile.o \
raw/clitransport.o \
raw/clisession.o \
raw/clitree.o \
+ raw/clierror.o \
raw/rawrequest.o \
raw/rawreadwrite.o \
raw/rawsearch.o \
diff --git a/source4/libcli/dgram/browse.c b/source4/libcli/dgram/browse.c
index 84a2a7e534..fc1162e644 100644
--- a/source4/libcli/dgram/browse.c
+++ b/source4/libcli/dgram/browse.c
@@ -25,6 +25,7 @@
#include "lib/socket/socket.h"
#include "libcli/resolve/resolve.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock,
struct nbt_name *dest_name,
@@ -69,7 +70,7 @@ NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock,
return status;
}
- make_nbt_name_client(&myname, lp_netbios_name());
+ make_nbt_name_client(&myname, lp_netbios_name(global_loadparm));
dest = socket_address_from_strings(tmp_ctx, dgmsock->sock->backend_name,
request->src_addr, request->src_port);
diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c
index 14eb7b931b..4e94e5ee5b 100644
--- a/source4/libcli/dgram/mailslot.c
+++ b/source4/libcli/dgram/mailslot.c
@@ -36,6 +36,7 @@
#include "lib/util/dlinklist.h"
#include "libcli/dgram/libdgram.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/*
destroy a mailslot handler
@@ -164,7 +165,7 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
if (_dest->port == 0) {
dest = socket_address_from_strings(tmp_ctx, _dest->family,
- _dest->addr, lp_dgram_port());
+ _dest->addr, lp_dgram_port(global_loadparm));
} else {
dest = _dest;
}
diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c
index df47a34a0e..46f6e50e7b 100644
--- a/source4/libcli/dgram/netlogon.c
+++ b/source4/libcli/dgram/netlogon.c
@@ -24,6 +24,7 @@
#include "lib/socket/socket.h"
#include "libcli/resolve/resolve.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
send a netlogon mailslot request
@@ -76,7 +77,7 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
return status;
}
- make_nbt_name_client(&myname, lp_netbios_name());
+ make_nbt_name_client(&myname, lp_netbios_name(global_loadparm));
dest = socket_address_from_strings(tmp_ctx, dgmsock->sock->backend_name,
request->src_addr, request->src_port);
diff --git a/source4/libcli/dgram/ntlogon.c b/source4/libcli/dgram/ntlogon.c
index 5881dcf702..25f767688a 100644
--- a/source4/libcli/dgram/ntlogon.c
+++ b/source4/libcli/dgram/ntlogon.c
@@ -24,6 +24,7 @@
#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
@@ -77,7 +78,7 @@ NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock,
return status;
}
- make_nbt_name_client(&myname, lp_netbios_name());
+ make_nbt_name_client(&myname, lp_netbios_name(global_loadparm));
dest = socket_address_from_strings(tmp_ctx,
dgmsock->sock->backend_name,
diff --git a/source4/libcli/finddcs.c b/source4/libcli/finddcs.c
index a159ab6dfc..e00697fe17 100644
--- a/source4/libcli/finddcs.c
+++ b/source4/libcli/finddcs.c
@@ -27,6 +27,8 @@
#include "libcli/composite/composite.h"
#include "libcli/libcli.h"
#include "libcli/resolve/resolve.h"
+#include "libcli/finddcs.h"
+#include "param/param.h"
struct finddcs_state {
struct composite_context *ctx;
@@ -143,9 +145,9 @@ static void finddcs_name_resolved(struct composite_context *ctx)
state->r.in.domainname = state->domain_name;
state->r.in.ip_address = state->dcs[0].address;
- state->r.in.my_computername = lp_netbios_name();
+ state->r.in.my_computername = lp_netbios_name(global_loadparm);
state->r.in.my_accountname = talloc_asprintf(state, "%s$",
- lp_netbios_name());
+ lp_netbios_name(global_loadparm));
if (composite_nomem(state->r.in.my_accountname, state->ctx)) return;
state->r.in.account_control = ACB_WSTRUST;
state->r.in.domain_sid = state->domain_sid;
diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c
index 64f6f90d31..11689fbd79 100644
--- a/source4/libcli/ldap/ldap.c
+++ b/source4/libcli/ldap/ldap.c
@@ -27,7 +27,7 @@
#include "libcli/ldap/ldap.h"
-static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree)
+static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree)
{
int i;
@@ -37,7 +37,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
asn1_push_tag(data, ASN1_CONTEXT(tree->operation==LDB_OP_AND?0:1));
for (i=0; i<tree->u.list.num_elements; i++) {
if (!ldap_push_filter(data, tree->u.list.elements[i])) {
- return False;
+ return false;
}
}
asn1_pop_tag(data);
@@ -46,7 +46,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
case LDB_OP_NOT:
asn1_push_tag(data, ASN1_CONTEXT(2));
if (!ldap_push_filter(data, tree->u.isnot.child)) {
- return False;
+ return false;
}
asn1_pop_tag(data);
break;
@@ -166,7 +166,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
break;
default:
- return False;
+ return false;
}
return !data->has_error;
}
@@ -187,12 +187,12 @@ static void ldap_encode_response(struct asn1_data *data, struct ldap_Result *res
}
}
-BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ctx)
+bool ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ctx)
{
struct asn1_data *data = asn1_init(mem_ctx);
int i, j;
- if (!data) return False;
+ if (!data) return false;
asn1_push_tag(data, ASN1_SEQUENCE(0));
asn1_write_Integer(data, msg->messageid);
@@ -225,7 +225,7 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
asn1_pop_tag(data);
break;
default:
- return False;
+ return false;
}
asn1_pop_tag(data);
@@ -256,7 +256,7 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
asn1_write_BOOLEAN(data, r->attributesonly);
if (!ldap_push_filter(data, r->tree)) {
- return False;
+ return false;
}
asn1_push_tag(data, ASN1_SEQUENCE(0));
@@ -467,7 +467,7 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
break;
}
default:
- return False;
+ return false;
}
if (msg->controls != NULL) {
@@ -475,7 +475,7 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
for (i = 0; msg->controls[i] != NULL; i++) {
if (!ldap_encode_control(mem_ctx, data, msg->controls[i])) {
- return False;
+ return false;
}
}
@@ -486,33 +486,33 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ct
if (data->has_error) {
asn1_free(data);
- return False;
+ return false;
}
*result = data_blob_talloc(mem_ctx, data->data, data->length);
asn1_free(data);
- return True;
+ return true;
}
static const char *blob2string_talloc(TALLOC_CTX *mem_ctx,
DATA_BLOB blob)
{
- char *result = talloc_size(mem_ctx, blob.length+1);
+ char *result = talloc_array(mem_ctx, char, blob.length+1);
memcpy(result, blob.data, blob.length);
result[blob.length] = '\0';
return result;
}
-static BOOL asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx,
+static bool asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx,
struct asn1_data *data,
const char **result)
{
DATA_BLOB string;
if (!asn1_read_OctetString(data, mem_ctx, &string))
- return False;
+ return false;
*result = blob2string_talloc(mem_ctx, string);
data_blob_free(&string);
- return True;
+ return true;
}
static void ldap_decode_response(TALLOC_CTX *mem_ctx,
@@ -955,7 +955,7 @@ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
}
if (pwlen != 0) {
- char *pw = talloc_size(msg, pwlen+1);
+ char *pw = talloc_array(msg, char, pwlen+1);
if (!pw) {
return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR);
}
@@ -1162,7 +1162,7 @@ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
if (len == -1) {
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
}
- dn = talloc_size(msg, len+1);
+ dn = talloc_array(msg, char, len+1);
if (dn == NULL)
break;
asn1_read(data, dn, len);
@@ -1198,7 +1198,7 @@ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
if (len == -1) {
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
}
- newsup = talloc_size(msg, len+1);
+ newsup = talloc_array(msg, char, len+1);
if (newsup == NULL) {
return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR);
}
diff --git a/source4/libcli/ldap/ldap.h b/source4/libcli/ldap/ldap.h
index 022c70e36a..e89322213a 100644
--- a/source4/libcli/ldap/ldap.h
+++ b/source4/libcli/ldap/ldap.h
@@ -22,6 +22,7 @@
#define _SMB_LDAP_H
#include "lib/ldb/include/ldb.h"
+#include "librpc/gen_ndr/misc.h"
enum ldap_request_tag {
LDAP_TAG_BindRequest = 0,
diff --git a/source4/libcli/ldap/ldap_bind.c b/source4/libcli/ldap/ldap_bind.c
index cbe8772414..d285735d4e 100644
--- a/source4/libcli/ldap/ldap_bind.c
+++ b/source4/libcli/ldap/ldap_bind.c
@@ -258,7 +258,7 @@ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn, struct cli_credentials *cr
}
status = ildap_search(conn, "", LDAP_SEARCH_SCOPE_BASE, "", supported_sasl_mech_attrs,
- False, NULL, NULL, &sasl_mechs_msgs);
+ false, NULL, NULL, &sasl_mechs_msgs);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to inquire of target's available sasl mechs in rootdse search: %s\n",
nt_errstr(status)));
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 8476a4977b..aea95de161 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -226,7 +226,7 @@ static void ldap_io_handler(struct event_context *ev, struct fd_event *fde,
parse a ldap URL
*/
static NTSTATUS ldap_parse_basic_url(TALLOC_CTX *mem_ctx, const char *url,
- char **host, uint16_t *port, BOOL *ldaps)
+ char **host, uint16_t *port, bool *ldaps)
{
int tmp_port = 0;
char protocol[11];
@@ -243,10 +243,10 @@ static NTSTATUS ldap_parse_basic_url(TALLOC_CTX *mem_ctx, const char *url,
if (strequal(protocol, "ldap")) {
*port = 389;
- *ldaps = False;
+ *ldaps = false;
} else if (strequal(protocol, "ldaps")) {
*port = 636;
- *ldaps = True;
+ *ldaps = true;
} else {
DEBUG(0, ("unrecognised ldap protocol (%s)!\n", protocol));
return NT_STATUS_PROTOCOL_UNREACHABLE;
diff --git a/source4/libcli/ldap/ldap_controls.c b/source4/libcli/ldap/ldap_controls.c
index 3a5d14c0c9..b7fd1ce178 100644
--- a/source4/libcli/ldap/ldap_controls.c
+++ b/source4/libcli/ldap/ldap_controls.c
@@ -26,56 +26,56 @@
struct control_handler {
const char *oid;
- BOOL (*decode)(void *mem_ctx, DATA_BLOB in, void **out);
- BOOL (*encode)(void *mem_ctx, void *in, DATA_BLOB *out);
+ bool (*decode)(void *mem_ctx, DATA_BLOB in, void **out);
+ bool (*encode)(void *mem_ctx, void *in, DATA_BLOB *out);
};
-static BOOL decode_server_sort_response(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_server_sort_response(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB attr;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_sort_resp_control *lsrc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lsrc = talloc(mem_ctx, struct ldb_sort_resp_control);
if (!lsrc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_enumerated(data, &(lsrc->result))) {
- return False;
+ return false;
}
lsrc->attr_desc = NULL;
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &attr)) {
- return False;
+ return false;
}
lsrc->attr_desc = talloc_strndup(lsrc, (const char *)attr.data, attr.length);
if (!lsrc->attr_desc) {
- return False;
+ return false;
}
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lsrc;
- return True;
+ return true;
}
-static BOOL decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB attr;
DATA_BLOB rule;
@@ -83,14 +83,14 @@ static BOOL decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
struct ldb_server_sort_control **lssc;
int num;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
lssc = NULL;
@@ -98,46 +98,46 @@ static BOOL decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
for (num = 0; asn1_peek_tag(data, ASN1_SEQUENCE(0)); num++) {
lssc = talloc_realloc(mem_ctx, lssc, struct ldb_server_sort_control *, num + 2);
if (!lssc) {
- return False;
+ return false;
}
lssc[num] = talloc_zero(lssc, struct ldb_server_sort_control);
if (!lssc[num]) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &attr)) {
- return False;
+ return false;
}
lssc[num]->attributeName = talloc_strndup(lssc[num], (const char *)attr.data, attr.length);
if (!lssc [num]->attributeName) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &rule)) {
- return False;
+ return false;
}
lssc[num]->orderingRule = talloc_strndup(lssc[num], (const char *)rule.data, rule.length);
if (!lssc[num]->orderingRule) {
- return False;
+ return false;
}
}
if (asn1_peek_tag(data, ASN1_BOOLEAN)) {
- BOOL reverse;
+ bool reverse;
if (!asn1_read_BOOLEAN(data, &reverse)) {
- return False;
+ return false;
}
lssc[num]->reverse = reverse;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
}
@@ -146,248 +146,248 @@ static BOOL decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lssc;
- return True;
+ return true;
}
-static BOOL decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void **out)
{
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_extended_dn_control *ledc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
ledc = talloc(mem_ctx, struct ldb_extended_dn_control);
if (!ledc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(ledc->type))) {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = ledc;
- return True;
+ return true;
}
-static BOOL decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void **out)
{
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_sd_flags_control *lsdfc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lsdfc = talloc(mem_ctx, struct ldb_sd_flags_control);
if (!lsdfc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lsdfc->secinfo_flags))) {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lsdfc;
- return True;
+ return true;
}
-static BOOL decode_search_options_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_search_options_request(void *mem_ctx, DATA_BLOB in, void **out)
{
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_search_options_control *lsoc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lsoc = talloc(mem_ctx, struct ldb_search_options_control);
if (!lsoc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lsoc->search_options))) {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lsoc;
- return True;
+ return true;
}
-static BOOL decode_paged_results_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_paged_results_request(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB cookie;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_paged_control *lprc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lprc = talloc(mem_ctx, struct ldb_paged_control);
if (!lprc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lprc->size))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &cookie)) {
- return False;
+ return false;
}
lprc->cookie_len = cookie.length;
if (lprc->cookie_len) {
lprc->cookie = talloc_memdup(lprc, cookie.data, cookie.length);
if (!(lprc->cookie)) {
- return False;
+ return false;
}
} else {
lprc->cookie = NULL;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lprc;
- return True;
+ return true;
}
-static BOOL decode_dirsync_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_dirsync_request(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB cookie;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_dirsync_control *ldc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
ldc = talloc(mem_ctx, struct ldb_dirsync_control);
if (!ldc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(ldc->flags))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(ldc->max_attributes))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &cookie)) {
- return False;
+ return false;
}
ldc->cookie_len = cookie.length;
if (ldc->cookie_len) {
ldc->cookie = talloc_memdup(ldc, cookie.data, cookie.length);
if (!(ldc->cookie)) {
- return False;
+ return false;
}
} else {
ldc->cookie = NULL;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = ldc;
- return True;
+ return true;
}
/* seem that this controls has 2 forms one in case it is used with
* a Search Request and another when used ina Search Response
*/
-static BOOL decode_asq_control(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_asq_control(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB source_attribute;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_asq_control *lac;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lac = talloc(mem_ctx, struct ldb_asq_control);
if (!lac) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &source_attribute)) {
- return False;
+ return false;
}
lac->src_attr_len = source_attribute.length;
if (lac->src_attr_len) {
lac->source_attribute = talloc_strndup(lac, (const char *)source_attribute.data, source_attribute.length);
if (!(lac->source_attribute)) {
- return False;
+ return false;
}
} else {
lac->source_attribute = NULL;
@@ -398,96 +398,96 @@ static BOOL decode_asq_control(void *mem_ctx, DATA_BLOB in, void **out)
} else if (asn1_peek_tag(data, ASN1_ENUMERATED)) {
if (!asn1_read_enumerated(data, &(lac->result))) {
- return False;
+ return false;
}
lac->request = 0;
} else {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lac;
- return True;
+ return true;
}
-static BOOL decode_domain_scope_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_domain_scope_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_notification_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_notification_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_show_deleted_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_show_deleted_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_permissive_modify_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_permissive_modify_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_manageDSAIT_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_manageDSAIT_request(void *mem_ctx, DATA_BLOB in, void **out)
{
if (in.length != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB assertion_value, context_id;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_vlv_req_control *lvrc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lvrc = talloc(mem_ctx, struct ldb_vlv_req_control);
if (!lvrc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->beforeCount))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->afterCount))) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_CONTEXT(0))) {
@@ -495,27 +495,27 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
lvrc->type = 0;
if (!asn1_start_tag(data, ASN1_CONTEXT(0))) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->match.byOffset.offset))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->match.byOffset.contentCount))) {
- return False;
+ return false;
}
if (!asn1_end_tag(data)) { /*SEQUENCE*/
- return False;
+ return false;
}
if (!asn1_end_tag(data)) { /*CONTEXT*/
- return False;
+ return false;
}
} else {
@@ -523,38 +523,38 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
lvrc->type = 1;
if (!asn1_start_tag(data, ASN1_CONTEXT(1))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &assertion_value)) {
- return False;
+ return false;
}
lvrc->match.gtOrEq.value_len = assertion_value.length;
if (lvrc->match.gtOrEq.value_len) {
lvrc->match.gtOrEq.value = talloc_memdup(lvrc, assertion_value.data, assertion_value.length);
if (!(lvrc->match.gtOrEq.value)) {
- return False;
+ return false;
}
} else {
lvrc->match.gtOrEq.value = NULL;
}
if (!asn1_end_tag(data)) { /*CONTEXT*/
- return False;
+ return false;
}
}
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &context_id)) {
- return False;
+ return false;
}
lvrc->ctxid_len = context_id.length;
if (lvrc->ctxid_len) {
lvrc->contextId = talloc_memdup(lvrc, context_id.data, context_id.length);
if (!(lvrc->contextId)) {
- return False;
+ return false;
}
} else {
lvrc->contextId = NULL;
@@ -565,54 +565,54 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lvrc;
- return True;
+ return true;
}
-static BOOL decode_vlv_response(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_vlv_response(void *mem_ctx, DATA_BLOB in, void **out)
{
DATA_BLOB context_id;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_vlv_resp_control *lvrc;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_load(data, in)) {
- return False;
+ return false;
}
lvrc = talloc(mem_ctx, struct ldb_vlv_resp_control);
if (!lvrc) {
- return False;
+ return false;
}
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->targetPosition))) {
- return False;
+ return false;
}
if (!asn1_read_Integer(data, &(lvrc->contentCount))) {
- return False;
+ return false;
}
if (!asn1_read_enumerated(data, &(lvrc->vlv_result))) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
if (!asn1_read_OctetString(data, mem_ctx, &context_id)) {
- return False;
+ return false;
}
lvrc->contextId = talloc_strndup(lvrc, (const char *)context_id.data, context_id.length);
if (!lvrc->contextId) {
- return False;
+ return false;
}
lvrc->ctxid_len = context_id.length;
} else {
@@ -621,455 +621,455 @@ static BOOL decode_vlv_response(void *mem_ctx, DATA_BLOB in, void **out)
}
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
*out = lvrc;
- return True;
+ return true;
}
-static BOOL encode_server_sort_response(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_server_sort_response(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_sort_resp_control *lsrc = talloc_get_type(in, struct ldb_sort_resp_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_enumerated(data, lsrc->result)) {
- return False;
+ return false;
}
if (lsrc->attr_desc) {
if (!asn1_write_OctetString(data, lsrc->attr_desc, strlen(lsrc->attr_desc))) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_server_sort_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_server_sort_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_server_sort_control **lssc = talloc_get_type(in, struct ldb_server_sort_control *);
struct asn1_data *data = asn1_init(mem_ctx);
int num;
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
for (num = 0; lssc[num]; num++) {
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, lssc[num]->attributeName, strlen(lssc[num]->attributeName))) {
- return False;
+ return false;
}
if (lssc[num]->orderingRule) {
if (!asn1_write_OctetString(data, lssc[num]->orderingRule, strlen(lssc[num]->orderingRule))) {
- return False;
+ return false;
}
}
if (lssc[num]->reverse) {
if (!asn1_write_BOOLEAN(data, lssc[num]->reverse)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_extended_dn_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_extended_dn_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_extended_dn_control *ledc = talloc_get_type(in, struct ldb_extended_dn_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, ledc->type)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_sd_flags_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_sd_flags_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_sd_flags_control *lsdfc = talloc_get_type(in, struct ldb_sd_flags_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lsdfc->secinfo_flags)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_search_options_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_search_options_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_search_options_control *lsoc = talloc_get_type(in, struct ldb_search_options_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lsoc->search_options)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_paged_results_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_paged_results_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_paged_control *lprc = talloc_get_type(in, struct ldb_paged_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lprc->size)) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, lprc->cookie, lprc->cookie_len)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
/* seem that this controls has 2 forms one in case it is used with
* a Search Request and another when used ina Search Response
*/
-static BOOL encode_asq_control(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_asq_control(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_asq_control *lac = talloc_get_type(in, struct ldb_asq_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (lac->request) {
if (!asn1_write_OctetString(data, lac->source_attribute, lac->src_attr_len)) {
- return False;
+ return false;
}
} else {
if (!asn1_write_enumerated(data, lac->result)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_dirsync_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_dirsync_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_dirsync_control *ldc = talloc_get_type(in, struct ldb_dirsync_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, ldc->flags)) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, ldc->max_attributes)) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, ldc->cookie, ldc->cookie_len)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_domain_scope_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_domain_scope_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_notification_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_notification_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_show_deleted_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_show_deleted_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_permissive_modify_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_permissive_modify_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_manageDSAIT_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_manageDSAIT_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
if (in) {
- return False;
+ return false;
}
*out = data_blob(NULL, 0);
- return True;
+ return true;
}
-static BOOL encode_vlv_request(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_vlv_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_vlv_req_control *lvrc = talloc_get_type(in, struct ldb_vlv_req_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->beforeCount)) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->afterCount)) {
- return False;
+ return false;
}
if (lvrc->type == 0) {
if (!asn1_push_tag(data, ASN1_CONTEXT(0))) {
- return False;
+ return false;
}
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->match.byOffset.offset)) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->match.byOffset.contentCount)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) { /*SEQUENCE*/
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) { /*CONTEXT*/
- return False;
+ return false;
}
} else {
if (!asn1_push_tag(data, ASN1_CONTEXT(1))) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, lvrc->match.gtOrEq.value, lvrc->match.gtOrEq.value_len)) {
- return False;
+ return false;
}
if (!asn1_pop_tag(data)) { /*CONTEXT*/
- return False;
+ return false;
}
}
if (lvrc->ctxid_len) {
if (!asn1_write_OctetString(data, lvrc->contextId, lvrc->ctxid_len)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
-static BOOL encode_vlv_response(void *mem_ctx, void *in, DATA_BLOB *out)
+static bool encode_vlv_response(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_vlv_resp_control *lvrc = talloc_get_type(in, struct ldb_vlv_resp_control);
struct asn1_data *data = asn1_init(mem_ctx);
- if (!data) return False;
+ if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->targetPosition)) {
- return False;
+ return false;
}
if (!asn1_write_Integer(data, lvrc->contentCount)) {
- return False;
+ return false;
}
if (!asn1_write_enumerated(data, lvrc->vlv_result)) {
- return False;
+ return false;
}
if (lvrc->ctxid_len) {
if (!asn1_write_OctetString(data, lvrc->contextId, lvrc->ctxid_len)) {
- return False;
+ return false;
}
}
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
- return False;
+ return false;
}
talloc_free(data);
- return True;
+ return true;
}
struct control_handler ldap_known_controls[] = {
@@ -1095,49 +1095,49 @@ struct control_handler ldap_known_controls[] = {
{ NULL, NULL, NULL }
};
-BOOL ldap_decode_control_value(void *mem_ctx, DATA_BLOB value, struct ldb_control *ctrl)
+bool ldap_decode_control_value(void *mem_ctx, DATA_BLOB value, struct ldb_control *ctrl)
{
int i;
for (i = 0; ldap_known_controls[i].oid != NULL; i++) {
if (strcmp(ldap_known_controls[i].oid, ctrl->oid) == 0) {
if (!ldap_known_controls[i].decode || !ldap_known_controls[i].decode(mem_ctx, value, &ctrl->data)) {
- return False;
+ return false;
}
break;
}
}
if (ldap_known_controls[i].oid == NULL) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL ldap_decode_control_wrapper(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl, DATA_BLOB *value)
+bool ldap_decode_control_wrapper(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl, DATA_BLOB *value)
{
DATA_BLOB oid;
if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_read_OctetString(data, mem_ctx, &oid)) {
- return False;
+ return false;
}
ctrl->oid = talloc_strndup(mem_ctx, (char *)oid.data, oid.length);
if (!ctrl->oid) {
- return False;
+ return false;
}
if (asn1_peek_tag(data, ASN1_BOOLEAN)) {
- BOOL critical;
+ bool critical;
if (!asn1_read_BOOLEAN(data, &critical)) {
- return False;
+ return false;
}
ctrl->critical = critical;
} else {
- ctrl->critical = False;
+ ctrl->critical = false;
}
ctrl->data = NULL;
@@ -1148,18 +1148,18 @@ BOOL ldap_decode_control_wrapper(void *mem_ctx, struct asn1_data *data, struct l
}
if (!asn1_read_OctetString(data, mem_ctx, value)) {
- return False;
+ return false;
}
end_tag:
if (!asn1_end_tag(data)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl)
+bool ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl)
{
DATA_BLOB value;
int i;
@@ -1168,33 +1168,33 @@ BOOL ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_contr
if (strcmp(ldap_known_controls[i].oid, ctrl->oid) == 0) {
if (!ldap_known_controls[i].encode) {
if (ctrl->critical) {
- return False;
+ return false;
} else {
/* not encoding this control */
- return True;
+ return true;
}
}
if (!ldap_known_controls[i].encode(mem_ctx, ctrl->data, &value)) {
- return False;
+ return false;
}
break;
}
}
if (ldap_known_controls[i].oid == NULL) {
- return False;
+ return false;
}
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return False;
+ return false;
}
if (!asn1_write_OctetString(data, ctrl->oid, strlen(ctrl->oid))) {
- return False;
+ return false;
}
if (ctrl->critical) {
if (!asn1_write_BOOLEAN(data, ctrl->critical)) {
- return False;
+ return false;
}
}
@@ -1203,13 +1203,13 @@ BOOL ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_contr
}
if (!asn1_write_OctetString(data, value.data, value.length)) {
- return False;
+ return false;
}
pop_tag:
if (!asn1_pop_tag(data)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
diff --git a/source4/libcli/ldap/ldap_ildap.c b/source4/libcli/ldap/ldap_ildap.c
index 62019b8cc1..7b592c65ae 100644
--- a/source4/libcli/ldap/ldap_ildap.c
+++ b/source4/libcli/ldap/ldap_ildap.c
@@ -41,7 +41,7 @@ int ildap_count_entries(struct ldap_connection *conn, struct ldap_message **res)
*/
NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
int scope, struct ldb_parse_tree *tree,
- const char * const *attrs, BOOL attributesonly,
+ const char * const *attrs, bool attributesonly,
struct ldb_control **control_req,
struct ldb_control ***control_res,
struct ldap_message ***results)
@@ -75,7 +75,7 @@ NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
req = ldap_request_send(conn, msg);
talloc_steal(msg, req);
- for (i=n=0;True;i++) {
+ for (i=n=0;true;i++) {
struct ldap_message *res;
status = ldap_result_n(req, i, &res);
if (!NT_STATUS_IS_OK(status)) break;
@@ -114,7 +114,7 @@ NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
*/
NTSTATUS ildap_search(struct ldap_connection *conn, const char *basedn,
int scope, const char *expression,
- const char * const *attrs, BOOL attributesonly,
+ const char * const *attrs, bool attributesonly,
struct ldb_control **control_req,
struct ldb_control ***control_res,
struct ldap_message ***results)
diff --git a/source4/libcli/ldap/ldap_msg.c b/source4/libcli/ldap/ldap_msg.c
index c9643dafda..12832b8ec4 100644
--- a/source4/libcli/ldap/ldap_msg.c
+++ b/source4/libcli/ldap/ldap_msg.c
@@ -32,7 +32,7 @@ struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx)
}
-BOOL add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldb_val *value,
+bool add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldb_val *value,
struct ldb_message_element *attrib)
{
attrib->values = talloc_realloc(mem_ctx,
@@ -40,16 +40,16 @@ BOOL add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldb_val *value,
DATA_BLOB,
attrib->num_values+1);
if (attrib->values == NULL)
- return False;
+ return false;
attrib->values[attrib->num_values].data = talloc_steal(attrib->values,
value->data);
attrib->values[attrib->num_values].length = value->length;
attrib->num_values += 1;
- return True;
+ return true;
}
-BOOL add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
+bool add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
const struct ldb_message_element *attrib,
struct ldb_message_element **attribs,
int *num_attribs)
@@ -60,16 +60,16 @@ BOOL add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
*num_attribs+1);
if (*attribs == NULL)
- return False;
+ return false;
(*attribs)[*num_attribs] = *attrib;
talloc_steal(*attribs, attrib->values);
talloc_steal(*attribs, attrib->name);
*num_attribs += 1;
- return True;
+ return true;
}
-BOOL add_mod_to_array_talloc(TALLOC_CTX *mem_ctx,
+bool add_mod_to_array_talloc(TALLOC_CTX *mem_ctx,
struct ldap_mod *mod,
struct ldap_mod **mods,
int *num_mods)
@@ -77,10 +77,10 @@ BOOL add_mod_to_array_talloc(TALLOC_CTX *mem_ctx,
*mods = talloc_realloc(mem_ctx, *mods, struct ldap_mod, (*num_mods)+1);
if (*mods == NULL)
- return False;
+ return false;
(*mods)[*num_mods] = *mod;
*num_mods += 1;
- return True;
+ return true;
}
diff --git a/source4/libcli/libcli.h b/source4/libcli/libcli.h
index 1d573cadde..163852d90a 100644
--- a/source4/libcli/libcli.h
+++ b/source4/libcli/libcli.h
@@ -23,6 +23,8 @@
#include "librpc/gen_ndr/nbt.h"
+struct substitute_context;
+
/*
smbcli_state: internal state used in libcli library for single-threaded callers,
i.e. a single session on a single socket.
diff --git a/source4/libcli/nbt/namequery.c b/source4/libcli/nbt/namequery.c
index 32de9723b9..755e06e880 100644
--- a/source4/libcli/nbt/namequery.c
+++ b/source4/libcli/nbt/namequery.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "libcli/nbt/libnbt.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/**
send a nbt name query
@@ -53,10 +54,10 @@ _PUBLIC_ struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nb
packet->questions[0].question_class = NBT_QCLASS_IP;
dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
@@ -157,10 +158,10 @@ _PUBLIC_ struct nbt_name_request *nbt_name_status_send(struct nbt_name_socket *n
packet->questions[0].question_class = NBT_QCLASS_IP;
dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
diff --git a/source4/libcli/nbt/namerefresh.c b/source4/libcli/nbt/namerefresh.c
index a60e54ed6a..d723eed9f5 100644
--- a/source4/libcli/nbt/namerefresh.c
+++ b/source4/libcli/nbt/namerefresh.c
@@ -23,6 +23,7 @@
#include "libcli/nbt/libnbt.h"
#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/*
send a nbt name refresh request
@@ -66,11 +67,12 @@ struct nbt_name_request *nbt_name_refresh_send(struct nbt_name_socket *nbtsock,
packet->additional[0].rdata.netbios.addresses[0].ipaddr =
talloc_strdup(packet->additional, io->in.address);
- dest = socket_address_from_strings(nbtsock, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ dest = socket_address_from_strings(nbtsock,
+ nbtsock->sock->backend_name,
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
@@ -240,7 +242,7 @@ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbt
state->io->in.dest_addr = state->wins_servers[0];
state->io->in.address = io->in.addresses[0];
state->io->in.nb_flags = io->in.nb_flags;
- state->io->in.broadcast = False;
+ state->io->in.broadcast = false;
state->io->in.ttl = io->in.ttl;
state->io->in.timeout = 2;
state->io->in.retries = 2;
diff --git a/source4/libcli/nbt/nameregister.c b/source4/libcli/nbt/nameregister.c
index 7b03667fec..fd4a94dd44 100644
--- a/source4/libcli/nbt/nameregister.c
+++ b/source4/libcli/nbt/nameregister.c
@@ -24,6 +24,7 @@
#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
send a nbt name registration request
@@ -76,10 +77,10 @@ struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock,
if (packet->additional[0].rdata.netbios.addresses[0].ipaddr == NULL) goto failed;
dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
@@ -165,7 +166,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req)
status = nbt_name_register_recv(state->req, state, state->io);
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- if (state->io->in.register_demand == True) {
+ if (state->io->in.register_demand == true) {
/* all done */
c->state = COMPOSITE_STATE_DONE;
c->status = NT_STATUS_OK;
@@ -173,7 +174,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req)
}
/* the registration timed out - good, send the demand */
- state->io->in.register_demand = True;
+ state->io->in.register_demand = true;
state->io->in.retries = 0;
state->req = nbt_name_register_send(state->nbtsock, state->io);
if (state->req == NULL) {
@@ -225,9 +226,9 @@ struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *n
state->io->in.dest_addr = io->in.dest_addr;
state->io->in.address = io->in.address;
state->io->in.nb_flags = io->in.nb_flags;
- state->io->in.register_demand = False;
- state->io->in.broadcast = True;
- state->io->in.multi_homed = False;
+ state->io->in.register_demand = false;
+ state->io->in.broadcast = true;
+ state->io->in.multi_homed = false;
state->io->in.ttl = io->in.ttl;
state->io->in.timeout = 1;
state->io->in.retries = 2;
@@ -378,9 +379,9 @@ struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nb
state->io->in.dest_addr = state->wins_servers[0];
state->io->in.address = io->in.addresses[0];
state->io->in.nb_flags = io->in.nb_flags;
- state->io->in.broadcast = False;
- state->io->in.register_demand = False;
- state->io->in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?False:True;
+ state->io->in.broadcast = false;
+ state->io->in.register_demand = false;
+ state->io->in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?false:true;
state->io->in.ttl = io->in.ttl;
state->io->in.timeout = 3;
state->io->in.retries = 2;
diff --git a/source4/libcli/nbt/namerelease.c b/source4/libcli/nbt/namerelease.c
index fd3967d1e6..1b3c9ae17e 100644
--- a/source4/libcli/nbt/namerelease.c
+++ b/source4/libcli/nbt/namerelease.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "libcli/nbt/libnbt.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/*
send a nbt name release request
@@ -66,10 +67,10 @@ struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket *nbtsock,
talloc_strdup(packet->additional, io->in.address);
dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
- io->in.dest_addr, lp_nbt_port());
+ io->in.dest_addr, lp_nbt_port(global_loadparm));
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
- io->in.timeout, io->in.retries, False);
+ io->in.timeout, io->in.retries, false);
if (req == NULL) goto failed;
talloc_free(packet);
diff --git a/source4/libcli/nbt/nbtname.c b/source4/libcli/nbt/nbtname.c
index af3f62b987..37cdf64023 100644
--- a/source4/libcli/nbt/nbtname.c
+++ b/source4/libcli/nbt/nbtname.c
@@ -111,7 +111,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const
NT_STATUS_NOT_OK_RETURN(status);
if (component == NULL) break;
if (name) {
- name = talloc_asprintf_append(name, ".%s", component);
+ name = talloc_asprintf_append_buffer(name, ".%s", component);
NT_STATUS_HAVE_NO_MEMORY(name);
} else {
name = (char *)component;
@@ -149,7 +149,7 @@ _PUBLIC_ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const
/* see if we have pushed the remaing string allready,
* if so we use a label pointer to this string
*/
- status = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, False);
+ status = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false);
if (NT_STATUS_IS_OK(status)) {
uint8_t b[2];
@@ -401,7 +401,7 @@ _PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx,
n->scope = NULL;
n->type = type;
- if (is_ipaddress(name)) {
+ if (is_ipaddress(name) || name == NULL) {
n->name = "*SMBSERVER";
return;
}
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 597dc5a354..7d88c83044 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -25,6 +25,7 @@
#include "libcli/nbt/libnbt.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
#define NBT_MAX_REPLIES 1000
@@ -214,7 +215,8 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
}
/* find the matching request */
- req = idr_find(nbtsock->idr, packet->name_trn_id);
+ req = (struct nbt_name_request *)idr_find(nbtsock->idr,
+ packet->name_trn_id);
if (req == NULL) {
if (nbtsock->unexpected.handler) {
nbtsock->unexpected.handler(nbtsock, packet, src);
@@ -239,10 +241,10 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
/* we know we won't need any more retries - the server
has received our request */
req->num_retries = 0;
- req->received_wack = True;
+ req->received_wack = true;
/* although there can be a timeout in the packet, w2k3 screws it up,
so better to set it ourselves */
- req->timeout = lp_parm_int(-1, "nbt", "wack_timeout", 30);
+ req->timeout = lp_parm_int(global_loadparm, NULL, "nbt", "wack_timeout", 30);
req->te = event_add_timed(req->nbtsock->event_ctx, req,
timeval_current_ofs(req->timeout, 0),
nbt_name_socket_timeout, req);
@@ -353,7 +355,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
struct socket_address *dest,
struct nbt_name_packet *request,
int timeout, int retries,
- BOOL allow_multiple_replies)
+ bool allow_multiple_replies)
{
struct nbt_name_request *req;
int id;
@@ -365,7 +367,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
req->nbtsock = nbtsock;
req->allow_multiple_replies = allow_multiple_replies;
req->state = NBT_REQUEST_SEND;
- req->is_reply = False;
+ req->is_reply = false;
req->timeout = timeout;
req->num_retries = retries;
req->dest = dest;
@@ -429,7 +431,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
req->dest = dest;
if (talloc_reference(req, dest) == NULL) goto failed;
req->state = NBT_REQUEST_SEND;
- req->is_reply = True;
+ req->is_reply = true;
talloc_set_destructor(req, nbt_name_request_destructor);
diff --git a/source4/libcli/util/clierror.c b/source4/libcli/raw/clierror.c
index 89bba21ed6..c515259ee7 100644
--- a/source4/libcli/util/clierror.c
+++ b/source4/libcli/raw/clierror.c
@@ -66,7 +66,7 @@ NTSTATUS smbcli_nt_error(struct smbcli_tree *tree)
/* Return true if the last packet was an error */
-BOOL smbcli_is_error(struct smbcli_tree *tree)
+bool smbcli_is_error(struct smbcli_tree *tree)
{
return NT_STATUS_IS_ERR(smbcli_nt_error(tree));
}
diff --git a/source4/libcli/raw/clioplock.c b/source4/libcli/raw/clioplock.c
index 12b586aafa..ae4e58ae01 100644
--- a/source4/libcli/raw/clioplock.c
+++ b/source4/libcli/raw/clioplock.c
@@ -23,9 +23,9 @@
/****************************************************************************
send an ack for an oplock break request
****************************************************************************/
-_PUBLIC_ BOOL smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level)
+_PUBLIC_ bool smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level)
{
- BOOL ret;
+ bool ret;
struct smbcli_request *req;
req = smbcli_request_setup(tree, SMBlockingX, 8, 0);
@@ -53,7 +53,7 @@ _PUBLIC_ BOOL smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_
set the oplock handler for a connection
****************************************************************************/
_PUBLIC_ void smbcli_oplock_handler(struct smbcli_transport *transport,
- BOOL (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *),
+ bool (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *),
void *private)
{
transport->oplock.handler = handler;
diff --git a/source4/libcli/raw/clisession.c b/source4/libcli/raw/clisession.c
index c6c575b818..617131c53c 100644
--- a/source4/libcli/raw/clisession.c
+++ b/source4/libcli/raw/clisession.c
@@ -33,7 +33,7 @@
Initialize the session context
****************************************************************************/
struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx, bool primary)
{
struct smbcli_session *session;
uint16_t flags2;
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 0aa6ec5616..a748b40a32 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -26,6 +26,7 @@
#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
#include "libcli/resolve/resolve.h"
+#include "param/param.h"
struct sock_connect_state {
struct composite_context *ctx;
@@ -72,7 +73,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
if (state->host_name == NULL) goto failed;
if (port == 0) {
- const char **ports = lp_smb_ports();
+ const char **ports = lp_smb_ports(global_loadparm);
int i;
for (i=0;ports[i];i++) /* noop */ ;
@@ -119,7 +120,7 @@ static void smbcli_sock_connect_recv_conn(struct composite_context *ctx)
if (!composite_is_ok(state->ctx)) return;
state->ctx->status =
- socket_set_option(sock, lp_socket_options(), NULL);
+ socket_set_option(sock, lp_socket_options(global_loadparm), NULL);
if (!composite_is_ok(state->ctx)) return;
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index 98f5042d99..0bf805910e 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -26,6 +26,7 @@
#include "lib/events/events.h"
#include "lib/stream/packet.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
@@ -71,7 +72,8 @@ static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob);
create a transport structure based on an established socket
*/
struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx,
+ bool primary)
{
struct smbcli_transport *transport;
@@ -84,9 +86,10 @@ struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
transport->socket = talloc_reference(transport, sock);
}
transport->negotiate.protocol = PROTOCOL_NT1;
- transport->options.use_spnego = lp_use_spnego() && lp_nt_status_support();
- transport->options.max_xmit = lp_max_xmit();
- transport->options.max_mux = lp_maxmux();
+ transport->options.use_spnego = lp_use_spnego(global_loadparm) &&
+ lp_nt_status_support(global_loadparm);
+ transport->options.max_xmit = lp_max_xmit(global_loadparm);
+ transport->options.max_mux = lp_maxmux(global_loadparm);
transport->options.request_timeout = SMB_REQUEST_TIMEOUT;
transport->negotiate.max_xmit = transport->options.max_xmit;
@@ -259,7 +262,7 @@ NTSTATUS smbcli_transport_connect_recv(struct smbcli_request *req)
/*
send a session request (if needed)
*/
-BOOL smbcli_transport_connect(struct smbcli_transport *transport,
+bool smbcli_transport_connect(struct smbcli_transport *transport,
struct nbt_name *calling,
struct nbt_name *called)
{
@@ -267,7 +270,7 @@ BOOL smbcli_transport_connect(struct smbcli_transport *transport,
NTSTATUS status;
if (transport->socket->port == 445) {
- return True;
+ return true;
}
req = smbcli_transport_connect_send(transport,
@@ -498,16 +501,16 @@ error:
/*
process some read/write requests that are pending
- return False if the socket is dead
+ return false if the socket is dead
*/
-BOOL smbcli_transport_process(struct smbcli_transport *transport)
+bool smbcli_transport_process(struct smbcli_transport *transport)
{
NTSTATUS status;
size_t npending;
packet_queue_run(transport->packet);
if (transport->socket->sock == NULL) {
- return False;
+ return false;
}
status = socket_pending(transport->socket->sock, &npending);
@@ -515,9 +518,9 @@ BOOL smbcli_transport_process(struct smbcli_transport *transport)
packet_recv(transport->packet);
}
if (transport->socket->sock == NULL) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
@@ -635,7 +638,7 @@ NTSTATUS smb_raw_echo_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
p->out.sequence_number = SVAL(req->in.vwv, VWV(0));
p->out.size = req->in.data_size;
talloc_free(p->out.data);
- p->out.data = talloc_size(mem_ctx, p->out.size);
+ p->out.data = talloc_array(mem_ctx, uint8_t, p->out.size);
NT_STATUS_HAVE_NO_MEMORY(p->out.data);
if (!smbcli_raw_pull_data(req, req->in.data, p->out.size, p->out.data)) {
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index a5217d74b2..54f8ac95a4 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
#define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \
req = smbcli_request_setup(tree, cmd, wct, buflen); \
@@ -33,7 +34,7 @@
Initialize the tree context
****************************************************************************/
struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx, bool primary)
{
struct smbcli_tree *tree;
@@ -188,8 +189,8 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
io.in.service = service;
io.in.service_type = service_type;
io.in.credentials = credentials;
- io.in.fallback_to_anonymous = False;
- io.in.workgroup = lp_workgroup();
+ io.in.fallback_to_anonymous = false;
+ io.in.workgroup = lp_workgroup(global_loadparm);
status = smb_composite_connect(&io, parent_ctx, ev);
if (NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index 23de6c3838..00ab788184 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -23,6 +23,7 @@
#define __LIBCLI_RAW_INTERFACES_H__
#include "smb.h"
+#include "librpc/gen_ndr/misc.h" /* for struct GUID */
/* this structure is just a wrapper for a string, the only reason we
bother with this is that it allows us to check the length provided
diff --git a/source4/libcli/raw/raweas.c b/source4/libcli/raw/raweas.c
index f79de88fa6..8ea8e621c9 100644
--- a/source4/libcli/raw/raweas.c
+++ b/source4/libcli/raw/raweas.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "smb.h"
+#include "libcli/raw/libcliraw.h"
/*
work out how many bytes on the wire a ea list will consume.
@@ -332,7 +333,7 @@ NTSTATUS ea_pull_name_list(const DATA_BLOB *blob,
/*
put a ea_name list into a data blob
*/
-BOOL ea_push_name_list(TALLOC_CTX *mem_ctx,
+bool ea_push_name_list(TALLOC_CTX *mem_ctx,
DATA_BLOB *data, uint_t num_names, struct ea_name *eas)
{
int i;
@@ -343,7 +344,7 @@ BOOL ea_push_name_list(TALLOC_CTX *mem_ctx,
*data = data_blob_talloc(mem_ctx, NULL, ea_size);
if (data->data == NULL) {
- return False;
+ return false;
}
SIVAL(data->data, 0, ea_size);
@@ -356,5 +357,5 @@ BOOL ea_push_name_list(TALLOC_CTX *mem_ctx,
off += 1+nlen+1;
}
- return True;
+ return true;
}
diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c
index 60a9bf2656..83303cf470 100644
--- a/source4/libcli/raw/rawfile.c
+++ b/source4/libcli/raw/rawfile.c
@@ -426,7 +426,7 @@ struct smbcli_request *smb_raw_open_send(struct smbcli_tree *tree, union smb_ope
{
int len;
struct smbcli_request *req = NULL;
- BOOL bigoffset = False;
+ bool bigoffset = false;
switch (parms->generic.level) {
case RAW_OPEN_T2OPEN:
@@ -527,7 +527,7 @@ struct smbcli_request *smb_raw_open_send(struct smbcli_tree *tree, union smb_ope
smbcli_req_append_string(req, parms->openxreadx.in.fname, STR_TERMINATE);
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
- bigoffset = True;
+ bigoffset = true;
}
smbcli_chained_request_setup(req, SMBreadX, bigoffset ? 12 : 10, 0);
diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c
index faae3a52b1..8481995c1a 100644
--- a/source4/libcli/raw/rawfileinfo.c
+++ b/source4/libcli/raw/rawfileinfo.c
@@ -66,7 +66,7 @@ NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx,
if (size == -1) {
return NT_STATUS_ILLEGAL_CHARACTER;
}
- io->streams[n].stream_name.s = vstr;
+ io->streams[n].stream_name.s = (const char *)vstr;
io->streams[n].stream_name.private_length = nlen;
io->num_streams++;
len = IVAL(blob.data, ofs);
diff --git a/source4/libcli/raw/rawlpq.c b/source4/libcli/raw/rawlpq.c
index 03f7a82f1c..46e0efaaf5 100644
--- a/source4/libcli/raw/rawlpq.c
+++ b/source4/libcli/raw/rawlpq.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "smb.h"
+#include "libcli/raw/libcliraw.h"
/****************************************************************************
lpq - async send
diff --git a/source4/libcli/raw/rawnegotiate.c b/source4/libcli/raw/rawnegotiate.c
index c2dc393481..82d6fe5236 100644
--- a/source4/libcli/raw/rawnegotiate.c
+++ b/source4/libcli/raw/rawnegotiate.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
#include "system/time.h"
+#include "param/param.h"
static const struct {
enum protocol_types prot;
@@ -57,7 +58,7 @@ struct smbcli_request *smb_raw_negotiate_send(struct smbcli_transport *transport
}
flags2 |= FLAGS2_32_BIT_ERROR_CODES;
- if (lp_unicode()) {
+ if (lp_unicode(global_loadparm)) {
flags2 |= FLAGS2_UNICODE_STRINGS;
}
flags2 |= FLAGS2_EXTENDED_ATTRIBUTES;
@@ -143,8 +144,8 @@ NTSTATUS smb_raw_negotiate_recv(struct smbcli_request *req)
}
if (transport->negotiate.capabilities & CAP_RAW_MODE) {
- transport->negotiate.readbraw_supported = True;
- transport->negotiate.writebraw_supported = True;
+ transport->negotiate.readbraw_supported = true;
+ transport->negotiate.writebraw_supported = true;
}
} else if (transport->negotiate.protocol >= PROTOCOL_LANMAN1) {
SMBCLI_CHECK_WCT(req, 13);
@@ -173,11 +174,11 @@ NTSTATUS smb_raw_negotiate_recv(struct smbcli_request *req)
}
/* a way to force ascii SMB */
- if (!lp_unicode()) {
+ if (!lp_unicode(global_loadparm)) {
transport->negotiate.capabilities &= ~CAP_UNICODE;
}
- if (!lp_nt_status_support()) {
+ if (!lp_nt_status_support(global_loadparm)) {
transport->negotiate.capabilities &= ~CAP_STATUS32;
}
diff --git a/source4/libcli/raw/rawreadwrite.c b/source4/libcli/raw/rawreadwrite.c
index a288b7ec54..b0c49ddab7 100644
--- a/source4/libcli/raw/rawreadwrite.c
+++ b/source4/libcli/raw/rawreadwrite.c
@@ -31,13 +31,13 @@
****************************************************************************/
struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_read *parms)
{
- BOOL bigoffset = False;
+ bool bigoffset = false;
struct smbcli_request *req = NULL;
switch (parms->generic.level) {
case RAW_READ_READBRAW:
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
- bigoffset = True;
+ bigoffset = true;
}
SETUP_REQUEST(SMBreadbraw, bigoffset? 10:8, 0);
SSVAL(req->out.vwv, VWV(0), parms->readbraw.in.file.fnum);
@@ -69,7 +69,7 @@ struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_rea
case RAW_READ_READX:
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
- bigoffset = True;
+ bigoffset = true;
}
SETUP_REQUEST(SMBreadX, bigoffset ? 12 : 10, 0);
SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
@@ -206,7 +206,7 @@ NTSTATUS smb_raw_read(struct smbcli_tree *tree, union smb_read *parms)
****************************************************************************/
struct smbcli_request *smb_raw_write_send(struct smbcli_tree *tree, union smb_write *parms)
{
- BOOL bigoffset = False;
+ bool bigoffset = false;
struct smbcli_request *req = NULL;
switch (parms->generic.level) {
@@ -253,7 +253,7 @@ struct smbcli_request *smb_raw_write_send(struct smbcli_tree *tree, union smb_wr
case RAW_WRITE_WRITEX:
if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) {
- bigoffset = True;
+ bigoffset = true;
}
SETUP_REQUEST(SMBwriteX, bigoffset ? 14 : 12, parms->writex.in.count);
SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE);
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index 6bf2bb58cc..6a4f432088 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -83,7 +83,7 @@ struct smbcli_request *smbcli_request_setup_nonsmb(struct smbcli_transport *tran
/* over allocate by a small amount */
req->out.allocated = req->out.size + REQ_OVER_ALLOCATION;
- req->out.buffer = talloc_size(req, req->out.allocated);
+ req->out.buffer = talloc_array(req, uint8_t, req->out.allocated);
if (!req->out.buffer) {
return NULL;
}
@@ -309,7 +309,7 @@ NTSTATUS smbcli_chained_advance(struct smbcli_request *req)
/*
send a message
*/
-BOOL smbcli_request_send(struct smbcli_request *req)
+bool smbcli_request_send(struct smbcli_request *req)
{
if (IVAL(req->out.buffer, 0) == 0) {
_smb_setlen(req->out.buffer, req->out.size - NBT_HDR_SIZE);
@@ -319,23 +319,23 @@ BOOL smbcli_request_send(struct smbcli_request *req)
smbcli_transport_send(req);
- return True;
+ return true;
}
/*
receive a response to a packet
*/
-BOOL smbcli_request_receive(struct smbcli_request *req)
+bool smbcli_request_receive(struct smbcli_request *req)
{
/* req can be NULL when a send has failed. This eliminates lots of NULL
checks in each module */
- if (!req) return False;
+ if (!req) return false;
/* keep receiving packets until this one is replied to */
while (req->state <= SMBCLI_REQUEST_RECV) {
if (event_loop_once(req->transport->socket->event.ctx) != 0) {
- return False;
+ return false;
}
}
@@ -347,7 +347,7 @@ BOOL smbcli_request_receive(struct smbcli_request *req)
receive another reply to a request - this is used for requests that
have multi-part replies (such as SMBtrans2)
*/
-BOOL smbcli_request_receive_more(struct smbcli_request *req)
+bool smbcli_request_receive_more(struct smbcli_request *req)
{
req->state = SMBCLI_REQUEST_RECV;
DLIST_ADD(req->transport->pending_recv, req);
@@ -357,10 +357,10 @@ BOOL smbcli_request_receive_more(struct smbcli_request *req)
/*
- handle oplock break requests from the server - return True if the request was
+ handle oplock break requests from the server - return true if the request was
an oplock break
*/
-BOOL smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len, const uint8_t *hdr, const uint8_t *vwv)
+bool smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len, const uint8_t *hdr, const uint8_t *vwv)
{
/* we must be very fussy about what we consider an oplock break to avoid
matching readbraw replies */
@@ -370,7 +370,7 @@ BOOL smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len,
SVAL(hdr, HDR_MID) != 0xFFFF ||
SVAL(vwv,VWV(6)) != 0 ||
SVAL(vwv,VWV(7)) != 0) {
- return False;
+ return false;
}
if (transport->oplock.handler) {
@@ -380,7 +380,7 @@ BOOL smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len,
transport->oplock.handler(transport, tid, fnum, level, transport->oplock.private);
}
- return True;
+ return true;
}
/*
@@ -395,7 +395,7 @@ NTSTATUS smbcli_request_simple_recv(struct smbcli_request *req)
/* Return true if the last packet was in error */
-BOOL smbcli_request_is_error(struct smbcli_request *req)
+bool smbcli_request_is_error(struct smbcli_request *req)
{
return NT_STATUS_IS_ERR(req->status);
}
@@ -676,33 +676,33 @@ DATA_BLOB smbcli_req_pull_blob(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
/* check that a lump of data in a request is within the bounds of the data section of
the packet */
-static BOOL smbcli_req_data_oob(struct smbcli_request *req, const uint8_t *ptr, uint32_t count)
+static bool smbcli_req_data_oob(struct smbcli_request *req, const uint8_t *ptr, uint32_t count)
{
/* be careful with wraparound! */
if (ptr < req->in.data ||
ptr >= req->in.data + req->in.data_size ||
count > req->in.data_size ||
ptr + count > req->in.data + req->in.data_size) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
pull a lump of data from a request packet
- return False if any part is outside the data portion of the packet
+ return false if any part is outside the data portion of the packet
*/
-BOOL smbcli_raw_pull_data(struct smbcli_request *req, const uint8_t *src, int len, uint8_t *dest)
+bool smbcli_raw_pull_data(struct smbcli_request *req, const uint8_t *src, int len, uint8_t *dest)
{
- if (len == 0) return True;
+ if (len == 0) return true;
if (smbcli_req_data_oob(req, src, len)) {
- return False;
+ return false;
}
memcpy(dest, src, len);
- return True;
+ return true;
}
diff --git a/source4/libcli/raw/rawsetfileinfo.c b/source4/libcli/raw/rawsetfileinfo.c
index 7738e849e8..5fa0c1f2da 100644
--- a/source4/libcli/raw/rawsetfileinfo.c
+++ b/source4/libcli/raw/rawsetfileinfo.c
@@ -27,7 +27,7 @@
/*
Handle setfileinfo/setpathinfo passthu constructions
*/
-BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
+bool smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
enum smb_setfileinfo_level level,
union smb_setfileinfo *parms,
DATA_BLOB *blob)
@@ -36,7 +36,7 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
#define NEED_BLOB(n) do { \
*blob = data_blob_talloc(mem_ctx, NULL, n); \
- if (blob->data == NULL) return False; \
+ if (blob->data == NULL) return false; \
} while (0)
switch (level) {
@@ -48,22 +48,22 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
smbcli_push_nttime(blob->data, 24, parms->basic_info.in.change_time);
SIVAL(blob->data, 32, parms->basic_info.in.attrib);
SIVAL(blob->data, 36, 0); /* padding */
- return True;
+ return true;
case RAW_SFILEINFO_DISPOSITION_INFORMATION:
NEED_BLOB(4);
SIVAL(blob->data, 0, parms->disposition_info.in.delete_on_close);
- return True;
+ return true;
case RAW_SFILEINFO_ALLOCATION_INFORMATION:
NEED_BLOB(8);
SBVAL(blob->data, 0, parms->allocation_info.in.alloc_size);
- return True;
+ return true;
case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
NEED_BLOB(8);
SBVAL(blob->data, 0, parms->end_of_file_info.in.size);
- return True;
+ return true;
case RAW_SFILEINFO_RENAME_INFORMATION:
NEED_BLOB(12);
@@ -73,17 +73,17 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
parms->rename_information.in.new_name,
STR_UNICODE|STR_TERMINATE);
SIVAL(blob->data, 8, len - 2);
- return True;
+ return true;
case RAW_SFILEINFO_POSITION_INFORMATION:
NEED_BLOB(8);
SBVAL(blob->data, 0, parms->position_information.in.position);
- return True;
+ return true;
case RAW_SFILEINFO_MODE_INFORMATION:
NEED_BLOB(4);
SIVAL(blob->data, 0, parms->mode_information.in.mode);
- return True;
+ return true;
case RAW_FILEINFO_SEC_DESC: {
NTSTATUS status;
@@ -91,9 +91,9 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
status = ndr_push_struct_blob(blob, mem_ctx,
parms->set_secdesc.in.sd,
(ndr_push_flags_fn_t)ndr_push_security_descriptor);
- if (!NT_STATUS_IS_OK(status)) return False;
+ if (!NT_STATUS_IS_OK(status)) return false;
- return True;
+ return true;
}
/* Unhandled levels */
@@ -107,16 +107,16 @@ BOOL smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
default:
DEBUG(0,("Unhandled setfileinfo passthru level %d\n", level));
- return False;
+ return false;
}
- return False;
+ return false;
}
/*
Handle setfileinfo/setpathinfo trans2 backend.
*/
-static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
+static bool smb_raw_setinfo_backend(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_setfileinfo *parms,
DATA_BLOB *blob)
@@ -127,7 +127,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
case RAW_SFILEINFO_SETATTRE:
case RAW_SFILEINFO_SEC_DESC:
/* not handled here */
- return False;
+ return false;
case RAW_SFILEINFO_STANDARD:
NEED_BLOB(12);
@@ -137,12 +137,12 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
blob->data, 4, parms->standard.in.access_time);
raw_push_dos_date2(tree->session->transport,
blob->data, 8, parms->standard.in.write_time);
- return True;
+ return true;
case RAW_SFILEINFO_EA_SET:
NEED_BLOB(ea_list_size(parms->ea_set.in.num_eas, parms->ea_set.in.eas));
ea_put_list(blob->data, parms->ea_set.in.num_eas, parms->ea_set.in.eas);
- return True;
+ return true;
case RAW_SFILEINFO_BASIC_INFO:
case RAW_SFILEINFO_BASIC_INFORMATION:
@@ -164,7 +164,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
SBVAL(blob->data, 76, parms->unix_basic.in.unique_id);
SBVAL(blob->data, 84, parms->unix_basic.in.permissions);
SBVAL(blob->data, 92, parms->unix_basic.in.nlink);
- return True;
+ return true;
case RAW_SFILEINFO_UNIX_INFO2:
NEED_BLOB(116);
@@ -184,7 +184,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
smbcli_push_nttime(blob->data, 100, parms->unix_info2.in.create_time);
SIVAL(blob->data, 108, parms->unix_info2.in.file_flags);
SIVAL(blob->data, 112, parms->unix_info2.in.flags_mask);
- return True;
+ return true;
case RAW_SFILEINFO_DISPOSITION_INFO:
case RAW_SFILEINFO_DISPOSITION_INFORMATION:
@@ -230,7 +230,7 @@ static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree,
break;
}
- return False;
+ return false;
}
/****************************************************************************
diff --git a/source4/libcli/raw/rawshadow.c b/source4/libcli/raw/rawshadow.c
index 8fc81dab4c..4c58c91383 100644
--- a/source4/libcli/raw/rawshadow.c
+++ b/source4/libcli/raw/rawshadow.c
@@ -39,7 +39,7 @@ _PUBLIC_ NTSTATUS smb_raw_shadow_data(struct smbcli_tree *tree,
nt.ntioctl.level = RAW_IOCTL_NTIOCTL;
nt.ntioctl.in.function = FSCTL_GET_SHADOW_COPY_DATA;
nt.ntioctl.in.file.fnum = info->in.file.fnum;
- nt.ntioctl.in.fsctl = True;
+ nt.ntioctl.in.fsctl = true;
nt.ntioctl.in.filter = 0;
nt.ntioctl.in.max_data = info->in.max_data;
nt.ntioctl.in.blob = data_blob(NULL, 0);
diff --git a/source4/libcli/raw/rawtrans.c b/source4/libcli/raw/rawtrans.c
index fe26a71310..53670d22a3 100644
--- a/source4/libcli/raw/rawtrans.c
+++ b/source4/libcli/raw/rawtrans.c
@@ -27,13 +27,13 @@
/*
check out of bounds for incoming data
*/
-static BOOL raw_trans_oob(struct smbcli_request *req,
+static bool raw_trans_oob(struct smbcli_request *req,
uint_t offset, uint_t count)
{
uint8_t *ptr;
if (count == 0) {
- return False;
+ return false;
}
ptr = req->in.hdr + offset;
@@ -43,9 +43,9 @@ static BOOL raw_trans_oob(struct smbcli_request *req,
ptr >= req->in.data + req->in.data_size ||
count > req->in.data_size ||
ptr + count > req->in.data + req->in.data_size) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/****************************************************************************
@@ -86,7 +86,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
/* allocate it */
if (total_data != 0) {
- tdata = talloc_size(mem_ctx, total_data);
+ tdata = talloc_array(mem_ctx, uint8_t, total_data);
if (!tdata) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge data buffer to %d bytes\n", total_data));
req->status = NT_STATUS_NO_MEMORY;
@@ -96,7 +96,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
}
if (total_param != 0) {
- tparam = talloc_size(mem_ctx, total_param);
+ tparam = talloc_array(mem_ctx, uint8_t, total_param);
if (!tparam) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge param buffer to %d bytes\n", total_param));
req->status = NT_STATUS_NO_MEMORY;
diff --git a/source4/libcli/raw/smb_signing.c b/source4/libcli/raw/smb_signing.c
index 99044d23ae..e19e81af7e 100644
--- a/source4/libcli/raw/smb_signing.c
+++ b/source4/libcli/raw/smb_signing.c
@@ -23,45 +23,46 @@
#include "smb.h"
#include "libcli/raw/libcliraw.h"
#include "lib/crypto/crypto.h"
+#include "param/param.h"
/***********************************************************
SMB signing - Common code before we set a new signing implementation
************************************************************/
-BOOL set_smb_signing_common(struct smb_signing_context *sign_info)
+bool set_smb_signing_common(struct smb_signing_context *sign_info)
{
if (sign_info->doing_signing) {
DEBUG(5, ("SMB Signing already in progress, so we don't start it again\n"));
- return False;
+ return false;
}
if (!sign_info->allow_smb_signing) {
DEBUG(5, ("SMB Signing has been locally disabled\n"));
- return False;
+ return false;
}
- return True;
+ return true;
}
/***********************************************************
SMB signing - Common code before we set a new signing implementation
************************************************************/
-static BOOL smbcli_set_smb_signing_common(struct smbcli_transport *transport)
+static bool smbcli_set_smb_signing_common(struct smbcli_transport *transport)
{
if (!set_smb_signing_common(&transport->negotiate.sign_info)) {
- return False;
+ return false;
}
if (!(transport->negotiate.sec_mode &
(NEGOTIATE_SECURITY_SIGNATURES_REQUIRED|NEGOTIATE_SECURITY_SIGNATURES_ENABLED))) {
DEBUG(5, ("SMB Signing is not negotiated by the peer\n"));
- return False;
+ return false;
}
/* These calls are INCOMPATIBLE with SMB signing */
- transport->negotiate.readbraw_supported = False;
- transport->negotiate.writebraw_supported = False;
+ transport->negotiate.readbraw_supported = false;
+ transport->negotiate.writebraw_supported = false;
- return True;
+ return true;
}
void mark_packet_signed(struct request_buffer *out)
@@ -72,17 +73,17 @@ void mark_packet_signed(struct request_buffer *out)
SSVAL(out->hdr, HDR_FLG2, flags2);
}
-BOOL signing_good(struct smb_signing_context *sign_info,
- unsigned int seq, BOOL good)
+bool signing_good(struct smb_signing_context *sign_info,
+ unsigned int seq, bool good)
{
if (good) {
if (!sign_info->doing_signing) {
DEBUG(5, ("Seen valid packet, so turning signing on\n"));
- sign_info->doing_signing = True;
+ sign_info->doing_signing = true;
}
if (!sign_info->seen_valid) {
DEBUG(5, ("Seen valid packet, so marking signing as 'seen valid'\n"));
- sign_info->seen_valid = True;
+ sign_info->seen_valid = true;
}
} else {
if (!sign_info->seen_valid) {
@@ -90,14 +91,14 @@ BOOL signing_good(struct smb_signing_context *sign_info,
DEBUG(5, ("signing_good: signing negotiated but not required and peer\n"
"isn't sending correct signatures. Turning off.\n"));
smbcli_set_signing_off(sign_info);
- return True;
+ return true;
} else {
/* bad packet after signing started - fail and disconnect. */
DEBUG(0, ("signing_good: BAD SIG: seq %u\n", seq));
- return False;
+ return false;
}
}
- return True;
+ return true;
}
void sign_outgoing_message(struct request_buffer *out, DATA_BLOB *mac_key, unsigned int seq_num)
@@ -132,9 +133,9 @@ void sign_outgoing_message(struct request_buffer *out, DATA_BLOB *mac_key, unsig
Uncomment this to test if the remote server actually verifies signitures...*/
}
-BOOL check_signed_incoming_message(struct request_buffer *in, DATA_BLOB *mac_key, uint_t seq_num)
+bool check_signed_incoming_message(struct request_buffer *in, DATA_BLOB *mac_key, uint_t seq_num)
{
- BOOL good;
+ bool good;
uint8_t calc_md5_mac[16];
uint8_t *server_sent_mac;
uint8_t sequence_buf[8];
@@ -145,12 +146,12 @@ BOOL check_signed_incoming_message(struct request_buffer *in, DATA_BLOB *mac_key
/* room enough for the signature? */
if (in->size < NBT_HDR_SIZE + HDR_SS_FIELD + 8) {
- return False;
+ return false;
}
if (!mac_key->length) {
/* NO key yet */
- return False;
+ return false;
}
/* its quite bogus to be guessing sequence numbers, but very useful
@@ -257,24 +258,24 @@ void smbcli_request_calculate_sign_mac(struct smbcli_request *req)
@note Used as an initialisation only - it will not correctly
shut down a real signing mechanism
*/
-BOOL smbcli_set_signing_off(struct smb_signing_context *sign_info)
+bool smbcli_set_signing_off(struct smb_signing_context *sign_info)
{
DEBUG(5, ("Shutdown SMB signing\n"));
- sign_info->doing_signing = False;
+ sign_info->doing_signing = false;
sign_info->next_seq_num = 0;
data_blob_free(&sign_info->mac_key);
sign_info->signing_state = SMB_SIGNING_ENGINE_OFF;
- return True;
+ return true;
}
/**
SMB signing - TEMP implementation - setup the MAC key.
*/
-BOOL smbcli_temp_set_signing(struct smbcli_transport *transport)
+bool smbcli_temp_set_signing(struct smbcli_transport *transport)
{
if (!smbcli_set_smb_signing_common(transport)) {
- return False;
+ return false;
}
DEBUG(5, ("BSRSPYL SMB signing enabled\n"));
smbcli_set_signing_off(&transport->negotiate.sign_info);
@@ -282,7 +283,7 @@ BOOL smbcli_temp_set_signing(struct smbcli_transport *transport)
transport->negotiate.sign_info.mac_key = data_blob(NULL, 0);
transport->negotiate.sign_info.signing_state = SMB_SIGNING_ENGINE_BSRSPYL;
- return True;
+ return true;
}
/***********************************************************
@@ -290,22 +291,22 @@ BOOL smbcli_temp_set_signing(struct smbcli_transport *transport)
************************************************************/
/**
* Check a packet supplied by the server.
- * @return False if we had an established signing connection
- * which had a back checksum, True otherwise
+ * @return false if we had an established signing connection
+ * which had a back checksum, true otherwise
*/
-BOOL smbcli_request_check_sign_mac(struct smbcli_request *req)
+bool smbcli_request_check_sign_mac(struct smbcli_request *req)
{
- BOOL good;
+ bool good;
switch (req->transport->negotiate.sign_info.signing_state)
{
case SMB_SIGNING_ENGINE_OFF:
- return True;
+ return true;
case SMB_SIGNING_ENGINE_BSRSPYL:
case SMB_SIGNING_ENGINE_ON:
{
if (req->in.size < (HDR_SS_FIELD + 8)) {
- return False;
+ return false;
} else {
good = check_signed_incoming_message(&req->in,
&req->transport->negotiate.sign_info.mac_key,
@@ -316,14 +317,14 @@ BOOL smbcli_request_check_sign_mac(struct smbcli_request *req)
}
}
}
- return False;
+ return false;
}
/***********************************************************
SMB signing - Simple implementation - setup the MAC key.
************************************************************/
-BOOL smbcli_simple_set_signing(TALLOC_CTX *mem_ctx,
+bool smbcli_simple_set_signing(TALLOC_CTX *mem_ctx,
struct smb_signing_context *sign_info,
const DATA_BLOB *user_session_key,
const DATA_BLOB *response)
@@ -353,19 +354,19 @@ BOOL smbcli_simple_set_signing(TALLOC_CTX *mem_ctx,
sign_info->signing_state = SMB_SIGNING_ENGINE_ON;
- return True;
+ return true;
}
/***********************************************************
SMB signing - Simple implementation - setup the MAC key.
************************************************************/
-BOOL smbcli_transport_simple_set_signing(struct smbcli_transport *transport,
+bool smbcli_transport_simple_set_signing(struct smbcli_transport *transport,
const DATA_BLOB user_session_key,
const DATA_BLOB response)
{
if (!smbcli_set_smb_signing_common(transport)) {
- return False;
+ return false;
}
return smbcli_simple_set_signing(transport,
@@ -375,25 +376,25 @@ BOOL smbcli_transport_simple_set_signing(struct smbcli_transport *transport,
}
-BOOL smbcli_init_signing(struct smbcli_transport *transport)
+bool smbcli_init_signing(struct smbcli_transport *transport)
{
transport->negotiate.sign_info.mac_key = data_blob(NULL, 0);
if (!smbcli_set_signing_off(&transport->negotiate.sign_info)) {
- return False;
+ return false;
}
- switch (lp_client_signing()) {
+ switch (lp_client_signing(global_loadparm)) {
case SMB_SIGNING_OFF:
- transport->negotiate.sign_info.allow_smb_signing = False;
+ transport->negotiate.sign_info.allow_smb_signing = false;
break;
case SMB_SIGNING_SUPPORTED:
case SMB_SIGNING_AUTO:
- transport->negotiate.sign_info.allow_smb_signing = True;
+ transport->negotiate.sign_info.allow_smb_signing = true;
break;
case SMB_SIGNING_REQUIRED:
- transport->negotiate.sign_info.allow_smb_signing = True;
- transport->negotiate.sign_info.mandatory_signing = True;
+ transport->negotiate.sign_info.allow_smb_signing = true;
+ transport->negotiate.sign_info.mandatory_signing = true;
break;
}
- return True;
+ return true;
}
diff --git a/source4/libcli/resolve/bcast.c b/source4/libcli/resolve/bcast.c
index f356dafdaa..3193d70789 100644
--- a/source4/libcli/resolve/bcast.c
+++ b/source4/libcli/resolve/bcast.c
@@ -51,7 +51,7 @@ struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx,
}
address_list[count] = NULL;
- c = resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, True, False);
+ c = resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, true, false);
talloc_free(address_list);
return c;
diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c
index ad331c872d..baf3874aa4 100644
--- a/source4/libcli/resolve/nbtlist.c
+++ b/source4/libcli/resolve/nbtlist.c
@@ -29,6 +29,7 @@
#include "lib/socket/netif.h"
#include "librpc/gen_ndr/ndr_nbt.h"
#include "libcli/nbt/libnbt.h"
+#include "param/param.h"
struct nbtlist_state {
struct nbt_name name;
@@ -98,8 +99,8 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
struct event_context *event_ctx,
struct nbt_name *name,
const char **address_list,
- BOOL broadcast,
- BOOL wins_lookup)
+ bool broadcast,
+ bool wins_lookup)
{
struct composite_context *c;
struct nbtlist_state *state;
@@ -154,7 +155,7 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
state->io_queries[i].in.broadcast = broadcast;
state->io_queries[i].in.wins_lookup = wins_lookup;
- state->io_queries[i].in.timeout = lp_parm_int(-1, "nbt", "timeout", 1);
+ state->io_queries[i].in.timeout = lp_parm_int(global_loadparm, NULL, "nbt", "timeout", 1);
state->io_queries[i].in.retries = 2;
state->queries[i] = nbt_name_query_send(state->nbtsock, &state->io_queries[i]);
@@ -192,7 +193,7 @@ NTSTATUS resolve_name_nbtlist_recv(struct composite_context *c,
NTSTATUS resolve_name_nbtlist(struct nbt_name *name,
TALLOC_CTX *mem_ctx,
const char **address_list,
- BOOL broadcast, BOOL wins_lookup,
+ bool broadcast, bool wins_lookup,
const char **reply_addr)
{
struct composite_context *c = resolve_name_nbtlist_send(mem_ctx, NULL, name, address_list,
diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c
index 4df4de020c..02e1fbdc04 100644
--- a/source4/libcli/resolve/resolve.c
+++ b/source4/libcli/resolve/resolve.c
@@ -24,6 +24,7 @@
#include "libcli/composite/composite.h"
#include "libcli/resolve/resolve.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
struct resolve_state {
struct nbt_name name;
@@ -67,7 +68,7 @@ static const struct resolve_method *find_method(const char *name)
*/
static void resolve_handler(struct composite_context *creq)
{
- struct composite_context *c = creq->async.private_data;
+ struct composite_context *c = (struct composite_context *)creq->async.private_data;
struct resolve_state *state = talloc_get_type(c->private_data, struct resolve_state);
const struct resolve_method *method = find_method(state->methods[0]);
@@ -188,7 +189,8 @@ NTSTATUS resolve_name_recv(struct composite_context *c,
NTSTATUS resolve_name(struct nbt_name *name, TALLOC_CTX *mem_ctx, const char **reply_addr,
struct event_context *ev)
{
- struct composite_context *c = resolve_name_send(name, ev, lp_name_resolve_order());
+ struct composite_context *c = resolve_name_send(name, ev,
+ lp_name_resolve_order(global_loadparm));
return resolve_name_recv(c, mem_ctx, reply_addr);
}
diff --git a/source4/libcli/resolve/wins.c b/source4/libcli/resolve/wins.c
index 7af12075a1..2cbcd5f483 100644
--- a/source4/libcli/resolve/wins.c
+++ b/source4/libcli/resolve/wins.c
@@ -22,17 +22,19 @@
#include "includes.h"
#include "libcli/nbt/libnbt.h"
#include "libcli/resolve/resolve.h"
+#include "param/param.h"
/*
wins name resolution method - async send
*/
-struct composite_context *resolve_name_wins_send(TALLOC_CTX *mem_ctx,
- struct event_context *event_ctx,
- struct nbt_name *name)
+struct composite_context *resolve_name_wins_send(
+ TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
+ struct nbt_name *name)
{
- const char **address_list = lp_wins_server_list();
+ const char **address_list = lp_wins_server_list(global_loadparm);
if (address_list == NULL) return NULL;
- return resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, False, True);
+ return resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, false, true);
}
/*
diff --git a/source4/libcli/security/dom_sid.c b/source4/libcli/security/dom_sid.c
index 64e418677a..f5457e7e0e 100644
--- a/source4/libcli/security/dom_sid.c
+++ b/source4/libcli/security/dom_sid.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "librpc/gen_ndr/security.h"
+#include "libcli/security/security.h"
/*****************************************************************
Compare the auth portion of two sids.
@@ -78,7 +79,7 @@ static int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid
Compare two sids.
*****************************************************************/
-BOOL dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2)
+bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2)
{
return dom_sid_compare(sid1, sid2) == 0;
}
@@ -240,24 +241,24 @@ NTSTATUS dom_sid_split_rid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
}
/*
- return True if the 2nd sid is in the domain given by the first sid
+ return true if the 2nd sid is in the domain given by the first sid
*/
-BOOL dom_sid_in_domain(const struct dom_sid *domain_sid,
+bool dom_sid_in_domain(const struct dom_sid *domain_sid,
const struct dom_sid *sid)
{
int i;
if (!domain_sid || !sid) {
- return False;
+ return false;
}
if (domain_sid->num_auths > sid->num_auths) {
- return False;
+ return false;
}
for (i = domain_sid->num_auths-1; i >= 0; --i) {
if (domain_sid->sub_auths[i] != sid->sub_auths[i]) {
- return False;
+ return false;
}
}
@@ -278,7 +279,7 @@ char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
}
maxlen = sid->num_auths * 11 + 25;
- ret = talloc_size(mem_ctx, maxlen);
+ ret = talloc_array(mem_ctx, char, maxlen);
if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)");
ia = (sid->id_auth[5]) +
diff --git a/source4/libcli/security/privilege.c b/source4/libcli/security/privilege.c
index 635f470bf6..2cbef13538 100644
--- a/source4/libcli/security/privilege.c
+++ b/source4/libcli/security/privilege.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "librpc/gen_ndr/security.h"
+#include "libcli/security/security.h"
static const struct {
@@ -191,21 +192,21 @@ static uint64_t sec_privilege_mask(enum sec_privilege privilege)
/*
- return True if a security_token has a particular privilege bit set
+ return true if a security_token has a particular privilege bit set
*/
-BOOL security_token_has_privilege(const struct security_token *token, enum sec_privilege privilege)
+bool security_token_has_privilege(const struct security_token *token, enum sec_privilege privilege)
{
uint64_t mask;
if (privilege < 1 || privilege > 64) {
- return False;
+ return false;
}
mask = sec_privilege_mask(privilege);
if (token->privilege_mask & mask) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
diff --git a/source4/libcli/security/sddl.c b/source4/libcli/security/sddl.c
index 4342a7b87a..09522f182a 100644
--- a/source4/libcli/security/sddl.c
+++ b/source4/libcli/security/sddl.c
@@ -32,7 +32,7 @@ struct flag_map {
/*
map a series of letter codes into a uint32_t
*/
-static BOOL sddl_map_flags(const struct flag_map *map, const char *str,
+static bool sddl_map_flags(const struct flag_map *map, const char *str,
uint32_t *flags, size_t *len)
{
const char *str0 = str;
@@ -51,10 +51,10 @@ static BOOL sddl_map_flags(const struct flag_map *map, const char *str,
}
if (map[i].name == NULL) {
DEBUG(1, ("Unknown flag - %s in %s\n", str, str0));
- return False;
+ return false;
}
}
- return True;
+ return true;
}
/*
@@ -176,10 +176,10 @@ static const struct flag_map ace_access_mask[] = {
/*
decode an ACE
- return True on success, False on failure
+ return true on success, false on failure
note that this routine modifies the string
*/
-static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char *str,
+static bool sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char *str,
const struct dom_sid *domain_sid)
{
const char *tok[6];
@@ -194,7 +194,7 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
tok[0] = str;
for (i=0;i<5;i++) {
char *ptr = strchr(str, ';');
- if (ptr == NULL) return False;
+ if (ptr == NULL) return false;
*ptr = 0;
str = ptr+1;
tok[i+1] = str;
@@ -202,13 +202,13 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
/* parse ace type */
if (!sddl_map_flags(ace_types, tok[0], &v, NULL)) {
- return False;
+ return false;
}
ace->type = v;
/* ace flags */
if (!sddl_map_flags(ace_flags, tok[1], &v, NULL)) {
- return False;
+ return false;
}
ace->flags = v;
@@ -217,7 +217,7 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
ace->access_mask = strtol(tok[2], NULL, 16);
} else {
if (!sddl_map_flags(ace_access_mask, tok[2], &v, NULL)) {
- return False;
+ return false;
}
ace->access_mask = v;
}
@@ -227,7 +227,7 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
NTSTATUS status = GUID_from_string(tok[3],
&ace->object.object.type.type);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ace->object.object.flags |= SEC_ACE_OBJECT_TYPE_PRESENT;
}
@@ -237,7 +237,7 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
NTSTATUS status = GUID_from_string(tok[4],
&ace->object.object.inherited_type.inherited_type);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ace->object.object.flags |= SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT;
}
@@ -246,13 +246,13 @@ static BOOL sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char
s = tok[5];
sid = sddl_decode_sid(mem_ctx, &s, domain_sid);
if (sid == NULL) {
- return False;
+ return false;
}
ace->trustee = *sid;
talloc_steal(mem_ctx, sid->sub_auths);
talloc_free(sid);
- return True;
+ return true;
}
static const struct flag_map acl_flags[] = {
@@ -388,7 +388,7 @@ failed:
turn a set of flags into a string
*/
static char *sddl_flags_to_string(TALLOC_CTX *mem_ctx, const struct flag_map *map,
- uint32_t flags, BOOL check_all)
+ uint32_t flags, bool check_all)
{
int i;
char *s;
@@ -405,7 +405,7 @@ static char *sddl_flags_to_string(TALLOC_CTX *mem_ctx, const struct flag_map *ma
/* now by bits */
for (i=0;map[i].name;i++) {
if ((flags & map[i].flag) != 0) {
- s = talloc_asprintf_append(s, "%s", map[i].name);
+ s = talloc_asprintf_append_buffer(s, "%s", map[i].name);
if (s == NULL) goto failed;
flags &= ~map[i].flag;
}
@@ -477,13 +477,13 @@ static char *sddl_encode_ace(TALLOC_CTX *mem_ctx, const struct security_ace *ace
return NULL;
}
- s_type = sddl_flags_to_string(tmp_ctx, ace_types, ace->type, True);
+ s_type = sddl_flags_to_string(tmp_ctx, ace_types, ace->type, true);
if (s_type == NULL) goto failed;
- s_flags = sddl_flags_to_string(tmp_ctx, ace_flags, ace->flags, True);
+ s_flags = sddl_flags_to_string(tmp_ctx, ace_flags, ace->flags, true);
if (s_flags == NULL) goto failed;
- s_mask = sddl_flags_to_string(tmp_ctx, ace_access_mask, ace->access_mask, True);
+ s_mask = sddl_flags_to_string(tmp_ctx, ace_access_mask, ace->access_mask, true);
if (s_mask == NULL) {
s_mask = talloc_asprintf(tmp_ctx, "0x%08x", ace->access_mask);
if (s_mask == NULL) goto failed;
@@ -525,14 +525,14 @@ static char *sddl_encode_acl(TALLOC_CTX *mem_ctx, const struct security_acl *acl
int i;
/* add any ACL flags */
- sddl = sddl_flags_to_string(mem_ctx, acl_flags, flags, False);
+ sddl = sddl_flags_to_string(mem_ctx, acl_flags, flags, false);
if (sddl == NULL) goto failed;
/* now the ACEs, encoded in braces */
for (i=0;i<acl->num_aces;i++) {
char *ace = sddl_encode_ace(sddl, &acl->aces[i], domain_sid);
if (ace == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "(%s)", ace);
+ sddl = talloc_asprintf_append_buffer(sddl, "(%s)", ace);
if (sddl == NULL) goto failed;
talloc_free(ace);
}
@@ -563,28 +563,28 @@ char *sddl_encode(TALLOC_CTX *mem_ctx, const struct security_descriptor *sd,
if (sd->owner_sid != NULL) {
char *sid = sddl_encode_sid(tmp_ctx, sd->owner_sid, domain_sid);
if (sid == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "O:%s", sid);
+ sddl = talloc_asprintf_append_buffer(sddl, "O:%s", sid);
if (sddl == NULL) goto failed;
}
if (sd->group_sid != NULL) {
char *sid = sddl_encode_sid(tmp_ctx, sd->group_sid, domain_sid);
if (sid == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "G:%s", sid);
+ sddl = talloc_asprintf_append_buffer(sddl, "G:%s", sid);
if (sddl == NULL) goto failed;
}
if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl != NULL) {
char *acl = sddl_encode_acl(tmp_ctx, sd->dacl, sd->type, domain_sid);
if (acl == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "D:%s", acl);
+ sddl = talloc_asprintf_append_buffer(sddl, "D:%s", acl);
if (sddl == NULL) goto failed;
}
if ((sd->type & SEC_DESC_SACL_PRESENT) && sd->sacl != NULL) {
char *acl = sddl_encode_acl(tmp_ctx, sd->sacl, sd->type>>1, domain_sid);
if (acl == NULL) goto failed;
- sddl = talloc_asprintf_append(sddl, "S:%s", acl);
+ sddl = talloc_asprintf_append_buffer(sddl, "S:%s", acl);
if (sddl == NULL) goto failed;
}
diff --git a/source4/libcli/security/security_descriptor.c b/source4/libcli/security/security_descriptor.c
index 06c3c2eca7..7ed619d0c4 100644
--- a/source4/libcli/security/security_descriptor.c
+++ b/source4/libcli/security/security_descriptor.c
@@ -60,7 +60,7 @@ static struct security_acl *security_acl_dup(TALLOC_CTX *mem_ctx,
return NULL;
}
- nacl->aces = talloc_memdup (nacl, oacl->aces, sizeof(struct security_ace) * oacl->num_aces);
+ nacl->aces = (struct security_ace *)talloc_memdup (nacl, oacl->aces, sizeof(struct security_ace) * oacl->num_aces);
if ((nacl->aces == NULL) && (oacl->num_aces > 0)) {
goto failed;
}
@@ -69,7 +69,7 @@ static struct security_acl *security_acl_dup(TALLOC_CTX *mem_ctx,
for (i = 0; i < oacl->num_aces; i++) {
nacl->aces[i].trustee.sub_auths =
- talloc_memdup(nacl->aces, nacl->aces[i].trustee.sub_auths,
+ (uint32_t *)talloc_memdup(nacl->aces, nacl->aces[i].trustee.sub_auths,
sizeof(uint32_t) * nacl->aces[i].trustee.num_auths);
if ((nacl->aces[i].trustee.sub_auths == NULL) && (nacl->aces[i].trustee.num_auths > 0)) {
@@ -163,7 +163,7 @@ NTSTATUS security_descriptor_dacl_add(struct security_descriptor *sd,
sd->dacl->aces[sd->dacl->num_aces] = *ace;
sd->dacl->aces[sd->dacl->num_aces].trustee.sub_auths =
- talloc_memdup(sd->dacl->aces,
+ (uint32_t *)talloc_memdup(sd->dacl->aces,
sd->dacl->aces[sd->dacl->num_aces].trustee.sub_auths,
sizeof(uint32_t) *
sd->dacl->aces[sd->dacl->num_aces].trustee.num_auths);
@@ -242,77 +242,77 @@ NTSTATUS security_descriptor_dacl_del(struct security_descriptor *sd,
/*
compare two security ace structures
*/
-BOOL security_ace_equal(const struct security_ace *ace1,
+bool security_ace_equal(const struct security_ace *ace1,
const struct security_ace *ace2)
{
- if (ace1 == ace2) return True;
- if (!ace1 || !ace2) return False;
- if (ace1->type != ace2->type) return False;
- if (ace1->flags != ace2->flags) return False;
- if (ace1->access_mask != ace2->access_mask) return False;
- if (!dom_sid_equal(&ace1->trustee, &ace2->trustee)) return False;
-
- return True;
+ if (ace1 == ace2) return true;
+ if (!ace1 || !ace2) return false;
+ if (ace1->type != ace2->type) return false;
+ if (ace1->flags != ace2->flags) return false;
+ if (ace1->access_mask != ace2->access_mask) return false;
+ if (!dom_sid_equal(&ace1->trustee, &ace2->trustee)) return false;
+
+ return true;
}
/*
compare two security acl structures
*/
-BOOL security_acl_equal(const struct security_acl *acl1,
+bool security_acl_equal(const struct security_acl *acl1,
const struct security_acl *acl2)
{
int i;
- if (acl1 == acl2) return True;
- if (!acl1 || !acl2) return False;
- if (acl1->revision != acl2->revision) return False;
- if (acl1->num_aces != acl2->num_aces) return False;
+ if (acl1 == acl2) return true;
+ if (!acl1 || !acl2) return false;
+ if (acl1->revision != acl2->revision) return false;
+ if (acl1->num_aces != acl2->num_aces) return false;
for (i=0;i<acl1->num_aces;i++) {
- if (!security_ace_equal(&acl1->aces[i], &acl2->aces[i])) return False;
+ if (!security_ace_equal(&acl1->aces[i], &acl2->aces[i])) return false;
}
- return True;
+ return true;
}
/*
compare two security descriptors.
*/
-BOOL security_descriptor_equal(const struct security_descriptor *sd1,
+bool security_descriptor_equal(const struct security_descriptor *sd1,
const struct security_descriptor *sd2)
{
- if (sd1 == sd2) return True;
- if (!sd1 || !sd2) return False;
- if (sd1->revision != sd2->revision) return False;
- if (sd1->type != sd2->type) return False;
+ if (sd1 == sd2) return true;
+ if (!sd1 || !sd2) return false;
+ if (sd1->revision != sd2->revision) return false;
+ if (sd1->type != sd2->type) return false;
- if (!dom_sid_equal(sd1->owner_sid, sd2->owner_sid)) return False;
- if (!dom_sid_equal(sd1->group_sid, sd2->group_sid)) return False;
- if (!security_acl_equal(sd1->sacl, sd2->sacl)) return False;
- if (!security_acl_equal(sd1->dacl, sd2->dacl)) return False;
+ if (!dom_sid_equal(sd1->owner_sid, sd2->owner_sid)) return false;
+ if (!dom_sid_equal(sd1->group_sid, sd2->group_sid)) return false;
+ if (!security_acl_equal(sd1->sacl, sd2->sacl)) return false;
+ if (!security_acl_equal(sd1->dacl, sd2->dacl)) return false;
- return True;
+ return true;
}
/*
compare two security descriptors, but allow certain (missing) parts
to be masked out of the comparison
*/
-BOOL security_descriptor_mask_equal(const struct security_descriptor *sd1,
+bool security_descriptor_mask_equal(const struct security_descriptor *sd1,
const struct security_descriptor *sd2,
uint32_t mask)
{
- if (sd1 == sd2) return True;
- if (!sd1 || !sd2) return False;
- if (sd1->revision != sd2->revision) return False;
- if ((sd1->type & mask) != (sd2->type & mask)) return False;
+ if (sd1 == sd2) return true;
+ if (!sd1 || !sd2) return false;
+ if (sd1->revision != sd2->revision) return false;
+ if ((sd1->type & mask) != (sd2->type & mask)) return false;
- if (!dom_sid_equal(sd1->owner_sid, sd2->owner_sid)) return False;
- if (!dom_sid_equal(sd1->group_sid, sd2->group_sid)) return False;
- if ((mask & SEC_DESC_DACL_PRESENT) && !security_acl_equal(sd1->dacl, sd2->dacl)) return False;
- if ((mask & SEC_DESC_SACL_PRESENT) && !security_acl_equal(sd1->sacl, sd2->sacl)) return False;
+ if (!dom_sid_equal(sd1->owner_sid, sd2->owner_sid)) return false;
+ if (!dom_sid_equal(sd1->group_sid, sd2->group_sid)) return false;
+ if ((mask & SEC_DESC_DACL_PRESENT) && !security_acl_equal(sd1->dacl, sd2->dacl)) return false;
+ if ((mask & SEC_DESC_SACL_PRESENT) && !security_acl_equal(sd1->sacl, sd2->sacl)) return false;
- return True;
+ return true;
}
diff --git a/source4/libcli/security/security_token.c b/source4/libcli/security/security_token.c
index 684c3de7e6..e126340c46 100644
--- a/source4/libcli/security/security_token.c
+++ b/source4/libcli/security/security_token.c
@@ -79,19 +79,19 @@ void security_token_debug(int dbg_lev, const struct security_token *token)
/* These really should be cheaper... */
-BOOL security_token_is_sid(const struct security_token *token, const struct dom_sid *sid)
+bool security_token_is_sid(const struct security_token *token, const struct dom_sid *sid)
{
if (dom_sid_equal(token->user_sid, sid)) {
- return True;
+ return true;
}
- return False;
+ return false;
}
-BOOL security_token_is_sid_string(const struct security_token *token, const char *sid_string)
+bool security_token_is_sid_string(const struct security_token *token, const char *sid_string)
{
- BOOL ret;
+ bool ret;
struct dom_sid *sid = dom_sid_parse_talloc(NULL, sid_string);
- if (!sid) return False;
+ if (!sid) return false;
ret = security_token_is_sid(token, sid);
@@ -99,32 +99,32 @@ BOOL security_token_is_sid_string(const struct security_token *token, const char
return ret;
}
-BOOL security_token_is_system(const struct security_token *token)
+bool security_token_is_system(const struct security_token *token)
{
return security_token_is_sid_string(token, SID_NT_SYSTEM);
}
-BOOL security_token_is_anonymous(const struct security_token *token)
+bool security_token_is_anonymous(const struct security_token *token)
{
return security_token_is_sid_string(token, SID_NT_ANONYMOUS);
}
-BOOL security_token_has_sid(const struct security_token *token, const struct dom_sid *sid)
+bool security_token_has_sid(const struct security_token *token, const struct dom_sid *sid)
{
int i;
for (i = 0; i < token->num_sids; i++) {
if (dom_sid_equal(token->sids[i], sid)) {
- return True;
+ return true;
}
}
- return False;
+ return false;
}
-BOOL security_token_has_sid_string(const struct security_token *token, const char *sid_string)
+bool security_token_has_sid_string(const struct security_token *token, const char *sid_string)
{
- BOOL ret;
+ bool ret;
struct dom_sid *sid = dom_sid_parse_talloc(NULL, sid_string);
- if (!sid) return False;
+ if (!sid) return false;
ret = security_token_has_sid(token, sid);
@@ -132,12 +132,12 @@ BOOL security_token_has_sid_string(const struct security_token *token, const cha
return ret;
}
-BOOL security_token_has_builtin_administrators(const struct security_token *token)
+bool security_token_has_builtin_administrators(const struct security_token *token)
{
return security_token_has_sid_string(token, SID_BUILTIN_ADMINISTRATORS);
}
-BOOL security_token_has_nt_authenticated_users(const struct security_token *token)
+bool security_token_has_nt_authenticated_users(const struct security_token *token)
{
return security_token_has_sid_string(token, SID_NT_AUTHENTICATED_USERS);
}
diff --git a/source4/libcli/smb2/cancel.c b/source4/libcli/smb2/cancel.c
index f0a0b01817..096919f177 100644
--- a/source4/libcli/smb2/cancel.c
+++ b/source4/libcli/smb2/cancel.c
@@ -46,7 +46,7 @@ NTSTATUS smb2_cancel(struct smb2_request *r)
/* we don't want a seqmun for a SMB2 Cancel */
old_seqnum = r->transport->seqnum;
- c = smb2_request_init(r->transport, SMB2_OP_CANCEL, 0x04, False, 0);
+ c = smb2_request_init(r->transport, SMB2_OP_CANCEL, 0x04, false, 0);
r->transport->seqnum = old_seqnum;
NT_STATUS_HAVE_NO_MEMORY(c);
c->seqnum = 0;
diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c
index e83f81b630..04c0c85499 100644
--- a/source4/libcli/smb2/close.c
+++ b/source4/libcli/smb2/close.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close *
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.flags);
@@ -54,7 +54,7 @@ NTSTATUS smb2_close_recv(struct smb2_request *req, struct smb2_close *io)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x3C, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x3C, false);
io->out.flags = SVAL(req->in.body, 0x02);
io->out._pad = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index a365f25d49..6f05d56cd4 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -25,6 +25,7 @@
#include "libcli/smb2/smb2_calls.h"
#include "libcli/composite/composite.h"
#include "libcli/resolve/resolve.h"
+#include "param/param.h"
struct smb2_connect_state {
struct cli_credentials *credentials;
@@ -68,7 +69,7 @@ static void continue_session(struct composite_context *creq)
c->status = smb2_session_setup_spnego_recv(creq);
if (!composite_is_ok(c)) return;
- state->tree = smb2_tree_init(state->session, state, True);
+ state->tree = smb2_tree_init(state->session, state, true);
if (composite_nomem(state->tree, c)) return;
state->tcon.in.unknown1 = 0x09;
@@ -98,7 +99,7 @@ static void continue_negprot(struct smb2_request *req)
c->status = smb2_negprot_recv(req, c, &state->negprot);
if (!composite_is_ok(c)) return;
- state->session = smb2_session_init(transport, state, True);
+ state->session = smb2_session_init(transport, state, true);
if (composite_nomem(state->session, c)) return;
creq = smb2_session_setup_spnego_send(state->session, state->credentials);
@@ -186,7 +187,8 @@ struct composite_context *smb2_connect_send(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(name);
name.name = host;
- creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
+ creq = resolve_name_send(&name, c->event_ctx,
+ lp_name_resolve_order(global_loadparm));
composite_continue(c, creq, continue_resolve, c);
return c;
}
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index c8ac271f44..ba11c22e87 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -32,7 +32,7 @@
*/
NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
uint32_t tag,
- DATA_BLOB add, BOOL last)
+ DATA_BLOB add, bool last)
{
uint32_t ofs = blob->length;
uint8_t pad = smb2_padding_size(add.length, 8);
@@ -65,7 +65,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
NTSTATUS status;
DATA_BLOB blob = data_blob(NULL, 0);
- req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, True, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, true, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.oplock_flags);
@@ -90,7 +90,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
DATA_BLOB b = data_blob_talloc(req, NULL,
ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas));
ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas);
- status = smb2_create_blob_add(req, &blob, CREATE_TAG_EXTA, b, False);
+ status = smb2_create_blob_add(req, &blob, CREATE_TAG_EXTA, b, false);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
return NULL;
@@ -100,7 +100,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
/* an empty MxAc tag seems to be used to ask the server to
return the maximum access mask allowed on the file */
- status = smb2_create_blob_add(req, &blob, CREATE_TAG_MXAC, data_blob(NULL, 0), True);
+ status = smb2_create_blob_add(req, &blob, CREATE_TAG_MXAC, data_blob(NULL, 0), true);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
@@ -130,7 +130,7 @@ NTSTATUS smb2_create_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, struct
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x58, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x58, true);
io->out.oplock_flags = SVAL(req->in.body, 0x02);
io->out.create_action = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb2/find.c b/source4/libcli/smb2/find.c
index e8643f1868..6d0a9c8072 100644
--- a/source4/libcli/smb2/find.c
+++ b/source4/libcli/smb2/find.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_find_send(struct smb2_tree *tree, struct smb2_find *io
struct smb2_request *req;
NTSTATUS status;
- req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, True, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, true, 0);
if (req == NULL) return NULL;
SCVAL(req->out.body, 0x02, io->in.level);
@@ -67,7 +67,7 @@ NTSTATUS smb2_find_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x08, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x08, true);
status = smb2_pull_o16s32_blob(&req->in, mem_ctx,
req->in.body+0x02, &io->out.blob);
diff --git a/source4/libcli/smb2/flush.c b/source4/libcli/smb2/flush.c
index 2f1b7bd749..116068ed6e 100644
--- a/source4/libcli/smb2/flush.c
+++ b/source4/libcli/smb2/flush.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_flush_send(struct smb2_tree *tree, struct smb2_flush *
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0); /* pad? */
@@ -53,7 +53,7 @@ NTSTATUS smb2_flush_recv(struct smb2_request *req, struct smb2_flush *io)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c
index a9a681ea53..0665dd441c 100644
--- a/source4/libcli/smb2/getinfo.c
+++ b/source4/libcli/smb2/getinfo.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, false, 0);
if (req == NULL) return NULL;
/* this seems to be a bug, they use 0x29 but only send 0x28 bytes */
@@ -64,7 +64,7 @@ NTSTATUS smb2_getinfo_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x08, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x08, true);
status = smb2_pull_o16s16_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.blob);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/smb2/ioctl.c b/source4/libcli/smb2/ioctl.c
index c13ec7943c..d81bca517f 100644
--- a/source4/libcli/smb2/ioctl.c
+++ b/source4/libcli/smb2/ioctl.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_ioctl_send(struct smb2_tree *tree, struct smb2_ioctl *
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38, True,
+ req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38, true,
io->in.in.length+io->in.out.length);
if (req == NULL) return NULL;
@@ -75,7 +75,7 @@ NTSTATUS smb2_ioctl_recv(struct smb2_request *req,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x30, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x30, true);
io->out._pad = SVAL(req->in.body, 0x02);
io->out.function = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb2/keepalive.c b/source4/libcli/smb2/keepalive.c
index e2b7c83b8a..402b063e81 100644
--- a/source4/libcli/smb2/keepalive.c
+++ b/source4/libcli/smb2/keepalive.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_keepalive_send(struct smb2_transport *transport)
{
struct smb2_request *req;
- req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, False, 0);
+ req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0);
@@ -51,7 +51,7 @@ NTSTATUS smb2_keepalive_recv(struct smb2_request *req)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/lock.c b/source4/libcli/smb2/lock.c
index 470648a34c..d71a337d56 100644
--- a/source4/libcli/smb2/lock.c
+++ b/source4/libcli/smb2/lock.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.unknown1);
@@ -57,7 +57,7 @@ NTSTATUS smb2_lock_recv(struct smb2_request *req, struct smb2_lock *io)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
io->out.unknown1 = SVAL(req->in.body, 0x02);
diff --git a/source4/libcli/smb2/logoff.c b/source4/libcli/smb2/logoff.c
index 00d5e19e82..321a4db1a6 100644
--- a/source4/libcli/smb2/logoff.c
+++ b/source4/libcli/smb2/logoff.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_logoff_send(struct smb2_session *session)
{
struct smb2_request *req;
- req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, False, 0);
+ req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, false, 0);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
@@ -53,7 +53,7 @@ NTSTATUS smb2_logoff_recv(struct smb2_request *req)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/negprot.c b/source4/libcli/smb2/negprot.c
index 07d06ca2ff..38fe0e7e53 100644
--- a/source4/libcli/smb2/negprot.c
+++ b/source4/libcli/smb2/negprot.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_negprot_send(struct smb2_transport *transport,
{
struct smb2_request *req;
- req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, False, 0);
+ req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, false, 0);
if (req == NULL) return NULL;
/* this seems to be a bug, they use 0x24 but the length is 0x26 */
@@ -60,7 +60,7 @@ NTSTATUS smb2_negprot_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x40, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x40, true);
io->out._pad = SVAL(req->in.body, 0x02);
io->out.unknown2 = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb2/notify.c b/source4/libcli/smb2/notify.c
index 58e2876745..a3bea41eb0 100644
--- a/source4/libcli/smb2/notify.c
+++ b/source4/libcli/smb2/notify.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_notify_send(struct smb2_tree *tree, struct smb2_notify
struct smb2_request *req;
uint32_t old_timeout;
- req = smb2_request_init_tree(tree, SMB2_OP_NOTIFY, 0x20, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_NOTIFY, 0x20, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0030);
@@ -67,7 +67,7 @@ NTSTATUS smb2_notify_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x08, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x08, true);
status = smb2_pull_o16s32_blob(&req->in, mem_ctx, req->in.body+0x02, &blob);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/smb2/read.c b/source4/libcli/smb2/read.c
index f78a1a8b0e..b61f918481 100644
--- a/source4/libcli/smb2/read.c
+++ b/source4/libcli/smb2/read.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_read_send(struct smb2_tree *tree, struct smb2_read *io
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x30, True, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x30, true, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0); /* pad */
@@ -59,7 +59,7 @@ NTSTATUS smb2_read_recv(struct smb2_request *req,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x10, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x10, true);
status = smb2_pull_o16s32_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.data);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c
index d857fc8c5b..576e2b6fcf 100644
--- a/source4/libcli/smb2/request.c
+++ b/source4/libcli/smb2/request.c
@@ -25,12 +25,13 @@
#include "libcli/smb2/smb2.h"
#include "lib/util/dlinklist.h"
#include "lib/events/events.h"
+#include "libcli/smb2/smb2_calls.h"
/*
initialise a smb2 request
*/
struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_t opcode,
- uint16_t body_fixed_size, BOOL body_dynamic_present,
+ uint16_t body_fixed_size, bool body_dynamic_present,
uint32_t body_dynamic_size)
{
struct smb2_request *req;
@@ -67,7 +68,7 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
req->out.size = SMB2_HDR_BODY+NBT_HDR_SIZE+body_fixed_size;
req->out.allocated = req->out.size + body_dynamic_size;
- req->out.buffer = talloc_size(req, req->out.allocated);
+ req->out.buffer = talloc_array(req, uint8_t, req->out.allocated);
if (req->out.buffer == NULL) {
talloc_free(req);
return NULL;
@@ -112,7 +113,7 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
initialise a smb2 request for tree operations
*/
struct smb2_request *smb2_request_init_tree(struct smb2_tree *tree, uint16_t opcode,
- uint16_t body_fixed_size, BOOL body_dynamic_present,
+ uint16_t body_fixed_size, bool body_dynamic_present,
uint32_t body_dynamic_size)
{
struct smb2_request *req = smb2_request_init(tree->session->transport, opcode,
@@ -156,16 +157,16 @@ NTSTATUS smb2_request_destroy(struct smb2_request *req)
/*
receive a response to a packet
*/
-BOOL smb2_request_receive(struct smb2_request *req)
+bool smb2_request_receive(struct smb2_request *req)
{
/* req can be NULL when a send has failed. This eliminates lots of NULL
checks in each module */
- if (!req) return False;
+ if (!req) return false;
/* keep receiving packets until this one is replied to */
while (req->state <= SMB2_REQUEST_RECV) {
if (event_loop_once(req->transport->socket->event.ctx) != 0) {
- return False;
+ return false;
}
}
@@ -173,13 +174,13 @@ BOOL smb2_request_receive(struct smb2_request *req)
}
/* Return true if the last packet was in error */
-BOOL smb2_request_is_error(struct smb2_request *req)
+bool smb2_request_is_error(struct smb2_request *req)
{
return NT_STATUS_IS_ERR(req->status);
}
/* Return true if the last packet was OK */
-BOOL smb2_request_is_ok(struct smb2_request *req)
+bool smb2_request_is_ok(struct smb2_request *req)
{
return NT_STATUS_IS_OK(req->status);
}
@@ -187,16 +188,16 @@ BOOL smb2_request_is_ok(struct smb2_request *req)
/*
check if a range in the reply body is out of bounds
*/
-BOOL smb2_oob(struct smb2_request_buffer *buf, const uint8_t *ptr, size_t size)
+bool smb2_oob(struct smb2_request_buffer *buf, const uint8_t *ptr, size_t size)
{
/* be careful with wraparound! */
if (ptr < buf->body ||
ptr >= buf->body + buf->body_size ||
size > buf->body_size ||
ptr + size > buf->body + buf->body_size) {
- return True;
+ return true;
}
- return False;
+ return false;
}
size_t smb2_padding_size(uint32_t offset, size_t n)
@@ -229,7 +230,7 @@ static NTSTATUS smb2_grow_buffer(struct smb2_request_buffer *buf, size_t increas
dynamic_ofs = buf->dynamic - buf->buffer;
- buffer_ptr = talloc_realloc_size(buf, buf->buffer, newsize);
+ buffer_ptr = talloc_realloc(buf, buf->buffer, uint8_t, newsize);
NT_STATUS_HAVE_NO_MEMORY(buffer_ptr);
buf->buffer = buffer_ptr;
@@ -581,7 +582,7 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me
size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
blob.data, blob.length, &vstr);
data_blob_free(&blob);
- (*str) = vstr;
+ (*str) = (char *)vstr;
if (size == -1) {
return NT_STATUS_ILLEGAL_CHARACTER;
}
diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c
index 3f9b3ed55c..462f60d2c2 100644
--- a/source4/libcli/smb2/session.c
+++ b/source4/libcli/smb2/session.c
@@ -30,7 +30,7 @@
initialise a smb2_session structure
*/
struct smb2_session *smb2_session_init(struct smb2_transport *transport,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx, bool primary)
{
struct smb2_session *session;
NTSTATUS status;
@@ -68,7 +68,7 @@ struct smb2_request *smb2_session_setup_send(struct smb2_session *session,
NTSTATUS status;
req = smb2_request_init(session->transport, SMB2_OP_SESSSETUP,
- 0x18, True, io->in.secblob.length);
+ 0x18, true, io->in.secblob.length);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
@@ -105,7 +105,7 @@ NTSTATUS smb2_session_setup_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x08, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x08, true);
io->out._pad = SVAL(req->in.body, 0x02);
io->out.uid = BVAL(req->in.hdr, SMB2_HDR_UID);
diff --git a/source4/libcli/smb2/setinfo.c b/source4/libcli/smb2/setinfo.c
index 67d433a48a..d942568a2d 100644
--- a/source4/libcli/smb2/setinfo.c
+++ b/source4/libcli/smb2/setinfo.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_setinfo_send(struct smb2_tree *tree, struct smb2_setin
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, True, io->in.blob.length);
+ req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, true, io->in.blob.length);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.level);
@@ -62,7 +62,7 @@ NTSTATUS smb2_setinfo_recv(struct smb2_request *req)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x02, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x02, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/tcon.c b/source4/libcli/smb2/tcon.c
index 4f341d1206..ad1ba4c92d 100644
--- a/source4/libcli/smb2/tcon.c
+++ b/source4/libcli/smb2/tcon.c
@@ -27,7 +27,7 @@
initialise a smb2_session structure
*/
struct smb2_tree *smb2_tree_init(struct smb2_session *session,
- TALLOC_CTX *parent_ctx, BOOL primary)
+ TALLOC_CTX *parent_ctx, bool primary)
{
struct smb2_tree *tree;
@@ -53,7 +53,7 @@ struct smb2_request *smb2_tree_connect_send(struct smb2_tree *tree,
NTSTATUS status;
req = smb2_request_init(tree->session->transport, SMB2_OP_TCON,
- 0x08, True, 0);
+ 0x08, true, 0);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
@@ -81,7 +81,7 @@ NTSTATUS smb2_tree_connect_recv(struct smb2_request *req, struct smb2_tree_conne
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x10, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x10, false);
io->out.tid = IVAL(req->in.hdr, SMB2_HDR_TID);
diff --git a/source4/libcli/smb2/tdis.c b/source4/libcli/smb2/tdis.c
index 6ad3120740..5adad9dc6e 100644
--- a/source4/libcli/smb2/tdis.c
+++ b/source4/libcli/smb2/tdis.c
@@ -30,7 +30,7 @@ struct smb2_request *smb2_tdis_send(struct smb2_tree *tree)
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, False, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, false, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0);
@@ -51,7 +51,7 @@ NTSTATUS smb2_tdis_recv(struct smb2_request *req)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x04, False);
+ SMB2_CHECK_PACKET_RECV(req, 0x04, false);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c
index de08201c8b..83e9436a58 100644
--- a/source4/libcli/smb2/transport.c
+++ b/source4/libcli/smb2/transport.c
@@ -193,7 +193,7 @@ static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob)
if (NT_STATUS_EQUAL(req->status, STATUS_PENDING)) {
if (flags & 0x00000002) {
- req->cancel.can_cancel = True;
+ req->cancel.can_cancel = true;
req->cancel.pending_id = IVAL(hdr, SMB2_HDR_PID);
for (i=0; i< req->cancel.do_cancel; i++) {
smb2_cancel(req);
diff --git a/source4/libcli/smb2/write.c b/source4/libcli/smb2/write.c
index 3d501dc915..bc283370d7 100644
--- a/source4/libcli/smb2/write.c
+++ b/source4/libcli/smb2/write.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_write_send(struct smb2_tree *tree, struct smb2_write *
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, True, io->in.data.length);
+ req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, true, io->in.data.length);
if (req == NULL) return NULL;
status = smb2_push_o16s32_blob(&req->out, 0x02, io->in.data);
@@ -62,7 +62,7 @@ NTSTATUS smb2_write_recv(struct smb2_request *req, struct smb2_write *io)
return smb2_request_destroy(req);
}
- SMB2_CHECK_PACKET_RECV(req, 0x10, True);
+ SMB2_CHECK_PACKET_RECV(req, 0x10, true);
io->out._pad = SVAL(req->in.body, 0x02);
io->out.nwritten = IVAL(req->in.body, 0x04);
diff --git a/source4/libcli/smb_composite/appendacl.c b/source4/libcli/smb_composite/appendacl.c
index f82714de5b..0fda8c4d65 100644
--- a/source4/libcli/smb_composite/appendacl.c
+++ b/source4/libcli/smb_composite/appendacl.c
@@ -187,7 +187,7 @@ static NTSTATUS appendacl_close(struct composite_context *c,
*/
static void appendacl_handler(struct smbcli_request *req)
{
- struct composite_context *c = req->async.private;
+ struct composite_context *c = (struct composite_context *)req->async.private;
struct appendacl_state *state = talloc_get_type(c->private_data, struct appendacl_state);
/* when this handler is called, the stage indicates what
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index 026fe0b029..9f18c0d924 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -28,6 +28,7 @@
#include "libcli/resolve/resolve.h"
#include "auth/credentials/credentials.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/* the stages of this call */
enum connect_stage {CONNECT_RESOLVE,
@@ -62,7 +63,8 @@ static NTSTATUS connect_send_negprot(struct composite_context *c,
{
struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
- state->req = smb_raw_negotiate_send(state->transport, lp_cli_maxprotocol());
+ state->req = smb_raw_negotiate_send(state->transport,
+ lp_cli_maxprotocol(global_loadparm));
NT_STATUS_HAVE_NO_MEMORY(state->req);
state->req->async.fn = request_handler;
@@ -114,12 +116,12 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c,
status = smb_composite_sesssetup_recv(state->creq);
NT_STATUS_NOT_OK_RETURN(status);
- io->out.anonymous_fallback_done = True;
+ io->out.anonymous_fallback_done = true;
state->session->vuid = state->io_setup->out.vuid;
/* setup for a tconx */
- io->out.tree = smbcli_tree_init(state->session, state, True);
+ 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);
@@ -171,7 +173,8 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
state->io_setup->in.credentials = cli_credentials_init(state);
NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials);
- cli_credentials_set_conf(state->io_setup->in.credentials);
+ cli_credentials_set_conf(state->io_setup->in.credentials,
+ global_loadparm);
cli_credentials_set_anonymous(state->io_setup->in.credentials);
/* If the preceding attempt was with extended security, we
@@ -200,7 +203,7 @@ 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);
+ 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);
@@ -248,7 +251,7 @@ static NTSTATUS connect_negprot(struct composite_context *c,
NT_STATUS_NOT_OK_RETURN(status);
/* next step is a session setup */
- state->session = smbcli_session_init(state->transport, state, True);
+ state->session = smbcli_session_init(state->transport, state, true);
NT_STATUS_HAVE_NO_MEMORY(state->session);
state->io_setup = talloc(c, struct smb_composite_sesssetup);
@@ -304,7 +307,7 @@ static NTSTATUS connect_socket(struct composite_context *c,
NT_STATUS_NOT_OK_RETURN(status);
/* the socket is up - we can initialise the smbcli transport layer */
- state->transport = smbcli_transport_init(state->sock, state, True);
+ state->transport = smbcli_transport_init(state->sock, state, true);
NT_STATUS_HAVE_NO_MEMORY(state->transport);
if (is_ipaddress(state->sock->hostname) &&
@@ -458,7 +461,8 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
state->stage = CONNECT_RESOLVE;
make_nbt_name_server(&name, io->in.dest_host);
- state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
+ state->creq = resolve_name_send(&name, c->event_ctx,
+ lp_name_resolve_order(global_loadparm));
if (state->creq == NULL) goto failed;
state->creq->async.private_data = c;
diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c
index 63a10a667d..2dbaff5a66 100644
--- a/source4/libcli/smb_composite/fetchfile.c
+++ b/source4/libcli/smb_composite/fetchfile.c
@@ -142,7 +142,7 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
state->connect->in.service = io->in.service;
state->connect->in.service_type = io->in.service_type;
state->connect->in.credentials = io->in.credentials;
- state->connect->in.fallback_to_anonymous = False;
+ state->connect->in.fallback_to_anonymous = false;
state->connect->in.workgroup = io->in.workgroup;
state->creq = smb_composite_connect_send(state->connect, state, event_ctx);
diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c
index e81e3a2085..faf3723539 100644
--- a/source4/libcli/smb_composite/fsinfo.c
+++ b/source4/libcli/smb_composite/fsinfo.c
@@ -148,7 +148,7 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
state->connect->in.service = io->in.service;
state->connect->in.service_type = io->in.service_type;
state->connect->in.credentials = io->in.credentials;
- state->connect->in.fallback_to_anonymous = False;
+ state->connect->in.fallback_to_anonymous = false;
state->connect->in.workgroup = io->in.workgroup;
c->state = COMPOSITE_STATE_IN_PROGRESS;
diff --git a/source4/libcli/smb_composite/loadfile.c b/source4/libcli/smb_composite/loadfile.c
index 9b65d04ef3..952f24b811 100644
--- a/source4/libcli/smb_composite/loadfile.c
+++ b/source4/libcli/smb_composite/loadfile.c
@@ -105,7 +105,7 @@ static NTSTATUS loadfile_open(struct composite_context *c,
state->io_read->readx.in.mincnt = MIN(32768, io->out.size);
state->io_read->readx.in.maxcnt = state->io_read->readx.in.mincnt;
state->io_read->readx.in.remaining = 0;
- state->io_read->readx.in.read_for_execute = False;
+ state->io_read->readx.in.read_for_execute = false;
state->io_read->readx.out.data = io->out.data;
state->req = smb_raw_read_send(tree, state->io_read);
@@ -180,7 +180,7 @@ static NTSTATUS loadfile_close(struct composite_context *c,
*/
static void loadfile_handler(struct smbcli_request *req)
{
- struct composite_context *c = req->async.private;
+ struct composite_context *c = (struct composite_context *)req->async.private;
struct loadfile_state *state = talloc_get_type(c->private_data, struct loadfile_state);
/* when this handler is called, the stage indicates what
diff --git a/source4/libcli/smb_composite/savefile.c b/source4/libcli/smb_composite/savefile.c
index 32fcdbcd87..b94be9e9b1 100644
--- a/source4/libcli/smb_composite/savefile.c
+++ b/source4/libcli/smb_composite/savefile.c
@@ -180,7 +180,7 @@ static NTSTATUS savefile_close(struct composite_context *c,
*/
static void savefile_handler(struct smbcli_request *req)
{
- struct composite_context *c = req->async.private;
+ struct composite_context *c = (struct composite_context *)req->async.private;
struct savefile_state *state = talloc_get_type(c->private_data, struct savefile_state);
/* when this handler is called, the stage indicates what
diff --git a/source4/libcli/smb_composite/sesssetup.c b/source4/libcli/smb_composite/sesssetup.c
index 25cf8b3f12..622367e746 100644
--- a/source4/libcli/smb_composite/sesssetup.c
+++ b/source4/libcli/smb_composite/sesssetup.c
@@ -29,6 +29,7 @@
#include "auth/gensec/gensec.h"
#include "auth/credentials/credentials.h"
#include "version.h"
+#include "param/param.h"
struct sesssetup_state {
union smb_sesssetup setup;
@@ -76,7 +77,7 @@ static void set_user_session_key(struct smbcli_session *session,
*/
static void request_handler(struct smbcli_request *req)
{
- struct composite_context *c = req->async.private;
+ struct composite_context *c = (struct composite_context *)req->async.private;
struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
struct smbcli_session *session = req->session;
DATA_BLOB session_key = data_blob(NULL, 0);
@@ -222,14 +223,14 @@ 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, session->transport->socket->hostname, lp_workgroup());
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
DATA_BLOB session_key;
int flags = CLI_CRED_NTLM_AUTH;
- if (lp_client_lanman_auth()) {
+ if (lp_client_lanman_auth(global_loadparm)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
- if (lp_client_ntlmv2_auth()) {
+ if (lp_client_ntlmv2_auth(global_loadparm)) {
flags |= CLI_CRED_NTLMv2_AUTH;
}
@@ -262,7 +263,7 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
set_user_session_key(session, &session_key);
data_blob_free(&session_key);
- } else if (lp_client_plaintext_auth()) {
+ } else if (lp_client_plaintext_auth(global_loadparm)) {
state->setup.nt1.in.password1 = data_blob_talloc(state, password, strlen(password));
state->setup.nt1.in.password2 = data_blob(NULL, 0);
} else {
@@ -289,14 +290,14 @@ static NTSTATUS session_setup_old(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, session->transport->socket->hostname, lp_workgroup());
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
DATA_BLOB session_key;
int flags = 0;
- if (lp_client_lanman_auth()) {
+ if (lp_client_lanman_auth(global_loadparm)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
- if (lp_client_ntlmv2_auth()) {
+ if (lp_client_ntlmv2_auth(global_loadparm)) {
flags |= CLI_CRED_NTLMv2_AUTH;
}
@@ -323,7 +324,7 @@ static NTSTATUS session_setup_old(struct composite_context *c,
set_user_session_key(session, &session_key);
data_blob_free(&session_key);
- } else if (lp_client_plaintext_auth()) {
+ } else if (lp_client_plaintext_auth(global_loadparm)) {
state->setup.old.in.password = data_blob_talloc(state, password, strlen(password));
} else {
/* could match windows client and return 'cannot logon from this workstation', but it just confuses everybody */
@@ -417,7 +418,7 @@ static NTSTATUS session_setup_spnego(struct composite_context *c,
}
}
- if (chosen_oid == GENSEC_OID_SPNEGO) {
+ if ((const void *)chosen_oid == (const void *)GENSEC_OID_SPNEGO) {
status = gensec_update(session->gensec, state,
session->transport->negotiate.secblob,
&state->setup.spnego.in.secblob);
diff --git a/source4/libcli/swig/libcli_nbt.i b/source4/libcli/swig/libcli_nbt.i
index b887e7df97..ec7632ccf4 100644
--- a/source4/libcli/swig/libcli_nbt.i
+++ b/source4/libcli/swig/libcli_nbt.i
@@ -31,6 +31,7 @@
#include "lib/talloc/talloc.h"
#include "lib/events/events.h"
#include "libcli/nbt/libnbt.h"
+#include "param/param.h"
/* Undo strcpy safety macro as it's used by swig )-: */
@@ -38,7 +39,7 @@
%}
-%apply bool { BOOL };
+%apply bool { bool };
%apply int { uint8_t };
%apply int { int8_t };
%apply unsigned int { uint16_t };
@@ -111,8 +112,8 @@ struct nbt_name_query {
struct {
struct nbt_name name;
const char *dest_addr;
- BOOL broadcast;
- BOOL wins_lookup;
+ bool broadcast;
+ bool wins_lookup;
int timeout; /* in seconds */
int retries;
} in;
@@ -127,9 +128,17 @@ struct nbt_name_query {
%include "carrays.i"
%array_functions(char *, char_ptr_array);
-%rename(do_nbt_name_query) nbt_name_query;
+NTSTATUS do_nbt_name_query(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
-NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
- TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
+%{
+NTSTATUS do_nbt_name_query(struct nbt_name_socket *nbtsock,
+ TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
+{
+ return nbt_name_query(nbtsock, mem_ctx, io);
+}
+%}
-void lp_load(void);
+%init %{
+ lp_load();
+%}
diff --git a/source4/libcli/swig/libcli_smb.i b/source4/libcli/swig/libcli_smb.i
new file mode 100644
index 0000000000..8eb055c2f0
--- /dev/null
+++ b/source4/libcli/swig/libcli_smb.i
@@ -0,0 +1,18 @@
+%module libcli_smb
+
+%{
+#include "includes.h"
+#include "lib/talloc/talloc.h"
+#include "lib/events/events.h"
+#include "libcli/raw/libcliraw.h"
+%}
+
+TALLOC_CTX *talloc_init(char *name);
+int talloc_free(TALLOC_CTX *ptr);
+struct event_context *event_context_init(TALLOC_CTX *mem_ctx);
+
+struct smbcli_socket *smbcli_sock_connect_byname(const char *host, int port,
+ TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx);
+
+void smbcli_sock_dead(struct smbcli_socket *sock);
diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c
index e7a2e163aa..58cb5f07be 100644
--- a/source4/libcli/util/asn1.c
+++ b/source4/libcli/util/asn1.c
@@ -37,41 +37,41 @@ void asn1_free(struct asn1_data *data)
}
/* write to the ASN1 buffer, advancing the buffer pointer */
-BOOL asn1_write(struct asn1_data *data, const void *p, int len)
+bool asn1_write(struct asn1_data *data, const void *p, int len)
{
- if (data->has_error) return False;
+ if (data->has_error) return false;
if (data->length < data->ofs+len) {
uint8_t *newp;
newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len);
if (!newp) {
asn1_free(data);
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data->data = newp;
data->length = data->ofs+len;
}
memcpy(data->data + data->ofs, p, len);
data->ofs += len;
- return True;
+ return true;
}
/* useful fn for writing a uint8_t */
-BOOL asn1_write_uint8(struct asn1_data *data, uint8_t v)
+bool asn1_write_uint8(struct asn1_data *data, uint8_t v)
{
return asn1_write(data, &v, 1);
}
/* push a tag onto the asn1 data buffer. Used for nested structures */
-BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag)
+bool asn1_push_tag(struct asn1_data *data, uint8_t tag)
{
struct nesting *nesting;
asn1_write_uint8(data, tag);
nesting = talloc(data, struct nesting);
if (!nesting) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
nesting->start = data->ofs;
@@ -81,7 +81,7 @@ BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag)
}
/* pop a tag */
-BOOL asn1_pop_tag(struct asn1_data *data)
+bool asn1_pop_tag(struct asn1_data *data)
{
struct nesting *nesting;
size_t len;
@@ -89,8 +89,8 @@ BOOL asn1_pop_tag(struct asn1_data *data)
nesting = data->nesting;
if (!nesting) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
len = data->ofs - (nesting->start+1);
/* yes, this is ugly. We don't know in advance how many bytes the length
@@ -98,10 +98,10 @@ BOOL asn1_pop_tag(struct asn1_data *data)
need to correct our mistake */
if (len > 0xFFFFFF) {
data->data[nesting->start] = 0x84;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
memmove(data->data+nesting->start+5, data->data+nesting->start+1, len);
data->data[nesting->start+1] = (len>>24) & 0xFF;
data->data[nesting->start+2] = (len>>16) & 0xFF;
@@ -109,23 +109,23 @@ BOOL asn1_pop_tag(struct asn1_data *data)
data->data[nesting->start+4] = len&0xff;
} else if (len > 0xFFFF) {
data->data[nesting->start] = 0x83;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
memmove(data->data+nesting->start+4, data->data+nesting->start+1, len);
data->data[nesting->start+1] = (len>>16) & 0xFF;
data->data[nesting->start+2] = (len>>8) & 0xFF;
data->data[nesting->start+3] = len&0xff;
} else if (len > 255) {
data->data[nesting->start] = 0x82;
- if (!asn1_write_uint8(data, 0)) return False;
- if (!asn1_write_uint8(data, 0)) return False;
+ if (!asn1_write_uint8(data, 0)) return false;
+ if (!asn1_write_uint8(data, 0)) return false;
memmove(data->data+nesting->start+3, data->data+nesting->start+1, len);
data->data[nesting->start+1] = len>>8;
data->data[nesting->start+2] = len&0xff;
} else if (len > 127) {
data->data[nesting->start] = 0x81;
- if (!asn1_write_uint8(data, 0)) return False;
+ if (!asn1_write_uint8(data, 0)) return false;
memmove(data->data+nesting->start+2, data->data+nesting->start+1, len);
data->data[nesting->start+1] = len;
} else {
@@ -134,20 +134,20 @@ BOOL asn1_pop_tag(struct asn1_data *data)
data->nesting = nesting->next;
talloc_free(nesting);
- return True;
+ return true;
}
/* "i" is the one's complement representation, as is the normal result of an
* implicit signed->unsigned conversion */
-static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL negative)
+static bool push_int_bigendian(struct asn1_data *data, unsigned int i, bool negative)
{
uint8_t lowest = i & 0xFF;
i = i >> 8;
if (i != 0)
if (!push_int_bigendian(data, i, negative))
- return False;
+ return false;
if (data->nesting->start+1 == data->ofs) {
@@ -157,14 +157,14 @@ static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL nega
if (negative) {
/* Don't write leading 0xff's */
if (lowest == 0xFF)
- return True;
+ return true;
if ((lowest & 0x80) == 0) {
/* The only exception for a leading 0xff is if
* the highest bit is 0, which would indicate
* a positive value */
if (!asn1_write_uint8(data, 0xff))
- return False;
+ return false;
}
} else {
if (lowest & 0x80) {
@@ -172,7 +172,7 @@ static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL nega
* this would indicate a negative number. Push
* a 0 to indicate a positive one */
if (!asn1_write_uint8(data, 0))
- return False;
+ return false;
}
}
}
@@ -183,7 +183,7 @@ static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL nega
/* write an Integer without the tag framing. Needed for example for the LDAP
* Abandon Operation */
-BOOL asn1_write_implicit_Integer(struct asn1_data *data, int i)
+bool asn1_write_implicit_Integer(struct asn1_data *data, int i)
{
if (i == -1) {
/* -1 is special as it consists of all-0xff bytes. In
@@ -198,14 +198,14 @@ BOOL asn1_write_implicit_Integer(struct asn1_data *data, int i)
/* write an integer */
-BOOL asn1_write_Integer(struct asn1_data *data, int i)
+bool asn1_write_Integer(struct asn1_data *data, int i)
{
- if (!asn1_push_tag(data, ASN1_INTEGER)) return False;
- if (!asn1_write_implicit_Integer(data, i)) return False;
+ if (!asn1_push_tag(data, ASN1_INTEGER)) return false;
+ if (!asn1_write_implicit_Integer(data, i)) return false;
return asn1_pop_tag(data);
}
-BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
+bool ber_write_OID_String(DATA_BLOB *blob, const char *OID)
{
uint_t v, v2;
const char *p = (const char *)OID;
@@ -213,16 +213,16 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
int i;
v = strtoul(p, &newp, 10);
- if (newp[0] != '.') return False;
+ if (newp[0] != '.') return false;
p = newp + 1;
v2 = strtoul(p, &newp, 10);
- if (newp[0] != '.') return False;
+ if (newp[0] != '.') return false;
p = newp + 1;
/*the ber representation can't use more space then the string one */
*blob = data_blob(NULL, strlen(OID));
- if (!blob->data) return False;
+ if (!blob->data) return false;
blob->data[0] = 40*v + v2;
@@ -235,7 +235,7 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
p = newp;
} else {
data_blob_free(blob);
- return False;
+ return false;
}
if (v >= (1<<28)) blob->data[i++] = (0x80 | ((v>>28)&0x7f));
if (v >= (1<<21)) blob->data[i++] = (0x80 | ((v>>21)&0x7f));
@@ -246,31 +246,31 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID)
blob->length = i;
- return True;
+ return true;
}
/* write an object ID to a ASN1 buffer */
-BOOL asn1_write_OID(struct asn1_data *data, const char *OID)
+bool asn1_write_OID(struct asn1_data *data, const char *OID)
{
DATA_BLOB blob;
- if (!asn1_push_tag(data, ASN1_OID)) return False;
+ if (!asn1_push_tag(data, ASN1_OID)) return false;
if (!ber_write_OID_String(&blob, OID)) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
if (!asn1_write(data, blob.data, blob.length)) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data_blob_free(&blob);
return asn1_pop_tag(data);
}
/* write an octet string */
-BOOL asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length)
+bool asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length)
{
asn1_push_tag(data, ASN1_OCTET_STRING);
asn1_write(data, p, length);
@@ -279,14 +279,14 @@ BOOL asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length
}
/* write a LDAP string */
-BOOL asn1_write_LDAPString(struct asn1_data *data, const char *s)
+bool asn1_write_LDAPString(struct asn1_data *data, const char *s)
{
asn1_write(data, s, strlen(s));
return !data->has_error;
}
/* write a general string */
-BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s)
+bool asn1_write_GeneralString(struct asn1_data *data, const char *s)
{
asn1_push_tag(data, ASN1_GENERAL_STRING);
asn1_write_LDAPString(data, s);
@@ -294,7 +294,7 @@ BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s)
return !data->has_error;
}
-BOOL asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
+bool asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
{
asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(num));
asn1_write(data, blob->data, blob->length);
@@ -303,7 +303,7 @@ BOOL asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *bl
}
/* write a BOOLEAN */
-BOOL asn1_write_BOOLEAN(struct asn1_data *data, BOOL v)
+bool asn1_write_BOOLEAN(struct asn1_data *data, bool v)
{
asn1_push_tag(data, ASN1_BOOLEAN);
asn1_write_uint8(data, v ? 0xFF : 0);
@@ -311,137 +311,140 @@ BOOL asn1_write_BOOLEAN(struct asn1_data *data, BOOL v)
return !data->has_error;
}
-BOOL asn1_read_BOOLEAN(struct asn1_data *data, BOOL *v)
+bool asn1_read_BOOLEAN(struct asn1_data *data, bool *v)
{
uint8_t tmp = 0;
asn1_start_tag(data, ASN1_BOOLEAN);
asn1_read_uint8(data, &tmp);
if (tmp == 0xFF) {
- *v = True;
+ *v = true;
} else {
- *v = False;
+ *v = false;
}
asn1_end_tag(data);
return !data->has_error;
}
/* check a BOOLEAN */
-BOOL asn1_check_BOOLEAN(struct asn1_data *data, BOOL v)
+bool asn1_check_BOOLEAN(struct asn1_data *data, bool v)
{
uint8_t b = 0;
asn1_read_uint8(data, &b);
if (b != ASN1_BOOLEAN) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read_uint8(data, &b);
if (b != v) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
return !data->has_error;
}
/* load a struct asn1_data structure with a lump of data, ready to be parsed */
-BOOL asn1_load(struct asn1_data *data, DATA_BLOB blob)
+bool asn1_load(struct asn1_data *data, DATA_BLOB blob)
{
ZERO_STRUCTP(data);
data->data = talloc_memdup(data, blob.data, blob.length);
if (!data->data) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data->length = blob.length;
- return True;
+ return true;
}
/* Peek into an ASN1 buffer, not advancing the pointer */
-BOOL asn1_peek(struct asn1_data *data, void *p, int len)
+bool asn1_peek(struct asn1_data *data, void *p, int len)
{
+ if (data->has_error)
+ return false;
+
if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len)
- return False;
+ return false;
if (data->ofs + len > data->length) {
/* we need to mark the buffer as consumed, so the caller knows
this was an out of data error, and not a decode error */
data->ofs = data->length;
- return False;
+ return false;
}
memcpy(p, data->data + data->ofs, len);
- return True;
+ return true;
}
/* read from a ASN1 buffer, advancing the buffer pointer */
-BOOL asn1_read(struct asn1_data *data, void *p, int len)
+bool asn1_read(struct asn1_data *data, void *p, int len)
{
if (!asn1_peek(data, p, len)) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data->ofs += len;
- return True;
+ return true;
}
/* read a uint8_t from a ASN1 buffer */
-BOOL asn1_read_uint8(struct asn1_data *data, uint8_t *v)
+bool asn1_read_uint8(struct asn1_data *data, uint8_t *v)
{
return asn1_read(data, v, 1);
}
-BOOL asn1_peek_uint8(struct asn1_data *data, uint8_t *v)
+bool asn1_peek_uint8(struct asn1_data *data, uint8_t *v)
{
return asn1_peek(data, v, 1);
}
-BOOL asn1_peek_tag(struct asn1_data *data, uint8_t tag)
+bool asn1_peek_tag(struct asn1_data *data, uint8_t tag)
{
uint8_t b;
if (asn1_tag_remaining(data) <= 0) {
- return False;
+ return false;
}
- if (!asn1_peek(data, &b, sizeof(b)))
- return False;
+ if (!asn1_peek_uint8(data, &b))
+ return false;
return (b == tag);
}
/* start reading a nested asn1 structure */
-BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag)
+bool asn1_start_tag(struct asn1_data *data, uint8_t tag)
{
uint8_t b;
struct nesting *nesting;
if (!asn1_read_uint8(data, &b))
- return False;
+ return false;
if (b != tag) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
nesting = talloc(data, struct nesting);
if (!nesting) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
if (!asn1_read_uint8(data, &b)) {
- return False;
+ return false;
}
if (b & 0x80) {
int n = b & 0x7f;
if (!asn1_read_uint8(data, &b))
- return False;
+ return false;
nesting->taglen = b;
while (n > 1) {
if (!asn1_read_uint8(data, &b))
- return False;
+ return false;
nesting->taglen = (nesting->taglen << 8) | b;
n--;
}
@@ -452,32 +455,32 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag)
nesting->next = data->nesting;
data->nesting = nesting;
if (asn1_tag_remaining(data) == -1) {
- return False;
+ return false;
}
return !data->has_error;
}
/* stop reading a tag */
-BOOL asn1_end_tag(struct asn1_data *data)
+bool asn1_end_tag(struct asn1_data *data)
{
struct nesting *nesting;
/* make sure we read it all */
if (asn1_tag_remaining(data) != 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
nesting = data->nesting;
if (!nesting) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
data->nesting = nesting->next;
talloc_free(nesting);
- return True;
+ return true;
}
/* work out how many bytes are left in this nested tag */
@@ -489,38 +492,38 @@ int asn1_tag_remaining(struct asn1_data *data)
}
if (!data->nesting) {
- data->has_error = True;
+ data->has_error = true;
return -1;
}
remaining = data->nesting->taglen - (data->ofs - data->nesting->start);
if (remaining > (data->length - data->ofs)) {
- data->has_error = True;
+ data->has_error = true;
return -1;
}
return remaining;
}
/* read an object ID from a data blob */
-BOOL ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID)
+bool ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID)
{
int i;
uint8_t *b;
uint_t v;
char *tmp_oid = NULL;
- if (blob.length < 2) return False;
+ if (blob.length < 2) return false;
b = blob.data;
tmp_oid = talloc_asprintf(mem_ctx, "%u", b[0]/40);
if (!tmp_oid) goto nomem;
- tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", b[0]%40);
+ tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", b[0]%40);
if (!tmp_oid) goto nomem;
for(i = 1, v = 0; i < blob.length; i++) {
v = (v<<7) | (b[i]&0x7f);
if ( ! (b[i] & 0x80)) {
- tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", v);
+ tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", v);
v = 0;
}
if (!tmp_oid) goto nomem;
@@ -528,82 +531,82 @@ BOOL ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID)
if (v != 0) {
talloc_free(tmp_oid);
- return False;
+ return false;
}
*OID = tmp_oid;
- return True;
+ return true;
nomem:
- return False;
+ return false;
}
/* read an object ID from a ASN1 buffer */
-BOOL asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID)
+bool asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID)
{
DATA_BLOB blob;
int len;
- if (!asn1_start_tag(data, ASN1_OID)) return False;
+ if (!asn1_start_tag(data, ASN1_OID)) return false;
len = asn1_tag_remaining(data);
if (len < 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
blob = data_blob(NULL, len);
if (!blob.data) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read(data, blob.data, len);
asn1_end_tag(data);
if (data->has_error) {
data_blob_free(&blob);
- return False;
+ return false;
}
if (!ber_read_OID_String(mem_ctx, blob, OID)) {
- data->has_error = True;
+ data->has_error = true;
data_blob_free(&blob);
- return False;
+ return false;
}
data_blob_free(&blob);
- return True;
+ return true;
}
/* check that the next object ID is correct */
-BOOL asn1_check_OID(struct asn1_data *data, const char *OID)
+bool asn1_check_OID(struct asn1_data *data, const char *OID)
{
const char *id;
- if (!asn1_read_OID(data, data, &id)) return False;
+ if (!asn1_read_OID(data, data, &id)) return false;
if (strcmp(id, OID) != 0) {
talloc_free(discard_const(id));
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
talloc_free(discard_const(id));
- return True;
+ return true;
}
/* read a LDAPString from a ASN1 buffer */
-BOOL asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
+bool asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
{
int len;
len = asn1_tag_remaining(data);
if (len < 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
- *s = talloc_size(mem_ctx, len+1);
+ *s = talloc_array(mem_ctx, char, len+1);
if (! *s) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read(data, *s, len);
(*s)[len] = 0;
@@ -612,29 +615,29 @@ BOOL asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
/* read a GeneralString from a ASN1 buffer */
-BOOL asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
+bool asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s)
{
- if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False;
- if (!asn1_read_LDAPString(data, mem_ctx, s)) return False;
+ if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return false;
+ if (!asn1_read_LDAPString(data, mem_ctx, s)) return false;
return asn1_end_tag(data);
}
/* read a octet string blob */
-BOOL asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob)
+bool asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob)
{
int len;
ZERO_STRUCTP(blob);
- if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return False;
+ if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return false;
len = asn1_tag_remaining(data);
if (len < 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
*blob = data_blob_talloc(mem_ctx, NULL, len+1);
if (!blob->data) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read(data, blob->data, len);
asn1_end_tag(data);
@@ -644,25 +647,25 @@ BOOL asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLO
if (data->has_error) {
data_blob_free(blob);
*blob = data_blob(NULL, 0);
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
+bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
{
int len;
ZERO_STRUCTP(blob);
- if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(num))) return False;
+ if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(num))) return false;
len = asn1_tag_remaining(data);
if (len < 0) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
*blob = data_blob(NULL, len);
if ((len != 0) && (!blob->data)) {
- data->has_error = True;
- return False;
+ data->has_error = true;
+ return false;
}
asn1_read(data, blob->data, len);
asn1_end_tag(data);
@@ -670,13 +673,13 @@ BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blo
}
/* read an interger without tag*/
-BOOL asn1_read_implicit_Integer(struct asn1_data *data, int *i)
+bool asn1_read_implicit_Integer(struct asn1_data *data, int *i)
{
uint8_t b;
*i = 0;
while (!data->has_error && asn1_tag_remaining(data)>0) {
- if (!asn1_read_uint8(data, &b)) return False;
+ if (!asn1_read_uint8(data, &b)) return false;
*i = (*i << 8) + b;
}
return !data->has_error;
@@ -684,21 +687,21 @@ BOOL asn1_read_implicit_Integer(struct asn1_data *data, int *i)
}
/* read an interger */
-BOOL asn1_read_Integer(struct asn1_data *data, int *i)
+bool asn1_read_Integer(struct asn1_data *data, int *i)
{
*i = 0;
- if (!asn1_start_tag(data, ASN1_INTEGER)) return False;
- if (!asn1_read_implicit_Integer(data, i)) return False;
+ if (!asn1_start_tag(data, ASN1_INTEGER)) return false;
+ if (!asn1_read_implicit_Integer(data, i)) return false;
return asn1_end_tag(data);
}
/* read an interger */
-BOOL asn1_read_enumerated(struct asn1_data *data, int *v)
+bool asn1_read_enumerated(struct asn1_data *data, int *v)
{
*v = 0;
- if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False;
+ if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false;
while (!data->has_error && asn1_tag_remaining(data)>0) {
uint8_t b;
asn1_read_uint8(data, &b);
@@ -708,23 +711,23 @@ BOOL asn1_read_enumerated(struct asn1_data *data, int *v)
}
/* check a enumarted value is correct */
-BOOL asn1_check_enumerated(struct asn1_data *data, int v)
+bool asn1_check_enumerated(struct asn1_data *data, int v)
{
uint8_t b;
- if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False;
+ if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false;
asn1_read_uint8(data, &b);
asn1_end_tag(data);
if (v != b)
- data->has_error = False;
+ data->has_error = false;
return !data->has_error;
}
/* write an enumarted value to the stream */
-BOOL asn1_write_enumerated(struct asn1_data *data, uint8_t v)
+bool asn1_write_enumerated(struct asn1_data *data, uint8_t v)
{
- if (!asn1_push_tag(data, ASN1_ENUMERATED)) return False;
+ if (!asn1_push_tag(data, ASN1_ENUMERATED)) return false;
asn1_write_uint8(data, v);
asn1_pop_tag(data);
return !data->has_error;
diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c
index 6fd84bbe74..7c32294648 100644
--- a/source4/libcli/util/clilsa.c
+++ b/source4/libcli/util/clilsa.c
@@ -31,6 +31,7 @@
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_lsa.h"
#include "librpc/gen_ndr/ndr_lsa_c.h"
+#include "libcli/util/clilsa.h"
struct smblsa_state {
struct dcerpc_pipe *pipe;
@@ -60,7 +61,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli)
return NT_STATUS_NO_MEMORY;
}
- lsa->ipc_tree = smbcli_tree_init(cli->session, lsa, False);
+ lsa->ipc_tree = smbcli_tree_init(cli->session, lsa, false);
if (lsa->ipc_tree == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c
index d62a31c1fa..49818e573a 100644
--- a/source4/libcli/util/doserr.c
+++ b/source4/libcli/util/doserr.c
@@ -20,7 +20,6 @@
/* DOS error codes. please read doserr.h */
#include "includes.h"
-#include "pstring.h"
struct werror_code_struct {
const char *dos_errstr;
@@ -133,7 +132,7 @@ static const struct werror_code_struct dos_errs[] =
*****************************************************************************/
const char *win_errstr(WERROR werror)
{
- static pstring msg;
+ static char msg[40];
int idx = 0;
while (dos_errs[idx].dos_errstr != NULL) {
diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h
index 0478eff947..bec268a565 100644
--- a/source4/libcli/util/doserr.h
+++ b/source4/libcli/util/doserr.h
@@ -161,133 +161,8 @@
#define ERRsharebufexc 36 /* share buffer exceeded */
#define ERRdiskfull 39
-
-/* these are win32 error codes. There are only a few places where
- these matter for Samba, primarily in the NT printing code */
-#define WERR_OK W_ERROR(0)
-#define WERR_BADFUNC W_ERROR(1)
-#define WERR_BADFILE W_ERROR(2)
-#define WERR_ACCESS_DENIED W_ERROR(5)
-#define WERR_BADFID W_ERROR(6)
-#define WERR_NOMEM W_ERROR(8)
-#define WERR_GENERAL_FAILURE W_ERROR(31)
-#define WERR_NOT_SUPPORTED W_ERROR(50)
-#define WERR_BAD_NETPATH W_ERROR(53)
-#define WERR_BAD_NET_RESP W_ERROR(58)
-#define WERR_UNEXP_NET_ERR W_ERROR(59)
-#define WERR_PRINTQ_FULL W_ERROR(61)
-#define WERR_NO_SPOOL_SPACE W_ERROR(62)
-#define WERR_NO_SUCH_SHARE W_ERROR(67)
-#define WERR_FILE_EXISTS W_ERROR(80)
-#define WERR_BAD_PASSWORD W_ERROR(86)
-#define WERR_INVALID_PARAM W_ERROR(87)
-#define WERR_INSUFFICIENT_BUFFER W_ERROR(122)
-#define WERR_INVALID_NAME W_ERROR(123)
-#define WERR_UNKNOWN_LEVEL W_ERROR(124)
-#define WERR_OBJECT_PATH_INVALID W_ERROR(161)
-#define WERR_ALREADY_EXISTS W_ERROR(183)
-#define WERR_NO_MORE_ITEMS W_ERROR(259)
-#define WERR_MORE_DATA W_ERROR(234)
-#define WERR_CAN_NOT_COMPLETE W_ERROR(1003)
-#define WERR_NOT_FOUND W_ERROR(1168)
-#define WERR_INVALID_COMPUTERNAME W_ERROR(1210)
-#define WERR_INVALID_DOMAINNAME W_ERROR(1212)
-#define WERR_UNKNOWN_REVISION W_ERROR(1305)
-#define WERR_REVISION_MISMATCH W_ERROR(1306)
-#define WERR_INVALID_OWNER W_ERROR(1307)
-#define WERR_NO_LOGON_SERVERS W_ERROR(1311)
-#define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313)
-#define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314)
-#define WERR_NO_SUCH_USER W_ERROR(1317)
-#define WERR_LOGON_FAILURE W_ERROR(1326)
-#define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338)
-#define WERR_INVALID_DOMAIN_ROLE W_ERROR(1354)
-#define WERR_NO_SUCH_DOMAIN W_ERROR(1355)
-#define WERR_NO_SYSTEM_RESOURCES W_ERROR(1450)
-#define WERR_SERVER_UNAVAILABLE W_ERROR(1722)
-#define WERR_INVALID_FORM_NAME W_ERROR(1902)
-#define WERR_INVALID_FORM_SIZE W_ERROR(1903)
-#define WERR_ALREADY_SHARED W_ERROR(2118)
-#define WERR_BUF_TOO_SMALL W_ERROR(2123)
-#define WERR_JOB_NOT_FOUND W_ERROR(2151)
-#define WERR_DEST_NOT_FOUND W_ERROR(2152)
-#define WERR_SESSION_NOT_FOUND W_ERROR(2312)
-#define WERR_FID_NOT_FOUND W_ERROR(2314)
-#define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320)
-#define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453)
-#define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319)
-#define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105)
-
-#define WERR_PRINTER_DRIVER_ALREADY_INSTALLED W_ERROR(ERRdriveralreadyinstalled)
-#define WERR_UNKNOWN_PORT W_ERROR(ERRunknownprinterport)
-#define WERR_UNKNOWN_PRINTER_DRIVER W_ERROR(ERRunknownprinterdriver)
-#define WERR_UNKNOWN_PRINTPROCESSOR W_ERROR(ERRunknownprintprocessor)
-#define WERR_INVALID_SEPARATOR_FILE W_ERROR(ERRinvalidseparatorfile)
-#define WERR_INVALID_PRIORITY W_ERROR(ERRinvalidjobpriority)
-#define WERR_INVALID_PRINTER_NAME W_ERROR(ERRinvalidprintername)
-#define WERR_PRINTER_ALREADY_EXISTS W_ERROR(ERRprinteralreadyexists)
-#define WERR_INVALID_PRINTER_COMMAND W_ERROR(ERRinvalidprintercommand)
-#define WERR_INVALID_DATATYPE W_ERROR(ERRinvaliddatatype)
-#define WERR_INVALID_ENVIRONMENT W_ERROR(ERRinvalidenvironment)
-
-#define WERR_UNKNOWN_PRINT_MONITOR W_ERROR(ERRunknownprintmonitor)
-#define WERR_PRINTER_DRIVER_IN_USE W_ERROR(ERRprinterdriverinuse)
-#define WERR_SPOOL_FILE_NOT_FOUND W_ERROR(ERRspoolfilenotfound)
-#define WERR_SPL_NO_STARTDOC W_ERROR(ERRnostartdoc)
-#define WERR_SPL_NO_ADDJOB W_ERROR(ERRnoaddjob)
-#define WERR_PRINT_PROCESSOR_ALREADY_INSTALLED W_ERROR(ERRprintprocessoralreadyinstalled)
-#define WERR_PRINT_MONITOR_ALREADY_INSTALLED W_ERROR(ERRprintmonitoralreadyinstalled)
-#define WERR_INVALID_PRINT_MONITOR W_ERROR(ERRinvalidprintmonitor)
-#define WERR_PRINT_MONITOR_IN_USE W_ERROR(ERRprintmonitorinuse)
-#define WERR_PRINTER_HAS_JOBS_QUEUED W_ERROR(ERRprinterhasjobsqueued)
-
-#define WERR_CLASS_NOT_REGISTERED W_ERROR(0x40154)
-#define WERR_NO_SHUTDOWN_IN_PROGRESS W_ERROR(0x45c)
-#define WERR_SHUTDOWN_ALREADY_IN_PROGRESS W_ERROR(0x45b)
-
-
#ifndef NERR_BASE
#define NERR_BASE (2100)
#endif
-#define WERR_NET_NAME_NOT_FOUND W_ERROR(NERR_BASE+210)
-#define WERR_DEVICE_NOT_SHARED W_ERROR(NERR_BASE+211)
-
-/* DFS errors */
-#define WERR_DFS_NO_SUCH_VOL W_ERROR(NERR_BASE+562)
-#define WERR_DFS_NO_SUCH_SHARE W_ERROR(NERR_BASE+565)
-#define WERR_DFS_NO_SUCH_SERVER W_ERROR(NERR_BASE+573)
-#define WERR_DFS_INTERNAL_ERROR W_ERROR(NERR_BASE+590)
-#define WERR_DFS_CANT_CREATE_JUNCT W_ERROR(NERR_BASE+569)
-
-/* DS errors */
-#define WERR_DS_SERVICE_BUSY W_ERROR(0x0000200e)
-#define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f)
-#define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030)
-#define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d)
-#define WERR_DS_SCHEMA_NOT_LOADED W_ERROR(0x20de)
-#define WERR_DS_SCHEMA_ALLOC_FAILED W_ERROR(0x20df)
-#define WERR_DS_ATT_SCHEMA_REQ_SYNTAX W_ERROR(0x000020e0)
-#define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020e2)
-#define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5)
-#define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7)
-#define WERR_DS_DRA_BAD_NC W_ERROR(0x000020f8)
-#define WERR_DS_DRA_INTERNAL_ERROR W_ERROR(0x000020fa)
-#define WERR_DS_DRA_OUT_OF_MEM W_ERROR(0x000020fe)
-#define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081)
-#define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103)
-#define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104)
-#define WERR_DS_DRA_ACCESS_DENIED W_ERROR(0x00002105)
-#define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c)
-#define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150)
-#define WERR_DS_NO_MSDS_INTID W_ERROR(0x00002194)
-#define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195)
-
-/* SEC errors */
-#define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329)
-#define WERR_SEC_E_DECRYPT_FAILURE W_ERROR(0x80090330)
-#define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331)
-
-#define WERR_FOOBAR WERR_GENERAL_FAILURE
-
#endif /* _DOSERR_H */
diff --git a/source4/libcli/util/error.h b/source4/libcli/util/error.h
index 8a641c8eb9..dd2de3da75 100644
--- a/source4/libcli/util/error.h
+++ b/source4/libcli/util/error.h
@@ -19,8 +19,33 @@
#ifndef _SAMBA_ERROR_H_
#define _SAMBA_ERROR_H_
-#include "libcli/util/nterr.h"
+#include "libcli/util/werror.h"
#include "libcli/util/doserr.h"
-#include "libcli/util/proto.h"
+#include "libcli/util/ntstatus.h"
+
+/** NT error on DOS connection! (NT_STATUS_OK) */
+bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2);
+
+/*****************************************************************************
+convert a NT status code to a dos class/code
+ *****************************************************************************/
+void ntstatus_to_dos(NTSTATUS ntstatus, uint8_t *eclass, uint32_t *ecode);
+
+/*****************************************************************************
+convert a WERROR to a NT status32 code
+ *****************************************************************************/
+NTSTATUS werror_to_ntstatus(WERROR error);
+
+/*****************************************************************************
+convert a NTSTATUS to a WERROR
+ *****************************************************************************/
+WERROR ntstatus_to_werror(NTSTATUS error);
+
+/*********************************************************************
+ Map an NT error code from a Unix error code.
+*********************************************************************/
+NTSTATUS map_nt_error_from_unix(int unix_error);
+
+
#endif /* _SAMBA_ERROR_H */
diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c
index 711f02a626..8d088e1e4b 100644
--- a/source4/libcli/util/errormap.c
+++ b/source4/libcli/util/errormap.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "param/param.h"
/* This map was extracted by the ERRMAPEXTRACT smbtorture command.
The setup was a Samba HEAD (2002-01-03) PDC and an Win2k member
@@ -1161,13 +1162,13 @@ static const struct {
/*
check if a DOS encoded NTSTATUS code maps to the given NTSTATUS code
*/
-BOOL ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2)
+bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2)
{
/* when we negotiate nt status support, we don't want to consider
the mapping of dos codes, as we want to catch the cases where
a forced dos code is needed
*/
- if (lp_nt_status_support()) {
+ if (lp_nt_status_support(global_loadparm)) {
return NT_STATUS_V(status1) == NT_STATUS_V(status2);
}
diff --git a/source4/libcli/util/nt_status.h b/source4/libcli/util/nt_status.h
deleted file mode 100644
index 8d81aab175..0000000000
--- a/source4/libcli/util/nt_status.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- SMB parameters and setup, plus a whole lot more.
-
- Copyright (C) Andrew Tridgell 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/>.
-*/
-
-#ifndef _NT_STATUS_H
-#define _NT_STATUS_H
-
-#include <stdint.h>
-
-/* the following rather strange looking definitions of NTSTATUS and WERROR
- and there in order to catch common coding errors where different error types
- are mixed up. This is especially important as we slowly convert Samba
- from using BOOL for internal functions
-*/
-
-#if defined(HAVE_IMMEDIATE_STRUCTURES)
-typedef struct {uint32_t v;} NTSTATUS;
-#define NT_STATUS(x) ((NTSTATUS) { x })
-#define NT_STATUS_V(x) ((x).v)
-#else
-typedef uint32_t NTSTATUS;
-#define NT_STATUS(x) (x)
-#define NT_STATUS_V(x) (x)
-#endif
-
-#if defined(HAVE_IMMEDIATE_STRUCTURES)
-typedef struct {uint32_t v;} WERROR;
-#define W_ERROR(x) ((WERROR) { x })
-#define W_ERROR_V(x) ((x).v)
-#else
-typedef uint32_t WERROR;
-#define W_ERROR(x) (x)
-#define W_ERROR_V(x) (x)
-#endif
-
-#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
-#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
-/* checking for DOS error mapping here is ugly, but unfortunately the
- alternative is a very intrusive rewrite of the torture code */
-#define NT_STATUS_EQUAL(x,y) (NT_STATUS_IS_DOS(x)||NT_STATUS_IS_DOS(y)?ntstatus_dos_equal(x,y):NT_STATUS_V(x) == NT_STATUS_V(y))
-
-#define NT_STATUS_HAVE_NO_MEMORY(x) do { \
- if (!(x)) {\
- return NT_STATUS_NO_MEMORY;\
- }\
-} while (0)
-
-#define NT_STATUS_IS_OK_RETURN(x) do { \
- if (NT_STATUS_IS_OK(x)) {\
- return x;\
- }\
-} while (0)
-
-#define NT_STATUS_NOT_OK_RETURN(x) do { \
- if (!NT_STATUS_IS_OK(x)) {\
- return x;\
- }\
-} while (0)
-
-#define NT_STATUS_IS_ERR_RETURN(x) do { \
- if (NT_STATUS_IS_ERR(x)) {\
- return x;\
- }\
-} while (0)
-
-#define NT_STATUS_NOT_ERR_RETURN(x) do { \
- if (!NT_STATUS_IS_ERR(x)) {\
- return x;\
- }\
-} while (0)
-
-#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
-#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y))
-
-#define W_ERROR_HAVE_NO_MEMORY(x) do { \
- if (!(x)) {\
- return WERR_NOMEM;\
- }\
-} while (0)
-
-#define W_ERROR_IS_OK_RETURN(x) do { \
- if (W_ERROR_IS_OK(x)) {\
- return x;\
- }\
-} while (0)
-
-#define W_ERROR_NOT_OK_RETURN(x) do { \
- if (!W_ERROR_IS_OK(x)) {\
- return x;\
- }\
-} while (0)
-
-/* this defines special NTSTATUS codes to represent DOS errors. I
- have chosen this macro to produce status codes in the invalid
- NTSTATUS range */
-#define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code)
-#define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000)
-#define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF)
-#define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF)
-
-/* define ldap error codes as NTSTATUS codes */
-#define NT_STATUS_LDAP(code) NT_STATUS(0xF2000000 | code)
-#define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF2000000)
-#define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000)
-
-#endif
diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c
index 3aea0b51bc..b1f345016d 100644
--- a/source4/libcli/util/nterr.c
+++ b/source4/libcli/util/nterr.c
@@ -20,7 +20,6 @@
/* NT error codes. please read nterr.h */
#include "includes.h"
-#include "pstring.h"
#include "libcli/ldap/ldap.h"
typedef struct
@@ -862,7 +861,7 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
*****************************************************************************/
const char *get_nt_error_c_code(NTSTATUS nt_code)
{
- static pstring out;
+ static char out[40];
int idx = 0;
while (nt_errs[idx].nt_errstr != NULL) {
diff --git a/source4/libcli/util/nterr.h b/source4/libcli/util/ntstatus.h
index 1ee867a0aa..026b5162db 100644
--- a/source4/libcli/util/nterr.h
+++ b/source4/libcli/util/ntstatus.h
@@ -20,8 +20,24 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _NTERR_H
-#define _NTERR_H
+#ifndef _NTSTATUS_H
+#define _NTSTATUS_H
+
+/* the following rather strange looking definitions of NTSTATUS
+ are there in order to catch common coding errors where different error types
+ are mixed up. This is especially important as we slowly convert Samba
+ from using bool for internal functions
+*/
+
+#if defined(HAVE_IMMEDIATE_STRUCTURES)
+typedef struct {uint32_t v;} NTSTATUS;
+#define NT_STATUS(x) ((NTSTATUS) { x })
+#define NT_STATUS_V(x) ((x).v)
+#else
+typedef uint32_t NTSTATUS;
+#define NT_STATUS(x) (x)
+#define NT_STATUS_V(x) (x)
+#endif
/* Win32 Status codes. */
@@ -585,4 +601,75 @@
* this means we need a torture test */
#define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL
-#endif /* _NTERR_H */
+/*****************************************************************************
+ returns an NT error message. not amazingly helpful, but better than a number.
+ *****************************************************************************/
+const char *nt_errstr(NTSTATUS nt_code);
+
+/************************************************************************
+ Print friendler version fo NT error code
+ ***********************************************************************/
+const char *get_friendly_nt_error_msg(NTSTATUS nt_code);
+
+/*****************************************************************************
+ returns an NT_STATUS constant as a string for inclusion in autogen C code
+ *****************************************************************************/
+const char *get_nt_error_c_code(NTSTATUS nt_code);
+
+/*****************************************************************************
+ returns the NT_STATUS constant matching the string supplied (as an NTSTATUS)
+ *****************************************************************************/
+NTSTATUS nt_status_string_to_code(const char *nt_status_str);
+
+#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
+#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
+/* checking for DOS error mapping here is ugly, but unfortunately the
+ alternative is a very intrusive rewrite of the torture code */
+#define NT_STATUS_EQUAL(x,y) (NT_STATUS_IS_DOS(x)||NT_STATUS_IS_DOS(y)?ntstatus_dos_equal(x,y):NT_STATUS_V(x) == NT_STATUS_V(y))
+
+#define NT_STATUS_HAVE_NO_MEMORY(x) do { \
+ if (!(x)) {\
+ return NT_STATUS_NO_MEMORY;\
+ }\
+} while (0)
+
+#define NT_STATUS_IS_OK_RETURN(x) do { \
+ if (NT_STATUS_IS_OK(x)) {\
+ return x;\
+ }\
+} while (0)
+
+#define NT_STATUS_NOT_OK_RETURN(x) do { \
+ if (!NT_STATUS_IS_OK(x)) {\
+ return x;\
+ }\
+} while (0)
+
+#define NT_STATUS_IS_ERR_RETURN(x) do { \
+ if (NT_STATUS_IS_ERR(x)) {\
+ return x;\
+ }\
+} while (0)
+
+#define NT_STATUS_NOT_ERR_RETURN(x) do { \
+ if (!NT_STATUS_IS_ERR(x)) {\
+ return x;\
+ }\
+} while (0)
+
+/* this defines special NTSTATUS codes to represent DOS errors. I
+ have chosen this macro to produce status codes in the invalid
+ NTSTATUS range */
+#define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code)
+#define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000)
+#define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF)
+#define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF)
+
+/* define ldap error codes as NTSTATUS codes */
+#define NT_STATUS_LDAP(code) NT_STATUS(0xF2000000 | code)
+#define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF2000000)
+#define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000)
+
+
+
+#endif /* _NTSTATUS_H */
diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h
new file mode 100644
index 0000000000..55a4faa6a5
--- /dev/null
+++ b/source4/libcli/util/werror.h
@@ -0,0 +1,193 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB parameters and setup, plus a whole lot more.
+
+ Copyright (C) Andrew Tridgell 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/>.
+*/
+
+#ifndef _WERROR_H_
+#define _WERROR_H_
+
+#include <stdint.h>
+
+/* the following rather strange looking definitions of NTSTATUS and WERROR
+ and there in order to catch common coding errors where different error types
+ are mixed up. This is especially important as we slowly convert Samba
+ from using bool for internal functions
+*/
+
+#if defined(HAVE_IMMEDIATE_STRUCTURES)
+typedef struct {uint32_t v;} WERROR;
+#define W_ERROR(x) ((WERROR) { x })
+#define W_ERROR_V(x) ((x).v)
+#else
+typedef uint32_t WERROR;
+#define W_ERROR(x) (x)
+#define W_ERROR_V(x) (x)
+#endif
+
+#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
+#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y))
+
+#define W_ERROR_HAVE_NO_MEMORY(x) do { \
+ if (!(x)) {\
+ return WERR_NOMEM;\
+ }\
+} while (0)
+
+#define W_ERROR_IS_OK_RETURN(x) do { \
+ if (W_ERROR_IS_OK(x)) {\
+ return x;\
+ }\
+} while (0)
+
+#define W_ERROR_NOT_OK_RETURN(x) do { \
+ if (!W_ERROR_IS_OK(x)) {\
+ return x;\
+ }\
+} while (0)
+
+/* these are win32 error codes. There are only a few places where
+ these matter for Samba, primarily in the NT printing code */
+#define WERR_OK W_ERROR(0)
+#define WERR_BADFUNC W_ERROR(1)
+#define WERR_BADFILE W_ERROR(2)
+#define WERR_ACCESS_DENIED W_ERROR(5)
+#define WERR_BADFID W_ERROR(6)
+#define WERR_NOMEM W_ERROR(8)
+#define WERR_GENERAL_FAILURE W_ERROR(31)
+#define WERR_NOT_SUPPORTED W_ERROR(50)
+#define WERR_BAD_NETPATH W_ERROR(53)
+#define WERR_BAD_NET_RESP W_ERROR(58)
+#define WERR_UNEXP_NET_ERR W_ERROR(59)
+#define WERR_PRINTQ_FULL W_ERROR(61)
+#define WERR_NO_SPOOL_SPACE W_ERROR(62)
+#define WERR_NO_SUCH_SHARE W_ERROR(67)
+#define WERR_FILE_EXISTS W_ERROR(80)
+#define WERR_BAD_PASSWORD W_ERROR(86)
+#define WERR_INVALID_PARAM W_ERROR(87)
+#define WERR_INSUFFICIENT_BUFFER W_ERROR(122)
+#define WERR_INVALID_NAME W_ERROR(123)
+#define WERR_UNKNOWN_LEVEL W_ERROR(124)
+#define WERR_OBJECT_PATH_INVALID W_ERROR(161)
+#define WERR_ALREADY_EXISTS W_ERROR(183)
+#define WERR_NO_MORE_ITEMS W_ERROR(259)
+#define WERR_MORE_DATA W_ERROR(234)
+#define WERR_CAN_NOT_COMPLETE W_ERROR(1003)
+#define WERR_NOT_FOUND W_ERROR(1168)
+#define WERR_INVALID_COMPUTERNAME W_ERROR(1210)
+#define WERR_INVALID_DOMAINNAME W_ERROR(1212)
+#define WERR_UNKNOWN_REVISION W_ERROR(1305)
+#define WERR_REVISION_MISMATCH W_ERROR(1306)
+#define WERR_INVALID_OWNER W_ERROR(1307)
+#define WERR_NO_LOGON_SERVERS W_ERROR(1311)
+#define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313)
+#define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314)
+#define WERR_NO_SUCH_USER W_ERROR(1317)
+#define WERR_LOGON_FAILURE W_ERROR(1326)
+#define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338)
+#define WERR_INVALID_DOMAIN_ROLE W_ERROR(1354)
+#define WERR_NO_SUCH_DOMAIN W_ERROR(1355)
+#define WERR_NO_SYSTEM_RESOURCES W_ERROR(1450)
+#define WERR_SERVER_UNAVAILABLE W_ERROR(1722)
+#define WERR_INVALID_FORM_NAME W_ERROR(1902)
+#define WERR_INVALID_FORM_SIZE W_ERROR(1903)
+#define WERR_ALREADY_SHARED W_ERROR(2118)
+#define WERR_BUF_TOO_SMALL W_ERROR(2123)
+#define WERR_JOB_NOT_FOUND W_ERROR(2151)
+#define WERR_DEST_NOT_FOUND W_ERROR(2152)
+#define WERR_SESSION_NOT_FOUND W_ERROR(2312)
+#define WERR_FID_NOT_FOUND W_ERROR(2314)
+#define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320)
+#define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453)
+#define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319)
+#define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105)
+
+#define WERR_PRINTER_DRIVER_ALREADY_INSTALLED W_ERROR(ERRdriveralreadyinstalled)
+#define WERR_UNKNOWN_PORT W_ERROR(ERRunknownprinterport)
+#define WERR_UNKNOWN_PRINTER_DRIVER W_ERROR(ERRunknownprinterdriver)
+#define WERR_UNKNOWN_PRINTPROCESSOR W_ERROR(ERRunknownprintprocessor)
+#define WERR_INVALID_SEPARATOR_FILE W_ERROR(ERRinvalidseparatorfile)
+#define WERR_INVALID_PRIORITY W_ERROR(ERRinvalidjobpriority)
+#define WERR_INVALID_PRINTER_NAME W_ERROR(ERRinvalidprintername)
+#define WERR_PRINTER_ALREADY_EXISTS W_ERROR(ERRprinteralreadyexists)
+#define WERR_INVALID_PRINTER_COMMAND W_ERROR(ERRinvalidprintercommand)
+#define WERR_INVALID_DATATYPE W_ERROR(ERRinvaliddatatype)
+#define WERR_INVALID_ENVIRONMENT W_ERROR(ERRinvalidenvironment)
+
+#define WERR_UNKNOWN_PRINT_MONITOR W_ERROR(ERRunknownprintmonitor)
+#define WERR_PRINTER_DRIVER_IN_USE W_ERROR(ERRprinterdriverinuse)
+#define WERR_SPOOL_FILE_NOT_FOUND W_ERROR(ERRspoolfilenotfound)
+#define WERR_SPL_NO_STARTDOC W_ERROR(ERRnostartdoc)
+#define WERR_SPL_NO_ADDJOB W_ERROR(ERRnoaddjob)
+#define WERR_PRINT_PROCESSOR_ALREADY_INSTALLED W_ERROR(ERRprintprocessoralreadyinstalled)
+#define WERR_PRINT_MONITOR_ALREADY_INSTALLED W_ERROR(ERRprintmonitoralreadyinstalled)
+#define WERR_INVALID_PRINT_MONITOR W_ERROR(ERRinvalidprintmonitor)
+#define WERR_PRINT_MONITOR_IN_USE W_ERROR(ERRprintmonitorinuse)
+#define WERR_PRINTER_HAS_JOBS_QUEUED W_ERROR(ERRprinterhasjobsqueued)
+
+#define WERR_CLASS_NOT_REGISTERED W_ERROR(0x40154)
+#define WERR_NO_SHUTDOWN_IN_PROGRESS W_ERROR(0x45c)
+#define WERR_SHUTDOWN_ALREADY_IN_PROGRESS W_ERROR(0x45b)
+
+#define WERR_NET_NAME_NOT_FOUND W_ERROR(NERR_BASE+210)
+#define WERR_DEVICE_NOT_SHARED W_ERROR(NERR_BASE+211)
+
+/* DFS errors */
+#define WERR_DFS_NO_SUCH_VOL W_ERROR(NERR_BASE+562)
+#define WERR_DFS_NO_SUCH_SHARE W_ERROR(NERR_BASE+565)
+#define WERR_DFS_NO_SUCH_SERVER W_ERROR(NERR_BASE+573)
+#define WERR_DFS_INTERNAL_ERROR W_ERROR(NERR_BASE+590)
+#define WERR_DFS_CANT_CREATE_JUNCT W_ERROR(NERR_BASE+569)
+
+/* DS errors */
+#define WERR_DS_SERVICE_BUSY W_ERROR(0x0000200e)
+#define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f)
+#define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030)
+#define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d)
+#define WERR_DS_SCHEMA_NOT_LOADED W_ERROR(0x20de)
+#define WERR_DS_SCHEMA_ALLOC_FAILED W_ERROR(0x20df)
+#define WERR_DS_ATT_SCHEMA_REQ_SYNTAX W_ERROR(0x000020e0)
+#define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020e2)
+#define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5)
+#define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7)
+#define WERR_DS_DRA_BAD_NC W_ERROR(0x000020f8)
+#define WERR_DS_DRA_INTERNAL_ERROR W_ERROR(0x000020fa)
+#define WERR_DS_DRA_OUT_OF_MEM W_ERROR(0x000020fe)
+#define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081)
+#define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103)
+#define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104)
+#define WERR_DS_DRA_ACCESS_DENIED W_ERROR(0x00002105)
+#define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c)
+#define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150)
+#define WERR_DS_NO_MSDS_INTID W_ERROR(0x00002194)
+#define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195)
+
+/* SEC errors */
+#define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329)
+#define WERR_SEC_E_DECRYPT_FAILURE W_ERROR(0x80090330)
+#define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331)
+
+#define WERR_FOOBAR WERR_GENERAL_FAILURE
+
+/*****************************************************************************
+ returns a windows error message. not amazingly helpful, but better than a number.
+ *****************************************************************************/
+const char *win_errstr(WERROR werror);
+
+
+
+#endif
diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c
index 5b2a9e1e4a..90714f774b 100644
--- a/source4/libcli/wrepl/winsrepl.c
+++ b/source4/libcli/wrepl/winsrepl.c
@@ -37,7 +37,7 @@ static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, N
*/
static void wrepl_socket_dead(struct wrepl_socket *wrepl_socket, NTSTATUS status)
{
- wrepl_socket->dead = True;
+ wrepl_socket->dead = true;
if (wrepl_socket->packet) {
packet_recv_disable(wrepl_socket->packet);
@@ -148,7 +148,7 @@ static void wrepl_error(void *private, NTSTATUS status)
static int wrepl_socket_destructor(struct wrepl_socket *sock)
{
if (sock->dead) {
- sock->free_skipped = True;
+ sock->free_skipped = true;
return -1;
}
wrepl_socket_dead(sock, NT_STATUS_LOCAL_DISCONNECT);
@@ -387,7 +387,7 @@ static void wrepl_request_trigger_handler(struct event_context *ev, struct timed
/*
trigger an immediate event on a wrepl_request
the return value should only be used in wrepl_request_send()
- this is the only place where req->trigger is True
+ this is the only place where req->trigger is true
*/
static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, NTSTATUS status)
{
@@ -406,7 +406,7 @@ static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, N
req->status = status;
if (req->trigger) {
- req->trigger = False;
+ req->trigger = false;
/* a zero timeout means immediate */
te = event_add_timed(req->wrepl_socket->event.ctx,
req, timeval_zero(),
@@ -448,7 +448,7 @@ static int wrepl_send_ctrl_destructor(struct wrepl_send_ctrl_state *s)
/* here, we need to make sure the async request handler is called
* later in the next event_loop and now now
*/
- req->trigger = True;
+ req->trigger = true;
wrepl_request_finished(req, NT_STATUS_OK);
if (s->ctrl.disconnect_after_send) {
@@ -473,7 +473,7 @@ struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket,
if (!req) return NULL;
req->wrepl_socket = wrepl_socket;
req->state = WREPL_REQUEST_RECV;
- req->trigger = True;
+ req->trigger = true;
DLIST_ADD_END(wrepl_socket->recv_queue, req, struct wrepl_request *);
talloc_set_destructor(req, wrepl_request_destructor);
@@ -516,7 +516,7 @@ struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket,
return wrepl_request_finished(req, req->status);
}
- req->trigger = False;
+ req->trigger = false;
return req;
}
@@ -638,8 +638,8 @@ struct wrepl_request *wrepl_associate_stop_send(struct wrepl_socket *wrepl_socke
ZERO_STRUCT(ctrl);
if (io->in.reason == 0) {
- ctrl.send_only = True;
- ctrl.disconnect_after_send = True;
+ ctrl.send_only = true;
+ ctrl.disconnect_after_send = true;
}
req = wrepl_request_send(wrepl_socket, packet, &ctrl);
diff --git a/source4/libcli/wrepl/winsrepl.h b/source4/libcli/wrepl/winsrepl.h
index 3265024407..8ce8b418a2 100644
--- a/source4/libcli/wrepl/winsrepl.h
+++ b/source4/libcli/wrepl/winsrepl.h
@@ -120,7 +120,7 @@ struct wrepl_pull_table {
#define WREPL_NAME_TYPE(flags) (flags & WREPL_FLAGS_RECORD_TYPE)
#define WREPL_NAME_STATE(flags) ((flags & WREPL_FLAGS_RECORD_STATE)>>2)
#define WREPL_NAME_NODE(flags) ((flags & WREPL_FLAGS_NODE_TYPE)>>5)
-#define WREPL_NAME_IS_STATIC(flags) ((flags & WREPL_FLAGS_IS_STATIC)?True:False)
+#define WREPL_NAME_IS_STATIC(flags) ((flags & WREPL_FLAGS_IS_STATIC)?true:false)
#define WREPL_NAME_FLAGS(type, state, node, is_static) \
(type | (state << 2) | (node << 5) | \
diff --git a/source4/libnet/config.mk b/source4/libnet/config.mk
index a4cbedb515..ef0c7ff6ca 100644
--- a/source4/libnet/config.mk
+++ b/source4/libnet/config.mk
@@ -28,6 +28,7 @@ OBJ_FILES = \
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 LIBSAMBA3 LIBCLI_CLDAP LIBCLI_FINDDCS gensec_schannel
PRIVATE_DEPENDENCIES = CREDENTIALS_KRB5
diff --git a/source4/libnet/groupman.c b/source4/libnet/groupman.c
new file mode 100644
index 0000000000..de0ae0af94
--- /dev/null
+++ b/source4/libnet/groupman.c
@@ -0,0 +1,138 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) Rafal Szczesniak 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/>.
+*/
+
+/*
+ a composite function for manipulating (add/edit/del) groups via samr pipe
+*/
+
+#include "includes.h"
+#include "libcli/composite/composite.h"
+#include "libnet/composite.h"
+#include "libnet/groupman.h"
+#include "librpc/gen_ndr/ndr_samr_c.h"
+
+
+struct groupadd_state {
+ struct dcerpc_pipe *pipe;
+ struct policy_handle domain_handle;
+ struct samr_CreateDomainGroup creategroup;
+ struct policy_handle group_handle;
+ uint32_t group_rid;
+
+ void (*monitor_fn)(struct monitor_msg*);
+};
+
+
+static void continue_groupadd_created(struct rpc_request *req);
+
+
+struct composite_context* libnet_rpc_groupadd_send(struct dcerpc_pipe *p,
+ struct libnet_rpc_groupadd *io,
+ void (*monitor)(struct monitor_msg*))
+{
+ struct composite_context *c;
+ struct groupadd_state *s;
+ struct rpc_request *create_req;
+
+ if (!p || !io) return NULL;
+
+ c = composite_create(p, dcerpc_event_context(p));
+ if (c == NULL) return NULL;
+
+ s = talloc_zero(c, struct groupadd_state);
+ if (composite_nomem(s, c)) return c;
+
+ c->private_data = s;
+
+ s->domain_handle = io->in.domain_handle;
+ s->pipe = p;
+ s->monitor_fn = monitor;
+
+ s->creategroup.in.domain_handle = &s->domain_handle;
+
+ s->creategroup.in.name = talloc_zero(c, struct lsa_String);
+ if (composite_nomem(s->creategroup.in.name, c)) return c;
+
+ s->creategroup.in.name->string = talloc_strdup(c, io->in.groupname);
+ if (composite_nomem(s->creategroup.in.name->string, c)) return c;
+
+ s->creategroup.in.access_mask = 0;
+
+ s->creategroup.out.group_handle = &s->group_handle;
+ s->creategroup.out.rid = &s->group_rid;
+
+ create_req = dcerpc_samr_CreateDomainGroup_send(s->pipe, c, &s->creategroup);
+ if (composite_nomem(create_req, c)) return c;
+
+ composite_continue_rpc(c, create_req, continue_groupadd_created, c);
+ return c;
+}
+
+
+NTSTATUS libnet_rpc_groupadd_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+ struct libnet_rpc_groupadd *io)
+{
+ NTSTATUS status;
+ struct groupadd_state *s;
+
+ status = composite_wait(c);
+ if (NT_STATUS_IS_OK(status)) {
+ s = talloc_get_type(c, struct groupadd_state);
+ }
+
+ return status;
+}
+
+
+static void continue_groupadd_created(struct rpc_request *req)
+{
+ struct composite_context *c;
+ struct groupadd_state *s;
+
+ c = talloc_get_type(req->async.private_data, struct composite_context);
+ s = talloc_get_type(c->private_data, struct groupadd_state);
+
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
+
+ c->status = s->creategroup.out.result;
+ if (!composite_is_ok(c)) return;
+
+ if (s->monitor_fn) {
+ struct monitor_msg msg;
+
+ msg.type = mon_SamrCreateUser;
+ msg.data = NULL;
+ msg.data_size = 0;
+
+ s->monitor_fn(&msg);
+ }
+
+ composite_done(c);
+}
+
+
+NTSTATUS libnet_rpc_groupadd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct libnet_rpc_groupadd *io)
+{
+ struct composite_context *c;
+
+ c = libnet_rpc_groupadd_send(p, io, NULL);
+ return libnet_rpc_groupadd_recv(c, mem_ctx, io);
+}
diff --git a/source4/libnet/groupman.h b/source4/libnet/groupman.h
new file mode 100644
index 0000000000..0acb02de5a
--- /dev/null
+++ b/source4/libnet/groupman.h
@@ -0,0 +1,35 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) Rafal Szczesniak 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 "librpc/gen_ndr/misc.h"
+
+
+/*
+ * IO structures for groupman.c functions
+ */
+
+struct libnet_rpc_groupadd {
+ struct {
+ struct policy_handle domain_handle;
+ const char *groupname;
+ } in;
+ struct {
+ struct policy_handle group_handle;
+ } out;
+};
diff --git a/source4/libnet/libnet.c b/source4/libnet/libnet.c
index a628a07a99..86804df1ea 100644
--- a/source4/libnet/libnet.c
+++ b/source4/libnet/libnet.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "libnet/libnet.h"
#include "lib/events/events.h"
+#include "param/param.h"
struct libnet_context *libnet_context_init(struct event_context *ev)
{
@@ -42,7 +43,7 @@ struct libnet_context *libnet_context_init(struct event_context *ev)
ctx->event_ctx = ev;
/* name resolution methods */
- ctx->name_res_methods = str_list_copy(ctx, lp_name_resolve_order());
+ ctx->name_res_methods = str_list_copy(ctx, lp_name_resolve_order(global_loadparm));
/* connected services' params */
ZERO_STRUCT(ctx->samr);
diff --git a/source4/libnet/libnet.h b/source4/libnet/libnet.h
index a51fa613a8..56a7d0ba20 100644
--- a/source4/libnet/libnet.h
+++ b/source4/libnet/libnet.h
@@ -18,6 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "librpc/gen_ndr/misc.h"
+
struct libnet_context {
/* here we need:
* a client env context
@@ -56,6 +58,7 @@ struct libnet_context {
#include "libnet/userman.h"
#include "libnet/userinfo.h"
#include "libnet/groupinfo.h"
+#include "libnet/groupman.h"
#include "libnet/libnet_passwd.h"
#include "libnet/libnet_time.h"
#include "libnet/libnet_rpc.h"
diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c
index e2f4f03c60..cd782066db 100644
--- a/source4/libnet/libnet_become_dc.c
+++ b/source4/libnet/libnet_become_dc.c
@@ -32,6 +32,7 @@
#include "librpc/gen_ndr/ndr_security.h"
#include "librpc/gen_ndr/ndr_drsuapi.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
/*****************************************************************************
* Windows 2003 (w2k3) does the following steps when changing the server role
@@ -789,7 +790,7 @@ static NTSTATUS becomeDC_ldap_connect(struct libnet_BecomeDC_state *s, struct be
url = talloc_asprintf(s, "ldap://%s/", s->source_dsa.dns_name);
NT_STATUS_HAVE_NO_MEMORY(url);
- ldap->ldb = ldb_wrap_connect(s, url,
+ ldap->ldb = ldb_wrap_connect(s, global_loadparm, url,
NULL,
s->libnet->cred,
0, NULL);
@@ -1510,7 +1511,7 @@ static void becomeDC_drsuapi_connect_send(struct libnet_BecomeDC_state *s,
drsuapi->s = s;
if (!drsuapi->binding) {
- if (lp_parm_bool(-1, "become_dc", "print", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "become_dc", "print", false)) {
binding_str = talloc_asprintf(s, "ncacn_ip_tcp:%s[krb5,print,seal]", s->source_dsa.dns_name);
if (composite_nomem(binding_str, c)) return;
} else {
@@ -2909,7 +2910,7 @@ struct composite_context *libnet_BecomeDC_send(struct libnet_context *ctx, TALLO
/* Destination DSA dns_name construction */
tmp_name = strlower_talloc(s, s->dest_dsa.netbios_name);
if (composite_nomem(tmp_name, c)) return c;
- tmp_name = talloc_asprintf_append(tmp_name, ".%s",s->domain.dns_name);
+ tmp_name = talloc_asprintf_append_buffer(tmp_name, ".%s",s->domain.dns_name);
if (composite_nomem(tmp_name, c)) return c;
s->dest_dsa.dns_name = tmp_name;
diff --git a/source4/libnet/libnet_group.c b/source4/libnet/libnet_group.c
index 50615f3946..39e5e7a4f9 100644
--- a/source4/libnet/libnet_group.c
+++ b/source4/libnet/libnet_group.c
@@ -57,7 +57,7 @@ struct composite_context* libnet_GroupInfo_send(struct libnet_context *ctx,
{
struct composite_context *c;
struct group_info_state *s;
- BOOL prereq_met = False;
+ bool prereq_met = false;
struct composite_context *lookup_req;
/* composite context allocation and setup */
diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c
index 40debc63dc..4abd2954f8 100644
--- a/source4/libnet/libnet_join.c
+++ b/source4/libnet/libnet_join.c
@@ -31,6 +31,7 @@
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
#include "librpc/gen_ndr/ndr_samr_c.h"
+#include "param/param.h"
/*
* complete a domain join, when joining to a AD domain:
@@ -227,7 +228,8 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
return NT_STATUS_NO_MEMORY;
}
- remote_ldb = ldb_wrap_connect(tmp_ctx, remote_ldb_url,
+ remote_ldb = ldb_wrap_connect(tmp_ctx, global_loadparm,
+ remote_ldb_url,
NULL, ctx->cred, 0, NULL);
if (!remote_ldb) {
r->out.error_string = NULL;
@@ -534,8 +536,8 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru
connect_with_info->out.domain_name = talloc_strdup(tmp_ctx, r->in.domain_name);
} else {
/* Bugger, we just lost our way to automaticly find the domain name */
- connect_with_info->out.domain_name = talloc_strdup(tmp_ctx, lp_workgroup());
- connect_with_info->out.realm = talloc_strdup(tmp_ctx, lp_realm());
+ connect_with_info->out.domain_name = talloc_strdup(tmp_ctx, lp_workgroup(global_loadparm));
+ connect_with_info->out.realm = talloc_strdup(tmp_ctx, lp_realm(global_loadparm));
}
}
@@ -887,7 +889,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
if (r->in.netbios_name != NULL) {
netbios_name = r->in.netbios_name;
} else {
- netbios_name = talloc_reference(tmp_mem, lp_netbios_name());
+ netbios_name = talloc_reference(tmp_mem, lp_netbios_name(global_loadparm));
if (!netbios_name) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
@@ -924,7 +926,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
r2->in.netbios_name = netbios_name;
r2->in.level = LIBNET_JOINDOMAIN_AUTOMATIC;
r2->in.acct_type = acct_type;
- r2->in.recreate_account = False;
+ 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);
diff --git a/source4/libnet/libnet_lookup.c b/source4/libnet/libnet_lookup.c
index 6856156734..459e5b1985 100644
--- a/source4/libnet/libnet_lookup.c
+++ b/source4/libnet/libnet_lookup.c
@@ -34,6 +34,8 @@
#include "librpc/gen_ndr/lsa.h"
#include "librpc/gen_ndr/ndr_lsa_c.h"
+#include "param/param.h"
+
struct lookup_state {
struct nbt_name hostname;
const char *address;
@@ -189,7 +191,8 @@ struct composite_context* libnet_LookupDCs_send(struct libnet_context *ctx,
struct libnet_LookupDCs *io)
{
struct composite_context *c;
- struct messaging_context *msg_ctx = messaging_client_init(mem_ctx, ctx->event_ctx);
+ struct messaging_context *msg_ctx =
+ messaging_client_init(mem_ctx, lp_messaging_path(mem_ctx, global_loadparm), ctx->event_ctx);
c = finddcs_send(mem_ctx, io->in.domain_name, io->in.name_type,
NULL, ctx->name_res_methods, ctx->event_ctx, msg_ctx);
@@ -257,7 +260,7 @@ struct composite_context* libnet_LookupName_send(struct libnet_context *ctx,
struct composite_context *c;
struct lookup_name_state *s;
struct rpc_request *lookup_req;
- BOOL prereq_met = False;
+ bool prereq_met = false;
c = composite_create(mem_ctx, ctx->event_ctx);
if (c == NULL) return NULL;
diff --git a/source4/libnet/libnet_samdump.c b/source4/libnet/libnet_samdump.c
index fb4267748a..5c7266d7a8 100644
--- a/source4/libnet/libnet_samdump.c
+++ b/source4/libnet/libnet_samdump.c
@@ -110,7 +110,7 @@ static NTSTATUS libnet_samdump_fn(TALLOC_CTX *mem_ctx,
char **error_string)
{
NTSTATUS nt_status = NT_STATUS_OK;
- struct samdump_state *samdump_state = private;
+ struct samdump_state *samdump_state = (struct samdump_state *)private;
*error_string = NULL;
switch (delta->delta_type) {
@@ -144,7 +144,8 @@ static NTSTATUS libnet_samdump_fn(TALLOC_CTX *mem_ctx,
return nt_status;
}
-NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_SamDump *r)
+NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
+ struct libnet_SamDump *r)
{
NTSTATUS nt_status;
struct libnet_SamSync r2;
@@ -162,7 +163,7 @@ NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct
r2.out.error_string = NULL;
r2.in.binding_string = r->in.binding_string;
- r2.in.rid_crypt = lp_parm_bool(-1, "vampire", "rid decrypt", True);
+ r2.in.rid_crypt = lp_parm_bool(global_loadparm, NULL, "vampire", "rid decrypt", true);
r2.in.init_fn = NULL;
r2.in.delta_fn = libnet_samdump_fn;
r2.in.fn_ctx = samdump_state;
diff --git a/source4/libnet/libnet_samdump_keytab.c b/source4/libnet/libnet_samdump_keytab.c
index 0eae9de039..c235df6d25 100644
--- a/source4/libnet/libnet_samdump_keytab.c
+++ b/source4/libnet/libnet_samdump_keytab.c
@@ -25,6 +25,7 @@
#include "system/kerberos.h"
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
+#include "param/param.h"
static NTSTATUS samdump_keytab_handle_user(TALLOC_CTX *mem_ctx,
const char *keytab_name,
@@ -44,7 +45,7 @@ static NTSTATUS samdump_keytab_handle_user(TALLOC_CTX *mem_ctx,
if (!credentials) {
return NT_STATUS_NO_MEMORY;
}
- cli_credentials_set_conf(credentials);
+ cli_credentials_set_conf(credentials, global_loadparm);
cli_credentials_set_username(credentials, username, CRED_SPECIFIED);
/* We really should consult ldap in the main SamSync code, and
diff --git a/source4/libnet/libnet_samsync_ldb.c b/source4/libnet/libnet_samsync_ldb.c
index 338b15d6d7..bdc3341aa6 100644
--- a/source4/libnet/libnet_samsync_ldb.c
+++ b/source4/libnet/libnet_samsync_ldb.c
@@ -31,6 +31,7 @@
#include "db_wrap.h"
#include "libcli/security/security.h"
#include "librpc/rpc/dcerpc.h"
+#include "param/param.h"
struct samsync_ldb_secret {
struct samsync_ldb_secret *prev, *next;
@@ -246,7 +247,7 @@ static NTSTATUS samsync_ldb_handle_user(TALLOC_CTX *mem_ctx,
struct ldb_message **remote_msgs = NULL;
int ret, i;
uint32_t acb;
- BOOL add = False;
+ bool add = false;
const char *attrs[] = { NULL };
/* we may change this to a global search, then fill in only the things not in ldap later */
const char *remote_attrs[] = { "userPrincipalName", "servicePrincipalName",
@@ -274,7 +275,7 @@ static NTSTATUS samsync_ldb_handle_user(TALLOC_CTX *mem_ctx,
ldb_errstring(state->sam_ldb));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
} else if (ret == 0) {
- add = True;
+ add = true;
} else if (ret > 1) {
*error_string = talloc_asprintf(mem_ctx, "More than one user with SID: %s in local LDB",
dom_sid_string(mem_ctx, user_sid));
@@ -431,14 +432,21 @@ static NTSTATUS samsync_ldb_handle_user(TALLOC_CTX *mem_ctx,
if (ret != 0) {
struct ldb_dn *first_try_dn = msg->dn;
/* Try again with the default DN */
- msg->dn = talloc_steal(msg, msgs[0]->dn);
- ret = samdb_add(state->sam_ldb, mem_ctx, msg);
- if (ret != 0) {
- *error_string = talloc_asprintf(mem_ctx, "Failed to create user record. Tried both %s and %s: %s",
+ if (!remote_msgs) {
+ *error_string = talloc_asprintf(mem_ctx, "Failed to create user record. Tried %s: %s",
ldb_dn_get_linearized(first_try_dn),
- ldb_dn_get_linearized(msg->dn),
ldb_errstring(state->sam_ldb));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ } else {
+ msg->dn = talloc_steal(msg, remote_msgs[0]->dn);
+ ret = samdb_add(state->sam_ldb, mem_ctx, msg);
+ if (ret != 0) {
+ *error_string = talloc_asprintf(mem_ctx, "Failed to create user record. Tried both %s and %s: %s",
+ ldb_dn_get_linearized(first_try_dn),
+ ldb_dn_get_linearized(msg->dn),
+ ldb_errstring(state->sam_ldb));
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
}
}
} else {
@@ -509,7 +517,7 @@ static NTSTATUS samsync_ldb_handle_group(TALLOC_CTX *mem_ctx,
struct ldb_message *msg;
struct ldb_message **msgs;
int ret;
- BOOL add = False;
+ bool add = false;
const char *attrs[] = { NULL };
msg = ldb_msg_new(mem_ctx);
@@ -526,7 +534,7 @@ static NTSTATUS samsync_ldb_handle_group(TALLOC_CTX *mem_ctx,
*error_string = talloc_asprintf(mem_ctx, "gendb_search failed: %s", ldb_errstring(state->sam_ldb));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
} else if (ret == 0) {
- add = True;
+ add = true;
} else if (ret > 1) {
*error_string = talloc_asprintf(mem_ctx, "More than one group/alias with SID: %s",
dom_sid_string(mem_ctx,
@@ -721,7 +729,7 @@ static NTSTATUS samsync_ldb_handle_alias(TALLOC_CTX *mem_ctx,
struct ldb_message *msg;
struct ldb_message **msgs;
int ret;
- BOOL add = False;
+ bool add = false;
const char *attrs[] = { NULL };
msg = ldb_msg_new(mem_ctx);
@@ -738,7 +746,7 @@ static NTSTATUS samsync_ldb_handle_alias(TALLOC_CTX *mem_ctx,
*error_string = talloc_asprintf(mem_ctx, "gendb_search failed: %s", ldb_errstring(state->sam_ldb));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
} else if (ret == 0) {
- add = True;
+ add = true;
} else if (ret > 1) {
*error_string = talloc_asprintf(mem_ctx, "More than one group/alias with SID: %s",
dom_sid_string(mem_ctx,
@@ -1183,7 +1191,9 @@ 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, ldap_url,
+ state->remote_ldb = ldb_wrap_connect(mem_ctx,
+ global_loadparm,
+ ldap_url,
NULL, state->samsync_state->machine_net_ctx->cred,
0, NULL);
if (!state->remote_ldb) {
@@ -1209,7 +1219,10 @@ NTSTATUS libnet_samsync_ldb(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, str
state->secrets = NULL;
state->trusted_domains = NULL;
- state->sam_ldb = ldb_wrap_connect(mem_ctx, lp_sam_url(), r->in.session_info,
+ state->sam_ldb = ldb_wrap_connect(mem_ctx,
+ global_loadparm,
+ lp_sam_url(global_loadparm),
+ r->in.session_info,
ctx->cred, 0, NULL);
r2.out.error_string = NULL;
diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c
index 6b63ebc839..40b1aab215 100644
--- a/source4/libnet/libnet_unbecome_dc.c
+++ b/source4/libnet/libnet_unbecome_dc.c
@@ -27,6 +27,7 @@
#include "dsdb/samdb/samdb.h"
#include "dsdb/common/flags.h"
#include "librpc/gen_ndr/ndr_drsuapi_c.h"
+#include "param/param.h"
/*****************************************************************************
* Windows 2003 (w2k3) does the following steps when changing the server role
@@ -307,7 +308,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, url,
+ s->ldap.ldb = ldb_wrap_connect(s, global_loadparm, url,
NULL,
s->libnet->cred,
0, NULL);
@@ -698,7 +699,7 @@ struct composite_context *libnet_UnbecomeDC_send(struct libnet_context *ctx, TAL
/* Destination DSA dns_name construction */
tmp_name = strlower_talloc(s, s->dest_dsa.netbios_name);
if (composite_nomem(tmp_name, c)) return c;
- s->dest_dsa.dns_name = talloc_asprintf_append(tmp_name, ".%s",
+ s->dest_dsa.dns_name = talloc_asprintf_append_buffer(tmp_name, ".%s",
s->domain.dns_name);
if (composite_nomem(s->dest_dsa.dns_name, c)) return c;
diff --git a/source4/libnet/libnet_user.c b/source4/libnet/libnet_user.c
index fe303620fe..75fd8f2000 100644
--- a/source4/libnet/libnet_user.c
+++ b/source4/libnet/libnet_user.c
@@ -1,7 +1,7 @@
/*
Unix SMB/CIFS implementation.
- Copyright (C) Rafal Szczesniak <mimir@samba.org> 2005
+ Copyright (C) Rafal Szczesniak 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
@@ -62,7 +62,7 @@ struct composite_context* libnet_CreateUser_send(struct libnet_context *ctx,
struct composite_context *c;
struct create_user_state *s;
struct composite_context *create_req;
- BOOL prereq_met = False;
+ bool prereq_met = false;
/* composite context allocation and setup */
c = composite_create(mem_ctx, ctx->event_ctx);
@@ -231,7 +231,7 @@ struct composite_context *libnet_DeleteUser_send(struct libnet_context *ctx,
struct composite_context *c;
struct delete_user_state *s;
struct composite_context *delete_req;
- BOOL prereq_met = False;
+ bool prereq_met = false;
/* composite context allocation and setup */
c = composite_create(mem_ctx, ctx->event_ctx);
@@ -402,7 +402,7 @@ struct composite_context *libnet_ModifyUser_send(struct libnet_context *ctx,
struct composite_context *c;
struct modify_user_state *s;
struct composite_context *userinfo_req;
- BOOL prereq_met = False;
+ bool prereq_met = false;
c = composite_create(mem_ctx, ctx->event_ctx);
if (c == NULL) return NULL;
@@ -533,6 +533,9 @@ static NTSTATUS set_user_changes(TALLOC_CTX *mem_ctx, struct usermod_change *mod
/* account expiry change */
SET_FIELD_NTTIME(r->in, user, mod, acct_expiry, USERMOD_FIELD_ACCT_EXPIRY);
+ /* account flags change */
+ SET_FIELD_UINT32(r->in, user, mod, acct_flags, USERMOD_FIELD_ACCT_FLAGS);
+
return NT_STATUS_OK;
}
@@ -626,7 +629,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;
- BOOL prereq_met = False;
+ bool prereq_met = false;
/* composite context allocation and setup */
c = composite_create(mem_ctx, ctx->event_ctx);
@@ -875,7 +878,7 @@ struct composite_context* libnet_UserList_send(struct libnet_context *ctx,
struct composite_context *c;
struct userlist_state *s;
struct rpc_request *query_req;
- BOOL prereq_met = False;
+ bool prereq_met = false;
/* composite context allocation and setup */
c = composite_create(mem_ctx, ctx->event_ctx);
@@ -949,7 +952,7 @@ static void continue_domain_queried(struct rpc_request *req)
struct composite_context *c;
struct userlist_state *s;
struct rpc_request *enum_req;
- BOOL prereq_met = False;
+ bool prereq_met = false;
c = talloc_get_type(req->async.private_data, struct composite_context);
s = talloc_get_type(c->private_data, struct userlist_state);
diff --git a/source4/libnet/libnet_user.h b/source4/libnet/libnet_user.h
index 3bbe1cc65e..ece06f08fc 100644
--- a/source4/libnet/libnet_user.h
+++ b/source4/libnet/libnet_user.h
@@ -85,6 +85,12 @@ struct libnet_ModifyUser {
} \
}
+#define SET_FIELD_UINT32(new, current, mod, field, flag) \
+ if (current->field != new.field) { \
+ mod->field = new.field; \
+ mod->fields |= flag; \
+ }
+
struct libnet_UserInfo {
struct {
diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c
index e21976cb02..dff915df71 100644
--- a/source4/libnet/libnet_vampire.c
+++ b/source4/libnet/libnet_vampire.c
@@ -28,6 +28,7 @@
#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"
/**
@@ -80,7 +81,7 @@ static NTSTATUS fix_user(TALLOC_CTX *mem_ctx,
} else {
user->lmpassword = keys.keys.keys2.lmpassword.pwd;
}
- user->lm_password_present = True;
+ user->lm_password_present = true;
}
if (keys.keys.keys2.ntpassword.length == 16) {
if (rid_crypt) {
@@ -89,7 +90,7 @@ static NTSTATUS fix_user(TALLOC_CTX *mem_ctx,
} else {
user->ntpassword = keys.keys.keys2.ntpassword.pwd;
}
- user->nt_password_present = True;
+ user->nt_password_present = true;
}
/* TODO: rid decrypt history fields */
} else {
@@ -184,7 +185,7 @@ NTSTATUS libnet_SamSync_netlogon(struct libnet_context *ctx, TALLOC_CTX *mem_ctx
talloc_free(samsync_ctx);
return NT_STATUS_NO_MEMORY;
}
- cli_credentials_set_conf(machine_account);
+ cli_credentials_set_conf(machine_account, global_loadparm);
nt_status = cli_credentials_set_machine_account(machine_account);
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?");
diff --git a/source4/libnet/prereq_domain.c b/source4/libnet/prereq_domain.c
index 52f8dcf112..e10e550585 100644
--- a/source4/libnet/prereq_domain.c
+++ b/source4/libnet/prereq_domain.c
@@ -29,7 +29,7 @@
#include "librpc/gen_ndr/ndr_lsa.h"
-BOOL samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
+bool samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
struct composite_context **parent_ctx,
struct libnet_DomainOpen *domain_open,
void (*continue_fn)(struct composite_context*),
@@ -37,7 +37,7 @@ BOOL samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
{
struct composite_context *domopen_req;
- if (parent_ctx == NULL || *parent_ctx == NULL) return False;
+ if (parent_ctx == NULL || *parent_ctx == NULL) return false;
if (domain_name == NULL) {
/*
@@ -52,7 +52,7 @@ BOOL samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
} else {
composite_error(*parent_ctx, NT_STATUS_INVALID_PARAMETER);
- return True;
+ return true;
}
} else {
@@ -71,20 +71,20 @@ BOOL samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
} else {
/* domain has already been opened and it's the same domain
as requested */
- return True;
+ return true;
}
}
/* send request to open the domain */
domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);
- if (composite_nomem(domopen_req, *parent_ctx)) return False;
+ if (composite_nomem(domopen_req, *parent_ctx)) return false;
composite_continue(*parent_ctx, domopen_req, continue_fn, *parent_ctx);
- return False;
+ return false;
}
-BOOL lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
+bool lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
struct composite_context **parent_ctx,
struct libnet_DomainOpen *domain_open,
void (*continue_fn)(struct composite_context*),
@@ -92,7 +92,7 @@ BOOL lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
{
struct composite_context *domopen_req;
- if (parent_ctx == NULL || *parent_ctx == NULL) return False;
+ if (parent_ctx == NULL || *parent_ctx == NULL) return false;
if (domain_name == NULL) {
/*
@@ -109,7 +109,7 @@ BOOL lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
composite_error(*parent_ctx, NT_STATUS_INVALID_PARAMETER);
/* this ensures the calling function exits and composite function error
gets noticed quickly */
- return True;
+ return true;
}
} else {
@@ -128,15 +128,15 @@ BOOL lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
} else {
/* domain has already been opened and it's the same domain
as requested */
- return True;
+ return true;
}
}
/* send request to open the domain */
domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);
/* see the comment above to find out why true is returned here */
- if (composite_nomem(domopen_req, *parent_ctx)) return True;
+ if (composite_nomem(domopen_req, *parent_ctx)) return true;
composite_continue(*parent_ctx, domopen_req, continue_fn, *parent_ctx);
- return False;
+ return false;
}
diff --git a/source4/libnet/userman.c b/source4/libnet/userman.c
index 2efb892155..25ed4775cb 100644
--- a/source4/libnet/userman.c
+++ b/source4/libnet/userman.c
@@ -32,12 +32,7 @@
* Composite USER ADD functionality
*/
-static void useradd_handler(struct rpc_request*);
-
-enum useradd_stage { USERADD_CREATE };
-
struct useradd_state {
- enum useradd_stage stage;
struct dcerpc_pipe *pipe;
struct rpc_request *req;
struct policy_handle domain_handle;
@@ -50,64 +45,46 @@ struct useradd_state {
};
+static void continue_useradd_create(struct rpc_request *req);
+
+
/**
* Stage 1 (and the only one for now): Create user account.
*/
-static NTSTATUS useradd_create(struct composite_context *c,
- struct useradd_state *s)
+static void continue_useradd_create(struct rpc_request *req)
{
+ struct composite_context *c;
+ struct useradd_state *s;
+
+ c = talloc_get_type(req->async.private_data, struct composite_context);
+ s = talloc_get_type(c->private_data, struct useradd_state);
+
+ /* check rpc layer status code */
c->status = dcerpc_ndr_request_recv(s->req);
- NT_STATUS_NOT_OK_RETURN(c->status);
+ if (!composite_is_ok(c)) return;
- /* return the actual function call status */
+ /* check create user call status code */
c->status = s->createuser.out.result;
-
- c->state = COMPOSITE_STATE_DONE;
- return c->status;
-}
+ /* get created user account data */
+ s->user_handle = *s->createuser.out.user_handle;
+ s->user_rid = *s->createuser.out.rid;
-/**
- * Event handler for asynchronous request. Handles transition through
- * intermediate stages of the call.
- *
- * @param req rpc call context
- */
-static void useradd_handler(struct rpc_request *req)
-{
- struct composite_context *c = req->async.private_data;
- struct useradd_state *s = talloc_get_type(c->private_data, struct useradd_state);
- struct monitor_msg msg;
- struct msg_rpc_create_user *rpc_create;
-
- switch (s->stage) {
- case USERADD_CREATE:
- c->status = useradd_create(c, s);
-
- /* prepare a message to pass to monitor function */
- msg.type = mon_SamrCreateUser;
- rpc_create = talloc(s, struct msg_rpc_create_user);
- rpc_create->rid = *s->createuser.out.rid;
- msg.data = (void*)rpc_create;
- msg.data_size = sizeof(*rpc_create);
- break;
- }
+ /* issue a monitor message */
+ if (s->monitor_fn) {
+ struct monitor_msg msg;
+ struct msg_rpc_create_user rpc_create;
- /* are we ok so far ? */
- if (!NT_STATUS_IS_OK(c->status)) {
- c->state = COMPOSITE_STATE_ERROR;
- }
+ rpc_create.rid = *s->createuser.out.rid;
- /* call monitor function provided the pointer has been passed */
- if (s->monitor_fn) {
+ msg.type = mon_SamrCreateUser;
+ msg.data = (void*)&rpc_create;
+ msg.data_size = sizeof(rpc_create);
+
s->monitor_fn(&msg);
}
-
- /* are we done yet ? */
- if (c->state >= COMPOSITE_STATE_DONE &&
- c->async.fn) {
- c->async.fn(c);
- }
+
+ composite_done(c);
}
@@ -158,11 +135,7 @@ struct composite_context *libnet_rpc_useradd_send(struct dcerpc_pipe *p,
s->req = dcerpc_samr_CreateUser_send(p, c, &s->createuser);
if (composite_nomem(s->req, c)) return c;
- /* callback handler for continuation */
- s->req->async.callback = useradd_handler;
- s->req->async.private_data = c;
- s->stage = USERADD_CREATE;
-
+ composite_continue_rpc(c, s->req, continue_useradd_create, c);
return c;
}
@@ -218,14 +191,9 @@ NTSTATUS libnet_rpc_useradd(struct dcerpc_pipe *p,
* Composite USER DELETE functionality
*/
-static void userdel_handler(struct rpc_request*);
-
-enum userdel_stage { USERDEL_LOOKUP, USERDEL_OPEN, USERDEL_DELETE };
struct userdel_state {
- enum userdel_stage stage;
struct dcerpc_pipe *pipe;
- struct rpc_request *req;
struct policy_handle domain_handle;
struct policy_handle user_handle;
struct samr_LookupNames lookupname;
@@ -237,166 +205,155 @@ struct userdel_state {
};
+static void continue_userdel_name_found(struct rpc_request *req);
+static void continue_userdel_user_opened(struct rpc_request* req);
+static void continue_userdel_deleted(struct rpc_request *req);
+
+
/**
* Stage 1: Lookup the user name and resolve it to rid
*/
-static NTSTATUS userdel_lookup(struct composite_context *c,
- struct userdel_state *s)
+static void continue_userdel_name_found(struct rpc_request *req)
{
- /* receive samr_LookupNames result */
- c->status = dcerpc_ndr_request_recv(s->req);
+ struct composite_context *c;
+ struct userdel_state *s;
+ struct rpc_request *openuser_req;
+ struct monitor_msg msg;
- /* check rpc layer status */
- NT_STATUS_NOT_OK_RETURN(c->status);
+ c = talloc_get_type(req->async.private_data, struct composite_context);
+ s = talloc_get_type(c->private_data, struct userdel_state);
- /* check the call itself status */
- NT_STATUS_NOT_OK_RETURN(s->lookupname.out.result);
+ /* receive samr_LookupNames result */
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
+
+ c->status = s->lookupname.out.result;
+ if (!NT_STATUS_IS_OK(c->status)) {
+ composite_error(c, c->status);
+ return;
+ }
/* what to do when there's no user account to delete
and what if there's more than one rid resolved */
if (!s->lookupname.out.rids.count) {
c->status = NT_STATUS_NO_SUCH_USER;
composite_error(c, c->status);
+ return;
} else if (!s->lookupname.out.rids.count > 1) {
c->status = NT_STATUS_INVALID_ACCOUNT_NAME;
composite_error(c, c->status);
+ return;
}
- /* prepare the next rpc call arguments */
+ /* issue a monitor message */
+ if (s->monitor_fn) {
+ struct msg_rpc_lookup_name msg_lookup;
+
+ msg_lookup.rid = s->lookupname.out.rids.ids;
+ msg_lookup.count = s->lookupname.out.rids.count;
+
+ msg.type = mon_SamrLookupName;
+ msg.data = (void*)&msg_lookup;
+ msg.data_size = sizeof(msg_lookup);
+ s->monitor_fn(&msg);
+ }
+
+ /* prepare the arguments for rpc call */
s->openuser.in.domain_handle = &s->domain_handle;
s->openuser.in.rid = s->lookupname.out.rids.ids[0];
s->openuser.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
s->openuser.out.user_handle = &s->user_handle;
/* send rpc request */
- s->req = dcerpc_samr_OpenUser_send(s->pipe, c, &s->openuser);
- if (s->req == NULL) return NT_STATUS_NO_MEMORY;
+ openuser_req = dcerpc_samr_OpenUser_send(s->pipe, c, &s->openuser);
+ if (composite_nomem(openuser_req, c)) return;
- /* callback handler setup */
- s->req->async.callback = userdel_handler;
- s->req->async.private_data = c;
- s->stage = USERDEL_OPEN;
-
- return NT_STATUS_OK;
+ composite_continue_rpc(c, openuser_req, continue_userdel_user_opened, c);
}
/**
* Stage 2: Open user account.
*/
-static NTSTATUS userdel_open(struct composite_context *c,
- struct userdel_state *s)
+static void continue_userdel_user_opened(struct rpc_request* req)
{
+ struct composite_context *c;
+ struct userdel_state *s;
+ struct rpc_request *deluser_req;
+ struct monitor_msg msg;
+
+ c = talloc_get_type(req->async.private_data, struct composite_context);
+ s = talloc_get_type(c->private_data, struct userdel_state);
+
/* receive samr_OpenUser result */
- c->status = dcerpc_ndr_request_recv(s->req);
- NT_STATUS_NOT_OK_RETURN(c->status);
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
+
+ c->status = s->openuser.out.result;
+ if (!NT_STATUS_IS_OK(c->status)) {
+ composite_error(c, c->status);
+ return;
+ }
+
+ /* issue a monitor message */
+ if (s->monitor_fn) {
+ struct msg_rpc_open_user msg_open;
+
+ msg_open.rid = s->openuser.in.rid;
+ msg_open.access_mask = s->openuser.in.access_mask;
+
+ msg.type = mon_SamrOpenUser;
+ msg.data = (void*)&msg_open;
+ msg.data_size = sizeof(msg_open);
+ s->monitor_fn(&msg);
+ }
/* prepare the final rpc call arguments */
s->deleteuser.in.user_handle = &s->user_handle;
s->deleteuser.out.user_handle = &s->user_handle;
/* send rpc request */
- s->req = dcerpc_samr_DeleteUser_send(s->pipe, c, &s->deleteuser);
- if (s->req == NULL) return NT_STATUS_NO_MEMORY;
+ deluser_req = dcerpc_samr_DeleteUser_send(s->pipe, c, &s->deleteuser);
+ if (composite_nomem(deluser_req, c)) return;
/* callback handler setup */
- s->req->async.callback = userdel_handler;
- s->req->async.private_data = c;
- s->stage = USERDEL_DELETE;
-
- return NT_STATUS_OK;
+ composite_continue_rpc(c, deluser_req, continue_userdel_deleted, c);
}
/**
* Stage 3: Delete user account
*/
-static NTSTATUS userdel_delete(struct composite_context *c,
- struct userdel_state *s)
-{
- /* receive samr_DeleteUser result */
- c->status = dcerpc_ndr_request_recv(s->req);
- NT_STATUS_NOT_OK_RETURN(c->status);
-
- /* return the actual function call status */
- c->status = s->deleteuser.out.result;
-
- c->state = COMPOSITE_STATE_DONE;
-
- return c->status;
-}
-
-
-/**
- * Event handler for asynchronous request. Handles transition through
- * intermediate stages of the call.
- *
- * @param req rpc call context
- */
-static void userdel_handler(struct rpc_request *req)
+static void continue_userdel_deleted(struct rpc_request *req)
{
struct composite_context *c;
struct userdel_state *s;
struct monitor_msg msg;
- struct msg_rpc_lookup_name *msg_lookup;
- struct msg_rpc_open_user *msg_open;
c = talloc_get_type(req->async.private_data, struct composite_context);
s = talloc_get_type(c->private_data, struct userdel_state);
-
- switch (s->stage) {
- case USERDEL_LOOKUP:
- c->status = userdel_lookup(c, s);
-
- /* monitor message */
- msg.type = mon_SamrLookupName;
- msg_lookup = talloc(s, struct msg_rpc_lookup_name);
-
- msg_lookup->rid = s->lookupname.out.rids.ids;
- msg_lookup->count = s->lookupname.out.rids.count;
- msg.data = (void*)msg_lookup;
- msg.data_size = sizeof(*msg_lookup);
- break;
-
- case USERDEL_OPEN:
- c->status = userdel_open(c, s);
-
- /* monitor message */
- msg.type = mon_SamrOpenUser;
- msg_open = talloc(s, struct msg_rpc_open_user);
-
- msg_open->rid = s->openuser.in.rid;
- msg_open->access_mask = s->openuser.in.rid;
- msg.data = (void*)msg_open;
- msg.data_size = sizeof(*msg_open);
- break;
-
- case USERDEL_DELETE:
- c->status = userdel_delete(c, s);
-
- /* monitor message */
- msg.type = mon_SamrDeleteUser;
- msg.data = NULL;
- msg.data_size = 0;
- break;
- }
- /* are we ok, so far ? */
+ /* receive samr_DeleteUser result */
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
+
+ /* return the actual function call status */
+ c->status = s->deleteuser.out.result;
if (!NT_STATUS_IS_OK(c->status)) {
- c->state = COMPOSITE_STATE_ERROR;
+ composite_error(c, c->status);
+ return;
}
-
- /* call monitor function provided the pointer has been passed */
+
+ /* issue a monitor message */
if (s->monitor_fn) {
+ msg.type = mon_SamrDeleteUser;
+ msg.data = NULL;
+ msg.data_size = 0;
s->monitor_fn(&msg);
}
- /* are we done yet */
- if (c->state >= COMPOSITE_STATE_DONE &&
- c->async.fn) {
- c->async.fn(c);
- }
+ composite_done(c);
}
@@ -414,17 +371,16 @@ struct composite_context *libnet_rpc_userdel_send(struct dcerpc_pipe *p,
{
struct composite_context *c;
struct userdel_state *s;
+ struct rpc_request *lookup_req;
/* composite context allocation and setup */
- c = talloc_zero(p, struct composite_context);
+ c = composite_create(p, dcerpc_event_context(p));
if (c == NULL) return NULL;
s = talloc_zero(c, struct userdel_state);
if (composite_nomem(s, c)) return c;
- c->state = COMPOSITE_STATE_IN_PROGRESS;
c->private_data = s;
- c->event_ctx = dcerpc_event_context(p);
/* store function parameters in the state structure */
s->pipe = p;
@@ -438,13 +394,11 @@ struct composite_context *libnet_rpc_userdel_send(struct dcerpc_pipe *p,
s->lookupname.in.names->string = io->in.username;
/* send the request */
- s->req = dcerpc_samr_LookupNames_send(p, c, &s->lookupname);
-
- /* callback handler setup */
- s->req->async.callback = userdel_handler;
- s->req->async.private_data = c;
- s->stage = USERDEL_LOOKUP;
+ lookup_req = dcerpc_samr_LookupNames_send(p, c, &s->lookupname);
+ if (composite_nomem(lookup_req, c)) return c;
+ /* set the next stage */
+ composite_continue_rpc(c, lookup_req, continue_userdel_name_found, c);
return c;
}
@@ -498,14 +452,14 @@ NTSTATUS libnet_rpc_userdel(struct dcerpc_pipe *p,
* USER MODIFY functionality
*/
-static void usermod_handler(struct rpc_request*);
+static void continue_usermod_name_found(struct rpc_request *req);
+static void continue_usermod_user_opened(struct rpc_request *req);
+static void continue_usermod_user_queried(struct rpc_request *req);
+static void continue_usermod_user_changed(struct rpc_request *req);
-enum usermod_stage { USERMOD_LOOKUP, USERMOD_OPEN, USERMOD_QUERY, USERMOD_MODIFY };
struct usermod_state {
- enum usermod_stage stage;
struct dcerpc_pipe *pipe;
- struct rpc_request *req;
struct policy_handle domain_handle;
struct policy_handle user_handle;
struct usermod_change change;
@@ -523,24 +477,50 @@ struct usermod_state {
/**
* Step 1: Lookup user name
*/
-static NTSTATUS usermod_lookup(struct composite_context *c,
- struct usermod_state *s)
+static void continue_usermod_name_found(struct rpc_request *req)
{
+ struct composite_context *c;
+ struct usermod_state *s;
+ struct rpc_request *openuser_req;
+ struct monitor_msg msg;
+
+ c = talloc_get_type(req->async.private_data, struct composite_context);
+ s = talloc_get_type(c->private_data, struct usermod_state);
+
/* receive samr_LookupNames result */
- c->status = dcerpc_ndr_request_recv(s->req);
- NT_STATUS_NOT_OK_RETURN(c->status);
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
+
+ c->status = s->lookupname.out.result;
+ if (!NT_STATUS_IS_OK(c->status)) {
+ composite_error(c, c->status);
+ return;
+ }
/* what to do when there's no user account to delete
and what if there's more than one rid resolved */
if (!s->lookupname.out.rids.count) {
c->status = NT_STATUS_NO_SUCH_USER;
- c->state = COMPOSITE_STATE_ERROR;
- return c->status;
+ composite_error(c, c->status);
+ return;
} else if (!s->lookupname.out.rids.count > 1) {
c->status = NT_STATUS_INVALID_ACCOUNT_NAME;
- c->state = COMPOSITE_STATE_ERROR;
- return c->status;
+ composite_error(c, c->status);
+ return;
+ }
+
+ /* issue a monitor message */
+ if (s->monitor_fn) {
+ struct msg_rpc_lookup_name msg_lookup;
+
+ msg_lookup.rid = s->lookupname.out.rids.ids;
+ msg_lookup.count = s->lookupname.out.rids.count;
+
+ msg.type = mon_SamrLookupName;
+ msg.data = (void*)&msg_lookup;
+ msg.data_size = sizeof(msg_lookup);
+ s->monitor_fn(&msg);
}
/* prepare the next rpc call */
@@ -550,14 +530,10 @@ static NTSTATUS usermod_lookup(struct composite_context *c,
s->openuser.out.user_handle = &s->user_handle;
/* send the rpc request */
- s->req = dcerpc_samr_OpenUser_send(s->pipe, c, &s->openuser);
+ openuser_req = dcerpc_samr_OpenUser_send(s->pipe, c, &s->openuser);
+ if (composite_nomem(openuser_req, c)) return;
- /* callback handler setup */
- s->req->async.callback = usermod_handler;
- s->req->async.private_data = c;
- s->stage = USERMOD_OPEN;
-
- return NT_STATUS_OK;
+ composite_continue_rpc(c, openuser_req, continue_usermod_user_opened, c);
}
@@ -567,8 +543,8 @@ static NTSTATUS usermod_lookup(struct composite_context *c,
* function are made until there's no flags set meaning that all of the
* changes have been made.
*/
-static uint32_t usermod_setfields(struct usermod_state *s, uint16_t *level,
- union samr_UserInfo *i)
+static bool usermod_setfields(struct usermod_state *s, uint16_t *level,
+ union samr_UserInfo *i, bool queried)
{
if (s->change.fields == 0) return s->change.fields;
@@ -602,15 +578,14 @@ static uint32_t usermod_setfields(struct usermod_state *s, uint16_t *level,
(*level == 0 || *level == 2)) {
*level = 2;
- if (s->stage == USERMOD_QUERY) {
+ if (queried) {
/* the user info is obtained, so now set the required field */
i->info2.comment.string = s->change.comment;
s->change.fields ^= USERMOD_FIELD_COMMENT;
} else {
/* we need to query the user info before setting one field in it */
- s->stage = USERMOD_QUERY;
- return s->change.fields;
+ return false;
}
}
@@ -634,12 +609,11 @@ static uint32_t usermod_setfields(struct usermod_state *s, uint16_t *level,
(*level == 0 || *level == 10)) {
*level = 10;
- if (s->stage == USERMOD_QUERY) {
+ if (queried) {
i->info10.home_directory.string = s->change.home_directory;
s->change.fields ^= USERMOD_FIELD_HOME_DIRECTORY;
} else {
- s->stage = USERMOD_QUERY;
- return s->change.fields;
+ return false;
}
}
@@ -647,12 +621,11 @@ static uint32_t usermod_setfields(struct usermod_state *s, uint16_t *level,
(*level == 0 || *level == 10)) {
*level = 10;
- if (s->stage == USERMOD_QUERY) {
+ if (queried) {
i->info10.home_drive.string = s->change.home_drive;
s->change.fields ^= USERMOD_FIELD_HOME_DRIVE;
} else {
- s->stage = USERMOD_QUERY;
- return s->change.fields;
+ return false;
}
}
@@ -673,19 +646,15 @@ static uint32_t usermod_setfields(struct usermod_state *s, uint16_t *level,
}
/* We're going to be here back again soon unless all fields have been set */
- if (s->change.fields) {
- s->stage = USERMOD_OPEN;
- } else {
- s->stage = USERMOD_MODIFY;
- }
-
- return s->change.fields;
+ return true;
}
static NTSTATUS usermod_change(struct composite_context *c,
struct usermod_state *s)
{
+ struct rpc_request *query_req, *setuser_req;
+ bool do_set;
union samr_UserInfo *i = &s->info;
/* set the level to invalid value, so that unless setfields routine
@@ -693,12 +662,11 @@ static NTSTATUS usermod_change(struct composite_context *c,
uint16_t level = 27;
/* prepare UserInfo level and data based on bitmask field */
- s->change.fields = usermod_setfields(s, &level, i);
+ do_set = usermod_setfields(s, &level, i, false);
if (level < 1 || level > 26) {
/* apparently there's a field that the setfields routine
does not know how to set */
- c->state = COMPOSITE_STATE_ERROR;
return NT_STATUS_INVALID_PARAMETER;
}
@@ -707,13 +675,14 @@ static NTSTATUS usermod_change(struct composite_context *c,
first, right before changing the data. Otherwise we could set required
fields and accidentally reset the others.
*/
- if (s->stage == USERMOD_QUERY) {
+ if (!do_set) {
s->queryuser.in.user_handle = &s->user_handle;
s->queryuser.in.level = level;
/* send query user info request to retrieve complete data of
a particular info level */
- s->req = dcerpc_samr_QueryUserInfo_send(s->pipe, c, &s->queryuser);
+ query_req = dcerpc_samr_QueryUserInfo_send(s->pipe, c, &s->queryuser);
+ composite_continue_rpc(c, query_req, continue_usermod_user_queried, c);
} else {
s->setuser.in.user_handle = &s->user_handle;
@@ -721,13 +690,10 @@ static NTSTATUS usermod_change(struct composite_context *c,
s->setuser.in.info = i;
/* send set user info request after making required change */
- s->req = dcerpc_samr_SetUserInfo_send(s->pipe, c, &s->setuser);
+ setuser_req = dcerpc_samr_SetUserInfo_send(s->pipe, c, &s->setuser);
+ composite_continue_rpc(c, setuser_req, continue_usermod_user_changed, c);
}
-
- /* callback handler setup */
- s->req->async.callback = usermod_handler;
- s->req->async.private_data = c;
-
+
return NT_STATUS_OK;
}
@@ -735,34 +701,58 @@ static NTSTATUS usermod_change(struct composite_context *c,
/**
* Stage 2: Open user account
*/
-static NTSTATUS usermod_open(struct composite_context *c,
- struct usermod_state *s)
+static void continue_usermod_user_opened(struct rpc_request *req)
{
- c->status = dcerpc_ndr_request_recv(s->req);
- NT_STATUS_NOT_OK_RETURN(c->status);
-
- return usermod_change(c, s);
+ struct composite_context *c;
+ struct usermod_state *s;
+
+ c = talloc_get_type(req->async.private_data, struct composite_context);
+ s = talloc_get_type(c->private_data, struct usermod_state);
+
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
+
+ c->status = s->openuser.out.result;
+ if (!NT_STATUS_IS_OK(c->status)) {
+ composite_error(c, c->status);
+ return;
+ }
+
+ c->status = usermod_change(c, s);
}
/**
* Stage 2a (optional): Query the user information
*/
-static NTSTATUS usermod_query(struct composite_context *c,
- struct usermod_state *s)
+static void continue_usermod_user_queried(struct rpc_request *req)
{
- union samr_UserInfo *i = &s->info;
+ struct composite_context *c;
+ struct usermod_state *s;
+ union samr_UserInfo *i;
uint16_t level;
+ struct rpc_request *setuser_req;
+
+ c = talloc_get_type(req->async.private_data, struct composite_context);
+ s = talloc_get_type(c->private_data, struct usermod_state);
+
+ i = &s->info;
/* receive samr_QueryUserInfo result */
- c->status = dcerpc_ndr_request_recv(s->req);
- NT_STATUS_NOT_OK_RETURN(c->status);
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
+
+ c->status = s->queryuser.out.result;
+ if (!NT_STATUS_IS_OK(c->status)) {
+ composite_error(c, c->status);
+ return;
+ }
/* get returned user data and make a change (potentially one
of many) */
s->info = *s->queryuser.out.info;
- s->change.fields = usermod_setfields(s, &level, i);
+ usermod_setfields(s, &level, i, true);
/* prepare rpc call arguments */
s->setuser.in.user_handle = &s->user_handle;
@@ -770,127 +760,40 @@ static NTSTATUS usermod_query(struct composite_context *c,
s->setuser.in.info = i;
/* send the rpc request */
- s->req = dcerpc_samr_SetUserInfo_send(s->pipe, c, &s->setuser);
-
- /* callback handler setup */
- s->req->async.callback = usermod_handler;
- s->req->async.private_data = c;
-
- return NT_STATUS_OK;
+ setuser_req = dcerpc_samr_SetUserInfo_send(s->pipe, c, &s->setuser);
+ composite_continue_rpc(c, setuser_req, continue_usermod_user_changed, c);
}
/**
* Stage 3: Set new user account data
*/
-static NTSTATUS usermod_modify(struct composite_context *c,
- struct usermod_state *s)
-{
- /* receive samr_SetUserInfo result */
- c->status = dcerpc_ndr_request_recv(s->req);
- NT_STATUS_NOT_OK_RETURN(c->status);
-
- /* return the actual function call status */
- c->status = s->setuser.out.result;
-
- if (s->change.fields == 0) {
- /* all fields have been set - we're done */
- c->state = COMPOSITE_STATE_DONE;
- } else {
- /* something's still not changed - repeat the procedure */
- return usermod_change(c, s);
- }
-
- return c->status;
-}
-
-
-/**
- * Event handler for asynchronous request. Handles transition through
- * intermediate stages of the call.
- *
- * @param req rpc call context
- */
-
-static void usermod_handler(struct rpc_request *req)
+static void continue_usermod_user_changed(struct rpc_request *req)
{
struct composite_context *c;
struct usermod_state *s;
- struct monitor_msg msg;
- struct msg_rpc_lookup_name *msg_lookup;
- struct msg_rpc_open_user *msg_open;
-
+
c = talloc_get_type(req->async.private_data, struct composite_context);
s = talloc_get_type(c->private_data, struct usermod_state);
- switch (s->stage) {
- case USERMOD_LOOKUP:
- c->status = usermod_lookup(c, s);
-
- if (NT_STATUS_IS_OK(c->status)) {
- /* monitor message */
- msg.type = mon_SamrLookupName;
- msg_lookup = talloc(s, struct msg_rpc_lookup_name);
-
- msg_lookup->rid = s->lookupname.out.rids.ids;
- msg_lookup->count = s->lookupname.out.rids.count;
- msg.data = (void*)msg_lookup;
- msg.data_size = sizeof(*msg_lookup);
- }
- break;
-
- case USERMOD_OPEN:
- c->status = usermod_open(c, s);
-
- if (NT_STATUS_IS_OK(c->status)) {
- /* monitor message */
- msg.type = mon_SamrOpenUser;
- msg_open = talloc(s, struct msg_rpc_open_user);
-
- msg_open->rid = s->openuser.in.rid;
- msg_open->access_mask = s->openuser.in.rid;
- msg.data = (void*)msg_open;
- msg.data_size = sizeof(*msg_open);
- }
- break;
-
- case USERMOD_QUERY:
- c->status = usermod_query(c, s);
-
- if (NT_STATUS_IS_OK(c->status)) {
- /* monitor message */
- msg.type = mon_SamrQueryUser;
- msg.data = NULL;
- msg.data_size = 0;
- }
- break;
-
- case USERMOD_MODIFY:
- c->status = usermod_modify(c, s);
-
- if (NT_STATUS_IS_OK(c->status)) {
- /* monitor message */
- msg.type = mon_SamrSetUser;
- msg.data = NULL;
- msg.data_size = 0;
- }
- break;
- }
+ /* receive samr_SetUserInfo result */
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
- /* are we ok, so far ? */
+ /* return the actual function call status */
+ c->status = s->setuser.out.result;
if (!NT_STATUS_IS_OK(c->status)) {
- c->state = COMPOSITE_STATE_ERROR;
+ composite_error(c, c->status);
+ return;
}
- /* call monitor function provided the pointer has been passed */
- if (s->monitor_fn) {
- s->monitor_fn(&msg);
- }
+ if (s->change.fields == 0) {
+ /* all fields have been set - we're done */
+ composite_done(c);
- /* are we done yet ? */
- if (c->state >= COMPOSITE_STATE_DONE &&
- c->async.fn) {
- c->async.fn(c);
+ } else {
+ /* something's still not changed - repeat the procedure */
+ c->status = usermod_change(c, s);
}
}
@@ -909,17 +812,15 @@ struct composite_context *libnet_rpc_usermod_send(struct dcerpc_pipe *p,
{
struct composite_context *c;
struct usermod_state *s;
+ struct rpc_request *lookup_req;
/* composite context allocation and setup */
- c = talloc_zero(p, struct composite_context);
+ c = composite_create(p, dcerpc_event_context(p));
if (c == NULL) return NULL;
-
s = talloc_zero(c, struct usermod_state);
if (composite_nomem(s, c)) return c;
- c->state = COMPOSITE_STATE_IN_PROGRESS;
c->private_data = s;
- c->event_ctx = dcerpc_event_context(p);
/* store parameters in the call structure */
s->pipe = p;
@@ -934,13 +835,11 @@ struct composite_context *libnet_rpc_usermod_send(struct dcerpc_pipe *p,
s->lookupname.in.names->string = io->in.username;
/* send the rpc request */
- s->req = dcerpc_samr_LookupNames_send(p, c, &s->lookupname);
+ lookup_req = dcerpc_samr_LookupNames_send(p, c, &s->lookupname);
+ if (composite_nomem(lookup_req, c)) return c;
/* callback handler setup */
- s->req->async.callback = usermod_handler;
- s->req->async.private_data = c;
- s->stage = USERMOD_LOOKUP;
-
+ composite_continue_rpc(c, lookup_req, continue_usermod_name_found, c);
return c;
}
diff --git a/source4/libnet/userman.h b/source4/libnet/userman.h
index b6302fe4ad..b681c25a16 100644
--- a/source4/libnet/userman.h
+++ b/source4/libnet/userman.h
@@ -17,6 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "librpc/gen_ndr/misc.h"
+
/*
* IO structures for userman.c functions
diff --git a/source4/librpc/idl/dcerpc.idl b/source4/librpc/idl/dcerpc.idl
index c864bd4b39..fcb0be4639 100644
--- a/source4/librpc/idl/dcerpc.idl
+++ b/source4/librpc/idl/dcerpc.idl
@@ -118,26 +118,34 @@ interface dcerpc
} dcerpc_fault;
/* the auth types we know about */
- const uint8 DCERPC_AUTH_TYPE_NONE = 0;
- /* this seems to be not krb5! */
- const uint8 DCERPC_AUTH_TYPE_KRB5_1 = 1;
- const uint8 DCERPC_AUTH_TYPE_SPNEGO = 9;
- const uint8 DCERPC_AUTH_TYPE_NTLMSSP = 10;
- const uint8 DCERPC_AUTH_TYPE_KRB5 = 16;
- const uint8 DCERPC_AUTH_TYPE_SCHANNEL = 68;
- const uint8 DCERPC_AUTH_TYPE_MSMQ = 100;
+ typedef [enum8bit] enum {
+ DCERPC_AUTH_TYPE_NONE = 0,
+ /* this seems to be not krb5! */
+ DCERPC_AUTH_TYPE_KRB5_1 = 1,
+ DCERPC_AUTH_TYPE_SPNEGO = 9,
+ DCERPC_AUTH_TYPE_NTLMSSP = 10,
+ DCERPC_AUTH_TYPE_KRB5 = 16,
+ DCERPC_AUTH_TYPE_DPA = 17,
+ DCERPC_AUTH_TYPE_MSN = 18,
+ DCERPC_AUTH_TYPE_DIGEST = 21,
+ DCERPC_AUTH_TYPE_SCHANNEL = 68,
+ DCERPC_AUTH_TYPE_MSMQ = 100
+ } dcerpc_AuthType;
+
+ typedef [enum8bit] enum {
+ DCERPC_AUTH_LEVEL_NONE = 1,
+ DCERPC_AUTH_LEVEL_CONNECT = 2,
+ DCERPC_AUTH_LEVEL_CALL = 3,
+ DCERPC_AUTH_LEVEL_PACKET = 4,
+ DCERPC_AUTH_LEVEL_INTEGRITY = 5,
+ DCERPC_AUTH_LEVEL_PRIVACY = 6
+ } dcerpc_AuthLevel;
const uint8 DCERPC_AUTH_LEVEL_DEFAULT = DCERPC_AUTH_LEVEL_CONNECT;
- const uint8 DCERPC_AUTH_LEVEL_NONE = 1;
- const uint8 DCERPC_AUTH_LEVEL_CONNECT = 2;
- const uint8 DCERPC_AUTH_LEVEL_CALL = 3;
- const uint8 DCERPC_AUTH_LEVEL_PACKET = 4;
- const uint8 DCERPC_AUTH_LEVEL_INTEGRITY = 5;
- const uint8 DCERPC_AUTH_LEVEL_PRIVACY = 6;
typedef [public] struct {
- uint8 auth_type;
- uint8 auth_level;
+ dcerpc_AuthType auth_type;
+ dcerpc_AuthLevel auth_level;
uint8 auth_pad_length;
uint8 auth_reserved;
uint32 auth_context_id;
diff --git a/source4/librpc/idl/dfs.idl b/source4/librpc/idl/dfs.idl
index 30da410a46..50c8a826df 100644
--- a/source4/librpc/idl/dfs.idl
+++ b/source4/librpc/idl/dfs.idl
@@ -2,6 +2,8 @@
dfs interface definition
*/
+import "misc.idl";
+
[ uuid("4fc742e0-4a10-11cf-8273-00aa004ae673"),
version(3.0),
pointer_default(unique),
diff --git a/source4/librpc/idl/dssetup.idl b/source4/librpc/idl/dssetup.idl
index 9c490aebe3..af6350cc43 100644
--- a/source4/librpc/idl/dssetup.idl
+++ b/source4/librpc/idl/dssetup.idl
@@ -2,6 +2,8 @@
dssetup interface definition
*/
+import "misc.idl";
+
[
uuid("3919286a-b10c-11d0-9ba8-00c04fd92ef5"),
version(0.0),
diff --git a/source4/librpc/idl/epmapper.idl b/source4/librpc/idl/epmapper.idl
index 5611c3de18..baf9f23877 100644
--- a/source4/librpc/idl/epmapper.idl
+++ b/source4/librpc/idl/epmapper.idl
@@ -8,6 +8,8 @@ http://www.opengroup.org/onlinepubs/9629399/chap6.htm#tagcjh_11_02_03_01: bindin
*/
+import "misc.idl";
+
[
uuid("e1af8308-5d1f-11c9-91a4-08002b14a0fa"),
version(3.0),
diff --git a/source4/librpc/idl/notify.idl b/source4/librpc/idl/notify.idl
index c4e633c254..6f9ad25f09 100644
--- a/source4/librpc/idl/notify.idl
+++ b/source4/librpc/idl/notify.idl
@@ -7,6 +7,8 @@
the change notify buffers
*/
+import "misc.idl";
+
[
pointer_default(unique)
]
diff --git a/source4/librpc/idl/orpc.idl b/source4/librpc/idl/orpc.idl
index c1faefd3b1..d023865035 100644
--- a/source4/librpc/idl/orpc.idl
+++ b/source4/librpc/idl/orpc.idl
@@ -5,6 +5,8 @@
http://www.ietf.org/internet-drafts/draft-brown-dcom-v1-spec-04.txt
*/
+import "misc.idl";
+
[
pointer_default(unique)
]
diff --git a/source4/librpc/idl/security.idl b/source4/librpc/idl/security.idl
index f05148aecc..753fad85cf 100644
--- a/source4/librpc/idl/security.idl
+++ b/source4/librpc/idl/security.idl
@@ -138,6 +138,8 @@ interface security
const string SID_NULL = "S-1-0-0";
/* the world domain */
+ const string NAME_WORLD = "WORLD";
+
const string SID_WORLD_DOMAIN = "S-1-1";
const string SID_WORLD = "S-1-1-0";
@@ -147,6 +149,8 @@ interface security
const string SID_CREATOR_GROUP = "S-1-3-1";
/* SECURITY_NT_AUTHORITY */
+ const string NAME_NT_AUTHORITY = "NT AUTHORITY";
+
const string SID_NT_AUTHORITY = "S-1-5";
const string SID_NT_DIALUP = "S-1-5-1";
const string SID_NT_NETWORK = "S-1-5-2";
@@ -167,6 +171,8 @@ interface security
const string SID_NT_NETWORK_SERVICE = "S-1-5-20";
/* SECURITY_BUILTIN_DOMAIN_RID */
+ const string NAME_BUILTIN = "BUILTIN";
+
const string SID_BUILTIN = "S-1-5-32";
const string SID_BUILTIN_ADMINISTRATORS = "S-1-5-32-544";
const string SID_BUILTIN_USERS = "S-1-5-32-545";
@@ -368,6 +374,10 @@ interface security
SECINFO_OWNER = 0x00000001,
SECINFO_GROUP = 0x00000002,
SECINFO_DACL = 0x00000004,
- SECINFO_SACL = 0x00000008
+ SECINFO_SACL = 0x00000008,
+ SECINFO_UNPROTECTED_SACL = 0x10000000,
+ SECINFO_UNPROTECTED_DACL = 0x20000000,
+ SECINFO_PROTECTED_SACL = 0x40000000,
+ SECINFO_PROTECTED_DACL = 0x80000000
} security_secinfo;
}
diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h
index 09a2680190..d110a25aeb 100644
--- a/source4/librpc/ndr/libndr.h
+++ b/source4/librpc/ndr/libndr.h
@@ -23,7 +23,7 @@
#include <talloc.h>
#include "lib/util/util.h" /* for discard_const */
#include "lib/charset/charset.h"
-#include "libcli/util/nt_status.h"
+#include "libcli/util/ntstatus.h"
/*
this provides definitions for the libcli/rpc/ MSRPC library
@@ -269,7 +269,7 @@ enum ndr_compression_alg {
#define NDR_PUSH_ALLOC_SIZE(ndr, s, size) do { \
- (s) = talloc_size(ndr, size); \
+ (s) = talloc_array(ndr, uint8_t, size); \
if (!(s)) return ndr_push_error(ndr, NDR_ERR_ALLOC, "push alloc %u failed: %s\n", (unsigned)size, __location__); \
} while (0)
@@ -285,6 +285,7 @@ typedef void (*ndr_print_fn_t)(struct ndr_print *, const char *, const void *);
typedef void (*ndr_print_function_t)(struct ndr_print *, const char *, int, const void *);
#include "librpc/gen_ndr/misc.h"
+#include "libcli/util/werror.h"
#include "librpc/ndr/libndr_proto.h"
extern const struct ndr_syntax_id ndr_transfer_syntax;
@@ -328,5 +329,7 @@ NTSTATUS ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const struct do
NTSTATUS 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);
+void ndr_print_ipv4_addr(struct ndr_print *ndr, const char *name, const struct ipv4_addr *_ip);
+void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid);
#endif /* __LIBNDR_H__ */
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c
index 9fb39beff3..1ee8d05975 100644
--- a/source4/librpc/ndr/ndr.c
+++ b/source4/librpc/ndr/ndr.c
@@ -200,13 +200,16 @@ _PUBLIC_ void ndr_print_string_helper(struct ndr_print *ndr, const char *format,
int i;
for (i=0;i<ndr->depth;i++) {
- ndr->private_data = talloc_asprintf_append(ndr->private_data, " ");
+ ndr->private_data = talloc_asprintf_append_buffer(
+ (char *)ndr->private_data, " ");
}
va_start(ap, format);
- ndr->private_data = talloc_vasprintf_append(ndr->private_data, format, ap);
+ ndr->private_data = talloc_vasprintf_append_buffer((char *)ndr->private_data,
+ format, ap);
va_end(ap);
- ndr->private_data = talloc_asprintf_append(ndr->private_data, "\n");
+ ndr->private_data = talloc_asprintf_append_buffer((char *)ndr->private_data,
+ "\n");
}
/*
@@ -276,7 +279,7 @@ _PUBLIC_ char *ndr_print_struct_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, c
ndr->depth = 1;
ndr->flags = 0;
fn(ndr, name, ptr);
- ret = talloc_steal(mem_ctx, ndr->private_data);
+ ret = talloc_steal(mem_ctx, (char *)ndr->private_data);
failed:
talloc_free(ndr);
return ret;
@@ -301,7 +304,7 @@ _PUBLIC_ char *ndr_print_union_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, co
ndr->flags = 0;
ndr_print_set_switch_value(ndr, ptr, level);
fn(ndr, name, ptr);
- ret = talloc_steal(mem_ctx, ndr->private_data);
+ ret = talloc_steal(mem_ctx, (char *)ndr->private_data);
failed:
talloc_free(ndr);
return ret;
@@ -327,7 +330,7 @@ _PUBLIC_ char *ndr_print_function_string(TALLOC_CTX *mem_ctx,
ndr->depth = 1;
ndr->flags = 0;
fn(ndr, name, flags, ptr);
- ret = talloc_steal(mem_ctx, ndr->private_data);
+ ret = talloc_steal(mem_ctx, (char *)ndr->private_data);
failed:
talloc_free(ndr);
return ret;
@@ -569,7 +572,7 @@ _PUBLIC_ NTSTATUS ndr_token_store(TALLOC_CTX *mem_ctx,
retrieve a token from a ndr context, using cmp_fn to match the tokens
*/
_PUBLIC_ NTSTATUS ndr_token_retrieve_cmp_fn(struct ndr_token_list **list, const void *key, uint32_t *v,
- comparison_fn_t _cmp_fn, BOOL _remove_tok)
+ comparison_fn_t _cmp_fn, bool _remove_tok)
{
struct ndr_token_list *tok;
for (tok=*list;tok;tok=tok->next) {
@@ -591,7 +594,7 @@ found:
*/
_PUBLIC_ NTSTATUS ndr_token_retrieve(struct ndr_token_list **list, const void *key, uint32_t *v)
{
- return ndr_token_retrieve_cmp_fn(list, key, v, NULL, True);
+ return ndr_token_retrieve_cmp_fn(list, key, v, NULL, true);
}
/*
@@ -601,7 +604,7 @@ _PUBLIC_ uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key)
{
NTSTATUS status;
uint32_t v;
- status = ndr_token_retrieve_cmp_fn(list, key, &v, NULL, False);
+ status = ndr_token_retrieve_cmp_fn(list, key, &v, NULL, false);
if (NT_STATUS_IS_OK(status)) return v;
return 0;
}
diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c
index 6b3b44109b..1d8cfec649 100644
--- a/source4/librpc/ndr/ndr_compression.c
+++ b/source4/librpc/ndr/ndr_compression.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "lib/compression/mszip.h"
#include "librpc/ndr/libndr.h"
+#include "librpc/ndr/ndr_compression.h"
static NTSTATUS ndr_pull_compression_mszip_chunk(struct ndr_pull *ndrpull,
struct ndr_push *ndrpush,
diff --git a/source4/librpc/ndr/ndr_drsuapi.c b/source4/librpc/ndr/ndr_drsuapi.c
index 6bd7d73cb8..689439c383 100644
--- a/source4/librpc/ndr/ndr_drsuapi.c
+++ b/source4/librpc/ndr/ndr_drsuapi.c
@@ -64,17 +64,17 @@ void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const ch
}
#define _OID_PUSH_CHECK(call) do { \
- BOOL _status; \
+ bool _status; \
_status = call; \
- if (_status != True) { \
+ if (_status != true) { \
return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \
} \
} while (0)
#define _OID_PULL_CHECK(call) do { \
- BOOL _status; \
+ bool _status; \
_status = call; \
- if (_status != True) { \
+ if (_status != true) { \
return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \
} \
} while (0)
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index fca864a5eb..b611f87a41 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -640,7 +640,7 @@ _PUBLIC_ uint32_t ndr_string_length(const void *_var, uint32_t element_size)
{
uint32_t i;
uint8_t zero[4] = {0,0,0,0};
- const char *var = _var;
+ const char *var = (const char *)_var;
for (i = 0; memcmp(var+i*element_size,zero,element_size) != 0; i++);
@@ -731,5 +731,5 @@ _PUBLIC_ uint32_t ndr_charset_length(const void *var, charset_t chset)
{
/* FIXME: Treat special chars special here, taking chset into account */
/* Also include 0 byte */
- return strlen(var)+1;
+ return strlen((const char *)var)+1;
}
diff --git a/source4/librpc/ndr/ndr_table.c b/source4/librpc/ndr/ndr_table.c
index 9b43f8836d..d73e82bb71 100644
--- a/source4/librpc/ndr/ndr_table.c
+++ b/source4/librpc/ndr/ndr_table.c
@@ -123,10 +123,10 @@ NTSTATUS ndr_table_register_builtin_tables(void);
NTSTATUS ndr_table_init(void)
{
- static BOOL initialized = False;
+ static bool initialized = false;
if (initialized) return NT_STATUS_OK;
- initialized = True;
+ initialized = true;
ndr_table_register_builtin_tables();
diff --git a/source4/librpc/ndr/uuid.c b/source4/librpc/ndr/uuid.c
index 8cf6ab5446..e92df22494 100644
--- a/source4/librpc/ndr/uuid.c
+++ b/source4/librpc/ndr/uuid.c
@@ -22,6 +22,7 @@
*/
#include "includes.h"
+#include "librpc/ndr/libndr.h"
/**
build a GUID from a string
@@ -132,7 +133,7 @@ _PUBLIC_ struct GUID GUID_zero(void)
return guid;
}
-_PUBLIC_ BOOL GUID_all_zero(const struct GUID *u)
+_PUBLIC_ bool GUID_all_zero(const struct GUID *u)
{
if (u->time_low != 0 ||
u->time_mid != 0 ||
@@ -140,12 +141,12 @@ _PUBLIC_ BOOL GUID_all_zero(const struct GUID *u)
u->clock_seq[0] != 0 ||
u->clock_seq[1] != 0 ||
!all_zero(u->node, 6)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-_PUBLIC_ BOOL GUID_equal(const struct GUID *u1, const struct GUID *u2)
+_PUBLIC_ bool GUID_equal(const struct GUID *u1, const struct GUID *u2)
{
if (u1->time_low != u2->time_low ||
u1->time_mid != u2->time_mid ||
@@ -153,9 +154,9 @@ _PUBLIC_ BOOL GUID_equal(const struct GUID *u1, const struct GUID *u2)
u1->clock_seq[0] != u2->clock_seq[0] ||
u1->clock_seq[1] != u2->clock_seq[1] ||
memcmp(u1->node, u2->node, 6) != 0) {
- return False;
+ return false;
}
- return True;
+ return true;
}
_PUBLIC_ int GUID_compare(const struct GUID *u1, const struct GUID *u2)
@@ -220,7 +221,7 @@ _PUBLIC_ char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid)
guid->node[4], guid->node[5]);
}
-_PUBLIC_ BOOL policy_handle_empty(struct policy_handle *h)
+_PUBLIC_ bool policy_handle_empty(struct policy_handle *h)
{
return (h->handle_type == 0 && GUID_all_zero(&h->uuid));
}
diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c
index 984cc20fbc..1f0cc3699a 100644
--- a/source4/librpc/rpc/dcerpc.c
+++ b/source4/librpc/rpc/dcerpc.c
@@ -43,7 +43,7 @@ static void dcerpc_ship_next_request(struct dcerpc_connection *c);
static int dcerpc_connection_destructor(struct dcerpc_connection *conn)
{
if (conn->dead) {
- conn->free_skipped = True;
+ conn->free_skipped = true;
return -1;
}
dcerpc_connection_dead(conn, NT_STATUS_LOCAL_DISCONNECT);
@@ -752,7 +752,7 @@ struct composite_context *dcerpc_bind_send(struct dcerpc_pipe *p,
talloc_set_destructor(req, dcerpc_req_dequeue);
c->status = p->conn->transport.send_request(p->conn, &blob,
- True);
+ true);
if (!composite_is_ok(c)) return c;
event_add_timed(c->event_ctx, req,
@@ -798,7 +798,7 @@ NTSTATUS dcerpc_auth3(struct dcerpc_connection *c,
}
/* send it on its way */
- status = c->transport.send_request(c, &blob, False);
+ status = c->transport.send_request(c, &blob, false);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -933,7 +933,7 @@ req_done:
static struct rpc_request *dcerpc_request_send(struct dcerpc_pipe *p,
const struct GUID *object,
uint16_t opnum,
- BOOL async,
+ bool async,
DATA_BLOB *stub_data)
{
struct rpc_request *req;
@@ -953,13 +953,13 @@ static struct rpc_request *dcerpc_request_send(struct dcerpc_pipe *p,
req->flags = 0;
req->fault_code = 0;
req->async_call = async;
- req->ignore_timeout = False;
+ req->ignore_timeout = false;
req->async.callback = NULL;
req->async.private_data = NULL;
req->recv_handler = NULL;
if (object != NULL) {
- req->object = talloc_memdup(req, object, sizeof(*object));
+ req->object = (struct GUID *)talloc_memdup(req, (const void *)object, sizeof(*object));
if (req->object == NULL) {
talloc_free(req);
return NULL;
@@ -1001,7 +1001,7 @@ static void dcerpc_ship_next_request(struct dcerpc_connection *c)
struct ncacn_packet pkt;
DATA_BLOB blob;
uint32_t remaining, chunk_size;
- BOOL first_packet = True;
+ bool first_packet = true;
req = c->request_queue;
if (req == NULL) {
@@ -1044,9 +1044,9 @@ static void dcerpc_ship_next_request(struct dcerpc_connection *c)
/* we send a series of pdus without waiting for a reply */
while (remaining > 0 || first_packet) {
uint32_t chunk = MIN(chunk_size, remaining);
- BOOL last_frag = False;
+ bool last_frag = false;
- first_packet = False;
+ first_packet = false;
pkt.pfc_flags &= ~(DCERPC_PFC_FLAG_FIRST |DCERPC_PFC_FLAG_LAST);
if (remaining == stub_data->length) {
@@ -1054,7 +1054,7 @@ static void dcerpc_ship_next_request(struct dcerpc_connection *c)
}
if (chunk == remaining) {
pkt.pfc_flags |= DCERPC_PFC_FLAG_LAST;
- last_frag = True;
+ last_frag = true;
}
pkt.u.request.stub_and_verifier.data = stub_data->data +
@@ -1123,7 +1123,7 @@ NTSTATUS dcerpc_request_recv(struct rpc_request *req,
NTSTATUS dcerpc_request(struct dcerpc_pipe *p,
struct GUID *object,
uint16_t opnum,
- BOOL async,
+ bool async,
TALLOC_CTX *mem_ctx,
DATA_BLOB *stub_data_in,
DATA_BLOB *stub_data_out)
@@ -1622,7 +1622,7 @@ struct composite_context *dcerpc_alter_context_send(struct dcerpc_pipe *p,
DLIST_ADD_END(p->conn->pending, req, struct rpc_request *);
talloc_set_destructor(req, dcerpc_req_dequeue);
- c->status = p->conn->transport.send_request(p->conn, &blob, True);
+ c->status = p->conn->transport.send_request(p->conn, &blob, true);
if (!composite_is_ok(c)) return c;
event_add_timed(c->event_ctx, req,
diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c
index 756cb58e3a..7db6c1b7cd 100644
--- a/source4/librpc/rpc/dcerpc_auth.c
+++ b/source4/librpc/rpc/dcerpc_auth.c
@@ -98,7 +98,7 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p,
struct bind_auth_state {
struct dcerpc_pipe *pipe;
DATA_BLOB credentials;
- BOOL more_processing; /* Is there anything more to do after the
+ bool more_processing; /* Is there anything more to do after the
* first bind itself received? */
};
@@ -109,7 +109,7 @@ static void bind_auth_next_step(struct composite_context *c)
struct bind_auth_state *state;
struct dcerpc_security *sec;
struct composite_context *creq;
- BOOL more_processing = False;
+ bool more_processing = false;
state = talloc_get_type(c->private_data, struct bind_auth_state);
sec = &state->pipe->conn->security_state;
@@ -129,7 +129,7 @@ static void bind_auth_next_step(struct composite_context *c)
&state->credentials);
if (NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- more_processing = True;
+ more_processing = true;
c->status = NT_STATUS_OK;
}
diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c
index be95f21594..2d6237634d 100644
--- a/source4/librpc/rpc/dcerpc_connect.c
+++ b/source4/librpc/rpc/dcerpc_connect.c
@@ -31,6 +31,7 @@
#include "libcli/smb2/smb2_calls.h"
#include "librpc/rpc/dcerpc.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
struct pipe_np_smb_state {
@@ -110,10 +111,13 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CT
remote rpc server */
conn->in.dest_host = s->io.binding->host;
conn->in.port = 0;
- conn->in.called_name = s->io.binding->target_hostname;
+ if (s->io.binding->target_hostname == NULL)
+ conn->in.called_name = "*SMBSERVER"; /* FIXME: This is invalid */
+ else
+ conn->in.called_name = s->io.binding->target_hostname;
conn->in.service = "IPC$";
conn->in.service_type = NULL;
- conn->in.workgroup = lp_workgroup();
+ conn->in.workgroup = lp_workgroup(global_loadparm);
/*
* provide proper credentials - user supplied, but allow a
@@ -123,9 +127,9 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CT
*/
s->conn.in.credentials = s->io.creds;
if (s->io.binding->flags & DCERPC_SCHANNEL) {
- conn->in.fallback_to_anonymous = True;
+ conn->in.fallback_to_anonymous = true;
} else {
- conn->in.fallback_to_anonymous = False;
+ conn->in.fallback_to_anonymous = false;
}
/* send smb connect request */
diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c
index 6b43de3358..718ce694c5 100644
--- a/source4/librpc/rpc/dcerpc_smb.c
+++ b/source4/librpc/rpc/dcerpc_smb.c
@@ -39,7 +39,7 @@ struct smb_private {
*/
static void pipe_dead(struct dcerpc_connection *c, NTSTATUS status)
{
- struct smb_private *smb = c->transport.private_data;
+ struct smb_private *smb = (struct smb_private *)c->transport.private_data;
if (smb->dead) {
return;
@@ -141,7 +141,7 @@ static void smb_read_callback(struct smbcli_request *req)
*/
static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLOB *blob)
{
- struct smb_private *smb = c->transport.private_data;
+ struct smb_private *smb = (struct smb_private *)c->transport.private_data;
union smb_read *io;
struct smb_read_state *state;
struct smbcli_request *req;
@@ -176,7 +176,7 @@ static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLO
io->readx.in.maxcnt = io->readx.in.mincnt;
io->readx.in.offset = 0;
io->readx.in.remaining = 0;
- io->readx.in.read_for_execute = False;
+ io->readx.in.read_for_execute = false;
io->readx.out.data = state->data.data + state->received;
req = smb_raw_read_send(smb->tree, io);
if (req == NULL) {
@@ -197,7 +197,7 @@ static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLO
*/
static NTSTATUS send_read_request(struct dcerpc_connection *c)
{
- struct smb_private *smb = c->transport.private_data;
+ struct smb_private *smb = (struct smb_private *)c->transport.private_data;
if (smb->dead) {
return NT_STATUS_CONNECTION_DISCONNECTED;
@@ -220,7 +220,7 @@ struct smb_trans_state {
*/
static void smb_trans_callback(struct smbcli_request *req)
{
- struct smb_trans_state *state = req->async.private;
+ struct smb_trans_state *state = (struct smb_trans_state *)req->async.private;
struct dcerpc_connection *c = state->c;
NTSTATUS status;
@@ -249,7 +249,7 @@ static void smb_trans_callback(struct smbcli_request *req)
*/
static NTSTATUS smb_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *blob)
{
- struct smb_private *smb = c->transport.private_data;
+ struct smb_private *smb = (struct smb_private *)c->transport.private_data;
struct smb_trans2 *trans;
uint16_t setup[2];
struct smb_trans_state *state;
@@ -297,7 +297,7 @@ static NTSTATUS smb_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *b
*/
static void smb_write_callback(struct smbcli_request *req)
{
- struct dcerpc_connection *c = req->async.private;
+ struct dcerpc_connection *c = (struct dcerpc_connection *)req->async.private;
if (!NT_STATUS_IS_OK(req->status)) {
DEBUG(0,("dcerpc_smb: write callback error\n"));
@@ -310,9 +310,10 @@ static void smb_write_callback(struct smbcli_request *req)
/*
send a packet to the server
*/
-static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob, BOOL trigger_read)
+static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob,
+ bool trigger_read)
{
- struct smb_private *smb = c->transport.private_data;
+ struct smb_private *smb = (struct smb_private *)c->transport.private_data;
union smb_write io;
struct smbcli_request *req;
@@ -356,7 +357,7 @@ static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob, B
*/
static NTSTATUS smb_shutdown_pipe(struct dcerpc_connection *c, NTSTATUS status)
{
- struct smb_private *smb = c->transport.private_data;
+ struct smb_private *smb = (struct smb_private *)c->transport.private_data;
union smb_close io;
struct smbcli_request *req;
@@ -382,7 +383,7 @@ static NTSTATUS smb_shutdown_pipe(struct dcerpc_connection *c, NTSTATUS status)
*/
static const char *smb_peer_name(struct dcerpc_connection *c)
{
- struct smb_private *smb = c->transport.private_data;
+ struct smb_private *smb = (struct smb_private *)c->transport.private_data;
return smb->server_name;
}
@@ -400,7 +401,7 @@ static const char *smb_target_hostname(struct dcerpc_connection *c)
*/
static NTSTATUS smb_session_key(struct dcerpc_connection *c, DATA_BLOB *session_key)
{
- struct smb_private *smb = c->transport.private_data;
+ struct smb_private *smb = (struct smb_private *)c->transport.private_data;
if (smb->tree->session->user_session_key.data) {
*session_key = smb->tree->session->user_session_key;
@@ -430,7 +431,9 @@ struct composite_context *dcerpc_pipe_open_smb_send(struct dcerpc_pipe *p,
/* if we don't have a binding on this pipe yet, then create one */
if (p->binding == NULL) {
NTSTATUS status;
- char *s = talloc_asprintf(p, "ncacn_np:%s", tree->session->transport->socket->hostname);
+ char *s;
+ SMB_ASSERT(tree->session->transport->socket->hostname != NULL);
+ s = talloc_asprintf(p, "ncacn_np:%s", tree->session->transport->socket->hostname);
if (s == NULL) return NULL;
status = dcerpc_parse_binding(p, s, &p->binding);
talloc_free(s);
diff --git a/source4/librpc/rpc/dcerpc_smb2.c b/source4/librpc/rpc/dcerpc_smb2.c
index dcfee1f223..b06964d331 100644
--- a/source4/librpc/rpc/dcerpc_smb2.c
+++ b/source4/librpc/rpc/dcerpc_smb2.c
@@ -41,7 +41,7 @@ struct smb2_private {
*/
static void pipe_dead(struct dcerpc_connection *c, NTSTATUS status)
{
- struct smb2_private *smb = c->transport.private_data;
+ struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
if (smb->dead) {
return;
@@ -145,7 +145,7 @@ static void smb2_read_callback(struct smb2_request *req)
*/
static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLOB *blob)
{
- struct smb2_private *smb = c->transport.private_data;
+ struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
struct smb2_read io;
struct smb2_read_state *state;
struct smb2_request *req;
@@ -190,7 +190,7 @@ static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLO
*/
static NTSTATUS send_read_request(struct dcerpc_connection *c)
{
- struct smb2_private *smb = c->transport.private_data;
+ struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
if (smb->dead) {
return NT_STATUS_CONNECTION_DISCONNECTED;
@@ -280,7 +280,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 = req->async.private;
+ struct dcerpc_connection *c = (struct dcerpc_connection *)req->async.private;
if (!NT_STATUS_IS_OK(req->status)) {
DEBUG(0,("dcerpc_smb2: write callback error\n"));
@@ -294,9 +294,9 @@ static void smb2_write_callback(struct smb2_request *req)
send a packet to the server
*/
static NTSTATUS smb2_send_request(struct dcerpc_connection *c, DATA_BLOB *blob,
- BOOL trigger_read)
+ bool trigger_read)
{
- struct smb2_private *smb = c->transport.private_data;
+ struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
struct smb2_write io;
struct smb2_request *req;
@@ -328,7 +328,7 @@ static NTSTATUS smb2_send_request(struct dcerpc_connection *c, DATA_BLOB *blob,
*/
static NTSTATUS smb2_shutdown_pipe(struct dcerpc_connection *c, NTSTATUS status)
{
- struct smb2_private *smb = c->transport.private_data;
+ struct smb2_private *smb = (struct smb2_private *)c->transport.private_data;
struct smb2_close io;
struct smb2_request *req;
diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c
index a5abf9b4be..f7ae377e7b 100644
--- a/source4/librpc/rpc/dcerpc_sock.c
+++ b/source4/librpc/rpc/dcerpc_sock.c
@@ -28,6 +28,7 @@
#include "libcli/composite/composite.h"
#include "librpc/rpc/dcerpc.h"
#include "libcli/resolve/resolve.h"
+#include "param/param.h"
/* transport private information used by general socket pipe transports */
struct sock_private {
@@ -45,7 +46,7 @@ struct sock_private {
*/
static void sock_dead(struct dcerpc_connection *p, NTSTATUS status)
{
- struct sock_private *sock = p->transport.private_data;
+ struct sock_private *sock = (struct sock_private *)p->transport.private_data;
if (!sock) return;
@@ -111,7 +112,7 @@ static NTSTATUS sock_process_recv(void *private, DATA_BLOB blob)
{
struct dcerpc_connection *p = talloc_get_type(private,
struct dcerpc_connection);
- struct sock_private *sock = p->transport.private_data;
+ struct sock_private *sock = (struct sock_private *)p->transport.private_data;
sock->pending_reads--;
if (sock->pending_reads == 0) {
packet_recv_disable(sock->packet);
@@ -128,7 +129,7 @@ static void sock_io_handler(struct event_context *ev, struct fd_event *fde,
{
struct dcerpc_connection *p = talloc_get_type(private,
struct dcerpc_connection);
- struct sock_private *sock = p->transport.private_data;
+ struct sock_private *sock = (struct sock_private *)p->transport.private_data;
if (flags & EVENT_FD_WRITE) {
packet_queue_run(sock->packet);
@@ -149,7 +150,7 @@ static void sock_io_handler(struct event_context *ev, struct fd_event *fde,
*/
static NTSTATUS sock_send_read(struct dcerpc_connection *p)
{
- struct sock_private *sock = p->transport.private_data;
+ struct sock_private *sock = (struct sock_private *)p->transport.private_data;
sock->pending_reads++;
if (sock->pending_reads == 1) {
packet_recv_enable(sock->packet);
@@ -161,9 +162,9 @@ static NTSTATUS sock_send_read(struct dcerpc_connection *p)
send an initial pdu in a multi-pdu sequence
*/
static NTSTATUS sock_send_request(struct dcerpc_connection *p, DATA_BLOB *data,
- BOOL trigger_read)
+ bool trigger_read)
{
- struct sock_private *sock = p->transport.private_data;
+ struct sock_private *sock = (struct sock_private *)p->transport.private_data;
DATA_BLOB blob;
NTSTATUS status;
@@ -193,7 +194,7 @@ static NTSTATUS sock_send_request(struct dcerpc_connection *p, DATA_BLOB *data,
*/
static NTSTATUS sock_shutdown_pipe(struct dcerpc_connection *p, NTSTATUS status)
{
- struct sock_private *sock = p->transport.private_data;
+ struct sock_private *sock = (struct sock_private *)p->transport.private_data;
if (sock && sock->sock) {
sock_dead(p, status);
@@ -294,7 +295,7 @@ static void continue_socket_connect(struct composite_context *ctx)
packet_set_initial_read(sock->packet, 16);
/* ensure we don't get SIGPIPE */
- BlockSignals(True,SIGPIPE);
+ BlockSignals(true, SIGPIPE);
composite_done(c);
}
@@ -477,7 +478,8 @@ struct composite_context* dcerpc_pipe_open_tcp_send(struct dcerpc_connection *co
s->conn = conn;
make_nbt_name_server(&name, server);
- resolve_req = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
+ resolve_req = resolve_name_send(&name, c->event_ctx,
+ lp_name_resolve_order(global_loadparm));
composite_continue(c, resolve_req, continue_ip_resolve_name, c);
return c;
}
@@ -617,7 +619,7 @@ struct composite_context* dcerpc_pipe_open_pipe_send(struct dcerpc_connection *c
s->conn = conn;
string_replace(canon, '/', '\\');
- s->full_path = talloc_asprintf(canon, "%s/%s", lp_ncalrpc_dir(), canon);
+ s->full_path = talloc_asprintf(canon, "%s/%s", lp_ncalrpc_dir(global_loadparm), canon);
if (composite_nomem(s->full_path, c)) return c;
/* prepare server address using path and transport name */
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 11f5451891..408860c9ed 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -29,6 +29,7 @@
#include "librpc/gen_ndr/ndr_dcerpc.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
/*
find a dcerpc call on an interface by name
@@ -254,43 +255,42 @@ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b)
}
if (t_name != NULL) {
- s = talloc_asprintf_append(s, "%s:", t_name);
- if (s == NULL)
+ s = talloc_asprintf_append_buffer(s, "%s:", t_name);
+ if (s == NULL) {
return NULL;
- } else {
- s = NULL;
+ }
}
if (b->host) {
- s = talloc_asprintf_append(s, "%s", b->host);
+ s = talloc_asprintf_append_buffer(s, "%s", b->host);
}
if (!b->endpoint && !b->options && !b->flags) {
return s;
}
- s = talloc_asprintf_append(s, "[");
+ s = talloc_asprintf_append_buffer(s, "[");
if (b->endpoint) {
- s = talloc_asprintf_append(s, "%s", 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(s, ",%s", b->options[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(s, ",%s", ncacn_options[i].name);
+ s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name);
if (!s) return NULL;
}
}
- s = talloc_asprintf_append(s, "]");
+ s = talloc_asprintf_append_buffer(s, "]");
return s;
}
@@ -930,7 +930,7 @@ 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_conf(anon_creds);
+ cli_credentials_set_conf(anon_creds, global_loadparm);
cli_credentials_set_anonymous(anon_creds);
/*
@@ -1363,7 +1363,7 @@ void dcerpc_log_packet(const struct ndr_interface_table *ndr,
for (i=0;i<num_examples;i++) {
char *name=NULL;
asprintf(&name, "%s/rpclog/%s-%u.%d.%s",
- lp_lockdir(), ndr->name, opnum, i,
+ lp_lockdir(global_loadparm), ndr->name, opnum, i,
(flags&NDR_IN)?"in":"out");
if (name == NULL) {
return;
diff --git a/source4/librpc/tests/binding_string.c b/source4/librpc/tests/binding_string.c
index 18cf4dfb46..362848049b 100644
--- a/source4/librpc/tests/binding_string.c
+++ b/source4/librpc/tests/binding_string.c
@@ -95,6 +95,41 @@ static const char *test_strings[] = {
"ncacn_unix_stream:[/tmp/epmapper,sign]",
};
+static bool test_parse_check_results(struct torture_context *tctx)
+{
+ struct dcerpc_binding *b;
+ struct GUID uuid;
+
+ torture_assert_ntstatus_ok(tctx,
+ GUID_from_string("308FB580-1EB2-11CA-923B-08002B1075A7", &uuid),
+ "parsing uuid");
+
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER", &b), "parse");
+ torture_assert(tctx, b->transport == NCACN_NP, "ncacn_np expected");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_ip_tcp:$SERVER", &b), "parse");
+ torture_assert(tctx, b->transport == NCACN_IP_TCP, "ncacn_ip_tcp expected");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER[rpcecho]", &b), "parse");
+ torture_assert_str_equal(tctx, b->endpoint, "rpcecho", "endpoint");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER[/pipe/rpcecho]", &b), "parse");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER[/pipe/rpcecho,sign,seal]", &b), "parse");
+ torture_assert(tctx, b->flags == DCERPC_SIGN+DCERPC_SEAL, "sign+seal flags");
+ torture_assert_str_equal(tctx, b->endpoint, "/pipe/rpcecho", "endpoint");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER[,sign]", &b), "parse");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_ip_tcp:$SERVER[,sign]", &b), "parse");
+ torture_assert(tctx, b->endpoint == NULL, "endpoint");
+ torture_assert(tctx, b->flags == DCERPC_SIGN, "sign flag");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncalrpc:", &b), "parse");
+ torture_assert(tctx, b->transport == NCALRPC, "ncalrpc expected");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx,
+ "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:$SERVER", &b), "parse");
+ torture_assert(tctx, GUID_equal(&b->object.uuid, &uuid), "object uuid");
+ torture_assert_int_equal(tctx, b->object.if_version, 0, "object version");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx,
+ "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:$SERVER", &b), "parse");
+
+ return true;
+}
+
static bool test_no_transport(struct torture_context *tctx)
{
const char *binding = "somehost";
@@ -129,5 +164,7 @@ struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx)
torture_suite_add_simple_test(suite, "no transport", test_no_transport);
+ torture_suite_add_simple_test(suite, "parsing results", test_parse_check_results);
+
return suite;
}
diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c
index 8a5e55f91e..5a3e63ed93 100644
--- a/source4/librpc/tools/ndrdump.c
+++ b/source4/librpc/tools/ndrdump.c
@@ -50,7 +50,7 @@ static const struct ndr_interface_call *find_function(
#if (_SAMBA_BUILD_ >= 4)
-static void show_pipes(void)
+_NORETURN_ static void show_pipes(void)
{
const struct ndr_interface_list *l;
printf("\nYou must specify a pipe\n");
@@ -67,7 +67,7 @@ static void show_pipes(void)
#endif
-static void show_functions(const struct ndr_interface_table *p)
+_NORETURN_ static void show_functions(const struct ndr_interface_table *p)
{
int i;
printf("\nYou must specify a function\n");
@@ -87,10 +87,10 @@ static char *stdin_load(TALLOC_CTX *mem_ctx, size_t *size)
while((num_read = read(STDIN_FILENO, buf, 255)) > 0) {
if (result) {
- result = (char *) talloc_realloc(
- mem_ctx, result, char *, total_len + num_read);
+ result = talloc_realloc(
+ mem_ctx, result, char, total_len + num_read);
} else {
- result = talloc_size(mem_ctx, num_read);
+ result = talloc_array(mem_ctx, char, num_read);
}
memcpy(result + total_len, buf, num_read);
@@ -104,7 +104,7 @@ static char *stdin_load(TALLOC_CTX *mem_ctx, size_t *size)
return result;
}
-const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, const char *pipe_name)
+static const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, const char *pipe_name)
{
const struct ndr_interface_table *p;
void *handle;
@@ -117,7 +117,7 @@ const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, con
}
symbol = talloc_asprintf(NULL, "ndr_table_%s", pipe_name);
- p = dlsym(handle, symbol);
+ p = (const struct ndr_interface_table *)dlsym(handle, symbol);
if (!p) {
printf("%s: Unable to find DCE/RPC interface table for '%s': %s\n", plugin, pipe_name, dlerror());
diff --git a/source4/main.mk b/source4/main.mk
index a0fafec3a3..1a6524cbf4 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -43,6 +43,12 @@ manpages: $(MANPAGES)
all: showflags $(ALL_PREDEP) bin/asn1_compile bin/compile_et binaries modules
everything: all libraries headers
+# 'make testsuite' creates all binaries which are
+# needed by samba3's 'make test' and the build-farm
+# scripts use that it as fallback in case
+# 'make everything' fails
+testsuite: bin/smbclient bin/cifsdd bin/smbtorture bin/nmblookup
+
showlayout:
@echo 'Samba will be installed into:'
@echo ' basedir: $(BASEDIR)'
@@ -58,8 +64,7 @@ showlayout:
@echo ' logfilebase: $(LOGFILEBASE)'
@echo ' setupdir: $(SETUPDIR)'
@echo ' jsdir: $(JSDIR)'
- @echo ' webappsdir: $(WEBAPPSDIR)'
- @echo ' servicesdir: $(SERVICESDIR)'
+ @echo ' swatdir: $(SWATDIR)'
@echo ' mandir: $(MANDIR)'
@echo ' torturedir: $(TORTUREDIR)'
@echo ' datadir: $(DATADIR)'
@@ -86,7 +91,7 @@ showflags:
# The permissions to give the executables
INSTALLPERMS = 0755
-install: showlayout everything installbin installdat installwebapps installmisc installlib \
+install: showlayout everything installbin installdat installswat installmisc installlib \
installheader installpc installplugins
# DESTDIR is used here to prevent packagers wasting their time
@@ -147,9 +152,8 @@ installheader: headers installdirs
installdat: installdirs
@$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir)
-installwebapps: installdirs
- @$(SHELL) $(srcdir)/script/installwebapps.sh $(DESTDIR)$(WEBAPPSDIR) $(srcdir)
- @$(SHELL) $(srcdir)/script/installjsonrpc.sh $(DESTDIR)$(SERVICESDIR) $(srcdir)
+installswat: installdirs
+ @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
installman: manpages installdirs
@$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
@@ -268,7 +272,6 @@ distclean: clean
-rm -f config.status
-rm -f config.log config.cache
-rm -f config.pm config.mk
- -rm -rf ../webapps/qooxdoo-*-sdk/frontend/framework/.cache
-rm -f $(PC_FILES)
removebackup:
@@ -315,7 +318,7 @@ quicktestone: all
testenv: everything
$(SELFTEST) --socket-wrapper --testenv
-valgrindtest: valgrindtest-quick
+valgrindtest: valgrindtest-all
valgrindtest-quick: all
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
@@ -332,7 +335,7 @@ valgrindtest-env: everything
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
$(SELFTEST) --socket-wrapper --testenv
-gdbtest: gdbtest-quick
+gdbtest: gdbtest-all
gdbtest-quick: all
SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run " \
diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk
index 5e8cfa61da..c498101c22 100644
--- a/source4/nbt_server/config.mk
+++ b/source4/nbt_server/config.mk
@@ -54,11 +54,8 @@ PRIVATE_DEPENDENCIES = \
#######################
# Start SUBSYSTEM NBTD
-[MODULE::NBTD]
-INIT_FUNCTION = server_service_nbtd_init
-SUBSYSTEM = service
+[SUBSYSTEM::NBT_SERVER]
OBJ_FILES = \
- nbt_server.o \
interfaces.o \
register.o \
query.o \
@@ -68,6 +65,13 @@ OBJ_FILES = \
irpc.o
PRIVATE_PROTO_HEADER = nbt_server_proto.h
PRIVATE_DEPENDENCIES = \
- LIBCLI_NBT NBTD_WINS NBTD_DGRAM process_model
+ LIBCLI_NBT NBTD_WINS NBTD_DGRAM
# End SUBSYSTEM NBTD
#######################
+
+[MODULE::service_nbtd]
+INIT_FUNCTION = server_service_nbtd_init
+SUBSYSTEM = service
+OBJ_FILES = \
+ nbt_server.o
+PRIVATE_DEPENDENCIES = NBT_SERVER process_model
diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c
index c255238913..2f96970a65 100644
--- a/source4/nbt_server/dgram/netlogon.c
+++ b/source4/nbt_server/dgram/netlogon.c
@@ -27,6 +27,7 @@
#include "auth/auth.h"
#include "db_wrap.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
reply to a GETDC request
@@ -38,7 +39,7 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
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 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};
@@ -74,7 +75,7 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
reply.command = NETLOGON_RESPONSE_FROM_PDC;
pdc = &reply.req.response;
- pdc->pdc_name = lp_netbios_name();
+ pdc->pdc_name = lp_netbios_name(global_loadparm);
pdc->unicode_pdc_name = pdc->pdc_name;
pdc->domain_name = samdb_result_string(ref_res[0], "nETBIOSName", name->name);;
pdc->nt_version = 1;
@@ -101,7 +102,7 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
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 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;
@@ -109,7 +110,7 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
const char *dom_attrs[] = {"objectGUID", NULL};
struct ldb_message **ref_res, **dom_res;
int ret;
- const char **services = lp_server_services();
+ const char **services = lp_server_services(global_loadparm);
const char *my_ip = reply_iface->ip_address;
struct ldb_dn *partitions_basedn;
if (!my_ip) {
@@ -182,15 +183,18 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
}
pdc->domain_uuid = samdb_result_guid(dom_res[0], "objectGUID");
- pdc->forest = samdb_result_string(ref_res[0], "dnsRoot", lp_realm());
- pdc->dns_domain = samdb_result_string(ref_res[0], "dnsRoot", lp_realm());
+ pdc->forest = samdb_result_string(ref_res[0], "dnsRoot",
+ lp_realm(global_loadparm));
+ pdc->dns_domain = samdb_result_string(ref_res[0], "dnsRoot",
+ lp_realm(global_loadparm));
/* TODO: get our full DNS name from somewhere else */
pdc->pdc_dns_name = talloc_asprintf(packet, "%s.%s",
- strlower_talloc(packet, lp_netbios_name()),
+ strlower_talloc(packet,
+ lp_netbios_name(global_loadparm)),
pdc->dns_domain);
pdc->domain = samdb_result_string(ref_res[0], "nETBIOSName", name->name);;
- pdc->pdc_name = lp_netbios_name();
+ pdc->pdc_name = lp_netbios_name(global_loadparm);
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";
diff --git a/source4/nbt_server/dgram/ntlogon.c b/source4/nbt_server/dgram/ntlogon.c
index 51888ceab4..ce1f725038 100644
--- a/source4/nbt_server/dgram/ntlogon.c
+++ b/source4/nbt_server/dgram/ntlogon.c
@@ -23,6 +23,7 @@
#include "nbt_server/nbt_server.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
reply to a SAM LOGON request
@@ -34,7 +35,7 @@ static void nbtd_ntlogon_sam_logon(struct dgram_mailslot_handler *dgmslot,
struct nbt_ntlogon_packet *ntlogon)
{
struct nbt_name *name = &packet->data.msg.dest_name;
- struct nbtd_interface *reply_iface = nbtd_find_reply_iface(iface, src->addr, False);
+ struct nbtd_interface *reply_iface = nbtd_find_reply_iface(iface, src->addr, false);
struct nbt_ntlogon_packet reply;
struct nbt_ntlogon_sam_logon_reply *logon;
@@ -48,9 +49,10 @@ static void nbtd_ntlogon_sam_logon(struct dgram_mailslot_handler *dgmslot,
reply.command = NTLOGON_SAM_LOGON_REPLY;
logon = &reply.req.reply;
- logon->server = talloc_asprintf(packet, "\\\\%s", lp_netbios_name());
+ logon->server = talloc_asprintf(packet, "\\\\%s",
+ lp_netbios_name(global_loadparm));
logon->user_name = ntlogon->req.logon.user_name;
- logon->domain = lp_workgroup();
+ logon->domain = lp_workgroup(global_loadparm);
logon->nt_version = 1;
logon->lmnt_token = 0xFFFF;
logon->lm20_token = 0xFFFF;
diff --git a/source4/nbt_server/dgram/request.c b/source4/nbt_server/dgram/request.c
index bea1e84213..48d6e4cb3a 100644
--- a/source4/nbt_server/dgram/request.c
+++ b/source4/nbt_server/dgram/request.c
@@ -26,6 +26,7 @@
#include "libcli/resolve/resolve.h"
#include "nbt_server/dgram/proto.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
a list of mailslots that we have static handlers for
@@ -79,7 +80,8 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address
}
bcast_addr = socket_address_from_strings(tmp_ctx, bcast_dgmsock->sock->backend_name,
- iface->bcast_address, lp_dgram_port());
+ iface->bcast_address,
+ lp_dgram_port(global_loadparm));
if (!bcast_addr) {
talloc_free(tmp_ctx);
return NT_STATUS_NO_MEMORY;
@@ -89,7 +91,8 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
DEBUG(0,("Failed to bind to %s:%d - %s\n",
- iface->bcast_address, lp_dgram_port(), nt_errstr(status)));
+ iface->bcast_address, lp_dgram_port(global_loadparm),
+ nt_errstr(status)));
return status;
}
@@ -104,7 +107,7 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address
}
bind_addr = socket_address_from_strings(tmp_ctx, iface->dgmsock->sock->backend_name,
- bind_address, lp_dgram_port());
+ bind_address, lp_dgram_port(global_loadparm));
if (!bind_addr) {
talloc_free(tmp_ctx);
return NT_STATUS_NO_MEMORY;
@@ -114,7 +117,7 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
DEBUG(0,("Failed to bind to %s:%d - %s\n",
- bind_address, lp_dgram_port(), nt_errstr(status)));
+ bind_address, lp_dgram_port(global_loadparm), nt_errstr(status)));
return status;
}
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c
index b0bc55c05b..f2a875142a 100644
--- a/source4/nbt_server/interfaces.c
+++ b/source4/nbt_server/interfaces.c
@@ -28,6 +28,7 @@
#include "nbt_server/dgram/proto.h"
#include "system/network.h"
#include "lib/socket/netif.h"
+#include "param/param.h"
/*
@@ -135,7 +136,7 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
}
bcast_address = socket_address_from_strings(bcast_nbtsock, bcast_nbtsock->sock->backend_name,
- bcast, lp_nbt_port());
+ bcast, lp_nbt_port(global_loadparm));
if (!bcast_address) {
talloc_free(iface);
return NT_STATUS_NO_MEMORY;
@@ -144,7 +145,7 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
status = socket_listen(bcast_nbtsock->sock, bcast_address, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to bind to %s:%d - %s\n",
- bcast, lp_nbt_port(), nt_errstr(status)));
+ bcast, lp_nbt_port(global_loadparm), nt_errstr(status)));
talloc_free(iface);
return status;
}
@@ -160,13 +161,14 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
return NT_STATUS_NO_MEMORY;
}
- unicast_address = socket_address_from_strings(iface->nbtsock, iface->nbtsock->sock->backend_name,
- bind_address, lp_nbt_port());
+ unicast_address = socket_address_from_strings(iface->nbtsock,
+ iface->nbtsock->sock->backend_name,
+ bind_address, lp_nbt_port(global_loadparm));
status = socket_listen(iface->nbtsock->sock, unicast_address, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to bind to %s:%d - %s\n",
- bind_address, lp_nbt_port(), nt_errstr(status)));
+ bind_address, lp_nbt_port(global_loadparm), nt_errstr(status)));
talloc_free(iface);
return status;
}
@@ -222,7 +224,7 @@ NTSTATUS nbtd_startup_interfaces(struct nbtd_server *nbtsrv)
/* if we are allowing incoming packets from any address, then
we also need to bind to the wildcard address */
- if (!lp_bind_interfaces_only()) {
+ if (!lp_bind_interfaces_only(global_loadparm)) {
const char *primary_address;
/* the primary address is the address we will return
@@ -232,7 +234,7 @@ NTSTATUS nbtd_startup_interfaces(struct nbtd_server *nbtsrv)
primary_address = iface_n_ip(0);
} else {
primary_address = sys_inet_ntoa(interpret_addr2(
- lp_netbios_name()));
+ lp_netbios_name(global_loadparm)));
}
primary_address = talloc_strdup(tmp_ctx, primary_address);
NT_STATUS_HAVE_NO_MEMORY(primary_address);
@@ -260,7 +262,7 @@ NTSTATUS nbtd_startup_interfaces(struct nbtd_server *nbtsrv)
NT_STATUS_NOT_OK_RETURN(status);
}
- if (lp_wins_server_list()) {
+ if (lp_wins_server_list(global_loadparm)) {
status = nbtd_add_wins_socket(nbtsrv);
NT_STATUS_NOT_OK_RETURN(status);
}
@@ -280,7 +282,7 @@ const char **nbtd_address_list(struct nbtd_interface *iface, TALLOC_CTX *mem_ctx
struct nbtd_server *nbtsrv = iface->nbtsrv;
const char **ret = NULL;
struct nbtd_interface *iface2;
- BOOL is_loopback = False;
+ bool is_loopback = false;
if (iface->ip_address) {
is_loopback = iface_same_net(iface->ip_address, "127.0.0.1", "255.0.0.0");
@@ -311,7 +313,7 @@ const char **nbtd_address_list(struct nbtd_interface *iface, TALLOC_CTX *mem_ctx
find the interface to use for sending a outgoing request
*/
struct nbtd_interface *nbtd_find_request_iface(struct nbtd_server *nbtd_server,
- const char *address, BOOL allow_bcast_iface)
+ const char *address, bool allow_bcast_iface)
{
struct nbtd_interface *cur;
@@ -335,7 +337,7 @@ struct nbtd_interface *nbtd_find_request_iface(struct nbtd_server *nbtd_server,
* find the interface to use for sending a outgoing reply
*/
struct nbtd_interface *nbtd_find_reply_iface(struct nbtd_interface *iface,
- const char *address, BOOL allow_bcast_iface)
+ const char *address, bool allow_bcast_iface)
{
struct nbtd_server *nbtd_server = iface->nbtsrv;
diff --git a/source4/nbt_server/irpc.c b/source4/nbt_server/irpc.c
index 6200c6bba5..8f2f7fc2c2 100644
--- a/source4/nbt_server/irpc.c
+++ b/source4/nbt_server/irpc.c
@@ -119,7 +119,7 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
{
struct nbtd_server *server =
talloc_get_type(msg->private, struct nbtd_server);
- struct nbtd_interface *iface = nbtd_find_request_iface(server, req->in.ip_address, True);
+ 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;
@@ -169,7 +169,7 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
return status;
}
- msg->defer_reply = True;
+ msg->defer_reply = true;
return NT_STATUS_OK;
}
diff --git a/source4/nbt_server/packet.c b/source4/nbt_server/packet.c
index 09b2549956..6b8e266f6d 100644
--- a/source4/nbt_server/packet.c
+++ b/source4/nbt_server/packet.c
@@ -23,6 +23,7 @@
#include "nbt_server/nbt_server.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
/*
we received a badly formed packet - log it
@@ -41,7 +42,7 @@ void nbtd_bad_packet(struct nbt_name_packet *packet,
see if an incoming packet is a broadcast packet from one of our own
interfaces
*/
-BOOL nbtd_self_packet_and_bcast(struct nbt_name_socket *nbtsock,
+bool nbtd_self_packet_and_bcast(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const struct socket_address *src)
{
@@ -50,7 +51,7 @@ BOOL nbtd_self_packet_and_bcast(struct nbt_name_socket *nbtsock,
/* if its not a broadcast then its not considered a self packet */
if (!(packet->operation & NBT_FLAG_BROADCAST)) {
- return False;
+ return false;
}
/*
@@ -62,13 +63,13 @@ BOOL nbtd_self_packet_and_bcast(struct nbt_name_socket *nbtsock,
*/
if (iface->nbtsock == nbtsock &&
iface != iface->nbtsrv->bcast_interface) {
- return False;
+ return false;
}
return nbtd_self_packet(nbtsock, packet, src);
}
-BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock,
+bool nbtd_self_packet(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const struct socket_address *src)
{
@@ -77,19 +78,19 @@ BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock,
struct nbtd_server *nbtsrv = iface->nbtsrv;
/* if its not from the nbt port, then it wasn't a broadcast from us */
- if (src->port != lp_nbt_port()) {
- return False;
+ if (src->port != lp_nbt_port(global_loadparm)) {
+ return false;
}
/* we have to loop over our interface list, seeing if its from
one of our own interfaces */
for (iface=nbtsrv->interfaces;iface;iface=iface->next) {
if (strcmp(src->addr, iface->ip_address) == 0) {
- return True;
+ return true;
}
}
- return False;
+ return false;
}
@@ -326,7 +327,7 @@ void nbtd_wack_reply(struct nbt_name_socket *nbtsock,
packet->answers[0].rr_class = NBT_QCLASS_IP;
packet->answers[0].ttl = ttl;
packet->answers[0].rdata.data.length = 2;
- packet->answers[0].rdata.data.data = talloc_size(packet, 2);
+ packet->answers[0].rdata.data.data = talloc_array(packet, uint8_t, 2);
if (packet->answers[0].rdata.data.data == NULL) goto failed;
RSSVAL(packet->answers[0].rdata.data.data, 0, request_packet->operation);
diff --git a/source4/nbt_server/query.c b/source4/nbt_server/query.c
index 4f42ec517d..f57cb7bf76 100644
--- a/source4/nbt_server/query.c
+++ b/source4/nbt_server/query.c
@@ -26,6 +26,7 @@
#include "nbt_server/wins/winsserver.h"
#include "librpc/gen_ndr/ndr_nbt.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/*
answer a name query
@@ -80,7 +81,7 @@ void nbtd_request_query(struct nbt_name_socket *nbtsock,
if (!(packet->operation & NBT_FLAG_BROADCAST) &&
(packet->operation & NBT_FLAG_RECURSION_DESIRED) &&
(iname->nb_flags & NBT_NM_GROUP) &&
- lp_wins_support()) {
+ lp_wins_support(global_loadparm)) {
nbtd_winsserver_request(nbtsock, packet, src);
return;
}
diff --git a/source4/nbt_server/register.c b/source4/nbt_server/register.c
index 6b592624c3..4ec70e319b 100644
--- a/source4/nbt_server/register.c
+++ b/source4/nbt_server/register.c
@@ -29,7 +29,7 @@
#include "nbt_server/wins/winsserver.h"
#include "librpc/gen_ndr/ndr_nbt.h"
#include "dsdb/samdb/samdb.h"
-
+#include "param/param.h"
static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname);
@@ -96,9 +96,9 @@ static void name_refresh_handler(struct event_context *ev, struct timed_event *t
io.in.address = iface->ip_address;
io.in.nb_flags = iname->nb_flags;
io.in.ttl = iname->ttl;
- io.in.register_demand = False;
- io.in.broadcast = True;
- io.in.multi_homed = False;
+ io.in.register_demand = false;
+ io.in.broadcast = true;
+ io.in.multi_homed = false;
io.in.timeout = 3;
io.in.retries = 0;
@@ -117,7 +117,7 @@ static void name_refresh_handler(struct event_context *ev, struct timed_event *t
static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname)
{
uint32_t refresh_time;
- uint32_t max_refresh_time = lp_parm_int(-1, "nbtd", "max_refresh_time", 7200);
+ uint32_t max_refresh_time = lp_parm_int(global_loadparm, NULL, "nbtd", "max_refresh_time", 7200);
refresh_time = MIN(max_refresh_time, iname->ttl/2);
@@ -170,7 +170,7 @@ static void nbtd_register_name_iface(struct nbtd_interface *iface,
uint16_t nb_flags)
{
struct nbtd_iface_name *iname;
- const char *scope = lp_netbios_scope();
+ const char *scope = lp_netbios_scope(global_loadparm);
struct nbt_name_register_bcast io;
struct composite_context *creq;
struct nbtd_server *nbtsrv = iface->nbtsrv;
@@ -187,7 +187,7 @@ static void nbtd_register_name_iface(struct nbtd_interface *iface,
iname->name.scope = NULL;
}
iname->nb_flags = nb_flags;
- iname->ttl = lp_parm_int(-1, "nbtd", "bcast_ttl", 300000);
+ iname->ttl = lp_parm_int(global_loadparm, NULL, "nbtd", "bcast_ttl", 300000);
iname->registration_time = timeval_zero();
iname->wins_server = NULL;
@@ -226,9 +226,9 @@ static void nbtd_register_name_iface(struct nbtd_interface *iface,
/*
register one name on all our interfaces
*/
-static void nbtd_register_name(struct nbtd_server *nbtsrv,
- const char *name, enum nbt_name_type type,
- uint16_t nb_flags)
+void nbtd_register_name(struct nbtd_server *nbtsrv,
+ const char *name, enum nbt_name_type type,
+ uint16_t nb_flags)
{
struct nbtd_interface *iface;
@@ -260,29 +260,29 @@ void nbtd_register_names(struct nbtd_server *nbtsrv)
/* note that we don't initially mark the names "ACTIVE". They are
marked active once registration is successful */
- nbtd_register_name(nbtsrv, lp_netbios_name(), NBT_NAME_CLIENT, nb_flags);
- nbtd_register_name(nbtsrv, lp_netbios_name(), NBT_NAME_USER, nb_flags);
- nbtd_register_name(nbtsrv, lp_netbios_name(), NBT_NAME_SERVER, nb_flags);
+ nbtd_register_name(nbtsrv, lp_netbios_name(global_loadparm), NBT_NAME_CLIENT, nb_flags);
+ nbtd_register_name(nbtsrv, lp_netbios_name(global_loadparm), NBT_NAME_USER, nb_flags);
+ nbtd_register_name(nbtsrv, lp_netbios_name(global_loadparm), NBT_NAME_SERVER, nb_flags);
- aliases = lp_netbios_aliases();
+ aliases = lp_netbios_aliases(global_loadparm);
while (aliases && aliases[0]) {
nbtd_register_name(nbtsrv, aliases[0], NBT_NAME_CLIENT, nb_flags);
nbtd_register_name(nbtsrv, aliases[0], NBT_NAME_SERVER, nb_flags);
aliases++;
}
- if (lp_server_role() == ROLE_DOMAIN_CONTROLLER) {
- BOOL is_pdc = samdb_is_pdc(nbtsrv->sam_ctx);
+ if (lp_server_role(global_loadparm) == ROLE_DOMAIN_CONTROLLER) {
+ bool is_pdc = samdb_is_pdc(nbtsrv->sam_ctx);
if (is_pdc) {
- nbtd_register_name(nbtsrv, lp_workgroup(),
+ nbtd_register_name(nbtsrv, lp_workgroup(global_loadparm),
NBT_NAME_PDC, nb_flags);
}
- nbtd_register_name(nbtsrv, lp_workgroup(),
+ nbtd_register_name(nbtsrv, lp_workgroup(global_loadparm),
NBT_NAME_LOGON, nb_flags | NBT_NM_GROUP);
}
nb_flags |= NBT_NM_GROUP;
- nbtd_register_name(nbtsrv, lp_workgroup(), NBT_NAME_CLIENT, nb_flags);
+ nbtd_register_name(nbtsrv, lp_workgroup(global_loadparm), NBT_NAME_CLIENT, nb_flags);
nb_flags |= NBT_NM_PERMANENT;
nbtd_register_name(nbtsrv, "__SAMBA__", NBT_NAME_CLIENT, nb_flags);
diff --git a/source4/nbt_server/wins/wins_hook.c b/source4/nbt_server/wins/wins_hook.c
index 15c0088192..768f9477f6 100644
--- a/source4/nbt_server/wins/wins_hook.c
+++ b/source4/nbt_server/wins/wins_hook.c
@@ -24,6 +24,7 @@
#include "nbt_server/nbt_server.h"
#include "nbt_server/wins/winsdb.h"
#include "system/filesys.h"
+#include "param/param.h"
static const char *wins_hook_action_string(enum wins_hook_action action)
{
@@ -36,9 +37,10 @@ static const char *wins_hook_action_string(enum wins_hook_action action)
return "unknown";
}
-void wins_hook(struct winsdb_handle *h, const struct winsdb_record *rec, enum wins_hook_action action)
+void wins_hook(struct winsdb_handle *h, const struct winsdb_record *rec,
+ enum wins_hook_action action)
{
- const char *script = lp_wins_hook();
+ const char *script = lp_wins_hook(global_loadparm);
uint32_t i, length;
int child;
char *cmd = NULL;
@@ -65,7 +67,7 @@ void wins_hook(struct winsdb_handle *h, const struct winsdb_record *rec, enum wi
if (!cmd) goto failed;
for (i=0; rec->addresses[i]; i++) {
- cmd = talloc_asprintf_append(cmd, " %s", rec->addresses[i]->address);
+ cmd = talloc_asprintf_append_buffer(cmd, " %s", rec->addresses[i]->address);
if (!cmd) goto failed;
}
diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c
index 0b8856fd3b..3d22b5fe1b 100644
--- a/source4/nbt_server/wins/wins_ldb.c
+++ b/source4/nbt_server/wins/wins_ldb.c
@@ -35,6 +35,7 @@
#include "lib/ldb/include/ldb_private.h"
#include "system/network.h"
#include "lib/socket/netif.h"
+#include "param/param.h"
static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req)
{
@@ -86,7 +87,7 @@ static int wins_ldb_init(struct ldb_module *ctx)
ctx->private_data = NULL;
- owner = lp_parm_string(-1, "winsdb", "local_owner");
+ owner = lp_parm_string(global_loadparm, NULL, "winsdb", "local_owner");
if (!owner) {
owner = iface_n_ip(0);
if (!owner) {
diff --git a/source4/nbt_server/wins/winsclient.c b/source4/nbt_server/wins/winsclient.c
index 3c599022d4..d1342c3766 100644
--- a/source4/nbt_server/wins/winsclient.c
+++ b/source4/nbt_server/wins/winsclient.c
@@ -26,6 +26,7 @@
#include "lib/events/events.h"
#include "librpc/gen_ndr/ndr_nbt.h"
#include "smbd/service_task.h"
+#include "param/param.h"
static void nbtd_wins_refresh_handler(struct composite_context *c);
@@ -57,7 +58,7 @@ static void nbtd_wins_register_retry(struct event_context *ev, struct timed_even
static void nbtd_wins_start_refresh_timer(struct nbtd_iface_name *iname)
{
uint32_t refresh_time;
- uint32_t max_refresh_time = lp_parm_int(-1, "nbtd", "max_refresh_time", 7200);
+ uint32_t max_refresh_time = lp_parm_int(global_loadparm, NULL, "nbtd", "max_refresh_time", 7200);
refresh_time = MIN(max_refresh_time, iname->ttl/2);
@@ -178,7 +179,7 @@ static void nbtd_wins_register_handler(struct composite_context *c)
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
/* none of the WINS servers responded - try again
periodically */
- int wins_retry_time = lp_parm_int(-1, "nbtd", "wins_retry", 300);
+ int wins_retry_time = lp_parm_int(global_loadparm, NULL, "nbtd", "wins_retry", 300);
event_add_timed(iname->iface->nbtsrv->task->event_ctx,
iname,
timeval_current_ofs(wins_retry_time, 0),
@@ -235,7 +236,7 @@ void nbtd_winsclient_register(struct nbtd_iface_name *iname)
/* setup a wins name register request */
io.in.name = iname->name;
- io.in.wins_servers = lp_wins_server_list();
+ io.in.wins_servers = lp_wins_server_list(global_loadparm);
io.in.addresses = nbtd_address_list(iface, iname);
io.in.nb_flags = iname->nb_flags;
io.in.ttl = iname->ttl;
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 7b281ff831..91996b24d3 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -30,6 +30,7 @@
#include "db_wrap.h"
#include "system/network.h"
#include "lib/socket/netif.h"
+#include "param/param.h"
uint64_t winsdb_get_maxVersion(struct winsdb_handle *h)
{
@@ -365,8 +366,8 @@ static int winsdb_addr_sort_list (struct winsdb_addr **p1, struct winsdb_addr **
struct winsdb_addr *a1 = talloc_get_type(*p1, struct winsdb_addr);
struct winsdb_addr *a2 = talloc_get_type(*p2, struct winsdb_addr);
struct winsdb_handle *h= talloc_get_type(opaque, struct winsdb_handle);
- BOOL a1_owned = False;
- BOOL a2_owned = False;
+ bool a1_owned = false;
+ bool a2_owned = false;
/*
* first the owned addresses with the newest to the oldest address
@@ -377,11 +378,11 @@ static int winsdb_addr_sort_list (struct winsdb_addr **p1, struct winsdb_addr **
}
if (strcmp(a2->wins_owner, h->local_owner) == 0) {
- a2_owned = True;
+ a2_owned = true;
}
if (strcmp(a1->wins_owner, h->local_owner) == 0) {
- a1_owned = True;
+ a1_owned = true;
}
return a2_owned - a1_owned;
@@ -390,12 +391,12 @@ static int winsdb_addr_sort_list (struct winsdb_addr **p1, struct winsdb_addr **
struct winsdb_addr **winsdb_addr_list_add(struct winsdb_handle *h, const struct winsdb_record *rec,
struct winsdb_addr **addresses, const char *address,
const char *wins_owner, time_t expire_time,
- BOOL is_name_registration)
+ bool is_name_registration)
{
struct winsdb_addr *old_addr = NULL;
size_t len = 0;
size_t i;
- BOOL found_old_replica = False;
+ bool found_old_replica = false;
/*
* count the addresses and maybe
@@ -443,10 +444,10 @@ struct winsdb_addr **winsdb_addr_list_add(struct winsdb_handle *h, const struct
* record at all, find the oldest owned address
*/
for (i=0; addresses[i]; i++) {
- BOOL cur_is_replica = False;
+ bool cur_is_replica = false;
/* find out if the current address is a replica */
if (strcmp(addresses[i]->wins_owner, h->local_owner) != 0) {
- cur_is_replica = True;
+ cur_is_replica = true;
}
/*
@@ -460,7 +461,7 @@ struct winsdb_addr **winsdb_addr_list_add(struct winsdb_handle *h, const struct
* that would be replaced
*/
if (!found_old_replica && cur_is_replica) {
- found_old_replica = True;
+ found_old_replica = true;
old_addr = addresses[i];
continue;
}
@@ -620,7 +621,7 @@ NTSTATUS winsdb_record(struct winsdb_handle *h, struct ldb_message *msg, TALLOC_
struct ldb_message_element *el;
struct nbt_name *name;
uint32_t i, j, num_values;
- BOOL we_are_owner = False;
+ bool we_are_owner = false;
rec = talloc(mem_ctx, struct winsdb_record);
if (rec == NULL) {
@@ -682,7 +683,7 @@ NTSTATUS winsdb_record(struct winsdb_handle *h, struct ldb_message *msg, TALLOC_
}
if (strcmp(rec->wins_owner, h->local_owner) == 0) {
- we_are_owner = True;
+ we_are_owner = true;
}
/*
@@ -944,7 +945,7 @@ failed:
return NBT_RCODE_SVR;
}
-static BOOL winsdb_check_or_add_module_list(struct winsdb_handle *h)
+static bool winsdb_check_or_add_module_list(struct winsdb_handle *h)
{
int trans;
int ret;
@@ -987,26 +988,26 @@ static BOOL winsdb_check_or_add_module_list(struct winsdb_handle *h)
talloc_free(h->ldb);
h->ldb = NULL;
- if (lp_parm_bool(-1,"winsdb", "nosync", False)) {
+ if (lp_parm_bool(global_loadparm, NULL,"winsdb", "nosync", false)) {
flags |= LDB_FLG_NOSYNC;
}
- h->ldb = ldb_wrap_connect(h, lock_path(h, lp_wins_url()),
+ h->ldb = ldb_wrap_connect(h, global_loadparm, lock_path(h, global_loadparm, lp_wins_url(global_loadparm)),
NULL, NULL, flags, NULL);
if (!h->ldb) goto failed;
talloc_free(tmp_ctx);
- return True;
+ return true;
skip:
if (trans == LDB_SUCCESS) ldb_transaction_cancel(h->ldb);
talloc_free(tmp_ctx);
- return True;
+ return true;
failed:
if (trans == LDB_SUCCESS) ldb_transaction_cancel(h->ldb);
talloc_free(tmp_ctx);
- return False;
+ return false;
}
struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, enum winsdb_handle_caller caller)
@@ -1014,23 +1015,23 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, enum winsdb_handle_cal
struct winsdb_handle *h = NULL;
const char *owner;
unsigned int flags = 0;
- BOOL ret;
+ bool ret;
int ldb_err;
h = talloc(mem_ctx, struct winsdb_handle);
if (!h) return NULL;
- if (lp_parm_bool(-1,"winsdb", "nosync", False)) {
+ if (lp_parm_bool(global_loadparm, NULL,"winsdb", "nosync", false)) {
flags |= LDB_FLG_NOSYNC;
}
- h->ldb = ldb_wrap_connect(h, lock_path(h, lp_wins_url()),
+ h->ldb = ldb_wrap_connect(h, global_loadparm, lock_path(h, global_loadparm, lp_wins_url(global_loadparm)),
NULL, NULL, flags, NULL);
if (!h->ldb) goto failed;
h->caller = caller;
- owner = lp_parm_string(-1, "winsdb", "local_owner");
+ owner = lp_parm_string(global_loadparm, NULL, "winsdb", "local_owner");
if (!owner) {
owner = iface_n_ip(0);
}
diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c
index f75250ee41..2ff5e3f69b 100644
--- a/source4/nbt_server/wins/winsserver.c
+++ b/source4/nbt_server/wins/winsserver.c
@@ -32,6 +32,7 @@
#include "lib/socket/socket.h"
#include "lib/socket/netif.h"
#include "lib/ldb/include/ldb.h"
+#include "param/param.h"
/*
work out the ttl we will use given a client requested ttl
@@ -43,7 +44,7 @@ uint32_t wins_server_ttl(struct wins_server *winssrv, uint32_t ttl)
return ttl;
}
-static enum wrepl_name_type wrepl_type(uint16_t nb_flags, struct nbt_name *name, BOOL mhomed)
+static enum wrepl_name_type wrepl_type(uint16_t nb_flags, struct nbt_name *name, bool mhomed)
{
/* this copes with the nasty hack that is the type 0x1c name */
if (name->type == NBT_NAME_LOGON) {
@@ -85,7 +86,7 @@ static uint8_t wins_register_new(struct nbt_name_socket *nbtsock,
rec.type = type;
rec.state = WREPL_STATE_ACTIVE;
rec.node = node;
- rec.is_static = False;
+ rec.is_static = false;
rec.expire_time = time(NULL) + ttl;
rec.version = 0; /* will be allocated later */
rec.wins_owner = NULL; /* will be set later */
@@ -98,7 +99,7 @@ static uint8_t wins_register_new(struct nbt_name_socket *nbtsock,
address,
winssrv->wins_db->local_owner,
rec.expire_time,
- True);
+ true);
if (rec.addresses == NULL) return NBT_RCODE_SVR;
DEBUG(4,("WINS: accepted registration of %s with address %s\n",
@@ -133,7 +134,7 @@ static uint8_t wins_update_ttl(struct nbt_name_socket *nbtsock,
winsdb_addr->address,
winssrv->wins_db->local_owner,
rec->expire_time,
- True);
+ true);
if (rec->addresses == NULL) return NBT_RCODE_SVR;
}
@@ -169,7 +170,7 @@ static uint8_t wins_sgroup_merge(struct nbt_name_socket *nbtsock,
address,
winssrv->wins_db->local_owner,
rec->expire_time,
- True);
+ true);
if (rec->addresses == NULL) return NBT_RCODE_SVR;
DEBUG(5,("WINS: sgroup merge of %s at %s\n",
@@ -248,11 +249,11 @@ static void wins_wack_allow(struct wack_state *s)
* and update the time stamp and owner for the ownes that are still there
*/
for (i=0; rec->addresses[i]; i++) {
- BOOL found = False;
+ bool found = false;
for (j=0; j < s->io.out.num_addresses; j++) {
if (strcmp(rec->addresses[i]->address, s->io.out.addresses[j]) != 0) continue;
- found = True;
+ found = true;
break;
}
if (found) {
@@ -261,7 +262,7 @@ static void wins_wack_allow(struct wack_state *s)
s->reg_address,
s->winssrv->wins_db->local_owner,
rec->expire_time,
- True);
+ true);
if (rec->addresses == NULL) goto failed;
continue;
}
@@ -274,7 +275,7 @@ static void wins_wack_allow(struct wack_state *s)
s->reg_address,
s->winssrv->wins_db->local_owner,
rec->expire_time,
- True);
+ true);
if (rec->addresses == NULL) goto failed;
/* if we have more than one address, this becomes implicit a MHOMED record */
@@ -301,7 +302,7 @@ static void wack_wins_challenge_handler(struct composite_context *c_req)
{
struct wack_state *s = talloc_get_type(c_req->async.private_data,
struct wack_state);
- BOOL found;
+ bool found;
uint32_t i;
s->status = wins_challenge_recv(c_req, s, &s->io);
@@ -327,11 +328,11 @@ static void wack_wins_challenge_handler(struct composite_context *c_req)
* with the address trying to be registered, then deny
* the registration
*/
- found = False;
+ found = false;
for (i=0; i < s->io.out.num_addresses; i++) {
if (strcmp(s->reg_address, s->io.out.addresses[i]) != 0) continue;
- found = True;
+ found = true;
break;
}
if (!found) {
@@ -420,7 +421,7 @@ static void nbtd_winsserver_register(struct nbt_name_socket *nbtsock,
uint8_t rcode = NBT_RCODE_OK;
uint16_t nb_flags = packet->additional[0].rdata.netbios.addresses[0].nb_flags;
const char *address = packet->additional[0].rdata.netbios.addresses[0].ipaddr;
- BOOL mhomed = ((packet->operation & NBT_OPCODE) == NBT_OPCODE_MULTI_HOME_REG);
+ bool mhomed = ((packet->operation & NBT_OPCODE) == NBT_OPCODE_MULTI_HOME_REG);
enum wrepl_name_type new_type = wrepl_type(nb_flags, name, mhomed);
struct winsdb_addr *winsdb_addr = NULL;
@@ -614,7 +615,7 @@ static void nbtd_wins_randomize1Clist(const char **addresses, struct socket_addr
ldb_qsort(addresses, num_addrs , sizeof(addresses[0]),
src, (ldb_qsort_cmp_fn_t)nbtd_wins_randomize1Clist_sort);
- mask = lp_parm_string(-1, "nbtd", "wins_randomize1Clist_mask");
+ mask = lp_parm_string(global_loadparm, NULL, "nbtd", "wins_randomize1Clist_mask");
if (!mask) {
mask = "255.255.255.0";
}
@@ -627,7 +628,7 @@ static void nbtd_wins_randomize1Clist(const char **addresses, struct socket_addr
idx = sidx = r % num_addrs;
while (1) {
- BOOL same;
+ bool same;
/* if the current one is in the same subnet, use it */
same = iface_same_net(addresses[idx], src->addr, mask);
@@ -690,7 +691,8 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
* Typ: Daten REG_DWORD
* Value: 0 = deactivated, 1 = activated
*/
- if (name->type == NBT_NAME_LOGON && lp_parm_bool(-1, "nbtd", "wins_prepend1Bto1Cqueries", True)) {
+ if (name->type == NBT_NAME_LOGON &&
+ lp_parm_bool(global_loadparm, NULL, "nbtd", "wins_prepend1Bto1Cqueries", true)) {
struct nbt_name name_1b;
name_1b = *name;
@@ -704,7 +706,7 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
status = winsdb_lookup(winssrv->wins_db, name, packet, &rec);
if (!NT_STATUS_IS_OK(status)) {
- if (!lp_wins_dns_proxy()) {
+ if (!lp_wins_dns_proxy(global_loadparm)) {
goto notfound;
}
@@ -785,7 +787,8 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
* Typ: Daten REG_DWORD
* Value: 0 = deactivated, 1 = activated
*/
- if (name->type == NBT_NAME_LOGON && lp_parm_bool(-1, "nbtd", "wins_randomize1Clist", False)) {
+ if (name->type == NBT_NAME_LOGON &&
+ lp_parm_bool(global_loadparm, NULL, "nbtd", "wins_randomize1Clist", false)) {
nbtd_wins_randomize1Clist(addresses, src);
}
@@ -954,7 +957,7 @@ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv)
{
uint32_t tmp;
- if (!lp_wins_support()) {
+ if (!lp_wins_support(global_loadparm)) {
nbtsrv->winssrv = NULL;
return NT_STATUS_OK;
}
@@ -962,11 +965,11 @@ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv)
nbtsrv->winssrv = talloc_zero(nbtsrv, struct wins_server);
NT_STATUS_HAVE_NO_MEMORY(nbtsrv->winssrv);
- nbtsrv->winssrv->config.max_renew_interval = lp_max_wins_ttl();
- nbtsrv->winssrv->config.min_renew_interval = lp_min_wins_ttl();
- tmp = lp_parm_int(-1,"wreplsrv","tombstone_interval", 6*24*60*60);
+ nbtsrv->winssrv->config.max_renew_interval = lp_max_wins_ttl(global_loadparm);
+ nbtsrv->winssrv->config.min_renew_interval = lp_min_wins_ttl(global_loadparm);
+ tmp = lp_parm_int(global_loadparm, NULL, "wreplsrv", "tombstone_interval", 6*24*60*60);
nbtsrv->winssrv->config.tombstone_interval = tmp;
- tmp = lp_parm_int(-1,"wreplsrv","tombstone_timeout", 1*24*60*60);
+ tmp = lp_parm_int(global_loadparm, NULL, "wreplsrv"," tombstone_timeout", 1*24*60*60);
nbtsrv->winssrv->config.tombstone_timeout = tmp;
nbtsrv->winssrv->wins_db = winsdb_connect(nbtsrv->winssrv, WINSDB_HANDLE_CALLER_NBTD);
diff --git a/source4/nbt_server/wins/winswack.c b/source4/nbt_server/wins/winswack.c
index a2b479673a..304edcf8de 100644
--- a/source4/nbt_server/wins/winswack.c
+++ b/source4/nbt_server/wins/winswack.c
@@ -48,7 +48,7 @@ static void wins_challenge_handler(struct nbt_name_request *req)
state->query.in.dest_addr = state->io->in.addresses[state->current_address];
- iface = nbtd_find_request_iface(state->io->in.nbtd_server, state->query.in.dest_addr, True);
+ iface = nbtd_find_request_iface(state->io->in.nbtd_server, state->query.in.dest_addr, true);
if (!iface) {
composite_error(ctx, NT_STATUS_INTERNAL_ERROR);
return;
@@ -104,13 +104,13 @@ struct composite_context *wins_challenge_send(TALLOC_CTX *mem_ctx, struct wins_c
/* setup a name query to the first address */
state->query.in.name = *state->io->in.name;
state->query.in.dest_addr = state->io->in.addresses[state->current_address];
- state->query.in.broadcast = False;
- state->query.in.wins_lookup = True;
+ state->query.in.broadcast = false;
+ state->query.in.wins_lookup = true;
state->query.in.timeout = 1;
state->query.in.retries = 2;
ZERO_STRUCT(state->query.out);
- iface = nbtd_find_request_iface(state->io->in.nbtd_server, state->query.in.dest_addr, True);
+ iface = nbtd_find_request_iface(state->io->in.nbtd_server, state->query.in.dest_addr, true);
if (!iface) {
goto failed;
}
@@ -164,7 +164,7 @@ static void wins_release_demand_handler(struct nbt_name_request *req)
state->release.in.timeout = (state->addresses_left > 1 ? 2 : 1);
state->release.in.retries = (state->addresses_left > 1 ? 0 : 2);
- iface = nbtd_find_request_iface(state->io->in.nbtd_server, state->release.in.dest_addr, True);
+ iface = nbtd_find_request_iface(state->io->in.nbtd_server, state->release.in.dest_addr, true);
if (!iface) {
composite_error(ctx, NT_STATUS_INTERNAL_ERROR);
return;
@@ -220,12 +220,12 @@ static struct composite_context *wins_release_demand_send(TALLOC_CTX *mem_ctx, s
state->release.in.name = *state->io->in.name;
state->release.in.dest_addr = state->io->in.addresses[state->current_address];
state->release.in.address = state->release.in.dest_addr;
- state->release.in.broadcast = False;
+ state->release.in.broadcast = false;
state->release.in.timeout = (state->addresses_left > 1 ? 2 : 1);
state->release.in.retries = (state->addresses_left > 1 ? 0 : 2);
ZERO_STRUCT(state->release.out);
- iface = nbtd_find_request_iface(state->io->in.nbtd_server, state->release.in.dest_addr, True);
+ iface = nbtd_find_request_iface(state->io->in.nbtd_server, state->release.in.dest_addr, true);
if (!iface) {
goto failed;
}
@@ -316,7 +316,7 @@ NTSTATUS nbtd_proxy_wins_challenge(struct irpc_message *msg,
s->c_req->async.fn = proxy_wins_challenge_handler;
s->c_req->async.private_data = s;
- msg->defer_reply = True;
+ msg->defer_reply = true;
return NT_STATUS_OK;
}
@@ -375,6 +375,6 @@ NTSTATUS nbtd_proxy_wins_release_demand(struct irpc_message *msg,
s->c_req->async.fn = proxy_wins_release_demand_handler;
s->c_req->async.private_data = s;
- msg->defer_reply = True;
+ msg->defer_reply = true;
return NT_STATUS_OK;
}
diff --git a/source4/nsswitch/nsstest.c b/source4/nsswitch/nsstest.c
index 6c21576c2d..df7f33f8e0 100644
--- a/source4/nsswitch/nsstest.c
+++ b/source4/nsswitch/nsstest.c
@@ -145,13 +145,13 @@ static struct group *nss_getgrent(void)
static int buflen = 1024;
NSS_STATUS status;
- if (!buf) buf = malloc(buflen);
+ if (!buf) buf = malloc_array_p(char, buflen);
again:
status = _nss_getgrent_r(&grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
buflen *= 2;
- buf = realloc(buf, buflen);
+ buf = realloc_p(buf, char, buflen);
goto again;
}
if (status == NSS_STATUS_NOTFOUND) {
@@ -173,12 +173,12 @@ static struct group *nss_getgrnam(const char *name)
static int buflen = 1000;
NSS_STATUS status;
- if (!buf) buf = malloc(buflen);
+ if (!buf) buf = malloc_array_p(char, buflen);
again:
status = _nss_getgrnam_r(name, &grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
buflen *= 2;
- buf = realloc(buf, buflen);
+ buf = realloc_p(buf, char, buflen);
goto again;
}
if (status == NSS_STATUS_NOTFOUND) {
@@ -200,12 +200,12 @@ static struct group *nss_getgrgid(gid_t gid)
static int buflen = 1000;
NSS_STATUS status;
- if (!buf) buf = malloc(buflen);
+ if (!buf) buf = malloc_array_p(char, buflen);
again:
status = _nss_getgrgid_r(gid, &grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
buflen *= 2;
- buf = realloc(buf, buflen);
+ buf = realloc_p(buf, char, buflen);
goto again;
}
if (status == NSS_STATUS_NOTFOUND) {
diff --git a/source4/nsswitch/wb_common.c b/source4/nsswitch/wb_common.c
index e8ea31db0f..2ae85dcb1e 100644
--- a/source4/nsswitch/wb_common.c
+++ b/source4/nsswitch/wb_common.c
@@ -22,16 +22,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "includes.h"
-#include "nsswitch/winbind_client.h"
+#include "winbind_client.h"
/* Global variables. These are effectively the client state information */
int winbindd_fd = -1; /* fd for winbindd socket */
+static int is_privileged = 0;
/* Free a response structure */
-void free_response(struct winbindd_response *response)
+void winbindd_free_response(struct winbindd_response *response)
{
/* Free any allocated extra_data */
@@ -41,7 +41,7 @@ void free_response(struct winbindd_response *response)
/* Initialise a request structure */
-void init_request(struct winbindd_request *request, int request_type)
+void winbindd_init_request(struct winbindd_request *request, int request_type)
{
request->length = sizeof(struct winbindd_request);
@@ -52,7 +52,7 @@ void init_request(struct winbindd_request *request, int request_type)
/* Initialise a response structure */
-void init_response(struct winbindd_response *response)
+static void init_response(struct winbindd_response *response)
{
/* Initialise return value */
@@ -61,7 +61,7 @@ void init_response(struct winbindd_response *response)
/* Close established socket */
-void close_sock(void)
+void winbind_close_sock(void)
{
if (winbindd_fd != -1) {
close(winbindd_fd);
@@ -70,10 +70,6 @@ void close_sock(void)
}
#define CONNECT_TIMEOUT 30
-#if 0 /* unused */
-#define WRITE_TIMEOUT CONNECT_TIMEOUT
-#define READ_TIMEOUT CONNECT_TIMEOUT
-#endif
/* Make sure socket handle isn't stdin, stdout or stderr */
#define RECURSION_LIMIT 3
@@ -172,7 +168,7 @@ static int winbind_named_pipe_sock(const char *dir)
{
struct sockaddr_un sunaddr;
struct stat st;
- char *path;
+ pstring path;
int fd;
int wait_time;
int slept;
@@ -189,8 +185,16 @@ static int winbind_named_pipe_sock(const char *dir)
}
/* Connect to socket */
-
- asprintf(&path, "%s%s", dir, "/" WINBINDD_SOCKET_NAME);
+
+ strncpy(path, dir, sizeof(path) - 1);
+ path[sizeof(path) - 1] = '\0';
+
+ strncat(path, "/", sizeof(path) - 1 - strlen(path));
+ path[sizeof(path) - 1] = '\0';
+
+ strncat(path, WINBINDD_SOCKET_NAME, sizeof(path) - 1 - strlen(path));
+ path[sizeof(path) - 1] = '\0';
+
ZERO_STRUCT(sunaddr);
sunaddr.sun_family = AF_UNIX;
strncpy(sunaddr.sun_path, path, sizeof(sunaddr.sun_path) - 1);
@@ -200,11 +204,8 @@ static int winbind_named_pipe_sock(const char *dir)
the winbindd daemon is not running. */
if (lstat(path, &st) == -1) {
- SAFE_FREE(path);
return -1;
}
-
- SAFE_FREE(path);
/* Check permissions on unix socket file */
@@ -277,72 +278,80 @@ static int winbind_named_pipe_sock(const char *dir)
close(fd);
return -1;
+}
- if (connect(fd, (struct sockaddr *)&sunaddr,
- sizeof(sunaddr)) == -1) {
- close(fd);
- return -1;
+static const char *winbindd_socket_dir(void)
+{
+#ifdef SOCKET_WRAPPER
+ const char *env_dir;
+
+ env_dir = getenv(WINBINDD_SOCKET_DIR_ENVVAR);
+ if (env_dir) {
+ return env_dir;
}
-
- return fd;
+#endif
+
+ return WINBINDD_SOCKET_DIR;
}
/* Connect to winbindd socket */
-int winbind_open_pipe_sock(void)
+static int winbind_open_pipe_sock(int recursing, int need_priv)
{
#ifdef HAVE_UNIXSOCKET
static pid_t our_pid;
struct winbindd_request request;
struct winbindd_response response;
- const char *winbindd_socket_dir_env;
ZERO_STRUCT(request);
ZERO_STRUCT(response);
if (our_pid != getpid()) {
- close_sock();
+ winbind_close_sock();
our_pid = getpid();
}
+
+ if ((need_priv != 0) && (is_privileged == 0)) {
+ winbind_close_sock();
+ }
if (winbindd_fd != -1) {
return winbindd_fd;
}
-#ifdef SOCKET_WRAPPER
- winbindd_socket_dir_env = getenv(WINBINDD_SOCKET_DIR_ENV);
-
- if (!winbindd_socket_dir_env)
- {
- winbindd_socket_dir_env = WINBINDD_SOCKET_DIR;
+ if (recursing) {
+ return -1;
}
-#else
- winbindd_socket_dir_env = WINBINDD_SOCKET_DIR;
-#endif
-
- winbindd_fd = winbind_named_pipe_sock(winbindd_socket_dir_env);
- if (winbindd_fd == -1)
- {
+ if ((winbindd_fd = winbind_named_pipe_sock(winbindd_socket_dir())) == -1) {
return -1;
}
+ is_privileged = 0;
+
/* version-check the socket */
- if ((winbindd_request(WINBINDD_INTERFACE_VERSION, &request, &response) != NSS_STATUS_SUCCESS) || (response.data.interface_version != WINBIND_INTERFACE_VERSION)) {
- close_sock();
+ request.wb_flags = WBFLAG_RECURSE;
+ if ((winbindd_request_response(WINBINDD_INTERFACE_VERSION, &request, &response) != NSS_STATUS_SUCCESS) || (response.data.interface_version != WINBIND_INTERFACE_VERSION)) {
+ winbind_close_sock();
return -1;
}
/* try and get priv pipe */
- if (winbindd_request(WINBINDD_PRIV_PIPE_DIR, &request, &response) == NSS_STATUS_SUCCESS) {
+ request.wb_flags = WBFLAG_RECURSE;
+ if (winbindd_request_response(WINBINDD_PRIV_PIPE_DIR, &request, &response) == NSS_STATUS_SUCCESS) {
int fd;
- if ((fd = winbind_named_pipe_sock(response.extra_data.data)) != -1) {
+ if ((fd = winbind_named_pipe_sock((char *)response.extra_data.data)) != -1) {
close(winbindd_fd);
winbindd_fd = fd;
+ is_privileged = 1;
}
}
+ if ((need_priv != 0) && (is_privileged == 0)) {
+ return -1;
+ }
+
SAFE_FREE(response.extra_data.data);
return winbindd_fd;
@@ -353,7 +362,7 @@ int winbind_open_pipe_sock(void)
/* Write data to winbindd socket */
-int write_sock(void *buffer, int count)
+int winbind_write_sock(void *buffer, int count, int recursing, int need_priv)
{
int result, nwritten;
@@ -361,7 +370,7 @@ int write_sock(void *buffer, int count)
restart:
- if (winbind_open_pipe_sock() == -1) {
+ if (winbind_open_pipe_sock(recursing, need_priv) == -1) {
return -1;
}
@@ -381,7 +390,7 @@ int write_sock(void *buffer, int count)
ZERO_STRUCT(tv);
if (select(winbindd_fd + 1, &r_fds, NULL, NULL, &tv) == -1) {
- close_sock();
+ winbind_close_sock();
return -1; /* Select error */
}
@@ -399,7 +408,7 @@ int write_sock(void *buffer, int count)
/* Write failed */
- close_sock();
+ winbind_close_sock();
return -1;
}
@@ -409,7 +418,7 @@ int write_sock(void *buffer, int count)
/* Pipe has closed on remote end */
- close_sock();
+ winbind_close_sock();
goto restart;
}
}
@@ -419,11 +428,15 @@ int write_sock(void *buffer, int count)
/* Read data from winbindd socket */
-static int read_sock(void *buffer, int count)
+int winbind_read_sock(void *buffer, int count)
{
int nread = 0;
int total_time = 0, selret;
+ if (winbindd_fd == -1) {
+ return -1;
+ }
+
/* Read data from socket */
while(nread < count) {
struct timeval tv;
@@ -439,7 +452,7 @@ static int read_sock(void *buffer, int count)
tv.tv_sec = 5;
if ((selret = select(winbindd_fd + 1, &r_fds, NULL, NULL, &tv)) == -1) {
- close_sock();
+ winbind_close_sock();
return -1; /* Select error */
}
@@ -447,7 +460,7 @@ static int read_sock(void *buffer, int count)
/* Not ready for read yet... */
if (total_time >= 30) {
/* Timeout */
- close_sock();
+ winbind_close_sock();
return -1;
}
total_time += 5;
@@ -467,7 +480,7 @@ static int read_sock(void *buffer, int count)
can do here is just return -1 and fail since the
transaction has failed half way through. */
- close_sock();
+ winbind_close_sock();
return -1;
}
@@ -481,7 +494,7 @@ static int read_sock(void *buffer, int count)
/* Read reply */
-int read_reply(struct winbindd_response *response)
+int winbindd_read_reply(struct winbindd_response *response)
{
int result1, result2 = 0;
@@ -491,9 +504,9 @@ int read_reply(struct winbindd_response *response)
/* Read fixed length response */
- if ((result1 = read_sock(response, sizeof(struct winbindd_response)))
- == -1) {
-
+ result1 = winbind_read_sock(response,
+ sizeof(struct winbindd_response));
+ if (result1 == -1) {
return -1;
}
@@ -515,9 +528,10 @@ int read_reply(struct winbindd_response *response)
return -1;
}
- if ((result2 = read_sock(response->extra_data.data, extra_data_len))
- == -1) {
- free_response(response);
+ result2 = winbind_read_sock(response->extra_data.data,
+ extra_data_len);
+ if (result2 == -1) {
+ winbindd_free_response(response);
return -1;
}
}
@@ -527,22 +541,31 @@ int read_reply(struct winbindd_response *response)
return result1 + result2;
}
+bool winbind_env_set(void)
+{
+ char *env;
+
+ if ((env=getenv(WINBINDD_DONT_ENV)) != NULL) {
+ if(strcmp(env, "1") == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
/*
* send simple types of requests
*/
-NSS_STATUS winbindd_send_request(int req_type, struct winbindd_request *request)
+NSS_STATUS winbindd_send_request(int req_type, int need_priv,
+ struct winbindd_request *request)
{
struct winbindd_request lrequest;
- char *env;
- int value;
-
+
/* Check for our tricky environment variable */
- if ( (env = getenv(WINBINDD_DONT_ENV)) != NULL ) {
- value = atoi(env);
- if ( value == 1 )
- return NSS_STATUS_NOTFOUND;
+ if (winbind_env_set()) {
+ return NSS_STATUS_NOTFOUND;
}
if (!request) {
@@ -552,9 +575,19 @@ NSS_STATUS winbindd_send_request(int req_type, struct winbindd_request *request)
/* Fill in request and send down pipe */
- init_request(request, req_type);
+ winbindd_init_request(request, req_type);
- if (write_sock(request, sizeof(*request)) == -1) {
+ if (winbind_write_sock(request, sizeof(*request),
+ request->wb_flags & WBFLAG_RECURSE,
+ need_priv) == -1) {
+ return NSS_STATUS_UNAVAIL;
+ }
+
+ if ((request->extra_len != 0) &&
+ (winbind_write_sock(request->extra_data.data,
+ request->extra_len,
+ request->wb_flags & WBFLAG_RECURSE,
+ need_priv) == -1)) {
return NSS_STATUS_UNAVAIL;
}
@@ -577,13 +610,13 @@ NSS_STATUS winbindd_get_response(struct winbindd_response *response)
init_response(response);
/* Wait for reply */
- if (read_reply(response) == -1) {
+ if (winbindd_read_reply(response) == -1) {
return NSS_STATUS_UNAVAIL;
}
/* Throw away extra data if client didn't request it */
if (response == &lresponse) {
- free_response(response);
+ winbindd_free_response(response);
}
/* Copy reply data from socket */
@@ -596,16 +629,40 @@ NSS_STATUS winbindd_get_response(struct winbindd_response *response)
/* Handle simple types of requests */
-NSS_STATUS winbindd_request(int req_type,
+NSS_STATUS winbindd_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response)
{
- NSS_STATUS status;
+ NSS_STATUS status = NSS_STATUS_UNAVAIL;
+ int count = 0;
- status = winbindd_send_request(req_type, request);
- if (status != NSS_STATUS_SUCCESS)
- return(status);
- return winbindd_get_response(response);
+ while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
+ status = winbindd_send_request(req_type, 0, request);
+ if (status != NSS_STATUS_SUCCESS)
+ return(status);
+ status = winbindd_get_response(response);
+ count += 1;
+ }
+
+ return status;
+}
+
+NSS_STATUS winbindd_priv_request_response(int req_type,
+ struct winbindd_request *request,
+ struct winbindd_response *response)
+{
+ NSS_STATUS status = NSS_STATUS_UNAVAIL;
+ int count = 0;
+
+ while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
+ status = winbindd_send_request(req_type, 1, request);
+ if (status != NSS_STATUS_SUCCESS)
+ return(status);
+ status = winbindd_get_response(response);
+ count += 1;
+ }
+
+ return status;
}
/*************************************************************************
@@ -613,14 +670,35 @@ NSS_STATUS winbindd_request(int req_type,
enable them
************************************************************************/
-BOOL winbind_off( void )
+bool winbind_off(void)
{
- setenv(WINBINDD_DONT_ENV, "1", 1);
- return True;
+ return setenv(WINBINDD_DONT_ENV, "1", 1) != -1;
}
-BOOL winbind_on( void )
+bool winbind_on(void)
{
- setenv(WINBINDD_DONT_ENV, "0", 1);
- return True;
+ return setenv(WINBINDD_DONT_ENV, "0", 1) != -1;
+}
+
+/*************************************************************************
+ ************************************************************************/
+
+const char *nss_err_str(NSS_STATUS ret)
+{
+ switch (ret) {
+ case NSS_STATUS_TRYAGAIN:
+ return "NSS_STATUS_TRYAGAIN";
+ case NSS_STATUS_SUCCESS:
+ return "NSS_STATUS_SUCCESS";
+ case NSS_STATUS_NOTFOUND:
+ return "NSS_STATUS_NOTFOUND";
+ case NSS_STATUS_UNAVAIL:
+ return "NSS_STATUS_UNAVAIL";
+#ifdef NSS_STATUS_RETURN
+ case NSS_STATUS_RETURN:
+ return "NSS_STATUS_RETURN";
+#endif
+ default:
+ return "UNKNOWN RETURN CODE!!!!!!!";
+ }
}
diff --git a/source4/nsswitch/wbinfo.c b/source4/nsswitch/wbinfo.c
index 7e674fde1f..4538911f97 100644
--- a/source4/nsswitch/wbinfo.c
+++ b/source4/nsswitch/wbinfo.c
@@ -22,21 +22,20 @@
#include "includes.h"
#include "pstring.h"
-#include "winbind_nss_config.h"
-#include "winbindd_nss.h"
#include "winbind_client.h"
#include "librpc/gen_ndr/ndr_netlogon.h"
#include "libcli/auth/libcli_auth.h"
#include "libcli/security/security.h"
#include "lib/cmdline/popt_common.h"
#include "dynconfig.h"
+#include "param/param.h"
extern int winbindd_fd;
-static char winbind_separator_int(BOOL strict)
+static char winbind_separator_int(bool strict)
{
struct winbindd_response response;
- static BOOL got_sep;
+ static bool got_sep;
static char sep;
if (got_sep)
@@ -46,18 +45,18 @@ static char winbind_separator_int(BOOL strict)
/* Send off request */
- if (winbindd_request(WINBINDD_INFO, NULL, &response) !=
+ if (winbindd_request_response(WINBINDD_INFO, NULL, &response) !=
NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "could not obtain winbind separator!\n");
if (strict) {
return 0;
}
/* HACK: (this module should not call lp_ funtions) */
- return *lp_winbind_separator();
+ return *lp_winbind_separator(global_loadparm);
}
sep = response.data.info.winbind_separator;
- got_sep = True;
+ got_sep = true;
if (!sep) {
d_fprintf(stderr, "winbind separator was NULL!\n");
@@ -65,7 +64,7 @@ static char winbind_separator_int(BOOL strict)
return 0;
}
/* HACK: (this module should not call lp_ funtions) */
- sep = *lp_winbind_separator();
+ sep = *lp_winbind_separator(global_loadparm);
}
return sep;
@@ -73,7 +72,7 @@ static char winbind_separator_int(BOOL strict)
static char winbind_separator(void)
{
- return winbind_separator_int(False);
+ return winbind_separator_int(false);
}
static const char *get_winbind_domain(void)
@@ -85,12 +84,12 @@ static const char *get_winbind_domain(void)
/* Send off request */
- if (winbindd_request(WINBINDD_DOMAIN_NAME, NULL, &response) !=
+ if (winbindd_request_response(WINBINDD_DOMAIN_NAME, NULL, &response) !=
NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "could not obtain winbind domain name!\n");
/* HACK: (this module should not call lp_ funtions) */
- return lp_workgroup();
+ return lp_workgroup(global_loadparm);
}
fstrcpy(winbind_domain, response.data.domain_name);
@@ -102,7 +101,7 @@ static const char *get_winbind_domain(void)
/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
form DOMAIN/user into a domain and a user */
-static BOOL parse_wbinfo_domain_user(const char *domuser, fstring domain,
+static bool parse_wbinfo_domain_user(const char *domuser, fstring domain,
fstring user)
{
@@ -111,7 +110,7 @@ static BOOL parse_wbinfo_domain_user(const char *domuser, fstring domain,
if (!p) {
fstrcpy(user, domuser);
fstrcpy(domain, get_winbind_domain());
- return True;
+ return true;
}
fstrcpy(user, p+1);
@@ -119,12 +118,12 @@ static BOOL parse_wbinfo_domain_user(const char *domuser, fstring domain,
domain[PTR_DIFF(p, domuser)] = 0;
strupper_m(domain);
- return True;
+ return true;
}
/* pull pwent info for a given user */
-static BOOL wbinfo_get_userinfo(char *user)
+static bool wbinfo_get_userinfo(char *user)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -137,10 +136,10 @@ static BOOL wbinfo_get_userinfo(char *user)
fstrcpy(request.data.username, user);
- result = winbindd_request(WINBINDD_GETPWNAM, &request, &response);
+ result = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
if (result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
d_printf( "%s:%s:%d:%d:%s:%s:%s\n",
response.data.pw.pw_name,
@@ -151,11 +150,11 @@ static BOOL wbinfo_get_userinfo(char *user)
response.data.pw.pw_dir,
response.data.pw.pw_shell );
- return True;
+ return true;
}
/* pull pwent info for a given uid */
-static BOOL wbinfo_get_uidinfo(int uid)
+static bool wbinfo_get_uidinfo(int uid)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -166,10 +165,10 @@ static BOOL wbinfo_get_uidinfo(int uid)
request.data.uid = uid;
- result = winbindd_request(WINBINDD_GETPWUID, &request, &response);
+ result = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
if (result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
d_printf( "%s:%s:%d:%d:%s:%s:%s\n",
response.data.pw.pw_name,
@@ -180,11 +179,11 @@ static BOOL wbinfo_get_uidinfo(int uid)
response.data.pw.pw_dir,
response.data.pw.pw_shell );
- return True;
+ return true;
}
/* pull grent for a given group */
-static BOOL wbinfo_get_groupinfo(char *group)
+static bool wbinfo_get_groupinfo(char *group)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -197,23 +196,23 @@ static BOOL wbinfo_get_groupinfo(char *group)
fstrcpy(request.data.groupname, group);
- result = winbindd_request(WINBINDD_GETGRNAM, &request,
+ result = winbindd_request_response(WINBINDD_GETGRNAM, &request,
&response);
if ( result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
d_printf( "%s:%s:%d\n",
response.data.gr.gr_name,
response.data.gr.gr_passwd,
response.data.gr.gr_gid );
- return True;
+ return true;
}
/* List groups a user is a member of */
-static BOOL wbinfo_get_usergroups(char *user)
+static bool wbinfo_get_usergroups(char *user)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -227,22 +226,22 @@ static BOOL wbinfo_get_usergroups(char *user)
fstrcpy(request.data.username, user);
- result = winbindd_request(WINBINDD_GETGROUPS, &request, &response);
+ result = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
if (result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
for (i = 0; i < response.data.num_entries; i++)
d_printf("%d\n", (int)((gid_t *)response.extra_data.data)[i]);
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
/* List group SIDs a user SID is a member of */
-static BOOL wbinfo_get_usersids(char *user_sid)
+static bool wbinfo_get_usersids(char *user_sid)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -256,10 +255,10 @@ static BOOL wbinfo_get_usersids(char *user_sid)
/* Send request */
fstrcpy(request.data.sid, user_sid);
- result = winbindd_request(WINBINDD_GETUSERSIDS, &request, &response);
+ result = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
if (result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
s = (const char *)response.extra_data.data;
for (i = 0; i < response.data.num_entries; i++) {
@@ -269,10 +268,10 @@ static BOOL wbinfo_get_usersids(char *user_sid)
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
-static BOOL wbinfo_get_userdomgroups(const char *user_sid)
+static bool wbinfo_get_userdomgroups(const char *user_sid)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -284,23 +283,23 @@ static BOOL wbinfo_get_userdomgroups(const char *user_sid)
/* Send request */
fstrcpy(request.data.sid, user_sid);
- result = winbindd_request(WINBINDD_GETUSERDOMGROUPS, &request,
+ result = winbindd_request_response(WINBINDD_GETUSERDOMGROUPS, &request,
&response);
if (result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
if (response.data.num_entries != 0)
printf("%s", (char *)response.extra_data.data);
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
/* Convert NetBIOS name to IP */
-static BOOL wbinfo_wins_byname(char *name)
+static bool wbinfo_wins_byname(char *name)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -312,21 +311,21 @@ static BOOL wbinfo_wins_byname(char *name)
fstrcpy(request.data.winsreq, name);
- if (winbindd_request(WINBINDD_WINS_BYNAME, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response) !=
NSS_STATUS_SUCCESS) {
- return False;
+ return false;
}
/* Display response */
d_printf("%s\n", response.data.winsresp);
- return True;
+ return true;
}
/* Convert IP to NetBIOS name */
-static BOOL wbinfo_wins_byip(char *ip)
+static bool wbinfo_wins_byip(char *ip)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -338,21 +337,21 @@ static BOOL wbinfo_wins_byip(char *ip)
fstrcpy(request.data.winsreq, ip);
- if (winbindd_request(WINBINDD_WINS_BYIP, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response) !=
NSS_STATUS_SUCCESS) {
- return False;
+ return false;
}
/* Display response */
d_printf("%s\n", response.data.winsresp);
- return True;
+ return true;
}
/* List trusted domains */
-static BOOL wbinfo_list_domains(BOOL list_all_domains)
+static bool wbinfo_list_domains(bool list_all_domains)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -364,9 +363,9 @@ static BOOL wbinfo_list_domains(BOOL list_all_domains)
request.data.list_all_domains = list_all_domains;
- if (winbindd_request(WINBINDD_LIST_TRUSTDOM, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
@@ -380,7 +379,7 @@ static BOOL wbinfo_list_domains(BOOL list_all_domains)
if (p == 0) {
d_fprintf(stderr, "Got invalid response: %s\n",
extra_data);
- return False;
+ return false;
}
*p = 0;
d_printf("%s\n", name);
@@ -389,20 +388,20 @@ static BOOL wbinfo_list_domains(BOOL list_all_domains)
SAFE_FREE(response.extra_data.data);
}
- return True;
+ return true;
}
/* List own domain */
-static BOOL wbinfo_list_own_domain(void)
+static bool wbinfo_list_own_domain(void)
{
d_printf("%s\n", get_winbind_domain());
- return True;
+ return true;
}
/* show sequence numbers */
-static BOOL wbinfo_show_sequence(const char *domain)
+static bool wbinfo_show_sequence(const char *domain)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -415,9 +414,9 @@ static BOOL wbinfo_show_sequence(const char *domain)
/* Send request */
- if (winbindd_request(WINBINDD_SHOW_SEQUENCE, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_SHOW_SEQUENCE, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
@@ -427,12 +426,12 @@ static BOOL wbinfo_show_sequence(const char *domain)
SAFE_FREE(response.extra_data.data);
}
- return True;
+ return true;
}
/* Show domain info */
-static BOOL wbinfo_domain_info(const char *domain_name)
+static bool wbinfo_domain_info(const char *domain_name)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -447,9 +446,9 @@ static BOOL wbinfo_domain_info(const char *domain_name)
/* Send request */
- if (winbindd_request(WINBINDD_DOMAIN_INFO, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_DOMAIN_INFO, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
@@ -466,13 +465,11 @@ static BOOL wbinfo_domain_info(const char *domain_name)
d_printf("Primary : %s\n",
response.data.domain_info.primary ? "Yes" : "No");
- d_printf("Sequence : %d\n", response.data.domain_info.sequence_number);
-
- return True;
+ return true;
}
/* Get a foreign DC's name */
-static BOOL wbinfo_getdcname(const char *domain_name)
+static bool wbinfo_getdcname(const char *domain_name)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -484,29 +481,29 @@ static BOOL wbinfo_getdcname(const char *domain_name)
/* Send request */
- if (winbindd_request(WINBINDD_GETDCNAME, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_GETDCNAME, &request, &response) !=
NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "Could not get dc name for %s\n", domain_name);
- return False;
+ return false;
}
/* Display response */
d_printf("%s\n", response.data.dc_name);
- return True;
+ return true;
}
/* Check trust account password */
-static BOOL wbinfo_check_secret(void)
+static bool wbinfo_check_secret(void)
{
struct winbindd_response response;
NSS_STATUS result;
ZERO_STRUCT(response);
- result = winbindd_request(WINBINDD_CHECK_MACHACC, NULL, &response);
+ result = winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response);
d_printf("checking the trust secret via RPC calls %s\n",
(result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
@@ -521,7 +518,7 @@ static BOOL wbinfo_check_secret(void)
/* Convert uid to sid */
-static BOOL wbinfo_uid_to_sid(uid_t uid)
+static bool wbinfo_uid_to_sid(uid_t uid)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -533,20 +530,20 @@ static BOOL wbinfo_uid_to_sid(uid_t uid)
request.data.uid = uid;
- if (winbindd_request(WINBINDD_UID_TO_SID, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%s\n", response.data.sid.sid);
- return True;
+ return true;
}
/* Convert gid to sid */
-static BOOL wbinfo_gid_to_sid(gid_t gid)
+static bool wbinfo_gid_to_sid(gid_t gid)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -558,20 +555,20 @@ static BOOL wbinfo_gid_to_sid(gid_t gid)
request.data.gid = gid;
- if (winbindd_request(WINBINDD_GID_TO_SID, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%s\n", response.data.sid.sid);
- return True;
+ return true;
}
/* Convert sid to uid */
-static BOOL wbinfo_sid_to_uid(char *sid)
+static bool wbinfo_sid_to_uid(char *sid)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -583,18 +580,18 @@ static BOOL wbinfo_sid_to_uid(char *sid)
fstrcpy(request.data.sid, sid);
- if (winbindd_request(WINBINDD_SID_TO_UID, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%d\n", (int)response.data.uid);
- return True;
+ return true;
}
-static BOOL wbinfo_sid_to_gid(char *sid)
+static bool wbinfo_sid_to_gid(char *sid)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -606,20 +603,20 @@ static BOOL wbinfo_sid_to_gid(char *sid)
fstrcpy(request.data.sid, sid);
- if (winbindd_request(WINBINDD_SID_TO_GID, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%d\n", (int)response.data.gid);
- return True;
+ return true;
}
/* Convert sid to string */
-static BOOL wbinfo_lookupsid(char *sid)
+static bool wbinfo_lookupsid(char *sid)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -631,9 +628,9 @@ static BOOL wbinfo_lookupsid(char *sid)
fstrcpy(request.data.sid, sid);
- if (winbindd_request(WINBINDD_LOOKUPSID, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
@@ -641,7 +638,7 @@ static BOOL wbinfo_lookupsid(char *sid)
winbind_separator(), response.data.name.name,
response.data.name.type);
- return True;
+ return true;
}
static const char *sid_type_lookup(enum lsa_SidType r)
@@ -662,7 +659,7 @@ static const char *sid_type_lookup(enum lsa_SidType r)
/* Convert string to sid */
-static BOOL wbinfo_lookupname(char *name)
+static bool wbinfo_lookupname(char *name)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -675,20 +672,20 @@ static BOOL wbinfo_lookupname(char *name)
parse_wbinfo_domain_user(name, request.data.name.dom_name,
request.data.name.name);
- if (winbindd_request(WINBINDD_LOOKUPNAME, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%s %s (%d)\n", response.data.sid.sid, sid_type_lookup(response.data.sid.type), response.data.sid.type);
- return True;
+ return true;
}
/* Authenticate a user with a plaintext password */
-static BOOL wbinfo_auth_krb5(char *username, const char *cctype, uint32 flags)
+static bool wbinfo_auth_krb5(char *username, const char *cctype, uint32_t flags)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -716,7 +713,7 @@ static BOOL wbinfo_auth_krb5(char *username, const char *cctype, uint32 flags)
request.data.auth.uid = geteuid();
- result = winbindd_request(WINBINDD_PAM_AUTH, &request, &response);
+ result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response);
/* Display response */
@@ -749,7 +746,7 @@ static BOOL wbinfo_auth_krb5(char *username, const char *cctype, uint32 flags)
/* Authenticate a user with a plaintext password */
-static BOOL wbinfo_auth(char *username)
+static bool wbinfo_auth(char *username)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -771,7 +768,7 @@ static BOOL wbinfo_auth(char *username)
} else
fstrcpy(request.data.auth.user, username);
- result = winbindd_request(WINBINDD_PAM_AUTH, &request, &response);
+ result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response);
/* Display response */
@@ -789,7 +786,7 @@ static BOOL wbinfo_auth(char *username)
/* Authenticate a user with a challenge/response */
-static BOOL wbinfo_auth_crap(char *username)
+static bool wbinfo_auth_crap(char *username)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -822,7 +819,7 @@ static BOOL wbinfo_auth_crap(char *username)
generate_random_buffer(request.data.auth_crap.chal, 8);
- if (lp_client_ntlmv2_auth()) {
+ if (lp_client_ntlmv2_auth(global_loadparm)) {
DATA_BLOB server_chal;
DATA_BLOB names_blob;
@@ -833,20 +830,20 @@ static BOOL wbinfo_auth_crap(char *username)
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
d_printf("talloc_new failed\n");
- return False;
+ return false;
}
server_chal = data_blob(request.data.auth_crap.chal, 8);
/* Pretend this is a login to 'us', for blob purposes */
- names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(), lp_workgroup());
+ names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(global_loadparm), lp_workgroup(global_loadparm));
if (!SMBNTLMv2encrypt(mem_ctx, name_user, name_domain, pass, &server_chal,
&names_blob,
&lm_response, &nt_response, NULL, NULL)) {
data_blob_free(&names_blob);
data_blob_free(&server_chal);
- return False;
+ return false;
}
data_blob_free(&names_blob);
data_blob_free(&server_chal);
@@ -865,7 +862,7 @@ static BOOL wbinfo_auth_crap(char *username)
data_blob_free(&lm_response);
} else {
- if (lp_client_lanman_auth()
+ if (lp_client_lanman_auth(global_loadparm)
&& SMBencrypt(pass, request.data.auth_crap.chal,
(unsigned char *)request.data.auth_crap.lm_resp)) {
request.data.auth_crap.lm_resp_len = 24;
@@ -878,7 +875,7 @@ static BOOL wbinfo_auth_crap(char *username)
request.data.auth_crap.nt_resp_len = 24;
}
- result = winbindd_request(WINBINDD_PAM_AUTH_CRAP, &request, &response);
+ result = winbindd_request_response(WINBINDD_PAM_AUTH_CRAP, &request, &response);
/* Display response */
@@ -896,7 +893,7 @@ static BOOL wbinfo_auth_crap(char *username)
/* Print domain users */
-static BOOL print_domain_users(const char *domain)
+static bool print_domain_users(const char *domain)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -916,14 +913,14 @@ static BOOL print_domain_users(const char *domain)
fstrcpy( request.domain_name, domain );
}
- if (winbindd_request(WINBINDD_LIST_USERS, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_LIST_USERS, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Look through extra data */
if (!response.extra_data.data)
- return False;
+ return false;
extra_data = (const char *)response.extra_data.data;
@@ -932,12 +929,12 @@ static BOOL print_domain_users(const char *domain)
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
/* Print domain groups */
-static BOOL print_domain_groups(const char *domain)
+static bool print_domain_groups(const char *domain)
{
struct winbindd_request request;
struct winbindd_response response;
@@ -954,14 +951,14 @@ static BOOL print_domain_groups(const char *domain)
fstrcpy( request.domain_name, domain );
}
- if (winbindd_request(WINBINDD_LIST_GROUPS, &request, &response) !=
+ if (winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Look through extra data */
if (!response.extra_data.data)
- return False;
+ return false;
extra_data = (const char *)response.extra_data.data;
@@ -970,14 +967,14 @@ static BOOL print_domain_groups(const char *domain)
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
-static BOOL wbinfo_ping(void)
+static bool wbinfo_ping(void)
{
NSS_STATUS result;
- result = winbindd_request(WINBINDD_PING, NULL, NULL);
+ result = winbindd_request_response(WINBINDD_PING, NULL, NULL);
/* Display response */
@@ -1153,7 +1150,7 @@ int main(int argc, char **argv, char **envp)
}
break;
case 'm':
- if (!wbinfo_list_domains(False)) {
+ if (!wbinfo_list_domains(false)) {
d_fprintf(stderr, "Could not list trusted domains\n");
goto done;
}
@@ -1213,18 +1210,18 @@ int main(int argc, char **argv, char **envp)
}
break;
case 'a': {
- BOOL got_error = False;
+ bool got_error = false;
if (!wbinfo_auth(string_arg)) {
d_fprintf(stderr, "Could not authenticate user %s with "
"plaintext password\n", string_arg);
- got_error = True;
+ got_error = true;
}
if (!wbinfo_auth_crap(string_arg)) {
d_fprintf(stderr, "Could not authenticate user %s with "
"challenge/response\n", string_arg);
- got_error = True;
+ got_error = true;
}
if (got_error)
@@ -1232,7 +1229,7 @@ int main(int argc, char **argv, char **envp)
break;
}
case 'K': {
- uint32 flags = WBFLAG_PAM_KRB5 |
+ uint32_t flags = WBFLAG_PAM_KRB5 |
WBFLAG_PAM_CACHED_LOGIN |
WBFLAG_PAM_FALLBACK_AFTER_KRB5 |
WBFLAG_PAM_INFO3_TEXT;
@@ -1256,7 +1253,7 @@ int main(int argc, char **argv, char **envp)
}
break;
case OPT_SEPARATOR: {
- const char sep = winbind_separator_int(True);
+ const char sep = winbind_separator_int(true);
if ( !sep ) {
goto done;
}
@@ -1264,7 +1261,7 @@ int main(int argc, char **argv, char **envp)
break;
}
case OPT_LIST_ALL_DOMAINS:
- if (!wbinfo_list_domains(True)) {
+ if (!wbinfo_list_domains(true)) {
goto done;
}
break;
diff --git a/source4/nsswitch/winbind_client.h b/source4/nsswitch/winbind_client.h
index 373d56804a..2a3956e1fd 100644
--- a/source4/nsswitch/winbind_client.h
+++ b/source4/nsswitch/winbind_client.h
@@ -1,16 +1,25 @@
-#include "nsswitch/winbind_nss_config.h"
-#include "nsswitch/winbindd_nss.h"
+#include "winbind_nss_config.h"
+#include "winbind_struct_protocol.h"
-void init_request(struct winbindd_request *req,int rq_type);
-NSS_STATUS winbindd_send_request(int req_type,
+void winbindd_init_request(struct winbindd_request *req,int rq_type);
+void winbindd_free_response(struct winbindd_response *response);
+NSS_STATUS winbindd_send_request(int req_type, int need_priv,
struct winbindd_request *request);
NSS_STATUS winbindd_get_response(struct winbindd_response *response);
-NSS_STATUS winbindd_request(int req_type,
+NSS_STATUS winbindd_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response);
-int winbind_open_pipe_sock(void);
-int write_sock(void *buffer, int count);
-int read_reply(struct winbindd_response *response);
-void close_sock(void);
-void free_response(struct winbindd_response *response);
+NSS_STATUS winbindd_priv_request_response(int req_type,
+ struct winbindd_request *request,
+ struct winbindd_response *response);
+int winbindd_read_reply(struct winbindd_response *response);
+bool winbind_env_set(void);
+bool winbind_off(void);
+bool winbind_on(void);
+
+int winbind_write_sock(void *buffer, int count, int recursing, int need_priv);
+int winbind_read_sock(void *buffer, int count);
+void winbind_close_sock(void);
+
+const char *nss_err_str(NSS_STATUS ret);
diff --git a/source4/nsswitch/winbind_nss.h b/source4/nsswitch/winbind_nss.h
index c4b2951643..0a3bc7cefa 100644
--- a/source4/nsswitch/winbind_nss.h
+++ b/source4/nsswitch/winbind_nss.h
@@ -53,7 +53,15 @@
#include "nsswitch/winbind_nss_hpux.h"
-#else /* Nothing's defined. Neither gnu nor sun nor hp */
+#elif defined(__NetBSD__) && defined(HAVE_GETPWENT_R)
+
+/*
+ * NetBSD 3 and newer
+ */
+
+#include "nsswitch/winbind_nss_netbsd.h"
+
+#else /* Nothing's defined. Neither gnu nor netbsd nor sun nor hp */
typedef enum
{
diff --git a/source4/nsswitch/winbind_nss_config.h b/source4/nsswitch/winbind_nss_config.h
index 9ab3f8ab0c..e0828dc905 100644
--- a/source4/nsswitch/winbind_nss_config.h
+++ b/source4/nsswitch/winbind_nss_config.h
@@ -51,48 +51,6 @@ typedef char pstring[PSTRING_LEN];
typedef char fstring[FSTRING_LEN];
#endif
-#if !defined(uint32)
-#if (SIZEOF_INT == 4)
-#define uint32 unsigned int
-#elif (SIZEOF_LONG == 4)
-#define uint32 unsigned long
-#elif (SIZEOF_SHORT == 4)
-#define uint32 unsigned short
-#endif
-#endif
-
-#if !defined(uint16)
-#if (SIZEOF_SHORT == 4)
-#define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
-#else /* SIZEOF_SHORT != 4 */
-#define uint16 unsigned short
-#endif /* SIZEOF_SHORT != 4 */
-#endif
-
-#ifndef uint8
-#define uint8 unsigned char
-#endif
-
-/*
- * check for 8 byte long long
- */
-
-#if !defined(uint64)
-#if (SIZEOF_LONG == 8)
-#define uint64 unsigned long
-#elif (SIZEOF_LONG_LONG == 8)
-#define uint64 unsigned long long
-#endif /* don't lie. If we don't have it, then don't use it */
-#endif
-
-#if !defined(int64)
-#if (SIZEOF_LONG == 8)
-#define int64 long
-#elif (SIZEOF_LONG_LONG == 8)
-#define int64 long long
-#endif /* don't lie. If we don't have it, then don't use it */
-#endif
-
/* Some systems (SCO) treat UNIX domain sockets as FIFOs */
#ifndef S_IFSOCK
@@ -103,9 +61,4 @@ typedef char fstring[FSTRING_LEN];
#define S_ISSOCK(mode) ((mode & S_IFSOCK) == S_IFSOCK)
#endif
-#ifndef HAVE_SOCKLEN_T
-#define HAVE_SOCKLEN_T
-typedef int socklen_t;
-#endif
-
#endif
diff --git a/source4/nsswitch/winbind_nss_irix.h b/source4/nsswitch/winbind_nss_irix.h
index 9752267c0e..b40b14b0b0 100644
--- a/source4/nsswitch/winbind_nss_irix.h
+++ b/source4/nsswitch/winbind_nss_irix.h
@@ -39,8 +39,4 @@ typedef enum
NSS_STATUS_TRYAGAIN=NS_TRYAGAIN
} NSS_STATUS;
-#define NSD_MEM_STATIC 0
-#define NSD_MEM_VOLATILE 1
-#define NSD_MEM_DYNAMIC 2
-
#endif /* _WINBIND_NSS_IRIX_H */
diff --git a/source4/nsswitch/winbind_nss_linux.c b/source4/nsswitch/winbind_nss_linux.c
index 52254b984d..ac53979ced 100644
--- a/source4/nsswitch/winbind_nss_linux.c
+++ b/source4/nsswitch/winbind_nss_linux.c
@@ -19,7 +19,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "includes.h"
#include "winbind_client.h"
/* Maximum number of users to pass back over the unix domain socket
@@ -29,64 +28,45 @@
#define MAX_GETPWENT_USERS 250
#define MAX_GETGRENT_USERS 250
-_PUBLIC_ NSS_STATUS _nss_winbind_setpwent(void);
-_PUBLIC_ NSS_STATUS _nss_winbind_endpwent(void);
-_PUBLIC_ NSS_STATUS _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
+NSS_STATUS _nss_winbind_setpwent(void);
+NSS_STATUS _nss_winbind_endpwent(void);
+NSS_STATUS _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result,
+NSS_STATUS _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result,
char *buffer, size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_getpwnam_r(const char *name, struct passwd *result,
+NSS_STATUS _nss_winbind_getpwnam_r(const char *name, struct passwd *result,
char *buffer, size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_setgrent(void);
-_PUBLIC_ NSS_STATUS _nss_winbind_endgrent(void);
-_PUBLIC_ NSS_STATUS _nss_winbind_getgrent_r(struct group *result, char *buffer,
+NSS_STATUS _nss_winbind_setgrent(void);
+NSS_STATUS _nss_winbind_endgrent(void);
+NSS_STATUS _nss_winbind_getgrent_r(struct group *result, char *buffer,
size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_getgrlst_r(struct group *result, char *buffer,
+NSS_STATUS _nss_winbind_getgrlst_r(struct group *result, char *buffer,
size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_getgrnam_r(const char *name, struct group *result,
+NSS_STATUS _nss_winbind_getgrnam_r(const char *name, struct group *result,
char *buffer, size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid, struct group *result, char *buffer,
+NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid, struct group *result, char *buffer,
size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
+NSS_STATUS _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
long int *size, gid_t **groups,
long int limit, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_getusersids(const char *user_sid, char **group_sids,
+NSS_STATUS _nss_winbind_getusersids(const char *user_sid, char **group_sids,
int *num_groups, char *buffer, size_t buf_size,
int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_nametosid(const char *name, char **sid, char *buffer,
+NSS_STATUS _nss_winbind_nametosid(const char *name, char **sid, char *buffer,
size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
+NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_sidtouid(const char *sid, uid_t *uid, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_sidtogid(const char *sid, gid_t *gid, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
+NSS_STATUS _nss_winbind_sidtouid(const char *sid, uid_t *uid, int *errnop);
+NSS_STATUS _nss_winbind_sidtogid(const char *sid, gid_t *gid, int *errnop);
+NSS_STATUS _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
size_t buflen, int *errnop);
-_PUBLIC_ NSS_STATUS _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
+NSS_STATUS _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
size_t buflen, int *errnop);
/* Prototypes from wb_common.c */
extern int winbindd_fd;
-#ifdef DEBUG_NSS
-static const char *nss_err_str(NSS_STATUS ret) {
- switch (ret) {
- case NSS_STATUS_TRYAGAIN:
- return "NSS_STATUS_TRYAGAIN";
- case NSS_STATUS_SUCCESS:
- return "NSS_STATUS_SUCCESS";
- case NSS_STATUS_NOTFOUND:
- return "NSS_STATUS_NOTFOUND";
- case NSS_STATUS_UNAVAIL:
- return "NSS_STATUS_UNAVAIL";
- case NSS_STATUS_RETURN:
- return "NSS_STATUS_RETURN";
- default:
- return "UNKNOWN RETURN CODE!!!!!!!";
- }
-}
-#endif
-
/* Allocate some space from the nss static buffer. The buffer and buflen
are the pointers passed in by the C library to the _nss_ntdom_*
functions. */
@@ -115,13 +95,13 @@ static char *get_static(char **buffer, size_t *buflen, size_t len)
lib/util_str.c as I really don't want to have to link in any other
objects if I can possibly avoid it. */
-static BOOL next_tok(char **ptr,char *buff,const char *sep, size_t bufsize)
+static bool next_token(char **ptr,char *buff,const char *sep, size_t bufsize)
{
char *s;
- BOOL quoted;
+ bool quoted;
size_t len=1;
- if (!ptr) return(False);
+ if (!ptr) return false;
s = *ptr;
@@ -132,10 +112,10 @@ static BOOL next_tok(char **ptr,char *buff,const char *sep, size_t bufsize)
while (*s && strchr(sep,*s)) s++;
/* nothing left? */
- if (! *s) return(False);
+ if (! *s) return false;
/* copy over the token */
- for (quoted = False; len < bufsize && *s && (quoted || !strchr(sep,*s)); s++) {
+ for (quoted = false; len < bufsize && *s && (quoted || !strchr(sep,*s)); s++) {
if (*s == '\"') {
quoted = !quoted;
} else {
@@ -147,7 +127,7 @@ static BOOL next_tok(char **ptr,char *buff,const char *sep, size_t bufsize)
*ptr = (*s) ? s+1 : s;
*buff = 0;
- return(True);
+ return true;
}
@@ -169,7 +149,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
return NSS_STATUS_TRYAGAIN;
}
- strlcpy(result->pw_name, pw->pw_name, strlen(pw->pw_name) + 1);
+ strcpy(result->pw_name, pw->pw_name);
/* Password */
@@ -181,7 +161,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
return NSS_STATUS_TRYAGAIN;
}
- strlcpy(result->pw_passwd, pw->pw_passwd, strlen(pw->pw_passwd) + 1);
+ strcpy(result->pw_passwd, pw->pw_passwd);
/* [ug]id */
@@ -198,7 +178,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
return NSS_STATUS_TRYAGAIN;
}
- strlcpy(result->pw_gecos, pw->pw_gecos, strlen(pw->pw_gecos) + 1);
+ strcpy(result->pw_gecos, pw->pw_gecos);
/* Home directory */
@@ -210,7 +190,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
return NSS_STATUS_TRYAGAIN;
}
- strlcpy(result->pw_dir, pw->pw_dir, strlen(pw->pw_dir) + 1);
+ strcpy(result->pw_dir, pw->pw_dir);
/* Logon shell */
@@ -222,7 +202,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
return NSS_STATUS_TRYAGAIN;
}
- strlcpy(result->pw_shell, pw->pw_shell, strlen(pw->pw_shell) + 1);
+ strcpy(result->pw_shell, pw->pw_shell);
/* The struct passwd for Solaris has some extra fields which must
be initialised or nscd crashes. */
@@ -259,7 +239,7 @@ static NSS_STATUS fill_grent(struct group *result, struct winbindd_gr *gr,
return NSS_STATUS_TRYAGAIN;
}
- strlcpy(result->gr_name, gr->gr_name, strlen(gr->gr_name) + 1);
+ strcpy(result->gr_name, gr->gr_name);
/* Password */
@@ -271,7 +251,7 @@ static NSS_STATUS fill_grent(struct group *result, struct winbindd_gr *gr,
return NSS_STATUS_TRYAGAIN;
}
- strlcpy(result->gr_passwd, gr->gr_passwd, strlen(gr->gr_passwd) + 1);
+ strcpy(result->gr_passwd, gr->gr_passwd);
/* gid */
@@ -310,7 +290,7 @@ static NSS_STATUS fill_grent(struct group *result, struct winbindd_gr *gr,
i = 0;
- while(next_tok((char **)&gr_mem, name, ",", sizeof(fstring))) {
+ while(next_token((char **)&gr_mem, name, ",", sizeof(fstring))) {
/* Allocate space for member */
@@ -322,7 +302,7 @@ static NSS_STATUS fill_grent(struct group *result, struct winbindd_gr *gr,
return NSS_STATUS_TRYAGAIN;
}
- strlcpy((result->gr_mem)[i], name, strlen(name) + 1);
+ strcpy((result->gr_mem)[i], name);
i++;
}
@@ -344,7 +324,8 @@ static int num_pw_cache; /* Current size of pwd cache */
/* Rewind "file pointer" to start of ntdom password database */
-_PUBLIC_ NSS_STATUS _nss_winbind_setpwent(void)
+NSS_STATUS
+_nss_winbind_setpwent(void)
{
NSS_STATUS ret;
#ifdef DEBUG_NSS
@@ -353,10 +334,10 @@ _PUBLIC_ NSS_STATUS _nss_winbind_setpwent(void)
if (num_pw_cache > 0) {
ndx_pw_cache = num_pw_cache = 0;
- free_response(&getpwent_response);
+ winbindd_free_response(&getpwent_response);
}
- ret = winbindd_request(WINBINDD_SETPWENT, NULL, NULL);
+ ret = winbindd_request_response(WINBINDD_SETPWENT, NULL, NULL);
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: setpwent returns %s (%d)\n", getpid(),
nss_err_str(ret), ret);
@@ -366,7 +347,8 @@ _PUBLIC_ NSS_STATUS _nss_winbind_setpwent(void)
/* Close ntdom password database "file pointer" */
-_PUBLIC_ NSS_STATUS _nss_winbind_endpwent(void)
+NSS_STATUS
+_nss_winbind_endpwent(void)
{
NSS_STATUS ret;
#ifdef DEBUG_NSS
@@ -375,10 +357,10 @@ _PUBLIC_ NSS_STATUS _nss_winbind_endpwent(void)
if (num_pw_cache > 0) {
ndx_pw_cache = num_pw_cache = 0;
- free_response(&getpwent_response);
+ winbindd_free_response(&getpwent_response);
}
- ret = winbindd_request(WINBINDD_ENDPWENT, NULL, NULL);
+ ret = winbindd_request_response(WINBINDD_ENDPWENT, NULL, NULL);
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: endpwent returns %s (%d)\n", getpid(),
nss_err_str(ret), ret);
@@ -388,8 +370,9 @@ _PUBLIC_ NSS_STATUS _nss_winbind_endpwent(void)
/* Fetch the next password entry from ntdom password database */
-_PUBLIC_ NSS_STATUS _nss_winbind_getpwent_r(struct passwd *result,
- char *buffer, size_t buflen, int *errnop)
+NSS_STATUS
+_nss_winbind_getpwent_r(struct passwd *result, char *buffer,
+ size_t buflen, int *errnop)
{
NSS_STATUS ret;
struct winbindd_request request;
@@ -409,7 +392,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getpwent_r(struct passwd *result,
/* Else call winbindd to get a bunch of entries */
if (num_pw_cache > 0) {
- free_response(&getpwent_response);
+ winbindd_free_response(&getpwent_response);
}
ZERO_STRUCT(request);
@@ -417,7 +400,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getpwent_r(struct passwd *result,
request.data.num_entries = MAX_GETPWENT_USERS;
- ret = winbindd_request(WINBINDD_GETPWENT, &request,
+ ret = winbindd_request_response(WINBINDD_GETPWENT, &request,
&getpwent_response);
if (ret == NSS_STATUS_SUCCESS) {
@@ -448,20 +431,20 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getpwent_r(struct passwd *result,
/* Out of memory - try again */
if (ret == NSS_STATUS_TRYAGAIN) {
- called_again = True;
+ called_again = true;
*errnop = errno = ERANGE;
goto done;
}
*errnop = errno = 0;
- called_again = False;
+ called_again = false;
ndx_pw_cache++;
/* If we've finished with this lot of results free cache */
if (ndx_pw_cache == num_pw_cache) {
ndx_pw_cache = num_pw_cache = 0;
- free_response(&getpwent_response);
+ winbindd_free_response(&getpwent_response);
}
}
done:
@@ -474,8 +457,9 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getpwent_r(struct passwd *result,
/* Return passwd struct from uid */
-_PUBLIC_ NSS_STATUS _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result,
- char *buffer, size_t buflen, int *errnop)
+NSS_STATUS
+_nss_winbind_getpwuid_r(uid_t uid, struct passwd *result, char *buffer,
+ size_t buflen, int *errnop)
{
NSS_STATUS ret;
static struct winbindd_response response;
@@ -496,14 +480,14 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result,
request.data.uid = uid;
- ret = winbindd_request(WINBINDD_GETPWUID, &request, &response);
+ ret = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_pwent(result, &response.data.pw,
&buffer, &buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
- keep_response = True;
+ keep_response = true;
*errnop = errno = ERANGE;
goto done;
}
@@ -516,16 +500,16 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result,
ret = fill_pwent(result, &response.data.pw, &buffer, &buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
- keep_response = True;
+ keep_response = true;
*errnop = errno = ERANGE;
goto done;
}
- keep_response = False;
+ keep_response = false;
*errnop = errno = 0;
}
- free_response(&response);
+ winbindd_free_response(&response);
done:
#ifdef DEBUG_NSS
@@ -536,8 +520,9 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result,
}
/* Return passwd struct from username */
-_PUBLIC_ NSS_STATUS _nss_winbind_getpwnam_r(const char *name,
- struct passwd *result, char *buffer, size_t buflen, int *errnop)
+NSS_STATUS
+_nss_winbind_getpwnam_r(const char *name, struct passwd *result, char *buffer,
+ size_t buflen, int *errnop)
{
NSS_STATUS ret;
static struct winbindd_response response;
@@ -562,14 +547,14 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getpwnam_r(const char *name,
request.data.username
[sizeof(request.data.username) - 1] = '\0';
- ret = winbindd_request(WINBINDD_GETPWNAM, &request, &response);
+ ret = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_pwent(result, &response.data.pw, &buffer,
&buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
- keep_response = True;
+ keep_response = true;
*errnop = errno = ERANGE;
goto done;
}
@@ -582,16 +567,16 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getpwnam_r(const char *name,
ret = fill_pwent(result, &response.data.pw, &buffer, &buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
- keep_response = True;
+ keep_response = true;
*errnop = errno = ERANGE;
goto done;
}
- keep_response = False;
+ keep_response = false;
*errnop = errno = 0;
}
- free_response(&response);
+ winbindd_free_response(&response);
done:
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: getpwnam %s returns %s (%d)\n", getpid(),
@@ -611,7 +596,8 @@ static int num_gr_cache; /* Current size of grp cache */
/* Rewind "file pointer" to start of ntdom group database */
-_PUBLIC_ NSS_STATUS _nss_winbind_setgrent(void)
+NSS_STATUS
+_nss_winbind_setgrent(void)
{
NSS_STATUS ret;
#ifdef DEBUG_NSS
@@ -620,10 +606,10 @@ _PUBLIC_ NSS_STATUS _nss_winbind_setgrent(void)
if (num_gr_cache > 0) {
ndx_gr_cache = num_gr_cache = 0;
- free_response(&getgrent_response);
+ winbindd_free_response(&getgrent_response);
}
- ret = winbindd_request(WINBINDD_SETGRENT, NULL, NULL);
+ ret = winbindd_request_response(WINBINDD_SETGRENT, NULL, NULL);
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: setgrent returns %s (%d)\n", getpid(),
nss_err_str(ret), ret);
@@ -633,7 +619,8 @@ _PUBLIC_ NSS_STATUS _nss_winbind_setgrent(void)
/* Close "file pointer" for ntdom group database */
-_PUBLIC_ NSS_STATUS _nss_winbind_endgrent(void)
+NSS_STATUS
+_nss_winbind_endgrent(void)
{
NSS_STATUS ret;
#ifdef DEBUG_NSS
@@ -642,10 +629,10 @@ _PUBLIC_ NSS_STATUS _nss_winbind_endgrent(void)
if (num_gr_cache > 0) {
ndx_gr_cache = num_gr_cache = 0;
- free_response(&getgrent_response);
+ winbindd_free_response(&getgrent_response);
}
- ret = winbindd_request(WINBINDD_ENDGRENT, NULL, NULL);
+ ret = winbindd_request_response(WINBINDD_ENDGRENT, NULL, NULL);
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: endgrent returns %s (%d)\n", getpid(),
nss_err_str(ret), ret);
@@ -679,7 +666,7 @@ winbind_getgrent(enum winbindd_cmd cmd,
/* Else call winbindd to get a bunch of entries */
if (num_gr_cache > 0) {
- free_response(&getgrent_response);
+ winbindd_free_response(&getgrent_response);
}
ZERO_STRUCT(request);
@@ -687,7 +674,7 @@ winbind_getgrent(enum winbindd_cmd cmd,
request.data.num_entries = MAX_GETGRENT_USERS;
- ret = winbindd_request(cmd, &request,
+ ret = winbindd_request_response(cmd, &request,
&getgrent_response);
if (ret == NSS_STATUS_SUCCESS) {
@@ -727,20 +714,20 @@ winbind_getgrent(enum winbindd_cmd cmd,
/* Out of memory - try again */
if (ret == NSS_STATUS_TRYAGAIN) {
- called_again = True;
+ called_again = true;
*errnop = errno = ERANGE;
goto done;
}
*errnop = 0;
- called_again = False;
+ called_again = false;
ndx_gr_cache++;
/* If we've finished with this lot of results free cache */
if (ndx_gr_cache == num_gr_cache) {
ndx_gr_cache = num_gr_cache = 0;
- free_response(&getgrent_response);
+ winbindd_free_response(&getgrent_response);
}
}
done:
@@ -752,13 +739,15 @@ winbind_getgrent(enum winbindd_cmd cmd,
}
-_PUBLIC_ NSS_STATUS _nss_winbind_getgrent_r(struct group *result,
+NSS_STATUS
+_nss_winbind_getgrent_r(struct group *result,
char *buffer, size_t buflen, int *errnop)
{
return winbind_getgrent(WINBINDD_GETGRENT, result, buffer, buflen, errnop);
}
-_PUBLIC_ NSS_STATUS _nss_winbind_getgrlst_r(struct group *result,
+NSS_STATUS
+_nss_winbind_getgrlst_r(struct group *result,
char *buffer, size_t buflen, int *errnop)
{
return winbind_getgrent(WINBINDD_GETGRLST, result, buffer, buflen, errnop);
@@ -766,7 +755,8 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getgrlst_r(struct group *result,
/* Return group struct from group name */
-_PUBLIC_ NSS_STATUS _nss_winbind_getgrnam_r(const char *name,
+NSS_STATUS
+_nss_winbind_getgrnam_r(const char *name,
struct group *result, char *buffer,
size_t buflen, int *errnop)
{
@@ -793,7 +783,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getgrnam_r(const char *name,
request.data.groupname
[sizeof(request.data.groupname) - 1] = '\0';
- ret = winbindd_request(WINBINDD_GETGRNAM, &request, &response);
+ ret = winbindd_request_response(WINBINDD_GETGRNAM, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_grent(result, &response.data.gr,
@@ -801,7 +791,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getgrnam_r(const char *name,
&buffer, &buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
- keep_response = True;
+ keep_response = true;
*errnop = errno = ERANGE;
goto done;
}
@@ -816,16 +806,16 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getgrnam_r(const char *name,
&buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
- keep_response = True;
+ keep_response = true;
*errnop = errno = ERANGE;
goto done;
}
- keep_response = False;
+ keep_response = false;
*errnop = 0;
}
- free_response(&response);
+ winbindd_free_response(&response);
done:
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: getgrnam %s returns %s (%d)\n", getpid(),
@@ -836,7 +826,8 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getgrnam_r(const char *name,
/* Return group struct from gid */
-_PUBLIC_ NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid,
+NSS_STATUS
+_nss_winbind_getgrgid_r(gid_t gid,
struct group *result, char *buffer,
size_t buflen, int *errnop)
{
@@ -860,7 +851,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid,
request.data.gid = gid;
- ret = winbindd_request(WINBINDD_GETGRGID, &request, &response);
+ ret = winbindd_request_response(WINBINDD_GETGRGID, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
@@ -869,7 +860,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid,
&buffer, &buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
- keep_response = True;
+ keep_response = true;
*errnop = errno = ERANGE;
goto done;
}
@@ -884,16 +875,16 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid,
&buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
- keep_response = True;
+ keep_response = true;
*errnop = errno = ERANGE;
goto done;
}
- keep_response = False;
+ keep_response = false;
*errnop = 0;
}
- free_response(&response);
+ winbindd_free_response(&response);
done:
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: getgrgid %d returns %s (%d)\n", getpid(),
@@ -904,9 +895,10 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid,
/* Initialise supplementary groups */
-_PUBLIC_ NSS_STATUS _nss_winbind_initgroups_dyn(char *user, gid_t group,
- long int *start, long int *size, gid_t **groups,
- long int limit, int *errnop)
+NSS_STATUS
+_nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
+ long int *size, gid_t **groups, long int limit,
+ int *errnop)
{
NSS_STATUS ret;
struct winbindd_request request;
@@ -924,7 +916,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_initgroups_dyn(char *user, gid_t group,
strncpy(request.data.username, user,
sizeof(request.data.username) - 1);
- ret = winbindd_request(WINBINDD_GETGROUPS, &request, &response);
+ ret = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
int num_gids = response.data.num_entries;
@@ -1003,9 +995,10 @@ _PUBLIC_ NSS_STATUS _nss_winbind_initgroups_dyn(char *user, gid_t group,
/* return a list of group SIDs for a user SID */
-_PUBLIC_ NSS_STATUS _nss_winbind_getusersids(const char *user_sid,
- char **group_sids, int *num_groups,
- char *buffer, size_t buf_size, int *errnop)
+NSS_STATUS
+_nss_winbind_getusersids(const char *user_sid, char **group_sids,
+ int *num_groups,
+ char *buffer, size_t buf_size, int *errnop)
{
NSS_STATUS ret;
struct winbindd_request request;
@@ -1021,7 +1014,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getusersids(const char *user_sid,
strncpy(request.data.sid, user_sid,sizeof(request.data.sid) - 1);
request.data.sid[sizeof(request.data.sid) - 1] = '\0';
- ret = winbindd_request(WINBINDD_GETUSERSIDS, &request, &response);
+ ret = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
goto done;
@@ -1039,14 +1032,15 @@ _PUBLIC_ NSS_STATUS _nss_winbind_getusersids(const char *user_sid,
errno = *errnop = 0;
done:
- free_response(&response);
+ winbindd_free_response(&response);
return ret;
}
/* map a user or group name to a SID string */
-_PUBLIC_ NSS_STATUS _nss_winbind_nametosid(const char *name, char **sid,
- char *buffer, size_t buflen, int *errnop)
+NSS_STATUS
+_nss_winbind_nametosid(const char *name, char **sid, char *buffer,
+ size_t buflen, int *errnop)
{
NSS_STATUS ret;
struct winbindd_response response;
@@ -1063,7 +1057,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_nametosid(const char *name, char **sid,
sizeof(request.data.name.name) - 1);
request.data.name.name[sizeof(request.data.name.name) - 1] = '\0';
- ret = winbindd_request(WINBINDD_LOOKUPNAME, &request, &response);
+ ret = winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1077,16 +1071,17 @@ _PUBLIC_ NSS_STATUS _nss_winbind_nametosid(const char *name, char **sid,
*errnop = errno = 0;
*sid = buffer;
- strlcpy(*sid, response.data.sid.sid, strlen(response.data.sid.sid) + 1);
+ strcpy(*sid, response.data.sid.sid);
failed:
- free_response(&response);
+ winbindd_free_response(&response);
return ret;
}
/* map a sid string to a user or group name */
-_PUBLIC_ NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name,
- char *buffer, size_t buflen, int *errnop)
+NSS_STATUS
+_nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
+ size_t buflen, int *errnop)
{
NSS_STATUS ret;
struct winbindd_response response;
@@ -1103,14 +1098,14 @@ _PUBLIC_ NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name,
/* we need to fetch the separator first time through */
if (!sep_char) {
- ret = winbindd_request(WINBINDD_INFO, &request, &response);
+ ret = winbindd_request_response(WINBINDD_INFO, &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
}
sep_char = response.data.info.winbind_separator;
- free_response(&response);
+ winbindd_free_response(&response);
}
@@ -1118,7 +1113,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name,
sizeof(request.data.sid) - 1);
request.data.sid[sizeof(request.data.sid) - 1] = '\0';
- ret = winbindd_request(WINBINDD_LOOKUPSID, &request, &response);
+ ret = winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1143,13 +1138,13 @@ _PUBLIC_ NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name,
*errnop = errno = 0;
failed:
- free_response(&response);
+ winbindd_free_response(&response);
return ret;
}
/* map a sid to a uid */
-_PUBLIC_ NSS_STATUS _nss_winbind_sidtouid(const char *sid, uid_t *uid,
- int *errnop)
+NSS_STATUS
+_nss_winbind_sidtouid(const char *sid, uid_t *uid, int *errnop)
{
NSS_STATUS ret;
struct winbindd_response response;
@@ -1165,7 +1160,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_sidtouid(const char *sid, uid_t *uid,
strncpy(request.data.sid, sid, sizeof(request.data.sid) - 1);
request.data.sid[sizeof(request.data.sid) - 1] = '\0';
- ret = winbindd_request(WINBINDD_SID_TO_UID, &request, &response);
+ ret = winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1178,8 +1173,8 @@ failed:
}
/* map a sid to a gid */
-_PUBLIC_ NSS_STATUS _nss_winbind_sidtogid(const char *sid, gid_t *gid,
- int *errnop)
+NSS_STATUS
+_nss_winbind_sidtogid(const char *sid, gid_t *gid, int *errnop)
{
NSS_STATUS ret;
struct winbindd_response response;
@@ -1195,7 +1190,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_sidtogid(const char *sid, gid_t *gid,
strncpy(request.data.sid, sid, sizeof(request.data.sid) - 1);
request.data.sid[sizeof(request.data.sid) - 1] = '\0';
- ret = winbindd_request(WINBINDD_SID_TO_GID, &request, &response);
+ ret = winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1208,7 +1203,8 @@ failed:
}
/* map a uid to a SID string */
-_PUBLIC_ NSS_STATUS _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
+NSS_STATUS
+_nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
size_t buflen, int *errnop)
{
NSS_STATUS ret;
@@ -1224,7 +1220,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
request.data.uid = uid;
- ret = winbindd_request(WINBINDD_UID_TO_SID, &request, &response);
+ ret = winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1238,15 +1234,16 @@ _PUBLIC_ NSS_STATUS _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
*errnop = errno = 0;
*sid = buffer;
- strlcpy(*sid, response.data.sid.sid, strlen(response.data.sid.sid) + 1);
+ strcpy(*sid, response.data.sid.sid);
failed:
- free_response(&response);
+ winbindd_free_response(&response);
return ret;
}
/* map a gid to a SID string */
-_PUBLIC_ NSS_STATUS _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
+NSS_STATUS
+_nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
size_t buflen, int *errnop)
{
NSS_STATUS ret;
@@ -1262,7 +1259,7 @@ _PUBLIC_ NSS_STATUS _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
request.data.gid = gid;
- ret = winbindd_request(WINBINDD_GID_TO_SID, &request, &response);
+ ret = winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1276,9 +1273,9 @@ _PUBLIC_ NSS_STATUS _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
*errnop = errno = 0;
*sid = buffer;
- strlcpy(*sid, response.data.sid.sid, strlen(response.data.sid.sid) + 1);
+ strcpy(*sid, response.data.sid.sid);
failed:
- free_response(&response);
+ winbindd_free_response(&response);
return ret;
}
diff --git a/source4/nsswitch/winbind_nss_solaris.h b/source4/nsswitch/winbind_nss_solaris.h
index 1c694394d3..941b3e66df 100644
--- a/source4/nsswitch/winbind_nss_solaris.h
+++ b/source4/nsswitch/winbind_nss_solaris.h
@@ -22,7 +22,37 @@
#ifndef _WINBIND_NSS_SOLARIS_H
#define _WINBIND_NSS_SOLARIS_H
+/* Solaris has a broken nss_common header file containing C++ reserved names. */
+#ifndef __cplusplus
+#undef class
+#undef private
+#undef public
+#undef protected
+#undef template
+#undef this
+#undef new
+#undef delete
+#undef friend
+#endif
+
#include <nss_common.h>
+
+/*
+TODO: we need to cleanup samba4's headers..
+
+#ifndef __cplusplus
+#define class #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
+#define private #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
+#define public #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
+#define protected #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
+#define template #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
+#define this #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
+#define new #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
+#define delete #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
+#define friend #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
+#endif
+*/
+
#include <nss_dbdefs.h>
#include <nsswitch.h>
diff --git a/source4/nsswitch/winbindd_nss.h b/source4/nsswitch/winbind_struct_protocol.h
index 724b830604..d8e5c2f3b8 100644
--- a/source4/nsswitch/winbindd_nss.h
+++ b/source4/nsswitch/winbind_struct_protocol.h
@@ -11,15 +11,6 @@
products. You do not need to give any attribution.
*/
-
-#ifndef CONST_DISCARD
-#define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
-#endif
-
-#ifndef CONST_ADD
-#define CONST_ADD(type, ptr) ((type) ((const void *) (ptr)))
-#endif
-
#ifndef SAFE_FREE
#define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
#endif
@@ -36,28 +27,28 @@
#define WINBINDD_SOCKET_DIR "/tmp/.winbindd" /* Name of PF_UNIX dir */
#endif
+/*
+ * when compiled with socket_wrapper support
+ * the location of the WINBINDD_SOCKET_DIR
+ * can be overwritten via an environment variable
+ */
+#define WINBINDD_SOCKET_DIR_ENVVAR "WINBINDD_SOCKET_DIR"
+
#define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privileged" /* name of subdirectory of lp_lockdir() to hold the 'privileged' pipe */
#define WINBINDD_DOMAIN_ENV "WINBINDD_DOMAIN" /* Environment variables */
#define WINBINDD_DONT_ENV "_NO_WINBINDD"
-
-#ifdef SOCKET_WRAPPER
-#define WINBINDD_SOCKET_DIR_ENV "WINBINDD_SOCKET_DIR"
-#endif
+#define WINBINDD_LOCATOR_KDC_ADDRESS "WINBINDD_LOCATOR_KDC_ADDRESS"
/* Update this when you change the interface. */
-#define WINBIND_INTERFACE_VERSION 18
+#define WINBIND_INTERFACE_VERSION 19
/* Have to deal with time_t being 4 or 8 bytes due to structure alignment.
On a 64bit Linux box, we have to support a constant structure size
between /lib/libnss_winbind.so.2 and /li64/libnss_winbind.so.2.
The easiest way to do this is to always use 8byte values for time_t. */
-#if defined(int64)
-# define SMB_TIME_T int64
-#else
-# define SMB_TIME_T time_t
-#endif
+#define SMB_TIME_T int64_t
/* Socket commands */
@@ -104,7 +95,7 @@ enum winbindd_cmd {
/* Lookup functions */
- WINBINDD_SID_TO_UID,
+ WINBINDD_SID_TO_UID,
WINBINDD_SID_TO_GID,
WINBINDD_SIDS_TO_XIDS,
WINBINDD_UID_TO_SID,
@@ -127,6 +118,7 @@ enum winbindd_cmd {
WINBINDD_DOMAIN_INFO, /* Most of what we know from
struct winbindd_domain */
WINBINDD_GETDCNAME, /* Issue a GetDCName Request */
+ WINBINDD_DSGETDCNAME, /* Issue a DsGetDCName Request */
WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */
@@ -194,30 +186,31 @@ typedef struct winbindd_gr {
fstring gr_name;
fstring gr_passwd;
gid_t gr_gid;
- uint32 num_gr_mem;
- uint32 gr_mem_ofs; /* offset to group membership */
+ uint32_t num_gr_mem;
+ uint32_t gr_mem_ofs; /* offset to group membership */
} WINBINDD_GR;
-
-#define WBFLAG_PAM_INFO3_NDR 0x0001
-#define WBFLAG_PAM_INFO3_TEXT 0x0002
-#define WBFLAG_PAM_USER_SESSION_KEY 0x0004
-#define WBFLAG_PAM_LMKEY 0x0008
-#define WBFLAG_PAM_CONTACT_TRUSTDOM 0x0010
-#define WBFLAG_QUERY_ONLY 0x0020
-#define WBFLAG_PAM_UNIX_NAME 0x0080
-#define WBFLAG_PAM_AFS_TOKEN 0x0100
-#define WBFLAG_PAM_NT_STATUS_SQUASH 0x0200
-
+/* PAM specific request flags */
+#define WBFLAG_PAM_INFO3_NDR 0x00000001
+#define WBFLAG_PAM_INFO3_TEXT 0x00000002
+#define WBFLAG_PAM_USER_SESSION_KEY 0x00000004
+#define WBFLAG_PAM_LMKEY 0x00000008
+#define WBFLAG_PAM_CONTACT_TRUSTDOM 0x00000010
+#define WBFLAG_PAM_UNIX_NAME 0x00000080
+#define WBFLAG_PAM_AFS_TOKEN 0x00000100
+#define WBFLAG_PAM_NT_STATUS_SQUASH 0x00000200
+#define WBFLAG_PAM_KRB5 0x00001000
+#define WBFLAG_PAM_FALLBACK_AFTER_KRB5 0x00002000
+#define WBFLAG_PAM_CACHED_LOGIN 0x00004000
+#define WBFLAG_PAM_GET_PWD_POLICY 0x00008000 /* not used */
+
+/* generic request flags */
+#define WBFLAG_QUERY_ONLY 0x00000020 /* not used */
/* This is a flag that can only be sent from parent to child */
-#define WBFLAG_IS_PRIVILEGED 0x0400
+#define WBFLAG_IS_PRIVILEGED 0x00000400 /* not used */
/* Flag to say this is a winbindd internal send - don't recurse. */
-#define WBFLAG_RECURSE 0x0800
+#define WBFLAG_RECURSE 0x00000800
-#define WBFLAG_PAM_KRB5 0x1000
-#define WBFLAG_PAM_FALLBACK_AFTER_KRB5 0x2000
-#define WBFLAG_PAM_CACHED_LOGIN 0x4000
-#define WBFLAG_PAM_GET_PWD_POLICY 0x8000 /* not used */
#define WINBINDD_MAX_EXTRA_DATA (128*1024)
@@ -232,12 +225,13 @@ typedef struct winbindd_gr {
******************************************************************************/
struct winbindd_request {
- uint32 length;
+ uint32_t length;
enum winbindd_cmd cmd; /* Winbindd command to execute */
enum winbindd_cmd original_cmd; /* Original Winbindd command
issued to parent process */
pid_t pid; /* pid of calling process */
- uint32 flags; /* flags relavant to a given request */
+ uint32_t wb_flags; /* generic flags */
+ uint32_t flags; /* flags relevant *only* to a given request */
fstring domain_name; /* name of domain for which the request applies */
union {
@@ -257,14 +251,14 @@ struct winbindd_request {
uid_t uid;
} auth; /* pam_winbind auth module */
struct {
- unsigned char chal[8];
- uint32 logon_parameters;
+ uint8_t chal[8];
+ uint32_t logon_parameters;
fstring user;
fstring domain;
fstring lm_resp;
- uint32 lm_resp_len;
+ uint32_t lm_resp_len;
fstring nt_resp;
- uint32 nt_resp_len;
+ uint32_t nt_resp_len;
fstring workstation;
fstring require_membership_of_sid;
} auth_crap;
@@ -276,14 +270,14 @@ struct winbindd_request {
struct {
fstring user;
fstring domain;
- unsigned char new_nt_pswd[516];
- uint16 new_nt_pswd_len;
- unsigned char old_nt_hash_enc[16];
- uint16 old_nt_hash_enc_len;
- unsigned char new_lm_pswd[516];
- uint16 new_lm_pswd_len;
- unsigned char old_lm_hash_enc[16];
- uint16 old_lm_hash_enc_len;
+ uint8_t new_nt_pswd[516];
+ uint16_t new_nt_pswd_len;
+ uint8_t old_nt_hash_enc[16];
+ uint16_t old_nt_hash_enc_len;
+ uint8_t new_lm_pswd[516];
+ uint16_t new_lm_pswd_len;
+ uint8_t old_lm_hash_enc[16];
+ uint16_t old_lm_hash_enc_len;
} chng_pswd_auth_crap;/* pam_winbind passwd module */
struct {
fstring user;
@@ -295,7 +289,7 @@ struct winbindd_request {
fstring dom_name; /* lookupname */
fstring name;
} name;
- uint32 num_entries; /* getpwent, getgrent */
+ uint32_t num_entries; /* getpwent, getgrent */
struct {
fstring username;
fstring groupname;
@@ -310,8 +304,8 @@ struct winbindd_request {
} dual_sid2id;
struct {
fstring sid;
- uint32 type;
- uint32 id;
+ uint32_t type;
+ uint32_t id;
} dual_idmapset;
bool list_all_domains;
@@ -324,8 +318,8 @@ struct winbindd_request {
produce an actual challenge response. It merely
succeeds if there are cached credentials available
that could be used. */
- uint32 initial_blob_len; /* blobs in extra_data */
- uint32 challenge_blob_len;
+ uint32_t initial_blob_len; /* blobs in extra_data */
+ uint32_t challenge_blob_len;
} ccache_ntlm_auth;
/* padding -- needed to fix alignment between 32bit and 64bit libs.
@@ -338,7 +332,7 @@ struct winbindd_request {
SMB_TIME_T padding;
char *data;
} extra_data;
- uint32 extra_len;
+ uint32_t extra_len;
char null_term;
};
@@ -364,7 +358,7 @@ struct winbindd_response {
/* Header information */
- uint32 length; /* Length of response */
+ uint32_t length; /* Length of response */
enum winbindd_result result; /* Result code */
/* Fixed length return data */
@@ -382,14 +376,14 @@ struct winbindd_response {
struct winbindd_gr gr;
- uint32 num_entries; /* getpwent, getgrent */
+ uint32_t num_entries; /* getpwent, getgrent */
struct winbindd_sid {
fstring sid; /* lookupname, [ug]id_to_sid */
int type;
} sid;
struct winbindd_name {
fstring dom_name; /* lookupsid */
- fstring name;
+ fstring name;
int type;
} name;
uid_t uid; /* sid_to_uid */
@@ -403,20 +397,20 @@ struct winbindd_response {
fstring dc_name;
struct auth_reply {
- uint32 nt_status;
+ uint32_t nt_status;
fstring nt_status_string;
fstring error_string;
int pam_error;
char user_session_key[16];
char first_8_lm_hash[8];
fstring krb5ccname;
- uint32 reject_reason;
- uint32 padding;
+ uint32_t reject_reason;
+ uint32_t padding;
struct policy_settings {
- uint32 min_length_password;
- uint32 password_history;
- uint32 password_properties;
- uint32 padding;
+ uint32_t min_length_password;
+ uint32_t password_history;
+ uint32_t password_properties;
+ uint32_t padding;
SMB_TIME_T expire;
SMB_TIME_T min_passwordage;
} policy;
@@ -427,14 +421,14 @@ struct winbindd_response {
SMB_TIME_T pass_last_set_time;
SMB_TIME_T pass_can_change_time;
SMB_TIME_T pass_must_change_time;
- uint32 logon_count;
- uint32 bad_pw_count;
- uint32 user_rid;
- uint32 group_rid;
- uint32 num_groups;
- uint32 user_flgs;
- uint32 acct_flags;
- uint32 num_other_sids;
+ uint32_t logon_count;
+ uint32_t bad_pw_count;
+ uint32_t user_rid;
+ uint32_t group_rid;
+ uint32_t num_groups;
+ uint32_t user_flgs;
+ uint32_t acct_flags;
+ uint32_t num_other_sids;
fstring dom_sid;
fstring user_name;
fstring full_name;
@@ -453,18 +447,18 @@ struct winbindd_response {
bool native_mode;
bool active_directory;
bool primary;
- uint32 sequence_number;
} domain_info;
+ uint32_t sequence_number;
struct {
fstring acct_name;
fstring full_name;
fstring homedir;
fstring shell;
- uint32 primary_gid;
- uint32 group_rid;
+ uint32_t primary_gid;
+ uint32_t group_rid;
} user_info;
struct {
- uint32 auth_blob_len; /* blob in extra_data */
+ uint32_t auth_blob_len; /* blob in extra_data */
} ccache_ntlm_auth;
} data;
@@ -482,8 +476,8 @@ struct WINBINDD_MEMORY_CREDS {
uid_t uid;
int ref_count;
size_t len;
- unsigned char *nt_hash; /* Base pointer for the following 2 */
- unsigned char *lm_hash;
+ uint8_t *nt_hash; /* Base pointer for the following 2 */
+ uint8_t *lm_hash;
char *pass;
};
diff --git a/source4/ntptr/ntptr_base.c b/source4/ntptr/ntptr_base.c
index d63bdb1546..379c4e5413 100644
--- a/source4/ntptr/ntptr_base.c
+++ b/source4/ntptr/ntptr_base.c
@@ -25,6 +25,7 @@
#include "includes.h"
#include "ntptr/ntptr.h"
#include "build.h"
+#include "param/param.h"
/* the list of currently registered NTPTR backends */
static struct ntptr_backend {
@@ -71,7 +72,7 @@ NTSTATUS ntptr_register(const void *_ops)
NTSTATUS ntptr_init(void)
{
init_module_fn static_init[] = STATIC_ntptr_MODULES;
- init_module_fn *shared_init = load_samba_modules(NULL, "ntptr");
+ init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "ntptr");
run_init_functions(static_init);
run_init_functions(shared_init);
diff --git a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
index dcdaa5e94e..4046c1bdbd 100644
--- a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
+++ b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
@@ -35,6 +35,7 @@
#include "dsdb/samdb/samdb.h"
#include "db_wrap.h"
#include "rpc_server/common/common.h"
+#include "param/param.h"
/*
connect to the SPOOLSS database
@@ -42,7 +43,7 @@
*/
static struct ldb_context *sptr_db_connect(TALLOC_CTX *mem_ctx)
{
- return ldb_wrap_connect(mem_ctx, lp_spoolss_url(), system_session(mem_ctx),
+ return ldb_wrap_connect(mem_ctx, global_loadparm, lp_spoolss_url(global_loadparm), system_session(mem_ctx),
NULL, 0, NULL);
}
@@ -202,12 +203,12 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC
r->out.data.binary = blob;
return WERR_OK;
} else if (strcmp("DNSMachineName", r->in.value_name) == 0) {
- if (!lp_realm()) return WERR_INVALID_PARAM;
+ if (!lp_realm(global_loadparm)) return WERR_INVALID_PARAM;
r->out.type = SPOOLSS_PRINTER_DATA_TYPE_STRING;
r->out.data.string = talloc_asprintf(mem_ctx, "%s.%s",
- lp_netbios_name(),
- lp_realm());
+ lp_netbios_name(global_loadparm),
+ lp_realm(global_loadparm));
W_ERROR_HAVE_NO_MEMORY(r->out.data.string);
return WERR_OK;
}
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c
index 4c079b36fc..cd4e363906 100644
--- a/source4/ntvfs/cifs/vfs_cifs.c
+++ b/source4/ntvfs/cifs/vfs_cifs.c
@@ -31,6 +31,7 @@
#include "auth/credentials/credentials.h"
#include "ntvfs/ntvfs.h"
#include "lib/util/dlinklist.h"
+#include "param/param.h"
struct cvfs_file {
struct cvfs_file *prev, *next;
@@ -45,8 +46,8 @@ struct cvfs_private {
struct ntvfs_module_context *ntvfs;
struct async_info *pending;
struct cvfs_file *files;
- BOOL map_generic;
- BOOL map_trans2;
+ bool map_generic;
+ bool map_trans2;
};
@@ -83,15 +84,15 @@ struct async_info {
#define CIFS_MAP_GENERIC "cifs:map-generic"
#define CIFS_MAP_TRANS2 "cifs:map-trans2"
-#define CIFS_USE_MACHINE_ACCT_DEFAULT False
-#define CIFS_MAP_GENERIC_DEFAULT False
-#define CIFS_MAP_TRANS2_DEFAULT True
+#define CIFS_USE_MACHINE_ACCT_DEFAULT false
+#define CIFS_MAP_GENERIC_DEFAULT false
+#define CIFS_MAP_TRANS2_DEFAULT true
/*
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)
+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;
@@ -106,13 +107,13 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin
if (!h) {
DEBUG(5,("vfs_cifs: ignoring oplock break level %d for fnum %d\n", level, fnum));
- return True;
+ return true;
}
DEBUG(5,("vfs_cifs: 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;
+ if (!NT_STATUS_IS_OK(status)) return false;
+ return true;
}
/*
@@ -129,7 +130,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
struct share_config *scfg = ntvfs->ctx->config;
struct cli_credentials *credentials;
- BOOL machine_account;
+ bool machine_account;
/* Here we need to determine which server to connect to.
* For now we use parametric options, type cifs.
@@ -165,7 +166,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
return NT_STATUS_NO_MEMORY;
}
cli_credentials_set_event_context(credentials, ntvfs->ctx->event_ctx);
- cli_credentials_set_conf(credentials);
+ cli_credentials_set_conf(credentials, global_loadparm);
cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
if (domain) {
cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
@@ -175,7 +176,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
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);
+ cli_credentials_set_conf(credentials, global_loadparm);
if (domain) {
cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
}
@@ -196,8 +197,8 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
io.in.port = 0;
io.in.called_name = host;
io.in.credentials = credentials;
- io.in.fallback_to_anonymous = False;
- io.in.workgroup = lp_workgroup();
+ io.in.fallback_to_anonymous = false;
+ io.in.workgroup = lp_workgroup(global_loadparm);
io.in.service = remote_share;
io.in.service_type = "?????";
@@ -921,7 +922,7 @@ static NTSTATUS cvfs_lpq(struct ntvfs_module_context *ntvfs,
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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct cvfs_private *private = ntvfs->private_data;
@@ -934,7 +935,7 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs,
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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct cvfs_private *private = ntvfs->private_data;
diff --git a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c
index 088d1644d3..a61ac16669 100644
--- a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c
+++ b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c
@@ -39,7 +39,7 @@
#define O_DIRECTORY 0
#endif
-#define CHECK_READ_ONLY(req) do { if (share_bool_option(ntvfs->ctx->config, SHARE_READONLY, True)) return NT_STATUS_ACCESS_DENIED; } while (0)
+#define CHECK_READ_ONLY(req) do { if (share_bool_option(ntvfs->ctx->config, SHARE_READONLY, true)) return NT_STATUS_ACCESS_DENIED; } while (0)
/*
connect to a share - used when a tree_connect operation comes
@@ -311,7 +311,7 @@ static NTSTATUS cifspsx_open(struct ntvfs_module_context *ntvfs,
int fd, flags;
struct cifspsx_file *f;
int create_flags, rdwr_flags;
- BOOL readonly;
+ bool readonly;
NTSTATUS status;
struct ntvfs_handle *handle;
@@ -829,7 +829,7 @@ static NTSTATUS cifspsx_lpq(struct ntvfs_module_context *ntvfs,
static NTSTATUS cifspsx_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct cifspsx_dir *dir;
int i;
@@ -903,7 +903,7 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs,
static NTSTATUS cifspsx_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct cifspsx_dir *dir;
int i;
diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c
index 0bca9d2590..2b81521a2c 100644
--- a/source4/ntvfs/common/brlock_tdb.c
+++ b/source4/ntvfs/common/brlock_tdb.c
@@ -126,7 +126,7 @@ static struct brl_handle *brl_tdb_create_handle(TALLOC_CTX *mem_ctx, struct ntvf
/*
see if two locking contexts are equal
*/
-static BOOL brl_tdb_same_context(struct lock_context *ctx1, struct lock_context *ctx2)
+static bool brl_tdb_same_context(struct lock_context *ctx1, struct lock_context *ctx2)
{
return (cluster_id_equal(&ctx1->server, &ctx2->server) &&
ctx1->smbpid == ctx2->smbpid &&
@@ -139,7 +139,7 @@ static BOOL brl_tdb_same_context(struct lock_context *ctx1, struct lock_context
lck1 is the existing lock. lck2 is the new lock we are
looking at adding
*/
-static BOOL brl_tdb_overlap(struct lock_struct *lck1,
+static bool brl_tdb_overlap(struct lock_struct *lck1,
struct lock_struct *lck2)
{
/* this extra check is not redundent - it copes with locks
@@ -147,12 +147,12 @@ static BOOL brl_tdb_overlap(struct lock_struct *lck1,
if (lck1->size != 0 &&
lck1->start == lck2->start &&
lck1->size == lck2->size) {
- return True;
+ return true;
}
if (lck1->start >= (lck2->start+lck2->size) ||
lck2->start >= (lck1->start+lck1->size)) {
- return False;
+ return false;
}
/* we have a conflict. Now check to see if lck1 really still
@@ -163,28 +163,28 @@ static BOOL brl_tdb_overlap(struct lock_struct *lck1,
* hasn't been written yet. When clustered this will need to
* call into ctdb */
- return True;
+ return true;
}
/*
See if lock2 can be added when lock1 is in place.
*/
-static BOOL brl_tdb_conflict(struct lock_struct *lck1,
+static bool brl_tdb_conflict(struct lock_struct *lck1,
struct lock_struct *lck2)
{
/* pending locks don't conflict with anything */
if (lck1->lock_type >= PENDING_READ_LOCK ||
lck2->lock_type >= PENDING_READ_LOCK) {
- return False;
+ return false;
}
if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK) {
- return False;
+ return false;
}
if (brl_tdb_same_context(&lck1->context, &lck2->context) &&
lck2->lock_type == READ_LOCK && lck1->ntvfs == lck2->ntvfs) {
- return False;
+ return false;
}
return brl_tdb_overlap(lck1, lck2);
@@ -195,16 +195,16 @@ static BOOL brl_tdb_conflict(struct lock_struct *lck1,
Check to see if this lock conflicts, but ignore our own locks on the
same fnum only.
*/
-static BOOL brl_tdb_conflict_other(struct lock_struct *lck1, struct lock_struct *lck2)
+static bool brl_tdb_conflict_other(struct lock_struct *lck1, struct lock_struct *lck2)
{
/* pending locks don't conflict with anything */
if (lck1->lock_type >= PENDING_READ_LOCK ||
lck2->lock_type >= PENDING_READ_LOCK) {
- return False;
+ return false;
}
if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK)
- return False;
+ return false;
/*
* note that incoming write calls conflict with existing READ
@@ -214,7 +214,7 @@ static BOOL brl_tdb_conflict_other(struct lock_struct *lck1, struct lock_struct
if (brl_tdb_same_context(&lck1->context, &lck2->context) &&
lck1->ntvfs == lck2->ntvfs &&
(lck2->lock_type == READ_LOCK || lck1->lock_type == WRITE_LOCK)) {
- return False;
+ return false;
}
return brl_tdb_overlap(lck1, lck2);
diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c
index 0d36a20a60..0214c39b2d 100644
--- a/source4/ntvfs/common/notify.c
+++ b/source4/ntvfs/common/notify.c
@@ -58,7 +58,7 @@ struct notify_list {
#define NOTIFY_KEY "notify array"
#define NOTIFY_ENABLE "notify:enable"
-#define NOTIFY_ENABLE_DEFAULT True
+#define NOTIFY_ENABLE_DEFAULT true
static NTSTATUS notify_remove_all(struct notify_context *notify);
static void notify_handler(struct messaging_context *msg_ctx, void *private_data,
@@ -86,7 +86,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
{
struct notify_context *notify;
- if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != True) {
+ if (share_bool_option(scfg, NOTIFY_ENABLE, NOTIFY_ENABLE_DEFAULT) != true) {
return NULL;
}
diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c
index 69282dd12e..59990d2fc1 100644
--- a/source4/ntvfs/common/opendb.c
+++ b/source4/ntvfs/common/opendb.c
@@ -41,6 +41,7 @@
#include "ntvfs/ntvfs.h"
#include "ntvfs/common/ntvfs_common.h"
#include "cluster/cluster.h"
+#include "param/param.h"
static const struct opendb_ops *ops;
@@ -61,7 +62,7 @@ _PUBLIC_ struct odb_context *odb_init(TALLOC_CTX *mem_ctx,
struct ntvfs_context *ntvfs_ctx)
{
if (ops == NULL) {
- if (lp_parm_bool(-1, "ctdb", "opendb", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "ctdb", "opendb", false)) {
odb_ctdb_init_ops();
} else {
odb_tdb_init_ops();
@@ -90,7 +91,7 @@ _PUBLIC_ struct odb_lock *odb_lock(TALLOC_CTX *mem_ctx,
*/
_PUBLIC_ NTSTATUS odb_open_file(struct odb_lock *lck, void *file_handle,
uint32_t stream_id, uint32_t share_access,
- uint32_t access_mask, BOOL delete_on_close,
+ uint32_t access_mask, bool delete_on_close,
const char *path,
uint32_t oplock_level, uint32_t *oplock_granted)
{
@@ -138,7 +139,7 @@ _PUBLIC_ NTSTATUS odb_rename(struct odb_lock *lck, const char *path)
/*
update delete on close flag on an open file
*/
-_PUBLIC_ NTSTATUS odb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_close)
+_PUBLIC_ NTSTATUS odb_set_delete_on_close(struct odb_lock *lck, bool del_on_close)
{
return ops->odb_set_delete_on_close(lck, del_on_close);
}
@@ -148,7 +149,7 @@ _PUBLIC_ NTSTATUS odb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_clos
people still have the file open
*/
_PUBLIC_ NTSTATUS odb_get_delete_on_close(struct odb_context *odb,
- DATA_BLOB *key, BOOL *del_on_close,
+ DATA_BLOB *key, bool *del_on_close,
int *open_count, char **path)
{
return ops->odb_get_delete_on_close(odb, key, del_on_close, open_count, path);
diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c
index 0bfe6e4eb3..a037e7e47e 100644
--- a/source4/ntvfs/common/opendb_tdb.c
+++ b/source4/ntvfs/common/opendb_tdb.c
@@ -47,11 +47,12 @@
#include "ntvfs/ntvfs.h"
#include "ntvfs/common/ntvfs_common.h"
#include "cluster/cluster.h"
+#include "param/param.h"
struct odb_context {
struct tdb_wrap *w;
struct ntvfs_context *ntvfs_ctx;
- BOOL oplocks;
+ bool oplocks;
};
/*
@@ -87,7 +88,7 @@ static struct odb_context *odb_tdb_init(TALLOC_CTX *mem_ctx,
odb->ntvfs_ctx = ntvfs_ctx;
/* leave oplocks disabled by default until the code is working */
- odb->oplocks = lp_parm_bool(-1, "opendb", "oplocks", False);
+ odb->oplocks = lp_parm_bool(global_loadparm, NULL, "opendb", "oplocks", false);
return odb;
}
@@ -265,7 +266,7 @@ static NTSTATUS odb_oplock_break_send(struct odb_context *odb, struct opendb_ent
*/
static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle,
uint32_t stream_id, uint32_t share_access,
- uint32_t access_mask, BOOL delete_on_close,
+ uint32_t access_mask, bool delete_on_close,
const char *path,
uint32_t oplock_level, uint32_t *oplock_granted)
{
@@ -275,7 +276,7 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, void *file_handle,
struct opendb_file file;
NTSTATUS status;
- if (odb->oplocks == False) {
+ if (odb->oplocks == false) {
oplock_level = OPLOCK_NONE;
}
@@ -406,7 +407,7 @@ static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle)
if (file_handle == file.entries[i].file_handle &&
cluster_id_equal(&odb->ntvfs_ctx->server_id, &file.entries[i].server)) {
if (file.entries[i].delete_on_close) {
- file.delete_on_close = True;
+ file.delete_on_close = true;
}
if (i < file.num_entries-1) {
memmove(file.entries+i, file.entries+i+1,
@@ -493,7 +494,7 @@ static NTSTATUS odb_tdb_rename(struct odb_lock *lck, const char *path)
/*
update delete on close flag on an open file
*/
-static NTSTATUS odb_tdb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_close)
+static NTSTATUS odb_tdb_set_delete_on_close(struct odb_lock *lck, bool del_on_close)
{
NTSTATUS status;
struct opendb_file file;
@@ -511,7 +512,7 @@ static NTSTATUS odb_tdb_set_delete_on_close(struct odb_lock *lck, BOOL del_on_cl
people still have the file open
*/
static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb,
- DATA_BLOB *key, BOOL *del_on_close,
+ DATA_BLOB *key, bool *del_on_close,
int *open_count, char **path)
{
NTSTATUS status;
@@ -524,7 +525,7 @@ static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb,
status = odb_pull_record(lck, &file);
if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
talloc_free(lck);
- (*del_on_close) = False;
+ (*del_on_close) = false;
return NT_STATUS_OK;
}
if (!NT_STATUS_IS_OK(status)) {
@@ -540,7 +541,7 @@ static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb,
*path = talloc_strdup(odb, file.path);
NT_STATUS_HAVE_NO_MEMORY(*path);
if (file.num_entries == 1 && file.entries[0].delete_on_close) {
- (*del_on_close) = True;
+ (*del_on_close) = true;
}
}
diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c
index fbac82a305..fc3c74ca6c 100644
--- a/source4/ntvfs/ipc/vfs_ipc.c
+++ b/source4/ntvfs/ipc/vfs_ipc.c
@@ -669,7 +669,7 @@ static NTSTATUS ipc_lpq(struct ntvfs_module_context *ntvfs,
static NTSTATUS ipc_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
return NT_STATUS_ACCESS_DENIED;
}
@@ -680,7 +680,7 @@ static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs,
static NTSTATUS ipc_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
return NT_STATUS_ACCESS_DENIED;
}
diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c
index 9379419c50..987227a0b7 100644
--- a/source4/ntvfs/nbench/vfs_nbench.c
+++ b/source4/ntvfs/nbench/vfs_nbench.c
@@ -841,7 +841,7 @@ static void nbench_search_first_send(struct ntvfs_request *req)
static NTSTATUS nbench_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
NTSTATUS status;
@@ -863,7 +863,7 @@ static void nbench_search_next_send(struct ntvfs_request *req)
static NTSTATUS nbench_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
NTSTATUS status;
diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c
index 03c5aff01c..20197a4ba9 100644
--- a/source4/ntvfs/ntvfs_base.c
+++ b/source4/ntvfs/ntvfs_base.c
@@ -26,6 +26,7 @@
#include "lib/util/dlinklist.h"
#include "build.h"
#include "ntvfs/ntvfs.h"
+#include "param/param.h"
/* the list of currently registered NTVFS backends, note that there
* can be more than one backend with the same name, as long as they
@@ -112,7 +113,7 @@ _PUBLIC_ const struct ntvfs_critical_sizes *ntvfs_interface_version(void)
return &critical_sizes;
}
-_PUBLIC_ BOOL ntvfs_interface_differs(const struct ntvfs_critical_sizes *const iface)
+_PUBLIC_ bool ntvfs_interface_differs(const struct ntvfs_critical_sizes *const iface)
{
/* The comparison would be easier with memcmp, but compiler-interset
* alignment padding is not guaranteed to be zeroed.
@@ -121,28 +122,28 @@ _PUBLIC_ BOOL ntvfs_interface_differs(const struct ntvfs_critical_sizes *const i
#define FIELD_DIFFERS(field) (iface->field != critical_sizes.field)
if (FIELD_DIFFERS(interface_version))
- return True;
+ return true;
if (FIELD_DIFFERS(sizeof_ntvfs_critical_sizes))
- return True;
+ return true;
if (FIELD_DIFFERS(sizeof_ntvfs_context))
- return True;
+ return true;
if (FIELD_DIFFERS(sizeof_ntvfs_module_context))
- return True;
+ return true;
if (FIELD_DIFFERS(sizeof_ntvfs_ops))
- return True;
+ return true;
if (FIELD_DIFFERS(sizeof_ntvfs_async_state))
- return True;
+ return true;
if (FIELD_DIFFERS(sizeof_ntvfs_request))
- return True;
+ return true;
/* Versions match. */
- return False;
+ return false;
#undef FIELD_DIFFERS
}
@@ -199,7 +200,7 @@ NTSTATUS ntvfs_init_connection(TALLOC_CTX *mem_ctx, struct share_config *scfg, e
NTSTATUS ntvfs_init(void)
{
init_module_fn static_init[] = STATIC_ntvfs_MODULES;
- init_module_fn *shared_init = load_samba_modules(NULL, "ntvfs");
+ init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "ntvfs");
run_init_functions(static_init);
run_init_functions(shared_init);
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index 8ed99ce3f1..7708f4fc80 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -116,21 +116,21 @@ static NTSTATUS ntvfs_map_async_finish(struct ntvfs_request *req, NTSTATUS statu
see if a filename ends in EXE COM DLL or SYM. This is needed for the
DENY_DOS mapping for OpenX
*/
-BOOL is_exe_filename(const char *fname)
+bool is_exe_filename(const char *fname)
{
char *p;
p = strrchr(fname, '.');
if (!p) {
- return False;
+ return false;
}
p++;
if (strcasecmp(p, "EXE") == 0 ||
strcasecmp(p, "COM") == 0 ||
strcasecmp(p, "DLL") == 0 ||
strcasecmp(p, "SYM") == 0) {
- return True;
+ return true;
}
- return False;
+ return false;
}
@@ -1247,7 +1247,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
}
rd2->readx.level = RAW_READ_READX;
- rd2->readx.in.read_for_execute = False;
+ rd2->readx.in.read_for_execute = false;
switch (rd->generic.level) {
case RAW_READ_READX:
diff --git a/source4/ntvfs/ntvfs_interface.c b/source4/ntvfs/ntvfs_interface.c
index 74fb815359..3bd2859388 100644
--- a/source4/ntvfs/ntvfs_interface.c
+++ b/source4/ntvfs/ntvfs_interface.c
@@ -149,7 +149,7 @@ _PUBLIC_ NTSTATUS ntvfs_copy(struct ntvfs_request *req, struct smb_copy *cp)
/* directory search */
_PUBLIC_ NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search_first *io, void *private,
- BOOL ntvfs_callback(void *private, const union smb_search_data *file))
+ bool ntvfs_callback(void *private, const union smb_search_data *file))
{
struct ntvfs_module_context *ntvfs = req->ctx->modules;
if (!ntvfs->ops->search_first) {
@@ -159,7 +159,7 @@ _PUBLIC_ NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search
}
_PUBLIC_ NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_next *io, void *private,
- BOOL ntvfs_callback(void *private, const union smb_search_data *file))
+ bool ntvfs_callback(void *private, const union smb_search_data *file))
{
struct ntvfs_module_context *ntvfs = req->ctx->modules;
if (!ntvfs->ops->search_next) {
@@ -469,7 +469,7 @@ _PUBLIC_ NTSTATUS ntvfs_next_open(struct ntvfs_module_context *ntvfs,
_PUBLIC_ NTSTATUS ntvfs_next_search_first(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req,
union smb_search_first *io, void *private,
- BOOL (*callback)(void *private, const union smb_search_data *file))
+ bool (*callback)(void *private, const union smb_search_data *file))
{
if (!ntvfs->next || !ntvfs->next->ops->search_first) {
return NT_STATUS_NOT_IMPLEMENTED;
@@ -480,7 +480,7 @@ _PUBLIC_ NTSTATUS ntvfs_next_search_first(struct ntvfs_module_context *ntvfs,
_PUBLIC_ NTSTATUS ntvfs_next_search_next(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req,
union smb_search_next *io, void *private,
- BOOL (*callback)(void *private, const union smb_search_data *file))
+ bool (*callback)(void *private, const union smb_search_data *file))
{
if (!ntvfs->next || !ntvfs->next->ops->search_next) {
return NT_STATUS_NOT_IMPLEMENTED;
diff --git a/source4/ntvfs/ntvfs_util.c b/source4/ntvfs/ntvfs_util.c
index 3158bdf1fd..7432ac2c13 100644
--- a/source4/ntvfs/ntvfs_util.c
+++ b/source4/ntvfs/ntvfs_util.c
@@ -112,7 +112,7 @@ _PUBLIC_ NTSTATUS ntvfs_handle_set_backend_data(struct ntvfs_handle *h,
TALLOC_CTX *private_data)
{
struct ntvfs_handle_data *d;
- BOOL first_time = h->backend_data?False:True;
+ bool first_time = h->backend_data?false:true;
for (d=h->backend_data; d; d = d->next) {
if (d->owner != ntvfs) continue;
diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c
index 4302b7f890..f19dc1f41f 100644
--- a/source4/ntvfs/posix/pvfs_acl.c
+++ b/source4/ntvfs/posix/pvfs_acl.c
@@ -365,7 +365,7 @@ NTSTATUS pvfs_acl_query(struct pvfs_state *pvfs,
/*
check the read only bit against any of the write access bits
*/
-static BOOL pvfs_read_only(struct pvfs_state *pvfs, uint32_t access_mask)
+static bool pvfs_read_only(struct pvfs_state *pvfs, uint32_t access_mask)
{
if ((pvfs->flags & PVFS_FLAG_READONLY) &&
(access_mask & (SEC_FILE_WRITE_DATA |
@@ -376,9 +376,9 @@ static BOOL pvfs_read_only(struct pvfs_state *pvfs, uint32_t access_mask)
SEC_STD_WRITE_DAC |
SEC_STD_WRITE_OWNER |
SEC_DIR_DELETE_CHILD))) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
@@ -548,24 +548,24 @@ NTSTATUS pvfs_access_check_parent(struct pvfs_state *pvfs,
/*
determine if an ACE is inheritable
*/
-static BOOL pvfs_inheritable_ace(struct pvfs_state *pvfs,
+static bool pvfs_inheritable_ace(struct pvfs_state *pvfs,
const struct security_ace *ace,
- BOOL container)
+ bool container)
{
if (!container) {
return (ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT) != 0;
}
if (ace->flags & SEC_ACE_FLAG_CONTAINER_INHERIT) {
- return True;
+ return true;
}
if ((ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT) &&
!(ace->flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT)) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
@@ -576,7 +576,7 @@ static BOOL pvfs_inheritable_ace(struct pvfs_state *pvfs,
static NTSTATUS pvfs_acl_inherit_aces(struct pvfs_state *pvfs,
struct security_descriptor *parent_sd,
struct security_descriptor *sd,
- BOOL container)
+ bool container)
{
int i;
@@ -663,7 +663,7 @@ NTSTATUS pvfs_acl_inherit(struct pvfs_state *pvfs,
NTSTATUS status;
struct pvfs_filename *parent;
struct security_descriptor *parent_sd, *sd;
- BOOL container;
+ bool container;
/* form the parents path */
status = pvfs_resolve_parent(pvfs, req, name, &parent);
@@ -716,7 +716,7 @@ NTSTATUS pvfs_acl_inherit(struct pvfs_state *pvfs,
sd->type |= SEC_DESC_DACL_PRESENT;
- container = (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) ? True:False;
+ container = (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) ? true:false;
/* fill in the aces from the parent */
status = pvfs_acl_inherit_aces(pvfs, parent_sd, sd, container);
diff --git a/source4/ntvfs/posix/pvfs_dirlist.c b/source4/ntvfs/posix/pvfs_dirlist.c
index e54cb847f5..77f19c3585 100644
--- a/source4/ntvfs/posix/pvfs_dirlist.c
+++ b/source4/ntvfs/posix/pvfs_dirlist.c
@@ -33,13 +33,13 @@ struct name_cache_entry {
struct pvfs_dir {
struct pvfs_state *pvfs;
- BOOL no_wildcard;
+ bool no_wildcard;
char *single_name;
const char *pattern;
off_t offset;
DIR *dir;
const char *unix_path;
- BOOL end_of_search;
+ bool end_of_search;
struct name_cache_entry *name_cache;
uint32_t name_cache_index;
};
@@ -69,8 +69,8 @@ static NTSTATUS pvfs_list_no_wildcard(struct pvfs_state *pvfs, struct pvfs_filen
}
dir->pvfs = pvfs;
- dir->no_wildcard = True;
- dir->end_of_search = False;
+ dir->no_wildcard = true;
+ dir->end_of_search = false;
dir->unix_path = talloc_strdup(dir, name->full_name);
if (!dir->unix_path) {
return NT_STATUS_NO_MEMORY;
@@ -145,8 +145,8 @@ NTSTATUS pvfs_list_start(struct pvfs_state *pvfs, struct pvfs_filename *name,
}
dir->pvfs = pvfs;
- dir->no_wildcard = False;
- dir->end_of_search = False;
+ dir->no_wildcard = false;
+ dir->end_of_search = false;
dir->offset = DIR_OFFSET_DOT;
dir->name_cache = talloc_zero_array(dir,
struct name_cache_entry,
@@ -187,7 +187,7 @@ const char *pvfs_list_next(struct pvfs_dir *dir, off_t *ofs)
/* non-wildcard searches are easy */
if (dir->no_wildcard) {
- dir->end_of_search = True;
+ dir->end_of_search = true;
if (*ofs != 0) return NULL;
(*ofs)++;
return dir->single_name;
@@ -246,7 +246,7 @@ const char *pvfs_list_next(struct pvfs_dir *dir, off_t *ofs)
return dname;
}
- dir->end_of_search = True;
+ dir->end_of_search = true;
return NULL;
}
@@ -259,9 +259,9 @@ const char *pvfs_list_unix_path(struct pvfs_dir *dir)
}
/*
- return True if end of search has been reached
+ return true if end of search has been reached
*/
-BOOL pvfs_list_eos(struct pvfs_dir *dir, off_t ofs)
+bool pvfs_list_eos(struct pvfs_dir *dir, off_t ofs)
{
return dir->end_of_search;
}
@@ -274,7 +274,7 @@ NTSTATUS pvfs_list_seek(struct pvfs_dir *dir, const char *name, off_t *ofs)
struct dirent *de;
int i;
- dir->end_of_search = False;
+ dir->end_of_search = false;
if (ISDOT(name)) {
dir->offset = DIR_OFFSET_DOTDOT;
@@ -313,7 +313,7 @@ NTSTATUS pvfs_list_seek(struct pvfs_dir *dir, const char *name, off_t *ofs)
}
}
- dir->end_of_search = True;
+ dir->end_of_search = true;
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
@@ -326,7 +326,7 @@ NTSTATUS pvfs_list_seek_ofs(struct pvfs_dir *dir, uint32_t resume_key, off_t *of
struct dirent *de;
int i;
- dir->end_of_search = False;
+ dir->end_of_search = false;
if (resume_key == DIR_OFFSET_DOT) {
*ofs = DIR_OFFSET_DOTDOT;
@@ -341,7 +341,7 @@ NTSTATUS pvfs_list_seek_ofs(struct pvfs_dir *dir, uint32_t resume_key, off_t *of
if (resume_key == DIR_OFFSET_BASE) {
rewinddir(dir->dir);
if ((de=readdir(dir->dir)) == NULL) {
- dir->end_of_search = True;
+ dir->end_of_search = true;
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
*ofs = telldir(dir->dir) + DIR_OFFSET_BASE;
@@ -374,7 +374,7 @@ NTSTATUS pvfs_list_seek_ofs(struct pvfs_dir *dir, uint32_t resume_key, off_t *of
}
}
- dir->end_of_search = True;
+ dir->end_of_search = true;
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
@@ -383,21 +383,21 @@ NTSTATUS pvfs_list_seek_ofs(struct pvfs_dir *dir, uint32_t resume_key, off_t *of
/*
see if a directory is empty
*/
-BOOL pvfs_directory_empty(struct pvfs_state *pvfs, struct pvfs_filename *name)
+bool pvfs_directory_empty(struct pvfs_state *pvfs, struct pvfs_filename *name)
{
struct dirent *de;
DIR *dir = opendir(name->full_name);
if (dir == NULL) {
- return True;
+ return true;
}
while ((de = readdir(dir))) {
if (!ISDOT(de->d_name) && !ISDOTDOT(de->d_name)) {
closedir(dir);
- return False;
+ return false;
}
}
closedir(dir);
- return True;
+ return true;
}
diff --git a/source4/ntvfs/posix/pvfs_lock.c b/source4/ntvfs/posix/pvfs_lock.c
index 989e3c56a4..b9bb58c71d 100644
--- a/source4/ntvfs/posix/pvfs_lock.c
+++ b/source4/ntvfs/posix/pvfs_lock.c
@@ -104,7 +104,7 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
enum brl_type rw;
NTSTATUS status;
int i;
- BOOL timed_out;
+ bool timed_out;
timed_out = (reason != PVFS_WAIT_EVENT);
@@ -136,7 +136,7 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
}
if (NT_STATUS_IS_OK(status)) {
f->lock_count++;
- timed_out = False;
+ timed_out = false;
}
/* if we have failed and timed out, or succeeded, then we
diff --git a/source4/ntvfs/posix/pvfs_notify.c b/source4/ntvfs/posix/pvfs_notify.c
index 3e289a0948..210f949395 100644
--- a/source4/ntvfs/posix/pvfs_notify.c
+++ b/source4/ntvfs/posix/pvfs_notify.c
@@ -58,7 +58,7 @@ static void pvfs_notify_send_next(struct event_context *ev, struct timed_event *
send a reply to a pending notify request
*/
static void pvfs_notify_send(struct pvfs_notify_buffer *notify_buffer,
- NTSTATUS status, BOOL immediate)
+ NTSTATUS status, bool immediate)
{
struct notify_pending *pending = notify_buffer->pending;
struct ntvfs_request *req;
@@ -118,7 +118,7 @@ static int pvfs_notify_destructor(struct pvfs_notify_buffer *n)
{
notify_remove(n->f->pvfs->notify_context, n);
n->f->notify_buffer = NULL;
- pvfs_notify_send(n, NT_STATUS_OK, True);
+ pvfs_notify_send(n, NT_STATUS_OK, true);
return 0;
}
@@ -161,7 +161,7 @@ static void pvfs_notify_callback(void *private, const struct notify_event *ev)
/* send what we have, unless its the first part of a rename */
if (ev->action != NOTIFY_ACTION_OLD_NAME) {
- pvfs_notify_send(n, NT_STATUS_OK, True);
+ pvfs_notify_send(n, NT_STATUS_OK, true);
}
}
@@ -169,7 +169,7 @@ static void pvfs_notify_callback(void *private, const struct notify_event *ev)
setup a notify buffer on a directory handle
*/
static NTSTATUS pvfs_notify_setup(struct pvfs_state *pvfs, struct pvfs_file *f,
- uint32_t buffer_size, uint32_t filter, BOOL recursive)
+ uint32_t buffer_size, uint32_t filter, bool recursive)
{
NTSTATUS status;
struct notify_entry e;
@@ -206,9 +206,9 @@ static void pvfs_notify_end(void *private, enum pvfs_wait_notice reason)
struct pvfs_notify_buffer *notify_buffer = talloc_get_type(private,
struct pvfs_notify_buffer);
if (reason == PVFS_WAIT_CANCEL) {
- pvfs_notify_send(notify_buffer, NT_STATUS_CANCELLED, False);
+ pvfs_notify_send(notify_buffer, NT_STATUS_CANCELLED, false);
} else {
- pvfs_notify_send(notify_buffer, NT_STATUS_OK, True);
+ pvfs_notify_send(notify_buffer, NT_STATUS_OK, true);
}
}
@@ -277,7 +277,7 @@ NTSTATUS pvfs_notify(struct ntvfs_module_context *ntvfs,
}
req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC;
- pvfs_notify_send(f->notify_buffer, NT_STATUS_OK, False);
+ pvfs_notify_send(f->notify_buffer, NT_STATUS_OK, false);
return NT_STATUS_OK;
}
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index 269df13069..8558f0476a 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -186,7 +186,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
uint32_t create_action;
uint32_t access_mask = io->generic.in.access_mask;
struct odb_lock *lck;
- BOOL del_on_close;
+ bool del_on_close;
uint32_t create_options;
uint32_t share_access;
@@ -268,14 +268,14 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
f->handle->seek_offset = 0;
f->handle->position = 0;
f->handle->mode = 0;
- f->handle->sticky_write_time = False;
- f->handle->open_completed = False;
+ f->handle->sticky_write_time = false;
+ f->handle->open_completed = false;
if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
pvfs_directory_empty(pvfs, f->handle->name)) {
- del_on_close = True;
+ del_on_close = true;
} else {
- del_on_close = False;
+ del_on_close = false;
}
if (name->exists) {
@@ -305,7 +305,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
return status;
}
- f->handle->have_opendb_entry = True;
+ f->handle->have_opendb_entry = true;
}
DLIST_ADD(pvfs->files.list, f);
@@ -357,7 +357,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
goto cleanup_delete;
}
- f->handle->have_opendb_entry = True;
+ f->handle->have_opendb_entry = true;
create_action = NTCREATEX_ACTION_CREATED;
@@ -379,7 +379,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
goto cleanup_delete;
}
- f->handle->open_completed = True;
+ f->handle->open_completed = true;
io->generic.out.oplock_level = OPLOCK_NONE;
io->generic.out.file.ntvfs = h;
@@ -552,7 +552,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
uint32_t access_mask = io->generic.in.access_mask;
mode_t mode;
uint32_t attrib;
- BOOL del_on_close;
+ bool del_on_close;
struct pvfs_filename *parent;
uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
@@ -656,9 +656,9 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
}
if (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) {
- del_on_close = True;
+ del_on_close = true;
} else {
- del_on_close = False;
+ del_on_close = false;
}
if (pvfs->flags & PVFS_FLAG_FAKE_OPLOCKS) {
@@ -702,9 +702,9 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
f->handle->seek_offset = 0;
f->handle->position = 0;
f->handle->mode = 0;
- f->handle->have_opendb_entry = True;
- f->handle->sticky_write_time = False;
- f->handle->open_completed = False;
+ f->handle->have_opendb_entry = true;
+ f->handle->sticky_write_time = false;
+ f->handle->open_completed = false;
DLIST_ADD(pvfs->files.list, f);
@@ -733,7 +733,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
goto cleanup_delete;
}
- f->handle->open_completed = True;
+ f->handle->open_completed = true;
notify_trigger(pvfs->notify_context,
NOTIFY_ACTION_ADDED,
@@ -989,8 +989,8 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
uint32_t create_options;
uint32_t share_access;
uint32_t access_mask;
- BOOL del_on_close;
- BOOL stream_existed, stream_truncate=False;
+ bool del_on_close;
+ bool stream_existed, stream_truncate=false;
uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
/* use the generic mapping code to avoid implementing all the
@@ -1035,7 +1035,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
if (name->stream_name == NULL) {
flags = O_TRUNC;
} else {
- stream_truncate = True;
+ stream_truncate = true;
}
break;
@@ -1053,7 +1053,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
if (name->stream_name == NULL) {
flags = O_TRUNC;
} else {
- stream_truncate = True;
+ stream_truncate = true;
}
break;
@@ -1133,9 +1133,9 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
f->handle->seek_offset = 0;
f->handle->position = 0;
f->handle->mode = 0;
- f->handle->have_opendb_entry = False;
- f->handle->sticky_write_time = False;
- f->handle->open_completed = False;
+ 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
opendb locking */
@@ -1172,9 +1172,9 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
*/
if (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE &&
req->ctx->protocol == PROTOCOL_SMB2) {
- del_on_close = True;
+ del_on_close = true;
} else {
- del_on_close = False;
+ del_on_close = false;
}
if (pvfs->flags & PVFS_FLAG_FAKE_OPLOCKS) {
@@ -1206,7 +1206,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
oplock_granted = OPLOCK_BATCH;
}
- f->handle->have_opendb_entry = True;
+ f->handle->have_opendb_entry = true;
if (access_mask & (SEC_FILE_WRITE_DATA | SEC_FILE_APPEND_DATA)) {
flags |= O_RDWR;
@@ -1273,7 +1273,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
/* mark the open as having completed fully, so delete on close
can now be used */
- f->handle->open_completed = True;
+ f->handle->open_completed = true;
io->generic.out.oplock_level = oplock_granted;
io->generic.out.file.ntvfs = h;
@@ -1379,7 +1379,7 @@ NTSTATUS pvfs_exit(struct ntvfs_module_context *ntvfs,
*/
NTSTATUS pvfs_set_delete_on_close(struct pvfs_state *pvfs,
struct ntvfs_request *req,
- struct pvfs_file *f, BOOL del_on_close)
+ struct pvfs_file *f, bool del_on_close)
{
struct odb_lock *lck;
NTSTATUS status;
@@ -1532,17 +1532,17 @@ NTSTATUS pvfs_can_stat(struct pvfs_state *pvfs,
/*
determine if delete on close is set on
*/
-BOOL pvfs_delete_on_close_set(struct pvfs_state *pvfs, struct pvfs_file_handle *h,
+bool pvfs_delete_on_close_set(struct pvfs_state *pvfs, struct pvfs_file_handle *h,
int *open_count, char **path)
{
NTSTATUS status;
- BOOL del_on_close;
+ bool del_on_close;
status = odb_get_delete_on_close(pvfs->odb_context, &h->odb_locking_key,
&del_on_close, open_count, path);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1,("WARNING: unable to determine delete on close status for open file\n"));
- return False;
+ return false;
}
return del_on_close;
diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c
index fae5ec432c..8a7aa13351 100644
--- a/source4/ntvfs/posix/pvfs_resolve.c
+++ b/source4/ntvfs/posix/pvfs_resolve.c
@@ -121,7 +121,7 @@ static NTSTATUS pvfs_case_search(struct pvfs_state *pvfs, struct pvfs_filename *
talloc_free(partial_name);
partial_name = test_name;
if (i == num_components - 1) {
- name->exists = True;
+ name->exists = true;
}
continue;
}
@@ -166,7 +166,7 @@ static NTSTATUS pvfs_case_search(struct pvfs_state *pvfs, struct pvfs_filename *
if (!name->exists) {
if (stat(partial_name, &name->st) == 0) {
- name->exists = True;
+ name->exists = true;
}
}
@@ -229,7 +229,7 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
name->original_name = talloc_strdup(name, cifs_name);
name->stream_name = NULL;
name->stream_id = 0;
- name->has_wildcard = False;
+ name->has_wildcard = false;
while (*cifs_name == '\\') {
cifs_name++;
@@ -291,7 +291,7 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
if (!(flags & PVFS_RESOLVE_WILDCARD)) {
return NT_STATUS_OBJECT_NAME_INVALID;
}
- name->has_wildcard = True;
+ name->has_wildcard = true;
break;
case '/':
case '|':
@@ -456,8 +456,8 @@ NTSTATUS pvfs_resolve_name(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- (*name)->exists = False;
- (*name)->stream_exists = False;
+ (*name)->exists = false;
+ (*name)->stream_exists = false;
if (!(pvfs->fs_attribs & FS_ATTR_NAMED_STREAMS)) {
flags &= ~PVFS_RESOLVE_STREAMS;
@@ -519,7 +519,7 @@ NTSTATUS pvfs_resolve_name(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
/* if we can stat() the full name now then we are done */
if (stat((*name)->full_name, &(*name)->st) == 0) {
- (*name)->exists = True;
+ (*name)->exists = true;
return pvfs_fill_dos_info(pvfs, *name, -1);
}
@@ -558,9 +558,9 @@ NTSTATUS pvfs_resolve_partial(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
- (*name)->exists = True;
- (*name)->stream_exists = True;
- (*name)->has_wildcard = False;
+ (*name)->exists = true;
+ (*name)->stream_exists = true;
+ (*name)->has_wildcard = false;
(*name)->original_name = talloc_strdup(*name, fname);
(*name)->stream_name = NULL;
(*name)->stream_id = 0;
@@ -608,7 +608,7 @@ NTSTATUS pvfs_resolve_name_fd(struct pvfs_state *pvfs, int fd,
return NT_STATUS_UNEXPECTED_IO_ERROR;
}
- name->exists = True;
+ name->exists = true;
return pvfs_fill_dos_info(pvfs, name, fd);
}
@@ -650,9 +650,9 @@ NTSTATUS pvfs_resolve_parent(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
- (*name)->exists = True;
- (*name)->stream_exists = True;
- (*name)->has_wildcard = False;
+ (*name)->exists = true;
+ (*name)->stream_exists = true;
+ (*name)->has_wildcard = false;
/* we can't get the correct 'original_name', but for the purposes
of this call this is close enough */
(*name)->original_name = talloc_reference(*name, child->original_name);
diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c
index cefcee6155..e47406dc09 100644
--- a/source4/ntvfs/posix/pvfs_search.c
+++ b/source4/ntvfs/posix/pvfs_search.c
@@ -237,7 +237,7 @@ static NTSTATUS pvfs_search_fill(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
enum smb_search_data_level level,
uint_t *reply_count,
void *search_private,
- BOOL (*callback)(void *, const union smb_search_data *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct pvfs_dir *dir = search->dir;
NTSTATUS status;
@@ -313,7 +313,7 @@ static void pvfs_search_cleanup(struct pvfs_state *pvfs)
static NTSTATUS pvfs_search_first_old(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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct pvfs_dir *dir;
struct pvfs_state *pvfs = ntvfs->private_data;
@@ -403,7 +403,7 @@ static NTSTATUS pvfs_search_first_old(struct ntvfs_module_context *ntvfs,
static NTSTATUS pvfs_search_next_old(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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct pvfs_state *pvfs = ntvfs->private_data;
struct pvfs_search_state *search;
@@ -452,7 +452,7 @@ static NTSTATUS pvfs_search_next_old(struct ntvfs_module_context *ntvfs,
static NTSTATUS pvfs_search_first_trans2(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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct pvfs_dir *dir;
struct pvfs_state *pvfs = ntvfs->private_data;
@@ -548,7 +548,7 @@ static NTSTATUS pvfs_search_first_trans2(struct ntvfs_module_context *ntvfs,
static NTSTATUS pvfs_search_next_trans2(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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct pvfs_state *pvfs = ntvfs->private_data;
struct pvfs_search_state *search;
@@ -609,7 +609,7 @@ static NTSTATUS pvfs_search_next_trans2(struct ntvfs_module_context *ntvfs,
static NTSTATUS pvfs_search_first_smb2(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req, const struct smb2_find *io,
void *search_private,
- BOOL (*callback)(void *, const union smb_search_data *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct pvfs_dir *dir;
struct pvfs_state *pvfs = ntvfs->private_data;
@@ -712,7 +712,7 @@ static NTSTATUS pvfs_search_first_smb2(struct ntvfs_module_context *ntvfs,
static NTSTATUS pvfs_search_next_smb2(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req, const struct smb2_find *io,
void *search_private,
- BOOL (*callback)(void *, const union smb_search_data *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct pvfs_state *pvfs = ntvfs->private_data;
struct pvfs_search_state *search;
@@ -765,7 +765,7 @@ static NTSTATUS pvfs_search_next_smb2(struct ntvfs_module_context *ntvfs,
NTSTATUS pvfs_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
switch (io->generic.level) {
case RAW_SEARCH_SEARCH:
@@ -787,7 +787,7 @@ NTSTATUS pvfs_search_first(struct ntvfs_module_context *ntvfs,
NTSTATUS pvfs_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
switch (io->generic.level) {
case RAW_SEARCH_SEARCH:
diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c
index f20270c743..340913cd4d 100644
--- a/source4/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_setfileinfo.c
@@ -323,7 +323,7 @@ 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;
+ 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_shortname.c b/source4/ntvfs/posix/pvfs_shortname.c
index 5df4a57f9c..1cbe287a4b 100644
--- a/source4/ntvfs/posix/pvfs_shortname.c
+++ b/source4/ntvfs/posix/pvfs_shortname.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "system/locale.h"
#include "vfs_posix.h"
+#include "param/param.h"
/*
this mangling scheme uses the following format
@@ -158,7 +159,7 @@ static const char *cache_lookup(struct pvfs_mangle_context *ctx, uint32_t hash)
In this algorithm, mangled names use only pure ascii characters (no
multi-byte) so we can avoid doing a UCS2 conversion
*/
-static BOOL is_mangled_component(struct pvfs_mangle_context *ctx,
+static bool is_mangled_component(struct pvfs_mangle_context *ctx,
const char *name, size_t len)
{
unsigned int i;
@@ -167,19 +168,19 @@ static BOOL is_mangled_component(struct pvfs_mangle_context *ctx,
/* check the length */
if (len > 12 || len < 8)
- return False;
+ return false;
/* the best distinguishing characteristic is the ~ */
if (name[6] != '~')
- return False;
+ return false;
/* check extension */
if (len > 8) {
if (name[8] != '.')
- return False;
+ return false;
for (i=9; name[i] && i < len; i++) {
if (! FLAG_CHECK(name[i], FLAG_ASCII)) {
- return False;
+ return false;
}
}
}
@@ -187,23 +188,23 @@ static BOOL is_mangled_component(struct pvfs_mangle_context *ctx,
/* check lead characters */
for (i=0;i<ctx->mangle_prefix;i++) {
if (! FLAG_CHECK(name[i], FLAG_ASCII)) {
- return False;
+ return false;
}
}
/* check rest of hash */
if (! FLAG_CHECK(name[7], FLAG_BASECHAR)) {
- return False;
+ return false;
}
for (i=ctx->mangle_prefix;i<6;i++) {
if (! FLAG_CHECK(name[i], FLAG_BASECHAR)) {
- return False;
+ return false;
}
}
M_DEBUG(10,("is_mangled_component %s (len %u) -> yes\n", name, (unsigned int)len));
- return True;
+ return true;
}
@@ -219,7 +220,7 @@ static BOOL is_mangled_component(struct pvfs_mangle_context *ctx,
directory separators. It should return true if any component is
mangled
*/
-static BOOL is_mangled(struct pvfs_mangle_context *ctx, const char *name)
+static bool is_mangled(struct pvfs_mangle_context *ctx, const char *name)
{
const char *p;
const char *s;
@@ -228,7 +229,7 @@ static BOOL is_mangled(struct pvfs_mangle_context *ctx, const char *name)
for (s=name; (p=strchr(s, '/')); s=p+1) {
if (is_mangled_component(ctx, s, PTR_DIFF(p, s))) {
- return True;
+ return true;
}
}
@@ -244,8 +245,8 @@ static BOOL is_mangled(struct pvfs_mangle_context *ctx, const char *name)
simplifies things greatly (it means that we know the string won't
get larger when converted from UNIX to DOS formats)
*/
-static BOOL is_8_3(struct pvfs_mangle_context *ctx,
- const char *name, BOOL check_case, BOOL allow_wildcards)
+static bool is_8_3(struct pvfs_mangle_context *ctx,
+ const char *name, bool check_case, bool allow_wildcards)
{
int len, i;
char *dot_p;
@@ -253,7 +254,7 @@ static BOOL is_8_3(struct pvfs_mangle_context *ctx,
/* as a special case, the names '.' and '..' are allowable 8.3 names */
if (name[0] == '.') {
if (!name[1] || (name[1] == '.' && !name[2])) {
- return True;
+ return true;
}
}
@@ -264,7 +265,7 @@ static BOOL is_8_3(struct pvfs_mangle_context *ctx,
only be slower, it would be incorrect */
len = strlen(name);
if (len > 12)
- return False;
+ return false;
/* find the '.'. Note that once again we use the non-multibyte
function */
@@ -274,7 +275,7 @@ static BOOL is_8_3(struct pvfs_mangle_context *ctx,
/* if the name doesn't contain a '.' then its length
must be less than 8 */
if (len > 8) {
- return False;
+ return false;
}
} else {
int prefix_len, suffix_len;
@@ -285,12 +286,12 @@ static BOOL is_8_3(struct pvfs_mangle_context *ctx,
suffix_len = len - (prefix_len+1);
if (prefix_len > 8 || suffix_len > 3 || suffix_len == 0) {
- return False;
+ return false;
}
/* a 8.3 name cannot contain more than 1 '.' */
if (strchr(dot_p+1, '.')) {
- return False;
+ return false;
}
}
@@ -299,12 +300,12 @@ static BOOL is_8_3(struct pvfs_mangle_context *ctx,
/* note that we may allow wildcard petterns! */
if (!FLAG_CHECK(name[i], FLAG_ASCII|(allow_wildcards ? FLAG_WILDCARD : 0)) &&
name[i] != '.') {
- return False;
+ return false;
}
}
/* it is a good 8.3 name */
- return True;
+ return true;
}
@@ -360,7 +361,7 @@ static char *check_cache(struct pvfs_mangle_context *ctx,
/*
look for a DOS reserved name
*/
-static BOOL is_reserved_name(struct pvfs_mangle_context *ctx, const char *name)
+static bool is_reserved_name(struct pvfs_mangle_context *ctx, const char *name)
{
if (FLAG_CHECK(name[0], FLAG_POSSIBLE1) &&
FLAG_CHECK(name[1], FLAG_POSSIBLE2) &&
@@ -370,12 +371,12 @@ static BOOL is_reserved_name(struct pvfs_mangle_context *ctx, const char *name)
int i;
for (i=0; reserved_names[i]; i++) {
if (strcasecmp(name, reserved_names[i]) == 0) {
- return True;
+ return true;
}
}
}
- return False;
+ return false;
}
@@ -383,13 +384,13 @@ static BOOL is_reserved_name(struct pvfs_mangle_context *ctx, const char *name)
See if a filename is a legal long filename.
A filename ending in a '.' is not legal unless it's "." or "..". JRA.
*/
-static BOOL is_legal_name(struct pvfs_mangle_context *ctx, const char *name)
+static bool is_legal_name(struct pvfs_mangle_context *ctx, const char *name)
{
while (*name) {
size_t c_size;
codepoint_t c = next_codepoint(name, &c_size);
if (c == INVALID_CODEPOINT) {
- return False;
+ return false;
}
/* all high chars are OK */
if (c >= 128) {
@@ -397,12 +398,12 @@ static BOOL is_legal_name(struct pvfs_mangle_context *ctx, const char *name)
continue;
}
if (FLAG_CHECK(c, FLAG_ILLEGAL)) {
- return False;
+ return false;
}
name += c_size;
}
- return True;
+ return true;
}
/*
@@ -417,7 +418,7 @@ static BOOL is_legal_name(struct pvfs_mangle_context *ctx, const char *name)
return NULL if we don't need to do any conversion
*/
static char *name_map(struct pvfs_mangle_context *ctx,
- const char *name, BOOL need83, BOOL cache83)
+ const char *name, bool need83, bool cache83)
{
char *dot_p;
char lead_chars[7];
@@ -432,7 +433,7 @@ static char *name_map(struct pvfs_mangle_context *ctx,
if (!is_reserved_name(ctx, name)) {
/* if the name is already a valid 8.3 name then we don't need to
do anything */
- if (is_8_3(ctx, name, False, False)) {
+ if (is_8_3(ctx, name, false, false)) {
return NULL;
}
@@ -613,7 +614,7 @@ NTSTATUS pvfs_mangle_init(struct pvfs_state *pvfs)
}
/* by default have a max of 512 entries in the cache. */
- ctx->cache_size = lp_parm_int(-1, "mangle", "cachesize", 512);
+ ctx->cache_size = lp_parm_int(global_loadparm, NULL, "mangle", "cachesize", 512);
ctx->prefix_cache = talloc_array(ctx, char *, ctx->cache_size);
if (ctx->prefix_cache == NULL) {
@@ -627,7 +628,7 @@ NTSTATUS pvfs_mangle_init(struct pvfs_state *pvfs)
memset(ctx->prefix_cache, 0, sizeof(char *) * ctx->cache_size);
memset(ctx->prefix_cache_hashes, 0, sizeof(uint32_t) * ctx->cache_size);
- ctx->mangle_prefix = lp_parm_int(-1, "mangle", "prefix", -1);
+ ctx->mangle_prefix = lp_parm_int(global_loadparm, NULL, "mangle", "prefix", -1);
if (ctx->mangle_prefix < 0 || ctx->mangle_prefix > 6) {
ctx->mangle_prefix = DEFAULT_MANGLE_PREFIX;
}
@@ -645,7 +646,7 @@ NTSTATUS pvfs_mangle_init(struct pvfs_state *pvfs)
*/
char *pvfs_short_name_component(struct pvfs_state *pvfs, const char *name)
{
- return name_map(pvfs->mangle_ctx, name, True, True);
+ return name_map(pvfs->mangle_ctx, name, true, true);
}
@@ -678,7 +679,7 @@ char *pvfs_mangled_lookup(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
/*
look for a DOS reserved name
*/
-BOOL pvfs_is_reserved_name(struct pvfs_state *pvfs, const char *name)
+bool pvfs_is_reserved_name(struct pvfs_state *pvfs, const char *name)
{
return is_reserved_name(pvfs->mangle_ctx, name);
}
@@ -688,7 +689,7 @@ BOOL pvfs_is_reserved_name(struct pvfs_state *pvfs, const char *name)
see if a component of a filename could be a mangled name from our
mangling code
*/
-BOOL pvfs_is_mangled_component(struct pvfs_state *pvfs, const char *name)
+bool pvfs_is_mangled_component(struct pvfs_state *pvfs, const char *name)
{
return is_mangled_component(pvfs->mangle_ctx, name, strlen(name));
}
diff --git a/source4/ntvfs/posix/pvfs_streams.c b/source4/ntvfs/posix/pvfs_streams.c
index a3b98feead..7e6173ef2f 100644
--- a/source4/ntvfs/posix/pvfs_streams.c
+++ b/source4/ntvfs/posix/pvfs_streams.c
@@ -79,7 +79,7 @@ NTSTATUS pvfs_stream_info(struct pvfs_state *pvfs, struct pvfs_filename *name, i
/* the NULL stream always exists */
if (name->stream_name == NULL) {
- name->stream_exists = True;
+ name->stream_exists = true;
return NT_STATUS_OK;
}
@@ -99,7 +99,7 @@ NTSTATUS pvfs_stream_info(struct pvfs_state *pvfs, struct pvfs_filename *name, i
if (strcasecmp_m(s->name, name->stream_name) == 0) {
name->dos.alloc_size = pvfs_round_alloc_size(pvfs, s->alloc_size);
name->st.st_size = s->size;
- name->stream_exists = True;
+ name->stream_exists = true;
talloc_free(streams);
return NT_STATUS_OK;
}
@@ -109,7 +109,7 @@ NTSTATUS pvfs_stream_info(struct pvfs_state *pvfs, struct pvfs_filename *name, i
name->dos.alloc_size = 0;
name->st.st_size = 0;
- name->stream_exists = False;
+ name->stream_exists = false;
return NT_STATUS_OK;
}
diff --git a/source4/ntvfs/posix/pvfs_util.c b/source4/ntvfs/posix/pvfs_util.c
index 895fcd9685..fd9724f7e2 100644
--- a/source4/ntvfs/posix/pvfs_util.c
+++ b/source4/ntvfs/posix/pvfs_util.c
@@ -24,14 +24,14 @@
#include "vfs_posix.h"
/*
- return True if a string contains one of the CIFS wildcard characters
+ return true if a string contains one of the CIFS wildcard characters
*/
-BOOL pvfs_has_wildcard(const char *str)
+bool pvfs_has_wildcard(const char *str)
{
if (strpbrk(str, "*?<>\"")) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
diff --git a/source4/ntvfs/posix/pvfs_xattr.c b/source4/ntvfs/posix/pvfs_xattr.c
index 61a95ec824..ead3585e0d 100644
--- a/source4/ntvfs/posix/pvfs_xattr.c
+++ b/source4/ntvfs/posix/pvfs_xattr.c
@@ -158,9 +158,9 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
struct xattr_DosInfo2 *info2;
if (name->stream_name != NULL) {
- name->stream_exists = False;
+ name->stream_exists = false;
} else {
- name->stream_exists = True;
+ name->stream_exists = true;
}
if (!(pvfs->flags & PVFS_FLAG_XATTR_ENABLE)) {
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index 2c414065cb..208c9e62b7 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -56,7 +56,7 @@ static void pvfs_setup_options(struct pvfs_state *pvfs)
pvfs->flags |= PVFS_FLAG_CI_FILESYSTEM;
if (share_bool_option(scfg, PVFS_FAKE_OPLOCKS, PVFS_FAKE_OPLOCKS_DEFAULT))
pvfs->flags |= PVFS_FLAG_FAKE_OPLOCKS;
- if (share_bool_option(scfg, PVFS_AIO, False))
+ if (share_bool_option(scfg, PVFS_AIO, false))
pvfs->flags |= PVFS_FLAG_LINUX_AIO;
/* file perm options */
@@ -234,7 +234,7 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs,
#ifdef SIGXFSZ
/* who had the stupid idea to generate a signal on a large
file write instead of just failing it!? */
- BlockSignals(True, SIGXFSZ);
+ BlockSignals(true, SIGXFSZ);
#endif
return NT_STATUS_OK;
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index dcf082fd88..a660da329a 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -237,8 +237,8 @@ enum pvfs_wait_notice {PVFS_WAIT_EVENT, PVFS_WAIT_TIMEOUT, PVFS_WAIT_CANCEL};
#define PVFS_ACL "posix:acl"
#define PVFS_AIO "posix:aio"
-#define PVFS_XATTR_DEFAULT True
-#define PVFS_FAKE_OPLOCKS_DEFAULT False
+#define PVFS_XATTR_DEFAULT true
+#define PVFS_FAKE_OPLOCKS_DEFAULT false
#define PVFS_SHARE_DELAY_DEFAULT 1000000
#define PVFS_ALLOCATION_ROUNDING_DEFAULT 512
#define PVFS_SEARCH_INACTIVITY_DEFAULT 300
diff --git a/source4/ntvfs/print/vfs_print.c b/source4/ntvfs/print/vfs_print.c
index 30bb530ee9..f9d3235116 100644
--- a/source4/ntvfs/print/vfs_print.c
+++ b/source4/ntvfs/print/vfs_print.c
@@ -24,6 +24,7 @@
#include "includes.h"
#include "libcli/raw/ioctl.h"
#include "ntvfs/ntvfs.h"
+#include "param/param.h"
/*
connect to a share - used when a tree_connect operation comes
@@ -82,7 +83,7 @@ static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs,
p = (char *)io->ioctl.out.blob.data;
SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */);
- push_string(p+2, lp_netbios_name(), 15, STR_TERMINATE|STR_ASCII);
+ push_string(p+2, lp_netbios_name(global_loadparm), 15, STR_TERMINATE|STR_ASCII);
push_string(p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
return NT_STATUS_OK;
}
diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c
index 95ea6d8647..dfc07f3483 100644
--- a/source4/ntvfs/simple/vfs_simple.c
+++ b/source4/ntvfs/simple/vfs_simple.c
@@ -38,7 +38,7 @@
#define O_DIRECTORY 0
#endif
-#define CHECK_READ_ONLY(req) do { if (share_bool_option(ntvfs->ctx->config, SHARE_READONLY, True)) return NT_STATUS_ACCESS_DENIED; } while (0)
+#define CHECK_READ_ONLY(req) do { if (share_bool_option(ntvfs->ctx->config, SHARE_READONLY, true)) return NT_STATUS_ACCESS_DENIED; } while (0)
/*
connect to a share - used when a tree_connect operation comes
@@ -308,7 +308,7 @@ static NTSTATUS svfs_open(struct ntvfs_module_context *ntvfs,
int fd, flags;
struct svfs_file *f;
int create_flags, rdwr_flags;
- BOOL readonly;
+ bool readonly;
NTSTATUS status;
struct ntvfs_handle *handle;
@@ -826,7 +826,7 @@ static NTSTATUS svfs_lpq(struct ntvfs_module_context *ntvfs,
static NTSTATUS svfs_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct svfs_dir *dir;
int i;
@@ -900,7 +900,7 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs,
static NTSTATUS svfs_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
struct svfs_dir *dir;
int i;
diff --git a/source4/ntvfs/sysdep/inotify.c b/source4/ntvfs/sysdep/inotify.c
index afeb319b35..3fa710415b 100644
--- a/source4/ntvfs/sysdep/inotify.c
+++ b/source4/ntvfs/sysdep/inotify.c
@@ -27,6 +27,7 @@
#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
#include "libcli/raw/smb.h"
+#include "param/param.h"
#include <linux/inotify.h>
#include <asm/unistd.h>
@@ -82,19 +83,19 @@ struct inotify_watch_context {
see if a particular event from inotify really does match a requested
notify event in SMB
*/
-static BOOL filter_match(struct inotify_watch_context *w,
+static bool filter_match(struct inotify_watch_context *w,
struct inotify_event *e)
{
if ((e->mask & w->mask) == 0) {
/* this happens because inotify_add_watch() coalesces watches on the same
path, oring their masks together */
- return False;
+ return false;
}
/* SMB separates the filters for files and directories */
if (e->mask & IN_ISDIR) {
if ((w->filter & FILE_NOTIFY_CHANGE_DIR_NAME) == 0) {
- return False;
+ return false;
}
} else {
if ((e->mask & IN_ATTRIB) &&
@@ -103,18 +104,18 @@ static BOOL filter_match(struct inotify_watch_context *w,
FILE_NOTIFY_CHANGE_LAST_ACCESS|
FILE_NOTIFY_CHANGE_EA|
FILE_NOTIFY_CHANGE_SECURITY))) {
- return True;
+ return true;
}
if ((e->mask & IN_MODIFY) &&
(w->filter & FILE_NOTIFY_CHANGE_ATTRIBUTES)) {
- return True;
+ return true;
}
if ((w->filter & FILE_NOTIFY_CHANGE_FILE_NAME) == 0) {
- return False;
+ return false;
}
}
- return True;
+ return true;
}
@@ -244,7 +245,7 @@ static NTSTATUS inotify_setup(struct sys_notify_context *ctx)
{
struct inotify_private *in;
- if (!lp_parm_bool(-1, "notify", "inotify", True)) {
+ if (!lp_parm_bool(global_loadparm, NULL, "notify", "inotify", true)) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
diff --git a/source4/ntvfs/sysdep/sys_notify.c b/source4/ntvfs/sysdep/sys_notify.c
index 8d2aed7fa0..1664461d33 100644
--- a/source4/ntvfs/sysdep/sys_notify.c
+++ b/source4/ntvfs/sysdep/sys_notify.c
@@ -27,6 +27,7 @@
#include "ntvfs/sysdep/sys_notify.h"
#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
+#include "param/param.h"
#include "build.h"
/* list of registered backends */
@@ -122,15 +123,15 @@ _PUBLIC_ NTSTATUS sys_notify_register(struct sys_notify_backend *backend)
_PUBLIC_ NTSTATUS sys_notify_init(void)
{
- static BOOL initialized = False;
+ static bool initialized = false;
init_module_fn static_init[] = STATIC_sys_notify_MODULES;
init_module_fn *shared_init;
if (initialized) return NT_STATUS_OK;
- initialized = True;
+ initialized = true;
- shared_init = load_samba_modules(NULL, "sys_notify");
+ shared_init = load_samba_modules(NULL, global_loadparm, "sys_notify");
run_init_functions(static_init);
run_init_functions(shared_init);
diff --git a/source4/ntvfs/unixuid/vfs_unixuid.c b/source4/ntvfs/unixuid/vfs_unixuid.c
index 74bc6309c1..0ad8a8501b 100644
--- a/source4/ntvfs/unixuid/vfs_unixuid.c
+++ b/source4/ntvfs/unixuid/vfs_unixuid.c
@@ -591,7 +591,7 @@ static NTSTATUS unixuid_lpq(struct ntvfs_module_context *ntvfs,
static NTSTATUS unixuid_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
NTSTATUS status;
@@ -604,7 +604,7 @@ static NTSTATUS unixuid_search_first(struct ntvfs_module_context *ntvfs,
static NTSTATUS unixuid_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 *))
+ bool (*callback)(void *, const union smb_search_data *))
{
NTSTATUS status;
diff --git a/source4/param/config.mk b/source4/param/config.mk
index cac95a63dd..5ed1097296 100644
--- a/source4/param/config.mk
+++ b/source4/param/config.mk
@@ -46,6 +46,5 @@ PRIVATE_DEPENDENCIES = LIBLDB
################################################
[SUBSYSTEM::SECRETS]
-PRIVATE_PROTO_HEADER = secrets_proto.h
OBJ_FILES = secrets.o
PRIVATE_DEPENDENCIES = DB_WRAP UTIL_TDB
diff --git a/source4/param/generic.c b/source4/param/generic.c
index ca52934950..d65502c02d 100644
--- a/source4/param/generic.c
+++ b/source4/param/generic.c
@@ -36,19 +36,20 @@ struct param_section *param_get_section(struct param_context *ctx, const char *n
return NULL;
}
-struct param *param_section_get (struct param_section *section, const char *name)
+struct param_opt *param_section_get(struct param_section *section,
+ const char *name)
{
- struct param *p;
+ struct param_opt *p;
for (p = section->parameters; p; p = p->next) {
- if (strcasecmp_m(p->name, name) == 0)
+ if (strcasecmp_m(p->key, name) == 0)
return p;
}
return NULL;
}
-struct param *param_get (struct param_context *ctx, const char *section_name, const char *name)
+struct param_opt *param_get (struct param_context *ctx, const char *section_name, const char *name)
{
struct param_section *section = param_get_section(ctx, section_name);
if (section == NULL)
@@ -58,10 +59,10 @@ struct param *param_get (struct param_context *ctx, const char *section_name, co
}
/* Look up parameter. If it is not found, add it */
-static struct param *param_get_add(struct param_context *ctx, const char *section_name, const char *name)
+static struct param_opt *param_get_add(struct param_context *ctx, const char *section_name, const char *name)
{
struct param_section *section;
- struct param *p;
+ struct param_opt *p;
section = param_get_section(ctx, section_name);
@@ -76,11 +77,11 @@ static struct param *param_get_add(struct param_context *ctx, const char *sectio
p = param_section_get(section, name);
if (p == NULL) {
- p = talloc_zero(section, struct param);
+ p = talloc_zero(section, struct param_opt);
if (p == NULL)
return NULL;
- p->name = talloc_strdup(p, name);
+ p->key = talloc_strdup(p, name);
DLIST_ADD(section->parameters, p);
}
@@ -89,7 +90,7 @@ static struct param *param_get_add(struct param_context *ctx, const char *sectio
const char *param_get_string(struct param_context *ctx, const char *section, const char *param)
{
- struct param *p = param_get(ctx, section, param);
+ struct param_opt *p = param_get(ctx, section, param);
if (p == NULL)
return NULL;
@@ -99,7 +100,7 @@ const char *param_get_string(struct param_context *ctx, const char *section, con
int param_set_string(struct param_context *ctx, const char *section, const char *param, const char *value)
{
- struct param *p = param_get_add(ctx, section, param);
+ struct param_opt *p = param_get_add(ctx, section, param);
if (p == NULL)
return -1;
@@ -112,7 +113,7 @@ int param_set_string(struct param_context *ctx, const char *section, const char
const char **param_get_string_list(struct param_context *ctx, const char *section, const char *param,
const char *separator)
{
- struct param *p = param_get(ctx, section, param);
+ struct param_opt *p = param_get(ctx, section, param);
if (p == NULL)
return NULL;
@@ -120,19 +121,14 @@ const char **param_get_string_list(struct param_context *ctx, const char *sectio
if (separator == NULL)
separator = LIST_SEP;
- if (p->list_value == NULL) {
- p->list_value = str_list_make(ctx, p->value, separator);
- }
-
- return p->list_value;
+ return str_list_make(ctx, p->value, separator);
}
int param_set_string_list(struct param_context *ctx, const char *section, const char *param, const char **list)
{
- struct param *p = param_get_add(ctx, section, param);
+ struct param_opt *p = param_get_add(ctx, section, param);
p->value = str_list_join(p, list, ' ');
- p->list_value = str_list_copy(p, list);
return 0;
}
@@ -149,7 +145,7 @@ int param_get_int(struct param_context *ctx, const char *section, const char *pa
void param_set_int(struct param_context *ctx, const char *section, const char *param, int value)
{
- struct param *p = param_get_add(ctx, section, param);
+ struct param_opt *p = param_get_add(ctx, section, param);
if (!p)
return;
@@ -169,7 +165,7 @@ unsigned long param_get_ulong(struct param_context *ctx, const char *section, co
void param_set_ulong(struct param_context *ctx, const char *section, const char *name, unsigned long value)
{
- struct param *p = param_get_add(ctx, section, name);
+ struct param_opt *p = param_get_add(ctx, section, name);
if (!p)
return;
@@ -177,15 +173,15 @@ void param_set_ulong(struct param_context *ctx, const char *section, const char
p->value = talloc_asprintf(p, "%lu", value);
}
-static BOOL param_sfunc (const char *name, void *_ctx)
+static bool param_sfunc (const char *name, void *_ctx)
{
- struct param_context *ctx = _ctx;
+ struct param_context *ctx = (struct param_context *)_ctx;
struct param_section *section = param_get_section(ctx, name);
if (section == NULL) {
section = talloc_zero(ctx, struct param_section);
if (section == NULL)
- return False;
+ return false;
section->name = talloc_strdup(section, name);
@@ -195,20 +191,20 @@ static BOOL param_sfunc (const char *name, void *_ctx)
/* Make sure this section is on top of the list for param_pfunc */
DLIST_PROMOTE(ctx->sections, section);
- return True;
+ return true;
}
-static BOOL param_pfunc (const char *name, const char *value, void *_ctx)
+static bool param_pfunc (const char *name, const char *value, void *_ctx)
{
- struct param_context *ctx = _ctx;
- struct param *p = param_section_get(ctx->sections, name);
+ struct param_context *ctx = (struct param_context *)_ctx;
+ struct param_opt *p = param_section_get(ctx->sections, name);
if (!p) {
- p = talloc_zero(ctx->sections, struct param);
+ p = talloc_zero(ctx->sections, struct param_opt);
if (p == NULL)
- return False;
+ return false;
- p->name = talloc_strdup(p, name);
+ p->key = talloc_strdup(p, name);
p->value = talloc_strdup(p, value);
DLIST_ADD(ctx->sections->parameters, p);
} else { /* Replace current value */
@@ -216,7 +212,7 @@ static BOOL param_pfunc (const char *name, const char *value, void *_ctx)
p->value = talloc_strdup(p, value);
}
- return True;
+ return true;
}
struct param_context *param_init(TALLOC_CTX *mem_ctx)
@@ -253,11 +249,11 @@ int param_write(struct param_context *ctx, const char *fn)
return -1;
for (section = ctx->sections; section; section = section->next) {
- struct param *param;
+ struct param_opt *param;
fdprintf(file, "[%s]\n", section->name);
for (param = section->parameters; param; param = param->next) {
- fdprintf(file, "\t%s = %s\n", param->name, param->value);
+ fdprintf(file, "\t%s = %s\n", param->key, param->value);
}
fdprintf(file, "\n");
}
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 483aa1f10b..c54932aa47 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -10,6 +10,7 @@
Copyright (C) Stefan (metze) Metzmacher 2002
Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
Copyright (C) James Myers 2003 <myersjj@samba.org>
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -54,44 +55,34 @@
#include "includes.h"
#include "version.h"
#include "dynconfig.h"
-#include "pstring.h"
#include "system/time.h"
#include "system/locale.h"
#include "system/network.h" /* needed for TCP_NODELAY */
#include "smb_server/smb_server.h"
#include "libcli/raw/signing.h"
#include "lib/util/dlinklist.h"
+#include "param/param.h"
#include "param/loadparm.h"
-static BOOL bLoaded = False;
+static bool bLoaded = false;
-#define standard_sub_basic(str,len)
+#define standard_sub_basic talloc_strdup
-/* some helpful bits */
-#define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && ServicePtrs[(i)]->valid)
-#define VALID(i) ServicePtrs[i]->valid
-
-static BOOL do_parameter(const char *, const char *, void *);
-static BOOL do_parameter_var(const char *pszParmName, const char *fmt, ...);
-
-static BOOL defaults_saved = False;
-
-struct param_opt {
- struct param_opt *prev, *next;
- char *key;
- char *value;
- int flags;
-};
+static bool do_parameter(const char *, const char *, void *);
+static bool defaults_saved = false;
/*
* This structure describes global (ie., server-wide) parameters.
*/
-typedef struct
+struct loadparm_global
{
- int server_role;
+ enum server_role server_role;
- char **smb_ports;
+ const char **smb_ports;
char *ncalrpc_dir;
+ char *dos_charset;
+ char *unix_charset;
+ char *display_charset;
char *szLockDir;
char *szModulesDir;
char *szPidDir;
@@ -99,7 +90,7 @@ typedef struct
char *szServerString;
char *szAutoServices;
char *szPasswdChat;
- char *szConfigFile;
+ const char *szConfigFile;
char *szShareBackend;
char *szSAM_URL;
char *szSECRETS_URL;
@@ -107,30 +98,30 @@ typedef struct
char *szWINS_CONFIG_URL;
char *szWINS_URL;
char *szPrivateDir;
- char **jsInclude;
+ const char **jsInclude;
char *jsonrpcServicesDir;
- char **szPasswordServers;
+ const char **szPasswordServers;
char *szSocketOptions;
char *szRealm;
- char **szWINSservers;
- char **szInterfaces;
+ const char **szWINSservers;
+ const char **szInterfaces;
char *szSocketAddress;
char *szAnnounceVersion; /* This is initialised in init_globals */
char *szWorkgroup;
char *szNetbiosName;
- char **szNetbiosAliases;
+ const char **szNetbiosAliases;
char *szNetbiosScope;
char *szDomainOtherSIDs;
- char **szNameResolveOrder;
- char **dcerpc_ep_servers;
- char **server_services;
+ const char **szNameResolveOrder;
+ const char **dcerpc_ep_servers;
+ const char **server_services;
char *ntptr_providor;
char *szWinbindSeparator;
char *szWinbinddSocketDirectory;
char *szTemplateShell;
char *szTemplateHomedir;
int bWinbindSealedPipes;
- char *webapps_directory;
+ char *swat_directory;
int tls_enabled;
char *tls_keyfile;
char *tls_certfile;
@@ -186,17 +177,14 @@ typedef struct
int bDisableNetbios;
int bRpcBigEndian;
struct param_opt *param_opt;
-}
-global;
+};
-static global Globals;
/*
* This structure describes a single service.
*/
-typedef struct
+struct loadparm_service
{
- int valid;
char *szService;
char *szPath;
char *szCopy;
@@ -230,59 +218,67 @@ typedef struct
struct param_opt *param_opt;
char dummy[3]; /* for alignment */
-}
-service;
+};
/* This is a default service used to prime a services structure */
-static service sDefault = {
- True, /* valid */
- NULL, /* szService */
- NULL, /* szPath */
- NULL, /* szCopy */
- NULL, /* szInclude */
- NULL, /* szPrintername */
- NULL, /* szHostsallow */
- NULL, /* szHostsdeny */
- NULL, /* comment */
- NULL, /* volume */
- NULL, /* fstype */
- NULL, /* ntvfs_handler */
- 1000, /* iMaxPrintJobs */
- 0, /* iMaxConnections */
- 0, /* iCSCPolicy */
- True, /* bAvailable */
- True, /* bBrowseable */
- True, /* bRead_only */
- False, /* bPrint_ok */
- False, /* bMap_system */
- False, /* bMap_hidden */
- True, /* bMap_archive */
- True, /* bStrictLocking */
- 0744, /* iCreate_mask */
- 0000, /* iCreate_force_mode */
- 0755, /* iDir_mask */
- 0000, /* iDir_force_mode */
- NULL, /* copymap */
- False, /* bMSDfsRoot */
- False, /* bStrictSync */
- False, /* bCIFileSystem */
- NULL, /* Parametric options */
-
- "" /* dummy */
+static struct loadparm_service sDefault = {
+ .szService = NULL,
+ .szPath = NULL,
+ .szCopy = NULL,
+ .szInclude = NULL,
+ .szPrintername = NULL,
+ .szHostsallow = NULL,
+ .szHostsdeny = NULL,
+ .comment = NULL,
+ .volume = NULL,
+ .fstype = NULL,
+ .ntvfs_handler = NULL,
+ .iMaxPrintJobs = 1000,
+ .iMaxConnections = 0,
+ .iCSCPolicy = 0,
+ .bAvailable = true,
+ .bBrowseable = true,
+ .bRead_only = true,
+ .bPrint_ok = false,
+ .bMap_system = false,
+ .bMap_hidden = false,
+ .bMap_archive = true,
+ .bStrictLocking = true,
+ .iCreate_mask = 0744,
+ .iCreate_force_mode = 0000,
+ .iDir_mask = 0755,
+ .iDir_force_mode = 0000,
+ .copymap = NULL,
+ .bMSDfsRoot = false,
+ .bStrictSync = false,
+ .bCIFileSystem = false,
};
/* local variables */
-static service **ServicePtrs = NULL;
-static int iNumServices = 0;
-static int iServiceIndex = 0;
-static BOOL bInGlobalSection = True;
+static struct loadparm_context {
+ struct loadparm_global Globals;
+ struct loadparm_service **ServicePtrs;
+ int iNumServices;
+ struct loadparm_service *currentService;
+ bool bInGlobalSection;
+ struct file_lists {
+ struct file_lists *next;
+ char *name;
+ char *subfname;
+ time_t modtime;
+ } *file_lists;
+} loadparm;
+
+struct loadparm_context *global_loadparm = &loadparm;
#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
/* prototypes for the special type handlers */
-static BOOL handle_include(const char *pszParmValue, char **ptr);
-static BOOL handle_copy(const char *pszParmValue, char **ptr);
+static bool handle_include(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr);
+static bool handle_copy(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr);
static const struct enum_list enum_protocol[] = {
{PROTOCOL_SMB2, "SMB2"},
@@ -311,21 +307,23 @@ static const struct enum_list enum_announce_as[] = {
};
static const struct enum_list enum_bool_auto[] = {
- {False, "No"},
- {False, "False"},
- {False, "0"},
- {True, "Yes"},
- {True, "True"},
- {True, "1"},
+ {false, "No"},
+ {false, "False"},
+ {false, "0"},
+ {true, "Yes"},
+ {true, "True"},
+ {true, "1"},
{Auto, "Auto"},
{-1, NULL}
};
/* Client-side offline caching policy types */
-#define CSC_POLICY_MANUAL 0
-#define CSC_POLICY_DOCUMENTS 1
-#define CSC_POLICY_PROGRAMS 2
-#define CSC_POLICY_DISABLE 3
+enum csc_policy {
+ CSC_POLICY_MANUAL=0,
+ CSC_POLICY_DOCUMENTS=1,
+ CSC_POLICY_PROGRAMS=2,
+ CSC_POLICY_DISABLE=3
+};
static const struct enum_list enum_csc_policy[] = {
{CSC_POLICY_MANUAL, "manual"},
@@ -370,199 +368,174 @@ static const struct enum_list enum_server_role[] = {
* is implied in current control logic. This may change at some later time. A
* flag value of 0 means - show as development option only.
*
- * The FLAG_HIDE is explicit. Paramters set this way do NOT appear in any edit
+ * The FLAG_HIDE is explicit. Parameters set this way do NOT appear in any edit
* screen in SWAT. This is used to exclude parameters as well as to squash all
* parameters that have been duplicated by pseudonyms.
*/
+
+#define GLOBAL_VAR(name) &loadparm.Globals.name
+#define LOCAL_VAR(name) &sDefault.name
+
static struct parm_struct parm_table[] = {
- {"Base Options", P_SEP, P_SEPARATOR},
-
- {"server role", P_ENUM, P_GLOBAL, &Globals.server_role, NULL, enum_server_role, FLAG_BASIC},
-
- {"dos charset", P_STRING, P_GLOBAL, &dos_charset, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"unix charset", P_STRING, P_GLOBAL, &unix_charset, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"ncalrpc dir", P_STRING, P_GLOBAL, &Globals.ncalrpc_dir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"display charset", P_STRING, P_GLOBAL, &display_charset, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
- {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
- {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_HIDE},
- {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkgroup, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"realm", P_STRING, P_GLOBAL, &Globals.szRealm, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"netbios name", P_USTRING, P_GLOBAL, &Globals.szNetbiosName, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"netbios aliases", P_LIST, P_GLOBAL, &Globals.szNetbiosAliases, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"netbios scope", P_USTRING, P_GLOBAL, &Globals.szNetbiosScope, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
- {"interfaces", P_LIST, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"bind interfaces only", P_BOOL, P_GLOBAL, &Globals.bBindInterfacesOnly, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"ntvfs handler", P_LIST, P_LOCAL, &sDefault.ntvfs_handler, NULL, NULL, FLAG_ADVANCED},
- {"ntptr providor", P_STRING, P_GLOBAL, &Globals.ntptr_providor, NULL, NULL, FLAG_ADVANCED},
- {"dcerpc endpoint servers", P_LIST, P_GLOBAL, &Globals.dcerpc_ep_servers, NULL, NULL, FLAG_ADVANCED},
- {"server services", P_LIST, P_GLOBAL, &Globals.server_services, NULL, NULL, FLAG_ADVANCED},
-
- {"Security Options", P_SEP, P_SEPARATOR},
+ {"config file", P_STRING, P_GLOBAL, GLOBAL_VAR(szConfigFile), NULL, NULL, FLAG_HIDE},
+
+ {"server role", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_role), NULL, enum_server_role, FLAG_BASIC},
+
+ {"dos charset", P_STRING, P_GLOBAL, GLOBAL_VAR(dos_charset), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"unix charset", P_STRING, P_GLOBAL, GLOBAL_VAR(unix_charset), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"ncalrpc dir", P_STRING, P_GLOBAL, GLOBAL_VAR(ncalrpc_dir), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"display charset", P_STRING, P_GLOBAL, GLOBAL_VAR(display_charset), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"comment", P_STRING, P_LOCAL, LOCAL_VAR(comment), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
+ {"path", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
+ {"directory", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL, FLAG_HIDE},
+ {"workgroup", P_USTRING, P_GLOBAL, GLOBAL_VAR(szWorkgroup), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"realm", P_STRING, P_GLOBAL, GLOBAL_VAR(szRealm), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"netbios name", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosName), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"netbios aliases", P_LIST, P_GLOBAL, GLOBAL_VAR(szNetbiosAliases), NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"netbios scope", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosScope), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"server string", P_STRING, P_GLOBAL, GLOBAL_VAR(szServerString), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"interfaces", P_LIST, P_GLOBAL, GLOBAL_VAR(szInterfaces), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"bind interfaces only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bBindInterfacesOnly), NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"ntvfs handler", P_LIST, P_LOCAL, LOCAL_VAR(ntvfs_handler), NULL, NULL, FLAG_ADVANCED},
+ {"ntptr providor", P_STRING, P_GLOBAL, GLOBAL_VAR(ntptr_providor), NULL, NULL, FLAG_ADVANCED},
+ {"dcerpc endpoint servers", P_LIST, P_GLOBAL, GLOBAL_VAR()dcerpc_ep_servers, NULL, NULL, FLAG_ADVANCED},
+ {"server services", P_LIST, P_GLOBAL, GLOBAL_VAR(server_services), NULL, NULL, FLAG_ADVANCED},
+
+ {"security", P_ENUM, P_GLOBAL, GLOBAL_VAR(security), NULL, enum_security, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"encrypt passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bEncryptPasswords), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"null passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNullPasswords), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"obey pam restrictions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bObeyPamRestrictions), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"password server", P_LIST, P_GLOBAL, GLOBAL_VAR(szPasswordServers), NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"sam database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSAM_URL), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"secrets database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSECRETS_URL), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"spoolss database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSPOOLSS_URL), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"wins config database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_CONFIG_URL), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"wins database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_URL), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"private dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szPrivateDir), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"passwd chat", P_STRING, P_GLOBAL, GLOBAL_VAR(szPasswdChat), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"password level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(pwordlevel), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLanmanAuth), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"ntlm auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTLMAuth), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"client NTLMv2 auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientNTLMv2Auth), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"client lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientLanManAuth), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"client plaintext auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientPlaintextAuth), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"client use spnego principal", P_BOOL, P_GLOBAL, GLOBAL_VAR(client_use_spnego_principal), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"encrypt passwords", P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"obey pam restrictions", P_BOOL, P_GLOBAL, &Globals.bObeyPamRestrictions, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"password server", P_LIST, P_GLOBAL, &Globals.szPasswordServers, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"sam database", P_STRING, P_GLOBAL, &Globals.szSAM_URL, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"secrets database", P_STRING, P_GLOBAL, &Globals.szSECRETS_URL, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"spoolss database", P_STRING, P_GLOBAL, &Globals.szSPOOLSS_URL, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"wins config database", P_STRING, P_GLOBAL, &Globals.szWINS_CONFIG_URL, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"wins database", P_STRING, P_GLOBAL, &Globals.szWINS_URL, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"private dir", P_STRING, P_GLOBAL, &Globals.szPrivateDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"lanman auth", P_BOOL, P_GLOBAL, &Globals.bLanmanAuth, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"ntlm auth", P_BOOL, P_GLOBAL, &Globals.bNTLMAuth, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"client NTLMv2 auth", P_BOOL, P_GLOBAL, &Globals.bClientNTLMv2Auth, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"client lanman auth", P_BOOL, P_GLOBAL, &Globals.bClientLanManAuth, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"client plaintext auth", P_BOOL, P_GLOBAL, &Globals.bClientPlaintextAuth, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"client use spnego principal", P_BOOL, P_GLOBAL, &Globals.client_use_spnego_principal, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
-
- {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE},
-
- {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
- {"force create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
- {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
- {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
+ {"read only", P_BOOL, P_LOCAL, LOCAL_VAR(bRead_only), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE},
- {"hosts allow", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
- {"hosts deny", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
+ {"create mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_mask), NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
+ {"force create mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_force_mode), NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
+ {"directory mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_mask), NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
+ {"force directory mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_force_mode), NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE},
- {"Logging Options", P_SEP, P_SEPARATOR},
+ {"hosts allow", P_LIST, P_LOCAL, LOCAL_VAR(szHostsallow), NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
+ {"hosts deny", P_LIST, P_LOCAL, LOCAL_VAR(szHostsdeny), NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
{"log level", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"debuglevel", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL, NULL, FLAG_HIDE},
{"log file", P_STRING, P_GLOBAL, &logfile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"Protocol Options", P_SEP, P_SEPARATOR},
-
- {"smb ports", P_LIST, P_GLOBAL, &Globals.smb_ports, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"nbt port", P_INTEGER, P_GLOBAL, &Globals.nbt_port, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"dgram port", P_INTEGER, P_GLOBAL, &Globals.dgram_port, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"cldap port", P_INTEGER, P_GLOBAL, &Globals.cldap_port, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"krb5 port", P_INTEGER, P_GLOBAL, &Globals.krb5_port, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"kpasswd port", P_INTEGER, P_GLOBAL, &Globals.kpasswd_port, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"web port", P_INTEGER, P_GLOBAL, &Globals.web_port, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"tls enabled", P_BOOL, P_GLOBAL, &Globals.tls_enabled, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"tls keyfile", P_STRING, P_GLOBAL, &Globals.tls_keyfile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"tls certfile", P_STRING, P_GLOBAL, &Globals.tls_certfile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"tls cafile", P_STRING, P_GLOBAL, &Globals.tls_cafile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"tls crlfile", P_STRING, P_GLOBAL, &Globals.tls_crlfile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"tls dh params file", P_STRING, P_GLOBAL, &Globals.tls_dhpfile, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"web application directory", P_STRING, P_GLOBAL, &Globals.webapps_directory, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, FLAG_DEVELOPER},
- {"server max protocol", P_ENUM, P_GLOBAL, &Globals.srv_maxprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
- {"server min protocol", P_ENUM, P_GLOBAL, &Globals.srv_minprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
- {"client max protocol", P_ENUM, P_GLOBAL, &Globals.cli_maxprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
- {"client min protocol", P_ENUM, P_GLOBAL, &Globals.cli_minprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
- {"unicode", P_BOOL, P_GLOBAL, &Globals.bUnicode, NULL, NULL, FLAG_DEVELOPER},
- {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, FLAG_DEVELOPER},
- {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, FLAG_DEVELOPER},
- {"disable netbios", P_BOOL, P_GLOBAL, &Globals.bDisableNetbios, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
-
- {"nt status support", P_BOOL, P_GLOBAL, &Globals.bNTStatusSupport, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
-
- {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, FLAG_DEVELOPER},
- {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, FLAG_DEVELOPER},
- {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"max xmit", P_BYTES, P_GLOBAL, &Globals.max_xmit, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
-
- {"name resolve order", P_LIST, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"max wins ttl", P_INTEGER, P_GLOBAL, &Globals.max_wins_ttl, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"min wins ttl", P_INTEGER, P_GLOBAL, &Globals.min_wins_ttl, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"unix extensions", P_BOOL, P_GLOBAL, &Globals.bUnixExtensions, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"use spnego", P_BOOL, P_GLOBAL, &Globals.bUseSpnego, NULL, NULL, FLAG_DEVELOPER},
- {"server signing", P_ENUM, P_GLOBAL, &Globals.server_signing, NULL, enum_smb_signing_vals, FLAG_ADVANCED},
- {"client signing", P_ENUM, P_GLOBAL, &Globals.client_signing, NULL, enum_smb_signing_vals, FLAG_ADVANCED},
- {"rpc big endian", P_BOOL, P_GLOBAL, &Globals.bRpcBigEndian, NULL, NULL, FLAG_DEVELOPER},
-
- {"Tuning Options", P_SEP, P_SEPARATOR},
-
- {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL, NULL, FLAG_SHARE},
- {"paranoid server security", P_BOOL, P_GLOBAL, &Globals.paranoid_server_security, NULL, NULL, FLAG_DEVELOPER},
- {"socket options", P_STRING, P_GLOBAL, &Globals.socket_options, NULL, NULL, FLAG_DEVELOPER},
-
- {"strict sync", P_BOOL, P_LOCAL, &sDefault.bStrictSync, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
- {"case insensitive filesystem", P_BOOL, P_LOCAL, &sDefault.bCIFileSystem, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
-
- {"Printing Options", P_SEP, P_SEPARATOR},
-
- {"max print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxPrintJobs, NULL, NULL, FLAG_PRINT},
- {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_PRINT},
- {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_HIDE},
-
- {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_PRINT},
- {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_HIDE},
-
- {"Filename Handling", P_SEP, P_SEPARATOR},
+ {"smb ports", P_LIST, P_GLOBAL, GLOBAL_VAR(smb_ports), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"nbt port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(nbt_port), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"dgram port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(dgram_port), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"cldap port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(cldap_port), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"krb5 port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(krb5_port), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"kpasswd port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(kpasswd_port), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"web port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(web_port), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"tls enabled", P_BOOL, P_GLOBAL, GLOBAL_VAR(tls_enabled), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"tls keyfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_keyfile), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"tls certfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_certfile), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"tls cafile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_cafile), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"tls crlfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_crlfile), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"tls dh params file", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_dhpfile), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"swat directory", P_STRING, P_GLOBAL, GLOBAL_VAR(swat_directory), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"large readwrite", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLargeReadwrite), NULL, NULL, FLAG_DEVELOPER},
+ {"server max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_maxprotocol), NULL, enum_protocol, FLAG_DEVELOPER},
+ {"server min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_minprotocol), NULL, enum_protocol, FLAG_DEVELOPER},
+ {"client max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_maxprotocol), NULL, enum_protocol, FLAG_DEVELOPER},
+ {"client min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_minprotocol), NULL, enum_protocol, FLAG_DEVELOPER},
+ {"unicode", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnicode), NULL, NULL, FLAG_DEVELOPER},
+ {"read raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bReadRaw), NULL, NULL, FLAG_DEVELOPER},
+ {"write raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWriteRaw), NULL, NULL, FLAG_DEVELOPER},
+ {"disable netbios", P_BOOL, P_GLOBAL, GLOBAL_VAR(bDisableNetbios), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
- {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
- {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
-
- {"Domain Options", P_SEP, P_SEPARATOR},
+ {"nt status support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTStatusSupport), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+
+ {"announce version", P_STRING, P_GLOBAL, GLOBAL_VAR(szAnnounceVersion), NULL, NULL, FLAG_DEVELOPER},
+ {"announce as", P_ENUM, P_GLOBAL, GLOBAL_VAR(announce_as), NULL, enum_announce_as, FLAG_DEVELOPER},
+ {"max mux", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_mux), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"max xmit", P_BYTES, P_GLOBAL, GLOBAL_VAR(max_xmit), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+
+ {"name resolve order", P_LIST, P_GLOBAL, GLOBAL_VAR(szNameResolveOrder), NULL, NULL, FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"max wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_wins_ttl), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"min wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(min_wins_ttl), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"time server", P_BOOL, P_GLOBAL, GLOBAL_VAR(bTimeServer), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"unix extensions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnixExtensions), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"use spnego", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUseSpnego), NULL, NULL, FLAG_DEVELOPER},
+ {"server signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_signing), NULL, enum_smb_signing_vals, FLAG_ADVANCED},
+ {"client signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(client_signing), NULL, enum_smb_signing_vals, FLAG_ADVANCED},
+ {"rpc big endian", P_BOOL, P_GLOBAL, GLOBAL_VAR(bRpcBigEndian), NULL, NULL, FLAG_DEVELOPER},
+
+ {"max connections", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxConnections), NULL, NULL, FLAG_SHARE},
+ {"paranoid server security", P_BOOL, P_GLOBAL, GLOBAL_VAR(paranoid_server_security), NULL, NULL, FLAG_DEVELOPER},
+ {"socket options", P_STRING, P_GLOBAL, GLOBAL_VAR(socket_options), NULL, NULL, FLAG_DEVELOPER},
+
+ {"strict sync", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictSync), NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
+ {"case insensitive filesystem", P_BOOL, P_LOCAL, LOCAL_VAR(bCIFileSystem), NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
+
+ {"max print jobs", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxPrintJobs), NULL, NULL, FLAG_PRINT},
+ {"printable", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL, FLAG_PRINT},
+ {"print ok", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL, FLAG_HIDE},
- {"Logon Options", P_SEP, P_SEPARATOR},
-
+ {"printer name", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL, FLAG_PRINT},
+ {"printer", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL, FLAG_HIDE},
- {"Browse Options", P_SEP, P_SEPARATOR},
-
- {"preferred master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
- {"prefered master", P_ENUM, P_GLOBAL, &Globals.bPreferredMaster, NULL, enum_bool_auto, FLAG_HIDE},
- {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
- {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
- {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_HIDE},
+ {"map system", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_system), NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
+ {"map hidden", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_hidden), NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
+ {"map archive", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_archive), NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
- {"WINS Options", P_SEP, P_SEPARATOR},
-
- {"wins server", P_LIST, P_GLOBAL, &Globals.szWINSservers, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bWINSdnsProxy, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
- {"wins hook", P_STRING, P_GLOBAL, &Globals.szWINSHook, NULL, NULL, FLAG_ADVANCED},
+ {"preferred master", P_ENUM, P_GLOBAL, GLOBAL_VAR(bPreferredMaster), NULL, enum_bool_auto, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"prefered master", P_ENUM, P_GLOBAL, GLOBAL_VAR(bPreferredMaster), NULL, enum_bool_auto, FLAG_HIDE},
+ {"local master", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLocalMaster), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"browseable", P_BOOL, P_LOCAL, LOCAL_VAR(bBrowseable), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
+ {"browsable", P_BOOL, P_LOCAL, LOCAL_VAR(bBrowseable), NULL, NULL, FLAG_HIDE},
- {"Locking Options", P_SEP, P_SEPARATOR},
-
- {"csc policy", P_ENUM, P_LOCAL, &sDefault.iCSCPolicy, NULL, enum_csc_policy, FLAG_SHARE | FLAG_GLOBAL},
-
- {"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
+ {"wins server", P_LIST, P_GLOBAL, GLOBAL_VAR(szWINSservers), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"wins support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWINSsupport), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"dns proxy", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWINSdnsProxy), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD | FLAG_DEVELOPER},
+ {"wins hook", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINSHook), NULL, NULL, FLAG_ADVANCED},
- {"Miscellaneous Options", P_SEP, P_SEPARATOR},
+ {"csc policy", P_ENUM, P_LOCAL, LOCAL_VAR(iCSCPolicy), NULL, enum_csc_policy, FLAG_SHARE | FLAG_GLOBAL},
- {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE},
- {"share backend", P_STRING, P_GLOBAL, &Globals.szShareBackend, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_HIDE},
- {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"modules dir", P_STRING, P_GLOBAL, &Globals.szModulesDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"js include", P_LIST, P_GLOBAL, &Globals.jsInclude, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"jsonrpc services directory", P_STRING, P_GLOBAL, &Globals.jsonrpcServicesDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"setup directory", P_STRING, P_GLOBAL, &Globals.szSetupDir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"strict locking", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictLocking), NULL, NULL, FLAG_SHARE | FLAG_GLOBAL},
+
+ {"share backend", P_STRING, P_GLOBAL, GLOBAL_VAR(szShareBackend), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"preload", P_STRING, P_GLOBAL, GLOBAL_VAR(szAutoServices), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"auto services", P_STRING, P_GLOBAL, GLOBAL_VAR(szAutoServices), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"lock dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szLockDir), NULL, NULL, FLAG_HIDE},
+ {"lock directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szLockDir), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"modules dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szModulesDir), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"pid directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szPidDir), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"js include", P_LIST, P_GLOBAL, GLOBAL_VAR(jsInclude), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"setup directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szSetupDir), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL, FLAG_DEVELOPER},
- {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL, FLAG_HIDE},
+ {"socket address", P_STRING, P_GLOBAL, GLOBAL_VAR(szSocketAddress), NULL, NULL, FLAG_DEVELOPER},
+ {"copy", P_STRING, P_LOCAL, LOCAL_VAR(szCopy), handle_copy, NULL, FLAG_HIDE},
+ {"include", P_STRING, P_LOCAL, LOCAL_VAR(szInclude), handle_include, NULL, FLAG_HIDE},
- {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy, NULL, FLAG_HIDE},
- {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include, NULL, FLAG_HIDE},
-
- {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
- {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL, FLAG_SHARE },
- {"fstype", P_STRING, P_LOCAL, &sDefault.fstype, NULL, NULL, FLAG_SHARE},
+ {"available", P_BOOL, P_LOCAL, LOCAL_VAR(bAvailable), NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
+ {"volume", P_STRING, P_LOCAL, LOCAL_VAR(volume), NULL, NULL, FLAG_SHARE },
+ {"fstype", P_STRING, P_LOCAL, LOCAL_VAR(fstype), NULL, NULL, FLAG_SHARE},
{"panic action", P_STRING, P_GLOBAL, &panic_action, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"msdfs root", P_BOOL, P_LOCAL, &sDefault.bMSDfsRoot, NULL, NULL, FLAG_SHARE},
- {"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
- {"winbind separator", P_STRING, P_GLOBAL, &Globals.szWinbindSeparator, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
- {"winbindd socket directory", P_STRING, P_GLOBAL, &Globals.szWinbinddSocketDirectory, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
- {"winbind sealed pipes", P_BOOL, P_GLOBAL, &Globals.bWinbindSealedPipes, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
- {"template shell", P_STRING, P_GLOBAL, &Globals.szTemplateShell, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
- {"template homedir", P_STRING, P_GLOBAL, &Globals.szTemplateHomedir, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
+ {"msdfs root", P_BOOL, P_LOCAL, LOCAL_VAR(bMSDfsRoot), NULL, NULL, FLAG_SHARE},
+ {"host msdfs", P_BOOL, P_GLOBAL, GLOBAL_VAR(bHostMSDfs), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"winbind separator", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbindSeparator), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
+ {"winbindd socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbinddSocketDirectory), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
+ {"winbind sealed pipes", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWinbindSealedPipes), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
+ {"template shell", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateShell), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
+ {"template homedir", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateHomedir), NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER },
{NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
};
@@ -576,163 +549,6 @@ struct parm_struct *lp_parm_table(void)
return parm_table;
}
-/***************************************************************************
- Initialise the global parameter structure.
-***************************************************************************/
-static void init_globals(void)
-{
- int i;
- char *myname;
-
- DEBUG(3, ("Initialising global parameters\n"));
-
- for (i = 0; parm_table[i].label; i++) {
- if ((parm_table[i].type == P_STRING ||
- parm_table[i].type == P_USTRING) &&
- parm_table[i].ptr &&
- !(parm_table[i].flags & FLAG_CMDLINE)) {
- string_set(parm_table[i].ptr, "");
- }
- }
-
- do_parameter("config file", dyn_CONFIGFILE, NULL);
-
- do_parameter("share backend", "classic", NULL);
-
- do_parameter("server role", "standalone", NULL);
-
- /* options that can be set on the command line must be initialised via
- the slower do_parameter() to ensure that FLAG_CMDLINE is obeyed */
-#ifdef TCP_NODELAY
- do_parameter("socket options", "TCP_NODELAY", NULL);
-#endif
- do_parameter("workgroup", DEFAULT_WORKGROUP, NULL);
- myname = get_myname();
- do_parameter("netbios name", myname, NULL);
- SAFE_FREE(myname);
- do_parameter("name resolve order", "lmhosts wins host bcast", NULL);
-
- do_parameter("fstype", FSTYPE_STRING, NULL);
- do_parameter("ntvfs handler", "unixuid default", NULL);
- do_parameter("max connections", "-1", NULL);
-
- do_parameter("dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo", NULL);
- do_parameter("server services", "smb rpc nbt wrepl ldap cldap web kdc drepl winbind", NULL);
- do_parameter("ntptr providor", "simple_ldb", NULL);
- do_parameter("auth methods:domain controller", "anonymous sam_ignoredomain", NULL);
- do_parameter("auth methods:member server", "anonymous sam winbind", NULL);
- do_parameter("auth methods:standalone", "anonymous sam_ignoredomain", NULL);
- do_parameter("private dir", dyn_PRIVATE_DIR, NULL);
- do_parameter("sam database", "sam.ldb", NULL);
- do_parameter("secrets database", "secrets.ldb", NULL);
- do_parameter("spoolss database", "spoolss.ldb", NULL);
- do_parameter("wins config database", "wins_config.ldb", NULL);
- do_parameter("wins database", "wins.ldb", NULL);
- do_parameter("registry:HKEY_LOCAL_MACHINE", "hklm.ldb", NULL);
-
- /* This hive should be dynamically generated by Samba using
- data from the sam, but for the moment leave it in a tdb to
- keep regedt32 from popping up an annoying dialog. */
- do_parameter("registry:HKEY_USERS", "hku.ldb", NULL);
-
- /* using UTF8 by default allows us to support all chars */
- do_parameter("unix charset", "UTF8", NULL);
-
- /* Use codepage 850 as a default for the dos character set */
- do_parameter("dos charset", "CP850", NULL);
-
- /*
- * Allow the default PASSWD_CHAT to be overridden in local.h.
- */
- do_parameter("passwd chat", DEFAULT_PASSWD_CHAT, NULL);
-
- do_parameter("pid directory", dyn_PIDDIR, NULL);
- do_parameter("lock dir", dyn_LOCKDIR, NULL);
- do_parameter("modules dir", dyn_MODULESDIR, NULL);
- do_parameter("ncalrpc dir", dyn_NCALRPCDIR, NULL);
-
- do_parameter("socket address", "0.0.0.0", NULL);
- do_parameter_var("server string", "Samba %s", SAMBA_VERSION_STRING);
-
- do_parameter_var("announce version", "%d.%d",
- DEFAULT_MAJOR_VERSION,
- DEFAULT_MINOR_VERSION);
-
- do_parameter("password server", "*", NULL);
-
- do_parameter("max mux", "50", NULL);
- do_parameter("max xmit", "12288", NULL);
- do_parameter("password level", "0", NULL);
- do_parameter("LargeReadwrite", "True", NULL);
- do_parameter("server min protocol", "CORE", NULL);
- do_parameter("server max protocol", "NT1", NULL);
- do_parameter("client min protocol", "CORE", NULL);
- do_parameter("client max protocol", "NT1", NULL);
- do_parameter("security", "USER", NULL);
- do_parameter("paranoid server security", "True", NULL);
- do_parameter("EncryptPasswords", "True", NULL);
- do_parameter("ReadRaw", "True", NULL);
- do_parameter("WriteRaw", "True", NULL);
- do_parameter("NullPasswords", "False", NULL);
- do_parameter("ObeyPamRestrictions", "False", NULL);
- do_parameter("announce as", "NT SERVER", NULL);
-
- do_parameter("TimeServer", "False", NULL);
- do_parameter("BindInterfacesOnly", "False", NULL);
- do_parameter("Unicode", "True", NULL);
- do_parameter("ClientLanManAuth", "True", NULL);
- do_parameter("LanmanAuth", "True", NULL);
- do_parameter("NTLMAuth", "True", NULL);
- do_parameter("client use spnego principal", "False", NULL);
-
- do_parameter("UnixExtensions", "False", NULL);
-
- do_parameter("PreferredMaster", "Auto", NULL);
- do_parameter("LocalMaster", "True", NULL);
-
- do_parameter("wins support", "False", NULL);
- do_parameter("dns proxy", "True", NULL);
-
- do_parameter("winbind separator", "\\", NULL);
- do_parameter("winbind sealed pipes", "True", NULL);
- do_parameter("winbindd socket directory", dyn_WINBINDD_SOCKET_DIR, NULL);
- do_parameter("template shell", "/bin/false", NULL);
- do_parameter("template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%", NULL);
-
- do_parameter("client signing", "Yes", NULL);
- do_parameter("server signing", "auto", NULL);
-
- do_parameter("use spnego", "True", NULL);
-
- do_parameter("smb ports", "445 139", NULL);
- do_parameter("nbt port", "137", NULL);
- do_parameter("dgram port", "138", NULL);
- do_parameter("cldap port", "389", NULL);
- do_parameter("krb5 port", "88", NULL);
- do_parameter("kpasswd port", "464", NULL);
- do_parameter("web port", "901", NULL);
- do_parameter("web application directory", dyn_WEBAPPSDIR, NULL);
- do_parameter("jsonrpc services directory", dyn_SERVICESDIR, NULL);
-
- do_parameter("nt status support", "True", NULL);
-
- do_parameter("max wins ttl", "518400", NULL); /* 6 days */
- do_parameter("min wins ttl", "10", NULL);
-
- do_parameter("tls enabled", "True", NULL);
- do_parameter("tls keyfile", "tls/key.pem", NULL);
- do_parameter("tls certfile", "tls/cert.pem", NULL);
- do_parameter("tls cafile", "tls/ca.pem", NULL);
- do_parameter_var("js include", "%s", dyn_JSDIR);
- do_parameter_var("setup directory", "%s", dyn_SETUPDIR);
-
- for (i = 0; parm_table[i].label; i++) {
- if (!(parm_table[i].flags & FLAG_CMDLINE)) {
- parm_table[i].flags |= FLAG_DEFAULT;
- }
- }
-}
-
static TALLOC_CTX *lp_talloc;
/******************************************************************* a
@@ -799,131 +615,124 @@ static const char *lp_string(const char *s)
parameters from the rest of the program are defined
*/
-#define FN_GLOBAL_STRING(fn_name,ptr) \
- const char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
-#define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
- const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
-#define FN_GLOBAL_LIST(fn_name,ptr) \
- const char **fn_name(void) {return(*(const char ***)(ptr));}
-#define FN_GLOBAL_BOOL(fn_name,ptr) \
- BOOL fn_name(void) {return((BOOL)*(int *)(ptr));}
+#define FN_GLOBAL_STRING(fn_name,var_name) \
+ const char *fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->Globals.var_name ? lp_string(lp_ctx->Globals.var_name) : "";}
+#define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
+ const char *fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->Globals.var_name ? lp_ctx->Globals.var_name : "";}
+#define FN_GLOBAL_LIST(fn_name,var_name) \
+ const char **fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->Globals.var_name;}
+#define FN_GLOBAL_BOOL(fn_name,var_name) \
+ bool fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return false; return lp_ctx->Globals.var_name;}
#if 0 /* unused */
#define FN_GLOBAL_CHAR(fn_name,ptr) \
char fn_name(void) {return(*(char *)(ptr));}
#endif
-#define FN_GLOBAL_INTEGER(fn_name,ptr) \
- int fn_name(void) {return(*(int *)(ptr));}
+#define FN_GLOBAL_INTEGER(fn_name,var_name) \
+ int fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return 0; return lp_ctx->Globals.var_name;}
#define FN_LOCAL_STRING(fn_name,val) \
- const char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
+ const char *fn_name(struct loadparm_service *service) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault.val)));}
#define FN_LOCAL_CONST_STRING(fn_name,val) \
- const char *fn_name(int i) {return (const char *)((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val);}
+ const char *fn_name(struct loadparm_service *service) {return (const char *)(service != NULL && service->val != NULL) ? service->val : sDefault.val;}
#define FN_LOCAL_LIST(fn_name,val) \
- const char **fn_name(int i) {return(const char **)(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
+ const char **fn_name(struct loadparm_service *service) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault.val);}
#define FN_LOCAL_BOOL(fn_name,val) \
- BOOL fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
-#if 0 /* unused */
-#define FN_LOCAL_CHAR(fn_name,val) \
- char fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
-#endif
+ bool fn_name(struct loadparm_service *service) {return((service != NULL)? service->val : sDefault.val);}
#define FN_LOCAL_INTEGER(fn_name,val) \
- int fn_name(int i) {return(LP_SNUM_OK(i)? ServicePtrs[(i)]->val : sDefault.val);}
-
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_role, &Globals.server_role)
-_PUBLIC_ FN_GLOBAL_LIST(lp_smb_ports, &Globals.smb_ports)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_nbt_port, &Globals.nbt_port)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_dgram_port, &Globals.dgram_port)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_cldap_port, &Globals.cldap_port)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_krb5_port, &Globals.krb5_port)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_kpasswd_port, &Globals.kpasswd_port)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_web_port, &Globals.web_port)
-_PUBLIC_ FN_GLOBAL_STRING(lp_dos_charset, &dos_charset)
-_PUBLIC_ FN_GLOBAL_STRING(lp_webapps_directory, &Globals.webapps_directory)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_tls_enabled, &Globals.tls_enabled)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_keyfile, &Globals.tls_keyfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_certfile, &Globals.tls_certfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_cafile, &Globals.tls_cafile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_crlfile, &Globals.tls_crlfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_dhpfile, &Globals.tls_dhpfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_unix_charset, &unix_charset)
-_PUBLIC_ FN_GLOBAL_STRING(lp_display_charset, &display_charset)
-_PUBLIC_ FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_share_backend, &Globals.szShareBackend)
-_PUBLIC_ FN_GLOBAL_STRING(lp_sam_url, &Globals.szSAM_URL)
-_PUBLIC_ FN_GLOBAL_STRING(lp_secrets_url, &Globals.szSECRETS_URL)
-_PUBLIC_ FN_GLOBAL_STRING(lp_spoolss_url, &Globals.szSPOOLSS_URL)
-_PUBLIC_ FN_GLOBAL_STRING(lp_wins_config_url, &Globals.szWINS_CONFIG_URL)
-_PUBLIC_ FN_GLOBAL_STRING(lp_wins_url, &Globals.szWINS_URL)
-_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
-_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbindd_socket_directory, &Globals.szWinbinddSocketDirectory)
-_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
-_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_winbind_sealed_pipes, &Globals.bWinbindSealedPipes)
-_PUBLIC_ FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
-_PUBLIC_ FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
-_PUBLIC_ FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
-_PUBLIC_ FN_GLOBAL_STRING(lp_modulesdir, &Globals.szModulesDir)
-_PUBLIC_ FN_GLOBAL_STRING(lp_setupdir, &Globals.szSetupDir)
-_PUBLIC_ FN_GLOBAL_STRING(lp_ncalrpc_dir, &Globals.ncalrpc_dir)
-_PUBLIC_ FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
-_PUBLIC_ FN_GLOBAL_LIST(lp_dcerpc_endpoint_servers, &Globals.dcerpc_ep_servers)
-_PUBLIC_ FN_GLOBAL_LIST(lp_server_services, &Globals.server_services)
-_PUBLIC_ FN_GLOBAL_STRING(lp_ntptr_providor, &Globals.ntptr_providor)
-_PUBLIC_ FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
-_PUBLIC_ FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
-_PUBLIC_ FN_GLOBAL_LIST(lp_passwordserver, &Globals.szPasswordServers)
-_PUBLIC_ FN_GLOBAL_LIST(lp_name_resolve_order, &Globals.szNameResolveOrder)
-_PUBLIC_ FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
-_PUBLIC_ FN_GLOBAL_STRING(lp_socket_options, &Globals.socket_options)
-_PUBLIC_ FN_GLOBAL_STRING(lp_workgroup, &Globals.szWorkgroup)
-_PUBLIC_ FN_GLOBAL_STRING(lp_netbios_name, &Globals.szNetbiosName)
-_PUBLIC_ FN_GLOBAL_STRING(lp_netbios_scope, &Globals.szNetbiosScope)
-_PUBLIC_ FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
-_PUBLIC_ FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
-_PUBLIC_ FN_GLOBAL_STRING(lp_socket_address, &Globals.szSocketAddress)
-_PUBLIC_ FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
-
-_PUBLIC_ FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_dns_proxy, &Globals.bWINSdnsProxy)
-_PUBLIC_ FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_unicode, &Globals.bUnicode)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_client_use_spnego_principal, &Globals.client_use_spnego_principal)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_rpc_big_endian, &Globals.bRpcBigEndian)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_max_xmit, &Globals.max_xmit)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_srv_maxprotocol, &Globals.srv_maxprotocol)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_srv_minprotocol, &Globals.srv_minprotocol)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_cli_maxprotocol, &Globals.cli_maxprotocol)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_cli_minprotocol, &Globals.cli_minprotocol)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_security, &Globals.security)
-_PUBLIC_ FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
-_PUBLIC_ FN_GLOBAL_LIST(lp_js_include, &Globals.jsInclude)
-_PUBLIC_ FN_GLOBAL_STRING(lp_jsonrpc_services_dir, &Globals.jsonrpcServicesDir)
-_PUBLIC_
-_PUBLIC_
+ int fn_name(struct loadparm_service *service) {return((service != NULL)? service->val : sDefault.val);}
+
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_role, server_role)
+_PUBLIC_ FN_GLOBAL_LIST(lp_smb_ports, smb_ports)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_nbt_port, nbt_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_dgram_port, dgram_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_cldap_port, cldap_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_krb5_port, krb5_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_kpasswd_port, kpasswd_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_web_port, web_port)
+_PUBLIC_ FN_GLOBAL_STRING(lp_swat_directory, swat_directory)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_tls_enabled, tls_enabled)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_keyfile, tls_keyfile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_certfile, tls_certfile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_cafile, tls_cafile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_crlfile, tls_crlfile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_dhpfile, tls_dhpfile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_share_backend, szShareBackend)
+_PUBLIC_ FN_GLOBAL_STRING(lp_sam_url, szSAM_URL)
+_PUBLIC_ FN_GLOBAL_STRING(lp_secrets_url, szSECRETS_URL)
+_PUBLIC_ FN_GLOBAL_STRING(lp_spoolss_url, szSPOOLSS_URL)
+_PUBLIC_ FN_GLOBAL_STRING(lp_wins_config_url, szWINS_CONFIG_URL)
+_PUBLIC_ FN_GLOBAL_STRING(lp_wins_url, szWINS_URL)
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbind_separator, szWinbindSeparator)
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbindd_socket_directory, szWinbinddSocketDirectory)
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_winbind_sealed_pipes, bWinbindSealedPipes)
+_PUBLIC_ FN_GLOBAL_STRING(lp_private_dir, szPrivateDir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_serverstring, szServerString)
+_PUBLIC_ FN_GLOBAL_STRING(lp_lockdir, szLockDir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_modulesdir, szModulesDir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_setupdir, szSetupDir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_ncalrpc_dir, ncalrpc_dir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_dos_charset, dos_charset)
+_PUBLIC_ FN_GLOBAL_STRING(lp_unix_charset, unix_charset)
+_PUBLIC_ FN_GLOBAL_STRING(lp_display_charset, display_charset)
+_PUBLIC_ FN_GLOBAL_STRING(lp_piddir, szPidDir)
+_PUBLIC_ FN_GLOBAL_LIST(lp_dcerpc_endpoint_servers, dcerpc_ep_servers)
+_PUBLIC_ FN_GLOBAL_LIST(lp_server_services, server_services)
+_PUBLIC_ FN_GLOBAL_STRING(lp_ntptr_providor, ntptr_providor)
+_PUBLIC_ FN_GLOBAL_STRING(lp_auto_services, szAutoServices)
+_PUBLIC_ FN_GLOBAL_STRING(lp_passwd_chat, szPasswdChat)
+_PUBLIC_ FN_GLOBAL_LIST(lp_passwordserver, szPasswordServers)
+_PUBLIC_ FN_GLOBAL_LIST(lp_name_resolve_order, szNameResolveOrder)
+_PUBLIC_ FN_GLOBAL_STRING(lp_realm, szRealm)
+_PUBLIC_ FN_GLOBAL_STRING(lp_socket_options, socket_options)
+_PUBLIC_ FN_GLOBAL_STRING(lp_workgroup, szWorkgroup)
+_PUBLIC_ FN_GLOBAL_STRING(lp_netbios_name, szNetbiosName)
+_PUBLIC_ FN_GLOBAL_STRING(lp_netbios_scope, szNetbiosScope)
+_PUBLIC_ FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)
+_PUBLIC_ FN_GLOBAL_LIST(lp_interfaces, szInterfaces)
+_PUBLIC_ FN_GLOBAL_STRING(lp_socket_address, szSocketAddress)
+_PUBLIC_ FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)
+
+_PUBLIC_ FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_support, bWINSsupport)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_dns_proxy, bWINSdnsProxy)
+_PUBLIC_ FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)
+_PUBLIC_ FN_GLOBAL_STRING(lp_configfile, szConfigFile)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_readraw, bReadRaw)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_writeraw, bWriteRaw)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_null_passwords, bNullPasswords)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_obey_pam_restrictions, bObeyPamRestrictions)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_encrypted_passwords, bEncryptPasswords)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_time_server, bTimeServer)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_bind_interfaces_only, bBindInterfacesOnly)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_unicode, bUnicode)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_nt_status_support, bNTStatusSupport)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_lanman_auth, bLanmanAuth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_ntlm_auth, bNTLMAuth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_client_plaintext_auth, bClientPlaintextAuth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_client_lanman_auth, bClientLanManAuth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, bClientNTLMv2Auth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_client_use_spnego_principal, client_use_spnego_principal)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_host_msdfs, bHostMSDfs)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_unix_extensions, bUnixExtensions)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_use_spnego, bUseSpnego)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_rpc_big_endian, bRpcBigEndian)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_max_wins_ttl, max_wins_ttl)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_min_wins_ttl, min_wins_ttl)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_maxmux, max_mux)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_max_xmit, max_xmit)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_passwordlevel, pwordlevel)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_srv_maxprotocol, srv_maxprotocol)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_srv_minprotocol, srv_minprotocol)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_cli_maxprotocol, cli_maxprotocol)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_cli_minprotocol, cli_minprotocol)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_security, security)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_announce_as, announce_as)
+_PUBLIC_ FN_GLOBAL_LIST(lp_js_include, jsInclude)
_PUBLIC_ FN_LOCAL_STRING(lp_servicename, szService)
_PUBLIC_ FN_LOCAL_CONST_STRING(lp_const_servicename, szService)
_PUBLIC_ FN_LOCAL_STRING(lp_pathname, szPath)
@@ -950,32 +759,31 @@ _PUBLIC_ FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
_PUBLIC_ FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
_PUBLIC_ FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
_PUBLIC_ FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
-_PUBLIC_ FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_signing, server_signing)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_client_signing, client_signing)
/* local prototypes */
-
static int map_parameter(const char *pszParmName);
-static int getservicebyname(const char *pszServiceName,
- service * pserviceDest);
-static void copy_service(service * pserviceDest,
- service * pserviceSource, int *pcopymapDest);
-static BOOL service_ok(int iService);
-static BOOL do_section(const char *pszSectionName, void *);
-static void init_copymap(service * pservice);
+static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
+ const char *pszServiceName);
+static void copy_service(struct loadparm_service *pserviceDest,
+ struct loadparm_service *pserviceSource,
+ int *pcopymapDest);
+static bool service_ok(struct loadparm_service *service);
+static bool do_section(const char *pszSectionName, void *);
+static void init_copymap(struct loadparm_service *pservice);
/* This is a helper function for parametrical options support. */
/* It returns a pointer to parametrical option value if it exists or NULL otherwise */
/* Actual parametrical functions are quite simple */
-const char *lp_get_parametric(int lookup_service, const char *type, const char *option)
+const char *lp_get_parametric(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *type, const char *option)
{
char *vfskey;
struct param_opt *data;
- if (lookup_service >= iNumServices) return NULL;
-
- data = (lookup_service < 0) ?
- Globals.param_opt : ServicePtrs[lookup_service]->param_opt;
+ data = (service == NULL ? lp_ctx->Globals.param_opt : service->param_opt);
asprintf(&vfskey, "%s:%s", type, option);
strlower(vfskey);
@@ -988,16 +796,15 @@ const char *lp_get_parametric(int lookup_service, const char *type, const char *
data = data->next;
}
- if (lookup_service >= 0) {
+ if (service != NULL) {
/* Try to fetch the same option but from globals */
/* but only if we are not already working with Globals */
- data = Globals.param_opt;
- while (data) {
+ for (data = lp_ctx->Globals.param_opt; data;
+ data = data->next) {
if (strcmp(data->key, vfskey) == 0) {
free(vfskey);
return data->value;
}
- data = data->next;
}
}
@@ -1015,7 +822,7 @@ static int lp_int(const char *s)
if (!s) {
DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
- return (-1);
+ return -1;
}
return strtol(s, NULL, 0);
@@ -1029,7 +836,7 @@ static int lp_ulong(const char *s)
if (!s) {
DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
- return (-1);
+ return -1;
}
return strtoul(s, NULL, 0);
@@ -1043,7 +850,7 @@ static double lp_double(const char *s)
if (!s) {
DEBUG(0,("lp_double(%s): is called with NULL!\n",s));
- return (-1);
+ return -1;
}
return strtod(s, NULL);
@@ -1052,18 +859,18 @@ static double lp_double(const char *s)
/*******************************************************************
convenience routine to return boolean parameters.
********************************************************************/
-static BOOL lp_bool(const char *s)
+static bool lp_bool(const char *s)
{
- BOOL ret = False;
+ bool ret = false;
if (!s) {
DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
- return False;
+ return false;
}
if (!set_boolean(s, &ret)) {
DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
- return False;
+ return false;
}
return ret;
@@ -1074,9 +881,11 @@ static BOOL lp_bool(const char *s)
/* Parametric option has following syntax: 'Type: option = value' */
/* Returned value is allocated in 'lp_talloc' context */
-const char *lp_parm_string(int lookup_service, const char *type, const char *option)
+const char *lp_parm_string(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
if (value)
return lp_string(value);
@@ -1088,13 +897,16 @@ const char *lp_parm_string(int lookup_service, const char *type, const char *opt
/* Parametric option has following syntax: 'Type: option = value' */
/* Returned value is allocated in 'lp_talloc' context */
-const char **lp_parm_string_list(int lookup_service, const char *type, const char *option,
- const char *separator)
+const char **lp_parm_string_list(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *type,
+ const char *option, const char *separator)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
if (value)
- return str_list_make(talloc_autofree_context(), value, separator);
+ return str_list_make(talloc_autofree_context(), value,
+ separator);
return NULL;
}
@@ -1102,9 +914,11 @@ const char **lp_parm_string_list(int lookup_service, const char *type, const cha
/* Return parametric option from a given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
-int lp_parm_int(int lookup_service, const char *type, const char *option, int default_v)
+int lp_parm_int(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, int default_v)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
if (value)
return lp_int(value);
@@ -1117,11 +931,13 @@ int lp_parm_int(int lookup_service, const char *type, const char *option, int de
* Parametric option has following syntax: 'Type: option = value'.
*/
-int lp_parm_bytes(int lookup_service, const char *type, const char *option, int default_v)
+int lp_parm_bytes(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, int default_v)
{
uint64_t bval;
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
if (value && conv_str_size(value, &bval)) {
if (bval <= INT_MAX) {
@@ -1135,9 +951,11 @@ int lp_parm_bytes(int lookup_service, const char *type, const char *option, int
/* Return parametric option from a given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
-unsigned long lp_parm_ulong(int lookup_service, const char *type, const char *option, unsigned long default_v)
+unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, unsigned long default_v)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
if (value)
return lp_ulong(value);
@@ -1146,9 +964,11 @@ unsigned long lp_parm_ulong(int lookup_service, const char *type, const char *op
}
-double lp_parm_double(int lookup_service, const char *type, const char *option, double default_v)
+double lp_parm_double(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, double default_v)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
if (value)
return lp_double(value);
@@ -1159,9 +979,11 @@ double lp_parm_double(int lookup_service, const char *type, const char *option,
/* Return parametric option from a given service. Type is a part of option before ':' */
/* Parametric option has following syntax: 'Type: option = value' */
-BOOL lp_parm_bool(int lookup_service, const char *type, const char *option, BOOL default_v)
+bool lp_parm_bool(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, bool default_v)
{
- const char *value = lp_get_parametric(lookup_service, type, option);
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
if (value)
return lp_bool(value);
@@ -1174,128 +996,103 @@ BOOL lp_parm_bool(int lookup_service, const char *type, const char *option, BOOL
Initialise a service to the defaults.
***************************************************************************/
-static void init_service(service * pservice)
+static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx)
{
- memset((char *)pservice, '\0', sizeof(service));
+ struct loadparm_service *pservice =
+ talloc_zero(mem_ctx, struct loadparm_service);
copy_service(pservice, &sDefault, NULL);
+ return pservice;
}
-/***************************************************************************
- Free the dynamically allocated parts of a service struct.
-***************************************************************************/
-
-static void free_service(service *pservice)
+/**
+ Set a string value, deallocating any existing space, and allocing the space
+ for the string
+**/
+static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
{
- int i;
- struct param_opt *data, *pdata;
- if (!pservice)
- return;
+ talloc_free(*dest);
- if (pservice->szService)
- DEBUG(5, ("free_service: Freeing service %s\n",
- pservice->szService));
+ if (src == NULL)
+ src = "";
- string_free(&pservice->szService);
- SAFE_FREE(pservice->copymap);
-
- for (i = 0; parm_table[i].label; i++) {
- if ((parm_table[i].type == P_STRING ||
- parm_table[i].type == P_USTRING) &&
- parm_table[i].class == P_LOCAL) {
- string_free((char **)
- (((char *)pservice) +
- PTR_DIFF(parm_table[i].ptr, &sDefault)));
- } else if (parm_table[i].type == P_LIST &&
- parm_table[i].class == P_LOCAL) {
- char ***listp = (char ***)(((char *)pservice) +
- PTR_DIFF(parm_table[i].ptr, &sDefault));
- talloc_free(*listp);
- *listp = NULL;
- }
- }
-
- DEBUG(5,("Freeing parametrics:\n"));
- data = pservice->param_opt;
- while (data) {
- DEBUG(5,("[%s = %s]\n", data->key, data->value));
- string_free(&data->key);
- string_free(&data->value);
- pdata = data->next;
- SAFE_FREE(data);
- data = pdata;
+ *dest = talloc_strdup(mem_ctx, src);
+ if ((*dest) == NULL) {
+ DEBUG(0,("Out of memory in string_init\n"));
+ return false;
}
- ZERO_STRUCTP(pservice);
+ return true;
}
+
+
/***************************************************************************
Add a new service to the services array initialising it with the given
service.
***************************************************************************/
-static int add_a_service(const service *pservice, const char *name)
+static struct loadparm_service *add_a_service(struct loadparm_context *lp_ctx,
+ const struct loadparm_service *pservice,
+ const char *name)
{
int i;
- service tservice;
- int num_to_alloc = iNumServices + 1;
+ struct loadparm_service tservice;
+ int num_to_alloc = lp_ctx->iNumServices + 1;
struct param_opt *data, *pdata;
tservice = *pservice;
/* it might already exist */
if (name) {
- i = getservicebyname(name, NULL);
- if (i >= 0) {
+ struct loadparm_service *service = getservicebyname(lp_ctx,
+ name);
+ if (service != NULL) {
/* Clean all parametric options for service */
/* They will be added during parsing again */
- data = ServicePtrs[i]->param_opt;
+ data = service->param_opt;
while (data) {
- string_free(&data->key);
- string_free(&data->value);
pdata = data->next;
- SAFE_FREE(data);
+ talloc_free(data);
data = pdata;
}
- ServicePtrs[i]->param_opt = NULL;
- return (i);
+ service->param_opt = NULL;
+ return service;
}
}
/* find an invalid one */
- for (i = 0; i < iNumServices; i++)
- if (!ServicePtrs[i]->valid)
+ for (i = 0; i < lp_ctx->iNumServices; i++)
+ if (lp_ctx->ServicePtrs[i] == NULL)
break;
/* if not, then create one */
- if (i == iNumServices) {
- service **tsp;
+ if (i == lp_ctx->iNumServices) {
+ struct loadparm_service **tsp;
- tsp = realloc_p(ServicePtrs, service *, num_to_alloc);
+ tsp = realloc_p(lp_ctx->ServicePtrs, struct loadparm_service *,
+ num_to_alloc);
if (!tsp) {
DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
- return (-1);
+ return NULL;
}
else {
- ServicePtrs = tsp;
- ServicePtrs[iNumServices] = malloc_p(service);
+ lp_ctx->ServicePtrs = tsp;
+ lp_ctx->ServicePtrs[lp_ctx->iNumServices] = NULL;
}
- if (!ServicePtrs[iNumServices]) {
- DEBUG(0,("add_a_service: out of memory!\n"));
- return (-1);
- }
-
- iNumServices++;
- } else
- free_service(ServicePtrs[i]);
- ServicePtrs[i]->valid = True;
+ lp_ctx->iNumServices++;
+ }
- init_service(ServicePtrs[i]);
- copy_service(ServicePtrs[i], &tservice, NULL);
- if (name)
- string_set(&ServicePtrs[i]->szService, name);
- return (i);
+ lp_ctx->ServicePtrs[i] = init_service(talloc_autofree_context());
+ if (lp_ctx->ServicePtrs[i] == NULL) {
+ DEBUG(0,("add_a_service: out of memory!\n"));
+ return NULL;
+ }
+ copy_service(lp_ctx->ServicePtrs[i], &tservice, NULL);
+ if (name != NULL)
+ string_set(lp_ctx->ServicePtrs[i], &lp_ctx->ServicePtrs[i]->szService, name);
+ return lp_ctx->ServicePtrs[i];
}
/***************************************************************************
@@ -1303,95 +1100,95 @@ static int add_a_service(const service *pservice, const char *name)
from service ifrom.
***************************************************************************/
-BOOL lp_add_home(const char *pszHomename, int iDefaultService,
+bool lp_add_home(struct loadparm_context *lp_ctx,
+ const char *pszHomename,
+ struct loadparm_service *default_service,
const char *user, const char *pszHomedir)
{
- int i;
- pstring newHomedir;
+ struct loadparm_service *service;
- i = add_a_service(ServicePtrs[iDefaultService], pszHomename);
+ service = add_a_service(lp_ctx, default_service, pszHomename);
- if (i < 0)
- return (False);
+ if (service == NULL)
+ return false;
- if (!(*(ServicePtrs[iDefaultService]->szPath))
- || strequal(ServicePtrs[iDefaultService]->szPath, lp_pathname(-1))) {
- pstrcpy(newHomedir, pszHomedir);
+ if (!(*(default_service->szPath))
+ || strequal(default_service->szPath, sDefault.szPath)) {
+ service->szPath = talloc_strdup(service, pszHomedir);
} else {
- pstrcpy(newHomedir, lp_pathname(iDefaultService));
- string_sub(newHomedir,"%H", pszHomedir, sizeof(newHomedir));
+ service->szPath = string_sub_talloc(service, lp_pathname(default_service),"%H", pszHomedir);
}
- string_set(&ServicePtrs[i]->szPath, newHomedir);
-
- if (!(*(ServicePtrs[i]->comment))) {
- pstring comment;
- slprintf(comment, sizeof(comment) - 1,
- "Home directory of %s", user);
- string_set(&ServicePtrs[i]->comment, comment);
+ if (!(*(service->comment))) {
+ service->comment = talloc_asprintf(service, "Home directory of %s", user);
}
- ServicePtrs[i]->bAvailable = sDefault.bAvailable;
- ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
+ service->bAvailable = default_service->bAvailable;
+ service->bBrowseable = default_service->bBrowseable;
- DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n", pszHomename,
- user, newHomedir));
+ DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
+ pszHomename, user, service->szPath));
- return (True);
+ return true;
}
/***************************************************************************
Add a new service, based on an old one.
***************************************************************************/
-int lp_add_service(const char *pszService, int iDefaultService)
+struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
+ const char *pszService,
+ struct loadparm_service *default_service)
{
- return (add_a_service(ServicePtrs[iDefaultService], pszService));
+ return add_a_service(lp_ctx, default_service, pszService);
}
/***************************************************************************
Add the IPC service.
***************************************************************************/
-static BOOL lp_add_hidden(const char *name, const char *fstype)
+static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
+ const char *fstype)
{
- pstring comment;
- int i = add_a_service(&sDefault, name);
+ struct loadparm_service *service = add_a_service(lp_ctx, &sDefault, name);
- if (i < 0)
- return (False);
+ if (service == NULL)
+ return false;
- slprintf(comment, sizeof(comment) - 1,
- "%s Service (%s)", fstype, Globals.szServerString);
+ string_set(service, &service->szPath, tmpdir());
- string_set(&ServicePtrs[i]->szPath, tmpdir());
- string_set(&ServicePtrs[i]->comment, comment);
- string_set(&ServicePtrs[i]->fstype, fstype);
- ServicePtrs[i]->iMaxConnections = -1;
- ServicePtrs[i]->bAvailable = True;
- ServicePtrs[i]->bRead_only = True;
- ServicePtrs[i]->bPrint_ok = False;
- ServicePtrs[i]->bBrowseable = False;
+ service->comment = talloc_asprintf(service, "%s Service (%s)",
+ fstype, lp_ctx->Globals.szServerString);
+ string_set(service, &service->fstype, fstype);
+ service->iMaxConnections = -1;
+ service->bAvailable = true;
+ service->bRead_only = true;
+ service->bPrint_ok = false;
+ service->bBrowseable = false;
if (strcasecmp(fstype, "IPC") == 0) {
- lp_do_parameter(i, "ntvfs handler", "default");
+ lp_do_service_parameter(lp_ctx, service, "ntvfs handler",
+ "default");
}
DEBUG(3, ("adding hidden service %s\n", name));
- return (True);
+ return true;
}
/***************************************************************************
Add a new printer service, with defaults coming from service iFrom.
***************************************************************************/
-BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
+bool lp_add_printer(struct loadparm_context *lp_ctx,
+ const char *pszPrintername,
+ struct loadparm_service *default_service)
{
const char *comment = "From Printcap";
- int i = add_a_service(ServicePtrs[iDefaultService], pszPrintername);
+ struct loadparm_service *service;
+ service = add_a_service(lp_ctx, default_service, pszPrintername);
- if (i < 0)
- return (False);
+ if (service == NULL)
+ return false;
/* note that we do NOT default the availability flag to True - */
/* we take it from the default service passed. This allows all */
@@ -1399,17 +1196,17 @@ BOOL lp_add_printer(const char *pszPrintername, int iDefaultService)
/* entry (if/when the 'available' keyword is implemented!). */
/* the printer name is set to the service name. */
- string_set(&ServicePtrs[i]->szPrintername, pszPrintername);
- string_set(&ServicePtrs[i]->comment, comment);
- ServicePtrs[i]->bBrowseable = sDefault.bBrowseable;
+ string_set(service, &service->szPrintername, pszPrintername);
+ string_set(service, &service->comment, comment);
+ service->bBrowseable = sDefault.bBrowseable;
/* Printers cannot be read_only. */
- ServicePtrs[i]->bRead_only = False;
+ service->bRead_only = false;
/* Printer services must be printable. */
- ServicePtrs[i]->bPrint_ok = True;
+ service->bPrint_ok = true;
DEBUG(3, ("adding printer service %s\n", pszPrintername));
- return (True);
+ return true;
}
/***************************************************************************
@@ -1422,11 +1219,11 @@ static int map_parameter(const char *pszParmName)
int iIndex;
if (*pszParmName == '-')
- return (-1);
+ return -1;
for (iIndex = 0; parm_table[iIndex].label; iIndex++)
if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
- return (iIndex);
+ return iIndex;
/* Warn only if it isn't parametric option */
if (strchr(pszParmName, ':') == NULL)
@@ -1434,7 +1231,7 @@ static int map_parameter(const char *pszParmName)
/* We do return 'fail' for parametric options as well because they are
stored in different storage
*/
- return (-1);
+ return -1;
}
@@ -1451,31 +1248,30 @@ struct parm_struct *lp_parm_struct(const char *name)
/*
return the parameter pointer for a parameter
*/
-void *lp_parm_ptr(int snum, struct parm_struct *parm)
+void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm)
{
- if (snum == -1) {
+ if (service == NULL)
return parm->ptr;
- }
- return ((char *)ServicePtrs[snum]) + PTR_DIFF(parm->ptr, &sDefault);
+
+ return ((char *)service) + PTR_DIFF(parm->ptr, &sDefault);
}
/***************************************************************************
Find a service by name. Otherwise works like get_service.
***************************************************************************/
-static int getservicebyname(const char *pszServiceName, service * pserviceDest)
+static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
+ const char *pszServiceName)
{
int iService;
- for (iService = iNumServices - 1; iService >= 0; iService--)
- if (VALID(iService) &&
- strwicmp(ServicePtrs[iService]->szService, pszServiceName) == 0) {
- if (pserviceDest != NULL)
- copy_service(pserviceDest, ServicePtrs[iService], NULL);
- break;
+ for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
+ if (lp_ctx->ServicePtrs[iService] != NULL &&
+ strwicmp(lp_ctx->ServicePtrs[iService]->szService, pszServiceName) == 0) {
+ return lp_ctx->ServicePtrs[iService];
}
- return (iService);
+ return NULL;
}
/***************************************************************************
@@ -1483,12 +1279,14 @@ static int getservicebyname(const char *pszServiceName, service * pserviceDest)
If pcopymapDest is NULL then copy all fields
***************************************************************************/
-static void copy_service(service * pserviceDest, service * pserviceSource, int *pcopymapDest)
+static void copy_service(struct loadparm_service *pserviceDest,
+ struct loadparm_service *pserviceSource,
+ int *pcopymapDest)
{
int i;
- BOOL bcopyall = (pcopymapDest == NULL);
+ bool bcopyall = (pcopymapDest == NULL);
struct param_opt *data, *pdata, *paramo;
- BOOL not_added;
+ bool not_added;
for (i = 0; parm_table[i].label; i++)
if (parm_table[i].ptr && parm_table[i].class == P_LOCAL &&
@@ -1513,12 +1311,14 @@ static void copy_service(service * pserviceDest, service * pserviceSource, int *
break;
case P_STRING:
- string_set(dest_ptr,
+ string_set(pserviceDest,
+ (char **)dest_ptr,
*(char **)src_ptr);
break;
case P_USTRING:
- string_set(dest_ptr,
+ string_set(pserviceDest,
+ (char **)dest_ptr,
*(char **)src_ptr);
strupper(*(char **)dest_ptr);
break;
@@ -1541,25 +1341,26 @@ static void copy_service(service * pserviceDest, service * pserviceSource, int *
data = pserviceSource->param_opt;
while (data) {
- not_added = True;
+ not_added = true;
pdata = pserviceDest->param_opt;
/* Traverse destination */
while (pdata) {
/* If we already have same option, override it */
if (strcmp(pdata->key, data->key) == 0) {
- string_free(&pdata->value);
- pdata->value = strdup(data->value);
- not_added = False;
+ talloc_free(pdata->value);
+ pdata->value = talloc_reference(pdata,
+ data->value);
+ not_added = false;
break;
}
pdata = pdata->next;
}
if (not_added) {
- paramo = malloc_p(struct param_opt);
- if (!paramo)
+ paramo = talloc(pserviceDest, struct param_opt);
+ if (paramo == NULL)
smb_panic("OOM");
- paramo->key = strdup(data->key);
- paramo->value = strdup(data->value);
+ paramo->key = talloc_reference(paramo, data->key);
+ paramo->value = talloc_reference(paramo, data->value);
DLIST_ADD(pserviceDest->param_opt, paramo);
}
data = data->next;
@@ -1571,53 +1372,48 @@ Check a service for consistency. Return False if the service is in any way
incomplete or faulty, else True.
***************************************************************************/
-static BOOL service_ok(int iService)
+static bool service_ok(struct loadparm_service *service)
{
- BOOL bRetval;
+ bool bRetval;
- bRetval = True;
- if (ServicePtrs[iService]->szService[0] == '\0') {
+ bRetval = true;
+ if (service->szService[0] == '\0') {
DEBUG(0, ("The following message indicates an internal error:\n"));
DEBUG(0, ("No service name in service entry.\n"));
- bRetval = False;
+ bRetval = false;
}
/* The [printers] entry MUST be printable. I'm all for flexibility, but */
/* I can't see why you'd want a non-printable printer service... */
- if (strwicmp(ServicePtrs[iService]->szService, PRINTERS_NAME) == 0) {
- if (!ServicePtrs[iService]->bPrint_ok) {
+ if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
+ if (!service->bPrint_ok) {
DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
- ServicePtrs[iService]->szService));
- ServicePtrs[iService]->bPrint_ok = True;
+ service->szService));
+ service->bPrint_ok = true;
}
/* [printers] service must also be non-browsable. */
- if (ServicePtrs[iService]->bBrowseable)
- ServicePtrs[iService]->bBrowseable = False;
+ if (service->bBrowseable)
+ service->bBrowseable = false;
}
/* If a service is flagged unavailable, log the fact at level 0. */
- if (!ServicePtrs[iService]->bAvailable)
+ if (!service->bAvailable)
DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
- ServicePtrs[iService]->szService));
+ service->szService));
- return (bRetval);
+ return bRetval;
}
-static struct file_lists {
- struct file_lists *next;
- char *name;
- char *subfname;
- time_t modtime;
-} *file_lists = NULL;
/*******************************************************************
Keep a linked list of all config files so we know when one has changed
it's date and needs to be reloaded.
********************************************************************/
-static void add_to_file_list(const char *fname, const char *subfname)
+static void add_to_file_list(struct loadparm_context *lp_ctx,
+ const char *fname, const char *subfname)
{
- struct file_lists *f = file_lists;
+ struct file_lists *f = lp_ctx->file_lists;
while (f) {
if (f->name && !strcmp(f->name, fname))
@@ -1626,21 +1422,21 @@ static void add_to_file_list(const char *fname, const char *subfname)
}
if (!f) {
- f = malloc_p(struct file_lists);
+ f = talloc(talloc_autofree_context(), struct file_lists);
if (!f)
return;
- f->next = file_lists;
- f->name = strdup(fname);
+ f->next = lp_ctx->file_lists;
+ f->name = talloc_strdup(f, fname);
if (!f->name) {
- SAFE_FREE(f);
+ talloc_free(f);
return;
}
- f->subfname = strdup(subfname);
+ f->subfname = talloc_strdup(f, subfname);
if (!f->subfname) {
- SAFE_FREE(f);
+ talloc_free(f);
return;
}
- file_lists = f;
+ lp_ctx->file_lists = f;
f->modtime = file_modtime(subfname);
} else {
time_t t = file_modtime(subfname);
@@ -1653,17 +1449,16 @@ static void add_to_file_list(const char *fname, const char *subfname)
Check if a config file has changed date.
********************************************************************/
-BOOL lp_file_list_changed(void)
+bool lp_file_list_changed(struct loadparm_context *lp_ctx)
{
- struct file_lists *f = file_lists;
+ struct file_lists *f;
DEBUG(6, ("lp_file_list_changed()\n"));
- while (f) {
- pstring n2;
+ for (f = lp_ctx->file_lists; f != NULL; f = f->next) {
+ char *n2;
time_t mod_time;
- pstrcpy(n2, f->name);
- standard_sub_basic(n2,sizeof(n2));
+ n2 = standard_sub_basic(talloc_autofree_context(), f->name);
DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
f->name, n2, ctime(&f->modtime)));
@@ -1671,129 +1466,119 @@ BOOL lp_file_list_changed(void)
mod_time = file_modtime(n2);
if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
- DEBUGADD(6,
- ("file %s modified: %s\n", n2,
+ DEBUGADD(6, ("file %s modified: %s\n", n2,
ctime(&mod_time)));
f->modtime = mod_time;
- SAFE_FREE(f->subfname);
- f->subfname = strdup(n2);
- return (True);
+ talloc_free(f->subfname);
+ f->subfname = talloc_strdup(f, n2);
+ return true;
}
- f = f->next;
}
- return (False);
+ return false;
}
/***************************************************************************
Handle the include operation.
***************************************************************************/
-static BOOL handle_include(const char *pszParmValue, char **ptr)
+static bool handle_include(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr)
{
- pstring fname;
- pstrcpy(fname, pszParmValue);
-
- standard_sub_basic(fname,sizeof(fname));
+ char *fname = standard_sub_basic(talloc_autofree_context(),
+ pszParmValue);
- add_to_file_list(pszParmValue, fname);
+ add_to_file_list(lp_ctx, pszParmValue, fname);
- string_set(ptr, fname);
+ string_set(talloc_autofree_context(), ptr, fname);
if (file_exist(fname))
- return (pm_process(fname, do_section, do_parameter, NULL));
+ return pm_process(fname, do_section, do_parameter, lp_ctx);
DEBUG(2, ("Can't find include file %s\n", fname));
- return (False);
+ return false;
}
/***************************************************************************
Handle the interpretation of the copy parameter.
***************************************************************************/
-static BOOL handle_copy(const char *pszParmValue, char **ptr)
+static bool handle_copy(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr)
{
- BOOL bRetval;
- int iTemp;
- service serviceTemp;
-
- string_set(ptr, pszParmValue);
+ bool bRetval;
+ struct loadparm_service *serviceTemp;
- init_service(&serviceTemp);
+ string_set(talloc_autofree_context(), ptr, pszParmValue);
- bRetval = False;
+ bRetval = false;
DEBUG(3, ("Copying service from service %s\n", pszParmValue));
- if ((iTemp = getservicebyname(pszParmValue, &serviceTemp)) >= 0) {
- if (iTemp == iServiceIndex) {
+ if ((serviceTemp = getservicebyname(lp_ctx, pszParmValue)) != NULL) {
+ if (serviceTemp == lp_ctx->currentService) {
DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
} else {
- copy_service(ServicePtrs[iServiceIndex],
- &serviceTemp,
- ServicePtrs[iServiceIndex]->copymap);
- bRetval = True;
+ copy_service(lp_ctx->currentService,
+ serviceTemp,
+ lp_ctx->currentService->copymap);
+ bRetval = true;
}
} else {
- DEBUG(0, ("Unable to copy service - source not found: %s\n", pszParmValue));
- bRetval = False;
+ DEBUG(0, ("Unable to copy service - source not found: %s\n",
+ pszParmValue));
+ bRetval = false;
}
- free_service(&serviceTemp);
- return (bRetval);
+ return bRetval;
}
/***************************************************************************
Initialise a copymap.
***************************************************************************/
-static void init_copymap(service * pservice)
+static void init_copymap(struct loadparm_service *pservice)
{
int i;
- SAFE_FREE(pservice->copymap);
- pservice->copymap = malloc_array_p(int, NUMPARAMETERS);
- if (!pservice->copymap)
+ talloc_free(pservice->copymap);
+ pservice->copymap = talloc_array(pservice, int, NUMPARAMETERS);
+ if (pservice->copymap == NULL) {
DEBUG(0,
("Couldn't allocate copymap!! (size %d)\n",
(int)NUMPARAMETERS));
- else
- for (i = 0; i < NUMPARAMETERS; i++)
- pservice->copymap[i] = True;
-}
-
-#if 0 /* not used anywhere */
-/***************************************************************************
- Return the local pointer to a parameter given the service number and the
- pointer into the default structure.
-***************************************************************************/
-
-void *lp_local_ptr(int snum, void *ptr)
-{
- return (void *)(((char *)ServicePtrs[snum]) + PTR_DIFF(ptr, &sDefault));
+ return;
+ }
+ for (i = 0; i < NUMPARAMETERS; i++)
+ pservice->copymap[i] = true;
}
-#endif
/***************************************************************************
Process a parametric option
***************************************************************************/
-static BOOL lp_do_parameter_parametric(int snum, const char *pszParmName, const char *pszParmValue, int flags)
+static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *pszParmName,
+ const char *pszParmValue, int flags)
{
struct param_opt *paramo, *data;
char *name;
+ TALLOC_CTX *mem_ctx;
while (isspace((unsigned char)*pszParmName)) {
pszParmName++;
}
name = strdup(pszParmName);
- if (!name) return False;
+ if (!name) return false;
strlower(name);
- if (snum < 0) {
- data = Globals.param_opt;
+ if (service == NULL) {
+ data = lp_ctx->Globals.param_opt;
+ mem_ctx = talloc_autofree_context();
} else {
- data = ServicePtrs[snum]->param_opt;
+ data = service->param_opt;
+ mem_ctx = service;
}
/* Traverse destination */
@@ -1803,107 +1588,54 @@ static BOOL lp_do_parameter_parametric(int snum, const char *pszParmName, const
if (strcmp(paramo->key, name) == 0) {
if ((paramo->flags & FLAG_CMDLINE) &&
!(flags & FLAG_CMDLINE)) {
- return True;
+ return true;
}
- free(paramo->value);
- paramo->value = strdup(pszParmValue);
+ talloc_free(paramo->value);
+ paramo->value = talloc_strdup(paramo, pszParmValue);
paramo->flags = flags;
free(name);
- return True;
+ return true;
}
}
- paramo = malloc_p(struct param_opt);
+ paramo = talloc(mem_ctx, struct param_opt);
if (!paramo)
smb_panic("OOM");
- paramo->key = strdup(name);
- paramo->value = strdup(pszParmValue);
+ paramo->key = talloc_strdup(paramo, name);
+ paramo->value = talloc_strdup(paramo, pszParmValue);
paramo->flags = flags;
- if (snum < 0) {
- DLIST_ADD(Globals.param_opt, paramo);
+ if (service == NULL) {
+ DLIST_ADD(lp_ctx->Globals.param_opt, paramo);
} else {
- DLIST_ADD(ServicePtrs[snum]->param_opt, paramo);
+ DLIST_ADD(service->param_opt, paramo);
}
free(name);
- return True;
+ return true;
}
-/***************************************************************************
- Process a parameter for a particular service number. If snum < 0
- then assume we are in the globals.
-***************************************************************************/
-BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue)
+static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
+ const char *pszParmName, const char *pszParmValue,
+ struct loadparm_context *lp_ctx)
{
- int parmnum, i;
- void *parm_ptr = NULL; /* where we are going to store the result */
- void *def_ptr = NULL;
-
- parmnum = map_parameter(pszParmName);
-
- if (parmnum < 0) {
- if (strchr(pszParmName, ':')) {
- return lp_do_parameter_parametric(snum, pszParmName, pszParmValue, 0);
- }
- DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
- return (True);
- }
-
- if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
- DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
- pszParmName));
- }
-
- /* if the flag has been set on the command line, then don't allow override,
- but don't report an error */
- if (parm_table[parmnum].flags & FLAG_CMDLINE) {
- return True;
- }
-
- def_ptr = parm_table[parmnum].ptr;
-
- /* we might point at a service, the default service or a global */
- if (snum < 0) {
- parm_ptr = def_ptr;
- } else {
- if (parm_table[parmnum].class == P_GLOBAL) {
- DEBUG(0,
- ("Global parameter %s found in service section!\n",
- pszParmName));
- return (True);
- }
- parm_ptr =
- ((char *)ServicePtrs[snum]) + PTR_DIFF(def_ptr,
- &sDefault);
- }
-
- if (snum >= 0) {
- if (!ServicePtrs[snum]->copymap)
- init_copymap(ServicePtrs[snum]);
-
- /* this handles the aliases - set the copymap for other entries with
- the same data pointer */
- for (i = 0; parm_table[i].label; i++)
- if (parm_table[i].ptr == parm_table[parmnum].ptr)
- ServicePtrs[snum]->copymap[i] = False;
- }
-
+ int i;
/* if it is a special case then go ahead */
if (parm_table[parmnum].special) {
- parm_table[parmnum].special(pszParmValue, (char **)parm_ptr);
- return (True);
+ parm_table[parmnum].special(lp_ctx, pszParmValue,
+ (char **)parm_ptr);
+ return true;
}
/* now switch on the type of variable it is */
switch (parm_table[parmnum].type)
{
case P_BOOL: {
- BOOL b;
+ bool b;
if (!set_boolean(pszParmValue, &b)) {
DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
- return False;
+ return false;
}
*(int *)parm_ptr = b;
}
@@ -1929,20 +1661,20 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
DEBUG(0,("lp_do_parameter(%s): value is not "
"a valid size specifier!\n", pszParmValue));
- return False;
+ return false;
}
case P_LIST:
- *(const char ***)parm_ptr = str_list_make(talloc_autofree_context(),
+ *(const char ***)parm_ptr = str_list_make(mem_ctx,
pszParmValue, NULL);
break;
case P_STRING:
- string_set(parm_ptr, pszParmValue);
+ string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
break;
case P_USTRING:
- string_set(parm_ptr, pszParmValue);
+ string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
strupper(*(char **)parm_ptr);
break;
@@ -1960,11 +1692,9 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
if (!parm_table[parmnum].enum_list[i].name) {
DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
pszParmValue, pszParmName));
- return False;
+ return false;
}
break;
- case P_SEP:
- break;
}
if (parm_table[parmnum].flags & FLAG_DEFAULT) {
@@ -1977,35 +1707,124 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
parm_table[i].flags &= ~FLAG_DEFAULT;
}
}
+ return true;
+}
- return (True);
+
+bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *pszParmValue)
+{
+ int parmnum = map_parameter(pszParmName);
+ void *parm_ptr;
+
+ if (parmnum < 0) {
+ if (strchr(pszParmName, ':')) {
+ return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, pszParmValue, 0);
+ }
+ DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
+ return true;
+ }
+
+ if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
+ DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
+ pszParmName));
+ }
+
+ /* if the flag has been set on the command line, then don't allow override,
+ but don't report an error */
+ if (parm_table[parmnum].flags & FLAG_CMDLINE) {
+ return true;
+ }
+
+ parm_ptr = parm_table[parmnum].ptr;
+
+ return set_variable(talloc_autofree_context(), parmnum, parm_ptr,
+ pszParmName, pszParmValue, lp_ctx);
+}
+
+bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *pszParmName, const char *pszParmValue)
+{
+ void *def_ptr = NULL;
+ void *parm_ptr;
+ int i;
+ int parmnum = map_parameter(pszParmName);
+
+ if (parmnum < 0) {
+ if (strchr(pszParmName, ':')) {
+ return lp_do_parameter_parametric(lp_ctx, service, pszParmName, pszParmValue, 0);
+ }
+ DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
+ return true;
+ }
+
+ if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
+ DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
+ pszParmName));
+ }
+
+ /* if the flag has been set on the command line, then don't allow override,
+ but don't report an error */
+ if (parm_table[parmnum].flags & FLAG_CMDLINE) {
+ return true;
+ }
+
+ def_ptr = parm_table[parmnum].ptr;
+
+ if (parm_table[parmnum].class == P_GLOBAL) {
+ DEBUG(0,
+ ("Global parameter %s found in service section!\n",
+ pszParmName));
+ return true;
+ }
+ parm_ptr = ((char *)service) + PTR_DIFF(def_ptr, &sDefault);
+
+ if (!service->copymap)
+ init_copymap(service);
+
+ /* this handles the aliases - set the copymap for other
+ * entries with the same data pointer */
+ for (i = 0; parm_table[i].label; i++)
+ if (parm_table[i].ptr == parm_table[parmnum].ptr)
+ service->copymap[i] = false;
+
+ return set_variable(service, parmnum, parm_ptr, pszParmName,
+ pszParmValue, lp_ctx);
}
/***************************************************************************
Process a parameter.
***************************************************************************/
-static BOOL do_parameter(const char *pszParmName, const char *pszParmValue, void *userdata)
+static bool do_parameter(const char *pszParmName, const char *pszParmValue,
+ void *userdata)
{
- return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex,
- pszParmName, pszParmValue));
+ struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
+
+ if (lp_ctx->bInGlobalSection)
+ return lp_do_global_parameter(lp_ctx, pszParmName,
+ pszParmValue);
+ else
+ return lp_do_service_parameter(lp_ctx, lp_ctx->currentService,
+ pszParmName, pszParmValue);
}
/*
variable argument do parameter
*/
-static BOOL do_parameter_var(const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
-
-static BOOL do_parameter_var(const char *pszParmName, const char *fmt, ...)
+bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *fmt, ...)
{
char *s;
- BOOL ret;
+ bool ret;
va_list ap;
va_start(ap, fmt);
s = talloc_vasprintf(NULL, fmt, ap);
va_end(ap);
- ret = do_parameter(pszParmName, s, NULL);
+ ret = lp_do_global_parameter(lp_ctx, pszParmName, s);
talloc_free(s);
return ret;
}
@@ -2016,7 +1835,8 @@ static BOOL do_parameter_var(const char *pszParmName, const char *fmt, ...)
parsing code. It sets the parameter then marks the parameter as unable to be modified
by smb.conf processing
*/
-BOOL lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
+bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
+ const char *pszParmValue)
{
int parmnum = map_parameter(pszParmName);
int i;
@@ -2026,19 +1846,20 @@ BOOL lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
if (parmnum < 0 && strchr(pszParmName, ':')) {
/* set a parametric option */
- return lp_do_parameter_parametric(-1, pszParmName, pszParmValue, FLAG_CMDLINE);
+ return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
+ pszParmValue, FLAG_CMDLINE);
}
if (parmnum < 0) {
DEBUG(0,("Unknown option '%s'\n", pszParmName));
- return False;
+ return false;
}
/* reset the CMDLINE flag in case this has been called before */
parm_table[parmnum].flags &= ~FLAG_CMDLINE;
- if (!lp_do_parameter(-2, pszParmName, pszParmValue)) {
- return False;
+ if (!lp_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
+ return false;
}
parm_table[parmnum].flags |= FLAG_CMDLINE;
@@ -2051,31 +1872,31 @@ BOOL lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
parm_table[i].flags |= FLAG_CMDLINE;
}
- return True;
+ return true;
}
/*
set a option from the commandline in 'a=b' format. Use to support --option
*/
-BOOL lp_set_option(const char *option)
+bool lp_set_option(struct loadparm_context *lp_ctx, const char *option)
{
char *p, *s;
- BOOL ret;
+ bool ret;
s = strdup(option);
if (!s) {
- return False;
+ return false;
}
p = strchr(s, '=');
if (!p) {
free(s);
- return False;
+ return false;
}
*p = 0;
- ret = lp_set_cmdline(s, p+1);
+ ret = lp_set_cmdline(lp_ctx, s, p+1);
free(s);
return ret;
}
@@ -2103,7 +1924,7 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
break;
case P_BOOL:
- fprintf(f, "%s", BOOLSTR((BOOL)*(int *)ptr));
+ fprintf(f, "%s", BOOLSTR((bool)*(int *)ptr));
break;
case P_INTEGER:
@@ -2131,8 +1952,6 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
fprintf(f, "%s", *(char **)ptr);
}
break;
- case P_SEP:
- break;
}
}
@@ -2140,7 +1959,7 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
Check if two parameters are equal.
***************************************************************************/
-static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
+static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
{
switch (type) {
case P_BOOL:
@@ -2166,10 +1985,8 @@ static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
p2 = NULL;
return (p1 == p2 || strequal(p1, p2));
}
- case P_SEP:
- break;
}
- return (False);
+ return false;
}
/***************************************************************************
@@ -2178,27 +1995,28 @@ static BOOL equal_parameter(parm_type type, void *ptr1, void *ptr2)
Returns True on success, False on failure.
***************************************************************************/
-static BOOL do_section(const char *pszSectionName, void *userdata)
+static bool do_section(const char *pszSectionName, void *userdata)
{
- BOOL bRetval;
- BOOL isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
+ struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
+ bool bRetval;
+ bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
(strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
- bRetval = False;
+ bRetval = false;
/* if we've just struck a global section, note the fact. */
- bInGlobalSection = isglobal;
+ lp_ctx->bInGlobalSection = isglobal;
/* check for multiple global sections */
- if (bInGlobalSection) {
+ if (lp_ctx->bInGlobalSection) {
DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
- return (True);
+ return true;
}
/* if we have a current service, tidy it up before moving on */
- bRetval = True;
+ bRetval = true;
- if (iServiceIndex >= 0)
- bRetval = service_ok(iServiceIndex);
+ if (lp_ctx->currentService != NULL)
+ bRetval = service_ok(lp_ctx->currentService);
/* if all is still well, move to the next record in the services array */
if (bRetval) {
@@ -2206,14 +2024,15 @@ static BOOL do_section(const char *pszSectionName, void *userdata)
/* issued by the post-processing of a previous section. */
DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
- if ((iServiceIndex = add_a_service(&sDefault, pszSectionName))
- < 0) {
+ if ((lp_ctx->currentService = add_a_service(lp_ctx, &sDefault,
+ pszSectionName))
+ == NULL) {
DEBUG(0, ("Failed to add a new service\n"));
- return (False);
+ return false;
}
}
- return (bRetval);
+ return bRetval;
}
@@ -2221,10 +2040,10 @@ static BOOL do_section(const char *pszSectionName, void *userdata)
Determine if a partcular base parameter is currentl set to the default value.
***************************************************************************/
-static BOOL is_default(int i)
+static bool is_default(int i)
{
if (!defaults_saved)
- return False;
+ return false;
switch (parm_table[i].type) {
case P_LIST:
return str_list_equal((const char **)parm_table[i].def.lvalue,
@@ -2242,17 +2061,15 @@ static BOOL is_default(int i)
case P_ENUM:
return parm_table[i].def.ivalue ==
*(int *)parm_table[i].ptr;
- case P_SEP:
- break;
}
- return False;
+ return false;
}
/***************************************************************************
Display the contents of the global structure.
***************************************************************************/
-static void dump_globals(FILE *f, BOOL show_defaults)
+static void dump_globals(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults)
{
int i;
struct param_opt *data;
@@ -2269,11 +2086,10 @@ static void dump_globals(FILE *f, BOOL show_defaults)
print_parameter(&parm_table[i], parm_table[i].ptr, f);
fprintf(f, "\n");
}
- if (Globals.param_opt != NULL) {
- data = Globals.param_opt;
- while(data) {
+ if (lp_ctx->Globals.param_opt != NULL) {
+ for (data = lp_ctx->Globals.param_opt; data;
+ data = data->next) {
fprintf(f, "\t%s = %s\n", data->key, data->value);
- data = data->next;
}
}
@@ -2283,7 +2099,7 @@ static void dump_globals(FILE *f, BOOL show_defaults)
Display the contents of a single services record.
***************************************************************************/
-static void dump_a_service(service * pService, FILE * f)
+static void dump_a_service(struct loadparm_service * pService, FILE * f)
{
int i;
struct param_opt *data;
@@ -2316,23 +2132,22 @@ static void dump_a_service(service * pService, FILE * f)
fprintf(f, "\n");
}
if (pService->param_opt != NULL) {
- data = pService->param_opt;
- while(data) {
+ for (data = pService->param_opt; data; data = data->next) {
fprintf(f, "\t%s = %s\n", data->key, data->value);
- data = data->next;
}
}
}
-BOOL lp_dump_a_parameter(int snum, char *parm_name, FILE * f, BOOL isGlobal)
+bool lp_dump_a_parameter(struct loadparm_context *lp_ctx, int snum, char *parm_name, FILE * f,
+ bool isGlobal)
{
- service * pService = ServicePtrs[snum];
+ struct loadparm_service * pService = lp_ctx->ServicePtrs[snum];
struct parm_struct *parm;
void *ptr;
parm = lp_parm_struct(parm_name);
if (!parm) {
- return False;
+ return false;
}
if (isGlobal)
@@ -2344,7 +2159,7 @@ BOOL lp_dump_a_parameter(int snum, char *parm_name, FILE * f, BOOL isGlobal)
print_parameter(parm,
ptr, f);
fprintf(f, "\n");
- return True;
+ return true;
}
/***************************************************************************
@@ -2352,14 +2167,12 @@ BOOL lp_dump_a_parameter(int snum, char *parm_name, FILE * f, BOOL isGlobal)
Return NULL when out of parameters.
***************************************************************************/
-struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
+struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
+ int allparameters)
{
if (snum == -1) {
/* do the globals */
for (; parm_table[*i].label; (*i)++) {
- if (parm_table[*i].class == P_SEPARATOR)
- return &parm_table[(*i)++];
-
if (!parm_table[*i].ptr
|| (*parm_table[*i].label == '-'))
continue;
@@ -2372,12 +2185,9 @@ struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
return &parm_table[(*i)++];
}
} else {
- service *pService = ServicePtrs[snum];
+ struct loadparm_service *pService = lp_ctx->ServicePtrs[snum];
for (; parm_table[*i].label; (*i)++) {
- if (parm_table[*i].class == P_SEPARATOR)
- return &parm_table[(*i)++];
-
if (parm_table[*i].class == P_LOCAL &&
parm_table[*i].ptr &&
(*parm_table[*i].label != '-') &&
@@ -2407,19 +2217,11 @@ struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
/***************************************************************************
- Return TRUE if the passed service number is within range.
-***************************************************************************/
-
-BOOL lp_snum_ok(int iService)
-{
- return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
-}
-
-/***************************************************************************
Auto-load some home services.
***************************************************************************/
-static void lp_add_auto_services(const char *str)
+static void lp_add_auto_services(struct loadparm_context *lp_ctx,
+ const char *str)
{
return;
}
@@ -2428,39 +2230,195 @@ static void lp_add_auto_services(const char *str)
Have we loaded a services file yet?
***************************************************************************/
-BOOL lp_loaded(void)
+bool lp_loaded(void)
{
- return (bLoaded);
+ return bLoaded;
}
/***************************************************************************
Unload unused services.
***************************************************************************/
-void lp_killunused(struct smbsrv_connection *smb, BOOL (*snumused) (struct smbsrv_connection *, int))
+void lp_killunused(struct loadparm_context *lp_ctx,
+ struct smbsrv_connection *smb,
+ bool (*snumused) (struct smbsrv_connection *, int))
{
int i;
- for (i = 0; i < iNumServices; i++) {
- if (!VALID(i))
+ for (i = 0; i < lp_ctx->iNumServices; i++) {
+ if (lp_ctx->ServicePtrs[i] == NULL)
continue;
if (!snumused || !snumused(smb, i)) {
- ServicePtrs[i]->valid = False;
- free_service(ServicePtrs[i]);
+ talloc_free(lp_ctx->ServicePtrs[i]);
+ lp_ctx->ServicePtrs[i] = NULL;
}
}
}
/***************************************************************************
- Unload a service.
+ Initialise the global parameter structure.
***************************************************************************/
-
-void lp_killservice(int iServiceIn)
+bool loadparm_init(struct loadparm_context *lp_ctx)
{
- if (VALID(iServiceIn)) {
- ServicePtrs[iServiceIn]->valid = False;
- free_service(ServicePtrs[iServiceIn]);
+ int i;
+ char *myname;
+
+ lp_ctx->bInGlobalSection = true;
+
+ DEBUG(3, ("Initialising global parameters\n"));
+
+ for (i = 0; parm_table[i].label; i++) {
+ if ((parm_table[i].type == P_STRING ||
+ parm_table[i].type == P_USTRING) &&
+ parm_table[i].ptr &&
+ !(parm_table[i].flags & FLAG_CMDLINE)) {
+ string_set(talloc_autofree_context(),
+ (char **)parm_table[i].ptr, "");
+ }
+ }
+
+ lp_do_global_parameter(lp_ctx, "share backend", "classic");
+
+ lp_do_global_parameter(lp_ctx, "server role", "standalone");
+
+ /* options that can be set on the command line must be initialised via
+ the slower lp_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
+#ifdef TCP_NODELAY
+ lp_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
+#endif
+ lp_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
+ myname = get_myname();
+ lp_do_global_parameter(lp_ctx, "netbios name", myname);
+ SAFE_FREE(myname);
+ lp_do_global_parameter(lp_ctx, "name resolve order", "lmhosts wins host bcast");
+
+ lp_do_global_parameter(lp_ctx, "fstype", FSTYPE_STRING);
+ lp_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
+ lp_do_global_parameter(lp_ctx, "max connections", "-1");
+
+ lp_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo");
+ lp_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl ldap cldap web kdc drepl winbind");
+ lp_do_global_parameter(lp_ctx, "ntptr providor", "simple_ldb");
+ lp_do_global_parameter(lp_ctx, "auth methods:domain controller", "anonymous sam_ignoredomain");
+ lp_do_global_parameter(lp_ctx, "auth methods:member server", "anonymous sam winbind");
+ lp_do_global_parameter(lp_ctx, "auth methods:standalone", "anonymous sam_ignoredomain");
+ lp_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
+ lp_do_global_parameter(lp_ctx, "sam database", "sam.ldb");
+ lp_do_global_parameter(lp_ctx, "secrets database", "secrets.ldb");
+ lp_do_global_parameter(lp_ctx, "spoolss database", "spoolss.ldb");
+ lp_do_global_parameter(lp_ctx, "wins config database", "wins_config.ldb");
+ lp_do_global_parameter(lp_ctx, "wins database", "wins.ldb");
+ lp_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
+
+ /* This hive should be dynamically generated by Samba using
+ data from the sam, but for the moment leave it in a tdb to
+ keep regedt32 from popping up an annoying dialog. */
+ lp_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
+
+ /* using UTF8 by default allows us to support all chars */
+ lp_do_global_parameter(lp_ctx, "unix charset", "UTF8");
+
+ /* Use codepage 850 as a default for the dos character set */
+ lp_do_global_parameter(lp_ctx, "dos charset", "CP850");
+
+ /*
+ * Allow the default PASSWD_CHAT to be overridden in local.h.
+ */
+ lp_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
+
+ lp_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
+ lp_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
+ lp_do_global_parameter(lp_ctx, "modules dir", dyn_MODULESDIR);
+ lp_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
+
+ lp_do_global_parameter(lp_ctx, "socket address", "0.0.0.0");
+ lp_do_global_parameter_var(lp_ctx, "server string",
+ "Samba %s", SAMBA_VERSION_STRING);
+
+ lp_do_global_parameter_var(lp_ctx, "announce version", "%d.%d",
+ DEFAULT_MAJOR_VERSION,
+ DEFAULT_MINOR_VERSION);
+
+ lp_do_global_parameter(lp_ctx, "password server", "*");
+
+ lp_do_global_parameter(lp_ctx, "max mux", "50");
+ lp_do_global_parameter(lp_ctx, "max xmit", "12288");
+ lp_do_global_parameter(lp_ctx, "password level", "0");
+ lp_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
+ lp_do_global_parameter(lp_ctx, "server min protocol", "CORE");
+ lp_do_global_parameter(lp_ctx, "server max protocol", "NT1");
+ lp_do_global_parameter(lp_ctx, "client min protocol", "CORE");
+ lp_do_global_parameter(lp_ctx, "client max protocol", "NT1");
+ lp_do_global_parameter(lp_ctx, "security", "USER");
+ lp_do_global_parameter(lp_ctx, "paranoid server security", "True");
+ lp_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
+ lp_do_global_parameter(lp_ctx, "ReadRaw", "True");
+ lp_do_global_parameter(lp_ctx, "WriteRaw", "True");
+ lp_do_global_parameter(lp_ctx, "NullPasswords", "False");
+ lp_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
+ lp_do_global_parameter(lp_ctx, "announce as", "NT SERVER");
+
+ lp_do_global_parameter(lp_ctx, "TimeServer", "False");
+ lp_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
+ lp_do_global_parameter(lp_ctx, "Unicode", "True");
+ lp_do_global_parameter(lp_ctx, "ClientLanManAuth", "True");
+ lp_do_global_parameter(lp_ctx, "LanmanAuth", "True");
+ lp_do_global_parameter(lp_ctx, "NTLMAuth", "True");
+ lp_do_global_parameter(lp_ctx, "client use spnego principal", "False");
+
+ lp_do_global_parameter(lp_ctx, "UnixExtensions", "False");
+
+ lp_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
+ lp_do_global_parameter(lp_ctx, "LocalMaster", "True");
+
+ lp_do_global_parameter(lp_ctx, "wins support", "False");
+ lp_do_global_parameter(lp_ctx, "dns proxy", "True");
+
+ lp_do_global_parameter(lp_ctx, "winbind separator", "\\");
+ lp_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
+ lp_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
+ lp_do_global_parameter(lp_ctx, "template shell", "/bin/false");
+ lp_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
+
+ lp_do_global_parameter(lp_ctx, "client signing", "Yes");
+ lp_do_global_parameter(lp_ctx, "server signing", "auto");
+
+ lp_do_global_parameter(lp_ctx, "use spnego", "True");
+
+ lp_do_global_parameter(lp_ctx, "smb ports", "445 139");
+ lp_do_global_parameter(lp_ctx, "nbt port", "137");
+ lp_do_global_parameter(lp_ctx, "dgram port", "138");
+ lp_do_global_parameter(lp_ctx, "cldap port", "389");
+ lp_do_global_parameter(lp_ctx, "krb5 port", "88");
+ lp_do_global_parameter(lp_ctx, "kpasswd port", "464");
+ lp_do_global_parameter(lp_ctx, "web port", "901");
+ lp_do_global_parameter(lp_ctx, "swat directory", dyn_SWATDIR);
+
+ lp_do_global_parameter(lp_ctx, "nt status support", "True");
+
+ lp_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
+ lp_do_global_parameter(lp_ctx, "min wins ttl", "10");
+
+ lp_do_global_parameter(lp_ctx, "tls enabled", "True");
+ lp_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
+ lp_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
+ lp_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
+ lp_do_global_parameter_var(lp_ctx, "js include", "%s", dyn_JSDIR);
+ lp_do_global_parameter_var(lp_ctx, "setup directory", "%s",
+ dyn_SETUPDIR);
+
+ for (i = 0; parm_table[i].label; i++) {
+ if (!(parm_table[i].flags & FLAG_CMDLINE)) {
+ parm_table[i].flags |= FLAG_DEFAULT;
+ }
}
+
+ return true;
+}
+
+_PUBLIC_ _DEPRECATED_ bool lp_load_default(void)
+{
+ return lp_load(dyn_CONFIGFILE);
}
/***************************************************************************
@@ -2468,171 +2426,147 @@ void lp_killservice(int iServiceIn)
False on failure.
***************************************************************************/
-BOOL lp_load(void)
+bool lp_load(const char *filename)
{
- pstring n2;
- BOOL bRetval;
+ char *n2;
+ bool bRetval;
struct param_opt *data;
+ struct loadparm_context *lp_ctx = &loadparm;
- bRetval = False;
+ filename = talloc_strdup(talloc_autofree_context(), filename);
- bInGlobalSection = True;
+ global_loadparm = lp_ctx;
- if (Globals.param_opt != NULL) {
+ if (lp_ctx->Globals.param_opt != NULL) {
struct param_opt *next;
- for (data=Globals.param_opt; data; data=next) {
+ for (data = lp_ctx->Globals.param_opt; data; data=next) {
next = data->next;
if (data->flags & FLAG_CMDLINE) continue;
- free(data->key);
- free(data->value);
- DLIST_REMOVE(Globals.param_opt, data);
- free(data);
+ DLIST_REMOVE(lp_ctx->Globals.param_opt, data);
+ talloc_free(data);
}
}
-
- init_globals();
- pstrcpy(n2, lp_configfile());
- standard_sub_basic(n2,sizeof(n2));
+ if (!loadparm_init(lp_ctx))
+ return false;
+
+ lp_ctx->Globals.szConfigFile = filename;
+
+ lp_ctx->bInGlobalSection = true;
+ n2 = standard_sub_basic(talloc_autofree_context(), lp_ctx->Globals.szConfigFile);
DEBUG(2, ("lp_load: refreshing parameters from %s\n", n2));
- add_to_file_list(lp_configfile(), n2);
+ add_to_file_list(lp_ctx, lp_ctx->Globals.szConfigFile, n2);
/* We get sections first, so have to start 'behind' to make up */
- iServiceIndex = -1;
- bRetval = pm_process(n2, do_section, do_parameter, NULL);
+ lp_ctx->currentService = NULL;
+ bRetval = pm_process(n2, do_section, do_parameter, lp_ctx);
/* finish up the last section */
DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
if (bRetval)
- if (iServiceIndex >= 0)
- bRetval = service_ok(iServiceIndex);
+ if (lp_ctx->currentService != NULL)
+ bRetval = service_ok(lp_ctx->currentService);
- lp_add_auto_services(lp_auto_services());
+ lp_add_auto_services(lp_ctx, lp_auto_services(lp_ctx));
- lp_add_hidden("IPC$", "IPC");
- lp_add_hidden("ADMIN$", "DISK");
+ lp_add_hidden(lp_ctx, "IPC$", "IPC");
+ lp_add_hidden(lp_ctx, "ADMIN$", "DISK");
- bLoaded = True;
+ bLoaded = true;
- if (!Globals.szWINSservers && Globals.bWINSsupport) {
- lp_do_parameter(-1, "wins server", "127.0.0.1");
+ if (!lp_ctx->Globals.szWINSservers && lp_ctx->Globals.bWINSsupport) {
+ lp_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
}
init_iconv();
- return (bRetval);
-}
-
-/***************************************************************************
- Reset the max number of services.
-***************************************************************************/
-
-void lp_resetnumservices(void)
-{
- iNumServices = 0;
+ return bRetval;
}
/***************************************************************************
Return the max number of services.
***************************************************************************/
-int lp_numservices(void)
+int lp_numservices(struct loadparm_context *lp_ctx)
{
- return (iNumServices);
+ return lp_ctx->iNumServices;
}
/***************************************************************************
Display the contents of the services array in human-readable form.
***************************************************************************/
-void lp_dump(FILE *f, BOOL show_defaults, int maxtoprint)
+void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
+ int maxtoprint)
{
int iService;
if (show_defaults)
- defaults_saved = False;
+ defaults_saved = false;
- dump_globals(f, show_defaults);
+ dump_globals(lp_ctx, f, show_defaults);
dump_a_service(&sDefault, f);
for (iService = 0; iService < maxtoprint; iService++)
- lp_dump_one(f, show_defaults, iService);
+ lp_dump_one(f, show_defaults, lp_ctx->ServicePtrs[iService]);
}
/***************************************************************************
Display the contents of one service in human-readable form.
***************************************************************************/
-void lp_dump_one(FILE * f, BOOL show_defaults, int snum)
+void lp_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service)
{
- if (VALID(snum)) {
- if (ServicePtrs[snum]->szService[0] == '\0')
+ if (service != NULL) {
+ if (service->szService[0] == '\0')
return;
- dump_a_service(ServicePtrs[snum], f);
+ dump_a_service(service, f);
}
}
-/***************************************************************************
-Return the number of the service with the given name, or -1 if it doesn't
-exist. Note that this is a DIFFERENT ANIMAL from the internal function
-getservicebyname()! This works ONLY if all services have been loaded, and
-does not copy the found service.
-***************************************************************************/
+struct loadparm_service *lp_servicebynum(struct loadparm_context *lp_ctx,
+ int snum)
+{
+ return lp_ctx->ServicePtrs[snum];
+}
-int lp_servicenumber(const char *pszServiceName)
+struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
+ const char *service_name)
{
int iService;
- fstring serviceName;
-
+ char *serviceName;
- for (iService = iNumServices - 1; iService >= 0; iService--) {
- if (VALID(iService) && ServicePtrs[iService]->szService) {
+ for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
+ if (lp_ctx->ServicePtrs[iService] &&
+ lp_ctx->ServicePtrs[iService]->szService) {
/*
* The substitution here is used to support %U is
* service names
*/
- fstrcpy(serviceName, ServicePtrs[iService]->szService);
- standard_sub_basic(serviceName,sizeof(serviceName));
- if (strequal(serviceName, pszServiceName))
- break;
+ serviceName = standard_sub_basic(
+ lp_ctx->ServicePtrs[iService],
+ lp_ctx->ServicePtrs[iService]->szService);
+ if (strequal(serviceName, service_name))
+ return lp_ctx->ServicePtrs[iService];
}
}
- if (iService < 0)
- DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
-
- return (iService);
+ DEBUG(7,("lp_servicenumber: couldn't find %s\n", service_name));
+ return NULL;
}
-int lp_find_valid_service(const char *pszServiceName)
-{
- int iService;
-
- iService = lp_servicenumber(pszServiceName);
-
- if (iService >= 0 && !lp_snum_ok(iService)) {
- DEBUG(0,("lp_find_valid_service: Invalid snum %d for '%s'\n",iService, pszServiceName));
- iService = -1;
- }
-
- if (iService == -1) {
- DEBUG(3,("lp_find_valid_service: failed to find service '%s'\n", pszServiceName));
- }
-
- return iService;
-}
/*******************************************************************
A useful volume label function.
********************************************************************/
-const char *volume_label(int snum)
+const char *volume_label(struct loadparm_service *service)
{
- const char *ret = lp_volume(snum);
+ const char *ret = lp_volume(service);
if (!*ret)
- return lp_servicename(snum);
- return (ret);
+ return lp_servicename(service);
+ return ret;
}
@@ -2640,40 +2574,16 @@ const char *volume_label(int snum)
If we are PDC then prefer us as DMB
************************************************************/
-BOOL lp_domain_logons(void)
-{
- return (lp_server_role() == ROLE_DOMAIN_CONTROLLER);
-}
-
-/*******************************************************************
- Remove a service.
-********************************************************************/
-
-void lp_remove_service(int snum)
-{
- ServicePtrs[snum]->valid = False;
-}
-
-/*******************************************************************
- Copy a service.
-********************************************************************/
-
-void lp_copy_service(int snum, const char *new_name)
+bool lp_domain_logons(struct loadparm_context *lp_ctx)
{
- const char *oldname = lp_servicename(snum);
- do_section(new_name, NULL);
- if (snum >= 0) {
- snum = lp_servicenumber(new_name);
- if (snum >= 0)
- lp_do_parameter(snum, "copy", oldname);
- }
+ return (lp_server_role(lp_ctx) == ROLE_DOMAIN_CONTROLLER);
}
-const char *lp_printername(int snum)
+const char *lp_printername(struct loadparm_service *service)
{
- const char *ret = _lp_printername(snum);
+ const char *ret = _lp_printername(service);
if (ret == NULL || (ret != NULL && *ret == '\0'))
- ret = lp_const_servicename(snum);
+ ret = lp_const_servicename(service);
return ret;
}
@@ -2683,9 +2593,9 @@ const char *lp_printername(int snum)
Return the max print jobs per queue.
********************************************************************/
-int lp_maxprintjobs(int snum)
+int lp_maxprintjobs(struct loadparm_service *service)
{
- int maxjobs = LP_SNUM_OK(snum) ? ServicePtrs[snum]->iMaxPrintJobs : sDefault.iMaxPrintJobs;
+ int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault.iMaxPrintJobs;
if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
maxjobs = PRINT_MAX_JOBID - 1;
diff --git a/source4/param/loadparm.h b/source4/param/loadparm.h
index 6b98ebe018..f834bce8f5 100644
--- a/source4/param/loadparm.h
+++ b/source4/param/loadparm.h
@@ -29,11 +29,11 @@
/* the following are used by loadparm for option lists */
typedef enum {
- P_BOOL,P_INTEGER,P_OCTAL,P_BYTES,P_LIST,P_STRING,P_USTRING,P_ENUM,P_SEP
+ P_BOOL,P_INTEGER,P_OCTAL,P_BYTES,P_LIST,P_STRING,P_USTRING,P_ENUM
} parm_type;
typedef enum {
- P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
+ P_LOCAL,P_GLOBAL,P_NONE
} parm_class;
struct enum_list {
@@ -41,12 +41,14 @@ struct enum_list {
const char *name;
};
+struct loadparm_context;
+
struct parm_struct {
const char *label;
parm_type type;
parm_class class;
void *ptr;
- bool (*special)(const char *, char **);
+ bool (*special)(struct loadparm_context *, const char *, char **);
const struct enum_list *enum_list;
unsigned int flags;
union {
@@ -78,4 +80,3 @@ struct parm_struct {
#define HOMES_NAME "homes"
#endif
-
diff --git a/source4/param/param.h b/source4/param/param.h
index 5f5da58388..1dd5950e31 100644
--- a/source4/param/param.h
+++ b/source4/param/param.h
@@ -20,21 +20,21 @@
#ifndef _PARAM_H /* _PARAM_H */
#define _PARAM_H
-struct param_context {
- struct param_section *sections;
+struct param_opt {
+ struct param_opt *prev, *next;
+ char *key;
+ char *value;
+ int flags;
};
-struct param {
- const char *name;
- char *value;
- const char **list_value;
- struct param *prev, *next;
+struct param_context {
+ struct param_section *sections;
};
struct param_section {
const char *name;
struct param_section *prev, *next;
- struct param *parameters;
+ struct param_opt *parameters;
};
struct param_context;
@@ -57,8 +57,11 @@ enum announce_as {/* Types of machine we can announce as. */
ANNOUNCE_AS_NT_WORKSTATION=4
};
-
+struct loadparm_context;
+struct loadparm_service;
#include "param/proto.h"
+extern struct loadparm_context *global_loadparm;
+
#endif /* _PARAM_H */
diff --git a/source4/param/params.c b/source4/param/params.c
index 5ee6dbea70..3a9e2b9505 100644
--- a/source4/param/params.c
+++ b/source4/param/params.c
@@ -188,7 +188,7 @@ static int Continuation(char *line, int pos )
}
-static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *, void *), void *userdata )
+static bool Section( myFILE *InFile, bool (*sfunc)(const char *, void *), void *userdata )
/* ------------------------------------------------------------------------ **
* Scan a section name, and pass the name to function sfunc().
*
@@ -196,8 +196,8 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *, void *), void *
* sfunc - Pointer to the function to be called if the section
* name is successfully read.
*
- * Output: True if the section name was read and True was returned from
- * <sfunc>. False if <sfunc> failed or if a lexical error was
+ * Output: true if the section name was read and true was returned from
+ * <sfunc>. false if <sfunc> failed or if a lexical error was
* encountered.
*
* ------------------------------------------------------------------------ **
@@ -229,7 +229,7 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *, void *), void *
if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
- return( False );
+ return( false );
}
InFile->bufr = tb;
InFile->bSize += BUFR_INC;
@@ -243,12 +243,12 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *, void *), void *
if( 0 == end ) /* Don't allow an empty name. */
{
DEBUG(0, ("%s Empty section name in configuration file.\n", func ));
- return( False );
+ return( false );
}
if( !sfunc(InFile->bufr,userdata) ) /* Got a valid name. Deal with it. */
- return( False );
+ return( false );
(void)EatComment( InFile ); /* Finish off the line. */
- return( True );
+ return( true );
case '\n': /* Got newline before closing ']'. */
i = Continuation( InFile->bufr, i ); /* Check for line continuation. */
@@ -257,7 +257,7 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *, void *), void *
InFile->bufr[end] = '\0';
DEBUG(0, ("%s Badly formed line in configuration file: %s\n",
func, InFile->bufr ));
- return( False );
+ return( false );
}
end = ( (i > 0) && (' ' == InFile->bufr[i - 1]) ) ? (i - 1) : (i);
c = mygetc( InFile ); /* Continue with next line. */
@@ -281,10 +281,10 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *, void *), void *
/* We arrive here if we've met the EOF before the closing bracket. */
DEBUG(0, ("%s Unexpected EOF in the configuration file\n", func));
- return( False );
+ return( false );
} /* Section */
-static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *, void *), int c, void *userdata )
+static bool Parameter( myFILE *InFile, bool (*pfunc)(const char *, const char *, void *), int c, void *userdata )
/* ------------------------------------------------------------------------ **
* Scan a parameter name and value, and pass these two fields to pfunc().
*
@@ -296,8 +296,8 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *,
* line or a section header, there is no lead-in
* character that can be discarded.
*
- * Output: True if the parameter name and value were scanned and processed
- * successfully, else False.
+ * Output: true if the parameter name and value were scanned and processed
+ * successfully, else false.
*
* Notes: This function is in two parts. The first loop scans the
* parameter name. Internal whitespace is compressed, and an
@@ -326,7 +326,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *,
if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
- return( False );
+ return( false );
}
InFile->bufr = tb;
InFile->bSize += BUFR_INC;
@@ -338,7 +338,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *,
if( 0 == end ) /* Don't allow an empty name. */
{
DEBUG(0, ("%s Invalid parameter name in config. file.\n", func ));
- return( False );
+ return( false );
}
InFile->bufr[end++] = '\0'; /* Mark end of string & advance. */
i = end; /* New string starts here. */
@@ -353,7 +353,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *,
InFile->bufr[end] = '\0';
DEBUG(1,("%s Ignoring badly formed line in configuration file: %s\n",
func, InFile->bufr ));
- return( True );
+ return( true );
}
end = ( (i > 0) && (' ' == InFile->bufr[i - 1]) ) ? (i - 1) : (i);
c = mygetc( InFile ); /* Read past eoln. */
@@ -363,7 +363,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *,
case EOF:
InFile->bufr[i] = '\0';
DEBUG(1,("%s Unexpected end-of-file at: %s\n", func, InFile->bufr ));
- return( True );
+ return( true );
default:
if( isspace( c ) ) /* One ' ' per whitespace region. */
@@ -394,7 +394,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *,
if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
- return( False );
+ return( false );
}
InFile->bufr = tb;
InFile->bSize += BUFR_INC;
@@ -431,9 +431,9 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *,
return( pfunc( InFile->bufr, &InFile->bufr[vstart], userdata ) ); /* Pass name & value to pfunc(). */
} /* Parameter */
-static BOOL Parse( myFILE *InFile,
- BOOL (*sfunc)(const char *, void *),
- BOOL (*pfunc)(const char *, const char *, void *),
+static bool Parse( myFILE *InFile,
+ bool (*sfunc)(const char *, void *),
+ bool (*pfunc)(const char *, const char *, void *),
void *userdata )
/* ------------------------------------------------------------------------ **
* Scan & parse the input.
@@ -444,7 +444,7 @@ static BOOL Parse( myFILE *InFile,
* pfunc - Function to be called when a parameter is scanned.
* See Parameter().
*
- * Output: True if the file was successfully scanned, else False.
+ * Output: true if the file was successfully scanned, else false.
*
* Notes: The input can be viewed in terms of 'lines'. There are four
* types of lines:
@@ -475,7 +475,7 @@ static BOOL Parse( myFILE *InFile,
case '[': /* Section Header. */
if( !Section( InFile, sfunc, userdata ) )
- return( False );
+ return( false );
c = EatWhitespace( InFile );
break;
@@ -485,12 +485,12 @@ static BOOL Parse( myFILE *InFile,
default: /* Parameter line. */
if( !Parameter( InFile, pfunc, c, userdata ) )
- return( False );
+ return( false );
c = EatWhitespace( InFile );
break;
}
}
- return( True );
+ return( true );
} /* Parse */
static myFILE *OpenConfFile( const char *FileName )
@@ -526,9 +526,9 @@ static myFILE *OpenConfFile( const char *FileName )
return( ret );
} /* OpenConfFile */
-BOOL pm_process( const char *FileName,
- BOOL (*sfunc)(const char *, void *),
- BOOL (*pfunc)(const char *, const char *, void *),
+bool pm_process( const char *FileName,
+ bool (*sfunc)(const char *, void *),
+ bool (*pfunc)(const char *, const char *, void *),
void *userdata)
/* ------------------------------------------------------------------------ **
* Process the named parameter file.
@@ -550,7 +550,7 @@ BOOL pm_process( const char *FileName,
InFile = OpenConfFile( FileName ); /* Open the config file. */
if( NULL == InFile )
- return( False );
+ return( false );
DEBUG( 3, ("%s Processing configuration file \"%s\"\n", func, FileName) );
@@ -566,7 +566,7 @@ BOOL pm_process( const char *FileName,
{
DEBUG(0,("%s memory allocation failure.\n", func));
myfile_close(InFile);
- return( False );
+ return( false );
}
result = Parse( InFile, sfunc, pfunc, userdata );
InFile->bufr = NULL;
@@ -578,10 +578,10 @@ BOOL pm_process( const char *FileName,
if( !result ) /* Generic failure. */
{
DEBUG(0,("%s Failed. Error returned from params.c:parse().\n", func));
- return( False );
+ return( false );
}
- return( True ); /* Generic success. */
+ return( true ); /* Generic success. */
} /* pm_process */
/* -------------------------------------------------------------------------- */
diff --git a/source4/param/secrets.c b/source4/param/secrets.c
index 657d2f7998..6640fd473d 100644
--- a/source4/param/secrets.c
+++ b/source4/param/secrets.c
@@ -56,22 +56,22 @@ void secrets_shutdown(void)
}
/* open up the secrets database */
-BOOL secrets_init(void)
+bool secrets_init(void)
{
char *fname;
uint8_t dummy;
if (tdb)
- return True;
+ return true;
- asprintf(&fname, "%s/secrets.tdb", lp_private_dir());
+ asprintf(&fname, "%s/secrets.tdb", lp_private_dir(global_loadparm));
tdb = tdb_wrap_open(talloc_autofree_context(), fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
if (!tdb) {
DEBUG(0,("Failed to open %s\n", fname));
SAFE_FREE(fname);
- return False;
+ return false;
}
SAFE_FREE(fname);
@@ -86,7 +86,7 @@ BOOL secrets_init(void)
/* Ensure that the reseed is done now, while we are root, etc */
generate_random_buffer(&dummy, sizeof(dummy));
- return True;
+ return true;
}
/*
@@ -97,18 +97,18 @@ struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx)
char *path;
const char *url;
struct ldb_context *ldb;
- BOOL existed;
+ bool existed;
const char *init_ldif =
"dn: @ATTRIBUTES\n" \
"computerName: CASE_INSENSITIVE\n" \
"flatname: CASE_INSENSITIVE\n";
- url = lp_secrets_url();
+ url = lp_secrets_url(global_loadparm);
if (!url || !url[0]) {
return NULL;
}
- path = private_path(mem_ctx, url);
+ path = private_path(mem_ctx, global_loadparm, url);
if (!path) {
return NULL;
}
@@ -117,7 +117,7 @@ struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx)
/* Secrets.ldb *must* always be local. If we call for a
* system_session() we will recurse */
- ldb = ldb_wrap_connect(mem_ctx, path, NULL, NULL, 0, NULL);
+ ldb = ldb_wrap_connect(mem_ctx, global_loadparm, path, NULL, NULL, 0, NULL);
talloc_free(path);
if (!ldb) {
return NULL;
diff --git a/source4/param/secrets.h b/source4/param/secrets.h
index 44ffdbd8a6..5aabb849c5 100644
--- a/source4/param/secrets.h
+++ b/source4/param/secrets.h
@@ -34,6 +34,19 @@ struct machine_acct_pass {
#define SECRETS_KRBTGT_SEARCH "(&((|(realm=%s)(flatname=%s))(samAccountName=krbtgt)))"
#define SECRETS_PRINCIPAL_SEARCH "(&(|(realm=%s)(flatname=%s))(servicePrincipalName=%s))"
-#include "param/secrets_proto.h"
+/**
+ * Use a TDB to store an incrementing random seed.
+ *
+ * Initialised to the current pid, the very first time Samba starts,
+ * and incremented by one each time it is needed.
+ *
+ * @note Not called by systems with a working /dev/urandom.
+ */
+void secrets_shutdown(void);
+bool secrets_init(void);
+struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx);
+struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx,
+ const char *domain);
+
#endif /* _SECRETS_H */
diff --git a/source4/param/share.c b/source4/param/share.c
index 26173fb876..489049f39f 100644
--- a/source4/param/share.c
+++ b/source4/param/share.c
@@ -22,6 +22,7 @@
#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)
{
@@ -33,7 +34,7 @@ int share_int_option(struct share_config *scfg, const char *opt_name, int defval
return scfg->ctx->ops->int_option(scfg, opt_name, defval);
}
-BOOL share_bool_option(struct share_config *scfg, const char *opt_name, BOOL defval)
+bool share_bool_option(struct share_config *scfg, const char *opt_name, bool defval)
{
return scfg->ctx->ops->bool_option(scfg, opt_name, defval);
}
@@ -115,12 +116,7 @@ NTSTATUS share_register(const struct share_ops *ops)
smb_panic("out of memory in share_register");
}
- backends[i] = malloc(sizeof(struct share_ops));
- if (!backends[i]) {
- smb_panic("out of memory in share_register");
- }
-
- backends[i] = smb_xmemdup(ops, sizeof(*ops));
+ backends[i] = (struct share_ops *)smb_xmemdup(ops, sizeof(*ops));
backends[i]->name = smb_xstrdup(ops->name);
backends[i + 1] = NULL;
@@ -138,7 +134,7 @@ NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx,
ops = share_backend_by_name(backend_name);
if (!ops) {
- DEBUG(0, ("share_init_connection: share backend [%s] not found!\n", lp_share_backend()));
+ DEBUG(0, ("share_init_connection: share backend [%s] not found!\n", lp_share_backend(global_loadparm)));
return NT_STATUS_INTERNAL_ERROR;
}
@@ -147,7 +143,7 @@ NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx,
NTSTATUS share_get_context(TALLOC_CTX *mem_ctx, struct share_context **ctx)
{
- return share_get_context_by_name(mem_ctx, lp_share_backend(), ctx);
+ return share_get_context_by_name(mem_ctx, lp_share_backend(global_loadparm), ctx);
}
/*
@@ -156,7 +152,7 @@ NTSTATUS share_get_context(TALLOC_CTX *mem_ctx, struct share_context **ctx)
NTSTATUS share_init(void)
{
init_module_fn static_init[] = STATIC_share_MODULES;
- init_module_fn *shared_init = load_samba_modules(NULL, "share");
+ init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "share");
run_init_functions(static_init);
run_init_functions(shared_init);
diff --git a/source4/param/share.h b/source4/param/share.h
index 4e16f03715..c93d0d9857 100644
--- a/source4/param/share.h
+++ b/source4/param/share.h
@@ -103,8 +103,8 @@ struct share_ops {
#define SHARE_VOLUME_DEFAULT NULL
#define SHARE_TYPE_DEFAULT "DISK"
#define SHARE_CSC_POLICY_DEFAULT 0
-#define SHARE_AVAILABLE_DEFAULT True
-#define SHARE_BROWSEABLE_DEFAULT True
+#define SHARE_AVAILABLE_DEFAULT true
+#define SHARE_BROWSEABLE_DEFAULT true
#define SHARE_MAX_CONNECTIONS_DEFAULT 0
#define SHARE_DIR_MASK_DEFAULT 0755
@@ -116,14 +116,14 @@ struct share_ops {
/* I'd like to see the following options go away
* and always use EAs and SECDESCs */
-#define SHARE_READONLY_DEFAULT True
-#define SHARE_MAP_SYSTEM_DEFAULT False
-#define SHARE_MAP_HIDDEN_DEFAULT False
-#define SHARE_MAP_ARCHIVE_DEFAULT True
-
-#define SHARE_STRICT_LOCKING_DEFAULT True
-#define SHARE_STRICT_SYNC_DEFAULT False
-#define SHARE_MSDFS_ROOT_DEFAULT False
-#define SHARE_CI_FILESYSTEM_DEFAULT False
+#define SHARE_READONLY_DEFAULT true
+#define SHARE_MAP_SYSTEM_DEFAULT false
+#define SHARE_MAP_HIDDEN_DEFAULT false
+#define SHARE_MAP_ARCHIVE_DEFAULT true
+
+#define SHARE_STRICT_LOCKING_DEFAULT true
+#define SHARE_STRICT_SYNC_DEFAULT false
+#define SHARE_MSDFS_ROOT_DEFAULT false
+#define SHARE_CI_FILESYSTEM_DEFAULT false
#endif /* _SHARE_H */
diff --git a/source4/param/share_classic.c b/source4/param/share_classic.c
index 234a632144..cf140f0d32 100644
--- a/source4/param/share_classic.c
+++ b/source4/param/share_classic.c
@@ -21,10 +21,7 @@
#include "includes.h"
#include "param/share.h"
-
-struct sclassic_snum {
- int snum;
-};
+#include "param/param.h"
static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, struct share_context **ctx)
{
@@ -42,7 +39,8 @@ static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops,
static const char *sclassic_string_option(struct share_config *scfg, const char *opt_name, const char *defval)
{
- struct sclassic_snum *s = talloc_get_type(scfg->opaque, struct sclassic_snum);
+ struct loadparm_service *s = talloc_get_type(scfg->opaque,
+ struct loadparm_service);
char *parm, *val;
const char *ret;
@@ -55,7 +53,7 @@ static const char *sclassic_string_option(struct share_config *scfg, const char
*val = '\0';
val++;
- ret = lp_parm_string(s->snum, parm, val);
+ ret = lp_parm_string(global_loadparm, s, parm, val);
if (!ret) {
ret = defval;
}
@@ -68,25 +66,29 @@ static const char *sclassic_string_option(struct share_config *scfg, const char
}
if (strcmp(opt_name, SHARE_PATH) == 0) {
- return lp_pathname(s->snum);
+ return lp_pathname(s);
}
if (strcmp(opt_name, SHARE_COMMENT) == 0) {
- return lp_comment(s->snum);
+ return lp_comment(s);
}
if (strcmp(opt_name, SHARE_VOLUME) == 0) {
- return volume_label(s->snum);
+ return volume_label(s);
}
if (strcmp(opt_name, SHARE_TYPE) == 0) {
- if (lp_print_ok(s->snum)) {
+ if (lp_print_ok(s)) {
return "PRINTER";
}
- if (strcmp("NTFS", lp_fstype(s->snum)) == 0) {
+ if (strcmp("NTFS", lp_fstype(s)) == 0) {
return "DISK";
}
- return lp_fstype(s->snum);
+ return lp_fstype(s);
+ }
+
+ if (strcmp(opt_name, SHARE_PASSWORD) == 0) {
+ return defval;
}
DEBUG(0,("request for unknown share string option '%s'\n",
@@ -95,9 +97,10 @@ static const char *sclassic_string_option(struct share_config *scfg, const char
return defval;
}
-int sclassic_int_option(struct share_config *scfg, const char *opt_name, int defval)
+static int sclassic_int_option(struct share_config *scfg, const char *opt_name, int defval)
{
- struct sclassic_snum *s = talloc_get_type(scfg->opaque, struct sclassic_snum);
+ struct loadparm_service *s = talloc_get_type(scfg->opaque,
+ struct loadparm_service);
char *parm, *val;
int ret;
@@ -110,7 +113,7 @@ int sclassic_int_option(struct share_config *scfg, const char *opt_name, int def
*val = '\0';
val++;
- ret = lp_parm_int(s->snum, parm, val, defval);
+ ret = lp_parm_int(global_loadparm, s, parm, val, defval);
if (!ret) {
ret = defval;
}
@@ -119,27 +122,27 @@ int sclassic_int_option(struct share_config *scfg, const char *opt_name, int def
}
if (strcmp(opt_name, SHARE_CSC_POLICY) == 0) {
- return lp_csc_policy(s->snum);
+ return lp_csc_policy(s);
}
if (strcmp(opt_name, SHARE_MAX_CONNECTIONS) == 0) {
- return lp_max_connections(s->snum);
+ return lp_max_connections(s);
}
if (strcmp(opt_name, SHARE_CREATE_MASK) == 0) {
- return lp_create_mask(s->snum);
+ return lp_create_mask(s);
}
if (strcmp(opt_name, SHARE_DIR_MASK) == 0) {
- return lp_dir_mask(s->snum);
+ return lp_dir_mask(s);
}
if (strcmp(opt_name, SHARE_FORCE_DIR_MODE) == 0) {
- return lp_force_dir_mode(s->snum);
+ return lp_force_dir_mode(s);
}
if (strcmp(opt_name, SHARE_FORCE_CREATE_MODE) == 0) {
- return lp_force_create_mode(s->snum);
+ return lp_force_create_mode(s);
}
@@ -149,64 +152,66 @@ int sclassic_int_option(struct share_config *scfg, const char *opt_name, int def
return defval;
}
-BOOL sclassic_bool_option(struct share_config *scfg, const char *opt_name, BOOL defval)
+static bool sclassic_bool_option(struct share_config *scfg, const char *opt_name,
+ bool defval)
{
- struct sclassic_snum *s = talloc_get_type(scfg->opaque, struct sclassic_snum);
+ struct loadparm_service *s = talloc_get_type(scfg->opaque,
+ struct loadparm_service);
char *parm, *val;
- BOOL ret;
+ bool ret;
if (strchr(opt_name, ':')) {
parm = talloc_strdup(scfg, opt_name);
if(!parm) {
- return False;
+ return false;
}
val = strchr(parm, ':');
*val = '\0';
val++;
- ret = lp_parm_bool(s->snum, parm, val, defval);
+ ret = lp_parm_bool(global_loadparm, s, parm, val, defval);
talloc_free(parm);
return ret;
}
if (strcmp(opt_name, SHARE_AVAILABLE) == 0) {
- return lp_snum_ok(s->snum);
+ return s != NULL;
}
if (strcmp(opt_name, SHARE_BROWSEABLE) == 0) {
- return lp_browseable(s->snum);
+ return lp_browseable(s);
}
if (strcmp(opt_name, SHARE_READONLY) == 0) {
- return lp_readonly(s->snum);
+ return lp_readonly(s);
}
if (strcmp(opt_name, SHARE_MAP_SYSTEM) == 0) {
- return lp_map_system(s->snum);
+ return lp_map_system(s);
}
if (strcmp(opt_name, SHARE_MAP_HIDDEN) == 0) {
- return lp_map_hidden(s->snum);
+ return lp_map_hidden(s);
}
if (strcmp(opt_name, SHARE_MAP_ARCHIVE) == 0) {
- return lp_map_archive(s->snum);
+ return lp_map_archive(s);
}
if (strcmp(opt_name, SHARE_STRICT_LOCKING) == 0) {
- return lp_strict_locking(s->snum);
+ return lp_strict_locking(s);
}
if (strcmp(opt_name, SHARE_STRICT_SYNC) == 0) {
- return lp_strict_sync(s->snum);
+ return lp_strict_sync(s);
}
if (strcmp(opt_name, SHARE_MSDFS_ROOT) == 0) {
- return lp_msdfs_root(s->snum);
+ return lp_msdfs_root(s);
}
if (strcmp(opt_name, SHARE_CI_FILESYSTEM) == 0) {
- return lp_ci_filesystem(s->snum);
+ return lp_ci_filesystem(s);
}
DEBUG(0,("request for unknown share bool option '%s'\n",
@@ -215,9 +220,10 @@ BOOL sclassic_bool_option(struct share_config *scfg, const char *opt_name, BOOL
return defval;
}
-const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_config *scfg, const char *opt_name)
+static const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_config *scfg, const char *opt_name)
{
- struct sclassic_snum *s = talloc_get_type(scfg->opaque, struct sclassic_snum);
+ struct loadparm_service *s = talloc_get_type(scfg->opaque,
+ struct loadparm_service);
char *parm, *val;
const char **ret;
@@ -230,21 +236,21 @@ const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_confi
*val = '\0';
val++;
- ret = lp_parm_string_list(s->snum, parm, val, ",;");
+ ret = lp_parm_string_list(global_loadparm, s, parm, val, ",;");
talloc_free(parm);
return ret;
}
if (strcmp(opt_name, SHARE_HOSTS_ALLOW) == 0) {
- return lp_hostsallow(s->snum);
+ return lp_hostsallow(s);
}
if (strcmp(opt_name, SHARE_HOSTS_DENY) == 0) {
- return lp_hostsdeny(s->snum);
+ return lp_hostsdeny(s);
}
if (strcmp(opt_name, SHARE_NTVFS_HANDLER) == 0) {
- return lp_ntvfs_handler(s->snum);
+ return lp_ntvfs_handler(s);
}
DEBUG(0,("request for unknown share list option '%s'\n",
@@ -253,16 +259,16 @@ const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_confi
return NULL;
}
-NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
- struct share_context *ctx,
- int *count,
- const char ***names)
+static NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
+ struct share_context *ctx,
+ int *count,
+ const char ***names)
{
int i;
int num_services;
const char **n;
- num_services = lp_numservices();
+ num_services = lp_numservices(global_loadparm);
n = talloc_array(mem_ctx, const char *, num_services);
if (!n) {
@@ -271,7 +277,7 @@ NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
}
for (i = 0; i < num_services; i++) {
- n[i] = talloc_strdup(n, lp_servicename(i));
+ n[i] = talloc_strdup(n, lp_servicename(lp_servicebynum(global_loadparm, i)));
if (!n[i]) {
DEBUG(0,("ERROR: Out of memory!\n"));
talloc_free(n);
@@ -285,24 +291,17 @@ NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
-NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
- struct share_context *ctx,
- const char *name,
- struct share_config **scfg)
+static NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
+ struct share_context *ctx,
+ const char *name,
+ struct share_config **scfg)
{
- int i, snum;
struct share_config *s;
- struct sclassic_snum *scnum;
+ struct loadparm_service *service;
- snum = -1;
- for (i = 0; i < lp_numservices(); i++) {
- if (strcasecmp_m(name, lp_servicename(i)) == 0) {
- snum = i;
- break;
- }
- }
+ service = lp_service(global_loadparm, name);
- if (snum < 0) {
+ if (service == NULL) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
@@ -312,22 +311,14 @@ NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- s->name = talloc_strdup(s, lp_servicename(snum));
+ s->name = talloc_strdup(s, lp_servicename(service));
if (!s->name) {
DEBUG(0,("ERROR: Out of memory!\n"));
talloc_free(s);
return NT_STATUS_NO_MEMORY;
}
- scnum = talloc(s, struct sclassic_snum);
- if (!scnum) {
- DEBUG(0,("ERROR: Out of memory!\n"));
- talloc_free(s);
- return NT_STATUS_NO_MEMORY;
- }
- scnum->snum = snum;
-
- s->opaque = (void *)scnum;
+ s->opaque = (void *)service;
s->ctx = ctx;
*scfg = s;
@@ -335,19 +326,19 @@ NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
+static const struct share_ops ops = {
+ .name = "classic",
+ .init = sclassic_init,
+ .string_option = sclassic_string_option,
+ .int_option = sclassic_int_option,
+ .bool_option = sclassic_bool_option,
+ .string_list_option = sclassic_string_list_option,
+ .list_all = sclassic_list_all,
+ .get_config = sclassic_get_config
+};
+
NTSTATUS share_classic_init(void)
{
- static struct share_ops ops = {
- .name = "classic",
- .init = sclassic_init,
- .string_option = sclassic_string_option,
- .int_option = sclassic_int_option,
- .bool_option = sclassic_bool_option,
- .string_list_option = sclassic_string_list_option,
- .list_all = sclassic_list_all,
- .get_config = sclassic_get_config
- };
-
return share_register(&ops);
}
diff --git a/source4/param/share_ldb.c b/source4/param/share_ldb.c
index fe65cb7a58..019b161639 100644
--- a/source4/param/share_ldb.c
+++ b/source4/param/share_ldb.c
@@ -25,6 +25,7 @@
#include "auth/auth.h"
#include "db_wrap.h"
#include "param/share.h"
+#include "param/param.h"
static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, struct share_context **ctx)
{
@@ -36,10 +37,10 @@ static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, stru
return NT_STATUS_NO_MEMORY;
}
- sdb = ldb_wrap_connect( *ctx,
- private_path(*ctx, "share.ldb"),
- system_session(*ctx),
- NULL, 0, NULL);
+ sdb = ldb_wrap_connect(*ctx, global_loadparm,
+ private_path(*ctx, global_loadparm, "share.ldb"),
+ system_session(*ctx),
+ NULL, 0, NULL);
if (!sdb) {
talloc_free(*ctx);
@@ -98,16 +99,16 @@ static int sldb_int_option(struct share_config *scfg, const char *opt_name, int
return ret;
}
-static BOOL sldb_bool_option(struct share_config *scfg, const char *opt_name, BOOL defval)
+static bool sldb_bool_option(struct share_config *scfg, const char *opt_name, bool defval)
{
const char *val;
val = sldb_string_option(scfg, opt_name, NULL);
if (val == NULL) return defval;
- if (strcasecmp(val, "true") == 0) return True;
+ if (strcasecmp(val, "true") == 0) return true;
- return False;
+ return false;
}
static const char **sldb_string_list_option(TALLOC_CTX *mem_ctx, struct share_config *scfg, const char *opt_name)
@@ -354,9 +355,9 @@ NTSTATUS sldb_create(struct share_context *ctx, const char *name, struct share_i
/* TODO: Security Descriptor */
- SHARE_ADD_STRING(SHARE_AVAILABLE, "True");
- SHARE_ADD_STRING(SHARE_BROWSEABLE, "True");
- SHARE_ADD_STRING(SHARE_READONLY, "False");
+ SHARE_ADD_STRING(SHARE_AVAILABLE, "true");
+ SHARE_ADD_STRING(SHARE_BROWSEABLE, "true");
+ SHARE_ADD_STRING(SHARE_READONLY, "false");
SHARE_ADD_STRING(SHARE_NTVFS_HANDLER, "unixuid");
SHARE_ADD_STRING(SHARE_NTVFS_HANDLER, "posix");
@@ -428,7 +429,7 @@ NTSTATUS sldb_set(struct share_context *ctx, const char *name, struct share_info
struct ldb_message *msg;
TALLOC_CTX *tmp_ctx;
NTSTATUS ret;
- bool do_rename = False;
+ bool do_rename = false;
char *newname;
int err, i;
@@ -462,7 +463,7 @@ NTSTATUS sldb_set(struct share_context *ctx, const char *name, struct share_info
for (i = 0; i < count; i++) {
if (strcasecmp(info[i].name, SHARE_NAME) == 0) {
if (strcasecmp(name, (char *)info[i].value) != 0) {
- do_rename = True;
+ do_rename = true;
newname = (char *)info[i].value;
SHARE_MOD_STRING("cn", (char *)info[i].value);
}
@@ -568,22 +569,21 @@ done:
return ret;
}
+static const struct share_ops ops = {
+ .name = "ldb",
+ .init = sldb_init,
+ .string_option = sldb_string_option,
+ .int_option = sldb_int_option,
+ .bool_option = sldb_bool_option,
+ .string_list_option = sldb_string_list_option,
+ .list_all = sldb_list_all,
+ .get_config = sldb_get_config,
+ .create = sldb_create,
+ .set = sldb_set,
+ .remove = sldb_remove
+};
+
NTSTATUS share_ldb_init(void)
{
- static struct share_ops ops = {
- .name = "ldb",
- .init = sldb_init,
- .string_option = sldb_string_option,
- .int_option = sldb_int_option,
- .bool_option = sldb_bool_option,
- .string_list_option = sldb_string_list_option,
- .list_all = sldb_list_all,
- .get_config = sldb_get_config,
- .create = sldb_create,
- .set = sldb_set,
- .remove = sldb_remove
- };
-
return share_register(&ops);
}
-
diff --git a/source4/param/util.c b/source4/param/util.c
index 6e6e12596b..8d59861f40 100644
--- a/source4/param/util.c
+++ b/source4/param/util.c
@@ -27,6 +27,7 @@
#include "system/network.h"
#include "system/filesys.h"
#include "system/dir.h"
+#include "param/param.h"
/**
* @file
@@ -34,34 +35,41 @@
*/
+_PUBLIC_ bool lp_is_mydomain(struct loadparm_context *lp_ctx,
+ const char *domain)
+{
+ return strequal(lp_workgroup(lp_ctx), domain);
+}
+
/**
see if a string matches either our primary or one of our secondary
netbios aliases. do a case insensitive match
*/
-_PUBLIC_ BOOL is_myname(const char *name)
+_PUBLIC_ bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name)
{
const char **aliases;
int i;
- if (strcasecmp(name, lp_netbios_name()) == 0) {
- return True;
+ if (strcasecmp(name, lp_netbios_name(lp_ctx)) == 0) {
+ return true;
}
- aliases = lp_netbios_aliases();
+ aliases = lp_netbios_aliases(lp_ctx);
for (i=0; aliases && aliases[i]; i++) {
if (strcasecmp(name, aliases[i]) == 0) {
- return True;
+ return true;
}
}
- return False;
+ return false;
}
/**
A useful function for returning a path in the Samba lock directory.
**/
-_PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, const char *name)
+_PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name)
{
char *fname, *dname;
if (name == NULL) {
@@ -71,7 +79,7 @@ _PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, const char *name)
return talloc_strdup(mem_ctx, name);
}
- dname = talloc_strdup(mem_ctx, lp_lockdir());
+ dname = talloc_strdup(mem_ctx, lp_lockdir(lp_ctx));
trim_string(dname,"","/");
if (!directory_exist(dname)) {
@@ -85,44 +93,6 @@ _PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, const char *name)
return fname;
}
-
-/**
- A useful function for returning a path in the Samba piddir directory.
-**/
-static char *pid_path(TALLOC_CTX* mem_ctx, const char *name)
-{
- char *fname, *dname;
-
- dname = talloc_strdup(mem_ctx, lp_piddir());
- trim_string(dname,"","/");
-
- if (!directory_exist(dname)) {
- mkdir(dname,0755);
- }
-
- fname = talloc_asprintf(mem_ctx, "%s/%s", dname, name);
-
- talloc_free(dname);
-
- return fname;
-}
-
-
-/**
- * @brief Returns an absolute path to a file in the Samba lib directory.
- *
- * @param name File to find, relative to DATADIR.
- *
- * @retval Pointer to a talloc'ed string containing the full path.
- **/
-
-_PUBLIC_ char *data_path(TALLOC_CTX* mem_ctx, const char *name)
-{
- char *fname;
- fname = talloc_asprintf(mem_ctx, "%s/%s", dyn_DATADIR, name);
- return fname;
-}
-
/**
* @brief Returns an absolute path to a file in the directory containing the current config file
*
@@ -131,10 +101,11 @@ _PUBLIC_ char *data_path(TALLOC_CTX* mem_ctx, const char *name)
* @retval Pointer to a talloc'ed string containing the full path.
**/
-_PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, const char *name)
+_PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name)
{
char *fname, *config_dir, *p;
- config_dir = talloc_strdup(mem_ctx, lp_configfile());
+ config_dir = talloc_strdup(mem_ctx, lp_configfile(lp_ctx));
p = strrchr(config_dir, '/');
if (!p) {
return NULL;
@@ -153,7 +124,9 @@ _PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, const char *name)
*
* @retval Pointer to a talloc'ed string containing the full path.
**/
-_PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, const char *name)
+_PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *name)
{
char *fname;
if (name == NULL) {
@@ -162,7 +135,7 @@ _PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, const char *name)
if (name[0] == 0 || name[0] == '/' || strstr(name, ":/")) {
return talloc_strdup(mem_ctx, name);
}
- fname = talloc_asprintf(mem_ctx, "%s/%s", lp_private_dir(), name);
+ fname = talloc_asprintf(mem_ctx, "%s/%s", lp_private_dir(lp_ctx), name);
return fname;
}
@@ -171,11 +144,13 @@ _PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, const char *name)
for smbd go. If NULL is passed for name then return the directory
path itself
*/
-_PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name)
+_PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *name)
{
char *fname, *dname;
- dname = pid_path(mem_ctx, "smbd.tmp");
+ dname = private_path(mem_ctx, lp_ctx, "smbd.tmp");
if (!directory_exist(dname)) {
mkdir(dname,0755);
}
@@ -275,12 +250,13 @@ _PUBLIC_ bool run_init_functions(init_module_fn *fns)
return ret;
}
-static char *modules_path(TALLOC_CTX* mem_ctx, const char *name)
+static char *modules_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name)
{
const char *env_moduledir = getenv("LD_SAMBA_MODULE_PATH");
return talloc_asprintf(mem_ctx, "%s/%s",
- env_moduledir?env_moduledir:lp_modulesdir(),
- name);
+ env_moduledir?env_moduledir:lp_modulesdir(lp_ctx),
+ name);
}
/**
@@ -289,9 +265,9 @@ static char *modules_path(TALLOC_CTX* mem_ctx, const char *name)
* Will return an array of function pointers to initialization functions
*/
-_PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem)
+_PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem)
{
- char *path = modules_path(mem_ctx, subsystem);
+ char *path = modules_path(mem_ctx, lp_ctx, subsystem);
init_module_fn *ret;
ret = load_modules(mem_ctx, path);
@@ -301,4 +277,9 @@ _PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *sub
return ret;
}
+_PUBLIC_ const char *lp_messaging_path(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx)
+{
+ return smbd_tmp_path(mem_ctx, lp_ctx, "messaging");
+}
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm
index 11fdbb2390..f624d2bdc0 100644
--- a/source4/pidl/lib/Parse/Pidl/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/NDR.pm
@@ -35,7 +35,7 @@ use vars qw($VERSION);
$VERSION = '0.01';
@ISA = qw(Exporter);
@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
-@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar ParseType);
+@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar ParseType can_contain_deferred);
use strict;
use Parse::Pidl qw(warning fatal);
@@ -264,7 +264,7 @@ sub GetElementLevelTable($)
TYPE => "DATA",
DATA_TYPE => $e->{TYPE},
IS_DEFERRED => $is_deferred,
- CONTAINS_DEFERRED => can_contain_deferred($e),
+ CONTAINS_DEFERRED => can_contain_deferred($e->{TYPE}),
IS_SURROUNDING => 0 #FIXME
});
@@ -279,18 +279,23 @@ sub GetElementLevelTable($)
sub can_contain_deferred($)
{
sub can_contain_deferred($);
- my $e = shift;
+ my ($type) = @_;
+
+ return 1 unless (hasType($type)); # assume the worst
- return 0 if (Parse::Pidl::Typelist::is_scalar($e->{TYPE}));
- return 1 unless (hasType($e->{TYPE})); # assume the worst
+ $type = getType($type);
- my $type = getType($e->{TYPE});
+ return 0 if (Parse::Pidl::Typelist::is_scalar($type));
return 1 if ($type->{TYPE} eq "DECLARE"); # assume the worst
- foreach my $x (@{$type->{DATA}->{ELEMENTS}}) {
- return 1 if ($x->{POINTERS});
- return 1 if (can_contain_deferred ($x));
+ return can_contain_deferred($type->{DATA}) if ($type->{TYPE} eq "TYPEDEF");
+
+ return 0 unless defined($type->{ELEMENTS});
+
+ foreach (@{$type->{ELEMENTS}}) {
+ return 1 if ($_->{POINTERS});
+ return 1 if (can_contain_deferred ($_->{TYPE}));
}
return 0;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm
index 75d4c235cb..7a6ffa46d6 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm
@@ -10,7 +10,7 @@ use strict;
use Parse::Pidl qw(fatal);
use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
use Parse::Pidl::Util qw(has_property is_constant unmake_str);
-use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets);
+use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets choose_header);
use vars qw($VERSION);
$VERSION = '0.01';
@@ -326,7 +326,7 @@ sub HeaderImport
foreach (@imports) {
s/\.idl\"$//;
s/^\"//;
- pidl "#include \"librpc/gen_ndr/$_\.h\"\n";
+ pidl choose_header("librpc/gen_ndr/$_\.h", "gen_ndr/$_.h") . "\n";
}
}
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
index cf14b645a9..e9c158e933 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
@@ -109,7 +109,7 @@ sub Parse($$$$)
$res .= "#include <stdlib.h>\n";
$res .= "#include <stdint.h>\n";
$res .= "#include <stdarg.h>\n";
- $res .= "#include <core/nterr.h>\n";
+ $res .= "#include <core/ntstatus.h>\n";
}
$res .= "#include \"$ndr_header\"\n";
$res .= "#include \"$client_header\"\n";
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 9a29b72c1d..cd3981bb28 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -2597,7 +2597,7 @@ sub GenerateIncludes($)
# Samba3 has everything in include/includes.h
if (is_intree() != 3) {
- $self->pidl(choose_header("libcli/util/nterr.h", "core/nterr.h"));
+ $self->pidl(choose_header("libcli/util/ntstatus.h", "core/ntstatus.h"));
$self->pidl(choose_header("librpc/gen_ndr/ndr_misc.h", "gen_ndr/ndr_misc.h"));
}
}
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
index b6980acc0f..ed17fcc0da 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
@@ -111,7 +111,10 @@ static NTSTATUS $name\__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_C
return NT_STATUS_NET_WRITE_FAULT;
}
- *r = talloc_size(mem_ctx, ndr_table_$name.calls[opnum].struct_size);
+ *r = talloc_named(mem_ctx,
+ ndr_table_$name.calls[opnum].struct_size,
+ \"struct %s\",
+ ndr_table_$name.calls[opnum].name);
NT_STATUS_HAVE_NO_MEMORY(*r);
/* unravel the NDR for the packet */
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm b/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm
index 832a2c5463..568dff5adf 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm
@@ -265,7 +265,7 @@ sub Parser($$$$)
$self->pidl("#include <stdint.h>");
$self->pidl("#include <stdarg.h>");
$self->pidl("#include <string.h>");
- $self->pidl("#include <core/nterr.h>");
+ $self->pidl("#include <core/ntstatus.h>");
}
$self->pidl("#include \"$hdrname\"");
$self->pidl("");
diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl
index 043d2b9905..1512f19d52 100755
--- a/source4/pidl/tests/ndr.pl
+++ b/source4/pidl/tests/ndr.pl
@@ -4,12 +4,12 @@
use strict;
use warnings;
-use Test::More tests => 27;
+use Test::More tests => 34;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type mapToScalar ParseType);
+use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type mapToScalar ParseType can_contain_deferred);
# Case 1
@@ -253,3 +253,18 @@ $t = {
}
};
is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t);
+
+ok(not can_contain_deferred("uint32"));
+ok(can_contain_deferred("some_unknown_type"));
+ok(can_contain_deferred({ TYPE => "STRUCT",
+ ELEMENTS => [ { TYPE => "uint32", POINTERS => 40 } ]}));
+ok(can_contain_deferred({ TYPE => "TYPEDEF",
+ DATA => { TYPE => "STRUCT",
+ ELEMENTS => [ { TYPE => "uint32", POINTERS => 40 } ]}}));
+ok(not can_contain_deferred({ TYPE => "STRUCT",
+ ELEMENTS => [ { TYPE => "uint32" } ]}));
+ok(not can_contain_deferred({ TYPE => "TYPEDEF",
+ DATA => { TYPE => "STRUCT",
+ ELEMENTS => [ { TYPE => "uint32" } ]}}));
+ok(can_contain_deferred({ TYPE => "STRUCT",
+ ELEMENTS => [ { TYPE => "someunknowntype" } ]}));
diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl
index 52cd06f817..84feeeb9ff 100755
--- a/source4/pidl/tests/ndr_represent.pl
+++ b/source4/pidl/tests/ndr_represent.pl
@@ -25,7 +25,7 @@ test_samba4_ndr('represent_as-simple',
return 2;
',
'
-#include <libcli/util/nterr.h>
+#include <libcli/util/ntstatus.h>
NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
{
@@ -58,7 +58,7 @@ test_samba4_ndr('transmit_as-simple',
return 2;
',
'
-#include <libcli/util/nterr.h>
+#include <libcli/util/ntstatus.h>
NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
{
diff --git a/source4/rpc_server/common/server_info.c b/source4/rpc_server/common/server_info.c
index ccd2bdbad4..c6f93f076a 100644
--- a/source4/rpc_server/common/server_info.c
+++ b/source4/rpc_server/common/server_info.c
@@ -25,6 +25,7 @@
#include "rpc_server/dcerpc_server.h"
#include "dsdb/samdb/samdb.h"
#include "auth/auth.h"
+#include "param/param.h"
/*
Here are common server info functions used by some dcerpc server interfaces
@@ -35,7 +36,7 @@ _PUBLIC_ enum srvsvc_PlatformId dcesrv_common_get_platform_id(TALLOC_CTX *mem_ct
{
enum srvsvc_PlatformId id;
- id = lp_parm_int(-1, "server_info", "platform_id", PLATFORM_ID_NT);
+ id = lp_parm_int(global_loadparm, NULL, "server_info", "platform_id", PLATFORM_ID_NT);
return id;
}
@@ -46,7 +47,7 @@ _PUBLIC_ const char *dcesrv_common_get_server_name(TALLOC_CTX *mem_ctx, struct d
/* if there's no string return our NETBIOS name */
if (!p) {
- return talloc_strdup(mem_ctx, lp_netbios_name());
+ return talloc_strdup(mem_ctx, lp_netbios_name(global_loadparm));
}
/* if there're '\\\\' in front remove them otherwise just pass the string */
@@ -59,25 +60,25 @@ _PUBLIC_ const char *dcesrv_common_get_server_name(TALLOC_CTX *mem_ctx, struct d
const char *dcesrv_common_get_domain_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
{
- return talloc_strdup(mem_ctx, lp_workgroup());
+ return talloc_strdup(mem_ctx, lp_workgroup(global_loadparm));
}
/* This hardcoded value should go into a ldb database! */
_PUBLIC_ uint32_t dcesrv_common_get_version_major(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
{
- return lp_parm_int(-1, "server_info", "version_major", 5);
+ return lp_parm_int(global_loadparm, NULL, "server_info", "version_major", 5);
}
/* This hardcoded value should go into a ldb database! */
_PUBLIC_ uint32_t dcesrv_common_get_version_minor(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
{
- return lp_parm_int(-1, "server_info", "version_minor", 2);
+ return lp_parm_int(global_loadparm, NULL, "server_info", "version_minor", 2);
}
/* This hardcoded value should go into a ldb database! */
_PUBLIC_ uint32_t dcesrv_common_get_version_build(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
{
- return lp_parm_int(-1, "server_info", "version_build", 3790);
+ return lp_parm_int(global_loadparm, NULL, "server_info", "version_build", 3790);
}
/* This hardcoded value should go into a ldb database! */
@@ -88,7 +89,7 @@ _PUBLIC_ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dces
default_server_announce |= SV_TYPE_SERVER;
default_server_announce |= SV_TYPE_SERVER_UNIX;
- switch (lp_announce_as()) {
+ switch (lp_announce_as(global_loadparm)) {
case ANNOUNCE_AS_NT_SERVER:
default_server_announce |= SV_TYPE_SERVER_NT;
/* fall through... */
@@ -105,7 +106,7 @@ _PUBLIC_ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dces
break;
}
- switch (lp_server_role()) {
+ switch (lp_server_role(global_loadparm)) {
case ROLE_DOMAIN_MEMBER:
default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
break;
@@ -122,7 +123,7 @@ _PUBLIC_ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dces
DEBUG(2,("Unable to open samdb in determining server announce flags\n"));
} else {
/* Determine if we are the pdc */
- BOOL is_pdc = samdb_is_pdc(samctx);
+ bool is_pdc = samdb_is_pdc(samctx);
if (is_pdc) {
default_server_announce |= SV_TYPE_DOMAIN_CTRL;
} else {
@@ -137,17 +138,17 @@ _PUBLIC_ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dces
default:
break;
}
- if (lp_time_server())
+ if (lp_time_server(global_loadparm))
default_server_announce |= SV_TYPE_TIME_SOURCE;
- if (lp_host_msdfs())
+ if (lp_host_msdfs(global_loadparm))
default_server_announce |= SV_TYPE_DFS_SERVER;
#if 0
{
/* TODO: announce us as print server when we are a print server */
- BOOL is_print_server = False;
+ bool is_print_server = false;
if (is_print_server) {
default_server_announce |= SV_TYPE_PRINTQ_SERVER;
}
@@ -209,8 +210,8 @@ _PUBLIC_ const char *dcesrv_common_get_userpath(TALLOC_CTX *mem_ctx, struct dces
_PUBLIC_ bool dcesrv_common_validate_share_name(TALLOC_CTX *mem_ctx, const char *share_name)
{
if (strpbrk(share_name, INVALID_SHARE_NAME_CHARS)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk
index 0de09b572e..1269dcc707 100644
--- a/source4/rpc_server/config.mk
+++ b/source4/rpc_server/config.mk
@@ -135,8 +135,11 @@ PRIVATE_DEPENDENCIES = \
[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/dcesrv_lsa.o \
+ lsa/lsa_init.o \
+ lsa/lsa_lookup.o
PRIVATE_DEPENDENCIES = \
SAMDB \
DCERPC_COMMON \
@@ -157,7 +160,8 @@ OBJ_FILES = \
PRIVATE_DEPENDENCIES = \
DCERPC_COMMON \
NDR_SPOOLSS \
- ntptr
+ ntptr \
+ RPC_NDR_SPOOLSS
# End MODULE dcerpc_spoolss
################################################
@@ -182,7 +186,6 @@ PUBLIC_HEADERS = dcerpc_server.h
PUBLIC_PROTO_HEADER = dcerpc_server_proto.h
OBJ_FILES = \
dcerpc_server.o \
- dcerpc_sock.o \
dcesrv_auth.o \
dcesrv_mgmt.o \
handles.o
@@ -196,5 +199,6 @@ PRIVATE_DEPENDENCIES = \
[MODULE::DCESRV]
INIT_FUNCTION = server_service_rpc_init
+OBJ_FILES = service_rpc.o
SUBSYSTEM = service
PRIVATE_DEPENDENCIES = dcerpc_server
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index 35b37b3af6..4388c86f22 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -33,17 +33,18 @@
#include "system/filesys.h"
#include "libcli/security/security.h"
#include "build.h"
+#include "param/param.h"
extern const struct dcesrv_interface dcesrv_mgmt_interface;
/*
see if two endpoints match
*/
-static BOOL endpoints_match(const struct dcerpc_binding *ep1,
+static bool endpoints_match(const struct dcerpc_binding *ep1,
const struct dcerpc_binding *ep2)
{
if (ep1->transport != ep2->transport) {
- return False;
+ return false;
}
if (!ep1->endpoint || !ep2->endpoint) {
@@ -51,9 +52,9 @@ static BOOL endpoints_match(const struct dcerpc_binding *ep1,
}
if (strcasecmp(ep1->endpoint, ep2->endpoint) != 0)
- return False;
+ return false;
- return True;
+ return true;
}
/*
@@ -87,7 +88,7 @@ static struct dcesrv_connection_context *dcesrv_find_context(struct dcesrv_conne
/*
see if a uuid and if_version match to an interface
*/
-static BOOL interface_match(const struct dcesrv_interface *if1,
+static bool interface_match(const struct dcesrv_interface *if1,
const struct dcesrv_interface *if2)
{
return (if1->syntax_id.if_version == if2->syntax_id.if_version &&
@@ -112,7 +113,7 @@ static const struct dcesrv_interface *find_interface(const struct dcesrv_endpoin
/*
see if a uuid and if_version match to an interface
*/
-static BOOL interface_match_by_uuid(const struct dcesrv_interface *iface,
+static bool interface_match_by_uuid(const struct dcesrv_interface *iface,
const struct GUID *uuid, uint32_t if_version)
{
return (iface->syntax_id.if_version == if_version &&
@@ -159,7 +160,7 @@ _PUBLIC_ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
struct dcesrv_endpoint *ep;
struct dcesrv_if_list *ifl;
struct dcerpc_binding *binding;
- BOOL add_ep = False;
+ bool add_ep = false;
NTSTATUS status;
status = dcerpc_parse_binding(dce_ctx, ep_name, &binding);
@@ -178,7 +179,7 @@ _PUBLIC_ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
}
ZERO_STRUCTP(ep);
ep->ep_description = talloc_reference(ep, binding);
- add_ep = True;
+ add_ep = true;
/* add mgmt interface */
ifl = talloc(dce_ctx, struct dcesrv_if_list);
@@ -337,7 +338,7 @@ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
p->event_ctx = event_ctx;
p->msg_ctx = msg_ctx;
p->server_id = server_id;
- p->processing = False;
+ p->processing = false;
p->state_flags = state_flags;
ZERO_STRUCT(p->transport);
@@ -389,7 +390,7 @@ static void dcesrv_init_hdr(struct ncacn_packet *pkt)
{
pkt->rpc_vers = 5;
pkt->rpc_vers_minor = 0;
- if (lp_rpc_big_endian()) {
+ if (lp_rpc_big_endian(global_loadparm)) {
pkt->drep[0] = 0;
} else {
pkt->drep[0] = DCERPC_DREP_LE;
@@ -891,7 +892,7 @@ _PUBLIC_ NTSTATUS dcesrv_reply(struct dcesrv_call_state *call)
pointers */
push->ptr_count = call->ndr_pull->ptr_count;
- if (lp_rpc_big_endian()) {
+ if (lp_rpc_big_endian(global_loadparm)) {
push->flags |= LIBNDR_FLAG_BIGENDIAN;
}
@@ -982,15 +983,15 @@ _PUBLIC_ struct socket_address *dcesrv_connection_get_peer_addr(struct dcesrv_co
/*
work out if we have a full packet yet
*/
-static BOOL dce_full_packet(const DATA_BLOB *data)
+static bool dce_full_packet(const DATA_BLOB *data)
{
if (data->length < DCERPC_FRAG_LEN_OFFSET+2) {
- return False;
+ return false;
}
if (dcerpc_get_frag_length(data) > data->length) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
@@ -1246,7 +1247,7 @@ _PUBLIC_ NTSTATUS dcesrv_output(struct dcesrv_connection *dce_conn,
return status;
}
-static NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx, const char **endpoint_servers, struct dcesrv_context **_dce_ctx)
+_PUBLIC_ NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx, const char **endpoint_servers, struct dcesrv_context **_dce_ctx)
{
NTSTATUS status;
struct dcesrv_context *dce_ctx;
@@ -1282,21 +1283,6 @@ static NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx, const char **endpoint_s
return NT_STATUS_OK;
}
-/*
- initialise the dcerpc server context for ncacn_np based services
-*/
-_PUBLIC_ NTSTATUS dcesrv_init_ipc_context(TALLOC_CTX *mem_ctx, struct dcesrv_context **_dce_ctx)
-{
- NTSTATUS status;
- struct dcesrv_context *dce_ctx;
-
- status = dcesrv_init_context(mem_ctx, lp_dcerpc_endpoint_servers(), &dce_ctx);
- NT_STATUS_NOT_OK_RETURN(status);
-
- *_dce_ctx = dce_ctx;
- return NT_STATUS_OK;
-}
-
/* the list of currently registered DCERPC endpoint servers.
*/
static struct ep_server {
@@ -1379,78 +1365,18 @@ const struct dcesrv_critical_sizes *dcerpc_module_version(void)
}
/*
- open the dcerpc server sockets
+ initialise the dcerpc server context for ncacn_np based services
*/
-static void dcesrv_task_init(struct task_server *task)
+_PUBLIC_ NTSTATUS dcesrv_init_ipc_context(TALLOC_CTX *mem_ctx, struct dcesrv_context **_dce_ctx)
{
NTSTATUS status;
struct dcesrv_context *dce_ctx;
- struct dcesrv_endpoint *e;
-
- task_server_set_title(task, "task[dcesrv]");
- status = dcesrv_init_context(task->event_ctx,
- lp_dcerpc_endpoint_servers(),
- &dce_ctx);
- if (!NT_STATUS_IS_OK(status)) goto failed;
-
- /* Make sure the directory for NCALRPC exists */
- if (!directory_exist(lp_ncalrpc_dir())) {
- mkdir(lp_ncalrpc_dir(), 0755);
- }
-
- for (e=dce_ctx->endpoint_list;e;e=e->next) {
- switch (e->ep_description->transport) {
- case NCACN_UNIX_STREAM:
- status = dcesrv_add_ep_unix(dce_ctx, e, task->event_ctx, task->model_ops);
- if (!NT_STATUS_IS_OK(status)) goto failed;
- break;
-
- case NCALRPC:
- status = dcesrv_add_ep_ncalrpc(dce_ctx, e, task->event_ctx, task->model_ops);
- if (!NT_STATUS_IS_OK(status)) goto failed;
- break;
-
- case NCACN_IP_TCP:
- status = dcesrv_add_ep_tcp(dce_ctx, e, task->event_ctx, task->model_ops);
- if (!NT_STATUS_IS_OK(status)) goto failed;
- break;
-
- case NCACN_NP:
- status = dcesrv_add_ep_np(dce_ctx, e, task->event_ctx, task->model_ops);
- if (!NT_STATUS_IS_OK(status)) goto failed;
- break;
-
- default:
- status = NT_STATUS_NOT_SUPPORTED;
- if (!NT_STATUS_IS_OK(status)) goto failed;
- }
- }
-
- return;
-failed:
- task_server_terminate(task, "Failed to startup dcerpc server task");
-}
+ status = dcesrv_init_context(mem_ctx, lp_dcerpc_endpoint_servers(global_loadparm), &dce_ctx);
+ NT_STATUS_NOT_OK_RETURN(status);
-/*
- called on startup of the smb server service It's job is to start
- listening on all configured sockets
-*/
-static NTSTATUS dcesrv_init(struct event_context *event_context,
- const struct model_ops *model_ops)
-{
- return task_server_startup(event_context, model_ops, dcesrv_task_init);
+ *_dce_ctx = dce_ctx;
+ return NT_STATUS_OK;
}
-NTSTATUS server_service_rpc_init(void)
-{
- init_module_fn static_init[] = STATIC_dcerpc_server_MODULES;
- init_module_fn *shared_init = load_samba_modules(NULL, "dcerpc_server");
-
- run_init_functions(static_init);
- run_init_functions(shared_init);
- talloc_free(shared_init);
-
- return register_server_service("rpc", dcesrv_init);
-}
diff --git a/source4/rpc_server/dcesrv_auth.c b/source4/rpc_server/dcesrv_auth.c
index 49a4c3de13..911cfe4799 100644
--- a/source4/rpc_server/dcesrv_auth.c
+++ b/source4/rpc_server/dcesrv_auth.c
@@ -25,13 +25,14 @@
#include "librpc/gen_ndr/ndr_dcerpc.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
/*
parse any auth information from a dcerpc bind request
- return False if we can't handle the auth request for some
+ return false if we can't handle the auth request for some
reason (in which case we send a bind_nak)
*/
-BOOL dcesrv_auth_bind(struct dcesrv_call_state *call)
+bool dcesrv_auth_bind(struct dcesrv_call_state *call)
{
struct cli_credentials *server_credentials;
struct ncacn_packet *pkt = &call->pkt;
@@ -41,12 +42,12 @@ BOOL dcesrv_auth_bind(struct dcesrv_call_state *call)
if (pkt->u.bind.auth_info.length == 0) {
dce_conn->auth_state.auth_info = NULL;
- return True;
+ return true;
}
dce_conn->auth_state.auth_info = talloc(dce_conn, struct dcerpc_auth);
if (!dce_conn->auth_state.auth_info) {
- return False;
+ return false;
}
status = ndr_pull_struct_blob(&pkt->u.bind.auth_info,
@@ -54,23 +55,23 @@ BOOL dcesrv_auth_bind(struct dcesrv_call_state *call)
dce_conn->auth_state.auth_info,
(ndr_pull_flags_fn_t)ndr_pull_dcerpc_auth);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
status = gensec_server_start(dce_conn, call->event_ctx, call->msg_ctx, &auth->gensec_security);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to start GENSEC for DCERPC server: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
server_credentials
= cli_credentials_init(call);
if (!server_credentials) {
DEBUG(1, ("Failed to init server credentials\n"));
- return False;
+ return false;
}
- cli_credentials_set_conf(server_credentials);
+ cli_credentials_set_conf(server_credentials, global_loadparm);
status = cli_credentials_set_machine_account(server_credentials);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(status)));
@@ -88,10 +89,10 @@ BOOL dcesrv_auth_bind(struct dcesrv_call_state *call)
(int)auth->auth_info->auth_type,
(int)auth->auth_info->auth_level,
nt_errstr(status)));
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
@@ -137,7 +138,7 @@ NTSTATUS dcesrv_auth_bind_ack(struct dcesrv_call_state *call, struct ncacn_packe
/*
process the final stage of a auth request
*/
-BOOL dcesrv_auth_auth3(struct dcesrv_call_state *call)
+bool dcesrv_auth_auth3(struct dcesrv_call_state *call)
{
struct ncacn_packet *pkt = &call->pkt;
struct dcesrv_connection *dce_conn = call->conn;
@@ -147,7 +148,7 @@ BOOL dcesrv_auth_auth3(struct dcesrv_call_state *call)
if (!dce_conn->auth_state.auth_info ||
!dce_conn->auth_state.gensec_security ||
pkt->u.auth3.auth_info.length == 0) {
- return False;
+ return false;
}
status = ndr_pull_struct_blob(&pkt->u.auth3.auth_info,
@@ -155,7 +156,7 @@ BOOL dcesrv_auth_auth3(struct dcesrv_call_state *call)
dce_conn->auth_state.auth_info,
(ndr_pull_flags_fn_t)ndr_pull_dcerpc_auth);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
/* Pass the extra data we got from the client down to gensec for processing */
@@ -168,26 +169,26 @@ BOOL dcesrv_auth_auth3(struct dcesrv_call_state *call)
&dce_conn->auth_state.session_info);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to establish session_info: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
/* Now that we are authenticated, go back to the generic session key... */
dce_conn->auth_state.session_key = dcesrv_generic_session_key;
- return True;
+ return true;
} else {
DEBUG(4, ("dcesrv_auth_auth3: failed to authenticate: %s\n",
nt_errstr(status)));
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
parse any auth information from a dcerpc alter request
- return False if we can't handle the auth request for some
+ return false if we can't handle the auth request for some
reason (in which case we send a bind_nak (is this true for here?))
*/
-BOOL dcesrv_auth_alter(struct dcesrv_call_state *call)
+bool dcesrv_auth_alter(struct dcesrv_call_state *call)
{
struct ncacn_packet *pkt = &call->pkt;
struct dcesrv_connection *dce_conn = call->conn;
@@ -195,17 +196,17 @@ BOOL dcesrv_auth_alter(struct dcesrv_call_state *call)
/* on a pure interface change there is no auth blob */
if (pkt->u.alter.auth_info.length == 0) {
- return True;
+ return true;
}
/* We can't work without an existing gensec state */
if (!dce_conn->auth_state.gensec_security) {
- return False;
+ return false;
}
dce_conn->auth_state.auth_info = talloc(dce_conn, struct dcerpc_auth);
if (!dce_conn->auth_state.auth_info) {
- return False;
+ return false;
}
status = ndr_pull_struct_blob(&pkt->u.alter.auth_info,
@@ -213,10 +214,10 @@ BOOL dcesrv_auth_alter(struct dcesrv_call_state *call)
dce_conn->auth_state.auth_info,
(ndr_pull_flags_fn_t)ndr_pull_dcerpc_auth);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
@@ -295,7 +296,7 @@ static NTSTATUS dcesrv_check_connect_verifier(DATA_BLOB *blob)
/*
check credentials on a request
*/
-BOOL dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet)
+bool dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet)
{
struct ncacn_packet *pkt = &call->pkt;
struct dcesrv_connection *dce_conn = call->conn;
@@ -306,14 +307,14 @@ BOOL dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet)
if (!dce_conn->auth_state.auth_info ||
!dce_conn->auth_state.gensec_security) {
- return True;
+ return true;
}
auth_blob.length = 8 + pkt->auth_length;
/* check for a valid length */
if (pkt->u.request.stub_and_verifier.length < auth_blob.length) {
- return False;
+ return false;
}
auth_blob.data =
@@ -324,7 +325,7 @@ BOOL dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet)
/* pull the auth structure */
ndr = ndr_pull_init_blob(&auth_blob, call);
if (!ndr) {
- return False;
+ return false;
}
if (!(pkt->drep[0] & DCERPC_DREP_LE)) {
@@ -334,7 +335,7 @@ BOOL dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet)
status = ndr_pull_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, &auth);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(ndr);
- return False;
+ return false;
}
/* check signature or unseal the packet */
@@ -374,7 +375,7 @@ BOOL dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet)
/* remove the indicated amount of padding */
if (pkt->u.request.stub_and_verifier.length < auth.auth_pad_length) {
talloc_free(ndr);
- return False;
+ return false;
}
pkt->u.request.stub_and_verifier.length -= auth.auth_pad_length;
talloc_free(ndr);
@@ -386,7 +387,7 @@ BOOL dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet)
/*
push a signed or sealed dcerpc request packet into a blob
*/
-BOOL dcesrv_auth_response(struct dcesrv_call_state *call,
+bool dcesrv_auth_response(struct dcesrv_call_state *call,
DATA_BLOB *blob, struct ncacn_packet *pkt)
{
struct dcesrv_connection *dce_conn = call->conn;
@@ -403,7 +404,7 @@ BOOL dcesrv_auth_response(struct dcesrv_call_state *call,
ndr = ndr_push_init_ctx(call);
if (!ndr) {
- return False;
+ return false;
}
if (!(pkt->drep[0] & DCERPC_DREP_LE)) {
@@ -412,7 +413,7 @@ BOOL dcesrv_auth_response(struct dcesrv_call_state *call,
status = ndr_push_ncacn_packet(ndr, NDR_SCALARS|NDR_BUFFERS, pkt);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
/* pad to 16 byte multiple, match win2k3 */
@@ -425,7 +426,7 @@ BOOL dcesrv_auth_response(struct dcesrv_call_state *call,
status = dcesrv_connect_verifier(call,
&dce_conn->auth_state.auth_info->credentials);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
} else {
@@ -443,7 +444,7 @@ BOOL dcesrv_auth_response(struct dcesrv_call_state *call,
status = ndr_push_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS,
dce_conn->auth_state.auth_info);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
/* extract the whole packet as a blob */
@@ -518,8 +519,8 @@ BOOL dcesrv_auth_response(struct dcesrv_call_state *call,
data_blob_free(&dce_conn->auth_state.auth_info->credentials);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
index 0c22e856f2..d8b361ca27 100644
--- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
+++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
@@ -589,7 +589,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
return WERR_GENERAL_FAILURE;
}
if (res_domain->count == 1) {
- ctr1->array[i].is_pdc = True;
+ ctr1->array[i].is_pdc = true;
}
}
}
@@ -603,7 +603,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
ctr1->array[i].server_dn = ldb_dn_get_linearized(res->msgs[i]->dn);
- ctr1->array[i].is_enabled = True;
+ ctr1->array[i].is_enabled = true;
}
break;
@@ -681,7 +681,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
LDB_SCOPE_BASE, attrs_none, "fSMORoleOwner=%s",
ldb_dn_get_linearized(ntds_dn));
if (ret == LDB_SUCCESS && res_domain->count == 1) {
- ctr2->array[i].is_pdc = True;
+ ctr2->array[i].is_pdc = true;
}
if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
DEBUG(5, ("warning: searching for domain DN %s failed: %s\n",
@@ -700,7 +700,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
ctr2->array[i].server_guid
= samdb_result_guid(res->msgs[i], "objectGUID");
- ctr2->array[i].is_enabled = True;
+ ctr2->array[i].is_enabled = true;
}
break;
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index 531cfc49e5..25d6f8c8f7 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -4,7 +4,7 @@
endpoint server for the lsarpc pipe
Copyright (C) Andrew Tridgell 2004
- Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-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
@@ -20,50 +20,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "includes.h"
-#include "rpc_server/dcerpc_server.h"
-#include "rpc_server/common/common.h"
-#include "auth/auth.h"
-#include "dsdb/samdb/samdb.h"
-#include "libcli/ldap/ldap.h"
-#include "lib/ldb/include/ldb_errors.h"
-#include "libcli/security/security.h"
-#include "libcli/auth/libcli_auth.h"
-#include "param/secrets.h"
-#include "db_wrap.h"
-#include "librpc/gen_ndr/ndr_dssetup.h"
+#include "rpc_server/lsa/lsa.h"
/*
this type allows us to distinguish handle types
*/
-enum lsa_handle {
- LSA_HANDLE_POLICY,
- LSA_HANDLE_ACCOUNT,
- LSA_HANDLE_SECRET,
- LSA_HANDLE_TRUSTED_DOMAIN
-};
-
-/*
- state associated with a lsa_OpenPolicy() operation
-*/
-struct lsa_policy_state {
- struct dcesrv_handle *handle;
- struct ldb_context *sam_ldb;
- struct sidmap_context *sidmap;
- uint32_t access_mask;
- struct ldb_dn *domain_dn;
- struct ldb_dn *forest_dn;
- struct ldb_dn *builtin_dn;
- struct ldb_dn *system_dn;
- const char *domain_name;
- const char *domain_dns;
- const char *forest_dns;
- struct dom_sid *domain_sid;
- struct GUID domain_guid;
- struct dom_sid *builtin_sid;
- int mixed_domain;
-};
-
/*
state associated with a lsa_OpenAccount() operation
@@ -83,7 +44,7 @@ struct lsa_secret_state {
uint32_t access_mask;
struct ldb_dn *secret_dn;
struct ldb_context *sam_ldb;
- BOOL global;
+ bool global;
};
/*
@@ -268,162 +229,6 @@ static NTSTATUS dcesrv_lsa_ChangePassword(struct dcesrv_call_state *dce_call, TA
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
-static NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct lsa_policy_state **_state)
-{
- struct lsa_policy_state *state;
- struct ldb_dn *partitions_basedn;
- struct ldb_result *dom_res;
- const char *dom_attrs[] = {
- "objectSid",
- "objectGUID",
- "nTMixedDomain",
- "fSMORoleOwner",
- NULL
- };
- struct ldb_result *ref_res;
- struct ldb_result *forest_ref_res;
- const char *ref_attrs[] = {
- "nETBIOSName",
- "dnsRoot",
- NULL
- };
- int ret;
-
- state = talloc(mem_ctx, struct lsa_policy_state);
- if (!state) {
- return NT_STATUS_NO_MEMORY;
- }
-
- /* make sure the sam database is accessible */
- state->sam_ldb = samdb_connect(state, dce_call->conn->auth_state.session_info);
- if (state->sam_ldb == NULL) {
- return NT_STATUS_INVALID_SYSTEM_SERVICE;
- }
-
- partitions_basedn = samdb_partitions_dn(state->sam_ldb, mem_ctx);
-
- state->sidmap = sidmap_open(state);
- if (state->sidmap == NULL) {
- return NT_STATUS_INVALID_SYSTEM_SERVICE;
- }
-
- /* work out the domain_dn - useful for so many calls its worth
- fetching here */
- state->domain_dn = samdb_base_dn(state->sam_ldb);
- if (!state->domain_dn) {
- return NT_STATUS_NO_MEMORY;
- }
-
- /* work out the forest root_dn - useful for so many calls its worth
- fetching here */
- state->forest_dn = samdb_root_dn(state->sam_ldb);
- if (!state->forest_dn) {
- return NT_STATUS_NO_MEMORY;
- }
-
- ret = ldb_search(state->sam_ldb, state->domain_dn, LDB_SCOPE_BASE, NULL, dom_attrs, &dom_res);
-
- if (ret != LDB_SUCCESS) {
- return NT_STATUS_INVALID_SYSTEM_SERVICE;
- }
- talloc_steal(mem_ctx, dom_res);
- if (dom_res->count != 1) {
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
-
- state->domain_sid = samdb_result_dom_sid(state, dom_res->msgs[0], "objectSid");
- if (!state->domain_sid) {
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
-
- state->domain_guid = samdb_result_guid(dom_res->msgs[0], "objectGUID");
- if (!state->domain_sid) {
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
-
- state->mixed_domain = ldb_msg_find_attr_as_uint(dom_res->msgs[0], "nTMixedDomain", 0);
-
- talloc_free(dom_res);
-
- ret = ldb_search_exp_fmt(state->sam_ldb, state, &ref_res,
- partitions_basedn, LDB_SCOPE_SUBTREE, ref_attrs,
- "(&(objectclass=crossRef)(ncName=%s))",
- ldb_dn_get_linearized(state->domain_dn));
-
- if (ret != LDB_SUCCESS) {
- talloc_free(ref_res);
- return NT_STATUS_INVALID_SYSTEM_SERVICE;
- }
- if (ref_res->count != 1) {
- talloc_free(ref_res);
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
-
- state->domain_name = ldb_msg_find_attr_as_string(ref_res->msgs[0], "nETBIOSName", NULL);
- if (!state->domain_name) {
- talloc_free(ref_res);
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
- talloc_steal(state, state->domain_name);
-
- state->domain_dns = ldb_msg_find_attr_as_string(ref_res->msgs[0], "dnsRoot", NULL);
- if (!state->domain_dns) {
- talloc_free(ref_res);
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
- talloc_steal(state, state->domain_dns);
-
- talloc_free(ref_res);
-
- ret = ldb_search_exp_fmt(state->sam_ldb, state, &forest_ref_res,
- partitions_basedn, LDB_SCOPE_SUBTREE, ref_attrs,
- "(&(objectclass=crossRef)(ncName=%s))",
- ldb_dn_get_linearized(state->forest_dn));
-
- if (ret != LDB_SUCCESS) {
- talloc_free(forest_ref_res);
- return NT_STATUS_INVALID_SYSTEM_SERVICE;
- }
- if (forest_ref_res->count != 1) {
- talloc_free(forest_ref_res);
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
-
- state->forest_dns = ldb_msg_find_attr_as_string(forest_ref_res->msgs[0], "dnsRoot", NULL);
- if (!state->forest_dns) {
- talloc_free(forest_ref_res);
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
- talloc_steal(state, state->forest_dns);
-
- talloc_free(forest_ref_res);
-
- /* work out the builtin_dn - useful for so many calls its worth
- fetching here */
- state->builtin_dn = samdb_search_dn(state->sam_ldb, state, state->domain_dn, "(objectClass=builtinDomain)");
- if (!state->builtin_dn) {
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
-
- /* work out the system_dn - useful for so many calls its worth
- fetching here */
- state->system_dn = samdb_search_dn(state->sam_ldb, state,
- state->domain_dn, "(&(objectClass=container)(cn=System))");
- if (!state->system_dn) {
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
-
- state->builtin_sid = dom_sid_parse_talloc(state, SID_BUILTIN);
- if (!state->builtin_sid) {
- return NT_STATUS_NO_SUCH_DOMAIN;
- }
-
- *_state = state;
-
- return NT_STATUS_OK;
-}
-
/*
dssetup_DsRoleGetPrimaryDomainInformation
@@ -457,7 +262,7 @@ static WERROR dcesrv_dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_cal
ZERO_STRUCT(domain_guid);
- switch (lp_server_role()) {
+ switch (lp_server_role(global_loadparm)) {
case ROLE_STANDALONE:
role = DS_ROLE_STANDALONE_SERVER;
break;
@@ -473,13 +278,13 @@ static WERROR dcesrv_dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_cal
break;
}
- switch (lp_server_role()) {
+ switch (lp_server_role(global_loadparm)) {
case ROLE_STANDALONE:
- domain = talloc_strdup(mem_ctx, lp_workgroup());
+ domain = talloc_strdup(mem_ctx, lp_workgroup(global_loadparm));
W_ERROR_HAVE_NO_MEMORY(domain);
break;
case ROLE_DOMAIN_MEMBER:
- domain = talloc_strdup(mem_ctx, lp_workgroup());
+ domain = talloc_strdup(mem_ctx, lp_workgroup(global_loadparm));
W_ERROR_HAVE_NO_MEMORY(domain);
/* TODO: what is with dns_domain and forest and guid? */
break;
@@ -531,60 +336,6 @@ static WERROR dcesrv_dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_cal
return WERR_INVALID_PARAM;
}
-/*
- lsa_OpenPolicy2
-*/
-static NTSTATUS dcesrv_lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct lsa_OpenPolicy2 *r)
-{
- NTSTATUS status;
- struct lsa_policy_state *state;
- struct dcesrv_handle *handle;
-
- ZERO_STRUCTP(r->out.handle);
-
- status = dcesrv_lsa_get_policy_state(dce_call, mem_ctx, &state);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- handle = dcesrv_handle_new(dce_call->context, LSA_HANDLE_POLICY);
- if (!handle) {
- return NT_STATUS_NO_MEMORY;
- }
-
- handle->data = talloc_steal(handle, state);
-
- state->access_mask = r->in.access_mask;
- state->handle = handle;
- *r->out.handle = handle->wire_handle;
-
- /* note that we have completely ignored the attr element of
- the OpenPolicy. As far as I can tell, this is what w2k3
- does */
-
- return NT_STATUS_OK;
-}
-
-/*
- lsa_OpenPolicy
- a wrapper around lsa_OpenPolicy2
-*/
-static NTSTATUS dcesrv_lsa_OpenPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct lsa_OpenPolicy *r)
-{
- struct lsa_OpenPolicy2 r2;
-
- r2.in.system_name = NULL;
- r2.in.attr = r->in.attr;
- r2.in.access_mask = r->in.access_mask;
- r2.out.handle = r->out.handle;
-
- return dcesrv_lsa_OpenPolicy2(dce_call, mem_ctx, &r2);
-}
-
-
-
/*
fill in the AccountDomain info
@@ -642,6 +393,10 @@ static NTSTATUS dcesrv_lsa_QueryInfoPolicy2(struct dcesrv_call_state *dce_call,
case LSA_POLICY_INFO_DNS:
return dcesrv_lsa_info_DNS(state, mem_ctx, &r->out.info->dns);
+ case LSA_POLICY_INFO_DB:
+ case LSA_POLICY_INFO_AUDIT_FULL_SET:
+ case LSA_POLICY_INFO_AUDIT_FULL_QUERY:
+ return NT_STATUS_INVALID_PARAMETER;
}
return NT_STATUS_INVALID_INFO_CLASS;
@@ -1472,311 +1227,6 @@ static NTSTATUS dcesrv_lsa_EnumTrustedDomainsEx(struct dcesrv_call_state *dce_ca
}
-/*
- return the authority name and authority sid, given a sid
-*/
-static NTSTATUS dcesrv_lsa_authority_name(struct lsa_policy_state *state,
- TALLOC_CTX *mem_ctx, struct dom_sid *sid,
- const char **authority_name,
- struct dom_sid **authority_sid)
-{
- if (dom_sid_in_domain(state->domain_sid, sid)) {
- *authority_name = state->domain_name;
- *authority_sid = state->domain_sid;
- return NT_STATUS_OK;
- }
-
- if (dom_sid_in_domain(state->builtin_sid, sid)) {
- *authority_name = "BUILTIN";
- *authority_sid = state->builtin_sid;
- return NT_STATUS_OK;
- }
-
- *authority_sid = dom_sid_dup(mem_ctx, sid);
- if (*authority_sid == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- (*authority_sid)->num_auths = 0;
- *authority_name = dom_sid_string(mem_ctx, *authority_sid);
- if (*authority_name == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- return NT_STATUS_OK;
-}
-
-/*
- add to the lsa_RefDomainList for LookupSids and LookupNames
-*/
-static NTSTATUS dcesrv_lsa_authority_list(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
- struct dom_sid *sid,
- struct lsa_RefDomainList *domains,
- uint32_t *sid_index)
-{
- NTSTATUS status;
- const char *authority_name;
- struct dom_sid *authority_sid;
- int i;
-
- /* work out the authority name */
- status = dcesrv_lsa_authority_name(state, mem_ctx, sid,
- &authority_name, &authority_sid);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- /* see if we've already done this authority name */
- for (i=0;i<domains->count;i++) {
- if (strcmp(authority_name, domains->domains[i].name.string) == 0) {
- *sid_index = i;
- return NT_STATUS_OK;
- }
- }
-
- domains->domains = talloc_realloc(domains,
- domains->domains,
- struct lsa_DomainInfo,
- domains->count+1);
- if (domains->domains == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- domains->domains[i].name.string = authority_name;
- domains->domains[i].sid = authority_sid;
- domains->count++;
- domains->max_size = LSA_REF_DOMAIN_LIST_MULTIPLIER * domains->count;
- *sid_index = i;
-
- return NT_STATUS_OK;
-}
-
-/*
- lookup a name for 1 SID
-*/
-static NTSTATUS dcesrv_lsa_lookup_sid(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
- struct dom_sid *sid, const char *sid_str,
- const char **name, uint32_t *atype)
-{
- int ret;
- struct ldb_message **res;
- const char * const attrs[] = { "sAMAccountName", "sAMAccountType", "name", NULL};
- NTSTATUS status;
-
- ret = gendb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs,
- "objectSid=%s", ldap_encode_ndr_dom_sid(mem_ctx, sid));
- if (ret == 1) {
- *name = ldb_msg_find_attr_as_string(res[0], "sAMAccountName", NULL);
- if (!*name) {
- *name = ldb_msg_find_attr_as_string(res[0], "name", NULL);
- if (!*name) {
- *name = talloc_strdup(mem_ctx, sid_str);
- NT_STATUS_HAVE_NO_MEMORY(*name);
- }
- }
-
- *atype = samdb_result_uint(res[0], "sAMAccountType", 0);
-
- return NT_STATUS_OK;
- }
-
- status = sidmap_allocated_sid_lookup(state->sidmap, mem_ctx, sid, name, atype);
-
- return status;
-}
-
-
-/*
- lsa_LookupSids2
-*/
-static NTSTATUS dcesrv_lsa_LookupSids2(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct lsa_LookupSids2 *r)
-{
- struct lsa_policy_state *state;
- int i;
- NTSTATUS status = NT_STATUS_OK;
-
- r->out.domains = NULL;
-
- status = dcesrv_lsa_get_policy_state(dce_call, mem_ctx, &state);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- r->out.domains = talloc_zero(mem_ctx, struct lsa_RefDomainList);
- if (r->out.domains == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- r->out.names = talloc_zero(mem_ctx, struct lsa_TransNameArray2);
- if (r->out.names == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- *r->out.count = 0;
-
- r->out.names->names = talloc_array(r->out.names, struct lsa_TranslatedName2,
- r->in.sids->num_sids);
- if (r->out.names->names == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- for (i=0;i<r->in.sids->num_sids;i++) {
- struct dom_sid *sid = r->in.sids->sids[i].sid;
- char *sid_str = dom_sid_string(mem_ctx, sid);
- const char *name;
- uint32_t atype, rtype, sid_index;
- NTSTATUS status2;
-
- r->out.names->count++;
- (*r->out.count)++;
-
- r->out.names->names[i].sid_type = SID_NAME_UNKNOWN;
- r->out.names->names[i].name.string = sid_str;
- r->out.names->names[i].sid_index = 0xFFFFFFFF;
- r->out.names->names[i].unknown = 0;
-
- if (sid_str == NULL) {
- r->out.names->names[i].name.string = "(SIDERROR)";
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- /* work out the authority name */
- status2 = dcesrv_lsa_authority_list(state, mem_ctx, sid, r->out.domains, &sid_index);
- if (!NT_STATUS_IS_OK(status2)) {
- return status2;
- }
-
- status2 = dcesrv_lsa_lookup_sid(state, mem_ctx, sid, sid_str,
- &name, &atype);
- if (!NT_STATUS_IS_OK(status2)) {
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- rtype = samdb_atype_map(atype);
- if (rtype == SID_NAME_UNKNOWN) {
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- r->out.names->names[i].sid_type = rtype;
- r->out.names->names[i].name.string = name;
- r->out.names->names[i].sid_index = sid_index;
- r->out.names->names[i].unknown = 0;
- }
-
- return status;
-}
-
-
-/*
- lsa_LookupSids3
-
- Identical to LookupSids2, but doesn't take a policy handle
-
-*/
-static NTSTATUS dcesrv_lsa_LookupSids3(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct lsa_LookupSids3 *r)
-{
- struct lsa_LookupSids2 r2;
- struct lsa_OpenPolicy2 pol;
- NTSTATUS status;
- struct dcesrv_handle *h;
-
- /* No policy handle on the wire, so make one up here */
- r2.in.handle = talloc(mem_ctx, struct policy_handle);
- if (!r2.in.handle) {
- return NT_STATUS_NO_MEMORY;
- }
-
- pol.out.handle = r2.in.handle;
- pol.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- pol.in.attr = NULL;
- pol.in.system_name = NULL;
- status = dcesrv_lsa_OpenPolicy2(dce_call, mem_ctx, &pol);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- /* ensure this handle goes away at the end of this call */
- DCESRV_PULL_HANDLE(h, r2.in.handle, LSA_HANDLE_POLICY);
- talloc_steal(mem_ctx, h);
-
- r2.in.sids = r->in.sids;
- r2.in.names = r->in.names;
- r2.in.level = r->in.level;
- r2.in.count = r->in.count;
- r2.in.unknown1 = r->in.unknown1;
- r2.in.unknown2 = r->in.unknown2;
- r2.out.count = r->out.count;
- r2.out.names = r->out.names;
-
- status = dcesrv_lsa_LookupSids2(dce_call, mem_ctx, &r2);
- if (dce_call->fault_code != 0) {
- return status;
- }
-
- r->out.domains = r2.out.domains;
- r->out.names = r2.out.names;
- r->out.count = r2.out.count;
-
- return status;
-}
-
-
-/*
- lsa_LookupSids
-*/
-static NTSTATUS dcesrv_lsa_LookupSids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct lsa_LookupSids *r)
-{
- struct lsa_LookupSids2 r2;
- NTSTATUS status;
- int i;
-
- r2.in.handle = r->in.handle;
- r2.in.sids = r->in.sids;
- r2.in.names = NULL;
- r2.in.level = r->in.level;
- r2.in.count = r->in.count;
- r2.in.unknown1 = 0;
- r2.in.unknown2 = 0;
- r2.out.count = r->out.count;
- r2.out.names = NULL;
-
- status = dcesrv_lsa_LookupSids2(dce_call, mem_ctx, &r2);
- if (dce_call->fault_code != 0) {
- return status;
- }
-
- r->out.domains = r2.out.domains;
- if (!r2.out.names) {
- r->out.names = NULL;
- return status;
- }
-
- r->out.names = talloc(mem_ctx, struct lsa_TransNameArray);
- if (r->out.names == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- r->out.names->count = r2.out.names->count;
- r->out.names->names = talloc_array(r->out.names, struct lsa_TranslatedName,
- r->out.names->count);
- if (r->out.names->names == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- for (i=0;i<r->out.names->count;i++) {
- r->out.names->names[i].sid_type = r2.out.names->names[i].sid_type;
- r->out.names->names[i].name.string = r2.out.names->names[i].name.string;
- r->out.names->names[i].sid_index = r2.out.names->names[i].sid_index;
- }
-
- return status;
-}
-
-
/*
lsa_OpenAccount
*/
@@ -2224,7 +1674,7 @@ static NTSTATUS dcesrv_lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALL
const char *name2;
name = &r->in.name.string[2];
secret_state->sam_ldb = talloc_reference(secret_state, policy_state->sam_ldb);
- secret_state->global = True;
+ secret_state->global = true;
if (strlen(name) < 1) {
return NT_STATUS_INVALID_PARAMETER;
@@ -2254,7 +1704,7 @@ static NTSTATUS dcesrv_lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALL
samdb_msg_add_string(secret_state->sam_ldb, mem_ctx, msg, "cn", name2);
} else {
- secret_state->global = False;
+ secret_state->global = false;
name = r->in.name.string;
if (strlen(name) < 1) {
@@ -2301,7 +1751,7 @@ static NTSTATUS dcesrv_lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALL
DEBUG(0,("Failed to create secret record %s: %s\n",
ldb_dn_get_linearized(msg->dn),
ldb_errstring(secret_state->sam_ldb)));
- return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ return NT_STATUS_ACCESS_DENIED;
}
handle = dcesrv_handle_new(dce_call->context, LSA_HANDLE_SECRET);
@@ -2357,7 +1807,7 @@ static NTSTATUS dcesrv_lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC
if (strncmp("G$", r->in.name.string, 2) == 0) {
name = &r->in.name.string[2];
secret_state->sam_ldb = talloc_reference(secret_state, policy_state->sam_ldb);
- secret_state->global = True;
+ secret_state->global = true;
if (strlen(name) < 1) {
return NT_STATUS_INVALID_PARAMETER;
@@ -2381,7 +1831,7 @@ static NTSTATUS dcesrv_lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC
} else {
secret_state->sam_ldb = talloc_reference(secret_state, secrets_db_connect(mem_ctx));
- secret_state->global = False;
+ secret_state->global = false;
name = r->in.name.string;
if (strlen(name) < 1) {
return NT_STATUS_INVALID_PARAMETER;
@@ -2398,8 +1848,8 @@ static NTSTATUS dcesrv_lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC
}
if (ret != 1) {
- DEBUG(0,("Found %d records matching DN %s\n", ret,
- ldb_dn_get_linearized(policy_state->system_dn)));
+ DEBUG(0,("Found %d records matching CN=%s\n",
+ ret, ldb_binary_encode_string(mem_ctx, name)));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
}
@@ -3006,293 +2456,6 @@ static NTSTATUS dcesrv_lsa_TestCall(struct dcesrv_call_state *dce_call,
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
-/*
- lookup a SID for 1 name
-*/
-static NTSTATUS dcesrv_lsa_lookup_name(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
- const char *name, struct dom_sid **sid, uint32_t *atype)
-{
- int ret;
- struct ldb_message **res;
- const char * const attrs[] = { "objectSid", "sAMAccountType", NULL};
- const char *p;
-
- p = strchr_m(name, '\\');
- if (p != NULL) {
- /* TODO: properly parse the domain prefix here, and use it to
- limit the search */
- name = p + 1;
- }
-
- ret = gendb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs, "sAMAccountName=%s", ldb_binary_encode_string(mem_ctx, name));
- if (ret == 1) {
- *sid = samdb_result_dom_sid(mem_ctx, res[0], "objectSid");
- if (*sid == NULL) {
- return NT_STATUS_INVALID_SID;
- }
-
- *atype = samdb_result_uint(res[0], "sAMAccountType", 0);
-
- return NT_STATUS_OK;
- }
-
- /* need to add a call into sidmap to check for a allocated sid */
-
- return NT_STATUS_INVALID_SID;
-}
-
-
-/*
- lsa_LookupNames3
-*/
-static NTSTATUS dcesrv_lsa_LookupNames3(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct lsa_LookupNames3 *r)
-{
- struct lsa_policy_state *policy_state;
- struct dcesrv_handle *policy_handle;
- int i;
- NTSTATUS status = NT_STATUS_OK;
-
- DCESRV_PULL_HANDLE(policy_handle, r->in.handle, LSA_HANDLE_POLICY);
-
- policy_state = policy_handle->data;
-
- r->out.domains = NULL;
-
- r->out.domains = talloc_zero(mem_ctx, struct lsa_RefDomainList);
- if (r->out.domains == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- r->out.sids = talloc_zero(mem_ctx, struct lsa_TransSidArray3);
- if (r->out.sids == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- *r->out.count = 0;
-
- r->out.sids->sids = talloc_array(r->out.sids, struct lsa_TranslatedSid3,
- r->in.num_names);
- if (r->out.sids->sids == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- for (i=0;i<r->in.num_names;i++) {
- const char *name = r->in.names[i].string;
- struct dom_sid *sid;
- uint32_t atype, rtype, sid_index;
- NTSTATUS status2;
-
- r->out.sids->count++;
- (*r->out.count)++;
-
- r->out.sids->sids[i].sid_type = SID_NAME_UNKNOWN;
- r->out.sids->sids[i].sid = NULL;
- r->out.sids->sids[i].sid_index = 0xFFFFFFFF;
- r->out.sids->sids[i].unknown = 0;
-
- status2 = dcesrv_lsa_lookup_name(policy_state, mem_ctx, name, &sid, &atype);
- if (!NT_STATUS_IS_OK(status2) || sid->num_auths == 0) {
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- rtype = samdb_atype_map(atype);
- if (rtype == SID_NAME_UNKNOWN) {
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- status2 = dcesrv_lsa_authority_list(policy_state, mem_ctx, sid, r->out.domains, &sid_index);
- if (!NT_STATUS_IS_OK(status2)) {
- return status2;
- }
-
- r->out.sids->sids[i].sid_type = rtype;
- r->out.sids->sids[i].sid = sid;
- r->out.sids->sids[i].sid_index = sid_index;
- r->out.sids->sids[i].unknown = 0;
- }
-
- return status;
-}
-
-/*
- lsa_LookupNames4
-
- Identical to LookupNames3, but doesn't take a policy handle
-
-*/
-static NTSTATUS dcesrv_lsa_LookupNames4(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct lsa_LookupNames4 *r)
-{
- struct lsa_LookupNames3 r2;
- struct lsa_OpenPolicy2 pol;
- NTSTATUS status;
- struct dcesrv_handle *h;
-
- /* No policy handle on the wire, so make one up here */
- r2.in.handle = talloc(mem_ctx, struct policy_handle);
- if (!r2.in.handle) {
- return NT_STATUS_NO_MEMORY;
- }
-
- pol.out.handle = r2.in.handle;
- pol.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- pol.in.attr = NULL;
- pol.in.system_name = NULL;
- status = dcesrv_lsa_OpenPolicy2(dce_call, mem_ctx, &pol);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- /* ensure this handle goes away at the end of this call */
- DCESRV_PULL_HANDLE(h, r2.in.handle, LSA_HANDLE_POLICY);
- talloc_steal(mem_ctx, h);
-
- r2.in.num_names = r->in.num_names;
- r2.in.names = r->in.names;
- r2.in.sids = r->in.sids;
- r2.in.count = r->in.count;
- r2.in.unknown1 = r->in.unknown1;
- r2.in.unknown2 = r->in.unknown2;
- r2.out.domains = r->out.domains;
- r2.out.sids = r->out.sids;
- r2.out.count = r->out.count;
-
- status = dcesrv_lsa_LookupNames3(dce_call, mem_ctx, &r2);
- if (dce_call->fault_code != 0) {
- return status;
- }
-
- r->out.domains = r2.out.domains;
- r->out.sids = r2.out.sids;
- r->out.count = r2.out.count;
- return status;
-}
-
-/*
- lsa_LookupNames2
-*/
-static NTSTATUS dcesrv_lsa_LookupNames2(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct lsa_LookupNames2 *r)
-{
- struct lsa_policy_state *state;
- struct dcesrv_handle *h;
- int i;
- NTSTATUS status = NT_STATUS_OK;
-
- r->out.domains = NULL;
-
- DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY);
-
- state = h->data;
-
- r->out.domains = talloc_zero(mem_ctx, struct lsa_RefDomainList);
- if (r->out.domains == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- r->out.sids = talloc_zero(mem_ctx, struct lsa_TransSidArray2);
- if (r->out.sids == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- *r->out.count = 0;
-
- r->out.sids->sids = talloc_array(r->out.sids, struct lsa_TranslatedSid2,
- r->in.num_names);
- if (r->out.sids->sids == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- for (i=0;i<r->in.num_names;i++) {
- const char *name = r->in.names[i].string;
- struct dom_sid *sid;
- uint32_t atype, rtype, sid_index;
- NTSTATUS status2;
-
- r->out.sids->count++;
- (*r->out.count)++;
-
- r->out.sids->sids[i].sid_type = SID_NAME_UNKNOWN;
- r->out.sids->sids[i].rid = 0xFFFFFFFF;
- r->out.sids->sids[i].sid_index = 0xFFFFFFFF;
- r->out.sids->sids[i].unknown = 0;
-
- status2 = dcesrv_lsa_lookup_name(state, mem_ctx, name, &sid, &atype);
- if (!NT_STATUS_IS_OK(status2) || sid->num_auths == 0) {
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- rtype = samdb_atype_map(atype);
- if (rtype == SID_NAME_UNKNOWN) {
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- status2 = dcesrv_lsa_authority_list(state, mem_ctx, sid, r->out.domains, &sid_index);
- if (!NT_STATUS_IS_OK(status2)) {
- return status2;
- }
-
- r->out.sids->sids[i].sid_type = rtype;
- r->out.sids->sids[i].rid = sid->sub_auths[sid->num_auths-1];
- r->out.sids->sids[i].sid_index = sid_index;
- r->out.sids->sids[i].unknown = 0;
- }
-
- return status;
-}
-
-/*
- lsa_LookupNames
-*/
-static NTSTATUS dcesrv_lsa_LookupNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct lsa_LookupNames *r)
-{
- struct lsa_LookupNames2 r2;
- NTSTATUS status;
- int i;
-
- r2.in.handle = r->in.handle;
- r2.in.num_names = r->in.num_names;
- r2.in.names = r->in.names;
- r2.in.sids = NULL;
- r2.in.level = r->in.level;
- r2.in.count = r->in.count;
- r2.in.unknown1 = 0;
- r2.in.unknown2 = 0;
- r2.out.count = r->out.count;
-
- status = dcesrv_lsa_LookupNames2(dce_call, mem_ctx, &r2);
- if (dce_call->fault_code != 0) {
- return status;
- }
-
- r->out.domains = r2.out.domains;
- r->out.sids = talloc(mem_ctx, struct lsa_TransSidArray);
- if (r->out.sids == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- r->out.sids->count = r2.out.sids->count;
- r->out.sids->sids = talloc_array(r->out.sids, struct lsa_TranslatedSid,
- r->out.sids->count);
- if (r->out.sids->sids == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- for (i=0;i<r->out.sids->count;i++) {
- r->out.sids->sids[i].sid_type = r2.out.sids->sids[i].sid_type;
- r->out.sids->sids[i].rid = r2.out.sids->sids[i].rid;
- r->out.sids->sids[i].sid_index = r2.out.sids->sids[i].sid_index;
- }
-
- return status;
-}
-
/*
lsa_CREDRWRITE
*/
diff --git a/source4/rpc_server/lsa/lsa.h b/source4/rpc_server/lsa/lsa.h
new file mode 100644
index 0000000000..6ecda0ff82
--- /dev/null
+++ b/source4/rpc_server/lsa/lsa.h
@@ -0,0 +1,69 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ endpoint server for the lsarpc pipe
+
+ Copyright (C) Andrew Tridgell 2004
+ 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 "rpc_server/dcerpc_server.h"
+#include "rpc_server/common/common.h"
+#include "auth/auth.h"
+#include "dsdb/samdb/samdb.h"
+#include "libcli/ldap/ldap.h"
+#include "lib/ldb/include/ldb_errors.h"
+#include "libcli/security/security.h"
+#include "libcli/auth/libcli_auth.h"
+#include "param/secrets.h"
+#include "db_wrap.h"
+#include "librpc/gen_ndr/ndr_dssetup.h"
+#include "param/param.h"
+
+/*
+ state associated with a lsa_OpenPolicy() operation
+*/
+struct lsa_policy_state {
+ struct dcesrv_handle *handle;
+ struct ldb_context *sam_ldb;
+ struct sidmap_context *sidmap;
+ uint32_t access_mask;
+ struct ldb_dn *domain_dn;
+ struct ldb_dn *forest_dn;
+ struct ldb_dn *builtin_dn;
+ struct ldb_dn *system_dn;
+ const char *domain_name;
+ const char *domain_dns;
+ const char *forest_dns;
+ struct dom_sid *domain_sid;
+ struct GUID domain_guid;
+ struct dom_sid *builtin_sid;
+ struct dom_sid *nt_authority_sid;
+ struct dom_sid *creator_owner_domain_sid;
+ struct dom_sid *world_domain_sid;
+ int mixed_domain;
+};
+
+enum lsa_handle {
+ LSA_HANDLE_POLICY,
+ LSA_HANDLE_ACCOUNT,
+ LSA_HANDLE_SECRET,
+ LSA_HANDLE_TRUSTED_DOMAIN
+};
+
+#include "rpc_server/lsa/proto.h"
+
diff --git a/source4/rpc_server/lsa/lsa_init.c b/source4/rpc_server/lsa/lsa_init.c
new file mode 100644
index 0000000000..6cf062a22a
--- /dev/null
+++ b/source4/rpc_server/lsa/lsa_init.c
@@ -0,0 +1,248 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ endpoint server for the lsarpc pipe
+
+ Copyright (C) Andrew Tridgell 2004
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-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 "rpc_server/lsa/lsa.h"
+
+NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct lsa_policy_state **_state)
+{
+ struct lsa_policy_state *state;
+ struct ldb_dn *partitions_basedn;
+ struct ldb_result *dom_res;
+ const char *dom_attrs[] = {
+ "objectSid",
+ "objectGUID",
+ "nTMixedDomain",
+ "fSMORoleOwner",
+ NULL
+ };
+ struct ldb_result *ref_res;
+ struct ldb_result *forest_ref_res;
+ const char *ref_attrs[] = {
+ "nETBIOSName",
+ "dnsRoot",
+ NULL
+ };
+ int ret;
+
+ state = talloc(mem_ctx, struct lsa_policy_state);
+ if (!state) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* make sure the sam database is accessible */
+ state->sam_ldb = samdb_connect(state, dce_call->conn->auth_state.session_info);
+ if (state->sam_ldb == NULL) {
+ return NT_STATUS_INVALID_SYSTEM_SERVICE;
+ }
+
+ partitions_basedn = samdb_partitions_dn(state->sam_ldb, mem_ctx);
+
+ state->sidmap = sidmap_open(state);
+ if (state->sidmap == NULL) {
+ return NT_STATUS_INVALID_SYSTEM_SERVICE;
+ }
+
+ /* work out the domain_dn - useful for so many calls its worth
+ fetching here */
+ state->domain_dn = samdb_base_dn(state->sam_ldb);
+ if (!state->domain_dn) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* work out the forest root_dn - useful for so many calls its worth
+ fetching here */
+ state->forest_dn = samdb_root_dn(state->sam_ldb);
+ if (!state->forest_dn) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ret = ldb_search(state->sam_ldb, state->domain_dn, LDB_SCOPE_BASE, NULL, dom_attrs, &dom_res);
+
+ if (ret != LDB_SUCCESS) {
+ return NT_STATUS_INVALID_SYSTEM_SERVICE;
+ }
+ talloc_steal(mem_ctx, dom_res);
+ if (dom_res->count != 1) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ state->domain_sid = samdb_result_dom_sid(state, dom_res->msgs[0], "objectSid");
+ if (!state->domain_sid) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ state->domain_guid = samdb_result_guid(dom_res->msgs[0], "objectGUID");
+ if (!state->domain_sid) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ state->mixed_domain = ldb_msg_find_attr_as_uint(dom_res->msgs[0], "nTMixedDomain", 0);
+
+ talloc_free(dom_res);
+
+ ret = ldb_search_exp_fmt(state->sam_ldb, state, &ref_res,
+ partitions_basedn, LDB_SCOPE_SUBTREE, ref_attrs,
+ "(&(objectclass=crossRef)(ncName=%s))",
+ ldb_dn_get_linearized(state->domain_dn));
+
+ if (ret != LDB_SUCCESS) {
+ talloc_free(ref_res);
+ return NT_STATUS_INVALID_SYSTEM_SERVICE;
+ }
+ if (ref_res->count != 1) {
+ talloc_free(ref_res);
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ state->domain_name = ldb_msg_find_attr_as_string(ref_res->msgs[0], "nETBIOSName", NULL);
+ if (!state->domain_name) {
+ talloc_free(ref_res);
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+ talloc_steal(state, state->domain_name);
+
+ state->domain_dns = ldb_msg_find_attr_as_string(ref_res->msgs[0], "dnsRoot", NULL);
+ if (!state->domain_dns) {
+ talloc_free(ref_res);
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+ talloc_steal(state, state->domain_dns);
+
+ talloc_free(ref_res);
+
+ ret = ldb_search_exp_fmt(state->sam_ldb, state, &forest_ref_res,
+ partitions_basedn, LDB_SCOPE_SUBTREE, ref_attrs,
+ "(&(objectclass=crossRef)(ncName=%s))",
+ ldb_dn_get_linearized(state->forest_dn));
+
+ if (ret != LDB_SUCCESS) {
+ talloc_free(forest_ref_res);
+ return NT_STATUS_INVALID_SYSTEM_SERVICE;
+ }
+ if (forest_ref_res->count != 1) {
+ talloc_free(forest_ref_res);
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ state->forest_dns = ldb_msg_find_attr_as_string(forest_ref_res->msgs[0], "dnsRoot", NULL);
+ if (!state->forest_dns) {
+ talloc_free(forest_ref_res);
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+ talloc_steal(state, state->forest_dns);
+
+ talloc_free(forest_ref_res);
+
+ /* work out the builtin_dn - useful for so many calls its worth
+ fetching here */
+ state->builtin_dn = samdb_search_dn(state->sam_ldb, state, state->domain_dn, "(objectClass=builtinDomain)");
+ if (!state->builtin_dn) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ /* work out the system_dn - useful for so many calls its worth
+ fetching here */
+ state->system_dn = samdb_search_dn(state->sam_ldb, state,
+ state->domain_dn, "(&(objectClass=container)(cn=System))");
+ if (!state->system_dn) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ state->builtin_sid = dom_sid_parse_talloc(state, SID_BUILTIN);
+ if (!state->builtin_sid) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ state->nt_authority_sid = dom_sid_parse_talloc(state, SID_NT_AUTHORITY);
+ if (!state->nt_authority_sid) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ state->creator_owner_domain_sid = dom_sid_parse_talloc(state, SID_CREATOR_OWNER_DOMAIN);
+ if (!state->creator_owner_domain_sid) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ state->world_domain_sid = dom_sid_parse_talloc(state, SID_WORLD_DOMAIN);
+ if (!state->world_domain_sid) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+
+ *_state = state;
+
+ return NT_STATUS_OK;
+}
+
+/*
+ lsa_OpenPolicy2
+*/
+NTSTATUS dcesrv_lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct lsa_OpenPolicy2 *r)
+{
+ NTSTATUS status;
+ struct lsa_policy_state *state;
+ struct dcesrv_handle *handle;
+
+ ZERO_STRUCTP(r->out.handle);
+
+ status = dcesrv_lsa_get_policy_state(dce_call, mem_ctx, &state);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ handle = dcesrv_handle_new(dce_call->context, LSA_HANDLE_POLICY);
+ if (!handle) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ handle->data = talloc_steal(handle, state);
+
+ state->access_mask = r->in.access_mask;
+ state->handle = handle;
+ *r->out.handle = handle->wire_handle;
+
+ /* note that we have completely ignored the attr element of
+ the OpenPolicy. As far as I can tell, this is what w2k3
+ does */
+
+ return NT_STATUS_OK;
+}
+
+/*
+ lsa_OpenPolicy
+ a wrapper around lsa_OpenPolicy2
+*/
+NTSTATUS dcesrv_lsa_OpenPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct lsa_OpenPolicy *r)
+{
+ struct lsa_OpenPolicy2 r2;
+
+ r2.in.system_name = NULL;
+ r2.in.attr = r->in.attr;
+ r2.in.access_mask = r->in.access_mask;
+ r2.out.handle = r->out.handle;
+
+ return dcesrv_lsa_OpenPolicy2(dce_call, mem_ctx, &r2);
+}
+
+
diff --git a/source4/rpc_server/lsa/lsa_lookup.c b/source4/rpc_server/lsa/lsa_lookup.c
new file mode 100644
index 0000000000..2275e76c38
--- /dev/null
+++ b/source4/rpc_server/lsa/lsa_lookup.c
@@ -0,0 +1,928 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ endpoint server for the lsarpc pipe
+
+ Copyright (C) Andrew Tridgell 2004
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-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 "rpc_server/lsa/lsa.h"
+
+static const struct {
+ const char *domain;
+ const char *name;
+ const char *sid;
+ int rtype;
+} well_known[] = {
+ {
+ .name = "EVERYONE",
+ .sid = SID_WORLD,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .name = "CREATOR OWNER",
+ .sid = SID_CREATOR_OWNER,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .name = "CREATOR GROUP",
+ .sid = SID_CREATOR_GROUP,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Dialup",
+ .sid = SID_NT_DIALUP,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Network",
+ .sid = SID_NT_NETWORK,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Batch",
+ .sid = SID_NT_BATCH,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Interactive",
+ .sid = SID_NT_INTERACTIVE,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Service",
+ .sid = SID_NT_SERVICE,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "ANONYMOUS LOGON",
+ .sid = SID_NT_ANONYMOUS,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Proxy",
+ .sid = SID_NT_PROXY,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "ServerLogon",
+ .sid = SID_NT_ENTERPRISE_DCS,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Self",
+ .sid = SID_NT_SELF,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Authenticated Users",
+ .sid = SID_NT_AUTHENTICATED_USERS,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Restricted",
+ .sid = SID_NT_RESTRICTED,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Termainal Server User",
+ .sid = SID_NT_TERMINAL_SERVER_USERS,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Remote Interactive Logon",
+ .sid = SID_NT_REMOTE_INTERACTIVE,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "This Organization",
+ .sid = SID_NT_THIS_ORGANISATION,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "SYSTEM",
+ .sid = SID_NT_SYSTEM,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Local Service",
+ .sid = SID_NT_LOCAL_SERVICE,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .domain = "NT AUTHORITY",
+ .name = "Network Service",
+ .sid = SID_NT_NETWORK_SERVICE,
+ .rtype = SID_NAME_WKN_GRP,
+ },
+ {
+ .sid = NULL,
+ }
+};
+
+static NTSTATUS lookup_well_known_names(TALLOC_CTX *mem_ctx, const char *domain,
+ const char *name, const char **authority_name,
+ struct dom_sid **sid, uint32_t *rtype)
+{
+ int i;
+ for (i=0; well_known[i].sid; i++) {
+ if (domain) {
+ if (strcasecmp_m(domain, well_known[i].domain) == 0
+ && strcasecmp_m(name, well_known[i].name) == 0) {
+ *authority_name = well_known[i].domain;
+ *sid = dom_sid_parse_talloc(mem_ctx, well_known[i].sid);
+ *rtype = well_known[i].rtype;
+ return NT_STATUS_OK;
+ }
+ } else {
+ if (strcasecmp_m(name, well_known[i].name) == 0) {
+ *authority_name = well_known[i].domain;
+ *sid = dom_sid_parse_talloc(mem_ctx, well_known[i].sid);
+ *rtype = well_known[i].rtype;
+ return NT_STATUS_OK;
+ }
+ }
+ }
+ return NT_STATUS_NOT_FOUND;
+}
+
+static NTSTATUS lookup_well_known_sids(TALLOC_CTX *mem_ctx,
+ const char *sid_str, const char **authority_name,
+ const char **name, uint32_t *rtype)
+{
+ int i;
+ for (i=0; well_known[i].sid; i++) {
+ if (strcasecmp_m(sid_str, well_known[i].sid) == 0) {
+ *authority_name = well_known[i].domain;
+ *name = well_known[i].name;
+ *rtype = well_known[i].rtype;
+ return NT_STATUS_OK;
+ }
+ }
+ return NT_STATUS_NOT_FOUND;
+}
+
+/*
+ lookup a SID for 1 name
+*/
+static NTSTATUS dcesrv_lsa_lookup_name(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
+ const char *name, const char **authority_name,
+ struct dom_sid **sid, enum lsa_SidType *rtype)
+{
+ int ret, atype, i;
+ struct ldb_message **res;
+ const char * const attrs[] = { "objectSid", "sAMAccountType", NULL};
+ const char *p;
+ const char *domain;
+ const char *username;
+ struct ldb_dn *domain_dn;
+ struct dom_sid *domain_sid;
+ NTSTATUS status;
+
+ p = strchr_m(name, '\\');
+ if (p != NULL) {
+ domain = talloc_strndup(mem_ctx, name, p-name);
+ if (!domain) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ username = p + 1;
+ } else if (strchr_m(name, '@')) {
+ status = crack_name_to_nt4_name(mem_ctx, DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, name, &domain, &username);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ } else {
+ domain = NULL;
+ username = name;
+ }
+
+ if (!domain) {
+ /* Look up table of well known names */
+ status = lookup_well_known_names(mem_ctx, NULL, username, authority_name, sid, rtype);
+ if (NT_STATUS_IS_OK(status)) {
+ return NT_STATUS_OK;
+ }
+
+ if (strcasecmp_m(username, NAME_NT_AUTHORITY) == 0) {
+ *authority_name = NAME_NT_AUTHORITY;
+ *sid = dom_sid_parse_talloc(mem_ctx, SID_NT_AUTHORITY);
+ *rtype = SID_NAME_DOMAIN;
+ return NT_STATUS_OK;
+ }
+ if (strcasecmp_m(username, NAME_BUILTIN) == 0) {
+ *authority_name = NAME_BUILTIN;
+ *sid = dom_sid_parse_talloc(mem_ctx, SID_BUILTIN);
+ *rtype = SID_NAME_DOMAIN;
+ return NT_STATUS_OK;
+ }
+ if (strcasecmp_m(username, state->domain_dns) == 0) {
+ *authority_name = state->domain_name;
+ *sid = state->domain_sid;
+ *rtype = SID_NAME_DOMAIN;
+ return NT_STATUS_OK;
+ }
+ if (strcasecmp_m(username, state->domain_name) == 0) {
+ *authority_name = state->domain_name;
+ *sid = state->domain_sid;
+ *rtype = SID_NAME_DOMAIN;
+ return NT_STATUS_OK;
+ }
+
+ /* Perhaps this is a well known user? */
+ name = talloc_asprintf(mem_ctx, "%s\\%s", NAME_NT_AUTHORITY, username);
+ if (!name) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ status = dcesrv_lsa_lookup_name(state, mem_ctx, name, authority_name, sid, rtype);
+ if (NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ /* Perhaps this is a BUILTIN user? */
+ name = talloc_asprintf(mem_ctx, "%s\\%s", NAME_BUILTIN, username);
+ if (!name) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ status = dcesrv_lsa_lookup_name(state, mem_ctx, name, authority_name, sid, rtype);
+ if (NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ /* OK, I give up - perhaps we need to assume the user is in our domain? */
+ name = talloc_asprintf(mem_ctx, "%s\\%s", state->domain_name, username);
+ if (!name) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ status = dcesrv_lsa_lookup_name(state, mem_ctx, name, authority_name, sid, rtype);
+ if (NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return STATUS_SOME_UNMAPPED;
+ } else if (strcasecmp_m(domain, NAME_NT_AUTHORITY) == 0) {
+ if (!*username) {
+ *authority_name = NAME_NT_AUTHORITY;
+ *sid = dom_sid_parse_talloc(mem_ctx, SID_NT_AUTHORITY);
+ *rtype = SID_NAME_DOMAIN;
+ return NT_STATUS_OK;
+ }
+
+ /* Look up table of well known names */
+ return lookup_well_known_names(mem_ctx, domain, username, authority_name,
+ sid, rtype);
+ } else if (strcasecmp_m(domain, NAME_BUILTIN) == 0) {
+ *authority_name = NAME_BUILTIN;
+ domain_dn = state->builtin_dn;
+ } else if (strcasecmp_m(domain, state->domain_dns) == 0) {
+ *authority_name = state->domain_name;
+ domain_dn = state->domain_dn;
+ } else if (strcasecmp_m(domain, state->domain_name) == 0) {
+ *authority_name = state->domain_name;
+ domain_dn = state->domain_dn;
+ } else {
+ /* Not local, need to ask winbind in future */
+ return STATUS_SOME_UNMAPPED;
+ }
+
+ ret = gendb_search_dn(state->sam_ldb, mem_ctx, domain_dn, &res, attrs);
+ if (ret == 1) {
+ domain_sid = samdb_result_dom_sid(mem_ctx, res[0], "objectSid");
+ if (domain_sid == NULL) {
+ return NT_STATUS_INVALID_SID;
+ }
+ } else {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ if (!*username) {
+ *sid = domain_sid;
+ *rtype = SID_NAME_DOMAIN;
+ return NT_STATUS_OK;
+ }
+
+ ret = gendb_search(state->sam_ldb, mem_ctx, domain_dn, &res, attrs,
+ "(&(sAMAccountName=%s)(objectSid=*))",
+ ldb_binary_encode_string(mem_ctx, username));
+ if (ret == -1) {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ for (i=0; i < ret; i++) {
+ *sid = samdb_result_dom_sid(mem_ctx, res[i], "objectSid");
+ if (*sid == NULL) {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ /* Check that this is in the domain */
+ if (!dom_sid_in_domain(domain_sid, *sid)) {
+ continue;
+ }
+
+ atype = samdb_result_uint(res[i], "sAMAccountType", 0);
+
+ *rtype = samdb_atype_map(atype);
+ if (*rtype == SID_NAME_UNKNOWN) {
+ return STATUS_SOME_UNMAPPED;
+ }
+
+ return NT_STATUS_OK;
+ }
+
+ /* need to add a call into sidmap to check for a allocated sid */
+
+ return NT_STATUS_INVALID_SID;
+}
+
+
+/*
+ add to the lsa_RefDomainList for LookupSids and LookupNames
+*/
+static NTSTATUS dcesrv_lsa_authority_list(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
+ enum lsa_SidType rtype,
+ const char *authority_name,
+ struct dom_sid *sid,
+ struct lsa_RefDomainList *domains,
+ uint32_t *sid_index)
+{
+ struct dom_sid *authority_sid;
+ int i;
+
+ if (rtype != SID_NAME_DOMAIN) {
+ authority_sid = dom_sid_dup(mem_ctx, sid);
+ if (authority_sid == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ authority_sid->num_auths--;
+ } else {
+ authority_sid = sid;
+ }
+
+ /* see if we've already done this authority name */
+ for (i=0;i<domains->count;i++) {
+ if (strcasecmp_m(authority_name, domains->domains[i].name.string) == 0) {
+ *sid_index = i;
+ return NT_STATUS_OK;
+ }
+ }
+
+ domains->domains = talloc_realloc(domains,
+ domains->domains,
+ struct lsa_DomainInfo,
+ domains->count+1);
+ if (domains->domains == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ domains->domains[i].name.string = authority_name;
+ domains->domains[i].sid = authority_sid;
+ domains->count++;
+ domains->max_size = LSA_REF_DOMAIN_LIST_MULTIPLIER * domains->count;
+ *sid_index = i;
+
+ return NT_STATUS_OK;
+}
+
+/*
+ lookup a name for 1 SID
+*/
+static NTSTATUS dcesrv_lsa_lookup_sid(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
+ struct dom_sid *sid, const char *sid_str,
+ const char **authority_name,
+ const char **name, enum lsa_SidType *rtype)
+{
+ NTSTATUS status;
+ int ret;
+ uint32_t atype;
+ struct ldb_message **res;
+ struct ldb_dn *domain_dn;
+ const char * const attrs[] = { "sAMAccountName", "sAMAccountType", "cn", NULL};
+
+ status = lookup_well_known_sids(mem_ctx, sid_str, authority_name, name, rtype);
+ if (NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (dom_sid_in_domain(state->domain_sid, sid)) {
+ *authority_name = state->domain_name;
+ domain_dn = state->domain_dn;
+ } else if (dom_sid_in_domain(state->builtin_sid, sid)) {
+ *authority_name = NAME_BUILTIN;
+ domain_dn = state->builtin_dn;
+ } else {
+ /* Not well known, our domain or built in */
+
+ /* In future, we must look at SID histories, and at trusted domains via winbind */
+
+ return NT_STATUS_NOT_FOUND;
+ }
+
+ ret = gendb_search(state->sam_ldb, mem_ctx, domain_dn, &res, attrs,
+ "objectSid=%s", ldap_encode_ndr_dom_sid(mem_ctx, sid));
+ if (ret == 1) {
+ *name = ldb_msg_find_attr_as_string(res[0], "sAMAccountName", NULL);
+ if (!*name) {
+ *name = ldb_msg_find_attr_as_string(res[0], "cn", NULL);
+ if (!*name) {
+ *name = talloc_strdup(mem_ctx, sid_str);
+ NT_STATUS_HAVE_NO_MEMORY(*name);
+ }
+ }
+
+ atype = samdb_result_uint(res[0], "sAMAccountType", 0);
+
+ *rtype = samdb_atype_map(atype);
+
+ return NT_STATUS_OK;
+ }
+
+ /* need to re-add a call into sidmap to check for a allocated sid */
+ /* status = sidmap_allocated_sid_lookup(state->sidmap, mem_ctx, sid, name, rtype); */
+
+ return NT_STATUS_NOT_FOUND;
+}
+
+
+/*
+ lsa_LookupSids2
+*/
+NTSTATUS dcesrv_lsa_LookupSids2(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct lsa_LookupSids2 *r)
+{
+ struct lsa_policy_state *state;
+ int i;
+ NTSTATUS status = NT_STATUS_OK;
+
+ r->out.domains = NULL;
+
+ status = dcesrv_lsa_get_policy_state(dce_call, mem_ctx, &state);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ r->out.domains = talloc_zero(mem_ctx, struct lsa_RefDomainList);
+ if (r->out.domains == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ r->out.names = talloc_zero(mem_ctx, struct lsa_TransNameArray2);
+ if (r->out.names == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ *r->out.count = 0;
+
+ r->out.names->names = talloc_array(r->out.names, struct lsa_TranslatedName2,
+ r->in.sids->num_sids);
+ if (r->out.names->names == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0;i<r->in.sids->num_sids;i++) {
+ struct dom_sid *sid = r->in.sids->sids[i].sid;
+ char *sid_str = dom_sid_string(mem_ctx, sid);
+ const char *name, *authority_name;
+ enum lsa_SidType rtype;
+ uint32_t sid_index;
+ NTSTATUS status2;
+
+ r->out.names->count++;
+
+ r->out.names->names[i].sid_type = SID_NAME_UNKNOWN;
+ r->out.names->names[i].name.string = sid_str;
+ r->out.names->names[i].sid_index = 0xFFFFFFFF;
+ r->out.names->names[i].unknown = 0;
+
+ if (sid_str == NULL) {
+ r->out.names->names[i].name.string = "(SIDERROR)";
+ status = STATUS_SOME_UNMAPPED;
+ continue;
+ }
+
+ status2 = dcesrv_lsa_lookup_sid(state, mem_ctx, sid, sid_str,
+ &authority_name, &name, &rtype);
+ if (!NT_STATUS_IS_OK(status2)) {
+ status = STATUS_SOME_UNMAPPED;
+ continue;
+ }
+
+ /* set up the authority table */
+ status2 = dcesrv_lsa_authority_list(state, mem_ctx, rtype,
+ authority_name, sid,
+ r->out.domains, &sid_index);
+ if (!NT_STATUS_IS_OK(status2)) {
+ return status2;
+ }
+
+ r->out.names->names[i].sid_type = rtype;
+ r->out.names->names[i].name.string = name;
+ r->out.names->names[i].sid_index = sid_index;
+ r->out.names->names[i].unknown = 0;
+
+ (*r->out.count)++;
+ }
+
+ if (*r->out.count == 0) {
+ return NT_STATUS_NONE_MAPPED;
+ }
+ if (*r->out.count != r->in.sids->num_sids) {
+ return STATUS_SOME_UNMAPPED;
+ }
+
+ return NT_STATUS_OK;
+}
+
+
+/*
+ lsa_LookupSids3
+
+ Identical to LookupSids2, but doesn't take a policy handle
+
+*/
+NTSTATUS dcesrv_lsa_LookupSids3(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct lsa_LookupSids3 *r)
+{
+ struct lsa_LookupSids2 r2;
+ struct lsa_OpenPolicy2 pol;
+ NTSTATUS status;
+ struct dcesrv_handle *h;
+
+ /* No policy handle on the wire, so make one up here */
+ r2.in.handle = talloc(mem_ctx, struct policy_handle);
+ if (!r2.in.handle) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ pol.out.handle = r2.in.handle;
+ pol.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ pol.in.attr = NULL;
+ pol.in.system_name = NULL;
+ status = dcesrv_lsa_OpenPolicy2(dce_call, mem_ctx, &pol);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ /* ensure this handle goes away at the end of this call */
+ DCESRV_PULL_HANDLE(h, r2.in.handle, LSA_HANDLE_POLICY);
+ talloc_steal(mem_ctx, h);
+
+ r2.in.sids = r->in.sids;
+ r2.in.names = r->in.names;
+ r2.in.level = r->in.level;
+ r2.in.count = r->in.count;
+ r2.in.unknown1 = r->in.unknown1;
+ r2.in.unknown2 = r->in.unknown2;
+ r2.out.count = r->out.count;
+ r2.out.names = r->out.names;
+
+ status = dcesrv_lsa_LookupSids2(dce_call, mem_ctx, &r2);
+ if (dce_call->fault_code != 0) {
+ return status;
+ }
+
+ r->out.domains = r2.out.domains;
+ r->out.names = r2.out.names;
+ r->out.count = r2.out.count;
+
+ return status;
+}
+
+
+/*
+ lsa_LookupSids
+*/
+NTSTATUS dcesrv_lsa_LookupSids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct lsa_LookupSids *r)
+{
+ struct lsa_LookupSids2 r2;
+ NTSTATUS status;
+ int i;
+
+ r2.in.handle = r->in.handle;
+ r2.in.sids = r->in.sids;
+ r2.in.names = NULL;
+ r2.in.level = r->in.level;
+ r2.in.count = r->in.count;
+ r2.in.unknown1 = 0;
+ r2.in.unknown2 = 0;
+ r2.out.count = r->out.count;
+ r2.out.names = NULL;
+
+ status = dcesrv_lsa_LookupSids2(dce_call, mem_ctx, &r2);
+ if (dce_call->fault_code != 0) {
+ return status;
+ }
+
+ r->out.domains = r2.out.domains;
+ if (!r2.out.names) {
+ r->out.names = NULL;
+ return status;
+ }
+
+ r->out.names = talloc(mem_ctx, struct lsa_TransNameArray);
+ if (r->out.names == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ r->out.names->count = r2.out.names->count;
+ r->out.names->names = talloc_array(r->out.names, struct lsa_TranslatedName,
+ r->out.names->count);
+ if (r->out.names->names == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ for (i=0;i<r->out.names->count;i++) {
+ r->out.names->names[i].sid_type = r2.out.names->names[i].sid_type;
+ r->out.names->names[i].name.string = r2.out.names->names[i].name.string;
+ r->out.names->names[i].sid_index = r2.out.names->names[i].sid_index;
+ }
+
+ return status;
+}
+
+
+/*
+ lsa_LookupNames3
+*/
+NTSTATUS dcesrv_lsa_LookupNames3(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct lsa_LookupNames3 *r)
+{
+ struct lsa_policy_state *policy_state;
+ struct dcesrv_handle *policy_handle;
+ int i;
+
+ DCESRV_PULL_HANDLE(policy_handle, r->in.handle, LSA_HANDLE_POLICY);
+
+ policy_state = policy_handle->data;
+
+ r->out.domains = NULL;
+
+ r->out.domains = talloc_zero(mem_ctx, struct lsa_RefDomainList);
+ if (r->out.domains == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ r->out.sids = talloc_zero(mem_ctx, struct lsa_TransSidArray3);
+ if (r->out.sids == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ *r->out.count = 0;
+
+ r->out.sids->sids = talloc_array(r->out.sids, struct lsa_TranslatedSid3,
+ r->in.num_names);
+ if (r->out.sids->sids == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0;i<r->in.num_names;i++) {
+ const char *name = r->in.names[i].string;
+ const char *authority_name;
+ struct dom_sid *sid;
+ uint32_t sid_index;
+ enum lsa_SidType rtype;
+ NTSTATUS status2;
+
+ r->out.sids->count++;
+
+ r->out.sids->sids[i].sid_type = SID_NAME_UNKNOWN;
+ r->out.sids->sids[i].sid = NULL;
+ r->out.sids->sids[i].sid_index = 0xFFFFFFFF;
+ r->out.sids->sids[i].unknown = 0;
+
+ status2 = dcesrv_lsa_lookup_name(policy_state, mem_ctx, name, &authority_name, &sid, &rtype);
+ if (!NT_STATUS_IS_OK(status2) || sid->num_auths == 0) {
+ continue;
+ }
+
+ status2 = dcesrv_lsa_authority_list(policy_state, mem_ctx, rtype, authority_name,
+ sid, r->out.domains, &sid_index);
+ if (!NT_STATUS_IS_OK(status2)) {
+ return status2;
+ }
+
+ r->out.sids->sids[i].sid_type = rtype;
+ r->out.sids->sids[i].sid = sid;
+ r->out.sids->sids[i].sid_index = sid_index;
+ r->out.sids->sids[i].unknown = 0;
+
+ (*r->out.count)++;
+ }
+
+ if (*r->out.count == 0) {
+ return NT_STATUS_NONE_MAPPED;
+ }
+ if (*r->out.count != r->in.num_names) {
+ return STATUS_SOME_UNMAPPED;
+ }
+
+ return NT_STATUS_OK;
+}
+
+/*
+ lsa_LookupNames4
+
+ Identical to LookupNames3, but doesn't take a policy handle
+
+*/
+NTSTATUS dcesrv_lsa_LookupNames4(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct lsa_LookupNames4 *r)
+{
+ struct lsa_LookupNames3 r2;
+ struct lsa_OpenPolicy2 pol;
+ NTSTATUS status;
+ struct dcesrv_handle *h;
+
+ /* No policy handle on the wire, so make one up here */
+ r2.in.handle = talloc(mem_ctx, struct policy_handle);
+ if (!r2.in.handle) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ pol.out.handle = r2.in.handle;
+ pol.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ pol.in.attr = NULL;
+ pol.in.system_name = NULL;
+ status = dcesrv_lsa_OpenPolicy2(dce_call, mem_ctx, &pol);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ /* ensure this handle goes away at the end of this call */
+ DCESRV_PULL_HANDLE(h, r2.in.handle, LSA_HANDLE_POLICY);
+ talloc_steal(mem_ctx, h);
+
+ r2.in.num_names = r->in.num_names;
+ r2.in.names = r->in.names;
+ r2.in.sids = r->in.sids;
+ r2.in.count = r->in.count;
+ r2.in.unknown1 = r->in.unknown1;
+ r2.in.unknown2 = r->in.unknown2;
+ r2.out.domains = r->out.domains;
+ r2.out.sids = r->out.sids;
+ r2.out.count = r->out.count;
+
+ status = dcesrv_lsa_LookupNames3(dce_call, mem_ctx, &r2);
+ if (dce_call->fault_code != 0) {
+ return status;
+ }
+
+ r->out.domains = r2.out.domains;
+ r->out.sids = r2.out.sids;
+ r->out.count = r2.out.count;
+ return status;
+}
+
+/*
+ lsa_LookupNames2
+*/
+NTSTATUS dcesrv_lsa_LookupNames2(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct lsa_LookupNames2 *r)
+{
+ struct lsa_policy_state *state;
+ struct dcesrv_handle *h;
+ int i;
+
+ r->out.domains = NULL;
+
+ DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY);
+
+ state = h->data;
+
+ r->out.domains = talloc_zero(mem_ctx, struct lsa_RefDomainList);
+ if (r->out.domains == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ r->out.sids = talloc_zero(mem_ctx, struct lsa_TransSidArray2);
+ if (r->out.sids == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ *r->out.count = 0;
+
+ r->out.sids->sids = talloc_array(r->out.sids, struct lsa_TranslatedSid2,
+ r->in.num_names);
+ if (r->out.sids->sids == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0;i<r->in.num_names;i++) {
+ const char *name = r->in.names[i].string;
+ const char *authority_name;
+ struct dom_sid *sid;
+ uint32_t rtype, sid_index;
+ NTSTATUS status2;
+
+ r->out.sids->count++;
+
+ r->out.sids->sids[i].sid_type = SID_NAME_UNKNOWN;
+ r->out.sids->sids[i].rid = 0xFFFFFFFF;
+ r->out.sids->sids[i].sid_index = 0xFFFFFFFF;
+ r->out.sids->sids[i].unknown = 0;
+
+ status2 = dcesrv_lsa_lookup_name(state, mem_ctx, name,
+ &authority_name, &sid, &rtype);
+ if (!NT_STATUS_IS_OK(status2)) {
+ continue;
+ }
+
+ status2 = dcesrv_lsa_authority_list(state, mem_ctx, rtype, authority_name,
+ sid, r->out.domains, &sid_index);
+ if (!NT_STATUS_IS_OK(status2)) {
+ return status2;
+ }
+
+ r->out.sids->sids[i].sid_type = rtype;
+ r->out.sids->sids[i].rid = sid->sub_auths[sid->num_auths-1];
+ r->out.sids->sids[i].sid_index = sid_index;
+ r->out.sids->sids[i].unknown = 0;
+
+ (*r->out.count)++;
+ }
+
+ if (*r->out.count == 0) {
+ return NT_STATUS_NONE_MAPPED;
+ }
+ if (*r->out.count != r->in.num_names) {
+ return STATUS_SOME_UNMAPPED;
+ }
+
+ return NT_STATUS_OK;
+}
+
+/*
+ lsa_LookupNames
+*/
+NTSTATUS dcesrv_lsa_LookupNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct lsa_LookupNames *r)
+{
+ struct lsa_LookupNames2 r2;
+ NTSTATUS status;
+ int i;
+
+ r2.in.handle = r->in.handle;
+ r2.in.num_names = r->in.num_names;
+ r2.in.names = r->in.names;
+ r2.in.sids = NULL;
+ r2.in.level = r->in.level;
+ r2.in.count = r->in.count;
+ r2.in.unknown1 = 0;
+ r2.in.unknown2 = 0;
+ r2.out.count = r->out.count;
+
+ status = dcesrv_lsa_LookupNames2(dce_call, mem_ctx, &r2);
+ if (dce_call->fault_code != 0) {
+ return status;
+ }
+
+ r->out.domains = r2.out.domains;
+ r->out.sids = talloc(mem_ctx, struct lsa_TransSidArray);
+ if (r->out.sids == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ r->out.sids->count = r2.out.sids->count;
+ r->out.sids->sids = talloc_array(r->out.sids, struct lsa_TranslatedSid,
+ r->out.sids->count);
+ if (r->out.sids->sids == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ for (i=0;i<r->out.sids->count;i++) {
+ r->out.sids->sids[i].sid_type = r2.out.sids->sids[i].sid_type;
+ r->out.sids->sids[i].rid = r2.out.sids->sids[i].rid;
+ r->out.sids->sids[i].sid_index = r2.out.sids->sids[i].sid_index;
+ }
+
+ return status;
+}
+
diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c
index 2198dc5ebc..45277dc3ed 100644
--- a/source4/rpc_server/netlogon/dcerpc_netlogon.c
+++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c
@@ -32,6 +32,7 @@
#include "libcli/auth/libcli_auth.h"
#include "auth/gensec/schannel_state.h"
#include "libcli/security/security.h"
+#include "param/param.h"
struct server_pipe_state {
struct netr_Credential client_challenge;
@@ -164,7 +165,7 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
creds->account_name = talloc_steal(creds, r->in.account_name);
creds->computer_name = talloc_steal(creds, r->in.computer_name);
- creds->domain = talloc_strdup(creds, lp_workgroup());
+ creds->domain = talloc_strdup(creds, lp_workgroup(global_loadparm));
creds->secure_channel_type = r->in.secure_channel_type;
@@ -258,7 +259,8 @@ static NTSTATUS dcesrv_netr_creds_server_step_check(const char *computer_name,
* disconnects) we must update the database every time we
* update the structure */
- nt_status = schannel_fetch_session_key_ldb(ldb, ldb, computer_name, lp_workgroup(),
+ nt_status = schannel_fetch_session_key_ldb(ldb, ldb, computer_name,
+ lp_workgroup(global_loadparm),
&creds);
if (NT_STATUS_IS_OK(nt_status)) {
nt_status = creds_server_step_check(creds,
@@ -311,7 +313,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet(struct dcesrv_call_state *dce_call
creds->sid,
NULL, /* Don't have plaintext */
NULL, &r->in.new_password,
- False, /* This is not considered a password change */
+ false, /* This is not considered a password change */
NULL, NULL);
return nt_status;
}
@@ -328,7 +330,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet2(struct dcesrv_call_state *dce_cal
NTSTATUS nt_status;
char new_pass[512];
uint32_t new_pass_len;
- BOOL ret;
+ bool ret;
struct samr_CryptPassword password_buf;
@@ -358,7 +360,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet2(struct dcesrv_call_state *dce_cal
creds->sid,
new_pass, /* we have plaintext */
NULL, NULL,
- False, /* This is not considered a password change */
+ false, /* This is not considered a password change */
NULL, NULL);
return nt_status;
}
@@ -408,7 +410,7 @@ static NTSTATUS dcesrv_netr_LogonSamLogon_base(struct dcesrv_call_state *dce_cal
NT_STATUS_HAVE_NO_MEMORY(user_info);
user_info->flags = 0;
- user_info->mapped_state = False;
+ user_info->mapped_state = false;
user_info->remote_host = NULL;
switch (r->in.logon_level) {
@@ -527,7 +529,7 @@ static NTSTATUS dcesrv_netr_LogonSamLogon_base(struct dcesrv_call_state *dce_cal
sam6 = talloc_zero(mem_ctx, struct netr_SamInfo6);
NT_STATUS_HAVE_NO_MEMORY(sam6);
sam6->base = *sam;
- sam6->forest.string = lp_realm();
+ sam6->forest.string = lp_realm(global_loadparm);
sam6->principle.string = talloc_asprintf(mem_ctx, "%s@%s",
sam->account_name.string, sam6->forest.string);
NT_STATUS_HAVE_NO_MEMORY(sam6->principle.string);
@@ -551,7 +553,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, r->in.computer_name, lp_workgroup(), &creds);
+ nt_status = schannel_fetch_session_key(mem_ctx, r->in.computer_name, lp_workgroup(global_loadparm), &creds);
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
@@ -834,7 +836,7 @@ static NTSTATUS fill_domain_trust_info(TALLOC_CTX *mem_ctx,
struct ldb_message *res,
struct ldb_message *ref_res,
struct netr_DomainTrustInfo *info,
- BOOL is_local)
+ bool is_local)
{
ZERO_STRUCTP(info);
@@ -924,15 +926,15 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
info1->num_trusts);
NT_STATUS_HAVE_NO_MEMORY(info1->trusts);
- status = fill_domain_trust_info(mem_ctx, res1[0], ref_res[0], &info1->domaininfo, True);
+ status = fill_domain_trust_info(mem_ctx, res1[0], ref_res[0], &info1->domaininfo, true);
NT_STATUS_NOT_OK_RETURN(status);
for (i=0;i<ret2;i++) {
- status = fill_domain_trust_info(mem_ctx, res2[i], NULL, &info1->trusts[i], False);
+ status = fill_domain_trust_info(mem_ctx, res2[i], NULL, &info1->trusts[i], false);
NT_STATUS_NOT_OK_RETURN(status);
}
- status = fill_domain_trust_info(mem_ctx, res1[0], ref_res[0], &info1->trusts[i], True);
+ status = fill_domain_trust_info(mem_ctx, res1[0], ref_res[0], &info1->trusts[i], true);
NT_STATUS_NOT_OK_RETURN(status);
r->out.info.info1 = info1;
@@ -1003,7 +1005,9 @@ static WERROR dcesrv_netr_DsRGetDCNameEx2(struct dcesrv_call_state *dce_call, TA
/* TODO: - return real IP address
* - check all r->in.* parameters (server_unc is ignored by w2k3!)
*/
- r->out.info->dc_unc = talloc_asprintf(mem_ctx, "\\\\%s.%s", lp_netbios_name(),lp_realm());
+ r->out.info->dc_unc = talloc_asprintf(mem_ctx, "\\\\%s.%s",
+ lp_netbios_name(global_loadparm),
+ lp_realm(global_loadparm));
W_ERROR_HAVE_NO_MEMORY(r->out.info->dc_unc);
r->out.info->dc_address = talloc_strdup(mem_ctx, "\\\\0.0.0.0");
W_ERROR_HAVE_NO_MEMORY(r->out.info->dc_address);
diff --git a/source4/rpc_server/remote/dcesrv_remote.c b/source4/rpc_server/remote/dcesrv_remote.c
index 6ddffa1d6c..f009323ae2 100644
--- a/source4/rpc_server/remote/dcesrv_remote.c
+++ b/source4/rpc_server/remote/dcesrv_remote.c
@@ -23,6 +23,7 @@
#include "auth/auth.h"
#include "auth/credentials/credentials.h"
#include "librpc/ndr/ndr_table.h"
+#include "param/param.h"
struct dcesrv_remote_private {
@@ -39,12 +40,12 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct
NTSTATUS status;
const struct ndr_interface_table *table;
struct dcesrv_remote_private *private;
- const char *binding = lp_parm_string(-1, "dcerpc_remote", "binding");
+ const char *binding = lp_parm_string(global_loadparm, NULL, "dcerpc_remote", "binding");
const char *user, *pass, *domain;
struct cli_credentials *credentials;
- BOOL machine_account;
+ bool machine_account;
- machine_account = lp_parm_bool(-1, "dcerpc_remote", "use_machine_account", False);
+ machine_account = lp_parm_bool(global_loadparm, NULL, "dcerpc_remote", "use_machine_account", false);
private = talloc(dce_call->conn, struct dcesrv_remote_private);
if (!private) {
@@ -59,9 +60,9 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct
return NT_STATUS_INVALID_PARAMETER;
}
- user = lp_parm_string(-1, "dcerpc_remote", "user");
- pass = lp_parm_string(-1, "dcerpc_remote", "password");
- domain = lp_parm_string(-1, "dceprc_remote", "domain");
+ user = lp_parm_string(global_loadparm, NULL, "dcerpc_remote", "user");
+ pass = lp_parm_string(global_loadparm, NULL, "dcerpc_remote", "password");
+ domain = lp_parm_string(global_loadparm, NULL, "dceprc_remote", "domain");
table = ndr_table_by_uuid(&iface->syntax_id.uuid); /* FIXME: What about if_version ? */
if (!table) {
@@ -75,7 +76,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct
if (!credentials) {
return NT_STATUS_NO_MEMORY;
}
- cli_credentials_set_conf(credentials);
+ cli_credentials_set_conf(credentials, global_loadparm);
cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
if (domain) {
cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
@@ -84,7 +85,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct
} else if (machine_account) {
DEBUG(5, ("dcerpc_remote: RPC Proxy: Using machine account\n"));
credentials = cli_credentials_init(private);
- cli_credentials_set_conf(credentials);
+ cli_credentials_set_conf(credentials, global_loadparm);
if (domain) {
cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
}
@@ -114,7 +115,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct
static void remote_op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
{
- struct dcesrv_remote_private *private = context->private;
+ struct dcesrv_remote_private *private = (struct dcesrv_remote_private *)context->private;
talloc_free(private->c_pipe);
@@ -124,7 +125,7 @@ static void remote_op_unbind(struct dcesrv_connection_context *context, const st
static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
{
NTSTATUS status;
- const struct ndr_interface_table *table = dce_call->context->iface->private;
+ const struct ndr_interface_table *table = (const struct ndr_interface_table *)dce_call->context->iface->private;
uint16_t opnum = dce_call->pkt.u.request.opnum;
dce_call->fault_code = 0;
@@ -223,7 +224,7 @@ static NTSTATUS remote_register_one_iface(struct dcesrv_context *dce_ctx, const
static NTSTATUS remote_op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
{
int i;
- const char **ifaces = str_list_make(dce_ctx, lp_parm_string(-1,"dcerpc_remote","interfaces"),NULL);
+ const char **ifaces = str_list_make(dce_ctx, lp_parm_string(global_loadparm, NULL, "dcerpc_remote", "interfaces"),NULL);
if (!ifaces) {
DEBUG(3,("remote_op_init_server: no interfaces configured\n"));
@@ -252,7 +253,7 @@ static NTSTATUS remote_op_init_server(struct dcesrv_context *dce_ctx, const stru
return NT_STATUS_OK;
}
-static BOOL remote_fill_interface(struct dcesrv_interface *iface, const struct ndr_interface_table *if_tabl)
+static bool remote_fill_interface(struct dcesrv_interface *iface, const struct ndr_interface_table *if_tabl)
{
iface->name = if_tabl->name;
iface->syntax_id = if_tabl->syntax_id;
@@ -267,10 +268,10 @@ static BOOL remote_fill_interface(struct dcesrv_interface *iface, const struct n
iface->private = if_tabl;
- return True;
+ return true;
}
-static BOOL remote_op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
+static bool remote_op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
{
const struct ndr_interface_list *l;
@@ -281,17 +282,17 @@ static BOOL remote_op_interface_by_uuid(struct dcesrv_interface *iface, const st
}
}
- return False;
+ return false;
}
-static BOOL remote_op_interface_by_name(struct dcesrv_interface *iface, const char *name)
+static bool remote_op_interface_by_name(struct dcesrv_interface *iface, const char *name)
{
const struct ndr_interface_table *tbl = ndr_table_by_name(name);
if (tbl)
return remote_fill_interface(iface, tbl);
- return False;
+ return false;
}
NTSTATUS dcerpc_server_remote_init(void)
diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c
index fcc52afc03..0ec979b81f 100644
--- a/source4/rpc_server/samr/dcesrv_samr.c
+++ b/source4/rpc_server/samr/dcesrv_samr.c
@@ -35,6 +35,7 @@
#include "libcli/security/security.h"
#include "rpc_server/samr/proto.h"
#include "db_wrap.h"
+#include "param/param.h"
/* these query macros make samr_Query[User|Group]Info a bit easier to read */
@@ -44,8 +45,8 @@
r->out.info->field = samdb_result_uint(msg, attr, 0);
#define QUERY_RID(msg, field, attr) \
r->out.info->field = samdb_result_rid_from_sid(mem_ctx, msg, attr, 0);
-#define QUERY_NTTIME(msg, field, attr) \
- r->out.info->field = samdb_result_nttime(msg, attr, 0);
+#define QUERY_UINT64(msg, field, attr) \
+ r->out.info->field = samdb_result_uint64(msg, attr, 0);
#define QUERY_APASSC(msg, field, attr) \
r->out.info->field = samdb_result_allow_password_change(sam_ctx, mem_ctx, \
a_state->domain_state->domain_dn, msg, attr);
@@ -497,7 +498,7 @@ static NTSTATUS dcesrv_samr_info_DomInfo2(struct samr_domain_state *state, TALLO
struct ldb_message **dom_msgs,
struct samr_DomInfo2 *info)
{
- enum server_role role = lp_server_role();
+ enum server_role role = lp_server_role(global_loadparm);
/* This pulls the NetBIOS name from the
cn=NTDS Settings,cn=<NETBIOS name of PDC>,....
@@ -610,7 +611,7 @@ static NTSTATUS dcesrv_samr_info_DomInfo7(struct samr_domain_state *state,
struct samr_DomInfo7 *info)
{
- enum server_role role = lp_server_role();
+ enum server_role role = lp_server_role(global_loadparm);
switch (role) {
case ROLE_DOMAIN_CONTROLLER:
@@ -3151,9 +3152,9 @@ static NTSTATUS dcesrv_samr_QueryUserInfo(struct dcesrv_call_state *dce_call, TA
QUERY_STRING(msg, info3.logon_script, "scriptPath");
QUERY_STRING(msg, info3.profile_path, "profilePath");
QUERY_STRING(msg, info3.workstations, "userWorkstations");
- QUERY_NTTIME(msg, info3.last_logon, "lastLogon");
- QUERY_NTTIME(msg, info3.last_logoff, "lastLogoff");
- QUERY_NTTIME(msg, info3.last_password_change, "pwdLastSet");
+ QUERY_UINT64(msg, info3.last_logon, "lastLogon");
+ QUERY_UINT64(msg, info3.last_logoff, "lastLogoff");
+ QUERY_UINT64(msg, info3.last_password_change, "pwdLastSet");
QUERY_APASSC(msg, info3.allow_password_change, "pwdLastSet");
QUERY_FPASSC(msg, info3.force_password_change, "pwdLastSet");
QUERY_LHOURS(msg, info3.logon_hours, "logonHours");
@@ -3177,13 +3178,13 @@ static NTSTATUS dcesrv_samr_QueryUserInfo(struct dcesrv_call_state *dce_call, TA
QUERY_STRING(msg, info5.profile_path, "profilePath");
QUERY_STRING(msg, info5.description, "description");
QUERY_STRING(msg, info5.workstations, "userWorkstations");
- QUERY_NTTIME(msg, info5.last_logon, "lastLogon");
- QUERY_NTTIME(msg, info5.last_logoff, "lastLogoff");
+ QUERY_UINT64(msg, info5.last_logon, "lastLogon");
+ QUERY_UINT64(msg, info5.last_logoff, "lastLogoff");
QUERY_LHOURS(msg, info5.logon_hours, "logonHours");
QUERY_UINT (msg, info5.bad_password_count, "badPwdCount");
QUERY_UINT (msg, info5.logon_count, "logonCount");
- QUERY_NTTIME(msg, info5.last_password_change, "pwdLastSet");
- QUERY_NTTIME(msg, info5.acct_expiry, "accountExpires");
+ QUERY_UINT64(msg, info5.last_password_change, "pwdLastSet");
+ QUERY_UINT64(msg, info5.acct_expiry, "accountExpires");
QUERY_AFLAGS(msg, info5.acct_flags, "userAccountControl");
break;
@@ -3230,17 +3231,18 @@ static NTSTATUS dcesrv_samr_QueryUserInfo(struct dcesrv_call_state *dce_call, TA
break;
case 17:
- QUERY_NTTIME(msg, info17.acct_expiry, "accountExpires");
+ QUERY_UINT64(msg, info17.acct_expiry, "accountExpires");
+ break;
case 20:
QUERY_STRING(msg, info20.parameters, "userParameters");
break;
case 21:
- QUERY_NTTIME(msg, info21.last_logon, "lastLogon");
- QUERY_NTTIME(msg, info21.last_logoff, "lastLogoff");
- QUERY_NTTIME(msg, info21.last_password_change, "pwdLastSet");
- QUERY_NTTIME(msg, info21.acct_expiry, "accountExpires");
+ QUERY_UINT64(msg, info21.last_logon, "lastLogon");
+ QUERY_UINT64(msg, info21.last_logoff, "lastLogoff");
+ QUERY_UINT64(msg, info21.last_password_change, "pwdLastSet");
+ QUERY_UINT64(msg, info21.acct_expiry, "accountExpires");
QUERY_APASSC(msg, info21.allow_password_change,"pwdLastSet");
QUERY_FPASSC(msg, info21.force_password_change,"pwdLastSet");
QUERY_STRING(msg, info21.account_name, "sAMAccountName");
diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c
index e3cb70ad17..28816c03f8 100644
--- a/source4/rpc_server/samr/samr_password.c
+++ b/source4/rpc_server/samr/samr_password.c
@@ -143,7 +143,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser(struct dcesrv_call_state *dce_call, TALL
status = samdb_set_password(sam_ctx, mem_ctx,
a_state->account_dn, a_state->domain_state->domain_dn,
msg, NULL, &new_lmPwdHash, &new_ntPwdHash,
- True, /* this is a user password change */
+ true, /* this is a user password change */
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
@@ -278,7 +278,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
user_dn, NULL,
mod, new_pass,
NULL, NULL,
- True, /* this is a user password change */
+ true, /* this is a user password change */
NULL,
NULL);
if (!NT_STATUS_IS_OK(status)) {
@@ -431,7 +431,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
user_dn, NULL,
mod, new_pass,
NULL, NULL,
- True, /* this is a user password change */
+ true, /* this is a user password change */
&reason,
&dominfo);
if (!NT_STATUS_IS_OK(status)) {
@@ -539,7 +539,7 @@ NTSTATUS samr_set_password(struct dcesrv_call_state *dce_call,
account_dn, domain_dn,
msg, new_pass,
NULL, NULL,
- False, /* This is a password set, not change */
+ false, /* This is a password set, not change */
NULL, NULL);
}
@@ -592,7 +592,7 @@ NTSTATUS samr_set_password_ex(struct dcesrv_call_state *dce_call,
account_dn, domain_dn,
msg, new_pass,
NULL, NULL,
- False, /* This is a password set, not change */
+ false, /* This is a password set, not change */
NULL, NULL);
}
diff --git a/source4/rpc_server/dcerpc_sock.c b/source4/rpc_server/service_rpc.c
index 834758356b..04dd5a8ee9 100644
--- a/source4/rpc_server/dcerpc_sock.c
+++ b/source4/rpc_server/service_rpc.c
@@ -1,12 +1,12 @@
/*
Unix SMB/CIFS implementation.
- server side dcerpc using various kinds of sockets (tcp, unix domain)
-
- Copyright (C) Andrew Tridgell 2003
- Copyright (C) Stefan (metze) Metzmacher 2004-2005
- Copyright (C) Jelmer Vernooij 2004
+ smbd-specific dcerpc server code
+ Copyright (C) Andrew Tridgell 2003-2005
+ Copyright (C) Stefan (metze) Metzmacher 2004-2005
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2004,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
@@ -22,15 +22,23 @@
*/
#include "includes.h"
-#include "lib/socket/socket.h"
-#include "lib/events/events.h"
+#include "librpc/gen_ndr/ndr_dcerpc.h"
+#include "auth/auth.h"
+#include "auth/gensec/gensec.h"
+#include "lib/util/dlinklist.h"
#include "rpc_server/dcerpc_server.h"
+#include "lib/events/events.h"
+#include "smbd/service_task.h"
#include "smbd/service_stream.h"
#include "smbd/service.h"
+#include "system/filesys.h"
+#include "libcli/security/security.h"
+#include "lib/socket/socket.h"
#include "lib/messaging/irpc.h"
#include "system/network.h"
#include "lib/socket/netif.h"
-#include "auth/auth.h"
+#include "build.h"
+#include "param/param.h"
struct dcesrv_socket_context {
const struct dcesrv_endpoint *endpoint;
@@ -165,9 +173,9 @@ static void dcesrv_sock_recv(struct stream_connection *conn, uint16_t flags)
tmp_blob.length = nread;
- dce_conn->processing = True;
+ dce_conn->processing = true;
status = dcesrv_input(dce_conn, &tmp_blob);
- dce_conn->processing = False;
+ dce_conn->processing = false;
talloc_free(tmp_blob.data);
EVENT_FD_READABLE(conn->event.fde);
@@ -208,8 +216,8 @@ static const struct stream_server_ops dcesrv_stream_ops = {
-NTSTATUS dcesrv_add_ep_unix(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
- struct event_context *event_ctx, const struct model_ops *model_ops)
+static NTSTATUS dcesrv_add_ep_unix(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
+ struct event_context *event_ctx, const struct model_ops *model_ops)
{
struct dcesrv_socket_context *dcesrv_sock;
uint16_t port = 1;
@@ -233,8 +241,8 @@ NTSTATUS dcesrv_add_ep_unix(struct dcesrv_context *dce_ctx, struct dcesrv_endpoi
return status;
}
-NTSTATUS dcesrv_add_ep_ncalrpc(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
- struct event_context *event_ctx, const struct model_ops *model_ops)
+static NTSTATUS dcesrv_add_ep_ncalrpc(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
+ struct event_context *event_ctx, const struct model_ops *model_ops)
{
struct dcesrv_socket_context *dcesrv_sock;
uint16_t port = 1;
@@ -248,7 +256,8 @@ NTSTATUS dcesrv_add_ep_ncalrpc(struct dcesrv_context *dce_ctx, struct dcesrv_end
e->ep_description->endpoint = talloc_strdup(dce_ctx, "DEFAULT");
}
- full_path = talloc_asprintf(dce_ctx, "%s/%s", lp_ncalrpc_dir(), e->ep_description->endpoint);
+ full_path = talloc_asprintf(dce_ctx, "%s/%s", lp_ncalrpc_dir(global_loadparm),
+ e->ep_description->endpoint);
dcesrv_sock = talloc(event_ctx, struct dcesrv_socket_context);
NT_STATUS_HAVE_NO_MEMORY(dcesrv_sock);
@@ -301,7 +310,7 @@ static NTSTATUS add_socket_rpc_pipe_iface(struct dcesrv_context *dce_ctx, struct
return status;
}
-NTSTATUS dcesrv_add_ep_np(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
+static NTSTATUS dcesrv_add_ep_np(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
struct event_context *event_ctx, const struct model_ops *model_ops)
{
NTSTATUS status;
@@ -348,13 +357,13 @@ static NTSTATUS add_socket_rpc_tcp_iface(struct dcesrv_context *dce_ctx, struct
return status;
}
-NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
+static NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
struct event_context *event_ctx, const struct model_ops *model_ops)
{
NTSTATUS status;
/* Add TCP/IP sockets */
- if (lp_interfaces() && lp_bind_interfaces_only()) {
+ if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) {
int num_interfaces = iface_count();
int i;
for(i = 0; i < num_interfaces; i++) {
@@ -363,9 +372,88 @@ NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx, struct dcesrv_endpoin
NT_STATUS_NOT_OK_RETURN(status);
}
} else {
- status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, lp_socket_address());
+ status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops,
+ lp_socket_address(global_loadparm));
NT_STATUS_NOT_OK_RETURN(status);
}
return NT_STATUS_OK;
}
+
+
+static NTSTATUS dcesrv_add_ep(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e,
+ struct event_context *event_ctx, const struct model_ops *model_ops)
+{
+ switch (e->ep_description->transport) {
+ case NCACN_UNIX_STREAM:
+ return dcesrv_add_ep_unix(dce_ctx, e, event_ctx, model_ops);
+
+ case NCALRPC:
+ return dcesrv_add_ep_ncalrpc(dce_ctx, e, event_ctx, model_ops);
+
+ case NCACN_IP_TCP:
+ return dcesrv_add_ep_tcp(dce_ctx, e, event_ctx, model_ops);
+
+ case NCACN_NP:
+ return dcesrv_add_ep_np(dce_ctx, e, event_ctx, model_ops);
+
+ default:
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+}
+
+/*
+ open the dcerpc server sockets
+*/
+static void dcesrv_task_init(struct task_server *task)
+{
+ NTSTATUS status;
+ struct dcesrv_context *dce_ctx;
+ struct dcesrv_endpoint *e;
+
+ task_server_set_title(task, "task[dcesrv]");
+
+ status = dcesrv_init_context(task->event_ctx,
+ lp_dcerpc_endpoint_servers(global_loadparm),
+ &dce_ctx);
+ if (!NT_STATUS_IS_OK(status)) goto failed;
+
+ /* Make sure the directory for NCALRPC exists */
+ if (!directory_exist(lp_ncalrpc_dir(global_loadparm))) {
+ mkdir(lp_ncalrpc_dir(global_loadparm), 0755);
+ }
+
+ for (e=dce_ctx->endpoint_list;e;e=e->next) {
+ status = dcesrv_add_ep(dce_ctx, e, task->event_ctx, task->model_ops);
+ if (!NT_STATUS_IS_OK(status)) goto failed;
+ }
+
+ return;
+failed:
+ task_server_terminate(task, "Failed to startup dcerpc server task");
+}
+
+/*
+ called on startup of the smb server service It's job is to start
+ listening on all configured sockets
+*/
+static NTSTATUS dcesrv_init(struct event_context *event_context,
+ const struct model_ops *model_ops)
+{
+ return task_server_startup(event_context, model_ops, dcesrv_task_init);
+}
+
+NTSTATUS server_service_rpc_init(void)
+{
+ init_module_fn static_init[] = STATIC_dcerpc_server_MODULES;
+ init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "dcerpc_server");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
+ return register_server_service("rpc", dcesrv_init);
+}
+
+
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index 2dca178245..09409b1514 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -27,6 +27,13 @@
#include "ntptr/ntptr.h"
#include "lib/socket/socket.h"
#include "smbd/service_stream.h"
+#include "librpc/gen_ndr/ndr_spoolss_c.h"
+#include "auth/credentials/credentials.h"
+#include "param/param.h"
+
+enum spoolss_handle {
+ SPOOLSS_NOTIFY
+};
#define SPOOLSS_BUFFER_UNION(fn,info,level) \
((info)?ndr_size_##fn(info, level, 0):0)
@@ -142,7 +149,7 @@ static WERROR dcesrv_spoolss_check_server_name(struct dcesrv_call_state *dce_cal
TALLOC_CTX *mem_ctx,
const char *server_name)
{
- BOOL ret;
+ bool ret;
struct socket_address *myaddr;
const char **aliases;
int i;
@@ -167,10 +174,10 @@ static WERROR dcesrv_spoolss_check_server_name(struct dcesrv_call_state *dce_cal
server_name += 2;
/* NETBIOS NAME is ok */
- ret = strequal(lp_netbios_name(), server_name);
+ ret = strequal(lp_netbios_name(global_loadparm), server_name);
if (ret) return WERR_OK;
- aliases = lp_netbios_aliases();
+ aliases = lp_netbios_aliases(global_loadparm);
for (i=0; aliases && aliases[i]; i++) {
if (strequal(aliases[i], server_name)) {
@@ -181,12 +188,12 @@ static WERROR dcesrv_spoolss_check_server_name(struct dcesrv_call_state *dce_cal
/* DNS NAME is ok
* TODO: we need to check if aliases are also ok
*/
- if (lp_realm()) {
+ if (lp_realm(global_loadparm)) {
char *str;
str = talloc_asprintf(mem_ctx, "%s.%s",
- lp_netbios_name(),
- lp_realm());
+ lp_netbios_name(global_loadparm),
+ lp_realm(global_loadparm));
W_ERROR_HAVE_NO_MEMORY(str);
ret = strequal(str, server_name);
@@ -209,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, lp_ntptr_providor(), &ntptr);
+ status = ntptr_init_context(dce_call->context, lp_ntptr_providor(global_loadparm), &ntptr);
NT_STATUS_NOT_OK_RETURN(status);
dce_call->context->private = ntptr;
@@ -1036,7 +1043,16 @@ static WERROR dcesrv_spoolss_RouterFindFirstPrinterChangeNotificationOld(struct
static WERROR dcesrv_spoolss_ReplyOpenPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct spoolss_ReplyOpenPrinter *r)
{
- DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+ struct dcesrv_handle *handle;
+
+ handle = dcesrv_handle_new(dce_call->context, SPOOLSS_NOTIFY);
+ W_ERROR_HAVE_NO_MEMORY(handle);
+
+ /* For now, just return a handle */
+
+ *r->out.handle = handle->wire_handle;
+
+ return WERR_OK;
}
@@ -1056,9 +1072,16 @@ static WERROR dcesrv_spoolss_RouterReplyPrinter(struct dcesrv_call_state *dce_ca
static WERROR dcesrv_spoolss_ReplyClosePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct spoolss_ReplyClosePrinter *r)
{
- DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
+ struct dcesrv_handle *handle;
+
+ DCESRV_PULL_HANDLE_WERR(handle, r->in.handle, SPOOLSS_NOTIFY);
+ talloc_free(handle);
+
+ ZERO_STRUCTP(r->out.handle);
+
+ return WERR_OK;
+}
/*
spoolss_AddPortEx
@@ -1106,11 +1129,56 @@ static WERROR dcesrv_spoolss_ResetPrinterEx(struct dcesrv_call_state *dce_call,
static WERROR dcesrv_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
{
+ struct dcerpc_pipe *p;
+ struct dcerpc_binding *binding;
+ NTSTATUS status;
+ struct spoolss_ReplyOpenPrinter rop;
+ struct cli_credentials *creds;
+ struct policy_handle notify_handle;
+
+ DEBUG(2, ("Received RFFPCNex from %s\n", r->in.str));
+
/*
- * TODO: for now just return ok,
+ * TODO: for now just open a connection to the client and drop it again
* to keep the w2k3 PrintServer
* happy to allow to open the Add Printer GUI
+ * and the torture suite passing
*/
+
+ binding = talloc_zero(mem_ctx, struct dcerpc_binding);
+
+ binding->transport = NCACN_NP;
+ if (strncmp(r->in.str, "\\\\", 2))
+ return WERR_INVALID_COMPUTERNAME;
+ binding->host = r->in.str+2;
+
+ 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);
+
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(0, ("unable to call back to %s\n", r->in.str));
+ return WERR_SERVER_UNAVAILABLE;
+ }
+
+ ZERO_STRUCT(rop);
+ rop.in.server_name = lp_netbios_name(global_loadparm);
+ W_ERROR_HAVE_NO_MEMORY(rop.in.server_name);
+ rop.in.printer_local = 0;
+ rop.in.type = REG_NONE;
+ rop.in.unknown1 = 0;
+ rop.in.unknown2 = 0;
+ rop.out.handle = &notify_handle;
+
+ status = dcerpc_spoolss_ReplyOpenPrinter(p, mem_ctx, &rop);
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(0, ("unable to open remote printer %s\n", r->in.str));
+ return WERR_SERVER_UNAVAILABLE;
+ }
+
+ talloc_free(p);
+
return WERR_OK;
}
diff --git a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
index c0e1a0d2b4..aee88d915c 100644
--- a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
+++ b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
@@ -28,6 +28,7 @@
#include "libcli/security/security.h"
#include "system/time.h"
#include "rpc_server/srvsvc/proto.h"
+#include "param/param.h"
#define SRVSVC_CHECK_ADMIN_ACCESS do { \
struct security_token *t = dce_call->conn->auth_state.session_info->security_token; \
@@ -1498,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);
info101->version_minor = dcesrv_common_get_version_minor(mem_ctx, dce_ctx);
info101->server_type = dcesrv_common_get_server_type(mem_ctx, dce_ctx);
- info101->comment = talloc_strdup(mem_ctx, lp_serverstring());
+ info101->comment = talloc_strdup(mem_ctx, lp_serverstring(global_loadparm));
W_ERROR_HAVE_NO_MEMORY(info101->comment);
r->out.info.info101 = info101;
@@ -1518,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);
info102->version_minor = dcesrv_common_get_version_minor(mem_ctx, dce_ctx);
info102->server_type = dcesrv_common_get_server_type(mem_ctx, dce_ctx);
- info102->comment = talloc_strdup(mem_ctx, lp_serverstring());
+ info102->comment = talloc_strdup(mem_ctx, lp_serverstring(global_loadparm));
W_ERROR_HAVE_NO_MEMORY(info102->comment);
info102->users = dcesrv_common_get_users(mem_ctx, dce_ctx);
diff --git a/source4/rpc_server/winreg/rpc_winreg.c b/source4/rpc_server/winreg/rpc_winreg.c
index d3d9977c12..3aea8e62c1 100644
--- a/source4/rpc_server/winreg/rpc_winreg.c
+++ b/source4/rpc_server/winreg/rpc_winreg.c
@@ -1,20 +1,20 @@
-/*
+/*
Unix SMB/CIFS implementation.
endpoint server for the winreg pipe
Copyright (C) Jelmer Vernooij 2004
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -28,14 +28,15 @@
enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY };
-static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call,
- const struct dcesrv_interface *iface)
+static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call,
+ const struct dcesrv_interface *iface)
{
struct registry_context *ctx;
WERROR err;
err = reg_open_samba(dce_call->context,
- &ctx, dce_call->conn->auth_state.session_info, NULL);
+ &ctx, dce_call->conn->auth_state.session_info,
+ NULL);
if (!W_ERROR_IS_OK(err)) {
DEBUG(0, ("Error opening registry: %s\n", win_errstr(err)));
@@ -49,24 +50,25 @@ static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call,
#define DCESRV_INTERFACE_WINREG_BIND dcerpc_winreg_bind
-static WERROR dcesrv_winreg_openhive(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx, uint32_t hkey,
- struct policy_handle **outh)
+static WERROR dcesrv_winreg_openhive(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx, uint32_t hkey,
+ struct policy_handle **outh)
{
struct registry_context *ctx = dce_call->context->private;
- struct dcesrv_handle *h;
+ struct dcesrv_handle *h;
WERROR error;
- h = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
+ h = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
- error = reg_get_predefined_key(ctx, hkey, (struct registry_key **)&h->data);
+ error = reg_get_predefined_key(ctx, hkey,
+ (struct registry_key **)&h->data);
if (!W_ERROR_IS_OK(error)) {
return error;
}
-
- *outh = &h->wire_handle;
- return error;
+ *outh = &h->wire_handle;
+
+ return error;
}
#define func_winreg_OpenHive(k,n) static WERROR dcesrv_winreg_Open ## k (struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct winreg_Open ## k *r) \
@@ -84,14 +86,14 @@ func_winreg_OpenHive(HKDD,HKEY_DYN_DATA)
func_winreg_OpenHive(HKPT,HKEY_PERFORMANCE_TEXT)
func_winreg_OpenHive(HKPN,HKEY_PERFORMANCE_NLSTEXT)
-/*
- winreg_CloseKey
+/*
+ winreg_CloseKey
*/
-static WERROR dcesrv_winreg_CloseKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_CloseKey *r)
+static WERROR dcesrv_winreg_CloseKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_CloseKey *r)
{
- struct dcesrv_handle *h;
+ struct dcesrv_handle *h;
DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
@@ -102,19 +104,19 @@ static WERROR dcesrv_winreg_CloseKey(struct dcesrv_call_state *dce_call,
return WERR_OK;
}
-/*
- winreg_CreateKey
+/*
+ winreg_CreateKey
*/
-static WERROR dcesrv_winreg_CreateKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_CreateKey *r)
+static WERROR dcesrv_winreg_CreateKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_CreateKey *r)
{
struct dcesrv_handle *h, *newh;
WERROR error;
struct security_descriptor sd;
DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
-
+
newh = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
/* the security descriptor is optional */
@@ -126,16 +128,16 @@ static WERROR dcesrv_winreg_CreateKey(struct dcesrv_call_state *dce_call,
if (sdblob.data == NULL) {
return WERR_INVALID_PARAM;
}
- status = ndr_pull_struct_blob_all(&sdblob, mem_ctx, &sd,
+ status = ndr_pull_struct_blob_all(&sdblob, mem_ctx, &sd,
(ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
if (!NT_STATUS_IS_OK(status)) {
return WERR_INVALID_PARAM;
}
}
- error = reg_key_add_name(newh, (struct registry_key *)h->data,
- r->in.name.name, NULL, r->in.secdesc?&sd:NULL,
- (struct registry_key **)&newh->data);
+ error = reg_key_add_name(newh, (struct registry_key *)h->data,
+ r->in.name.name, NULL, r->in.secdesc?&sd:NULL,
+ (struct registry_key **)&newh->data);
if (W_ERROR_IS_OK(error)) {
r->out.new_handle = &newh->wire_handle;
} else {
@@ -146,27 +148,27 @@ static WERROR dcesrv_winreg_CreateKey(struct dcesrv_call_state *dce_call,
}
-/*
- winreg_DeleteKey
+/*
+ winreg_DeleteKey
*/
-static WERROR dcesrv_winreg_DeleteKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_DeleteKey *r)
+static WERROR dcesrv_winreg_DeleteKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_DeleteKey *r)
{
struct dcesrv_handle *h;
DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
-
+
return reg_key_del((struct registry_key *)h->data, r->in.key.name);
}
-/*
- winreg_DeleteValue
+/*
+ winreg_DeleteValue
*/
-static WERROR dcesrv_winreg_DeleteValue(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_DeleteValue *r)
+static WERROR dcesrv_winreg_DeleteValue(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_DeleteValue *r)
{
struct dcesrv_handle *h;
struct registry_key *key;
@@ -174,17 +176,17 @@ static WERROR dcesrv_winreg_DeleteValue(struct dcesrv_call_state *dce_call,
DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
key = h->data;
-
+
return reg_del_value(key, r->in.value.name);
}
-/*
- winreg_EnumKey
+/*
+ winreg_EnumKey
*/
-static WERROR dcesrv_winreg_EnumKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_EnumKey *r)
+static WERROR dcesrv_winreg_EnumKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_EnumKey *r)
{
struct dcesrv_handle *h;
const char *name;
@@ -192,9 +194,10 @@ static WERROR dcesrv_winreg_EnumKey(struct dcesrv_call_state *dce_call,
DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
- r->out.result = reg_key_get_subkey_by_index(mem_ctx,
- (struct registry_key *)h->data, r->in.enum_index,
- &name, NULL, &last_mod);
+ r->out.result = reg_key_get_subkey_by_index(mem_ctx,
+ (struct registry_key *)h->data,
+ r->in.enum_index,
+ &name, NULL, &last_mod);
if (W_ERROR_IS_OK(r->out.result)) {
if (2*strlen_m_term(name) > r->in.name->size) {
@@ -207,17 +210,17 @@ static WERROR dcesrv_winreg_EnumKey(struct dcesrv_call_state *dce_call,
r->out.last_changed_time = &last_mod;
}
}
-
+
return r->out.result;
}
-/*
- winreg_EnumValue
+/*
+ winreg_EnumValue
*/
-static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_EnumValue *r)
+static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_EnumValue *r)
{
struct dcesrv_handle *h;
struct registry_key *key;
@@ -230,9 +233,9 @@ static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call,
key = h->data;
- result = reg_key_get_value_by_index(mem_ctx, key, r->in.enum_index,
- &data_name,
- &data_type, &data);
+ result = reg_key_get_value_by_index(mem_ctx, key, r->in.enum_index,
+ &data_name,
+ &data_type, &data);
if (!W_ERROR_IS_OK(result)) {
return result;
}
@@ -246,14 +249,14 @@ static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call,
/* check the client has enough room for the value */
if (r->in.value != NULL &&
- r->in.size != NULL &&
+ r->in.size != NULL &&
data.length > *r->in.size) {
return WERR_MORE_DATA;
}
-
+
/* and enough room for the name */
if (r->in.name->size < 2*strlen_m_term(data_name)) {
- return WERR_MORE_DATA;
+ return WERR_MORE_DATA;
}
r->out.name->name = data_name;
@@ -269,17 +272,17 @@ static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call,
*r->out.size = data.length;
r->out.length = r->out.size;
}
-
+
return WERR_OK;
}
-/*
- winreg_FlushKey
+/*
+ winreg_FlushKey
*/
-static WERROR dcesrv_winreg_FlushKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_FlushKey *r)
+static WERROR dcesrv_winreg_FlushKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_FlushKey *r)
{
struct dcesrv_handle *h;
@@ -289,12 +292,12 @@ static WERROR dcesrv_winreg_FlushKey(struct dcesrv_call_state *dce_call,
}
-/*
- winreg_GetKeySecurity
+/*
+ winreg_GetKeySecurity
*/
-static WERROR dcesrv_winreg_GetKeySecurity(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_GetKeySecurity *r)
+static WERROR dcesrv_winreg_GetKeySecurity(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_GetKeySecurity *r)
{
struct dcesrv_handle *h;
@@ -304,34 +307,34 @@ static WERROR dcesrv_winreg_GetKeySecurity(struct dcesrv_call_state *dce_call,
}
-/*
- winreg_LoadKey
+/*
+ winreg_LoadKey
*/
-static WERROR dcesrv_winreg_LoadKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_LoadKey *r)
+static WERROR dcesrv_winreg_LoadKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_LoadKey *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_NotifyChangeKeyValue
+/*
+ winreg_NotifyChangeKeyValue
*/
-static WERROR dcesrv_winreg_NotifyChangeKeyValue(
- struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx, struct winreg_NotifyChangeKeyValue *r)
+static WERROR dcesrv_winreg_NotifyChangeKeyValue(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_NotifyChangeKeyValue *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_OpenKey
+/*
+ winreg_OpenKey
*/
-static WERROR dcesrv_winreg_OpenKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_OpenKey *r)
+static WERROR dcesrv_winreg_OpenKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_OpenKey *r)
{
struct dcesrv_handle *h, *newh;
WERROR result;
@@ -343,26 +346,27 @@ static WERROR dcesrv_winreg_OpenKey(struct dcesrv_call_state *dce_call,
result = WERR_OK;
} else {
newh = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
- result = reg_open_key(newh, (struct registry_key *)h->data,
- r->in.keyname.name, (struct registry_key **)&newh->data);
+ result = reg_open_key(newh, (struct registry_key *)h->data,
+ r->in.keyname.name,
+ (struct registry_key **)&newh->data);
}
-
+
if (W_ERROR_IS_OK(result)) {
- r->out.handle = &newh->wire_handle;
+ r->out.handle = &newh->wire_handle;
} else {
talloc_free(newh);
}
-
+
return result;
}
-/*
- winreg_QueryInfoKey
+/*
+ winreg_QueryInfoKey
*/
-static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_QueryInfoKey *r)
+static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_QueryInfoKey *r)
{
struct dcesrv_handle *h;
struct registry_key *k;
@@ -373,8 +377,8 @@ static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call,
k = h->data;
- ret = reg_key_get_info(mem_ctx, k, &classname, r->out.num_subkeys,
- r->out.num_values, r->out.last_changed_time);
+ ret = reg_key_get_info(mem_ctx, k, &classname, r->out.num_subkeys,
+ r->out.num_values, r->out.last_changed_time);
if (r->out.classname != NULL)
r->out.classname->name = classname;
@@ -383,12 +387,12 @@ static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call,
}
-/*
- winreg_QueryValue
+/*
+ winreg_QueryValue
*/
-static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_QueryValue *r)
+static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_QueryValue *r)
{
struct dcesrv_handle *h;
struct registry_key *key;
@@ -399,11 +403,11 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call,
DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
key = h->data;
-
- result = reg_key_get_value_by_name(mem_ctx, key, r->in.value_name.name,
- &value_type, &value_data);
- if (!W_ERROR_IS_OK(result)) {
+ result = reg_key_get_value_by_name(mem_ctx, key, r->in.value_name.name,
+ &value_type, &value_data);
+
+ if (!W_ERROR_IS_OK(result)) {
return result;
}
@@ -430,56 +434,56 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call,
}
-/*
- winreg_ReplaceKey
+/*
+ winreg_ReplaceKey
*/
-static WERROR dcesrv_winreg_ReplaceKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_ReplaceKey *r)
+static WERROR dcesrv_winreg_ReplaceKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_ReplaceKey *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_RestoreKey
+/*
+ winreg_RestoreKey
*/
-static WERROR dcesrv_winreg_RestoreKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_RestoreKey *r)
+static WERROR dcesrv_winreg_RestoreKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_RestoreKey *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_SaveKey
+/*
+ winreg_SaveKey
*/
-static WERROR dcesrv_winreg_SaveKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_SaveKey *r)
+static WERROR dcesrv_winreg_SaveKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_SaveKey *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_SetKeySecurity
+/*
+ winreg_SetKeySecurity
*/
-static WERROR dcesrv_winreg_SetKeySecurity(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_SetKeySecurity *r)
+static WERROR dcesrv_winreg_SetKeySecurity(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_SetKeySecurity *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_SetValue
+/*
+ winreg_SetValue
*/
-static WERROR dcesrv_winreg_SetValue(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_SetValue *r)
+static WERROR dcesrv_winreg_SetValue(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_SetValue *r)
{
struct dcesrv_handle *h;
struct registry_key *key;
@@ -489,7 +493,7 @@ static WERROR dcesrv_winreg_SetValue(struct dcesrv_call_state *dce_call,
DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
key = h->data;
-
+
data.data = r->in.data;
data.length = r->in.size;
result = reg_val_set(key, r->in.name.name, r->in.type, data);
@@ -498,45 +502,45 @@ static WERROR dcesrv_winreg_SetValue(struct dcesrv_call_state *dce_call,
}
-/*
- winreg_UnLoadKey
+/*
+ winreg_UnLoadKey
*/
-static WERROR dcesrv_winreg_UnLoadKey(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_UnLoadKey *r)
+static WERROR dcesrv_winreg_UnLoadKey(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_UnLoadKey *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_InitiateSystemShutdown
+/*
+ winreg_InitiateSystemShutdown
*/
-static WERROR dcesrv_winreg_InitiateSystemShutdown(
- struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct winreg_InitiateSystemShutdown *r)
+static WERROR dcesrv_winreg_InitiateSystemShutdown(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_InitiateSystemShutdown *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_AbortSystemShutdown
+/*
+ winreg_AbortSystemShutdown
*/
-static WERROR dcesrv_winreg_AbortSystemShutdown(
- struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct winreg_AbortSystemShutdown *r)
+static WERROR dcesrv_winreg_AbortSystemShutdown(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_AbortSystemShutdown *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_GetVersion
+/*
+ winreg_GetVersion
*/
-static WERROR dcesrv_winreg_GetVersion(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_GetVersion *r)
+static WERROR dcesrv_winreg_GetVersion(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_GetVersion *r)
{
struct dcesrv_handle *h;
@@ -551,45 +555,45 @@ static WERROR dcesrv_winreg_GetVersion(struct dcesrv_call_state *dce_call,
}
-/*
- winreg_QueryMultipleValues
+/*
+ winreg_QueryMultipleValues
*/
-static WERROR dcesrv_winreg_QueryMultipleValues(
- struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct winreg_QueryMultipleValues *r)
+static WERROR dcesrv_winreg_QueryMultipleValues(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_QueryMultipleValues *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_InitiateSystemShutdownEx
+/*
+ winreg_InitiateSystemShutdownEx
*/
-static WERROR dcesrv_winreg_InitiateSystemShutdownEx(
- struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct winreg_InitiateSystemShutdownEx *r)
+static WERROR dcesrv_winreg_InitiateSystemShutdownEx(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_InitiateSystemShutdownEx *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_SaveKeyEx
+/*
+ winreg_SaveKeyEx
*/
-static WERROR dcesrv_winreg_SaveKeyEx(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct winreg_SaveKeyEx *r)
+static WERROR dcesrv_winreg_SaveKeyEx(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_SaveKeyEx *r)
{
return WERR_NOT_SUPPORTED;
}
-/*
- winreg_QueryMultipleValues2
+/*
+ winreg_QueryMultipleValues2
*/
-static WERROR dcesrv_winreg_QueryMultipleValues2(
- struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct winreg_QueryMultipleValues2 *r)
+static WERROR dcesrv_winreg_QueryMultipleValues2(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct winreg_QueryMultipleValues2 *r)
{
return WERR_NOT_SUPPORTED;
}
diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail
index 02d024726e..d2a227a1dc 100644
--- a/source4/samba4-knownfail
+++ b/source4/samba4-knownfail
@@ -13,3 +13,18 @@ RPC-HANDLES.*/mixed-shared
RPC-EPMAPPER.*/Insert
RPC-EPMAPPER.*/InqObject
RPC-DFS.*
+RPC-DRSUAPI.*
+RPC-LSALOOKUP
+RPC-CRACKNAMES
+RPC-NETLOGON.*/LogonUasLogon
+RPC-NETLOGON.*/LogonUasLogoff
+RPC-NETLOGON.*/DatabaseSync
+RPC-NETLOGON.*/DatabaseSync2
+RPC-NETLOGON.*/GetDcName
+RPC-NETLOGON.*/LogonControl
+RPC-NETLOGON.*/LogonControl2
+RPC-NETLOGON.*/GetAnyDCName
+RPC-NETLOGON.*/DsrEnumerateDomainTrusts
+RPC-NETLOGON.*/DsrGetDcSiteCoverageW
+BASE-CHARSET.*/Testing partial surrogate
+.*NET-API-DELSHARE.* # DelShare isn't implemented yet
diff --git a/source4/samba4-skip b/source4/samba4-skip
index 4a09985406..f273c4c51c 100644
--- a/source4/samba4-skip
+++ b/source4/samba4-skip
@@ -1,21 +1,16 @@
-BASE-CHARSET
BASE-DEFER_OPEN
BASE-DELAYWRITE
RAW-COMPOSITE
RAW-OPLOCK
BASE-IOMETER
-BASE-SAMBA3ERROR
BASE-CASETABLE
BASE-NTTRANS
-BASE-BENCH-HOLDCON
+.*BASE-BENCH-HOLDCON.* # Very slow
BASE-SCAN-MAXFID
RAW-BENCH-OPLOCK
RAW-HOLD-OPLOCK
RAW-PING-PONG
-RAW-SAMBA3HIDE
-RAW-SAMBA3CLOSEERR
-RAW-SAMBA3CHECKFSP
-RAW-SAMBA3BADPATH
+RPC-SAMR_ACCESSMASK
RAW-SCAN-EAMAX
RAW-QFILEINFO-IPC
BASE-UTABLE
@@ -26,10 +21,8 @@ ntvfs/cifs BASE-CHARSET
ntvfs/cifs BASE-DEFER_OPEN
ntvfs/cifs BASE-DELAYWRITE
ntvfs/cifs BASE-IOMETER
-ntvfs/cifs BASE-SAMBA3ERROR
ntvfs/cifs BASE-CASETABLE
ntvfs/cifs BASE-NTTRANS
-ntvfs/cifs BASE-BENCH-HOLDCON
ntvfs/cifs BASE-SCAN-MAXFID
ntvfs/cifs BASE-UTABLE
ntvfs/cifs BASE-SMB
@@ -37,14 +30,20 @@ ntvfs/cifs RAW-COMPOSITE
ntvfs/cifs RAW-OPLOCK
ntvfs/cifs RAW-NOTIFY
ntvfs/cifs RAW-BENCH-OPLOCK
-ntvfs/cifs RAW-SAMBA3HIDE
-ntvfs/cifs RAW-SAMBA3CLOSEERR
-ntvfs/cifs RAW-SAMBA3CHECKFSP
-ntvfs/cifs RAW-SAMBA3BADPATH
ntvfs/cifs RAW-SCAN-EAMAX
ntvfs/cifs RAW-CONTEXT
ntvfs/cifs RAW-QFILEINFO-IPC
RPC-DSSYNC
RPC-SAMSYNC
-LDAP-UPTODATEVECTOR
-RAW-SAMBA3POSIXTIMEDLOCK
+LDAP-UPTODATEVECTOR # Segfaults
+RPC-SCANNER # Very slow
+RPC-REMACT # Not provided by Samba 4
+RPC-OXIDRESOLVE # Not provided by Samba 4
+RPC-EVENTLOG # Not provided by Samba 4
+RPC-INITSHUTDOWN # Not provided by Samba 4
+RPC-SVCCTL # Not provided by Samba 4
+RPC-ATSVC # Not provided by Samba 4
+.*SAMBA3.* # Samba3-specific test
+^NET-DOMOPEN$ # Hangs for some reason
+^NET-API-BECOME-DC$ # Fails
+WINBIND # FIXME: This should not be skipped
diff --git a/source4/script/gdb_run b/source4/script/gdb_run
index bfefce1ac9..146259d705 100755
--- a/source4/script/gdb_run
+++ b/source4/script/gdb_run
@@ -8,7 +8,6 @@ TMPFILE=$TMPDIR/gdb_run.$$
cat << EOF > $TMPFILE
run
bt
-quit
EOF
trap "/bin/rm -f $TMPFILE" EXIT
diff --git a/source4/script/installbin.sh b/source4/script/installbin.sh
index c2f34082dd..c2f34082dd 100644..100755
--- a/source4/script/installbin.sh
+++ b/source4/script/installbin.sh
diff --git a/source4/script/installjsonrpc.sh b/source4/script/installjsonrpc.sh
deleted file mode 100755
index b91f6bf3bb..0000000000
--- a/source4/script/installjsonrpc.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-SERVICESDIR=$1
-SRCDIR=$2
-
-echo Installing JSON-RPC services in $SERVICESDIR
-
-cd $SRCDIR/../services || exit 1
-
-mkdir -p $SERVICESDIR || exit 1
-
-installdir() {
- for f in $*; do
- dname=`dirname $f`
- echo "Installing $f in $dname"
- test -d $SERVICESDIR/$dname || mkdir -p $SERVICESDIR/$dname || exit 1
- cp $f $SERVICESDIR/$dname/ || exit 1
- chmod 0644 $SERVICESDIR/$f || exit 1
- done
-}
-
-installdir `find . -name '*.esp'`
-
-cat << EOF
-======================================================================
-The JSON-RPC services have been installed.
-======================================================================
-EOF
-
-
-exit 0
-
diff --git a/source4/script/installman.sh b/source4/script/installman.sh
index ae99bceacf..ae99bceacf 100644..100755
--- a/source4/script/installman.sh
+++ b/source4/script/installman.sh
diff --git a/source4/script/installmisc.sh b/source4/script/installmisc.sh
index 1555fa21d2..55297c43d9 100755
--- a/source4/script/installmisc.sh
+++ b/source4/script/installmisc.sh
@@ -16,11 +16,18 @@ echo "Installing setup templates"
mkdir -p $SETUPDIR || exit 1
cp setup/schema-map-* $SETUPDIR || exit 1
cp setup/DB_CONFIG $SETUPDIR || exit 1
+cp setup/upgrade $SETUPDIR || exit 1
+cp setup/provision-backend $SETUPDIR || exit 1
+cp setup/provision $SETUPDIR || exit 1
+cp setup/newuser $SETUPDIR || exit 1
cp setup/*.inf $SETUPDIR || exit 1
cp setup/*.ldif $SETUPDIR || exit 1
cp setup/*.reg $SETUPDIR || exit 1
cp setup/*.zone $SETUPDIR || exit 1
cp setup/*.conf $SETUPDIR || exit 1
+cp setup/provision.smb.conf.dc $SETUPDIR || exit 1
+cp setup/provision.smb.conf.member $SETUPDIR || exit 1
+cp setup/provision.smb.conf.standalone $SETUPDIR || exit 1
echo "Installing script tools"
mkdir -p "$BINDIR"
diff --git a/source4/script/installmodules.sh b/source4/script/installmodules.sh
index fb0ad90c14..fb0ad90c14 100644..100755
--- a/source4/script/installmodules.sh
+++ b/source4/script/installmodules.sh
diff --git a/source4/script/installscripts.sh b/source4/script/installscripts.sh
index bff5423e7c..bff5423e7c 100644..100755
--- a/source4/script/installscripts.sh
+++ b/source4/script/installscripts.sh
diff --git a/source4/script/installswat.sh b/source4/script/installswat.sh
new file mode 100755
index 0000000000..4304e3e490
--- /dev/null
+++ b/source4/script/installswat.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+SWATDIR=$1
+SRCDIR=$2
+
+echo Installing swat files in $SWATDIR
+
+cd $SRCDIR/../swat || exit 1
+
+mkdir -p $SWATDIR || exit 1
+
+installdir() {
+ for f in $*; do
+ dname=`dirname $f`
+ echo "Installing $f in $dname"
+ test -d $SWATDIR/$dname || mkdir -p $SWATDIR/$dname || exit 1
+ cp $f $SWATDIR/$dname/ || exit 1
+ chmod 0644 $SWATDIR/$f || exit 1
+ done
+}
+
+installdir `find . -name '*.js'`
+installdir `find . -name '*.esp'`
+installdir `find . -name '*.css'`
+installdir `find . -name '*.png'`
+installdir `find . -name '*.ico'`
+installdir `find . -name '*.gif'`
+installdir `find . -name '*.ejs'`
+
+cat << EOF
+======================================================================
+The swat files have been installed.
+======================================================================
+EOF
+
+exit 0
+
diff --git a/source4/script/installwebapps.sh b/source4/script/installwebapps.sh
deleted file mode 100755
index 25a43dba24..0000000000
--- a/source4/script/installwebapps.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/sh
-
-WEBAPPSDIR=$1
-SRCDIR=$2
-
-echo Installing web application files in $WEBAPPSDIR
-
-cd $SRCDIR/../webapps/swat || exit 1
-
-# building the web application framework is now done by autogen.sh
-#make build || exit 1
-
-mkdir -p $WEBAPPSDIR || exit 1
-
-installdir() {
- for f in $*; do
- dname=`dirname $f`
- echo "Installing $f in $dname"
- test -d $WEBAPPSDIR/$dname || mkdir -p $WEBAPPSDIR/$dname || exit 1
- cp $f $WEBAPPSDIR/$dname/ || exit 1
- chmod 0644 $WEBAPPSDIR/$f || exit 1
- done
-}
-
-# install our web application
-cd build || exit 1
-installdir `find . -type f -print`
-
-# install files from the 'scripting', 'style' and 'images' directories
-cd ../.. || exit 1
-installdir `find scripting -name '*.js'`
-installdir `find scripting -name '*.esp'`
-installdir `find style -name '*.css'`
-installdir `find images -name '*.png'`
-installdir `find images -name '*.gif'`
-installdir `find images -name '*.ico'`
-
-# install the old installation scripts, since there's no replacement yet
-installdir `find install -name '*.esp'`
-
-# install top-level scripts
-installdir index.esp login.esp logout.esp menu.js
-
-cat << EOF
-======================================================================
-The web application files have been installed.
-======================================================================
-EOF
-
-exit 0
-
diff --git a/source4/script/lex_compile.sh b/source4/script/lex_compile.sh
index f655f81f2d..9bba7257b1 100755
--- a/source4/script/lex_compile.sh
+++ b/source4/script/lex_compile.sh
@@ -35,8 +35,14 @@ if cd $dir && $LEX $ARGS $file; then
if [ -r $base.yy.c ];then
# we must guarantee that config.h comes first
echo "#include \"config.h\"" > $base.c
- sed '/^#/ s|$base.yy\.c|$DEST|' $base.yy.c >> $base.c
+ sed -e "s|$base\.yy\.c|$DEST|" $base.yy.c >> $base.c
rm -f $base.yy.c
+ elif [ -r $base.c ];then
+ # we must guarantee that config.h comes first
+ mv $base.c $base.c.tmp
+ echo "#include \"config.h\"" > $base.c
+ sed -e "s|$base\.yy\.c|$DEST|" $base.c.tmp >> $base.c
+ rm -f $base.c.tmp
elif [ ! -r base.c ]; then
echo "$base.c nor $base.yy.c generated."
exit 1
diff --git a/source4/script/mkproto.pl b/source4/script/mkproto.pl
index 51888c704f..f1c2cf9d0e 100755
--- a/source4/script/mkproto.pl
+++ b/source4/script/mkproto.pl
@@ -68,20 +68,24 @@ GetOptions(
'help' => \&usage
) or exit(1);
-if (not defined($public_define) and defined($public_file)) {
- $public_define = ".." . uc($public_file) . "__";
- $public_define =~ tr{./}{__};
-} elsif (not defined($public_define)) {
- $public_define = '_PROTO_H_';
-}
+sub normalize_define($$)
+{
+ my ($define, $file) = @_;
+
+ if (not defined($define) and defined($file)) {
+ $define = "__" . uc($file) . "__";
+ $define =~ tr{./}{__};
+ $define =~ tr{\-}{_};
+ } elsif (not defined($define)) {
+ $define = '_PROTO_H_';
+ }
-if (not defined($private_define) and defined($private_file)) {
- $private_define = "__" . uc($private_file) . "__";
- $private_define =~ tr{./}{__};
-} elsif (not defined($public_define)) {
- $public_define = '_PROTO_H_';
+ return $define;
}
+$public_define = normalize_define($public_define, $public_file);
+$private_define = normalize_define($private_define, $private_file);
+
if ((defined($private_file) and defined($public_file) and ($private_file eq $public_file)) or
(not defined($private_file) and not defined($public_file))) {
$private_data = $public_data;
@@ -129,7 +133,6 @@ sub handle_loadparm($$)
my %tmap = (
"BOOL" => "bool ",
- "bool" => "bool ",
"CONST_STRING" => "const char *",
"STRING" => "const char *",
"INTEGER" => "int ",
@@ -138,8 +141,8 @@ sub handle_loadparm($$)
);
my %smap = (
- "GLOBAL" => "void",
- "LOCAL" => "int "
+ "GLOBAL" => "struct loadparm_context *",
+ "LOCAL" => "struct loadparm_service *"
);
$file->("$tmap{$type}$name($smap{$scope});\n");
@@ -194,8 +197,8 @@ sub process_file($$$)
}
next unless ( $is_public || $line =~ /
- (_DEPRECATED_ |_NORETURN_ |_WARN_UNUSED_RESULT_ |_PURE_ )*^(
- void|BOOL|bool|int|struct|char|const|\w+_[tT]\s|uint|unsigned|long|NTSTATUS|
+ ^(_DEPRECATED_ |_NORETURN_ |_WARN_UNUSED_RESULT_ |_PURE_ )*(
+ void|bool|int|struct|char|const|\w+_[tT]\s|uint|unsigned|long|NTSTATUS|
ADS_STATUS|enum\s.*\(|DATA_BLOB|WERROR|XFILE|FILE|DIR|
double|TDB_CONTEXT|TDB_DATA|TALLOC_CTX|NTTIME|FN_|init_module|
GtkWidget|GType|smb_ucs2_t|krb5_error_code)
@@ -205,7 +208,6 @@ sub process_file($$$)
$target->("\n$comment") if (defined($comment)); $comment = undef;
- $line =~ s/BOOL /bool /g;
if ( $line =~ /\(.*\)\s*$/o ) {
chomp $line;
$target->("$line;\n");
@@ -215,7 +217,6 @@ sub process_file($$$)
$target->($line);
while ($line = <FH>) {
- $line =~ s/BOOL /bool /g;
if ($line =~ /\)\s*$/o) {
chomp $line;
$target->("$line;\n");
diff --git a/source4/script/mkversion.sh b/source4/script/mkversion.sh
index 91c7894cdb..828f67d71b 100755
--- a/source4/script/mkversion.sh
+++ b/source4/script/mkversion.sh
@@ -111,7 +111,7 @@ if test x"${SAMBA_VERSION_IS_SVN_SNAPSHOT}" = x"yes";then
if test x"${HAVEVER}" != x"yes" -a -d "${SOURCE_DIR}../.git";then
HAVEGIT=no
GIT_INFO=`git show --abbrev-commit HEAD 2>/dev/null`
- TMP_REVISION=`echo -e "${GIT_INFO}" | grep 'commit ' | sed 1q |sed -e 's/commit \([0-9a-f]*\).*/\1/'`
+ TMP_REVISION=`echo -e "${GIT_INFO}" | sed 1q | grep 'commit ' | sed -e 's/commit \([0-9a-f]*\).*/\1/'`
if test -n "$TMP_REVISION";then
HAVEGIT=yes
HAVEVER=yes
diff --git a/source4/script/revert.sh b/source4/script/revert.sh
index 8df5fd2fbd..8df5fd2fbd 100644..100755
--- a/source4/script/revert.sh
+++ b/source4/script/revert.sh
diff --git a/source4/script/uninstallbin.sh b/source4/script/uninstallbin.sh
index a8bbdea7af..a8bbdea7af 100644..100755
--- a/source4/script/uninstallbin.sh
+++ b/source4/script/uninstallbin.sh
diff --git a/source4/script/uninstallman.sh b/source4/script/uninstallman.sh
index 72b523ed9e..72b523ed9e 100644..100755
--- a/source4/script/uninstallman.sh
+++ b/source4/script/uninstallman.sh
diff --git a/source4/script/uninstallmodules.sh b/source4/script/uninstallmodules.sh
index 30582a39fa..30582a39fa 100644..100755
--- a/source4/script/uninstallmodules.sh
+++ b/source4/script/uninstallmodules.sh
diff --git a/source4/script/uninstallscripts.sh b/source4/script/uninstallscripts.sh
index 13104acedd..13104acedd 100644..100755
--- a/source4/script/uninstallscripts.sh
+++ b/source4/script/uninstallscripts.sh
diff --git a/source4/scripting/ejs/ejsnet/net_ctx.c b/source4/scripting/ejs/ejsnet/net_ctx.c
index 411c98cc72..97a05ab88f 100644
--- a/source4/scripting/ejs/ejsnet/net_ctx.c
+++ b/source4/scripting/ejs/ejsnet/net_ctx.c
@@ -68,7 +68,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
talloc_free(ctx);
return -1;
}
- cli_credentials_set_conf(creds);
+ cli_credentials_set_conf(creds, global_loadparm);
cli_credentials_set_anonymous(creds);
mprCreds = mprCredentials(creds);
@@ -78,7 +78,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
get credential values from credentials object
*/
mprCreds = *(argv[0]);
- creds = mprGetPtr(&mprCreds, "creds");
+ creds = (struct cli_credentials *)mprGetPtr(&mprCreds, "creds");
if (creds == NULL) {
ejsSetErrorMsg(eid, "invalid credentials parameter");
talloc_free(ctx);
@@ -122,7 +122,7 @@ static int ejs_net_join_domain(MprVarHandle eid, int argc, struct MprVar **argv)
struct libnet_context *ctx;
struct libnet_Join *join;
NTSTATUS status;
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
mem_ctx = talloc_new(mprMemCtx());
join = talloc(mem_ctx, struct libnet_Join);
@@ -166,9 +166,9 @@ static int ejs_net_join_domain(MprVarHandle eid, int argc, struct MprVar **argv)
MprVar error_string = mprString(join->out.error_string);
mprSetPropertyValue(argv[0], "error_string", error_string);
- mpr_Return(eid, mprCreateBoolVar(False));
+ mpr_Return(eid, mprCreateBoolVar(false));
} else {
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
}
talloc_free(mem_ctx);
return 0;
@@ -181,7 +181,7 @@ static int ejs_net_samsync_ldb(MprVarHandle eid, int argc, struct MprVar **argv)
struct libnet_context *ctx;
struct libnet_samsync_ldb *samsync;
NTSTATUS status;
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
mem_ctx = talloc_new(mprMemCtx());
samsync = talloc(mem_ctx, struct libnet_samsync_ldb);
@@ -214,9 +214,9 @@ static int ejs_net_samsync_ldb(MprVarHandle eid, int argc, struct MprVar **argv)
MprVar error_string = mprString(samsync->out.error_string);
mprSetPropertyValue(argv[0], "error_string", error_string);
- mpr_Return(eid, mprCreateBoolVar(False));
+ mpr_Return(eid, mprCreateBoolVar(false));
} else {
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
}
talloc_free(mem_ctx);
return 0;
diff --git a/source4/scripting/ejs/ejsnet/net_user.c b/source4/scripting/ejs/ejsnet/net_user.c
index 8c9ab9f0eb..34524cc0fa 100644
--- a/source4/scripting/ejs/ejsnet/net_user.c
+++ b/source4/scripting/ejs/ejsnet/net_user.c
@@ -45,7 +45,7 @@ int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar **argv)
struct MprVar obj;
/* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
if (ctx == NULL) {
ejsSetErrorMsg(eid, "ctx property returns null pointer");
return 0;
@@ -128,14 +128,14 @@ static int ejs_net_createuser(MprVarHandle eid, int argc, char **argv)
}
/* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
if (ctx == NULL) {
ejsSetErrorMsg(eid, "ctx property returns null pointer");
goto done;
}
/* domain where the account is to be created */
- userman_domain = mprGetThisPtr(eid, "domain");
+ userman_domain = (const char *)mprGetThisPtr(eid, "domain");
if (userman_domain == NULL) {
ejsSetErrorMsg(eid, "domain property returns null pointer");
goto done;
@@ -197,7 +197,7 @@ static int ejs_net_deleteuser(MprVarHandle eid, int argc, char **argv)
}
/* domain where the account is to be deleted */
- userman_domain = mprGetThisPtr(eid, "domain");
+ userman_domain = (struct libnet_context *)mprGetThisPtr(eid, "domain");
if (!userman_domain) {
ejsSetErrorMsg(eid, "domain property returns null pointer");
goto done;
@@ -253,14 +253,14 @@ static int ejs_net_userinfo(MprVarHandle eid, int argc, char **argv)
}
/* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
if (ctx == NULL) {
ejsSetErrorMsg(eid, "ctx property returns null pointer");
goto done;
}
/* domain where the user account is to be queried */
- userman_domain = mprGetThisPtr(eid, "domain");
+ userman_domain = (struct libnet_context *)mprGetThisPtr(eid, "domain");
if (userman_domain == NULL) {
ejsSetErrorMsg(eid, "domain property returns null pointer");
return -1;
@@ -331,7 +331,7 @@ static int ejs_net_userlist(MprVarHandle eid, int argc, struct MprVar **argv)
}
/* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
+ ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
if (ctx == NULL) {
ejsSetErrorMsg(eid, "ctx property returns null pointer");
goto done;
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c
index 966c803a30..3769607949 100644
--- a/source4/scripting/ejs/ejsrpc.c
+++ b/source4/scripting/ejs/ejsrpc.c
@@ -311,16 +311,16 @@ NTSTATUS ejs_push_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
return mprSetVar(v, name, mprCreatePtrVar(NULL));
}
-BOOL ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
+bool ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
{
NTSTATUS status = mprGetVar(&v, name);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
if (v->type == MPR_TYPE_PTR && v->ptr == NULL) {
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
@@ -372,16 +372,16 @@ NTSTATUS ejs_push_DATA_BLOB(struct ejs_rpc *ejs,
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS ejs_pull_BOOL(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, BOOL *r)
+NTSTATUS ejs_pull_bool(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, bool *r)
{
NDR_CHECK(mprGetVar(&v, name));
*r = mprVarToBool(v);
return NT_STATUS_OK;
}
-NTSTATUS ejs_push_BOOL(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const BOOL *r)
+NTSTATUS ejs_push_bool(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const bool *r)
{
return mprSetVar(v, name, mprCreateBoolVar(*r));
}
@@ -417,7 +417,7 @@ NTSTATUS ejs_push_array_uint8(struct ejs_rpc *ejs,
const uint8_t *r, uint32_t length)
{
DATA_BLOB blob;
- blob.data = discard_const(r);
+ blob.data = (uint8_t *)discard_const(r);
blob.length = length;
mprSetVar(v, name, mprDataBlob(blob));
return NT_STATUS_OK;
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
index ef920b816a..6723fb4107 100644
--- a/source4/scripting/ejs/ejsrpc.h
+++ b/source4/scripting/ejs/ejsrpc.h
@@ -113,9 +113,9 @@ NTSTATUS ejs_pull_DATA_BLOB(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, DATA_BLOB *r);
NTSTATUS ejs_push_DATA_BLOB(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const DATA_BLOB *r);
-NTSTATUS ejs_pull_BOOL(struct ejs_rpc *ejs,
+NTSTATUS ejs_pull_bool(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, bool *r);
-NTSTATUS ejs_push_BOOL(struct ejs_rpc *ejs,
+NTSTATUS ejs_push_bool(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const bool *r);
NTSTATUS ejs_pull_array_uint8(struct ejs_rpc *ejs,
diff --git a/source4/scripting/ejs/literal.c b/source4/scripting/ejs/literal.c
index d50e5afdb9..8307c211d3 100644
--- a/source4/scripting/ejs/literal.c
+++ b/source4/scripting/ejs/literal.c
@@ -132,27 +132,11 @@ static void *append_string(void *ctx,
char *append,
int size)
{
- char c;
- char *end_p = append + size;
- void *ret;
+ if (!orig) {
+ return talloc_strndup(ctx, append, size);
+ }
- /*
- * We need to null terminate the string to be copied. Save character at
- * the size limit of the source string.
- */
- c = *end_p;
-
- /* Temporarily null-terminate it */
- *end_p = '\0';
-
- /* Append the requested data */
- ret = talloc_append_string(ctx, orig, append);
-
- /* Restore the original character in place of our temporary null byte */
- *end_p = c;
-
- /* Give 'em what they came for */
- return ret;
+ return talloc_strndup_append(orig, append, size);
}
diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c
index b8271d97c5..9143947fb8 100644
--- a/source4/scripting/ejs/mprutil.c
+++ b/source4/scripting/ejs/mprutil.c
@@ -134,7 +134,7 @@ struct MprVar mprString(const char *s)
if (s == NULL) {
return mprCreatePtrVar(NULL);
}
- return mprCreateStringVar(s, True);
+ return mprCreateStringVar(s, true);
}
/*
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index bc7994a007..8a3ce245d2 100644
--- a/source4/scripting/ejs/smbcalls.c
+++ b/source4/scripting/ejs/smbcalls.c
@@ -21,6 +21,7 @@
*/
#include "includes.h"
+#include "param/param.h"
#include "scripting/ejs/smbcalls.h"
#include "build.h"
#include "version.h"
@@ -110,7 +111,7 @@ static int ejs_typeof_native(MprVarHandle eid, int argc, struct MprVar **argv)
static int ejs_libinclude(int eid, int argc, char **argv)
{
int i, j;
- const char **js_include = lp_js_include();
+ const char **js_include = lp_js_include(global_loadparm);
if (js_include == NULL || js_include[0] == NULL) {
ejsSetErrorMsg(eid, "js include path not set");
@@ -160,51 +161,6 @@ static int ejs_version(MprVarHandle eid, int argc, struct MprVar **argv)
}
-/*
- * jsonrpc_include() allows you to include jsonrpc files from a path based at
- * "jsonrpc services directory =" in smb.conf.
- */
-static int jsonrpc_include(int eid, int argc, char **argv)
-{
- int ret = -1;
- char *path;
- char *emsg;
- const char *jsonrpc_services_dir = lp_jsonrpc_services_dir();
- struct MprVar result;
-
-
- if (jsonrpc_services_dir == NULL || jsonrpc_services_dir == NULL) {
- ejsSetErrorMsg(eid, "'jsonrpc services directory' not set");
- return -1;
- }
-
- if (argc != 1) {
- mpr_Return(eid, mprCreateIntegerVar(-1));
- return 0;
- }
-
- path = talloc_asprintf(mprMemCtx(), "%s/%s",
- jsonrpc_services_dir,
- argv[0]);
- if (path == NULL) {
- mpr_Return(eid, mprCreateIntegerVar(-1));
- return 0;
- }
-
- if (file_exist(path)) {
- ret = ejsEvalFile(eid, path, &result, &emsg);
- if (ret < 0) {
- ejsSetErrorMsg(eid, "Could not eval file");
- printf("file found; ret=%d (%s)\n", ret, emsg);
- }
- }
-
- mpr_Return(eid, mprCreateIntegerVar(ret));
- talloc_free(path);
- return 0;
-}
-
-
static void (*ejs_exception_handler) (const char *) = NULL;
_PUBLIC_ void ejs_exception(const char *reason)
@@ -228,7 +184,7 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *))
smb_setup_ejs_param();
smb_setup_ejs_literal();
- shared_init = load_samba_modules(NULL, "smbcalls");
+ shared_init = load_samba_modules(NULL, global_loadparm, "smbcalls");
run_init_functions(static_init);
run_init_functions(shared_init);
@@ -239,6 +195,5 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *))
ejsDefineCFunction(-1, "nativeTypeOf", ejs_typeof_native, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "version", ejs_version, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineStringCFunction(-1, "jsonrpc_include", jsonrpc_include, NULL, MPR_VAR_SCRIPT_HANDLE);
}
diff --git a/source4/scripting/ejs/smbcalls.h b/source4/scripting/ejs/smbcalls.h
index 77d9dd3381..3aaf324b6e 100644
--- a/source4/scripting/ejs/smbcalls.h
+++ b/source4/scripting/ejs/smbcalls.h
@@ -38,4 +38,5 @@ struct ldb_context;
struct ldb_message;
struct cli_credentials;
+#include "param/param.h"
#include "scripting/ejs/proto.h"
diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c
index 2624084f02..b4848d4323 100644
--- a/source4/scripting/ejs/smbcalls_auth.c
+++ b/source4/scripting/ejs/smbcalls_auth.c
@@ -30,9 +30,11 @@
#include "libcli/security/security.h"
static int ejs_doauth(MprVarHandle eid,
- TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username,
- const char *password, const char *domain, const char *workstation,
- struct socket_address *remote_host, const char **auth_types)
+ TALLOC_CTX *tmp_ctx, struct MprVar *auth,
+ const char *username, const char *password,
+ const char *domain, const char *workstation,
+ struct socket_address *remote_host,
+ const char **auth_types)
{
struct auth_usersupplied_info *user_info = NULL;
struct auth_serversupplied_info *server_info = NULL;
@@ -54,7 +56,7 @@ static int ejs_doauth(MprVarHandle eid,
} else {
/* Hope we can find the event context somewhere up there... */
ev = event_context_find(tmp_ctx);
- msg = messaging_client_init(tmp_ctx, ev);
+ msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, global_loadparm), ev);
}
if (auth_types) {
@@ -63,19 +65,19 @@ static int ejs_doauth(MprVarHandle eid,
nt_status = auth_context_create(tmp_ctx, ev, msg, &auth_context);
}
if (!NT_STATUS_IS_OK(nt_status)) {
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
mprSetPropertyValue(auth, "report", mprString("Auth System Failure"));
goto done;
}
user_info = talloc(tmp_ctx, struct auth_usersupplied_info);
if (!user_info) {
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
mprSetPropertyValue(auth, "report", mprString("talloc failed"));
goto done;
}
- user_info->mapped_state = True;
+ user_info->mapped_state = true;
user_info->client.account_name = username;
user_info->mapped.account_name = username;
user_info->client.domain_name = domain;
@@ -102,14 +104,14 @@ static int ejs_doauth(MprVarHandle eid,
if (!NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(auth, "report",
mprString(talloc_strdup(mprMemCtx(), get_friendly_nt_error_msg(nt_status))));
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
goto done;
}
nt_status = auth_generate_session_info(tmp_ctx, server_info, &session_info);
if (!NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(auth, "report", mprString("Session Info generation failed"));
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
goto done;
}
@@ -130,13 +132,13 @@ static int ejs_doauth(MprVarHandle eid,
if (security_token_is_anonymous(session_info->security_token)) {
mprSetPropertyValue(auth, "report", mprString("Anonymous login not permitted"));
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
goto done;
}
if (!set) {
mprSetPropertyValue(auth, "report", mprString("Session Info generation failed"));
- mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
+ mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
}
session_info_obj = mprInitObject(eid, "session_info", 0, NULL);
@@ -181,7 +183,7 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
return -1;
}
- remote_host = mprGetPtr(argv[1], "socket_address");
+ remote_host = (struct socket_address *)mprGetPtr(argv[1], "socket_address");
if (remote_host == NULL) {
ejsSetErrorMsg(eid, "userAuth requires a socket address second parameter");
return -1;
diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c
index e94207bf36..e08a098833 100644
--- a/source4/scripting/ejs/smbcalls_cli.c
+++ b/source4/scripting/ejs/smbcalls_cli.c
@@ -27,6 +27,7 @@
#include "libcli/smb_composite/smb_composite.h"
#include "libcli/libcli.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
#if 0
@@ -60,7 +61,7 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv)
return -1;
}
- transport = smbcli_transport_init(sock, sock, False);
+ transport = smbcli_transport_init(sock, sock, false);
if (!transport) {
ejsSetErrorMsg(eid, "transport init failed");
@@ -191,7 +192,7 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv)
/* Do session setup */
- session = smbcli_session_init(transport, transport, False);
+ session = smbcli_session_init(transport, transport, false);
if (!session) {
ejsSetErrorMsg(eid, "session init failed");
@@ -251,7 +252,7 @@ static int ejs_cli_tree_connect(MprVarHandle eid, int argc, MprVar **argv)
}
session = argv[0]->ptr;
- tree = smbcli_tree_init(session, session, False);
+ tree = smbcli_tree_init(session, session, false);
if (!tree) {
ejsSetErrorMsg(eid, "tree init failed");
@@ -430,7 +431,7 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
/* Set up credentials */
creds = cli_credentials_init(NULL);
- cli_credentials_set_conf(creds);
+ cli_credentials_set_conf(creds, global_loadparm);
cli_credentials_parse_string(creds, argv[1], CRED_SPECIFIED);
/* Do connect */
@@ -441,8 +442,8 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
io.in.service = sharename;
io.in.service_type = "?????";
io.in.credentials = creds;
- io.in.fallback_to_anonymous = False;
- io.in.workgroup = lp_workgroup();
+ io.in.fallback_to_anonymous = false;
+ io.in.workgroup = lp_workgroup(global_loadparm);
result = smb_composite_connect(&io, mem_ctx, NULL);
tree = io.out.tree;
@@ -483,7 +484,7 @@ static int ejs_tree_disconnect(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = talloc_check_name(argv[0]->ptr, "struct smbcli_tree");
+ tree = talloc_get_type(argv[0]->ptr, struct smbcli_tree);
result = smb_tree_disconnect(tree);
@@ -512,7 +513,7 @@ static int ejs_mkdir(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -546,7 +547,7 @@ static int ejs_rmdir(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -580,7 +581,7 @@ static int ejs_rename(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -619,7 +620,7 @@ static int ejs_unlink(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -666,7 +667,7 @@ static int ejs_list(MprVarHandle eid, int argc, MprVar **argv)
return -1;
}
- tree = argv[0]->ptr;
+ tree = (struct smbcli_tree *)argv[0]->ptr;
if (!mprVarIsString(argv[1]->type)) {
ejsSetErrorMsg(eid, "arg 2 must be a string");
diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c
index 6f15ee5a4a..1c76757659 100644
--- a/source4/scripting/ejs/smbcalls_config.c
+++ b/source4/scripting/ejs/smbcalls_config.c
@@ -25,6 +25,7 @@
#include "param/loadparm.h"
#include "system/network.h"
#include "lib/socket/netif.h"
+#include "param/param.h"
/*
return a list of defined services
@@ -35,8 +36,8 @@ static int ejs_lpServices(MprVarHandle eid, int argc, char **argv)
const char **list = NULL;
if (argc != 0) return -1;
- for (i=0;i<lp_numservices();i++) {
- list = str_list_add(list, lp_servicename(i));
+ for (i=0;i<lp_numservices(global_loadparm);i++) {
+ list = str_list_add(list, lp_servicename(lp_servicebynum(global_loadparm, i)));
}
talloc_steal(mprMemCtx(), list);
mpr_Return(eid, mprList("services", list));
@@ -45,27 +46,6 @@ static int ejs_lpServices(MprVarHandle eid, int argc, char **argv)
/*
- return a list of parameter categories
-*/
-static int ejs_lpCategories(MprVarHandle eid, int argc, char **argv)
-{
- struct parm_struct *parm_table = lp_parm_table();
- int i;
- const char **list = NULL;
- if (argc != 0) return -1;
-
- for (i=0;parm_table[i].label;i++) {
- if (parm_table[i].class == P_SEPARATOR) {
- list = str_list_add(list, parm_table[i].label);
- }
- }
- talloc_steal(mprMemCtx(), list);
- mpr_Return(eid, mprList("categories", list));
- return 0;
-}
-
-
-/*
allow access to loadparm variables from inside ejs scripts in web apps
can be called in 4 ways:
@@ -86,9 +66,10 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
if (argc < 1) return -1;
if (argc == 2) {
+ struct loadparm_service *service;
/* its a share parameter */
- int snum = lp_servicenumber(argv[0]);
- if (snum == -1) {
+ service = lp_service(global_loadparm, argv[0]);
+ if (service == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
@@ -103,7 +84,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- value = lp_get_parametric(snum, type, option);
+ value = lp_get_parametric(global_loadparm, service, type, option);
if (value == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
@@ -117,7 +98,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- parm_ptr = lp_parm_ptr(snum, parm);
+ parm_ptr = lp_parm_ptr(service, parm);
} else if (strchr(argv[0], ':')) {
/* its a global parametric option */
const char *type = talloc_strndup(mprMemCtx(),
@@ -128,7 +109,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- value = lp_get_parametric(-1, type, option);
+ value = lp_get_parametric(global_loadparm, NULL, type, option);
if (value == NULL) {
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
@@ -142,7 +123,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_Return(eid, mprCreateUndefinedVar());
return 0;
}
- parm_ptr = lp_parm_ptr(-1, parm);
+ parm_ptr = lp_parm_ptr(NULL, parm);
}
if (parm == NULL || parm_ptr == NULL) {
@@ -157,7 +138,7 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
mpr_ReturnString(eid, *(char **)parm_ptr);
break;
case P_BOOL:
- mpr_Return(eid, mprCreateBoolVar(*(BOOL *)parm_ptr));
+ mpr_Return(eid, mprCreateBoolVar(*(bool *)parm_ptr));
break;
case P_INTEGER:
case P_OCTAL:
@@ -176,9 +157,6 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
case P_LIST:
mpr_Return(eid, mprList(parm->label, *(const char ***)parm_ptr));
break;
- case P_SEP:
- mpr_Return(eid, mprCreateUndefinedVar());
- return 0;
}
return 0;
}
@@ -198,7 +176,7 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
return -1;
}
- mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(argv[0], argv[1])));
+ mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(global_loadparm, argv[0], argv[1])));
return 0;
}
@@ -209,7 +187,7 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
*/
static int ejs_lpReload(MprVarHandle eid, int argc, char **argv)
{
- BOOL ret = lp_load();
+ bool ret = lp_load(lp_configfile(global_loadparm));
if (ret) {
unload_interfaces();
}
@@ -228,7 +206,6 @@ static int ejs_loadparm_init(MprVarHandle eid, int argc, struct MprVar **argv)
mprSetStringCFunction(obj, "set", ejs_lpSet);
mprSetStringCFunction(obj, "reload", ejs_lpReload);
mprSetStringCFunction(obj, "services", ejs_lpServices);
- mprSetStringCFunction(obj, "categories", ejs_lpCategories);
return 0;
}
diff --git a/source4/scripting/ejs/smbcalls_creds.c b/source4/scripting/ejs/smbcalls_creds.c
index 0feead201e..781843371a 100644
--- a/source4/scripting/ejs/smbcalls_creds.c
+++ b/source4/scripting/ejs/smbcalls_creds.c
@@ -30,7 +30,7 @@
*/
static struct cli_credentials *ejs_creds_get_credentials(int eid)
{
- struct cli_credentials *creds = mprGetThisPtr(eid, "creds");
+ struct cli_credentials *creds = (struct cli_credentials *)mprGetThisPtr(eid, "creds");
if (creds == NULL) {
ejsSetErrorMsg(eid, "NULL ejs credentials");
}
@@ -61,7 +61,7 @@ static int ejs_creds_set_domain(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_domain(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -90,7 +90,7 @@ static int ejs_creds_set_username(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_username(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -119,7 +119,7 @@ static int ejs_creds_set_password(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_password(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -136,7 +136,7 @@ static int ejs_creds_set_realm(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_realm(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -165,7 +165,7 @@ static int ejs_creds_set_workstation(MprVarHandle eid, int argc, char **argv)
}
cli_credentials_set_workstation(creds, argv[0], CRED_SPECIFIED);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
@@ -193,9 +193,9 @@ static int ejs_creds_set_machine_account(MprVarHandle eid, int argc, struct MprV
}
if (NT_STATUS_IS_OK(cli_credentials_set_machine_account(creds))) {
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
} else {
- mpr_Return(eid, mprCreateBoolVar(False));
+ mpr_Return(eid, mprCreateBoolVar(false));
}
return 0;
}
@@ -248,7 +248,7 @@ static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv
return -1;
}
- cli_credentials_set_conf(creds);
+ cli_credentials_set_conf(creds, global_loadparm);
return ejs_credentials_obj(obj, creds);
}
diff --git a/source4/scripting/ejs/smbcalls_data.c b/source4/scripting/ejs/smbcalls_data.c
index 60dadc5165..a98266c3da 100644
--- a/source4/scripting/ejs/smbcalls_data.c
+++ b/source4/scripting/ejs/smbcalls_data.c
@@ -107,7 +107,7 @@ failed:
static int ejs_blobCompare(MprVarHandle eid, int argc, struct MprVar **argv)
{
DATA_BLOB *blob1, *blob2;
- BOOL ret = False;
+ bool ret = false;
if (argc != 2) {
ejsSetErrorMsg(eid, "blobCompare invalid arguments");
@@ -118,24 +118,24 @@ static int ejs_blobCompare(MprVarHandle eid, int argc, struct MprVar **argv)
blob2 = mprToDataBlob(argv[1]);
if (blob1 == blob2) {
- ret = True;
+ ret = true;
goto done;
}
if (blob1 == NULL || blob2 == NULL) {
- ret = False;
+ ret = false;
goto done;
}
if (blob1->length != blob2->length) {
- ret = False;
+ ret = false;
goto done;
}
if (memcmp(blob1->data, blob2->data, blob1->length) != 0) {
- ret = False;
+ ret = false;
goto done;
}
- ret = True;
+ ret = true;
done:
mpr_Return(eid, mprCreateBoolVar(ret));
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c
index 7b143ae4d9..04162830b4 100644
--- a/source4/scripting/ejs/smbcalls_ldb.c
+++ b/source4/scripting/ejs/smbcalls_ldb.c
@@ -34,7 +34,7 @@
*/
static struct ldb_context *ejs_get_ldb_context(int eid)
{
- struct ldb_context *ldb = mprGetThisPtr(eid, "db");
+ struct ldb_context *ldb = (struct ldb_context *)mprGetThisPtr(eid, "db");
if (ldb == NULL) {
ejsSetErrorMsg(eid, "invalid ldb connection");
}
@@ -452,7 +452,7 @@ static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv)
dbfile = argv[0];
- ldb = ldb_wrap_connect(mprMemCtx(), dbfile,
+ ldb = ldb_wrap_connect(mprMemCtx(), global_loadparm, dbfile,
session_info, creds,
0, (const char **)(argv+1));
if (ldb == NULL) {
@@ -483,7 +483,7 @@ static int ejs_ldbClose(MprVarHandle eid, int argc, struct MprVar **argv)
}
mprSetThisPtr(eid, "db", NULL);
- mpr_Return(eid, mprCreateBoolVar(True));
+ mpr_Return(eid, mprCreateBoolVar(true));
return 0;
}
diff --git a/source4/scripting/ejs/smbcalls_param.c b/source4/scripting/ejs/smbcalls_param.c
index afdee28a65..830c45d978 100644
--- a/source4/scripting/ejs/smbcalls_param.c
+++ b/source4/scripting/ejs/smbcalls_param.c
@@ -20,9 +20,9 @@
*/
#include "includes.h"
+#include "param/param.h"
#include "scripting/ejs/smbcalls.h"
#include "lib/appweb/ejs/ejs.h"
-#include "param/param.h"
/*
get parameter
@@ -39,7 +39,7 @@ static int ejs_param_get(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
if (argc == 2) {
@@ -72,7 +72,7 @@ static int ejs_param_get_list(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
if (argc == 2) {
@@ -107,7 +107,7 @@ static int ejs_param_set(MprVarHandle eid, int argc, struct MprVar **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
@@ -148,17 +148,17 @@ static int ejs_param_data(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
ret = mprObject("array");
for (sec = ctx->sections; sec; sec = sec->next) {
struct MprVar ps = mprObject("array");
- struct param *p;
+ struct param_opt *p;
for (p = sec->parameters; p; p = p->next) {
- mprSetVar(&ps, p->name, mprString(p->value));
+ mprSetVar(&ps, p->key, mprString(p->value));
}
mprSetVar(&ret, sec->name, ps);
@@ -184,7 +184,7 @@ static int ejs_param_load(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
ret = param_read(ctx, argv[0]);
@@ -209,7 +209,7 @@ static int ejs_param_save(MprVarHandle eid, int argc, char **argv)
return -1;
}
- ctx = mprGetThisPtr(eid, "param");
+ ctx = (struct param_context *)mprGetThisPtr(eid, "param");
mprAssert(ctx);
ret = param_write(ctx, argv[0]);
diff --git a/source4/scripting/ejs/smbcalls_reg.c b/source4/scripting/ejs/smbcalls_reg.c
index 4d84587fa4..d4b13cc2ca 100644
--- a/source4/scripting/ejs/smbcalls_reg.c
+++ b/source4/scripting/ejs/smbcalls_reg.c
@@ -32,7 +32,7 @@
*/
static struct registry_context *ejs_get_reg_context(int eid)
{
- struct registry_context *rctx = mprGetThisPtr(eid, "registry");
+ struct registry_context *rctx = (struct registry_context *)mprGetThisPtr(eid, "registry");
if (rctx == NULL) {
ejsSetErrorMsg(eid, "unable to find registry");
}
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index 4addd473da..5d7c674208 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -78,7 +78,9 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
/* create a messaging context, looping as we have no way to
allocate temporary server ids automatically */
for (i=0;i<10000;i++) {
- p->msg_ctx = messaging_init(p, cluster_id(EJS_ID_BASE + i), ev);
+ p->msg_ctx = messaging_init(p,
+ lp_messaging_path(p, global_loadparm),
+ cluster_id(EJS_ID_BASE + i), ev);
if (p->msg_ctx) break;
}
if (p->msg_ctx == NULL) {
@@ -144,7 +146,8 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, char **argv)
credentials = mprGetProperty(this, "credentials", NULL);
if (credentials) {
- creds = mprGetPtr(credentials, "creds");
+ creds = (struct cli_credentials *)
+ mprGetPtr(credentials, "creds");
} else {
creds = cmdline_credentials;
}
@@ -188,7 +191,7 @@ static int ejs_irpc_call(int eid, struct MprVar *io,
int i, count;
struct MprVar *results;
- p = mprGetThisPtr(eid, "irpc");
+ p = (struct ejs_irpc_connection *)mprGetThisPtr(eid, "irpc");
ejs = talloc(mprMemCtx(), struct ejs_rpc);
if (ejs == NULL) {
diff --git a/source4/scripting/ejs/smbcalls_samba3.c b/source4/scripting/ejs/smbcalls_samba3.c
index 3c550e57cd..7c9ef50cf5 100644
--- a/source4/scripting/ejs/smbcalls_samba3.c
+++ b/source4/scripting/ejs/smbcalls_samba3.c
@@ -433,7 +433,7 @@ static int ejs_find_domainsecrets(MprVarHandle eid, int argc, struct MprVar **ar
return -1;
}
- samba3 = mprGetThisPtr(eid, "samba3");
+ samba3 = (struct samba3 *)mprGetThisPtr(eid, "samba3");
mprAssert(samba3);
sec = samba3_find_domainsecrets(samba3, mprToString(argv[0]));
diff --git a/source4/scripting/ejs/smbcalls_string.c b/source4/scripting/ejs/smbcalls_string.c
index b83178dbba..541303ff2d 100644
--- a/source4/scripting/ejs/smbcalls_string.c
+++ b/source4/scripting/ejs/smbcalls_string.c
@@ -238,7 +238,7 @@ static int ejs_join(MprVarHandle eid, int argc, struct MprVar **argv)
goto failed;
}
for (i=1;list[i];i++) {
- ret = talloc_asprintf_append(ret, "%s%s", separator, list[i]);
+ ret = talloc_asprintf_append_buffer(ret, "%s%s", separator, list[i]);
if (ret == NULL) {
goto failed;
}
@@ -275,7 +275,7 @@ static int ejs_sprintf(MprVarHandle eid, int argc, struct MprVar **argv)
ret = talloc_strdup(tmp_ctx, "");
/* avoid all the format string warnings */
- _asprintf_append = (_asprintf_append_t)talloc_asprintf_append;
+ _asprintf_append = (_asprintf_append_t)talloc_asprintf_append_buffer;
/*
hackity hack ...
@@ -284,7 +284,7 @@ static int ejs_sprintf(MprVarHandle eid, int argc, struct MprVar **argv)
char *fmt2;
int len, len_count=0;
char *tstr;
- ret = talloc_asprintf_append(ret, "%*.*s",
+ ret = talloc_asprintf_append_buffer(ret, "%*.*s",
(int)(p-format), (int)(p-format),
format);
if (ret == NULL) goto failed;
@@ -299,7 +299,7 @@ static int ejs_sprintf(MprVarHandle eid, int argc, struct MprVar **argv)
tstr--;
}
if (strcmp(tstr, "%") == 0) {
- ret = talloc_asprintf_append(ret, "%%");
+ ret = talloc_asprintf_append_buffer(ret, "%%");
if (ret == NULL) {
goto failed;
}
@@ -372,7 +372,7 @@ static int ejs_sprintf(MprVarHandle eid, int argc, struct MprVar **argv)
format += len+1;
}
- ret = talloc_asprintf_append(ret, "%s", format);
+ ret = talloc_asprintf_append_buffer(ret, "%s", format);
mpr_Return(eid, mprString(ret));
talloc_free(tmp_ctx);
return 0;
@@ -437,7 +437,7 @@ static int ejs_encodeURIComponent(MprVarHandle eid, int argc, char **argv)
if (!isalnum(s[i])) count++;
}
- ret = talloc_size(mprMemCtx(), i + count*2 + 1);
+ ret = talloc_array(mprMemCtx(), char, i + count*2 + 1);
if (ret == NULL) {
return -1;
}
@@ -470,7 +470,7 @@ static int ejs_decodeURIComponent(MprVarHandle eid, int argc, char **argv)
s = argv[0];
- ret = talloc_size(mprMemCtx(), strlen(s) + 1);
+ ret = talloc_array(mprMemCtx(), char, strlen(s) + 1);
if (ret == NULL) {
return -1;
}
diff --git a/source4/scripting/ejs/smbcalls_sys.c b/source4/scripting/ejs/smbcalls_sys.c
index 96e665ab3a..10de8e162e 100644
--- a/source4/scripting/ejs/smbcalls_sys.c
+++ b/source4/scripting/ejs/smbcalls_sys.c
@@ -294,7 +294,7 @@ static int ejs_sys_file_load(MprVarHandle eid, int argc, char **argv)
*/
static int ejs_sys_file_save(MprVarHandle eid, int argc, char **argv)
{
- BOOL ret;
+ bool ret;
if (argc != 2) {
ejsSetErrorMsg(eid, "sys_file_save invalid arguments");
return -1;
@@ -311,7 +311,7 @@ static int ejs_sys_file_save(MprVarHandle eid, int argc, char **argv)
*/
static int ejs_sys_mkdir(MprVarHandle eid, int argc, struct MprVar **argv)
{
- BOOL ret;
+ bool ret;
char *name;
if (argc != 2) {
ejsSetErrorMsg(eid, "sys_mkdir invalid arguments, need mkdir(dirname, mode)");
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c
index c97bc1ff8d..29ce763f96 100644
--- a/source4/scripting/ejs/smbscript.c
+++ b/source4/scripting/ejs/smbscript.c
@@ -26,10 +26,11 @@
#include "scripting/ejs/smbcalls.h"
#include "auth/gensec/gensec.h"
#include "ldb/include/ldb.h"
+#include "dynconfig.h"
static EjsId eid;
-static void smbscript_ejs_exception(const char *reason)
+_NORETURN_ static void smbscript_ejs_exception(const char *reason)
{
Ejs *ep = ejsPtr(eid);
ejsSetErrorMsg(eid, "%s", reason);
@@ -52,7 +53,9 @@ int main(int argc, const char **argv)
fault_setup(argv[0]);
if (getenv("SMB_CONF_PATH")) {
- lp_set_cmdline("config file", getenv("SMB_CONF_PATH"));
+ lp_load(getenv("SMB_CONF_PATH"));
+ } else {
+ lp_load(dyn_CONFIGFILE);
}
ldb_global_init();
@@ -60,7 +63,6 @@ int main(int argc, const char **argv)
gensec_init();
mprSetCtx(mem_ctx);
- lp_load();
if (argc < 2) {
fprintf(stderr, "You must supply a script name\n");
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
index fd6de2695f..870e33f84a 100644
--- a/source4/scripting/libjs/provision.js
+++ b/source4/scripting/libjs/provision.js
@@ -162,7 +162,6 @@ function ldb_erase(info, ldb)
/* delete the specials */
ldb.del("@INDEXLIST");
ldb.del("@ATTRIBUTES");
- ldb.del("@SUBCLASSES");
ldb.del("@MODULES");
ldb.del("@PARTITION");
ldb.del("@KLUDGEACL");
@@ -356,6 +355,11 @@ function setup_file(template, message, fname, subobj)
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);
@@ -490,6 +494,17 @@ function provision_fix_subobj(subobj, paths)
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 (subobj.SERVERROLE != "domain controller") {
+ subobj.REALM = subobj.HOSTNAME;
+ subobj.DOMAIN = subobj.HOSTNAME;
+ }
+
return true;
}
@@ -537,6 +552,8 @@ function provision_become_dc(subobj, message, erase, paths, session_info)
setup_ldb("secrets.ldif", info, paths.secrets, false);
+ setup_ldb("secrets_dc.ldif", info, paths.secrets, false);
+
return true;
}
@@ -572,8 +589,16 @@ function provision(subobj, message, blank, paths, session_info, credentials, lda
/* 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 (subobj.SERVERROLE == "domain controller") {
+ smbconfsuffix = "dc";
+ } else if (subobj.SERVERROLE == "member server") {
+ smbconfsuffix = "member";
+ } else {
+ smbconfsuffix = subobj.SERVERROLE;
+ }
message("Setting up " + paths.smbconf +"\n");
- setup_file("provision.smb.conf", info.message, paths.smbconf, subobj);
+ setup_file("provision.smb.conf." + smbconfsuffix, info.message, paths.smbconf, subobj);
lp.reload();
}
/* only install a new shares config db if there is none */
@@ -725,7 +750,7 @@ function provision(subobj, message, blank, paths, session_info, credentials, lda
message("Setting up sam.ldb users and groups\n");
setup_add_ldif("provision_users.ldif", info, samdb, false);
- if (lp.get("server role") == "domain controller") {
+ if (subobj.SERVERROLE == "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);
@@ -738,6 +763,9 @@ function provision(subobj, message, blank, paths, session_info, credentials, lda
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) {
@@ -810,8 +838,8 @@ function provision_schema(subobj, message, tmp_schema_path, paths)
function provision_dns(subobj, message, paths, session_info, credentials)
{
var lp = loadparm_init();
- if (lp.get("server role") != "domain controller") {
- message("No DNS zone required for role %s\n", lp.get("server role"));
+ if (subobj.SERVERROLE != "domain controller") {
+ message("No DNS zone required for role %s\n", subobj.SERVERROLE);
return;
}
message("Setting up DNS zone: " + subobj.DNSDOMAIN + " \n");
@@ -887,6 +915,7 @@ function provision_guess()
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();
@@ -1101,15 +1130,21 @@ function provision_validate(subobj, message)
}
- if (strupper(lp.get("workgroup")) != strupper(subobj.DOMAIN)) {
+ 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);
+ lp.get("workgroup"), subobj.DOMAIN_CONF);
return false;
}
- if (strupper(lp.get("realm")) != strupper(subobj.REALM)) {
+ 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);
+ lp.get("realm"), subobj.REALM_CONF);
+ return false;
+ }
+
+ if (strupper(lp.get("server role")) != strupper(subobj.SERVERROLE)) {
+ message("server role '%s' in smb.conf must match chosen role '%s'\n",
+ lp.get("server role"), subobj.SERVERROLE);
return false;
}
diff --git a/source4/scripting/swig/config.mk b/source4/scripting/swig/config.mk
index 61e8081268..bf9a481e4e 100644
--- a/source4/scripting/swig/config.mk
+++ b/source4/scripting/swig/config.mk
@@ -9,7 +9,7 @@ OBJ_FILES = dcerpc_wrap.o
# Swig extensions
swig: lib/tdb/swig/_tdb.$(SHLIBEXT) lib/ldb/swig/_ldb.$(SHLIBEXT) \
- libcli/swig/_libcli_nbt.$(SHLIBEXT)
+ libcli/swig/_libcli_nbt.$(SHLIBEXT) libcli/swig/_libcli_smb.$(SHLIBEXT)
.SUFFIXES: _wrap.c .i
diff --git a/source4/selftest/README b/source4/selftest/README
index 1d67a6d85d..a0afda3d19 100644
--- a/source4/selftest/README
+++ b/source4/selftest/README
@@ -3,18 +3,22 @@ bunch of tests all at once.
The following environments are currently available:
- - none: No server set up
+ - none: No server set up, no variables set.
- dc: Domain controller set up. The following environment variables will
be set:
- * USERNAME
- * PASSWORD
- * DOMAIN
- * REALM
- * SERVER
+ * USERNAME: Administrator user name
+ * PASSWORD: Administrator password
+ * DOMAIN: Domain name
+ * REALM: Realm name
+ * SERVER: DC host name
+ * SERVER_IP: DC IPv4 address
+ * NETBIOSNAME: DC NetBIOS name
+ * NETIOSALIAS: DC NetBIOS alias
+
- member: Domain controller and member server that is joined to it set up. The
following environment variables will be set:
- * USERNAME
- * PASSWORD
- * DOMAIN
- * REALM
- * SERVER (contains the name of the member server)
+ * USERNAME: Domain administrator user name
+ * PASSWORD: Domain administrator password
+ * DOMAIN: Domain name
+ * REALM: Realm name
+ * SERVER: Name of the member server
diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm
index 1be412c356..2ecafb42d0 100644
--- a/source4/selftest/Subunit.pm
+++ b/source4/selftest/Subunit.pm
@@ -9,7 +9,10 @@ use strict;
sub parse_results($$$$$)
{
my ($msg_ops, $msg_state, $statistics, $fh, $expecting_failure) = @_;
- my $expected_ret = 1;
+ my $unexpected_ok = 0;
+ my $expected_fail = 0;
+ my $unexpected_fail = 0;
+ my $unexpected_err = 0;
my $open_tests = {};
while(<$fh>) {
@@ -34,6 +37,7 @@ sub parse_results($$$$$)
if ($expecting_failure->("$msg_state->{NAME}/$2")) {
$statistics->{TESTS_UNEXPECTED_OK}++;
$msg_ops->end_test($msg_state, $2, $1, 1, $reason);
+ $unexpected_ok++;
} else {
$statistics->{TESTS_EXPECTED_OK}++;
$msg_ops->end_test($msg_state, $2, $1, 0, $reason);
@@ -43,10 +47,11 @@ sub parse_results($$$$$)
if ($expecting_failure->("$msg_state->{NAME}/$2")) {
$statistics->{TESTS_EXPECTED_FAIL}++;
$msg_ops->end_test($msg_state, $2, $1, 0, $reason);
- $expected_ret = 0;
+ $expected_fail++;
} else {
$statistics->{TESTS_UNEXPECTED_FAIL}++;
$msg_ops->end_test($msg_state, $2, $1, 1, $reason);
+ $unexpected_fail++;
}
} elsif ($1 eq "skip") {
$statistics->{TESTS_SKIP}++;
@@ -56,6 +61,7 @@ sub parse_results($$$$$)
$statistics->{TESTS_ERROR}++;
delete $open_tests->{$2};
$msg_ops->end_test($msg_state, $2, $1, 1, $reason);
+ $unexpected_err++;
}
} else {
$msg_ops->output_msg($msg_state, $_);
@@ -63,12 +69,18 @@ sub parse_results($$$$$)
}
foreach (keys %$open_tests) {
- $msg_ops->end_test($msg_state, $_, "error", 1,
- "was started but never finished!");
+ $msg_ops->end_test($msg_state, $_, "error", 1,
+ "was started but never finished!");
$statistics->{TESTS_ERROR}++;
+ $unexpected_err++;
}
- return $expected_ret;
+ return 1 if $unexpected_err > 0;
+ return 1 if $unexpected_fail > 0;
+ return 1 if $unexpected_ok > 0 and $expected_fail > 0;
+ return 0 if $unexpected_ok > 0 and $expected_fail == 0;
+ return 0 if $expected_fail > 0;
+ return 1;
}
1;
diff --git a/source4/selftest/TODO b/source4/selftest/TODO
index 42f90188ed..67776ffc76 100644
--- a/source4/selftest/TODO
+++ b/source4/selftest/TODO
@@ -1,3 +1,2 @@
- warn about unexpected successes
- better way to detect that smbd has finished initialization
-- move ldap-specific code into mktestdc.sh
diff --git a/source4/selftest/env/Samba3.pm b/source4/selftest/env/Samba3.pm
index b12208bd9f..951fbee4ec 100644
--- a/source4/selftest/env/Samba3.pm
+++ b/source4/selftest/env/Samba3.pm
@@ -8,6 +8,7 @@ package Samba3;
use strict;
use Cwd qw(abs_path);
use FindBin qw($RealBin);
+use POSIX;
sub binpath($$)
{
@@ -33,18 +34,51 @@ sub teardown_env($$)
{
my ($self, $envvars) = @_;
- $self->samba3_stop_sig_term($envvars->{PIDDIR});
- $self->samba3_stop_sig_kill($envvars->{PIDDIR});
+ my $smbdpid = read_pid($envvars, "smbd");
+ my $nmbdpid = read_pid($envvars, "nmbd");
+# my $winbinddpid = read_pid($envvars, "winbindd");
+
+ $self->stop_sig_term($smbdpid);
+ $self->stop_sig_term($nmbdpid);
+# $self->stop_sig_term($winbinddpid);
+ $self->stop_sig_kill($smbdpid);
+ $self->stop_sig_kill($nmbdpid);
+# $self->stop_sig_kill($winbinddpid);
return 0;
}
+sub getlog_env_app($$$)
+{
+ my ($self, $envvars, $name) = @_;
+
+ my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
+ my $out = $title;
+
+ open(LOG, "<".$envvars->{$name."_TEST_LOG"});
+
+ seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
+ while (<LOG>) {
+ $out .= $_;
+ }
+ $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
+ close(LOG);
+
+ return "" if $out eq $title;
+
+ return $out;
+}
+
sub getlog_env($$)
{
my ($self, $envvars) = @_;
+ my $ret = "";
- # TODO...
- return "";
+ $ret .= $self->getlog_env_app($envvars, "SMBD");
+ $ret .= $self->getlog_env_app($envvars, "NMBD");
+# $ret .= $self->getlog_env_app($envvars, "WINBINDD");
+
+ return $ret;
}
sub check_env($$)
@@ -62,7 +96,7 @@ sub setup_env($$$)
if ($envname eq "dc") {
return $self->setup_dc("$path/dc");
} else {
- die("Samba4 can't provide environment '$envname'");
+ return undef;
}
}
@@ -70,9 +104,12 @@ sub setup_dc($$)
{
my ($self, $path) = @_;
- my $vars = $self->provision($path);
+ my $vars = $self->provision($path, "dc");
- $self->check_or_start($vars, ($ENV{NMBD_MAXTIME} or 2700), ($ENV{SMBD_MAXTIME} or 2700));
+ $self->check_or_start($vars,
+ ($ENV{NMBD_MAXTIME} or 2700),
+ ($ENV{WINBINDD_MAXTIME} or 2700),
+ ($ENV{SMBD_MAXTIME} or 2700));
$self->wait_for_start($vars);
@@ -84,27 +121,37 @@ sub stop($)
my ($self) = @_;
}
-sub samba3_stop_sig_term($$) {
- my ($self, $piddir) = @_;
- my $ret = 0;
- kill("USR1", `cat $piddir/timelimit.nmbd.pid`) or \
- kill("ALRM", `cat $piddir/timelimit.nmbd.pid`) or $ret++;
+sub stop_sig_term($$) {
+ my ($self, $pid) = @_;
+ kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
+}
- kill("USR1", `cat $piddir/timelimit.smbd.pid`) or \
- kill("ALRM", `cat $piddir/timelimit.smbd.pid`) or $ret++;
+sub stop_sig_kill($$) {
+ my ($self, $pid) = @_;
+ kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
+}
- return $ret;
+sub write_pid($$$)
+{
+ my ($env_vars, $app, $pid) = @_;
+
+ open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
+ print PID $pid;
+ close(PID);
}
-sub samba3_stop_sig_kill($$) {
- my ($self, $piddir) = @_;
- kill("ALRM", `cat $piddir/timelimit.nmbd.pid`);
- kill("ALRM", `cat $piddir/timelimit.smbd.pid`);
- return 0;
+sub read_pid($$)
+{
+ my ($env_vars, $app) = @_;
+
+ open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
+ my $pid = <PID>;
+ close(PID);
+ return $pid;
}
sub check_or_start($$$$) {
- my ($self, $env_vars, $nmbd_maxtime, $smbd_maxtime) = @_;
+ my ($self, $env_vars, $nmbd_maxtime, $winbindd_maxtime, $smbd_maxtime) = @_;
unlink($env_vars->{NMBD_TEST_LOG});
print "STARTING NMBD...";
@@ -112,28 +159,58 @@ sub check_or_start($$$$) {
if ($pid == 0) {
open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
open STDERR, '>&STDOUT';
-
+
+ $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
+
+ my @optargs = ("-d0");
+ if (defined($ENV{NMBD_OPTIONS})) {
+ @optargs = split(/ /, $ENV{NMBD_OPTIONS});
+ }
+
$ENV{MAKE_TEST_BINARY} = $self->binpath("nmbd");
- exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("nmbd"), "-F", "-S", "--no-process-group", "-d0" ,"-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start nmbd: $!");
+ exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("nmbd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
}
- open(PID, ">$env_vars->{PIDDIR}/timelimit.nmbd.pid");
- print PID $pid;
- close(PID);
+ write_pid($env_vars, "nmbd", $pid);
print "DONE\n";
+# disable winbindd until the build-farm faked_users work with it
+# unlink($env_vars->{WINBINDD_TEST_LOG});
+# print "STARTING WINBINDD...";
+# $pid = fork();
+# if ($pid == 0) {
+# open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
+# open STDERR, '>&STDOUT';
+#
+# $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
+#
+# my @optargs = ("-d0");
+# if (defined($ENV{WINBINDD_OPTIONS})) {
+# @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
+# }
+#
+# $ENV{MAKE_TEST_BINARY} = $self->binpath("winbindd");
+# exec($self->binpath("timelimit"), $winbindd_maxtime, $self->binpath("winbindd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
+# }
+# write_pid($env_vars, "winbindd", $pid);
+# print "DONE\n";
+
unlink($env_vars->{SMBD_TEST_LOG});
print "STARTING SMBD...";
$pid = fork();
if ($pid == 0) {
open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
open STDERR, '>&STDOUT';
-
+
+ $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
+
$ENV{MAKE_TEST_BINARY} = $self->binpath("smbd");
- exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("smbd"), "-F", "-S", "--no-process-group", "-d0" ,"-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start smbd: $!");
+ my @optargs = ("-d0");
+ if (defined($ENV{SMBD_OPTIONS})) {
+ @optargs = split(/ /, $ENV{SMBD_OPTIONS});
+ }
+ exec($self->binpath("timelimit"), $smbd_maxtime, $self->binpath("smbd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
}
- open(PID, ">$env_vars->{PIDDIR}/timelimit.smbd.pid");
- print PID $pid;
- close(PID);
+ write_pid($env_vars, "smbd", $pid);
print "DONE\n";
return 0;
@@ -173,31 +250,50 @@ sub create_clientconf($$$)
close(CONF);
}
-sub provision($$)
+sub provision($$$)
{
- my ($self, $prefix) = @_;
+ my ($self, $prefix, $role) = @_;
##
## setup the various environment variables we need
##
my %ret = ();
- my $server = "localhost2";
+ my $server = "LOCALHOST2";
my $server_ip = "127.0.0.2";
+ my $domain = "SAMBA-TEST";
+
my $username = `PATH=/usr/ucb:$ENV{PATH} whoami`;
+ chomp $username;
my $password = "test";
my $srcdir="$RealBin/..";
my $scriptdir="$srcdir/selftest";
my $prefix_abs = abs_path($prefix);
- my $shrdir="$prefix_abs/tmp";
+
+ my @dirs = ();
+
+ my $shrdir="$prefix_abs/share";
+ push(@dirs,$shrdir);
+
my $libdir="$prefix_abs/lib";
+ push(@dirs,$libdir);
+
my $piddir="$prefix_abs/pid";
- my $conffile="$libdir/server.conf";
+ push(@dirs,$piddir);
+
my $privatedir="$prefix_abs/private";
+ push(@dirs,$privatedir);
+
my $lockdir="$prefix_abs/lockdir";
+ push(@dirs,$lockdir);
+
my $logdir="$prefix_abs/logs";
- my $domain = "SAMBA-TEST";
+ push(@dirs,$logdir);
+
+ # this gets autocreated by winbindd
+ my $wbsockdir="$prefix_abs/winbindd";
+ my $wbsockprivdir="$lockdir/winbindd_privileged";
##
## create the test directory layout
@@ -205,10 +301,9 @@ sub provision($$)
mkdir($prefix_abs, 0777);
print "CREATE TEST ENVIRONMENT IN '$prefix'...";
system("rm -rf $prefix_abs/*");
- mkdir($_, 0777) foreach($privatedir,$libdir,$piddir,$lockdir,$logdir);
- my $tmpdir = "$prefix_abs/tmp";
- mkdir($tmpdir, 0777);
- chmod 0777, $tmpdir;
+ mkdir($_, 0777) foreach(@dirs);
+
+ my $conffile="$libdir/server.conf";
open(CONF, ">$conffile") or die("Unable to open $conffile");
print CONF "
@@ -241,8 +336,19 @@ sub provision($$)
printing = bsd
printcap name = /dev/null
+";
+
+ if ($role eq "dc") {
+ print CONF "\tdomain logons = yes\n";
+ print CONF "\tdomain master = yes\n";
+ }
+
+print CONF "
+
+ winbindd:socket dir = $wbsockdir
+
[tmp]
- path = $tmpdir
+ path = $shrdir
read only = no
smbd:sharedelay = 100000
map hidden = yes
@@ -279,6 +385,7 @@ sub provision($$)
$ret{SERVER_IP} = $server_ip;
$ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
+ $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
$ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
$ret{SERVERCONFFILE} = $conffile;
$ret{CONFIGURATION} ="-s $conffile";
@@ -288,6 +395,8 @@ sub provision($$)
$ret{NETBIOSNAME} = $server;
$ret{PASSWORD} = $password;
$ret{PIDDIR} = $piddir;
+ $ret{WINBINDD_SOCKET_DIR} = $wbsockdir;
+ $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir;
return \%ret;
}
diff --git a/source4/selftest/env/Samba4.pm b/source4/selftest/env/Samba4.pm
index 11afc0e6f3..944ed83d58 100644
--- a/source4/selftest/env/Samba4.pm
+++ b/source4/selftest/env/Samba4.pm
@@ -104,6 +104,9 @@ sub check_or_start($$$)
if (defined($max_time)) {
$optarg = "--maximum-runtime=$max_time ";
}
+ if (defined($ENV{SMBD_OPTIONS})) {
+ $optarg.= " $ENV{SMBD_OPTIONS}";
+ }
my $ret = system("$valgrind $self->{bindir}/smbd $optarg $env_vars->{CONFIGURATION} -M single -i --leak-report-full");
if ($? == -1) {
print "Unable to start smbd: $ret: $!\n";
@@ -216,7 +219,7 @@ sub mk_openldap($$$)
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};
- $ENV{PATH} = "/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}";
+ $ENV{PATH} = "$ENV{OPENLDAP_PATH}/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}";
unlink($modconf);
open(CONF, ">$modconf"); close(CONF);
@@ -225,8 +228,18 @@ sub mk_openldap($$$)
open(CONF, ">$modconf");
# enable slapd modules
print CONF "
+moduleload back_hdb
+moduleload syncprov
+";
+ close(CONF);
+ }
+
+ if (system("slaptest -u -f $slapd_conf >&2") != 0) {
+ open(CONF, ">$modconf");
+ # enable slapd modules
+ print CONF "
modulepath /usr/lib/ldap
-moduleload back_bdb
+moduleload back_hdb
moduleload syncprov
";
close(CONF);
@@ -283,6 +296,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 $configuration = "--configfile=$conffile";
my $ldapdir = "$privatedir/ldap";
@@ -297,10 +311,6 @@ sub provision($$$$$$)
$tmpdir);
- my $localdomain = $domain;
- $localdomain = $netbiosname if $server_role eq "member server";
- my $localrealm = $realm;
- $localrealm = $netbiosname if $server_role eq "member server";
my $localbasedn = $basedn;
$localbasedn = "DC=$netbiosname" if $server_role eq "member server";
@@ -417,8 +427,8 @@ my @provision_options = ("$self->{bindir}/smbscript", "$self->{setupdir}/provisi
push (@provision_options, "--host-name=$netbiosname");
push (@provision_options, "--host-ip=$ifaceipv4");
push (@provision_options, "--quiet");
- push (@provision_options, "--domain=$localdomain");
- push (@provision_options, "--realm=$localrealm");
+ push (@provision_options, "--domain=$domain");
+ push (@provision_options, "--realm=$realm");
push (@provision_options, "--adminpass=$password");
push (@provision_options, "--krbtgtpass=krbtgt$password");
push (@provision_options, "--machinepass=machine$password");
@@ -426,6 +436,7 @@ my @provision_options = ("$self->{bindir}/smbscript", "$self->{setupdir}/provisi
push (@provision_options, "--simple-bind-dn=cn=Manager,$localbasedn");
push (@provision_options, "--password=$password");
push (@provision_options, "--root=$root");
+ push (@provision_options, "--server-role=$server_role");
my $ldap_uri= "$ldapdir/ldapi";
$ldap_uri =~ s|/|%2F|g;
@@ -445,7 +456,9 @@ my @provision_options = ("$self->{bindir}/smbscript", "$self->{setupdir}/provisi
PASSWORD => $password,
LDAPDIR => $ldapdir,
WINBINDD_SOCKET_DIR => $winbindd_socket_dir,
+ WINBINDD_PRIV_PIPE_DIR => $winbindd_priv_pipe_dir,
NCALRPCDIR => $ncalrpcdir,
+ LOCKDIR => $lockdir,
CONFIGURATION => $configuration,
SOCKET_WRAPPER_DEFAULT_IFACE => $swiface
};
@@ -453,7 +466,7 @@ my @provision_options = ("$self->{bindir}/smbscript", "$self->{setupdir}/provisi
if (defined($self->{ldap})) {
push (@provision_options, "--ldap-backend=$ldap_uri");
- system("$self->{bindir}/smbscript $self->{setupdir}/provision-backend $configuration --ldap-manager-pass=$password --root=$root --realm=$localrealm --host-name=$netbiosname --ldap-backend-type=$self->{ldap}>&2") == 0 or die("backend provision failed");
+ system("$self->{bindir}/smbscript $self->{setupdir}/provision-backend $configuration --ldap-manager-pass=$password --root=$root --realm=$realm --host-name=$netbiosname --ldap-backend-type=$self->{ldap}>&2") == 0 or die("backend provision failed");
if ($self->{ldap} eq "openldap") {
($ret->{SLAPD_CONF}, $ret->{OPENLDAP_PIDFILE}) = $self->mk_openldap($ldapdir, $configuration) or die("Unable to create openldap directories");
diff --git a/source4/selftest/output/buildfarm.pm b/source4/selftest/output/buildfarm.pm
index 7d6c3a987a..efb1e3ef5b 100644
--- a/source4/selftest/output/buildfarm.pm
+++ b/source4/selftest/output/buildfarm.pm
@@ -7,10 +7,10 @@ use Exporter;
use strict;
-sub new($$) {
- my ($class) = @_;
- my $self = {
- start => time(),
+sub new($$$$) {
+ my ($class, $statistics) = @_;
+ my $self = {
+ statistics => $statistics,
test_output => {}
};
bless($self, $class);
@@ -21,11 +21,12 @@ sub start_testsuite($$)
my ($self, $state) = @_;
my $out = "";
+ my $duration = $state->{START_TIME} - $self->{statistics}->{START_TIME};
$out .= "--==--==--==--==--==--==--==--==--==--==--\n";
$out .= "Running test $state->{NAME} (level 0 stdout)\n";
$out .= "--==--==--==--==--==--==--==--==--==--==--\n";
$out .= scalar(localtime())."\n";
- $out .= "SELFTEST RUNTIME: " . ($state->{START_TIME} - $self->{START_TIME}) . "s\n";
+ $out .= "SELFTEST RUNTIME: " . $duration . "s\n";
$out .= "NAME: $state->{NAME}\n";
$out .= "CMD: $state->{CMD}\n";
@@ -58,7 +59,7 @@ sub end_testsuite($$$$$)
if ($ret == $expected_ret) {
$out .= "ALL OK\n";
} else {
- $out .= "ERROR: $ret";
+ $out .= "ERROR: $ret\n";
$out .= $self->{test_output}->{$state->{NAME}};
}
@@ -84,7 +85,11 @@ sub start_test($$$)
sub end_test($$$$$$)
{
- my ($self, $state, $testname, $result, $expected, $reason) = @_;
+ my ($self, $state, $testname, $result, $unexpected, $reason) = @_;
+
+ return unless ($unexpected);
+
+ $self->{test_output}->{$state->{NAME}} .= "UNEXPECTED($result): $testname\n";
}
sub summary($)
@@ -99,11 +104,11 @@ sub missing_env($$$)
print "FAIL: $name (ENV[$envname] not available!)\n";
}
-sub skip_testsuite($$)
+sub skip_testsuite($$$$)
{
- my ($self, $name) = @_;
+ my ($self, $envname, $name, $reason) = @_;
- print "SKIPPED: $name\n";
+ # Ignore skipped tests
}
1;
diff --git a/source4/selftest/output/html.pm b/source4/selftest/output/html.pm
index 156b5b98c7..22488576b4 100644
--- a/source4/selftest/output/html.pm
+++ b/source4/selftest/output/html.pm
@@ -7,6 +7,8 @@ use Exporter;
use strict;
use warnings;
+use FindBin qw($RealBin);
+
sub new($$$$) {
my ($class, $dirname, $statistics) = @_;
my $self = {
@@ -21,11 +23,12 @@ sub new($$$$) {
unexpected_success => [],
expected_failure => [],
unexpected_failure => [],
+ skip_testsuites => [],
error => []
}
};
- link("selftest/output/testresults.css", "$dirname/testresults.css");
+ link("$RealBin/output/testresults.css", "$dirname/testresults.css");
open(INDEX, ">$dirname/index.html");
@@ -89,6 +92,29 @@ sub start_testsuite($$)
$self->print_html_header("Test Results for $state->{NAME}",
*TEST);
+
+ if ($state->{ENVNAME} ne "none") {
+ print TEST "<h2>Environment settings</h2>\n";
+
+ print TEST " <table>\n";
+ print TEST " <tr><td><b>Variable name</b></td><td><b>Variable value</b></td></tr>\n";
+ foreach (keys %{$state->{ENVVARS}}) {
+ print TEST " <tr><td>$_</td><td>";
+ my $val = $state->{ENVVARS}->{$_};
+ if ($val =~ /^\.\// and -r $val) {
+ print TEST "<a href=\"../$val\">$val</a>";
+ } elsif (-r $val) {
+ print TEST "<a href=\"$val\">$val</a>";
+ } else {
+ print TEST $val;
+ }
+ print TEST "</td></tr>\n";
+ }
+ print TEST " </table>\n";
+ }
+
+ print TEST "<h2>Tests</h2>\n";
+
print TEST " <table>\n";
}
@@ -116,6 +142,7 @@ sub end_testsuite($$$$$)
print TEST "</table>\n";
+ print TEST "<div class=\"command\">$state->{CMD}</div>\n";
print TEST "<div class=\"duration\">Duration: " . (time() - $state->{START_TIME}) . "s</div>\n";
$self->print_html_footer(*TEST);
@@ -261,6 +288,7 @@ sub summary($)
print INDEX "</tr>\n";
print INDEX "</table>\n";
+ print INDEX "<a href=\"summary.html\">Summary</a>\n";
print INDEX "</center>\n";
$self->print_html_footer(*INDEX);
close(INDEX);
@@ -298,6 +326,27 @@ sub summary($)
print_table("Unexpected failures", $summ->{unexpected_failure});
print_table("Skipped tests", $summ->{skip});
print_table("Expected failures", $summ->{expected_failure});
+
+ print SUMMARY "<h3>Skipped testsuites</h3>\n";
+ print SUMMARY "<table>\n";
+ print SUMMARY "<tr>\n";
+ print SUMMARY " <td class=\"tableHead\">Testsuite</td>\n";
+ print SUMMARY " <td class=\"tableHead\">Reason</td>\n";
+ print SUMMARY "</tr>\n";
+
+ foreach (@{$summ->{skip_testsuites}}) {
+ print SUMMARY "<tr>\n";
+ print SUMMARY " <td>$$_[1]</td>\n";
+ if (defined($$_[2])) {
+ print SUMMARY " <td>$$_[2]</td>\n";
+ } else {
+ print SUMMARY " <td></td>\n";
+ }
+ print SUMMARY "</tr>\n";
+ }
+
+ print SUMMARY "</table>";
+
$self->print_html_footer(*SUMMARY);
close(SUMMARY);
}
@@ -306,20 +355,15 @@ sub missing_env($$$)
{
my ($self, $name, $envname) = @_;
- print INDEX "<tr>\n";
- print INDEX " <td class=\"testSuite\">$name</td>\n";
- print INDEX " <td class=\"resultSkipped\" colspan=\"2\">SKIPPED - environment `$envname` not available!</td>\n";
- print INDEX "</tr>\n";
+ $self->skip_testsuite($envname, $name, "environment `$envname` not available!");
}
-sub skip_testsuite($$)
+sub skip_testsuite($$$$)
{
- my ($self, $name) = @_;
+ my ($self, $envname, $name, $reason) = @_;
- print INDEX "<tr>\n";
- print INDEX " <td class=\"testSuite\">$name</td>\n";
- print INDEX " <td class=\"resultSkipped\" colspan=\"2\">SKIPPED</td>\n";
- print INDEX "</tr>\n";
+ push (@{$self->{error_summary}->{skip_testsuites}},
+ [$envname, $name, $reason]);
}
1;
diff --git a/source4/selftest/output/plain.pm b/source4/selftest/output/plain.pm
index 10d6eee215..e4abb2d05a 100644
--- a/source4/selftest/output/plain.pm
+++ b/source4/selftest/output/plain.pm
@@ -13,8 +13,7 @@ sub new($$$$) {
immediate => $immediate,
statistics => $statistics,
test_output => {},
- suitesfailed => [],
- start => time()
+ suitesfailed => []
};
bless($self, $class);
}
@@ -61,6 +60,8 @@ sub end_testsuite($$$$$)
my ($self, $state, $expected_ret, $ret, $envlog) = @_;
my $out = "";
+ $self->output_msg($state, "ENVLOG: $envlog\n") if ($envlog ne "");
+
if ($ret != $expected_ret) {
$self->output_msg($state, "ERROR: $ret\n");
}
@@ -77,9 +78,24 @@ sub start_test($$)
my ($state, $testname) = @_;
}
-sub end_test($$$$$)
+sub end_test($$$$$$)
{
- my ($state, $testname, $result, $unexpected, $reason) = @_;
+ my ($self, $state, $testname, $result, $unexpected, $reason) = @_;
+ my $append = "";
+
+ unless ($unexpected) {
+ $self->{test_output}->{$state->{NAME}} = "";
+ return;
+ }
+
+ $append = "UNEXPECTED($result): $testname\n";
+
+ $self->{test_output}->{$state->{NAME}} .= $append;
+
+ if ($self->{immediate} and not $self->{verbose}) {
+ print $self->{test_output}->{$state->{NAME}};
+ $self->{test_output}->{$state->{NAME}} = "";
+ }
}
sub summary($)
@@ -111,11 +127,15 @@ sub missing_env($$$)
print "FAIL: $name (ENV[$envname] not available!)\n";
}
-sub skip_testsuite($$)
+sub skip_testsuite($$$)
{
- my ($self, $name) = @_;
+ my ($self, $envname, $name, $reason) = @_;
- print "SKIPPED: $name\n";
+ if ($reason) {
+ print "SKIPPED: $name [$reason]\n";
+ } else {
+ print "SKIPPED: $name\n";
+ }
}
1;
diff --git a/source4/selftest/output/testresults.css b/source4/selftest/output/testresults.css
index 56c4b0ead4..66d1d6b2ad 100644
--- a/source4/selftest/output/testresults.css
+++ b/source4/selftest/output/testresults.css
@@ -122,3 +122,8 @@ div.duration
text-align: right;
font-weight: bold;
}
+
+div.command
+{
+ background-color: gray;
+}
diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl
index 3f8a74f7bc..3ab87f8dcc 100755
--- a/source4/selftest/selftest.pl
+++ b/source4/selftest/selftest.pl
@@ -13,7 +13,7 @@ selftest - Samba test runner
selftest --help
-selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win] [--socket-wrapper] [--quick] [--one] [--prefix=prefix] [--immediate] [TESTS]
+selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win] [--socket-wrapper] [--quick] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS]
=head1 DESCRIPTION
@@ -69,15 +69,23 @@ The format for the file is, one entry per line:
TESTSUITE-NAME/TEST-NAME
+The reason for a test can also be specified, by adding a hash sign (#) and the reason
+after the test name.
+
=item I<--skip>
Specify a file containing a list of tests that should be skipped. Possible candidates are
-tests that segfault the server, flip or don't end.
+tests that segfault the server, flip or don't end. The format of this file is the same as
+for the --expected-failures flag.
=item I<--one>
Abort as soon as one test fails.
+=item I<--testlist>
+
+Load a list of tests from the specified location.
+
=back
=head1 ENVIRONMENT
@@ -129,7 +137,7 @@ my $opt_socket_wrapper_keep_pcap = undef;
my $opt_one = 0;
my $opt_immediate = 0;
my $opt_expected_failures = undef;
-my $opt_skip = undef;
+my @opt_skip = ();
my $opt_verbose = 0;
my $opt_testenv = 0;
my $ldap = undef;
@@ -138,6 +146,7 @@ my $opt_resetup_env = undef;
my $opt_bindir = undef;
my $opt_no_lazy_setup = undef;
my $opt_format = "plain";
+my @opt_testlists = ();
my $srcdir = ".";
my $builddir = ".";
@@ -161,26 +170,30 @@ my $statistics = {
TESTS_SKIP => 0,
};
-sub expecting_failure($)
+sub find_in_list($$)
{
- my $fullname = shift;
+ my ($list, $fullname) = @_;
- foreach (@expected_failures) {
- return 1 if ($fullname =~ /$_/);
+ foreach (@$list) {
+ if ($fullname =~ /$$_[0]/) {
+ return ($$_[1]) if ($$_[1]);
+ return "NO REASON SPECIFIED";
+ }
}
- return 0;
+ return undef;
}
-sub skip($)
+sub expecting_failure($)
{
- my $fullname = shift;
-
- foreach (@skips) {
- return 1 if ($fullname =~ /$_/);
- }
+ my ($name) = @_;
+ return find_in_list(\@expected_failures, $name);
+}
- return 0;
+sub skip($)
+{
+ my ($name) = @_;
+ return find_in_list(\@skips, $name);
}
sub getlog_env($);
@@ -213,11 +226,12 @@ sub cleanup_pcap($$$)
$state->{PCAP_FILE} = undef;
}
-sub run_testsuite($$$$$$)
+sub run_testsuite($$$$$$$)
{
- my ($envname, $name, $cmd, $i, $totalsuites, $msg_ops) = @_;
+ my ($envname, $envvars, $name, $cmd, $i, $totalsuites, $msg_ops) = @_;
my $msg_state = {
ENVNAME => $envname,
+ ENVVARS => $envvars,
NAME => $name,
CMD => $cmd,
INDEX => $i,
@@ -234,6 +248,7 @@ sub run_testsuite($$$$$$)
$msg_ops, $msg_state, $statistics, *RESULT, \&expecting_failure);
my $ret = close(RESULT);
+ $ret = 0 unless $ret == 1;
cleanup_pcap($msg_state, $expected_ret, $ret);
@@ -266,6 +281,7 @@ Usage: $Script [OPTIONS] PREFIX
Generic options:
--help this help page
--target=samba4|samba3|win Samba version to target
+ --testlist=FILE file to read available tests from
Paths:
--prefix=DIR prefix to run tests in [st]
@@ -273,7 +289,7 @@ Paths:
--builddir=DIR output directory [.]
Target Specific:
- --socket-wrapper-pcap=DIR save traffic to pcap directories
+ --socket-wrapper-pcap save traffic to pcap directories
--socket-wrapper-keep-pcap keep all pcap files, not just those for tests that
failed
--socket-wrapper enable socket wrapper
@@ -306,7 +322,7 @@ my $result = GetOptions (
'one' => \$opt_one,
'immediate' => \$opt_immediate,
'expected-failures=s' => \$opt_expected_failures,
- 'skip=s' => \$opt_skip,
+ 'skip=s' => \@opt_skip,
'srcdir=s' => \$srcdir,
'builddir=s' => \$builddir,
'verbose' => \$opt_verbose,
@@ -317,6 +333,7 @@ my $result = GetOptions (
'resetup-environment' => \$opt_resetup_env,
'bindir:s' => \$opt_bindir,
'format=s' => \$opt_format,
+ 'testlist=s' => \@opt_testlists
);
exit(1) if (not $result);
@@ -368,12 +385,12 @@ $ENV{PREFIX_ABS} = $prefix_abs;
$ENV{SRCDIR} = $srcdir;
$ENV{SRCDIR_ABS} = $srcdir_abs;
-my $tls_enabled = not $opt_quick;
if (defined($ENV{RUN_FROM_BUILD_FARM}) and
($ENV{RUN_FROM_BUILD_FARM} eq "yes")) {
$opt_format = "buildfarm";
}
+my $tls_enabled = not $opt_quick;
$ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
$ENV{LD_LDB_MODULE_PATH} = "$old_pwd/bin/modules/ldb";
$ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/bin/modules";
@@ -387,7 +404,8 @@ if (defined($ENV{PKG_CONFIG_PATH})) {
} else {
$ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig";
}
-$ENV{PATH} = "$old_pwd/bin:$ENV{PATH}";
+# Required for smbscript:
+$ENV{PATH} = "$old_pwd/bin:$old_pwd:$ENV{PATH}";
if ($opt_socket_wrapper_pcap) {
@@ -404,37 +422,48 @@ if ($opt_socket_wrapper) {
}
my $target;
+my $testenv_default = "none";
if ($opt_target eq "samba4") {
- $target = new Samba4("$srcdir/bin", $ldap, "$srcdir/setup");
+ $testenv_default = "member";
+ $target = new Samba4($opt_bindir or "$srcdir/bin", $ldap, "$srcdir/setup");
} elsif ($opt_target eq "samba3") {
- if ($opt_socket_wrapper and `smbd -b | grep SOCKET_WRAPPER` eq "") {
+ if ($opt_socket_wrapper and `$opt_bindir/smbd -b | grep SOCKET_WRAPPER` eq "") {
die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting....");
}
-
+ $testenv_default = "dc";
$target = new Samba3($opt_bindir);
} elsif ($opt_target eq "win") {
die("Windows tests will not run with socket wrapper enabled.")
if ($opt_socket_wrapper);
+ $testenv_default = "dc";
$target = new Windows();
}
-if (defined($opt_expected_failures)) {
- open(KNOWN, "<$opt_expected_failures") or die("unable to read known failures file: $!");
- while (<KNOWN>) {
+sub read_test_regexes($)
+{
+ my ($name) = @_;
+ my @ret = ();
+ open(LF, "<$name") or die("unable to read $name: $!");
+ while (<LF>) {
chomp;
- s/([ \t]+)\#(.*)$//;
- push (@expected_failures, $_); }
- close(KNOWN);
+ if (/^(.*?)([ \t]+)\#(.*)$/) {
+ push (@ret, [$1, $3]);
+ } else {
+ s/^(.*?)([ \t]+)\#(.*)$//;
+ push (@ret, [$_, undef]);
+ }
+ }
+ close(LF);
+ return @ret;
}
-if (defined($opt_skip)) {
- open(SKIP, "<$opt_skip") or die("unable to read skip file: $!");
- while (<SKIP>) {
- chomp;
- s/([ \t]+)\#(.*)$//;
- push (@skips, $_); }
- close(SKIP);
+if (defined($opt_expected_failures)) {
+ @expected_failures = read_test_regexes($opt_expected_failures);
+}
+
+foreach (@opt_skip) {
+ push (@skips, read_test_regexes($_));
}
my $interfaces = join(',', ("127.0.0.6/8",
@@ -504,7 +533,7 @@ push (@torture_options, "--configfile=$conffile");
# ensure any one smbtorture call doesn't run too long
push (@torture_options, "--maximum-runtime=$torture_maxtime");
push (@torture_options, "--target=$opt_target");
-push (@torture_options, "--basedir=$prefix");
+push (@torture_options, "--basedir=$prefix_abs");
push (@torture_options, "--option=torture:progress=no") if ($opt_format eq "buildfarm");
push (@torture_options, "--format=subunit");
push (@torture_options, "--option=torture:quick=yes") if ($opt_quick);
@@ -520,28 +549,47 @@ $ENV{CONFIGURATION} = "--configfile=$conffile";
my %required_envs = ();
-if ($opt_quick) {
- open(IN, "$testsdir/tests_quick.sh|");
-} else {
- open(IN, "$testsdir/tests_all.sh|");
-}
-while (<IN>) {
- if ($_ eq "-- TEST --\n") {
- my $name = <IN>;
- $name =~ s/\n//g;
- my $env = <IN>;
- $env =~ s/\n//g;
- my $cmdline = <IN>;
- $cmdline =~ s/\n//g;
- if (not defined($tests) or $name =~ /$tests/) {
- $required_envs{$env} = 1;
- push (@todo, [$name, $env, $cmdline]);
+sub read_testlist($)
+{
+ my ($filename) = @_;
+
+ my @ret = ();
+ open(IN, $filename) or die("Unable to open $filename: $!");
+
+ while (<IN>) {
+ if ($_ eq "-- TEST --\n") {
+ my $name = <IN>;
+ $name =~ s/\n//g;
+ my $env = <IN>;
+ $env =~ s/\n//g;
+ my $cmdline = <IN>;
+ $cmdline =~ s/\n//g;
+ if (not defined($tests) or $name =~ /$tests/) {
+ $required_envs{$env} = 1;
+ push (@ret, [$name, $env, $cmdline]);
+ }
+ } else {
+ print;
}
- } else {
- print;
}
+ close(IN) or die("Error creating recipe");
+ return @ret;
+}
+
+if ($opt_quick) {
+ @todo = read_testlist("$testsdir/tests_quick.sh|");
+} else {
+ @todo = read_testlist("$testsdir/tests_all.sh|");
}
-close(IN) or die("Error creating recipe");
+
+foreach (@opt_testlists) {
+ push(@todo, read_testlist($_));
+}
+
+if ($#todo == -1) {
+ print STDERR "No tests to run\n";
+ exit(1);
+ }
my $suitestotal = $#todo + 1;
my $i = 0;
@@ -574,9 +622,16 @@ my @exported_envvars = (
# misc stuff
"KRB5_CONFIG",
- "WINBINDD_SOCKET_DIR"
+ "WINBINDD_SOCKET_DIR",
+ "WINBINDD_PRIV_PIPE_DIR"
);
+$SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
+ my $signame = shift;
+ teardown_env($_) foreach(keys %running_envs);
+ die("Received signal $signame");
+};
+
sub setup_env($)
{
my ($envname) = @_;
@@ -595,6 +650,8 @@ sub setup_env($)
return undef unless defined($testenv_vars);
+ $running_envs{$envname} = $testenv_vars;
+
SocketWrapper::set_default_iface(6);
write_clientconf($conffile, $testenv_vars);
@@ -606,7 +663,6 @@ sub setup_env($)
}
}
- $running_envs{$envname} = $testenv_vars;
return $testenv_vars;
}
@@ -648,7 +704,7 @@ sub teardown_env($)
my $msg_ops;
if ($opt_format eq "buildfarm") {
require output::buildfarm;
- $msg_ops = new output::buildfarm();
+ $msg_ops = new output::buildfarm($statistics);
} elsif ($opt_format eq "plain") {
require output::plain;
$msg_ops = new output::plain($opt_verbose, $opt_immediate, $statistics);
@@ -666,7 +722,7 @@ if ($opt_no_lazy_setup) {
if ($opt_testenv) {
my $testenv_name = $ENV{SELFTEST_TESTENV};
- $testenv_name = "dc" unless defined($testenv_name);
+ $testenv_name = $testenv_default unless defined($testenv_name);
my $testenv_vars = setup_env($testenv_name);
@@ -696,21 +752,22 @@ $envvarstr
my $name = $$_[0];
my $envname = $$_[1];
- if (skip($name)) {
- $msg_ops->skip_testsuite($name);
+ my $skipreason = skip($name);
+ if ($skipreason) {
+ $msg_ops->skip_testsuite($envname, $name, $skipreason);
$statistics->{SUITES_SKIPPED}++;
next;
}
my $envvars = setup_env($envname);
if (not defined($envvars)) {
- $statistics->{SUITES_FAIL}++;
- $statistics->{TESTS_ERROR}++;
+ $statistics->{SUITES_SKIPPED}++;
$msg_ops->missing_env($name, $envname);
next;
}
- run_testsuite($envname, $name, $cmd, $i, $suitestotal, $msg_ops);
+ run_testsuite($envname, $envvars, $name, $cmd, $i, $suitestotal,
+ $msg_ops);
if (defined($opt_analyse_cmd)) {
system("$opt_analyse_cmd \"$name\"");
diff --git a/source4/selftest/test_binding_string.sh b/source4/selftest/test_binding_string.sh
deleted file mode 100755
index a8afc07ac1..0000000000
--- a/source4/selftest/test_binding_string.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-incdir=`dirname $0`
-. $incdir/test_functions.sh
-
-for I in "ncacn_np:\$SERVER" \
- "ncacn_ip_tcp:\$SERVER" \
- "ncacn_np:\$SERVER[rpcecho]" \
- "ncacn_np:\$SERVER[/pipe/rpcecho]" \
- "ncacn_np:\$SERVER[/pipe/rpcecho,sign,seal]" \
- "ncacn_np:\$SERVER[,sign]" \
- "ncacn_ip_tcp:\$SERVER[,sign]" \
- "ncalrpc:" \
- "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:\$SERVER" \
- "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:\$SERVER"
-do
- plantest "$I" dc bin/smbtorture $TORTURE_OPTIONS "$I" -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" --option=torture:quick=yes RPC-ECHO "$*"
-done
diff --git a/source4/selftest/test_cifs.sh b/source4/selftest/test_cifs.sh
index 76bb4c65e7..f24f8d7398 100755
--- a/source4/selftest/test_cifs.sh
+++ b/source4/selftest/test_cifs.sh
@@ -8,10 +8,10 @@ ADDARGS="$*"
incdir=`dirname $0`
. $incdir/test_functions.sh
-raw=`bin/smbtorture --list | grep "^RAW-" | xargs`
-base=`bin/smbtorture --list | grep "^BASE-" | xargs`
+raw=`$samba4bindir/smbtorture --list | grep "^RAW-" | xargs`
+base=`$samba4bindir/smbtorture --list | grep "^BASE-" | xargs`
tests="$base $raw"
for t in $tests; do
- plantest "ntvfs/cifs $t" dc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" $t
+ plantest "ntvfs/cifs $t" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS $ADDARGS //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" $t
done
diff --git a/source4/selftest/test_echo.sh b/source4/selftest/test_echo.sh
index f09aeca4e5..38bbec4f4e 100755
--- a/source4/selftest/test_echo.sh
+++ b/source4/selftest/test_echo.sh
@@ -10,7 +10,7 @@ for transport in $transports; do
for ntlmoptions in \
"--option=socket:testnonblock=True --option=torture:quick=yes"; do
name="RPC-ECHO on $transport with $bindoptions and $ntlmoptions"
- plantest "$name" dc bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" RPC-ECHO "$*"
+ plantest "$name" dc $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" RPC-ECHO "$*"
done
done
done
@@ -29,10 +29,10 @@ for transport in $transports; do
"--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
; do
name="RPC-ECHO on $transport with $bindoptions and $ntlmoptions"
- plantest "$name" dc bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*"
+ plantest "$name" dc $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*"
done
done
done
name="RPC-ECHO on ncacn_np over smb2"
-plantest "$name" dc bin/smbtorture $TORTURE_OPTIONS ncacn_np:"\$SERVER[smb2]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*"
+plantest "$name" dc $samba4bindir/smbtorture $TORTURE_OPTIONS ncacn_np:"\$SERVER[smb2]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*"
diff --git a/source4/selftest/test_ejs.sh b/source4/selftest/test_ejs.sh
index c81a2afefb..86ea6cd8c9 100755
--- a/source4/selftest/test_ejs.sh
+++ b/source4/selftest/test_ejs.sh
@@ -6,11 +6,8 @@ CONFIGURATION="$*"
incdir=`dirname $0`
. $incdir/test_functions.sh
-SCRIPTDIR=../testprogs/ejs
-DATADIR=../testdata
-
-PATH=bin:$PATH
-export PATH
+SCRIPTDIR=$samba4srcdir/../testprogs/ejs
+DATADIR=$samba4srcdir/../testdata
plantest "base.js" dc "$SCRIPTDIR/base.js" $CONFIGURATION
plantest "samr.js" dc "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U\$USERNAME%\$PASSWORD
@@ -18,4 +15,4 @@ plantest "echo.js" dc "$SCRIPTDIR/echo.js" $CONFIGURATION ncalrpc: -U\$USERNAME%
#plantest "ejsnet.js" dc "$SCRIPTDIR/ejsnet.js" $CONFIGURATION -U\$USERNAME%\$PASSWORD \$DOMAIN ejstestuser
plantest "ldb.js" none "$SCRIPTDIR/ldb.js" `pwd` $CONFIGURATION
plantest "samba3sam.js" none $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/
-plantest "winreg" dc scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U\$USERNAME%\$PASSWORD
+plantest "winreg" dc $samba4srcdir/scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U\$USERNAME%\$PASSWORD
diff --git a/source4/selftest/test_functions.sh b/source4/selftest/test_functions.sh
index 6a7f8aba98..1983760c64 100755
--- a/source4/selftest/test_functions.sh
+++ b/source4/selftest/test_functions.sh
@@ -10,3 +10,6 @@ plantest() {
echo $env
echo $cmdline
}
+
+samba4srcdir=$incdir/..
+samba4bindir=$samba4srcdir/bin
diff --git a/source4/selftest/test_ldap.sh b/source4/selftest/test_ldap.sh
index 627eb905fb..85c3f95915 100755
--- a/source4/selftest/test_ldap.sh
+++ b/source4/selftest/test_ldap.sh
@@ -4,30 +4,28 @@
incdir=`dirname $0`
. $incdir/test_functions.sh
-p=ldap
for options in "" "--option=socket:testnonblock=true" "-U\$USERNAME%\$PASSWORD --option=socket:testnonblock=true" "-U\$USERNAME%\$PASSWORD"; do
- plantest "TESTING PROTOCOL $p with options $options" dc ../testprogs/blackbox/test_ldb.sh $p \$SERVER_IP $options
+ plantest "TESTING PROTOCOL ldap with options $options" dc $samba4srcdir/../testprogs/blackbox/test_ldb.sh ldap \$SERVER_IP $options
done
# see if we support ldaps
if grep ENABLE_GNUTLS.1 include/config.h > /dev/null; then
- p=ldaps
for options in "" "-U\$USERNAME%\$PASSWORD"; do
- plantest "TESTING PROTOCOL $p with options $options" dc ../testprogs/blackbox/test_ldb.sh $p \$SERVER_IP $options
+ plantest "TESTING PROTOCOL ldaps with options $options" dc $samba4srcdir/../testprogs/blackbox/test_ldb.sh ldaps \$SERVER_IP $options
done
fi
for t in LDAP-CLDAP LDAP-BASIC LDAP-SCHEMA LDAP-UPTODATEVECTOR
do
- plantest "$t" dc bin/smbtorture $TORTURE_OPTIONS "-U\$USERNAME%\$PASSWORD" //\$SERVER_IP/_none_ $t
+ plantest "$t" dc $samba4bindir/smbtorture $TORTURE_OPTIONS "-U\$USERNAME%\$PASSWORD" //\$SERVER_IP/_none_ $t
done
# only do the ldb tests when not in quick mode - they are quite slow, and ldb
# is now pretty well tested by the rest of the quick tests anyway
test "$TORTURE_QUICK" = "yes" || {
- LDBDIR=lib/ldb
+ LDBDIR=$samba4srcdir/lib/ldb
export LDBDIR
plantest "ldb" none $LDBDIR/tests/test-tdb.sh
}
-SCRIPTDIR=../testprogs/ejs
+SCRIPTDIR=$samba4srcdir/../testprogs/ejs
plantest "ejs ldap" dc $SCRIPTDIR/ldap.js $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD
diff --git a/source4/selftest/test_local.sh b/source4/selftest/test_local.sh
index b3b8387f00..5f53b4efed 100755
--- a/source4/selftest/test_local.sh
+++ b/source4/selftest/test_local.sh
@@ -1,12 +1,10 @@
#!/bin/sh
-local_tests=`bin/smbtorture --list | grep "^LOCAL-" | xargs`
-
incdir=`dirname $0`
. $incdir/test_functions.sh
-for t in $local_tests; do
- plantest "$t" none $VALGRIND bin/smbtorture $TORTURE_OPTIONS ncalrpc: $t "$*"
+for t in `$samba4bindir/smbtorture --list | grep "^LOCAL-" | xargs`; do
+ plantest "$t" none $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS ncalrpc: $t "$*"
done
-plantest "tdb stress" none $VALGRIND bin/tdbtorture
+plantest "tdb stress" none $VALGRIND $samba4bindir/tdbtorture
diff --git a/source4/selftest/test_member.sh b/source4/selftest/test_member.sh
index 88b382fbeb..0fdc957d53 100755
--- a/source4/selftest/test_member.sh
+++ b/source4/selftest/test_member.sh
@@ -3,6 +3,9 @@
incdir=`dirname $0`
. $incdir/test_functions.sh
-plantest "RPC-ECHO against member server with local creds" member $VALGRIND bin/smbtorture $TORTURE_OPTIONS ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" RPC-ECHO "$*"
-plantest "RPC-ECHO against member server with domain creds" member $VALGRIND bin/smbtorture $TORTURE_OPTIONS ncacn_np:"\$NETBIOSNAME" -U"\$DOMAIN/\$DC_USERNAME"%"\$DC_PASSWORD" RPC-ECHO "$*"
-plantest "wbinfo -a against member server with domain creds" member $VALGRIND bin/wbinfo -a "\$DOMAIN/\$DC_USERNAME"%"\$DC_PASSWORD"
+plantest "RPC-ECHO against member server with local creds" member $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" RPC-ECHO "$*"
+plantest "RPC-ECHO against member server with domain creds" member $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS ncacn_np:"\$NETBIOSNAME" -U"\$DOMAIN/\$DC_USERNAME"%"\$DC_PASSWORD" RPC-ECHO "$*"
+plantest "RPC-SAMR against member server with local creds" member $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR" "$*"
+plantest "RPC-SAMR-USERS against member server with local creds" member $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR-USERS" "$*"
+plantest "RPC-SAMR-PASSWORDS against member server with local creds" member $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS 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"
diff --git a/source4/selftest/test_nbt.sh b/source4/selftest/test_nbt.sh
index 1ff5ee641d..22062d5d44 100755
--- a/source4/selftest/test_nbt.sh
+++ b/source4/selftest/test_nbt.sh
@@ -4,18 +4,15 @@
incdir=`dirname $0`
. $incdir/test_functions.sh
-PATH=bin:$PATH
-export PATH
-
TEST_NBT_ENVNAME=$1
if test x"$TEST_NBT_ENVNAME" = x"";then
TEST_NBT_ENVNAME="dc"
fi
-NBT_TESTS=`bin/smbtorture --list | grep "^NBT-" | xargs`
+NBT_TESTS=`$samba4bindir/smbtorture --list | grep "^NBT-" | xargs`
if test x"$TEST_NBT_ENVNAME" = x"dc";then
for f in $NBT_TESTS; do
- plantest "$f:$TEST_NBT_ENVNAME" $TEST_NBT_ENVNAME bin/smbtorture $TORTURE_OPTIONS //\$SERVER/_none_ $f -U\$USERNAME%\$PASSWORD
+ plantest "$f:$TEST_NBT_ENVNAME" $TEST_NBT_ENVNAME $samba4bindir/smbtorture $TORTURE_OPTIONS //\$SERVER/_none_ $f -U\$USERNAME%\$PASSWORD
done
fi
diff --git a/source4/selftest/test_net.sh b/source4/selftest/test_net.sh
index c99fee4f46..1721c31b02 100755
--- a/source4/selftest/test_net.sh
+++ b/source4/selftest/test_net.sh
@@ -2,23 +2,11 @@
# add tests to this list as they start passing, so we test
# that they stay passing
-ncacn_np_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC NET-API-RPCCONN-BIND NET-API-RPCCONN-SRV NET-API-RPCCONN-PDC NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES NET-API-CREATEUSER NET-API-DELETEUSER NET-API-DOMLIST"
-ncalrpc_tests="NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES NET-API-CREATEUSER NET-API-DELETEUSER NET-USERINFO NET-USERADD NET-USERDEL NET-USERMOD NET-API-LOOKUPNAME NET-API-USERINFO NET-API-USERLIST NET-API-DOMOPENLSA NET-API-DOMCLOSELSA NET-API-DOMOPENSAMR NET-API-DOMCLOSESAMR NET-API-DOMLIST"
-ncacn_ip_tcp_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES NET-API-CREATEUSER NET-API-DELETEUSER NET-API-MODIFYUSER NET-API-DOMLIST"
-
incdir=`dirname $0`
. $incdir/test_functions.sh
-for bindoptions in seal,padcheck $VALIDATE bigendian; do
- for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
- case $transport in
- ncalrpc) tests=$ncalrpc_tests ;;
- ncacn_np) tests=$ncacn_np_tests ;;
- ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
- esac
- for t in $tests; do
- name="$t on $transport with $bindoptions"
- plantest "$name" dc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" $t "$*"
- done
- done
+tests=`$samba4bindir/smbtorture --list | grep ^NET-`
+
+for t in $tests; do
+ plantest "$t" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS "\$SERVER[$VALIDATE]" -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" $t "$*"
done
diff --git a/source4/selftest/test_nss.sh b/source4/selftest/test_nss.sh
index f493cbe208..689d1038f1 100755
--- a/source4/selftest/test_nss.sh
+++ b/source4/selftest/test_nss.sh
@@ -3,9 +3,9 @@
incdir=`dirname $0`
. $incdir/test_functions.sh
-if [ ! -f bin/nsstest ]; then
+if [ ! -f $samba4bindir/nsstest ]; then
exit 0
fi
-plantest "NSS-TEST using winbind" member $VALGRIND bin/nsstest bin/shared/libnss_winbind.so
+plantest "NSS-TEST using winbind" member $VALGRIND $samba4bindir/nsstest $samba4bindir/shared/libnss_winbind.so
diff --git a/source4/selftest/test_pidl.sh b/source4/selftest/test_pidl.sh
index 6a20cd9fc8..1c68acf053 100755
--- a/source4/selftest/test_pidl.sh
+++ b/source4/selftest/test_pidl.sh
@@ -10,8 +10,8 @@ incdir=`dirname $0`
if test x"${PIDL_TESTS_SKIP}" = x"yes"; then
echo "Skipping pidl tests - PIDL_TESTS_SKIP=yes"
elif $PERL -e 'eval require Test::More;' > /dev/null 2>&1; then
- for f in pidl/tests/*.pl; do
- plantest "$f" none $PERL $f "|" ./script/harness2subunit.pl
+ for f in $samba4srcdir/pidl/tests/*.pl; do
+ plantest "pidl/`basename $f`" none $PERL $f "|" $samba4srcdir/script/harness2subunit.pl
done
else
echo "Skipping pidl tests - Test::More not installed"
diff --git a/source4/selftest/test_posix.sh b/source4/selftest/test_posix.sh
index 8a547b906e..383766cdf3 100755
--- a/source4/selftest/test_posix.sh
+++ b/source4/selftest/test_posix.sh
@@ -8,11 +8,11 @@ ADDARGS="$*"
incdir=`dirname $0`
. $incdir/test_functions.sh
-smb2=`bin/smbtorture --list | grep "^SMB2-" | xargs`
-raw=`bin/smbtorture --list | grep "^RAW-" | xargs`
-base=`bin/smbtorture --list | grep "^BASE-" | xargs`
+smb2=`$samba4bindir/smbtorture --list | grep "^SMB2-" | xargs`
+raw=`$samba4bindir/smbtorture --list | grep "^RAW-" | xargs`
+base=`$samba4bindir/smbtorture --list | grep "^BASE-" | xargs`
tests="$base $raw $smb2"
for t in $tests; do
- plantest "$t" dc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" $t
+ plantest "$t" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" $t
done
diff --git a/source4/selftest/test_quick.sh b/source4/selftest/test_quick.sh
deleted file mode 100755
index 438c04e444..0000000000
--- a/source4/selftest/test_quick.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-# run a quick set of filesystem tests
-
-ADDARGS="$*"
-
-incdir=`dirname $0`
-. $incdir/test_functions.sh
-
-tests="BASE-UNLINK BASE-ATTR BASE-DELETE"
-tests="$tests BASE-TCON BASE-OPEN"
-tests="$tests BASE-CHKPATH RAW-QFSINFO RAW-QFILEINFO RAW-SFILEINFO"
-tests="$tests RAW-MKDIR RAW-SEEK RAW-OPEN RAW-WRITE"
-tests="$tests RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-RENAME"
-tests="$tests RAW-EAS RAW-STREAMS"
-
-for t in $tests; do
- plantest "$t" dc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" $t
-done
-
-name=BASE-OPEN
-plantest "ntvfs/cifs $name" dc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" $name
diff --git a/source4/selftest/test_rpc.sh b/source4/selftest/test_rpc.sh
index adcab0af39..3ac4e3de66 100755
--- a/source4/selftest/test_rpc.sh
+++ b/source4/selftest/test_rpc.sh
@@ -2,16 +2,28 @@
# add tests to this list as they start passing, so we test
# that they stay passing
-ncacn_np_tests="RPC-SPOOLSS RPC-SRVSVC RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-MGMT RPC-HANDLES RPC-WINREG RPC-WKSSVC RPC-SVCCTL RPC-EPMAPPER RPC-INITSHUTDOWN RPC-EVENTLOG RPC-ATSVC RPC-SAMSYNC RPC-OXIDRESOLVE RPC-DFS"
-ncalrpc_tests="RPC-MGMT RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-WINREG RPC-WKSSVC RPC-SVCCTL RPC-EPMAPPER RPC-EVENTLOG RPC-ATSVC RPC-INITSHUTDOWN RPC-OXIDRESOLVE RPC-DFS"
-ncacn_ip_tcp_tests="RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-MGMT RPC-HANDLES RPC-WINREG RPC-WKSSVC RPC-SVCCTL RPC-EPMAPPER RPC-ATSVC RPC-EVENTLOG RPC-DSSYNC RPC-OXIDRESOLVE RPC-DFS"
-slow_ncacn_np_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS RPC-COUNTCALLS"
-slow_ncalrpc_tests="RPC-SAMR RPC-SAMR-PASSWORDS RPC-COUNTCALLS RPC-CRACKNAMES"
-slow_ncacn_ip_tcp_tests="RPC-SAMR RPC-SAMR-PASSWORDS RPC-COUNTCALLS RPC-CRACKNAMES"
+ncacn_np_tests="RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-HANDLES RPC-SAMSYNC RPC-SAMBA3SESSIONKEY RPC-SAMBA3-GETUSERNAME RPC-SAMBA3-LSA RPC-BINDSAMBA3 RPC-NETLOGSAMBA3 RPC-ASYNCBIND RPC-LSALOOKUP RPC-LSA-GETUSER RPC-SCHANNEL2 RPC-AUTHCONTEXT"
+ncalrpc_tests="RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-DRSUAPI RPC-ASYNCBIND RPC-LSALOOKUP RPC-LSA-GETUSER RPC-SCHANNEL2 RPC-AUTHCONTEXT"
+ncacn_ip_tcp_tests="RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-HANDLES RPC-DSSYNC RPC-ASYNCBIND RPC-LSALOOKUP RPC-LSA-GETUSER RPC-SCHANNEL2 RPC-AUTHCONTEXT"
+slow_ncacn_np_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
+slow_ncalrpc_tests="RPC-SAMR RPC-SAMR-PASSWORDS"
+slow_ncacn_ip_tcp_tests="RPC-SAMR RPC-SAMR-PASSWORDS RPC-CRACKNAMES"
incdir=`dirname $0`
. $incdir/test_functions.sh
+all_tests="$ncalrpc_tests $ncacn_np_tests $ncacn_ip_tcp_tests $slow_ncalrpc_tests $slow_ncacn_np_tests $slow_ncacn_ip_tcp_tests RPC-SECRETS RPC-SAMBA3-SHARESEC"
+
+# Make sure all tests get run
+for t in `$samba4bindir/smbtorture --list | grep "^RPC-"`
+do
+ echo $all_tests | grep $t > /dev/null
+ if [ $? -ne 0 ]
+ then
+ auto_rpc_tests="$auto_rpc_tests $t"
+ fi
+done
+
for bindoptions in seal,padcheck $VALIDATE bigendian; do
for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
case $transport in
@@ -21,8 +33,15 @@ for bindoptions in seal,padcheck $VALIDATE bigendian; do
esac
for t in $tests; do
name="$t on $transport with $bindoptions"
- plantest "$name" dc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
+ plantest "$name" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
done
+ plantest "RPC-SAMBA3-SHARESEC on $transport with $bindoptions" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=torture:share=tmp $t "$*"
+ done
+done
+
+for bindoptions in "" $VALIDATE bigendian; do
+ for t in $auto_rpc_tests; do
+ plantest "$t with $bindoptions" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS "\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
done
done
@@ -35,7 +54,8 @@ for bindoptions in connect $VALIDATE ; do
esac
for t in $tests; do
name="$t on $transport with $bindoptions"
- plantest "$name" dc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
+ plantest "$name" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
done
done
done
+
diff --git a/source4/selftest/test_rpc_quick.sh b/source4/selftest/test_rpc_quick.sh
deleted file mode 100755
index 8793e0b6e6..0000000000
--- a/source4/selftest/test_rpc_quick.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-# add tests to this list as they start passing, so we test
-# that they stay passing
-ncacn_np_tests="RPC-ALTERCONTEXT RPC-JOIN RPC-ECHO RPC-SCHANNEL RPC-NETLOGON RPC-UNIXINFO RPC-HANDLES"
-ncacn_ip_tcp_tests="RPC-ALTERCONTEXT RPC-JOIN RPC-ECHO RPC-HANDLES"
-ncalrpc_tests="RPC-ECHO"
-
-incdir=`dirname $0`
-. $incdir/test_functions.sh
-
-for bindoptions in seal,padcheck $VALIDATE bigendian; do
- for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
- case $transport in
- ncalrpc) tests=$ncalrpc_tests ;;
- ncacn_np) tests=$ncacn_np_tests ;;
- ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
- esac
- for t in $tests; do
- name="$t on $transport with $bindoptions"
- plantest "$name" dc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
- done
- done
-done
diff --git a/source4/selftest/test_s3upgrade.sh b/source4/selftest/test_s3upgrade.sh
index 1ed43cb8eb..692199acda 100755
--- a/source4/selftest/test_s3upgrade.sh
+++ b/source4/selftest/test_s3upgrade.sh
@@ -7,16 +7,14 @@ then
exit 1
fi
-SCRIPTDIR=../testprogs/ejs
-DATADIR=../testdata
-
-PATH=bin:$PATH
-export PATH
-
mkdir -p $PREFIX
rm -f $PREFIX/*
-. selftest/test_functions.sh
+incdir=`dirname $0`
+. $incdir/test_functions.sh
+
+SCRIPTDIR=$samba4srcdir/../testprogs/ejs
+DATADIR=$samba4srcdir/../testdata
-plantest "parse samba3" none bin/smbscript ../testdata/samba3/verify $CONFIGURATION ../testdata/samba3
-#plantest "upgrade" none bin/smbscript setup/upgrade $CONFIGURATION --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf
+plantest "parse samba3" none $samba4bindir/smbscript $DATADIR/samba3/verify $CONFIGURATION $DATADIR/samba3
+#plantest "upgrade" none $samba4bindir/smbscript setup/upgrade $CONFIGURATION --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf
diff --git a/source4/selftest/test_session_key.sh b/source4/selftest/test_session_key.sh
index 30d03431ba..93be4f99f2 100755
--- a/source4/selftest/test_session_key.sh
+++ b/source4/selftest/test_session_key.sh
@@ -4,11 +4,7 @@ incdir=`dirname $0`
. $incdir/test_functions.sh
transport="ncacn_np"
-for bindoptions in bigendian seal; do
- for keyexchange in "yes" "no"; do
- for ntlm2 in "yes" "no"; do
- for lm_key in "yes" "no"; do
- for ntlmoptions in \
+for ntlmoptions in \
"-k no --option=usespnego=yes" \
"-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no" \
"-k no --option=usespnego=yes --option=ntlmssp_client:56bit=yes" \
@@ -21,18 +17,14 @@ for bindoptions in bigendian seal; do
"-k no --option=usespnego=no --option=clientntlmv2auth=yes" \
"-k no --option=gensec:spnego=no --option=clientntlmv2auth=yes" \
"-k no --option=usespnego=no"; do
- name="RPC-SECRETS on $transport with $bindoptions with NTLM2:$ntlm2 KEYEX:$keyexchange LM_KEY:$lm_key $ntlmoptions"
- plantest "$name" dc bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" --option=ntlmssp_client:keyexchange=$keyexchange --option=ntlmssp_client:ntlm2=$ntlm2 --option=ntlmssp_client:lm_key=$lm_key $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=gensec:target_hostname=\$NETBIOSNAME RPC-SECRETS "$*"
- done
- done
- done
- done
- name="RPC-SECRETS on $transport with $bindoptions with Kerberos"
- plantest "$name" dc bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -k yes -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
- name="RPC-SECRETS on $transport with $bindoptions with Kerberos - use target principal"
- plantest "$name" dc bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -k yes -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN "--option=clientusespnegoprincipal=yes" "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
+ name="RPC-SECRETS on $transport with $bindoptions with $ntlmoptions"
+ plantest "$name" dc $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=gensec:target_hostname=\$NETBIOSNAME RPC-SECRETS "$*"
done
+name="RPC-SECRETS on $transport with $bindoptions with Kerberos"
+plantest "$name" dc $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -k yes -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
+name="RPC-SECRETS on $transport with $bindoptions with Kerberos - use target principal"
+plantest "$name" dc $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -k yes -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN "--option=clientusespnegoprincipal=yes" "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
name="RPC-SECRETS on $transport with Kerberos - use Samba3 style login"
- plantest "$name" dc bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER" -k yes -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
+ plantest "$name" dc $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER" -k yes -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=\$NETBIOSNAME" "RPC-SECRETS-none*" "$*"
name="RPC-SECRETS on $transport with Kerberos - use Samba3 style login, use target principal"
- plantest "$name" dc bin/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER" -k yes -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "--option=clientusespnegoprincipal=yes" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
+ plantest "$name" dc $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER" -k yes -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "--option=clientusespnegoprincipal=yes" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=\$NETBIOSNAME" "RPC-SECRETS-none*" "$*"
diff --git a/source4/selftest/test_simple.sh b/source4/selftest/test_simple.sh
index 00cfb34a9f..3532cba180 100755
--- a/source4/selftest/test_simple.sh
+++ b/source4/selftest/test_simple.sh
@@ -9,5 +9,5 @@ incdir=`dirname $0`
tests="BASE-RW1"
for t in $tests; do
- plantest "$t" dc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS //\$SERVER/simple -U"\$USERNAME"%"\$PASSWORD" $t
+ plantest "ntvfs/simple $t" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS $ADDARGS //\$SERVER/simple -U"\$USERNAME"%"\$PASSWORD" $t
done
diff --git a/source4/selftest/test_winbind.sh b/source4/selftest/test_winbind.sh
new file mode 100755
index 0000000000..832d12c411
--- /dev/null
+++ b/source4/selftest/test_winbind.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+
+incdir=`dirname $0`
+. $incdir/test_functions.sh
+
+ENVNAME=$1
+if test x"$ENVNAME" = x"";then
+ ENVNAME="dc"
+fi
+
+WB_OPTS="${TORTURE_OPTIONS}"
+WB_OPTS="${WB_OPTS} --option=\"torture:strict mode=yes\""
+WB_OPTS="${WB_OPTS} --option=\"torture:timelimit=1\""
+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\""
+
+STRUCT_TESTS=`$samba4bindir/smbtorture --list | grep "^WINBIND-STRUCT" | xargs`
+for t in $STRUCT_TESTS; do
+ plantest "$ENVNAME:$t" $ENVNAME $samba4bindir/smbtorture $WB_OPTS //_none_/_none_ $t
+done
+
+NDR_TESTS=`$samba4bindir/smbtorture --list | grep "^WINBIND-NDR" | xargs`
+for t in $NDR_TESTS; do
+ plantest "$ENVNAME:$t" $ENVNAME $samba4bindir/smbtorture $WB_OPTS //_none_/_none_ $t
+done
diff --git a/source4/selftest/tests_all.sh b/source4/selftest/tests_all.sh
index 7a1167e9ac..0db8504848 100755
--- a/source4/selftest/tests_all.sh
+++ b/source4/selftest/tests_all.sh
@@ -1,18 +1,21 @@
#!/bin/sh
- $SRCDIR/selftest/test_ejs.sh $CONFIGURATION
- $SRCDIR/selftest/test_ldap.sh
- $SRCDIR/selftest/test_nbt.sh "dc"
- $SRCDIR/selftest/test_rpc.sh
- $SRCDIR/selftest/test_net.sh
- $SRCDIR/selftest/test_session_key.sh
- $SRCDIR/selftest/test_binding_string.sh
- $SRCDIR/selftest/test_echo.sh
- $SRCDIR/selftest/test_posix.sh
- $SRCDIR/selftest/test_cifs.sh
- $SRCDIR/selftest/test_local.sh
- $SRCDIR/selftest/test_pidl.sh
- $SRCDIR/selftest/test_blackbox.sh $PREFIX
- $SRCDIR/selftest/test_simple.sh
- $SRCDIR/selftest/test_s3upgrade.sh $PREFIX/upgrade
- $SRCDIR/selftest/test_member.sh
- $SRCDIR/selftest/test_nbt.sh "member"
+includedir=`dirname $0`
+$includedir/../bin/smbtorture -V
+$SRCDIR/selftest/test_ejs.sh $CONFIGURATION
+$SRCDIR/selftest/test_ldap.sh
+$SRCDIR/selftest/test_nbt.sh "dc"
+$SRCDIR/selftest/test_winbind.sh "dc"
+$SRCDIR/selftest/test_rpc.sh
+$SRCDIR/selftest/test_net.sh
+$SRCDIR/selftest/test_session_key.sh
+$SRCDIR/selftest/test_echo.sh
+$SRCDIR/selftest/test_posix.sh
+$SRCDIR/selftest/test_cifs.sh
+$SRCDIR/selftest/test_local.sh
+$SRCDIR/selftest/test_pidl.sh
+$SRCDIR/selftest/test_blackbox.sh $PREFIX
+$SRCDIR/selftest/test_simple.sh
+$SRCDIR/selftest/test_s3upgrade.sh $PREFIX/upgrade
+$SRCDIR/selftest/test_member.sh
+$SRCDIR/selftest/test_nbt.sh "member"
+$SRCDIR/selftest/test_winbind.sh "member"
diff --git a/source4/selftest/tests_quick.sh b/source4/selftest/tests_quick.sh
index bb3065b0a3..c05185afad 100755
--- a/source4/selftest/tests_quick.sh
+++ b/source4/selftest/tests_quick.sh
@@ -1,9 +1,47 @@
#!/bin/sh
+ADDARGS="$*"
+
+incdir=`dirname $0`
+. $incdir/test_functions.sh
+
+$incdir/../bin/smbtorture -V
+
TORTURE_QUICK="yes"
export TORTURE_QUICK
$SRCDIR/selftest/test_ejs.sh $CONFIGURATION
$SRCDIR/selftest/test_ldap.sh
$SRCDIR/selftest/test_nbt.sh
-$SRCDIR/selftest/test_quick.sh
-$SRCDIR/selftest/test_rpc_quick.sh
+
+tests="BASE-UNLINK BASE-ATTR BASE-DELETE"
+tests="$tests BASE-TCON BASE-OPEN"
+tests="$tests BASE-CHKPATH RAW-QFSINFO RAW-QFILEINFO RAW-SFILEINFO"
+tests="$tests RAW-MKDIR RAW-SEEK RAW-OPEN RAW-WRITE"
+tests="$tests RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-RENAME"
+tests="$tests RAW-EAS RAW-STREAMS"
+
+for t in $tests; do
+ plantest "$t" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" $t
+done
+
+plantest "ntvfs/cifs BASE-OPEN" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS $ADDARGS //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" BASE-OPEN
+
+# add tests to this list as they start passing, so we test
+# that they stay passing
+ncacn_np_tests="RPC-ALTERCONTEXT RPC-JOIN RPC-ECHO RPC-SCHANNEL RPC-NETLOGON RPC-UNIXINFO RPC-HANDLES"
+ncacn_ip_tcp_tests="RPC-ALTERCONTEXT RPC-JOIN RPC-ECHO RPC-HANDLES"
+ncalrpc_tests="RPC-ECHO"
+
+for bindoptions in seal,padcheck $VALIDATE bigendian; do
+ for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
+ case $transport in
+ ncalrpc) tests=$ncalrpc_tests ;;
+ ncacn_np) tests=$ncacn_np_tests ;;
+ ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
+ esac
+ for t in $tests; do
+ name="$t on $transport with $bindoptions"
+ plantest "$name" dc $VALGRIND $samba4bindir/smbtorture $TORTURE_OPTIONS $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
+ done
+ done
+done
diff --git a/source4/setup/named.conf b/source4/setup/named.conf
index 17beb7a2d7..025788093e 100644
--- a/source4/setup/named.conf
+++ b/source4/setup/named.conf
@@ -3,11 +3,12 @@
# the BIND nameserver.
#
-#insert this into options {}
+# 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}";
-#the zone file
+# You should always include the actual zone configuration reference:
zone "${DNSDOMAIN}." IN {
type master;
file "${DNSDOMAIN}.zone";
@@ -29,7 +30,7 @@ zone "${DNSDOMAIN}." IN {
# 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 thge daemon to read it. In the FC6
+# permissions altered to allow the daemon to read it. In the FC6
# example, execute the commands:
#
# chgrp named ${DNS_KEYTAB_ABS}
diff --git a/source4/setup/provision b/source4/setup/provision
index f6b9cde188..bf03026987 100755
--- a/source4/setup/provision
+++ b/source4/setup/provision
@@ -14,7 +14,6 @@ options = GetOptions(ARGV,
'realm=s',
'domain=s',
'domain-guid=s',
- 'domain-guid=s',
'domain-sid=s',
'policy-guid=s',
'host-name=s',
@@ -32,6 +31,7 @@ options = GetOptions(ARGV,
'users=s',
'quiet',
'blank',
+ 'server-role=s',
'partitions-only',
'ldap-base',
'ldap-backend=s',
@@ -84,11 +84,12 @@ provision [options]
--users GROUPNAME choose 'users' group
--quiet Be quiet
--blank do not add users or groups, just the structure
+ --server-role ROLE Set server role to provision for (default standalone)
--partitions-only Configure Samba's partitions, but do not modify them (ie, join a BDC)
--ldap-base output only an LDIF file, suitable for creating an LDAP baseDN
--ldap-backend LDAPSERVER LDAP server to use for this provision
- --ldap-module= MODULE LDB mapping module to use for the LDAP backend
- --aci= ACI An arbitary LDIF fragment, particularly useful to loading a backend ACI value into a target LDAP server
+ --ldap-module MODULE LDB mapping module to use for the LDAP backend
+ --aci ACI An arbitary LDIF fragment, particularly useful to loading a backend ACI value into a target LDAP server
You must provide at least a realm and domain
");
@@ -112,6 +113,7 @@ if (options["realm"] == undefined ||
var lp = loadparm_init();
lp.set("realm", options.realm);
lp.set("workgroup", options.domain);
+lp.set("server role", options["server-role"]);
lp.reload();
var subobj = provision_guess();
@@ -166,6 +168,30 @@ if (ldapbase) {
} else {
provision(subobj, message, blank, paths, system_session, creds, ldapbackend);
provision_dns(subobj, message, paths, system_session, creds);
+ message("To reproduce this provision, run with:\n");
+/* There has to be a better way than this... */
+ message("--realm='%s' --domain='%s' \\\n", subobj.REALM_CONF, subobj.DOMAIN_CONF);
+ if (subobj.DOMAINGUID != undefined) {
+ message("--domain-guid='%s' \\\n", subobj.DOMAINGUID);
+ }
+ if (subobj.HOSTGUID != undefined) {
+ message("--host-guid='%s' \\\n", subobj.HOSTGUID);
+ }
+ message("--policy-guid='%s' --host-name='%s' --host-ip='%s' \\\n", subobj.POLICYGUID, subobj.HOSTNAME, subobj.HOSTIP);
+ message("--invocationid='%s' \\\n", subobj.INVOCATIONID);
+ message("--adminpass='%s' --krbtgtpass='%s' \\\n", subobj.ADMINPASS, subobj.KRBTGTPASS);
+ message("--machinepass='%s' --dnspass='%s' \\\n", subobj.MACHINEPASS, subobj.DNSPASS);
+ message("--root='%s' --nobody='%s' --nogroup-'%s' \\\n", subobj.ROOT, subobj.NOBODY, subobj.NOGROUP);
+ message("--wheel='%s' --users='%s' --server-role='%s' \\\n", subobj.WHEEL, subobj.USERS, subobj.SERVERROLE);
+ if (ldapbackend) {
+ message("--ldap-backend='%s' \\\n", subobj.LDAPBACKEND);
+ }
+ if (ldapmodule) {
+ message("--ldap-mdoule='%s' \\\n", + subobj.LDAPMODULE);
+ }
+ message("--aci='" + subobj.ACI + "' \\\n")
}
+
+
message("All OK\n");
return 0;
diff --git a/source4/setup/provision.smb.conf b/source4/setup/provision.smb.conf.dc
index fe08d7e3be..5b8e141cbf 100644
--- a/source4/setup/provision.smb.conf
+++ b/source4/setup/provision.smb.conf.dc
@@ -1,8 +1,8 @@
[globals]
netbios name = ${HOSTNAME}
- workgroup = ${DOMAIN}
- realm = ${REALM}
- server role = domain controller
+ workgroup = ${DOMAIN_CONF}
+ realm = ${REALM_CONF}
+ server role = ${SERVERROLE}
[netlogon]
path = ${NETLOGONPATH}
diff --git a/source4/setup/provision.smb.conf.member b/source4/setup/provision.smb.conf.member
new file mode 100644
index 0000000000..bc37d4f3d3
--- /dev/null
+++ b/source4/setup/provision.smb.conf.member
@@ -0,0 +1,5 @@
+[globals]
+ netbios name = ${HOSTNAME}
+ workgroup = ${DOMAIN_CONF}
+ realm = ${REALM_CONF}
+ server role = ${SERVERROLE}
diff --git a/source4/setup/provision.smb.conf.standalone b/source4/setup/provision.smb.conf.standalone
new file mode 100644
index 0000000000..bc37d4f3d3
--- /dev/null
+++ b/source4/setup/provision.smb.conf.standalone
@@ -0,0 +1,5 @@
+[globals]
+ netbios name = ${HOSTNAME}
+ workgroup = ${DOMAIN_CONF}
+ realm = ${REALM_CONF}
+ server role = ${SERVERROLE}
diff --git a/source4/setup/provision_configuration.ldif b/source4/setup/provision_configuration.ldif
index 0e6ee4d845..050f110d9a 100644
--- a/source4/setup/provision_configuration.ldif
+++ b/source4/setup/provision_configuration.ldif
@@ -66,29 +66,6 @@ instanceType: 4
showInAdvancedViewOnly: TRUE
systemFlags: 2181038080
-dn: CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
-objectClass: top
-objectClass: server
-cn: ${NETBIOSNAME}
-instanceType: 4
-showInAdvancedViewOnly: TRUE
-systemFlags: 1375731712
-dNSHostName: ${DNSNAME}
-serverReference: CN=${NETBIOSNAME},OU=Domain Controllers,${DOMAINDN}
-
-dn: CN=NTDS Settings,CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
-objectClass: top
-objectClass: applicationSettings
-objectClass: nTDSDSA
-cn: NTDS Settings
-options: 1
-instanceType: 4
-showInAdvancedViewOnly: TRUE
-systemFlags: 33554432
-dMDLocation: ${SCHEMADN}
-invocationId: ${INVOCATIONID}
-msDS-Behavior-Version: 2
-
dn: CN=Services,${CONFIGDN}
objectClass: top
objectClass: container
diff --git a/source4/setup/provision_init.ldif b/source4/setup/provision_init.ldif
index 12d71f9080..a69399c3e6 100644
--- a/source4/setup/provision_init.ldif
+++ b/source4/setup/provision_init.ldif
@@ -23,17 +23,6 @@ sAMAccountType: INTEGER
systemFlags: INTEGER
userAccountControl: INTEGER
-dn: @SUBCLASSES
-top: domain
-top: person
-top: group
-domain: domainDNS
-person: organizationalPerson
-organizationalPerson: user
-user: computer
-template: userTemplate
-template: groupTemplate
-
dn: @KLUDGEACL
passwordAttribute: sambaPassword
passwordAttribute: ntPwdHash
diff --git a/source4/setup/provision_partitions.ldif b/source4/setup/provision_partitions.ldif
index c6107c6502..f07ec680e0 100644
--- a/source4/setup/provision_partitions.ldif
+++ b/source4/setup/provision_partitions.ldif
@@ -2,7 +2,6 @@ dn: @PARTITION
partition: ${SCHEMADN}:${SCHEMADN_LDB}
partition: ${CONFIGDN}:${CONFIGDN_LDB}
partition: ${DOMAINDN}:${DOMAINDN_LDB}
-replicateEntries: @SUBCLASSES
replicateEntries: @ATTRIBUTES
replicateEntries: @INDEXLIST
modules:${SCHEMADN}:${SCHEMADN_MOD}${SCHEMADN_MOD2}
diff --git a/source4/setup/provision_self_join.ldif b/source4/setup/provision_self_join.ldif
index ff44a35f6d..8c6959dbaa 100644
--- a/source4/setup/provision_self_join.ldif
+++ b/source4/setup/provision_self_join.ldif
@@ -21,3 +21,44 @@ servicePrincipalName: HOST/${NETBIOSNAME}/${REALM}
servicePrincipalName: HOST/${DNSNAME}/${DOMAIN}
servicePrincipalName: HOST/${NETBIOSNAME}/${DOMAIN}
${HOSTGUID_ADD}
+
+#Provide a account for DNS keytab export
+dn: CN=dns,CN=Users,${DOMAINDN}
+objectClass: top
+objectClass: person
+objectClass: organizationalPerson
+objectClass: user
+cn: dns
+description: DNS Service Account
+showInAdvancedViewOnly: TRUE
+userAccountControl: 514
+accountExpires: 9223372036854775807
+sAMAccountName: dns
+sAMAccountType: 805306368
+servicePrincipalName: DNS/${DNSDOMAIN}
+isCriticalSystemObject: TRUE
+sambaPassword:: ${DNSPASS_B64}
+
+dn: CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+objectClass: top
+objectClass: server
+cn: ${NETBIOSNAME}
+instanceType: 4
+showInAdvancedViewOnly: TRUE
+systemFlags: 1375731712
+dNSHostName: ${DNSNAME}
+serverReference: CN=${NETBIOSNAME},OU=Domain Controllers,${DOMAINDN}
+
+dn: CN=NTDS Settings,CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+objectClass: top
+objectClass: applicationSettings
+objectClass: nTDSDSA
+cn: NTDS Settings
+options: 1
+instanceType: 4
+showInAdvancedViewOnly: TRUE
+systemFlags: 33554432
+dMDLocation: ${SCHEMADN}
+invocationId: ${INVOCATIONID}
+msDS-Behavior-Version: 2
+
diff --git a/source4/setup/provision_users.ldif b/source4/setup/provision_users.ldif
index f6fbb0bd52..030fe5d742 100644
--- a/source4/setup/provision_users.ldif
+++ b/source4/setup/provision_users.ldif
@@ -205,22 +205,6 @@ servicePrincipalName: kadmin/changepw
isCriticalSystemObject: TRUE
sambaPassword:: ${KRBTGTPASS_B64}
-dn: CN=dns,CN=Users,${DOMAINDN}
-objectClass: top
-objectClass: person
-objectClass: organizationalPerson
-objectClass: user
-cn: dns
-description: DNS Service Account
-showInAdvancedViewOnly: TRUE
-userAccountControl: 514
-accountExpires: 9223372036854775807
-sAMAccountName: dns
-sAMAccountType: 805306368
-servicePrincipalName: DNS/${DNSDOMAIN}
-isCriticalSystemObject: TRUE
-sambaPassword:: ${DNSPASS_B64}
-
dn: CN=Domain Computers,CN=Users,${DOMAINDN}
objectClass: top
objectClass: group
diff --git a/source4/setup/secrets.ldif b/source4/setup/secrets.ldif
index 80015b4b41..95cbe20e5f 100644
--- a/source4/setup/secrets.ldif
+++ b/source4/setup/secrets.ldif
@@ -8,47 +8,3 @@ objectClass: top
objectClass: container
cn: Primary Domains
-dn: flatname=${DOMAIN},CN=Primary Domains
-objectClass: top
-objectClass: primaryDomain
-objectClass: kerberosSecret
-flatname: ${DOMAIN}
-realm: ${REALM}
-secret:: ${MACHINEPASS_B64}
-secureChannelType: 6
-sAMAccountName: ${NETBIOSNAME}$
-whenCreated: ${LDAPTIME}
-whenChanged: ${LDAPTIME}
-msDS-KeyVersionNumber: 1
-objectSid: ${DOMAINSID}
-privateKeytab: ${SECRETS_KEYTAB}
-
-# A hook from our credentials system into HDB, as we must be on a KDC,
-# we can look directly into the database.
-dn: samAccountName=krbtgt,flatname=${DOMAIN},CN=Principals
-objectClass: top
-objectClass: secret
-objectClass: kerberosSecret
-flatname: ${DOMAIN}
-realm: ${REALM}
-sAMAccountName: krbtgt
-whenCreated: ${LDAPTIME}
-whenChanged: ${LDAPTIME}
-objectSid: ${DOMAINSID}
-servicePrincipalName: kadmin/changepw
-krb5Keytab: HDB:ldb:${SAM_LDB}:
-#The trailing : here is a HACK, but it matches the Heimdal format.
-
-# A hook from our credentials system into HDB, as we must be on a KDC,
-# we can look directly into the database.
-dn: servicePrincipalName=DNS/${DNSDOMAIN},CN=Principals
-objectClass: top
-objectClass: secret
-objectClass: kerberosSecret
-realm: ${REALM}
-whenCreated: ${LDAPTIME}
-whenChanged: ${LDAPTIME}
-servicePrincipalName: DNS/${DNSDOMAIN}
-privateKeytab: ${DNS_KEYTAB}
-secret:: ${DNSPASS_B64}
-
diff --git a/source4/setup/secrets_dc.ldif b/source4/setup/secrets_dc.ldif
new file mode 100644
index 0000000000..64469352bb
--- /dev/null
+++ b/source4/setup/secrets_dc.ldif
@@ -0,0 +1,44 @@
+dn: flatname=${DOMAIN},CN=Primary Domains
+objectClass: top
+objectClass: primaryDomain
+objectClass: kerberosSecret
+flatname: ${DOMAIN}
+realm: ${REALM}
+secret:: ${MACHINEPASS_B64}
+secureChannelType: 6
+sAMAccountName: ${NETBIOSNAME}$
+whenCreated: ${LDAPTIME}
+whenChanged: ${LDAPTIME}
+msDS-KeyVersionNumber: 1
+objectSid: ${DOMAINSID}
+privateKeytab: ${SECRETS_KEYTAB}
+
+# A hook from our credentials system into HDB, as we must be on a KDC,
+# we can look directly into the database.
+dn: samAccountName=krbtgt,flatname=${DOMAIN},CN=Principals
+objectClass: top
+objectClass: secret
+objectClass: kerberosSecret
+flatname: ${DOMAIN}
+realm: ${REALM}
+sAMAccountName: krbtgt
+whenCreated: ${LDAPTIME}
+whenChanged: ${LDAPTIME}
+objectSid: ${DOMAINSID}
+servicePrincipalName: kadmin/changepw
+krb5Keytab: HDB:ldb:${SAM_LDB}:
+#The trailing : here is a HACK, but it matches the Heimdal format.
+
+# A hook from our credentials system into HDB, as we must be on a KDC,
+# we can look directly into the database.
+dn: servicePrincipalName=DNS/${DNSDOMAIN},CN=Principals
+objectClass: top
+objectClass: secret
+objectClass: kerberosSecret
+realm: ${REALM}
+whenCreated: ${LDAPTIME}
+whenChanged: ${LDAPTIME}
+servicePrincipalName: DNS/${DNSDOMAIN}
+privateKeytab: ${DNS_KEYTAB}
+secret:: ${DNSPASS_B64}
+
diff --git a/source4/setup/slapd.conf b/source4/setup/slapd.conf
index 34896d04b9..15e3610e3a 100644
--- a/source4/setup/slapd.conf
+++ b/source4/setup/slapd.conf
@@ -21,7 +21,7 @@ include ${LDAPDIR}/modules.conf
defaultsearchbase ${DOMAINDN}
-backend bdb
+backend hdb
database bdb
suffix ${SCHEMADN}
directory ${LDAPDIR}/db/schema
@@ -32,7 +32,7 @@ index objectCategory eq
index lDAPDisplayName eq
index subClassOf eq
-database bdb
+database hdb
suffix ${CONFIGDN}
directory ${LDAPDIR}/db/config
index objectClass eq
@@ -45,7 +45,7 @@ index subClassOf eq
index dnsRoot eq
index nETBIOSName eq pres
-database bdb
+database hdb
suffix ${DOMAINDN}
rootdn ${LDAPMANAGERDN}
rootpw ${LDAPMANAGERPASS}
diff --git a/source4/smb_server/smb/negprot.c b/source4/smb_server/smb/negprot.c
index 95411943a1..de70dfe5f6 100644
--- a/source4/smb_server/smb/negprot.c
+++ b/source4/smb_server/smb/negprot.c
@@ -27,6 +27,7 @@
#include "smb_server/service_smb_proto.h"
#include "smbd/service_stream.h"
#include "lib/stream/packet.h"
+#include "param/param.h"
/* initialise the auth_context for this server and return the cryptkey */
@@ -90,7 +91,7 @@ this any more it probably doesn't matter
****************************************************************************/
static void reply_coreplus(struct smbsrv_request *req, uint16_t choice)
{
- uint16_t raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0);
+ uint16_t raw = (lp_readraw(global_loadparm)?1:0) | (lp_writeraw(global_loadparm)?2:0);
smbsrv_setup_reply(req, 13, 0);
@@ -121,13 +122,13 @@ static void reply_coreplus(struct smbsrv_request *req, uint16_t choice)
****************************************************************************/
static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
{
- int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0);
+ int raw = (lp_readraw(global_loadparm)?1:0) | (lp_writeraw(global_loadparm)?2:0);
int secword=0;
time_t t = req->request_time.tv_sec;
- req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords();
+ req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords(global_loadparm);
- if (lp_security() != SEC_SHARE)
+ if (lp_security(global_loadparm) != SEC_SHARE)
secword |= NEGOTIATE_SECURITY_USER_LEVEL;
if (req->smb_conn->negotiate.encrypted_passwords)
@@ -144,7 +145,7 @@ static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
SSVAL(req->out.vwv, VWV(0), choice);
SSVAL(req->out.vwv, VWV(1), secword);
SSVAL(req->out.vwv, VWV(2), req->smb_conn->negotiate.max_recv);
- SSVAL(req->out.vwv, VWV(3), lp_maxmux());
+ SSVAL(req->out.vwv, VWV(3), lp_maxmux(global_loadparm));
SSVAL(req->out.vwv, VWV(4), 1);
SSVAL(req->out.vwv, VWV(5), raw);
SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id);
@@ -179,13 +180,13 @@ static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
****************************************************************************/
static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
{
- int raw = (lp_readraw()?1:0) | (lp_writeraw()?2:0);
+ int raw = (lp_readraw(global_loadparm)?1:0) | (lp_writeraw(global_loadparm)?2:0);
int secword=0;
time_t t = req->request_time.tv_sec;
- req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords();
+ req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords(global_loadparm);
- if (lp_security() != SEC_SHARE)
+ if (lp_security(global_loadparm) != SEC_SHARE)
secword |= NEGOTIATE_SECURITY_USER_LEVEL;
if (req->smb_conn->negotiate.encrypted_passwords)
@@ -198,7 +199,7 @@ static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
SSVAL(req->out.vwv, VWV(0), choice);
SSVAL(req->out.vwv, VWV(1), secword);
SSVAL(req->out.vwv, VWV(2), req->smb_conn->negotiate.max_recv);
- SSVAL(req->out.vwv, VWV(3), lp_maxmux());
+ SSVAL(req->out.vwv, VWV(3), lp_maxmux(global_loadparm));
SSVAL(req->out.vwv, VWV(4), 1);
SSVAL(req->out.vwv, VWV(5), raw);
SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id);
@@ -213,7 +214,7 @@ static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
get_challenge(req->smb_conn, req->out.data);
}
- req_push_str(req, NULL, lp_workgroup(), -1, STR_TERMINATE);
+ req_push_str(req, NULL, lp_workgroup(global_loadparm), -1, STR_TERMINATE);
if (req->smb_conn->signing.mandatory_signing) {
smbsrv_terminate_connection(req->smb_conn,
@@ -235,8 +236,8 @@ static void reply_nt1_orig(struct smbsrv_request *req)
req->out.ptr += 8;
SCVAL(req->out.vwv+1, VWV(16), 8);
}
- req_push_str(req, NULL, lp_workgroup(), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
- req_push_str(req, NULL, lp_netbios_name(), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
+ req_push_str(req, NULL, lp_workgroup(global_loadparm), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
+ req_push_str(req, NULL, lp_netbios_name(global_loadparm), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
DEBUG(3,("not using extended security (SPNEGO or NTLMSSP)\n"));
}
@@ -250,7 +251,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
int secword=0;
time_t t = req->request_time.tv_sec;
NTTIME nttime;
- BOOL negotiate_spnego = False;
+ bool negotiate_spnego = false;
char *large_test_path;
unix_to_nt_time(&nttime, t);
@@ -259,50 +260,50 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
CAP_NT_FIND | CAP_LOCK_AND_READ |
CAP_LEVEL_II_OPLOCKS | CAP_NT_SMBS | CAP_RPC_REMOTE_APIS;
- req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords();
+ req->smb_conn->negotiate.encrypted_passwords = lp_encrypted_passwords(global_loadparm);
/* do spnego in user level security if the client
supports it and we can do encrypted passwords */
if (req->smb_conn->negotiate.encrypted_passwords &&
- (lp_security() != SEC_SHARE) &&
- lp_use_spnego() &&
+ (lp_security(global_loadparm) != SEC_SHARE) &&
+ lp_use_spnego(global_loadparm) &&
(req->flags2 & FLAGS2_EXTENDED_SECURITY)) {
- negotiate_spnego = True;
+ negotiate_spnego = true;
capabilities |= CAP_EXTENDED_SECURITY;
}
- if (lp_unix_extensions()) {
+ if (lp_unix_extensions(global_loadparm)) {
capabilities |= CAP_UNIX;
}
- if (lp_large_readwrite()) {
+ if (lp_large_readwrite(global_loadparm)) {
capabilities |= CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS;
}
- large_test_path = lock_path(req, "large_test.dat");
+ large_test_path = lock_path(req, global_loadparm, "large_test.dat");
if (large_file_support(large_test_path)) {
capabilities |= CAP_LARGE_FILES;
}
- if (lp_readraw() && lp_writeraw()) {
+ if (lp_readraw(global_loadparm) && lp_writeraw(global_loadparm)) {
capabilities |= CAP_RAW_MODE;
}
/* allow for disabling unicode */
- if (lp_unicode()) {
+ if (lp_unicode(global_loadparm)) {
capabilities |= CAP_UNICODE;
}
- if (lp_nt_status_support()) {
+ if (lp_nt_status_support(global_loadparm)) {
capabilities |= CAP_STATUS32;
}
- if (lp_host_msdfs()) {
+ if (lp_host_msdfs(global_loadparm)) {
capabilities |= CAP_DFS;
}
- if (lp_security() != SEC_SHARE) {
+ if (lp_security(global_loadparm) != SEC_SHARE) {
secword |= NEGOTIATE_SECURITY_USER_LEVEL;
}
@@ -329,7 +330,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
this is the one and only SMB packet that is malformed in
the specification - all the command words after the secword
are offset by 1 byte */
- SSVAL(req->out.vwv+1, VWV(1), lp_maxmux());
+ SSVAL(req->out.vwv+1, VWV(1), lp_maxmux(global_loadparm));
SSVAL(req->out.vwv+1, VWV(2), 1); /* num vcs */
SIVAL(req->out.vwv+1, VWV(3), req->smb_conn->negotiate.max_recv);
SIVAL(req->out.vwv+1, VWV(5), 0x10000); /* raw size. full 64k */
@@ -370,7 +371,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
return;
}
- cli_credentials_set_conf(server_credentials);
+ cli_credentials_set_conf(server_credentials, global_loadparm);
nt_status = cli_credentials_set_machine_account(server_credentials);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(10, ("Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(nt_status)));
@@ -492,10 +493,10 @@ void smbsrv_reply_negprot(struct smbsrv_request *req)
smbsrv_terminate_connection(req->smb_conn, "multiple negprot's are not permitted");
return;
}
- req->smb_conn->negotiate.done_negprot = True;
+ req->smb_conn->negotiate.done_negprot = true;
p = req->in.data;
- while (True) {
+ while (true) {
size_t len;
protos = talloc_realloc(req, protos, char *, protos_count + 1);
@@ -516,8 +517,10 @@ void smbsrv_reply_negprot(struct smbsrv_request *req)
for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) {
int i;
- if (supported_protocols[protocol].protocol_level > lp_srv_maxprotocol()) continue;
- if (supported_protocols[protocol].protocol_level < lp_srv_minprotocol()) continue;
+ if (supported_protocols[protocol].protocol_level > lp_srv_maxprotocol(global_loadparm))
+ continue;
+ if (supported_protocols[protocol].protocol_level < lp_srv_minprotocol(global_loadparm))
+ continue;
for (i = 0; i < protos_count; i++) {
if (strcmp(supported_protocols[protocol].proto_name, protos[i]) != 0) continue;
diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c
index caa977c4f2..973b6b993e 100644
--- a/source4/smb_server/smb/receive.c
+++ b/source4/smb_server/smb/receive.c
@@ -26,6 +26,7 @@
#include "smb_server/service_smb_proto.h"
#include "ntvfs/ntvfs.h"
#include "system/filesys.h"
+#include "param/param.h"
/*
@@ -651,12 +652,12 @@ NTSTATUS smbsrv_init_smb_connection(struct smbsrv_connection *smb_conn)
/* this is the size that w2k uses, and it appears to be important for
good performance */
- smb_conn->negotiate.max_recv = lp_max_xmit();
+ smb_conn->negotiate.max_recv = lp_max_xmit(global_loadparm);
smb_conn->negotiate.zone_offset = get_time_zone(time(NULL));
- smb_conn->config.security = lp_security();
- smb_conn->config.nt_status_support = lp_nt_status_support();
+ smb_conn->config.security = lp_security(global_loadparm);
+ smb_conn->config.nt_status_support = lp_nt_status_support(global_loadparm);
status = smbsrv_init_sessions(smb_conn, UINT16_MAX);
NT_STATUS_NOT_OK_RETURN(status);
diff --git a/source4/smb_server/smb/reply.c b/source4/smb_server/smb/reply.c
index 47963a205f..aff0587bc6 100644
--- a/source4/smb_server/smb/reply.c
+++ b/source4/smb_server/smb/reply.c
@@ -824,9 +824,9 @@ void smbsrv_reply_read_and_X(struct smbsrv_request *req)
io->readx.in.mincnt = SVAL(req->in.vwv, VWV(6));
io->readx.in.remaining = SVAL(req->in.vwv, VWV(9));
if (req->flags2 & FLAGS2_READ_PERMIT_EXECUTE) {
- io->readx.in.read_for_execute = True;
+ io->readx.in.read_for_execute = true;
} else {
- io->readx.in.read_for_execute = False;
+ io->readx.in.read_for_execute = false;
}
if (req->smb_conn->negotiate.client_caps & CAP_LARGE_READX) {
@@ -2272,7 +2272,7 @@ static NTSTATUS parse_session_request(struct smbsrv_request *req)
req->smb_conn->negotiate.calling_name);
NT_STATUS_NOT_OK_RETURN(status);
- req->smb_conn->negotiate.done_nbt_session = True;
+ req->smb_conn->negotiate.done_nbt_session = true;
return NT_STATUS_OK;
}
diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c
index b882e8d5c8..da8d1e2d05 100644
--- a/source4/smb_server/smb/request.c
+++ b/source4/smb_server/smb/request.c
@@ -614,25 +614,25 @@ size_t req_pull_ascii4(struct smbsrv_request *req, const char **dest, const uint
/*
pull a DATA_BLOB from a request packet, returning a talloced blob
- return False if any part is outside the data portion of the packet
+ return false if any part is outside the data portion of the packet
*/
-BOOL req_pull_blob(struct smbsrv_request *req, const uint8_t *src, int len, DATA_BLOB *blob)
+bool req_pull_blob(struct smbsrv_request *req, const uint8_t *src, int len, DATA_BLOB *blob)
{
if (len != 0 && req_data_oob(req, src, len)) {
- return False;
+ return false;
}
(*blob) = data_blob_talloc(req, src, len);
- return True;
+ return true;
}
/* check that a lump of data in a request is within the bounds of the data section of
the packet */
-BOOL req_data_oob(struct smbsrv_request *req, const uint8_t *ptr, uint32_t count)
+bool req_data_oob(struct smbsrv_request *req, const uint8_t *ptr, uint32_t count)
{
if (count == 0) {
- return False;
+ return false;
}
/* be careful with wraparound! */
@@ -640,9 +640,9 @@ BOOL req_data_oob(struct smbsrv_request *req, const uint8_t *ptr, uint32_t count
ptr >= req->in.data + req->in.data_size ||
count > req->in.data_size ||
ptr + count > req->in.data + req->in.data_size) {
- return True;
+ return true;
}
- return False;
+ return false;
}
diff --git a/source4/smb_server/smb/search.c b/source4/smb_server/smb/search.c
index 000f21ee24..ccf2ff7365 100644
--- a/source4/smb_server/smb/search.c
+++ b/source4/smb_server/smb/search.c
@@ -37,13 +37,13 @@ struct search_state {
/*
fill a single entry in a search find reply
*/
-static BOOL find_fill_info(struct smbsrv_request *req,
+static bool find_fill_info(struct smbsrv_request *req,
const union smb_search_data *file)
{
uint8_t *p;
if (req->out.data_size + 43 > req_max_data(req)) {
- return False;
+ return false;
}
req_grow_data(req, req->out.data_size + 43);
@@ -61,11 +61,11 @@ static BOOL find_fill_info(struct smbsrv_request *req,
memcpy(p+30, file->search.name, MIN(strlen(file->search.name)+1, 12));
SCVAL(p,42,0);
- return True;
+ return true;
}
/* callback function for search first/next */
-static BOOL find_callback(void *private, const union smb_search_data *file)
+static bool find_callback(void *private, const union smb_search_data *file)
{
struct search_state *state = (struct search_state *)private;
diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c
index c159eb3b88..558f30307b 100644
--- a/source4/smb_server/smb/service.c
+++ b/source4/smb_server/smb/service.c
@@ -21,6 +21,8 @@
#include "smb_server/smb_server.h"
#include "smbd/service_stream.h"
#include "ntvfs/ntvfs.h"
+#include "param/share.h"
+#include "param/param.h"
/****************************************************************************
Make a connection, given the snum to connect to, and the vuser of the
@@ -199,7 +201,7 @@ NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con)
con->tconx.out.dev_type = talloc_strdup(req, req->tcon->ntvfs->dev_type);
con->tconx.out.fs_type = talloc_strdup(req, req->tcon->ntvfs->fs_type);
con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (share_int_option(req->tcon->ntvfs->config, SHARE_CSC_POLICY, SHARE_CSC_POLICY_DEFAULT) << 2);
- if (share_bool_option(req->tcon->ntvfs->config, SHARE_MSDFS_ROOT, SHARE_MSDFS_ROOT_DEFAULT) && lp_host_msdfs()) {
+ if (share_bool_option(req->tcon->ntvfs->config, SHARE_MSDFS_ROOT, SHARE_MSDFS_ROOT_DEFAULT) && lp_host_msdfs(global_loadparm)) {
con->tconx.out.options |= SMB_SHARE_IN_DFS;
}
diff --git a/source4/smb_server/smb/sesssetup.c b/source4/smb_server/smb/sesssetup.c
index 6470060286..57e2f28b8a 100644
--- a/source4/smb_server/smb/sesssetup.c
+++ b/source4/smb_server/smb/sesssetup.c
@@ -30,6 +30,7 @@
#include "smb_server/smb_server.h"
#include "smbd/service_stream.h"
#include "librpc/gen_ndr/nbt.h"
+#include "param/param.h"
/*
setup the OS, Lanman and domain portions of a session setup reply
@@ -39,7 +40,7 @@ static void sesssetup_common_strings(struct smbsrv_request *req,
{
(*os) = talloc_asprintf(req, "Unix");
(*lanman) = talloc_asprintf(req, "Samba %s", SAMBA_VERSION_STRING);
- (*domain) = talloc_asprintf(req, "%s", lp_workgroup());
+ (*domain) = talloc_asprintf(req, "%s", lp_workgroup(global_loadparm));
}
static void smbsrv_sesssetup_backend_send(struct smbsrv_request *req,
@@ -47,7 +48,7 @@ static void smbsrv_sesssetup_backend_send(struct smbsrv_request *req,
NTSTATUS status)
{
if (NT_STATUS_IS_OK(status)) {
- req->smb_conn->negotiate.done_sesssetup = True;
+ req->smb_conn->negotiate.done_sesssetup = true;
/* we need to keep the session long term */
req->session = talloc_steal(req->smb_conn, req->session);
}
@@ -128,7 +129,7 @@ static void sesssetup_old(struct smbsrv_request *req, union smb_sesssetup *sess)
user_info = talloc(req, struct auth_usersupplied_info);
if (!user_info) goto nomem;
- user_info->mapped_state = False;
+ user_info->mapped_state = false;
user_info->logon_parameters = 0;
user_info->flags = 0;
user_info->client.account_name = sess->old.in.user;
@@ -265,7 +266,7 @@ static void sesssetup_nt1(struct smbsrv_request *req, union smb_sesssetup *sess)
user_info = talloc(req, struct auth_usersupplied_info);
if (!user_info) goto nomem;
- user_info->mapped_state = False;
+ user_info->mapped_state = false;
user_info->logon_parameters = 0;
user_info->flags = 0;
user_info->client.account_name = sess->nt1.in.user;
diff --git a/source4/smb_server/smb/signing.c b/source4/smb_server/smb/signing.c
index 7b7f03f8d3..b91a65ab84 100644
--- a/source4/smb_server/smb/signing.c
+++ b/source4/smb_server/smb/signing.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "smb_server/smb_server.h"
#include "libcli/raw/libcliraw.h"
+#include "param/param.h"
/*
@@ -62,12 +63,12 @@ void smbsrv_sign_packet(struct smbsrv_request *req)
setup the signing key for a connection. Called after authentication succeeds
in a session setup
*/
-BOOL smbsrv_setup_signing(struct smbsrv_connection *smb_conn,
+bool smbsrv_setup_signing(struct smbsrv_connection *smb_conn,
DATA_BLOB *session_key,
DATA_BLOB *response)
{
if (!set_smb_signing_common(&smb_conn->signing)) {
- return False;
+ return false;
}
return smbcli_simple_set_signing(smb_conn,
&smb_conn->signing, session_key, response);
@@ -89,38 +90,38 @@ void smbsrv_signing_restart(struct smbsrv_connection *smb_conn,
* pretend we have seen a
* valid packet, so we don't
* turn it off */
- smb_conn->signing.seen_valid = True;
+ smb_conn->signing.seen_valid = true;
}
}
}
-BOOL smbsrv_init_signing(struct smbsrv_connection *smb_conn)
+bool smbsrv_init_signing(struct smbsrv_connection *smb_conn)
{
smb_conn->signing.mac_key = data_blob(NULL, 0);
if (!smbcli_set_signing_off(&smb_conn->signing)) {
- return False;
+ return false;
}
- switch (lp_server_signing()) {
+ switch (lp_server_signing(global_loadparm)) {
case SMB_SIGNING_OFF:
- smb_conn->signing.allow_smb_signing = False;
+ smb_conn->signing.allow_smb_signing = false;
break;
case SMB_SIGNING_SUPPORTED:
- smb_conn->signing.allow_smb_signing = True;
+ smb_conn->signing.allow_smb_signing = true;
break;
case SMB_SIGNING_REQUIRED:
- smb_conn->signing.allow_smb_signing = True;
- smb_conn->signing.mandatory_signing = True;
+ smb_conn->signing.allow_smb_signing = true;
+ smb_conn->signing.mandatory_signing = true;
break;
case SMB_SIGNING_AUTO:
- if (lp_domain_logons()) {
- smb_conn->signing.allow_smb_signing = True;
+ if (lp_domain_logons(global_loadparm)) {
+ smb_conn->signing.allow_smb_signing = true;
} else {
- smb_conn->signing.allow_smb_signing = False;
+ smb_conn->signing.allow_smb_signing = false;
}
break;
}
- return True;
+ return true;
}
/*
@@ -150,24 +151,24 @@ void smbsrv_signing_no_reply(struct smbsrv_request *req)
************************************************************/
/**
* Check a packet supplied by the server.
- * @return False if we had an established signing connection
- * which had a back checksum, True otherwise
+ * @return false if we had an established signing connection
+ * which had a back checksum, true otherwise
*/
-BOOL smbsrv_signing_check_incoming(struct smbsrv_request *req)
+bool smbsrv_signing_check_incoming(struct smbsrv_request *req)
{
- BOOL good;
+ bool good;
req_signing_alloc_seq_num(req);
switch (req->smb_conn->signing.signing_state)
{
case SMB_SIGNING_ENGINE_OFF:
- return True;
+ return true;
case SMB_SIGNING_ENGINE_BSRSPYL:
case SMB_SIGNING_ENGINE_ON:
{
if (req->in.size < (HDR_SS_FIELD + 8)) {
- return False;
+ return false;
} else {
good = check_signed_incoming_message(&req->in,
&req->smb_conn->signing.mac_key,
@@ -178,5 +179,5 @@ BOOL smbsrv_signing_check_incoming(struct smbsrv_request *req)
}
}
}
- return False;
+ return false;
}
diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c
index 75a03fbe79..45ea234d09 100644
--- a/source4/smb_server/smb/trans2.c
+++ b/source4/smb_server/smb/trans2.c
@@ -790,7 +790,7 @@ static NTSTATUS find_fill_info(struct find_state *state,
}
/* callback function for trans2 findfirst/findnext */
-static BOOL find_callback(void *private, const union smb_search_data *file)
+static bool find_callback(void *private, const union smb_search_data *file)
{
struct find_state *state = talloc_get_type(private, struct find_state);
struct smb_trans2 *trans = state->op->trans;
@@ -802,11 +802,11 @@ static BOOL find_callback(void *private, const union smb_search_data *file)
trans->out.data.length > trans->in.max_data) {
/* restore the old length and tell the backend to stop */
smbsrv_blob_grow_data(trans, &trans->out.data, old_length);
- return False;
+ return false;
}
state->last_entry_offset = old_length;
- return True;
+ return true;
}
/*
diff --git a/source4/smb_server/smb2/fileinfo.c b/source4/smb_server/smb2/fileinfo.c
index 4f4b790702..41b31f586f 100644
--- a/source4/smb_server/smb2/fileinfo.c
+++ b/source4/smb_server/smb2/fileinfo.c
@@ -53,7 +53,7 @@ static void smb2srv_getinfo_send(struct ntvfs_request *ntvfs)
SMB2SRV_CHECK(op->send_fn(op));
}
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, True, op->info->out.blob.length));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, true, op->info->out.blob.length));
/* TODO: this is maybe a o16s32_blob */
SMB2SRV_CHECK(smb2_push_o16s16_blob(&req->out, 0x02, op->info->out.blob));
@@ -205,7 +205,7 @@ void smb2srv_getinfo_recv(struct smb2srv_request *req)
struct smb2_getinfo *info;
struct smb2srv_getinfo_op *op;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x28, True);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x28, true);
SMB2SRV_TALLOC_IO_PTR(info, struct smb2_getinfo);
/* this overwrites req->io_ptr !*/
SMB2SRV_TALLOC_IO_PTR(op, struct smb2srv_getinfo_op);
@@ -247,7 +247,7 @@ static void smb2srv_setinfo_send(struct ntvfs_request *ntvfs)
SMB2SRV_CHECK_ASYNC_STATUS(op, struct smb2srv_setinfo_op);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x02, False, 0));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x02, false, 0));
smb2srv_send_reply(req);
}
@@ -349,7 +349,7 @@ void smb2srv_setinfo_recv(struct smb2srv_request *req)
struct smb2_setinfo *info;
struct smb2srv_setinfo_op *op;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x20, True);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x20, true);
SMB2SRV_TALLOC_IO_PTR(info, struct smb2_setinfo);
/* this overwrites req->io_ptr !*/
SMB2SRV_TALLOC_IO_PTR(op, struct smb2srv_setinfo_op);
diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c
index 3e4d7ffceb..47b5dbe60c 100644
--- a/source4/smb_server/smb2/fileio.c
+++ b/source4/smb_server/smb2/fileio.c
@@ -31,7 +31,7 @@ static void smb2srv_create_send(struct ntvfs_request *ntvfs)
union smb_open *io;
SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_open);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x58, True, io->smb2.out.blob.length));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x58, true, io->smb2.out.blob.length));
SSVAL(req->out.body, 0x02, io->smb2.out.oplock_flags);
SIVAL(req->out.body, 0x04, io->smb2.out.create_action);
@@ -58,7 +58,7 @@ void smb2srv_create_recv(struct smb2srv_request *req)
union smb_open *io;
DATA_BLOB blob;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x38, True);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x38, true);
SMB2SRV_TALLOC_IO_PTR(io, union smb_open);
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_create_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
@@ -88,7 +88,7 @@ static void smb2srv_close_send(struct ntvfs_request *ntvfs)
union smb_close *io;
SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_close);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x3C, False, 0));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x3C, false, 0));
SSVAL(req->out.body, 0x02, io->smb2.out.flags);
SIVAL(req->out.body, 0x04, io->smb2.out._pad);
@@ -107,7 +107,7 @@ void smb2srv_close_recv(struct smb2srv_request *req)
{
union smb_close *io;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x18, False);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x18, false);
SMB2SRV_TALLOC_IO_PTR(io, union smb_close);
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_close_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
@@ -126,7 +126,7 @@ static void smb2srv_flush_send(struct ntvfs_request *ntvfs)
union smb_flush *io;
SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_flush);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, False, 0));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, false, 0));
SSVAL(req->out.body, 0x02, 0);
@@ -138,7 +138,7 @@ void smb2srv_flush_recv(struct smb2srv_request *req)
union smb_flush *io;
uint16_t _pad;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x18, False);
+ 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);
@@ -157,7 +157,7 @@ static void smb2srv_read_send(struct ntvfs_request *ntvfs)
union smb_read *io;
SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_read);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, True, io->smb2.out.data.length));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, true, io->smb2.out.data.length));
/* TODO: avoid the memcpy */
SMB2SRV_CHECK(smb2_push_o16s32_blob(&req->out, 0x02, io->smb2.out.data));
@@ -170,7 +170,7 @@ void smb2srv_read_recv(struct smb2srv_request *req)
{
union smb_read *io;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x30, True);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x30, true);
SMB2SRV_TALLOC_IO_PTR(io, union smb_read);
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_read_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
@@ -199,7 +199,7 @@ static void smb2srv_write_send(struct ntvfs_request *ntvfs)
union smb_write *io;
SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_write);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, True, 0));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, true, 0));
SSVAL(req->out.body, 0x02, io->smb2.out._pad);
SIVAL(req->out.body, 0x04, io->smb2.out.nwritten);
@@ -212,7 +212,7 @@ void smb2srv_write_recv(struct smb2srv_request *req)
{
union smb_write *io;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x30, True);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x30, true);
SMB2SRV_TALLOC_IO_PTR(io, union smb_write);
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_write_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
@@ -234,7 +234,7 @@ static void smb2srv_lock_send(struct ntvfs_request *ntvfs)
union smb_lock *io;
SMB2SRV_CHECK_ASYNC_STATUS_ERR(io, union smb_lock);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, False, 0));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, false, 0));
SSVAL(req->out.body, 0x02, io->smb2.out.unknown1);
@@ -245,7 +245,7 @@ void smb2srv_lock_recv(struct smb2srv_request *req)
{
union smb_lock *io;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x30, False);
+ 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);
@@ -269,7 +269,7 @@ static void smb2srv_ioctl_send(struct ntvfs_request *ntvfs)
union smb_ioctl *io;
SMB2SRV_CHECK_ASYNC_STATUS_ERR(io, union smb_ioctl);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x30, True, 0));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x30, true, 0));
SSVAL(req->out.body, 0x02, io->smb2.out._pad);
SIVAL(req->out.body, 0x04, io->smb2.out.function);
@@ -294,7 +294,7 @@ void smb2srv_ioctl_recv(struct smb2srv_request *req)
union smb_ioctl *io;
struct smb2_handle h;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x38, True);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x38, true);
SMB2SRV_TALLOC_IO_PTR(io, union smb_ioctl);
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_ioctl_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
@@ -330,7 +330,7 @@ static void smb2srv_notify_send(struct ntvfs_request *ntvfs)
DATA_BLOB blob = data_blob(NULL, 0);
SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_notify);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, True, 0));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, true, 0));
#define MAX_BYTES_PER_CHAR 3
@@ -384,7 +384,7 @@ void smb2srv_notify_recv(struct smb2srv_request *req)
{
union smb_notify *io;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x20, False);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x20, false);
SMB2SRV_TALLOC_IO_PTR(io, union smb_notify);
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_notify_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
diff --git a/source4/smb_server/smb2/find.c b/source4/smb_server/smb2/find.c
index 9ab62c35f5..c594adf7a0 100644
--- a/source4/smb_server/smb2/find.c
+++ b/source4/smb_server/smb2/find.c
@@ -40,7 +40,7 @@ struct smb2srv_find_state {
};
/* callback function for SMB2 Find */
-static BOOL smb2srv_find_callback(void *private, const union smb_search_data *file)
+static bool smb2srv_find_callback(void *private, const union smb_search_data *file)
{
struct smb2srv_find_state *state = talloc_get_type(private, struct smb2srv_find_state);
struct smb2_find *info = state->info;
@@ -54,12 +54,12 @@ static BOOL smb2srv_find_callback(void *private, const union smb_search_data *fi
info->out.blob.length > info->in.max_response_size) {
/* restore the old length and tell the backend to stop */
smbsrv_blob_grow_data(state, &info->out.blob, old_length);
- return False;
+ return false;
}
state->last_entry_offset = old_length;
- return True;
+ return true;
}
static void smb2srv_find_send(struct ntvfs_request *ntvfs)
@@ -68,7 +68,7 @@ static void smb2srv_find_send(struct ntvfs_request *ntvfs)
struct smb2srv_find_state *state;
SMB2SRV_CHECK_ASYNC_STATUS(state, struct smb2srv_find_state);
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, True, state->info->out.blob.length));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, true, state->info->out.blob.length));
if (state->info->out.blob.length > 0) {
SIVAL(state->info->out.blob.data + state->last_entry_offset, 0, 0);
@@ -141,7 +141,7 @@ void smb2srv_find_recv(struct smb2srv_request *req)
struct smb2srv_find_state *state;
struct smb2_find *info;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x20, True);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x20, true);
SMB2SRV_TALLOC_IO_PTR(info, struct smb2_find);
/* this overwrites req->io_ptr !*/
SMB2SRV_TALLOC_IO_PTR(state, struct smb2srv_find_state);
diff --git a/source4/smb_server/smb2/keepalive.c b/source4/smb_server/smb2/keepalive.c
index ed4903ec29..f40bcc485c 100644
--- a/source4/smb_server/smb2/keepalive.c
+++ b/source4/smb_server/smb2/keepalive.c
@@ -38,7 +38,7 @@ static void smb2srv_keepalive_send(struct smb2srv_request *req)
return;
}
- status = smb2srv_setup_reply(req, 0x04, False, 0);
+ status = smb2srv_setup_reply(req, 0x04, false, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
diff --git a/source4/smb_server/smb2/negprot.c b/source4/smb_server/smb2/negprot.c
index 2aca91adf8..78c17aa03e 100644
--- a/source4/smb_server/smb2/negprot.c
+++ b/source4/smb_server/smb2/negprot.c
@@ -27,6 +27,7 @@
#include "smb_server/service_smb_proto.h"
#include "smb_server/smb2/smb2_server.h"
#include "smbd/service_stream.h"
+#include "param/param.h"
static NTSTATUS smb2srv_negprot_secblob(struct smb2srv_request *req, DATA_BLOB *_blob)
{
@@ -52,7 +53,7 @@ static NTSTATUS smb2srv_negprot_secblob(struct smb2srv_request *req, DATA_BLOB *
return NT_STATUS_NO_MEMORY;
}
- cli_credentials_set_conf(server_credentials);
+ cli_credentials_set_conf(server_credentials, global_loadparm);
nt_status = cli_credentials_set_machine_account(server_credentials);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(10, ("Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(nt_status)));
@@ -121,7 +122,7 @@ static void smb2srv_negprot_send(struct smb2srv_request *req, struct smb2_negpro
return;
}
- status = smb2srv_setup_reply(req, 0x40, True, io->out.secblob.length);
+ status = smb2srv_setup_reply(req, 0x40, true, io->out.secblob.length);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
@@ -196,7 +197,7 @@ void smb2srv_reply_smb_negprot(struct smbsrv_request *smb_req)
req->in.size = NBT_HDR_SIZE+SMB2_HDR_BODY+body_fixed_size;
req->in.allocated = req->in.size;
- req->in.buffer = talloc_size(req, req->in.allocated);
+ req->in.buffer = talloc_array(req, uint8_t, req->in.allocated);
if (!req->in.buffer) goto nomem;
req->in.hdr = req->in.buffer + NBT_HDR_SIZE;
req->in.body = req->in.hdr + SMB2_HDR_BODY;
diff --git a/source4/smb_server/smb2/receive.c b/source4/smb_server/smb2/receive.c
index a8c0e6f786..a440c33dc0 100644
--- a/source4/smb_server/smb2/receive.c
+++ b/source4/smb_server/smb2/receive.c
@@ -28,6 +28,7 @@
#include "smbd/service_stream.h"
#include "lib/stream/packet.h"
#include "ntvfs/ntvfs.h"
+#include "param/param.h"
static int smb2srv_request_destructor(struct smb2srv_request *req)
{
@@ -58,7 +59,7 @@ struct smb2srv_request *smb2srv_init_request(struct smbsrv_connection *smb_conn)
}
NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint16_t body_fixed_size,
- BOOL body_dynamic_present, uint32_t body_dynamic_size)
+ bool body_dynamic_present, uint32_t body_dynamic_size)
{
uint32_t flags = 0x00000001;
uint32_t pid = IVAL(req->in.hdr, SMB2_HDR_PID);
@@ -81,7 +82,8 @@ NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint16_t body_fixed_si
req->out.size = SMB2_HDR_BODY+NBT_HDR_SIZE+body_fixed_size;
req->out.allocated = req->out.size + body_dynamic_size;
- req->out.buffer = talloc_size(req, req->out.allocated);
+ req->out.buffer = talloc_array(req, uint8_t,
+ req->out.allocated);
NT_STATUS_HAVE_NO_MEMORY(req->out.buffer);
req->out.hdr = req->out.buffer + NBT_HDR_SIZE;
@@ -235,7 +237,7 @@ void smb2srv_send_error(struct smb2srv_request *req, NTSTATUS error)
return;
}
- status = smb2srv_setup_reply(req, 8, True, 0);
+ status = smb2srv_setup_reply(req, 8, true, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
@@ -514,12 +516,12 @@ NTSTATUS smbsrv_init_smb2_connection(struct smbsrv_connection *smb_conn)
/* this is the size that w2k uses, and it appears to be important for
good performance */
- smb_conn->negotiate.max_recv = lp_max_xmit();
+ smb_conn->negotiate.max_recv = lp_max_xmit(global_loadparm);
smb_conn->negotiate.zone_offset = get_time_zone(time(NULL));
smb_conn->config.security = SEC_USER;
- smb_conn->config.nt_status_support = True;
+ smb_conn->config.nt_status_support = true;
status = smbsrv_init_sessions(smb_conn, UINT64_MAX);
NT_STATUS_NOT_OK_RETURN(status);
diff --git a/source4/smb_server/smb2/sesssetup.c b/source4/smb_server/smb2/sesssetup.c
index 76f89d43d2..7d72193e6e 100644
--- a/source4/smb_server/smb2/sesssetup.c
+++ b/source4/smb_server/smb2/sesssetup.c
@@ -42,7 +42,7 @@ static void smb2srv_sesssetup_send(struct smb2srv_request *req, union smb_sessse
return;
}
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, True, io->smb2.out.secblob.length));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, true, io->smb2.out.secblob.length));
SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, unknown1);
SBVAL(req->out.hdr, SMB2_HDR_UID, io->smb2.out.uid);
@@ -187,7 +187,7 @@ void smb2srv_sesssetup_recv(struct smb2srv_request *req)
{
union smb_sesssetup *io;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x18, True);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x18, true);
SMB2SRV_TALLOC_IO_PTR(io, union smb_sesssetup);
io->smb2.level = RAW_SESSSETUP_SMB2;
@@ -215,7 +215,7 @@ static void smb2srv_logoff_send(struct smb2srv_request *req)
return;
}
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, False, 0));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, false, 0));
SSVAL(req->out.body, 0x02, 0);
@@ -226,7 +226,7 @@ void smb2srv_logoff_recv(struct smb2srv_request *req)
{
uint16_t _pad;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x04, False);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x04, false);
_pad = SVAL(req->in.body, 0x02);
diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c
index b476e97168..572d3b5bf5 100644
--- a/source4/smb_server/smb2/tcon.c
+++ b/source4/smb_server/smb2/tcon.c
@@ -41,7 +41,8 @@ static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *h, uint8
req = smb2srv_init_request(handle->tcon->smb_conn);
NT_STATUS_HAVE_NO_MEMORY(req);
- req->in.buffer = talloc_size(req, NBT_HDR_SIZE + SMB2_MIN_SIZE);
+ req->in.buffer = talloc_array(req, uint8_t,
+ NBT_HDR_SIZE + SMB2_MIN_SIZE);
NT_STATUS_HAVE_NO_MEMORY(req->in.buffer);
req->in.size = NBT_HDR_SIZE + SMB2_MIN_SIZE;
req->in.allocated = req->in.size;
@@ -69,7 +70,7 @@ static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *h, uint8
SSVAL(req->in.body, 0, 2);
- status = smb2srv_setup_reply(req, 0x18, False, 0);
+ status = smb2srv_setup_reply(req, 0x18, false, 0);
NT_STATUS_NOT_OK_RETURN(status);
SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0000);
@@ -371,7 +372,7 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io)
unknown1 = 0x0001;
}
- SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, False, 0));
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, false, 0));
SIVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid);
SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1,unknown1);
@@ -388,7 +389,7 @@ void smb2srv_tcon_recv(struct smb2srv_request *req)
{
union smb_tcon *io;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x08, True);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x08, true);
SMB2SRV_TALLOC_IO_PTR(io, union smb_tcon);
io->smb2.level = RAW_TCON_SMB2;
@@ -421,7 +422,7 @@ static void smb2srv_tdis_send(struct smb2srv_request *req)
return;
}
- status = smb2srv_setup_reply(req, 0x04, False, 0);
+ status = smb2srv_setup_reply(req, 0x04, false, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
@@ -437,7 +438,7 @@ void smb2srv_tdis_recv(struct smb2srv_request *req)
{
uint16_t _pad;
- SMB2SRV_CHECK_BODY_SIZE(req, 0x04, False);
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x04, false);
_pad = SVAL(req->in.body, 0x02);
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index 30c78eb3a7..691934f71c 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -32,6 +32,7 @@
#include "lib/socket/netif.h"
#include "param/share.h"
#include "dsdb/samdb/samdb.h"
+#include "param/param.h"
static NTSTATUS smbsrv_recv_generic_request(void *private, DATA_BLOB blob)
{
@@ -62,7 +63,7 @@ static NTSTATUS smbsrv_recv_generic_request(void *private, DATA_BLOB blob)
packet_set_callback(smb_conn->packet, smbsrv_recv_smb_request);
return smbsrv_recv_smb_request(smb_conn, blob);
case SMB2_MAGIC:
- if (lp_srv_maxprotocol() < PROTOCOL_SMB2) break;
+ if (lp_srv_maxprotocol(global_loadparm) < PROTOCOL_SMB2) break;
status = smbsrv_init_smb2_connection(smb_conn);
NT_STATUS_NOT_OK_RETURN(status);
packet_set_callback(smb_conn->packet, smbsrv_recv_smb2_request);
@@ -173,11 +174,11 @@ static const struct stream_server_ops smb_stream_ops = {
/*
setup a listening socket on all the SMB ports for a particular address
*/
-static NTSTATUS smb_add_socket(struct event_context *event_context,
+_PUBLIC_ NTSTATUS smbsrv_add_socket(struct event_context *event_context,
const struct model_ops *model_ops,
const char *address)
{
- const char **ports = lp_smb_ports();
+ const char **ports = lp_smb_ports(global_loadparm);
int i;
NTSTATUS status;
@@ -214,7 +215,7 @@ static void smbsrv_task_init(struct task_server *task)
task_server_set_title(task, "task[smbsrv]");
- if (lp_interfaces() && lp_bind_interfaces_only()) {
+ if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) {
int num_interfaces = iface_count();
int i;
@@ -224,12 +225,13 @@ static void smbsrv_task_init(struct task_server *task)
*/
for(i = 0; i < num_interfaces; i++) {
const char *address = iface_n_ip(i);
- status = smb_add_socket(task->event_ctx, task->model_ops, address);
+ status = smbsrv_add_socket(task->event_ctx, task->model_ops, address);
if (!NT_STATUS_IS_OK(status)) goto failed;
}
} else {
/* Just bind to lp_socket_address() (usually 0.0.0.0) */
- status = smb_add_socket(task->event_ctx, task->model_ops, lp_socket_address());
+ status = smbsrv_add_socket(task->event_ctx, task->model_ops,
+ lp_socket_address(global_loadparm));
if (!NT_STATUS_IS_OK(status)) goto failed;
}
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 10bafcd208..8ebd3e683f 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -376,6 +376,12 @@ struct smbsrv_connection {
struct share_context *share_context;
};
+struct model_ops;
+
+NTSTATUS smbsrv_add_socket(struct event_context *event_context,
+ const struct model_ops *model_ops,
+ const char *address);
+
#include "smb_server/smb_server_proto.h"
#include "smb_server/smb/smb_proto.h"
diff --git a/source4/smbd/pidfile.c b/source4/smbd/pidfile.c
index fdb502d41d..4847ddd7b5 100644
--- a/source4/smbd/pidfile.c
+++ b/source4/smbd/pidfile.c
@@ -21,6 +21,8 @@
#include "includes.h"
#include "system/filesys.h"
+#include "param/param.h"
+#include "smbd/pidfile.h"
/**
* @file
@@ -38,7 +40,7 @@ pid_t pidfile_pid(const char *name)
pid_t ret;
char *pidFile;
- asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name);
+ asprintf(&pidFile, "%s/%s.pid", lp_piddir(global_loadparm), name);
fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
@@ -85,7 +87,7 @@ void pidfile_create(const char *name)
char *pidFile;
pid_t pid;
- asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name);
+ asprintf(&pidFile, "%s/%s.pid", lp_piddir(global_loadparm), name);
pid = pidfile_pid(name);
if (pid != 0) {
@@ -101,7 +103,7 @@ void pidfile_create(const char *name)
exit(1);
}
- if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==False) {
+ if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==false) {
DEBUG(0,("ERROR: %s : fcntl lock of file %s failed. Error was %s\n",
name, pidFile, strerror(errno)));
exit(1);
diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c
index f83c7b784b..bb4d3a53bb 100644
--- a/source4/smbd/process_model.c
+++ b/source4/smbd/process_model.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "smbd/process_model.h"
#include "build.h"
+#include "param/param.h"
/*
setup the events for the chosen process model
@@ -82,7 +83,7 @@ _PUBLIC_ NTSTATUS register_process_model(const void *_ops)
NTSTATUS process_model_init(void)
{
init_module_fn static_init[] = STATIC_process_model_MODULES;
- init_module_fn *shared_init = load_samba_modules(NULL, "process_model");
+ init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "process_model");
run_init_functions(static_init);
run_init_functions(shared_init);
diff --git a/source4/smbd/process_model.h b/source4/smbd/process_model.h
index 513e903781..19212606c1 100644
--- a/source4/smbd/process_model.h
+++ b/source4/smbd/process_model.h
@@ -67,6 +67,8 @@ struct process_model_critical_sizes {
int sizeof_model_ops;
};
+extern const struct model_ops single_ops;
+
#include "smbd/process_model_proto.h"
#endif /* __PROCESS_MODEL_H__ */
diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c
index 65f5a7e375..5ba2c8df88 100644
--- a/source4/smbd/process_single.c
+++ b/source4/smbd/process_single.c
@@ -87,7 +87,7 @@ static void single_set_title(struct event_context *ev, const char *title)
{
}
-static const struct model_ops single_ops = {
+const struct model_ops single_ops = {
.name = "single",
.model_init = single_model_init,
.new_task = single_new_task,
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index b9a245d140..07fdccdb36 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -191,7 +191,7 @@ static void standard_new_task(struct event_context *ev,
/* called when a task goes down */
-static void standard_terminate(struct event_context *ev, const char *reason)
+_NORETURN_ static void standard_terminate(struct event_context *ev, const char *reason)
{
DEBUG(2,("standard_terminate: reason[%s]\n",reason));
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index 1a90592fcd..8f5c3b66ec 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -39,6 +39,7 @@
#include "param/secrets.h"
#include "smbd/pidfile.h"
#include "cluster/ctdb/ctdb_cluster.h"
+#include "param/param.h"
/*
recursively delete a directory tree
@@ -92,7 +93,7 @@ static void cleanup_tmp_files(void)
char *path;
TALLOC_CTX *mem_ctx = talloc_new(NULL);
- path = smbd_tmp_path(mem_ctx, NULL);
+ path = smbd_tmp_path(mem_ctx, global_loadparm, NULL);
recursive_delete(path);
talloc_free(mem_ctx);
@@ -122,25 +123,25 @@ static void sig_term(int sig)
static void setup_signals(void)
{
/* we are never interested in SIGPIPE */
- BlockSignals(True,SIGPIPE);
+ BlockSignals(true,SIGPIPE);
#if defined(SIGFPE)
/* we are never interested in SIGFPE */
- BlockSignals(True,SIGFPE);
+ BlockSignals(true,SIGFPE);
#endif
/* We are no longer interested in USR1 */
- BlockSignals(True, SIGUSR1);
+ BlockSignals(true, SIGUSR1);
#if defined(SIGUSR2)
/* We are no longer interested in USR2 */
- BlockSignals(True,SIGUSR2);
+ BlockSignals(true,SIGUSR2);
#endif
/* POSIX demands that signals are inherited. If the invoking process has
* these signals masked, we will have problems, as we won't recieve them. */
- BlockSignals(False, SIGHUP);
- BlockSignals(False, SIGTERM);
+ BlockSignals(false, SIGHUP);
+ BlockSignals(false, SIGTERM);
CatchSignal(SIGHUP, sig_hup);
CatchSignal(SIGTERM, sig_term);
@@ -152,7 +153,7 @@ static void setup_signals(void)
static void server_stdin_handler(struct event_context *event_ctx, struct fd_event *fde,
uint16_t flags, void *private)
{
- const char *binary_name = private;
+ const char *binary_name = (const char *)private;
uint8_t c;
if (read(0, &c, 1) == 0) {
DEBUG(0,("%s: EOF on stdin - terminating\n", binary_name));
@@ -168,10 +169,11 @@ static void server_stdin_handler(struct event_context *event_ctx, struct fd_even
/*
die if the user selected maximum runtime is exceeded
*/
-static void max_runtime_handler(struct event_context *ev, struct timed_event *te,
- struct timeval t, void *private)
+_NORETURN_ static void max_runtime_handler(struct event_context *ev,
+ struct timed_event *te,
+ struct timeval t, void *private)
{
- const char *binary_name = private;
+ const char *binary_name = (const char *)private;
DEBUG(0,("%s: maximum runtime exceeded - terminating\n", binary_name));
exit(0);
}
@@ -267,8 +269,8 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
cleanup_tmp_files();
- if (!directory_exist(lp_lockdir())) {
- mkdir(lp_lockdir(), 0755);
+ if (!directory_exist(lp_lockdir(global_loadparm))) {
+ mkdir(lp_lockdir(global_loadparm), 0755);
}
pidfile_create(binary_name);
@@ -294,7 +296,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
process_model_init();
- shared_init = load_samba_modules(NULL, "service");
+ shared_init = load_samba_modules(NULL, global_loadparm, "service");
run_init_functions(static_init);
run_init_functions(shared_init);
@@ -305,6 +307,11 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
should hang off that */
event_ctx = event_context_init(talloc_autofree_context());
+ if (event_ctx == NULL) {
+ DEBUG(0,("Initializing event context failed\n"));
+ return 1;
+ }
+
/* initialise clustering if needed */
cluster_ctdb_init(event_ctx, model);
@@ -327,7 +334,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
}
DEBUG(0,("%s: using '%s' process model\n", binary_name, model));
- status = server_service_startup(event_ctx, model, lp_server_services());
+ status = server_service_startup(event_ctx, model, lp_server_services(global_loadparm));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Starting Services failed - %s\n", nt_errstr(status)));
return 1;
diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c
index 08c323fc0a..ad72f907bb 100644
--- a/source4/smbd/service_stream.c
+++ b/source4/smbd/service_stream.c
@@ -28,6 +28,7 @@
#include "smbd/service_stream.h"
#include "lib/messaging/irpc.h"
#include "cluster/cluster.h"
+#include "param/param.h"
/* the range of ports to try for dcerpc over tcp endpoints */
#define SERVER_TCP_LOW_PORT 1024
@@ -83,13 +84,13 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
*/
static void stream_io_handler(struct stream_connection *conn, uint16_t flags)
{
- conn->processing = True;
+ conn->processing = true;
if (flags & EVENT_FD_WRITE) {
conn->ops->send_handler(conn, flags);
} else if (flags & EVENT_FD_READ) {
conn->ops->recv_handler(conn, flags);
}
- conn->processing = False;
+ conn->processing = false;
if (conn->terminate) {
stream_terminate_connection(conn, conn->terminate);
@@ -174,13 +175,15 @@ static void stream_new_connection(struct event_context *ev,
srv_conn->event.fde = event_add_fd(ev, srv_conn, socket_get_fd(sock),
0, stream_io_handler_fde, srv_conn);
- if (!socket_check_access(sock, "smbd", lp_hostsallow(-1), lp_hostsdeny(-1))) {
+ if (!socket_check_access(sock, "smbd", lp_hostsallow(NULL), lp_hostsdeny(NULL))) {
stream_terminate_connection(srv_conn, "denied by access rules");
return;
}
/* setup to receive internal messages on this connection */
- srv_conn->msg_ctx = messaging_init(srv_conn, srv_conn->server_id, ev);
+ srv_conn->msg_ctx = messaging_init(srv_conn,
+ lp_messaging_path(srv_conn, global_loadparm),
+ srv_conn->server_id, ev);
if (!srv_conn->msg_ctx) {
stream_terminate_connection(srv_conn, "messaging_init() failed");
return;
@@ -224,11 +227,13 @@ static void stream_accept_handler(struct event_context *ev, struct fd_event *fde
stream_new_connection, stream_socket);
}
-
-
/*
setup a listen stream socket
if you pass *port == 0, then a port > 1024 is used
+
+ FIXME: This function is TCP/IP specific - uses an int rather than
+ a string for the port. Should leave allocating a port nr
+ to the socket implementation - JRV20070903
*/
NTSTATUS stream_setup_socket(struct event_context *event_context,
const struct model_ops *model_ops,
@@ -255,7 +260,8 @@ NTSTATUS stream_setup_socket(struct event_context *event_context,
status = socket_set_option(stream_socket->sock, "SO_KEEPALIVE", NULL);
NT_STATUS_NOT_OK_RETURN(status);
- status = socket_set_option(stream_socket->sock, lp_socket_options(), NULL);
+ status = socket_set_option(stream_socket->sock, lp_socket_options(global_loadparm),
+ NULL);
NT_STATUS_NOT_OK_RETURN(status);
/* TODO: set socket ACL's here when they're implemented */
diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h
index 49869d8eed..6eb26a4282 100644
--- a/source4/smbd/service_stream.h
+++ b/source4/smbd/service_stream.h
@@ -23,6 +23,8 @@
#ifndef __SERVICE_STREAM_H__
#define __SERVICE_STREAM_H__
+#include "librpc/gen_ndr/misc.h"
+
/* modules can use the following to determine if the interface has changed
* please increment the version number after each interface change
* with a comment and maybe update struct stream_connection_critical_sizes.
diff --git a/source4/smbd/service_task.c b/source4/smbd/service_task.c
index cab5c7e112..c77cae4185 100644
--- a/source4/smbd/service_task.c
+++ b/source4/smbd/service_task.c
@@ -25,6 +25,7 @@
#include "smbd/service.h"
#include "smbd/service_task.h"
#include "lib/messaging/irpc.h"
+#include "param/param.h"
/*
terminate a task service
@@ -64,7 +65,9 @@ static void task_server_callback(struct event_context *event_ctx,
task->model_ops = state->model_ops;
task->server_id = server_id;
- task->msg_ctx = messaging_init(task, task->server_id, task->event_ctx);
+ task->msg_ctx = messaging_init(task,
+ lp_messaging_path(task, global_loadparm),
+ task->server_id, task->event_ctx);
if (!task->msg_ctx) {
task_server_terminate(task, "messaging_init() failed");
return;
diff --git a/source4/smbd/service_task.h b/source4/smbd/service_task.h
index 54e6d0fa6c..e5bf9ea414 100644
--- a/source4/smbd/service_task.h
+++ b/source4/smbd/service_task.h
@@ -22,6 +22,8 @@
#ifndef __SERVICE_TASK_H__
#define __SERVICE_TASK_H__
+#include "librpc/gen_ndr/misc.h"
+
struct task_server {
struct event_context *event_ctx;
const struct model_ops *model_ops;
diff --git a/source4/static_deps.mk b/source4/static_deps.mk
index a09ba74e88..1f86372aa3 100644
--- a/source4/static_deps.mk
+++ b/source4/static_deps.mk
@@ -12,7 +12,6 @@ include/includes.h: \
include/config.h \
lib/charset/charset.h \
param/proto.h \
- libcli/util/proto.h \
librpc/gen_ndr/misc.h
heimdal_basics: \
diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c
index e97338d3a6..23269a0160 100644
--- a/source4/torture/auth/ntlmssp.c
+++ b/source4/torture/auth/ntlmssp.c
@@ -44,7 +44,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
gensec_start_mech_by_oid(gensec_security, GENSEC_OID_NTLMSSP),
"Failed to start GENSEC for NTLMSSP");
- gensec_ntlmssp_state = gensec_security->private_data;
+ gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405060708090a0b0c0d0e0f00");
dump_data_pw("NTLMSSP session key: \n",
@@ -98,7 +98,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
gensec_start_mech_by_oid(gensec_security, GENSEC_OID_NTLMSSP),
"GENSEC start mech by oid");
- gensec_ntlmssp_state = gensec_security->private_data;
+ gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405e538b0");
dump_data_pw("NTLMSSP session key: \n",
diff --git a/source4/torture/basic/aliases.c b/source4/torture/basic/aliases.c
index 0b5f1fb88a..660009704b 100644
--- a/source4/torture/basic/aliases.c
+++ b/source4/torture/basic/aliases.c
@@ -381,9 +381,9 @@ static bool setpathinfo_aliases(struct torture_context *tctx,
/* look for aliased info levels in trans2 calls */
-struct torture_suite *torture_trans2_aliases(void)
+struct torture_suite *torture_trans2_aliases(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "ALIASES");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "ALIASES");
torture_suite_add_1smb_test(suite, "QFILEINFO aliases", qfsinfo_aliases);
torture_suite_add_1smb_test(suite, "QFSINFO aliases", qfileinfo_aliases);
diff --git a/source4/torture/basic/attr.c b/source4/torture/basic/attr.c
index 4c6a7a3ab6..07071bb68a 100644
--- a/source4/torture/basic/attr.c
+++ b/source4/torture/basic/attr.c
@@ -86,8 +86,8 @@ static const struct trunc_open_results attr_results[] = {
};
-BOOL torture_openattrtest(struct torture_context *tctx,
- struct smbcli_state *cli1)
+bool torture_openattrtest(struct torture_context *tctx,
+ struct smbcli_state *cli1)
{
const char *fname = "\\openattr.file";
int fnum1;
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index bfe1e082f1..1415b4195f 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -29,6 +29,7 @@
#include "librpc/gen_ndr/ndr_nbt.h"
#include "lib/events/events.h"
#include "lib/cmdline/popt_common.h"
+#include "param/param.h"
#define CHECK_MAX_FAILURES(label) do { if (++failures >= torture_failures) goto label; } while (0)
@@ -40,7 +41,7 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
struct smbcli_state *cli;
const char *host = torture_setting_string(tctx, "host", NULL);
- make_nbt_name_client(&calling, lp_netbios_name());
+ make_nbt_name_client(&calling, lp_netbios_name(global_loadparm));
nbt_choose_called_name(NULL, &called, host, NBT_NAME_SERVER);
@@ -67,12 +68,12 @@ failed:
return NULL;
}
-static BOOL tcon_devtest(struct torture_context *tctx,
+static bool tcon_devtest(struct torture_context *tctx,
struct smbcli_state *cli,
const char *myshare, const char *devtype,
NTSTATUS expected_error)
{
- BOOL status;
+ bool status;
const char *password = torture_setting_string(tctx, "password", NULL);
status = NT_STATUS_IS_OK(smbcli_tconX(cli, myshare, devtype,
@@ -157,13 +158,13 @@ static bool run_fdpasstest(struct torture_context *tctx,
/**
This checks how the getatr calls works
*/
-static BOOL run_attrtest(struct torture_context *tctx,
+static bool run_attrtest(struct torture_context *tctx,
struct smbcli_state *cli)
{
int fnum;
time_t t, t2;
const char *fname = "\\attrib123456789.tst";
- BOOL correct = True;
+ bool correct = true;
smbcli_unlink(cli->tree, fname);
fnum = smbcli_open(cli->tree, fname,
@@ -172,7 +173,7 @@ static BOOL run_attrtest(struct torture_context *tctx,
if (NT_STATUS_IS_ERR(smbcli_getatr(cli->tree, fname, NULL, NULL, &t))) {
torture_comment(tctx, "getatr failed (%s)\n", smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
}
torture_comment(tctx, "New file time is %s", ctime(&t));
@@ -181,7 +182,7 @@ static BOOL run_attrtest(struct torture_context *tctx,
torture_comment(tctx, "ERROR: SMBgetatr bug. time is %s",
ctime(&t));
t = time(NULL);
- correct = False;
+ correct = false;
}
t2 = t-60*60*24; /* 1 day ago */
@@ -190,12 +191,12 @@ static BOOL run_attrtest(struct torture_context *tctx,
if (NT_STATUS_IS_ERR(smbcli_setatr(cli->tree, fname, 0, t2))) {
torture_comment(tctx, "setatr failed (%s)\n", smbcli_errstr(cli->tree));
- correct = True;
+ correct = true;
}
if (NT_STATUS_IS_ERR(smbcli_getatr(cli->tree, fname, NULL, NULL, &t))) {
torture_comment(tctx, "getatr failed (%s)\n", smbcli_errstr(cli->tree));
- correct = True;
+ correct = true;
}
torture_comment(tctx, "Retrieved file time as %s", ctime(&t));
@@ -204,7 +205,7 @@ static BOOL run_attrtest(struct torture_context *tctx,
torture_comment(tctx, "ERROR: getatr/setatr bug. times are\n%s",
ctime(&t));
torture_comment(tctx, "%s", ctime(&t2));
- correct = True;
+ correct = true;
}
smbcli_unlink(cli->tree, fname);
@@ -215,7 +216,7 @@ static BOOL run_attrtest(struct torture_context *tctx,
/**
This checks a couple of trans2 calls
*/
-static BOOL run_trans2test(struct torture_context *tctx,
+static bool run_trans2test(struct torture_context *tctx,
struct smbcli_state *cli)
{
int fnum;
@@ -225,7 +226,7 @@ static BOOL run_trans2test(struct torture_context *tctx,
const char *dname = "\\trans2";
const char *fname2 = "\\trans2\\trans2.tst";
const char *pname;
- BOOL correct = True;
+ bool correct = true;
smbcli_unlink(cli->tree, fname);
@@ -236,20 +237,20 @@ static BOOL run_trans2test(struct torture_context *tctx,
if (NT_STATUS_IS_ERR(smbcli_qfileinfo(cli->tree, fnum, NULL, &size, &c_time, &a_time, &m_time,
NULL, NULL))) {
torture_comment(tctx, "ERROR: qfileinfo failed (%s)\n", smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
}
torture_comment(tctx, "Testing NAME_INFO\n");
if (NT_STATUS_IS_ERR(smbcli_qfilename(cli->tree, fnum, &pname))) {
torture_comment(tctx, "ERROR: qfilename failed (%s)\n", smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
}
if (!pname || strcmp(pname, fname)) {
torture_comment(tctx, "qfilename gave different name? [%s] [%s]\n",
fname, pname);
- correct = False;
+ correct = false;
}
smbcli_close(cli->tree, fnum);
@@ -259,7 +260,7 @@ static BOOL run_trans2test(struct torture_context *tctx,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
if (fnum == -1) {
torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
smbcli_close(cli->tree, fnum);
@@ -267,7 +268,7 @@ static BOOL run_trans2test(struct torture_context *tctx,
if (NT_STATUS_IS_ERR(smbcli_qpathinfo(cli->tree, fname, &c_time, &a_time, &m_time, &size, NULL))) {
torture_comment(tctx, "ERROR: qpathinfo failed (%s)\n", smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
} else {
if (c_time != m_time) {
torture_comment(tctx, "create time=%s", ctime(&c_time));
@@ -277,12 +278,12 @@ static BOOL run_trans2test(struct torture_context *tctx,
if (a_time % (60*60) == 0) {
torture_comment(tctx, "access time=%s", ctime(&a_time));
torture_comment(tctx, "This system appears to set a midnight access time\n");
- correct = False;
+ correct = false;
}
if (abs(m_time - time(NULL)) > 60*60*24*7) {
torture_comment(tctx, "ERROR: totally incorrect times - maybe word reversed? mtime=%s", ctime(&m_time));
- correct = False;
+ correct = false;
}
}
@@ -293,12 +294,12 @@ static BOOL run_trans2test(struct torture_context *tctx,
smbcli_close(cli->tree, fnum);
if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, fname, &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) {
torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
} else {
if (w_time < 60*60*24*2) {
torture_comment(tctx, "write time=%s", ctime(&w_time));
torture_comment(tctx, "This system appears to set a initial 0 write time\n");
- correct = False;
+ correct = false;
}
}
@@ -309,12 +310,12 @@ static BOOL run_trans2test(struct torture_context *tctx,
when creating a new file */
if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, dname))) {
torture_comment(tctx, "ERROR: mkdir failed (%s)\n", smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
}
sleep(3);
if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) {
torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
}
fnum = smbcli_open(cli->tree, fname2,
@@ -323,11 +324,11 @@ static BOOL run_trans2test(struct torture_context *tctx,
smbcli_close(cli->tree, fnum);
if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time2, &w_time, &size, NULL, NULL))) {
torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
} else {
if (m_time2 == m_time) {
torture_comment(tctx, "This system does not update directory modification times\n");
- correct = False;
+ correct = false;
}
}
smbcli_unlink(cli->tree, fname2);
@@ -337,17 +338,17 @@ static BOOL run_trans2test(struct torture_context *tctx,
}
/* send smb negprot commands, not reading the response */
-static BOOL run_negprot_nowait(struct torture_context *tctx)
+static bool run_negprot_nowait(struct torture_context *tctx)
{
int i;
struct smbcli_state *cli, *cli2;
- BOOL correct = True;
+ bool correct = true;
torture_comment(tctx, "starting negprot nowait test\n");
cli = open_nbt_connection(tctx);
if (!cli) {
- return False;
+ return false;
}
torture_comment(tctx, "Filling send buffer\n");
@@ -363,7 +364,7 @@ static BOOL run_negprot_nowait(struct torture_context *tctx)
} else {
torture_comment(tctx, "Failed to fill pipe - %s \n", nt_errstr(req->status));
torture_close_connection(cli);
- return False;
+ return false;
}
}
}
@@ -371,12 +372,12 @@ static BOOL run_negprot_nowait(struct torture_context *tctx)
torture_comment(tctx, "Opening secondary connection\n");
if (!torture_open_connection(&cli2, 1)) {
torture_comment(tctx, "Failed to open secondary connection\n");
- correct = False;
+ correct = false;
}
if (!torture_close_connection(cli2)) {
torture_comment(tctx, "Failed to close secondary connection\n");
- correct = False;
+ correct = false;
}
torture_close_connection(cli);
@@ -388,14 +389,14 @@ static BOOL run_negprot_nowait(struct torture_context *tctx)
this checks to see if a secondary tconx can use open files from an
earlier tconx
*/
-static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli)
+static bool run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli)
{
const char *fname = "\\tcontest.tmp";
int fnum1;
uint16_t cnum1, cnum2, cnum3;
uint16_t vuid1, vuid2;
uint8_t buf[4];
- BOOL ret = True;
+ bool ret = true;
struct smbcli_tree *tree1;
const char *host = torture_setting_string(tctx, "host", NULL);
const char *share = torture_setting_string(tctx, "share", NULL);
@@ -408,16 +409,16 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
cnum1 = cli->tree->tid;
vuid1 = cli->session->vuid;
- memset(&buf, 0, 4); /* init buf so valgrind won't complain */
+ memset(buf, 0, 4); /* init buf so valgrind won't complain */
if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) != 4) {
torture_comment(tctx, "initial write failed (%s)\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
tree1 = cli->tree; /* save old tree connection */
@@ -425,7 +426,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli
torture_comment(tctx, "%s refused 2nd tree connect (%s)\n", host,
smbcli_errstr(cli->tree));
talloc_free(cli);
- return False;
+ return false;
}
cnum2 = cli->tree->tid;
@@ -437,7 +438,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli
if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
torture_comment(tctx, "* server allows write with wrong TID\n");
- ret = False;
+ ret = false;
} else {
torture_comment(tctx, "server fails write with wrong TID : %s\n", smbcli_errstr(cli->tree));
}
@@ -448,7 +449,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli
if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
torture_comment(tctx, "* server allows write with invalid TID\n");
- ret = False;
+ ret = false;
} else {
torture_comment(tctx, "server fails write with invalid TID : %s\n", smbcli_errstr(cli->tree));
}
@@ -459,7 +460,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli
if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
torture_comment(tctx, "* server allows write with invalid VUID\n");
- ret = False;
+ ret = false;
} else {
torture_comment(tctx, "server fails write with invalid VUID : %s\n", smbcli_errstr(cli->tree));
}
@@ -469,14 +470,14 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli
if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum1))) {
torture_comment(tctx, "close failed (%s)\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
cli->tree->tid = cnum2;
if (NT_STATUS_IS_ERR(smbcli_tdis(cli))) {
torture_comment(tctx, "secondary tdis failed (%s)\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
cli->tree = tree1; /* restore initial tree */
@@ -490,7 +491,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli
/**
checks for correct tconX support
*/
-static BOOL run_tcon_devtype_test(struct torture_context *tctx,
+static bool run_tcon_devtype_test(struct torture_context *tctx,
struct smbcli_state *cli1)
{
const char *share = torture_setting_string(tctx, "share", NULL);
@@ -528,7 +529,7 @@ static BOOL run_tcon_devtype_test(struct torture_context *tctx,
return true;
}
-static BOOL rw_torture2(struct torture_context *tctx,
+static bool rw_torture2(struct torture_context *tctx,
struct smbcli_state *c1, struct smbcli_state *c2)
{
const char *lockfname = "\\torture2.lck";
@@ -537,7 +538,7 @@ static BOOL rw_torture2(struct torture_context *tctx,
int i;
uint8_t buf[131072];
uint8_t buf_rd[131072];
- BOOL correct = True;
+ bool correct = true;
ssize_t bytes_read, bytes_written;
torture_assert(tctx, smbcli_deltree(c1->tree, lockfname) != -1,
@@ -574,14 +575,14 @@ static BOOL rw_torture2(struct torture_context *tctx,
if ((bytes_written = smbcli_write(c1->tree, fnum1, 0, buf, 0, buf_size)) != buf_size) {
torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c1->tree));
torture_comment(tctx, "wrote %d, expected %d\n", (int)bytes_written, (int)buf_size);
- correct = False;
+ correct = false;
break;
}
if ((bytes_read = smbcli_read(c2->tree, fnum2, buf_rd, 0, buf_size)) != buf_size) {
torture_comment(tctx, "read failed (%s)\n", smbcli_errstr(c2->tree));
torture_comment(tctx, "read %d, expected %d\n", (int)bytes_read, (int)buf_size);
- correct = False;
+ correct = false;
break;
}
@@ -623,16 +624,16 @@ static bool run_readwritetest(struct torture_context *tctx,
/*
test the timing of deferred open requests
*/
-static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli, int dummy)
+static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli, int dummy)
{
const char *fname = "\\defer_open_test.dat";
int retries=4;
int i = 0;
- BOOL correct = True;
+ bool correct = true;
if (retries <= 0) {
torture_comment(tctx, "failed to connect\n");
- return False;
+ return false;
}
torture_comment(tctx, "Testing deferred open requests.\n");
@@ -662,7 +663,7 @@ static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
if (fnum == -1) {
torture_comment(tctx,"Failed to open %s, error=%s\n", fname, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
torture_comment(tctx, "pid %u open %d\n", (unsigned)getpid(), i);
@@ -671,7 +672,7 @@ static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
i++;
if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
torture_comment(tctx,"Failed to close %s, error=%s\n", fname, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
sleep(2);
}
@@ -680,7 +681,7 @@ static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
/* All until the last unlink will fail with sharing violation. */
if (!NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) {
torture_comment(tctx, "unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
}
}
@@ -692,7 +693,7 @@ static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
Try with a wrong vuid and check error message.
*/
-static BOOL run_vuidtest(struct torture_context *tctx,
+static bool run_vuidtest(struct torture_context *tctx,
struct smbcli_state *cli)
{
const char *fname = "\\vuid.tst";
@@ -743,7 +744,7 @@ static BOOL run_vuidtest(struct torture_context *tctx,
/*
Test open mode returns on read-only files.
*/
- static BOOL run_opentest(struct torture_context *tctx, struct smbcli_state *cli1,
+ static bool run_opentest(struct torture_context *tctx, struct smbcli_state *cli1,
struct smbcli_state *cli2)
{
const char *fname = "\\readonly.file";
@@ -751,7 +752,7 @@ static BOOL run_vuidtest(struct torture_context *tctx,
int fnum1, fnum2;
uint8_t buf[20];
size_t fsize;
- BOOL correct = True;
+ bool correct = true;
char *tmp_path;
int failures = 0;
int i;
@@ -786,25 +787,25 @@ static BOOL run_vuidtest(struct torture_context *tctx,
fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "close2 failed (%s)\n", smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_setatr(cli1->tree, fname, FILE_ATTRIBUTE_READONLY, 0))) {
torture_comment(tctx, "smbcli_setatr failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test1);
- return False;
+ return false;
}
fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE);
if (fnum1 == -1) {
torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test1);
- return False;
+ return false;
}
/* This will fail - but the error should be ERRnoaccess, not ERRbadshare. */
@@ -826,7 +827,7 @@ error_test1:
fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE);
if (fnum1 == -1) {
torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
/* This will fail - but the error should be ERRshare. */
@@ -839,7 +840,7 @@ error_test1:
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "close2 failed (%s)\n", smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
smbcli_unlink(cli1->tree, fname);
@@ -851,7 +852,7 @@ error_test1:
fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
torture_comment(tctx, "(3) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
/* write 20 bytes. */
@@ -860,25 +861,25 @@ error_test1:
if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) {
torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(cli1->tree));
- correct = False;
+ correct = false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "(3) close1 failed (%s)\n", smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
/* Ensure size == 20. */
if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
torture_comment(tctx, "(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test3);
- return False;
+ return false;
}
if (fsize != 20) {
torture_comment(tctx, "(3) file size != 20\n");
CHECK_MAX_FAILURES(error_test3);
- return False;
+ return false;
}
/* Now test if we can truncate a file opened for readonly. */
@@ -887,25 +888,25 @@ error_test1:
if (fnum1 == -1) {
torture_comment(tctx, "(3) open (2) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test3);
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "close2 failed (%s)\n", smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
/* Ensure size == 0. */
if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
torture_comment(tctx, "(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test3);
- return False;
+ return false;
}
if (fsize != 0) {
torture_comment(tctx, "(3) file size != 0\n");
CHECK_MAX_FAILURES(error_test3);
- return False;
+ return false;
}
torture_comment(tctx, "finished open test 3\n");
error_test3:
@@ -917,7 +918,7 @@ error_test3:
if (fnum1 == -1) {
torture_comment(tctx, "ctemp failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test4);
- return False;
+ return false;
}
torture_comment(tctx, "ctemp gave path %s\n", tmp_path);
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
@@ -940,7 +941,7 @@ error_test4:
if (fnum1 == -1) {
torture_comment(tctx, "test 1 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test10);
- return False;
+ return false;
}
fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL,
@@ -948,16 +949,16 @@ error_test4:
if (fnum2 == -1) {
torture_comment(tctx, "test 1 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test10);
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
torture_comment(tctx, "test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
- return False;
+ return false;
}
torture_comment(tctx, "non-io open test #1 passed.\n");
@@ -972,7 +973,7 @@ error_test10:
if (fnum1 == -1) {
torture_comment(tctx, "test 2 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test20);
- return False;
+ return false;
}
fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL,
@@ -981,16 +982,16 @@ error_test10:
if (fnum2 == -1) {
torture_comment(tctx, "test 2 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test20);
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
torture_comment(tctx, "test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
torture_comment(tctx, "non-io open test #2 passed.\n");
@@ -1005,7 +1006,7 @@ error_test20:
if (fnum1 == -1) {
torture_comment(tctx, "test 3 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test30);
- return False;
+ return false;
}
fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL,
@@ -1014,16 +1015,16 @@ error_test20:
if (fnum2 == -1) {
torture_comment(tctx, "test 3 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test30);
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "test 3 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
torture_comment(tctx, "test 3 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
- return False;
+ return false;
}
torture_comment(tctx, "non-io open test #3 passed.\n");
@@ -1038,7 +1039,7 @@ error_test30:
if (fnum1 == -1) {
torture_comment(tctx, "test 4 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test40);
- return False;
+ return false;
}
fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL,
@@ -1047,14 +1048,14 @@ error_test30:
if (fnum2 != -1) {
torture_comment(tctx, "test 4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test40);
- return False;
+ return false;
}
torture_comment(tctx, "test 4 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation");
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "test 4 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
torture_comment(tctx, "non-io open test #4 passed.\n");
@@ -1069,7 +1070,7 @@ error_test40:
if (fnum1 == -1) {
torture_comment(tctx, "test 5 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test50);
- return False;
+ return false;
}
fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL,
@@ -1078,17 +1079,17 @@ error_test40:
if (fnum2 == -1) {
torture_comment(tctx, "test 5 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test50);
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "test 5 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
torture_comment(tctx, "test 5 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
- return False;
+ return false;
}
torture_comment(tctx, "non-io open test #5 passed.\n");
@@ -1103,7 +1104,7 @@ error_test50:
if (fnum1 == -1) {
torture_comment(tctx, "test 6 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test60);
- return False;
+ return false;
}
fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL,
@@ -1112,17 +1113,17 @@ error_test50:
if (fnum2 == -1) {
torture_comment(tctx, "test 6 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test60);
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "test 6 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
torture_comment(tctx, "test 6 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree));
- return False;
+ return false;
}
torture_comment(tctx, "non-io open test #6 passed.\n");
@@ -1137,7 +1138,7 @@ error_test60:
if (fnum1 == -1) {
torture_comment(tctx, "test 7 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test70);
- return False;
+ return false;
}
fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL,
@@ -1146,14 +1147,14 @@ error_test60:
if (fnum2 != -1) {
torture_comment(tctx, "test 7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test70);
- return False;
+ return false;
}
torture_comment(tctx, "test 7 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation");
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "test 7 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
torture_comment(tctx, "non-io open test #7 passed.\n");
@@ -1167,7 +1168,7 @@ error_test70:
fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
torture_comment(tctx, "(8) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
/* write 20 bytes. */
@@ -1176,56 +1177,56 @@ error_test70:
if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) {
torture_comment(tctx, "(8) write failed (%s)\n", smbcli_errstr(cli1->tree));
- correct = False;
+ correct = false;
}
/* Ensure size == 20. */
if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
torture_comment(tctx, "(8) getatr (1) failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test80);
- return False;
+ return false;
}
if (fsize != 20) {
torture_comment(tctx, "(8) file size != 20\n");
CHECK_MAX_FAILURES(error_test80);
- return False;
+ return false;
}
/* Get an exclusive lock on the open file. */
if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
torture_comment(tctx, "(8) lock1 failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test80);
- return False;
+ return false;
}
fnum2 = smbcli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE);
if (fnum1 == -1) {
torture_comment(tctx, "(8) open (2) of %s with truncate failed (%s)\n", fname, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
/* Ensure size == 0. */
if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
torture_comment(tctx, "(8) getatr (2) failed (%s)\n", smbcli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test80);
- return False;
+ return false;
}
if (fsize != 0) {
torture_comment(tctx, "(8) file size != 0\n");
CHECK_MAX_FAILURES(error_test80);
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
torture_comment(tctx, "(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) {
torture_comment(tctx, "(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
error_test80:
@@ -1314,7 +1315,7 @@ static bool run_iometer(struct torture_context *tctx,
ops = 0;
- while (True) {
+ while (true) {
int i, num_reads, num_writes;
num_reads = random() % 10;
@@ -1350,11 +1351,11 @@ static bool run_iometer(struct torture_context *tctx,
/**
tries variants of chkpath
*/
-static BOOL torture_chkpath_test(struct torture_context *tctx,
+static bool torture_chkpath_test(struct torture_context *tctx,
struct smbcli_state *cli)
{
int fnum;
- BOOL ret;
+ bool ret;
torture_comment(tctx, "Testing valid and invalid paths\n");
@@ -1365,29 +1366,29 @@ static BOOL torture_chkpath_test(struct torture_context *tctx,
if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\chkpath.dir"))) {
torture_comment(tctx, "mkdir1 failed : %s\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\chkpath.dir\\dir2"))) {
torture_comment(tctx, "mkdir2 failed : %s\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
fnum = smbcli_open(cli->tree, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
torture_comment(tctx, "open1 failed (%s)\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
smbcli_close(cli->tree, fnum);
if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir"))) {
torture_comment(tctx, "chkpath1 failed: %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
}
if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\dir2"))) {
torture_comment(tctx, "chkpath2 failed: %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
}
if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\foo.txt"))) {
@@ -1395,7 +1396,7 @@ static BOOL torture_chkpath_test(struct torture_context *tctx,
NT_STATUS_NOT_A_DIRECTORY);
} else {
torture_comment(tctx, "* chkpath on a file should fail\n");
- ret = False;
+ ret = false;
}
if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\bar.txt"))) {
@@ -1403,7 +1404,7 @@ static BOOL torture_chkpath_test(struct torture_context *tctx,
NT_STATUS_OBJECT_NAME_NOT_FOUND);
} else {
torture_comment(tctx, "* chkpath on a non existent file should fail\n");
- ret = False;
+ ret = false;
}
if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\dirxx\\bar.txt"))) {
@@ -1411,7 +1412,7 @@ static BOOL torture_chkpath_test(struct torture_context *tctx,
NT_STATUS_OBJECT_PATH_NOT_FOUND);
} else {
torture_comment(tctx, "* chkpath on a non existent component should fail\n");
- ret = False;
+ ret = false;
}
smbcli_rmdir(cli->tree, "\\chkpath.dir\\dir2");
@@ -1425,11 +1426,11 @@ static BOOL torture_chkpath_test(struct torture_context *tctx,
* This is a test to excercise some weird Samba3 error paths.
*/
-static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
+static bool torture_samba3_errorpaths(struct torture_context *tctx)
{
- BOOL nt_status_support;
+ bool nt_status_support;
struct smbcli_state *cli_nt = NULL, *cli_dos = NULL;
- BOOL result = False;
+ bool result = false;
int fnum;
const char *os2_fname = ".+,;=[].";
const char *dname = "samba3_errordir";
@@ -1439,12 +1440,12 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
if (mem_ctx == NULL) {
torture_comment(tctx, "talloc_init failed\n");
- return False;
+ return false;
}
- nt_status_support = lp_nt_status_support();
+ nt_status_support = lp_nt_status_support(global_loadparm);
- if (!lp_set_cmdline("nt status support", "yes")) {
+ if (!lp_set_cmdline(global_loadparm, "nt status support", "yes")) {
torture_comment(tctx, "Could not set 'nt status support = yes'\n");
goto fail;
}
@@ -1453,7 +1454,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
goto fail;
}
- if (!lp_set_cmdline("nt status support", "no")) {
+ if (!lp_set_cmdline(global_loadparm, "nt status support", "no")) {
torture_comment(tctx, "Could not set 'nt status support = yes'\n");
goto fail;
}
@@ -1462,7 +1463,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
goto fail;
}
- if (!lp_set_cmdline("nt status support",
+ if (!lp_set_cmdline(global_loadparm, "nt status support",
nt_status_support ? "yes":"no")) {
torture_comment(tctx, "Could not reset 'nt status support = yes'");
goto fail;
@@ -1633,7 +1634,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
torture_comment(tctx, "ntcreate as dir gave %s, "
"expected NT_STATUS_NOT_A_DIRECTORY\n",
nt_errstr(status));
- result = False;
+ result = false;
}
if (NT_STATUS_IS_OK(status)) {
@@ -1646,7 +1647,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
torture_comment(tctx, "ntcreate as dir gave %s, "
"expected NT_STATUS_NOT_A_DIRECTORY\n",
nt_errstr(status));
- result = False;
+ result = false;
}
if (NT_STATUS_IS_OK(status)) {
@@ -1657,7 +1658,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
smbcli_unlink(cli_nt->tree, fname);
}
- if (!torture_setting_bool(tctx, "samba3", False)) {
+ if (!torture_setting_bool(tctx, "samba3", false)) {
goto done;
}
@@ -1696,7 +1697,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
}
done:
- result = True;
+ result = true;
fail:
if (cli_dos != NULL) {
@@ -1712,11 +1713,10 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
NTSTATUS torture_base_init(void)
{
- struct torture_suite *suite = torture_suite_create(
- talloc_autofree_context(), "BASE");
+ struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "BASE");
torture_suite_add_2smb_test(suite, "FDPASS", run_fdpasstest);
- torture_suite_add_suite(suite, torture_base_locktest());
+ torture_suite_add_suite(suite, torture_base_locktest(suite));
torture_suite_add_1smb_test(suite, "UNLINK", torture_unlinktest);
torture_suite_add_1smb_test(suite, "ATTR", run_attrtest);
torture_suite_add_1smb_test(suite, "TRANS2", run_trans2test);
@@ -1742,17 +1742,16 @@ NTSTATUS torture_base_init(void)
torture_suite_add_1smb_test(suite, "PROPERTIES", torture_test_properties);
torture_suite_add_1smb_test(suite, "MANGLE", torture_mangle);
torture_suite_add_1smb_test(suite, "OPENATTR", torture_openattrtest);
- torture_suite_add_1smb_test(suite, "CHARSET", torture_charset);
+ torture_suite_add_suite(suite, torture_charset(suite));
torture_suite_add_1smb_test(suite, "CHKPATH", torture_chkpath_test);
torture_suite_add_1smb_test(suite, "SECLEAK", torture_sec_leak);
torture_suite_add_simple_test(suite, "DISCONNECT", torture_disconnect);
torture_suite_add_suite(suite, torture_delay_write());
- torture_suite_add_simple_test(suite, "SAMBA3ERROR",
- torture_samba3_errorpaths);
+ torture_suite_add_simple_test(suite, "SAMBA3ERROR", torture_samba3_errorpaths);
torture_suite_add_1smb_test(suite, "CASETABLE", torture_casetable);
torture_suite_add_1smb_test(suite, "UTABLE", torture_utable);
torture_suite_add_simple_test(suite, "SMB", torture_smb_scan);
- torture_suite_add_suite(suite, torture_trans2_aliases());
+ torture_suite_add_suite(suite, torture_trans2_aliases(suite));
torture_suite_add_1smb_test(suite, "TRANS2-SCAN", torture_trans2_scan);
torture_suite_add_1smb_test(suite, "NTTRANS", torture_nttrans_scan);
diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c
index 3fa094e05c..b1e3b96c2b 100644
--- a/source4/torture/basic/charset.c
+++ b/source4/torture/basic/charset.c
@@ -33,7 +33,7 @@
the prefix BASEDIR is added before the name
*/
static NTSTATUS unicode_open(struct torture_context *tctx,
- struct smbcli_tree *tree,
+ struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
uint32_t open_disposition,
const uint32_t *u_name,
@@ -82,7 +82,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx,
io.ntcreatex.in.fname = fname2;
io.ntcreatex.in.open_disposition = open_disposition;
- status = smb_raw_open(tree, mem_ctx, &io);
+ status = smb_raw_open(tree, tctx, &io);
talloc_free(ucs_name);
@@ -93,172 +93,118 @@ static NTSTATUS unicode_open(struct torture_context *tctx,
/*
see if the server recognises composed characters
*/
-static BOOL test_composed(struct torture_context *tctx,
- struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_composed(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
const uint32_t name1[] = {0x61, 0x308};
const uint32_t name2[] = {0xe4};
NTSTATUS status1, status2;
- printf("Testing composite character (a umlaut)\n");
-
- status1 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 2);
- if (!NT_STATUS_IS_OK(status1)) {
- printf("Failed to create composed name - %s\n",
- nt_errstr(status1));
- return False;
- }
+ torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+ "setting up basedir");
- status2 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
+ status1 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 2);
+ torture_assert_ntstatus_ok(tctx, status1, "Failed to create composed name");
- if (!NT_STATUS_IS_OK(status2)) {
- printf("Failed to create accented character - %s\n",
- nt_errstr(status2));
- return False;
- }
+ status2 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 1);
+
+ torture_assert_ntstatus_ok(tctx, status2, "Failed to create accented character");
- return True;
+ return true;
}
/*
see if the server recognises a naked diacritical
*/
-static BOOL test_diacritical(struct torture_context *tctx,
- struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_diacritical(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
const uint32_t name1[] = {0x308};
const uint32_t name2[] = {0x308, 0x308};
NTSTATUS status1, status2;
- printf("Testing naked diacritical (umlaut)\n");
-
- status1 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
+ torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+ "setting up basedir");
- if (!NT_STATUS_IS_OK(status1)) {
- printf("Failed to create naked diacritical - %s\n",
- nt_errstr(status1));
- return False;
- }
+ status1 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 1);
+
+ torture_assert_ntstatus_ok(tctx, status1, "Failed to create naked diacritical");
/* try a double diacritical */
- status2 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 2);
+ status2 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 2);
- if (!NT_STATUS_IS_OK(status2)) {
- printf("Failed to create double naked diacritical - %s\n",
- nt_errstr(status2));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status2, "Failed to create double naked diacritical");
- return True;
+ return true;
}
/*
see if the server recognises a partial surrogate pair
*/
-static BOOL test_surrogate(struct torture_context *tctx,
- struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_surrogate(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
const uint32_t name1[] = {0xd800};
const uint32_t name2[] = {0xdc00};
const uint32_t name3[] = {0xd800, 0xdc00};
NTSTATUS status;
- printf("Testing partial surrogate\n");
+ torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+ "setting up basedir");
- status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
+ status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to create partial surrogate 1 - %s\n",
- nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create partial surrogate 1");
- status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
+ status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to create partial surrogate 2 - %s\n",
- nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create partial surrogate 2");
- status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 2);
+ status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name3, 2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to create full surrogate - %s\n",
- nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create full surrogate");
- return True;
+ return true;
}
/*
see if the server recognises wide-a characters
*/
-static BOOL test_widea(struct torture_context *tctx,
- struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_widea(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
const uint32_t name1[] = {'a'};
const uint32_t name2[] = {0xff41};
const uint32_t name3[] = {0xff21};
NTSTATUS status;
- printf("Testing wide-a\n");
-
- status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
+ torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+ "setting up basedir");
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to create 'a' - %s\n",
- nt_errstr(status));
- return False;
- }
+ status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 1);
- status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create 'a'");
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to create wide-a - %s\n",
- nt_errstr(status));
- return False;
- }
+ status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 1);
- status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 1);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create wide-a");
- if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
- printf("Expected %s creating wide-A - %s\n",
- nt_errstr(NT_STATUS_OBJECT_NAME_COLLISION),
- nt_errstr(status));
- return False;
- }
+ status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name3, 1);
- return True;
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OBJECT_NAME_COLLISION,
+ "Failed to create wide-A");
+
+ return true;
}
-BOOL torture_charset(struct torture_context *tctx, struct smbcli_state *cli)
+struct torture_suite *torture_charset(TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
- TALLOC_CTX *mem_ctx;
-
- mem_ctx = talloc_init("torture_charset");
-
- if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
- }
-
- if (!test_composed(tctx, cli, mem_ctx)) {
- ret = False;
- }
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "CHARSET");
- if (!test_diacritical(tctx, cli, mem_ctx)) {
- ret = False;
- }
-
- if (!test_surrogate(tctx, cli, mem_ctx)) {
- ret = False;
- }
-
- if (!test_widea(tctx, cli, mem_ctx)) {
- ret = False;
- }
+ torture_suite_add_1smb_test(suite, "Testing composite character (a umlaut)", test_composed);
+ torture_suite_add_1smb_test(suite, "Testing naked diacritical (umlaut)", test_diacritical);
+ torture_suite_add_1smb_test(suite, "Testing partial surrogate", test_surrogate);
+ torture_suite_add_1smb_test(suite, "Testing wide-a", test_widea);
- return ret;
+ return suite;
}
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index 289e08ae59..8928754e1a 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -31,24 +31,24 @@
#define BASEDIR "\\delaywrite"
-static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcli_state *cli)
+static bool test_delayed_write_update(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_fileinfo finfo1, finfo2;
const char *fname = BASEDIR "\\torture_file.txt";
NTSTATUS status;
int fnum1 = -1;
- BOOL ret = True;
+ bool ret = true;
ssize_t written;
time_t t;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
torture_comment(tctx, "Failed to open %s\n", fname);
- return False;
+ return false;
}
finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
@@ -59,7 +59,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
torture_comment(tctx, "Initial write time %s\n",
@@ -74,7 +74,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl
if (written != 1) {
torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
(int)written, __location__);
- return False;
+ return false;
}
t = time(NULL);
@@ -84,7 +84,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- ret = False;
+ ret = false;
break;
}
torture_comment(tctx, "write time %s\n",
@@ -100,7 +100,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
torture_comment(tctx, "Server did not update write time?!\n");
- ret = False;
+ ret = false;
}
@@ -116,7 +116,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl
* Do as above, but using 2 connections.
*/
-static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbcli_state *cli,
+static bool test_delayed_write_update2(struct torture_context *tctx, struct smbcli_state *cli,
struct smbcli_state *cli2)
{
union smb_fileinfo finfo1, finfo2;
@@ -124,19 +124,19 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
NTSTATUS status;
int fnum1 = -1;
int fnum2 = -1;
- BOOL ret = True;
+ bool ret = true;
ssize_t written;
time_t t;
union smb_flush flsh;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
torture_comment(tctx, "Failed to open %s\n", fname);
- return False;
+ return false;
}
finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
@@ -147,7 +147,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
torture_comment(tctx, "Initial write time %s\n",
@@ -180,7 +180,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("sfileinfo failed: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
}
@@ -193,7 +193,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- ret = False;
+ ret = false;
break;
}
torture_comment(tctx, "write time %s\n",
@@ -209,7 +209,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
torture_comment(tctx, "Server did not update write time?!\n");
- ret = False;
+ ret = false;
}
/* Now try a write to see if the write time gets reset. */
@@ -222,7 +222,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
torture_comment(tctx, "Modified write time %s\n",
@@ -236,7 +236,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (written != 10) {
torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
(int)written, __location__);
- return False;
+ return false;
}
/* Just to prove to tridge that the an smbflush has no effect on
@@ -249,7 +249,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
status = smb_raw_flush(cli->tree, &flsh);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("smbflush failed: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
t = time(NULL);
@@ -262,7 +262,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- ret = False;
+ ret = false;
break;
}
torture_comment(tctx, "write time %s\n",
@@ -283,7 +283,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
torture_comment(tctx, "Failed to open %s\n", fname);
- return False;
+ return false;
}
torture_comment(tctx, "Doing a 10 byte write to extend the file via second fd and see if this changes the last write time.\n");
@@ -293,14 +293,14 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (written != 10) {
torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
(int)written, __location__);
- return False;
+ return false;
}
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
@@ -319,7 +319,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (written != 10) {
torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
(int)written, __location__);
- return False;
+ return false;
}
finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
@@ -329,7 +329,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
@@ -347,7 +347,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- ret = False;
+ ret = false;
break;
}
torture_comment(tctx, "write time %s\n",
@@ -373,7 +373,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
fnum1 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum1 == -1) {
torture_comment(tctx, "Failed to open %s\n", fname);
- return False;
+ return false;
}
finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
@@ -384,7 +384,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
torture_comment(tctx, "Second open initial write time %s\n",
@@ -398,7 +398,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (written != 10) {
torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
(int)written, __location__);
- return False;
+ return false;
}
finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
@@ -408,7 +408,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return False;
+ return false;
}
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
@@ -426,7 +426,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- ret = False;
+ ret = false;
break;
}
torture_comment(tctx, "write time %s\n",
@@ -468,7 +468,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc
* nasty....
*/
-static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_state *cli,
+static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_state *cli,
struct smbcli_state *cli2)
{
union smb_fileinfo finfo1, finfo2;
@@ -476,16 +476,16 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
NTSTATUS status;
int fnum1 = -1;
int fnum2;
- BOOL ret = True;
+ bool ret = true;
ssize_t written;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
- ret = False;
+ ret = false;
torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname);
goto done;
}
@@ -496,7 +496,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status));
goto done;
}
@@ -507,7 +507,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
if (written != 1) {
torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1", (int)written);
- ret = False;
+ ret = false;
goto done;
}
@@ -515,7 +515,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
if (fnum2 == -1) {
torture_result(tctx, TORTURE_FAIL, __location__": failed to open 2nd time - %s",
smbcli_errstr(cli2->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -524,7 +524,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
if (written != 1) {
torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1",
(int)written);
- ret = False;
+ ret = false;
goto done;
}
@@ -536,21 +536,21 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
if (!NT_STATUS_IS_OK(status)) {
torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s",
nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
if (finfo1.basic_info.out.create_time !=
finfo2.basic_info.out.create_time) {
torture_result(tctx, TORTURE_FAIL, __location__": create_time changed");
- ret = False;
+ ret = false;
goto done;
}
if (finfo1.basic_info.out.access_time !=
finfo2.basic_info.out.access_time) {
torture_result(tctx, TORTURE_FAIL, __location__": access_time changed");
- ret = False;
+ ret = false;
goto done;
}
@@ -560,14 +560,14 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
"write time conn 1 = %s, conn 2 = %s",
nt_time_string(tctx, finfo1.basic_info.out.write_time),
nt_time_string(tctx, finfo2.basic_info.out.write_time));
- ret = False;
+ ret = false;
goto done;
}
if (finfo1.basic_info.out.change_time !=
finfo2.basic_info.out.change_time) {
torture_result(tctx, TORTURE_FAIL, __location__": change_time changed");
- ret = False;
+ ret = false;
goto done;
}
@@ -587,7 +587,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
if (!NT_STATUS_IS_OK(status)) {
torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c
index 93b282272f..38528cd845 100644
--- a/source4/torture/basic/delete.c
+++ b/source4/torture/basic/delete.c
@@ -144,7 +144,7 @@ static bool deltest1(struct torture_context *tctx, struct smbcli_state *cli1, st
torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)",
fname));
- return True;
+ return true;
}
/* Test 2 - this should delete the file on close. */
@@ -163,7 +163,7 @@ static bool deltest2(struct torture_context *tctx, struct smbcli_state *cli1, st
talloc_asprintf(tctx, "open of %s failed (%s)",
fname, smbcli_errstr(cli1->tree)));
- torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True),
+ torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
talloc_asprintf(tctx, "setting delete_on_close failed (%s)",
smbcli_errstr(cli1->tree)));
@@ -178,7 +178,7 @@ static bool deltest2(struct torture_context *tctx, struct smbcli_state *cli1, st
if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
printf("(%s) close failed (%s)\n",
__location__, smbcli_errstr(cli1->tree));
- return False;
+ return false;
}
smbcli_unlink(cli1->tree, fname);
}
@@ -227,7 +227,7 @@ static bool deltest3(struct torture_context *tctx, struct smbcli_state *cli1, st
fname, smbcli_errstr(cli1->tree)));
torture_assert_ntstatus_ok(tctx,
- smbcli_nt_delete_on_close(cli1->tree, fnum1, True),
+ smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
talloc_asprintf(tctx, "setting delete_on_close failed (%s)",
smbcli_errstr(cli1->tree)));
@@ -250,9 +250,9 @@ static bool deltest3(struct torture_context *tctx, struct smbcli_state *cli1, st
__location__, smbcli_errstr(cli1->tree));
}
smbcli_unlink(cli1->tree, fname);
- return False;
+ return false;
}
- return True;
+ return true;
}
/* Test 4 ... */
@@ -260,7 +260,7 @@ static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, st
{
int fnum1 = -1;
int fnum2 = -1;
- bool correct = True;
+ bool correct = true;
del_clean_area(cli1, cli2);
@@ -292,7 +292,7 @@ static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, st
smbcli_errstr(cli1->tree)));
torture_assert_ntstatus_ok(tctx,
- smbcli_nt_delete_on_close(cli1->tree, fnum1, True),
+ smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
talloc_asprintf(tctx, "setting delete_on_close failed (%s)",
smbcli_errstr(cli1->tree)));
@@ -328,13 +328,13 @@ static bool deltest5(struct torture_context *tctx, struct smbcli_state *cli1, st
/* This should fail - only allowed on NT opens with DELETE access. */
- torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)),
+ torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, true)),
"setting delete_on_close on OpenX file succeeded - should fail !");
torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree)));
- return True;
+ return true;
}
/* Test 6 ... */
@@ -358,7 +358,7 @@ static bool deltest6(struct torture_context *tctx, struct smbcli_state *cli1, st
/* This should fail - only allowed on NT opens with DELETE access. */
torture_assert(tctx,
- !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)),
+ !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, true)),
"setting delete_on_close on file with no delete access succeeded - should fail !");
torture_assert_ntstatus_ok(tctx,
@@ -366,14 +366,14 @@ static bool deltest6(struct torture_context *tctx, struct smbcli_state *cli1, st
talloc_asprintf(tctx, "close - 2 failed (%s)",
smbcli_errstr(cli1->tree)));
- return True;
+ return true;
}
/* Test 7 ... */
static bool deltest7(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
{
int fnum1 = -1;
- bool correct = True;
+ bool correct = true;
del_clean_area(cli1, cli2);
@@ -387,16 +387,16 @@ static bool deltest7(struct torture_context *tctx, struct smbcli_state *cli1, st
torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)",
fname, smbcli_errstr(cli1->tree)));
- torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True),
+ torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
"setting delete_on_close on file failed !");
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__);
torture_assert_ntstatus_ok(tctx,
- smbcli_nt_delete_on_close(cli1->tree, fnum1, False),
+ smbcli_nt_delete_on_close(cli1->tree, fnum1, false),
"unsetting delete_on_close on file failed !");
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree)));
@@ -419,7 +419,7 @@ static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, st
{
int fnum1 = -1;
int fnum2 = -1;
- bool correct = True;
+ bool correct = true;
del_clean_area(cli1, cli2);
@@ -447,18 +447,18 @@ static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, st
fname, smbcli_errstr(cli1->tree)));
torture_assert_ntstatus_ok(tctx,
- smbcli_nt_delete_on_close(cli1->tree, fnum1, True),
+ smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
"setting delete_on_close on file failed !");
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__);
torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
talloc_asprintf(tctx, "close - 1 failed (%s)",
smbcli_errstr(cli1->tree)));
- correct &= check_delete_on_close(tctx, cli1, -1, fname, True, __location__);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__);
+ correct &= check_delete_on_close(tctx, cli1, -1, fname, true, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__);
torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2),
talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli2->tree)));
@@ -490,7 +490,7 @@ static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, st
talloc_asprintf(tctx, "open of %s succeeded should have failed!",
fname));
- return True;
+ return true;
}
/* Test 10 ... */
@@ -544,7 +544,7 @@ static bool deltest11(struct torture_context *tctx, struct smbcli_state *cli1, s
torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)",
fname, smbcli_errstr(cli1->tree)));
- status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True);
+ status = smbcli_nt_delete_on_close(cli1->tree, fnum1, true);
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_CANNOT_DELETE,
talloc_asprintf(tctx, "setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)", smbcli_errstr(cli1->tree)));
@@ -553,7 +553,7 @@ static bool deltest11(struct torture_context *tctx, struct smbcli_state *cli1, s
talloc_asprintf(tctx, "close failed (%s)",
smbcli_errstr(cli1->tree)));
- return True;
+ return true;
}
/* Test 12 ... */
@@ -593,7 +593,7 @@ static bool deltest13(struct torture_context *tctx, struct smbcli_state *cli1, s
{
int fnum1 = -1;
int fnum2 = -1;
- bool correct = True;
+ bool correct = true;
del_clean_area(cli1, cli2);
@@ -631,18 +631,18 @@ static bool deltest13(struct torture_context *tctx, struct smbcli_state *cli1, s
torture_assert_ntstatus_ok(tctx,
smbcli_nt_delete_on_close(cli1->tree, fnum1,
- True),
+ true),
"setting delete_on_close on file failed !");
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__);
torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli2->tree, fnum2,
- False),
+ false),
"setting delete_on_close on file failed !");
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
talloc_asprintf(tctx, "close - 1 failed (%s)",
@@ -684,10 +684,10 @@ static bool deltest14(struct torture_context *tctx, struct smbcli_state *cli1, s
torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!",
dname, smbcli_errstr(cli1->tree)));
- correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__);
- torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, True),
+ correct &= check_delete_on_close(tctx, cli1, dnum1, dname, false, __location__);
+ torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, true),
"setting delete_on_close on file failed !");
- correct &= check_delete_on_close(tctx, cli1, dnum1, dname, True, __location__);
+ correct &= check_delete_on_close(tctx, cli1, dnum1, dname, true, __location__);
smbcli_close(cli1->tree, dnum1);
/* Now it should be gone... */
@@ -751,7 +751,7 @@ static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, s
talloc_asprintf(tctx, "open - 1 of %s failed (%s)",
fname_new, smbcli_errstr(cli1->tree)));
- status = smbcli_nt_delete_on_close(cli2->tree, fnum2, True);
+ status = smbcli_nt_delete_on_close(cli2->tree, fnum2, true);
torture_assert_ntstatus_ok(tctx, status,
"setting delete_on_close on file failed !");
@@ -761,7 +761,7 @@ static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, s
/* The file should be around under the new name, there's a second
* handle open */
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname_new, True, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname_new, true, __location__);
fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0,
SEC_GENERIC_ALL,
@@ -775,7 +775,7 @@ static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, s
torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)",
fname, smbcli_errstr(cli1->tree)));
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
smbcli_close(cli2->tree, fnum2);
smbcli_close(cli1->tree, fnum1);
@@ -840,11 +840,11 @@ static bool deltest16(struct torture_context *tctx, struct smbcli_state *cli1, s
torture_assert (tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree)));
/* The delete on close bit is *not* reported as being set. */
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
/* The delete on close bit is *not* reported as being set. */
- correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__);
- correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, -1, fname, false, __location__);
+ correct &= check_delete_on_close(tctx, cli2, -1, fname, false, __location__);
/* Now try opening again for read-only. */
fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0,
@@ -860,15 +860,15 @@ static bool deltest16(struct torture_context *tctx, struct smbcli_state *cli1, s
torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)",
fname, smbcli_errstr(cli1->tree)));
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
- correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
- correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+ correct &= check_delete_on_close(tctx, cli1, -1, fname, false, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
+ correct &= check_delete_on_close(tctx, cli2, -1, fname, false, __location__);
smbcli_close(cli1->tree, fnum1);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__);
- correct &= check_delete_on_close(tctx, cli2, -1, fname, True, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__);
+ correct &= check_delete_on_close(tctx, cli2, -1, fname, true, __location__);
smbcli_close(cli2->tree, fnum2);
@@ -885,7 +885,7 @@ static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, s
{
int fnum1 = -1;
int fnum2 = -1;
- bool correct = True;
+ bool correct = true;
del_clean_area(cli1, cli2);
@@ -926,7 +926,7 @@ static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, s
fname, smbcli_errstr(cli1->tree)));
/* The delete on close bit is *not* reported as being set. */
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
/* Now try opening again for read-only. */
fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0,
@@ -944,12 +944,12 @@ static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, s
fname, smbcli_errstr(cli1->tree)));
/* still not reported as being set on either */
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
- correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum2, fname, false, __location__);
smbcli_close(cli1->tree, fnum1);
- correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum2, fname, false, __location__);
smbcli_close(cli1->tree, fnum2);
@@ -966,7 +966,7 @@ static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, s
{
int fnum1 = -1;
int fnum2 = -1;
- bool correct = True;
+ bool correct = true;
del_clean_area(cli1, cli2);
@@ -994,7 +994,7 @@ static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, s
dname, smbcli_errstr(cli1->tree)));
/* The delete on close bit is *not* reported as being set. */
- correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__);
/* Now try opening again for read-only. */
fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0,
@@ -1011,12 +1011,12 @@ static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, s
torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)",
dname, smbcli_errstr(cli1->tree)));
- correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__);
- correct &= check_delete_on_close(tctx, cli1, fnum2, dname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum2, dname, false, __location__);
smbcli_close(cli1->tree, fnum1);
- correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum2, dname, true, __location__);
smbcli_close(cli1->tree, fnum2);
@@ -1040,7 +1040,7 @@ static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, s
{
int fnum1 = -1;
int fnum2 = -1;
- bool correct = True;
+ bool correct = true;
del_clean_area(cli1, cli2);
@@ -1082,7 +1082,7 @@ static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, s
talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree)));
/* The delete on close bit is *not* reported as being set. */
- correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__);
/* Now try opening again for read-only. */
fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0,
@@ -1100,7 +1100,7 @@ static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, s
smbcli_close(cli1->tree, fnum1);
- correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum2, dname, true, __location__);
smbcli_close(cli1->tree, fnum2);
@@ -1127,15 +1127,15 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s
{
int fnum1 = -1;
int dnum1 = -1;
- bool correct = True;
+ bool correct = true;
NTSTATUS status;
del_clean_area(cli1, cli2);
/* Test 20 -- non-empty directory hardest to get right... */
- if (torture_setting_bool(tctx, "samba3", False)) {
- return True;
+ if (torture_setting_bool(tctx, "samba3", false)) {
+ return true;
}
smbcli_deltree(cli1->tree, dname);
@@ -1153,8 +1153,8 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s
torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!",
dname, smbcli_errstr(cli1->tree)));
- correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__);
- status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True);
+ correct &= check_delete_on_close(tctx, cli1, dnum1, dname, false, __location__);
+ status = smbcli_nt_delete_on_close(cli1->tree, dnum1, true);
{
char *fullname;
@@ -1172,7 +1172,7 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s
"smbcli_open failed");
}
- status = smbcli_nt_delete_on_close(cli1->tree, dnum1, False);
+ status = smbcli_nt_delete_on_close(cli1->tree, dnum1, false);
torture_assert_ntstatus_ok(tctx, status,
"setting delete_on_close on file failed !");
@@ -1187,7 +1187,7 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s
smbcli_close(cli1->tree, fnum1);
}
- status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True);
+ status = smbcli_nt_delete_on_close(cli1->tree, dnum1, true);
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DIRECTORY_NOT_EMPTY,
"setting delete_on_close failed");
@@ -1201,7 +1201,7 @@ static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1,
{
int fnum1 = -1;
int fnum2 = -1;
- bool correct = True;
+ bool correct = true;
del_clean_area(cli1, cli2);
@@ -1239,12 +1239,12 @@ static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1,
fname, smbcli_errstr(cli2->tree)));
/* The delete on close bit is *not* reported as being set. */
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
smbcli_close(cli1->tree, fnum1);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
smbcli_close(cli2->tree, fnum2);
@@ -1267,7 +1267,7 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1,
{
int fnum1 = -1;
int fnum2 = -1;
- bool correct = True;
+ bool correct = true;
del_clean_area(cli1, cli2);
@@ -1322,12 +1322,12 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1,
fname, smbcli_errstr(cli2->tree)));
/* The delete on close bit is *not* reported as being set. */
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
smbcli_close(cli1->tree, fnum1);
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
/* Rename the file by handle. */
@@ -1349,7 +1349,7 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1,
fname, fname_new, smbcli_errstr(cli2->tree)));
}
- correct &= check_delete_on_close(tctx, cli2, fnum2, fname_new, False, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname_new, false, __location__);
smbcli_close(cli2->tree, fnum2);
@@ -1371,13 +1371,13 @@ static bool deltest21(struct torture_context *tctx)
int fnum1 = -1;
struct smbcli_state *cli1;
struct smbcli_state *cli2;
- bool correct = True;
+ bool correct = true;
if (!torture_open_connection(&cli1, 0))
- return False;
+ return false;
if (!torture_open_connection(&cli2, 1))
- return False;
+ return false;
del_clean_area(cli1, cli2);
@@ -1392,12 +1392,12 @@ static bool deltest21(struct torture_context *tctx)
fname, smbcli_errstr(cli1->tree)));
torture_assert_ntstatus_ok(tctx,
- smbcli_nt_delete_on_close(cli1->tree, fnum1, True),
+ smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
talloc_asprintf(tctx, "setting delete_on_close failed (%s)",
smbcli_errstr(cli1->tree)));
/* Ensure delete on close is set. */
- correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__);
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__);
/* Now yank the rug from under cli1. */
smbcli_transport_dead(cli1->transport, NT_STATUS_LOCAL_DISCONNECT);
@@ -1405,7 +1405,7 @@ static bool deltest21(struct torture_context *tctx)
fnum1 = -1;
if (!torture_open_connection(&cli1, 0)) {
- return False;
+ return false;
}
/* On slow build farm machines it might happen that they are not fast
@@ -1438,10 +1438,10 @@ static bool deltest22(struct torture_context *tctx)
int dnum1 = -1;
int dnum2 = -1;
struct smbcli_state *cli1;
- bool correct = True;
+ bool correct = true;
if (!torture_open_connection(&cli1, 0))
- return False;
+ return false;
smbcli_deltree(cli1->tree, dname);
@@ -1480,7 +1480,7 @@ static bool deltest22(struct torture_context *tctx)
dname, smbcli_errstr(cli1->tree)));
torture_assert_ntstatus_ok(
- tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, True),
+ tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, true),
talloc_asprintf(tctx, "setting delete_on_close failed (%s)",
smbcli_errstr(cli1->tree)));
diff --git a/source4/torture/basic/denytest.c b/source4/torture/basic/denytest.c
index 98f4323ce6..bc64d4b2ff 100644
--- a/source4/torture/basic/denytest.c
+++ b/source4/torture/basic/denytest.c
@@ -1410,12 +1410,12 @@ static void progress_bar(struct torture_context *tctx, uint_t i, uint_t total)
/*
this produces a matrix of deny mode behaviour for 1 connection
*/
-BOOL torture_denytest1(struct torture_context *tctx,
- struct smbcli_state *cli1)
+bool torture_denytest1(struct torture_context *tctx,
+ struct smbcli_state *cli1)
{
int fnum1, fnum2;
int i;
- BOOL correct = True;
+ bool correct = true;
struct timeval tv, tv_start;
const char *fnames[2] = {"\\denytest1.dat", "\\denytest1.exe"};
int failures=0;
@@ -1461,7 +1461,7 @@ BOOL torture_denytest1(struct torture_context *tctx,
}
}
- if (torture_setting_bool(tctx, "showall", False) ||
+ if (torture_setting_bool(tctx, "showall", false) ||
res != denytable1[i].result) {
int64_t tdif;
GetTimeOfDay(&tv);
@@ -1479,7 +1479,7 @@ BOOL torture_denytest1(struct torture_context *tctx,
}
if (res != denytable1[i].result) {
- correct = False;
+ correct = false;
CHECK_MAX_FAILURES(failed);
}
@@ -1500,13 +1500,13 @@ failed:
/*
this produces a matrix of deny mode behaviour with 2 connections
*/
-BOOL torture_denytest2(struct torture_context *tctx,
- struct smbcli_state *cli1,
- struct smbcli_state *cli2)
+bool torture_denytest2(struct torture_context *tctx,
+ struct smbcli_state *cli1,
+ struct smbcli_state *cli2)
{
int fnum1, fnum2;
int i;
- BOOL correct = True;
+ bool correct = true;
const char *fnames[2] = {"\\denytest2.dat", "\\denytest2.exe"};
struct timeval tv, tv_start;
int failures=0;
@@ -1548,7 +1548,7 @@ BOOL torture_denytest2(struct torture_context *tctx,
}
}
- if (torture_setting_bool(tctx, "showall", False) ||
+ if (torture_setting_bool(tctx, "showall", false) ||
res != denytable2[i].result) {
int64_t tdif;
GetTimeOfDay(&tv);
@@ -1566,7 +1566,7 @@ BOOL torture_denytest2(struct torture_context *tctx,
}
if (res != denytable2[i].result) {
- correct = False;
+ correct = false;
CHECK_MAX_FAILURES(failed);
}
@@ -1588,9 +1588,9 @@ failed:
/*
simple test harness for playing with deny modes
*/
-BOOL torture_denytest3(struct torture_context *tctx,
- struct smbcli_state *cli1,
- struct smbcli_state *cli2)
+bool torture_denytest3(struct torture_context *tctx,
+ struct smbcli_state *cli1,
+ struct smbcli_state *cli2)
{
int fnum1, fnum2;
const char *fname;
@@ -1616,7 +1616,7 @@ BOOL torture_denytest3(struct torture_context *tctx,
smbcli_unlink(cli1->tree, fname);
torture_comment(tctx, "fnum1=%d fnum2=%d\n", fnum1, fnum2);
- return True;
+ return true;
}
struct bit_value {
@@ -1645,7 +1645,7 @@ static const char *bit_string(TALLOC_CTX *mem_ctx, const struct bit_value *bv, i
if (ret == NULL) {
ret = talloc_asprintf(mem_ctx, "%s", bv[i].name);
} else {
- ret = talloc_asprintf_append(ret, " | %s", bv[i].name);
+ ret = talloc_asprintf_append_buffer(ret, " | %s", bv[i].name);
}
}
}
@@ -1658,7 +1658,7 @@ static const char *bit_string(TALLOC_CTX *mem_ctx, const struct bit_value *bv, i
determine if two opens conflict
*/
static NTSTATUS predict_share_conflict(uint32_t sa1, uint32_t am1, uint32_t sa2, uint32_t am2,
- BOOL read_for_execute, enum deny_result *res)
+ bool read_for_execute, enum deny_result *res)
{
#define CHECK_MASK(am, sa, right, share) do { \
if (((am) & (right)) && !((sa) & (share))) { \
@@ -1721,7 +1721,7 @@ static NTSTATUS predict_share_conflict(uint32_t sa1, uint32_t am1, uint32_t sa2,
/*
a denytest for ntcreatex
*/
-static BOOL torture_ntdenytest(struct torture_context *tctx,
+static bool torture_ntdenytest(struct torture_context *tctx,
struct smbcli_state *cli1, struct smbcli_state *cli2, int client)
{
const struct bit_value share_access_bits[] = {
@@ -1741,7 +1741,7 @@ static BOOL torture_ntdenytest(struct torture_context *tctx,
};
int fnum1;
int i;
- BOOL correct = True;
+ bool correct = true;
struct timeval tv, tv_start;
const char *fname;
int nbits1 = ARRAY_SIZE(share_access_bits);
@@ -1787,7 +1787,7 @@ static BOOL torture_ntdenytest(struct torture_context *tctx,
int b_am1 = random() & ((1<<nbits2)-1);
int b_sa2 = random() & ((1<<nbits1)-1);
int b_am2 = random() & ((1<<nbits2)-1);
- BOOL read_for_execute;
+ bool read_for_execute;
progress_bar(tctx, i, torture_numops);
@@ -1801,9 +1801,9 @@ static BOOL torture_ntdenytest(struct torture_context *tctx,
status2 = smb_raw_open(cli2->tree, mem_ctx, &io2);
if (random() % 2 == 0) {
- read_for_execute = True;
+ read_for_execute = true;
} else {
- read_for_execute = False;
+ read_for_execute = false;
}
if (!NT_STATUS_IS_OK(status1)) {
@@ -1853,7 +1853,7 @@ static BOOL torture_ntdenytest(struct torture_context *tctx,
GetTimeOfDay(&tv);
tdif = usec_time_diff(&tv, &tv_start);
tdif /= 1000;
- if (torture_setting_bool(tctx, "showall", False) ||
+ if (torture_setting_bool(tctx, "showall", false) ||
!NT_STATUS_EQUAL(status2, status2_p) ||
res != res2) {
torture_comment(tctx, "\n%-20s %-70s\n%-20s %-70s %4s %4s %s/%s\n",
@@ -1871,7 +1871,7 @@ static BOOL torture_ntdenytest(struct torture_context *tctx,
if (res != res2 ||
!NT_STATUS_EQUAL(status2, status2_p)) {
CHECK_MAX_FAILURES(failed);
- correct = False;
+ correct = false;
}
talloc_free(mem_ctx);
@@ -1889,7 +1889,8 @@ failed:
/*
a denytest for ntcreatex
*/
-BOOL torture_ntdenytest1(struct torture_context *tctx, struct smbcli_state *cli, int client)
+bool torture_ntdenytest1(struct torture_context *tctx,
+ struct smbcli_state *cli, int client)
{
extern int torture_seed;
@@ -1903,9 +1904,9 @@ BOOL torture_ntdenytest1(struct torture_context *tctx, struct smbcli_state *cli,
/*
a denytest for ntcreatex
*/
-BOOL torture_ntdenytest2(struct torture_context *torture,
- struct smbcli_state *cli1,
- struct smbcli_state *cli2)
+bool torture_ntdenytest2(struct torture_context *torture,
+ struct smbcli_state *cli1,
+ struct smbcli_state *cli2)
{
return torture_ntdenytest(torture, cli1, cli2, 0);
}
@@ -1915,7 +1916,7 @@ BOOL torture_ntdenytest2(struct torture_context *torture,
if (!NT_STATUS_EQUAL(status, correct)) { \
torture_comment(tctx, "(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -1923,21 +1924,21 @@ BOOL torture_ntdenytest2(struct torture_context *torture,
if ((v) != (correct)) { \
torture_comment(tctx, "(%s) wrong value for %s 0x%x - should be 0x%x\n", \
__location__, #v, (int)(v), (int)correct); \
- ret = False; \
+ ret = false; \
}} while (0)
/*
test sharing of handles with DENY_DOS on a single connection
*/
-BOOL torture_denydos_sharing(struct torture_context *tctx,
- struct smbcli_state *cli)
+bool torture_denydos_sharing(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
union smb_open io;
union smb_fileinfo finfo;
const char *fname = "\\torture_denydos.txt";
NTSTATUS status;
int fnum1 = -1, fnum2 = -1;
- BOOL ret = True;
+ bool ret = true;
union smb_setfileinfo sfinfo;
TALLOC_CTX *mem_ctx;
diff --git a/source4/torture/basic/dir.c b/source4/torture/basic/dir.c
index 8b37188299..9a1ae2f744 100644
--- a/source4/torture/basic/dir.c
+++ b/source4/torture/basic/dir.c
@@ -33,12 +33,12 @@ static void list_fn(struct clilist_file_info *finfo, const char *name, void *sta
/*
test directory listing speed
*/
-BOOL torture_dirtest1(struct torture_context *tctx,
- struct smbcli_state *cli)
+bool torture_dirtest1(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
int i;
int fnum;
- BOOL correct = True;
+ bool correct = true;
extern int torture_numops;
struct timeval tv;
@@ -53,7 +53,7 @@ BOOL torture_dirtest1(struct torture_context *tctx,
if (fnum == -1) {
fprintf(stderr,"(%s) Failed to open %s\n",
__location__, fname);
- return False;
+ return false;
}
smbcli_close(cli->tree, fnum);
free(fname);
@@ -76,16 +76,16 @@ BOOL torture_dirtest1(struct torture_context *tctx,
return correct;
}
-BOOL torture_dirtest2(struct torture_context *tctx,
- struct smbcli_state *cli)
+bool torture_dirtest2(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
int i;
int fnum, num_seen;
- BOOL correct = True;
+ bool correct = true;
extern int torture_entries;
if (!torture_setup_dir(cli, "\\LISTDIR")) {
- return False;
+ return false;
}
torture_comment(tctx, "Creating %d files\n", torture_entries);
@@ -102,7 +102,7 @@ BOOL torture_dirtest2(struct torture_context *tctx,
if (fnum == -1) {
fprintf(stderr,"(%s) Failed to open %s, error=%s\n",
__location__, fname, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
free(fname);
smbcli_close(cli->tree, fnum);
@@ -113,7 +113,7 @@ BOOL torture_dirtest2(struct torture_context *tctx,
if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) {
fprintf(stderr,"(%s) Failed to open %s, error=%s\n",
__location__, fname, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
free(fname);
}
@@ -123,7 +123,7 @@ BOOL torture_dirtest2(struct torture_context *tctx,
torture_comment(tctx, "num_seen = %d\n", num_seen );
/* We should see (torture_entries) each of files & directories + . and .. */
if (num_seen != (2*torture_entries)+2) {
- correct = False;
+ correct = false;
fprintf(stderr,"(%s) entry count mismatch, should be %d, was %d\n",
__location__, (2*torture_entries)+2, num_seen);
}
@@ -135,7 +135,7 @@ BOOL torture_dirtest2(struct torture_context *tctx,
num_seen = smbcli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
torture_comment(tctx, "num_seen = %d\n", num_seen );
if (num_seen != torture_entries+2) {
- correct = False;
+ correct = false;
fprintf(stderr,"(%s) entry count mismatch, should be %d, was %d\n",
__location__, torture_entries+2, num_seen);
}
@@ -143,7 +143,7 @@ BOOL torture_dirtest2(struct torture_context *tctx,
num_seen = smbcli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
torture_comment(tctx, "num_seen = %d\n", num_seen );
if (num_seen != torture_entries) {
- correct = False;
+ correct = false;
fprintf(stderr,"(%s) entry count mismatch, should be %d, was %d\n",
__location__, torture_entries, num_seen);
}
@@ -152,7 +152,7 @@ BOOL torture_dirtest2(struct torture_context *tctx,
if (smbcli_deltree(cli->tree, "\\LISTDIR") == -1) {
fprintf(stderr,"(%s) Failed to deltree %s, error=%s\n", "\\LISTDIR",
__location__, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
#if 0
diff --git a/source4/torture/basic/disconnect.c b/source4/torture/basic/disconnect.c
index e05e3ef082..cb77bfe984 100644
--- a/source4/torture/basic/disconnect.c
+++ b/source4/torture/basic/disconnect.c
@@ -33,13 +33,13 @@
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
talloc_free(cli); \
- return False; \
+ return false; \
}} while (0)
/*
test disconnect after async open
*/
-static BOOL test_disconnect_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_disconnect_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
NTSTATUS status;
@@ -71,14 +71,14 @@ static BOOL test_disconnect_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
talloc_free(cli);
- return True;
+ return true;
}
/*
test disconnect with timed lock
*/
-static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_lock io;
NTSTATUS status;
@@ -92,7 +92,7 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
O_RDWR | O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
io.lockx.level = RAW_LOCK_LOCKX;
@@ -118,7 +118,7 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
talloc_free(cli);
- return True;
+ return true;
}
@@ -126,9 +126,9 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
/*
basic testing of disconnects
*/
-BOOL torture_disconnect(struct torture_context *torture)
+bool torture_disconnect(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx;
int i;
extern int torture_numops;
@@ -137,25 +137,25 @@ BOOL torture_disconnect(struct torture_context *torture)
mem_ctx = talloc_init("torture_raw_mux");
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
for (i=0;i<torture_numops;i++) {
ret &= test_disconnect_lock(cli, mem_ctx);
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
ret &= test_disconnect_open(cli, mem_ctx);
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
- if (torture_setting_bool(torture, "samba3", False)) {
+ if (torture_setting_bool(torture, "samba3", false)) {
/*
* In Samba3 it might happen that the old smbd from
* test_disconnect_lock is not scheduled before the
diff --git a/source4/torture/basic/locking.c b/source4/torture/basic/locking.c
index aa3168fb08..2e2585b976 100644
--- a/source4/torture/basic/locking.c
+++ b/source4/torture/basic/locking.c
@@ -48,7 +48,7 @@ static bool torture_locktest1(struct torture_context *tctx,
uint_t lock_timeout;
if (!torture_setup_dir(cli1, BASEDIR)) {
- return False;
+ return false;
}
fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
@@ -71,14 +71,14 @@ static bool torture_locktest1(struct torture_context *tctx,
"lock2 succeeded! This is a locking bug\n");
if (!check_error(__location__, cli2, ERRDOS, ERRlock,
- NT_STATUS_LOCK_NOT_GRANTED)) return False;
+ NT_STATUS_LOCK_NOT_GRANTED)) return false;
torture_assert(tctx,
!NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)),
"lock2 succeeded! This is a locking bug\n");
if (!check_error(__location__, cli2, ERRDOS, ERRlock,
- NT_STATUS_FILE_LOCK_CONFLICT)) return False;
+ NT_STATUS_FILE_LOCK_CONFLICT)) return false;
torture_assert_ntstatus_ok(tctx,
smbcli_lock(cli1->tree, fnum1, 5, 9, 0, WRITE_LOCK),
@@ -90,21 +90,21 @@ static bool torture_locktest1(struct torture_context *tctx,
"lock2 succeeded! This is a locking bug");
if (!check_error(__location__, cli2, ERRDOS, ERRlock,
- NT_STATUS_LOCK_NOT_GRANTED)) return False;
+ NT_STATUS_LOCK_NOT_GRANTED)) return false;
torture_assert(tctx,
!NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)),
"lock2 succeeded! This is a locking bug");
if (!check_error(__location__, cli2, ERRDOS, ERRlock,
- NT_STATUS_LOCK_NOT_GRANTED)) return False;
+ NT_STATUS_LOCK_NOT_GRANTED)) return false;
torture_assert(tctx,
!NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)),
"lock2 succeeded! This is a locking bug");
if (!check_error(__location__, cli2, ERRDOS, ERRlock,
- NT_STATUS_FILE_LOCK_CONFLICT)) return False;
+ NT_STATUS_FILE_LOCK_CONFLICT)) return false;
lock_timeout = (6 + (random() % 20));
torture_comment(tctx, "Testing lock timeout with timeout=%u\n",
@@ -115,7 +115,7 @@ static bool torture_locktest1(struct torture_context *tctx,
"lock3 succeeded! This is a locking bug\n");
if (!check_error(__location__, cli2, ERRDOS, ERRlock,
- NT_STATUS_FILE_LOCK_CONFLICT)) return False;
+ NT_STATUS_FILE_LOCK_CONFLICT)) return false;
t2 = time(NULL);
if (t2 - t1 < 5) {
@@ -133,7 +133,7 @@ static bool torture_locktest1(struct torture_context *tctx,
"lock4 succeeded! This is a locking bug");
if (!check_error(__location__, cli2, ERRDOS, ERRlock,
- NT_STATUS_FILE_LOCK_CONFLICT)) return False;
+ NT_STATUS_FILE_LOCK_CONFLICT)) return false;
torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
talloc_asprintf(tctx, "close2 failed (%s)", smbcli_errstr(cli1->tree)));
@@ -166,7 +166,7 @@ static bool torture_locktest2(struct torture_context *tctx,
int fnum1, fnum2, fnum3;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
torture_comment(tctx, "Testing pid context\n");
@@ -202,21 +202,21 @@ static bool torture_locktest2(struct torture_context *tctx,
"WRITE lock1 succeeded! This is a locking bug");
if (!check_error(__location__, cli, ERRDOS, ERRlock,
- NT_STATUS_LOCK_NOT_GRANTED)) return False;
+ NT_STATUS_LOCK_NOT_GRANTED)) return false;
torture_assert(tctx,
!NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, WRITE_LOCK)),
"WRITE lock2 succeeded! This is a locking bug");
if (!check_error(__location__, cli, ERRDOS, ERRlock,
- NT_STATUS_LOCK_NOT_GRANTED)) return False;
+ NT_STATUS_LOCK_NOT_GRANTED)) return false;
torture_assert(tctx,
!NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, READ_LOCK)),
"READ lock2 succeeded! This is a locking bug");
if (!check_error(__location__, cli, ERRDOS, ERRlock,
- NT_STATUS_FILE_LOCK_CONFLICT)) return False;
+ NT_STATUS_FILE_LOCK_CONFLICT)) return false;
torture_assert_ntstatus_ok(tctx,
smbcli_lock(cli->tree, fnum1, 100, 4, 0, WRITE_LOCK),
@@ -235,7 +235,7 @@ static bool torture_locktest2(struct torture_context *tctx,
if (!check_error(__location__, cli,
ERRDOS, ERRnotlocked,
- NT_STATUS_RANGE_NOT_LOCKED)) return False;
+ NT_STATUS_RANGE_NOT_LOCKED)) return false;
torture_assert(tctx,
!NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 0, 8)),
@@ -243,13 +243,13 @@ static bool torture_locktest2(struct torture_context *tctx,
if (!check_error(__location__, cli,
ERRDOS, ERRnotlocked,
- NT_STATUS_RANGE_NOT_LOCKED)) return False;
+ NT_STATUS_RANGE_NOT_LOCKED)) return false;
torture_assert(tctx,
!NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum3, 0, 4, 0, WRITE_LOCK)),
"lock3 succeeded! This is a locking bug");
- if (!check_error(__location__, cli, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False;
+ if (!check_error(__location__, cli, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return false;
cli->session->pid = 1;
@@ -285,7 +285,7 @@ static bool torture_locktest3(struct torture_context *tctx,
torture_comment(tctx, "Testing 32 bit offset ranges");
if (!torture_setup_dir(cli1, BASEDIR)) {
- return False;
+ return false;
}
fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
@@ -362,7 +362,7 @@ static bool torture_locktest3(struct torture_context *tctx,
}
#define EXPECTED(ret, v) if ((ret) != (v)) { \
- torture_comment(tctx, "** "); correct = False; \
+ torture_comment(tctx, "** "); correct = false; \
}
/*
@@ -374,12 +374,12 @@ static bool torture_locktest4(struct torture_context *tctx,
{
const char *fname = BASEDIR "\\lockt4.lck";
int fnum1, fnum2, f;
- BOOL ret;
+ bool ret;
uint8_t buf[1000];
- BOOL correct = True;
+ bool correct = true;
if (!torture_setup_dir(cli1, BASEDIR)) {
- return False;
+ return false;
}
fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
@@ -389,80 +389,80 @@ static bool torture_locktest4(struct torture_context *tctx,
if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
torture_comment(tctx, "Failed to create file\n");
- correct = False;
+ correct = false;
goto fail;
}
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 2, 4, 0, WRITE_LOCK));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "the same process %s set overlapping write locks\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 10, 4, 0, READ_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 12, 4, 0, READ_LOCK));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the same process %s set overlapping read locks\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 20, 4, 0, WRITE_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 22, 4, 0, WRITE_LOCK));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "a different connection %s set overlapping write locks\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 30, 4, 0, READ_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 32, 4, 0, READ_LOCK));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "a different connection %s set overlapping read locks\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 40, 4, 0, WRITE_LOCK))) &&
NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 42, 4, 0, WRITE_LOCK)));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "a different pid %s set overlapping write locks\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 50, 4, 0, READ_LOCK))) &&
NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 52, 4, 0, READ_LOCK)));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "a different pid %s set overlapping read locks\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the same process %s set the same read lock twice\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "the same process %s set the same write lock twice\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 80, 4, 0, READ_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 80, 4, 0, WRITE_LOCK));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "the same process %s overlay a read lock with a write lock\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 90, 4, 0, WRITE_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 90, 4, 0, READ_LOCK));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the same process %s overlay a write lock with a read lock\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 100, 4, 0, WRITE_LOCK))) &&
NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 100, 4, 0, READ_LOCK)));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "a different pid %s overlay a write lock with a read lock\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 110, 4, 0, READ_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 112, 4, 0, READ_LOCK)) &&
NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 110, 6));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "the same process %s coalesce read locks\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 120, 4, 0, WRITE_LOCK)) &&
(smbcli_read(cli2->tree, fnum2, buf, 120, 4) == 4);
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "this server %s strict write locking\n", ret?"doesn't do":"does");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK)) &&
(smbcli_write(cli2->tree, fnum2, 0, buf, 130, 4) == 4);
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "this server %s strict read locking\n", ret?"doesn't do":"does");
@@ -470,7 +470,7 @@ static bool torture_locktest4(struct torture_context *tctx,
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 140, 4, 0, READ_LOCK)) &&
NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 140, 4)) &&
NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 140, 4));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "this server %s do recursive read locking\n", ret?"does":"doesn't");
@@ -480,21 +480,21 @@ static bool torture_locktest4(struct torture_context *tctx,
(smbcli_read(cli2->tree, fnum2, buf, 150, 4) == 4) &&
!(smbcli_write(cli2->tree, fnum2, 0, buf, 150, 4) == 4) &&
NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 150, 4));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "this server %s do recursive lock overlays\n", ret?"does":"doesn't");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 160, 4, 0, READ_LOCK)) &&
NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 160, 4)) &&
(smbcli_write(cli2->tree, fnum2, 0, buf, 160, 4) == 4) &&
(smbcli_read(cli2->tree, fnum2, buf, 160, 4) == 4);
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the same process %s remove a read lock using write locking\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 170, 4, 0, WRITE_LOCK)) &&
NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 170, 4)) &&
(smbcli_write(cli2->tree, fnum2, 0, buf, 170, 4) == 4) &&
(smbcli_read(cli2->tree, fnum2, buf, 170, 4) == 4);
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the same process %s remove a write lock using read locking\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 190, 4, 0, WRITE_LOCK)) &&
@@ -502,7 +502,7 @@ static bool torture_locktest4(struct torture_context *tctx,
NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 190, 4)) &&
!(smbcli_write(cli2->tree, fnum2, 0, buf, 190, 4) == 4) &&
(smbcli_read(cli2->tree, fnum2, buf, 190, 4) == 4);
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the same process %s remove the first lock first\n", ret?"does":"doesn't");
smbcli_close(cli1->tree, fnum1);
@@ -516,7 +516,7 @@ static bool torture_locktest4(struct torture_context *tctx,
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK));
smbcli_close(cli1->tree, f);
smbcli_close(cli1->tree, fnum1);
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the server %s have the NT byte range lock bug\n", !ret?"does":"doesn't");
fail:
@@ -535,12 +535,12 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state
{
const char *fname = BASEDIR "\\lockt5.lck";
int fnum1, fnum2, fnum3;
- BOOL ret;
+ bool ret;
uint8_t buf[1000];
- BOOL correct = True;
+ bool correct = true;
if (!torture_setup_dir(cli1, BASEDIR)) {
- return False;
+ return false;
}
fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
@@ -558,7 +558,7 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state
smbcli_close(cli1->tree, fnum1);
fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "this server %s the NT locking bug\n", ret ? "doesn't have" : "has");
smbcli_close(cli1->tree, fnum1);
fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
@@ -566,11 +566,11 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 1, 1, 0, READ_LOCK));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the same process %s overlay a write with a read lock\n", ret?"can":"cannot");
ret = NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "a different processs %s get a read lock on the first process lock stack\n", ret?"can":"cannot");
@@ -578,7 +578,7 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state
smbcli_unlock(cli2->tree, fnum2, 0, 4);
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum3, 0, 4, 0, READ_LOCK));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "the same processs on a different fnum %s get a read lock\n", ret?"can":"cannot");
@@ -589,7 +589,7 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state
ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK)) &&
NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the same process %s stack read locks\n", ret?"can":"cannot");
/* Unlock the first process lock, then check this was the WRITE lock that was
@@ -598,7 +598,7 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state
ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) &&
NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the first unlock removes the %s lock\n", ret?"WRITE":"READ");
/* Unlock the process 2 lock. */
@@ -610,17 +610,17 @@ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) &&
NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) &&
NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "the same process %s unlock the stack of 4 locks\n", ret?"can":"cannot");
/* Ensure the next unlock fails. */
ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4));
- EXPECTED(ret, False);
+ EXPECTED(ret, false);
torture_comment(tctx, "the same process %s count the lock stack\n", !ret?"can":"cannot");
/* Ensure connection 2 can get a write lock. */
ret = NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, WRITE_LOCK));
- EXPECTED(ret, True);
+ EXPECTED(ret, true);
torture_comment(tctx, "a different processs %s get a write lock on the unlocked stack\n", ret?"can":"cannot");
@@ -644,7 +644,7 @@ static bool torture_locktest6(struct torture_context *tctx,
NTSTATUS status;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
for (i=0;i<1;i++) {
@@ -665,7 +665,7 @@ static bool torture_locktest6(struct torture_context *tctx,
smbcli_unlink(cli->tree, fname[i]);
}
- return True;
+ return true;
}
static bool torture_locktest7(struct torture_context *tctx,
@@ -676,7 +676,7 @@ static bool torture_locktest7(struct torture_context *tctx,
int fnum2 = -1;
size_t size;
uint8_t buf[200];
- BOOL correct = False;
+ bool correct = false;
torture_assert(tctx, torture_setup_dir(cli1, BASEDIR),
talloc_asprintf(tctx, "Unable to set up %s", BASEDIR));
@@ -785,7 +785,7 @@ static bool torture_locktest7(struct torture_context *tctx,
cli1->session->pid = 1;
smbcli_unlock(cli1->tree, fnum1, 130, 4);
- correct = True;
+ correct = true;
fail:
smbcli_close(cli1->tree, fnum1);
@@ -795,10 +795,9 @@ fail:
return correct;
}
-struct torture_suite *torture_base_locktest(void)
+struct torture_suite *torture_base_locktest(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(talloc_autofree_context(),
- "LOCK");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCK");
torture_suite_add_2smb_test(suite, "LOCK1", torture_locktest1);
torture_suite_add_1smb_test(suite, "LOCK2", torture_locktest2);
torture_suite_add_2smb_test(suite, "LOCK3", torture_locktest3);
diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c
index 665360fc64..58d7098972 100644
--- a/source4/torture/basic/mangle_test.c
+++ b/source4/torture/basic/mangle_test.c
@@ -25,7 +25,6 @@
#include "lib/util/util_tdb.h"
#include "libcli/libcli.h"
#include "torture/util.h"
-#include "pstring.h"
static TDB_CONTEXT *tdb;
@@ -33,11 +32,12 @@ static TDB_CONTEXT *tdb;
static uint_t total, collisions, failures;
-static BOOL test_one(struct smbcli_state *cli, const char *name)
+static bool test_one(struct torture_context *tctx ,struct smbcli_state *cli,
+ const char *name)
{
int fnum;
const char *shortname;
- fstring name2;
+ const char *name2;
NTSTATUS status;
TDB_DATA data;
@@ -46,37 +46,37 @@ static BOOL test_one(struct smbcli_state *cli, const char *name)
fnum = smbcli_open(cli->tree, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
printf("open of %s failed (%s)\n", name, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
/* get the short name */
status = smbcli_qpathinfo_alt_name(cli->tree, name, &shortname);
if (!NT_STATUS_IS_OK(status)) {
printf("query altname of %s failed (%s)\n", name, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
- snprintf(name2, sizeof(name2), "\\mangle_test\\%s", shortname);
+ name2 = talloc_asprintf(tctx, "\\mangle_test\\%s", shortname);
if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, name2))) {
printf("unlink of %s (%s) failed (%s)\n",
name2, name, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
/* recreate by short name */
fnum = smbcli_open(cli->tree, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
printf("open2 of %s failed (%s)\n", name2, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
/* and unlink by long name */
@@ -85,7 +85,7 @@ static BOOL test_one(struct smbcli_state *cli, const char *name)
name, name2, smbcli_errstr(cli->tree));
failures++;
smbcli_unlink(cli->tree, name2);
- return True;
+ return true;
}
/* see if the short name is already in the tdb */
@@ -108,22 +108,25 @@ static BOOL test_one(struct smbcli_state *cli, const char *name)
tdb_store_bystring(tdb, shortname, namedata, TDB_REPLACE);
}
- return True;
+ return true;
}
-static void gen_name(char *name)
+static char *gen_name(TALLOC_CTX *mem_ctx)
{
const char *chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-$~...";
uint_t max_idx = strlen(chars);
uint_t len;
int i;
char *p;
+ char *name;
- fstrcpy(name, "\\mangle_test\\");
- p = name + strlen(name);
+ name = talloc_strdup(mem_ctx, "\\mangle_test\\");
len = 1 + random() % NAME_LENGTH;
+
+ name = talloc_realloc(mem_ctx, name, char, strlen(name) + len + 6);
+ p = name + strlen(name);
for (i=0;i<len;i++) {
p[i] = chars[random() % max_idx];
@@ -141,7 +144,7 @@ static void gen_name(char *name)
}
/* and a medium probability of a common lead string */
- if (random() % 10 == 0) {
+ if ((len > 5) && (random() % 10 == 0)) {
strncpy(p, "ABCDE", 5);
}
@@ -152,11 +155,13 @@ static void gen_name(char *name)
s[4] = 0;
}
}
+
+ return name;
}
-BOOL torture_mangle(struct torture_context *torture,
- struct smbcli_state *cli)
+bool torture_mangle(struct torture_context *torture,
+ struct smbcli_state *cli)
{
extern int torture_numops;
int i;
@@ -165,21 +170,19 @@ BOOL torture_mangle(struct torture_context *torture,
tdb = tdb_open(NULL, 100000, TDB_INTERNAL, 0, 0);
if (!tdb) {
printf("ERROR: Failed to open tdb\n");
- return False;
+ return false;
}
if (!torture_setup_dir(cli, "\\mangle_test")) {
- return False;
+ return false;
}
for (i=0;i<torture_numops;i++) {
- fstring name;
-
- ZERO_STRUCT(name);
+ char *name;
- gen_name(name);
+ name = gen_name(torture);
- if (!test_one(cli, name)) {
+ if (!test_one(torture, cli, name)) {
break;
}
if (total && total % 100 == 0) {
@@ -193,7 +196,7 @@ BOOL torture_mangle(struct torture_context *torture,
smbcli_unlink(cli->tree, "\\mangle_test\\*");
if (NT_STATUS_IS_ERR(smbcli_rmdir(cli->tree, "\\mangle_test"))) {
printf("ERROR: Failed to remove directory\n");
- return False;
+ return false;
}
printf("\nTotal collisions %u/%u - %.2f%% (%u failures)\n",
diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c
index d72e3ca1cd..f0d5ef5536 100644
--- a/source4/torture/basic/misc.c
+++ b/source4/torture/basic/misc.c
@@ -33,19 +33,20 @@
#include "torture/util.h"
#include "libcli/smb_composite/smb_composite.h"
#include "libcli/composite/composite.h"
+#include "param/param.h"
extern struct cli_credentials *cmdline_credentials;
-static BOOL wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len)
+static bool wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len)
{
while (NT_STATUS_IS_ERR(smbcli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK))) {
- if (!check_error(__location__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False;
+ if (!check_error(__location__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return false;
}
- return True;
+ return true;
}
-static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c)
+static bool rw_torture(struct torture_context *tctx, struct smbcli_state *c)
{
const char *lockfname = "\\torture.lck";
char *fname;
@@ -54,7 +55,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c)
pid_t pid2, pid = getpid();
int i, j;
uint8_t buf[1024];
- BOOL correct = True;
+ bool correct = true;
fnum2 = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
DENY_NONE);
@@ -62,7 +63,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c)
fnum2 = smbcli_open(c->tree, lockfname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
torture_comment(tctx, "open of %s failed (%s)\n", lockfname, smbcli_errstr(c->tree));
- return False;
+ return false;
}
generate_random_buffer(buf, sizeof(buf));
@@ -78,19 +79,19 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c)
asprintf(&fname, "\\torture.%u", n);
if (!wait_lock(c, fnum2, n*sizeof(int), sizeof(int))) {
- return False;
+ return false;
}
fnum = smbcli_open(c->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL);
if (fnum == -1) {
torture_comment(tctx, "open failed (%s)\n", smbcli_errstr(c->tree));
- correct = False;
+ correct = false;
break;
}
if (smbcli_write(c->tree, fnum, 0, &pid, 0, sizeof(pid)) != sizeof(pid)) {
torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree));
- correct = False;
+ correct = false;
}
for (j=0;j<50;j++) {
@@ -98,7 +99,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c)
sizeof(pid)+(j*sizeof(buf)),
sizeof(buf)) != sizeof(buf)) {
torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree));
- correct = False;
+ correct = false;
}
}
@@ -106,27 +107,27 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c)
if (smbcli_read(c->tree, fnum, &pid2, 0, sizeof(pid)) != sizeof(pid)) {
torture_comment(tctx, "read failed (%s)\n", smbcli_errstr(c->tree));
- correct = False;
+ correct = false;
}
if (pid2 != pid) {
torture_comment(tctx, "data corruption!\n");
- correct = False;
+ correct = false;
}
if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) {
torture_comment(tctx, "close failed (%s)\n", smbcli_errstr(c->tree));
- correct = False;
+ correct = false;
}
if (NT_STATUS_IS_ERR(smbcli_unlink(c->tree, fname))) {
torture_comment(tctx, "unlink failed (%s)\n", smbcli_errstr(c->tree));
- correct = False;
+ correct = false;
}
if (NT_STATUS_IS_ERR(smbcli_unlock(c->tree, fnum2, n*sizeof(int), sizeof(int)))) {
torture_comment(tctx, "unlock failed (%s)\n", smbcli_errstr(c->tree));
- correct = False;
+ correct = false;
}
free(fname);
}
@@ -139,7 +140,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c)
return correct;
}
-BOOL run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dummy)
+bool run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dummy)
{
return rw_torture(tctx, cli);
}
@@ -148,7 +149,7 @@ BOOL run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dum
/*
see how many RPC pipes we can open at once
*/
-BOOL run_pipe_number(struct torture_context *tctx,
+bool run_pipe_number(struct torture_context *tctx,
struct smbcli_state *cli1)
{
const char *pipe_name = "\\WKSSVC";
@@ -171,7 +172,7 @@ BOOL run_pipe_number(struct torture_context *tctx,
}
torture_comment(tctx, "pipe_number test - we can open %d %s pipes.\n", num_pipes, pipe_name );
- return True;
+ return true;
}
@@ -182,7 +183,7 @@ BOOL run_pipe_number(struct torture_context *tctx,
used for testing performance when there are N idle users
already connected
*/
-BOOL torture_holdcon(struct torture_context *tctx)
+bool torture_holdcon(struct torture_context *tctx)
{
int i;
struct smbcli_state **cli;
@@ -194,7 +195,7 @@ BOOL torture_holdcon(struct torture_context *tctx)
for (i=0;i<torture_numops;i++) {
if (!torture_open_connection(&cli[i], i)) {
- return False;
+ return false;
}
if (torture_setting_bool(tctx, "progress", true)) {
torture_comment(tctx, "opened %d connections\r", i);
@@ -227,34 +228,34 @@ BOOL torture_holdcon(struct torture_context *tctx)
fflush(stdout);
}
- return True;
+ return true;
}
/*
test how many open files this server supports on the one socket
*/
-BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int dummy)
+bool run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int dummy)
{
#define MAXFID_TEMPLATE "\\maxfid\\fid%d\\maxfid.%d.%d"
char *fname;
int fnums[0x11000], i;
int retries=4, maxfid;
- BOOL correct = True;
+ bool correct = true;
if (retries <= 0) {
torture_comment(tctx, "failed to connect\n");
- return False;
+ return false;
}
if (smbcli_deltree(cli->tree, "\\maxfid") == -1) {
torture_comment(tctx, "Failed to deltree \\maxfid - %s\n",
smbcli_errstr(cli->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\maxfid"))) {
torture_comment(tctx, "Failed to mkdir \\maxfid, error=%s\n",
smbcli_errstr(cli->tree));
- return False;
+ return false;
}
torture_comment(tctx, "Testing maximum number of open files\n");
@@ -265,7 +266,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int
if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) {
torture_comment(tctx, "Failed to mkdir %s, error=%s\n",
fname, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
free(fname);
}
@@ -298,7 +299,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int
if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {
torture_comment(tctx, "unlink of %s failed (%s)\n",
fname, smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
}
free(fname);
@@ -309,7 +310,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int
if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {
torture_comment(tctx, "unlink of %s failed (%s)\n",
fname, smbcli_errstr(cli->tree));
- correct = False;
+ correct = false;
}
free(fname);
@@ -323,12 +324,12 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int
if (smbcli_deltree(cli->tree, "\\maxfid") == -1) {
torture_comment(tctx, "Failed to deltree \\maxfid - %s\n",
smbcli_errstr(cli->tree));
- return False;
+ return false;
}
torture_comment(tctx, "maxfid test finished\n");
if (!torture_close_connection(cli)) {
- correct = False;
+ correct = false;
}
return correct;
#undef MAXFID_TEMPLATE
@@ -339,7 +340,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int
/*
sees what IOCTLs are supported
*/
-BOOL torture_ioctl_test(struct torture_context *tctx,
+bool torture_ioctl_test(struct torture_context *tctx,
struct smbcli_state *cli)
{
uint16_t device, function;
@@ -356,7 +357,7 @@ BOOL torture_ioctl_test(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
parms.ioctl.level = RAW_IOCTL_IOCTL;
@@ -378,7 +379,7 @@ BOOL torture_ioctl_test(struct torture_context *tctx,
}
}
- return True;
+ return true;
}
static void benchrw_callback(struct smbcli_request *req);
@@ -441,7 +442,7 @@ static int init_benchrw_params(struct torture_context *tctx,
lpar->writeratio = torture_setting_int(tctx, "writeratio",5);
lpar->num_parallel_requests = torture_setting_int(
tctx, "parallel_requests", 5);
- lpar->workgroup = lp_workgroup();
+ lpar->workgroup = lp_workgroup(global_loadparm);
p = torture_setting_string(tctx, "unclist", NULL);
if (p) {
@@ -581,7 +582,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx,
rd.readx.in.maxcnt = rd.readx.in.mincnt;
rd.readx.in.remaining = 0 ;
rd.readx.out.data = state->buffer;
- rd.readx.in.read_for_execute = False;
+ rd.readx.in.read_for_execute = false;
if(state->readcnt < state->lp_params->writeblocks){
state->readcnt++;
}else{
@@ -818,13 +819,13 @@ static struct composite_context *torture_connect_async(
smb->in.called_name = strupper_talloc(mem_ctx, host);
smb->in.service_type=NULL;
smb->in.credentials=cmdline_credentials;
- smb->in.fallback_to_anonymous=False;
+ smb->in.fallback_to_anonymous=false;
smb->in.workgroup=workgroup;
return smb_composite_connect_send(smb,mem_ctx,ev);
}
-BOOL run_benchrw(struct torture_context *tctx)
+bool run_benchrw(struct torture_context *tctx)
{
struct smb_composite_connect *smb_con;
const char *fname = "\\rwtest.dat";
@@ -836,7 +837,7 @@ BOOL run_benchrw(struct torture_context *tctx)
struct params lpparams;
union smb_mkdir parms;
int finished = 0;
- BOOL success=True;
+ bool success=true;
int torture_nprocs = torture_setting_int(tctx, "nprocs", 4);
torture_comment(tctx, "Start BENCH-READWRITE num_ops=%d "
@@ -910,7 +911,7 @@ BOOL run_benchrw(struct torture_context *tctx)
/* error occured , finish */
case ERROR:
finished++;
- success=False;
+ success=false;
break;
/* cleanup , close connection */
case CLEANUP:
diff --git a/source4/torture/basic/properties.c b/source4/torture/basic/properties.c
index 6a8e84cc2f..1825dff993 100644
--- a/source4/torture/basic/properties.c
+++ b/source4/torture/basic/properties.c
@@ -88,10 +88,10 @@ static void show_bits(const struct bitmapping *bm, uint32_t value)
/*
print out server properties
*/
-BOOL torture_test_properties(struct torture_context *torture,
- struct smbcli_state *cli)
+bool torture_test_properties(struct torture_context *torture,
+ struct smbcli_state *cli)
{
- BOOL correct = True;
+ bool correct = true;
union smb_fsinfo fs;
NTSTATUS status;
@@ -103,7 +103,7 @@ BOOL torture_test_properties(struct torture_context *torture,
status = smb_raw_fsinfo(cli->tree, cli, &fs);
if (!NT_STATUS_IS_OK(status)) {
d_printf("qfsinfo failed - %s\n", nt_errstr(status));
- correct = False;
+ correct = false;
} else {
d_printf("Filesystem attributes: 0x%08x\n",
fs.attribute_info.out.fs_attr);
diff --git a/source4/torture/basic/rename.c b/source4/torture/basic/rename.c
index 572048e0ea..12fd5e1c99 100644
--- a/source4/torture/basic/rename.c
+++ b/source4/torture/basic/rename.c
@@ -27,8 +27,8 @@
/*
Test rename on files open with share delete and no share delete.
*/
-BOOL torture_test_rename(struct torture_context *tctx,
- struct smbcli_state *cli1)
+bool torture_test_rename(struct torture_context *tctx,
+ struct smbcli_state *cli1)
{
const char *fname = "\\test.txt";
const char *fname1 = "\\test1.txt";
diff --git a/source4/torture/basic/scanner.c b/source4/torture/basic/scanner.c
index 0a1cfc2e01..dd596c9ee3 100644
--- a/source4/torture/basic/scanner.c
+++ b/source4/torture/basic/scanner.c
@@ -122,7 +122,7 @@ static NTSTATUS try_trans2_len(struct smbcli_state *cli,
/****************************************************************************
check whether a trans2 opnum exists at all
****************************************************************************/
-static BOOL trans2_op_exists(struct smbcli_state *cli, int op)
+static bool trans2_op_exists(struct smbcli_state *cli, int op)
{
int data_len = 0;
int param_len = 0;
@@ -146,17 +146,17 @@ static BOOL trans2_op_exists(struct smbcli_state *cli, int op)
status2 = try_trans2(cli, op, param, data, param_len, data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_EQUAL(status1, status2)) return False;
+ if (NT_STATUS_EQUAL(status1, status2)) return false;
printf("Found op %d (status=%s)\n", op, nt_errstr(status2));
- return True;
+ return true;
}
/****************************************************************************
check for existance of a trans2 call
****************************************************************************/
-static BOOL scan_trans2(struct smbcli_state *cli, int op, int level,
+static bool scan_trans2(struct smbcli_state *cli, int op, int level,
int fnum, int dnum, int qfnum, const char *fname)
{
int data_len = 0;
@@ -173,7 +173,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level,
SSVAL(param, 0, level);
status = try_trans2_len(cli, "void", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try with a file descriptor */
param_len = 6;
@@ -182,7 +182,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level,
SSVAL(param, 4, 0);
status = try_trans2_len(cli, "fnum", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try with a quota file descriptor */
param_len = 6;
@@ -191,7 +191,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level,
SSVAL(param, 4, 0);
status = try_trans2_len(cli, "qfnum", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try with a notify style */
param_len = 6;
@@ -200,7 +200,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level,
SSVAL(param, 4, level);
status = try_trans2_len(cli, "notify", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try with a file name */
param_len = 6;
@@ -211,7 +211,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level,
status = try_trans2_len(cli, "fname", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try with a new file name */
param_len = 6;
@@ -224,7 +224,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level,
&rparam_len, &rdata_len);
smbcli_unlink(cli->tree, "\\newfile.dat");
smbcli_rmdir(cli->tree, "\\newfile.dat");
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try dfs style */
smbcli_mkdir(cli->tree, "\\testdir");
@@ -235,13 +235,13 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level,
status = try_trans2_len(cli, "dfs", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
smbcli_rmdir(cli->tree, "\\testdir");
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
- return False;
+ return false;
}
-BOOL torture_trans2_scan(struct torture_context *torture,
+bool torture_trans2_scan(struct torture_context *torture,
struct smbcli_state *cli)
{
int op, level;
@@ -292,7 +292,7 @@ BOOL torture_trans2_scan(struct torture_context *torture,
}
}
- return True;
+ return true;
}
@@ -396,7 +396,7 @@ static NTSTATUS try_nttrans_len(struct smbcli_state *cli,
/****************************************************************************
check for existance of a nttrans call
****************************************************************************/
-static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level,
+static bool scan_nttrans(struct smbcli_state *cli, int op, int level,
int fnum, int dnum, const char *fname)
{
int data_len = 0;
@@ -413,7 +413,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level,
SSVAL(param, 0, level);
status = try_nttrans_len(cli, "void", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try with a file descriptor */
param_len = 6;
@@ -422,7 +422,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level,
SSVAL(param, 4, 0);
status = try_nttrans_len(cli, "fnum", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try with a notify style */
@@ -432,7 +432,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level,
SSVAL(param, 4, level);
status = try_nttrans_len(cli, "notify", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try with a file name */
param_len = 6;
@@ -443,7 +443,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level,
status = try_nttrans_len(cli, "fname", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try with a new file name */
param_len = 6;
@@ -456,7 +456,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level,
&rparam_len, &rdata_len);
smbcli_unlink(cli->tree, "\\newfile.dat");
smbcli_rmdir(cli->tree, "\\newfile.dat");
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
/* try dfs style */
smbcli_mkdir(cli->tree, "\\testdir");
@@ -467,14 +467,14 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level,
status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
smbcli_rmdir(cli->tree, "\\testdir");
- if (NT_STATUS_IS_OK(status)) return True;
+ if (NT_STATUS_IS_OK(status)) return true;
- return False;
+ return false;
}
-BOOL torture_nttrans_scan(struct torture_context *torture,
- struct smbcli_state *cli)
+bool torture_nttrans_scan(struct torture_context *torture,
+ struct smbcli_state *cli)
{
int op, level;
const char *fname = "\\scanner.dat";
@@ -499,15 +499,13 @@ BOOL torture_nttrans_scan(struct torture_context *torture,
}
}
- torture_close_connection(cli);
-
printf("nttrans scan finished\n");
- return True;
+ return true;
}
/* scan for valid base SMB requests */
-BOOL torture_smb_scan(struct torture_context *torture)
+bool torture_smb_scan(struct torture_context *torture)
{
static struct smbcli_state *cli;
int op;
@@ -518,7 +516,7 @@ BOOL torture_smb_scan(struct torture_context *torture)
if (op == SMBreadbraw) continue;
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
req = smbcli_request_setup(cli->tree, op, 0, 0);
@@ -553,5 +551,5 @@ BOOL torture_smb_scan(struct torture_context *torture)
printf("smb scan finished\n");
- return True;
+ return true;
}
diff --git a/source4/torture/basic/secleak.c b/source4/torture/basic/secleak.c
index cb6cc84152..3d4aeea956 100644
--- a/source4/torture/basic/secleak.c
+++ b/source4/torture/basic/secleak.c
@@ -27,20 +27,21 @@
#include "system/time.h"
#include "libcli/smb_composite/smb_composite.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
-static BOOL try_failed_login(struct smbcli_state *cli)
+static bool try_failed_login(struct smbcli_state *cli)
{
NTSTATUS status;
struct smb_composite_sesssetup setup;
struct smbcli_session *session;
- session = smbcli_session_init(cli->transport, cli, False);
+ session = smbcli_session_init(cli->transport, cli, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
setup.in.credentials = cli_credentials_init(session);
- cli_credentials_set_conf(setup.in.credentials);
+ cli_credentials_set_conf(setup.in.credentials, global_loadparm);
cli_credentials_set_domain(setup.in.credentials, "INVALID-DOMAIN", CRED_SPECIFIED);
cli_credentials_set_username(setup.in.credentials, "INVALID-USERNAME", CRED_SPECIFIED);
cli_credentials_set_password(setup.in.credentials, "INVALID-PASSWORD", CRED_SPECIFIED);
@@ -49,23 +50,23 @@ static BOOL try_failed_login(struct smbcli_state *cli)
talloc_free(session);
if (NT_STATUS_IS_OK(status)) {
printf("Allowed session setup with invalid credentials?!\n");
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_sec_leak(struct torture_context *tctx, struct smbcli_state *cli)
+bool torture_sec_leak(struct torture_context *tctx, struct smbcli_state *cli)
{
time_t t1 = time(NULL);
int timelimit = torture_setting_int(tctx, "timelimit", 20);
while (time(NULL) < t1+timelimit) {
if (!try_failed_login(cli)) {
- return False;
+ return false;
}
talloc_report(NULL, stdout);
}
- return True;
+ return true;
}
diff --git a/source4/torture/basic/unlink.c b/source4/torture/basic/unlink.c
index 60d5a1554d..9e13021d20 100644
--- a/source4/torture/basic/unlink.c
+++ b/source4/torture/basic/unlink.c
@@ -33,11 +33,11 @@
1) the server does not allow an unlink on a file that is open
*/
-BOOL torture_unlinktest(struct torture_context *tctx, struct smbcli_state *cli)
+bool torture_unlinktest(struct torture_context *tctx, struct smbcli_state *cli)
{
const char *fname = BASEDIR "\\unlink.tst";
int fnum;
- BOOL correct = True;
+ bool correct = true;
union smb_open io;
NTSTATUS status;
diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c
index 52babe4d53..82511aa8f9 100644
--- a/source4/torture/basic/utable.c
+++ b/source4/torture/basic/utable.c
@@ -166,7 +166,7 @@ bool torture_casetable(struct torture_context *tctx,
torture_comment(tctx, "too many chars match?? size=%d c=0x%04x\n",
(int)size, c);
smbcli_close(cli->tree, fnum);
- return False;
+ return false;
}
smbcli_read(cli->tree, fnum, c2, 0, size);
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index fc85cc160a..02188d8560 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -96,6 +96,7 @@ PRIVATE_DEPENDENCIES = \
#################################
include smb2/config.mk
+include winbind/config.mk
[SUBSYSTEM::TORTURE_NDR]
PRIVATE_PROTO_HEADER = ndr/proto.h
@@ -128,8 +129,10 @@ OBJ_FILES = \
rpc/drsuapi_cracknames.o \
rpc/dssync.o \
rpc/spoolss.o \
+ rpc/spoolss_notify.o \
rpc/unixinfo.o \
rpc/samr.o \
+ rpc/samr_accessmask.o \
rpc/wkssvc.o \
rpc/srvsvc.o \
rpc/svcctl.o \
@@ -164,7 +167,8 @@ PRIVATE_DEPENDENCIES = \
RPC_NDR_LSA RPC_NDR_EPMAPPER RPC_NDR_DFS RPC_NDR_SPOOLSS \
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
+ LIBCLI_AUTH POPT_CREDENTIALS TORTURE_LDAP TORTURE_UTIL TORTURE_RAP \
+ dcerpc_server service process_model
#################################
# Start SUBSYSTEM TORTURE_RAP
@@ -273,9 +277,11 @@ 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 \
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index d232f49016..79eb7eb0e9 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -26,29 +26,31 @@
#include "librpc/gen_ndr/security.h"
#include "auth/credentials/credentials.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 {
- BOOL showall;
- BOOL analyze;
- BOOL analyze_always;
- BOOL analyze_continuous;
+ bool showall;
+ bool analyze;
+ bool analyze_always;
+ bool analyze_continuous;
uint_t max_open_handles;
uint_t seed;
uint_t numops;
- BOOL use_oplocks;
+ bool use_oplocks;
char **ignore_patterns;
const char *seeds_file;
- BOOL use_preset_seeds;
- BOOL fast_reconnect;
+ bool use_preset_seeds;
+ bool fast_reconnect;
} options;
/* mapping between open handles on the server and local handles */
static struct {
- BOOL active;
+ bool active;
uint_t instance;
uint_t server_fnum[NSERVERS];
const char *name;
@@ -67,17 +69,17 @@ static struct {
/* the seeds and flags for each operation */
static struct {
uint_t seed;
- BOOL disabled;
+ bool disabled;
} *op_parms;
/* oplock break info */
static struct {
- BOOL got_break;
+ bool got_break;
uint16_t fnum;
uint16_t handle;
uint8_t level;
- BOOL do_close;
+ bool do_close;
} oplocks[NSERVERS][NINSTANCES];
/* change notify reply info */
@@ -100,32 +102,32 @@ static struct {
#define BAD_HANDLE 0xFFFE
-static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private);
+static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private);
static void idle_func(struct smbcli_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)
+static bool ignore_pattern(const char *str)
{
int i;
- if (!options.ignore_patterns) return False;
+ 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 true;
}
}
- return False;
+ return false;
}
/*****************************************************
connect to the servers
*******************************************************/
-static BOOL connect_servers_fast(void)
+static bool connect_servers_fast(void)
{
int h, i;
@@ -135,13 +137,13 @@ static BOOL connect_servers_fast(void)
for (i=0;i<NSERVERS;i++) {
if (NT_STATUS_IS_ERR((smbcli_close(servers[i].cli[open_handles[h].instance]->tree,
open_handles[h].server_fnum[i])))) {
- return False;
+ return false;
}
- open_handles[h].active = False;
+ open_handles[h].active = false;
}
}
- return True;
+ return true;
}
@@ -150,13 +152,13 @@ static BOOL connect_servers_fast(void)
/*****************************************************
connect to the servers
*******************************************************/
-static BOOL connect_servers(void)
+static bool connect_servers(void)
{
int i, j;
if (options.fast_reconnect && servers[0].cli[0]) {
if (connect_servers_fast()) {
- return True;
+ return true;
}
}
@@ -189,7 +191,7 @@ static BOOL connect_servers(void)
printf("Failed to connect to \\\\%s\\%s - %s\n",
servers[i].server_name, servers[i].share_name,
nt_errstr(status));
- return False;
+ return false;
}
smbcli_oplock_handler(servers[i].cli[j]->transport, oplock_handler, NULL);
@@ -197,7 +199,7 @@ static BOOL connect_servers(void)
}
}
- return True;
+ return true;
}
/*
@@ -254,7 +256,7 @@ static void gen_add_handle(int instance, const char *name, uint16_t fnums[NSERVE
for (i=0;i<NSERVERS;i++) {
open_handles[h].server_fnum[i] = fnums[i];
open_handles[h].instance = instance;
- open_handles[h].active = True;
+ open_handles[h].active = true;
open_handles[h].name = name;
}
num_open_handles++;
@@ -274,7 +276,7 @@ static void gen_remove_handle(int instance, uint16_t fnums[NSERVERS])
for (h=0;h<options.max_open_handles;h++) {
if (instance == open_handles[h].instance &&
open_handles[h].server_fnum[0] == fnums[0]) {
- open_handles[h].active = False;
+ open_handles[h].active = false;
num_open_handles--;
printf("CLOSE num_open_handles=%d h=%d s1=0x%x s2=0x%x (%s)\n",
num_open_handles, h,
@@ -288,9 +290,9 @@ static void gen_remove_handle(int instance, uint16_t fnums[NSERVERS])
}
/*
- return True with 'chance' probability as a percentage
+ return true with 'chance' probability as a percentage
*/
-static BOOL gen_chance(uint_t chance)
+static bool gen_chance(uint_t chance)
{
return ((random() % 100) <= chance);
}
@@ -472,7 +474,7 @@ static uint32_t gen_bits_mask2(uint32_t mask1, uint32_t mask2)
/*
generate a boolean
*/
-static BOOL gen_bool(void)
+static bool gen_bool(void)
{
return gen_bits_mask2(0x1, 0xFF);
}
@@ -725,11 +727,11 @@ static void oplock_handler_close_recv(struct smbcli_request *req)
/*
the oplock handler will either ack the break or close the file
*/
-static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
+static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private)
{
union smb_close io;
int i, j;
- BOOL do_close;
+ bool do_close;
struct smbcli_tree *tree = NULL;
struct smbcli_request *req;
@@ -740,7 +742,7 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin
for (j=0;j<NINSTANCES;j++) {
if (transport == servers[i].cli[j]->transport &&
tid == servers[i].cli[j]->tree->tid) {
- oplocks[i][j].got_break = True;
+ oplocks[i][j].got_break = true;
oplocks[i][j].fnum = fnum;
oplocks[i][j].handle = fnum_to_handle(i, j, fnum);
oplocks[i][j].level = level;
@@ -752,7 +754,7 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin
if (!tree) {
printf("Oplock break not for one of our trees!?\n");
- return False;
+ return false;
}
if (!do_close) {
@@ -769,13 +771,13 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin
if (req == NULL) {
printf("WARNING: close failed in oplock_handler_close\n");
- return False;
+ return false;
}
req->async.fn = oplock_handler_close_recv;
req->async.private = NULL;
- return True;
+ return true;
}
@@ -802,19 +804,19 @@ static void idle_func(struct smbcli_transport *transport, void *private)
/*
compare NTSTATUS, using checking ignored patterns
*/
-static BOOL compare_status(NTSTATUS status1, NTSTATUS status2)
+static bool compare_status(NTSTATUS status1, NTSTATUS status2)
{
- if (NT_STATUS_EQUAL(status1, status2)) return True;
+ 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 (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 true;
}
- return False;
+ return false;
}
@@ -837,7 +839,7 @@ static void check_pending(void)
/*
check that the same oplock breaks have been received by all instances
*/
-static BOOL check_oplocks(const char *call)
+static bool check_oplocks(const char *call)
{
int i, j;
int tries = 0;
@@ -858,7 +860,7 @@ again:
oplocks[i][j].got_break,
oplocks[i][j].handle,
oplocks[i][j].level);
- return False;
+ return false;
}
}
}
@@ -875,14 +877,14 @@ again:
break;
}
}
- return True;
+ return true;
}
/*
check that the same change notify info has been received by all instances
*/
-static BOOL check_notifies(const char *call)
+static bool check_notifies(const char *call)
{
int i, j;
int tries = 0;
@@ -900,7 +902,7 @@ again:
printf("Notify count inconsistent %d %d\n",
notifies[0][j].notify_count,
notifies[i][j].notify_count);
- return False;
+ return false;
}
if (notifies[0][j].notify_count == 0) continue;
@@ -910,7 +912,7 @@ again:
printf("Notify status mismatch - %s - %s\n",
nt_errstr(notifies[0][j].status),
nt_errstr(notifies[i][j].status));
- return False;
+ return false;
}
if (!NT_STATUS_IS_OK(notifies[0][j].status)) {
@@ -926,21 +928,21 @@ again:
printf("Notify action %d inconsistent %d %d\n", n,
not1.nttrans.out.changes[n].action,
not2.nttrans.out.changes[n].action);
- return False;
+ 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;
+ 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;
+ return false;
}
}
}
@@ -948,7 +950,7 @@ again:
ZERO_STRUCT(notifies);
- return True;
+ return true;
}
@@ -972,13 +974,13 @@ again:
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; \
+ return false; \
} \
} \
- if (!check_oplocks(#call)) return False; \
- if (!check_notifies(#call)) return False; \
+ if (!check_oplocks(#call)) return false; \
+ if (!check_notifies(#call)) return false; \
if (!NT_STATUS_IS_OK(status[0])) { \
- return True; \
+ return true; \
} \
} while(0)
@@ -1011,19 +1013,19 @@ again:
if (parm[0].field != 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; \
+ 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; \
+ 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; \
+ return false; \
} \
CHECK_EQUAL(field.private_length); \
} while(0)
@@ -1031,7 +1033,7 @@ again:
#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; \
+ return false; \
} \
CHECK_EQUAL(field.length); \
} while(0)
@@ -1041,7 +1043,7 @@ again:
!ignore_pattern(#field)) { \
printf("Mismatch in %s - 0x%x 0x%x\n", #field, \
(int)parm[0].field, (int)parm[1].field); \
- return False; \
+ return false; \
} \
} while(0)
@@ -1052,14 +1054,14 @@ again:
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; \
+ return false; \
} \
} while(0)
/*
generate openx operations
*/
-static BOOL handler_openx(int instance)
+static bool handler_openx(int instance)
{
union smb_open parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1097,14 +1099,14 @@ static BOOL handler_openx(int instance)
/* open creates a new file handle */
ADD_HANDLE(parm[0].openx.in.fname, openx.out.file.fnum);
- return True;
+ return true;
}
/*
generate open operations
*/
-static BOOL handler_open(int instance)
+static bool handler_open(int instance)
{
union smb_open parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1131,14 +1133,14 @@ static BOOL handler_open(int instance)
/* open creates a new file handle */
ADD_HANDLE(parm[0].openold.in.fname, openold.out.file.fnum);
- return True;
+ return true;
}
/*
generate ntcreatex operations
*/
-static BOOL handler_ntcreatex(int instance)
+static bool handler_ntcreatex(int instance)
{
union smb_open parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1184,13 +1186,13 @@ static BOOL handler_ntcreatex(int instance)
/* ntcreatex creates a new file handle */
ADD_HANDLE(parm[0].ntcreatex.in.fname, ntcreatex.out.file.fnum);
- return True;
+ return true;
}
/*
generate close operations
*/
-static BOOL handler_close(int instance)
+static bool handler_close(int instance)
{
union smb_close parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1205,13 +1207,13 @@ static BOOL handler_close(int instance)
REMOVE_HANDLE(close.in.file.fnum);
- return True;
+ return true;
}
/*
generate unlink operations
*/
-static BOOL handler_unlink(int instance)
+static bool handler_unlink(int instance)
{
union smb_unlink parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1222,13 +1224,13 @@ static BOOL handler_unlink(int instance)
GEN_COPY_PARM;
GEN_CALL(smb_raw_unlink(tree, &parm[i]));
- return True;
+ return true;
}
/*
generate chkpath operations
*/
-static BOOL handler_chkpath(int instance)
+static bool handler_chkpath(int instance)
{
union smb_chkpath parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1238,13 +1240,13 @@ static BOOL handler_chkpath(int instance)
GEN_COPY_PARM;
GEN_CALL(smb_raw_chkpath(tree, &parm[i]));
- return True;
+ return true;
}
/*
generate mkdir operations
*/
-static BOOL handler_mkdir(int instance)
+static bool handler_mkdir(int instance)
{
union smb_mkdir parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1255,13 +1257,13 @@ static BOOL handler_mkdir(int instance)
GEN_COPY_PARM;
GEN_CALL(smb_raw_mkdir(tree, &parm[i]));
- return True;
+ return true;
}
/*
generate rmdir operations
*/
-static BOOL handler_rmdir(int instance)
+static bool handler_rmdir(int instance)
{
struct smb_rmdir parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1271,13 +1273,13 @@ static BOOL handler_rmdir(int instance)
GEN_COPY_PARM;
GEN_CALL(smb_raw_rmdir(tree, &parm[i]));
- return True;
+ return true;
}
/*
generate rename operations
*/
-static BOOL handler_rename(int instance)
+static bool handler_rename(int instance)
{
union smb_rename parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1290,13 +1292,13 @@ static BOOL handler_rename(int instance)
GEN_COPY_PARM;
GEN_CALL(smb_raw_rename(tree, &parm[i]));
- return True;
+ return true;
}
/*
generate ntrename operations
*/
-static BOOL handler_ntrename(int instance)
+static bool handler_ntrename(int instance)
{
union smb_rename parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1311,14 +1313,14 @@ static BOOL handler_ntrename(int instance)
GEN_COPY_PARM;
GEN_CALL(smb_raw_rename(tree, &parm[i]));
- return True;
+ return true;
}
/*
generate seek operations
*/
-static BOOL handler_seek(int instance)
+static bool handler_seek(int instance)
{
union smb_seek parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1333,14 +1335,14 @@ static BOOL handler_seek(int instance)
CHECK_EQUAL(lseek.out.offset);
- return True;
+ return true;
}
/*
generate readx operations
*/
-static BOOL handler_readx(int instance)
+static bool handler_readx(int instance)
{
union smb_read parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1352,7 +1354,7 @@ static BOOL handler_readx(int instance)
parm[0].readx.in.maxcnt = gen_io_count();
parm[0].readx.in.remaining = gen_io_count();
parm[0].readx.in.read_for_execute = gen_bool();
- parm[0].readx.out.data = talloc_size(current_op.mem_ctx,
+ parm[0].readx.out.data = talloc_array(current_op.mem_ctx, uint8_t,
MAX(parm[0].readx.in.mincnt, parm[0].readx.in.maxcnt));
GEN_COPY_PARM;
@@ -1363,13 +1365,13 @@ static BOOL handler_readx(int instance)
CHECK_EQUAL(readx.out.compaction_mode);
CHECK_EQUAL(readx.out.nread);
- return True;
+ return true;
}
/*
generate writex operations
*/
-static BOOL handler_writex(int instance)
+static bool handler_writex(int instance)
{
union smb_write parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1380,7 +1382,7 @@ static BOOL handler_writex(int instance)
parm[0].writex.in.wmode = gen_bits_mask(0xFFFF);
parm[0].writex.in.remaining = gen_io_count();
parm[0].writex.in.count = gen_io_count();
- parm[0].writex.in.data = talloc_zero_size(current_op.mem_ctx, parm[0].writex.in.count);
+ parm[0].writex.in.data = talloc_zero_array(current_op.mem_ctx, uint8_t, parm[0].writex.in.count);
GEN_COPY_PARM;
GEN_SET_FNUM(writex.in.file.fnum);
@@ -1389,13 +1391,13 @@ static BOOL handler_writex(int instance)
CHECK_EQUAL(writex.out.nwritten);
CHECK_EQUAL(writex.out.remaining);
- return True;
+ return true;
}
/*
generate lockingx operations
*/
-static BOOL handler_lockingx(int instance)
+static bool handler_lockingx(int instance)
{
union smb_lock parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1428,7 +1430,7 @@ static BOOL handler_lockingx(int instance)
GEN_SET_FNUM(lockx.in.file.fnum);
GEN_CALL(smb_raw_lock(tree, &parm[i]));
- return True;
+ return true;
}
/*
@@ -1463,7 +1465,7 @@ static void gen_fileinfo(int instance, union smb_fileinfo *info)
/*
compare returned fileinfo structures
*/
-static BOOL cmp_fileinfo(int instance,
+static bool cmp_fileinfo(int instance,
union smb_fileinfo parm[NSERVERS],
NTSTATUS status[NSERVERS])
{
@@ -1471,7 +1473,7 @@ static BOOL cmp_fileinfo(int instance,
switch (parm[0].generic.level) {
case RAW_FILEINFO_GENERIC:
- return False;
+ return false;
case RAW_FILEINFO_GETATTR:
CHECK_EQUAL(getattr.out.attrib);
@@ -1633,13 +1635,13 @@ static BOOL cmp_fileinfo(int instance,
break;
}
- return True;
+ return true;
}
/*
generate qpathinfo operations
*/
-static BOOL handler_qpathinfo(int instance)
+static bool handler_qpathinfo(int instance)
{
union smb_fileinfo parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1657,7 +1659,7 @@ static BOOL handler_qpathinfo(int instance)
/*
generate qfileinfo operations
*/
-static BOOL handler_qfileinfo(int instance)
+static bool handler_qfileinfo(int instance)
{
union smb_fileinfo parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1775,7 +1777,7 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
/*
generate setpathinfo operations
*/
-static BOOL handler_spathinfo(int instance)
+static bool handler_spathinfo(int instance)
{
union smb_setfileinfo parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1794,14 +1796,14 @@ static BOOL handler_spathinfo(int instance)
GEN_CALL(smb_raw_setpathinfo(tree, &parm[i]));
- return True;
+ return true;
}
/*
generate setfileinfo operations
*/
-static BOOL handler_sfileinfo(int instance)
+static bool handler_sfileinfo(int instance)
{
union smb_setfileinfo parm[NSERVERS];
NTSTATUS status[NSERVERS];
@@ -1814,14 +1816,14 @@ static BOOL handler_sfileinfo(int instance)
GEN_SET_FNUM(generic.in.file.fnum);
GEN_CALL(smb_raw_setfileinfo(tree, &parm[i]));
- return True;
+ return true;
}
/*
generate change notify operations
*/
-static BOOL handler_notify(int instance)
+static bool handler_notify(int instance)
{
union smb_notify parm[NSERVERS];
int n;
@@ -1842,7 +1844,7 @@ static BOOL handler_notify(int instance)
req->async.fn = async_notify;
}
- return True;
+ return true;
}
/*
@@ -1896,7 +1898,7 @@ static void dump_seeds(void)
*/
static struct {
const char *name;
- BOOL (*handler)(int instance);
+ bool (*handler)(int instance);
int count, success_count;
} gen_ops[] = {
{"OPEN", handler_open},
@@ -1950,7 +1952,7 @@ static int run_test(void)
for (op=0; op<options.numops; op++) {
int instance, which_op;
- BOOL ret;
+ bool ret;
if (op_parms[op].disabled) continue;
@@ -2023,14 +2025,14 @@ static void backtrack_analyze(void)
/* mark this range as disabled */
max = MIN(options.numops, base+chunk);
for (i=base;i<max; i++) {
- op_parms[i].disabled = True;
+ op_parms[i].disabled = true;
}
printf("Testing %d ops with %d-%d disabled\n",
options.numops, base, max-1);
ret = run_test();
printf("Completed %d of %d ops\n", ret, options.numops);
for (i=base;i<max; i++) {
- op_parms[i].disabled = False;
+ op_parms[i].disabled = false;
}
if (ret == options.numops) {
/* this chunk is needed */
@@ -2068,7 +2070,7 @@ static void backtrack_analyze(void)
/*
start the main gentest process
*/
-static BOOL start_gentest(void)
+static bool start_gentest(void)
{
int op;
int ret;
@@ -2143,21 +2145,21 @@ static void usage(void)
/**
split a UNC name into server and share names
*/
-static BOOL split_unc_name(const char *unc, char **server, char **share)
+static bool split_unc_name(const char *unc, char **server, char **share)
{
char *p = strdup(unc);
- if (!p) return False;
+ if (!p) return false;
all_string_sub(p, "\\", "/", 0);
- if (strncmp(p, "//", 2) != 0) return False;
+ if (strncmp(p, "//", 2) != 0) return false;
(*server) = p+2;
p = strchr(*server, '/');
- if (!p) return False;
+ if (!p) return false;
*p = 0;
(*share) = p+1;
- return True;
+ return true;
}
@@ -2169,7 +2171,7 @@ static BOOL split_unc_name(const char *unc, char **server, char **share)
{
int opt;
int i, username_count=0;
- BOOL ret;
+ bool ret;
setlinebuf(stdout);
@@ -2194,7 +2196,7 @@ static BOOL split_unc_name(const char *unc, char **server, char **share)
argc -= NSERVERS;
argv += NSERVERS;
- lp_load();
+ lp_load(dyn_CONFIGFILE);
servers[0].credentials = cli_credentials_init(talloc_autofree_context());
servers[1].credentials = cli_credentials_init(talloc_autofree_context());
@@ -2228,28 +2230,28 @@ static BOOL split_unc_name(const char *unc, char **server, char **share)
options.seeds_file = optarg;
break;
case 'L':
- options.use_preset_seeds = True;
+ options.use_preset_seeds = true;
break;
case 'F':
- options.fast_reconnect = True;
+ options.fast_reconnect = true;
break;
case 'o':
options.numops = atoi(optarg);
break;
case 'O':
- options.use_oplocks = True;
+ options.use_oplocks = true;
break;
case 'a':
- options.showall = True;
+ options.showall = true;
break;
case 'A':
- options.analyze = True;
+ options.analyze = true;
break;
case 'X':
- options.analyze_always = True;
+ options.analyze_always = true;
break;
case 'C':
- options.analyze_continuous = True;
+ options.analyze_continuous = true;
break;
case 'i':
options.ignore_patterns = file_lines_load(optarg, NULL, NULL);
diff --git a/source4/torture/ldap/basic.c b/source4/torture/ldap/basic.c
index e7d1365c24..3f030c97ba 100644
--- a/source4/torture/ldap/basic.c
+++ b/source4/torture/ldap/basic.c
@@ -27,37 +27,37 @@
#include "torture/torture.h"
#include "torture/ldap/proto.h"
-static BOOL test_bind_simple(struct ldap_connection *conn, const char *userdn, const char *password)
+static bool test_bind_simple(struct ldap_connection *conn, const char *userdn, const char *password)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
status = torture_ldap_bind(conn, userdn, password);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_bind_sasl(struct ldap_connection *conn, struct cli_credentials *creds)
+static bool test_bind_sasl(struct ldap_connection *conn, struct cli_credentials *creds)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("Testing sasl bind as user\n");
status = torture_ldap_bind_sasl(conn, creds);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_multibind(struct ldap_connection *conn, const char *userdn, const char *password)
+static bool test_multibind(struct ldap_connection *conn, const char *userdn, const char *password)
{
- BOOL ret = True;
+ bool ret = true;
printf("Testing multiple binds on a single connnection as anonymous and user\n");
@@ -75,9 +75,9 @@ static BOOL test_multibind(struct ldap_connection *conn, const char *userdn, con
return ret;
}
-static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn)
+static bool test_search_rootDSE(struct ldap_connection *conn, char **basedn)
{
- BOOL ret = True;
+ bool ret = true;
struct ldap_message *msg, *result;
struct ldap_request *req;
int i;
@@ -90,7 +90,7 @@ static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn)
msg = new_ldap_message(conn);
if (!msg) {
- return False;
+ return false;
}
msg->type = LDAP_TAG_SearchRequest;
@@ -99,7 +99,7 @@ static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn)
msg->r.SearchRequest.deref = LDAP_DEREFERENCE_NEVER;
msg->r.SearchRequest.timelimit = 0;
msg->r.SearchRequest.sizelimit = 0;
- msg->r.SearchRequest.attributesonly = False;
+ msg->r.SearchRequest.attributesonly = false;
msg->r.SearchRequest.tree = ldb_parse_tree(msg, "(objectclass=*)");
msg->r.SearchRequest.num_attributes = 0;
msg->r.SearchRequest.attributes = NULL;
@@ -107,13 +107,13 @@ static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn)
req = ldap_request_send(conn, msg);
if (req == NULL) {
printf("Could not setup ldap search\n");
- return False;
+ return false;
}
status = ldap_result_one(req, &result, LDAP_TAG_SearchResultEntry);
if (!NT_STATUS_IS_OK(status)) {
printf("search failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("received %d replies\n", req->num_replies);
@@ -142,7 +142,7 @@ static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn)
return ret;
}
-static BOOL test_compare_sasl(struct ldap_connection *conn, const char *basedn)
+static bool test_compare_sasl(struct ldap_connection *conn, const char *basedn)
{
struct ldap_message *msg, *rep;
struct ldap_request *req;
@@ -152,12 +152,12 @@ static BOOL test_compare_sasl(struct ldap_connection *conn, const char *basedn)
printf("Testing SASL Compare: %s\n", basedn);
if (!basedn) {
- return False;
+ return false;
}
msg = new_ldap_message(conn);
if (!msg) {
- return False;
+ return false;
}
msg->type = LDAP_TAG_CompareRequest;
@@ -168,13 +168,13 @@ static BOOL test_compare_sasl(struct ldap_connection *conn, const char *basedn)
req = ldap_request_send(conn, msg);
if (!req) {
- return False;
+ return false;
}
status = ldap_result_one(req, &rep, LDAP_TAG_CompareResponse);
if (!NT_STATUS_IS_OK(status)) {
printf("error in ldap compare request - %s\n", nt_errstr(status));
- return False;
+ return false;
}
DEBUG(5,("Code: %d DN: [%s] ERROR:[%s] REFERRAL:[%s]\n",
@@ -183,16 +183,16 @@ static BOOL test_compare_sasl(struct ldap_connection *conn, const char *basedn)
rep->r.CompareResponse.errormessage,
rep->r.CompareResponse.referral));
- return True;
+ return true;
}
-BOOL torture_ldap_basic(struct torture_context *torture)
+bool torture_ldap_basic(struct torture_context *torture)
{
NTSTATUS status;
struct ldap_connection *conn;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
const char *host = torture_setting_string(torture, "host", NULL);
const char *userdn = torture_setting_string(torture, "ldap_userdn", NULL);
const char *secret = torture_setting_string(torture, "ldap_secret", NULL);
@@ -205,25 +205,25 @@ BOOL torture_ldap_basic(struct torture_context *torture)
status = torture_ldap_connection(mem_ctx, &conn, url);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
if (!test_search_rootDSE(conn, &basedn)) {
- ret = False;
+ ret = false;
}
/* other basic tests here */
if (!test_multibind(conn, userdn, secret)) {
- ret = False;
+ ret = false;
}
if (!test_bind_sasl(conn, cmdline_credentials)) {
- ret = False;
+ ret = false;
}
if (!test_compare_sasl(conn, basedn)) {
- ret = False;
+ ret = false;
}
/* no more test we are closing */
diff --git a/source4/torture/ldap/cldap.c b/source4/torture/ldap/cldap.c
index 8b7fa20b74..f258a1c32f 100644
--- a/source4/torture/ldap/cldap.c
+++ b/source4/torture/ldap/cldap.c
@@ -31,7 +31,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
} \
} while (0)
@@ -39,7 +39,7 @@
/*
test netlogon operations
*/
-static BOOL test_cldap_netlogon(TALLOC_CTX *mem_ctx, const char *dest)
+static bool test_cldap_netlogon(TALLOC_CTX *mem_ctx, const char *dest)
{
struct cldap_socket *cldap = cldap_socket_init(mem_ctx, NULL);
NTSTATUS status;
@@ -47,7 +47,7 @@ static BOOL test_cldap_netlogon(TALLOC_CTX *mem_ctx, const char *dest)
union nbt_cldap_netlogon n1;
struct GUID guid;
int i;
- BOOL ret = True;
+ bool ret = true;
ZERO_STRUCT(search);
search.in.dest_address = dest;
@@ -203,12 +203,12 @@ static void cldap_dump_results(struct cldap_search *search)
/*
test generic cldap operations
*/
-static BOOL test_cldap_generic(TALLOC_CTX *mem_ctx, const char *dest)
+static bool test_cldap_generic(TALLOC_CTX *mem_ctx, const char *dest)
{
struct cldap_socket *cldap = cldap_socket_init(mem_ctx, NULL);
NTSTATUS status;
struct cldap_search search;
- BOOL ret = True;
+ bool ret = true;
const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL };
const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL };
const char *attrs3[] = { "netlogon", NULL };
@@ -270,10 +270,10 @@ done:
return ret;
}
-BOOL torture_cldap(struct torture_context *torture)
+bool torture_cldap(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
const char *host = torture_setting_string(torture, "host", NULL);
mem_ctx = talloc_init("torture_cldap");
diff --git a/source4/torture/ldap/cldapbench.c b/source4/torture/ldap/cldapbench.c
index 52d8689927..9f860f98d9 100644
--- a/source4/torture/ldap/cldapbench.c
+++ b/source4/torture/ldap/cldapbench.c
@@ -53,7 +53,7 @@ static bool bench_cldap(struct torture_context *tctx, const char *address)
struct cldap_socket *cldap = cldap_socket_init(tctx, NULL);
int num_sent=0;
struct timeval tv = timeval_current();
- BOOL ret = True;
+ bool ret = true;
int timelimit = torture_setting_int(tctx, "timelimit", 10);
struct cldap_netlogon search;
struct bench_state *state;
diff --git a/source4/torture/ldap/schema.c b/source4/torture/ldap/schema.c
index f754880d0b..30fd9877e6 100644
--- a/source4/torture/ldap/schema.c
+++ b/source4/torture/ldap/schema.c
@@ -31,6 +31,8 @@
#include "torture/torture.h"
#include "torture/ldap/proto.h"
+#include "param/param.h"
+
struct test_rootDSE {
const char *defaultdn;
const char *rootdn;
@@ -41,13 +43,13 @@ struct test_rootDSE {
struct test_schema_ctx {
struct ldb_paged_control *ctrl;
uint32_t count;
- BOOL pending;
+ bool pending;
int (*callback)(void *, struct ldb_context *ldb, struct ldb_message *);
void *private_data;
};
-static BOOL test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *root)
+static bool test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *root)
{
int ret;
struct ldb_message *msg;
@@ -58,10 +60,10 @@ static BOOL test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *ro
ret = ldb_search(ldb, ldb_dn_new(ldb, ldb, NULL), LDB_SCOPE_BASE,
NULL, NULL, &r);
if (ret != LDB_SUCCESS) {
- return False;
+ return false;
} else if (r->count != 1) {
talloc_free(r);
- return False;
+ return false;
}
msg = r->msgs[0];
@@ -77,7 +79,7 @@ static BOOL test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *ro
talloc_free(r);
- return True;
+ return true;
}
static int test_schema_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
@@ -113,7 +115,7 @@ static int test_schema_search_callback(struct ldb_context *ldb, void *context, s
actx->ctrl->cookie_len = ctrl->cookie_len;
if (actx->ctrl->cookie_len > 0) {
- actx->pending = True;
+ actx->pending = true;
}
}
break;
@@ -136,7 +138,7 @@ static int test_schema_search_callback(struct ldb_context *ldb, void *context, s
return LDB_SUCCESS;
}
-static BOOL test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE *root,
+static bool test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE *root,
const char *filter,
int (*callback)(void *, struct ldb_context *ldb, struct ldb_message *),
void *private_data)
@@ -153,7 +155,7 @@ static BOOL test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE
ctrl = talloc_array(req, struct ldb_control *, 2);
ctrl[0] = talloc(ctrl, struct ldb_control);
ctrl[0]->oid = LDB_CONTROL_PAGED_RESULTS_OID;
- ctrl[0]->critical = True;
+ ctrl[0]->critical = true;
control = talloc(ctrl[0], struct ldb_paged_control);
control->size = 1000;
control->cookie = NULL;
@@ -177,25 +179,25 @@ static BOOL test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE
actx->callback = callback;
actx->private_data = private_data;
again:
- actx->pending = False;
+ actx->pending = false;
ret = ldb_request(ldb, req);
if (ret != LDB_SUCCESS) {
d_printf("search failed - %s\n", ldb_errstring(ldb));
- return False;
+ return false;
}
ret = ldb_wait(req->handle, LDB_WAIT_ALL);
if (ret != LDB_SUCCESS) {
d_printf("search error - %s\n", ldb_errstring(ldb));
- return False;
+ return false;
}
if (actx->pending)
goto again;
d_printf("filter[%s] count[%u]\n", filter, actx->count);
- return True;
+ return true;
}
static int test_add_attribute(void *ptr, struct ldb_context *ldb, struct ldb_message *msg)
@@ -243,9 +245,9 @@ failed:
return LDB_ERR_OTHER;
}
-static BOOL test_create_schema(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema **_schema)
+static bool test_create_schema(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema **_schema)
{
- BOOL ret = True;
+ bool ret = true;
struct dsdb_schema *schema;
schema = talloc_zero(ldb, struct dsdb_schema);
@@ -257,13 +259,13 @@ static BOOL test_create_schema(struct ldb_context *ldb, struct test_rootDSE *roo
ret &= test_create_schema_type(ldb, root, "(objectClass=classSchema)",
test_add_class, schema);
- if (ret == True) {
+ if (ret == true) {
*_schema = schema;
}
return ret;
}
-static BOOL test_dump_not_replicated(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema)
+static bool test_dump_not_replicated(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema)
{
struct dsdb_attribute *a;
uint32_t a_i = 1;
@@ -276,10 +278,10 @@ static BOOL test_dump_not_replicated(struct ldb_context *ldb, struct test_rootDS
a->lDAPDisplayName);
}
- return True;
+ return true;
}
-static BOOL test_dump_partial(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema)
+static bool test_dump_partial(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema)
{
struct dsdb_attribute *a;
uint32_t a_i = 1;
@@ -293,10 +295,10 @@ static BOOL test_dump_partial(struct ldb_context *ldb, struct test_rootDSE *root
a->lDAPDisplayName);
}
- return True;
+ return true;
}
-static BOOL test_dump_contructed(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema)
+static bool test_dump_contructed(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema)
{
struct dsdb_attribute *a;
uint32_t a_i = 1;
@@ -309,10 +311,10 @@ static BOOL test_dump_contructed(struct ldb_context *ldb, struct test_rootDSE *r
a->lDAPDisplayName);
}
- return True;
+ return true;
}
-static BOOL test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema)
+static bool test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema)
{
struct dsdb_attribute *a;
uint32_t a_i = 1;
@@ -348,7 +350,7 @@ static BOOL test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE
om_hex = data_blob_hex_string(ldb, &a->oMObjectClass);
if (!om_hex) {
- return False;
+ return false;
}
d_printf("attr[%4u]: %s %u '%s' '%s'\n", a_i++,
@@ -358,13 +360,13 @@ static BOOL test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE
}
}
- return True;
+ return true;
}
-BOOL torture_ldap_schema(struct torture_context *torture)
+bool torture_ldap_schema(struct torture_context *torture)
{
struct ldb_context *ldb;
- BOOL ret = True;
+ bool ret = true;
const char *host = torture_setting_string(torture, "host", NULL);
char *url;
struct test_rootDSE rootDSE;
@@ -374,7 +376,7 @@ BOOL torture_ldap_schema(struct torture_context *torture)
url = talloc_asprintf(torture, "ldap://%s/", host);
- ldb = ldb_wrap_connect(torture, url,
+ ldb = ldb_wrap_connect(torture, global_loadparm, url,
NULL,
cmdline_credentials,
0, NULL);
diff --git a/source4/torture/ldap/uptodatevector.c b/source4/torture/ldap/uptodatevector.c
index 0ff9948cad..b3c6e8d555 100644
--- a/source4/torture/ldap/uptodatevector.c
+++ b/source4/torture/ldap/uptodatevector.c
@@ -34,6 +34,8 @@
#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"
+#include "param/param.h"
+
static bool test_check_uptodatevector(struct torture_context *torture,
struct ldb_context *ldb,
struct ldb_dn *partition_dn)
@@ -148,17 +150,17 @@ static bool test_check_uptodatevector(struct torture_context *torture,
return ok;
}
-BOOL torture_ldap_uptodatevector(struct torture_context *torture)
+bool torture_ldap_uptodatevector(struct torture_context *torture)
{
struct ldb_context *ldb;
- BOOL ret = True;
+ bool ret = true;
const char *host = torture_setting_string(torture, "host", NULL);
char *url;
url = talloc_asprintf(torture, "ldap://%s/", host);
if (!url) goto failed;
- ldb = ldb_wrap_connect(torture, url,
+ ldb = ldb_wrap_connect(torture, global_loadparm, url,
NULL,
cmdline_credentials,
0, NULL);
@@ -170,5 +172,5 @@ BOOL torture_ldap_uptodatevector(struct torture_context *torture)
return ret;
failed:
- return False;
+ return false;
}
diff --git a/source4/torture/libnet/domain.c b/source4/torture/libnet/domain.c
index 17b8a94f42..daf9012e0c 100644
--- a/source4/torture/libnet/domain.c
+++ b/source4/torture/libnet/domain.c
@@ -23,8 +23,9 @@
#include "lib/events/events.h"
#include "libnet/libnet.h"
#include "librpc/gen_ndr/ndr_samr_c.h"
+#include "param/param.h"
-static BOOL test_domainopen(struct libnet_context *net_ctx, TALLOC_CTX *mem_ctx,
+static bool test_domainopen(struct libnet_context *net_ctx, TALLOC_CTX *mem_ctx,
struct lsa_String *domname,
struct policy_handle *domain_handle)
{
@@ -39,15 +40,15 @@ static BOOL test_domainopen(struct libnet_context *net_ctx, TALLOC_CTX *mem_ctx,
status = libnet_DomainOpen(net_ctx, mem_ctx, &io);
if (!NT_STATUS_IS_OK(status)) {
printf("Composite domain open failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
*domain_handle = io.out.domain_handle;
- return True;
+ return true;
}
-static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle)
{
NTSTATUS status;
@@ -62,20 +63,20 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Close(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Close failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_domainopen(struct torture_context *torture)
+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;
+ bool ret = true;
struct policy_handle h;
struct lsa_String name;
@@ -89,21 +90,21 @@ BOOL torture_domainopen(struct torture_context *torture)
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- name.string = lp_workgroup();
+ name.string = lp_workgroup(global_loadparm);
/*
* Testing synchronous version
*/
if (!test_domainopen(net_ctx, mem_ctx, &name, &h)) {
- ret = False;
+ ret = false;
goto done;
}
if (!test_cleanup(net_ctx->samr.pipe, mem_ctx, &h)) {
- ret = False;
+ ret = false;
goto done;
}
diff --git a/source4/torture/libnet/groupinfo.c b/source4/torture/libnet/groupinfo.c
index 0dca1519de..bff2f405cd 100644
--- a/source4/torture/libnet/groupinfo.c
+++ b/source4/torture/libnet/groupinfo.c
@@ -23,163 +23,13 @@
#include "libnet/libnet.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_samr_c.h"
+#include "param/param.h"
+#include "torture/libnet/utils.h"
#define TEST_GROUPNAME "libnetgroupinfotest"
-static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, struct lsa_String *domname,
- struct dom_sid2 *sid)
-{
- NTSTATUS status;
- struct policy_handle h, domain_handle;
- struct samr_Connect r1;
- struct samr_LookupDomain r2;
- struct samr_OpenDomain r3;
-
- printf("connecting\n");
-
- r1.in.system_name = 0;
- r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r1.out.connect_handle = &h;
-
- status = dcerpc_samr_Connect(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Connect failed - %s\n", nt_errstr(status));
- return False;
- }
-
- r2.in.connect_handle = &h;
- r2.in.domain_name = domname;
-
- printf("domain lookup on %s\n", domname->string);
-
- status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LookupDomain failed - %s\n", nt_errstr(status));
- return False;
- }
-
- r3.in.connect_handle = &h;
- r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r3.in.sid = r2.out.sid;
- r3.out.domain_handle = &domain_handle;
-
- printf("opening domain\n");
-
- status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenDomain failed - %s\n", nt_errstr(status));
- return False;
- } else {
- *handle = domain_handle;
- }
-
- *sid = *r2.out.sid;
- return True;
-}
-
-
-static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *domain_handle, const char *groupname)
-{
- NTSTATUS status;
- struct samr_LookupNames r1;
- struct samr_OpenGroup r2;
- struct samr_DeleteDomainGroup r3;
- struct lsa_String names[2];
- uint32_t rid;
- struct policy_handle group_handle;
-
- names[0].string = groupname;
-
- r1.in.domain_handle = domain_handle;
- r1.in.num_names = 1;
- r1.in.names = names;
-
- printf("group account lookup '%s'\n", groupname);
-
- status = dcerpc_samr_LookupNames(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LookupNames failed - %s\n", nt_errstr(status));
- return False;
- }
-
- rid = r1.out.rids.ids[0];
-
- r2.in.domain_handle = domain_handle;
- r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r2.in.rid = rid;
- r2.out.group_handle = &group_handle;
-
- printf("opening group account\n");
-
- status = dcerpc_samr_OpenGroup(p, mem_ctx, &r2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenUser failed - %s\n", nt_errstr(status));
- return False;
- }
-
- r3.in.group_handle = &group_handle;
- r3.out.group_handle = &group_handle;
-
- printf("deleting group account\n");
-
- status = dcerpc_samr_DeleteDomainGroup(p, mem_ctx, &r3);
- if (!NT_STATUS_IS_OK(status)) {
- printf("DeleteGroup failed - %s\n", nt_errstr(status));
- return False;
- }
-
- return True;
-}
-
-
-static BOOL test_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, const char *name, uint32_t *rid)
-{
- NTSTATUS status;
- struct lsa_String groupname;
- struct samr_CreateDomainGroup r;
- struct policy_handle group_handle;
-
- groupname.string = name;
-
- r.in.domain_handle = handle;
- r.in.name = &groupname;
- r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r.out.group_handle = &group_handle;
- r.out.rid = rid;
-
- printf("creating group account %s\n", name);
-
- status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("CreateGroup failed - %s\n", nt_errstr(status));
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
- printf("Group (%s) already exists - attempting to delete and recreate account again\n", name);
- if (!test_cleanup(p, mem_ctx, handle, TEST_GROUPNAME)) {
- return False;
- }
-
- printf("creating group account\n");
-
- status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("CreateGroup failed - %s\n", nt_errstr(status));
- return False;
- }
- return True;
- }
- return False;
- }
-
- return True;
-}
-
-
-static BOOL test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
struct dom_sid2 *domain_sid, const char* group_name,
uint32_t *rid)
@@ -199,7 +49,7 @@ static BOOL test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = libnet_rpc_groupinfo(p, mem_ctx, &group);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
- return False;
+ return false;
}
ZERO_STRUCT(group);
@@ -213,19 +63,19 @@ static BOOL test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = libnet_rpc_groupinfo(p, mem_ctx, &group);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to call sync libnet_rpc_groupinfo - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_groupinfo(struct torture_context *torture)
+bool torture_groupinfo(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct policy_handle h;
struct lsa_String name;
struct dom_sid2 sid;
@@ -238,31 +88,31 @@ BOOL torture_groupinfo(struct torture_context *torture)
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- name.string = lp_workgroup();
+ name.string = lp_workgroup(global_loadparm);
/*
* Testing synchronous version
*/
if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) {
- ret = False;
+ ret = false;
goto done;
}
- if (!test_create(p, mem_ctx, &h, TEST_GROUPNAME, &rid)) {
- ret = False;
+ if (!test_group_create(p, mem_ctx, &h, TEST_GROUPNAME, &rid)) {
+ ret = false;
goto done;
}
if (!test_groupinfo(p, mem_ctx, &h, &sid, TEST_GROUPNAME, &rid)) {
- ret = False;
+ ret = false;
goto done;
}
- if (!test_cleanup(p, mem_ctx, &h, TEST_GROUPNAME)) {
- ret = False;
+ if (!test_group_cleanup(p, mem_ctx, &h, TEST_GROUPNAME)) {
+ ret = false;
goto done;
}
diff --git a/source4/torture/libnet/groupman.c b/source4/torture/libnet/groupman.c
new file mode 100644
index 0000000000..552e02c420
--- /dev/null
+++ b/source4/torture/libnet/groupman.c
@@ -0,0 +1,93 @@
+/*
+ Unix SMB/CIFS implementation.
+ Test suite for libnet calls.
+
+ Copyright (C) Rafal Szczesniak 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 "torture/rpc/rpc.h"
+#include "torture/libnet/grouptest.h"
+#include "libnet/libnet.h"
+#include "librpc/gen_ndr/ndr_samr_c.h"
+#include "param/param.h"
+#include "torture/libnet/utils.h"
+
+
+static bool test_groupadd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *domain_handle,
+ const char *name)
+{
+ NTSTATUS status;
+ bool ret = true;
+ struct libnet_rpc_groupadd group;
+
+ group.in.domain_handle = *domain_handle;
+ group.in.groupname = name;
+
+ printf("Testing libnet_rpc_groupadd\n");
+
+ status = libnet_rpc_groupadd(p, mem_ctx, &group);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to call sync libnet_rpc_groupadd - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ return ret;
+}
+
+
+bool torture_groupadd(struct torture_context *torture)
+{
+ NTSTATUS status;
+ struct dcerpc_pipe *p;
+ struct policy_handle h;
+ struct lsa_String domain_name;
+ struct dom_sid2 sid;
+ const char *name = TEST_GROUPNAME;
+ TALLOC_CTX *mem_ctx;
+ bool ret = true;
+
+ mem_ctx = talloc_init("test_groupadd");
+
+ status = torture_rpc_connection(torture,
+ &p,
+ &ndr_table_samr);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ domain_name.string = lp_workgroup(global_loadparm);
+ if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ ret = false;
+ goto done;
+ }
+
+ if (!test_groupadd(p, mem_ctx, &h, name)) {
+ ret = false;
+ goto done;
+ }
+
+ if (!test_group_cleanup(p, mem_ctx, &h, name)) {
+ ret = false;
+ goto done;
+ }
+
+done:
+ talloc_free(mem_ctx);
+ return ret;
+}
diff --git a/source4/torture/libnet/grouptest.h b/source4/torture/libnet/grouptest.h
new file mode 100644
index 0000000000..9d030acd17
--- /dev/null
+++ b/source4/torture/libnet/grouptest.h
@@ -0,0 +1,20 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) Rafal Szczesniak 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/>.
+*/
+
+#define TEST_GROUPNAME "libnetgrptest"
diff --git a/source4/torture/libnet/libnet.c b/source4/torture/libnet/libnet.c
index dc0e35e102..0e5c9301f8 100644
--- a/source4/torture/libnet/libnet.c
+++ b/source4/torture/libnet/libnet.c
@@ -31,6 +31,7 @@ NTSTATUS torture_net_init(void)
torture_suite_add_simple_test(suite, "USERMOD", torture_usermod);
torture_suite_add_simple_test(suite, "DOMOPEN", torture_domainopen);
torture_suite_add_simple_test(suite, "GROUPINFO", torture_groupinfo);
+ torture_suite_add_simple_test(suite, "GROUPADD", torture_groupadd);
torture_suite_add_simple_test(suite, "API-LOOKUP", torture_lookup);
torture_suite_add_simple_test(suite, "API-LOOKUPHOST", torture_lookup_host);
torture_suite_add_simple_test(suite, "API-LOOKUPPDC", torture_lookup_pdc);
diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c
index 9d67e093b1..edcf92b8ec 100644
--- a/source4/torture/libnet/libnet_BecomeDC.c
+++ b/source4/torture/libnet/libnet_BecomeDC.c
@@ -163,7 +163,7 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
DEBUG(0,("Pathes under PRIVATEDIR[%s]\n"
"SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n",
- lp_private_dir(),
+ lp_private_dir(global_loadparm),
s->path.samdb_ldb,
s->path.secrets_ldb,
s->path.secrets_keytab));
@@ -256,7 +256,7 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
DEBUG(0,("Open the SAM LDB with system credentials: %s\n", s->path.samdb_ldb));
- s->ldb = ldb_wrap_connect(s, s->path.samdb_ldb,
+ s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb,
system_session(s),
NULL, 0, NULL);
if (!s->ldb) {
@@ -345,7 +345,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
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(tmp_dns_name, "._msdcs.%s", c->forest->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;
@@ -442,7 +442,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
return werror_to_ntstatus(status);
}
- if (lp_parm_bool(-1, "become dc", "dump objects", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "become dc", "dump objects", false)) {
for (i=0; i < objs->num_objects; i++) {
struct ldb_ldif ldif;
fprintf(stdout, "#\n");
@@ -484,7 +484,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
s->schema = NULL;
DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema: %s\n", s->path.samdb_ldb));
- s->ldb = ldb_wrap_connect(s, s->path.samdb_ldb,
+ s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb,
system_session(s),
NULL, 0, NULL);
if (!s->ldb) {
@@ -642,7 +642,7 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data,
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(tmp_dns_name, "._msdcs.%s", c->forest->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;
@@ -670,7 +670,7 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data,
return werror_to_ntstatus(status);
}
- if (lp_parm_bool(-1, "become dc", "dump objects", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "become dc", "dump objects", false)) {
for (i=0; i < objs->num_objects; i++) {
struct ldb_ldif ldif;
fprintf(stdout, "#\n");
@@ -700,7 +700,7 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data,
return NT_STATUS_FOOBAR;
}
- if (lp_parm_bool(-1, "become dc", "dump objects", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "become dc", "dump objects", false)) {
DEBUG(0,("# %s\n", sa->lDAPDisplayName));
NDR_PRINT_DEBUG(drsuapi_DsReplicaLinkedAttribute, &linked_attributes[i]);
dump_data(0,
@@ -712,9 +712,9 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data,
return NT_STATUS_OK;
}
-BOOL torture_net_become_dc(struct torture_context *torture)
+bool torture_net_become_dc(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
struct libnet_BecomeDC b;
struct libnet_UnbecomeDC u;
@@ -724,9 +724,9 @@ BOOL torture_net_become_dc(struct torture_context *torture)
uint32_t i;
s = talloc_zero(torture, struct test_become_dc_state);
- if (!s) return False;
+ if (!s) return false;
- s->netbios_name = lp_parm_string(-1, "become dc", "smbtorture dc");
+ s->netbios_name = lp_parm_string(global_loadparm, NULL, "become dc", "smbtorture dc");
if (!s->netbios_name || !s->netbios_name[0]) {
s->netbios_name = "smbtorturedc";
}
@@ -751,7 +751,7 @@ BOOL torture_net_become_dc(struct torture_context *torture)
if (!s->tj) {
DEBUG(0, ("%s failed to join domain as workstation\n",
s->netbios_name));
- return False;
+ return false;
}
s->ctx = libnet_context_init(torture->ev);
@@ -776,27 +776,27 @@ BOOL torture_net_become_dc(struct torture_context *torture)
status = libnet_BecomeDC(s->ctx, s, &b);
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_BecomeDC() failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto cleanup;
}
msg = ldb_msg_new(s);
if (!msg) {
printf("ldb_msg_new() failed\n");
- ret = False;
+ ret = false;
goto cleanup;
}
msg->dn = ldb_dn_new(msg, s->ldb, "cn=ROOTDSE");
if (!msg->dn) {
printf("ldb_msg_new(cn=ROOTDSE) failed\n");
- ret = False;
+ ret = false;
goto cleanup;
}
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);
- ret = False;
+ ret = false;
goto cleanup;
}
@@ -808,7 +808,7 @@ BOOL torture_net_become_dc(struct torture_context *torture)
ldb_ret = ldb_modify(s->ldb, msg);
if (ldb_ret != LDB_SUCCESS) {
printf("ldb_modify() failed: %d\n", ldb_ret);
- ret = False;
+ ret = false;
goto cleanup;
}
@@ -817,24 +817,24 @@ BOOL torture_net_become_dc(struct torture_context *torture)
s->schema = NULL;
DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", s->path.samdb_ldb));
- s->ldb = ldb_wrap_connect(s, s->path.samdb_ldb,
+ s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb,
system_session(s),
NULL, 0, NULL);
if (!s->ldb) {
DEBUG(0,("Failed to open '%s'\n",
s->path.samdb_ldb));
- ret = False;
+ ret = false;
goto cleanup;
}
s->schema = dsdb_get_schema(s->ldb);
if (!s->schema) {
DEBUG(0,("Failed to get loaded dsdb_schema\n"));
- ret = False;
+ ret = false;
goto cleanup;
}
- if (lp_parm_bool(-1, "become dc", "do not unjoin", false)) {
+ if (lp_parm_bool(global_loadparm, NULL, "become dc", "do not unjoin", false)) {
talloc_free(s);
return ret;
}
@@ -849,7 +849,7 @@ cleanup:
status = libnet_UnbecomeDC(s->ctx, s, &u);
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_UnbecomeDC() failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
/* Leave domain. */
diff --git a/source4/torture/libnet/libnet_domain.c b/source4/torture/libnet/libnet_domain.c
index 675ab9f099..379cca19be 100644
--- a/source4/torture/libnet/libnet_domain.c
+++ b/source4/torture/libnet/libnet_domain.c
@@ -30,9 +30,10 @@
#include "librpc/rpc/dcerpc.h"
#include "torture/torture.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
-static BOOL test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct lsa_String *domname,
uint32_t *access_mask, struct dom_sid **sid)
{
@@ -53,7 +54,7 @@ static BOOL test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Connect(p, mem_ctx, &r1);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r2.in.connect_handle = &h;
@@ -64,7 +65,7 @@ static BOOL test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r3.in.connect_handle = &h;
@@ -77,16 +78,16 @@ static BOOL test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else {
*handle = domain_handle;
}
- return True;
+ return true;
}
-static BOOL test_opendomain_lsa(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_opendomain_lsa(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct lsa_String *domname,
uint32_t *access_mask)
{
@@ -114,16 +115,16 @@ static BOOL test_opendomain_lsa(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_lsa_OpenPolicy2(p, mem_ctx, &open);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
bool torture_domain_open_lsa(struct torture_context *torture)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct libnet_context *ctx;
struct libnet_DomainOpen r;
struct lsa_Close lsa_close;
@@ -133,12 +134,12 @@ bool torture_domain_open_lsa(struct torture_context *torture)
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup();
+ domain_name = lp_workgroup(global_loadparm);
ctx = libnet_context_init(NULL);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
- return False;
+ return false;
}
ctx->cred = cmdline_credentials;
@@ -151,7 +152,7 @@ bool torture_domain_open_lsa(struct torture_context *torture)
status = libnet_DomainOpen(ctx, torture, &r);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to open domain on lsa service: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
@@ -162,7 +163,7 @@ bool torture_domain_open_lsa(struct torture_context *torture)
status = dcerpc_lsa_Close(ctx->lsa.pipe, ctx, &lsa_close);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to close domain on lsa service: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
done:
@@ -171,9 +172,9 @@ done:
}
-BOOL torture_domain_close_lsa(struct torture_context *torture)
+bool torture_domain_close_lsa(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
TALLOC_CTX *mem_ctx=NULL;
struct libnet_context *ctx;
@@ -192,7 +193,7 @@ BOOL torture_domain_close_lsa(struct torture_context *torture)
ctx = libnet_context_init(NULL);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -203,15 +204,15 @@ BOOL torture_domain_close_lsa(struct torture_context *torture)
cmdline_credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to connect to server: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
- domain_name.string = lp_workgroup();
+ domain_name.string = lp_workgroup(global_loadparm);
if (!test_opendomain_lsa(p, torture, &h, &domain_name, &access_mask)) {
d_printf("failed to open domain on lsa service\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -229,7 +230,7 @@ BOOL torture_domain_close_lsa(struct torture_context *torture)
status = libnet_DomainClose(ctx, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -240,7 +241,7 @@ done:
}
-BOOL torture_domain_open_samr(struct torture_context *torture)
+bool torture_domain_open_samr(struct torture_context *torture)
{
NTSTATUS status;
struct libnet_context *ctx;
@@ -250,7 +251,7 @@ BOOL torture_domain_open_samr(struct torture_context *torture)
struct libnet_DomainOpen io;
struct samr_Close r;
const char *domain_name;
- BOOL ret = True;
+ bool ret = true;
mem_ctx = talloc_init("test_domainopen_lsa");
@@ -260,7 +261,7 @@ BOOL torture_domain_open_samr(struct torture_context *torture)
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup();
+ domain_name = lp_workgroup(global_loadparm);
/*
* Testing synchronous version
@@ -274,7 +275,7 @@ BOOL torture_domain_open_samr(struct torture_context *torture)
status = libnet_DomainOpen(ctx, mem_ctx, &io);
if (!NT_STATUS_IS_OK(status)) {
printf("Composite domain open failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
@@ -288,7 +289,7 @@ BOOL torture_domain_open_samr(struct torture_context *torture)
status = dcerpc_samr_Close(ctx->samr.pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Close failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
@@ -300,9 +301,9 @@ done:
}
-BOOL torture_domain_close_samr(struct torture_context *torture)
+bool torture_domain_close_samr(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL;
struct libnet_context *ctx;
@@ -322,7 +323,7 @@ BOOL torture_domain_close_samr(struct torture_context *torture)
ctx = libnet_context_init(NULL);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -333,15 +334,15 @@ BOOL torture_domain_close_samr(struct torture_context *torture)
ctx->cred, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to connect to server: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
- domain_name.string = talloc_strdup(mem_ctx, lp_workgroup());
+ domain_name.string = talloc_strdup(mem_ctx, lp_workgroup(global_loadparm));
if (!test_opendomain_samr(p, torture, &h, &domain_name, &access_mask, &sid)) {
d_printf("failed to open domain on samr service\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -361,7 +362,7 @@ BOOL torture_domain_close_samr(struct torture_context *torture)
status = libnet_DomainClose(ctx, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -372,9 +373,9 @@ done:
}
-BOOL torture_domain_list(struct torture_context *torture)
+bool torture_domain_list(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL;
struct dcerpc_binding *binding;
@@ -390,7 +391,7 @@ BOOL torture_domain_list(struct torture_context *torture)
ctx = libnet_context_init(NULL);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -407,7 +408,7 @@ BOOL torture_domain_list(struct torture_context *torture)
status = libnet_DomainList(ctx, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -428,7 +429,7 @@ BOOL torture_domain_list(struct torture_context *torture)
status = libnet_DomainList(ctx, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto done;
}
diff --git a/source4/torture/libnet/libnet_group.c b/source4/torture/libnet/libnet_group.c
index 1f4725d6dd..a4489d376d 100644
--- a/source4/torture/libnet/libnet_group.c
+++ b/source4/torture/libnet/libnet_group.c
@@ -26,12 +26,13 @@
#include "librpc/gen_ndr/ndr_lsa_c.h"
#include "torture/torture.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
#define TEST_GROUPNAME "libnetgrouptest"
-static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle, const char *groupname)
{
NTSTATUS status;
@@ -53,7 +54,7 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupNames(p, mem_ctx, &r1);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupNames failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
rid = r1.out.rids.ids[0];
@@ -68,7 +69,7 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenGroup(p, mem_ctx, &r2);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenGroup failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r3.in.group_handle = &group_handle;
@@ -79,14 +80,14 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_DeleteDomainGroup(p, mem_ctx, &r3);
if (!NT_STATUS_IS_OK(status)) {
printf("DeleteGroup failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_creategroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_creategroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char *name)
{
NTSTATUS status;
@@ -112,7 +113,7 @@ static BOOL test_creategroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_GROUP_EXISTS)) {
printf("Group (%s) already exists - attempting to delete and recreate group again\n", name);
if (!test_cleanup(p, mem_ctx, handle, TEST_GROUPNAME)) {
- return False;
+ return false;
}
printf("creating group account\n");
@@ -120,18 +121,18 @@ static BOOL test_creategroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("CreateGroup failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct lsa_String *domname)
{
NTSTATUS status;
@@ -149,7 +150,7 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Connect(p, mem_ctx, &r1);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r2.in.connect_handle = &h;
@@ -160,7 +161,7 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r3.in.connect_handle = &h;
@@ -173,16 +174,16 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else {
*handle = domain_handle;
}
- return True;
+ return true;
}
-static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle)
{
NTSTATUS status;
@@ -194,17 +195,17 @@ static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Close(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Close samr domain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_groupinfo_api(struct torture_context *torture)
+bool torture_groupinfo_api(struct torture_context *torture)
{
const char *name = TEST_GROUPNAME;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx;
struct libnet_context *ctx;
@@ -222,17 +223,17 @@ BOOL torture_groupinfo_api(struct torture_context *torture)
&p,
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- domain_name.string = lp_workgroup();
+ domain_name.string = lp_workgroup(global_loadparm);
if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
- ret = False;
+ ret = false;
goto done;
}
if (!test_creategroup(p, prep_mem_ctx, &h, name)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -246,20 +247,20 @@ BOOL torture_groupinfo_api(struct torture_context *torture)
status = libnet_GroupInfo(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_GroupInfo call failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
talloc_free(mem_ctx);
goto done;
}
if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) {
printf("cleanup failed\n");
- ret = False;
+ ret = false;
goto done;
}
if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
printf("domain close failed\n");
- ret = False;
+ ret = false;
}
talloc_free(ctx);
diff --git a/source4/torture/libnet/libnet_lookup.c b/source4/torture/libnet/libnet_lookup.c
index b48f7e7bac..4734ec5088 100644
--- a/source4/torture/libnet/libnet_lookup.c
+++ b/source4/torture/libnet/libnet_lookup.c
@@ -26,11 +26,12 @@
#include "libcli/libcli.h"
#include "torture/rpc/rpc.h"
#include "torture/torture.h"
+#include "param/param.h"
-BOOL torture_lookup(struct torture_context *torture)
+bool torture_lookup(struct torture_context *torture)
{
- BOOL ret;
+ bool ret;
NTSTATUS status;
TALLOC_CTX *mem_ctx;
struct libnet_context *ctx;
@@ -58,13 +59,13 @@ BOOL torture_lookup(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
printf("Couldn't lookup name %s: %s\n", lookup.in.hostname, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
- ret = True;
+ ret = true;
- printf("Name [%s] found at adrress: %s.\n", lookup.in.hostname, *lookup.out.address);
+ printf("Name [%s] found at address: %s.\n", lookup.in.hostname, *lookup.out.address);
done:
talloc_free(mem_ctx);
@@ -72,9 +73,9 @@ done:
}
-BOOL torture_lookup_host(struct torture_context *torture)
+bool torture_lookup_host(struct torture_context *torture)
{
- BOOL ret;
+ bool ret;
NTSTATUS status;
TALLOC_CTX *mem_ctx;
struct libnet_context *ctx;
@@ -101,13 +102,13 @@ BOOL torture_lookup_host(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
printf("Couldn't lookup host %s: %s\n", lookup.in.hostname, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
- ret = True;
+ ret = true;
- printf("Host [%s] found at adrress: %s.\n", lookup.in.hostname, *lookup.out.address);
+ printf("Host [%s] found at address: %s.\n", lookup.in.hostname, *lookup.out.address);
done:
talloc_free(mem_ctx);
@@ -115,9 +116,9 @@ done:
}
-BOOL torture_lookup_pdc(struct torture_context *torture)
+bool torture_lookup_pdc(struct torture_context *torture)
{
- BOOL ret;
+ bool ret;
NTSTATUS status;
TALLOC_CTX *mem_ctx;
struct libnet_context *ctx;
@@ -133,11 +134,11 @@ BOOL torture_lookup_pdc(struct torture_context *torture)
lookup = talloc(mem_ctx, struct libnet_LookupDCs);
if (!lookup) {
- ret = False;
+ ret = false;
goto done;
}
- lookup->in.domain_name = lp_workgroup();
+ lookup->in.domain_name = lp_workgroup(global_loadparm);
lookup->in.name_type = NBT_NAME_PDC;
status = libnet_LookupDCs(ctx, mem_ctx, lookup);
@@ -145,11 +146,11 @@ BOOL torture_lookup_pdc(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
printf("Couldn't lookup pdc %s: %s\n", lookup->in.domain_name,
nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
- ret = True;
+ ret = true;
printf("DCs of domain [%s] found.\n", lookup->in.domain_name);
for (i = 0; i < lookup->out.num_dcs; i++) {
@@ -163,7 +164,7 @@ done:
}
-BOOL torture_lookup_sam_name(struct torture_context *torture)
+bool torture_lookup_sam_name(struct torture_context *torture)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx;
@@ -174,15 +175,15 @@ BOOL torture_lookup_sam_name(struct torture_context *torture)
ctx->cred = cmdline_credentials;
mem_ctx = talloc_init("torture lookup sam name");
- if (mem_ctx == NULL) return False;
+ if (mem_ctx == NULL) return false;
r.in.name = "Administrator";
- r.in.domain_name = lp_workgroup();
+ r.in.domain_name = lp_workgroup(global_loadparm);
status = libnet_LookupName(ctx, mem_ctx, &r);
talloc_free(mem_ctx);
talloc_free(ctx);
- return True;
+ return true;
}
diff --git a/source4/torture/libnet/libnet_rpc.c b/source4/torture/libnet/libnet_rpc.c
index 07c586ebf3..5ca927a1e3 100644
--- a/source4/torture/libnet/libnet_rpc.c
+++ b/source4/torture/libnet/libnet_rpc.c
@@ -30,14 +30,15 @@
#include "librpc/rpc/dcerpc.h"
#include "torture/rpc/rpc.h"
#include "torture/torture.h"
+#include "param/param.h"
-static BOOL test_connect_service(struct libnet_context *ctx,
+static bool test_connect_service(struct libnet_context *ctx,
const struct ndr_interface_table *iface,
const char *binding_string,
const char *hostname,
const enum libnet_RpcConnect_level level,
- BOOL badcreds, NTSTATUS expected_status)
+ bool badcreds, NTSTATUS expected_status)
{
NTSTATUS status;
struct libnet_RpcConnect connect;
@@ -61,7 +62,7 @@ static BOOL test_connect_service(struct libnet_context *ctx,
connect.in.dcerpc_iface->name, connect.in.binding, nt_errstr(expected_status),
nt_errstr(status));
- return False;
+ return false;
}
d_printf("PASSED. Expected: %s, received: %s\n", nt_errstr(expected_status),
@@ -78,11 +79,11 @@ static BOOL test_connect_service(struct libnet_context *ctx,
d_printf("Error string: %s\n", connect.out.error_string);
}
- return True;
+ return true;
}
-static BOOL torture_rpc_connect(struct torture_context *torture,
+static bool torture_rpc_connect(struct torture_context *torture,
const enum libnet_RpcConnect_level level,
const char *bindstr, const char *hostname)
{
@@ -93,46 +94,46 @@ static BOOL torture_rpc_connect(struct torture_context *torture,
d_printf("Testing connection to LSA interface\n");
if (!test_connect_service(ctx, &ndr_table_lsarpc, bindstr,
- hostname, level, False, NT_STATUS_OK)) {
+ hostname, level, false, NT_STATUS_OK)) {
d_printf("failed to connect LSA interface\n");
- return False;
+ return false;
}
d_printf("Testing connection to SAMR interface\n");
if (!test_connect_service(ctx, &ndr_table_samr, bindstr,
- hostname, level, False, NT_STATUS_OK)) {
+ hostname, level, false, NT_STATUS_OK)) {
d_printf("failed to connect SAMR interface\n");
- return False;
+ return false;
}
d_printf("Testing connection to SRVSVC interface\n");
if (!test_connect_service(ctx, &ndr_table_srvsvc, bindstr,
- hostname, level, False, NT_STATUS_OK)) {
+ hostname, level, false, NT_STATUS_OK)) {
d_printf("failed to connect SRVSVC interface\n");
- return False;
+ return false;
}
d_printf("Testing connection to LSA interface with wrong credentials\n");
if (!test_connect_service(ctx, &ndr_table_lsarpc, bindstr,
- hostname, level, True, NT_STATUS_LOGON_FAILURE)) {
+ hostname, level, true, NT_STATUS_LOGON_FAILURE)) {
d_printf("failed to test wrong credentials on LSA interface\n");
- return False;
+ return false;
}
d_printf("Testing connection to SAMR interface with wrong credentials\n");
if (!test_connect_service(ctx, &ndr_table_samr, bindstr,
- hostname, level, True, NT_STATUS_LOGON_FAILURE)) {
+ hostname, level, true, NT_STATUS_LOGON_FAILURE)) {
d_printf("failed to test wrong credentials on SAMR interface\n");
- return False;
+ return false;
}
talloc_free(ctx);
- return True;
+ return true;
}
-BOOL torture_rpc_connect_srv(struct torture_context *torture)
+bool torture_rpc_connect_srv(struct torture_context *torture)
{
const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_SERVER;
NTSTATUS status;
@@ -140,14 +141,14 @@ BOOL torture_rpc_connect_srv(struct torture_context *torture)
status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
return torture_rpc_connect(torture, level, NULL, binding->host);
}
-BOOL torture_rpc_connect_pdc(struct torture_context *torture)
+bool torture_rpc_connect_pdc(struct torture_context *torture)
{
const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_PDC;
NTSTATUS status;
@@ -156,18 +157,18 @@ BOOL torture_rpc_connect_pdc(struct torture_context *torture)
status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup();
+ domain_name = lp_workgroup(global_loadparm);
return torture_rpc_connect(torture, level, NULL, domain_name);
}
-BOOL torture_rpc_connect_dc(struct torture_context *torture)
+bool torture_rpc_connect_dc(struct torture_context *torture)
{
const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_DC;
NTSTATUS status;
@@ -176,18 +177,18 @@ BOOL torture_rpc_connect_dc(struct torture_context *torture)
status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup();
+ domain_name = lp_workgroup(global_loadparm);
return torture_rpc_connect(torture, level, NULL, domain_name);
}
-BOOL torture_rpc_connect_dc_info(struct torture_context *torture)
+bool torture_rpc_connect_dc_info(struct torture_context *torture)
{
const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_DC_INFO;
NTSTATUS status;
@@ -196,18 +197,18 @@ BOOL torture_rpc_connect_dc_info(struct torture_context *torture)
status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
/* we're accessing domain controller so the domain name should be
passed (it's going to be resolved to dc name and address) instead
of specific server name. */
- domain_name = lp_workgroup();
+ domain_name = lp_workgroup(global_loadparm);
return torture_rpc_connect(torture, level, NULL, domain_name);
}
-BOOL torture_rpc_connect_binding(struct torture_context *torture)
+bool torture_rpc_connect_binding(struct torture_context *torture)
{
const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_BINDING;
NTSTATUS status;
@@ -216,7 +217,7 @@ BOOL torture_rpc_connect_binding(struct torture_context *torture)
status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
bindstr = dcerpc_binding_string(torture, binding);
diff --git a/source4/torture/libnet/libnet_share.c b/source4/torture/libnet/libnet_share.c
index b6b0b37d01..d18e6ea9db 100644
--- a/source4/torture/libnet/libnet_share.c
+++ b/source4/torture/libnet/libnet_share.c
@@ -113,13 +113,13 @@ static void test_displayshares(struct libnet_ListShares s)
}
-BOOL torture_listshares(struct torture_context *torture)
+bool torture_listshares(struct torture_context *torture)
{
struct libnet_ListShares share;
NTSTATUS status;
uint32_t levels[] = { 0, 1, 2, 501, 502 };
int i;
- BOOL ret = True;
+ bool ret = true;
struct libnet_context* libnetctx;
struct dcerpc_binding *bind;
TALLOC_CTX *mem_ctx;
@@ -127,14 +127,14 @@ BOOL torture_listshares(struct torture_context *torture)
mem_ctx = talloc_init("test_listshares");
status = torture_rpc_binding(torture, &bind);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto done;
}
libnetctx = libnet_context_init(NULL);
if (!libnetctx) {
printf("Couldn't allocate libnet context\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -151,7 +151,7 @@ BOOL torture_listshares(struct torture_context *torture)
status = libnet_ListShares(libnetctx, mem_ctx, &share);
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_ListShare level %u failed - %s\n", share.in.level, share.out.error_string);
- ret = False;
+ ret = false;
goto done;
}
@@ -165,7 +165,7 @@ done:
}
-static BOOL test_addshare(struct dcerpc_pipe *svc_pipe, TALLOC_CTX *mem_ctx, const char *host,
+static bool test_addshare(struct dcerpc_pipe *svc_pipe, TALLOC_CTX *mem_ctx, const char *host,
const char* share)
{
NTSTATUS status;
@@ -187,32 +187,27 @@ static BOOL test_addshare(struct dcerpc_pipe *svc_pipe, TALLOC_CTX *mem_ctx, con
status = dcerpc_srvsvc_NetShareAdd(svc_pipe, mem_ctx, &add);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to add a new share\n");
- return False;
+ return false;
}
printf("share added\n");
- return True;
+ return true;
}
-BOOL torture_delshare(struct torture_context *torture)
+bool torture_delshare(struct torture_context *torture)
{
struct dcerpc_pipe *p;
struct dcerpc_binding *bind;
struct libnet_context* libnetctx;
const char *host;
- TALLOC_CTX *mem_ctx;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct libnet_DelShare share;
- mem_ctx = talloc_init("test_listshares");
host = torture_setting_string(torture, "host", NULL);
status = torture_rpc_binding(torture, &bind);
- if (!NT_STATUS_IS_OK(status)) {
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(torture, status, "Failed to get binding");
libnetctx = libnet_context_init(NULL);
libnetctx->cred = cmdline_credentials;
@@ -221,22 +216,15 @@ BOOL torture_delshare(struct torture_context *torture)
&p,
&ndr_table_srvsvc);
- if (!test_addshare(p, mem_ctx, host, TEST_SHARENAME)) {
- ret = False;
- goto done;
+ if (!test_addshare(p, torture, host, TEST_SHARENAME)) {
+ return false;
}
share.in.server_name = bind->host;
share.in.share_name = TEST_SHARENAME;
- status = libnet_DelShare(libnetctx, mem_ctx, &share);
- if (!NT_STATUS_IS_OK(status)) {
- ret = False;
- goto done;
- }
+ status = libnet_DelShare(libnetctx, torture, &share);
+ torture_assert_ntstatus_ok(torture, status, "Failed to delete share");
-
-done:
- talloc_free(mem_ctx);
return ret;
}
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c
index 7a3b9f19c1..b3aadc776e 100644
--- a/source4/torture/libnet/libnet_user.c
+++ b/source4/torture/libnet/libnet_user.c
@@ -27,9 +27,10 @@
#include "torture/torture.h"
#include "torture/rpc/rpc.h"
#include "torture/libnet/usertest.h"
+#include "param/param.h"
-static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle, const char *username)
{
NTSTATUS status;
@@ -51,7 +52,7 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupNames(p, mem_ctx, &r1);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupNames failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
rid = r1.out.rids.ids[0];
@@ -66,7 +67,7 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenUser(p, mem_ctx, &r2);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenUser failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r3.in.user_handle = &user_handle;
@@ -77,14 +78,14 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3);
if (!NT_STATUS_IS_OK(status)) {
printf("DeleteUser failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct lsa_String *domname)
{
NTSTATUS status;
@@ -102,7 +103,7 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Connect(p, mem_ctx, &r1);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r2.in.connect_handle = &h;
@@ -113,7 +114,7 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r3.in.connect_handle = &h;
@@ -126,16 +127,16 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else {
*handle = domain_handle;
}
- return True;
+ return true;
}
-static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle)
{
NTSTATUS status;
@@ -147,14 +148,14 @@ static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Close(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Close samr domain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_lsa_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_lsa_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle)
{
NTSTATUS status;
@@ -166,14 +167,14 @@ static BOOL test_lsa_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_lsa_Close(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Close lsa domain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char* user)
{
NTSTATUS status;
@@ -200,7 +201,7 @@ static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
printf("User (%s) already exists - attempting to delete and recreate account again\n", user);
if (!test_cleanup(p, mem_ctx, handle, TEST_USERNAME)) {
- return False;
+ return false;
}
printf("creating user account\n");
@@ -208,11 +209,11 @@ static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_CreateUser(p, mem_ctx, &r1);
if (!NT_STATUS_IS_OK(status)) {
printf("CreateUser failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
- return False;
+ return false;
}
r2.in.handle = &user_handle;
@@ -223,20 +224,20 @@ static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Close(p, mem_ctx, &r2);
if (!NT_STATUS_IS_OK(status)) {
printf("Close failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_createuser(struct torture_context *torture)
+bool torture_createuser(struct torture_context *torture)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx;
struct libnet_context *ctx;
struct libnet_CreateUser req;
- BOOL ret = True;
+ bool ret = true;
mem_ctx = talloc_init("test_createuser");
@@ -244,25 +245,25 @@ BOOL torture_createuser(struct torture_context *torture)
ctx->cred = cmdline_credentials;
req.in.user_name = TEST_USERNAME;
- req.in.domain_name = lp_workgroup();
+ req.in.domain_name = lp_workgroup(global_loadparm);
req.out.error_string = NULL;
status = libnet_CreateUser(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_CreateUser call failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) {
printf("cleanup failed\n");
- ret = False;
+ ret = false;
goto done;
}
if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
printf("domain close failed\n");
- ret = False;
+ ret = false;
}
done:
@@ -272,7 +273,7 @@ done:
}
-BOOL torture_deleteuser(struct torture_context *torture)
+bool torture_deleteuser(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
@@ -282,7 +283,7 @@ BOOL torture_deleteuser(struct torture_context *torture)
const char *name = TEST_USERNAME;
struct libnet_context *ctx;
struct libnet_DeleteUser req;
- BOOL ret = True;
+ bool ret = true;
prep_mem_ctx = talloc_init("prepare test_deleteuser");
@@ -290,24 +291,24 @@ BOOL torture_deleteuser(struct torture_context *torture)
ctx->cred = cmdline_credentials;
req.in.user_name = TEST_USERNAME;
- req.in.domain_name = lp_workgroup();
+ req.in.domain_name = lp_workgroup(global_loadparm);
status = torture_rpc_connection(torture,
&p,
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto done;
}
- domain_name.string = lp_workgroup();
+ domain_name.string = lp_workgroup(global_loadparm);
if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
- ret = False;
+ ret = false;
goto done;
}
if (!test_createuser(p, prep_mem_ctx, &h, name)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -316,7 +317,7 @@ BOOL torture_deleteuser(struct torture_context *torture)
status = libnet_DeleteUser(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_DeleteUser call failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
talloc_free(mem_ctx);
@@ -417,7 +418,7 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
case acct_expiry:
continue_if_field_set(r->in.acct_expiry);
now = timeval_add(&now, (random() % (31*24*60*60)), 0);
- r->in.acct_expiry = talloc_memdup(mem_ctx, &now, sizeof(now));
+ r->in.acct_expiry = (struct timeval *)talloc_memdup(mem_ctx, &now, sizeof(now));
fldname = "acct_expiry";
break;
@@ -438,26 +439,26 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
#define TEST_STR_FLD(fld) \
if (!strequal(req.in.fld, user_req.out.fld)) { \
printf("failed to change '%s'\n", #fld); \
- ret = False; \
+ ret = false; \
goto cleanup; \
}
#define TEST_TIME_FLD(fld) \
if (timeval_compare(req.in.fld, user_req.out.fld)) { \
printf("failed to change '%s'\n", #fld); \
- ret = False; \
+ ret = false; \
goto cleanup; \
}
#define TEST_NUM_FLD(fld) \
if (req.in.fld != user_req.out.fld) { \
printf("failed to change '%s'\n", #fld); \
- ret = False; \
+ ret = false; \
goto cleanup; \
}
-BOOL torture_modifyuser(struct torture_context *torture)
+bool torture_modifyuser(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_binding *bind;
@@ -470,7 +471,7 @@ BOOL torture_modifyuser(struct torture_context *torture)
struct libnet_ModifyUser req;
struct libnet_UserInfo user_req;
int fld;
- BOOL ret = True;
+ bool ret = true;
prep_mem_ctx = talloc_init("prepare test_deleteuser");
@@ -481,20 +482,20 @@ BOOL torture_modifyuser(struct torture_context *torture)
&p,
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto done;
}
name = talloc_strdup(prep_mem_ctx, TEST_USERNAME);
- domain_name.string = lp_workgroup();
+ domain_name.string = lp_workgroup(global_loadparm);
if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
- ret = False;
+ ret = false;
goto done;
}
if (!test_createuser(p, prep_mem_ctx, &h, name)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -502,7 +503,7 @@ BOOL torture_modifyuser(struct torture_context *torture)
status = torture_rpc_binding(mem_ctx, &bind);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -510,7 +511,7 @@ BOOL torture_modifyuser(struct torture_context *torture)
for (fld = 1; fld < FIELDS_NUM - 1; fld++) {
ZERO_STRUCT(req);
- req.in.domain_name = lp_workgroup();
+ req.in.domain_name = lp_workgroup(global_loadparm);
req.in.user_name = name;
set_test_changes(mem_ctx, &req, 1, &name, fld);
@@ -518,18 +519,18 @@ BOOL torture_modifyuser(struct torture_context *torture)
status = libnet_ModifyUser(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
ZERO_STRUCT(user_req);
- user_req.in.domain_name = lp_workgroup();
+ user_req.in.domain_name = lp_workgroup(global_loadparm);
user_req.in.user_name = name;
status = libnet_UserInfo(ctx, mem_ctx, &user_req);
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_UserInfo call failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
@@ -562,7 +563,7 @@ BOOL torture_modifyuser(struct torture_context *torture)
/* restore original testing username - it's useful when test fails
because it prevents from problems with recreating account */
ZERO_STRUCT(req);
- req.in.domain_name = lp_workgroup();
+ req.in.domain_name = lp_workgroup(global_loadparm);
req.in.user_name = name;
req.in.account_name = TEST_USERNAME;
@@ -570,7 +571,7 @@ BOOL torture_modifyuser(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status));
talloc_free(mem_ctx);
- ret = False;
+ ret = false;
goto done;
}
@@ -581,13 +582,13 @@ BOOL torture_modifyuser(struct torture_context *torture)
cleanup:
if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, name)) {
printf("cleanup failed\n");
- ret = False;
+ ret = false;
goto done;
}
if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
printf("domain close failed\n");
- ret = False;
+ ret = false;
}
talloc_free(mem_ctx);
@@ -599,10 +600,10 @@ done:
}
-BOOL torture_userinfo_api(struct torture_context *torture)
+bool torture_userinfo_api(struct torture_context *torture)
{
const char *name = TEST_USERNAME;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx;
struct libnet_context *ctx;
@@ -620,17 +621,17 @@ BOOL torture_userinfo_api(struct torture_context *torture)
&p,
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- domain_name.string = lp_workgroup();
+ domain_name.string = lp_workgroup(global_loadparm);
if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
- ret = False;
+ ret = false;
goto done;
}
if (!test_createuser(p, prep_mem_ctx, &h, name)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -644,20 +645,20 @@ BOOL torture_userinfo_api(struct torture_context *torture)
status = libnet_UserInfo(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
printf("libnet_UserInfo call failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
talloc_free(mem_ctx);
goto done;
}
if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) {
printf("cleanup failed\n");
- ret = False;
+ ret = false;
goto done;
}
if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
printf("domain close failed\n");
- ret = False;
+ ret = false;
}
talloc_free(ctx);
@@ -668,9 +669,9 @@ done:
}
-BOOL torture_userlist(struct torture_context *torture)
+bool torture_userlist(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL;
struct libnet_context *ctx;
@@ -681,7 +682,7 @@ BOOL torture_userlist(struct torture_context *torture)
ctx = libnet_context_init(NULL);
ctx->cred = cmdline_credentials;
- domain_name.string = lp_workgroup();
+ domain_name.string = lp_workgroup(global_loadparm);
mem_ctx = talloc_init("torture user list");
ZERO_STRUCT(req);
@@ -706,19 +707,19 @@ BOOL torture_userlist(struct torture_context *torture)
if (!(NT_STATUS_IS_OK(status) ||
NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))) {
printf("libnet_UserList call failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
printf("samr domain close failed\n");
- ret = False;
+ ret = false;
goto done;
}
if (!test_lsa_close(ctx->lsa.pipe, mem_ctx, &ctx->lsa.handle)) {
printf("lsa domain close failed\n");
- ret = False;
+ ret = false;
}
talloc_free(ctx);
diff --git a/source4/torture/libnet/userinfo.c b/source4/torture/libnet/userinfo.c
index ad35e84861..46a9a6a015 100644
--- a/source4/torture/libnet/userinfo.c
+++ b/source4/torture/libnet/userinfo.c
@@ -23,162 +23,13 @@
#include "libnet/libnet.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_samr_c.h"
+#include "param/param.h"
+#include "torture/libnet/utils.h"
-#define TEST_USERNAME "libnetuserinfotest"
-
-static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, struct lsa_String *domname,
- struct dom_sid2 *sid)
-{
- NTSTATUS status;
- struct policy_handle h, domain_handle;
- struct samr_Connect r1;
- struct samr_LookupDomain r2;
- struct samr_OpenDomain r3;
-
- printf("connecting\n");
-
- r1.in.system_name = 0;
- r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r1.out.connect_handle = &h;
-
- status = dcerpc_samr_Connect(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Connect failed - %s\n", nt_errstr(status));
- return False;
- }
-
- r2.in.connect_handle = &h;
- r2.in.domain_name = domname;
-
- printf("domain lookup on %s\n", domname->string);
-
- status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LookupDomain failed - %s\n", nt_errstr(status));
- return False;
- }
-
- r3.in.connect_handle = &h;
- r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r3.in.sid = r2.out.sid;
- r3.out.domain_handle = &domain_handle;
-
- printf("opening domain\n");
-
- status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenDomain failed - %s\n", nt_errstr(status));
- return False;
- } else {
- *handle = domain_handle;
- }
-
- *sid = *r2.out.sid;
- return True;
-}
-
-
-static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *domain_handle, const char *username)
-{
- NTSTATUS status;
- struct samr_LookupNames r1;
- struct samr_OpenUser r2;
- struct samr_DeleteUser r3;
- struct lsa_String names[2];
- uint32_t rid;
- struct policy_handle user_handle;
-
- names[0].string = username;
-
- r1.in.domain_handle = domain_handle;
- r1.in.num_names = 1;
- r1.in.names = names;
-
- printf("user account lookup '%s'\n", username);
-
- status = dcerpc_samr_LookupNames(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LookupNames failed - %s\n", nt_errstr(status));
- return False;
- }
-
- rid = r1.out.rids.ids[0];
-
- r2.in.domain_handle = domain_handle;
- r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r2.in.rid = rid;
- r2.out.user_handle = &user_handle;
-
- printf("opening user account\n");
-
- status = dcerpc_samr_OpenUser(p, mem_ctx, &r2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenUser failed - %s\n", nt_errstr(status));
- return False;
- }
-
- r3.in.user_handle = &user_handle;
- r3.out.user_handle = &user_handle;
-
- printf("deleting user account\n");
-
- status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3);
- if (!NT_STATUS_IS_OK(status)) {
- printf("DeleteUser failed - %s\n", nt_errstr(status));
- return False;
- }
-
- return True;
-}
-
-
-static BOOL test_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, const char *name, uint32_t *rid)
-{
- NTSTATUS status;
- struct lsa_String username;
- struct samr_CreateUser r;
- struct policy_handle user_handle;
-
- username.string = name;
-
- r.in.domain_handle = handle;
- r.in.account_name = &username;
- r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r.out.user_handle = &user_handle;
- r.out.rid = rid;
-
- printf("creating user account %s\n", name);
-
- status = dcerpc_samr_CreateUser(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("CreateUser failed - %s\n", nt_errstr(status));
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
- printf("User (%s) already exists - attempting to delete and recreate account again\n", name);
- if (!test_cleanup(p, mem_ctx, handle, TEST_USERNAME)) {
- return False;
- }
-
- printf("creating user account\n");
-
- status = dcerpc_samr_CreateUser(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("CreateUser failed - %s\n", nt_errstr(status));
- return False;
- }
- return True;
- }
- return False;
- }
-
- return True;
-}
+#define TEST_USERNAME "libnetuserinfotest"
-static BOOL test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
struct dom_sid2 *domain_sid, const char* user_name,
uint32_t *rid)
@@ -198,7 +49,7 @@ static BOOL test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = libnet_rpc_userinfo(p, mem_ctx, &user);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
- return False;
+ return false;
}
ZERO_STRUCT(user);
@@ -212,38 +63,14 @@ static BOOL test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = libnet_rpc_userinfo(p, mem_ctx, &user);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
-}
-
-
-static void msg_handler(struct monitor_msg *m)
-{
- struct msg_rpc_open_user *msg_open;
- struct msg_rpc_query_user *msg_query;
- struct msg_rpc_close_user *msg_close;
-
- switch (m->type) {
- case mon_SamrOpenUser:
- msg_open = (struct msg_rpc_open_user*)m->data;
- printf("monitor_msg: user opened (rid=%d, access_mask=0x%08x)\n",
- msg_open->rid, msg_open->access_mask);
- break;
- case mon_SamrQueryUser:
- msg_query = (struct msg_rpc_query_user*)m->data;
- printf("monitor_msg: user queried (level=%d)\n", msg_query->level);
- break;
- case mon_SamrCloseUser:
- msg_close = (struct msg_rpc_close_user*)m->data;
- printf("monitor_msg: user closed (rid=%d)\n", msg_close->rid);
- break;
- }
+ return true;
}
-static BOOL test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
struct dom_sid2 *domain_sid, const char* user_name,
uint32_t *rid)
@@ -265,13 +92,13 @@ static BOOL test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
c = libnet_rpc_userinfo_send(p, &user, msg_handler);
if (!c) {
printf("Failed to call sync libnet_rpc_userinfo_send\n");
- return False;
+ return false;
}
status = libnet_rpc_userinfo_recv(c, mem_ctx, &user);
if (!NT_STATUS_IS_OK(status)) {
printf("Calling async libnet_rpc_userinfo failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
ZERO_STRUCT(user);
@@ -286,25 +113,25 @@ static BOOL test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
c = libnet_rpc_userinfo_send(p, &user, msg_handler);
if (!c) {
printf("Failed to call sync libnet_rpc_userinfo_send\n");
- return False;
+ return false;
}
status = libnet_rpc_userinfo_recv(c, mem_ctx, &user);
if (!NT_STATUS_IS_OK(status)) {
printf("Calling async libnet_rpc_userinfo failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_userinfo(struct torture_context *torture)
+bool torture_userinfo(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct policy_handle h;
struct lsa_String name;
struct dom_sid2 sid;
@@ -317,31 +144,31 @@ BOOL torture_userinfo(struct torture_context *torture)
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- name.string = lp_workgroup();
+ name.string = lp_workgroup(global_loadparm);
/*
* Testing synchronous version
*/
if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) {
- ret = False;
+ ret = false;
goto done;
}
- if (!test_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) {
- ret = False;
+ if (!test_user_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) {
+ ret = false;
goto done;
}
if (!test_userinfo(p, mem_ctx, &h, &sid, TEST_USERNAME, &rid)) {
- ret = False;
+ ret = false;
goto done;
}
- if (!test_cleanup(p, mem_ctx, &h, TEST_USERNAME)) {
- ret = False;
+ if (!test_user_cleanup(p, mem_ctx, &h, TEST_USERNAME)) {
+ ret = false;
goto done;
}
@@ -349,22 +176,22 @@ BOOL torture_userinfo(struct torture_context *torture)
* Testing asynchronous version and monitor messages
*/
if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) {
- ret = False;
+ ret = false;
goto done;
}
- if (!test_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) {
- ret = False;
+ if (!test_user_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) {
+ ret = false;
goto done;
}
if (!test_userinfo_async(p, mem_ctx, &h, &sid, TEST_USERNAME, &rid)) {
- ret = False;
+ ret = false;
goto done;
}
- if (!test_cleanup(p, mem_ctx, &h, TEST_USERNAME)) {
- ret = False;
+ if (!test_user_cleanup(p, mem_ctx, &h, TEST_USERNAME)) {
+ ret = false;
goto done;
}
diff --git a/source4/torture/libnet/userman.c b/source4/torture/libnet/userman.c
index 90b3f41959..e834938bc5 100644
--- a/source4/torture/libnet/userman.c
+++ b/source4/torture/libnet/userman.c
@@ -23,65 +23,17 @@
#include "torture/libnet/usertest.h"
#include "libnet/libnet.h"
#include "librpc/gen_ndr/ndr_samr_c.h"
+#include "param/param.h"
+#include "torture/libnet/utils.h"
-static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, struct lsa_String *domname)
-{
- NTSTATUS status;
- struct policy_handle h, domain_handle;
- struct samr_Connect r1;
- struct samr_LookupDomain r2;
- struct samr_OpenDomain r3;
-
- printf("connecting\n");
-
- r1.in.system_name = 0;
- r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r1.out.connect_handle = &h;
-
- status = dcerpc_samr_Connect(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Connect failed - %s\n", nt_errstr(status));
- return False;
- }
-
- r2.in.connect_handle = &h;
- r2.in.domain_name = domname;
-
- printf("domain lookup on %s\n", domname->string);
-
- status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LookupDomain failed - %s\n", nt_errstr(status));
- return False;
- }
-
- r3.in.connect_handle = &h;
- r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r3.in.sid = r2.out.sid;
- r3.out.domain_handle = &domain_handle;
-
- printf("opening domain\n");
-
- status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenDomain failed - %s\n", nt_errstr(status));
- return False;
- } else {
- *handle = domain_handle;
- }
-
- return True;
-}
-
-static BOOL test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
const char *name)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct libnet_rpc_useradd user;
user.in.domain_handle = *domain_handle;
@@ -91,28 +43,15 @@ static BOOL test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = libnet_rpc_useradd(p, mem_ctx, &user);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to call sync rpc_composite_userinfo - %s\n", nt_errstr(status));
- return False;
+ printf("Failed to call libnet_rpc_useradd - %s\n", nt_errstr(status));
+ return false;
}
return ret;
}
-static void msg_handler(struct monitor_msg *m)
-{
- struct msg_rpc_create_user *msg_create;
-
- switch (m->type) {
- case mon_SamrCreateUser:
- msg_create = (struct msg_rpc_create_user*)m->data;
- printf("monitor_msg: user created (rid=%d)\n", msg_create->rid);
- break;
- }
-}
-
-
-static BOOL test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char* username)
{
NTSTATUS status;
@@ -127,133 +66,20 @@ static BOOL test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
c = libnet_rpc_useradd_send(p, &user, msg_handler);
if (!c) {
printf("Failed to call async libnet_rpc_useradd\n");
- return False;
+ return false;
}
status = libnet_rpc_useradd_recv(c, mem_ctx, &user);
if (!NT_STATUS_IS_OK(status)) {
printf("Calling async libnet_rpc_useradd failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-
-static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *domain_handle, const char *username)
-{
- NTSTATUS status;
- struct samr_LookupNames r1;
- struct samr_OpenUser r2;
- struct samr_DeleteUser r3;
- struct lsa_String names[2];
- uint32_t rid;
- struct policy_handle user_handle;
-
- names[0].string = username;
-
- r1.in.domain_handle = domain_handle;
- r1.in.num_names = 1;
- r1.in.names = names;
-
- printf("user account lookup '%s'\n", username);
-
- status = dcerpc_samr_LookupNames(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LookupNames failed - %s\n", nt_errstr(status));
- return False;
- }
-
- rid = r1.out.rids.ids[0];
-
- r2.in.domain_handle = domain_handle;
- r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r2.in.rid = rid;
- r2.out.user_handle = &user_handle;
-
- printf("opening user account\n");
-
- status = dcerpc_samr_OpenUser(p, mem_ctx, &r2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenUser failed - %s\n", nt_errstr(status));
- return False;
- }
-
- r3.in.user_handle = &user_handle;
- r3.out.user_handle = &user_handle;
-
- printf("deleting user account\n");
-
- status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3);
- if (!NT_STATUS_IS_OK(status)) {
- printf("DeleteUser failed - %s\n", nt_errstr(status));
- return False;
- }
-
- return True;
-}
-
-
-static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, const char* user)
-{
- NTSTATUS status;
- struct policy_handle user_handle;
- struct lsa_String username;
- struct samr_CreateUser r1;
- struct samr_Close r2;
- uint32_t user_rid;
-
- username.string = user;
-
- r1.in.domain_handle = handle;
- r1.in.account_name = &username;
- r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r1.out.user_handle = &user_handle;
- r1.out.rid = &user_rid;
-
- printf("creating user '%s'\n", username.string);
-
- status = dcerpc_samr_CreateUser(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("CreateUser failed - %s\n", nt_errstr(status));
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
- printf("User (%s) already exists - attempting to delete and recreate account again\n", user);
- if (!test_cleanup(p, mem_ctx, handle, TEST_USERNAME)) {
- return False;
- }
-
- printf("creating user account\n");
-
- status = dcerpc_samr_CreateUser(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("CreateUser failed - %s\n", nt_errstr(status));
- return False;
- }
- return True;
- }
- return False;
- }
-
- r2.in.handle = &user_handle;
- r2.out.handle = &user_handle;
-
- printf("closing user '%s'\n", username.string);
-
- status = dcerpc_samr_Close(p, mem_ctx, &r2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Close failed - %s\n", nt_errstr(status));
- return False;
- }
-
- return True;
-}
-
-
-static BOOL test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, int num_changes,
struct libnet_rpc_usermod *mod, char **username)
{
@@ -356,7 +182,7 @@ static BOOL test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
case acct_expiry:
continue_if_field_set(mod->in.change.acct_expiry);
now = timeval_add(&now, (random() % (31*24*60*60)), 0);
- mod->in.change.acct_expiry = talloc_memdup(mem_ctx, &now, sizeof(now));
+ mod->in.change.acct_expiry = (struct timeval *)talloc_memdup(mem_ctx, &now, sizeof(now));
mod->in.change.fields |= USERMOD_FIELD_ACCT_EXPIRY;
fldname = "acct_expiry";
break;
@@ -380,14 +206,14 @@ static BOOL test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = libnet_rpc_usermod(p, mem_ctx, mod);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to call sync libnet_rpc_usermod - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char *username)
{
NTSTATUS status;
@@ -399,10 +225,10 @@ static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = libnet_rpc_userdel(p, mem_ctx, &user);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to call sync libnet_rpc_userdel - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
@@ -412,7 +238,7 @@ static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("'%s' field does not match\n", #fld); \
printf("received: '%s'\n", i->fld.string); \
printf("expected: '%s'\n", mod->in.change.fld); \
- return False; \
+ return false; \
}
@@ -421,9 +247,12 @@ static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
nttime_to_timeval(&t, i->fld); \
if (timeval_compare(&t, mod->in.change.fld)) { \
printf("'%s' field does not match\n", #fld); \
- printf("received: '%s (+%ld us)'\n", timestring(mem_ctx, t.tv_sec), t.tv_usec); \
- printf("expected: '%s (+%ld us)'\n", timestring(mem_ctx, mod->in.change.fld->tv_sec), mod->in.change.fld->tv_usec); \
- return False; \
+ printf("received: '%s (+%ld us)'\n", \
+ timestring(mem_ctx, t.tv_sec), t.tv_usec); \
+ printf("expected: '%s (+%ld us)'\n", \
+ timestring(mem_ctx, mod->in.change.fld->tv_sec), \
+ mod->in.change.fld->tv_usec); \
+ return false; \
} \
}
@@ -433,11 +262,11 @@ static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("'%s' field does not match\n", #fld); \
printf("received: '%04x'\n", i->fld); \
printf("expected: '%04x'\n", mod->in.change.fld); \
- return False; \
+ return false; \
}
-static BOOL test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct libnet_rpc_usermod *mod,
const char *username)
{
@@ -455,7 +284,7 @@ static BOOL test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = libnet_rpc_userinfo(p, mem_ctx, &info);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
- return False;
+ return false;
}
i = &info.out.info.info21;
@@ -471,19 +300,20 @@ static BOOL test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
CMP_TIME_FLD(acct_expiry, USERMOD_FIELD_ACCT_EXPIRY);
CMP_NUM_FLD(acct_flags, USERMOD_FIELD_ACCT_FLAGS)
- return True;
+ return true;
}
-BOOL torture_useradd(struct torture_context *torture)
+bool torture_useradd(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
struct policy_handle h;
struct lsa_String domain_name;
+ struct dom_sid2 sid;
const char *name = TEST_USERNAME;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
mem_ctx = talloc_init("test_useradd");
@@ -492,37 +322,37 @@ BOOL torture_useradd(struct torture_context *torture)
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- domain_name.string = lp_workgroup();
- if (!test_opendomain(p, mem_ctx, &h, &domain_name)) {
- ret = False;
+ domain_name.string = lp_workgroup(global_loadparm);
+ if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ ret = false;
goto done;
}
if (!test_useradd(p, mem_ctx, &h, name)) {
- ret = False;
+ ret = false;
goto done;
}
- if (!test_cleanup(p, mem_ctx, &h, name)) {
- ret = False;
+ if (!test_user_cleanup(p, mem_ctx, &h, name)) {
+ ret = false;
goto done;
}
- if (!test_opendomain(p, mem_ctx, &h, &domain_name)) {
- ret = False;
+ if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ ret = false;
goto done;
}
if (!test_useradd_async(p, mem_ctx, &h, name)) {
- ret = False;
+ ret = false;
goto done;
}
- if (!test_cleanup(p, mem_ctx, &h, name)) {
- ret = False;
+ if (!test_user_cleanup(p, mem_ctx, &h, name)) {
+ ret = false;
goto done;
}
@@ -532,15 +362,17 @@ done:
}
-BOOL torture_userdel(struct torture_context *torture)
+bool torture_userdel(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
struct policy_handle h;
struct lsa_String domain_name;
+ struct dom_sid2 sid;
+ uint32_t rid;
const char *name = TEST_USERNAME;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
mem_ctx = talloc_init("test_userdel");
@@ -549,22 +381,22 @@ BOOL torture_userdel(struct torture_context *torture)
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
- domain_name.string = lp_workgroup();
- if (!test_opendomain(p, mem_ctx, &h, &domain_name)) {
- ret = False;
+ domain_name.string = lp_workgroup(global_loadparm);
+ if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ ret = false;
goto done;
}
- if (!test_createuser(p, mem_ctx, &h, name)) {
- ret = False;
+ if (!test_user_create(p, mem_ctx, &h, name, &rid)) {
+ ret = false;
goto done;
}
if (!test_userdel(p, mem_ctx, &h, name)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -574,16 +406,18 @@ done:
}
-BOOL torture_usermod(struct torture_context *torture)
+bool torture_usermod(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
struct policy_handle h;
struct lsa_String domain_name;
+ struct dom_sid2 sid;
+ uint32_t rid;
int i;
char *name;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
mem_ctx = talloc_init("test_userdel");
@@ -592,20 +426,20 @@ BOOL torture_usermod(struct torture_context *torture)
&ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto done;
}
- domain_name.string = lp_workgroup();
+ domain_name.string = lp_workgroup(global_loadparm);
name = talloc_strdup(mem_ctx, TEST_USERNAME);
- if (!test_opendomain(p, mem_ctx, &h, &domain_name)) {
- ret = False;
+ if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ ret = false;
goto done;
}
- if (!test_createuser(p, mem_ctx, &h, name)) {
- ret = False;
+ if (!test_user_create(p, mem_ctx, &h, name, &rid)) {
+ ret = false;
goto done;
}
@@ -613,19 +447,19 @@ BOOL torture_usermod(struct torture_context *torture)
struct libnet_rpc_usermod m;
if (!test_usermod(p, mem_ctx, &h, i, &m, &name)) {
- ret = False;
+ ret = false;
goto cleanup;
}
if (!test_compare(p, mem_ctx, &h, &m, name)) {
- ret = False;
+ ret = false;
goto cleanup;
}
}
cleanup:
- if (!test_cleanup(p, mem_ctx, &h, name)) {
- ret = False;
+ if (!test_user_cleanup(p, mem_ctx, &h, name)) {
+ ret = false;
goto done;
}
diff --git a/source4/torture/libnet/utils.c b/source4/torture/libnet/utils.c
new file mode 100644
index 0000000000..47bb9315c7
--- /dev/null
+++ b/source4/torture/libnet/utils.c
@@ -0,0 +1,313 @@
+/*
+ Unix SMB/CIFS implementation.
+ Test suite for libnet calls.
+
+ Copyright (C) Rafal Szczesniak 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/>.
+*/
+
+/*
+ * These are more general use functions shared among the tests.
+ */
+
+#include "includes.h"
+#include "torture/rpc/rpc.h"
+#include "libnet/libnet.h"
+#include "librpc/gen_ndr/ndr_samr_c.h"
+#include "param/param.h"
+
+
+bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle, struct lsa_String *domname,
+ struct dom_sid2 *sid)
+{
+ NTSTATUS status;
+ struct policy_handle h, domain_handle;
+ struct samr_Connect r1;
+ struct samr_LookupDomain r2;
+ struct samr_OpenDomain r3;
+
+ printf("connecting\n");
+
+ r1.in.system_name = 0;
+ r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ r1.out.connect_handle = &h;
+
+ status = dcerpc_samr_Connect(p, mem_ctx, &r1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Connect failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ r2.in.connect_handle = &h;
+ r2.in.domain_name = domname;
+
+ printf("domain lookup on %s\n", domname->string);
+
+ status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("LookupDomain failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ r3.in.connect_handle = &h;
+ r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ r3.in.sid = r2.out.sid;
+ r3.out.domain_handle = &domain_handle;
+
+ printf("opening domain\n");
+
+ status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("OpenDomain failed - %s\n", nt_errstr(status));
+ return false;
+ } else {
+ *handle = domain_handle;
+ }
+
+ *sid = *r2.out.sid;
+ return true;
+}
+
+
+bool test_user_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *domain_handle,
+ const char *name)
+{
+ NTSTATUS status;
+ struct samr_LookupNames r1;
+ struct samr_OpenUser r2;
+ struct samr_DeleteUser r3;
+ struct lsa_String names[2];
+ uint32_t rid;
+ struct policy_handle user_handle;
+
+ names[0].string = name;
+
+ r1.in.domain_handle = domain_handle;
+ r1.in.num_names = 1;
+ r1.in.names = names;
+
+ printf("user account lookup '%s'\n", name);
+
+ status = dcerpc_samr_LookupNames(p, mem_ctx, &r1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("LookupNames failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ rid = r1.out.rids.ids[0];
+
+ r2.in.domain_handle = domain_handle;
+ r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ r2.in.rid = rid;
+ r2.out.user_handle = &user_handle;
+
+ printf("opening user account\n");
+
+ status = dcerpc_samr_OpenUser(p, mem_ctx, &r2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("OpenUser failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ r3.in.user_handle = &user_handle;
+ r3.out.user_handle = &user_handle;
+
+ printf("deleting user account\n");
+
+ status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("DeleteUser failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ return true;
+}
+
+
+bool test_user_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle, const char *name,
+ uint32_t *rid)
+{
+ NTSTATUS status;
+ struct lsa_String username;
+ struct samr_CreateUser r;
+ struct policy_handle user_handle;
+
+ username.string = name;
+
+ r.in.domain_handle = handle;
+ r.in.account_name = &username;
+ r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ r.out.user_handle = &user_handle;
+ r.out.rid = rid;
+
+ printf("creating user account %s\n", name);
+
+ status = dcerpc_samr_CreateUser(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("CreateUser failed - %s\n", nt_errstr(status));
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
+ printf("User (%s) already exists - attempting to delete and recreate account again\n", name);
+ if (!test_user_cleanup(p, mem_ctx, handle, name)) {
+ return false;
+ }
+
+ printf("creating user account\n");
+
+ status = dcerpc_samr_CreateUser(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("CreateUser failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ return true;
+}
+
+
+bool test_group_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *domain_handle,
+ const char *name)
+{
+ NTSTATUS status;
+ struct samr_LookupNames r1;
+ struct samr_OpenGroup r2;
+ struct samr_DeleteDomainGroup r3;
+ struct lsa_String names[2];
+ uint32_t rid;
+ struct policy_handle group_handle;
+
+ names[0].string = name;
+
+ r1.in.domain_handle = domain_handle;
+ r1.in.num_names = 1;
+ r1.in.names = names;
+
+ printf("group account lookup '%s'\n", name);
+
+ status = dcerpc_samr_LookupNames(p, mem_ctx, &r1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("LookupNames failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ rid = r1.out.rids.ids[0];
+
+ r2.in.domain_handle = domain_handle;
+ r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ r2.in.rid = rid;
+ r2.out.group_handle = &group_handle;
+
+ printf("opening group account\n");
+
+ status = dcerpc_samr_OpenGroup(p, mem_ctx, &r2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("OpenGroup failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ r3.in.group_handle = &group_handle;
+ r3.out.group_handle = &group_handle;
+
+ printf("deleting group account\n");
+
+ status = dcerpc_samr_DeleteDomainGroup(p, mem_ctx, &r3);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("DeleteGroup failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ return true;
+}
+
+
+bool test_group_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle, const char *name,
+ uint32_t *rid)
+{
+ NTSTATUS status;
+ struct lsa_String groupname;
+ struct samr_CreateDomainGroup r;
+ struct policy_handle group_handle;
+
+ groupname.string = name;
+
+ r.in.domain_handle = handle;
+ r.in.name = &groupname;
+ r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ r.out.group_handle = &group_handle;
+ r.out.rid = rid;
+
+ printf("creating group account %s\n", name);
+
+ status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("CreateGroup failed - %s\n", nt_errstr(status));
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
+ printf("Group (%s) already exists - attempting to delete and recreate account again\n", name);
+ if (!test_group_cleanup(p, mem_ctx, handle, name)) {
+ return false;
+ }
+
+ printf("creating group account\n");
+
+ status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("CreateGroup failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ return true;
+}
+
+
+void msg_handler(struct monitor_msg *m)
+{
+ struct msg_rpc_open_user *msg_open;
+ struct msg_rpc_query_user *msg_query;
+ struct msg_rpc_close_user *msg_close;
+ struct msg_rpc_create_user *msg_create;
+
+ switch (m->type) {
+ case mon_SamrOpenUser:
+ msg_open = (struct msg_rpc_open_user*)m->data;
+ printf("monitor_msg: user opened (rid=%d, access_mask=0x%08x)\n",
+ msg_open->rid, msg_open->access_mask);
+ break;
+ case mon_SamrQueryUser:
+ msg_query = (struct msg_rpc_query_user*)m->data;
+ printf("monitor_msg: user queried (level=%d)\n", msg_query->level);
+ break;
+ case mon_SamrCloseUser:
+ msg_close = (struct msg_rpc_close_user*)m->data;
+ printf("monitor_msg: user closed (rid=%d)\n", msg_close->rid);
+ break;
+ case mon_SamrCreateUser:
+ msg_create = (struct msg_rpc_create_user*)m->data;
+ printf("monitor_msg: user created (rid=%d)\n", msg_create->rid);
+ break;
+ }
+}
diff --git a/source4/torture/libnet/utils.h b/source4/torture/libnet/utils.h
new file mode 100644
index 0000000000..ff94ec49e9
--- /dev/null
+++ b/source4/torture/libnet/utils.h
@@ -0,0 +1,42 @@
+/*
+ Unix SMB/CIFS implementation.
+ Test suite for libnet calls.
+
+ Copyright (C) Rafal Szczesniak 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/>.
+*/
+
+
+bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle, struct lsa_String *domname,
+ struct dom_sid2 *sid);
+
+bool test_user_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle, const char *name,
+ uint32_t *rid);
+
+bool test_user_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *domain_handle,
+ const char *name);
+
+bool test_group_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle, const char *name,
+ uint32_t *rid);
+
+bool test_group_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *domain_handle,
+ const char *name);
+
+void msg_handler(struct monitor_msg *m);
diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk
index 1364028ab7..e3ea9e44ef 100644
--- a/source4/torture/local/config.mk
+++ b/source4/torture/local/config.mk
@@ -28,6 +28,7 @@ OBJ_FILES = \
../../lib/registry/tests/registry.o \
resolve.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 \
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c
index 2a9eb49d01..3445812365 100644
--- a/source4/torture/local/dbspeed.c
+++ b/source4/torture/local/dbspeed.c
@@ -26,10 +26,12 @@
#include "lib/ldb/include/ldb_errors.h"
#include "lib/db_wrap.h"
#include "torture/torture.h"
+#include "param/param.h"
float tdb_speed;
-static BOOL tdb_add_record(struct tdb_wrap *tdbw, const char *fmt1, const char *fmt2, int i)
+static bool tdb_add_record(struct tdb_wrap *tdbw, const char *fmt1,
+ const char *fmt2, int i)
{
TDB_DATA key, data;
int ret;
@@ -48,7 +50,7 @@ static BOOL tdb_add_record(struct tdb_wrap *tdbw, const char *fmt1, const char *
/*
test tdb speed
*/
-static BOOL test_tdb_speed(struct torture_context *torture, const void *_data)
+static bool test_tdb_speed(struct torture_context *torture, const void *_data)
{
struct timeval tv;
struct tdb_wrap *tdbw;
@@ -118,32 +120,32 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data)
unlink("test.tdb");
talloc_free(tmp_ctx);
- return True;
+ return true;
failed:
unlink("test.tdb");
talloc_free(tmp_ctx);
- return False;
+ return false;
}
-static BOOL ldb_add_record(struct ldb_context *ldb, unsigned rid)
+static bool ldb_add_record(struct ldb_context *ldb, unsigned rid)
{
struct ldb_message *msg;
int ret;
msg = ldb_msg_new(ldb);
if (msg == NULL) {
- return False;
+ return false;
}
msg->dn = ldb_dn_new_fmt(msg, ldb, "SID=S-1-5-21-53173311-3623041448-2049097239-%u", rid);
if (msg->dn == NULL) {
- return False;
+ return false;
}
if (ldb_msg_add_fmt(msg, "UID", "%u", rid) != 0) {
- return False;
+ return false;
}
ret = ldb_add(ldb, msg);
@@ -157,7 +159,7 @@ static BOOL ldb_add_record(struct ldb_context *ldb, unsigned rid)
/*
test ldb speed
*/
-static BOOL test_ldb_speed(struct torture_context *torture, const void *_data)
+static bool test_ldb_speed(struct torture_context *torture, const void *_data)
{
struct timeval tv;
struct ldb_context *ldb;
@@ -173,7 +175,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, "tdb://test.ldb",
+ ldb = ldb_wrap_connect(tmp_ctx, global_loadparm, "tdb://test.ldb",
NULL, NULL, LDB_FLG_NOSYNC, NULL);
if (!ldb) {
unlink("./test.ldb");
@@ -239,12 +241,12 @@ static BOOL test_ldb_speed(struct torture_context *torture, const void *_data)
unlink("./test.ldb");
talloc_free(tmp_ctx);
- return True;
+ return true;
failed:
unlink("./test.ldb");
talloc_free(tmp_ctx);
- return False;
+ return false;
}
struct torture_suite *torture_local_dbspeed(TALLOC_CTX *mem_ctx)
diff --git a/source4/torture/local/event.c b/source4/torture/local/event.c
index e2c7de1c72..46acf5938e 100644
--- a/source4/torture/local/event.c
+++ b/source4/torture/local/event.c
@@ -29,7 +29,7 @@ static int fde_count;
static void fde_handler(struct event_context *ev_ctx, struct fd_event *f,
uint16_t flags, void *private)
{
- int *fd = private;
+ int *fd = (int *)private;
char c;
#ifdef SA_SIGINFO
kill(getpid(), SIGUSR1);
@@ -43,14 +43,14 @@ static void fde_handler(struct event_context *ev_ctx, struct fd_event *f,
static void finished_handler(struct event_context *ev_ctx, struct timed_event *te,
struct timeval tval, void *private)
{
- int *finished = private;
+ int *finished = (int *)private;
(*finished) = 1;
}
static void count_handler(struct event_context *ev_ctx, struct signal_event *te,
int signum, int count, void *info, void *private)
{
- int *countp = private;
+ int *countp = (int *)private;
(*countp) += count;
}
diff --git a/source4/torture/local/iconv.c b/source4/torture/local/iconv.c
index c543aa7c8f..259769d60f 100644
--- a/source4/torture/local/iconv.c
+++ b/source4/torture/local/iconv.c
@@ -25,6 +25,7 @@
#include "system/iconv.h"
#include "system/time.h"
#include "libcli/raw/libcliraw.h"
+#include "param/param.h"
#include "torture/util.h"
#if HAVE_NATIVE_ICONV
@@ -33,7 +34,7 @@ static bool iconv_untestable(struct torture_context *tctx)
{
iconv_t cd;
- if (!lp_parm_bool(-1, "iconv", "native", true))
+ if (!lp_parm_bool(global_loadparm, NULL, "iconv", "native", true))
torture_skip(tctx, "system iconv disabled - skipping test");
cd = iconv_open("UTF-16LE", "UCS-4LE");
@@ -313,10 +314,10 @@ static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint)
static bool test_next_codepoint(struct torture_context *tctx)
{
+ unsigned int codepoint;
if (iconv_untestable(tctx))
return true;
- unsigned int codepoint;
for (codepoint=0;codepoint<(1<<20);codepoint++) {
if (!test_codepoint(tctx, codepoint))
return false;
@@ -339,7 +340,7 @@ static bool test_first_1m(struct torture_context *tctx)
}
if (codepoint % 1000 == 0) {
- if (torture_setting_bool(tctx, "progress", True)) {
+ if (torture_setting_bool(tctx, "progress", true)) {
torture_comment(tctx, "codepoint=%u \r", codepoint);
fflush(stdout);
}
@@ -402,13 +403,13 @@ struct torture_suite *torture_local_iconv(TALLOC_CTX *mem_ctx)
struct torture_suite *suite = torture_suite_create(mem_ctx, "ICONV");
torture_suite_add_simple_test(suite, "next_codepoint()",
- test_next_codepoint);
+ test_next_codepoint);
torture_suite_add_simple_test(suite, "first 1M codepoints",
- test_first_1m);
+ test_first_1m);
torture_suite_add_simple_test(suite, "5M random UTF-16LE sequences",
- test_random_5m);
+ test_random_5m);
return suite;
}
diff --git a/source4/torture/local/irpc.c b/source4/torture/local/irpc.c
index fa6e3e7ade..aae6b4882e 100644
--- a/source4/torture/local/irpc.c
+++ b/source4/torture/local/irpc.c
@@ -25,10 +25,11 @@
#include "librpc/gen_ndr/ndr_echo.h"
#include "torture/torture.h"
#include "cluster/cluster.h"
+#include "param/param.h"
const uint32_t MSG_ID1 = 1, MSG_ID2 = 2;
-static BOOL test_debug;
+static bool test_debug;
struct irpc_test_data
{
@@ -71,7 +72,7 @@ static void deferred_echodata(struct event_context *ev, struct timed_event *te,
*/
static NTSTATUS irpc_EchoData(struct irpc_message *irpc, struct echo_EchoData *r)
{
- irpc->defer_reply = True;
+ irpc->defer_reply = true;
event_add_timed(irpc->ev, irpc, timeval_zero(), deferred_echodata, irpc);
return NT_STATUS_OK;
}
@@ -85,16 +86,16 @@ static bool test_addone(struct torture_context *test, const void *_data,
{
struct echo_AddOne r;
NTSTATUS status;
- const struct irpc_test_data *data = _data;
+ const struct irpc_test_data *data = (const struct irpc_test_data *)_data;
uint32_t value = (uint32_t)_value;
/* make the call */
r.in.in_data = value;
- test_debug = True;
+ test_debug = true;
status = IRPC_CALL(data->msg_ctx1, cluster_id(MSG_ID2),
rpcecho, ECHO_ADDONE, &r, test);
- test_debug = False;
+ test_debug = false;
torture_assert_ntstatus_ok(test, status, "AddOne failed");
/* check the answer */
@@ -114,7 +115,7 @@ static bool test_echodata(struct torture_context *tctx,
{
struct echo_EchoData r;
NTSTATUS status;
- const struct irpc_test_data *data = tcase_data;
+ const struct irpc_test_data *data = (const struct irpc_test_data *)tcase_data;
TALLOC_CTX *mem_ctx = tctx;
/* make the call */
@@ -143,7 +144,7 @@ static bool test_echodata(struct torture_context *tctx,
static void irpc_callback(struct irpc_request *irpc)
{
- struct echo_AddOne *r = irpc->r;
+ struct echo_AddOne *r = (struct echo_AddOne *)irpc->r;
int *pong_count = (int *)irpc->async.private;
NTSTATUS status = irpc_call_recv(irpc);
if (!NT_STATUS_IS_OK(status)) {
@@ -165,7 +166,7 @@ static bool test_speed(struct torture_context *tctx,
{
int ping_count = 0;
int pong_count = 0;
- const struct irpc_test_data *data = tcase_data;
+ const struct irpc_test_data *data = (const struct irpc_test_data *)tcase_data;
struct timeval tv;
struct echo_AddOne r;
TALLOC_CTX *mem_ctx = tctx;
@@ -208,22 +209,24 @@ static bool test_speed(struct torture_context *tctx,
}
-static BOOL irpc_setup(struct torture_context *tctx, void **_data)
+static bool irpc_setup(struct torture_context *tctx, void **_data)
{
struct irpc_test_data *data;
*_data = data = talloc(tctx, struct irpc_test_data);
- lp_set_cmdline("lock dir", "lockdir.tmp");
+ lp_set_cmdline(global_loadparm, "pid directory", "piddir.tmp");
data->ev = tctx->ev;
torture_assert(tctx, data->msg_ctx1 =
messaging_init(tctx,
+ lp_messaging_path(tctx, global_loadparm),
cluster_id(MSG_ID1), data->ev),
"Failed to init first messaging context");
torture_assert(tctx, data->msg_ctx2 =
messaging_init(tctx,
+ lp_messaging_path(tctx, global_loadparm),
cluster_id(MSG_ID2), data->ev),
"Failed to init second messaging context");
@@ -234,7 +237,7 @@ static BOOL irpc_setup(struct torture_context *tctx, void **_data)
IRPC_REGISTER(data->msg_ctx1, rpcecho, ECHO_ECHODATA, irpc_EchoData, NULL);
IRPC_REGISTER(data->msg_ctx2, rpcecho, ECHO_ECHODATA, irpc_EchoData, NULL);
- return True;
+ return true;
}
struct torture_suite *torture_local_irpc(TALLOC_CTX *mem_ctx)
diff --git a/source4/torture/local/local.c b/source4/torture/local/local.c
index 90c3c0d3d9..a52f5d2f7d 100644
--- a/source4/torture/local/local.c
+++ b/source4/torture/local/local.c
@@ -33,6 +33,7 @@
torture_local_irpc,
torture_local_util_strlist,
torture_local_util_file,
+ torture_local_util_str,
torture_local_idtree,
torture_local_genrand,
torture_local_iconv,
diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c
index 724e2a54c7..bf2b83a0e4 100644
--- a/source4/torture/local/messaging.c
+++ b/source4/torture/local/messaging.c
@@ -24,6 +24,7 @@
#include "lib/messaging/irpc.h"
#include "torture/torture.h"
#include "cluster/cluster.h"
+#include "param/param.h"
static uint32_t msg_pong;
@@ -67,20 +68,25 @@ static bool test_ping_speed(struct torture_context *tctx)
uint32_t msg_ping, msg_exit;
TALLOC_CTX *mem_ctx = tctx;
- lp_set_cmdline("pid directory", "piddir.tmp");
+ lp_set_cmdline(global_loadparm, "pid directory", "piddir.tmp");
ev = tctx->ev;
- msg_server_ctx = messaging_init(mem_ctx, cluster_id(1), ev);
+ msg_server_ctx = messaging_init(mem_ctx,
+ lp_messaging_path(tctx, global_loadparm),
+ cluster_id(1), ev);
torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context");
messaging_register_tmp(msg_server_ctx, NULL, ping_message, &msg_ping);
messaging_register_tmp(msg_server_ctx, mem_ctx, exit_message, &msg_exit);
- msg_client_ctx = messaging_init(mem_ctx, cluster_id(2), ev);
+ msg_client_ctx = messaging_init(mem_ctx,
+ lp_messaging_path(mem_ctx, global_loadparm),
+ cluster_id(2), ev);
- torture_assert(tctx, msg_client_ctx != NULL, "msg_client_ctx messaging_init() failed");
+ torture_assert(tctx, msg_client_ctx != NULL,
+ "msg_client_ctx messaging_init() failed");
messaging_register_tmp(msg_client_ctx, &pong_count, pong_message, &msg_pong);
diff --git a/source4/torture/local/sddl.c b/source4/torture/local/sddl.c
index ac10627783..3e6382309e 100644
--- a/source4/torture/local/sddl.c
+++ b/source4/torture/local/sddl.c
@@ -33,7 +33,7 @@ static bool test_sddl(struct torture_context *tctx,
{
struct security_descriptor *sd, *sd2;
struct dom_sid *domain;
- const char *sddl = test_data;
+ const char *sddl = (const char *)test_data;
const char *sddl2;
TALLOC_CTX *mem_ctx = tctx;
diff --git a/source4/torture/local/share.c b/source4/torture/local/share.c
index 528f34f861..de93e3c591 100644
--- a/source4/torture/local/share.c
+++ b/source4/torture/local/share.c
@@ -27,7 +27,7 @@ static bool test_list_empty(struct torture_context *tctx,
const void *tcase_data,
const void *test_data)
{
- struct share_context *ctx = discard_const(tcase_data);
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
int count;
const char **names;
@@ -41,7 +41,7 @@ static bool test_create(struct torture_context *tctx,
const void *tcase_data,
const void *test_data)
{
- struct share_context *ctx = discard_const(tcase_data);
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
int count;
const char **names;
int i;
@@ -79,7 +79,7 @@ static bool test_create_invalid(struct torture_context *tctx,
const void *tcase_data,
const void *test_data)
{
- struct share_context *ctx = discard_const(tcase_data);
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
NTSTATUS status;
status = share_create(ctx, "bla", NULL, 0);
@@ -102,7 +102,7 @@ static bool test_share_remove_invalid(struct torture_context *tctx,
const void *tcase_data,
const void *test_data)
{
- struct share_context *ctx = discard_const(tcase_data);
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
NTSTATUS status;
status = share_remove(ctx, "nonexistant");
@@ -121,7 +121,7 @@ static bool test_share_remove(struct torture_context *tctx,
const void *tcase_data,
const void *test_data)
{
- struct share_context *ctx = discard_const(tcase_data);
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
struct share_info inf[] = {
{ SHARE_INFO_STRING, SHARE_TYPE, discard_const_p(void *, "IPC$") },
{ SHARE_INFO_STRING, SHARE_PATH, discard_const_p(void *, "/tmp/bla") }
@@ -144,7 +144,7 @@ static bool test_double_create(struct torture_context *tctx,
const void *tcase_data,
const void *test_data)
{
- struct share_context *ctx = discard_const(tcase_data);
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
struct share_info inf[] = {
{ SHARE_INFO_STRING, SHARE_TYPE, discard_const_p(void *, "IPC$") },
{ SHARE_INFO_STRING, SHARE_PATH, discard_const_p(void *, "/tmp/bla") }
@@ -175,17 +175,17 @@ static void tcase_add_share_tests(struct torture_tcase *tcase)
torture_tcase_add_test(tcase, "share_double_create", test_double_create, NULL);
}
-static BOOL setup_ldb(struct torture_context *tctx, void **data)
+static bool setup_ldb(struct torture_context *tctx, void **data)
{
return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "ldb", (struct share_context **)data));
}
-static BOOL setup_classic(struct torture_context *tctx, void **data)
+static bool setup_classic(struct torture_context *tctx, void **data)
{
return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "classic", (struct share_context **)data));
}
-static BOOL teardown(struct torture_context *tctx, void *data)
+static bool teardown(struct torture_context *tctx, void *data)
{
talloc_free(data);
return true;
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index ba0ba344d9..24b9606961 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -24,17 +24,19 @@
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
#include "libcli/libcli.h"
+#include "param/param.h"
+#include "dynconfig.h"
static int numops = 1000;
-static BOOL showall;
-static BOOL analyze;
-static BOOL hide_unlock_fails;
-static BOOL use_oplocks;
+static bool showall;
+static bool analyze;
+static bool hide_unlock_fails;
+static bool use_oplocks;
static uint_t lock_range = 100;
static uint_t lock_base = 0;
static uint_t min_length = 0;
-static BOOL exact_error_codes;
-static BOOL zero_zero;
+static bool exact_error_codes;
+static bool zero_zero;
#define FILENAME "\\locktest.dat"
@@ -122,7 +124,7 @@ static struct smbcli_state *connect_one(char *share, int snum, int conn)
char **unc_list = NULL;
int num_unc_names;
const char *p;
- p = lp_parm_string(-1, "torture", "unclist");
+ p = lp_parm_string(global_loadparm, NULL, "torture", "unclist");
if (p) {
char *h, *s;
unc_list = file_lines_load(p, &num_unc_names, NULL);
@@ -201,7 +203,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
uint64_t len = rec->len;
enum brl_type op = rec->lock_type;
int server;
- BOOL ret[NSERVERS];
+ bool ret[NSERVERS];
NTSTATUS status[NSERVERS];
switch (rec->lock_op) {
@@ -251,7 +253,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
op==READ_LOCK?"READ_LOCK":"WRITE_LOCK",
nt_errstr(status[0]), nt_errstr(status[1]));
}
- if (!NT_STATUS_EQUAL(status[0],status[1])) return False;
+ if (!NT_STATUS_EQUAL(status[0],status[1])) return false;
break;
case OP_UNLOCK:
@@ -293,7 +295,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
nt_errstr(status[0]), nt_errstr(status[1]));
}
if (!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1]))
- return False;
+ return false;
break;
case OP_REOPEN:
@@ -308,7 +310,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
DENY_NONE);
if (fnum[server][conn][f] == -1) {
printf("failed to reopen on share%d\n", server);
- return False;
+ return false;
}
}
if (showall) {
@@ -318,7 +320,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
break;
}
- return True;
+ return true;
}
static void close_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
@@ -425,7 +427,7 @@ static void test_locks(char *share[NSERVERS])
} else {
recorded[n].lock_op = OP_REOPEN;
}
- recorded[n].needed = True;
+ recorded[n].needed = true;
if (!zero_zero && recorded[n].start==0 && recorded[n].len==0) {
recorded[n].len = 1;
}
@@ -454,7 +456,7 @@ static void test_locks(char *share[NSERVERS])
int m, j;
printf("excluding %d-%d\n", i, i+skip-1);
for (j=i;j<i+skip;j++) {
- recorded[j].needed = False;
+ recorded[j].needed = false;
}
close_files(cli, fnum);
@@ -463,7 +465,7 @@ static void test_locks(char *share[NSERVERS])
m = retest(cli, fnum, n);
if (m == n) {
for (j=i;j<i+skip;j++) {
- recorded[j].needed = True;
+ recorded[j].needed = true;
}
} else {
if (i+(skip-1) < m) {
@@ -487,7 +489,7 @@ static void test_locks(char *share[NSERVERS])
close_files(cli, fnum);
reconnect(cli, fnum, share);
open_files(cli, fnum);
- showall = True;
+ showall = true;
n1 = retest(cli, fnum, n);
if (n1 != n-1) {
printf("ERROR - inconsistent result (%u %u)\n", n1, n);
@@ -559,7 +561,7 @@ static void usage(void)
argc -= NSERVERS;
argv += NSERVERS;
- lp_load();
+ lp_load(dyn_CONFIGFILE);
servers[0] = cli_credentials_init(talloc_autofree_context());
servers[1] = cli_credentials_init(talloc_autofree_context());
@@ -592,31 +594,31 @@ static void usage(void)
seed = atoi(optarg);
break;
case 'u':
- hide_unlock_fails = True;
+ hide_unlock_fails = true;
break;
case 'o':
numops = atoi(optarg);
break;
case 'O':
- use_oplocks = True;
+ use_oplocks = true;
break;
case 'a':
- showall = True;
+ showall = true;
break;
case 'A':
- analyze = True;
+ analyze = true;
break;
case 'Z':
- zero_zero = True;
+ zero_zero = true;
break;
case 'E':
- exact_error_codes = True;
+ exact_error_codes = true;
break;
case 'l':
- lp_set_cmdline("torture:unclist", optarg);
+ lp_set_cmdline(global_loadparm, "torture:unclist", optarg);
break;
case 'W':
- lp_set_cmdline("workgroup", optarg);
+ lp_set_cmdline(global_loadparm, "workgroup", optarg);
break;
case 'h':
usage();
diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c
index 9d4f0260b1..55edd4aa17 100644
--- a/source4/torture/locktest2.c
+++ b/source4/torture/locktest2.c
@@ -24,10 +24,10 @@ static fstring password;
static fstring username;
static int got_pass;
static int numops = 1000;
-static BOOL showall;
-static BOOL analyze;
-static BOOL hide_unlock_fails;
-static BOOL use_oplocks;
+static bool showall;
+static bool analyze;
+static bool hide_unlock_fails;
+static bool use_oplocks;
#define FILENAME "\\locktest.dat"
#define LOCKRANGE 100
@@ -77,7 +77,7 @@ static int try_open(struct smbcli_state *c, char *nfs, int fstype, const char *f
return -1;
}
-static BOOL try_close(struct smbcli_state *c, int fstype, int fd)
+static bool try_close(struct smbcli_state *c, int fstype, int fd)
{
switch (fstype) {
case FSTYPE_SMB:
@@ -87,10 +87,10 @@ static BOOL try_close(struct smbcli_state *c, int fstype, int fd)
return close(fd) == 0;
}
- return False;
+ return false;
}
-static BOOL try_lock(struct smbcli_state *c, int fstype,
+static bool try_lock(struct smbcli_state *c, int fstype,
int fd, uint_t start, uint_t len,
enum brl_type op)
{
@@ -109,10 +109,10 @@ static BOOL try_lock(struct smbcli_state *c, int fstype,
return fcntl(fd,F_SETLK,&lock) == 0;
}
- return False;
+ return false;
}
-static BOOL try_unlock(struct smbcli_state *c, int fstype,
+static bool try_unlock(struct smbcli_state *c, int fstype,
int fd, uint_t start, uint_t len)
{
struct flock lock;
@@ -130,7 +130,7 @@ static BOOL try_unlock(struct smbcli_state *c, int fstype,
return fcntl(fd,F_SETLK,&lock) == 0;
}
- return False;
+ return false;
}
/*****************************************************
@@ -207,7 +207,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
-static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
+static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
struct record *rec)
@@ -221,7 +221,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
uint_t r2 = rec->r2;
enum brl_type op;
int server;
- BOOL ret[NSERVERS];
+ bool ret[NSERVERS];
if (r1 < READ_PCT) {
op = READ_LOCK;
@@ -243,7 +243,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
op==READ_LOCK?"READ_LOCK":"WRITE_LOCK",
ret[0], ret[1]);
}
- if (ret[0] != ret[1]) return False;
+ if (ret[0] != ret[1]) return false;
} else if (r2 < LOCK_PCT+UNLOCK_PCT) {
/* unset a lock */
for (server=0;server<NSERVERS;server++) {
@@ -257,7 +257,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
start, start+len-1, len,
ret[0], ret[1]);
}
- if (!hide_unlock_fails && ret[0] != ret[1]) return False;
+ if (!hide_unlock_fails && ret[0] != ret[1]) return false;
} else {
/* reopen the file */
for (server=0;server<NSERVERS;server++) {
@@ -266,7 +266,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
O_RDWR|O_CREAT);
if (fnum[server][fstype][conn][f] == -1) {
printf("failed to reopen on share1\n");
- return False;
+ return false;
}
}
if (showall) {
@@ -274,7 +274,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
conn, fstype, f);
}
}
- return True;
+ return true;
}
static void close_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
@@ -369,7 +369,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
recorded[n].len *= RANGE_MULTIPLE;
recorded[n].r1 = random() % 100;
recorded[n].r2 = random() % 100;
- recorded[n].needed = True;
+ recorded[n].needed = true;
}
reconnect(cli, nfs, fnum, share1, share2);
@@ -388,14 +388,14 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
for (i=0;i<n-1;i++) {
int m;
- recorded[i].needed = False;
+ recorded[i].needed = false;
close_files(cli, nfs, fnum);
open_files(cli, nfs, fnum);
m = retest(cli, nfs, fnum, n);
if (m == n) {
- recorded[i].needed = True;
+ recorded[i].needed = true;
} else {
if (i < m) {
memmove(&recorded[i], &recorded[i+1],
@@ -412,7 +412,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
close_files(cli, nfs, fnum);
reconnect(cli, nfs, fnum, share1, share2);
open_files(cli, nfs, fnum);
- showall = True;
+ showall = true;
n1 = retest(cli, nfs, fnum, n);
if (n1 != n-1) {
printf("ERROR - inconsistent result (%u %u)\n", n1, n);
@@ -483,7 +483,7 @@ static void usage(void)
argc -= 4;
argv += 4;
- lp_load();
+ lp_load(dyn_CONFIGFILE);
if (getenv("USER")) {
fstrcpy(username,getenv("USER"));
@@ -506,19 +506,19 @@ static void usage(void)
seed = atoi(optarg);
break;
case 'u':
- hide_unlock_fails = True;
+ hide_unlock_fails = true;
break;
case 'o':
numops = atoi(optarg);
break;
case 'O':
- use_oplocks = True;
+ use_oplocks = true;
break;
case 'a':
- showall = True;
+ showall = true;
break;
case 'A':
- analyze = True;
+ analyze = true;
break;
case 'h':
usage();
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index 3eac50cbca..fec7657afe 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -26,10 +26,12 @@
#include "pstring.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
+#include "dynconfig.h"
static struct cli_credentials *credentials;
-static BOOL showall = False;
-static BOOL old_list = False;
+static bool showall = false;
+static bool old_list = false;
static const char *maskchars = "<>\"?*abc.";
static const char *filechars = "abcdefghijklm.";
static int verbose;
@@ -37,12 +39,12 @@ static int die_on_error;
static int NumLoops = 0;
static int max_length = 20;
-static BOOL reg_match_one(struct smbcli_state *cli, const char *pattern, const char *file)
+static bool reg_match_one(struct smbcli_state *cli, const char *pattern, const char *file)
{
/* oh what a weird world this is */
- if (old_list && strcmp(pattern, "*.*") == 0) return True;
+ if (old_list && strcmp(pattern, "*.*") == 0) return true;
- if (ISDOT(pattern)) return False;
+ if (ISDOT(pattern)) return false;
if (ISDOTDOT(file)) file = ".";
@@ -98,7 +100,7 @@ static struct {
pstring long_name;
pstring short_name;
} last_hit;
-static BOOL f_info_hit;
+static bool f_info_hit;
static void listfn(struct clilist_file_info *f, const char *s, void *state)
{
@@ -111,7 +113,7 @@ static void listfn(struct clilist_file_info *f, const char *s, void *state)
}
pstrcpy(last_hit.long_name, f->name);
pstrcpy(last_hit.short_name, f->short_name);
- f_info_hit = True;
+ f_info_hit = true;
}
static void get_real_name(struct smbcli_state *cli,
@@ -124,7 +126,7 @@ static void get_real_name(struct smbcli_state *cli,
mask = "\\masktest\\*";
}
- f_info_hit = False;
+ f_info_hit = false;
smbcli_list_new(cli->tree, mask,
FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
@@ -284,7 +286,7 @@ static void usage(void)
setup_logging("masktest", DEBUG_STDOUT);
- lp_set_cmdline("log level", "0");
+ lp_set_cmdline(global_loadparm, "log level", "0");
if (argc < 2 || argv[1][0] == '-') {
usage();
@@ -300,7 +302,7 @@ static void usage(void)
argc -= 1;
argv += 1;
- lp_load();
+ lp_load(dyn_CONFIGFILE);
credentials = cli_credentials_init(talloc_autofree_context());
cli_credentials_guess(credentials);
@@ -324,7 +326,7 @@ static void usage(void)
verbose++;
break;
case 'M':
- lp_set_cmdline("max protocol", optarg);
+ lp_set_cmdline(global_loadparm, "max protocol", optarg);
break;
case 'U':
cli_credentials_parse_string(credentials, optarg, CRED_SPECIFIED);
@@ -348,7 +350,7 @@ static void usage(void)
showall = 1;
break;
case 'o':
- old_list = True;
+ old_list = true;
break;
default:
printf("Unknown option %c (%d)\n", (char)opt, opt);
diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c
index d01c5a7ecd..ddedd102f9 100644
--- a/source4/torture/nbench/nbench.c
+++ b/source4/torture/nbench/nbench.c
@@ -56,14 +56,14 @@ static void do_reconnect(struct smbcli_state **cli, int client)
}
/* run a test that simulates an approximate netbench client load */
-static BOOL run_netbench(struct torture_context *tctx, struct smbcli_state *cli, int client)
+static bool run_netbench(struct torture_context *tctx, struct smbcli_state *cli, int client)
{
int torture_nprocs = torture_setting_int(tctx, "nprocs", 4);
int i;
pstring line;
char *cname;
FILE *f;
- BOOL correct = True;
+ bool correct = true;
double target_rate = torture_setting_double(tctx, "targetrate", 0);
int n;
@@ -85,7 +85,7 @@ static BOOL run_netbench(struct torture_context *tctx, struct smbcli_state *cli,
if (!f) {
perror(loadfile);
- return False;
+ return false;
}
again:
@@ -212,7 +212,7 @@ done:
smbcli_deltree(cli->tree, "\\clients");
}
if (!torture_close_connection(cli)) {
- correct = False;
+ correct = false;
}
return correct;
@@ -220,14 +220,14 @@ done:
/* run a test that simulates an approximate netbench client load */
-BOOL torture_nbench(struct torture_context *torture)
+bool torture_nbench(struct torture_context *torture)
{
- BOOL correct = True;
+ bool correct = true;
int torture_nprocs = torture_setting_int(torture, "nprocs", 4);
struct smbcli_state *cli;
const char *p;
- read_only = torture_setting_bool(torture, "readonly", False);
+ read_only = torture_setting_bool(torture, "readonly", false);
nb_max_retries = torture_setting_int(torture, "nretries", 1);
@@ -245,11 +245,11 @@ BOOL torture_nbench(struct torture_context *torture)
if (torture_nprocs > 1) {
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
if (!read_only && !torture_setup_dir(cli, "\\clients")) {
- return False;
+ return false;
}
}
diff --git a/source4/torture/nbench/nbio.c b/source4/torture/nbench/nbio.c
index 9624a7b14f..5de903ff78 100644
--- a/source4/torture/nbench/nbio.c
+++ b/source4/torture/nbench/nbio.c
@@ -36,7 +36,7 @@
extern int nbench_line_count;
static int nbio_id = -1;
static int nprocs;
-static BOOL bypass_io;
+static bool bypass_io;
static struct timeval tv_start, tv_end;
static int warmup, timelimit;
static int in_cleanup;
@@ -117,13 +117,13 @@ static bool nb_reestablish_locks(struct ftable *f)
if (!nb_do_lockx(true, f->handle, linfo->offset, linfo->size, NT_STATUS_OK)) {
printf("nb_reestablish_locks: failed to get lock for file %s at %lu\n",
f->cp.fname, (unsigned long) linfo->offset);
- return False;
+ return false;
}
linfo = linfo->next;
}
- return True;
+ return true;
}
static bool nb_reopen_all_files(void)
@@ -140,21 +140,21 @@ static bool nb_reopen_all_files(void)
f->cp.create_disposition,
f->cp.handle,
NT_STATUS_OK,
- True))
+ true))
{
printf("-- nb_reopen_all_files: failed to open file %s\n", f->cp.fname);
- return False;
+ return false;
}
if (!nb_reestablish_locks(f)) {
printf("--nb_reopen_all_files: failed to reestablish locks\n");
- return False;
+ return false;
}
f = f->next;
}
- return True;
+ return true;
}
bool nb_reconnect(struct smbcli_state **cli, int client)
@@ -168,17 +168,17 @@ bool nb_reconnect(struct smbcli_state **cli, int client)
if (!torture_open_connection(cli, client)) {
printf("nb_reconnect: failed to connect\n");
*cli = NULL;
- return False;
+ return false;
}
nb_setup(*cli, client);
if (!nb_reopen_all_files()) {
printf("nb_reconnect: failed to reopen files in client %d\n", client);
- return False;
+ return false;
}
- return True;
+ return true;
}
void nbio_target_rate(double rate)
@@ -242,7 +242,7 @@ double nbio_latency(void)
return max_latency;
}
-BOOL nb_tick(void)
+bool nb_tick(void)
{
return children[nbio_id].done;
}
@@ -383,10 +383,10 @@ static struct smbcli_state *c;
/*
a handler function for oplock break requests
*/
-static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid,
+static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid,
uint16_t fnum, uint8_t level, void *private)
{
- struct smbcli_tree *tree = private;
+ struct smbcli_tree *tree = (struct smbcli_tree *)private;
return smbcli_oplock_ack(tree, fnum, OPLOCK_BREAK_TO_NONE);
}
@@ -412,7 +412,7 @@ static bool check_status(const char *op, NTSTATUS status, NTSTATUS ret)
NT_STATUS_EQUAL(ret, NT_STATUS_CONNECTION_RESET))
&& !NT_STATUS_EQUAL (status, ret))
{
- return False;
+ return false;
}
if (!NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(ret)) {
@@ -432,7 +432,7 @@ static bool check_status(const char *op, NTSTATUS status, NTSTATUS ret)
nbench_line_count, nt_errstr(ret), nt_errstr(status));
}
- return True;
+ return true;
}
@@ -453,7 +453,7 @@ bool nb_unlink(const char *fname, int attr, NTSTATUS status, bool retry)
if (!retry)
return check_status("Unlink", status, ret);
- return True;
+ return true;
}
static bool nb_do_createx(struct ftable *f,
@@ -515,10 +515,10 @@ static bool nb_do_createx(struct ftable *f,
talloc_free(mem_ctx);
if (!check_status("NTCreateX", status, ret))
- return False;
+ return false;
if (!NT_STATUS_IS_OK(ret))
- return True;
+ return true;
if (f == NULL) {
f = talloc (NULL, struct ftable);
@@ -530,14 +530,14 @@ static bool nb_do_createx(struct ftable *f,
f->handle = handle;
f->fd = io.ntcreatex.out.file.fnum;
- return True;
+ return true;
}
bool nb_createx(const char *fname,
uint_t create_options, uint_t create_disposition, int handle,
NTSTATUS status)
{
- return nb_do_createx(NULL, fname, create_options, create_disposition, handle, status, False);
+ return nb_do_createx(NULL, fname, create_options, create_disposition, handle, status, false);
}
bool nb_writex(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
@@ -550,7 +550,7 @@ bool nb_writex(int handle, off_t offset, int size, int ret_size, NTSTATUS status
i = find_handle(handle, NULL);
if (bypass_io)
- return True;
+ return true;
buf = malloc(size);
memset(buf, 0xab, size);
@@ -568,7 +568,7 @@ bool nb_writex(int handle, off_t offset, int size, int ret_size, NTSTATUS status
free(buf);
if (!check_status("WriteX", status, ret))
- return False;
+ return false;
if (NT_STATUS_IS_OK(ret) && io.writex.out.nwritten != ret_size) {
printf("[%d] Warning: WriteX got count %d expected %d\n",
@@ -578,7 +578,7 @@ bool nb_writex(int handle, off_t offset, int size, int ret_size, NTSTATUS status
children[nbio_id].bytes += ret_size;
- return True;
+ return true;
}
bool nb_write(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
@@ -591,7 +591,7 @@ bool nb_write(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
i = find_handle(handle, NULL);
if (bypass_io)
- return True;
+ return true;
buf = malloc(size);
@@ -609,7 +609,7 @@ bool nb_write(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
free(buf);
if (!check_status("Write", status, ret))
- return False;
+ return false;
if (NT_STATUS_IS_OK(ret) && io.write.out.nwritten != ret_size) {
printf("[%d] Warning: Write got count %d expected %d\n",
@@ -619,7 +619,7 @@ bool nb_write(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
children[nbio_id].bytes += ret_size;
- return True;
+ return true;
}
static bool nb_do_lockx(bool relock, int handle, off_t offset, int size, NTSTATUS status)
@@ -647,7 +647,7 @@ static bool nb_do_lockx(bool relock, int handle, off_t offset, int size, NTSTATU
ret = smb_raw_lock(c->tree, &io);
if (!check_status("LockX", status, ret))
- return False;
+ return false;
if (f != NULL &&
!relock)
@@ -659,7 +659,7 @@ static bool nb_do_lockx(bool relock, int handle, off_t offset, int size, NTSTATU
DLIST_ADD_END(f->locks, linfo, struct lock_info *);
}
- return True;
+ return true;
}
bool nb_lockx(int handle, off_t offset, int size, NTSTATUS status)
@@ -692,7 +692,7 @@ bool nb_unlockx(int handle, uint_t offset, int size, NTSTATUS status)
ret = smb_raw_lock(c->tree, &io);
if (!check_status("UnlockX", status, ret))
- return False;
+ return false;
if (f != NULL) {
struct lock_info *linfo;
@@ -703,7 +703,7 @@ bool nb_unlockx(int handle, uint_t offset, int size, NTSTATUS status)
printf("nb_unlockx: unknown lock (%d)\n", handle);
}
- return True;
+ return true;
}
bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
@@ -716,7 +716,7 @@ bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
i = find_handle(handle, NULL);
if (bypass_io)
- return True;
+ return true;
buf = malloc(size);
@@ -726,7 +726,7 @@ bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
io.readx.in.mincnt = size;
io.readx.in.maxcnt = size;
io.readx.in.remaining = 0;
- io.readx.in.read_for_execute = False;
+ io.readx.in.read_for_execute = false;
io.readx.out.data = buf;
ret = smb_raw_read(c->tree, &io);
@@ -734,7 +734,7 @@ bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
free(buf);
if (!check_status("ReadX", status, ret))
- return False;
+ return false;
if (NT_STATUS_IS_OK(ret) && io.readx.out.nread != ret_size) {
printf("[%d] ERROR: ReadX got count %d expected %d\n",
@@ -745,7 +745,7 @@ bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
children[nbio_id].bytes += ret_size;
- return True;
+ return true;
}
bool nb_close(int handle, NTSTATUS status)
@@ -763,7 +763,7 @@ bool nb_close(int handle, NTSTATUS status)
ret = smb_raw_close(c->tree, &io);
if (!check_status("Close", status, ret))
- return False;
+ return false;
if (NT_STATUS_IS_OK(ret)) {
struct ftable *f = find_ftable(handle);
@@ -771,7 +771,7 @@ bool nb_close(int handle, NTSTATUS status)
talloc_free(f);
}
- return True;
+ return true;
}
bool nb_rmdir(const char *dname, NTSTATUS status, bool retry)
@@ -786,7 +786,7 @@ bool nb_rmdir(const char *dname, NTSTATUS status, bool retry)
if (!retry)
return check_status("Rmdir", status, ret);
- return True;
+ return true;
}
bool nb_mkdir(const char *dname, NTSTATUS status, bool retry)
@@ -799,7 +799,7 @@ bool nb_mkdir(const char *dname, NTSTATUS status, bool retry)
/* NOTE! no error checking. Used for base fileset creation */
smb_raw_mkdir(c->tree, &io);
- return True;
+ return true;
}
bool nb_rename(const char *old, const char *new, NTSTATUS status, bool retry)
@@ -817,7 +817,7 @@ bool nb_rename(const char *old, const char *new, NTSTATUS status, bool retry)
if (!retry)
return check_status("Rename", status, ret);
- return True;
+ return true;
}
@@ -869,7 +869,7 @@ bool nb_sfileinfo(int fnum, int level, NTSTATUS status)
if (level != RAW_SFILEINFO_BASIC_INFORMATION) {
printf("[%d] Warning: setfileinfo level %d not handled\n", nbench_line_count, level);
- return True;
+ return true;
}
ZERO_STRUCT(io);
@@ -906,9 +906,9 @@ bool nb_qfsinfo(int level, NTSTATUS status)
}
/* callback function used for trans2 search */
-static BOOL findfirst_callback(void *private, const union smb_search_data *file)
+static bool findfirst_callback(void *private, const union smb_search_data *file)
{
- return True;
+ return true;
}
bool nb_findfirst(const char *mask, int level, int maxcnt, int count, NTSTATUS status)
@@ -932,7 +932,7 @@ bool nb_findfirst(const char *mask, int level, int maxcnt, int count, NTSTATUS s
talloc_free(mem_ctx);
if (!check_status("Search", status, ret))
- return False;
+ return false;
if (NT_STATUS_IS_OK(ret) && io.t2ffirst.out.count != count) {
printf("[%d] Warning: got count %d expected %d\n",
@@ -940,7 +940,7 @@ bool nb_findfirst(const char *mask, int level, int maxcnt, int count, NTSTATUS s
io.t2ffirst.out.count, count);
}
- return True;
+ return true;
}
bool nb_flush(int fnum, NTSTATUS status)
@@ -984,7 +984,7 @@ bool nb_deltree(const char *dname, bool retry)
smbcli_rmdir(c->tree, dname);
- return True;
+ return true;
}
diff --git a/source4/torture/nbt/browse.c b/source4/torture/nbt/browse.c
index a9aac79469..e609e72055 100644
--- a/source4/torture/nbt/browse.c
+++ b/source4/torture/nbt/browse.c
@@ -33,7 +33,7 @@ bool torture_nbt_browse(struct torture_context *torture)
struct nbt_name name;
TALLOC_CTX *mem_ctx = talloc_new(NULL);
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
name.name = lp_workgroup();
name.type = NBT_NAME_BROWSER;
@@ -45,7 +45,7 @@ bool torture_nbt_browse(struct torture_context *torture)
printf("Failed to resolve %s - %s\n",
name.name, nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
talloc_free(mem_ctx);
diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c
index 2effe25ab7..e9cfda4b17 100644
--- a/source4/torture/nbt/dgram.c
+++ b/source4/torture/nbt/dgram.c
@@ -30,6 +30,7 @@
#include "libcli/resolve/resolve.h"
#include "system/network.h"
#include "lib/socket/netif.h"
+#include "param/param.h"
#define TEST_NAME "TORTURE_TEST"
@@ -42,7 +43,7 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot,
{
NTSTATUS status;
struct nbt_netlogon_packet netlogon;
- int *replies = dgmslot->private;
+ int *replies = (int *)dgmslot->private;
printf("netlogon reply from %s:%d\n", src->addr, src->port);
@@ -77,7 +78,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
const char *address;
struct nbt_name name;
- name.name = lp_workgroup();
+ name.name = lp_workgroup(global_loadparm);
name.type = NBT_NAME_LOGON;
name.scope = NULL;
@@ -90,7 +91,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
- myaddress, lp_dgram_port());
+ myaddress, lp_dgram_port(global_loadparm));
torture_assert(tctx, socket_address != NULL, "Error getting address");
/* try receiving replies on port 138 first, which will only
@@ -156,7 +157,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx)
const char *address;
struct nbt_name name;
- name.name = lp_workgroup();
+ name.name = lp_workgroup(global_loadparm);
name.type = NBT_NAME_LOGON;
name.scope = NULL;
@@ -168,7 +169,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx)
myaddress = talloc_strdup(dgmsock, iface_best_ip(address));
socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
- myaddress, lp_dgram_port());
+ myaddress, lp_dgram_port(global_loadparm));
torture_assert(tctx, socket_address != NULL, "Error getting address");
/* try receiving replies on port 138 first, which will only
@@ -227,7 +228,7 @@ static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot,
{
NTSTATUS status;
struct nbt_ntlogon_packet ntlogon;
- int *replies = dgmslot->private;
+ int *replies = (int *)dgmslot->private;
printf("ntlogon reply from %s:%d\n", src->addr, src->port);
@@ -265,7 +266,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
const char *address;
struct nbt_name name;
- name.name = lp_workgroup();
+ name.name = lp_workgroup(global_loadparm);
name.type = NBT_NAME_LOGON;
name.scope = NULL;
@@ -277,7 +278,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
myaddress = talloc_strdup(dgmsock, iface_best_ip(address));
socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
- myaddress, lp_dgram_port());
+ myaddress, lp_dgram_port(global_loadparm));
torture_assert(tctx, socket_address != NULL, "Error getting address");
/* try receiving replies on port 138 first, which will only
@@ -298,7 +299,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
ACB_WSTRUST, &machine_credentials);
torture_assert(tctx, join_ctx != NULL,
talloc_asprintf(tctx, "Failed to join domain %s as %s\n",
- lp_workgroup(), TEST_NAME));
+ lp_workgroup(global_loadparm), TEST_NAME));
dom_sid = torture_join_sid(join_ctx);
@@ -340,9 +341,9 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
/*
test nbt dgram operations
*/
-struct torture_suite *torture_nbt_dgram(void)
+struct torture_suite *torture_nbt_dgram(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "DGRAM");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "DGRAM");
torture_suite_add_simple_test(suite, "netlogon", nbt_test_netlogon);
torture_suite_add_simple_test(suite, "netlogon2", nbt_test_netlogon2);
diff --git a/source4/torture/nbt/nbt.c b/source4/torture/nbt/nbt.c
index 5c941c60c9..2a3678ee75 100644
--- a/source4/torture/nbt/nbt.c
+++ b/source4/torture/nbt/nbt.c
@@ -29,7 +29,7 @@ bool torture_nbt_get_name(struct torture_context *tctx,
const char **address)
{
make_nbt_name_server(name, strupper_talloc(tctx,
- torture_setting_string(tctx, "host", NULL)));
+ torture_setting_string(tctx, "host", NULL)));
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
@@ -43,18 +43,17 @@ bool torture_nbt_get_name(struct torture_context *tctx,
NTSTATUS torture_nbt_init(void)
{
struct torture_suite *suite = torture_suite_create(
- talloc_autofree_context(),
- "NBT");
+ talloc_autofree_context(), "NBT");
/* nbt tests */
- torture_suite_add_suite(suite, torture_nbt_register());
- torture_suite_add_suite(suite, torture_nbt_wins());
- torture_suite_add_suite(suite, torture_nbt_dgram());
- torture_suite_add_suite(suite, torture_nbt_winsreplication());
- torture_suite_add_suite(suite, torture_bench_nbt());
- torture_suite_add_suite(suite, torture_bench_wins());
+ torture_suite_add_suite(suite, torture_nbt_register(suite));
+ torture_suite_add_suite(suite, torture_nbt_wins(suite));
+ torture_suite_add_suite(suite, torture_nbt_dgram(suite));
+ torture_suite_add_suite(suite, torture_nbt_winsreplication(suite));
+ torture_suite_add_suite(suite, torture_bench_nbt(suite));
+ torture_suite_add_suite(suite, torture_bench_wins(suite));
suite->description = talloc_strdup(suite,
- "NetBIOS over TCP/IP and WINS tests");
+ "NetBIOS over TCP/IP and WINS tests");
torture_register_suite(suite);
diff --git a/source4/torture/nbt/query.c b/source4/torture/nbt/query.c
index 5794d840ec..1040335227 100644
--- a/source4/torture/nbt/query.c
+++ b/source4/torture/nbt/query.c
@@ -61,8 +61,8 @@ static bool bench_namequery(struct torture_context *tctx)
io.in.name = name;
io.in.dest_addr = address;
- io.in.broadcast = False;
- io.in.wins_lookup = False;
+ io.in.broadcast = false;
+ io.in.wins_lookup = false;
io.in.timeout = 1;
result = talloc_zero(tctx, struct result_struct);
@@ -104,10 +104,9 @@ static bool bench_namequery(struct torture_context *tctx)
/*
benchmark how fast a server can respond to name queries
*/
-struct torture_suite *torture_bench_nbt(void)
+struct torture_suite *torture_bench_nbt(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(talloc_autofree_context(),
- "BENCH");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "BENCH");
torture_suite_add_simple_test(suite, "namequery", bench_namequery);
return suite;
diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c
index 03cc4e6cee..9ff22c4bb9 100644
--- a/source4/torture/nbt/register.c
+++ b/source4/torture/nbt/register.c
@@ -68,9 +68,9 @@ static bool nbt_register_own(struct torture_context *tctx)
io.in.dest_addr = address;
io.in.address = myaddress;
io.in.nb_flags = NBT_NODE_B | NBT_NM_ACTIVE;
- io.in.register_demand = False;
- io.in.broadcast = True;
- io.in.multi_homed = False;
+ io.in.register_demand = false;
+ io.in.broadcast = true;
+ io.in.multi_homed = false;
io.in.ttl = 1234;
io.in.timeout = 3;
io.in.retries = 0;
@@ -86,7 +86,7 @@ static bool nbt_register_own(struct torture_context *tctx)
/* check a register demand */
io.in.address = myaddress;
- io.in.register_demand = True;
+ io.in.register_demand = true;
status = nbt_name_register(nbtsock, tctx, &io);
@@ -134,7 +134,7 @@ static bool nbt_refresh_own(struct torture_context *tctx)
io.in.dest_addr = address;
io.in.address = myaddress;
io.in.nb_flags = NBT_NODE_B | NBT_NM_ACTIVE;
- io.in.broadcast = False;
+ io.in.broadcast = false;
io.in.ttl = 1234;
io.in.timeout = 3;
io.in.retries = 0;
@@ -155,11 +155,11 @@ static bool nbt_refresh_own(struct torture_context *tctx)
/*
test name registration to a server
*/
-struct torture_suite *torture_nbt_register(void)
+struct torture_suite *torture_nbt_register(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite;
- suite = torture_suite_create(talloc_autofree_context(), "REGISTER");
+ suite = torture_suite_create(mem_ctx, "REGISTER");
torture_suite_add_simple_test(suite, "register_own", nbt_register_own);
torture_suite_add_simple_test(suite, "refresh_own", nbt_refresh_own);
diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c
index 7f3ed8e415..e25c3e78f0 100644
--- a/source4/torture/nbt/wins.c
+++ b/source4/torture/nbt/wins.c
@@ -77,7 +77,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
release.in.dest_addr = address;
release.in.address = myaddress;
release.in.nb_flags = nb_flags;
- release.in.broadcast = False;
+ release.in.broadcast = false;
release.in.timeout = 3;
release.in.retries = 0;
@@ -113,8 +113,8 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
torture_comment(tctx, "query the name to make sure its there\n");
query.in.name = *name;
query.in.dest_addr = address;
- query.in.broadcast = False;
- query.in.wins_lookup = True;
+ query.in.broadcast = false;
+ query.in.wins_lookup = true;
query.in.timeout = 3;
query.in.retries = 0;
@@ -174,7 +174,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
release.in.dest_addr = address;
release.in.address = myaddress;
release.in.nb_flags = nb_flags;
- release.in.broadcast = False;
+ release.in.broadcast = false;
release.in.timeout = 3;
release.in.retries = 0;
@@ -284,10 +284,9 @@ static bool nbt_test_wins(struct torture_context *tctx)
/*
test WINS operations
*/
-struct torture_suite *torture_nbt_wins(void)
+struct torture_suite *torture_nbt_wins(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(talloc_autofree_context(),
- "WINS");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "WINS");
torture_suite_add_simple_test(suite, "wins", nbt_test_wins);
diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c
index f06db648fc..27edd57206 100644
--- a/source4/torture/nbt/winsbench.c
+++ b/source4/torture/nbt/winsbench.c
@@ -282,11 +282,10 @@ static bool bench_wins(struct torture_context *tctx)
benchmark how fast a WINS server can respond to a mixture of
registration/refresh/release and name query requests
*/
-struct torture_suite *torture_bench_wins(void)
+struct torture_suite *torture_bench_wins(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(
- talloc_autofree_context(),
- "BENCH-WINS");
+ struct torture_suite *suite = torture_suite_create(mem_ctx,
+ "BENCH-WINS");
torture_suite_add_simple_test(suite, "wins", bench_wins);
diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c
index bc370c8b4e..f0b17b9778 100644
--- a/source4/torture/nbt/winsreplication.c
+++ b/source4/torture/nbt/winsreplication.c
@@ -30,6 +30,7 @@
#include "librpc/gen_ndr/ndr_nbt.h"
#include "torture/torture.h"
#include "torture/nbt/proto.h"
+#include "param/param.h"
#define CHECK_STATUS(tctx, status, correct) \
torture_assert_ntstatus_equal(tctx, status, correct, \
@@ -97,10 +98,6 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
struct nbt_name name;
const char *address;
- if (!torture_setting_bool(tctx, "dangerous", false)) {
- torture_skip(tctx, "winsrepl: cross connection assoc_ctx usage disabled - enable dangerous tests to use");
- }
-
if (!torture_nbt_get_name(tctx, &name, &address))
return false;
@@ -224,7 +221,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
/*
display a replication entry
*/
-static void display_entry(TALLOC_CTX *tctx, struct wrepl_name *name)
+static void display_entry(struct torture_context *tctx, struct wrepl_name *name)
{
int i;
@@ -541,8 +538,8 @@ static const struct wrepl_ip addresses_X_3_4[] = {
}
};
-static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *tctx,
- const char *address)
+static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
+ struct torture_context *tctx, const char *address)
{
struct test_wrepl_conflict_conn *ctx;
struct wrepl_associate associate;
@@ -632,7 +629,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *tct
if (!ctx->nbtsock_srv) return NULL;
/* Make a port 137 version of ctx->myaddr */
- nbt_srv_addr = socket_address_from_strings(tctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr->addr, lp_nbt_port());
+ nbt_srv_addr = socket_address_from_strings(tctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr->addr, lp_nbt_port(global_loadparm));
if (!nbt_srv_addr) return NULL;
/* And if possible, bind to it. This won't work unless we are root or in sockewrapper */
@@ -657,7 +654,8 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *tct
/* Make a port 137 version of ctx->myaddr2 */
nbt_srv_addr = socket_address_from_strings(tctx,
ctx->nbtsock_srv->sock->backend_name,
- ctx->myaddr2->addr, lp_nbt_port());
+ ctx->myaddr2->addr,
+ lp_nbt_port(global_loadparm));
if (!nbt_srv_addr) return NULL;
/* And if possible, bind to it. This won't work unless we are root or in sockewrapper */
@@ -9158,7 +9156,7 @@ static bool test_conflict_owned_active_vs_replica(struct torture_context *tctx,
if (!ctx->nbtsock_srv) {
torture_comment(tctx, "SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n",
- lp_nbt_port());
+ lp_nbt_port(global_loadparm));
return true;
}
@@ -9454,7 +9452,8 @@ static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_
{
struct nbt_name *name;
struct nbt_name_packet *rep_packet;
- struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
+ struct test_conflict_owned_active_vs_replica_struct *rec =
+ (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private;
_NBT_ASSERT(req_packet->qdcount, 1);
_NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
@@ -9550,7 +9549,8 @@ static void test_conflict_owned_active_vs_replica_handler_release(
{
struct nbt_name *name;
struct nbt_name_packet *rep_packet;
- struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
+ struct test_conflict_owned_active_vs_replica_struct *rec =
+ (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private;
_NBT_ASSERT(req_packet->qdcount, 1);
_NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
@@ -9601,7 +9601,8 @@ static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket
struct nbt_name_packet *req_packet,
struct socket_address *src)
{
- struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
+ struct test_conflict_owned_active_vs_replica_struct *rec =
+ (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private;
rec->defend.ret = false;
@@ -9670,13 +9671,15 @@ static bool torture_nbt_winsreplication_owned(struct torture_context *tctx)
/*
test simple WINS replication operations
*/
-struct torture_suite *torture_nbt_winsreplication(void)
+struct torture_suite *torture_nbt_winsreplication(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(
- talloc_autofree_context(),
- "WINSREPLICATION");
- torture_suite_add_simple_test(suite, "assoc_ctx1",
- test_assoc_ctx1);
+ mem_ctx, "WINSREPLICATION");
+ struct torture_tcase *tcase;
+
+ tcase = torture_suite_add_simple_test(suite, "assoc_ctx1",
+ test_assoc_ctx1);
+ tcase->tests->dangerous = true;
torture_suite_add_simple_test(suite, "assoc_ctx2",
test_assoc_ctx2);
diff --git a/source4/torture/ndr/lsa.c b/source4/torture/ndr/lsa.c
index 768c8db63e..a72a03fa38 100644
--- a/source4/torture/ndr/lsa.c
+++ b/source4/torture/ndr/lsa.c
@@ -1747,7 +1747,7 @@ static const uint8_t lsarlookupsids3_out_data[] = {
};
static bool lsarlookupsids3_out_check(struct torture_context *tctx,
- struct lsa_LookupSids3 *r)
+ struct lsa_LookupSids3 *r)
{
/* FIXME: Handle */
torture_assert(tctx, r->out.names != NULL, "names ptr");
diff --git a/source4/torture/ndr/ndr.c b/source4/torture/ndr/ndr.c
index 5c7dfc7c29..18ede54867 100644
--- a/source4/torture/ndr/ndr.c
+++ b/source4/torture/ndr/ndr.c
@@ -36,7 +36,7 @@ static bool wrap_ndr_pull_test(struct torture_context *tctx,
struct torture_test *test)
{
bool (*check_fn) (struct torture_context *ctx, void *data) = test->fn;
- const struct ndr_pull_test_data *data = test->data;
+ const struct ndr_pull_test_data *data = (const struct ndr_pull_test_data *)test->data;
void *ds = talloc_zero_size(tctx, data->struct_size);
struct ndr_pull *ndr = ndr_pull_init_blob(&(data->data), tctx);
diff --git a/source4/torture/ndr/winreg.c b/source4/torture/ndr/winreg.c
index d7c956efd6..ab256a7152 100644
--- a/source4/torture/ndr/winreg.c
+++ b/source4/torture/ndr/winreg.c
@@ -240,7 +240,7 @@ static const uint8_t querymultiplevalues_in_data[] = {
};
static bool querymultiplevalues_in_check(struct torture_context *tctx,
- struct winreg_QueryMultipleValues *r)
+ struct winreg_QueryMultipleValues *r)
{
torture_assert_int_equal(tctx, r->in.num_values, 1, "num values");
torture_assert_str_equal(tctx, r->in.values[0].name->name, "HOMEPATH",
@@ -272,7 +272,7 @@ static const uint8_t querymultiplevalues_out_data[] = {
};
static bool querymultiplevalues_out_check(struct torture_context *tctx,
- struct winreg_QueryMultipleValues *r)
+ struct winreg_QueryMultipleValues *r)
{
torture_assert_str_equal(tctx, r->out.values[0].name->name, "HOMEPATH",
"name");
@@ -458,7 +458,7 @@ static const uint8_t getkeysecurity_in_data[] = {
};
static bool getkeysecurity_in_check(struct torture_context *tctx,
- struct winreg_GetKeySecurity *r)
+ struct winreg_GetKeySecurity *r)
{
/* FIXME: Handle */
torture_assert_int_equal(tctx, r->in.sec_info, 2, "sec info");
@@ -476,7 +476,7 @@ static const uint8_t getkeysecurity_out_data[] = {
};
static bool getkeysecurity_out_check(struct torture_context *tctx,
- struct winreg_GetKeySecurity *r)
+ struct winreg_GetKeySecurity *r)
{
torture_assert_int_equal(tctx, r->in.sd->size, 20, "sd size");
torture_assert_int_equal(tctx, r->in.sd->len, 20, "sd len");
diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c
index bd05c0f38f..483b33dc11 100644
--- a/source4/torture/rap/rap.c
+++ b/source4/torture/rap/rap.c
@@ -155,7 +155,7 @@ static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr,
if ( string_offset + len + 1 > ndr->data_size )
return NT_STATUS_INVALID_PARAMETER;
- *dest = talloc_zero_size(mem_ctx, len+1);
+ *dest = talloc_zero_array(mem_ctx, char, len+1);
pull_string(*dest, p, len+1, len, STR_ASCII);
return NT_STATUS_OK;
@@ -287,7 +287,7 @@ static NTSTATUS smbcli_rap_netshareenum(struct smbcli_tree *tree,
return result;
}
-static BOOL test_netshareenum(struct smbcli_tree *tree)
+static bool test_netshareenum(struct smbcli_tree *tree)
{
struct rap_NetShareEnum r;
int i;
@@ -297,7 +297,7 @@ static BOOL test_netshareenum(struct smbcli_tree *tree)
r.in.bufsize = 8192;
if (!NT_STATUS_IS_OK(smbcli_rap_netshareenum(tree, tmp_ctx, &r)))
- return False;
+ return false;
for (i=0; i<r.out.count; i++) {
printf("%s %d %s\n", r.out.info[i].info1.name,
@@ -307,7 +307,7 @@ static BOOL test_netshareenum(struct smbcli_tree *tree)
talloc_free(tmp_ctx);
- return True;
+ return true;
}
static NTSTATUS smbcli_rap_netserverenum2(struct smbcli_tree *tree,
@@ -385,7 +385,7 @@ static NTSTATUS smbcli_rap_netserverenum2(struct smbcli_tree *tree,
return result;
}
-static BOOL test_netserverenum(struct smbcli_tree *tree)
+static bool test_netserverenum(struct smbcli_tree *tree)
{
struct rap_NetServerEnum2 r;
int i;
@@ -398,7 +398,7 @@ static BOOL test_netserverenum(struct smbcli_tree *tree)
r.in.domain = NULL;
if (!NT_STATUS_IS_OK(smbcli_rap_netserverenum2(tree, tmp_ctx, &r)))
- return False;
+ return false;
for (i=0; i<r.out.count; i++) {
switch (r.in.level) {
@@ -415,7 +415,7 @@ static BOOL test_netserverenum(struct smbcli_tree *tree)
talloc_free(tmp_ctx);
- return True;
+ return true;
}
_PUBLIC_ NTSTATUS smbcli_rap_netservergetinfo(struct smbcli_tree *tree,
@@ -477,14 +477,14 @@ _PUBLIC_ NTSTATUS smbcli_rap_netservergetinfo(struct smbcli_tree *tree,
return result;
}
-static BOOL test_netservergetinfo(struct smbcli_tree *tree)
+static bool test_netservergetinfo(struct smbcli_tree *tree)
{
struct rap_WserverGetInfo r;
- BOOL res = True;
+ bool res = true;
TALLOC_CTX *mem_ctx;
if (!(mem_ctx = talloc_new(tree))) {
- return False;
+ return false;
}
r.in.bufsize = 0xffff;
@@ -498,9 +498,9 @@ static BOOL test_netservergetinfo(struct smbcli_tree *tree)
return res;
}
-static BOOL test_rap(struct smbcli_tree *tree)
+static bool test_rap(struct smbcli_tree *tree)
{
- BOOL res = True;
+ bool res = true;
res &= test_netserverenum(tree);
res &= test_netshareenum(tree);
@@ -509,20 +509,20 @@ static BOOL test_rap(struct smbcli_tree *tree)
return res;
}
-BOOL torture_rap_basic(struct torture_context *torture)
+bool torture_rap_basic(struct torture_context *torture)
{
struct smbcli_state *cli;
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx;
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
mem_ctx = talloc_init("torture_rap_basic");
if (!test_rap(cli->tree)) {
- ret = False;
+ ret = false;
}
torture_close_connection(cli);
@@ -531,7 +531,7 @@ BOOL torture_rap_basic(struct torture_context *torture)
return ret;
}
-BOOL torture_rap_scan(struct torture_context *torture)
+bool torture_rap_scan(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
struct smbcli_state *cli;
@@ -540,7 +540,7 @@ BOOL torture_rap_scan(struct torture_context *torture)
mem_ctx = talloc_init("torture_rap_scan");
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
for (callno = 0; callno < 0xffff; callno++) {
@@ -557,7 +557,7 @@ BOOL torture_rap_scan(struct torture_context *torture)
torture_close_connection(cli);
- return True;
+ return true;
}
NTSTATUS torture_rap_init(void)
diff --git a/source4/torture/raw/acls.c b/source4/torture/raw/acls.c
index 026384cb8b..2c3f4a52c6 100644
--- a/source4/torture/raw/acls.c
+++ b/source4/torture/raw/acls.c
@@ -35,7 +35,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -46,7 +46,7 @@ static bool test_sd(struct torture_context *tctx,
NTSTATUS status;
union smb_open io;
const char *fname = BASEDIR "\\sd.txt";
- BOOL ret = True;
+ bool ret = true;
int fnum = -1;
union smb_fileinfo q;
union smb_setfileinfo set;
@@ -113,7 +113,7 @@ static bool test_sd(struct torture_context *tctx,
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd);
- ret = False;
+ ret = false;
}
printf("remove it again\n");
@@ -226,7 +226,7 @@ static bool test_nttrans_create(struct torture_context *tctx,
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd);
- ret = False;
+ ret = false;
}
done:
@@ -243,7 +243,7 @@ done:
if (_q.access_information.out.access_flags != (flags)) { \
printf("(%s) Incorrect access_flags 0x%08x - should be 0x%08x\n", \
__location__, _q.access_information.out.access_flags, (flags)); \
- ret = False; \
+ ret = false; \
goto done; \
} \
} while (0)
@@ -259,7 +259,7 @@ static bool test_creator_sid(struct torture_context *tctx,
NTSTATUS status;
union smb_open io;
const char *fname = BASEDIR "\\creator.txt";
- BOOL ret = True;
+ bool ret = true;
int fnum = -1;
union smb_fileinfo q;
union smb_setfileinfo set;
@@ -358,7 +358,7 @@ static bool test_creator_sid(struct torture_context *tctx,
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd);
- ret = False;
+ ret = false;
}
printf("try open for write\n");
@@ -418,7 +418,7 @@ static bool test_creator_sid(struct torture_context *tctx,
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd2);
- ret = False;
+ ret = false;
}
@@ -471,7 +471,7 @@ static bool test_generic_bits(struct torture_context *tctx,
NTSTATUS status;
union smb_open io;
const char *fname = BASEDIR "\\generic.txt";
- BOOL ret = True;
+ bool ret = true;
int fnum = -1, i;
union smb_fileinfo q;
union smb_setfileinfo set;
@@ -499,8 +499,8 @@ static bool test_generic_bits(struct torture_context *tctx,
{ SEC_GENERIC_EXECUTE, SEC_RIGHTS_DIR_EXECUTE },
{ SEC_GENERIC_ALL, SEC_RIGHTS_DIR_ALL }
};
- BOOL has_restore_privilege;
- BOOL has_take_ownership_privilege;
+ bool has_restore_privilege;
+ bool has_take_ownership_privilege;
printf("TESTING FILE GENERIC BITS\n");
@@ -599,7 +599,7 @@ static bool test_generic_bits(struct torture_context *tctx,
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd2);
- ret = False;
+ ret = false;
}
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -647,7 +647,7 @@ static bool test_generic_bits(struct torture_context *tctx,
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd2);
- ret = False;
+ ret = false;
}
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -764,7 +764,7 @@ static bool test_generic_bits(struct torture_context *tctx,
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd2);
- ret = False;
+ ret = false;
}
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -812,7 +812,7 @@ static bool test_generic_bits(struct torture_context *tctx,
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd2);
- ret = False;
+ ret = false;
}
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -846,14 +846,14 @@ static bool test_owner_bits(struct torture_context *tctx,
NTSTATUS status;
union smb_open io;
const char *fname = BASEDIR "\\generic.txt";
- BOOL ret = True;
+ bool ret = true;
int fnum = -1, i;
union smb_fileinfo q;
union smb_setfileinfo set;
struct security_descriptor *sd, *sd_orig;
const char *owner_sid;
- BOOL has_restore_privilege;
- BOOL has_take_ownership_privilege;
+ bool has_restore_privilege;
+ bool has_take_ownership_privilege;
uint32_t expected_bits;
printf("TESTING FILE OWNER BITS\n");
@@ -966,7 +966,7 @@ static bool test_inheritance(struct torture_context *tctx,
const char *dname = BASEDIR "\\inheritance";
const char *fname1 = BASEDIR "\\inheritance\\testfile";
const char *fname2 = BASEDIR "\\inheritance\\testdir";
- BOOL ret = True;
+ bool ret = true;
int fnum=0, fnum2, i;
union smb_fileinfo q;
union smb_setfileinfo set;
@@ -1175,7 +1175,7 @@ static bool test_inheritance(struct torture_context *tctx,
sd_orig->owner_sid)) {
printf("Bad sd in child file at %d\n", i);
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
- ret = False;
+ ret = false;
goto check_dir;
}
@@ -1186,7 +1186,7 @@ static bool test_inheritance(struct torture_context *tctx,
test_flags[i].file_flags,
test_flags[i].parent_flags,
i);
- ret = False;
+ ret = false;
}
check_dir:
@@ -1224,7 +1224,7 @@ static bool test_inheritance(struct torture_context *tctx,
printf("Bad sd in child dir at %d (parent 0x%x)\n",
i, test_flags[i].parent_flags);
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
- ret = False;
+ ret = false;
continue;
}
} else if (test_flags[i].parent_flags & SEC_ACE_FLAG_CONTAINER_INHERIT) {
@@ -1242,7 +1242,7 @@ static bool test_inheritance(struct torture_context *tctx,
printf("Bad sd in child dir at %d (parent 0x%x)\n",
i, test_flags[i].parent_flags);
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
- ret = False;
+ ret = false;
continue;
}
} else {
@@ -1255,7 +1255,7 @@ static bool test_inheritance(struct torture_context *tctx,
printf("Bad sd in child dir at %d (parent 0x%x)\n",
i, test_flags[i].parent_flags);
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
- ret = False;
+ ret = false;
continue;
}
}
@@ -1308,7 +1308,7 @@ static bool test_inheritance(struct torture_context *tctx,
NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd2);
- ret = False;
+ ret = false;
}
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
@@ -1316,7 +1316,7 @@ static bool test_inheritance(struct torture_context *tctx,
status = smb_raw_open(cli->tree, tctx, &io);
if (NT_STATUS_IS_OK(status)) {
printf("failed: w2k3 ACL bug (allowed open when ACL should deny)\n");
- ret = False;
+ ret = false;
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_ACCESS_FLAGS(fnum2, SEC_RIGHTS_FILE_ALL);
smbcli_close(cli->tree, fnum2);
@@ -1382,14 +1382,14 @@ done:
/*
test dynamic acl inheritance
*/
-static BOOL test_inheritance_dynamic(struct torture_context *tctx,
+static bool test_inheritance_dynamic(struct torture_context *tctx,
struct smbcli_state *cli)
{
NTSTATUS status;
union smb_open io;
const char *dname = BASEDIR "\\inheritance";
const char *fname1 = BASEDIR "\\inheritance\\testfile";
- BOOL ret = True;
+ bool ret = true;
int fnum=0, fnum2;
union smb_fileinfo q;
union smb_setfileinfo set;
@@ -1399,7 +1399,7 @@ static BOOL test_inheritance_dynamic(struct torture_context *tctx,
printf("TESTING DYNAMIC ACL INHERITANCE\n");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
io.generic.level = RAW_OPEN_NTCREATEX;
@@ -1533,14 +1533,14 @@ done:
if (!(granted & access)) {\
printf("(%s) %s but flags 0x%08X are not granted! granted[0x%08X] desired[0x%08X]\n", \
__location__, nt_errstr(status), access, granted, desired); \
- ret = False; \
+ ret = false; \
goto done; \
} \
} else { \
if (granted & access) {\
printf("(%s) %s but flags 0x%08X are granted! granted[0x%08X] desired[0x%08X]\n", \
__location__, nt_errstr(status), access, granted, desired); \
- ret = False; \
+ ret = false; \
goto done; \
} \
} \
@@ -1552,7 +1552,7 @@ static bool test_sd_get_set(struct torture_context *tctx,
struct smbcli_state *cli)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
union smb_open io;
union smb_fileinfo fi;
union smb_setfileinfo si;
@@ -1736,7 +1736,7 @@ done:
*/
bool torture_raw_acls(struct torture_context *tctx, struct smbcli_state *cli)
{
- BOOL ret = True;
+ bool ret = true;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
diff --git a/source4/torture/raw/chkpath.c b/source4/torture/raw/chkpath.c
index a56afee546..42a3c3cebe 100644
--- a/source4/torture/raw/chkpath.c
+++ b/source4/torture/raw/chkpath.c
@@ -29,7 +29,7 @@
if (!NT_STATUS_EQUAL(status, correct) && !NT_STATUS_EQUAL(status, dos_correct)) { \
printf("(%d) Incorrect status %s - should be %s\n", \
__LINE__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -54,7 +54,7 @@ static NTSTATUS single_search(struct smbcli_state *cli,
return status;
}
-static BOOL test_path(struct smbcli_state *cli, const char *path, NTSTATUS expected, NTSTATUS dos_expected)
+static bool test_path(struct smbcli_state *cli, const char *path, NTSTATUS expected, NTSTATUS dos_expected)
{
union smb_chkpath io;
NTSTATUS status;
@@ -63,19 +63,19 @@ static BOOL test_path(struct smbcli_state *cli, const char *path, NTSTATUS expec
if (!NT_STATUS_EQUAL(status, expected) && !NT_STATUS_EQUAL(status, dos_expected)) {
printf("%-40s FAILED %s should be %s or %s\n",
path, nt_errstr(status), nt_errstr(expected), nt_errstr(dos_expected));
- return False;
+ return false;
} else {
printf("%-40s correct (%s)\n", path, nt_errstr(status));
}
- return True;
+ return true;
}
-static BOOL test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_chkpath io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum = -1;
int fnum1 = -1;
@@ -89,7 +89,7 @@ static BOOL test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\test.txt..");
if (fnum == -1) {
printf("failed to open test.txt - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -97,7 +97,7 @@ static BOOL test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
if (!torture_set_file_attribute(cli->tree, BASEDIR, FILE_ATTRIBUTE_HIDDEN)) {
printf("failed to set basedir hidden\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -215,34 +215,34 @@ done:
basic testing of chkpath calls
*/
bool torture_raw_chkpath(struct torture_context *torture,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
bool ret = true;
int fnum;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt"))) {
printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\V S"))) {
printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\V S\\VB98"))) {
printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
- return False;
+ return false;
}
fnum = create_complex_file(cli, torture, BASEDIR "\\nt\\V S\\VB98\\vb6.exe");
if (fnum == -1) {
printf("failed to open \\nt\\V S\\VB98\\vb6.exe - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
diff --git a/source4/torture/raw/close.c b/source4/torture/raw/close.c
index 34ac2f0db8..6f139f8530 100644
--- a/source4/torture/raw/close.c
+++ b/source4/torture/raw/close.c
@@ -28,7 +28,7 @@
* basic testing of all RAW_CLOSE_* calls
*/
bool torture_raw_close(struct torture_context *torture,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
bool ret = true;
union smb_close io;
diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c
index 374ff3cb98..c6969574a8 100644
--- a/source4/torture/raw/composite.c
+++ b/source4/torture/raw/composite.c
@@ -30,6 +30,7 @@
#include "librpc/gen_ndr/ndr_misc.h"
#include "lib/cmdline/popt_common.h"
#include "torture/util.h"
+#include "param/param.h"
#define BASEDIR "\\composite"
@@ -42,7 +43,7 @@ static void loadfile_complete(struct composite_context *c)
/*
test a simple savefile/loadfile combination
*/
-static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const char *fname = BASEDIR "\\test.txt";
NTSTATUS status;
@@ -67,8 +68,8 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
status = smb_composite_savefile(cli->tree, &io1);
if (!NT_STATUS_IS_OK(status)) {
- printf("savefile failed: %s\n", nt_errstr(status));
- return False;
+ printf("(%s) savefile failed: %s\n", __location__,nt_errstr(status));
+ return false;
}
io2.in.fname = fname;
@@ -86,8 +87,8 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("waiting for completion\n");
while (*count != num_ops) {
event_loop_once(cli->transport->socket->event.ctx);
- if (lp_parm_bool(-1, "torture", "progress", true)) {
- printf("count=%d\r", *count);
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
+ printf("(%s) count=%d\r", __location__, *count);
fflush(stdout);
}
}
@@ -96,31 +97,31 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
for (i=0;i<num_ops;i++) {
status = smb_composite_loadfile_recv(c[i], mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
- printf("loadfile[%d] failed - %s\n", i, nt_errstr(status));
- return False;
+ printf("(%s) loadfile[%d] failed - %s\n", __location__, i, nt_errstr(status));
+ return false;
}
if (io2.out.size != len) {
- printf("wrong length in returned data - %d should be %d\n",
+ printf("(%s) wrong length in returned data - %d should be %d\n",__location__,
io2.out.size, (int)len);
- return False;
+ return false;
}
if (memcmp(io2.out.data, data, len) != 0) {
- printf("wrong data in loadfile!\n");
- return False;
+ printf("(%s) wrong data in loadfile!\n",__location__);
+ return false;
}
}
talloc_free(data);
- return True;
+ return true;
}
/*
test a simple savefile/loadfile combination
*/
-static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const char *fname = BASEDIR "\\test.txt";
NTSTATUS status;
@@ -133,7 +134,7 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
extern int torture_numops;
struct event_context *event_ctx;
int *count = talloc_zero(mem_ctx, int);
- BOOL ret = True;
+ bool ret = true;
data = talloc_array(mem_ctx, uint8_t, len);
@@ -147,18 +148,18 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
status = smb_composite_savefile(cli->tree, &io1);
if (!NT_STATUS_IS_OK(status)) {
- printf("savefile failed: %s\n", nt_errstr(status));
- return False;
+ printf("(%s) savefile failed: %s\n",__location__, nt_errstr(status));
+ return false;
}
- io2.in.dest_host = lp_parm_string(-1, "torture", "host");
+ io2.in.dest_host = lp_parm_string(global_loadparm, NULL, "torture", "host");
io2.in.port = 0;
- io2.in.called_name = lp_parm_string(-1, "torture", "host");
- io2.in.service = lp_parm_string(-1, "torture", "share");
+ io2.in.called_name = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ io2.in.service = lp_parm_string(global_loadparm, NULL, "torture", "share");
io2.in.service_type = "A:";
io2.in.credentials = cmdline_credentials;
- io2.in.workgroup = lp_workgroup();
+ io2.in.workgroup = lp_workgroup(global_loadparm);
io2.in.filename = fname;
printf("testing parallel fetchfile with %d ops\n", torture_numops);
@@ -176,8 +177,8 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
while (*count != torture_numops) {
event_loop_once(event_ctx);
- if (lp_parm_bool(-1, "torture", "progress", true)) {
- printf("count=%d\r", *count);
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
+ printf("(%s) count=%d\r", __location__, *count);
fflush(stdout);
}
}
@@ -186,23 +187,23 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
for (i=0;i<torture_numops;i++) {
status = smb_composite_fetchfile_recv(c[i], mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
- printf("loadfile[%d] failed - %s\n", i,
+ printf("(%s) loadfile[%d] failed - %s\n", __location__, i,
nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
if (io2.out.size != len) {
- printf("wrong length in returned data - %d "
- "should be %d\n",
+ printf("(%s) wrong length in returned data - %d "
+ "should be %d\n", __location__,
io2.out.size, (int)len);
- ret = False;
+ ret = false;
continue;
}
if (memcmp(io2.out.data, data, len) != 0) {
- printf("wrong data in loadfile!\n");
- ret = False;
+ printf("(%s) wrong data in loadfile!\n", __location__);
+ ret = false;
continue;
}
}
@@ -213,7 +214,7 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
/*
test setfileacl
*/
-static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
struct smb_composite_appendacl **io;
struct smb_composite_appendacl **io_orig;
@@ -242,8 +243,8 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
status = smb_composite_savefile(cli->tree, &io1);
if (!NT_STATUS_IS_OK(status)) {
- printf("savefile failed: %s\n", nt_errstr(status));
- return False;
+ printf("(%s) savefile failed: %s\n", __location__, nt_errstr(status));
+ return false;
}
io_orig[i] = talloc (io_orig, struct smb_composite_appendacl);
@@ -251,8 +252,8 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
io_orig[i]->in.sd = security_descriptor_initialise(io_orig[i]);
status = smb_composite_appendacl(cli->tree, io_orig[i], io_orig[i]);
if (!NT_STATUS_IS_OK(status)) {
- printf("appendacl failed: %s\n", nt_errstr(status));
- return False;
+ printf("(%s) appendacl failed: %s\n", __location__, nt_errstr(status));
+ return false;
}
}
@@ -271,8 +272,8 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
status = security_descriptor_dacl_add(test_sd, ace);
if (!NT_STATUS_IS_OK(status)) {
- printf("appendacl failed: %s\n", nt_errstr(status));
- return False;
+ printf("(%s) appendacl failed: %s\n", __location__, nt_errstr(status));
+ return false;
}
/* set parameters for appendacl async call */
@@ -296,8 +297,8 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("waiting for completion\n");
while (*count != num_ops) {
event_loop_once(event_ctx);
- if (lp_parm_bool(-1, "torture", "progress", true)) {
- printf("count=%d\r", *count);
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
+ printf("(%s) count=%d\r", __location__, *count);
fflush(stdout);
}
}
@@ -306,14 +307,14 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
for (i=0; i < num_ops; i++) {
status = smb_composite_appendacl_recv(c[i], io[i]);
if (!NT_STATUS_IS_OK(status)) {
- printf("appendacl[%d] failed - %s\n", i, nt_errstr(status));
- return False;
+ printf("(%s) appendacl[%d] failed - %s\n", __location__, i, nt_errstr(status));
+ return false;
}
security_descriptor_dacl_add(io_orig[i]->out.sd, ace);
if (!security_acl_equal(io_orig[i]->out.sd->dacl, io[i]->out.sd->dacl)) {
- printf("appendacl[%d] failed - needed acl isn't set\n", i);
- return False;
+ printf("(%s) appendacl[%d] failed - needed acl isn't set\n", __location__, i);
+ return false;
}
}
@@ -322,11 +323,11 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
talloc_free (test_sid);
talloc_free (test_sd);
- return True;
+ return true;
}
/* test a query FS info by asking for share's GUID */
-static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
char *guid = NULL;
NTSTATUS status;
@@ -337,15 +338,15 @@ static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
extern int torture_numops;
struct event_context *event_ctx;
int *count = talloc_zero(mem_ctx, int);
- BOOL ret = True;
+ bool ret = true;
- io1.in.dest_host = lp_parm_string(-1, "torture", "host");
+ io1.in.dest_host = lp_parm_string(global_loadparm, NULL, "torture", "host");
io1.in.port = 0;
- io1.in.called_name = lp_parm_string(-1, "torture", "host");
- io1.in.service = lp_parm_string(-1, "torture", "share");
+ io1.in.called_name = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ io1.in.service = lp_parm_string(global_loadparm, NULL, "torture", "share");
io1.in.service_type = "A:";
io1.in.credentials = cmdline_credentials;
- io1.in.workgroup = lp_workgroup();
+ io1.in.workgroup = lp_workgroup(global_loadparm);
io1.in.level = RAW_QFS_OBJECTID_INFORMATION;
printf("testing parallel queryfsinfo [Object ID] with %d ops\n", torture_numops);
@@ -363,8 +364,8 @@ static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
while (*count < torture_numops) {
event_loop_once(event_ctx);
- if (lp_parm_bool(-1, "torture", "progress", true)) {
- printf("count=%d\r", *count);
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
+ printf("(%s) count=%d\r", __location__, *count);
fflush(stdout);
}
}
@@ -373,16 +374,16 @@ static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
for (i=0;i<torture_numops;i++) {
status = smb_composite_fsinfo_recv(c[i], mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
- printf("fsinfo[%d] failed - %s\n", i, nt_errstr(status));
- ret = False;
+ printf("(%s) fsinfo[%d] failed - %s\n", __location__, i, nt_errstr(status));
+ ret = false;
continue;
}
if (io1.out.fsinfo->generic.level != RAW_QFS_OBJECTID_INFORMATION) {
- printf("wrong level in returned info - %d "
- "should be %d\n",
+ printf("(%s) wrong level in returned info - %d "
+ "should be %d\n", __location__,
io1.out.fsinfo->generic.level, RAW_QFS_OBJECTID_INFORMATION);
- ret = False;
+ ret = false;
continue;
}
@@ -400,12 +401,12 @@ static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
basic testing of libcli composite calls
*/
bool torture_raw_composite(struct torture_context *tctx,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
bool ret = true;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
ret &= test_fetchfile(cli, tctx);
diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c
index df7f5f3851..11ad11ab3f 100644
--- a/source4/torture/raw/context.c
+++ b/source4/torture/raw/context.c
@@ -27,6 +27,7 @@
#include "libcli/libcli.h"
#include "torture/util.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
#define BASEDIR "\\rawcontext"
@@ -34,7 +35,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -42,7 +43,7 @@
if ((v) != (correct)) { \
printf("(%s) Incorrect value %s=%d - should be %d\n", \
__location__, #v, v, correct); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -50,7 +51,7 @@
if ((v) == (correct)) { \
printf("(%s) Incorrect value %s=%d - should not be %d\n", \
__location__, #v, v, correct); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -58,10 +59,10 @@
/*
test session ops
*/
-static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct smbcli_session *session;
struct smbcli_session *session2;
struct smbcli_session *session3;
@@ -83,15 +84,15 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("TESTING SESSION HANDLING\n");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("create a second security context on the same transport\n");
- session = smbcli_session_init(cli->transport, mem_ctx, False);
+ session = smbcli_session_init(cli->transport, mem_ctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
setup.in.credentials = cmdline_credentials;
@@ -101,12 +102,12 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
session->vuid = setup.out.vuid;
printf("create a third security context on the same transport, with vuid set\n");
- session2 = smbcli_session_init(cli->transport, mem_ctx, False);
+ session2 = smbcli_session_init(cli->transport, mem_ctx, false);
session2->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
setup.in.credentials = cmdline_credentials;
@@ -128,12 +129,12 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
if (cli->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY) {
printf("create a fourth security context on the same transport, without extended security\n");
- session3 = smbcli_session_init(cli->transport, mem_ctx, False);
+ session3 = smbcli_session_init(cli->transport, mem_ctx, false);
session3->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
setup.in.credentials = cmdline_credentials;
@@ -142,15 +143,15 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
CHECK_STATUS(status, NT_STATUS_LOGON_FAILURE);
printf("create a fouth anonymous security context on the same transport, without extended security\n");
- session4 = smbcli_session_init(cli->transport, mem_ctx, False);
+ session4 = smbcli_session_init(cli->transport, mem_ctx, false);
session4->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
anon_creds = cli_credentials_init(mem_ctx);
- cli_credentials_set_conf(anon_creds);
+ cli_credentials_set_conf(anon_creds, global_loadparm);
cli_credentials_set_anonymous(anon_creds);
setup.in.credentials = anon_creds;
@@ -162,7 +163,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
}
printf("use the same tree as the existing connection\n");
- tree = smbcli_tree_init(session, mem_ctx, False);
+ tree = smbcli_tree_init(session, mem_ctx, false);
tree->tid = cli->tree->tid;
printf("create a file using the new vuid\n");
@@ -224,11 +225,11 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
for (i=0; i <ARRAY_SIZE(sessions); i++) {
setups[i].in.sesskey = cli->transport->negotiate.sesskey;
setups[i].in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
- setups[i].in.workgroup = lp_workgroup();
+ setups[i].in.workgroup = lp_workgroup(global_loadparm);
setups[i].in.credentials = cmdline_credentials;
- sessions[i] = smbcli_session_init(cli->transport, mem_ctx, False);
+ sessions[i] = smbcli_session_init(cli->transport, mem_ctx, false);
composite_contexts[i] = smb_composite_sesssetup_send(sessions[i], &setups[i]);
}
@@ -256,10 +257,10 @@ done:
/*
test tree ops
*/
-static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
const char *share, *host;
struct smbcli_tree *tree;
union smb_tcon tcon;
@@ -273,14 +274,14 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("TESTING TREE HANDLING\n");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
- share = lp_parm_string(-1, "torture", "share");
- host = lp_parm_string(-1, "torture", "host");
+ share = lp_parm_string(global_loadparm, NULL, "torture", "share");
+ host = lp_parm_string(global_loadparm, NULL, "torture", "host");
printf("create a second tree context on the same session\n");
- tree = smbcli_tree_init(cli->session, mem_ctx, False);
+ tree = smbcli_tree_init(cli->session, mem_ctx, false);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
@@ -361,10 +362,10 @@ done:
this demonstrates that a tcon isn't autoclosed by a ulogoff
the tcon can be reused using any other valid session later
*/
-static BOOL test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
const char *share, *host;
struct smbcli_session *session1;
struct smbcli_session *session2;
@@ -381,17 +382,17 @@ static BOOL test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("TESTING TREE with ulogoff\n");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
- share = lp_parm_string(-1, "torture", "share");
- host = lp_parm_string(-1, "torture", "host");
+ share = lp_parm_string(global_loadparm, NULL, "torture", "share");
+ host = lp_parm_string(global_loadparm, NULL, "torture", "host");
printf("create the first new sessions\n");
- session1 = smbcli_session_init(cli->transport, mem_ctx, False);
+ session1 = smbcli_session_init(cli->transport, mem_ctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
setup.in.credentials = cmdline_credentials;
status = smb_composite_sesssetup(session1, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -399,7 +400,7 @@ static BOOL test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("vuid1=%d\n", session1->vuid);
printf("create a tree context on the with vuid1\n");
- tree = smbcli_tree_init(session1, mem_ctx, False);
+ tree = smbcli_tree_init(session1, mem_ctx, false);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
tcon.tconx.in.password = data_blob(NULL, 0);
@@ -444,10 +445,10 @@ static BOOL test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
CHECK_STATUS(status, NT_STATUS_OK);
printf("create the second new sessions\n");
- session2 = smbcli_session_init(cli->transport, mem_ctx, False);
+ session2 = smbcli_session_init(cli->transport, mem_ctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
setup.in.credentials = cmdline_credentials;
status = smb_composite_sesssetup(session2, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -511,10 +512,10 @@ done:
this test demonstrates that exit() only sees the PID
used for the open() calls
*/
-static BOOL test_pid_exit_only_sees_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_pid_exit_only_sees_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
union smb_open io;
union smb_write wr;
union smb_close cl;
@@ -526,7 +527,7 @@ static BOOL test_pid_exit_only_sees_open(struct smbcli_state *cli, TALLOC_CTX *m
printf("TESTING PID HANDLING exit() only cares about open() PID\n");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
pid1 = cli->session->pid;
@@ -619,10 +620,10 @@ done:
/*
test pid ops with 2 sessions
*/
-static BOOL test_pid_2sess(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_pid_2sess(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct smbcli_session *session;
struct smb_composite_sesssetup setup;
union smb_open io;
@@ -636,15 +637,15 @@ static BOOL test_pid_2sess(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("TESTING PID HANDLING WITH 2 SESSIONS\n");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("create a second security context on the same transport\n");
- session = smbcli_session_init(cli->transport, mem_ctx, False);
+ session = smbcli_session_init(cli->transport, mem_ctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
setup.in.credentials = cmdline_credentials;
@@ -723,10 +724,10 @@ done:
/*
test pid ops with 2 tcons
*/
-static BOOL test_pid_2tcon(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_pid_2tcon(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
const char *share, *host;
struct smbcli_tree *tree;
union smb_tcon tcon;
@@ -742,14 +743,14 @@ static BOOL test_pid_2tcon(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("TESTING PID HANDLING WITH 2 TCONS\n");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
- share = lp_parm_string(-1, "torture", "share");
- host = lp_parm_string(-1, "torture", "host");
+ share = lp_parm_string(global_loadparm, NULL, "torture", "share");
+ host = lp_parm_string(global_loadparm, NULL, "torture", "host");
printf("create a second tree context on the same session\n");
- tree = smbcli_tree_init(cli->session, mem_ctx, False);
+ tree = smbcli_tree_init(cli->session, mem_ctx, false);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
@@ -868,7 +869,7 @@ done:
static bool torture_raw_context_int(struct torture_context *tctx,
struct smbcli_state *cli)
{
- BOOL ret = True;
+ bool ret = true;
ret &= test_session(cli, tctx);
ret &= test_tree(cli, tctx);
@@ -886,12 +887,12 @@ static bool torture_raw_context_int(struct torture_context *tctx,
basic testing of session/tree context calls
*/
bool torture_raw_context(struct torture_context *torture,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
bool ret = true;
- if (lp_use_spnego()) {
+ if (lp_use_spnego(global_loadparm)) {
ret &= torture_raw_context_int(torture, cli);
- lp_set_cmdline("use spnego", "False");
+ lp_set_cmdline(global_loadparm, "use spnego", "False");
}
ret &= torture_raw_context_int(torture, cli);
diff --git a/source4/torture/raw/eas.c b/source4/torture/raw/eas.c
index 7e9c742943..b24b98796f 100644
--- a/source4/torture/raw/eas.c
+++ b/source4/torture/raw/eas.c
@@ -25,6 +25,7 @@
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
#include "torture/util.h"
+#include "param/param.h"
#define BASEDIR "\\testeas"
@@ -32,26 +33,26 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
-static BOOL maxeadebug; /* need that here, to allow no file delete in debug case */
+static bool maxeadebug; /* need that here, to allow no file delete in debug case */
-static BOOL check_ea(struct smbcli_state *cli,
+static bool check_ea(struct smbcli_state *cli,
const char *fname, const char *eaname, const char *value)
{
NTSTATUS status = torture_check_ea(cli, fname, eaname, value);
return NT_STATUS_IS_OK(status);
}
-static BOOL test_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
union smb_setfileinfo setfile;
union smb_open io;
const char *fname = BASEDIR "\\ea.txt";
- BOOL ret = True;
+ bool ret = true;
int fnum = -1;
printf("TESTING SETFILEINFO EA_SET\n");
@@ -207,7 +208,7 @@ static int test_one_eamax(struct smbcli_state *cli, const int fnum,
}
i -= (high - low + 1) / 2;
}
- } while (True);
+ } while (true);
return low;
}
@@ -221,21 +222,21 @@ static int test_one_eamax(struct smbcli_state *cli, const int fnum,
* maxeasize 65536 limit the max. size for a single EA name
* maxeanames 101 limit of the number of tested names
* maxeastart 1 this EA size is used to test for the 1st EA (atm)
- * maxeadebug 0 if set True, further debug output is done - in addition
+ * maxeadebug 0 if set true, further debug output is done - in addition
* the testfile is not deleted for further inspection!
*
* Set some/all of these options on the cmdline with:
* --option torture:maxeasize=1024 --option torture:maxeadebug=1 ...
*
*/
-static BOOL test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
union smb_open io;
const char *fname = BASEDIR "\\ea_max.txt";
int fnum = -1;
- BOOL ret = True;
- BOOL err = False;
+ bool ret = true;
+ bool err = false;
int i, j, k, last, total;
DATA_BLOB eablob;
@@ -246,27 +247,27 @@ static BOOL test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("TESTING SETFILEINFO MAX. EA_SET\n");
- maxeasize = lp_parm_int(-1, "torture", "maxeasize", 65536);
- maxeanames = lp_parm_int(-1, "torture", "maxeanames", 101);
- maxeastart = lp_parm_int(-1, "torture", "maxeastart", 1);
- maxeadebug = lp_parm_int(-1, "torture", "maxeadebug", 0);
+ maxeasize = lp_parm_int(global_loadparm, NULL, "torture", "maxeasize", 65536);
+ maxeanames = lp_parm_int(global_loadparm, NULL, "torture", "maxeanames", 101);
+ maxeastart = lp_parm_int(global_loadparm, NULL, "torture", "maxeastart", 1);
+ maxeadebug = lp_parm_int(global_loadparm, NULL, "torture", "maxeadebug", 0);
/* Do some sanity check on possibly passed parms */
if (maxeasize <= 0) {
printf("Invalid parameter 'maxeasize=%d'",maxeasize);
- err = True;
+ err = true;
}
if (maxeanames <= 0) {
printf("Invalid parameter 'maxeanames=%d'",maxeanames);
- err = True;
+ err = true;
}
if (maxeastart <= 0) {
printf("Invalid parameter 'maxeastart=%d'",maxeastart);
- err = True;
+ err = true;
}
if (maxeadebug < 0) {
printf("Invalid parameter 'maxeadebug=%d'",maxeadebug);
- err = True;
+ err = true;
}
if (err) {
printf("\n\n");
@@ -352,7 +353,7 @@ static BOOL test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf ("NOTE: More EAs could be available!\n");
}
if (total == 0) {
- ret = False;
+ ret = false;
}
done:
smbcli_close(cli->tree, fnum);
@@ -362,12 +363,12 @@ done:
/*
test using NTTRANS CREATE to create a file with an initial EA set
*/
-static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
union smb_open io;
const char *fname = BASEDIR "\\ea2.txt";
- BOOL ret = True;
+ bool ret = true;
int fnum = -1;
struct ea_struct eas[3];
struct smb_ea_list ea_list;
@@ -446,10 +447,10 @@ done:
*/
bool torture_raw_eas(struct torture_context *torture, struct smbcli_state *cli)
{
- BOOL ret = True;
+ bool ret = true;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
ret &= test_eas(cli, torture);
@@ -463,20 +464,20 @@ bool torture_raw_eas(struct torture_context *torture, struct smbcli_state *cli)
/*
test max EA size
*/
-BOOL torture_max_eas(struct torture_context *torture)
+bool torture_max_eas(struct torture_context *torture)
{
struct smbcli_state *cli;
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx;
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
mem_ctx = talloc_init("torture_raw_eas");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
ret &= test_max_eas(cli, mem_ctx);
diff --git a/source4/torture/raw/ioctl.c b/source4/torture/raw/ioctl.c
index 8e98822e11..c4dd4c5bf2 100644
--- a/source4/torture/raw/ioctl.c
+++ b/source4/torture/raw/ioctl.c
@@ -31,18 +31,18 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%d) Incorrect status %s - should be %s\n", \
__LINE__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
/* test some ioctls */
-static BOOL test_ioctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_ioctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_ioctl ctl;
int fnum;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
const char *fname = BASEDIR "\\test.dat";
printf("TESTING IOCTL FUNCTIONS\n");
@@ -50,7 +50,7 @@ static BOOL test_ioctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
printf("Failed to create test.dat - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -81,11 +81,11 @@ done:
}
/* test some filesystem control functions */
-static BOOL test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
int fnum;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
const char *fname = BASEDIR "\\test.dat";
union smb_ioctl nt;
@@ -94,7 +94,7 @@ static BOOL test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
printf("Failed to create test.dat - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -102,7 +102,7 @@ static BOOL test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
nt.ioctl.level = RAW_IOCTL_NTIOCTL;
nt.ntioctl.in.function = FSCTL_SET_SPARSE;
nt.ntioctl.in.file.fnum = fnum;
- nt.ntioctl.in.fsctl = True;
+ nt.ntioctl.in.fsctl = true;
nt.ntioctl.in.filter = 0;
nt.ntioctl.in.max_data = 0;
nt.ntioctl.in.blob = data_blob(NULL, 0);
@@ -114,7 +114,7 @@ static BOOL test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
nt.ioctl.level = RAW_IOCTL_NTIOCTL;
nt.ntioctl.in.function = FSCTL_REQUEST_BATCH_OPLOCK;
nt.ntioctl.in.file.fnum = fnum;
- nt.ntioctl.in.fsctl = True;
+ nt.ntioctl.in.fsctl = true;
nt.ntioctl.in.filter = 0;
nt.ntioctl.in.max_data = 0;
nt.ntioctl.in.blob = data_blob(NULL, 0);
@@ -152,12 +152,12 @@ done:
basic testing of some ioctl calls
*/
bool torture_raw_ioctl(struct torture_context *torture,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
bool ret = true;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
ret &= test_ioctl(cli, torture);
diff --git a/source4/torture/raw/lock.c b/source4/torture/raw/lock.c
index 533974c9a9..c2d5a778fb 100644
--- a/source4/torture/raw/lock.c
+++ b/source4/torture/raw/lock.c
@@ -27,12 +27,13 @@
#include "libcli/composite/composite.h"
#include "libcli/smb_composite/smb_composite.h"
#include "lib/cmdline/popt_common.h"
+#include "param/param.h"
#define CHECK_STATUS(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -46,12 +47,12 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_lock io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
const char *fname = BASEDIR "\\test.txt";
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_LOCK_LOCK\n");
@@ -60,7 +61,7 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli)
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -182,12 +183,12 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
union smb_lock io;
struct smb_lock_entry lock[1];
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
const char *fname = BASEDIR "\\test.txt";
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_LOCK_LOCKX\n");
@@ -196,7 +197,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -362,13 +363,13 @@ static bool test_pidhigh(struct torture_context *tctx,
union smb_lock io;
struct smb_lock_entry lock[1];
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
const char *fname = BASEDIR "\\test.txt";
uint8_t c = 1;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing high pid\n");
@@ -379,13 +380,13 @@ static bool test_pidhigh(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
if (smbcli_write(cli->tree, fnum, 0, &c, 0, 1) != 1) {
printf("Failed to write 1 byte - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -404,7 +405,7 @@ static bool test_pidhigh(struct torture_context *tctx,
if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) {
printf("Failed to read 1 byte - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -414,7 +415,7 @@ static bool test_pidhigh(struct torture_context *tctx,
if (smbcli_read(cli->tree, fnum, &c, 0, 1) == 1) {
printf("pid is incorrect handled for read with lock!\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -422,7 +423,7 @@ static bool test_pidhigh(struct torture_context *tctx,
if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) {
printf("High pid is used on this server!\n");
- ret = False;
+ ret = false;
} else {
printf("High pid is not used on this server (correct)\n");
}
@@ -449,14 +450,14 @@ static bool test_async(struct torture_context *tctx,
union smb_lock io;
struct smb_lock_entry lock[2];
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
const char *fname = BASEDIR "\\test.txt";
time_t t;
struct smbcli_request *req;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing LOCKING_ANDX_CANCEL_LOCK\n");
@@ -465,7 +466,7 @@ static bool test_async(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -491,7 +492,7 @@ static bool test_async(struct torture_context *tctx,
req = smb_raw_lock_send(cli->tree, &io);
if (req == NULL) {
printf("Failed to setup timed lock (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -522,7 +523,7 @@ static bool test_async(struct torture_context *tctx,
if (time(NULL) > t+2) {
printf("lock cancel was not immediate (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -538,7 +539,7 @@ static bool test_async(struct torture_context *tctx,
req = smb_raw_lock_send(cli->tree, &io);
if (req == NULL) {
printf("Failed to setup timed lock (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -554,7 +555,7 @@ static bool test_async(struct torture_context *tctx,
if (time(NULL) > t+2) {
printf("lock cancel by unlock was not immediate (%s) - took %d secs\n",
__location__, (int)(time(NULL)-t));
- ret = False;
+ ret = false;
goto done;
}
@@ -571,7 +572,7 @@ static bool test_async(struct torture_context *tctx,
req = smb_raw_lock_send(cli->tree, &io);
if (req == NULL) {
printf("Failed to setup timed lock (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -583,24 +584,24 @@ static bool test_async(struct torture_context *tctx,
if (time(NULL) > t+2) {
printf("lock cancel by close was not immediate (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
printf("create a new sessions\n");
- session = smbcli_session_init(cli->transport, tctx, False);
+ session = smbcli_session_init(cli->transport, tctx, false);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
- setup.in.workgroup = lp_workgroup();
+ setup.in.workgroup = lp_workgroup(global_loadparm);
setup.in.credentials = cmdline_credentials;
status = smb_composite_sesssetup(session, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
session->vuid = setup.out.vuid;
printf("create new tree context\n");
- share = lp_parm_string(-1, "torture", "share");
- host = lp_parm_string(-1, "torture", "host");
- tree = smbcli_tree_init(session, tctx, False);
+ share = lp_parm_string(global_loadparm, NULL, "torture", "share");
+ host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ tree = smbcli_tree_init(session, tctx, false);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
tcon.tconx.in.password = data_blob(NULL, 0);
@@ -615,7 +616,7 @@ static bool test_async(struct torture_context *tctx,
fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree));
- ret = False;
+ ret = false;
goto done;
}
io.lockx.level = RAW_LOCK_LOCKX;
@@ -643,7 +644,7 @@ static bool test_async(struct torture_context *tctx,
req = smb_raw_lock_send(tree, &io);
if (req == NULL) {
printf("Failed to setup timed lock (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -655,7 +656,7 @@ static bool test_async(struct torture_context *tctx,
if (time(NULL) > t+2) {
printf("lock cancel by exit was not immediate (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -664,7 +665,7 @@ static bool test_async(struct torture_context *tctx,
fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree));
- ret = False;
+ ret = false;
goto done;
}
io.lockx.level = RAW_LOCK_LOCKX;
@@ -692,7 +693,7 @@ static bool test_async(struct torture_context *tctx,
req = smb_raw_lock_send(tree, &io);
if (req == NULL) {
printf("Failed to setup timed lock (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -711,7 +712,7 @@ static bool test_async(struct torture_context *tctx,
if (time(NULL) > t+2) {
printf("lock cancel by ulogoff was not immediate (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -722,7 +723,7 @@ static bool test_async(struct torture_context *tctx,
fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree));
- ret = False;
+ ret = false;
goto done;
}
io.lockx.level = RAW_LOCK_LOCKX;
@@ -746,7 +747,7 @@ static bool test_async(struct torture_context *tctx,
req = smb_raw_lock_send(tree, &io);
if (req == NULL) {
printf("Failed to setup timed lock (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -758,7 +759,7 @@ static bool test_async(struct torture_context *tctx,
if (time(NULL) > t+2) {
printf("lock cancel by tdis was not immediate (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -778,7 +779,7 @@ static bool test_errorcode(struct torture_context *tctx,
union smb_open op;
struct smb_lock_entry lock[2];
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum, fnum2;
const char *fname;
struct smbcli_request *req;
@@ -786,7 +787,7 @@ static bool test_errorcode(struct torture_context *tctx,
int t;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing LOCK_NOT_GRANTED vs. FILE_LOCK_CONFLICT\n");
@@ -1104,7 +1105,7 @@ next_run:
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
io.lockx.level = RAW_LOCK_LOCKX;
@@ -1125,7 +1126,7 @@ next_run:
req = smb_raw_lock_send(cli->tree, &io);
if (req == NULL) {
printf("Failed to setup timed lock (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1143,7 +1144,7 @@ next_run:
if (time(NULL) < start+1) {
printf("lock comes back to early (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1152,7 +1153,7 @@ next_run:
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
io.lockx.level = RAW_LOCK_LOCKX;
@@ -1173,7 +1174,7 @@ next_run:
req = smb_raw_lock_send(cli->tree, &io);
if (req == NULL) {
printf("Failed to setup timed lock (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1193,7 +1194,7 @@ next_run:
if (time(NULL) < start+1) {
printf("lock comes back to early (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1202,7 +1203,7 @@ next_run:
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
io.lockx.level = RAW_LOCK_LOCKX;
@@ -1223,7 +1224,7 @@ next_run:
req = smb_raw_lock_send(cli->tree, &io);
if (req == NULL) {
printf("Failed to setup timed lock (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1239,7 +1240,7 @@ next_run:
if (time(NULL) < start+1) {
printf("lock comes back to early (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1259,13 +1260,13 @@ static bool test_changetype(struct torture_context *tctx,
union smb_lock io;
struct smb_lock_entry lock[2];
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
uint8_t c = 0;
const char *fname = BASEDIR "\\test.txt";
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing LOCKING_ANDX_CHANGE_LOCKTYPE\n");
@@ -1274,7 +1275,7 @@ static bool test_changetype(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -1293,7 +1294,7 @@ static bool test_changetype(struct torture_context *tctx,
if (smbcli_write(cli->tree, fnum, 0, &c, 100, 1) == 1) {
printf("allowed write on read locked region (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1304,7 +1305,7 @@ static bool test_changetype(struct torture_context *tctx,
if (smbcli_write(cli->tree, fnum, 0, &c, 100, 1) == 1) {
printf("allowed write after lock change (%s)\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c
index 44b60b8695..855364b169 100644
--- a/source4/torture/raw/lockbench.c
+++ b/source4/torture/raw/lockbench.c
@@ -30,6 +30,7 @@
#include "lib/cmdline/popt_common.h"
#include "libcli/composite/composite.h"
#include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
#define BASEDIR "\\benchlock"
#define FNAME BASEDIR "\\lock.dat"
@@ -188,8 +189,8 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te,
io->in.service = share;
io->in.service_type = state->service_type;
io->in.credentials = cmdline_credentials;
- io->in.fallback_to_anonymous = False;
- io->in.workgroup = lp_workgroup();
+ io->in.fallback_to_anonymous = false;
+ io->in.workgroup = lp_workgroup(global_loadparm);
/* kill off the remnants of the old connection */
talloc_free(state->tree);
@@ -302,9 +303,9 @@ static void report_rate(struct event_context *ev, struct timed_event *te,
/*
benchmark locking calls
*/
-BOOL torture_bench_lock(struct torture_context *torture)
+bool torture_bench_lock(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx = talloc_new(torture);
int i;
int timelimit = torture_setting_int(torture, "timelimit", 10);
@@ -317,7 +318,7 @@ BOOL torture_bench_lock(struct torture_context *torture)
progress = torture_setting_bool(torture, "progress", true);
- nprocs = lp_parm_int(-1, "torture", "nprocs", 4);
+ nprocs = lp_parm_int(global_loadparm, NULL, "torture", "nprocs", 4);
state = talloc_zero_array(mem_ctx, struct benchlock_state, nprocs);
@@ -327,7 +328,7 @@ BOOL torture_bench_lock(struct torture_context *torture)
state[i].client_num = i;
state[i].ev = ev;
if (!torture_open_connection_ev(&cli, i, ev)) {
- return False;
+ return false;
}
talloc_steal(mem_ctx, state);
state[i].tree = cli->tree;
diff --git a/source4/torture/raw/mkdir.c b/source4/torture/raw/mkdir.c
index 0e2fd1afe0..f502b10a69 100644
--- a/source4/torture/raw/mkdir.c
+++ b/source4/torture/raw/mkdir.c
@@ -22,6 +22,7 @@
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
#include "torture/util.h"
+#include "param/param.h"
#define BASEDIR "\\mkdirtest"
@@ -29,23 +30,23 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
/*
test mkdir ops
*/
-static BOOL test_mkdir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_mkdir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_mkdir md;
struct smb_rmdir rd;
const char *path = BASEDIR "\\mkdir.dir";
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
/*
@@ -129,7 +130,7 @@ static BOOL test_mkdir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
md.t2mkdir.in.eas[2].value = data_blob_talloc(mem_ctx, "xx1", 3);
status = smb_raw_mkdir(cli->tree, &md);
- if (lp_parm_bool(-1, "torture", "samba3", False)
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)
&& NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED)) {
d_printf("EAS not supported -- not treating as fatal\n");
}
@@ -160,8 +161,8 @@ done:
/*
basic testing of all RAW_MKDIR_* calls
*/
-BOOL torture_raw_mkdir(struct torture_context *torture,
- struct smbcli_state *cli)
+bool torture_raw_mkdir(struct torture_context *torture,
+ struct smbcli_state *cli)
{
bool ret = true;
diff --git a/source4/torture/raw/mux.c b/source4/torture/raw/mux.c
index b67d756ed9..846a9787cb 100644
--- a/source4/torture/raw/mux.c
+++ b/source4/torture/raw/mux.c
@@ -30,7 +30,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -38,12 +38,12 @@
/*
test the delayed reply to a open that leads to a sharing violation
*/
-static BOOL test_mux_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_mux_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
NTSTATUS status;
int fnum1, fnum2;
- BOOL ret = True;
+ bool ret = true;
struct smbcli_request *req1, *req2;
struct timeval tv;
double d;
@@ -104,7 +104,7 @@ static BOOL test_mux_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
d = timeval_elapsed(&tv);
if (d > 0.25) {
printf("bad timeout after cancel - %.2f should be <0.25\n", d);
- ret = False;
+ ret = false;
}
printf("close the 2nd sync open\n");
@@ -117,7 +117,7 @@ static BOOL test_mux_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
d = timeval_elapsed(&tv);
if (d > 0.25) {
printf("bad timeout for async conflict - %.2f should be <0.25\n", d);
- ret = False;
+ ret = false;
} else {
printf("async open delay %.2f\n", d);
}
@@ -141,12 +141,12 @@ done:
/*
test a write that hits a byte range lock and send the close after the write
*/
-static BOOL test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_write io;
NTSTATUS status;
int fnum;
- BOOL ret = True;
+ bool ret = true;
struct smbcli_request *req;
printf("testing multiplexed lock/write/close\n");
@@ -154,7 +154,7 @@ static BOOL test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
fnum = smbcli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -163,7 +163,7 @@ static BOOL test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
/* lock a range */
if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 0, 4, 0, WRITE_LOCK))) {
printf("lock failed in mux_write - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -176,7 +176,7 @@ static BOOL test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
io.writex.in.wmode = 0;
io.writex.in.remaining = 0;
io.writex.in.count = 4;
- io.writex.in.data = (void *)&fnum;
+ io.writex.in.data = (const uint8_t *)&fnum;
req = smb_raw_write_send(cli->tree, &io);
/* unlock the range */
@@ -197,12 +197,12 @@ done:
/*
test a lock that conflicts with an existing lock
*/
-static BOOL test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_lock io;
NTSTATUS status;
int fnum;
- BOOL ret = True;
+ bool ret = true;
struct smbcli_request *req;
struct smb_lock_entry lock[1];
struct timeval t;
@@ -212,7 +212,7 @@ static BOOL test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
fnum = smbcli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -256,7 +256,7 @@ static BOOL test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("async lock took %.2f msec\n", timeval_elapsed(&t) * 1000);
if (timeval_elapsed(&t) > 0.1) {
printf("failed to trigger early lock retry\n");
- return False;
+ return false;
}
printf("reopening with an exit\n");
@@ -330,7 +330,7 @@ static BOOL test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("async lock exit took %.2f msec\n", timeval_elapsed(&t) * 1000);
if (timeval_elapsed(&t) > 0.1) {
printf("failed to trigger early lock failure\n");
- return False;
+ return false;
}
done:
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 1540a4a2dd..96c7e4f947 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -23,6 +23,7 @@
#include "libcli/libcli.h"
#include "system/filesys.h"
#include "torture/util.h"
+#include "param/param.h"
#define BASEDIR "\\test_notify"
@@ -30,7 +31,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%d) Incorrect status %s - should be %s\n", \
__LINE__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -39,14 +40,14 @@
if ((v) != (correct)) { \
printf("(%d) wrong value for %s 0x%x should be 0x%x\n", \
__LINE__, #v, (int)v, (int)correct); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
#define CHECK_WSTR(field, value, flags) do { \
if (!field.s || strcmp(field.s, value) || wire_bad_flags(&field, flags, cli->transport)) { \
printf("(%d) %s [%s] != %s\n", __LINE__, #field, field.s, value); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -54,10 +55,10 @@
/*
basic testing of change notify on directories
*/
-static BOOL test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2,
+static bool test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2,
TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_notify notify;
union smb_open io;
@@ -98,7 +99,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2,
notify.nttrans.in.buffer_size = 1000;
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
notify.nttrans.in.file.fnum = fnum;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
printf("testing notify cancel\n");
@@ -158,7 +159,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2,
if (fnum3 == -1) {
printf("Failed to create %s - %s\n",
fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
talloc_free(fname);
@@ -266,7 +267,7 @@ done:
* pair in any of the three following notify_changes.
*/
-static BOOL check_rename_reply(struct smbcli_state *cli,
+static bool check_rename_reply(struct smbcli_state *cli,
int line,
struct notify_changes *actions,
uint32_t action, const char *name)
@@ -281,22 +282,22 @@ static BOOL check_rename_reply(struct smbcli_state *cli,
cli->transport))) {
printf("(%d) name [%s] != %s\n", line,
actions[i].name.s, name);
- return False;
+ return false;
}
- return True;
+ return true;
}
}
printf("(%d) expected action %d, not found\n", line, action);
- return False;
+ return false;
}
/*
testing of recursive change notify
*/
-static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_notify notify;
union smb_open io;
@@ -332,10 +333,10 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_CREATION;
notify.nttrans.in.file.fnum = fnum;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
req1 = smb_raw_changenotify_send(cli->tree, &notify);
- notify.nttrans.in.recursive = False;
+ notify.nttrans.in.recursive = false;
req2 = smb_raw_changenotify_send(cli->tree, &notify);
/* cancel initial requests so the buffer is setup */
@@ -356,7 +357,7 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
smbcli_rename(cli->tree, BASEDIR "\\subname2-r", BASEDIR "\\subname3-r");
notify.nttrans.in.completion_filter = 0;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
msleep(200);
req1 = smb_raw_changenotify_send(cli->tree, &notify);
@@ -364,7 +365,7 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
smbcli_unlink(cli->tree, BASEDIR "\\subname3-r");
- notify.nttrans.in.recursive = False;
+ notify.nttrans.in.recursive = false;
req2 = smb_raw_changenotify_send(cli->tree, &notify);
status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
@@ -425,15 +426,14 @@ done:
/*
testing of change notify mask change
*/
-static BOOL test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_notify notify;
union smb_open io;
int fnum;
struct smbcli_request *req1, *req2;
- union smb_setfileinfo sfinfo;
printf("TESTING CHANGE NOTIFY WITH MASK CHANGE\n");
@@ -464,10 +464,10 @@ static BOOL test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ct
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_ATTRIBUTES;
notify.nttrans.in.file.fnum = fnum;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
req1 = smb_raw_changenotify_send(cli->tree, &notify);
- notify.nttrans.in.recursive = False;
+ notify.nttrans.in.recursive = false;
req2 = smb_raw_changenotify_send(cli->tree, &notify);
/* cancel initial requests so the buffer is setup */
@@ -479,7 +479,7 @@ static BOOL test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ct
status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
CHECK_STATUS(status, NT_STATUS_CANCELLED);
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
req1 = smb_raw_changenotify_send(cli->tree, &notify);
/* Set to hidden then back again. */
@@ -499,10 +499,10 @@ static BOOL test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ct
* fnum it seems to be fixed until the fnum is closed. */
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_CREATION;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
req1 = smb_raw_changenotify_send(cli->tree, &notify);
- notify.nttrans.in.recursive = False;
+ notify.nttrans.in.recursive = false;
req2 = smb_raw_changenotify_send(cli->tree, &notify);
smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
@@ -544,9 +544,9 @@ done:
/*
testing of mask bits for change notify
*/
-static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_notify notify;
union smb_open io;
@@ -580,7 +580,7 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
notify.nttrans.level = RAW_NOTIFY_NTTRANS;
notify.nttrans.in.buffer_size = 1000;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
#define NOTIFY_MASK_TEST(setup, op, cleanup, Action, expected, nchanges) \
do { for (mask=i=0;i<32;i++) { \
@@ -611,21 +611,21 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
nchanges, \
notify.nttrans.out.changes[0].action, \
notify.nttrans.in.completion_filter); \
- ret = False; \
+ ret = false; \
} else if (notify.nttrans.out.changes[0].action != Action) { \
printf("ERROR: nchanges=%d action=%d expectedAction=%d filter=0x%08x\n", \
notify.nttrans.out.num_changes, \
notify.nttrans.out.changes[0].action, \
Action, \
notify.nttrans.in.completion_filter); \
- ret = False; \
+ ret = false; \
} else if (strcmp(notify.nttrans.out.changes[0].name.s, "tname1") != 0) { \
printf("ERROR: nchanges=%d action=%d filter=0x%08x name=%s\n", \
notify.nttrans.out.num_changes, \
notify.nttrans.out.changes[0].action, \
notify.nttrans.in.completion_filter, \
notify.nttrans.out.changes[0].name.s); \
- ret = False; \
+ ret = false; \
} \
mask |= (1<<i); \
} \
@@ -633,7 +633,7 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
if (((expected) & ~mask) != 0) { \
printf("ERROR: trigger on too few bits. mask=0x%08x expected=0x%08x\n", \
mask, expected); \
- ret = False; \
+ ret = false; \
} else { \
printf("WARNING: trigger on too many bits. mask=0x%08x expected=0x%08x\n", \
mask, expected); \
@@ -711,7 +711,7 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
NOTIFY_ACTION_MODIFIED,
FILE_NOTIFY_CHANGE_ATTRIBUTES, 1);
- if (lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
printf("Samba3 does not yet support create times "
"everywhere\n");
}
@@ -776,10 +776,10 @@ done:
/*
basic testing of change notify on files
*/
-static BOOL test_notify_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_notify_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
union smb_open io;
union smb_close cl;
union smb_notify notify;
@@ -811,7 +811,7 @@ static BOOL test_notify_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
notify.nttrans.in.file.fnum = fnum;
notify.nttrans.in.buffer_size = 1000;
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_STREAM_NAME;
- notify.nttrans.in.recursive = False;
+ notify.nttrans.in.recursive = false;
printf("testing if notifies on file handles are invalid (should be)\n");
@@ -836,9 +836,9 @@ done:
/*
basic testing of change notifies followed by a tdis
*/
-static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx)
+static bool test_notify_tdis(TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_notify notify;
union smb_open io;
@@ -849,7 +849,7 @@ static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx)
printf("TESTING CHANGE NOTIFY FOLLOWED BY TDIS\n");
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
/*
@@ -878,7 +878,7 @@ static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx)
notify.nttrans.in.buffer_size = 1000;
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
notify.nttrans.in.file.fnum = fnum;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
req = smb_raw_changenotify_send(cli->tree, &notify);
@@ -898,9 +898,9 @@ done:
/*
basic testing of change notifies followed by a exit
*/
-static BOOL test_notify_exit(TALLOC_CTX *mem_ctx)
+static bool test_notify_exit(TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_notify notify;
union smb_open io;
@@ -911,7 +911,7 @@ static BOOL test_notify_exit(TALLOC_CTX *mem_ctx)
printf("TESTING CHANGE NOTIFY FOLLOWED BY EXIT\n");
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
/*
@@ -940,7 +940,7 @@ static BOOL test_notify_exit(TALLOC_CTX *mem_ctx)
notify.nttrans.in.buffer_size = 1000;
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
notify.nttrans.in.file.fnum = fnum;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
req = smb_raw_changenotify_send(cli->tree, &notify);
@@ -959,9 +959,9 @@ done:
/*
basic testing of change notifies followed by a ulogoff
*/
-static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx)
+static bool test_notify_ulogoff(TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_notify notify;
union smb_open io;
@@ -972,7 +972,7 @@ static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx)
printf("TESTING CHANGE NOTIFY FOLLOWED BY ULOGOFF\n");
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
/*
@@ -1001,7 +1001,7 @@ static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx)
notify.nttrans.in.buffer_size = 1000;
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
notify.nttrans.in.file.fnum = fnum;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
req = smb_raw_changenotify_send(cli->tree, &notify);
@@ -1019,7 +1019,7 @@ done:
static void tcp_dis_handler(struct smbcli_transport *t, void *p)
{
- struct smbcli_state *cli = p;
+ struct smbcli_state *cli = (struct smbcli_state *)p;
smbcli_transport_dead(cli->transport, NT_STATUS_LOCAL_DISCONNECT);
cli->transport = NULL;
cli->tree = NULL;
@@ -1027,9 +1027,9 @@ static void tcp_dis_handler(struct smbcli_transport *t, void *p)
/*
basic testing of change notifies followed by tcp disconnect
*/
-static BOOL test_notify_tcp_dis(TALLOC_CTX *mem_ctx)
+static bool test_notify_tcp_dis(TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_notify notify;
union smb_open io;
@@ -1040,7 +1040,7 @@ static BOOL test_notify_tcp_dis(TALLOC_CTX *mem_ctx)
printf("TESTING CHANGE NOTIFY FOLLOWED BY TCP DISCONNECT\n");
if (!torture_open_connection(&cli, 0)) {
- return False;
+ return false;
}
/*
@@ -1069,7 +1069,7 @@ static BOOL test_notify_tcp_dis(TALLOC_CTX *mem_ctx)
notify.nttrans.in.buffer_size = 1000;
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
notify.nttrans.in.file.fnum = fnum;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
req = smb_raw_changenotify_send(cli->tree, &notify);
@@ -1086,9 +1086,9 @@ done:
/*
test setting up two change notify requests on one handle
*/
-static BOOL test_notify_double(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_notify_double(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_notify notify;
union smb_open io;
@@ -1123,7 +1123,7 @@ static BOOL test_notify_double(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
notify.nttrans.in.buffer_size = 1000;
notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
notify.nttrans.in.file.fnum = fnum;
- notify.nttrans.in.recursive = True;
+ notify.nttrans.in.recursive = true;
req1 = smb_raw_changenotify_send(cli->tree, &notify);
req2 = smb_raw_changenotify_send(cli->tree, &notify);
@@ -1151,45 +1151,45 @@ done:
/*
test multiple change notifies at different depths and with/without recursion
*/
-static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
union smb_notify notify;
union smb_open io;
struct smbcli_request *req;
struct timeval tv;
struct {
const char *path;
- BOOL recursive;
+ bool recursive;
uint32_t filter;
int expected;
int fnum;
int counted;
} dirs[] = {
- {BASEDIR "\\abc", True, FILE_NOTIFY_CHANGE_NAME, 30 },
- {BASEDIR "\\zqy", True, FILE_NOTIFY_CHANGE_NAME, 8 },
- {BASEDIR "\\atsy", True, FILE_NOTIFY_CHANGE_NAME, 4 },
- {BASEDIR "\\abc\\foo", True, FILE_NOTIFY_CHANGE_NAME, 2 },
- {BASEDIR "\\abc\\blah", True, FILE_NOTIFY_CHANGE_NAME, 13 },
- {BASEDIR "\\abc\\blah", False, FILE_NOTIFY_CHANGE_NAME, 7 },
- {BASEDIR "\\abc\\blah\\a", True, FILE_NOTIFY_CHANGE_NAME, 2 },
- {BASEDIR "\\abc\\blah\\b", True, FILE_NOTIFY_CHANGE_NAME, 2 },
- {BASEDIR "\\abc\\blah\\c", True, FILE_NOTIFY_CHANGE_NAME, 2 },
- {BASEDIR "\\abc\\fooblah", True, FILE_NOTIFY_CHANGE_NAME, 2 },
- {BASEDIR "\\zqy\\xx", True, FILE_NOTIFY_CHANGE_NAME, 2 },
- {BASEDIR "\\zqy\\yyy", True, FILE_NOTIFY_CHANGE_NAME, 2 },
- {BASEDIR "\\zqy\\..", True, FILE_NOTIFY_CHANGE_NAME, 40 },
- {BASEDIR, True, FILE_NOTIFY_CHANGE_NAME, 40 },
- {BASEDIR, False,FILE_NOTIFY_CHANGE_NAME, 6 },
- {BASEDIR "\\atsy", False,FILE_NOTIFY_CHANGE_NAME, 4 },
- {BASEDIR "\\abc", True, FILE_NOTIFY_CHANGE_NAME, 24 },
- {BASEDIR "\\abc", False,FILE_NOTIFY_CHANGE_FILE_NAME, 0 },
- {BASEDIR "\\abc", True, FILE_NOTIFY_CHANGE_FILE_NAME, 0 },
- {BASEDIR "\\abc", True, FILE_NOTIFY_CHANGE_NAME, 24 },
+ {BASEDIR "\\abc", true, FILE_NOTIFY_CHANGE_NAME, 30 },
+ {BASEDIR "\\zqy", true, FILE_NOTIFY_CHANGE_NAME, 8 },
+ {BASEDIR "\\atsy", true, FILE_NOTIFY_CHANGE_NAME, 4 },
+ {BASEDIR "\\abc\\foo", true, FILE_NOTIFY_CHANGE_NAME, 2 },
+ {BASEDIR "\\abc\\blah", true, FILE_NOTIFY_CHANGE_NAME, 13 },
+ {BASEDIR "\\abc\\blah", false, FILE_NOTIFY_CHANGE_NAME, 7 },
+ {BASEDIR "\\abc\\blah\\a", true, FILE_NOTIFY_CHANGE_NAME, 2 },
+ {BASEDIR "\\abc\\blah\\b", true, FILE_NOTIFY_CHANGE_NAME, 2 },
+ {BASEDIR "\\abc\\blah\\c", true, FILE_NOTIFY_CHANGE_NAME, 2 },
+ {BASEDIR "\\abc\\fooblah", true, FILE_NOTIFY_CHANGE_NAME, 2 },
+ {BASEDIR "\\zqy\\xx", true, FILE_NOTIFY_CHANGE_NAME, 2 },
+ {BASEDIR "\\zqy\\yyy", true, FILE_NOTIFY_CHANGE_NAME, 2 },
+ {BASEDIR "\\zqy\\..", true, FILE_NOTIFY_CHANGE_NAME, 40 },
+ {BASEDIR, true, FILE_NOTIFY_CHANGE_NAME, 40 },
+ {BASEDIR, false,FILE_NOTIFY_CHANGE_NAME, 6 },
+ {BASEDIR "\\atsy", false,FILE_NOTIFY_CHANGE_NAME, 4 },
+ {BASEDIR "\\abc", true, FILE_NOTIFY_CHANGE_NAME, 24 },
+ {BASEDIR "\\abc", false,FILE_NOTIFY_CHANGE_FILE_NAME, 0 },
+ {BASEDIR "\\abc", true, FILE_NOTIFY_CHANGE_FILE_NAME, 0 },
+ {BASEDIR "\\abc", true, FILE_NOTIFY_CHANGE_NAME, 24 },
};
int i;
NTSTATUS status;
- BOOL all_done = False;
+ bool all_done = false;
printf("TESTING CHANGE NOTIFY FOR DIFFERENT DEPTHS\n");
@@ -1248,11 +1248,11 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
dirs[i].counted += notify.nttrans.out.num_changes;
}
- all_done = True;
+ all_done = true;
for (i=0;i<ARRAY_SIZE(dirs);i++) {
if (dirs[i].counted != dirs[i].expected) {
- all_done = False;
+ all_done = false;
}
}
} while (!all_done && timeval_elapsed(&tv) < 20);
@@ -1263,7 +1263,7 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
if (dirs[i].counted != dirs[i].expected) {
printf("ERROR: i=%d expected %d got %d for '%s'\n",
i, dirs[i].expected, dirs[i].counted, dirs[i].path);
- ret = False;
+ ret = false;
}
}
@@ -1284,8 +1284,8 @@ done:
basic testing of change notify
*/
bool torture_raw_notify(struct torture_context *torture,
- struct smbcli_state *cli,
- struct smbcli_state *cli2)
+ struct smbcli_state *cli,
+ struct smbcli_state *cli2)
{
bool ret = true;
diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c
index f8fa4ff8fe..c4ccc0eb17 100644
--- a/source4/torture/raw/open.c
+++ b/source4/torture/raw/open.c
@@ -28,6 +28,7 @@
#include "torture/util.h"
#include "auth/credentials/credentials.h"
#include "lib/cmdline/popt_common.h"
+#include "param/param.h"
/* enum for whether reads/writes are possible on a file */
enum rdwr_mode {RDWR_NONE, RDWR_RDONLY, RDWR_WRONLY, RDWR_RDWR};
@@ -40,8 +41,8 @@ enum rdwr_mode {RDWR_NONE, RDWR_RDONLY, RDWR_WRONLY, RDWR_RDWR};
static enum rdwr_mode check_rdwr(struct smbcli_tree *tree, int fnum)
{
uint8_t c = 1;
- BOOL can_read = (smbcli_read(tree, fnum, &c, 0, 1) == 1);
- BOOL can_write = (smbcli_write(tree, fnum, 0, &c, 0, 1) == 1);
+ bool can_read = (smbcli_read(tree, fnum, &c, 0, 1) == 1);
+ bool can_write = (smbcli_write(tree, fnum, 0, &c, 0, 1) == 1);
if ( can_read && can_write) return RDWR_RDWR;
if ( can_read && !can_write) return RDWR_RDONLY;
if (!can_read && can_write) return RDWR_WRONLY;
@@ -66,7 +67,7 @@ static const char *rdwr_string(enum rdwr_mode m)
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -74,7 +75,7 @@ static const char *rdwr_string(enum rdwr_mode m)
fnum = create_complex_file(cli, mem_ctx, fname); \
if (fnum == -1) { \
printf("(%s) Failed to create %s - %s\n", __location__, fname, smbcli_errstr(cli->tree)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -83,7 +84,7 @@ static const char *rdwr_string(enum rdwr_mode m)
if (m != correct) { \
printf("(%s) Incorrect readwrite mode %s - expected %s\n", \
__location__, rdwr_string(m), rdwr_string(correct)); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_TIME(t, field) do { \
@@ -100,7 +101,7 @@ static const char *rdwr_string(enum rdwr_mode m)
timestring(mem_ctx, t1), \
timestring(mem_ctx, t2)); \
dump_all_info(mem_ctx, &finfo); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_NTTIME(t, field) do { \
@@ -116,7 +117,7 @@ static const char *rdwr_string(enum rdwr_mode m)
nt_time_string(mem_ctx, t), \
nt_time_string(mem_ctx, t2)); \
dump_all_info(mem_ctx, &finfo); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_ALL_INFO(v, field) do { \
@@ -128,14 +129,14 @@ static const char *rdwr_string(enum rdwr_mode m)
printf("(%s) wrong value for field %s 0x%x - 0x%x\n", \
__location__, #field, (int)v, (int)(finfo.all_info.out.field)); \
dump_all_info(mem_ctx, &finfo); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_VAL(v, correct) do { \
if ((v) != (correct)) { \
printf("(%s) wrong value for %s 0x%x - should be 0x%x\n", \
__location__, #v, (int)(v), (int)correct); \
- ret = False; \
+ ret = false; \
}} while (0)
#define SET_ATTRIB(sattrib) do { \
@@ -153,14 +154,14 @@ static const char *rdwr_string(enum rdwr_mode m)
/*
test RAW_OPEN_OPEN
*/
-static BOOL test_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
union smb_fileinfo finfo;
const char *fname = BASEDIR "\\torture_open.txt";
NTSTATUS status;
int fnum = -1, fnum2;
- BOOL ret = True;
+ bool ret = true;
printf("Checking RAW_OPEN_OPEN\n");
@@ -264,7 +265,7 @@ done:
/*
test RAW_OPEN_OPENX
*/
-static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
union smb_fileinfo finfo;
@@ -272,26 +273,26 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
const char *fname_exe = BASEDIR "\\torture_openx.exe";
NTSTATUS status;
int fnum = -1, fnum2;
- BOOL ret = True;
+ bool ret = true;
int i;
struct timeval tv;
struct {
uint16_t open_func;
- BOOL with_file;
+ bool with_file;
NTSTATUS correct_status;
} open_funcs[] = {
- { OPENX_OPEN_FUNC_OPEN, True, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_OPEN, False, NT_STATUS_OBJECT_NAME_NOT_FOUND },
- { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_FAIL, True, NT_STATUS_DOS(ERRDOS, ERRbadaccess) },
- { OPENX_OPEN_FUNC_FAIL, False, NT_STATUS_DOS(ERRDOS, ERRbadaccess) },
- { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OBJECT_NAME_COLLISION },
- { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_TRUNC, True, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_TRUNC, False, NT_STATUS_OBJECT_NAME_NOT_FOUND },
- { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_OPEN, true, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_FAIL, true, NT_STATUS_DOS(ERRDOS, ERRbadaccess) },
+ { OPENX_OPEN_FUNC_FAIL, false, NT_STATUS_DOS(ERRDOS, ERRbadaccess) },
+ { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION },
+ { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_TRUNC, true, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_TRUNC, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
};
printf("Checking RAW_OPEN_OPENX\n");
@@ -313,7 +314,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
smbcli_close(cli->tree, fnum);
@@ -324,7 +325,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_func=0x%x)\n",
__location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_func);
- ret = False;
+ ret = false;
}
if (NT_STATUS_IS_OK(status)) {
smbcli_close(cli->tree, io.openx.out.file.fnum);
@@ -357,7 +358,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
/* check the fields when the file already existed */
fnum2 = create_complex_file(cli, mem_ctx, fname);
if (fnum2 == -1) {
- ret = False;
+ ret = false;
goto done;
}
smbcli_close(cli->tree, fnum2);
@@ -397,7 +398,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
io.openx.in.file_attrs = FILE_ATTRIBUTE_SYSTEM;
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- if (lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE,
attrib & ~(FILE_ATTRIBUTE_NONINDEXED|
FILE_ATTRIBUTE_SPARSE));
@@ -425,7 +426,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
if (timeval_elapsed(&tv) > 3.0) {
printf("(%s) Incorrect timing in openx with timeout - waited %.2f seconds\n",
__location__, timeval_elapsed(&tv));
- ret = False;
+ ret = false;
}
smbcli_close(cli->tree, fnum);
smbcli_unlink(cli->tree, fname);
@@ -494,7 +495,7 @@ done:
many thanks to kukks for a sniff showing how this works with os2->w2k
*/
-static BOOL test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
union smb_fileinfo finfo;
@@ -503,31 +504,31 @@ static BOOL test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
const char *fname = BASEDIR "\\torture_t2open_3.txt";
NTSTATUS status;
int fnum;
- BOOL ret = True;
+ bool ret = true;
int i;
struct {
uint16_t open_func;
- BOOL with_file;
+ bool with_file;
NTSTATUS correct_status;
} open_funcs[] = {
- { OPENX_OPEN_FUNC_OPEN, True, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_OPEN, False, NT_STATUS_OBJECT_NAME_NOT_FOUND },
- { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_FAIL, True, NT_STATUS_OBJECT_NAME_COLLISION },
- { OPENX_OPEN_FUNC_FAIL, False, NT_STATUS_OBJECT_NAME_COLLISION },
- { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OBJECT_NAME_COLLISION },
- { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OBJECT_NAME_COLLISION },
- { OPENX_OPEN_FUNC_TRUNC, True, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_TRUNC, False, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OK },
- { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_OPEN, true, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_FAIL, true, NT_STATUS_OBJECT_NAME_COLLISION },
+ { OPENX_OPEN_FUNC_FAIL, false, NT_STATUS_OBJECT_NAME_COLLISION },
+ { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION },
+ { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OBJECT_NAME_COLLISION },
+ { OPENX_OPEN_FUNC_TRUNC, true, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_TRUNC, false, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK },
+ { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
};
fnum = create_complex_file(cli, mem_ctx, fname1);
if (fnum == -1) {
d_printf("Failed to create file %s - %s\n", fname1, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
smbcli_close(cli->tree, fnum);
@@ -568,7 +569,7 @@ static BOOL test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
status = smb_raw_open(cli->tree, mem_ctx, &io);
if ((io.t2open.in.num_eas != 0)
&& NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED)
- && lp_parm_bool(-1, "torture", "samba3", False)) {
+ && lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
printf("(%s) EAs not supported, not treating as fatal "
"in Samba3 test\n", __location__);
io.t2open.in.num_eas = 0;
@@ -579,7 +580,7 @@ static BOOL test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_func=0x%x)\n",
__location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_func);
- ret = False;
+ ret = false;
}
if (NT_STATUS_IS_OK(status)) {
smbcli_close(cli->tree, io.t2open.out.file.fnum);
@@ -659,7 +660,7 @@ done:
/*
test RAW_OPEN_NTCREATEX
*/
-static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
union smb_fileinfo finfo;
@@ -667,27 +668,27 @@ static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
const char *dname = BASEDIR "\\torture_ntcreatex.dir";
NTSTATUS status;
int fnum = -1;
- BOOL ret = True;
+ bool ret = true;
int i;
struct {
uint32_t open_disp;
- BOOL with_file;
+ bool with_file;
NTSTATUS correct_status;
} open_funcs[] = {
- { NTCREATEX_DISP_SUPERSEDE, True, NT_STATUS_OK },
- { NTCREATEX_DISP_SUPERSEDE, False, NT_STATUS_OK },
- { NTCREATEX_DISP_OPEN, True, NT_STATUS_OK },
- { NTCREATEX_DISP_OPEN, False, NT_STATUS_OBJECT_NAME_NOT_FOUND },
- { NTCREATEX_DISP_CREATE, True, NT_STATUS_OBJECT_NAME_COLLISION },
- { NTCREATEX_DISP_CREATE, False, NT_STATUS_OK },
- { NTCREATEX_DISP_OPEN_IF, True, NT_STATUS_OK },
- { NTCREATEX_DISP_OPEN_IF, False, NT_STATUS_OK },
- { NTCREATEX_DISP_OVERWRITE, True, NT_STATUS_OK },
- { NTCREATEX_DISP_OVERWRITE, False, NT_STATUS_OBJECT_NAME_NOT_FOUND },
- { NTCREATEX_DISP_OVERWRITE_IF, True, NT_STATUS_OK },
- { NTCREATEX_DISP_OVERWRITE_IF, False, NT_STATUS_OK },
- { 6, True, NT_STATUS_INVALID_PARAMETER },
- { 6, False, NT_STATUS_INVALID_PARAMETER },
+ { NTCREATEX_DISP_SUPERSEDE, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_SUPERSEDE, false, NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { NTCREATEX_DISP_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION },
+ { NTCREATEX_DISP_CREATE, false, NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN_IF, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN_IF, false, NT_STATUS_OK },
+ { NTCREATEX_DISP_OVERWRITE, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_OVERWRITE, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { NTCREATEX_DISP_OVERWRITE_IF, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_OVERWRITE_IF, false, NT_STATUS_OK },
+ { 6, true, NT_STATUS_INVALID_PARAMETER },
+ { 6, false, NT_STATUS_INVALID_PARAMETER },
};
printf("Checking RAW_OPEN_NTCREATEX\n");
@@ -712,7 +713,7 @@ static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE);
if (fnum == -1) {
d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
smbcli_close(cli->tree, fnum);
@@ -723,7 +724,7 @@ static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n",
__location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_disp);
- ret = False;
+ ret = false;
}
if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) {
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
@@ -755,7 +756,7 @@ static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- ret = False;
+ ret = false;
goto done;
}
smbcli_close(cli->tree, fnum);
@@ -832,7 +833,7 @@ done:
/*
test RAW_OPEN_NTTRANS_CREATE
*/
-static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
union smb_fileinfo finfo;
@@ -840,27 +841,27 @@ static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
const char *dname = BASEDIR "\\torture_ntcreatex.dir";
NTSTATUS status;
int fnum = -1;
- BOOL ret = True;
+ bool ret = true;
int i;
struct {
uint32_t open_disp;
- BOOL with_file;
+ bool with_file;
NTSTATUS correct_status;
} open_funcs[] = {
- { NTCREATEX_DISP_SUPERSEDE, True, NT_STATUS_OK },
- { NTCREATEX_DISP_SUPERSEDE, False, NT_STATUS_OK },
- { NTCREATEX_DISP_OPEN, True, NT_STATUS_OK },
- { NTCREATEX_DISP_OPEN, False, NT_STATUS_OBJECT_NAME_NOT_FOUND },
- { NTCREATEX_DISP_CREATE, True, NT_STATUS_OBJECT_NAME_COLLISION },
- { NTCREATEX_DISP_CREATE, False, NT_STATUS_OK },
- { NTCREATEX_DISP_OPEN_IF, True, NT_STATUS_OK },
- { NTCREATEX_DISP_OPEN_IF, False, NT_STATUS_OK },
- { NTCREATEX_DISP_OVERWRITE, True, NT_STATUS_OK },
- { NTCREATEX_DISP_OVERWRITE, False, NT_STATUS_OBJECT_NAME_NOT_FOUND },
- { NTCREATEX_DISP_OVERWRITE_IF, True, NT_STATUS_OK },
- { NTCREATEX_DISP_OVERWRITE_IF, False, NT_STATUS_OK },
- { 6, True, NT_STATUS_INVALID_PARAMETER },
- { 6, False, NT_STATUS_INVALID_PARAMETER },
+ { NTCREATEX_DISP_SUPERSEDE, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_SUPERSEDE, false, NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { NTCREATEX_DISP_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION },
+ { NTCREATEX_DISP_CREATE, false, NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN_IF, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_OPEN_IF, false, NT_STATUS_OK },
+ { NTCREATEX_DISP_OVERWRITE, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_OVERWRITE, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { NTCREATEX_DISP_OVERWRITE_IF, true, NT_STATUS_OK },
+ { NTCREATEX_DISP_OVERWRITE_IF, false, NT_STATUS_OK },
+ { 6, true, NT_STATUS_INVALID_PARAMETER },
+ { 6, false, NT_STATUS_INVALID_PARAMETER },
};
printf("Checking RAW_OPEN_NTTRANS_CREATE\n");
@@ -887,7 +888,7 @@ static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE);
if (fnum == -1) {
d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
smbcli_close(cli->tree, fnum);
@@ -898,7 +899,7 @@ static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n",
__location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_disp);
- ret = False;
+ ret = false;
}
if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) {
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
@@ -930,7 +931,7 @@ static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- ret = False;
+ ret = false;
goto done;
}
smbcli_close(cli->tree, fnum);
@@ -1011,14 +1012,14 @@ done:
open_disposition==NTCREATEX_DISP_OVERWRITE_IF. Windows 2003 allows the
second open.
*/
-static BOOL test_ntcreatex_brlocked(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_ntcreatex_brlocked(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io, io1;
union smb_lock io2;
struct smb_lock_entry lock[1];
const char *fname = BASEDIR "\\torture_ntcreatex.txt";
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("Testing ntcreatex with a byte range locked file\n");
@@ -1081,13 +1082,13 @@ static BOOL test_ntcreatex_brlocked(struct smbcli_state *cli, TALLOC_CTX *mem_ct
/*
test RAW_OPEN_MKNEW
*/
-static BOOL test_mknew(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_mknew(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_mknew.txt";
NTSTATUS status;
int fnum = -1;
- BOOL ret = True;
+ bool ret = true;
time_t basetime = (time(NULL) + 3600*24*3) & ~1;
union smb_fileinfo finfo;
@@ -1136,13 +1137,13 @@ done:
/*
test RAW_OPEN_CREATE
*/
-static BOOL test_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_create.txt";
NTSTATUS status;
int fnum = -1;
- BOOL ret = True;
+ bool ret = true;
time_t basetime = (time(NULL) + 3600*24*3) & ~1;
union smb_fileinfo finfo;
@@ -1192,12 +1193,12 @@ done:
/*
test RAW_OPEN_CTEMP
*/
-static BOOL test_ctemp(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_ctemp(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
NTSTATUS status;
int fnum = -1;
- BOOL ret = True;
+ bool ret = true;
time_t basetime = (time(NULL) + 3600*24*3) & ~1;
union smb_fileinfo finfo;
const char *name, *fname = NULL;
@@ -1235,13 +1236,13 @@ done:
/*
test chained RAW_OPEN_OPENX_READX
*/
-static BOOL test_chained(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_chained(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_chained.txt";
NTSTATUS status;
int fnum = -1;
- BOOL ret = True;
+ bool ret = true;
const char *buf = "test";
char buf2[4];
@@ -1277,7 +1278,7 @@ static BOOL test_chained(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
if (memcmp(buf, buf2, sizeof(buf)) != 0) {
d_printf("wrong data in reply buffer\n");
- ret = False;
+ ret = false;
}
done:
@@ -1292,13 +1293,13 @@ done:
NetApp filers are known to fail on this.
*/
-static BOOL test_no_leading_slash(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_no_leading_slash(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_open io;
const char *fname = BASEDIR "\\torture_no_leading_slash.txt";
NTSTATUS status;
int fnum = -1;
- BOOL ret = True;
+ bool ret = true;
const char *buf = "test";
printf("Checking RAW_OPEN_OPENX without leading slash on path\n");
@@ -1334,19 +1335,19 @@ done:
/* A little torture test to expose a race condition in Samba 3.0.20 ... :-) */
-static BOOL test_raw_open_multi(void)
+static bool test_raw_open_multi(void)
{
struct smbcli_state *cli;
TALLOC_CTX *mem_ctx = talloc_init("torture_test_oplock_multi");
const char *fname = "\\test_oplock.dat";
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
union smb_open io;
struct smbcli_state **clients;
struct smbcli_request **requests;
union smb_open *ios;
- const char *host = lp_parm_string(-1, "torture", "host");
- const char *share = lp_parm_string(-1, "torture", "share");
+ const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share");
int i, num_files = 3;
struct event_context *ev;
int num_ok = 0;
@@ -1359,11 +1360,11 @@ static BOOL test_raw_open_multi(void)
if ((ev == NULL) || (clients == NULL) || (requests == NULL) ||
(ios == NULL)) {
DEBUG(0, ("talloc failed\n"));
- return False;
+ return false;
}
if (!torture_open_connection_share(mem_ctx, &cli, host, share, ev)) {
- return False;
+ return false;
}
cli->tree->session->transport->options.request_timeout = 60000;
@@ -1372,7 +1373,7 @@ static BOOL test_raw_open_multi(void)
if (!torture_open_connection_share(mem_ctx, &(clients[i]),
host, share, ev)) {
DEBUG(0, ("Could not open %d'th connection\n", i));
- return False;
+ return false;
}
clients[i]->tree->session->transport->
options.request_timeout = 60000;
@@ -1404,19 +1405,19 @@ static BOOL test_raw_open_multi(void)
requests[i] = smb_raw_open_send(clients[i]->tree, &ios[i]);
if (requests[i] == NULL) {
DEBUG(0, ("could not send %d'th request\n", i));
- return False;
+ return false;
}
}
DEBUG(10, ("waiting for replies\n"));
while (1) {
- BOOL unreplied = False;
+ bool unreplied = false;
for (i=0; i<num_files; i++) {
if (requests[i] == NULL) {
continue;
}
if (requests[i]->state < SMBCLI_REQUEST_DONE) {
- unreplied = True;
+ unreplied = true;
break;
}
status = smb_raw_open_recv(requests[i], mem_ctx,
@@ -1442,12 +1443,12 @@ static BOOL test_raw_open_multi(void)
if (event_loop_once(ev) != 0) {
DEBUG(0, ("event_loop_once failed\n"));
- return False;
+ return false;
}
}
if ((num_ok != 1) || (num_ok + num_collision != num_files)) {
- ret = False;
+ ret = false;
}
for (i=0; i<num_files; i++) {
diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c
index fffb572d50..a53efb3a8b 100644
--- a/source4/torture/raw/openbench.c
+++ b/source4/torture/raw/openbench.c
@@ -30,6 +30,7 @@
#include "lib/cmdline/popt_common.h"
#include "libcli/composite/composite.h"
#include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
#define BASEDIR "\\benchopen"
@@ -126,8 +127,8 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te,
io->in.service = share;
io->in.service_type = state->service_type;
io->in.credentials = cmdline_credentials;
- io->in.fallback_to_anonymous = False;
- io->in.workgroup = lp_workgroup();
+ io->in.fallback_to_anonymous = false;
+ io->in.workgroup = lp_workgroup(global_loadparm);
/* kill off the remnants of the old connection */
talloc_free(state->tree);
@@ -337,9 +338,9 @@ static void report_rate(struct event_context *ev, struct timed_event *te,
/*
benchmark open calls
*/
-BOOL torture_bench_open(struct torture_context *torture)
+bool torture_bench_open(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx = talloc_new(torture);
int i;
int timelimit = torture_setting_int(torture, "timelimit", 10);
@@ -347,7 +348,7 @@ BOOL torture_bench_open(struct torture_context *torture)
struct event_context *ev = event_context_find(mem_ctx);
struct benchopen_state *state;
int total = 0, minops=0;
- bool progress=False;
+ bool progress=false;
progress = torture_setting_bool(torture, "progress", true);
@@ -361,7 +362,7 @@ BOOL torture_bench_open(struct torture_context *torture)
state[i].client_num = i;
state[i].ev = ev;
if (!torture_open_connection_ev(&state[i].cli, i, ev)) {
- return False;
+ return false;
}
talloc_steal(mem_ctx, state);
state[i].tree = state[i].cli->tree;
@@ -437,5 +438,5 @@ BOOL torture_bench_open(struct torture_context *torture)
failed:
talloc_free(mem_ctx);
- return False;
+ return false;
}
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index 7a921af422..1f44f96b44 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -29,14 +29,14 @@
if ((v) != (correct)) { \
torture_comment(tctx, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
__location__, #v, (int)v, (int)correct); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_STATUS(tctx, 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; \
+ ret = false; \
goto done; \
}} while (0)
@@ -53,10 +53,11 @@ static struct {
/*
a handler function for oplock break requests. Ack it as a break to level II if possible
*/
-static BOOL oplock_handler_ack_to_levelII(struct smbcli_transport *transport, uint16_t tid,
- uint16_t fnum, uint8_t level, void *private)
+static bool oplock_handler_ack_to_levelII(struct smbcli_transport *transport,
+ uint16_t tid, uint16_t fnum,
+ uint8_t level, void *private)
{
- struct smbcli_tree *tree = private;
+ struct smbcli_tree *tree = (struct smbcli_tree *)private;
break_info.fnum = fnum;
break_info.level = level;
break_info.count++;
@@ -69,11 +70,11 @@ static BOOL oplock_handler_ack_to_levelII(struct smbcli_transport *transport, ui
/*
a handler function for oplock break requests. Ack it as a break to none
*/
-static BOOL oplock_handler_ack_to_none(struct smbcli_transport *transport, uint16_t tid,
- uint16_t fnum, uint8_t level,
- void *private)
+static bool oplock_handler_ack_to_none(struct smbcli_transport *transport,
+ uint16_t tid, uint16_t fnum,
+ uint8_t level, void *private)
{
- struct smbcli_tree *tree = private;
+ struct smbcli_tree *tree = (struct smbcli_tree *)private;
break_info.fnum = fnum;
break_info.level = level;
break_info.count++;
@@ -96,11 +97,11 @@ static void oplock_handler_close_recv(struct smbcli_request *req)
/*
a handler function for oplock break requests - close the file
*/
-static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t tid,
+static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t tid,
uint16_t fnum, uint8_t level, void *private)
{
union smb_close io;
- struct smbcli_tree *tree = private;
+ struct smbcli_tree *tree = (struct smbcli_tree *)private;
struct smbcli_request *req;
break_info.fnum = fnum;
@@ -113,13 +114,13 @@ static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t ti
req = smb_raw_close_send(tree, &io);
if (req == NULL) {
printf("failed to send close in oplock_handler_close\n");
- return False;
+ return false;
}
req->async.fn = oplock_handler_close_recv;
req->async.private = NULL;
- return True;
+ return true;
}
static bool test_raw_oplock_normal(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
@@ -1308,10 +1309,10 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
/*
stress testing of oplocks
*/
-BOOL torture_bench_oplock(struct torture_context *torture)
+bool torture_bench_oplock(struct torture_context *torture)
{
struct smbcli_state **cli;
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx = talloc_new(torture);
int torture_nprocs = torture_setting_int(torture, "nprocs", 4);
int i, count=0;
@@ -1325,7 +1326,7 @@ BOOL torture_bench_oplock(struct torture_context *torture)
torture_comment(torture, "Opening %d connections\n", torture_nprocs);
for (i=0;i<torture_nprocs;i++) {
if (!torture_open_connection_ev(&cli[i], i, ev)) {
- return False;
+ return false;
}
talloc_steal(mem_ctx, cli[i]);
smbcli_oplock_handler(cli[i]->transport, oplock_handler_close,
@@ -1333,7 +1334,7 @@ BOOL torture_bench_oplock(struct torture_context *torture)
}
if (!torture_setup_dir(cli[0], BASEDIR)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -1396,20 +1397,21 @@ static struct hold_oplock_info {
uint32_t share_access;
uint16_t fnum;
} hold_info[] = {
- { BASEDIR "\\notshared_close", True,
+ { BASEDIR "\\notshared_close", true,
NTCREATEX_SHARE_ACCESS_NONE, },
- { BASEDIR "\\notshared_noclose", False,
+ { BASEDIR "\\notshared_noclose", false,
NTCREATEX_SHARE_ACCESS_NONE, },
- { BASEDIR "\\shared_close", True,
+ { BASEDIR "\\shared_close", true,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, },
- { BASEDIR "\\shared_noclose", False,
+ { BASEDIR "\\shared_noclose", false,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, },
};
-static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid,
- uint16_t fnum, uint8_t level, void *private)
+static bool oplock_handler_hold(struct smbcli_transport *transport,
+ uint16_t tid, uint16_t fnum, uint8_t level,
+ void *private)
{
- struct smbcli_tree *tree = private;
+ struct smbcli_tree *tree = (struct smbcli_tree *)private;
struct hold_oplock_info *info;
int i;
@@ -1419,7 +1421,7 @@ static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid
if (i == ARRAY_SIZE(hold_info)) {
printf("oplock break for unknown fnum %u\n", fnum);
- return False;
+ return false;
}
info = &hold_info[i];
@@ -1428,7 +1430,7 @@ static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid
printf("oplock break on %s - closing\n",
info->fname);
oplock_handler_close(transport, tid, fnum, level, private);
- return True;
+ return true;
}
printf("oplock break on %s - acking break\n", info->fname);
@@ -1441,16 +1443,17 @@ static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid
used for manual testing of oplocks - especially interaction with
other filesystems (such as NFS and local access)
*/
-BOOL torture_hold_oplock(struct torture_context *torture,
+bool torture_hold_oplock(struct torture_context *torture,
struct smbcli_state *cli)
{
- struct event_context *ev = cli->transport->socket->event.ctx;
+ struct event_context *ev =
+ (struct event_context *)cli->transport->socket->event.ctx;
int i;
printf("Setting up open files with oplocks in %s\n", BASEDIR);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
smbcli_oplock_handler(cli->transport, oplock_handler_hold, cli->tree);
@@ -1480,14 +1483,14 @@ BOOL torture_hold_oplock(struct torture_context *torture,
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to open %s - %s\n",
hold_info[i].fname, nt_errstr(status));
- return False;
+ return false;
}
if (io.ntcreatex.out.oplock_level != BATCH_OPLOCK_RETURN) {
printf("Oplock not granted for %s - expected %d but got %d\n",
hold_info[i].fname, BATCH_OPLOCK_RETURN,
io.ntcreatex.out.oplock_level);
- return False;
+ return false;
}
hold_info[i].fnum = io.ntcreatex.out.file.fnum;
}
@@ -1495,5 +1498,5 @@ BOOL torture_hold_oplock(struct torture_context *torture,
printf("Waiting for oplock events\n");
event_loop_wait(ev);
- return True;
+ return true;
}
diff --git a/source4/torture/raw/pingpong.c b/source4/torture/raw/pingpong.c
index 027034275a..2e9de28d67 100755
--- a/source4/torture/raw/pingpong.c
+++ b/source4/torture/raw/pingpong.c
@@ -37,10 +37,10 @@
over and over until it completes.
reading from the file can be enabled with
- --option=torture:read=True
+ --option=torture:read=true
writing to the file can be enabled with
- --option=torture:write=True
+ --option=torture:write=true
*/
#include "includes.h"
@@ -50,11 +50,9 @@
#include "system/filesys.h"
#include "libcli/libcli.h"
#include "torture/util.h"
+#include "param/param.h"
-
-
-
-void lock_byte(struct smbcli_state *cli, int fd, int offset, int lock_timeout)
+static void lock_byte(struct smbcli_state *cli, int fd, int offset, int lock_timeout)
{
union smb_lock io;
struct smb_lock_entry lock;
@@ -92,7 +90,7 @@ try_again:
}
}
-void unlock_byte(struct smbcli_state *cli, int fd, int offset)
+static void unlock_byte(struct smbcli_state *cli, int fd, int offset)
{
union smb_lock io;
struct smb_lock_entry lock;
@@ -119,7 +117,7 @@ void unlock_byte(struct smbcli_state *cli, int fd, int offset)
}
}
-void write_byte(struct smbcli_state *cli, int fd, uint8_t c, int offset)
+static void write_byte(struct smbcli_state *cli, int fd, uint8_t c, int offset)
{
union smb_write io;
NTSTATUS status;
@@ -139,7 +137,7 @@ void write_byte(struct smbcli_state *cli, int fd, uint8_t c, int offset)
}
}
-void read_byte(struct smbcli_state *cli, int fd, uint8_t *c, int offset)
+static void read_byte(struct smbcli_state *cli, int fd, uint8_t *c, int offset)
{
union smb_read io;
NTSTATUS status;
@@ -150,7 +148,7 @@ void read_byte(struct smbcli_state *cli, int fd, uint8_t *c, int offset)
io.readx.in.maxcnt = 1;
io.readx.in.offset = offset;
io.readx.in.remaining = 0;
- io.readx.in.read_for_execute = False;
+ io.readx.in.read_for_execute = false;
io.readx.out.data = c;
status = smb_raw_read(cli->tree, &io);
@@ -178,13 +176,13 @@ static double end_timer(void)
/*
ping pong
*/
-BOOL torture_ping_pong(struct torture_context *torture)
+bool torture_ping_pong(struct torture_context *torture)
{
const char *fn;
int num_locks;
TALLOC_CTX *mem_ctx = talloc_new(torture);
- static BOOL do_reads;
- static BOOL do_writes;
+ static bool do_reads;
+ static bool do_writes;
int lock_timeout;
int fd;
struct smbcli_state *cli;
@@ -193,21 +191,21 @@ BOOL torture_ping_pong(struct torture_context *torture)
uint8_t *val;
int count, loops;
- fn = lp_parm_string(-1, "torture", "filename");
+ fn = lp_parm_string(global_loadparm, NULL, "torture", "filename");
if (fn == NULL) {
DEBUG(0,("You must specify the filename using --option=torture:filename=...\n"));
return false;
}
- num_locks = lp_parm_int(-1, "torture", "num_locks", -1);
+ num_locks = lp_parm_int(global_loadparm, NULL, "torture", "num_locks", -1);
if (num_locks == -1) {
DEBUG(0,("You must specify num_locks using --option=torture:num_locks=...\n"));
return false;
}
- do_reads = lp_parm_bool(-1, "torture", "read", False);
- do_writes = lp_parm_bool(-1, "torture", "write", False);
- lock_timeout = lp_parm_int(-1, "torture", "lock_timeout", 100000);
+ do_reads = lp_parm_bool(global_loadparm, NULL, "torture", "read", false);
+ do_writes = lp_parm_bool(global_loadparm, NULL, "torture", "write", false);
+ lock_timeout = lp_parm_int(global_loadparm, NULL, "torture", "lock_timeout", 100000);
if (!torture_open_connection(&cli, 0)) {
DEBUG(0,("Could not open connection\n"));
diff --git a/source4/torture/raw/qfileinfo.c b/source4/torture/raw/qfileinfo.c
index 8cb80cecc1..7dcd2000e9 100644
--- a/source4/torture/raw/qfileinfo.c
+++ b/source4/torture/raw/qfileinfo.c
@@ -25,6 +25,7 @@
#include "torture/util.h"
#include "librpc/rpc/dcerpc.h"
#include "torture/rpc/rpc.h"
+#include "torture/raw/proto.h"
static struct {
const char *name;
@@ -185,7 +186,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
#n1, #v1, (uint_t)s1->n1.out.v1, \
#n2, #v2, (uint_t)s2->n2.out.v2, \
__FILE__, __LINE__); \
- ret = False; \
+ ret = false; \
}} while(0)
#define STR_EQUAL(n1, v1, n2, v2) do {if (strcmp_safe(s1->n1.out.v1.s, s2->n2.out.v2.s) || \
@@ -194,7 +195,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
#n1, #v1, s1->n1.out.v1.s, s1->n1.out.v1.private_length, \
#n2, #v2, s2->n2.out.v2.s, s2->n2.out.v2.private_length, \
__FILE__, __LINE__); \
- ret = False; \
+ ret = false; \
}} while(0)
#define STRUCT_EQUAL(n1, v1, n2, v2) do {if (memcmp(&s1->n1.out.v1,&s2->n2.out.v2,sizeof(s1->n1.out.v1))) { \
@@ -202,7 +203,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
#n1, #v1, \
#n2, #v2, \
__FILE__, __LINE__); \
- ret = False; \
+ ret = false; \
}} while(0)
/* used to find hints on unknown values - and to make sure
@@ -214,7 +215,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
(uint_t)s1->n1.out.v1, \
(uint_t)s1->n1.out.v1, \
__FILE__, __LINE__); \
- ret = False; \
+ ret = false; \
}} while(0)
#endif
@@ -222,21 +223,21 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
for each call we test that it succeeds, and where possible test
for consistency between the calls.
*/
-static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
+static bool torture_raw_qfileinfo_internals(struct torture_context *torture,
TALLOC_CTX *mem_ctx,
struct smbcli_tree *tree,
int fnum, const char *fname,
bool is_ipc)
{
int i;
- BOOL ret = True;
+ bool ret = true;
int count;
union smb_fileinfo *s1, *s2;
NTTIME correct_time;
uint64_t correct_size;
uint32_t correct_attrib;
const char *correct_name;
- BOOL skip_streams = False;
+ bool skip_streams = false;
/* scan all the fileinfo and pathinfo levels */
for (i=0; levels[i].name; i++) {
@@ -292,11 +293,10 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
}
if (count != 0) {
- ret = False;
+ ret = false;
printf("%d levels failed\n", count);
if (count > 35) {
- printf("too many level failures - giving up\n");
- goto done;
+ torture_fail(torture, "too many level failures - giving up");
}
}
@@ -307,7 +307,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
printf("STREAM_INFO broken (%d) - skipping streams checks\n",
s1 ? s1->stream_info.out.num_streams : -1);
}
- skip_streams = True;
+ skip_streams = true;
}
@@ -401,14 +401,14 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \
nt_time_string(mem_ctx, s1->stype.out.tfield), \
nt_time_string(mem_ctx, correct_time)); \
- ret = False; \
+ ret = false; \
} \
s1 = fname_find(is_ipc, sname); \
if (s1 && memcmp(&s1->stype.out.tfield, &correct_time, sizeof(correct_time)) != 0) { \
printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \
nt_time_string(mem_ctx, s1->stype.out.tfield), \
nt_time_string(mem_ctx, correct_time)); \
- ret = False; \
+ ret = false; \
}} while (0)
#define TIME_CHECK_DOS(sname, stype, tfield) do { \
@@ -417,14 +417,14 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \
timestring(mem_ctx, s1->stype.out.tfield), \
nt_time_string(mem_ctx, correct_time)); \
- ret = False; \
+ ret = false; \
} \
s1 = fname_find(is_ipc, sname); \
if (s1 && dos_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \
printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \
timestring(mem_ctx, s1->stype.out.tfield), \
nt_time_string(mem_ctx, correct_time)); \
- ret = False; \
+ ret = false; \
}} while (0)
#if 0 /* unused */
@@ -434,21 +434,21 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \
timestring(mem_ctx, s1->stype.out.tfield), \
nt_time_string(mem_ctx, correct_time)); \
- ret = False; \
+ ret = false; \
} \
s1 = fname_find(is_ipc, sname); \
if (s1 && unx_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \
printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \
timestring(mem_ctx, s1->stype.out.tfield), \
nt_time_string(mem_ctx, correct_time)); \
- ret = False; \
+ ret = false; \
}} while (0)
#endif
/* now check that all the times that are supposed to be equal are correct */
s1 = fnum_find("BASIC_INFO");
correct_time = s1->basic_info.out.create_time;
- printf("create_time: %s\n", nt_time_string(mem_ctx, correct_time));
+ torture_comment(torture, "create_time: %s\n", nt_time_string(mem_ctx, correct_time));
TIME_CHECK_NT ("BASIC_INFO", basic_info, create_time);
TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, create_time);
@@ -460,7 +460,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("BASIC_INFO");
correct_time = s1->basic_info.out.access_time;
- printf("access_time: %s\n", nt_time_string(mem_ctx, correct_time));
+ torture_comment(torture, "access_time: %s\n", nt_time_string(mem_ctx, correct_time));
TIME_CHECK_NT ("BASIC_INFO", basic_info, access_time);
TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, access_time);
@@ -472,7 +472,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("BASIC_INFO");
correct_time = s1->basic_info.out.write_time;
- printf("write_time : %s\n", nt_time_string(mem_ctx, correct_time));
+ torture_comment(torture, "write_time : %s\n", nt_time_string(mem_ctx, correct_time));
TIME_CHECK_NT ("BASIC_INFO", basic_info, write_time);
TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, write_time);
@@ -485,7 +485,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("BASIC_INFO");
correct_time = s1->basic_info.out.change_time;
- printf("change_time: %s\n", nt_time_string(mem_ctx, correct_time));
+ torture_comment(torture, "change_time: %s\n", nt_time_string(mem_ctx, correct_time));
TIME_CHECK_NT ("BASIC_INFO", basic_info, change_time);
TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, change_time);
@@ -499,19 +499,19 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
printf("(%d) handle %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield, \
(uint_t)s1->stype.out.tfield, \
(uint_t)correct_size); \
- ret = False; \
+ ret = false; \
} \
s1 = fname_find(is_ipc, sname); \
if (s1 && s1->stype.out.tfield != correct_size) { \
printf("(%d) path %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield, \
(uint_t)s1->stype.out.tfield, \
(uint_t)correct_size); \
- ret = False; \
+ ret = false; \
}} while (0)
s1 = fnum_find("STANDARD_INFO");
correct_size = s1->standard_info.out.size;
- printf("size: %u\n", (uint_t)correct_size);
+ torture_comment(torture, "size: %u\n", (uint_t)correct_size);
SIZE_CHECK("GETATTR", getattr, size);
SIZE_CHECK("GETATTRE", getattre, size);
@@ -532,7 +532,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("STANDARD_INFO");
correct_size = s1->standard_info.out.alloc_size;
- printf("alloc_size: %u\n", (uint_t)correct_size);
+ torture_comment(torture, "alloc_size: %u\n", (uint_t)correct_size);
SIZE_CHECK("GETATTRE", getattre, alloc_size);
SIZE_CHECK("STANDARD", standard, alloc_size);
@@ -553,19 +553,19 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
printf("(%d) handle %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield, \
(uint_t)s1->stype.out.tfield, \
(uint_t)correct_attrib); \
- ret = False; \
+ ret = false; \
} \
s1 = fname_find(is_ipc, sname); \
if (s1 && s1->stype.out.tfield != correct_attrib) { \
printf("(%d) path %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield, \
(uint_t)s1->stype.out.tfield, \
(uint_t)correct_attrib); \
- ret = False; \
+ ret = false; \
}} while (0)
s1 = fnum_find("BASIC_INFO");
correct_attrib = s1->basic_info.out.attrib;
- printf("attrib: 0x%x\n", (uint_t)correct_attrib);
+ torture_comment(torture, "attrib: 0x%x\n", (uint_t)correct_attrib);
ATTRIB_CHECK("GETATTR", getattr, attrib);
if (!is_ipc) {
@@ -581,7 +581,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
ATTRIB_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, attrib);
correct_name = fname;
- printf("name: %s\n", correct_name);
+ torture_comment(torture, "name: %s\n", correct_name);
#define NAME_CHECK(sname, stype, tfield, flags) do { \
s1 = fnum_find(sname); \
@@ -589,14 +589,14 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \
printf("(%d) handle %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \
s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \
- ret = False; \
+ ret = false; \
} \
s1 = fname_find(is_ipc, sname); \
if (s1 && (strcmp_safe(s1->stype.out.tfield.s, correct_name) != 0 || \
wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \
printf("(%d) path %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \
s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \
- ret = False; \
+ ret = false; \
}} while (0)
NAME_CHECK("NAME_INFO", name_info, fname, STR_UNICODE);
@@ -605,32 +605,31 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
/* the ALL_INFO file name is the full path on the filesystem */
s1 = fnum_find("ALL_INFO");
if (s1 && !s1->all_info.out.fname.s) {
- printf("ALL_INFO didn't give a filename\n");
- ret = False;
+ torture_fail(torture, "ALL_INFO didn't give a filename");
}
if (s1 && s1->all_info.out.fname.s) {
char *p = strrchr(s1->all_info.out.fname.s, '\\');
if (!p) {
printf("Not a full path in all_info/fname? - '%s'\n",
s1->all_info.out.fname.s);
- ret = False;
+ ret = false;
} else {
if (strcmp_safe(correct_name, p) != 0) {
printf("incorrect basename in all_info/fname - '%s'\n",
s1->all_info.out.fname.s);
- ret = False;
+ ret = false;
}
}
if (wire_bad_flags(&s1->all_info.out.fname, STR_UNICODE, tree->session->transport)) {
printf("Should not null terminate all_info/fname\n");
- ret = False;
+ ret = false;
}
}
s1 = fnum_find("ALT_NAME_INFO");
if (s1) {
correct_name = s1->alt_name_info.out.fname.s;
- printf("alt_name: %s\n", correct_name);
+ torture_comment(torture, "alt_name: %s\n", correct_name);
NAME_CHECK("ALT_NAME_INFO", alt_name_info, fname, STR_UNICODE);
NAME_CHECK("ALT_NAME_INFORMATION", alt_name_info, fname, STR_UNICODE);
@@ -647,12 +646,12 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
0, 0);
if (fnum == -1) {
printf("Unable to open by alt_name - %s\n", smbcli_errstr(tree));
- ret = False;
+ ret = false;
}
if (!skip_streams) {
correct_name = "::$DATA";
- printf("stream_name: %s\n", correct_name);
+ torture_comment(torture, "stream_name: %s\n", correct_name);
NAME_CHECK("STREAM_INFO", stream_info, streams[0].stream_name, STR_UNICODE);
NAME_CHECK("STREAM_INFORMATION", stream_info, streams[0].stream_name, STR_UNICODE);
@@ -703,28 +702,28 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
printf("(%d) handle %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \
#stype1, #tfield1, #stype2, #tfield2, \
s1->stype1.out.tfield1, s2->stype2.out.tfield2); \
- ret = False; \
+ ret = false; \
} \
s1 = fname_find(is_ipc, sname1); s2 = fname_find(is_ipc, sname2); \
if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \
printf("(%d) path %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \
#stype1, #tfield1, #stype2, #tfield2, \
s1->stype1.out.tfield1, s2->stype2.out.tfield2); \
- ret = False; \
+ ret = false; \
} \
s1 = fnum_find(sname1); s2 = fname_find(is_ipc, sname2); \
if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \
printf("(%d) handle %s/%s != path %s/%s - 0x%x vs 0x%x\n", __LINE__, \
#stype1, #tfield1, #stype2, #tfield2, \
s1->stype1.out.tfield1, s2->stype2.out.tfield2); \
- ret = False; \
+ ret = false; \
} \
s1 = fname_find(is_ipc, sname1); s2 = fnum_find(sname2); \
if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \
printf("(%d) path %s/%s != handle %s/%s - 0x%x vs 0x%x\n", __LINE__, \
#stype1, #tfield1, #stype2, #tfield2, \
s1->stype1.out.tfield1, s2->stype2.out.tfield2); \
- ret = False; \
+ ret = false; \
}} while (0)
VAL_CHECK("STANDARD_INFO", standard_info, delete_pending,
@@ -737,18 +736,18 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
if (s1 && is_ipc) {
if (s1->basic_info.out.attrib != FILE_ATTRIBUTE_NORMAL) {
printf("(%d) attrib basic_info/nlink incorrect - %d should be %d\n", __LINE__, s1->basic_info.out.attrib, FILE_ATTRIBUTE_NORMAL);
- ret = False;
+ ret = false;
}
}
s1 = fnum_find("STANDARD_INFO");
if (s1 && is_ipc) {
if (s1->standard_info.out.nlink != 1) {
printf("(%d) nlinks standard_info/nlink incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.nlink);
- ret = False;
+ ret = false;
}
if (s1->standard_info.out.delete_pending != 1) {
printf("(%d) nlinks standard_info/delete_pending incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.delete_pending);
- ret = False;
+ ret = false;
}
}
VAL_CHECK("EA_INFO", ea_info, ea_size,
@@ -768,7 +767,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("INTERNAL_INFORMATION");
if (s1) {
- printf("file_id=%.0f\n", (double)s1->internal_information.out.file_id);
+ torture_comment(torture, "file_id=%.0f\n", (double)s1->internal_information.out.file_id);
}
NAME_PATH_CHECK("INTERNAL_INFORMATION", internal_information, file_id);
@@ -808,9 +807,6 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
/* when we set the delete disposition then the link count should drop
to 0 and delete_pending should be 1 */
-
-done:
-
return ret;
}
@@ -831,7 +827,7 @@ bool torture_raw_qfileinfo(struct torture_context *torture,
return false;
}
- ret = torture_raw_qfileinfo_internals(torture, torture, cli->tree, fnum, fname, False /* is_ipc */);
+ ret = torture_raw_qfileinfo_internals(torture, torture, cli->tree, fnum, fname, false /* is_ipc */);
smbcli_close(cli->tree, fnum);
smbcli_unlink(cli->tree, fname);
@@ -840,7 +836,7 @@ bool torture_raw_qfileinfo(struct torture_context *torture,
}
bool torture_raw_qfileinfo_pipe(struct torture_context *torture,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
bool ret = true;
int fnum;
@@ -849,23 +845,17 @@ bool torture_raw_qfileinfo_pipe(struct torture_context *torture,
struct smbcli_tree *ipc_tree;
NTSTATUS status;
- if (!(p = dcerpc_pipe_init(torture,
- cli->tree->session->transport->socket->event.ctx))) {
- return False;
+ if (!(p = dcerpc_pipe_init(torture, cli->tree->session->transport->socket->event.ctx))) {
+ return false;
}
status = dcerpc_pipe_open_smb(p, cli->tree, fname);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_pipe_open_smb failed: %s\n",
- nt_errstr(status));
- talloc_free(p);
- return False;
- }
+ torture_assert_ntstatus_ok(torture, status, "dcerpc_pipe_open_smb failed");
ipc_tree = dcerpc_smb_tree(p->conn);
fnum = dcerpc_smb_fnum(p->conn);
- ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, True /* is_ipc */);
+ ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, true /* is_ipc */);
talloc_free(p);
return ret;
diff --git a/source4/torture/raw/qfsinfo.c b/source4/torture/raw/qfsinfo.c
index dc09e55b63..3207558624 100644
--- a/source4/torture/raw/qfsinfo.c
+++ b/source4/torture/raw/qfsinfo.c
@@ -74,7 +74,7 @@ static union smb_fsinfo *find(const char *name)
#n1, #v1, (uint_t)s1->n1.out.v1, \
#n2, #v2, (uint_t)s2->n2.out.v2, \
__FILE__, __LINE__); \
- ret = False; \
+ ret = false; \
}} while(0)
#define VAL_APPROX_EQUAL(n1, v1, n2, v2) do {if (abs((int)(s1->n1.out.v1) - (int)(s2->n2.out.v2)) > 0.1*s1->n1.out.v1) { \
@@ -82,7 +82,7 @@ static union smb_fsinfo *find(const char *name)
#n1, #v1, (uint_t)s1->n1.out.v1, \
#n2, #v2, (uint_t)s2->n2.out.v2, \
__FILE__, __LINE__); \
- ret = False; \
+ ret = false; \
}} while(0)
#define STR_EQUAL(n1, v1, n2, v2) do { \
@@ -91,7 +91,7 @@ static union smb_fsinfo *find(const char *name)
#n1, #v1, s1->n1.out.v1, \
#n2, #v2, s2->n2.out.v2, \
__FILE__, __LINE__); \
- ret = False; \
+ ret = false; \
}} while(0)
#define STRUCT_EQUAL(n1, v1, n2, v2) do {if (memcmp(&s1->n1.out.v1,&s2->n2.out.v2,sizeof(s1->n1.out.v1))) { \
@@ -99,7 +99,7 @@ static union smb_fsinfo *find(const char *name)
#n1, #v1, \
#n2, #v2, \
__FILE__, __LINE__); \
- ret = False; \
+ ret = false; \
}} while(0)
/* used to find hints on unknown values - and to make sure
@@ -110,7 +110,7 @@ static union smb_fsinfo *find(const char *name)
(uint_t)s1->n1.out.v1, \
(uint_t)s1->n1.out.v1, \
__FILE__, __LINE__); \
- ret = False; \
+ ret = false; \
}} while(0)
/* basic testing of all RAW_QFS_* calls
@@ -121,10 +121,10 @@ static union smb_fsinfo *find(const char *name)
quiescent, which is sometimes hard to achieve
*/
bool torture_raw_qfsinfo(struct torture_context *torture,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
int i;
- BOOL ret = True;
+ bool ret = true;
int count;
union smb_fsinfo *s1, *s2;
@@ -154,7 +154,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
printf("%d levels failed\n", count);
if (count > 13) {
printf("too many level failures - giving up\n");
- return False;
+ return false;
}
}
@@ -212,7 +212,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
if (abs(size1 - size2) > 1) {
printf("Inconsistent total size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n",
size1, size2);
- ret = False;
+ ret = false;
}
printf("total disk = %.0f MB\n", size1*scale/1.0e6);
}
@@ -234,7 +234,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
if (abs(size1 - size2) > 1) {
printf("Inconsistent avail size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n",
size1, size2);
- ret = False;
+ ret = false;
}
printf("free disk = %.0f MB\n", size1*scale/1.0e6);
}
@@ -283,7 +283,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
if (s1->stype.out.field.s && wire_bad_flags(&s1->stype.out.field, flags, cli->transport)) { \
printf("(%d) incorrect string termination in %s/%s\n", \
__LINE__, #stype, #field); \
- ret = False; \
+ ret = false; \
} \
}} while (0)
diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c
index 0c4a28e0d6..112c34d299 100644
--- a/source4/torture/raw/raw.c
+++ b/source4/torture/raw/raw.c
@@ -63,6 +63,8 @@ NTSTATUS torture_raw_init(void)
torture_suite_add_1smb_test(suite, "COMPOSITE", torture_raw_composite);
torture_suite_add_simple_test(suite, "SAMBA3HIDE", torture_samba3_hide);
torture_suite_add_simple_test(suite, "SAMBA3CLOSEERR", torture_samba3_closeerr);
+ torture_suite_add_simple_test(suite, "SAMBA3ROOTDIRFID",
+ torture_samba3_rootdirfid);
torture_suite_add_simple_test(suite, "SAMBA3CHECKFSP", torture_samba3_checkfsp);
torture_suite_add_simple_test(suite, "SAMBA3BADPATH", torture_samba3_badpath);
torture_suite_add_simple_test(suite, "SAMBA3CASEINSENSITIVE",
@@ -71,8 +73,7 @@ NTSTATUS torture_raw_init(void)
torture_samba3_posixtimedlock);
torture_suite_add_simple_test(suite, "SCAN-EAMAX", torture_max_eas);
- suite->description = talloc_strdup(suite,
- "Tests for the raw SMB interface");
+ suite->description = talloc_strdup(suite, "Tests for the raw SMB interface");
torture_register_suite(suite);
diff --git a/source4/torture/raw/read.c b/source4/torture/raw/read.c
index f1048f25ac..90f6a3d4a8 100644
--- a/source4/torture/raw/read.c
+++ b/source4/torture/raw/read.c
@@ -24,12 +24,13 @@
#include "system/filesys.h"
#include "libcli/libcli.h"
#include "torture/util.h"
+#include "param/param.h"
#define CHECK_STATUS(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -37,13 +38,13 @@
if ((v) != (correct)) { \
printf("(%s) Incorrect value %s=%ld - should be %ld\n", \
__location__, #v, (long)v, (long)correct); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
#define CHECK_BUFFER(buf, seed, len) do { \
if (!check_buffer(buf, seed, len, __LINE__)) { \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -63,7 +64,7 @@ static void setup_buffer(uint8_t *buf, uint_t seed, int len)
/*
check a random buffer based on a seed
*/
-static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, int line)
+static bool check_buffer(uint8_t *buf, uint_t seed, int len, int line)
{
int i;
srandom(seed);
@@ -72,10 +73,10 @@ static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, int line)
if (buf[i] != v) {
printf("Buffer incorrect at line %d! ofs=%d v1=0x%x v2=0x%x\n",
line, i, buf[i], v);
- return False;
+ return false;
}
}
- return True;
+ return true;
}
/*
@@ -85,7 +86,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_read io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
uint8_t *buf;
const int maxsize = 90000;
@@ -93,10 +94,10 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli)
const char *test_data = "TEST DATA";
uint_t seed = time(NULL);
- buf = talloc_zero_size(tctx, maxsize);
+ buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_READ_READ\n");
@@ -105,7 +106,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli)
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -143,7 +144,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli)
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.read.out.nread, strlen(test_data));
if (memcmp(buf, test_data, strlen(test_data)) != 0) {
- ret = False;
+ ret = false;
printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data, buf);
goto done;
}
@@ -155,7 +156,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli)
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.read.out.nread, strlen(test_data)-1);
if (memcmp(buf, test_data+1, strlen(test_data)-1) != 0) {
- ret = False;
+ ret = false;
printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data+1, buf);
goto done;
}
@@ -185,7 +186,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli)
cli->session->pid++;
if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
- ret = False;
+ ret = false;
goto done;
}
cli->session->pid--;
@@ -212,7 +213,7 @@ static bool test_lockread(struct torture_context *tctx,
{
union smb_read io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
uint8_t *buf;
const int maxsize = 90000;
@@ -220,10 +221,10 @@ static bool test_lockread(struct torture_context *tctx,
const char *test_data = "TEST DATA";
uint_t seed = time(NULL);
- buf = talloc_zero_size(tctx, maxsize);
+ buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_READ_LOCKREAD\n");
@@ -232,7 +233,7 @@ static bool test_lockread(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -282,7 +283,7 @@ static bool test_lockread(struct torture_context *tctx,
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.lockread.out.nread, strlen(test_data));
if (memcmp(buf, test_data, strlen(test_data)) != 0) {
- ret = False;
+ ret = false;
printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data, buf);
goto done;
}
@@ -298,7 +299,7 @@ static bool test_lockread(struct torture_context *tctx,
CHECK_VALUE(io.lockread.out.nread, strlen(test_data)-1);
if (memcmp(buf, test_data+1, strlen(test_data)-1) != 0) {
- ret = False;
+ ret = false;
printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data+1, buf);
goto done;
}
@@ -332,7 +333,7 @@ static bool test_lockread(struct torture_context *tctx,
cli->session->pid++;
if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
- ret = False;
+ ret = false;
goto done;
}
cli->session->pid--;
@@ -357,7 +358,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_read io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
uint8_t *buf;
const int maxsize = 90000;
@@ -365,10 +366,10 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
const char *test_data = "TEST DATA";
uint_t seed = time(NULL);
- buf = talloc_zero_size(tctx, maxsize);
+ buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_READ_READX\n");
@@ -376,7 +377,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -387,7 +388,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
io.readx.in.maxcnt = 1;
io.readx.in.offset = 0;
io.readx.in.remaining = 0;
- io.readx.in.read_for_execute = False;
+ io.readx.in.read_for_execute = false;
io.readx.out.data = buf;
status = smb_raw_read(cli->tree, &io);
@@ -417,7 +418,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
io.readx.in.file.fnum = fnum;
io.readx.in.offset = 0;
io.readx.in.remaining = 0;
- io.readx.in.read_for_execute = False;
+ io.readx.in.read_for_execute = false;
io.readx.in.mincnt = strlen(test_data);
io.readx.in.maxcnt = strlen(test_data);
status = smb_raw_read(cli->tree, &io);
@@ -426,7 +427,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
CHECK_VALUE(io.readx.out.remaining, 0xFFFF);
CHECK_VALUE(io.readx.out.compaction_mode, 0);
if (memcmp(buf, test_data, strlen(test_data)) != 0) {
- ret = False;
+ ret = false;
printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data, buf);
goto done;
}
@@ -441,7 +442,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
CHECK_VALUE(io.readx.out.remaining, 0xFFFF);
CHECK_VALUE(io.readx.out.compaction_mode, 0);
if (memcmp(buf, test_data+1, strlen(test_data)-1) != 0) {
- ret = False;
+ ret = false;
printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data+1, buf);
goto done;
}
@@ -481,7 +482,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.readx.out.remaining, 0xFFFF);
CHECK_VALUE(io.readx.out.compaction_mode, 0);
- if (lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
printf("SAMBA3: large read extension\n");
CHECK_VALUE(io.readx.out.nread, 80000);
} else {
@@ -525,7 +526,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
io.readx.in.maxcnt = 0x10000;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- if (lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
printf("SAMBA3: large read extension\n");
CHECK_VALUE(io.readx.out.nread, 0x10000);
} else {
@@ -535,7 +536,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
io.readx.in.maxcnt = 0x10001;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- if (lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
printf("SAMBA3: large read extension\n");
CHECK_VALUE(io.readx.out.nread, 0x10001);
} else {
@@ -547,7 +548,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
cli->session->pid++;
if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
- ret = False;
+ ret = false;
goto done;
}
cli->session->pid--;
@@ -573,7 +574,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
if (NT_STATUS_IS_ERR(smbcli_lock64(cli->tree, fnum, io.readx.in.offset, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
- ret = False;
+ ret = false;
goto done;
}
@@ -596,7 +597,7 @@ static bool test_readbraw(struct torture_context *tctx,
{
union smb_read io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
uint8_t *buf;
const int maxsize = 90000;
@@ -604,10 +605,10 @@ static bool test_readbraw(struct torture_context *tctx,
const char *test_data = "TEST DATA";
uint_t seed = time(NULL);
- buf = talloc_zero_size(tctx, maxsize);
+ buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_READ_READBRAW\n");
@@ -615,7 +616,7 @@ static bool test_readbraw(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -657,7 +658,7 @@ static bool test_readbraw(struct torture_context *tctx,
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.readbraw.out.nread, strlen(test_data));
if (memcmp(buf, test_data, strlen(test_data)) != 0) {
- ret = False;
+ ret = false;
printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data, buf);
goto done;
}
@@ -670,7 +671,7 @@ static bool test_readbraw(struct torture_context *tctx,
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.readbraw.out.nread, strlen(test_data)-1);
if (memcmp(buf, test_data+1, strlen(test_data)-1) != 0) {
- ret = False;
+ ret = false;
printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data+1, buf);
goto done;
}
@@ -722,7 +723,7 @@ static bool test_readbraw(struct torture_context *tctx,
cli->session->pid++;
if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %d\n", __LINE__);
- ret = False;
+ ret = false;
goto done;
}
cli->session->pid--;
@@ -771,17 +772,17 @@ static bool test_read_for_execute(struct torture_context *tctx,
union smb_write wr;
union smb_read rd;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum=0;
uint8_t *buf;
const int maxsize = 900;
const char *fname = BASEDIR "\\test.txt";
const uint8_t data[] = "TEST DATA";
- buf = talloc_zero_size(tctx, maxsize);
+ buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_READ_READX with read_for_execute\n");
@@ -840,7 +841,7 @@ static bool test_read_for_execute(struct torture_context *tctx,
rd.readx.in.maxcnt = maxsize;
rd.readx.in.offset = 0;
rd.readx.in.remaining = 0;
- rd.readx.in.read_for_execute = True;
+ rd.readx.in.read_for_execute = true;
rd.readx.out.data = buf;
status = smb_raw_read(cli->tree, &rd);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -855,7 +856,7 @@ static bool test_read_for_execute(struct torture_context *tctx,
rd.readx.in.maxcnt = maxsize;
rd.readx.in.offset = 0;
rd.readx.in.remaining = 0;
- rd.readx.in.read_for_execute = False;
+ rd.readx.in.read_for_execute = false;
rd.readx.out.data = buf;
status = smb_raw_read(cli->tree, &rd);
CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
@@ -887,7 +888,7 @@ static bool test_read_for_execute(struct torture_context *tctx,
rd.readx.in.maxcnt = maxsize;
rd.readx.in.offset = 0;
rd.readx.in.remaining = 0;
- rd.readx.in.read_for_execute = True;
+ rd.readx.in.read_for_execute = true;
rd.readx.out.data = buf;
status = smb_raw_read(cli->tree, &rd);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -902,7 +903,7 @@ static bool test_read_for_execute(struct torture_context *tctx,
rd.readx.in.maxcnt = maxsize;
rd.readx.in.offset = 0;
rd.readx.in.remaining = 0;
- rd.readx.in.read_for_execute = False;
+ rd.readx.in.read_for_execute = false;
rd.readx.out.data = buf;
status = smb_raw_read(cli->tree, &rd);
CHECK_STATUS(status, NT_STATUS_OK);
diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c
index 05a5320859..4b0d986659 100644
--- a/source4/torture/raw/rename.c
+++ b/source4/torture/raw/rename.c
@@ -27,7 +27,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -35,7 +35,7 @@
if ((v) != (correct)) { \
printf("(%s) Incorrect %s %d - should be %d\n", \
__location__, #v, (int)v, (int)correct); \
- ret = False; \
+ ret = false; \
}} while (0)
#define BASEDIR "\\testrename"
@@ -48,7 +48,7 @@ static bool test_mv(struct torture_context *tctx,
{
union smb_rename io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum = -1;
const char *fname1 = BASEDIR "\\test1.txt";
const char *fname2 = BASEDIR "\\test2.txt";
@@ -59,7 +59,7 @@ static bool test_mv(struct torture_context *tctx,
printf("Testing SMBmv\n");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Trying simple rename\n");
@@ -197,7 +197,7 @@ static bool test_ntrename(struct torture_context *tctx,
{
union smb_rename io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum, i;
const char *fname1 = BASEDIR "\\test1.txt";
const char *fname2 = BASEDIR "\\test2.txt";
@@ -206,7 +206,7 @@ static bool test_ntrename(struct torture_context *tctx,
printf("Testing SMBntrename\n");
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Trying simple rename\n");
diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c
index 3fe151f009..8fe3aa4d2d 100644
--- a/source4/torture/raw/samba3hide.c
+++ b/source4/torture/raw/samba3hide.c
@@ -57,7 +57,7 @@ static void init_unixinfo_nochange(union smb_setfileinfo *info)
struct list_state {
const char *fname;
- BOOL visible;
+ bool visible;
};
static void set_visible(struct clilist_file_info *i, const char *mask,
@@ -66,43 +66,43 @@ static void set_visible(struct clilist_file_info *i, const char *mask,
struct list_state *state = (struct list_state *)priv;
if (strcasecmp_m(state->fname, i->name) == 0)
- state->visible = True;
+ state->visible = true;
}
-static BOOL is_visible(struct smbcli_tree *tree, const char *fname)
+static bool is_visible(struct smbcli_tree *tree, const char *fname)
{
struct list_state state;
- state.visible = False;
+ state.visible = false;
state.fname = fname;
if (smbcli_list(tree, "*.*", 0, set_visible, &state) < 0) {
- return False;
+ return false;
}
return state.visible;
}
-static BOOL is_readable(struct smbcli_tree *tree, const char *fname)
+static bool is_readable(struct smbcli_tree *tree, const char *fname)
{
int fnum;
fnum = smbcli_open(tree, fname, O_RDONLY, DENY_NONE);
if (fnum < 0) {
- return False;
+ return false;
}
smbcli_close(tree, fnum);
- return True;
+ return true;
}
-static BOOL is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree,
+static bool is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree,
const char *fname)
{
int fnum;
fnum = smbcli_open(tree, fname, O_WRONLY, DENY_NONE);
if (fnum < 0) {
- return False;
+ return false;
}
smbcli_close(tree, fnum);
- return True;
+ return true;
}
/*
@@ -110,7 +110,7 @@ static BOOL is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree,
* might fail. But for our purposes it's sufficient.
*/
-static BOOL smbcli_file_exists(struct smbcli_tree *tree, const char *fname)
+static bool smbcli_file_exists(struct smbcli_tree *tree, const char *fname)
{
return NT_STATUS_IS_OK(smbcli_getatr(tree, fname, NULL, NULL, NULL));
}
@@ -125,7 +125,7 @@ static NTSTATUS smbcli_chmod(struct smbcli_tree *tree, const char *fname,
return smb_raw_setpathinfo(tree, &sfinfo);
}
-BOOL torture_samba3_hide(struct torture_context *torture)
+bool torture_samba3_hide(struct torture_context *torture)
{
struct smbcli_state *cli;
const char *fname = "test.txt";
@@ -138,7 +138,7 @@ BOOL torture_samba3_hide(struct torture_context *torture)
torture, &cli, torture_setting_string(torture, "host", NULL),
torture_setting_string(torture, "share", NULL), NULL)) {
d_printf("torture_open_connection_share failed\n");
- return False;
+ return false;
}
status = torture_second_tcon(torture, cli->session, "hideunread",
@@ -146,7 +146,7 @@ BOOL torture_samba3_hide(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("second_tcon(hideunread) failed: %s\n",
nt_errstr(status));
- return False;
+ return false;
}
status = torture_second_tcon(torture, cli->session, "hideunwrite",
@@ -154,7 +154,7 @@ BOOL torture_samba3_hide(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("second_tcon(hideunwrite) failed: %s\n",
nt_errstr(status));
- return False;
+ return false;
}
status = smbcli_unlink(cli->tree, fname);
@@ -167,14 +167,14 @@ BOOL torture_samba3_hide(struct torture_context *torture)
if (fnum == -1) {
d_printf("Failed to create %s - %s\n", fname,
smbcli_errstr(cli->tree));
- return False;
+ return false;
}
smbcli_close(cli->tree, fnum);
if (!smbcli_file_exists(cli->tree, fname)) {
d_printf("%s does not exist\n", fname);
- return False;
+ return false;
}
/* R/W file should be visible everywhere */
@@ -182,27 +182,27 @@ BOOL torture_samba3_hide(struct torture_context *torture)
status = smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_chmod failed: %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!is_writeable(torture, cli->tree, fname)) {
d_printf("File not writable\n");
- return False;
+ return false;
}
if (!is_readable(cli->tree, fname)) {
d_printf("File not readable\n");
- return False;
+ return false;
}
if (!is_visible(cli->tree, fname)) {
d_printf("r/w file not visible via normal share\n");
- return False;
+ return false;
}
if (!is_visible(hideunread, fname)) {
d_printf("r/w file not visible via hide unreadable\n");
- return False;
+ return false;
}
if (!is_visible(hideunwrite, fname)) {
d_printf("r/w file not visible via hide unwriteable\n");
- return False;
+ return false;
}
/* R/O file should not be visible via hide unwriteable files */
@@ -211,27 +211,27 @@ BOOL torture_samba3_hide(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_chmod failed: %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (is_writeable(torture, cli->tree, fname)) {
d_printf("r/o is writable\n");
- return False;
+ return false;
}
if (!is_readable(cli->tree, fname)) {
d_printf("r/o not readable\n");
- return False;
+ return false;
}
if (!is_visible(cli->tree, fname)) {
d_printf("r/o file not visible via normal share\n");
- return False;
+ return false;
}
if (!is_visible(hideunread, fname)) {
d_printf("r/o file not visible via hide unreadable\n");
- return False;
+ return false;
}
if (is_visible(hideunwrite, fname)) {
d_printf("r/o file visible via hide unwriteable\n");
- return False;
+ return false;
}
/* inaccessible file should be only visible on normal share */
@@ -239,33 +239,33 @@ BOOL torture_samba3_hide(struct torture_context *torture)
status = smbcli_chmod(cli->tree, fname, 0);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_chmod failed: %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (is_writeable(torture, cli->tree, fname)) {
d_printf("inaccessible file is writable\n");
- return False;
+ return false;
}
if (is_readable(cli->tree, fname)) {
d_printf("inaccessible file is readable\n");
- return False;
+ return false;
}
if (!is_visible(cli->tree, fname)) {
d_printf("inaccessible file not visible via normal share\n");
- return False;
+ return false;
}
if (is_visible(hideunread, fname)) {
d_printf("inaccessible file visible via hide unreadable\n");
- return False;
+ return false;
}
if (is_visible(hideunwrite, fname)) {
d_printf("inaccessible file visible via hide unwriteable\n");
- return False;
+ return false;
}
smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR);
smbcli_unlink(cli->tree, fname);
- return True;
+ return true;
}
/*
@@ -274,10 +274,10 @@ BOOL torture_samba3_hide(struct torture_context *torture)
* close. smb_close should return NT_STATUS_ACCESS_DENIED.
*/
-BOOL torture_samba3_closeerr(struct torture_context *tctx)
+bool torture_samba3_closeerr(struct torture_context *tctx)
{
struct smbcli_state *cli = NULL;
- BOOL result = False;
+ bool result = false;
NTSTATUS status;
const char *dname = "closeerr.dir";
const char *fname = "closeerr.dir\\closerr.txt";
@@ -311,7 +311,7 @@ BOOL torture_samba3_closeerr(struct torture_context *tctx)
talloc_asprintf(tctx, "smbcli_open failed: %s\n",
smbcli_errstr(cli->tree)));
- status = smbcli_nt_delete_on_close(cli->tree, fnum, True);
+ status = smbcli_nt_delete_on_close(cli->tree, fnum, true);
torture_assert_ntstatus_ok(tctx, status,
"setting delete_on_close on file failed !");
@@ -329,7 +329,7 @@ BOOL torture_samba3_closeerr(struct torture_context *tctx)
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_ACCESS_DENIED,
"smbcli_close");
- result = True;
+ result = true;
fail:
if (cli) {
diff --git a/source4/torture/raw/samba3misc.c b/source4/torture/raw/samba3misc.c
index e1b1fcaf6d..988405e806 100644
--- a/source4/torture/raw/samba3misc.c
+++ b/source4/torture/raw/samba3misc.c
@@ -25,23 +25,24 @@
#include "libcli/libcli.h"
#include "torture/util.h"
#include "lib/events/events.h"
+#include "param/param.h"
#define CHECK_STATUS(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
} \
} while (0)
-BOOL torture_samba3_checkfsp(struct torture_context *torture)
+bool torture_samba3_checkfsp(struct torture_context *torture)
{
struct smbcli_state *cli;
const char *fname = "test.txt";
const char *dirname = "testdir";
int fnum;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx;
ssize_t nread;
char buf[16];
@@ -49,14 +50,14 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture)
if ((mem_ctx = talloc_init("torture_samba3_checkfsp")) == NULL) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
if (!torture_open_connection_share(
torture, &cli, torture_setting_string(torture, "host", NULL),
torture_setting_string(torture, "share", NULL), NULL)) {
d_printf("torture_open_connection_share failed\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -79,7 +80,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture)
status = smbcli_mkdir(cli->tree, dirname);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
@@ -102,7 +103,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("smb_open on the directory failed: %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
fnum = io.ntcreatex.out.file.fnum;
@@ -114,7 +115,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture)
if (nread >= 0) {
d_printf("smbcli_read on a directory succeeded, expected "
"failure\n");
- ret = False;
+ ret = false;
}
CHECK_STATUS(smbcli_nt_error(cli->tree),
@@ -126,7 +127,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture)
if (nread >= 0) {
d_printf("smbcli_read on a directory succeeded, expected "
"failure\n");
- ret = False;
+ ret = false;
}
CHECK_STATUS(smbcli_nt_error(tree2), NT_STATUS_INVALID_HANDLE);
@@ -139,7 +140,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture)
if (fnum == -1) {
d_printf("Failed to create %s - %s\n", fname,
smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -323,7 +324,7 @@ static NTSTATUS raw_smbcli_ntcreate(struct smbcli_tree *tree, const char *fname,
}
-BOOL torture_samba3_badpath(struct torture_context *torture)
+bool torture_samba3_badpath(struct torture_context *torture)
{
struct smbcli_state *cli_nt;
struct smbcli_state *cli_dos;
@@ -334,18 +335,18 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
char *fpath1;
int fnum;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx;
- BOOL nt_status_support;
+ bool nt_status_support;
if (!(mem_ctx = talloc_init("torture_samba3_badpath"))) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
- nt_status_support = lp_nt_status_support();
+ nt_status_support = lp_nt_status_support(global_loadparm);
- if (!lp_set_cmdline("nt status support", "yes")) {
+ if (!lp_set_cmdline(global_loadparm, "nt status support", "yes")) {
printf("Could not set 'nt status support = yes'\n");
goto fail;
}
@@ -354,7 +355,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
goto fail;
}
- if (!lp_set_cmdline("nt status support", "no")) {
+ if (!lp_set_cmdline(global_loadparm, "nt status support", "no")) {
printf("Could not set 'nt status support = yes'\n");
goto fail;
}
@@ -363,7 +364,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
goto fail;
}
- if (!lp_set_cmdline("nt status support",
+ if (!lp_set_cmdline(global_loadparm, "nt status support",
nt_status_support ? "yes":"no")) {
printf("Could not reset 'nt status support = yes'");
goto fail;
@@ -374,7 +375,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
status = smbcli_mkdir(cli_nt->tree, dirname);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
@@ -585,7 +586,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
goto done;
fail:
- ret = False;
+ ret = false;
done:
if (cli_nt != NULL) {
@@ -607,7 +608,7 @@ static void count_fn(struct clilist_file_info *info, const char *name,
*counter += 1;
}
-BOOL torture_samba3_caseinsensitive(struct torture_context *torture)
+bool torture_samba3_caseinsensitive(struct torture_context *torture)
{
struct smbcli_state *cli;
TALLOC_CTX *mem_ctx;
@@ -618,11 +619,11 @@ BOOL torture_samba3_caseinsensitive(struct torture_context *torture)
char *fpath;
int fnum;
int counter = 0;
- BOOL ret = True;
+ bool ret = true;
if (!(mem_ctx = talloc_init("torture_samba3_caseinsensitive"))) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
if (!torture_open_connection(&cli, 0)) {
@@ -655,11 +656,11 @@ BOOL torture_samba3_caseinsensitive(struct torture_context *torture)
count_fn, (void *)&counter);
if (counter == 3) {
- ret = True;
+ ret = true;
}
else {
d_fprintf(stderr, "expected 3 entries, got %d\n", counter);
- ret = False;
+ ret = false;
}
done:
@@ -672,11 +673,11 @@ BOOL torture_samba3_caseinsensitive(struct torture_context *torture)
* on an underlying file
*/
-BOOL torture_samba3_posixtimedlock(struct torture_context *tctx)
+bool torture_samba3_posixtimedlock(struct torture_context *tctx)
{
struct smbcli_state *cli;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
const char *dirname = "posixlock";
const char *fname = "locked";
const char *fpath;
@@ -692,7 +693,7 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx)
struct smbcli_request *req;
if (!torture_open_connection(&cli, 0)) {
- ret = False;
+ ret = false;
goto done;
}
@@ -702,33 +703,33 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx)
if (!NT_STATUS_IS_OK(status)) {
torture_warning(tctx, "smbcli_mkdir failed: %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
if (!(fpath = talloc_asprintf(tctx, "%s\\%s", dirname, fname))) {
torture_warning(tctx, "talloc failed\n");
- ret = False;
+ ret = false;
goto done;
}
fnum = smbcli_open(cli->tree, fpath, O_RDWR | O_CREAT, DENY_NONE);
if (fnum == -1) {
torture_warning(tctx, "Could not create file %s: %s\n", fpath,
smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
if (!(localdir = torture_setting_string(tctx, "localdir", NULL))) {
torture_warning(tctx, "Need 'localdir' setting\n");
- ret = False;
+ ret = false;
goto done;
}
if (!(localname = talloc_asprintf(tctx, "%s/%s/%s", localdir, dirname,
fname))) {
torture_warning(tctx, "talloc failed\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -750,7 +751,7 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx)
if (fcntl(fd, F_SETLK, &posix_lock) == -1) {
torture_warning(tctx, "fcntl failed: %s\n", strerror(errno));
- ret = False;
+ ret = false;
goto done;
}
@@ -773,7 +774,7 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx)
status = smb_raw_lock(cli->tree, &io);
- ret = True;
+ ret = true;
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
if (!ret) {
@@ -790,7 +791,7 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx)
req = smb_raw_lock_send(cli->tree, &io);
if (req == NULL) {
torture_warning(tctx, "smb_raw_lock_send failed\n");
- ret = False;
+ ret = false;
goto done;
}
@@ -816,3 +817,73 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx)
smbcli_deltree(cli->tree, dirname);
return ret;
}
+
+bool torture_samba3_rootdirfid(struct torture_context *tctx)
+{
+ struct smbcli_state *cli;
+ NTSTATUS status;
+ uint16_t dnum;
+ union smb_open io;
+ const char *fname = "testfile";
+ bool ret = false;
+
+ if (!torture_open_connection(&cli, 0)) {
+ ret = false;
+ goto done;
+ }
+
+ smbcli_unlink(cli->tree, fname);
+
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.access_mask =
+ SEC_STD_SYNCHRONIZE | SEC_FILE_EXECUTE;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
+ io.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ
+ | NTCREATEX_SHARE_ACCESS_READ;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.fname = "\\";
+ status = smb_raw_open(cli->tree, tctx, &io);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("smb_open on the directory failed: %s\n",
+ nt_errstr(status));
+ ret = false;
+ goto done;
+ }
+ dnum = io.ntcreatex.out.file.fnum;
+
+ io.ntcreatex.in.flags =
+ NTCREATEX_FLAGS_REQUEST_OPLOCK
+ | NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
+ io.ntcreatex.in.root_fid = dnum;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.fname = fname;
+
+ status = smb_raw_open(cli->tree, tctx, &io);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("smb_open on the file %s failed: %s\n",
+ fname, nt_errstr(status));
+ ret = false;
+ goto done;
+ }
+
+ smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
+ smbcli_close(cli->tree, dnum);
+ smbcli_unlink(cli->tree, fname);
+
+ ret = true;
+ done:
+ return ret;
+}
+
diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c
index 986da474d0..0242b9c545 100644
--- a/source4/torture/raw/search.c
+++ b/source4/torture/raw/search.c
@@ -30,13 +30,13 @@
/*
callback function for single_search
*/
-static BOOL single_search_callback(void *private, const union smb_search_data *file)
+static bool single_search_callback(void *private, const union smb_search_data *file)
{
- union smb_search_data *data = private;
+ union smb_search_data *data = (union smb_search_data *)private;
*data = *file;
- return True;
+ return true;
}
/*
@@ -231,10 +231,10 @@ static union smb_search_data *find(const char *name)
/*
basic testing of all RAW_SEARCH_* calls using a single file
*/
-static BOOL test_one_file(struct torture_context *tctx,
- struct smbcli_state *cli)
+static bool test_one_file(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
- BOOL ret = True;
+ bool ret = true;
int fnum;
const char *fname = "\\torture_search.txt";
const char *fname2 = "\\torture_search-NOTEXIST.txt";
@@ -243,12 +243,10 @@ static BOOL test_one_file(struct torture_context *tctx,
union smb_fileinfo all_info, alt_info, name_info, internal_info;
union smb_search_data *s;
- printf("Testing one file searches\n");
-
fnum = create_complex_file(cli, tctx, fname);
if (fnum == -1) {
printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -257,7 +255,7 @@ static BOOL test_one_file(struct torture_context *tctx,
NTSTATUS expected_status;
uint32_t cap = cli->transport->negotiate.capabilities;
- printf("testing %s\n", levels[i].name);
+ torture_comment(tctx, "testing %s\n", levels[i].name);
levels[i].status = torture_single_search(cli, tctx, fname,
levels[i].level,
@@ -276,7 +274,7 @@ static BOOL test_one_file(struct torture_context *tctx,
printf("search level %s(%d) failed - %s\n",
levels[i].name, (int)levels[i].level,
nt_errstr(levels[i].status));
- ret = False;
+ ret = false;
continue;
}
@@ -297,7 +295,7 @@ static BOOL test_one_file(struct torture_context *tctx,
levels[i].name, (int)levels[i].level,
nt_errstr(expected_status),
nt_errstr(status));
- ret = False;
+ ret = false;
}
}
@@ -305,38 +303,22 @@ static BOOL test_one_file(struct torture_context *tctx,
all_info.generic.level = RAW_FILEINFO_ALL_INFO;
all_info.generic.in.file.path = fname;
status = smb_raw_pathinfo(cli->tree, tctx, &all_info);
- if (!NT_STATUS_IS_OK(status)) {
- printf("RAW_FILEINFO_ALL_INFO failed - %s\n", nt_errstr(status));
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_ALL_INFO failed");
alt_info.generic.level = RAW_FILEINFO_ALT_NAME_INFO;
alt_info.generic.in.file.path = fname;
status = smb_raw_pathinfo(cli->tree, tctx, &alt_info);
- if (!NT_STATUS_IS_OK(status)) {
- printf("RAW_FILEINFO_ALT_NAME_INFO failed - %s\n", nt_errstr(status));
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_ALT_NAME_INFO failed");
internal_info.generic.level = RAW_FILEINFO_INTERNAL_INFORMATION;
internal_info.generic.in.file.path = fname;
status = smb_raw_pathinfo(cli->tree, tctx, &internal_info);
- if (!NT_STATUS_IS_OK(status)) {
- printf("RAW_FILEINFO_INTERNAL_INFORMATION failed - %s\n", nt_errstr(status));
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_INTERNAL_INFORMATION failed");
name_info.generic.level = RAW_FILEINFO_NAME_INFO;
name_info.generic.in.file.path = fname;
status = smb_raw_pathinfo(cli->tree, tctx, &name_info);
- if (!NT_STATUS_IS_OK(status)) {
- printf("RAW_FILEINFO_NAME_INFO failed - %s\n", nt_errstr(status));
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_NAME_INFO failed");
#define CHECK_VAL(name, sname1, field1, v, sname2, field2) do { \
s = find(name); \
@@ -346,7 +328,7 @@ static BOOL test_one_file(struct torture_context *tctx,
__location__, \
#sname1, #field1, (int)s->sname1.field1, \
#sname2, #field2, (int)v.sname2.out.field2); \
- ret = False; \
+ ret = false; \
} \
}} while (0)
@@ -358,7 +340,7 @@ static BOOL test_one_file(struct torture_context *tctx,
__location__, \
#sname1, #field1, timestring(tctx, s->sname1.field1), \
#sname2, #field2, nt_time_string(tctx, v.sname2.out.field2)); \
- ret = False; \
+ ret = false; \
} \
}} while (0)
@@ -370,7 +352,7 @@ static BOOL test_one_file(struct torture_context *tctx,
__location__, \
#sname1, #field1, nt_time_string(tctx, s->sname1.field1), \
#sname2, #field2, nt_time_string(tctx, v.sname2.out.field2)); \
- ret = False; \
+ ret = false; \
} \
}} while (0)
@@ -382,7 +364,7 @@ static BOOL test_one_file(struct torture_context *tctx,
__location__, \
#sname1, #field1, s->sname1.field1, \
#sname2, #field2, v.sname2.out.field2.s); \
- ret = False; \
+ ret = false; \
} \
}} while (0)
@@ -396,7 +378,7 @@ static BOOL test_one_file(struct torture_context *tctx,
__location__, \
#sname1, #field1, s->sname1.field1.s, \
#sname2, #field2, v.sname2.out.field2.s); \
- ret = False; \
+ ret = false; \
} \
}} while (0)
@@ -410,7 +392,7 @@ static BOOL test_one_file(struct torture_context *tctx,
__location__, \
#sname1, #field1, s->sname1.field1.s, \
fname); \
- ret = False; \
+ ret = false; \
} \
}} while (0)
@@ -423,7 +405,7 @@ static BOOL test_one_file(struct torture_context *tctx,
__location__, \
#sname1, #field1, s->sname1.field1, \
fname); \
- ret = False; \
+ ret = false; \
} \
}} while (0)
@@ -527,9 +509,9 @@ struct multiple_result {
/*
callback function for multiple_search
*/
-static BOOL multiple_search_callback(void *private, const union smb_search_data *file)
+static bool multiple_search_callback(void *private, const union smb_search_data *file)
{
- struct multiple_result *data = private;
+ struct multiple_result *data = (struct multiple_result *)private;
data->count++;
@@ -540,7 +522,7 @@ static BOOL multiple_search_callback(void *private, const union smb_search_data
data->list[data->count-1] = *file;
- return True;
+ return true;
}
enum continue_type {CONT_FLAGS, CONT_NAME, CONT_RESUME_KEY};
@@ -559,7 +541,7 @@ static NTSTATUS multiple_search(struct smbcli_state *cli,
union smb_search_next io2;
NTSTATUS status;
const int per_search = 100;
- struct multiple_result *result = data;
+ struct multiple_result *result = (struct multiple_result *)data;
if (data_level == RAW_SEARCH_DATA_SEARCH) {
io.search_first.level = RAW_SEARCH_SEARCH;
@@ -640,28 +622,11 @@ static NTSTATUS multiple_search(struct smbcli_state *cli,
return status;
}
-#define CHECK_STATUS(status, correct) do { \
- if (!NT_STATUS_EQUAL(status, correct)) { \
- printf("(%s) Incorrect status %s - should be %s\n", \
- __location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
- goto done; \
- }} while (0)
+#define CHECK_STATUS(status, correct) torture_assert_ntstatus_equal(tctx, status, correct, "incorrect status")
-#define CHECK_VALUE(v, correct) do { \
- if ((v) != (correct)) { \
- printf("(%s) Incorrect value %s=%ld - should be %ld\n", \
- __location__, #v, (long)v, (long)correct); \
- ret = False; \
- goto done; \
- }} while (0)
+#define CHECK_VALUE(v, correct) torture_assert_int_equal(tctx, (v), (correct), "incorrect value");
-#define CHECK_STRING(v, correct) do { \
- if (strcasecmp_m(v, correct) != 0) { \
- printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \
- __location__, #v, v, correct); \
- ret = False; \
- }} while (0)
+#define CHECK_STRING(v, correct) torture_assert_casestr_equal(tctx, v, correct, "incorrect value");
static enum smb_search_data_level compare_data_level;
@@ -688,12 +653,12 @@ static int search_compare(union smb_search_data *d1, union smb_search_data *d2)
basic testing of search calls using many files
*/
static bool test_many_files(struct torture_context *tctx,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
const int num_files = 700;
int i, fnum, t;
char *fname;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
struct multiple_result result;
struct {
@@ -727,19 +692,15 @@ static bool test_many_files(struct torture_context *tctx,
};
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
- printf("Testing with %d files\n", num_files);
+ torture_comment(tctx, "Testing with %d files\n", num_files);
for (i=0;i<num_files;i++) {
fname = talloc_asprintf(cli, BASEDIR "\\t%03d-%d.txt", i, i);
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
- goto done;
- }
+ torture_assert(tctx, fnum != -1, "Failed to create");
talloc_free(fname);
smbcli_close(cli->tree, fnum);
}
@@ -749,20 +710,15 @@ static bool test_many_files(struct torture_context *tctx,
ZERO_STRUCT(result);
result.tctx = talloc_new(tctx);
- printf("Continue %s via %s\n", search_types[t].name, search_types[t].cont_name);
+ torture_comment(tctx,
+ "Continue %s via %s\n", search_types[t].name, search_types[t].cont_name);
status = multiple_search(cli, tctx, BASEDIR "\\*.*",
search_types[t].data_level,
search_types[t].cont_type,
&result);
- if (!NT_STATUS_IS_OK(status)) {
- printf("search type %s failed - %s\n",
- search_types[t].name,
- nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "search failed");
CHECK_VALUE(result.count, num_files);
compare_data_level = search_types[t].data_level;
@@ -780,17 +736,12 @@ static bool test_many_files(struct torture_context *tctx,
}
s = extract_name(&result.list[i], level, compare_data_level);
fname = talloc_asprintf(cli, "t%03d-%d.txt", i, i);
- if (strcmp(fname, s)) {
- printf("Incorrect name %s at entry %d\n", s, i);
- ret = False;
- break;
- }
+ torture_assert_str_equal(tctx, fname, s, "Incorrect name");
talloc_free(fname);
}
talloc_free(result.tctx);
}
-done:
smb_raw_exit(cli->session);
smbcli_deltree(cli->tree, BASEDIR);
@@ -800,7 +751,7 @@ done:
/*
check a individual file result
*/
-static BOOL check_result(struct multiple_result *result, const char *name, BOOL exist, uint32_t attrib)
+static bool check_result(struct multiple_result *result, const char *name, bool exist, uint32_t attrib)
{
int i;
for (i=0;i<result->count;i++) {
@@ -810,24 +761,24 @@ static BOOL check_result(struct multiple_result *result, const char *name, BOOL
if (exist) {
printf("failed: '%s' should exist with attribute %s\n",
name, attrib_string(result->list, attrib));
- return False;
+ return false;
}
- return True;
+ return true;
}
if (!exist) {
printf("failed: '%s' should NOT exist (has attribute %s)\n",
name, attrib_string(result->list, result->list[i].both_directory_info.attrib));
- return False;
+ return false;
}
if ((result->list[i].both_directory_info.attrib&0xFFF) != attrib) {
printf("failed: '%s' should have attribute 0x%x (has 0x%x)\n",
name,
attrib, result->list[i].both_directory_info.attrib);
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
@@ -839,7 +790,7 @@ static bool test_modify_search(struct torture_context *tctx,
const int num_files = 20;
int i, fnum;
char *fname;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
struct multiple_result result;
union smb_search_first io;
@@ -847,7 +798,7 @@ static bool test_modify_search(struct torture_context *tctx,
union smb_setfileinfo sfinfo;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Creating %d files\n", num_files);
@@ -857,7 +808,7 @@ static bool test_modify_search(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
talloc_free(fname);
@@ -925,16 +876,16 @@ static bool test_modify_search(struct torture_context *tctx,
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(result.count, 20);
- ret &= check_result(&result, "t009-9.txt", True, FILE_ATTRIBUTE_ARCHIVE);
- ret &= check_result(&result, "t014-14.txt", False, 0);
- ret &= check_result(&result, "t015-15.txt", False, 0);
- ret &= check_result(&result, "t016-16.txt", True, FILE_ATTRIBUTE_NORMAL);
- ret &= check_result(&result, "t017-17.txt", False, 0);
- ret &= check_result(&result, "t018-18.txt", True, FILE_ATTRIBUTE_ARCHIVE);
- ret &= check_result(&result, "t019-19.txt", True, FILE_ATTRIBUTE_ARCHIVE);
- ret &= check_result(&result, "T013-13.txt.2", True, FILE_ATTRIBUTE_ARCHIVE);
- ret &= check_result(&result, "T003-3.txt.2", False, 0);
- ret &= check_result(&result, "T013-13.txt.3", True, FILE_ATTRIBUTE_ARCHIVE);
+ ret &= check_result(&result, "t009-9.txt", true, FILE_ATTRIBUTE_ARCHIVE);
+ ret &= check_result(&result, "t014-14.txt", false, 0);
+ ret &= check_result(&result, "t015-15.txt", false, 0);
+ ret &= check_result(&result, "t016-16.txt", true, FILE_ATTRIBUTE_NORMAL);
+ ret &= check_result(&result, "t017-17.txt", false, 0);
+ ret &= check_result(&result, "t018-18.txt", true, FILE_ATTRIBUTE_ARCHIVE);
+ ret &= check_result(&result, "t019-19.txt", true, FILE_ATTRIBUTE_ARCHIVE);
+ ret &= check_result(&result, "T013-13.txt.2", true, FILE_ATTRIBUTE_ARCHIVE);
+ ret &= check_result(&result, "T003-3.txt.2", false, 0);
+ ret &= check_result(&result, "T013-13.txt.3", true, FILE_ATTRIBUTE_ARCHIVE);
if (!ret) {
for (i=0;i<result.count;i++) {
@@ -961,12 +912,12 @@ static bool test_sorted(struct torture_context *tctx, struct smbcli_state *cli)
const int num_files = 700;
int i, fnum;
char *fname;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
struct multiple_result result;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Creating %d files\n", num_files);
@@ -976,7 +927,7 @@ static bool test_sorted(struct torture_context *tctx, struct smbcli_state *cli)
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
talloc_free(fname);
@@ -1025,12 +976,12 @@ static bool test_many_dirs(struct torture_context *tctx,
const int num_dirs = 20;
int i, fnum, n;
char *fname, *dname;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_search_data *file, *file2, *file3;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Creating %d dirs\n", num_dirs);
@@ -1041,7 +992,7 @@ static bool test_many_dirs(struct torture_context *tctx,
if (!NT_STATUS_IS_OK(status)) {
printf("(%s) Failed to create %s - %s\n",
__location__, dname, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
@@ -1051,7 +1002,7 @@ static bool test_many_dirs(struct torture_context *tctx,
if (fnum == -1) {
printf("(%s) Failed to create %s - %s\n",
__location__, fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
talloc_free(fname);
@@ -1083,14 +1034,14 @@ static bool test_many_dirs(struct torture_context *tctx,
if (io.search_first.out.count != 1) {
printf("(%s) search first gave %d entries for dir %d - %s\n",
__location__, io.search_first.out.count, i, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
if (strncasecmp(file[i].search.name, fname, strlen(fname)) != 0) {
printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
__location__, file[i].search.name, fname);
- ret = False;
+ ret = false;
goto done;
}
@@ -1116,14 +1067,14 @@ static bool test_many_dirs(struct torture_context *tctx,
if (io2.search_next.out.count != 1) {
printf("(%s) search next gave %d entries for dir %d - %s\n",
__location__, io2.search_next.out.count, i, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
if (strncasecmp(file2[i].search.name, fname, strlen(fname)) != 0) {
printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
__location__, file2[i].search.name, fname);
- ret = False;
+ ret = false;
goto done;
}
@@ -1149,7 +1100,7 @@ static bool test_many_dirs(struct torture_context *tctx,
if (io2.search_next.out.count != 1) {
printf("(%s) search next gave %d entries for dir %d - %s\n",
__location__, io2.search_next.out.count, i, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
@@ -1157,14 +1108,14 @@ static bool test_many_dirs(struct torture_context *tctx,
if (strncasecmp(file3[i].search.name, file2[i].search.name, 3) != 0) {
printf("(%s) incorrect name '%s' on rewind at dir %d\n",
__location__, file2[i].search.name, i);
- ret = False;
+ ret = false;
goto done;
}
if (strcmp(file3[i].search.name, file2[i].search.name) != 0) {
printf("(%s) server did not rewind - got '%s' expected '%s'\n",
__location__, file3[i].search.name, file2[i].search.name);
- ret = False;
+ ret = false;
goto done;
}
@@ -1191,14 +1142,14 @@ static bool test_os2_delete(struct torture_context *tctx,
int total_deleted = 0;
int i, fnum;
char *fname;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_search_first io;
union smb_search_next io2;
struct multiple_result result;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing OS/2 style delete on %d files\n", num_files);
@@ -1208,7 +1159,7 @@ static bool test_os2_delete(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
talloc_free(fname);
@@ -1276,7 +1227,7 @@ static bool test_os2_delete(struct torture_context *tctx,
if (total_deleted != num_files) {
printf("error: deleted %d - expected to delete %d\n",
total_deleted, num_files);
- ret = False;
+ ret = false;
}
done:
@@ -1299,7 +1250,7 @@ static bool test_ea_list(struct torture_context *tctx,
struct smbcli_state *cli)
{
int fnum;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
union smb_search_first io;
union smb_search_next nxt;
@@ -1307,7 +1258,7 @@ static bool test_ea_list(struct torture_context *tctx,
union smb_setfileinfo setfile;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_SEARCH_EA_LIST level\n");
@@ -1402,7 +1353,6 @@ static bool test_ea_list(struct torture_context *tctx,
CHECK_STRING(result.list[2].ea_list.eas.eas[1].name.s, "THIRD EA");
CHECK_VALUE(result.list[2].ea_list.eas.eas[1].value.length, 0);
-done:
smb_raw_exit(cli->session);
smbcli_deltree(cli->tree, BASEDIR);
@@ -1418,7 +1368,7 @@ struct torture_suite *torture_raw_search(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "SEARCH");
- torture_suite_add_1smb_test(suite, "one file", test_one_file);
+ torture_suite_add_1smb_test(suite, "one file search", test_one_file);
torture_suite_add_1smb_test(suite, "many files", test_many_files);
torture_suite_add_1smb_test(suite, "sorted", test_sorted);
torture_suite_add_1smb_test(suite, "modify search", test_modify_search);
diff --git a/source4/torture/raw/seek.c b/source4/torture/raw/seek.c
index f5413d8b1d..3ba022feef 100644
--- a/source4/torture/raw/seek.c
+++ b/source4/torture/raw/seek.c
@@ -28,7 +28,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%d) Incorrect status %s - should be %s\n", \
__LINE__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -36,7 +36,7 @@
if ((v) != (correct)) { \
printf("(%d) Incorrect value %s=%d - should be %d\n", \
__LINE__, #v, (int)v, (int)correct); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -45,25 +45,25 @@
/*
test seek ops
*/
-static BOOL test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
union smb_seek io;
union smb_fileinfo finfo;
union smb_setfileinfo sfinfo;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum, fnum2;
const char *fname = BASEDIR "\\test.txt";
uint8_t c[2];
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
if (fnum == -1) {
printf("Failed to open test.txt - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -142,7 +142,7 @@ static BOOL test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
ZERO_STRUCT(c);
if (smbcli_write(cli->tree, fnum, 0, c, 0, 2) != 2) {
printf("Write failed - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -162,7 +162,7 @@ static BOOL test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
if (smbcli_read(cli->tree, fnum, c, 0, 1) != 1) {
printf("Read failed - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -181,7 +181,7 @@ static BOOL test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
printf("2nd open failed - %s\n", smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
sfinfo.generic.level = RAW_SFILEINFO_POSITION_INFORMATION;
diff --git a/source4/torture/raw/setfileinfo.c b/source4/torture/raw/setfileinfo.c
index b06a04753f..e58b3fd760 100644
--- a/source4/torture/raw/setfileinfo.c
+++ b/source4/torture/raw/setfileinfo.c
@@ -23,6 +23,7 @@
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
#include "torture/util.h"
+#include "torture/raw/proto.h"
#define BASEDIR "\\testsfileinfo"
@@ -31,10 +32,10 @@
for consistency between the calls.
*/
bool torture_raw_sfileinfo(struct torture_context *torture,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
- BOOL ret = True;
- int fnum_saved, d_fnum, fnum2, fnum = -1;
+ bool ret = true;
+ int fnum = -1;
char *fnum_fname;
char *fnum_fname_new;
char *path_fname;
@@ -44,7 +45,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
NTSTATUS status, status2;
const char *call_name;
time_t basetime = (time(NULL) - 86400) & ~1;
- BOOL check_fnum;
+ bool check_fnum;
int n = time(NULL) % 100;
asprintf(&path_fname, BASEDIR "\\fname_test_%d.txt", n);
@@ -53,7 +54,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
asprintf(&fnum_fname_new, BASEDIR "\\fnum_test_new_%d.txt", n);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
#define RECREATE_FILE(fname) do { \
@@ -62,7 +63,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
if (fnum == -1) { \
printf("(%s) ERROR: open of %s failed (%s)\n", \
__location__, fname, smbcli_errstr(cli->tree)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -75,7 +76,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
RECREATE_BOTH;
#define CHECK_CALL_FNUM(call, rightstatus) do { \
- check_fnum = True; \
+ check_fnum = true; \
call_name = #call; \
sfinfo.generic.level = RAW_SFILEINFO_ ## call; \
sfinfo.generic.in.file.fnum = fnum; \
@@ -83,18 +84,18 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
if (!NT_STATUS_EQUAL(status, rightstatus)) { \
printf("(%s) %s - %s (should be %s)\n", __location__, #call, \
nt_errstr(status), nt_errstr(rightstatus)); \
- ret = False; \
+ ret = false; \
} \
finfo1.generic.level = RAW_FILEINFO_ALL_INFO; \
finfo1.generic.in.file.fnum = fnum; \
status2 = smb_raw_fileinfo(cli->tree, torture, &finfo1); \
if (!NT_STATUS_IS_OK(status2)) { \
printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status)); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_CALL_PATH(call, rightstatus) do { \
- check_fnum = False; \
+ check_fnum = false; \
call_name = #call; \
sfinfo.generic.level = RAW_SFILEINFO_ ## call; \
sfinfo.generic.in.file.path = path_fname; \
@@ -106,7 +107,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
if (!NT_STATUS_EQUAL(status, rightstatus)) { \
printf("(%s) %s - %s (should be %s)\n", __location__, #call, \
nt_errstr(status), nt_errstr(rightstatus)); \
- ret = False; \
+ ret = false; \
} \
finfo1.generic.level = RAW_FILEINFO_ALL_INFO; \
finfo1.generic.in.file.path = path_fname; \
@@ -117,7 +118,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
} \
if (!NT_STATUS_IS_OK(status2)) { \
printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status2)); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK1(call) \
@@ -136,7 +137,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
} \
if (!NT_STATUS_IS_OK(status2)) { \
printf("%s - %s\n", #call, nt_errstr(status2)); \
- ret = False; \
+ ret = false; \
} \
}} while (0)
@@ -147,7 +148,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
call_name, #stype, #field, \
(uint_t)value, (uint_t)finfo2.stype.out.field); \
dump_all_info(torture, &finfo1); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_TIME(call, stype, field, value) do { \
@@ -160,7 +161,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
printf("\t%s", timestring(torture, value)); \
printf("\t%s\n", nt_time_string(torture, finfo2.stype.out.field)); \
dump_all_info(torture, &finfo1); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_STR(call, stype, field, value) do { \
@@ -171,14 +172,14 @@ bool torture_raw_sfileinfo(struct torture_context *torture,
value, \
finfo2.stype.out.field); \
dump_all_info(torture, &finfo1); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_STATUS(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -446,7 +447,7 @@ done:
bool torture_raw_sfileinfo_rename(struct torture_context *torture,
struct smbcli_state *cli)
{
- BOOL ret = True;
+ bool ret = true;
int fnum_saved, d_fnum, fnum2, fnum = -1;
char *fnum_fname;
char *fnum_fname_new;
@@ -456,7 +457,7 @@ bool torture_raw_sfileinfo_rename(struct torture_context *torture,
union smb_setfileinfo sfinfo;
NTSTATUS status, status2;
const char *call_name;
- BOOL check_fnum;
+ bool check_fnum;
int n = time(NULL) % 100;
asprintf(&path_fname, BASEDIR "\\fname_test_%d.txt", n);
@@ -465,7 +466,7 @@ bool torture_raw_sfileinfo_rename(struct torture_context *torture,
asprintf(&fnum_fname_new, BASEDIR "\\fnum_test_new_%d.txt", n);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
RECREATE_BOTH;
@@ -596,5 +597,5 @@ bool torture_raw_sfileinfo_bug(struct torture_context *torture,
printf("now try and delete %s\n", fname);
- return True;
+ return true;
}
diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c
index 24428efcf7..14d674e482 100644
--- a/source4/torture/raw/streams.c
+++ b/source4/torture/raw/streams.c
@@ -32,7 +32,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -40,13 +40,13 @@
if ((v) != (correct)) { \
printf("(%s) Incorrect value %s=%d - should be %d\n", \
__location__, #v, (int)v, (int)correct); \
- ret = False; \
+ ret = false; \
}} while (0)
/*
check that a stream has the right contents
*/
-static BOOL check_stream(struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
+static bool check_stream(struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
const char *fname, const char *sname,
const char *value)
{
@@ -62,45 +62,45 @@ static BOOL check_stream(struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
if (value == NULL) {
if (fnum != -1) {
printf("should have failed stream open of %s\n", full_name);
- return False;
+ return false;
}
- return True;
+ return true;
}
if (fnum == -1) {
printf("Failed to open stream '%s' - %s\n",
full_name, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
- buf = talloc_size(mem_ctx, strlen(value)+11);
+ buf = talloc_array(mem_ctx, uint8_t, strlen(value)+11);
ret = smbcli_read(cli->tree, fnum, buf, 0, strlen(value)+11);
if (ret != strlen(value)) {
printf("Failed to read %lu bytes from stream '%s' - got %d\n",
(long)strlen(value), full_name, (int)ret);
- return False;
+ return false;
}
if (memcmp(buf, value, strlen(value)) != 0) {
printf("Bad data in stream\n");
- return False;
+ return false;
}
smbcli_close(cli->tree, fnum);
- return True;
+ return true;
}
/*
test basic io on streams
*/
-static BOOL test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
union smb_open io;
const char *fname = BASEDIR "\\stream.txt";
const char *sname1, *sname2;
- BOOL ret = True;
+ bool ret = true;
int fnum = -1;
ssize_t retsize;
@@ -214,12 +214,12 @@ done:
basic testing of streams calls
*/
bool torture_raw_streams(struct torture_context *torture,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
- BOOL ret = True;
+ bool ret = true;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
ret &= test_stream_io(cli, torture);
diff --git a/source4/torture/raw/unlink.c b/source4/torture/raw/unlink.c
index c307b14e08..b9043a5899 100644
--- a/source4/torture/raw/unlink.c
+++ b/source4/torture/raw/unlink.c
@@ -23,12 +23,13 @@
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
#include "torture/util.h"
+#include "param/param.h"
#define CHECK_STATUS(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -41,11 +42,11 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli)
{
union smb_unlink io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
const char *fname = BASEDIR "\\test.txt";
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Trying non-existant file\n");
@@ -128,7 +129,7 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli)
io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
status = smb_raw_unlink(cli->tree, &io);
- if (lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
/*
* In Samba3 we gave up upon getting the error codes in
* wildcard unlink correct. Trying gentest showed that this is
@@ -156,7 +157,7 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli)
io.unlink.in.pattern = BASEDIR "\\t*";
io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
status = smb_raw_unlink(cli->tree, &io);
- if (lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
}
else {
@@ -168,7 +169,7 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli)
io.unlink.in.pattern = BASEDIR "\\*.dat";
io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
status = smb_raw_unlink(cli->tree, &io);
- if (lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
}
else {
@@ -178,7 +179,7 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli)
io.unlink.in.pattern = BASEDIR "\\*.tx?";
io.unlink.in.attrib = 0;
status = smb_raw_unlink(cli->tree, &io);
- if (lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
}
else {
@@ -206,7 +207,7 @@ static bool test_delete_on_close(struct torture_context *tctx,
union smb_unlink io;
struct smb_rmdir dio;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum, fnum2;
const char *fname = BASEDIR "\\test.txt";
const char *dname = BASEDIR "\\test.dir";
@@ -214,7 +215,7 @@ static bool test_delete_on_close(struct torture_context *tctx,
union smb_setfileinfo sfinfo;
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
dio.in.path = dname;
@@ -281,7 +282,7 @@ static bool test_delete_on_close(struct torture_context *tctx,
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
- if (!lp_parm_bool(-1, "torture", "samba3", False)) {
+ if (!lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) {
/*
* Known deficiency, also skipped in base-delete.
@@ -439,8 +440,7 @@ done:
*/
struct torture_suite *torture_raw_unlink(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(mem_ctx,
- "UNLINK");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "UNLINK");
torture_suite_add_1smb_test(suite, "unlink", test_unlink);
torture_suite_add_1smb_test(suite, "delete_on_close", test_delete_on_close);
diff --git a/source4/torture/raw/write.c b/source4/torture/raw/write.c
index b704a19ed6..98a0dde8c7 100644
--- a/source4/torture/raw/write.c
+++ b/source4/torture/raw/write.c
@@ -30,7 +30,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -38,13 +38,13 @@
if ((v) != (correct)) { \
printf("(%s) Incorrect value %s=%d - should be %d\n", \
__location__, #v, v, correct); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
#define CHECK_BUFFER(buf, seed, len) do { \
if (!check_buffer(buf, seed, len, __location__)) { \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -57,7 +57,7 @@
printf("(%s) wrong value for field %s %.0f - %.0f\n", \
__location__, #field, (double)v, (double)finfo.all_info.out.field); \
dump_all_info(tctx, &finfo); \
- ret = False; \
+ ret = false; \
}} while (0)
@@ -77,7 +77,7 @@ static void setup_buffer(uint8_t *buf, uint_t seed, int len)
/*
check a random buffer based on a seed
*/
-static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, const char *location)
+static bool check_buffer(uint8_t *buf, uint_t seed, int len, const char *location)
{
int i;
srandom(seed);
@@ -86,10 +86,10 @@ static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, const char *locatio
if (buf[i] != v) {
printf("Buffer incorrect at %s! ofs=%d buf=0x%x correct=0x%x\n",
location, i, buf[i], v);
- return False;
+ return false;
}
}
- return True;
+ return true;
}
/*
@@ -100,7 +100,7 @@ static bool test_write(struct torture_context *tctx,
{
union smb_write io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
uint8_t *buf;
const int maxsize = 90000;
@@ -108,10 +108,10 @@ static bool test_write(struct torture_context *tctx,
uint_t seed = time(NULL);
union smb_fileinfo finfo;
- buf = talloc_zero_size(tctx, maxsize);
+ buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_WRITE_WRITE\n");
@@ -120,7 +120,7 @@ static bool test_write(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -147,7 +147,7 @@ static bool test_write(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf+4, seed, 9);
@@ -166,7 +166,7 @@ static bool test_write(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf, seed, 4000);
@@ -207,7 +207,7 @@ static bool test_write(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf, seed, 4000);
@@ -228,7 +228,7 @@ static bool test_writex(struct torture_context *tctx,
{
union smb_write io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum, i;
uint8_t *buf;
const int maxsize = 90000;
@@ -242,10 +242,10 @@ static bool test_writex(struct torture_context *tctx,
torture_comment(tctx, "dangerous not set - limiting range of test to 2^%d\n", max_bits);
}
- buf = talloc_zero_size(tctx, maxsize);
+ buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_WRITE_WRITEX\n");
@@ -254,7 +254,7 @@ static bool test_writex(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -282,7 +282,7 @@ static bool test_writex(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf+4, seed, 9);
@@ -301,7 +301,7 @@ static bool test_writex(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf, seed, 4000);
@@ -334,7 +334,7 @@ static bool test_writex(struct torture_context *tctx,
cli->session->pid++;
if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 3, 1, 0, WRITE_LOCK))) {
printf("Failed to lock file at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
cli->session->pid--;
@@ -367,7 +367,7 @@ static bool test_writex(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf, seed, 4000);
@@ -391,7 +391,7 @@ static bool test_writex(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf, seed+1, 4000);
@@ -416,7 +416,7 @@ static bool test_writeunlock(struct torture_context *tctx,
{
union smb_write io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
uint8_t *buf;
const int maxsize = 90000;
@@ -424,10 +424,10 @@ static bool test_writeunlock(struct torture_context *tctx,
uint_t seed = time(NULL);
union smb_fileinfo finfo;
- buf = talloc_zero_size(tctx, maxsize);
+ buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_WRITE_WRITEUNLOCK\n");
@@ -436,7 +436,7 @@ static bool test_writeunlock(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -460,7 +460,7 @@ static bool test_writeunlock(struct torture_context *tctx,
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf+4, seed, 9);
@@ -476,7 +476,7 @@ static bool test_writeunlock(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf+4, seed, 9);
@@ -500,7 +500,7 @@ static bool test_writeunlock(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf, seed, 4000);
@@ -538,7 +538,7 @@ static bool test_writeunlock(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, io.writeunlock.in.offset, 4000) != 4000) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf, seed, 4000);
@@ -559,7 +559,7 @@ static bool test_writeclose(struct torture_context *tctx,
{
union smb_write io;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int fnum;
uint8_t *buf;
const int maxsize = 90000;
@@ -567,10 +567,10 @@ static bool test_writeclose(struct torture_context *tctx,
uint_t seed = time(NULL);
union smb_fileinfo finfo;
- buf = talloc_zero_size(tctx, maxsize);
+ buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
printf("Testing RAW_WRITE_WRITECLOSE\n");
@@ -579,7 +579,7 @@ static bool test_writeclose(struct torture_context *tctx,
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
+ ret = false;
goto done;
}
@@ -614,7 +614,7 @@ static bool test_writeclose(struct torture_context *tctx,
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf+4, seed, 9);
@@ -631,7 +631,7 @@ static bool test_writeclose(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf+4, seed, 9);
@@ -656,7 +656,7 @@ static bool test_writeclose(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf, seed, 4000);
@@ -695,7 +695,7 @@ static bool test_writeclose(struct torture_context *tctx,
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, io.writeclose.in.offset, 4000) != 4000) {
printf("read failed at %s\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
CHECK_BUFFER(buf, seed, 4000);
diff --git a/source4/torture/rpc/alter_context.c b/source4/torture/rpc/alter_context.c
index 6dd0b40d7b..7843713074 100644
--- a/source4/torture/rpc/alter_context.c
+++ b/source4/torture/rpc/alter_context.c
@@ -28,86 +28,59 @@
bool torture_rpc_alter_context(struct torture_context *torture)
{
- NTSTATUS status;
- struct dcerpc_pipe *p, *p2;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ NTSTATUS status;
+ struct dcerpc_pipe *p, *p2, *p3;
struct policy_handle *handle;
struct ndr_interface_table tmptbl;
struct ndr_syntax_id syntax;
struct ndr_syntax_id transfer_syntax;
-
- mem_ctx = talloc_init("torture_rpc_alter_context");
+ bool ret = true;
torture_comment(torture, "opening LSA connection\n");
status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- return False;
- }
+ torture_assert_ntstatus_ok(torture, status, "connecting");
- if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
+ ret = false;
}
torture_comment(torture, "Opening secondary DSSETUP context\n");
status = dcerpc_secondary_context(p, &p2, &ndr_table_dssetup);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- torture_comment(torture, "dcerpc_alter_context failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed");
tmptbl = ndr_table_dssetup;
tmptbl.syntax_id.if_version += 100;
torture_comment(torture, "Opening bad secondary connection\n");
- status = dcerpc_secondary_context(p, &p2, &tmptbl);
- if (NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- torture_comment(torture, "dcerpc_alter_context with wrong version should fail\n");
- return False;
- }
+ status = dcerpc_secondary_context(p, &p3, &tmptbl);
+ torture_assert_ntstatus_equal(torture, status, NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX,
+ "dcerpc_alter_context with wrong version should fail");
torture_comment(torture, "testing DSSETUP pipe operations\n");
- ret &= test_DsRoleGetPrimaryDomainInformation(p2, mem_ctx);
+ ret &= test_DsRoleGetPrimaryDomainInformation(torture, p2);
if (handle) {
- if (!test_lsa_Close(p, mem_ctx, handle)) {
- ret = False;
- }
+ ret &= test_lsa_Close(p, torture, handle);
}
syntax = p->syntax;
transfer_syntax = p->transfer_syntax;
torture_comment(torture, "Testing change of primary context\n");
- status = dcerpc_alter_context(p, mem_ctx, &p2->syntax, &p2->transfer_syntax);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- torture_comment(torture, "dcerpc_alter_context failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_alter_context(p, torture, &p2->syntax, &p2->transfer_syntax);
+ torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed");
torture_comment(torture, "testing DSSETUP pipe operations - should fault\n");
- if (test_DsRoleGetPrimaryDomainInformation(p, mem_ctx)) {
- ret = False;
- }
+ ret &= test_DsRoleGetPrimaryDomainInformation_ext(torture, p, NT_STATUS_NET_WRITE_FAULT);
- if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
- ret = False;
- }
+ ret &= test_lsa_OpenPolicy2(p, torture, &handle);
if (handle) {
- if (!test_lsa_Close(p, mem_ctx, handle)) {
- ret = False;
- }
+ ret &= test_lsa_Close(p, torture, handle);
}
torture_comment(torture, "testing DSSETUP pipe operations\n");
- ret &= test_DsRoleGetPrimaryDomainInformation(p2, mem_ctx);
-
- talloc_free(mem_ctx);
+ ret &= test_DsRoleGetPrimaryDomainInformation(torture, p2);
return ret;
}
diff --git a/source4/torture/rpc/async_bind.c b/source4/torture/rpc/async_bind.c
index 155f3f8244..70743bd433 100644
--- a/source4/torture/rpc/async_bind.c
+++ b/source4/torture/rpc/async_bind.c
@@ -35,7 +35,7 @@
*/
-BOOL torture_async_bind(struct torture_context *torture)
+bool torture_async_bind(struct torture_context *torture)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx;
@@ -49,30 +49,30 @@ BOOL torture_async_bind(struct torture_context *torture)
struct dcerpc_pipe **pipe;
const struct ndr_interface_table **table;
- if (!torture_setting_bool(torture, "async", False)) {
+ if (!torture_setting_bool(torture, "async", false)) {
printf("async bind test disabled - enable async tests to use\n");
- return True;
+ return true;
}
binding_string = torture_setting_string(torture, "binding", NULL);
/* talloc context */
mem_ctx = talloc_init("torture_async_bind");
- if (mem_ctx == NULL) return False;
+ if (mem_ctx == NULL) return false;
bind_req = talloc_array(torture, struct composite_context*, torture_numasync);
- if (bind_req == NULL) return False;
+ if (bind_req == NULL) return false;
pipe = talloc_array(torture, struct dcerpc_pipe*, torture_numasync);
- if (pipe == NULL) return False;
+ if (pipe == NULL) return false;
table = talloc_array(torture, const struct ndr_interface_table*, torture_numasync);
- if (table == NULL) return False;
+ if (table == NULL) return false;
/* credentials */
creds = cmdline_credentials;
/* event context */
evt_ctx = cli_credentials_get_event_context(creds);
- if (evt_ctx == NULL) return False;
+ if (evt_ctx == NULL) return false;
/* send bind requests */
for (i = 0; i < torture_numasync; i++) {
@@ -86,10 +86,10 @@ BOOL torture_async_bind(struct torture_context *torture)
status = dcerpc_pipe_connect_recv(bind_req[i], mem_ctx, &pipe[i]);
if (!NT_STATUS_IS_OK(status)) {
printf("async rpc connection failed: %s\n", nt_errstr(status));
- return False;
+ return false;
}
}
talloc_free(mem_ctx);
- return True;
+ return true;
}
diff --git a/source4/torture/rpc/atsvc.c b/source4/torture/rpc/atsvc.c
index f5295cc6cc..b0d1d1519d 100644
--- a/source4/torture/rpc/atsvc.c
+++ b/source4/torture/rpc/atsvc.c
@@ -76,7 +76,7 @@ static bool test_JobEnum(struct torture_context *tctx, struct dcerpc_pipe *p)
for (i = 0; i < r.out.ctr->entries_read; i++) {
if (!test_JobGetInfo(p, tctx, r.out.ctr->first_entry[i].job_id)) {
- ret = False;
+ ret = false;
}
}
@@ -118,15 +118,12 @@ static bool test_JobAdd(struct torture_context *tctx, struct dcerpc_pipe *p)
return true;
}
-struct torture_suite *torture_rpc_atsvc(void)
+struct torture_suite *torture_rpc_atsvc(TALLOC_CTX *mem_ctx)
{
- struct torture_suite *suite = torture_suite_create(
- talloc_autofree_context(),
- "ATSVC");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "ATSVC");
struct torture_rpc_tcase *tcase;
- tcase = torture_suite_add_rpc_iface_tcase(suite, "atsvc",
- &ndr_table_atsvc);
+ tcase = torture_suite_add_rpc_iface_tcase(suite, "atsvc", &ndr_table_atsvc);
torture_rpc_tcase_add_test(tcase, "JobEnum", test_JobEnum);
torture_rpc_tcase_add_test(tcase, "JobAdd", test_JobAdd);
diff --git a/source4/torture/rpc/autoidl.c b/source4/torture/rpc/autoidl.c
index 76d838517c..9343734413 100644
--- a/source4/torture/rpc/autoidl.c
+++ b/source4/torture/rpc/autoidl.c
@@ -31,7 +31,7 @@
/*
get a DRSUAPI policy handle
*/
-static BOOL get_policy_handle(struct dcerpc_pipe *p,
+static bool get_policy_handle(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -44,16 +44,16 @@ static BOOL get_policy_handle(struct dcerpc_pipe *p,
status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("drsuapi_DsBind failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
#else
/*
get a SAMR handle
*/
-static BOOL get_policy_handle(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool get_policy_handle(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -66,10 +66,10 @@ static BOOL get_policy_handle(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Connect(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("samr_Connect failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
#endif
@@ -95,8 +95,7 @@ static void reopen(TALLOC_CTX *mem_ctx,
talloc_free(*p);
- status = torture_rpc_connection(mem_ctx,
- p, iface);
+ status = torture_rpc_connection(mem_ctx, p, iface);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to reopen '%s' - %s\n", iface->name, nt_errstr(status));
exit(1);
@@ -131,7 +130,7 @@ static void try_expand(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *if
memcpy(stub_in.data, base_in->data, insert_ofs);
memcpy(stub_in.data+insert_ofs+n, base_in->data+insert_ofs, base_in->length-insert_ofs);
- status = dcerpc_request(p, NULL, opnum, False, mem_ctx, &stub_in, &stub_out);
+ status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out);
if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
print_depth(depth);
@@ -172,7 +171,7 @@ static void test_ptr_scan(TALLOC_CTX *mem_ctx, const struct ndr_interface_table
/* work out which elements are pointers */
for (ofs=min_ofs;ofs<=max_ofs-4;ofs+=4) {
SIVAL(stub_in.data, ofs, 1);
- status = dcerpc_request(p, NULL, opnum, False, mem_ctx, &stub_in, &stub_out);
+ status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out);
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
print_depth(depth);
@@ -214,7 +213,7 @@ static void test_scan_call(TALLOC_CTX *mem_ctx, const struct ndr_interface_table
data_blob_clear(&stub_in);
- status = dcerpc_request(p, NULL, opnum, False, mem_ctx, &stub_in, &stub_out);
+ status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out);
if (NT_STATUS_IS_OK(status)) {
printf("opnum %d min_input %d - output %d\n",
@@ -227,7 +226,7 @@ static void test_scan_call(TALLOC_CTX *mem_ctx, const struct ndr_interface_table
fill_blob_handle(&stub_in, mem_ctx, &handle);
- status = dcerpc_request(p, NULL, opnum, False, mem_ctx, &stub_in, &stub_out);
+ status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out);
if (NT_STATUS_IS_OK(status)) {
printf("opnum %d min_input %d - output %d (with handle)\n",
@@ -259,7 +258,7 @@ static void test_auto_scan(TALLOC_CTX *mem_ctx, const struct ndr_interface_table
test_scan_call(mem_ctx, iface, 2);
}
-BOOL torture_rpc_autoidl(struct torture_context *torture)
+bool torture_rpc_autoidl(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
const struct ndr_interface_table *iface;
@@ -267,7 +266,7 @@ BOOL torture_rpc_autoidl(struct torture_context *torture)
iface = ndr_table_by_name("drsuapi");
if (!iface) {
printf("Unknown interface!\n");
- return False;
+ return false;
}
mem_ctx = talloc_init("torture_rpc_autoidl");
@@ -277,5 +276,5 @@ BOOL torture_rpc_autoidl(struct torture_context *torture)
test_auto_scan(mem_ctx, iface);
talloc_free(mem_ctx);
- return True;
+ return true;
}
diff --git a/source4/torture/rpc/bench.c b/source4/torture/rpc/bench.c
index 48fd0609f0..2619ac2d25 100644
--- a/source4/torture/rpc/bench.c
+++ b/source4/torture/rpc/bench.c
@@ -23,18 +23,19 @@
#include "torture/torture.h"
#include "librpc/gen_ndr/ndr_srvsvc_c.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
/**************************/
/* srvsvc_NetShare */
/**************************/
-static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
struct srvsvc_NetShareEnumAll r;
struct srvsvc_NetShareCtr0 c0;
uint32_t levels[] = {0, 1, 2, 501, 502};
int i;
- BOOL ret = True;
+ bool ret = true;
uint32_t resume_handle;
ZERO_STRUCT(c0);
@@ -52,7 +53,7 @@ static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
status = dcerpc_srvsvc_NetShareEnumAll(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("NetShareEnumAll level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
if (!W_ERROR_IS_OK(r.out.result)) {
@@ -67,11 +68,11 @@ static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
/*
benchmark srvsvc netshareenumall queries
*/
-static BOOL bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
struct timeval tv = timeval_current();
- BOOL ret = True;
- int timelimit = lp_parm_int(-1, "torture", "timelimit", 10);
+ bool ret = true;
+ int timelimit = lp_parm_int(global_loadparm, NULL, "torture", "timelimit", 10);
int count=0;
printf("Running for %d seconds\n", timelimit);
@@ -81,7 +82,7 @@ static BOOL bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
talloc_free(tmp_ctx);
count++;
if (count % 50 == 0) {
- if (lp_parm_bool(-1, "torture", "progress", true)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) {
printf("%.1f queries per second \r",
count / timeval_elapsed(&tv));
}
@@ -94,12 +95,12 @@ static BOOL bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
}
-BOOL torture_bench_rpc(struct torture_context *torture)
+bool torture_bench_rpc(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
mem_ctx = talloc_init("torture_rpc_srvsvc");
@@ -108,11 +109,11 @@ BOOL torture_bench_rpc(struct torture_context *torture)
&ndr_table_srvsvc);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (!bench_NetShareEnumAll(p, mem_ctx)) {
- ret = False;
+ ret = false;
}
talloc_free(mem_ctx);
diff --git a/source4/torture/rpc/bind.c b/source4/torture/rpc/bind.c
index c7848f4a89..1800901873 100644
--- a/source4/torture/rpc/bind.c
+++ b/source4/torture/rpc/bind.c
@@ -41,27 +41,27 @@
*/
-BOOL torture_multi_bind(struct torture_context *torture)
+bool torture_multi_bind(struct torture_context *torture)
{
struct dcerpc_pipe *p;
struct dcerpc_binding *binding;
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- BOOL ret;
+ bool ret;
mem_ctx = talloc_init("torture_multi_bind");
status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
status = dcerpc_pipe_auth(mem_ctx, &p, binding, &ndr_table_lsarpc, cmdline_credentials);
@@ -69,10 +69,10 @@ BOOL torture_multi_bind(struct torture_context *torture)
if (NT_STATUS_IS_OK(status)) {
printf("(incorrectly) allowed re-bind to uuid %s - %s\n",
GUID_string(mem_ctx, &ndr_table_lsarpc.syntax_id.uuid), nt_errstr(status));
- ret = False;
+ ret = false;
} else {
printf("\n");
- ret = True;
+ ret = true;
}
talloc_free(mem_ctx);
diff --git a/source4/torture/rpc/countcalls.c b/source4/torture/rpc/countcalls.c
index e2e222d2ec..f9a31feaaf 100644
--- a/source4/torture/rpc/countcalls.c
+++ b/source4/torture/rpc/countcalls.c
@@ -25,12 +25,13 @@
#include "librpc/ndr/libndr.h"
#include "librpc/ndr/ndr_table.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
-BOOL count_calls(TALLOC_CTX *mem_ctx,
+bool count_calls(TALLOC_CTX *mem_ctx,
const struct ndr_interface_table *iface,
- BOOL all)
+ bool all)
{
struct dcerpc_pipe *p;
DATA_BLOB stub_in, stub_out;
@@ -42,14 +43,14 @@ BOOL count_calls(TALLOC_CTX *mem_ctx,
|| NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) {
if (all) {
/* Not fatal if looking for all pipes */
- return True;
+ return true;
} else {
printf("Failed to open '%s' to count calls - %s\n", iface->name, nt_errstr(status));
- return False;
+ return false;
}
} else if (!NT_STATUS_IS_OK(status)) {
printf("Failed to open '%s' to count calls - %s\n", iface->name, nt_errstr(status));
- return False;
+ return false;
}
stub_in = data_blob_talloc(p, mem_ctx, 0);
@@ -57,7 +58,7 @@ BOOL count_calls(TALLOC_CTX *mem_ctx,
printf("\nScanning pipe '%s'\n", iface->name);
for (i=0;i<500;i++) {
- status = dcerpc_request(p, NULL, i, False, p, &stub_in, &stub_out);
+ status = dcerpc_request(p, NULL, i, false, p, &stub_in, &stub_out);
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT) &&
p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) {
i--;
@@ -89,41 +90,41 @@ BOOL count_calls(TALLOC_CTX *mem_ctx,
if (i==500) {
talloc_free(p);
printf("no limit on calls: %s!?\n", nt_errstr(status));
- return False;
+ return false;
}
printf("Found %d calls\n", i);
talloc_free(p);
- return True;
+ return true;
}
-BOOL torture_rpc_countcalls(struct torture_context *torture)
+bool torture_rpc_countcalls(struct torture_context *torture)
{
const struct ndr_interface_table *iface;
const char *iface_name;
- BOOL ret = True;
+ bool ret = true;
const struct ndr_interface_list *l;
TALLOC_CTX *mem_ctx = talloc_named(torture, 0, "torture_rpc_countcalls context");
if (!mem_ctx) {
- return False;
+ return false;
}
- iface_name = lp_parm_string(-1, "countcalls", "interface");
+ iface_name = lp_parm_string(global_loadparm, NULL, "countcalls", "interface");
if (iface_name != NULL) {
iface = ndr_table_by_name(iface_name);
if (!iface) {
printf("Unknown interface '%s'\n", iface_name);
- return False;
+ return false;
}
- return count_calls(mem_ctx, iface, False);
+ return count_calls(mem_ctx, iface, false);
}
for (l=ndr_table_list();l;l=l->next) {
TALLOC_CTX *loop_ctx;
loop_ctx = talloc_named(mem_ctx, 0, "torture_rpc_councalls loop context");
- ret &= count_calls(loop_ctx, l->table, True);
+ ret &= count_calls(loop_ctx, l->table, true);
talloc_free(loop_ctx);
}
return ret;
diff --git a/source4/torture/rpc/dfs.c b/source4/torture/rpc/dfs.c
index 7dc600ae93..afa647e71c 100644
--- a/source4/torture/rpc/dfs.c
+++ b/source4/torture/rpc/dfs.c
@@ -38,12 +38,12 @@
if (x == DFS_MANAGER_VERSION_W2K3) {\
if (!W_ERROR_EQUAL(y,WERR_NOT_SUPPORTED)) {\
printf("expected WERR_NOT_SUPPORTED\n");\
- return False;\
+ return false;\
}\
- return True;\
+ return true;\
}\
-static BOOL test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char *sharename, const char *dir)
+static bool test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char *sharename, const char *dir)
{
NTSTATUS status;
struct srvsvc_NetShareInfo2 i;
@@ -53,7 +53,7 @@ static BOOL test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char *
printf("Creating share %s\n", sharename);
if (!(libnetctx = libnet_context_init(NULL))) {
- return False;
+ return false;
}
libnetctx->cred = cmdline_credentials;
@@ -75,13 +75,13 @@ static BOOL test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char *
if (!NT_STATUS_IS_OK(status)) {
d_printf("Failed to add new share: %s (%s)\n",
nt_errstr(status), r.out.error_string);
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
+static bool test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
{
NTSTATUS status;
struct libnet_context* libnetctx;
@@ -90,7 +90,7 @@ static BOOL test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char *
printf("Deleting share %s\n", sharename);
if (!(libnetctx = libnet_context_init(NULL))) {
- return False;
+ return false;
}
libnetctx->cred = cmdline_credentials;
@@ -102,13 +102,13 @@ static BOOL test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char *
if (!NT_STATUS_IS_OK(status)) {
d_printf("Failed to delete share: %s (%s)\n",
nt_errstr(status), r.out.error_string);
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_CreateDir(TALLOC_CTX *mem_ctx,
+static bool test_CreateDir(TALLOC_CTX *mem_ctx,
struct smbcli_state **cli,
const char *host,
const char *share,
@@ -117,29 +117,29 @@ static BOOL test_CreateDir(TALLOC_CTX *mem_ctx,
printf("Creating directory %s\n", dir);
if (!torture_open_connection_share(mem_ctx, cli, host, share, NULL)) {
- return False;
+ return false;
}
if (!torture_setup_dir(*cli, dir)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_DeleteDir(struct smbcli_state *cli, const char *dir)
+static bool test_DeleteDir(struct smbcli_state *cli, const char *dir)
{
printf("Deleting directory %s\n", dir);
if (smbcli_deltree(cli->tree, dir) == -1) {
printf("Unable to delete dir %s - %s\n", dir, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, enum dfs_ManagerVersion *version)
+static bool test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, enum dfs_ManagerVersion *version)
{
NTSTATUS status;
struct dfs_GetManagerVersion r;
@@ -149,13 +149,13 @@ static BOOL test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, e
status = dcerpc_dfs_GetManagerVersion(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetManagerVersion failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
+static bool test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
{
NTSTATUS status;
enum dfs_ManagerVersion version;
@@ -164,7 +164,7 @@ static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c
printf("Testing ManagerInitialize\n");
if (!test_GetManagerVersion(p, mem_ctx, &version)) {
- return False;
+ return false;
}
r.in.servername = host;
@@ -173,17 +173,17 @@ static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c
status = dcerpc_dfs_ManagerInitialize(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("ManagerInitialize failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("dfs_ManagerInitialize failed - %s\n", win_errstr(r.out.result));
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result);
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level,
+static bool test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level,
const char *root)
{
NTSTATUS status;
@@ -199,32 +199,32 @@ static BOOL test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16
status = dcerpc_dfs_GetInfo(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetInfo failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else if (!W_ERROR_IS_OK(r.out.result) &&
!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) {
printf("dfs_GetInfo failed - %s\n", win_errstr(r.out.result));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root)
+static bool test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root)
{
- BOOL ret = True;
+ bool ret = true;
/* 103, 104, 105, 106 is only available on Set */
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103, 104, 105, 106};
int i;
for (i=0;i<ARRAY_SIZE(levels);i++) {
if (!test_GetInfoLevel(p, mem_ctx, levels[i], root)) {
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, const char *dfs_name)
+static bool test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, const char *dfs_name)
{
NTSTATUS status;
struct dfs_EnumEx rex;
@@ -232,7 +232,7 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_
struct dfs_EnumStruct e;
struct dfs_Info1 s;
struct dfs_EnumArray1 e1;
- BOOL ret = True;
+ bool ret = true;
rex.in.level = level;
rex.in.bufsize = (uint32_t)-1;
@@ -251,7 +251,7 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_
status = dcerpc_dfs_EnumEx(p, mem_ctx, &rex);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumEx failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (level == 1 && rex.out.total) {
@@ -259,7 +259,7 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_
for (i=0;i<*rex.out.total;i++) {
const char *root = talloc_strdup(mem_ctx, rex.out.info->e.info1->s[i].path);
if (!test_GetInfo(p, mem_ctx, root)) {
- ret = False;
+ ret = false;
}
}
}
@@ -271,11 +271,11 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_
const char *root = talloc_strdup(mem_ctx, rex.out.info->e.info300->s[i].dom_root);
for (k=0;k<ARRAY_SIZE(levels);k++) {
if (!test_EnumLevelEx(p, mem_ctx, levels[k], root)) {
- ret = False;
+ ret = false;
}
}
if (!test_GetInfo(p, mem_ctx, root)) {
- ret = False;
+ ret = false;
}
}
}
@@ -284,7 +284,7 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_
}
-static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level)
+static bool test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level)
{
NTSTATUS status;
struct dfs_Enum r;
@@ -292,7 +292,7 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
struct dfs_EnumStruct e;
struct dfs_Info1 s;
struct dfs_EnumArray1 e1;
- BOOL ret = True;
+ bool ret = true;
r.in.level = level;
r.in.bufsize = (uint32_t)-1;
@@ -310,11 +310,11 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
status = dcerpc_dfs_Enum(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Enum failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else if (!W_ERROR_IS_OK(r.out.result) &&
!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) {
printf("dfs_Enum failed - %s\n", win_errstr(r.out.result));
- return False;
+ return false;
}
if (level == 1 && r.out.total) {
@@ -322,7 +322,7 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
for (i=0;i<*r.out.total;i++) {
const char *root = r.out.info->e.info1->s[i].path;
if (!test_GetInfo(p, mem_ctx, root)) {
- ret = False;
+ ret = false;
}
}
@@ -332,37 +332,37 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
}
-static BOOL test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
- BOOL ret = True;
+ bool ret = true;
uint16_t levels[] = {1, 2, 3, 4, 200, 300};
int i;
for (i=0;i<ARRAY_SIZE(levels);i++) {
if (!test_EnumLevel(p, mem_ctx, levels[i])) {
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_EnumEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
+static bool test_EnumEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
{
- BOOL ret = True;
+ bool ret = true;
uint16_t levels[] = {1, 2, 3, 4, 200, 300};
int i;
for (i=0;i<ARRAY_SIZE(levels);i++) {
if (!test_EnumLevelEx(p, mem_ctx, levels[i], host)) {
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_RemoveStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
+static bool test_RemoveStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
{
struct dfs_RemoveStdRoot r;
NTSTATUS status;
@@ -376,16 +376,16 @@ static BOOL test_RemoveStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const
status = dcerpc_dfs_RemoveStdRoot(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("RemoveStdRoot failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("dfs_RemoveStdRoot failed - %s\n", win_errstr(r.out.result));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_AddStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
+static bool test_AddStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
{
NTSTATUS status;
struct dfs_AddStdRoot r;
@@ -400,16 +400,16 @@ static BOOL test_AddStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const ch
status = dcerpc_dfs_AddStdRoot(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("AddStdRoot failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("dfs_AddStdRoot failed - %s\n", win_errstr(r.out.result));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
+static bool test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
{
NTSTATUS status;
struct dfs_AddStdRootForced r;
@@ -418,7 +418,7 @@ static BOOL test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, co
printf("Testing AddStdRootForced\n");
if (!test_GetManagerVersion(p, mem_ctx, &version)) {
- return False;
+ return false;
}
r.in.servername = host;
@@ -429,11 +429,11 @@ static BOOL test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, co
status = dcerpc_dfs_AddStdRootForced(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("AddStdRootForced failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("dfs_AddStdRootForced failed - %s\n", win_errstr(r.out.result));
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result);
- return False;
+ return false;
}
return test_RemoveStdRoot(p, mem_ctx, host, sharename);
@@ -456,13 +456,13 @@ static void test_cleanup_stdroot(struct dcerpc_pipe *p,
torture_close_connection(cli);
}
-static BOOL test_StdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
+static bool test_StdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
{
const char *sharename = SMBTORTURE_DFS_SHARENAME;
const char *dir = SMBTORTURE_DFS_DIRNAME;
const char *path = SMBTORTURE_DFS_PATHNAME;
struct smbcli_state *cli;
- BOOL ret;
+ bool ret;
printf("Testing StdRoot\n");
@@ -485,9 +485,9 @@ bool torture_rpc_dfs(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- BOOL ret = True;
+ bool ret = true;
enum dfs_ManagerVersion version;
- const char *host = lp_parm_string(-1, "torture", "host");
+ const char *host = torture_setting_string(torture, "host", NULL);
status = torture_rpc_connection(torture, &p, &ndr_table_netdfs);
torture_assert_ntstatus_ok(torture, status, "Unable to connect");
diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c
index 606240993f..3407e49565 100644
--- a/source4/torture/rpc/drsuapi.c
+++ b/source4/torture/rpc/drsuapi.c
@@ -25,15 +25,15 @@
#include "torture/torture.h"
#include "librpc/gen_ndr/ndr_drsuapi_c.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
#define TEST_MACHINE_NAME "torturetest"
-BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_DsBind(struct dcerpc_pipe *p, struct torture_context *tctx,
struct DsPrivate *priv)
{
NTSTATUS status;
struct drsuapi_DsBind r;
- BOOL ret = True;
GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid);
@@ -41,31 +41,28 @@ BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.bind_info = NULL;
r.out.bind_handle = &priv->bind_handle;
- printf("testing DsBind\n");
+ torture_comment(tctx, "testing DsBind\n");
- status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r);
+ status = dcerpc_drsuapi_DsBind(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
const char *errstr = nt_errstr(status);
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
- errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
+ errstr = dcerpc_errstr(tctx, p->last_fault_code);
}
- printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr);
- ret = False;
+ torture_fail(tctx, "dcerpc_drsuapi_DsBind failed");
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsBind failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ torture_fail(tctx, "DsBind failed");
}
- return ret;
+ return true;
}
-static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture_context *torture,
struct DsPrivate *priv)
{
NTSTATUS status;
struct drsuapi_DsGetDomainControllerInfo r;
- BOOL ret = True;
- BOOL found = False;
+ bool found = false;
int i, j, k;
struct {
@@ -101,45 +98,32 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me
r.in.req.req1.domain_name = names[j].name;
r.in.req.req1.level = level;
- printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
+ torture_comment(torture,
+ "testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
r.in.req.req1.level, r.in.req.req1.domain_name);
- status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- const char *errstr = nt_errstr(status);
- if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
- errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
- }
- printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
- " with dns domain failed - %s\n",
- r.in.req.req1.level, errstr);
- ret = False;
- } else if (!W_ERROR_EQUAL(r.out.result, names[j].expected)) {
- printf("DsGetDomainControllerInfo level %d\n"
- " with dns domain failed - %s, expected %s\n",
- r.in.req.req1.level, win_errstr(r.out.result),
- win_errstr(names[j].expected));
- ret = False;
- }
+ status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r);
+ torture_assert_ntstatus_ok(torture, status,
+ "dcerpc_drsuapi_DsGetDomainControllerInfo with dns domain failed");
+ torture_assert_werr_equal(torture,
+ r.out.result, names[j].expected,
+ "DsGetDomainControllerInfo level with dns domain failed");
if (!W_ERROR_IS_OK(r.out.result)) {
/* If this was an error, we can't read the result structure */
continue;
}
- if (r.in.req.req1.level != r.out.level_out) {
- printf("dcerpc_drsuapi_DsGetDomainControllerInfo level in (%d) != out (%d)\n",
- r.in.req.req1.level, r.out.level_out);
- ret = False;
- /* We can't safely read the result structure */
- continue;
- }
+ torture_assert_int_equal(torture,
+ r.in.req.req1.level, r.out.level_out,
+ "dcerpc_drsuapi_DsGetDomainControllerInfo level");
+
switch (level) {
case 1:
for (k=0; k < r.out.ctr.ctr1.count; k++) {
if (strcasecmp_m(r.out.ctr.ctr1.array[k].netbios_name,
torture_join_netbios_name(priv->join)) == 0) {
- found = True;
+ found = true;
break;
}
}
@@ -148,27 +132,18 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me
for (k=0; k < r.out.ctr.ctr2.count; k++) {
if (strcasecmp_m(r.out.ctr.ctr2.array[k].netbios_name,
torture_join_netbios_name(priv->join)) == 0) {
- found = True;
+ found = true;
priv->dcinfo = r.out.ctr.ctr2.array[k];
break;
}
}
break;
}
- if (!found) {
- printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) we just created during the join\n",
- r.in.req.req1.level,
- torture_join_netbios_name(priv->join));
- ret = False;
- }
+ torture_assert(torture, found,
+ "dcerpc_drsuapi_DsGetDomainControllerInfo: Failed to find the domain controller we just created during the join");
}
}
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping DsGetDomainControllerInfo level -1 test against Samba4\n");
- return ret;
- }
-
r.in.bind_handle = &priv->bind_handle;
r.in.level = 1;
@@ -178,53 +153,39 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me
printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
r.in.req.req1.level, r.in.req.req1.domain_name);
- status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- const char *errstr = nt_errstr(status);
- if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
- errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
- }
- printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
- " with dns domain failed - %s\n",
- r.in.req.req1.level, errstr);
- ret = False;
- } else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsGetDomainControllerInfo level %d\n"
- " with dns domain failed - %s\n",
- r.in.req.req1.level, win_errstr(r.out.result));
- ret = False;
- }
+ status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r);
+
+ torture_assert_ntstatus_ok(torture, status,
+ "dcerpc_drsuapi_DsGetDomainControllerInfo with dns domain failed");
+ torture_assert_werr_ok(torture, r.out.result,
+ "DsGetDomainControllerInfo with dns domain failed");
{
- const char *dc_account = talloc_asprintf(mem_ctx, "%s\\%s$",
+ const char *dc_account = talloc_asprintf(torture, "%s\\%s$",
torture_join_dom_netbios_name(priv->join),
priv->dcinfo.netbios_name);
for (k=0; k < r.out.ctr.ctr01.count; k++) {
if (strcasecmp_m(r.out.ctr.ctr01.array[k].client_account,
dc_account)) {
- found = True;
+ found = true;
break;
}
}
- if (!found) {
- printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) in last logon records\n",
- r.in.req.req1.level,
- dc_account);
- ret = False;
- }
+ torture_assert(torture, found,
+ "dcerpc_drsuapi_DsGetDomainControllerInfo level: Failed to find the domain controller in last logon records");
}
- return ret;
+ return true;
}
-static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv)
{
NTSTATUS status;
struct drsuapi_DsWriteAccountSpn r;
struct drsuapi_DsNameString names[2];
- BOOL ret = True;
+ bool ret = true;
r.in.bind_handle = &priv->bind_handle;
r.in.level = 1;
@@ -246,10 +207,10 @@ static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE;
@@ -262,21 +223,21 @@ static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv)
{
NTSTATUS status;
struct drsuapi_DsReplicaGetInfo r;
- BOOL ret = True;
+ bool ret = true;
int i;
struct {
int32_t level;
@@ -346,9 +307,9 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
};
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping DsReplicaGetInfo test against Samba4\n");
- return True;
+ return true;
}
r.in.bind_handle = &priv->bind_handle;
@@ -387,25 +348,25 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) {
printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else {
printf("DsReplicaGetInfo level %d and/or infotype %d not supported by server\n",
array[i].level, array[i].infotype);
}
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsReplicaGetInfo failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int i;
struct drsuapi_DsReplicaSync r;
struct drsuapi_DsReplicaObjectIdentifier nc;
@@ -419,14 +380,14 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
};
- if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
+ if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) {
printf("DsReplicaSync disabled - enable dangerous tests to use\n");
- return True;
+ return true;
}
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping DsReplicaSync test against Samba4\n");
- return True;
+ return true;
}
ZERO_STRUCT(null_guid);
@@ -459,21 +420,21 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsReplicaSync failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int i;
struct drsuapi_DsReplicaUpdateRefs r;
struct drsuapi_DsReplicaObjectIdentifier nc;
@@ -487,9 +448,9 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
};
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping DsReplicaUpdateRefs test against Samba4\n");
- return True;
+ return true;
}
ZERO_STRUCT(null_guid);
@@ -523,21 +484,21 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsReplicaUpdateRefs failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int i;
struct drsuapi_DsGetNCChanges r;
struct drsuapi_DsReplicaObjectIdentifier nc;
@@ -554,9 +515,9 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
};
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping DsGetNCChanges test against Samba4\n");
- return True;
+ return true;
}
ZERO_STRUCT(null_guid);
@@ -583,7 +544,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.req.req5.highwatermark.highest_usn = 0;
r.in.req.req5.uptodateness_vector = NULL;
r.in.req.req5.replica_flags = 0;
- if (lp_parm_bool(-1, "drsuapi","compression", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "drsuapi","compression", false)) {
r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES;
}
r.in.req.req5.max_object_count = 0;
@@ -605,10 +566,10 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.req.req8.highwatermark.highest_usn = 0;
r.in.req.req8.uptodateness_vector = NULL;
r.in.req.req8.replica_flags = 0;
- if (lp_parm_bool(-1,"drsuapi","compression",False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "drsuapi", "compression", false)) {
r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES;
}
- if (lp_parm_bool(-1,"drsuapi","neighbour_writeable",True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "drsuapi", "neighbour_writeable", true)) {
r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE;
}
r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
@@ -635,22 +596,22 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
}
return ret;
}
-BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv)
{
NTSTATUS status;
struct drsuapi_QuerySitesByCost r;
- BOOL ret = True;
+ bool ret = true;
const char *my_site = "Default-First-Site-Name";
const char *remote_site1 = "smbtorture-nonexisting-site1";
@@ -672,10 +633,10 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("drsuapi_QuerySitesByCost - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("QuerySitesByCost failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
if (W_ERROR_IS_OK(r.out.result)) {
@@ -684,14 +645,14 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
!W_ERROR_EQUAL(r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND)) {
printf("expected error_code WERR_DS_OBJ_NOT_FOUND, got %s\n",
win_errstr(r.out.ctr.ctr1.info[0].error_code));
- ret = False;
+ ret = false;
}
if ((r.out.ctr.ctr1.info[0].site_cost != (uint32_t) -1) ||
(r.out.ctr.ctr1.info[1].site_cost != (uint32_t) -1)) {
printf("expected site_cost %d, got %d\n",
(uint32_t) -1, r.out.ctr.ctr1.info[0].site_cost);
- ret = False;
+ ret = false;
}
}
@@ -700,12 +661,12 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv)
{
NTSTATUS status;
struct drsuapi_DsUnbind r;
- BOOL ret = True;
+ bool ret = true;
r.in.bind_handle = &priv->bind_handle;
r.out.bind_handle = &priv->bind_handle;
@@ -719,34 +680,29 @@ BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsBind failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
return ret;
}
-BOOL torture_rpc_drsuapi(struct torture_context *torture)
+bool torture_rpc_drsuapi(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct DsPrivate priv;
struct cli_credentials *machine_credentials;
- mem_ctx = talloc_init("torture_rpc_drsuapi");
-
ZERO_STRUCT(priv);
priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST,
&machine_credentials);
if (!priv.join) {
- talloc_free(mem_ctx);
- printf("Failed to join as BDC\n");
- return False;
+ torture_fail(torture, "Failed to join as BDC");
}
status = torture_rpc_connection(torture,
@@ -754,31 +710,28 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture)
&ndr_table_drsuapi);
if (!NT_STATUS_IS_OK(status)) {
torture_leave_domain(priv.join);
- talloc_free(mem_ctx);
- return False;
+ torture_fail(torture, "Unable to connect to DRSUAPI pipe");
}
- ret &= test_DsBind(p, mem_ctx, &priv);
+ ret &= test_DsBind(p, torture, &priv);
#if 0
- ret &= test_QuerySitesByCost(p, mem_ctx, &priv);
+ ret &= test_QuerySitesByCost(p, torture, &priv);
#endif
- ret &= test_DsGetDomainControllerInfo(p, mem_ctx, &priv);
-
- ret &= test_DsCrackNames(p, mem_ctx, &priv);
+ ret &= test_DsGetDomainControllerInfo(p, torture, &priv);
- ret &= test_DsWriteAccountSpn(p, mem_ctx, &priv);
+ ret &= test_DsCrackNames(p, torture, &priv);
- ret &= test_DsReplicaGetInfo(p, mem_ctx, &priv);
+ ret &= test_DsWriteAccountSpn(p, torture, &priv);
- ret &= test_DsReplicaSync(p, mem_ctx, &priv);
+ ret &= test_DsReplicaGetInfo(p, torture, &priv);
- ret &= test_DsReplicaUpdateRefs(p, mem_ctx, &priv);
+ ret &= test_DsReplicaSync(p, torture, &priv);
- ret &= test_DsGetNCChanges(p, mem_ctx, &priv);
+ ret &= test_DsReplicaUpdateRefs(p, torture, &priv);
- ret &= test_DsUnbind(p, mem_ctx, &priv);
+ ret &= test_DsGetNCChanges(p, torture, &priv);
- talloc_free(mem_ctx);
+ ret &= test_DsUnbind(p, torture, &priv);
torture_leave_domain(priv.join);
@@ -786,27 +739,22 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture)
}
-BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture)
+bool torture_rpc_drsuapi_cracknames(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct DsPrivate priv;
struct cli_credentials *machine_credentials;
- mem_ctx = talloc_init("torture_rpc_drsuapi");
-
- printf("Connected to DRAUAPI pipe\n");
+ torture_comment(torture, "Connected to DRSUAPI pipe\n");
ZERO_STRUCT(priv);
priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST,
&machine_credentials);
if (!priv.join) {
- talloc_free(mem_ctx);
- printf("Failed to join as BDC\n");
- return False;
+ torture_fail(torture, "Failed to join as BDC\n");
}
status = torture_rpc_connection(torture,
@@ -814,21 +762,19 @@ BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture)
&ndr_table_drsuapi);
if (!NT_STATUS_IS_OK(status)) {
torture_leave_domain(priv.join);
- talloc_free(mem_ctx);
- return False;
+ torture_fail(torture, "Unable to connect to DRSUAPI pipe");
}
- ret &= test_DsBind(p, mem_ctx, &priv);
+ ret &= test_DsBind(p, torture, &priv);
if (ret) {
/* We don't care if this fails, we just need some info from it */
- test_DsGetDomainControllerInfo(p, mem_ctx, &priv);
+ test_DsGetDomainControllerInfo(p, torture, &priv);
- ret &= test_DsCrackNames(p, mem_ctx, &priv);
+ ret &= test_DsCrackNames(p, torture, &priv);
- ret &= test_DsUnbind(p, mem_ctx, &priv);
+ ret &= test_DsUnbind(p, torture, &priv);
}
- talloc_free(mem_ctx);
torture_leave_domain(priv.join);
diff --git a/source4/torture/rpc/drsuapi_cracknames.c b/source4/torture/rpc/drsuapi_cracknames.c
index a29010f73b..ac3eebfa68 100644
--- a/source4/torture/rpc/drsuapi_cracknames.c
+++ b/source4/torture/rpc/drsuapi_cracknames.c
@@ -27,15 +27,16 @@
#include "torture/rpc/rpc.h"
#include "ldb/include/ldb.h"
#include "libcli/security/security.h"
+#include "param/param.h"
-static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv, const char *dn,
const char *user_principal_name, const char *service_principal_name)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct drsuapi_DsCrackNames r;
enum drsuapi_DsNameFormat formats[] = {
DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
@@ -80,13 +81,13 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired);
printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d ",
names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired);
printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
if (!ret) {
@@ -97,7 +98,7 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE) {
printf(__location__ ": Unexpected error (%d): This name lookup should fail\n",
r.out.ctr.ctr1->array[0].status);
- return False;
+ return false;
}
printf ("(expected) error\n");
break;
@@ -105,7 +106,7 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NO_MAPPING) {
printf(__location__ ": Unexpected error (%d): This name lookup should fail\n",
r.out.ctr.ctr1->array[0].status);
- return False;
+ return false;
}
printf ("(expected) error\n");
break;
@@ -114,14 +115,14 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR) {
printf(__location__ ": Unexpected error (%d): This name lookup should fail\n",
r.out.ctr.ctr1->array[0].status);
- return False;
+ return false;
}
printf ("(expected) error\n");
break;
default:
if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
printf("Error: %d\n", r.out.ctr.ctr1->array[0].status);
- return False;
+ return false;
}
}
@@ -159,12 +160,12 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s",
names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired, errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s",
names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired,
win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
if (!ret) {
@@ -190,26 +191,26 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
} else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL) {
} else if (n_matrix[i][j] == NULL && n_from[j] != NULL) {
printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]);
- ret = False;
+ ret = false;
} else if (n_matrix[i][j] != NULL && n_from[j] == NULL) {
printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]);
- ret = False;
+ ret = false;
} else if (strcmp(n_matrix[i][j], n_from[j]) != 0) {
printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]);
- ret = False;
+ ret = false;
}
}
}
return ret;
}
-BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv)
{
NTSTATUS status;
struct drsuapi_DsCrackNames r;
struct drsuapi_DsNameString names[1];
- BOOL ret = True;
+ bool ret = true;
const char *dns_domain;
const char *nt4_domain;
const char *FQDN_1779_name;
@@ -253,13 +254,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
} else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
- ret = False;
+ ret = false;
}
if (!ret) {
@@ -281,13 +282,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
} else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
- ret = False;
+ ret = false;
}
if (!ret) {
@@ -310,13 +311,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
} else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
- ret = False;
+ ret = false;
}
if (!ret) {
@@ -334,7 +335,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("local Round trip on canonical name failed: %s != %s!\n",
realm_canonical,
talloc_asprintf(mem_ctx, "%s/", dns_domain));
- return False;
+ return false;
};
realm_canonical_ex = ldb_dn_canonical_ex_string(mem_ctx, realm_dn);
@@ -344,7 +345,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("local Round trip on canonical ex name failed: %s != %s!\n",
realm_canonical,
talloc_asprintf(mem_ctx, "%s\n", dns_domain));
- return False;
+ return false;
};
r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
@@ -361,13 +362,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
} else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
- ret = False;
+ ret = false;
}
if (!ret) {
@@ -390,13 +391,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
} else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
- ret = False;
+ ret = false;
}
if (!ret) {
@@ -419,13 +420,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
} else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
- ret = False;
+ ret = false;
}
if (!ret) {
@@ -434,7 +435,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (strcmp(priv->domain_dns_name, r.out.ctr.ctr1->array[0].dns_domain_name) != 0) {
printf("DsCrackNames failed to return same DNS name - expected %s got %s\n", priv->domain_dns_name, r.out.ctr.ctr1->array[0].dns_domain_name);
- return False;
+ return false;
}
FQDN_1779_dn = ldb_dn_new(mem_ctx, ldb, FQDN_1779_name);
@@ -462,7 +463,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
enum drsuapi_DsNameStatus status;
enum drsuapi_DsNameStatus alternate_status;
enum drsuapi_DsNameFlags flags;
- BOOL skip;
+ bool skip;
} crack[] = {
{
.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL,
@@ -588,7 +589,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
.comment = "display name for Microsoft Support Account",
.status = DRSUAPI_DS_NAME_STATUS_OK,
.alternate_status = DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE,
- .skip = lp_parm_bool(-1, "torture", "samba4", False)
+ .skip = lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)
},
{
.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID,
@@ -814,6 +815,27 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
.status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND
},
{
+ .format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT,
+ .format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
+ .comment = "NT AUTHORITY\\ -> DN",
+ .str = "NT AUTHORITY\\",
+ .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND
+ },
+ {
+ .format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT,
+ .format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
+ .comment = "NT AUTHORITY\\ANONYMOUS LOGON -> DN",
+ .str = "NT AUTHORITY\\ANONYMOUS LOGON",
+ .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND
+ },
+ {
+ .format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT,
+ .format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
+ .comment = "NT AUTHORITY\\SYSTEM -> DN",
+ .str = "NT AUTHORITY\\SYSTEM",
+ .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND
+ },
+ {
.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY,
.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT,
.comment = "BUITIN SID -> NT4 account",
@@ -848,6 +870,20 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
},
{
.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY,
+ .format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT,
+ .str = SID_NT_ANONYMOUS,
+ .comment = "NT Anonymous SID -> NT4 Account",
+ .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND
+ },
+ {
+ .format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY,
+ .format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT,
+ .str = SID_NT_SYSTEM,
+ .comment = "NT SYSTEM SID -> NT4 Account",
+ .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND
+ },
+ {
+ .format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY,
.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
.comment = "Domain SID -> DN",
.str = dom_sid,
@@ -905,10 +941,10 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
printf("dcerpc_drsuapi_DsCrackNames failed on %s - %s\n", comment, errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
} else if (r.out.ctr.ctr1->array[0].status != crack[i].status) {
if (crack[i].alternate_status) {
if (r.out.ctr.ctr1->array[0].status != crack[i].alternate_status) {
@@ -917,14 +953,14 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
crack[i].status,
crack[i].alternate_status,
comment);
- ret = False;
+ ret = false;
}
} else {
printf("DsCrackNames unexpected status %d, wanted %d on: %s\n",
r.out.ctr.ctr1->array[0].status,
crack[i].status,
comment);
- ret = False;
+ ret = false;
}
} else if (crack[i].expected_str
&& (strcmp(r.out.ctr.ctr1->array[0].result_name,
@@ -934,7 +970,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("DsCrackNames failed - got %s, expected %s on %s\n",
r.out.ctr.ctr1->array[0].result_name,
crack[i].expected_str, comment);
- ret = False;
+ ret = false;
} else {
printf("(warning) DsCrackNames returned different case - got %s, expected %s on %s\n",
r.out.ctr.ctr1->array[0].result_name,
@@ -946,14 +982,14 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("DsCrackNames failed - got DNS name %s, expected %s on %s\n",
r.out.ctr.ctr1->array[0].result_name,
crack[i].expected_str, comment);
- ret = False;
+ ret = false;
}
}
}
if (!test_DsCrackNamesMatrix(p, mem_ctx, priv, FQDN_1779_name,
user_principal_name, service_principal_name)) {
- ret = False;
+ ret = false;
}
return ret;
diff --git a/source4/torture/rpc/dssetup.c b/source4/torture/rpc/dssetup.c
index c80e37eb7d..aa5f12eb92 100644
--- a/source4/torture/rpc/dssetup.c
+++ b/source4/torture/rpc/dssetup.c
@@ -25,56 +25,40 @@
#include "torture/rpc/rpc.h"
-BOOL test_DsRoleGetPrimaryDomainInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+bool test_DsRoleGetPrimaryDomainInformation_ext(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ NTSTATUS ext_status)
{
struct dssetup_DsRoleGetPrimaryDomainInformation r;
NTSTATUS status;
- BOOL ret = True;
int i;
- printf("\ntesting DsRoleGetPrimaryDomainInformation\n");
-
for (i=DS_ROLE_BASIC_INFORMATION; i <= DS_ROLE_OP_STATUS; i++) {
r.in.level = i;
+ torture_comment(tctx, "dcerpc_dssetup_DsRoleGetPrimaryDomainInformation level %d\n", i);
- status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- const char *errstr = nt_errstr(status);
- if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
- errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
- }
- printf("dcerpc_dssetup_DsRoleGetPrimaryDomainInformation level %d failed - %s\n",
- i, errstr);
- ret = False;
- } else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsRoleGetPrimaryDomainInformation level %d failed - %s\n",
- i, win_errstr(r.out.result));
- ret = False;
+ status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(p, tctx, &r);
+ torture_assert_ntstatus_equal(tctx, ext_status, status, "DsRoleGetPrimaryDomainInformation failed");
+ if (NT_STATUS_IS_OK(ext_status)) {
+ torture_assert_werr_ok(tctx, r.out.result, "DsRoleGetPrimaryDomainInformation failed");
}
}
- return ret;
+ return true;
}
-BOOL torture_rpc_dssetup(struct torture_context *torture)
+bool test_DsRoleGetPrimaryDomainInformation(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
-
- mem_ctx = talloc_init("torture_rpc_dssetup");
-
- status = torture_rpc_connection(torture, &p, &ndr_table_dssetup);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
-
- return False;
- }
+ return test_DsRoleGetPrimaryDomainInformation_ext(tctx, p, NT_STATUS_OK);
+}
- ret &= test_DsRoleGetPrimaryDomainInformation(p, mem_ctx);
+struct torture_suite *torture_rpc_dssetup(TALLOC_CTX *mem_ctx)
+{
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "DSSETUP");
+ struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite, "dssetup", &ndr_table_dssetup);
- talloc_free(mem_ctx);
+ torture_rpc_tcase_add_test(tcase, "DsRoleGetPrimaryDomainInformation", test_DsRoleGetPrimaryDomainInformation);
- return ret;
+ return suite;
}
diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c
index 6357fa9ee5..15125ac365 100644
--- a/source4/torture/rpc/dssync.c
+++ b/source4/torture/rpc/dssync.c
@@ -32,6 +32,7 @@
#include "auth/credentials/credentials.h"
#include "libcli/auth/libcli_auth.h"
#include "auth/gensec/gensec.h"
+#include "param/param.h"
struct DsSyncBindInfo {
struct dcerpc_pipe *pipe;
@@ -83,7 +84,7 @@ static struct DsSyncTest *test_create_context(TALLOC_CTX *mem_ctx)
struct DsSyncTest *ctx;
struct drsuapi_DsBindInfo28 *our_bind_info28;
struct drsuapi_DsBindInfoCtr *our_bind_info_ctr;
- const char *binding = lp_parm_string(-1, "torture", "binding");
+ const char *binding = lp_parm_string(global_loadparm, NULL, "torture", "binding");
ctx = talloc_zero(mem_ctx, struct DsSyncTest);
if (!ctx) return NULL;
@@ -148,7 +149,7 @@ static struct DsSyncTest *test_create_context(TALLOC_CTX *mem_ctx)
our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
- if (lp_parm_bool(-1,"dssync","xpress",False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "dssync", "xpress", false)) {
our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS;
}
our_bind_info28->site_guid = GUID_zero();
@@ -172,10 +173,10 @@ static struct DsSyncTest *test_create_context(TALLOC_CTX *mem_ctx)
return ctx;
}
-static BOOL _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncBindInfo *b)
+static bool _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncBindInfo *b)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct event_context *event = NULL;
status = dcerpc_pipe_connect_b(ctx,
@@ -185,7 +186,7 @@ static BOOL _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credent
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_drsuapi_DsBind(b->pipe, ctx, &b->req);
@@ -195,10 +196,10 @@ static BOOL _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credent
errstr = dcerpc_errstr(ctx, b->pipe->last_fault_code);
}
printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(b->req.out.result)) {
printf("DsBind failed - %s\n", win_errstr(b->req.out.result));
- ret = False;
+ ret = false;
}
ZERO_STRUCT(b->peer_bind_info28);
@@ -222,15 +223,15 @@ static BOOL _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credent
return ret;
}
-static BOOL test_LDAPBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncLDAPInfo *l)
+static bool test_LDAPBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncLDAPInfo *l)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
status = torture_ldap_connection(ctx, &l->conn, ctx->ldap_url);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to connect to LDAP: %s\n", ctx->ldap_url);
- return False;
+ return false;
}
printf("connected to LDAP: %s\n", ctx->ldap_url);
@@ -238,19 +239,19 @@ static BOOL test_LDAPBind(struct DsSyncTest *ctx, struct cli_credentials *creden
status = torture_ldap_bind_sasl(l->conn, credentials);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to bind to LDAP:\n");
- return False;
+ return false;
}
printf("bound to LDAP.\n");
return ret;
}
-static BOOL test_GetInfo(struct DsSyncTest *ctx)
+static bool test_GetInfo(struct DsSyncTest *ctx)
{
NTSTATUS status;
struct drsuapi_DsCrackNames r;
struct drsuapi_DsNameString names[1];
- BOOL ret = True;
+ bool ret = true;
struct cldap_socket *cldap = cldap_socket_init(ctx, NULL);
struct cldap_netlogon search;
@@ -264,7 +265,7 @@ static BOOL test_GetInfo(struct DsSyncTest *ctx)
r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS;
r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
- names[0].str = talloc_asprintf(ctx, "%s\\", lp_workgroup());
+ names[0].str = talloc_asprintf(ctx, "%s\\", lp_workgroup(global_loadparm));
status = dcerpc_drsuapi_DsCrackNames(ctx->admin.drsuapi.pipe, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
@@ -273,10 +274,10 @@ static BOOL test_GetInfo(struct DsSyncTest *ctx)
errstr = dcerpc_errstr(ctx, ctx->admin.drsuapi.pipe->last_fault_code);
}
printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- return False;
+ return false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- return False;
+ return false;
}
ctx->domain_dn = r.out.ctr.ctr1->array[0].result_name;
@@ -419,17 +420,17 @@ static void test_analyse_objects(struct DsSyncTest *ctx,
static uint32_t object_id;
const char *save_values_dir;
- if (!lp_parm_bool(-1,"dssync","print_pwd_blobs", false)) {
+ if (!lp_parm_bool(global_loadparm, NULL,"dssync","print_pwd_blobs", false)) {
return;
}
- save_values_dir = lp_parm_string(-1,"dssync","save_pwd_blobs_dir");
+ save_values_dir = lp_parm_string(global_loadparm, NULL, "dssync", "save_pwd_blobs_dir");
for (; cur; cur = cur->next_object) {
const char *dn;
struct dom_sid *sid = NULL;
uint32_t rid = 0;
- BOOL dn_printed = False;
+ bool dn_printed = false;
uint32_t i;
if (!cur->object.identifier) continue;
@@ -503,7 +504,7 @@ static void test_analyse_objects(struct DsSyncTest *ctx,
if (!dn_printed) {
object_id++;
DEBUG(0,("DN[%u] %s\n", object_id, dn));
- dn_printed = True;
+ dn_printed = true;
}
DEBUGADD(0,("ATTR: %s enc.length=%lu plain.length=%lu\n",
name, (long)enc_data->length, (long)plain_data.length));
@@ -530,10 +531,10 @@ static void test_analyse_objects(struct DsSyncTest *ctx,
}
}
-static BOOL test_FetchData(struct DsSyncTest *ctx)
+static bool test_FetchData(struct DsSyncTest *ctx)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
int i, y = 0;
uint64_t highest_usn = 0;
const char *partition = NULL;
@@ -559,17 +560,17 @@ static BOOL test_FetchData(struct DsSyncTest *ctx)
ZERO_STRUCT(null_guid);
ZERO_STRUCT(null_sid);
- partition = lp_parm_string(-1, "dssync", "partition");
+ partition = lp_parm_string(global_loadparm, NULL, "dssync", "partition");
if (partition == NULL) {
partition = ctx->domain_dn;
printf("dssync:partition not specified, defaulting to %s.\n", ctx->domain_dn);
}
- highest_usn = lp_parm_int(-1, "dssync", "highest_usn", 0);
+ highest_usn = lp_parm_int(global_loadparm, NULL, "dssync", "highest_usn", 0);
- array[0].level = lp_parm_int(-1, "dssync", "get_nc_changes_level", array[0].level);
+ array[0].level = lp_parm_int(global_loadparm, NULL, "dssync", "get_nc_changes_level", array[0].level);
- if (lp_parm_bool(-1,"dssync","print_pwd_blobs",False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "dssync", "print_pwd_blobs", false)) {
const struct samr_Password *nthash;
nthash = cli_credentials_get_nt_hash(ctx->new_dc.credentials, ctx);
if (nthash) {
@@ -581,7 +582,7 @@ static BOOL test_FetchData(struct DsSyncTest *ctx)
&gensec_skey);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to get gensec session key: %s\n", nt_errstr(status));
- return False;
+ return false;
}
for (i=0; i < ARRAY_SIZE(array); i++) {
@@ -605,10 +606,10 @@ static BOOL test_FetchData(struct DsSyncTest *ctx)
r.in.req.req5.highwatermark.highest_usn = highest_usn;
r.in.req.req5.uptodateness_vector = NULL;
r.in.req.req5.replica_flags = 0;
- if (lp_parm_bool(-1,"dssync","compression",False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "dssync", "compression", false)) {
r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES;
}
- if (lp_parm_bool(-1,"dssync","neighbour_writeable",True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "dssync", "neighbour_writeable", true)) {
r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE;
}
r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
@@ -636,10 +637,10 @@ static BOOL test_FetchData(struct DsSyncTest *ctx)
r.in.req.req8.highwatermark.highest_usn = highest_usn;
r.in.req.req8.uptodateness_vector = NULL;
r.in.req.req8.replica_flags = 0;
- if (lp_parm_bool(-1,"dssync","compression",False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "dssync", "compression", false)) {
r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES;
}
- if (lp_parm_bool(-1,"dssync","neighbour_writeable",True)) {
+ if (lp_parm_bool(global_loadparm, NULL, "dssync", "neighbour_writeable", true)) {
r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE;
}
r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
@@ -685,16 +686,16 @@ static BOOL test_FetchData(struct DsSyncTest *ctx)
errstr = dcerpc_errstr(ctx, ctx->new_dc.drsuapi.pipe->last_fault_code);
}
printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
}
- if (ret == True && *r.out.level == 1) {
+ if (ret == true && *r.out.level == 1) {
out_level = 1;
ctr1 = &r.out.ctr.ctr1;
- } else if (ret == True && *r.out.level == 2) {
+ } else if (ret == true && *r.out.level == 2) {
out_level = 1;
ctr1 = r.out.ctr.ctr2.ctr.mszip1.ctr1;
}
@@ -712,10 +713,10 @@ static BOOL test_FetchData(struct DsSyncTest *ctx)
}
}
- if (ret == True && *r.out.level == 6) {
+ if (ret == true && *r.out.level == 6) {
out_level = 6;
ctr6 = &r.out.ctr.ctr6;
- } else if (ret == True && *r.out.level == 7
+ } else if (ret == true && *r.out.level == 7
&& r.out.ctr.ctr7.level == 6
&& r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) {
out_level = 6;
@@ -742,10 +743,10 @@ static BOOL test_FetchData(struct DsSyncTest *ctx)
return ret;
}
-static BOOL test_FetchNT4Data(struct DsSyncTest *ctx)
+static bool test_FetchNT4Data(struct DsSyncTest *ctx)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct drsuapi_DsGetNT4ChangeLog r;
struct GUID null_guid;
struct dom_sid null_sid;
@@ -759,8 +760,8 @@ static BOOL test_FetchNT4Data(struct DsSyncTest *ctx)
r.in.bind_handle = &ctx->new_dc.drsuapi.bind_handle;
r.in.level = 1;
- r.in.req.req1.unknown1 = lp_parm_int(-1, "dssync", "nt4-1", 3);
- r.in.req.req1.unknown2 = lp_parm_int(-1, "dssync", "nt4-2", 0x00004000);
+ r.in.req.req1.unknown1 = lp_parm_int(global_loadparm, NULL, "dssync", "nt4-1", 3);
+ r.in.req.req1.unknown2 = lp_parm_int(global_loadparm, NULL, "dssync", "nt4-2", 0x00004000);
while (1) {
r.in.req.req1.length = cookie.length;
@@ -773,16 +774,16 @@ static BOOL test_FetchNT4Data(struct DsSyncTest *ctx)
errstr = dcerpc_errstr(ctx, ctx->new_dc.drsuapi.pipe->last_fault_code);
}
printf("dcerpc_drsuapi_DsGetNT4ChangeLog failed - %s\n", errstr);
- ret = False;
+ ret = false;
} else if (W_ERROR_EQUAL(r.out.result, WERR_INVALID_DOMAIN_ROLE)) {
printf("DsGetNT4ChangeLog not supported by target server\n");
break;
} else if (!W_ERROR_IS_OK(r.out.result)) {
printf("DsGetNT4ChangeLog failed - %s\n", win_errstr(r.out.result));
- ret = False;
+ ret = false;
} else if (r.out.level != 1) {
printf("DsGetNT4ChangeLog unknown level - %u\n", r.out.level);
- ret = False;
+ ret = false;
} else if (NT_STATUS_IS_OK(r.out.info.info1.status)) {
} else if (NT_STATUS_EQUAL(r.out.info.info1.status, STATUS_MORE_ENTRIES)) {
cookie.length = r.out.info.info1.length1;
@@ -790,7 +791,7 @@ static BOOL test_FetchNT4Data(struct DsSyncTest *ctx)
continue;
} else {
printf("DsGetNT4ChangeLog failed - %s\n", nt_errstr(r.out.info.info1.status));
- ret = False;
+ ret = false;
}
break;
@@ -799,9 +800,9 @@ static BOOL test_FetchNT4Data(struct DsSyncTest *ctx)
return ret;
}
-BOOL torture_rpc_dssync(struct torture_context *torture)
+bool torture_rpc_dssync(struct torture_context *torture)
{
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx;
struct DsSyncTest *ctx;
diff --git a/source4/torture/rpc/echo.c b/source4/torture/rpc/echo.c
index edc35c0aa7..5c027d3299 100644
--- a/source4/torture/rpc/echo.c
+++ b/source4/torture/rpc/echo.c
@@ -78,8 +78,8 @@ static bool test_echodata(struct torture_context *tctx,
len = 1 + (random() % 5000);
}
- data_in = talloc_size(tctx, len);
- data_out = talloc_size(tctx, len);
+ data_in = talloc_array(tctx, uint8_t, len);
+ data_out = talloc_array(tctx, uint8_t, len);
for (i=0;i<len;i++) {
data_in[i] = i;
}
@@ -159,7 +159,7 @@ static bool test_sinkdata(struct torture_context *tctx,
len = 200000 + (random() % 5000);
}
- data_in = talloc_size(tctx, len);
+ data_in = talloc_array(tctx, uint8_t, len);
for (i=0;i<len;i++) {
data_in[i] = i+1;
}
@@ -230,7 +230,7 @@ static bool test_sleep(struct torture_context *tctx,
#define ASYNC_COUNT 3
struct rpc_request *req[ASYNC_COUNT];
struct echo_TestSleep r[ASYNC_COUNT];
- BOOL done[ASYNC_COUNT];
+ bool done[ASYNC_COUNT];
struct timeval snd[ASYNC_COUNT];
struct timeval rcv[ASYNC_COUNT];
struct timeval diff[ASYNC_COUNT];
@@ -240,10 +240,10 @@ static bool test_sleep(struct torture_context *tctx,
if (torture_setting_bool(tctx, "quick", false)) {
torture_skip(tctx, "TestSleep disabled - use \"torture:quick=no\" to enable\n");
}
- torture_comment(tctx, "Testing TestSleep - use \"torture:quick=no\" to disable\n");
+ torture_comment(tctx, "Testing TestSleep - use \"torture:quick=yes\" to disable\n");
for (i=0;i<ASYNC_COUNT;i++) {
- done[i] = False;
+ done[i] = false;
snd[i] = timeval_current();
rcv[i] = timeval_zero();
r[i].in.seconds = ASYNC_COUNT-i;
@@ -256,15 +256,15 @@ static bool test_sleep(struct torture_context *tctx,
torture_assert(tctx, event_loop_once(ctx) == 0,
"Event context loop failed");
for (i=0;i<ASYNC_COUNT;i++) {
- if (done[i] == False && req[i]->state == RPC_REQUEST_DONE) {
+ if (done[i] == false && req[i]->state == RPC_REQUEST_DONE) {
int rounded_tdiff;
total_done++;
- done[i] = True;
+ done[i] = true;
rcv[i] = timeval_current();
diff[i] = timeval_until(&snd[i], &rcv[i]);
rounded_tdiff = (int)(0.5 + diff[i].tv_sec + (1.0e-6*diff[i].tv_usec));
status = dcerpc_ndr_request_recv(req[i]);
- printf("rounded_tdiff=%d\n", rounded_tdiff);
+ torture_comment(tctx, "rounded_tdiff=%d\n", rounded_tdiff);
torture_assert_ntstatus_ok(tctx, status,
talloc_asprintf(tctx, "TestSleep(%d) failed", i));
torture_assert(tctx, r[i].out.result == r[i].in.seconds,
@@ -287,7 +287,7 @@ static bool test_sleep(struct torture_context *tctx,
}
}
}
- printf("\n");
+ torture_comment(tctx, "\n");
return true;
}
@@ -393,7 +393,7 @@ static bool test_timeout(struct torture_context *tctx,
torture_comment(tctx, "Failed to send async sleep request\n");
goto failed;
}
- req->ignore_timeout = True;
+ req->ignore_timeout = true;
status = dcerpc_ndr_request_recv(req);
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_IO_TIMEOUT,
@@ -412,7 +412,7 @@ static bool test_timeout(struct torture_context *tctx,
torture_comment(tctx, "Failed to send async sleep request\n");
goto failed;
}
- req->ignore_timeout = True;
+ req->ignore_timeout = true;
status = dcerpc_ndr_request_recv(req);
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_IO_TIMEOUT,
"request should have timed out");
@@ -427,10 +427,10 @@ failed:
}
-struct torture_suite *torture_rpc_echo(void)
+struct torture_suite *torture_rpc_echo(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(
- talloc_autofree_context(), "ECHO");
+ mem_ctx, "ECHO");
struct torture_rpc_tcase *tcase;
tcase = torture_suite_add_rpc_iface_tcase(suite, "echo",
diff --git a/source4/torture/rpc/epmapper.c b/source4/torture/rpc/epmapper.c
index f6f8e66369..830b77aed9 100644
--- a/source4/torture/rpc/epmapper.c
+++ b/source4/torture/rpc/epmapper.c
@@ -39,7 +39,7 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_tower *twr)
}
-static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct epm_twr_t *twr)
{
NTSTATUS status;
@@ -131,7 +131,7 @@ static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
/* FIXME: Extend to do other protocols as well (ncacn_unix_stream, ncalrpc) */
- return True;
+ return true;
}
static bool test_Lookup(struct torture_context *tctx,
@@ -186,7 +186,7 @@ static bool test_Lookup(struct torture_context *tctx,
return true;
}
-static BOOL test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct epm_entry_t *entries)
+static bool test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct epm_entry_t *entries)
{
NTSTATUS status;
struct epm_Delete r;
@@ -197,15 +197,15 @@ static BOOL test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct epm_e
status = dcerpc_epm_Delete(p, mem_ctx, &r);
if (NT_STATUS_IS_ERR(status)) {
printf("Delete failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (r.out.result != 0) {
printf("Delete failed - %d\n", r.out.result);
- return False;
+ return false;
}
- return True;
+ return true;
}
static bool test_Insert(struct torture_context *tctx,
diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c
index 1c72625f73..c1d863454c 100644
--- a/source4/torture/rpc/eventlog.c
+++ b/source4/torture/rpc/eventlog.c
@@ -125,7 +125,7 @@ static bool test_ReadEventLog(struct torture_context *tctx,
/* Now read the actual record */
r.in.number_of_bytes = *r.out.real_size;
- r.out.data = talloc_size(tctx, r.in.number_of_bytes);
+ r.out.data = talloc_array(tctx, uint8_t, r.in.number_of_bytes);
status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r);
@@ -192,10 +192,6 @@ static bool test_ClearEventLog(struct torture_context *tctx,
struct eventlog_CloseEventLog cr;
struct policy_handle handle;
- if (!torture_setting_bool(tctx, "dangerous", false)) {
- torture_skip(tctx, "ClearEventLog test disabled - enable dangerous tests to use");
- }
-
if (!get_policy_handle(tctx, p, &handle))
return false;
@@ -233,17 +229,20 @@ static bool test_OpenEventLog(struct torture_context *tctx,
return true;
}
-struct torture_suite *torture_rpc_eventlog(void)
+struct torture_suite *torture_rpc_eventlog(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite;
struct torture_rpc_tcase *tcase;
+ struct torture_test *test;
- suite = torture_suite_create(talloc_autofree_context(), "EVENTLOG");
+ suite = torture_suite_create(mem_ctx, "EVENTLOG");
tcase = torture_suite_add_rpc_iface_tcase(suite, "eventlog",
&ndr_table_eventlog);
torture_rpc_tcase_add_test(tcase, "OpenEventLog", test_OpenEventLog);
- torture_rpc_tcase_add_test(tcase, "ClearEventLog", test_ClearEventLog);
+ test = torture_rpc_tcase_add_test(tcase, "ClearEventLog",
+ test_ClearEventLog);
+ test->dangerous = true;
torture_rpc_tcase_add_test(tcase, "GetNumRecords", test_GetNumRecords);
torture_rpc_tcase_add_test(tcase, "ReadEventLog", test_ReadEventLog);
torture_rpc_tcase_add_test(tcase, "FlushEventLog", test_FlushEventLog);
diff --git a/source4/torture/rpc/initshutdown.c b/source4/torture/rpc/initshutdown.c
index 77b86ea3a1..9f6f1735ee 100644
--- a/source4/torture/rpc/initshutdown.c
+++ b/source4/torture/rpc/initshutdown.c
@@ -51,16 +51,12 @@ static bool test_Abort(struct torture_context *tctx,
}
static bool test_Init(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+ struct dcerpc_pipe *p)
{
struct initshutdown_Init r;
NTSTATUS status;
uint16_t hostname = 0x0;
- if (!torture_setting_bool(tctx, "dangerous", false))
- torture_skip(tctx,
- "initshutdown tests disabled - enable dangerous tests to use");
-
r.in.hostname = &hostname;
r.in.message = talloc(tctx, struct initshutdown_String);
init_initshutdown_String(tctx, r.in.message, "spottyfood");
@@ -83,10 +79,6 @@ static bool test_InitEx(struct torture_context *tctx,
NTSTATUS status;
uint16_t hostname = 0x0;
- if (!torture_setting_bool(tctx, "dangerous", false))
- torture_skip(tctx,
- "initshutdown tests disabled - enable dangerous tests to use");
-
r.in.hostname = &hostname;
r.in.message = talloc(tctx, struct initshutdown_String);
init_initshutdown_String(tctx, r.in.message, "spottyfood");
@@ -109,12 +101,15 @@ struct torture_suite *torture_rpc_initshutdown(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "INITSHUTDOWN");
struct torture_rpc_tcase *tcase;
+ struct torture_test *test;
tcase = torture_suite_add_rpc_iface_tcase(suite, "initshutdown",
- &ndr_table_initshutdown);
+ &ndr_table_initshutdown);
- torture_rpc_tcase_add_test(tcase, "Init", test_Init);
- torture_rpc_tcase_add_test(tcase, "InitEx", test_InitEx);
+ test = torture_rpc_tcase_add_test(tcase, "Init", test_Init);
+ test->dangerous = true;
+ test = torture_rpc_tcase_add_test(tcase, "InitEx", test_InitEx);
+ test->dangerous = true;
return suite;
}
diff --git a/source4/torture/rpc/join.c b/source4/torture/rpc/join.c
index 23c43c525e..d0ad97110a 100644
--- a/source4/torture/rpc/join.c
+++ b/source4/torture/rpc/join.c
@@ -8,7 +8,7 @@
#define TORTURE_NETBIOS_NAME "smbtorturejoin"
-BOOL torture_rpc_join(struct torture_context *torture)
+bool torture_rpc_join(struct torture_context *torture)
{
NTSTATUS status;
struct test_join *tj;
@@ -24,7 +24,7 @@ BOOL torture_rpc_join(struct torture_context *torture)
if (!tj) {
DEBUG(0, ("%s failed to join domain as workstation\n",
TORTURE_NETBIOS_NAME));
- return False;
+ return false;
}
status = smbcli_full_connection(tj, &cli, host,
@@ -34,7 +34,7 @@ BOOL torture_rpc_join(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
TORTURE_NETBIOS_NAME));
- return False;
+ return false;
}
smbcli_tdis(cli);
@@ -48,7 +48,7 @@ BOOL torture_rpc_join(struct torture_context *torture)
if (!tj) {
DEBUG(0, ("%s failed to join domain as domain controller\n",
TORTURE_NETBIOS_NAME));
- return False;
+ return false;
}
status = smbcli_full_connection(tj, &cli, host,
@@ -58,7 +58,7 @@ BOOL torture_rpc_join(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
TORTURE_NETBIOS_NAME));
- return False;
+ return false;
}
smbcli_tdis(cli);
@@ -66,6 +66,6 @@ BOOL torture_rpc_join(struct torture_context *torture)
/* Leave domain. */
torture_leave_domain(tj);
- return True;
+ return true;
}
diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c
index cfdf483f8d..1250743955 100644
--- a/source4/torture/rpc/lsa.c
+++ b/source4/torture/rpc/lsa.c
@@ -27,13 +27,14 @@
#include "libcli/security/security.h"
#include "libcli/auth/libcli_auth.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
static void init_lsa_String(struct lsa_String *name, const char *s)
{
name->string = s;
}
-static BOOL test_OpenPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_OpenPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
struct lsa_ObjectAttribute attr;
struct policy_handle handle;
@@ -66,17 +67,17 @@ static BOOL test_OpenPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
printf("not considering %s to be an error\n", nt_errstr(status));
- return True;
+ return true;
}
printf("OpenPolicy failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL test_lsa_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_lsa_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle **handle)
{
struct lsa_ObjectAttribute attr;
@@ -88,7 +89,7 @@ BOOL test_lsa_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
*handle = talloc(mem_ctx, struct policy_handle);
if (!*handle) {
- return False;
+ return false;
}
qos.len = 0;
@@ -115,19 +116,19 @@ BOOL test_lsa_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("not considering %s to be an error\n", nt_errstr(status));
talloc_free(*handle);
*handle = NULL;
- return True;
+ return true;
}
printf("OpenPolicy2 failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_LookupNames(struct dcerpc_pipe *p,
+static bool test_LookupNames(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
- struct lsa_TransNameArray *tnames)
+ struct lsa_TransNameArray *tnames)
{
struct lsa_LookupNames r;
struct lsa_TransSidArray sids;
@@ -156,17 +157,106 @@ static BOOL test_LookupNames(struct dcerpc_pipe *p,
r.out.sids = &sids;
status = dcerpc_lsa_LookupNames(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("LookupNames failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ printf("\n");
+
+ return true;
+}
+
+static bool test_LookupNames_bogus(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle)
+{
+ struct lsa_LookupNames r;
+ struct lsa_TransSidArray sids;
+ struct lsa_String *names;
+ uint32_t count = 0;
+ NTSTATUS status;
+ int i;
+
+ struct lsa_TranslatedName name;
+ struct lsa_TransNameArray tnames;
+
+ tnames.names = &name;
+ tnames.count = 1;
+ name.name.string = "NT AUTHORITY\\BOGUS";
+
+ printf("\nTesting LookupNames with bogus names\n");
+
+ sids.count = 0;
+ sids.sids = NULL;
+
+ names = talloc_array(mem_ctx, struct lsa_String, tnames.count);
+ for (i=0;i<tnames.count;i++) {
+ init_lsa_String(&names[i], tnames.names[i].name.string);
+ }
+
+ r.in.handle = handle;
+ r.in.num_names = tnames.count;
+ r.in.names = names;
+ r.in.sids = &sids;
+ r.in.level = 1;
+ r.in.count = &count;
+ r.out.count = &count;
+ r.out.sids = &sids;
+
+ status = dcerpc_lsa_LookupNames(p, mem_ctx, &r);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) {
printf("LookupNames failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("\n");
- return True;
+ return true;
}
-static BOOL test_LookupNames2(struct dcerpc_pipe *p,
+static bool test_LookupNames_wellknown(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle)
+{
+ struct lsa_TranslatedName name;
+ struct lsa_TransNameArray tnames;
+ bool ret = true;
+
+ printf("Testing LookupNames with well known names\n");
+
+ tnames.names = &name;
+ tnames.count = 1;
+ name.name.string = "NT AUTHORITY\\SYSTEM";
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
+
+ name.name.string = "NT AUTHORITY\\ANONYMOUS LOGON";
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
+
+ name.name.string = "NT AUTHORITY\\Authenticated Users";
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
+
+ name.name.string = "NT AUTHORITY";
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
+
+ name.name.string = "NT AUTHORITY\\";
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
+
+ name.name.string = "BUILTIN\\";
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
+
+ name.name.string = "BUILTIN\\Administrators";
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
+
+ name.name.string = "SYSTEM";
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
+
+ name.name.string = "Everyone";
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
+ return ret;
+}
+
+static bool test_LookupNames2(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_TransNameArray2 *tnames)
@@ -200,18 +290,18 @@ static BOOL test_LookupNames2(struct dcerpc_pipe *p,
r.out.sids = &sids;
status = dcerpc_lsa_LookupNames2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+ if (!NT_STATUS_IS_OK(status)) {
printf("LookupNames2 failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("\n");
- return True;
+ return true;
}
-static BOOL test_LookupNames3(struct dcerpc_pipe *p,
+static bool test_LookupNames3(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_TransNameArray2 *tnames)
@@ -245,17 +335,17 @@ static BOOL test_LookupNames3(struct dcerpc_pipe *p,
r.out.sids = &sids;
status = dcerpc_lsa_LookupNames3(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+ if (!NT_STATUS_IS_OK(status)) {
printf("LookupNames3 failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("\n");
- return True;
+ return true;
}
-static BOOL test_LookupNames4(struct dcerpc_pipe *p,
+static bool test_LookupNames4(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct lsa_TransNameArray2 *tnames)
{
@@ -287,18 +377,18 @@ static BOOL test_LookupNames4(struct dcerpc_pipe *p,
r.out.sids = &sids;
status = dcerpc_lsa_LookupNames4(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+ if (!NT_STATUS_IS_OK(status)) {
printf("LookupNames4 failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("\n");
- return True;
+ return true;
}
-static BOOL test_LookupSids(struct dcerpc_pipe *p,
+static bool test_LookupSids(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_SidArray *sids)
@@ -322,22 +412,22 @@ static BOOL test_LookupSids(struct dcerpc_pipe *p,
r.out.names = &names;
status = dcerpc_lsa_LookupSids(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+ if (!NT_STATUS_IS_OK(status)) {
printf("LookupSids failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("\n");
if (!test_LookupNames(p, mem_ctx, handle, &names)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_LookupSids2(struct dcerpc_pipe *p,
+static bool test_LookupSids2(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_SidArray *sids)
@@ -363,25 +453,25 @@ static BOOL test_LookupSids2(struct dcerpc_pipe *p,
r.out.names = &names;
status = dcerpc_lsa_LookupSids2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+ if (!NT_STATUS_IS_OK(status)) {
printf("LookupSids2 failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("\n");
if (!test_LookupNames2(p, mem_ctx, handle, &names)) {
- return False;
+ return false;
}
if (!test_LookupNames3(p, mem_ctx, handle, &names)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_LookupSids3(struct dcerpc_pipe *p,
+static bool test_LookupSids3(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct lsa_SidArray *sids)
{
@@ -405,27 +495,27 @@ static BOOL test_LookupSids3(struct dcerpc_pipe *p,
r.out.names = &names;
status = dcerpc_lsa_LookupSids3(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+ if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
printf("not considering %s to be an error\n", nt_errstr(status));
- return True;
+ return true;
}
printf("LookupSids3 failed - %s - not considered an error\n",
nt_errstr(status));
- return False;
+ return false;
}
printf("\n");
if (!test_LookupNames4(p, mem_ctx, &names)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL test_many_LookupSids(struct dcerpc_pipe *p,
+bool test_many_LookupSids(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -462,16 +552,15 @@ BOOL test_many_LookupSids(struct dcerpc_pipe *p,
r.out.names = &names;
status = dcerpc_lsa_LookupSids(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) &&
- !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+ if (!NT_STATUS_IS_OK(status)) {
printf("LookupSids failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("\n");
if (!test_LookupNames(p, mem_ctx, handle, &names)) {
- return False;
+ return false;
}
} else {
struct lsa_LookupSids3 r;
@@ -492,18 +581,18 @@ BOOL test_many_LookupSids(struct dcerpc_pipe *p,
r.out.names = &names;
status = dcerpc_lsa_LookupSids3(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+ if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
printf("not considering %s to be an error\n", nt_errstr(status));
- return True;
+ return true;
}
printf("LookupSids3 failed - %s\n",
nt_errstr(status));
- return False;
+ return false;
}
if (!test_LookupNames4(p, mem_ctx, &names)) {
- return False;
+ return false;
}
}
@@ -511,7 +600,7 @@ BOOL test_many_LookupSids(struct dcerpc_pipe *p,
- return True;
+ return true;
}
static void lookupsids_cb(struct rpc_request *req)
@@ -530,7 +619,7 @@ static void lookupsids_cb(struct rpc_request *req)
}
}
-static BOOL test_LookupSids_async(struct dcerpc_pipe *p,
+static bool test_LookupSids_async(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -541,7 +630,7 @@ static BOOL test_LookupSids_async(struct dcerpc_pipe *p,
struct lsa_LookupSids *r;
struct rpc_request **req;
int i, replies;
- BOOL ret = True;
+ bool ret = true;
const int num_async_requests = 50;
count = talloc_array(mem_ctx, uint32_t, num_async_requests);
@@ -573,7 +662,7 @@ static BOOL test_LookupSids_async(struct dcerpc_pipe *p,
req[i] = dcerpc_lsa_LookupSids_send(p, req, &r[i]);
if (req[i] == NULL) {
- ret = False;
+ ret = false;
break;
}
@@ -588,13 +677,13 @@ static BOOL test_LookupSids_async(struct dcerpc_pipe *p,
talloc_free(req);
if (replies < 0) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_LookupPrivValue(struct dcerpc_pipe *p,
+static bool test_LookupPrivValue(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_String *name)
@@ -610,13 +699,13 @@ static BOOL test_LookupPrivValue(struct dcerpc_pipe *p,
status = dcerpc_lsa_LookupPrivValue(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("\nLookupPrivValue failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_LookupPrivName(struct dcerpc_pipe *p,
+static bool test_LookupPrivName(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_LUID *luid)
@@ -630,13 +719,13 @@ static BOOL test_LookupPrivName(struct dcerpc_pipe *p,
status = dcerpc_lsa_LookupPrivName(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("\nLookupPrivName failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p,
+static bool test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *acct_handle,
struct lsa_LUID *luid)
@@ -644,7 +733,7 @@ static BOOL test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p,
NTSTATUS status;
struct lsa_RemovePrivilegesFromAccount r;
struct lsa_PrivilegeSet privs;
- BOOL ret = True;
+ bool ret = true;
printf("Testing RemovePrivilegesFromAccount\n");
@@ -661,13 +750,13 @@ static BOOL test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p,
status = dcerpc_lsa_RemovePrivilegesFromAccount(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("RemovePrivilegesFromAccount failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
return ret;
}
-static BOOL test_AddPrivilegesToAccount(struct dcerpc_pipe *p,
+static bool test_AddPrivilegesToAccount(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *acct_handle,
struct lsa_LUID *luid)
@@ -675,7 +764,7 @@ static BOOL test_AddPrivilegesToAccount(struct dcerpc_pipe *p,
NTSTATUS status;
struct lsa_AddPrivilegesToAccount r;
struct lsa_PrivilegeSet privs;
- BOOL ret = True;
+ bool ret = true;
printf("Testing AddPrivilegesToAccount\n");
@@ -691,20 +780,20 @@ static BOOL test_AddPrivilegesToAccount(struct dcerpc_pipe *p,
status = dcerpc_lsa_AddPrivilegesToAccount(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("AddPrivilegesToAccount failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
return ret;
}
-static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p,
+static bool test_EnumPrivsAccount(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct policy_handle *acct_handle)
{
NTSTATUS status;
struct lsa_EnumPrivsAccount r;
- BOOL ret = True;
+ bool ret = true;
printf("Testing EnumPrivsAccount\n");
@@ -713,7 +802,7 @@ static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p,
status = dcerpc_lsa_EnumPrivsAccount(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumPrivsAccount failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (r.out.privs && r.out.privs->count > 0) {
@@ -732,7 +821,7 @@ static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p,
return ret;
}
-static BOOL test_Delete(struct dcerpc_pipe *p,
+static bool test_Delete(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -745,14 +834,14 @@ static BOOL test_Delete(struct dcerpc_pipe *p,
status = dcerpc_lsa_Delete(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Delete failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_CreateAccount(struct dcerpc_pipe *p,
+static bool test_CreateAccount(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -773,17 +862,17 @@ static BOOL test_CreateAccount(struct dcerpc_pipe *p,
status = dcerpc_lsa_CreateAccount(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("CreateAccount failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!test_Delete(p, mem_ctx, &acct_handle)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_DeleteTrustedDomain(struct dcerpc_pipe *p,
+static bool test_DeleteTrustedDomain(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_StringLarge name)
@@ -800,17 +889,17 @@ static BOOL test_DeleteTrustedDomain(struct dcerpc_pipe *p,
status = dcerpc_lsa_OpenTrustedDomainByName(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("lsa_OpenTrustedDomainByName failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!test_Delete(p, mem_ctx, &trustdom_handle)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_DeleteTrustedDomainBySid(struct dcerpc_pipe *p,
+static bool test_DeleteTrustedDomainBySid(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct dom_sid *sid)
@@ -824,14 +913,14 @@ static BOOL test_DeleteTrustedDomainBySid(struct dcerpc_pipe *p,
status = dcerpc_lsa_DeleteTrustedDomain(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("lsa_DeleteTrustedDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_CreateSecret(struct dcerpc_pipe *p,
+static bool test_CreateSecret(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -850,7 +939,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
struct lsa_DATA_BUF_PTR bufp1;
struct lsa_DATA_BUF_PTR bufp2;
DATA_BLOB enc_key;
- BOOL ret = True;
+ bool ret = true;
DATA_BLOB session_key;
NTTIME old_mtime, new_mtime;
DATA_BLOB blob1, blob2;
@@ -880,7 +969,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_CreateSecret(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("CreateSecret failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r.in.handle = handle;
@@ -890,7 +979,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_CreateSecret(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
printf("CreateSecret should have failed OBJECT_NAME_COLLISION - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r2.in.handle = handle;
@@ -903,13 +992,13 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_OpenSecret(p, mem_ctx, &r2);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenSecret failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_fetch_session_key(p, &session_key);
if (!NT_STATUS_IS_OK(status)) {
printf("dcerpc_fetch_session_key failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
enc_key = sess_encrypt_string(secret1, &session_key);
@@ -926,7 +1015,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_SetSecret(p, mem_ctx, &r3);
if (!NT_STATUS_IS_OK(status)) {
printf("SetSecret failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r3.in.sec_handle = &sec_handle;
@@ -944,7 +1033,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_SetSecret(p, mem_ctx, &r3);
if (!NT_STATUS_EQUAL(status, NT_STATUS_UNKNOWN_REVISION)) {
printf("SetSecret should have failed UNKNOWN_REVISION - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
data_blob_free(&enc_key);
@@ -965,11 +1054,11 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_QuerySecret(p, mem_ctx, &r4);
if (!NT_STATUS_IS_OK(status)) {
printf("QuerySecret failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
if (r4.out.new_val == NULL || r4.out.new_val->buf == NULL) {
printf("No secret buffer returned\n");
- ret = False;
+ ret = false;
} else {
blob1.data = r4.out.new_val->buf->data;
blob1.length = r4.out.new_val->buf->size;
@@ -982,7 +1071,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
if (strcmp(secret1, secret2) != 0) {
printf("Returned secret '%s' doesn't match '%s'\n",
secret2, secret1);
- ret = False;
+ ret = false;
}
}
}
@@ -1001,7 +1090,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_SetSecret(p, mem_ctx, &r5);
if (!NT_STATUS_IS_OK(status)) {
printf("SetSecret failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
data_blob_free(&enc_key);
@@ -1022,14 +1111,14 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_QuerySecret(p, mem_ctx, &r6);
if (!NT_STATUS_IS_OK(status)) {
printf("QuerySecret failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
secret4 = NULL;
} else {
if (r6.out.new_val->buf == NULL || r6.out.old_val->buf == NULL
|| r6.out.new_mtime == NULL || r6.out.old_mtime == NULL) {
printf("Both secret buffers and both times not returned\n");
- ret = False;
+ ret = false;
secret4 = NULL;
} else {
blob1.data = r6.out.new_val->buf->data;
@@ -1042,7 +1131,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
if (strcmp(secret3, secret4) != 0) {
printf("Returned NEW secret %s doesn't match %s\n", secret4, secret3);
- ret = False;
+ ret = false;
}
blob1.data = r6.out.old_val->buf->data;
@@ -1055,14 +1144,14 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
if (strcmp(secret1, secret2) != 0) {
printf("Returned OLD secret %s doesn't match %s\n", secret2, secret1);
- ret = False;
+ ret = false;
}
if (*r6.out.new_mtime == *r6.out.old_mtime) {
printf("Returned secret %s had same mtime for both secrets: %s\n",
secname[i],
nt_time_string(mem_ctx, *r6.out.new_mtime));
- ret = False;
+ ret = false;
}
}
}
@@ -1081,7 +1170,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_SetSecret(p, mem_ctx, &r7);
if (!NT_STATUS_IS_OK(status)) {
printf("SetSecret failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
data_blob_free(&enc_key);
@@ -1099,26 +1188,26 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_QuerySecret(p, mem_ctx, &r8);
if (!NT_STATUS_IS_OK(status)) {
printf("QuerySecret failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
if (!r8.out.new_val || !r8.out.old_val) {
printf("in/out pointers not returned, despite being set on in for QuerySecret\n");
- ret = False;
+ ret = false;
} else if (r8.out.new_val->buf == NULL) {
if (i != LOCAL) {
printf("NEW secret buffer not returned after GLOBAL OLD set\n");
- ret = False;
+ ret = false;
}
} else if (r8.out.old_val->buf == NULL) {
printf("OLD secret buffer not returned after OLD set\n");
- ret = False;
+ ret = false;
} else if (r8.out.new_mtime == NULL || r8.out.old_mtime == NULL) {
printf("Both times not returned after OLD set\n");
- ret = False;
+ ret = false;
} else {
if (i == LOCAL) {
printf("NEW secret buffer should not be returned after LOCAL OLD set\n");
- ret = False;
+ ret = false;
}
blob1.data = r8.out.new_val->buf->data;
blob1.length = r8.out.new_val->buf->length;
@@ -1130,7 +1219,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
if (strcmp(secret3, secret4) != 0) {
printf("Returned NEW secret '%s' doesn't match '%s'\n", secret4, secret3);
- ret = False;
+ ret = false;
}
blob1.data = r8.out.old_val->buf->data;
@@ -1143,7 +1232,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
if (strcmp(secret5, secret6) != 0) {
printf("Returned OLD secret %s doesn't match %s\n", secret5, secret6);
- ret = False;
+ ret = false;
}
if (*r8.out.new_mtime == *r8.out.old_mtime) {
@@ -1151,27 +1240,27 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
printf("Returned secret %s had same mtime for both secrets: %s\n",
secname[i],
nt_time_string(mem_ctx, *r8.out.new_mtime));
- ret = False;
+ ret = false;
}
} else {
printf("Returned secret %s should have had same mtime for both secrets: %s != %s\n",
secname[i],
nt_time_string(mem_ctx, *r8.out.old_mtime),
nt_time_string(mem_ctx, *r8.out.new_mtime));
- ret = False;
+ ret = false;
}
}
}
if (!test_Delete(p, mem_ctx, &sec_handle)) {
- ret = False;
+ ret = false;
}
d.in.handle = &sec_handle2;
status = dcerpc_lsa_Delete(p, mem_ctx, &d);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
printf("Second delete expected INVALID_HANDLE - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
printf("Testing OpenSecret of just-deleted secret\n");
@@ -1179,7 +1268,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
status = dcerpc_lsa_OpenSecret(p, mem_ctx, &r2);
if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
printf("OpenSecret expected OBJECT_NAME_NOT_FOUND - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
}
@@ -1189,7 +1278,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p,
}
-static BOOL test_EnumAccountRights(struct dcerpc_pipe *p,
+static bool test_EnumAccountRights(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *acct_handle,
struct dom_sid *sid)
@@ -1208,14 +1297,14 @@ static BOOL test_EnumAccountRights(struct dcerpc_pipe *p,
if (!NT_STATUS_IS_OK(status)) {
printf("EnumAccountRights of %s failed - %s\n",
dom_sid_string(mem_ctx, sid), nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_QuerySecurity(struct dcerpc_pipe *p,
+static bool test_QuerySecurity(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct policy_handle *acct_handle)
@@ -1223,9 +1312,9 @@ static BOOL test_QuerySecurity(struct dcerpc_pipe *p,
NTSTATUS status;
struct lsa_QuerySecurity r;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping QuerySecurity test against Samba4\n");
- return True;
+ return true;
}
printf("Testing QuerySecurity\n");
@@ -1236,13 +1325,13 @@ static BOOL test_QuerySecurity(struct dcerpc_pipe *p,
status = dcerpc_lsa_QuerySecurity(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("QuerySecurity failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_OpenAccount(struct dcerpc_pipe *p,
+static bool test_OpenAccount(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct dom_sid *sid)
@@ -1261,21 +1350,21 @@ static BOOL test_OpenAccount(struct dcerpc_pipe *p,
status = dcerpc_lsa_OpenAccount(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenAccount failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!test_EnumPrivsAccount(p, mem_ctx, handle, &acct_handle)) {
- return False;
+ return false;
}
if (!test_QuerySecurity(p, mem_ctx, handle, &acct_handle)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_EnumAccounts(struct dcerpc_pipe *p,
+static bool test_EnumAccounts(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -1284,7 +1373,7 @@ static BOOL test_EnumAccounts(struct dcerpc_pipe *p,
struct lsa_SidArray sids1, sids2;
uint32_t resume_handle = 0;
int i;
- BOOL ret = True;
+ bool ret = true;
printf("\ntesting EnumAccounts\n");
@@ -1295,26 +1384,26 @@ static BOOL test_EnumAccounts(struct dcerpc_pipe *p,
r.out.sids = &sids1;
resume_handle = 0;
- while (True) {
+ while (true) {
status = dcerpc_lsa_EnumAccounts(p, mem_ctx, &r);
if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) {
break;
}
if (!NT_STATUS_IS_OK(status)) {
printf("EnumAccounts failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!test_LookupSids(p, mem_ctx, handle, &sids1)) {
- return False;
+ return false;
}
if (!test_LookupSids2(p, mem_ctx, handle, &sids1)) {
- return False;
+ return false;
}
if (!test_LookupSids3(p, mem_ctx, &sids1)) {
- return False;
+ return false;
}
printf("testing all accounts\n");
@@ -1337,18 +1426,18 @@ static BOOL test_EnumAccounts(struct dcerpc_pipe *p,
status = dcerpc_lsa_EnumAccounts(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumAccounts failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (sids2.num_sids != 1) {
printf("Returned wrong number of entries (%d)\n", sids2.num_sids);
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_LookupPrivDisplayName(struct dcerpc_pipe *p,
+static bool test_LookupPrivDisplayName(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_String *priv_name)
@@ -1370,16 +1459,16 @@ static BOOL test_LookupPrivDisplayName(struct dcerpc_pipe *p,
status = dcerpc_lsa_LookupPrivDisplayName(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupPrivDisplayName failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("%s -> \"%s\" (language 0x%x/0x%x)\n",
priv_name->string, r.out.disp_name->string,
*r.in.language_id, *r.out.language_id);
- return True;
+ return true;
}
-static BOOL test_EnumAccountsWithUserRight(struct dcerpc_pipe *p,
+static bool test_EnumAccountsWithUserRight(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_String *priv_name)
@@ -1400,19 +1489,19 @@ static BOOL test_EnumAccountsWithUserRight(struct dcerpc_pipe *p,
/* NT_STATUS_NO_MORE_ENTRIES means noone has this privilege */
if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) {
- return True;
+ return true;
}
if (!NT_STATUS_IS_OK(status)) {
printf("EnumAccountsWithUserRight failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_EnumPrivs(struct dcerpc_pipe *p,
+static bool test_EnumPrivs(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -1421,7 +1510,7 @@ static BOOL test_EnumPrivs(struct dcerpc_pipe *p,
struct lsa_PrivArray privs1;
uint32_t resume_handle = 0;
int i;
- BOOL ret = True;
+ bool ret = true;
printf("\ntesting EnumPrivs\n");
@@ -1435,26 +1524,26 @@ static BOOL test_EnumPrivs(struct dcerpc_pipe *p,
status = dcerpc_lsa_EnumPrivs(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumPrivs failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
for (i = 0; i< privs1.count; i++) {
test_LookupPrivDisplayName(p, mem_ctx, handle, (struct lsa_String *)&privs1.privs[i].name);
test_LookupPrivValue(p, mem_ctx, handle, (struct lsa_String *)&privs1.privs[i].name);
if (!test_EnumAccountsWithUserRight(p, mem_ctx, handle, (struct lsa_String *)&privs1.privs[i].name)) {
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_QueryForestTrustInformation(struct dcerpc_pipe *p,
+static bool test_QueryForestTrustInformation(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
const char *trusted_domain_name)
{
- BOOL ret = True;
+ bool ret = true;
struct lsa_lsaRQueryForestTrustInformation r;
NTSTATUS status;
struct lsa_String string;
@@ -1462,9 +1551,9 @@ static BOOL test_QueryForestTrustInformation(struct dcerpc_pipe *p,
printf("\nTesting lsaRQueryForestTrustInformation\n");
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping QueryForestTrustInformation against Samba4\n");
- return True;
+ return true;
}
ZERO_STRUCT(string);
@@ -1484,19 +1573,19 @@ static BOOL test_QueryForestTrustInformation(struct dcerpc_pipe *p,
if (!NT_STATUS_IS_OK(status)) {
printf("lsaRQueryForestTrustInformation failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_query_each_TrustDomEx(struct dcerpc_pipe *p,
+static bool test_query_each_TrustDomEx(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_DomainListEx *domains)
{
int i;
- BOOL ret = True;
+ bool ret = true;
for (i=0; i< domains->count; i++) {
@@ -1509,14 +1598,14 @@ static BOOL test_query_each_TrustDomEx(struct dcerpc_pipe *p,
return ret;
}
-static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p,
+static bool test_query_each_TrustDom(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
struct lsa_DomainList *domains)
{
NTSTATUS status;
int i,j;
- BOOL ret = True;
+ bool ret = true;
printf("\nTesting OpenTrustedDomain, OpenTrustedDomainByName and QueryInfoTrustedDomain\n");
for (i=0; i< domains->count; i++) {
@@ -1539,7 +1628,7 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p,
if (!NT_STATUS_IS_OK(status)) {
printf("OpenTrustedDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
c.in.handle = &trustdom_handle;
@@ -1558,18 +1647,18 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p,
if (!NT_STATUS_IS_OK(status) && ok[j]) {
printf("QueryTrustedDomainInfo level %d failed - %s\n",
levels[j], nt_errstr(status));
- ret = False;
+ ret = false;
} else if (NT_STATUS_IS_OK(status) && !ok[j]) {
printf("QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n",
levels[j], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
status = dcerpc_lsa_CloseTrustedDomainEx(p, mem_ctx, &c_trust);
if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) {
printf("Expected CloseTrustedDomainEx to return NT_STATUS_NOT_IMPLEMENTED, instead - %s\n", nt_errstr(status));
- return False;
+ return false;
}
c.in.handle = &trustdom_handle;
@@ -1578,7 +1667,7 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p,
status = dcerpc_lsa_Close(p, mem_ctx, &c);
if (!NT_STATUS_IS_OK(status)) {
printf("Close of trusted domain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
for (j=0; j < ARRAY_SIZE(levels); j++) {
@@ -1597,11 +1686,11 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p,
if (!NT_STATUS_IS_OK(status) && ok[j]) {
printf("QueryTrustedDomainInfoBySid level %d failed - %s\n",
levels[j], nt_errstr(status));
- ret = False;
+ ret = false;
} else if (NT_STATUS_IS_OK(status) && !ok[j]) {
printf("QueryTrustedDomainInfoBySid level %d unexpectedly succeeded - %s\n",
levels[j], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
}
@@ -1615,7 +1704,7 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p,
if (!NT_STATUS_IS_OK(status)) {
printf("OpenTrustedDomainByName failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
for (j=0; j < ARRAY_SIZE(levels); j++) {
@@ -1628,11 +1717,11 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p,
if (!NT_STATUS_IS_OK(status) && ok[j]) {
printf("QueryTrustedDomainInfo level %d failed - %s\n",
levels[j], nt_errstr(status));
- ret = False;
+ ret = false;
} else if (NT_STATUS_IS_OK(status) && !ok[j]) {
printf("QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n",
levels[j], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
@@ -1642,7 +1731,7 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p,
status = dcerpc_lsa_Close(p, mem_ctx, &c);
if (!NT_STATUS_IS_OK(status)) {
printf("Close of trusted domain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
for (j=0; j < ARRAY_SIZE(levels); j++) {
@@ -1656,18 +1745,18 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p,
if (!NT_STATUS_IS_OK(status) && ok[j]) {
printf("QueryTrustedDomainInfoByName level %d failed - %s\n",
levels[j], nt_errstr(status));
- ret = False;
+ ret = false;
} else if (NT_STATUS_IS_OK(status) && !ok[j]) {
printf("QueryTrustedDomainInfoByName level %d unexpectedly succeeded - %s\n",
levels[j], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
}
return ret;
}
-static BOOL test_EnumTrustDom(struct dcerpc_pipe *p,
+static bool test_EnumTrustDom(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -1677,7 +1766,7 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p,
uint32_t resume_handle = 0;
struct lsa_DomainList domains;
struct lsa_DomainListEx domains_ex;
- BOOL ret = True;
+ bool ret = true;
printf("\nTesting EnumTrustDom\n");
@@ -1692,7 +1781,7 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p,
/* NO_MORE_ENTRIES is allowed */
if (NT_STATUS_EQUAL(enum_status, NT_STATUS_NO_MORE_ENTRIES)) {
- return True;
+ return true;
} else if (NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES)) {
/* Windows 2003 gets this off by one on the first run */
if (r.out.domains->count < 3 || r.out.domains->count > 4) {
@@ -1700,11 +1789,11 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p,
"asked it to (got %d, expected %d / %d == %d entries)\n",
r.out.domains->count, LSA_ENUM_TRUST_DOMAIN_MULTIPLIER * 3,
LSA_ENUM_TRUST_DOMAIN_MULTIPLIER, r.in.max_size);
- ret = False;
+ ret = false;
}
} else if (!NT_STATUS_IS_OK(enum_status)) {
printf("EnumTrustDom failed - %s\n", nt_errstr(enum_status));
- return False;
+ return false;
}
ret &= test_query_each_TrustDom(p, mem_ctx, handle, &domains);
@@ -1725,7 +1814,7 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p,
/* NO_MORE_ENTRIES is allowed */
if (NT_STATUS_EQUAL(enum_status, NT_STATUS_NO_MORE_ENTRIES)) {
- return True;
+ return true;
} else if (NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES)) {
/* Windows 2003 gets this off by one on the first run */
if (r_ex.out.domains->count < 3 || r_ex.out.domains->count > 4) {
@@ -1735,12 +1824,12 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p,
r_ex.in.max_size,
LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER,
r_ex.in.max_size / LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER);
- ret = False;
+ ret = false;
exit(1);
}
} else if (!NT_STATUS_IS_OK(enum_status)) {
printf("EnumTrustedDomainEx failed - %s\n", nt_errstr(enum_status));
- return False;
+ return false;
}
ret &= test_query_each_TrustDomEx(p, mem_ctx, handle, &domains_ex);
@@ -1750,12 +1839,12 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p,
return ret;
}
-static BOOL test_CreateTrustedDomain(struct dcerpc_pipe *p,
+static bool test_CreateTrustedDomain(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct lsa_CreateTrustedDomain r;
struct lsa_DomainInfo trustinfo;
struct dom_sid *domsid[12];
@@ -1786,7 +1875,7 @@ static BOOL test_CreateTrustedDomain(struct dcerpc_pipe *p,
}
if (!NT_STATUS_IS_OK(status)) {
printf("CreateTrustedDomain failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
q.in.trustdom_handle = &trustdom_handle[i];
@@ -1794,14 +1883,14 @@ static BOOL test_CreateTrustedDomain(struct dcerpc_pipe *p,
status = dcerpc_lsa_QueryTrustedDomainInfo(p, mem_ctx, &q);
if (!NT_STATUS_IS_OK(status)) {
printf("QueryTrustedDomainInfo level 1 failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else if (!q.out.info) {
- ret = False;
+ ret = false;
} else {
if (strcmp(q.out.info->name.netbios_name.string, trustinfo.name.string) != 0) {
printf("QueryTrustedDomainInfo returned inconsistant short name: %s != %s\n",
q.out.info->name.netbios_name.string, trustinfo.name.string);
- ret = False;
+ ret = false;
}
}
}
@@ -1809,29 +1898,29 @@ static BOOL test_CreateTrustedDomain(struct dcerpc_pipe *p,
/* now that we have some domains to look over, we can test the enum calls */
if (!test_EnumTrustDom(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
for (i=0; i<12; i++) {
if (!test_DeleteTrustedDomainBySid(p, mem_ctx, handle, domsid[i])) {
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_QueryDomainInfoPolicy(struct dcerpc_pipe *p,
+static bool test_QueryDomainInfoPolicy(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
struct lsa_QueryDomainInformationPolicy r;
NTSTATUS status;
int i;
- BOOL ret = True;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ bool ret = true;
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping QueryDomainInformationPolicy test against Samba4\n");
- return True;
+ return true;
}
printf("\nTesting QueryDomainInformationPolicy\n");
@@ -1846,7 +1935,7 @@ static BOOL test_QueryDomainInfoPolicy(struct dcerpc_pipe *p,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryDomainInformationPolicy failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
}
@@ -1855,19 +1944,19 @@ static BOOL test_QueryDomainInfoPolicy(struct dcerpc_pipe *p,
}
-static BOOL test_QueryInfoPolicy(struct dcerpc_pipe *p,
+static bool test_QueryInfoPolicy(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
struct lsa_QueryInfoPolicy r;
NTSTATUS status;
int i;
- BOOL ret = True;
+ bool ret = true;
printf("\nTesting QueryInfoPolicy\n");
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping QueryInfoPolicy against Samba4\n");
- return True;
+ return true;
}
for (i=1;i<13;i++) {
@@ -1878,36 +1967,69 @@ static BOOL test_QueryInfoPolicy(struct dcerpc_pipe *p,
status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r);
- if ((i == 9 || i == 10 || i == 11) &&
- NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
- printf("server failed level %u (OK)\n", i);
- continue;
+ switch (i) {
+ case LSA_POLICY_INFO_DB:
+ case LSA_POLICY_INFO_AUDIT_FULL_SET:
+ case LSA_POLICY_INFO_AUDIT_FULL_QUERY:
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
+ printf("server should have failed level %u: %s\n", i, nt_errstr(status));
+ ret = false;
+ }
+ break;
+ case LSA_POLICY_INFO_DOMAIN:
+ case LSA_POLICY_INFO_ACCOUNT_DOMAIN:
+ case LSA_POLICY_INFO_DNS:
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("QueryInfoPolicy failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+ break;
+ default:
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
+ /* Other levels not implemented yet */
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
+ printf("QueryInfoPolicy failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+ } else if (!NT_STATUS_IS_OK(status)) {
+ printf("QueryInfoPolicy failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+ break;
}
- if (!NT_STATUS_IS_OK(status)) {
- printf("QueryInfoPolicy failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
+ if (NT_STATUS_IS_OK(status) && i == LSA_POLICY_INFO_DNS) {
+ /* Let's look up some of these names */
+
+ struct lsa_TransNameArray tnames;
+ tnames.count = 10;
+ tnames.names = talloc_array(mem_ctx, struct lsa_TranslatedName, tnames.count);
+ tnames.names[0].name.string = r.out.info->dns.name.string;
+ tnames.names[1].name.string = r.out.info->dns.dns_domain.string;
+ tnames.names[2].name.string = talloc_asprintf(mem_ctx, "%s\\", r.out.info->dns.name.string);
+ tnames.names[3].name.string = talloc_asprintf(mem_ctx, "%s\\", r.out.info->dns.dns_domain.string);
+ tnames.names[4].name.string = talloc_asprintf(mem_ctx, "%s\\guest", r.out.info->dns.name.string);
+ tnames.names[5].name.string = talloc_asprintf(mem_ctx, "%s\\krbtgt", r.out.info->dns.name.string);
+ tnames.names[6].name.string = talloc_asprintf(mem_ctx, "%s\\guest", r.out.info->dns.dns_domain.string);
+ tnames.names[7].name.string = talloc_asprintf(mem_ctx, "%s\\krbtgt", r.out.info->dns.dns_domain.string);
+ tnames.names[8].name.string = talloc_asprintf(mem_ctx, "krbtgt@%s", r.out.info->dns.name.string);
+ tnames.names[9].name.string = talloc_asprintf(mem_ctx, "krbtgt@%s", r.out.info->dns.dns_domain.string);
+ ret &= test_LookupNames(p, mem_ctx, handle, &tnames);
}
}
return ret;
}
-static BOOL test_QueryInfoPolicy2(struct dcerpc_pipe *p,
+static bool test_QueryInfoPolicy2(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
struct lsa_QueryInfoPolicy2 r;
NTSTATUS status;
int i;
- BOOL ret = True;
+ bool ret = true;
printf("\nTesting QueryInfoPolicy2\n");
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping QueryInfoPolicy2 against Samba4\n");
- return True;
- }
-
for (i=1;i<13;i++) {
r.in.handle = handle;
r.in.level = i;
@@ -1915,28 +2037,47 @@ static BOOL test_QueryInfoPolicy2(struct dcerpc_pipe *p,
printf("\ntrying QueryInfoPolicy2 level %d\n", i);
status = dcerpc_lsa_QueryInfoPolicy2(p, mem_ctx, &r);
-
- if ((i == 9 || i == 10 || i == 11) &&
- NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
- printf("server failed level %u (OK)\n", i);
- continue;
- }
-
- if (!NT_STATUS_IS_OK(status)) {
- printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
+
+ switch (i) {
+ case LSA_POLICY_INFO_DB:
+ case LSA_POLICY_INFO_AUDIT_FULL_SET:
+ case LSA_POLICY_INFO_AUDIT_FULL_QUERY:
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
+ printf("server should have failed level %u: %s\n", i, nt_errstr(status));
+ ret = false;
+ }
+ break;
+ case LSA_POLICY_INFO_DOMAIN:
+ case LSA_POLICY_INFO_ACCOUNT_DOMAIN:
+ case LSA_POLICY_INFO_DNS:
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+ break;
+ default:
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
+ /* Other levels not implemented yet */
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
+ printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+ } else if (!NT_STATUS_IS_OK(status)) {
+ printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+ break;
}
}
return ret;
}
-static BOOL test_GetUserName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_GetUserName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
struct lsa_GetUserName r;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct lsa_StringPointer authority_name_p;
printf("\nTesting GetUserName\n");
@@ -1950,13 +2091,13 @@ static BOOL test_GetUserName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
if (!NT_STATUS_IS_OK(status)) {
printf("GetUserName failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-BOOL test_lsa_Close(struct dcerpc_pipe *p,
+bool test_lsa_Close(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -1972,27 +2113,27 @@ BOOL test_lsa_Close(struct dcerpc_pipe *p,
status = dcerpc_lsa_Close(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Close failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_lsa_Close(p, mem_ctx, &r);
/* its really a fault - we need a status code for rpc fault */
if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
printf("Close failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("\n");
- return True;
+ return true;
}
-BOOL torture_rpc_lsa(struct torture_context *torture)
+bool torture_rpc_lsa(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct policy_handle *handle;
mem_ctx = talloc_init("torture_rpc_lsa");
@@ -2000,75 +2141,83 @@ BOOL torture_rpc_lsa(struct torture_context *torture)
status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (!test_OpenPolicy(p, mem_ctx)) {
- ret = False;
+ ret = false;
}
if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
- ret = False;
+ ret = false;
}
if (handle) {
+ if (!test_LookupNames_wellknown(p, mem_ctx, handle)) {
+ ret = false;
+ }
+
+ if (!test_LookupNames_bogus(p, mem_ctx, handle)) {
+ ret = false;
+ }
+
if (!test_LookupSids_async(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryDomainInfoPolicy(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
if (!test_CreateAccount(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
if (!test_CreateSecret(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
if (!test_CreateTrustedDomain(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
if (!test_EnumAccounts(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
if (!test_EnumPrivs(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryInfoPolicy(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryInfoPolicy2(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
#if 0
if (!test_Delete(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
#endif
if (!test_many_LookupSids(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
if (!test_lsa_Close(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
} else {
if (!test_many_LookupSids(p, mem_ctx, handle)) {
- ret = False;
+ ret = false;
}
}
if (!test_GetUserName(p, mem_ctx)) {
- ret = False;
+ ret = false;
}
talloc_free(mem_ctx);
@@ -2076,23 +2225,23 @@ BOOL torture_rpc_lsa(struct torture_context *torture)
return ret;
}
-BOOL torture_rpc_lsa_get_user(struct torture_context *torture)
+bool torture_rpc_lsa_get_user(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
mem_ctx = talloc_init("torture_rpc_lsa_get_user");
status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (!test_GetUserName(p, mem_ctx)) {
- ret = False;
+ ret = false;
}
talloc_free(mem_ctx);
diff --git a/source4/torture/rpc/lsa_lookup.c b/source4/torture/rpc/lsa_lookup.c
index d90c3694a9..9c817a7061 100644
--- a/source4/torture/rpc/lsa_lookup.c
+++ b/source4/torture/rpc/lsa_lookup.c
@@ -26,7 +26,7 @@
#include "librpc/gen_ndr/ndr_lsa_c.h"
#include "libcli/security/security.h"
-static BOOL open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
+static bool open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
struct policy_handle **handle)
{
struct lsa_ObjectAttribute attr;
@@ -36,7 +36,7 @@ static BOOL open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
*handle = talloc(mem_ctx, struct policy_handle);
if (!*handle) {
- return False;
+ return false;
}
qos.len = 0;
@@ -61,7 +61,7 @@ static BOOL open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
return NT_STATUS_IS_OK(status);
}
-static BOOL get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
+static bool get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
struct policy_handle *handle,
struct dom_sid **sid)
{
@@ -72,10 +72,10 @@ static BOOL get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
r.in.handle = handle;
status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) return False;
+ if (!NT_STATUS_IS_OK(status)) return false;
*sid = r.out.info->domain.sid;
- return True;
+ return true;
}
static NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, uint16_t level,
@@ -122,11 +122,12 @@ static const char *sid_type_lookup(enum lsa_SidType r)
case SID_NAME_DELETED: return "SID_NAME_DELETED"; break;
case SID_NAME_INVALID: return "SID_NAME_INVALID"; break;
case SID_NAME_UNKNOWN: return "SID_NAME_UNKNOWN"; break;
+ case SID_NAME_COMPUTER: return "SID_NAME_COMPUTER"; break;
}
return "Invalid sid type\n";
}
-static BOOL test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
+static bool test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
struct policy_handle *handle,
struct dom_sid **sids, uint32_t num_sids,
int level, NTSTATUS expected_result,
@@ -135,7 +136,7 @@ static BOOL test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
struct lsa_TransNameArray names;
NTSTATUS status;
uint32_t i;
- BOOL ret = True;
+ bool ret = true;
status = lookup_sids(mem_ctx, level, p, handle, sids, num_sids,
&names);
@@ -143,12 +144,12 @@ static BOOL test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
printf("For level %d expected %s, got %s\n",
level, nt_errstr(expected_result),
nt_errstr(status));
- return False;
+ return false;
}
if (!NT_STATUS_EQUAL(status, NT_STATUS_OK) &&
!NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
- return True;
+ return true;
}
for (i=0; i<num_sids; i++) {
@@ -158,13 +159,13 @@ static BOOL test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
dom_sid_string(mem_ctx, sids[i]),
sid_type_lookup(types[i]),
sid_type_lookup(names.names[i].sid_type));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL get_downleveltrust(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
+static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_pipe *p,
struct policy_handle *handle,
struct dom_sid **sid)
{
@@ -180,16 +181,13 @@ static BOOL get_downleveltrust(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
r.out.domains = &domains;
r.out.resume_handle = &resume_handle;
- status = dcerpc_lsa_EnumTrustDom(p, mem_ctx, &r);
+ status = dcerpc_lsa_EnumTrustDom(p, tctx, &r);
- if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) {
- printf("no trusts\n");
- return False;
- }
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))
+ torture_fail(tctx, "no trusts");
if (domains.count == 0) {
- printf("no trusts\n");
- return False;
+ torture_fail(tctx, "no trusts");
}
for (i=0; i<domains.count; i++) {
@@ -201,62 +199,58 @@ static BOOL get_downleveltrust(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
q.in.handle = handle;
q.in.dom_sid = domains.domains[i].sid;
q.in.level = 6;
- status = dcerpc_lsa_QueryTrustedDomainInfoBySid(p, mem_ctx, &q);
+ status = dcerpc_lsa_QueryTrustedDomainInfoBySid(p, tctx, &q);
if (!NT_STATUS_IS_OK(status)) continue;
if ((q.out.info->info_ex.trust_direction & 2) &&
(q.out.info->info_ex.trust_type == 1)) {
*sid = domains.domains[i].sid;
- return True;
+ return true;
}
}
- printf("I need a AD DC with an outgoing trust to NT4\n");
- return False;
+ torture_fail(tctx, "I need a AD DC with an outgoing trust to NT4");
}
#define NUM_SIDS 8
-BOOL torture_rpc_lsa_lookup(struct torture_context *torture)
+bool torture_rpc_lsa_lookup(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct policy_handle *handle;
struct dom_sid *dom_sid;
struct dom_sid *trusted_sid;
struct dom_sid *sids[NUM_SIDS];
- mem_ctx = talloc_init("torture_rpc_lsa");
-
status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
- goto done;
+ torture_fail(torture, "unable to connect to table");
}
- ret &= open_policy(mem_ctx, p, &handle);
- if (!ret) goto done;
+ ret &= open_policy(torture, p, &handle);
+ if (!ret) return false;
- ret &= get_domainsid(mem_ctx, p, handle, &dom_sid);
- if (!ret) goto done;
+ ret &= get_domainsid(torture, p, handle, &dom_sid);
+ if (!ret) return false;
- ret &= get_downleveltrust(mem_ctx, p, handle, &trusted_sid);
- if (!ret) goto done;
+ ret &= get_downleveltrust(torture, p, handle, &trusted_sid);
+ if (!ret) return false;
- printf("domain sid: %s\n", dom_sid_string(mem_ctx, dom_sid));
+ torture_comment(torture, "domain sid: %s\n",
+ dom_sid_string(torture, dom_sid));
- sids[0] = dom_sid_parse_talloc(mem_ctx, "S-1-1-0");
- sids[1] = dom_sid_parse_talloc(mem_ctx, "S-1-5-4");
- sids[2] = dom_sid_parse_talloc(mem_ctx, "S-1-5-32");
- sids[3] = dom_sid_parse_talloc(mem_ctx, "S-1-5-32-545");
- sids[4] = dom_sid_dup(mem_ctx, dom_sid);
- sids[5] = dom_sid_add_rid(mem_ctx, dom_sid, 512);
- sids[6] = dom_sid_dup(mem_ctx, trusted_sid);
- sids[7] = dom_sid_add_rid(mem_ctx, trusted_sid, 512);
+ sids[0] = dom_sid_parse_talloc(torture, "S-1-1-0");
+ sids[1] = dom_sid_parse_talloc(torture, "S-1-5-4");
+ sids[2] = dom_sid_parse_talloc(torture, "S-1-5-32");
+ sids[3] = dom_sid_parse_talloc(torture, "S-1-5-32-545");
+ sids[4] = dom_sid_dup(torture, dom_sid);
+ sids[5] = dom_sid_add_rid(torture, dom_sid, 512);
+ sids[6] = dom_sid_dup(torture, trusted_sid);
+ sids[7] = dom_sid_add_rid(torture, trusted_sid, 512);
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 0,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 0,
NT_STATUS_INVALID_PARAMETER, NULL);
{
@@ -265,7 +259,7 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture)
SID_NAME_ALIAS, SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
SID_NAME_DOMAIN, SID_NAME_DOM_GRP };
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 1,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 1,
NT_STATUS_OK, types);
}
@@ -275,7 +269,7 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture)
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN,
SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
SID_NAME_DOMAIN, SID_NAME_DOM_GRP };
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 2,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 2,
STATUS_SOME_UNMAPPED, types);
}
@@ -285,7 +279,7 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture)
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN,
SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN };
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 3,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 3,
STATUS_SOME_UNMAPPED, types);
}
@@ -295,11 +289,11 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture)
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN,
SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN };
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 4,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 4,
STATUS_SOME_UNMAPPED, types);
}
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 5,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 5,
NT_STATUS_NONE_MAPPED, NULL);
{
@@ -308,21 +302,18 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture)
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN,
SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN };
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 6,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 6,
STATUS_SOME_UNMAPPED, types);
}
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 7,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 7,
NT_STATUS_INVALID_PARAMETER, NULL);
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 8,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 8,
NT_STATUS_INVALID_PARAMETER, NULL);
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 9,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 9,
NT_STATUS_INVALID_PARAMETER, NULL);
- ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 10,
+ ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 10,
NT_STATUS_INVALID_PARAMETER, NULL);
- done:
- talloc_free(mem_ctx);
-
return ret;
}
diff --git a/source4/torture/rpc/mgmt.c b/source4/torture/rpc/mgmt.c
index 6d0c3d56c9..258450ada1 100644
--- a/source4/torture/rpc/mgmt.c
+++ b/source4/torture/rpc/mgmt.c
@@ -24,14 +24,15 @@
#include "auth/gensec/gensec.h"
#include "librpc/ndr/ndr_table.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
/*
ask the server what interface IDs are available on this endpoint
*/
-BOOL test_inq_if_ids(struct torture_context *tctx,
+bool test_inq_if_ids(struct torture_context *tctx,
struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- BOOL (*per_id_test)(struct torture_context *,
+ bool (*per_id_test)(struct torture_context *,
const struct ndr_interface_table *iface,
TALLOC_CTX *mem_ctx,
struct ndr_syntax_id *id),
@@ -48,17 +49,17 @@ BOOL test_inq_if_ids(struct torture_context *tctx,
status = dcerpc_mgmt_inq_if_ids(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("inq_if_ids failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!W_ERROR_IS_OK(r.out.result)) {
printf("inq_if_ids gave error code %s\n", win_errstr(r.out.result));
- return False;
+ return false;
}
if (!vector) {
printf("inq_if_ids gave NULL if_id_vector\n");
- return False;
+ return false;
}
for (i=0;i<vector->count;i++) {
@@ -75,10 +76,10 @@ BOOL test_inq_if_ids(struct torture_context *tctx,
}
}
- return True;
+ return true;
}
-static BOOL test_inq_stats(struct dcerpc_pipe *p,
+static bool test_inq_stats(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
@@ -92,12 +93,12 @@ static BOOL test_inq_stats(struct dcerpc_pipe *p,
status = dcerpc_mgmt_inq_stats(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("inq_stats failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (statistics.count != MGMT_STATS_ARRAY_MAX_SIZE) {
printf("Unexpected array size %d\n", statistics.count);
- return False;
+ return false;
}
printf("\tcalls_in %6d calls_out %6d\n\tpkts_in %6d pkts_out %6d\n",
@@ -106,16 +107,16 @@ static BOOL test_inq_stats(struct dcerpc_pipe *p,
statistics.statistics[MGMT_STATS_PKTS_IN],
statistics.statistics[MGMT_STATS_PKTS_OUT]);
- return True;
+ return true;
}
-static BOOL test_inq_princ_name(struct dcerpc_pipe *p,
+static bool test_inq_princ_name(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
struct mgmt_inq_princ_name r;
int i;
- BOOL ret = False;
+ bool ret = false;
for (i=0;i<100;i++) {
r.in.authn_proto = i; /* DCERPC_AUTH_TYPE_* */
@@ -127,7 +128,7 @@ static BOOL test_inq_princ_name(struct dcerpc_pipe *p,
}
if (W_ERROR_IS_OK(r.out.result)) {
const char *name = gensec_get_name_by_authtype(i);
- ret = True;
+ ret = true;
if (name) {
printf("\tprinciple name for proto %u (%s) is '%s'\n",
i, name, r.out.princ_name);
@@ -142,10 +143,10 @@ static BOOL test_inq_princ_name(struct dcerpc_pipe *p,
printf("\tno principle names?\n");
}
- return True;
+ return true;
}
-static BOOL test_is_server_listening(struct dcerpc_pipe *p,
+static bool test_is_server_listening(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
@@ -155,7 +156,7 @@ static BOOL test_is_server_listening(struct dcerpc_pipe *p,
status = dcerpc_mgmt_is_server_listening(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("is_server_listening failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (*r.out.status != 0 || r.out.result == 0) {
@@ -164,10 +165,10 @@ static BOOL test_is_server_listening(struct dcerpc_pipe *p,
printf("\tserver is listening\n");
}
- return True;
+ return true;
}
-static BOOL test_stop_server_listening(struct dcerpc_pipe *p,
+static bool test_stop_server_listening(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
@@ -176,26 +177,26 @@ static BOOL test_stop_server_listening(struct dcerpc_pipe *p,
status = dcerpc_mgmt_stop_server_listening(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("stop_server_listening failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!W_ERROR_IS_OK(r.out.result)) {
printf("\tserver refused to stop listening - %s\n", win_errstr(r.out.result));
} else {
printf("\tserver allowed a stop_server_listening request\n");
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_rpc_mgmt(struct torture_context *torture)
+bool torture_rpc_mgmt(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx, *loop_ctx;
- BOOL ret = True;
+ bool ret = true;
const struct ndr_interface_list *l;
struct dcerpc_binding *b;
@@ -204,7 +205,7 @@ BOOL torture_rpc_mgmt(struct torture_context *torture)
status = torture_rpc_binding(torture, &b);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
for (l=ndr_table_list();l;l=l->next) {
@@ -227,7 +228,7 @@ BOOL torture_rpc_mgmt(struct torture_context *torture)
continue;
}
- lp_set_cmdline("torture:binding", dcerpc_binding_string(loop_ctx, b));
+ lp_set_cmdline(global_loadparm, "torture:binding", dcerpc_binding_string(loop_ctx, b));
status = torture_rpc_connection(torture, &p, &ndr_table_mgmt);
if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
@@ -238,28 +239,28 @@ BOOL torture_rpc_mgmt(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
talloc_free(loop_ctx);
- ret = False;
+ ret = false;
continue;
}
if (!test_is_server_listening(p, loop_ctx)) {
- ret = False;
+ ret = false;
}
if (!test_stop_server_listening(p, loop_ctx)) {
- ret = False;
+ ret = false;
}
if (!test_inq_stats(p, loop_ctx)) {
- ret = False;
+ ret = false;
}
if (!test_inq_princ_name(p, loop_ctx)) {
- ret = False;
+ ret = false;
}
if (!test_inq_if_ids(torture, p, loop_ctx, NULL, NULL)) {
- ret = False;
+ ret = false;
}
}
diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c
index df69a097b6..3ff0561f77 100644
--- a/source4/torture/rpc/netlogon.c
+++ b/source4/torture/rpc/netlogon.c
@@ -30,66 +30,44 @@
#include "libcli/auth/libcli_auth.h"
#include "librpc/gen_ndr/ndr_netlogon_c.h"
#include "librpc/gen_ndr/ndr_lsa_c.h"
-
-static const char *machine_password;
+#include "param/param.h"
#define TEST_MACHINE_NAME "torturetest"
-static BOOL test_LogonUasLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_LogonUasLogon(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_LogonUasLogon r;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping LogonUasLogon test against Samba4\n");
- return True;
- }
-
r.in.server_name = NULL;
r.in.account_name = cli_credentials_get_username(cmdline_credentials);
r.in.workstation = TEST_MACHINE_NAME;
- printf("Testing LogonUasLogon\n");
-
- status = dcerpc_netr_LogonUasLogon(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonUasLogon - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_LogonUasLogon(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonUasLogon");
- return True;
-
+ return true;
}
-static BOOL test_LogonUasLogoff(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_LogonUasLogoff(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_LogonUasLogoff r;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping LogonUasLogoff test against Samba4\n");
- return True;
- }
-
r.in.server_name = NULL;
r.in.account_name = cli_credentials_get_username(cmdline_credentials);
r.in.workstation = TEST_MACHINE_NAME;
- printf("Testing LogonUasLogoff\n");
+ status = dcerpc_netr_LogonUasLogoff(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonUasLogoff");
- status = dcerpc_netr_LogonUasLogoff(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonUasLogoff - %s\n", nt_errstr(status));
- return False;
- }
-
- return True;
-
+ return true;
}
-static BOOL test_SetupCredentials(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- const char *machine_name,
- const char *plain_pass,
+static bool test_SetupCredentials(struct dcerpc_pipe *p, struct torture_context *tctx,
+ struct cli_credentials *credentials,
struct creds_CredentialState **creds_out)
{
NTSTATUS status;
@@ -98,13 +76,16 @@ static BOOL test_SetupCredentials(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct netr_Credential credentials1, credentials2, credentials3;
struct creds_CredentialState *creds;
struct samr_Password mach_password;
+ const char *plain_pass;
+ const char *machine_name;
- printf("Testing ServerReqChallenge\n");
+ plain_pass = cli_credentials_get_password(credentials);
+ machine_name = cli_credentials_get_workstation(credentials);
- creds = talloc(mem_ctx, struct creds_CredentialState);
- if (!creds) {
- return False;
- }
+ torture_comment(tctx, "Testing ServerReqChallenge\n");
+
+ creds = talloc(tctx, struct creds_CredentialState);
+ torture_assert(tctx, creds != NULL, "memory allocation");
r.in.server_name = NULL;
r.in.computer_name = machine_name;
@@ -113,16 +94,13 @@ static BOOL test_SetupCredentials(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
generate_random_buffer(credentials1.data, sizeof(credentials1.data));
- status = dcerpc_netr_ServerReqChallenge(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerReqChallenge - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerReqChallenge(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ServerReqChallenge");
E_md4hash(plain_pass, mach_password.hash);
a.in.server_name = NULL;
- a.in.account_name = talloc_asprintf(mem_ctx, "%s$", machine_name);
+ a.in.account_name = talloc_asprintf(tctx, "%s$", machine_name);
a.in.secure_channel_type = SEC_CHAN_BDC;
a.in.computer_name = machine_name;
a.in.credentials = &credentials3;
@@ -132,27 +110,21 @@ static BOOL test_SetupCredentials(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
&mach_password, &credentials3,
0);
- printf("Testing ServerAuthenticate\n");
+ torture_comment(tctx, "Testing ServerAuthenticate\n");
- status = dcerpc_netr_ServerAuthenticate(p, mem_ctx, &a);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerAuthenticate - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerAuthenticate(p, tctx, &a);
+ torture_assert_ntstatus_ok(tctx, status, "ServerAuthenticate");
- if (!creds_client_check(creds, &credentials3)) {
- printf("Credential chaining failed\n");
- return False;
- }
+ torture_assert(tctx, creds_client_check(creds, &credentials3),
+ "Credential chaining failed");
*creds_out = creds;
- return True;
+ return true;
}
-static BOOL test_SetupCredentials2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetupCredentials2(struct dcerpc_pipe *p, struct torture_context *tctx,
uint32_t negotiate_flags,
- const char *machine_name,
- const char *plain_pass,
+ struct cli_credentials *machine_credentials,
int sec_chan_type,
struct creds_CredentialState **creds_out)
{
@@ -162,13 +134,16 @@ static BOOL test_SetupCredentials2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct netr_Credential credentials1, credentials2, credentials3;
struct creds_CredentialState *creds;
struct samr_Password mach_password;
+ const char *machine_name;
+ const char *plain_pass;
- printf("Testing ServerReqChallenge\n");
+ machine_name = cli_credentials_get_workstation(machine_credentials);
+ plain_pass = cli_credentials_get_password(machine_credentials);
- creds = talloc(mem_ctx, struct creds_CredentialState);
- if (!creds) {
- return False;
- }
+ torture_comment(tctx, "Testing ServerReqChallenge\n");
+
+ creds = talloc(tctx, struct creds_CredentialState);
+ torture_assert(tctx, creds != NULL, "memory allocation");
r.in.server_name = NULL;
r.in.computer_name = machine_name;
@@ -177,16 +152,13 @@ static BOOL test_SetupCredentials2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
generate_random_buffer(credentials1.data, sizeof(credentials1.data));
- status = dcerpc_netr_ServerReqChallenge(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerReqChallenge - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerReqChallenge(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ServerReqChallenge");
E_md4hash(plain_pass, mach_password.hash);
a.in.server_name = NULL;
- a.in.account_name = talloc_asprintf(mem_ctx, "%s$", machine_name);
+ a.in.account_name = talloc_asprintf(tctx, "%s$", machine_name);
a.in.secure_channel_type = sec_chan_type;
a.in.computer_name = machine_name;
a.in.negotiate_flags = &negotiate_flags;
@@ -198,30 +170,24 @@ static BOOL test_SetupCredentials2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
&mach_password, &credentials3,
negotiate_flags);
- printf("Testing ServerAuthenticate2\n");
+ torture_comment(tctx, "Testing ServerAuthenticate2\n");
- status = dcerpc_netr_ServerAuthenticate2(p, mem_ctx, &a);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerAuthenticate2 - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerAuthenticate2(p, tctx, &a);
+ torture_assert_ntstatus_ok(tctx, status, "ServerAuthenticate2");
- if (!creds_client_check(creds, &credentials3)) {
- printf("Credential chaining failed\n");
- return False;
- }
+ torture_assert(tctx, creds_client_check(creds, &credentials3),
+ "Credential chaining failed");
- printf("negotiate_flags=0x%08x\n", negotiate_flags);
+ torture_comment(tctx, "negotiate_flags=0x%08x\n", negotiate_flags);
*creds_out = creds;
- return True;
+ return true;
}
-static BOOL test_SetupCredentials3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetupCredentials3(struct dcerpc_pipe *p, struct torture_context *tctx,
uint32_t negotiate_flags,
- const char *machine_name,
- const char *plain_pass,
+ struct cli_credentials *machine_credentials,
struct creds_CredentialState **creds_out)
{
NTSTATUS status;
@@ -231,13 +197,16 @@ static BOOL test_SetupCredentials3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct creds_CredentialState *creds;
struct samr_Password mach_password;
uint32_t rid;
+ const char *machine_name;
+ const char *plain_pass;
- printf("Testing ServerReqChallenge\n");
+ machine_name = cli_credentials_get_workstation(machine_credentials);
+ plain_pass = cli_credentials_get_password(machine_credentials);
- creds = talloc(mem_ctx, struct creds_CredentialState);
- if (!creds) {
- return False;
- }
+ torture_comment(tctx, "Testing ServerReqChallenge\n");
+
+ creds = talloc(tctx, struct creds_CredentialState);
+ torture_assert(tctx, creds != NULL, "memory allocation");
r.in.server_name = NULL;
r.in.computer_name = machine_name;
@@ -246,16 +215,13 @@ static BOOL test_SetupCredentials3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
generate_random_buffer(credentials1.data, sizeof(credentials1.data));
- status = dcerpc_netr_ServerReqChallenge(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerReqChallenge - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerReqChallenge(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ServerReqChallenge");
E_md4hash(plain_pass, mach_password.hash);
a.in.server_name = NULL;
- a.in.account_name = talloc_asprintf(mem_ctx, "%s$", machine_name);
+ a.in.account_name = talloc_asprintf(tctx, "%s$", machine_name);
a.in.secure_channel_type = SEC_CHAN_BDC;
a.in.computer_name = machine_name;
a.in.negotiate_flags = &negotiate_flags;
@@ -268,98 +234,90 @@ static BOOL test_SetupCredentials3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
&mach_password, &credentials3,
negotiate_flags);
- printf("Testing ServerAuthenticate3\n");
+ torture_comment(tctx, "Testing ServerAuthenticate3\n");
- status = dcerpc_netr_ServerAuthenticate3(p, mem_ctx, &a);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerAuthenticate3 - %s\n", nt_errstr(status));
- return False;
- }
-
- if (!creds_client_check(creds, &credentials3)) {
- printf("Credential chaining failed\n");
- return False;
- }
+ status = dcerpc_netr_ServerAuthenticate3(p, tctx, &a);
+ torture_assert_ntstatus_ok(tctx, status, "ServerAuthenticate3");
+ torture_assert(tctx, creds_client_check(creds, &credentials3), "Credential chaining failed");
- printf("negotiate_flags=0x%08x\n", negotiate_flags);
+ torture_comment(tctx, "negotiate_flags=0x%08x\n", negotiate_flags);
*creds_out = creds;
- return True;
+ return true;
}
/*
try a change password for our machine account
*/
-static BOOL test_SetPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_SetPassword(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *machine_credentials)
{
NTSTATUS status;
struct netr_ServerPasswordSet r;
const char *password;
struct creds_CredentialState *creds;
- if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME,
- machine_password, &creds)) {
- return False;
+ if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) {
+ return false;
}
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
- r.in.account_name = talloc_asprintf(mem_ctx, "%s$", TEST_MACHINE_NAME);
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.account_name = talloc_asprintf(tctx, "%s$", TEST_MACHINE_NAME);
r.in.secure_channel_type = SEC_CHAN_BDC;
r.in.computer_name = TEST_MACHINE_NAME;
- password = generate_random_str(mem_ctx, 8);
+ password = generate_random_str(tctx, 8);
E_md4hash(password, r.in.new_password.hash);
creds_des_encrypt(creds, &r.in.new_password);
- printf("Testing ServerPasswordSet on machine account\n");
- d_printf("Changing machine account password to '%s'\n", password);
+ torture_comment(tctx, "Testing ServerPasswordSet on machine account\n");
+ torture_comment(tctx, "Changing machine account password to '%s'\n",
+ password);
creds_client_authenticator(creds, &r.in.credential);
- status = dcerpc_netr_ServerPasswordSet(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerPasswordSet - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerPasswordSet(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet");
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
- printf("Credential chaining failed\n");
+ torture_comment(tctx, "Credential chaining failed\n");
}
/* by changing the machine password twice we test the
credentials chaining fully, and we verify that the server
allows the password to be set to the same value twice in a
row (match win2k3) */
- printf("Testing a second ServerPasswordSet on machine account\n");
- d_printf("Changing machine account password to '%s' (same as previous run)\n", password);
+ torture_comment(tctx,
+ "Testing a second ServerPasswordSet on machine account\n");
+ torture_comment(tctx,
+ "Changing machine account password to '%s' (same as previous run)\n", password);
creds_client_authenticator(creds, &r.in.credential);
- status = dcerpc_netr_ServerPasswordSet(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerPasswordSet (2) - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerPasswordSet(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet (2)");
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
- printf("Credential chaining failed\n");
+ torture_comment(tctx, "Credential chaining failed\n");
}
- machine_password = password;
+ cli_credentials_set_password(machine_credentials, password, CRED_SPECIFIED);
- if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) {
- printf("ServerPasswordSet failed to actually change the password\n");
- return False;
- }
+ torture_assert(tctx,
+ test_SetupCredentials(p, tctx, machine_credentials, &creds),
+ "ServerPasswordSet failed to actually change the password");
- return True;
+ return true;
}
/*
try a change password for our machine account
*/
-static BOOL test_SetPassword2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_SetPassword2(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *machine_credentials)
{
NTSTATUS status;
struct netr_ServerPasswordSet2 r;
@@ -367,42 +325,39 @@ static BOOL test_SetPassword2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
struct creds_CredentialState *creds;
struct samr_CryptPassword password_buf;
- if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME,
- machine_password, &creds)) {
- return False;
+ if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) {
+ return false;
}
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
- r.in.account_name = talloc_asprintf(mem_ctx, "%s$", TEST_MACHINE_NAME);
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.account_name = talloc_asprintf(tctx, "%s$", TEST_MACHINE_NAME);
r.in.secure_channel_type = SEC_CHAN_BDC;
r.in.computer_name = TEST_MACHINE_NAME;
- password = generate_random_str(mem_ctx, 8);
+ password = generate_random_str(tctx, 8);
encode_pw_buffer(password_buf.data, password, STR_UNICODE);
creds_arcfour_crypt(creds, password_buf.data, 516);
memcpy(r.in.new_password.data, password_buf.data, 512);
r.in.new_password.length = IVAL(password_buf.data, 512);
- printf("Testing ServerPasswordSet2 on machine account\n");
- d_printf("Changing machine account password to '%s'\n", password);
+ torture_comment(tctx, "Testing ServerPasswordSet2 on machine account\n");
+ torture_comment(tctx, "Changing machine account password to '%s'\n", password);
creds_client_authenticator(creds, &r.in.credential);
- status = dcerpc_netr_ServerPasswordSet2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerPasswordSet2 - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerPasswordSet2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet2");
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
- printf("Credential chaining failed\n");
+ torture_comment(tctx, "Credential chaining failed\n");
}
- machine_password = password;
+ cli_credentials_set_password(machine_credentials, password, CRED_SPECIFIED);
- if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
- printf("Not testing ability to set password to '', enable dangerous tests to perform this test\n");
+ if (!torture_setting_bool(tctx, "dangerous", false)) {
+ torture_comment(tctx,
+ "Not testing ability to set password to '', enable dangerous tests to perform this test\n");
} else {
/* by changing the machine password to ""
* we check if the server uses password restrictions
@@ -416,85 +371,77 @@ static BOOL test_SetPassword2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
memcpy(r.in.new_password.data, password_buf.data, 512);
r.in.new_password.length = IVAL(password_buf.data, 512);
- printf("Testing ServerPasswordSet2 on machine account\n");
- d_printf("Changing machine account password to '%s'\n", password);
+ torture_comment(tctx,
+ "Testing ServerPasswordSet2 on machine account\n");
+ torture_comment(tctx,
+ "Changing machine account password to '%s'\n", password);
creds_client_authenticator(creds, &r.in.credential);
- status = dcerpc_netr_ServerPasswordSet2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerPasswordSet2 - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerPasswordSet2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet2");
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
- printf("Credential chaining failed\n");
+ torture_comment(tctx, "Credential chaining failed\n");
}
- machine_password = password;
+ cli_credentials_set_password(machine_credentials, password, CRED_SPECIFIED);
}
- if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) {
- printf("ServerPasswordSet failed to actually change the password\n");
- return False;
- }
+ torture_assert(tctx, test_SetupCredentials(p, tctx, machine_credentials, &creds),
+ "ServerPasswordSet failed to actually change the password");
/* now try a random password */
- password = generate_random_str(mem_ctx, 8);
+ password = generate_random_str(tctx, 8);
encode_pw_buffer(password_buf.data, password, STR_UNICODE);
creds_arcfour_crypt(creds, password_buf.data, 516);
memcpy(r.in.new_password.data, password_buf.data, 512);
r.in.new_password.length = IVAL(password_buf.data, 512);
- printf("Testing second ServerPasswordSet2 on machine account\n");
- d_printf("Changing machine account password to '%s'\n", password);
+ torture_comment(tctx, "Testing second ServerPasswordSet2 on machine account\n");
+ torture_comment(tctx, "Changing machine account password to '%s'\n", password);
creds_client_authenticator(creds, &r.in.credential);
- status = dcerpc_netr_ServerPasswordSet2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerPasswordSet2 (2) - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerPasswordSet2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet2 (2)");
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
- printf("Credential chaining failed\n");
+ torture_comment(tctx, "Credential chaining failed\n");
}
/* by changing the machine password twice we test the
credentials chaining fully, and we verify that the server
allows the password to be set to the same value twice in a
row (match win2k3) */
- printf("Testing a second ServerPasswordSet2 on machine account\n");
- d_printf("Changing machine account password to '%s' (same as previous run)\n", password);
+ torture_comment(tctx,
+ "Testing a second ServerPasswordSet2 on machine account\n");
+ torture_comment(tctx,
+ "Changing machine account password to '%s' (same as previous run)\n", password);
creds_client_authenticator(creds, &r.in.credential);
- status = dcerpc_netr_ServerPasswordSet2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ServerPasswordSet (3) - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_ServerPasswordSet2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet (3)");
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
- printf("Credential chaining failed\n");
+ torture_comment(tctx, "Credential chaining failed\n");
}
- machine_password = password;
+ cli_credentials_set_password(machine_credentials, password, CRED_SPECIFIED);
- if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) {
- printf("ServerPasswordSet failed to actually change the password\n");
- return False;
- }
+ torture_assert (tctx,
+ test_SetupCredentials(p, tctx, machine_credentials, &creds),
+ "ServerPasswordSet failed to actually change the password");
- return True;
+ return true;
}
/*
try a netlogon SamLogon
*/
-BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_netlogon_ops(struct dcerpc_pipe *p, struct torture_context *tctx,
struct cli_credentials *credentials,
struct creds_CredentialState *creds)
{
@@ -504,17 +451,16 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct netr_NetworkInfo ninfo;
DATA_BLOB names_blob, chal, lm_resp, nt_resp;
int i;
- BOOL ret = True;
int flags = CLI_CRED_NTLM_AUTH;
- if (lp_client_lanman_auth()) {
+ if (lp_client_lanman_auth(global_loadparm)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
- if (lp_client_ntlmv2_auth()) {
+ if (lp_client_ntlmv2_auth(global_loadparm)) {
flags |= CLI_CRED_NTLMv2_AUTH;
}
- cli_credentials_get_ntlm_username_domain(cmdline_credentials, mem_ctx,
+ cli_credentials_get_ntlm_username_domain(cmdline_credentials, tctx,
&ninfo.identity_info.account_name.string,
&ninfo.identity_info.domain_name.string);
@@ -523,20 +469,16 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
chal = data_blob_const(ninfo.challenge,
sizeof(ninfo.challenge));
- names_blob = NTLMv2_generate_names_blob(mem_ctx, cli_credentials_get_workstation(credentials),
+ names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials),
cli_credentials_get_domain(credentials));
- status = cli_credentials_get_ntlm_response(cmdline_credentials, mem_ctx,
+ status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx,
&flags,
chal,
names_blob,
&lm_resp, &nt_resp,
NULL, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- printf("cli_credentials_get_ntlm_response failed: %s\n",
- nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "cli_credentials_get_ntlm_response failed");
ninfo.lm.data = lm_resp.data;
ninfo.lm.length = lm_resp.length;
@@ -549,7 +491,7 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
ninfo.identity_info.logon_id_high = 0;
ninfo.identity_info.workstation.string = cli_credentials_get_workstation(credentials);
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.computer_name = cli_credentials_get_workstation(credentials);
r.in.credential = &auth;
r.in.return_authenticator = &auth2;
@@ -564,17 +506,11 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.validation_level = i;
- status = dcerpc_netr_LogonSamLogon(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonSamLogon failed: %s\n",
- nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_LogonSamLogon(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonSamLogon failed");
- if (!creds_client_check(creds, &r.out.return_authenticator->cred)) {
- printf("Credential chaining failed\n");
- ret = False;
- }
+ torture_assert(tctx, creds_client_check(creds, &r.out.return_authenticator->cred),
+ "Credential chaining failed");
}
r.in.credential = NULL;
@@ -583,33 +519,31 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.validation_level = i;
- printf("Testing SamLogon with validation level %d and a NULL credential\n", i);
+ torture_comment(tctx, "Testing SamLogon with validation level %d and a NULL credential\n", i);
- status = dcerpc_netr_LogonSamLogon(p, mem_ctx, &r);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
- printf("LogonSamLogon expected INVALID_PARAMETER, got: %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonSamLogon(p, tctx, &r);
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_INVALID_PARAMETER,
+ "LogonSamLogon expected INVALID_PARAMETER");
}
- return ret;
+ return true;
}
/*
try a netlogon SamLogon
*/
-static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SamLogon(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
struct cli_credentials *credentials)
{
struct creds_CredentialState *creds;
- if (!test_SetupCredentials(p, mem_ctx, cli_credentials_get_workstation(credentials),
- cli_credentials_get_password(credentials), &creds)) {
- return False;
+ if (!test_SetupCredentials(p, tctx, credentials, &creds)) {
+ return false;
}
- return test_netlogon_ops(p, mem_ctx, credentials, creds);
+ return test_netlogon_ops(p, tctx, credentials, creds);
}
/* we remember the sequence numbers so we can easily do a DatabaseDelta */
@@ -618,25 +552,21 @@ static uint64_t sequence_nums[3];
/*
try a netlogon DatabaseSync
*/
-static BOOL test_DatabaseSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_DatabaseSync(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *machine_credentials)
{
NTSTATUS status;
struct netr_DatabaseSync r;
struct creds_CredentialState *creds;
const uint32_t database_ids[] = {SAM_DATABASE_DOMAIN, SAM_DATABASE_BUILTIN, SAM_DATABASE_PRIVS};
int i;
- BOOL ret = True;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping DatabaseSync test against Samba4\n");
- return True;
+ if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) {
+ return false;
}
- if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) {
- return False;
- }
-
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.computername = TEST_MACHINE_NAME;
r.in.preferredmaximumlength = (uint32_t)-1;
ZERO_STRUCT(r.in.return_authenticator);
@@ -645,21 +575,19 @@ static BOOL test_DatabaseSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.sync_context = 0;
r.in.database_id = database_ids[i];
- printf("Testing DatabaseSync of id %d\n", r.in.database_id);
+ torture_comment(tctx, "Testing DatabaseSync of id %d\n", r.in.database_id);
do {
creds_client_authenticator(creds, &r.in.credential);
- status = dcerpc_netr_DatabaseSync(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) &&
- !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
- printf("DatabaseSync - %s\n", nt_errstr(status));
- ret = False;
- break;
- }
+ status = dcerpc_netr_DatabaseSync(p, tctx, &r);
+ if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES))
+ break;
+
+ torture_assert_ntstatus_ok(tctx, status, "DatabaseSync");
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
- printf("Credential chaining failed\n");
+ torture_comment(tctx, "Credential chaining failed\n");
}
r.in.sync_context = r.out.sync_context;
@@ -670,39 +598,35 @@ static BOOL test_DatabaseSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.out.delta_enum_array->delta_enum[0].delta_union.domain) {
sequence_nums[r.in.database_id] =
r.out.delta_enum_array->delta_enum[0].delta_union.domain->sequence_num;
- printf("\tsequence_nums[%d]=%llu\n",
+ torture_comment(tctx, "\tsequence_nums[%d]=%llu\n",
r.in.database_id,
(unsigned long long)sequence_nums[r.in.database_id]);
}
} while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
}
- return ret;
+ return true;
}
/*
try a netlogon DatabaseDeltas
*/
-static BOOL test_DatabaseDeltas(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_DatabaseDeltas(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *machine_credentials)
{
NTSTATUS status;
struct netr_DatabaseDeltas r;
struct creds_CredentialState *creds;
const uint32_t database_ids[] = {0, 1, 2};
int i;
- BOOL ret = True;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping DatabaseDeltas test against Samba4\n");
- return True;
+ if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) {
+ return false;
}
- if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) {
- return False;
- }
-
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.computername = TEST_MACHINE_NAME;
r.in.preferredmaximumlength = (uint32_t)-1;
ZERO_STRUCT(r.in.return_authenticator);
@@ -715,54 +639,52 @@ static BOOL test_DatabaseDeltas(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.sequence_num -= 1;
-
- printf("Testing DatabaseDeltas of id %d at %llu\n",
+ torture_comment(tctx, "Testing DatabaseDeltas of id %d at %llu\n",
r.in.database_id, (unsigned long long)r.in.sequence_num);
do {
creds_client_authenticator(creds, &r.in.credential);
- status = dcerpc_netr_DatabaseDeltas(p, mem_ctx, &r);
+ status = dcerpc_netr_DatabaseDeltas(p, tctx, &r);
if (NT_STATUS_EQUAL(status,
NT_STATUS_SYNCHRONIZATION_REQUIRED)) {
- printf("no considering %s to be an error\n",
+ torture_comment(tctx, "not considering %s to be an error\n",
nt_errstr(status));
- return True;
- }
- if (!NT_STATUS_IS_OK(status) &&
- !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
- printf("DatabaseDeltas - %s\n", nt_errstr(status));
- ret = False;
- break;
+ return true;
}
+ if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES))
+ break;
+
+ torture_assert_ntstatus_ok(tctx, status, "DatabaseDeltas");
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
- printf("Credential chaining failed\n");
+ torture_comment(tctx, "Credential chaining failed\n");
}
r.in.sequence_num++;
} while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
}
- return ret;
+ return true;
}
/*
try a netlogon AccountDeltas
*/
-static BOOL test_AccountDeltas(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_AccountDeltas(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *machine_credentials)
{
NTSTATUS status;
struct netr_AccountDeltas r;
struct creds_CredentialState *creds;
- BOOL ret = True;
- if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) {
- return False;
+ if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) {
+ return false;
}
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.computername = TEST_MACHINE_NAME;
ZERO_STRUCT(r.in.return_authenticator);
creds_client_authenticator(creds, &r.in.credential);
@@ -771,33 +693,28 @@ static BOOL test_AccountDeltas(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.level=0;
r.in.buffersize=100;
- printf("Testing AccountDeltas\n");
-
/* w2k3 returns "NOT IMPLEMENTED" for this call */
- status = dcerpc_netr_AccountDeltas(p, mem_ctx, &r);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) {
- printf("AccountDeltas - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_AccountDeltas(p, tctx, &r);
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_NOT_IMPLEMENTED, "AccountDeltas");
- return ret;
+ return true;
}
/*
try a netlogon AccountSync
*/
-static BOOL test_AccountSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_AccountSync(struct torture_context *tctx, struct dcerpc_pipe *p,
+ struct cli_credentials *machine_credentials)
{
NTSTATUS status;
struct netr_AccountSync r;
struct creds_CredentialState *creds;
- BOOL ret = True;
- if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) {
- return False;
+ if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) {
+ return false;
}
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.computername = TEST_MACHINE_NAME;
ZERO_STRUCT(r.in.return_authenticator);
creds_client_authenticator(creds, &r.in.credential);
@@ -806,177 +723,132 @@ static BOOL test_AccountSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.level=0;
r.in.buffersize=100;
- printf("Testing AccountSync\n");
-
/* w2k3 returns "NOT IMPLEMENTED" for this call */
- status = dcerpc_netr_AccountSync(p, mem_ctx, &r);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) {
- printf("AccountSync - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_AccountSync(p, tctx, &r);
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_NOT_IMPLEMENTED, "AccountSync");
- return ret;
+ return true;
}
/*
try a netlogon GetDcName
*/
-static BOOL test_GetDcName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_GetDcName(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_GetDcName r;
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.domainname = lp_workgroup(global_loadparm);
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping GetDCName test against Samba4\n");
- return True;
- }
-
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
- r.in.domainname = lp_workgroup();
-
- printf("Testing GetDcName\n");
-
- status = dcerpc_netr_GetDcName(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- printf("GetDcName - %s/%s\n", nt_errstr(status), win_errstr(r.out.result));
- return False;
- }
+ status = dcerpc_netr_GetDcName(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetDcName");
+ torture_assert_werr_ok(tctx, r.out.result, "GetDcName");
- d_printf("\tDC is at '%s'\n", r.out.dcname);
+ torture_comment(tctx, "\tDC is at '%s'\n", r.out.dcname);
- return True;
+ return true;
}
/*
try a netlogon LogonControl
*/
-static BOOL test_LogonControl(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_LogonControl(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_LogonControl r;
- BOOL ret = True;
int i;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping LogonControl test against Samba4\n");
- return True;
- }
-
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.function_code = 1;
for (i=1;i<4;i++) {
r.in.level = i;
- printf("Testing LogonControl level %d\n", i);
+ torture_comment(tctx, "Testing LogonControl level %d\n", i);
- status = dcerpc_netr_LogonControl(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonControl - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonControl(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
- return ret;
+ return true;
}
/*
try a netlogon GetAnyDCName
*/
-static BOOL test_GetAnyDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_GetAnyDCName(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_GetAnyDCName r;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping GetAnyDCName test against Samba4\n");
- return True;
- }
-
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
- r.in.domainname = lp_workgroup();
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.domainname = lp_workgroup(global_loadparm);
- printf("Testing GetAnyDCName\n");
-
- status = dcerpc_netr_GetAnyDCName(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetAnyDCName - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_GetAnyDCName(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetAnyDCName");
if (r.out.dcname) {
- printf("\tDC is at '%s'\n", r.out.dcname);
+ torture_comment(tctx, "\tDC is at '%s'\n", r.out.dcname);
}
- return True;
+ return true;
}
/*
try a netlogon LogonControl2
*/
-static BOOL test_LogonControl2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_LogonControl2(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_LogonControl2 r;
- BOOL ret = True;
int i;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping LogonControl2 test against Samba4\n");
- return True;
- }
-
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.function_code = NETLOGON_CONTROL_REDISCOVER;
- r.in.data.domain = lp_workgroup();
+ r.in.data.domain = lp_workgroup(global_loadparm);
for (i=1;i<4;i++) {
r.in.level = i;
- printf("Testing LogonControl2 level %d function %d\n",
+ torture_comment(tctx, "Testing LogonControl2 level %d function %d\n",
i, r.in.function_code);
- status = dcerpc_netr_LogonControl2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonControl - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonControl2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
r.in.function_code = NETLOGON_CONTROL_TC_QUERY;
- r.in.data.domain = lp_workgroup();
+ r.in.data.domain = lp_workgroup(global_loadparm);
for (i=1;i<4;i++) {
r.in.level = i;
- printf("Testing LogonControl2 level %d function %d\n",
+ torture_comment(tctx, "Testing LogonControl2 level %d function %d\n",
i, r.in.function_code);
- status = dcerpc_netr_LogonControl2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonControl - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonControl2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
r.in.function_code = NETLOGON_CONTROL_TRANSPORT_NOTIFY;
- r.in.data.domain = lp_workgroup();
+ r.in.data.domain = lp_workgroup(global_loadparm);
for (i=1;i<4;i++) {
r.in.level = i;
- printf("Testing LogonControl2 level %d function %d\n",
+ torture_comment(tctx, "Testing LogonControl2 level %d function %d\n",
i, r.in.function_code);
- status = dcerpc_netr_LogonControl2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonControl - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonControl2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
r.in.function_code = NETLOGON_CONTROL_SET_DBFLAG;
@@ -985,43 +857,36 @@ static BOOL test_LogonControl2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
for (i=1;i<4;i++) {
r.in.level = i;
- printf("Testing LogonControl2 level %d function %d\n",
+ torture_comment(tctx, "Testing LogonControl2 level %d function %d\n",
i, r.in.function_code);
- status = dcerpc_netr_LogonControl2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonControl - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonControl2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
- return ret;
+ return true;
}
/*
try a netlogon DatabaseSync2
*/
-static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_DatabaseSync2(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *machine_credentials)
{
NTSTATUS status;
struct netr_DatabaseSync2 r;
struct creds_CredentialState *creds;
const uint32_t database_ids[] = {0, 1, 2};
int i;
- BOOL ret = True;
- if (!test_SetupCredentials2(p, mem_ctx, NETLOGON_NEG_AUTH2_FLAGS,
- TEST_MACHINE_NAME, machine_password,
+ if (!test_SetupCredentials2(p, tctx, NETLOGON_NEG_AUTH2_FLAGS,
+ machine_credentials,
SEC_CHAN_BDC, &creds)) {
- return False;
- }
-
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping DatabaseSync2 test against Samba4\n");
- return True;
+ return false;
}
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.computername = TEST_MACHINE_NAME;
r.in.preferredmaximumlength = (uint32_t)-1;
ZERO_STRUCT(r.in.return_authenticator);
@@ -1031,94 +896,78 @@ static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.database_id = database_ids[i];
r.in.restart_state = 0;
- printf("Testing DatabaseSync2 of id %d\n", r.in.database_id);
+ torture_comment(tctx, "Testing DatabaseSync2 of id %d\n", r.in.database_id);
do {
creds_client_authenticator(creds, &r.in.credential);
- status = dcerpc_netr_DatabaseSync2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) &&
- !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
- printf("DatabaseSync2 - %s\n", nt_errstr(status));
- ret = False;
- break;
- }
+ status = dcerpc_netr_DatabaseSync2(p, tctx, &r);
+ if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES))
+ break;
+
+ torture_assert_ntstatus_ok(tctx, status, "DatabaseSync2");
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
- printf("Credential chaining failed\n");
+ torture_comment(tctx, "Credential chaining failed\n");
}
r.in.sync_context = r.out.sync_context;
} while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
}
- return ret;
+ return true;
}
/*
try a netlogon LogonControl2Ex
*/
-static BOOL test_LogonControl2Ex(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_LogonControl2Ex(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_LogonControl2Ex r;
- BOOL ret = True;
int i;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping DatabaseSync2 test against Samba4\n");
- return True;
- }
-
- r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.function_code = NETLOGON_CONTROL_REDISCOVER;
- r.in.data.domain = lp_workgroup();
+ r.in.data.domain = lp_workgroup(global_loadparm);
for (i=1;i<4;i++) {
r.in.level = i;
- printf("Testing LogonControl2Ex level %d function %d\n",
+ torture_comment(tctx, "Testing LogonControl2Ex level %d function %d\n",
i, r.in.function_code);
- status = dcerpc_netr_LogonControl2Ex(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonControl - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonControl2Ex(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
r.in.function_code = NETLOGON_CONTROL_TC_QUERY;
- r.in.data.domain = lp_workgroup();
+ r.in.data.domain = lp_workgroup(global_loadparm);
for (i=1;i<4;i++) {
r.in.level = i;
- printf("Testing LogonControl2Ex level %d function %d\n",
+ torture_comment(tctx, "Testing LogonControl2Ex level %d function %d\n",
i, r.in.function_code);
- status = dcerpc_netr_LogonControl2Ex(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonControl - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonControl2Ex(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
r.in.function_code = NETLOGON_CONTROL_TRANSPORT_NOTIFY;
- r.in.data.domain = lp_workgroup();
+ r.in.data.domain = lp_workgroup(global_loadparm);
for (i=1;i<4;i++) {
r.in.level = i;
- printf("Testing LogonControl2Ex level %d function %d\n",
+ torture_comment(tctx, "Testing LogonControl2Ex level %d function %d\n",
i, r.in.function_code);
- status = dcerpc_netr_LogonControl2Ex(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonControl - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonControl2Ex(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
r.in.function_code = NETLOGON_CONTROL_SET_DBFLAG;
@@ -1127,77 +976,63 @@ static BOOL test_LogonControl2Ex(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
for (i=1;i<4;i++) {
r.in.level = i;
- printf("Testing LogonControl2Ex level %d function %d\n",
+ torture_comment(tctx, "Testing LogonControl2Ex level %d function %d\n",
i, r.in.function_code);
- status = dcerpc_netr_LogonControl2Ex(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonControl - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_netr_LogonControl2Ex(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
- return ret;
+ return true;
}
-static BOOL test_netr_DsRGetForestTrustInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *trusted_domain_name)
+static bool test_netr_DsRGetForestTrustInformation(struct torture_context *tctx,
+ struct dcerpc_pipe *p, const char *trusted_domain_name)
{
NTSTATUS status;
struct netr_DsRGetForestTrustInformation r;
- BOOL ret = True;
struct lsa_ForestTrustInformation info, *info_ptr;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping DsRGetForestTrustInformation test against Samba4\n");
- return True;
- }
-
info_ptr = &info;
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.trusted_domain_name = trusted_domain_name;
r.in.flags = 0;
r.out.forest_trust_info = &info_ptr;
- printf("Testing netr_DsRGetForestTrustInformation\n");
+ torture_comment(tctx ,"Testing netr_DsRGetForestTrustInformation\n");
- status = dcerpc_netr_DsRGetForestTrustInformation(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- printf("netr_DsRGetForestTrustInformation - %s/%s\n",
- nt_errstr(status), win_errstr(r.out.result));
- ret = False;
- }
- return ret;
+ status = dcerpc_netr_DsRGetForestTrustInformation(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "DsRGetForestTrustInformation");
+ torture_assert_werr_ok(tctx, r.out.result, "DsRGetForestTrustInformation");
+
+ return true;
}
/*
try a netlogon netr_DsrEnumerateDomainTrusts
*/
-static BOOL test_DsrEnumerateDomainTrusts(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_DsrEnumerateDomainTrusts(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_DsrEnumerateDomainTrusts r;
int i;
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.trust_flags = 0x3f;
- printf("Testing netr_DsrEnumerateDomainTrusts\n");
-
- status = dcerpc_netr_DsrEnumerateDomainTrusts(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- printf("netr_DsrEnumerateDomainTrusts - %s/%s\n",
- nt_errstr(status), win_errstr(r.out.result));
- return False;
- }
+ status = dcerpc_netr_DsrEnumerateDomainTrusts(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "DsrEnumerateDomaintrusts");
+ torture_assert_werr_ok(tctx, r.out.result, "DsrEnumerateDomaintrusts");
/* when trusted_domain_name is NULL, netr_DsRGetForestTrustInformation
* will show non-forest trusts and all UPN suffixes of the own forest
* as LSA_FOREST_TRUST_TOP_LEVEL_NAME types */
if (r.out.count) {
- if (!test_netr_DsRGetForestTrustInformation(p, mem_ctx, NULL)) {
- return False;
+ if (!test_netr_DsRGetForestTrustInformation(tctx, p, NULL)) {
+ return false;
}
}
@@ -1206,194 +1041,145 @@ static BOOL test_DsrEnumerateDomainTrusts(struct dcerpc_pipe *p, TALLOC_CTX *mem
/* get info for transitive forest trusts */
if (r.out.trusts[i].trust_attributes & NETR_TRUST_ATTRIBUTE_FOREST_TRANSITIVE) {
- if (!test_netr_DsRGetForestTrustInformation(p, mem_ctx,
+ if (!test_netr_DsRGetForestTrustInformation(tctx, p,
r.out.trusts[i].dns_name)) {
- return False;
+ return false;
}
}
}
- return True;
+ return true;
}
-static BOOL test_netr_DsRGetSiteName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_netr_DsRGetSiteName(struct dcerpc_pipe *p, struct torture_context *tctx,
const char *computer_name,
const char *expected_site)
{
NTSTATUS status;
struct netr_DsRGetSiteName r;
- BOOL ret = True;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping DsRGetSiteName test against Samba4\n");
- return True;
- }
+ if (torture_setting_bool(tctx, "samba4", false))
+ torture_skip(tctx, "skipping DsRGetSiteName test against Samba4");
r.in.computer_name = computer_name;
- printf("Testing netr_DsRGetSiteName\n");
+ torture_comment(tctx, "Testing netr_DsRGetSiteName\n");
- status = dcerpc_netr_DsRGetSiteName(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- printf("netr_DsRGetSiteName - %s/%s\n",
- nt_errstr(status), win_errstr(r.out.result));
- ret = False;
- } else {
- if (strcmp(expected_site, r.out.site) != 0) {
- d_printf("netr_DsRGetSiteName - unexpected result: %s, expected %s\n",
- r.out.site, expected_site);
-
- ret = False;
- }
- }
- r.in.computer_name = talloc_asprintf(mem_ctx, "\\\\%s", computer_name);
- d_printf("Testing netr_DsRGetSiteName with broken computer name: %s\n", r.in.computer_name);
-
- status = dcerpc_netr_DsRGetSiteName(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("netr_DsRGetSiteName - %s\n",
- nt_errstr(status));
- ret = False;
- } else if (!W_ERROR_EQUAL(r.out.result, WERR_INVALID_COMPUTERNAME)) {
- printf("netr_DsRGetSiteName - incorrect error return %s, expected %s\n",
- win_errstr(r.out.result), win_errstr(WERR_INVALID_COMPUTERNAME));
- ret = False;
- }
- return ret;
+ status = dcerpc_netr_DsRGetSiteName(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "DsRGetSiteName");
+ torture_assert_werr_ok(tctx, r.out.result, "DsRGetSiteName");
+ torture_assert_str_equal(tctx, expected_site, r.out.site, "netr_DsRGetSiteName");
+
+ r.in.computer_name = talloc_asprintf(tctx, "\\\\%s", computer_name);
+ torture_comment(tctx,
+ "Testing netr_DsRGetSiteName with broken computer name: %s\n", r.in.computer_name);
+
+ status = dcerpc_netr_DsRGetSiteName(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "DsRGetSiteName");
+ torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_COMPUTERNAME, "netr_DsRGetSiteName");
+
+ return true;
}
/*
try a netlogon netr_DsRGetDCName
*/
-static BOOL test_netr_DsRGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_netr_DsRGetDCName(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_DsRGetDCName r;
- BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
- r.in.domain_name = talloc_asprintf(mem_ctx, "%s", lp_realm());
+ r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(global_loadparm));
r.in.domain_guid = NULL;
r.in.site_guid = NULL;
r.in.flags = DS_RETURN_DNS_NAME;
- printf("Testing netr_DsRGetDCName\n");
-
- status = dcerpc_netr_DsRGetDCName(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- printf("netr_DsRGetDCName - %s/%s\n",
- nt_errstr(status), win_errstr(r.out.result));
- ret = False;
- } else {
- ret = test_netr_DsRGetSiteName(p, mem_ctx,
- r.out.info->dc_unc,
- r.out.info->dc_site_name);
- }
-
- return ret;
+ status = dcerpc_netr_DsRGetDCName(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "DsRGetDCName");
+ torture_assert_werr_ok(tctx, r.out.result, "DsRGetDCName");
+ return test_netr_DsRGetSiteName(p, tctx,
+ r.out.info->dc_unc,
+ r.out.info->dc_site_name);
}
/*
try a netlogon netr_DsRGetDCNameEx
*/
-static BOOL test_netr_DsRGetDCNameEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_netr_DsRGetDCNameEx(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_DsRGetDCNameEx r;
- BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
- r.in.domain_name = talloc_asprintf(mem_ctx, "%s", lp_realm());
+ r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(global_loadparm));
r.in.domain_guid = NULL;
r.in.site_name = NULL;
r.in.flags = DS_RETURN_DNS_NAME;
- printf("Testing netr_DsRGetDCNameEx\n");
-
- status = dcerpc_netr_DsRGetDCNameEx(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- printf("netr_DsRGetDCNameEx - %s/%s\n",
- nt_errstr(status), win_errstr(r.out.result));
- ret = False;
- } else {
- ret = test_netr_DsRGetSiteName(p, mem_ctx,
- r.out.info->dc_unc,
- r.out.info->dc_site_name);
- }
+ status = dcerpc_netr_DsRGetDCNameEx(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "netr_DsRGetDCNameEx");
+ torture_assert_werr_ok(tctx, r.out.result, "netr_DsRGetDCNameEx");
- return ret;
+ return test_netr_DsRGetSiteName(p, tctx, r.out.info->dc_unc,
+ r.out.info->dc_site_name);
}
/*
try a netlogon netr_DsRGetDCNameEx2
*/
-static BOOL test_netr_DsRGetDCNameEx2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_netr_DsRGetDCNameEx2(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_DsRGetDCNameEx2 r;
- BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.client_account = NULL;
r.in.mask = 0x00000000;
- r.in.domain_name = talloc_asprintf(mem_ctx, "%s", lp_realm());
+ r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(global_loadparm));
r.in.domain_guid = NULL;
r.in.site_name = NULL;
r.in.flags = DS_RETURN_DNS_NAME;
- printf("Testing netr_DsRGetDCNameEx2 without client account\n");
+ torture_comment(tctx, "Testing netr_DsRGetDCNameEx2 without client account\n");
- status = dcerpc_netr_DsRGetDCNameEx2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- printf("netr_DsRGetDCNameEx2 - %s/%s\n",
- nt_errstr(status), win_errstr(r.out.result));
- ret = False;
- }
+ status = dcerpc_netr_DsRGetDCNameEx2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "netr_DsRGetDCNameEx2");
+ torture_assert_werr_ok(tctx, r.out.result, "netr_DsRGetDCNameEx2");
- printf("Testing netr_DsRGetDCNameEx2 with client acount\n");
+ torture_comment(tctx, "Testing netr_DsRGetDCNameEx2 with client acount\n");
r.in.client_account = TEST_MACHINE_NAME"$";
r.in.mask = ACB_SVRTRUST;
r.in.flags = DS_RETURN_FLAT_NAME;
- status = dcerpc_netr_DsRGetDCNameEx2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- printf("netr_DsRGetDCNameEx2 - %s/%s\n",
- nt_errstr(status), win_errstr(r.out.result));
- ret = False;
- } else {
- ret = test_netr_DsRGetSiteName(p, mem_ctx,
- r.out.info->dc_unc,
- r.out.info->dc_site_name);
- }
-
- return ret;
+ status = dcerpc_netr_DsRGetDCNameEx2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "netr_DsRGetDCNameEx2");
+ torture_assert_werr_ok(tctx, r.out.result, "netr_DsRGetDCNameEx2");
+ return test_netr_DsRGetSiteName(p, tctx, r.out.info->dc_unc,
+ r.out.info->dc_site_name);
}
-static BOOL test_netr_DsrGetDcSiteCoverageW(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_netr_DsrGetDcSiteCoverageW(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct netr_DsrGetDcSiteCoverageW r;
- BOOL ret = True;
-
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
- printf("skipping DsrGetDcSiteCoverageW test against Samba4\n");
- return True;
- }
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
- printf("Testing netr_DsrGetDcSiteCoverageW\n");
+ status = dcerpc_netr_DsrGetDcSiteCoverageW(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "failed");
+ torture_assert_werr_ok(tctx, r.out.result, "failed");
- status = dcerpc_netr_DsrGetDcSiteCoverageW(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
- printf("netr_DsrGetDcSiteCoverageW - %s/%s\n",
- nt_errstr(status), win_errstr(r.out.result));
- ret = False;
- }
- return ret;
+ return true;
}
-static BOOL test_GetDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_GetDomainInfo(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *machine_credentials)
{
NTSTATUS status;
struct netr_LogonGetDomainInfo r;
@@ -1401,16 +1187,16 @@ static BOOL test_GetDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
struct netr_Authenticator a;
struct creds_CredentialState *creds;
- if (!test_SetupCredentials3(p, mem_ctx, NETLOGON_NEG_AUTH2_ADS_FLAGS,
- TEST_MACHINE_NAME, machine_password, &creds)) {
- return False;
+ if (!test_SetupCredentials3(p, tctx, NETLOGON_NEG_AUTH2_ADS_FLAGS,
+ machine_credentials, &creds)) {
+ return false;
}
ZERO_STRUCT(r);
creds_client_authenticator(creds, &a);
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.computer_name = TEST_MACHINE_NAME;
r.in.level = 1;
r.in.credential = &a;
@@ -1428,32 +1214,27 @@ static BOOL test_GetDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
q1.blob2.data = NULL;
q1.product.string = "product string";
- printf("Testing netr_LogonGetDomainInfo\n");
+ torture_comment(tctx, "Testing netr_uogonGetDomainInfo\n");
- status = dcerpc_netr_LogonGetDomainInfo(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("netr_LogonGetDomainInfo - %s\n", nt_errstr(status));
- return False;
- }
-
- if (!creds_client_check(creds, &a.cred)) {
- printf("Credential chaining failed\n");
- return False;
- }
+ status = dcerpc_netr_LogonGetDomainInfo(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "netr_LogonGetDomainInfo");
+ torture_assert(tctx, creds_client_check(creds, &a.cred), "Credential chaining failed");
- return True;
+ return true;
}
static void async_callback(struct rpc_request *req)
{
- int *counter = req->async.private_data;
+ int *counter = (int *)req->async.private_data;
if (NT_STATUS_IS_OK(req->status)) {
(*counter)++;
}
}
-static BOOL test_GetDomainInfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_GetDomainInfo_async(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *machine_credentials)
{
NTSTATUS status;
struct netr_LogonGetDomainInfo r;
@@ -1464,20 +1245,15 @@ static BOOL test_GetDomainInfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
struct creds_CredentialState *creds_async[ASYNC_COUNT];
struct rpc_request *req[ASYNC_COUNT];
int i;
- int *async_counter = talloc(mem_ctx, int);
-
- if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
- printf("test_GetDomainInfo_async disabled - enable dangerous tests to use\n");
- return True;
- }
+ int *async_counter = talloc(tctx, int);
- if (!test_SetupCredentials3(p, mem_ctx, NETLOGON_NEG_AUTH2_ADS_FLAGS,
- TEST_MACHINE_NAME, machine_password, &creds)) {
- return False;
+ if (!test_SetupCredentials3(p, tctx, NETLOGON_NEG_AUTH2_ADS_FLAGS,
+ machine_credentials, &creds)) {
+ return false;
}
ZERO_STRUCT(r);
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.computer_name = TEST_MACHINE_NAME;
r.in.level = 1;
r.in.credential = &a;
@@ -1495,46 +1271,45 @@ static BOOL test_GetDomainInfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
q1.blob2.data = NULL;
q1.product.string = "product string";
- printf("Testing netr_LogonGetDomainInfo - async count %d\n", ASYNC_COUNT);
+ torture_comment(tctx, "Testing netr_LogonGetDomainInfo - async count %d\n", ASYNC_COUNT);
*async_counter = 0;
for (i=0;i<ASYNC_COUNT;i++) {
creds_client_authenticator(creds, &a);
- creds_async[i] = talloc_memdup(creds, creds, sizeof(*creds));
- req[i] = dcerpc_netr_LogonGetDomainInfo_send(p, mem_ctx, &r);
+ creds_async[i] = (struct creds_CredentialState *)talloc_memdup(creds, creds, sizeof(*creds));
+ req[i] = dcerpc_netr_LogonGetDomainInfo_send(p, tctx, &r);
req[i]->async.callback = async_callback;
req[i]->async.private_data = async_counter;
/* even with this flush per request a w2k3 server seems to
clag with multiple outstanding requests. bleergh. */
- if (event_loop_once(dcerpc_event_context(p)) != 0) {
- return False;
- }
+ torture_assert_int_equal(tctx, event_loop_once(dcerpc_event_context(p)), 0,
+ "event_loop_once failed");
}
for (i=0;i<ASYNC_COUNT;i++) {
status = dcerpc_ndr_request_recv(req[i]);
- if (!NT_STATUS_IS_OK(status) || !NT_STATUS_IS_OK(r.out.result)) {
- printf("netr_LogonGetDomainInfo_async(%d) - %s/%s\n",
- i, nt_errstr(status), nt_errstr(r.out.result));
- break;
- }
- if (!creds_client_check(creds_async[i], &a.cred)) {
- printf("Credential chaining failed at async %d\n", i);
- break;
- }
+ torture_assert_ntstatus_ok(tctx, status, "netr_LogonGetDomainInfo_async");
+ torture_assert_ntstatus_ok(tctx, r.out.result, "netr_LogonGetDomainInfo_async");
+
+ torture_assert(tctx, creds_client_check(creds_async[i], &a.cred),
+ "Credential chaining failed at async");
}
- printf("Testing netr_LogonGetDomainInfo - async count %d OK\n", *async_counter);
+ torture_comment(tctx,
+ "Testing netr_LogonGetDomainInfo - async count %d OK\n", *async_counter);
+
+ torture_assert_int_equal(tctx, (*async_counter), ASYNC_COUNT, "int");
- return (*async_counter) == ASYNC_COUNT;
+ return true;
}
-static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_ManyGetDCName(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct dcerpc_pipe *p2;
@@ -1549,25 +1324,18 @@ static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
struct netr_GetAnyDCName d;
int i;
- BOOL ret = True;
if (p->conn->transport.transport != NCACN_NP) {
- return True;
+ return true;
}
- printf("Torturing GetDCName\n");
+ torture_comment(tctx, "Torturing GetDCName\n");
status = dcerpc_secondary_connection(p, &p2, p->binding);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to create secondary connection\n");
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create secondary connection");
status = dcerpc_bind_auth_none(p2, &ndr_table_lsarpc);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to create bind on secondary connection\n");
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create bind on secondary connection");
qos.len = 0;
qos.impersonation_level = 2;
@@ -1586,11 +1354,8 @@ static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
o.out.handle = &lsa_handle;
- status = dcerpc_lsa_OpenPolicy2(p2, mem_ctx, &o);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenPolicy2 failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_lsa_OpenPolicy2(p2, tctx, &o);
+ torture_assert_ntstatus_ok(tctx, status, "OpenPolicy2 failed");
t.in.handle = &lsa_handle;
t.in.resume_handle = &resume_handle;
@@ -1598,17 +1363,15 @@ static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
t.out.domains = &domains;
t.out.resume_handle = &resume_handle;
- status = dcerpc_lsa_EnumTrustDom(p2, mem_ctx, &t);
+ status = dcerpc_lsa_EnumTrustDom(p2, tctx, &t);
if ((!NT_STATUS_IS_OK(status) &&
- (!NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)))) {
- printf("Could not list domains\n");
- return False;
- }
+ (!NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))))
+ torture_fail(tctx, "Could not list domains");
talloc_free(p2);
- d.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s",
+ d.in.logon_server = talloc_asprintf(tctx, "\\\\%s",
dcerpc_server_name(p));
for (i=0; i<domains.count * 4; i++) {
@@ -1617,74 +1380,49 @@ static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
d.in.domainname = info->name.string;
- status = dcerpc_netr_GetAnyDCName(p, mem_ctx, &d);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetAnyDCName - %s\n", nt_errstr(status));
- continue;
- }
+ status = dcerpc_netr_GetAnyDCName(p, tctx, &d);
+ torture_assert_ntstatus_ok(tctx, status, "GetAnyDCName");
- printf("\tDC for domain %s is %s\n", info->name.string,
+ torture_comment(tctx, "\tDC for domain %s is %s\n", info->name.string,
d.out.dcname ? d.out.dcname : "unknown");
}
- return ret;
+ return true;
}
-
-BOOL torture_rpc_netlogon(struct torture_context *torture)
+struct torture_suite *torture_rpc_netlogon(TALLOC_CTX *mem_ctx)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
- struct test_join *join_ctx;
- struct cli_credentials *machine_credentials;
-
- mem_ctx = talloc_init("torture_rpc_netlogon");
-
- join_ctx = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST,
- &machine_credentials);
- if (!join_ctx) {
- talloc_free(mem_ctx);
- printf("Failed to join as BDC\n");
- return False;
- }
-
- machine_password = cli_credentials_get_password(machine_credentials);
-
- status = torture_rpc_connection(torture, &p, &ndr_table_netlogon);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- return False;
- }
-
- ret &= test_LogonUasLogon(p, mem_ctx);
- ret &= test_LogonUasLogoff(p, mem_ctx);
- ret &= test_SamLogon(p, mem_ctx, machine_credentials);
- ret &= test_SetPassword(p, mem_ctx);
- ret &= test_SetPassword2(p, mem_ctx);
- ret &= test_GetDomainInfo(p, mem_ctx);
- ret &= test_DatabaseSync(p, mem_ctx);
- ret &= test_DatabaseDeltas(p, mem_ctx);
- ret &= test_AccountDeltas(p, mem_ctx);
- ret &= test_AccountSync(p, mem_ctx);
- ret &= test_GetDcName(p, mem_ctx);
- ret &= test_ManyGetDCName(p, mem_ctx);
- ret &= test_LogonControl(p, mem_ctx);
- ret &= test_GetAnyDCName(p, mem_ctx);
- ret &= test_LogonControl2(p, mem_ctx);
- ret &= test_DatabaseSync2(p, mem_ctx);
- ret &= test_LogonControl2Ex(p, mem_ctx);
- ret &= test_DsrEnumerateDomainTrusts(p, mem_ctx);
- ret &= test_GetDomainInfo_async(p, mem_ctx);
- ret &= test_netr_DsRGetDCName(p, mem_ctx);
- ret &= test_netr_DsRGetDCNameEx(p, mem_ctx);
- ret &= test_netr_DsRGetDCNameEx2(p, mem_ctx);
- ret &= test_netr_DsrGetDcSiteCoverageW(p, mem_ctx);
-
- talloc_free(mem_ctx);
-
- torture_leave_domain(join_ctx);
-
- return ret;
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "NETLOGON");
+ struct torture_rpc_tcase *tcase;
+ struct torture_test *test;
+
+ tcase = torture_suite_add_machine_rpc_iface_tcase(suite, "netlogon",
+ &ndr_table_netlogon, TEST_MACHINE_NAME);
+
+ torture_rpc_tcase_add_test(tcase, "LogonUasLogon", test_LogonUasLogon);
+ torture_rpc_tcase_add_test(tcase, "LogonUasLogoff", test_LogonUasLogoff);
+ torture_rpc_tcase_add_test_creds(tcase, "SamLogon", test_SamLogon);
+ torture_rpc_tcase_add_test_creds(tcase, "SetPassword", test_SetPassword);
+ torture_rpc_tcase_add_test_creds(tcase, "SetPassword2", test_SetPassword2);
+ torture_rpc_tcase_add_test_creds(tcase, "GetDomainInfo", test_GetDomainInfo);
+ torture_rpc_tcase_add_test_creds(tcase, "DatabaseSync", test_DatabaseSync);
+ torture_rpc_tcase_add_test_creds(tcase, "DatabaseDeltas", test_DatabaseDeltas);
+ torture_rpc_tcase_add_test_creds(tcase, "AccountDeltas", test_AccountDeltas);
+ torture_rpc_tcase_add_test_creds(tcase, "AccountSync", test_AccountSync);
+ torture_rpc_tcase_add_test(tcase, "GetDcName", test_GetDcName);
+ torture_rpc_tcase_add_test(tcase, "ManyGetDCName", test_ManyGetDCName);
+ torture_rpc_tcase_add_test(tcase, "LogonControl", test_LogonControl);
+ torture_rpc_tcase_add_test(tcase, "GetAnyDCName", test_GetAnyDCName);
+ torture_rpc_tcase_add_test(tcase, "LogonControl2", test_LogonControl2);
+ torture_rpc_tcase_add_test_creds(tcase, "DatabaseSync2", test_DatabaseSync2);
+ torture_rpc_tcase_add_test(tcase, "LogonControl2Ex", test_LogonControl2Ex);
+ torture_rpc_tcase_add_test(tcase, "DsrEnumerateDomainTrusts", test_DsrEnumerateDomainTrusts);
+ test = torture_rpc_tcase_add_test_creds(tcase, "GetDomainInfo_async", test_GetDomainInfo_async);
+ test->dangerous = true;
+ torture_rpc_tcase_add_test(tcase, "DsRGetDCName", test_netr_DsRGetDCName);
+ torture_rpc_tcase_add_test(tcase, "DsRGetDCNameEx", test_netr_DsRGetDCNameEx);
+ torture_rpc_tcase_add_test(tcase, "DsRGetDCNameEx2", test_netr_DsRGetDCNameEx2);
+ torture_rpc_tcase_add_test(tcase, "DsrGetDcSiteCoverageW", test_netr_DsrGetDcSiteCoverageW);
+
+ return suite;
}
diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c
index af7e05a9f0..6891783a82 100644
--- a/source4/torture/rpc/rpc.c
+++ b/source4/torture/rpc/rpc.c
@@ -27,33 +27,49 @@
#include "librpc/ndr/ndr_table.h"
#include "lib/util/dlinklist.h"
-struct torture_rpc_tcase {
- struct torture_tcase tcase;
- const struct ndr_interface_table *table;
- struct dcerpc_pipe *pipe;
-};
+static bool torture_rpc_teardown (struct torture_context *tcase,
+ void *data)
+{
+ struct torture_rpc_tcase_data *tcase_data =
+ (struct torture_rpc_tcase_data *)data;
+ if (tcase_data->join_ctx != NULL)
+ torture_leave_domain(tcase_data->join_ctx);
+ talloc_free(tcase_data);
+ return true;
+}
+/**
+ * Obtain the DCE/RPC binding context associated with a torture context.
+ *
+ * @param tctx Torture context
+ * @param binding Pointer to store DCE/RPC binding
+ */
NTSTATUS torture_rpc_binding(struct torture_context *tctx,
- struct dcerpc_binding **binding)
+ struct dcerpc_binding **binding)
{
NTSTATUS status;
- const char *binding_string = torture_setting_string(tctx, "binding", NULL);
+ const char *binding_string = torture_setting_string(tctx, "binding",
+ NULL);
if (binding_string == NULL) {
- torture_comment(tctx, "You must specify a ncacn binding string\n");
+ torture_comment(tctx,
+ "You must specify a DCE/RPC binding string\n");
return NT_STATUS_INVALID_PARAMETER;
}
status = dcerpc_parse_binding(tctx, binding_string, binding);
if (NT_STATUS_IS_ERR(status)) {
- DEBUG(0,("Failed to parse dcerpc binding '%s'\n", binding_string));
+ DEBUG(0,("Failed to parse dcerpc binding '%s'\n",
+ binding_string));
return status;
}
return NT_STATUS_OK;
}
-/* open a rpc connection to the chosen binding string */
+/**
+ * open a rpc connection to the chosen binding string
+ */
_PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx,
struct dcerpc_pipe **p,
const struct ndr_interface_table *table)
@@ -77,16 +93,17 @@ _PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx,
return status;
}
-/* open a rpc connection to a specific transport */
+/**
+ * open a rpc connection to a specific transport
+ */
NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx,
struct dcerpc_pipe **p,
const struct ndr_interface_table *table,
enum dcerpc_transport_t transport,
uint32_t assoc_group_id)
{
- NTSTATUS status;
+ NTSTATUS status;
struct dcerpc_binding *binding;
- TALLOC_CTX *mem_ctx = talloc_named(tctx, 0, "torture_rpc_connection_smb");
status = torture_rpc_binding(tctx, &binding);
if (NT_STATUS_IS_ERR(status))
@@ -95,38 +112,100 @@ NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx,
binding->transport = transport;
binding->assoc_group_id = assoc_group_id;
- status = dcerpc_pipe_connect_b(mem_ctx, p, binding, table,
+ status = dcerpc_pipe_connect_b(tctx, p, binding, table,
cmdline_credentials, NULL);
- if (NT_STATUS_IS_OK(status)) {
- *p = talloc_reference(tctx, *p);
- } else {
+ if (NT_STATUS_IS_ERR(status)) {
*p = NULL;
}
- talloc_free(mem_ctx);
+
return status;
}
+static bool torture_rpc_setup_machine(struct torture_context *tctx,
+ void **data)
+{
+ NTSTATUS status;
+ struct dcerpc_binding *binding;
+ struct torture_rpc_tcase *tcase = talloc_get_type(tctx->active_tcase,
+ struct torture_rpc_tcase);
+ struct torture_rpc_tcase_data *tcase_data;
+
+ status = torture_rpc_binding(tctx, &binding);
+ if (NT_STATUS_IS_ERR(status))
+ return false;
+
+ *data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data);
+ tcase_data->credentials = cmdline_credentials;
+ tcase_data->join_ctx = torture_join_domain(tcase->machine_name,
+ ACB_SVRTRUST,
+ &tcase_data->credentials);
+ if (tcase_data->join_ctx == NULL)
+ torture_fail(tctx, "Failed to join as BDC");
+
+ status = dcerpc_pipe_connect_b(tctx,
+ &(tcase_data->pipe),
+ binding,
+ tcase->table,
+ tcase_data->credentials, NULL);
+
+ torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
+
+ return true;
+}
+
+_PUBLIC_ struct torture_rpc_tcase *torture_suite_add_machine_rpc_iface_tcase(
+ struct torture_suite *suite,
+ const char *name,
+ const struct ndr_interface_table *table,
+ const char *machine_name)
+{
+ struct torture_rpc_tcase *tcase = talloc(suite,
+ struct torture_rpc_tcase);
+
+ torture_suite_init_rpc_tcase(suite, tcase, name, table);
+
+ tcase->machine_name = talloc_strdup(tcase, machine_name);
+ tcase->tcase.setup = torture_rpc_setup_machine;
+ tcase->tcase.teardown = torture_rpc_teardown;
+
+ return tcase;
+}
+
+_PUBLIC_ bool torture_suite_init_rpc_tcase(struct torture_suite *suite,
+ struct torture_rpc_tcase *tcase,
+ const char *name,
+ const struct ndr_interface_table *table)
+{
+ if (!torture_suite_init_tcase(suite, (struct torture_tcase *)tcase, name))
+ return false;
+
+ tcase->table = table;
+
+ return true;
+}
+
static bool torture_rpc_setup_anonymous(struct torture_context *tctx,
- void **data)
+ void **data)
{
- struct cli_credentials *anon_credentials;
NTSTATUS status;
struct dcerpc_binding *binding;
- struct torture_rpc_tcase *tcase = talloc_get_type(
- tctx->active_tcase, struct torture_rpc_tcase);
+ struct torture_rpc_tcase_data *tcase_data;
+ struct torture_rpc_tcase *tcase = talloc_get_type(tctx->active_tcase,
+ struct torture_rpc_tcase);
status = torture_rpc_binding(tctx, &binding);
if (NT_STATUS_IS_ERR(status))
return false;
- anon_credentials = cli_credentials_init_anon(tctx);
+ *data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data);
+ tcase_data->credentials = cli_credentials_init_anon(tctx);
status = dcerpc_pipe_connect_b(tctx,
- (struct dcerpc_pipe **)data,
+ &(tcase_data->pipe),
binding,
tcase->table,
- anon_credentials, NULL);
+ tcase_data->credentials, NULL);
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
@@ -138,21 +217,21 @@ static bool torture_rpc_setup (struct torture_context *tctx, void **data)
NTSTATUS status;
struct torture_rpc_tcase *tcase = talloc_get_type(
tctx->active_tcase, struct torture_rpc_tcase);
+ struct torture_rpc_tcase_data *tcase_data;
+
+ *data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data);
+ tcase_data->credentials = cmdline_credentials;
status = torture_rpc_connection(tctx,
- (struct dcerpc_pipe **)data,
- (const struct ndr_interface_table *)tcase->table);
+ &(tcase_data->pipe),
+ tcase->table);
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
return true;
}
-static bool torture_rpc_teardown (struct torture_context *tcase, void *data)
-{
- talloc_free(data);
- return true;
-}
+
_PUBLIC_ struct torture_rpc_tcase *torture_suite_add_anon_rpc_iface_tcase(struct torture_suite *suite,
const char *name,
@@ -160,11 +239,10 @@ _PUBLIC_ struct torture_rpc_tcase *torture_suite_add_anon_rpc_iface_tcase(struct
{
struct torture_rpc_tcase *tcase = talloc(suite, struct torture_rpc_tcase);
- torture_suite_init_tcase(suite, (struct torture_tcase *)tcase, name);
+ torture_suite_init_rpc_tcase(suite, tcase, name, table);
tcase->tcase.setup = torture_rpc_setup_anonymous;
tcase->tcase.teardown = torture_rpc_teardown;
- tcase->table = table;
return tcase;
}
@@ -176,11 +254,10 @@ _PUBLIC_ struct torture_rpc_tcase *torture_suite_add_rpc_iface_tcase(struct tort
{
struct torture_rpc_tcase *tcase = talloc(suite, struct torture_rpc_tcase);
- torture_suite_init_tcase(suite, (struct torture_tcase *)tcase, name);
+ torture_suite_init_rpc_tcase(suite, tcase, name, table);
tcase->tcase.setup = torture_rpc_setup;
tcase->tcase.teardown = torture_rpc_teardown;
- tcase->table = table;
return tcase;
}
@@ -190,10 +267,12 @@ static bool torture_rpc_wrap_test(struct torture_context *tctx,
struct torture_test *test)
{
bool (*fn) (struct torture_context *, struct dcerpc_pipe *);
+ struct torture_rpc_tcase_data *tcase_data =
+ (struct torture_rpc_tcase_data *)tcase->data;
fn = test->fn;
- return fn(tctx, (struct dcerpc_pipe *)tcase->data);
+ return fn(tctx, tcase_data->pipe);
}
static bool torture_rpc_wrap_test_ex(struct torture_context *tctx,
@@ -201,10 +280,26 @@ static bool torture_rpc_wrap_test_ex(struct torture_context *tctx,
struct torture_test *test)
{
bool (*fn) (struct torture_context *, struct dcerpc_pipe *, const void *);
+ struct torture_rpc_tcase_data *tcase_data =
+ (struct torture_rpc_tcase_data *)tcase->data;
+
+ fn = test->fn;
+
+ return fn(tctx, tcase_data->pipe, test->data);
+}
+
+
+static bool torture_rpc_wrap_test_creds(struct torture_context *tctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
+{
+ bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct cli_credentials *);
+ struct torture_rpc_tcase_data *tcase_data =
+ (struct torture_rpc_tcase_data *)tcase->data;
fn = test->fn;
- return fn(tctx, (struct dcerpc_pipe *)tcase->data, test->data);
+ return fn(tctx, tcase_data->pipe, tcase_data->credentials);
}
_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test(
@@ -228,6 +323,27 @@ _PUBLIC_ struct torture_test *torture_rpc_tcase_add_test(
return test;
}
+_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test_creds(
+ struct torture_rpc_tcase *tcase,
+ const char *name,
+ bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct cli_credentials *))
+{
+ struct torture_test *test;
+
+ test = talloc(tcase, struct torture_test);
+
+ test->name = talloc_strdup(test, name);
+ test->description = NULL;
+ test->run = torture_rpc_wrap_test_creds;
+ test->dangerous = false;
+ test->data = NULL;
+ test->fn = fn;
+
+ DLIST_ADD(tcase->tcase.tests, test);
+
+ return test;
+}
+
_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test_ex(
struct torture_rpc_tcase *tcase,
const char *name,
@@ -262,26 +378,28 @@ NTSTATUS torture_rpc_init(void)
torture_suite_add_simple_test(suite, "LSA", torture_rpc_lsa);
torture_suite_add_simple_test(suite, "LSALOOKUP", torture_rpc_lsa_lookup);
torture_suite_add_simple_test(suite, "LSA-GETUSER", torture_rpc_lsa_get_user);
- torture_suite_add_simple_test(suite, "SECRETS", torture_rpc_lsa_secrets);
- torture_suite_add_suite(suite, torture_rpc_echo());
+ torture_suite_add_suite(suite, torture_rpc_lsa_secrets(suite));
+ torture_suite_add_suite(suite, torture_rpc_echo(suite));
torture_suite_add_simple_test(suite, "DFS", torture_rpc_dfs);
- torture_suite_add_suite(suite, torture_rpc_unixinfo());
- torture_suite_add_suite(suite, torture_rpc_eventlog());
- torture_suite_add_suite(suite, torture_rpc_atsvc());
+ torture_suite_add_suite(suite, torture_rpc_unixinfo(suite));
+ torture_suite_add_suite(suite, torture_rpc_eventlog(suite));
+ torture_suite_add_suite(suite, torture_rpc_atsvc(suite));
torture_suite_add_suite(suite, torture_rpc_wkssvc(suite));
torture_suite_add_suite(suite, torture_rpc_handles(suite));
torture_suite_add_suite(suite, torture_rpc_winreg(suite));
torture_suite_add_simple_test(suite, "SPOOLSS", torture_rpc_spoolss);
+ torture_suite_add_suite(suite, torture_rpc_spoolss_notify(suite));
torture_suite_add_simple_test(suite, "SAMR", torture_rpc_samr);
torture_suite_add_simple_test(suite, "SAMR-USERS", torture_rpc_samr_users);
torture_suite_add_simple_test(suite, "SAMR-PASSWORDS", torture_rpc_samr_passwords);
- torture_suite_add_simple_test(suite, "NETLOGON", torture_rpc_netlogon);
+ torture_suite_add_suite(suite, torture_rpc_netlogon(suite));
torture_suite_add_simple_test(suite, "SAMLOGON", torture_rpc_samlogon);
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_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));
torture_suite_add_suite(suite, torture_rpc_epmapper(suite));
torture_suite_add_suite(suite, torture_rpc_initshutdown(suite));
torture_suite_add_suite(suite, torture_rpc_oxidresolve(suite));
@@ -303,10 +421,10 @@ NTSTATUS torture_rpc_init(void)
torture_suite_add_simple_test(suite, "SAMBA3-LSA", torture_samba3_rpc_lsa);
torture_suite_add_simple_test(suite, "SAMBA3-SPOOLSS", torture_samba3_rpc_spoolss);
torture_suite_add_simple_test(suite, "SAMBA3-WKSSVC", torture_samba3_rpc_wkssvc);
- torture_suite_add_simple_test(suite, "RPC-SAMBA3-WINREG", torture_samba3_rpc_winreg);
+ torture_suite_add_simple_test(suite, "SAMBA3-WINREG", torture_samba3_rpc_winreg);
torture_suite_add_simple_test(suite, "DRSUAPI", torture_rpc_drsuapi);
torture_suite_add_simple_test(suite, "CRACKNAMES", torture_rpc_drsuapi_cracknames);
- torture_suite_add_simple_test(suite, "DSSETUP", torture_rpc_dssetup);
+ torture_suite_add_suite(suite, torture_rpc_dssetup(suite));
torture_suite_add_simple_test(suite, "ALTERCONTEXT", torture_rpc_alter_context);
torture_suite_add_simple_test(suite, "JOIN", torture_rpc_join);
torture_suite_add_simple_test(suite, "DSSYNC", torture_rpc_dssync);
diff --git a/source4/torture/rpc/rpc.h b/source4/torture/rpc/rpc.h
index 2f1ff323eb..385c734d9c 100644
--- a/source4/torture/rpc/rpc.h
+++ b/source4/torture/rpc/rpc.h
@@ -30,4 +30,18 @@
#include "torture/rpc/proto.h"
#include "torture/ui.h"
+struct torture_rpc_tcase {
+ struct torture_tcase tcase;
+ const struct ndr_interface_table *table;
+ const char *machine_name;
+};
+
+struct torture_rpc_tcase_data {
+ struct test_join *join_ctx;
+ struct dcerpc_pipe *pipe;
+ struct cli_credentials *credentials;
+};
+
+
+
#endif /* __TORTURE_RPC_H__ */
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index 72eba40344..8c52199e66 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -48,6 +48,7 @@
#include "libcli/auth/libcli_auth.h"
#include "lib/crypto/crypto.h"
#include "libcli/security/proto.h"
+#include "param/param.h"
static struct cli_credentials *create_anon_creds(TALLOC_CTX *mem_ctx)
{
@@ -57,7 +58,7 @@ static struct cli_credentials *create_anon_creds(TALLOC_CTX *mem_ctx)
return NULL;
}
- cli_credentials_set_conf(result);
+ cli_credentials_set_conf(result, global_loadparm);
cli_credentials_set_anonymous(result);
return result;
@@ -67,11 +68,11 @@ static struct cli_credentials *create_anon_creds(TALLOC_CTX *mem_ctx)
* This tests a RPC call using an invalid vuid
*/
-BOOL torture_bind_authcontext(struct torture_context *torture)
+bool torture_bind_authcontext(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- BOOL ret = False;
+ bool ret = false;
struct lsa_ObjectAttribute objectattr;
struct lsa_OpenPolicy2 openpolicy;
struct policy_handle handle;
@@ -87,7 +88,7 @@ BOOL torture_bind_authcontext(struct torture_context *torture)
if (mem_ctx == NULL) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
status = smbcli_full_connection(mem_ctx, &cli,
@@ -145,7 +146,7 @@ BOOL torture_bind_authcontext(struct torture_context *torture)
goto done;
}
- session2 = smbcli_session_init(cli->transport, mem_ctx, False);
+ session2 = smbcli_session_init(cli->transport, mem_ctx, false);
if (session2 == NULL) {
d_printf("smbcli_session_init failed\n");
goto done;
@@ -185,7 +186,7 @@ BOOL torture_bind_authcontext(struct torture_context *torture)
goto done;
}
- ret = True;
+ ret = true;
done:
talloc_free(mem_ctx);
return ret;
@@ -195,12 +196,12 @@ BOOL torture_bind_authcontext(struct torture_context *torture)
* Bind to lsa using a specific auth method
*/
-static BOOL bindtest(struct smbcli_state *cli,
+static bool bindtest(struct smbcli_state *cli,
struct cli_credentials *credentials,
uint8_t auth_type, uint8_t auth_level)
{
TALLOC_CTX *mem_ctx;
- BOOL ret = False;
+ bool ret = false;
NTSTATUS status;
struct dcerpc_pipe *lsa_pipe;
@@ -212,7 +213,7 @@ static BOOL bindtest(struct smbcli_state *cli,
if ((mem_ctx = talloc_init("bindtest")) == NULL) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
lsa_pipe = dcerpc_pipe_init(mem_ctx,
@@ -272,7 +273,7 @@ static BOOL bindtest(struct smbcli_state *cli,
goto done;
}
- ret = True;
+ ret = true;
done:
talloc_free(mem_ctx);
return ret;
@@ -282,18 +283,18 @@ static BOOL bindtest(struct smbcli_state *cli,
* test authenticated RPC binds with the variants Samba3 does support
*/
-BOOL torture_bind_samba3(struct torture_context *torture)
+bool torture_bind_samba3(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- BOOL ret = False;
+ bool ret = false;
struct smbcli_state *cli;
mem_ctx = talloc_init("torture_bind_authcontext");
if (mem_ctx == NULL) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
status = smbcli_full_connection(mem_ctx, &cli,
@@ -306,7 +307,7 @@ BOOL torture_bind_samba3(struct torture_context *torture)
goto done;
}
- ret = True;
+ ret = true;
ret &= bindtest(cli, cmdline_credentials, DCERPC_AUTH_TYPE_NTLMSSP,
DCERPC_AUTH_LEVEL_INTEGRITY);
@@ -501,7 +502,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
* Create a test user
*/
-static BOOL create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
+static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
struct cli_credentials *admin_creds,
const char *username, const char *password,
char **domain_name,
@@ -511,11 +512,11 @@ static BOOL create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
NTSTATUS status;
struct dcerpc_pipe *samr_pipe;
struct policy_handle *wks_handle;
- BOOL ret = False;
+ bool ret = false;
if (!(tmp_ctx = talloc_new(mem_ctx))) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
status = get_usr_handle(cli, tmp_ctx, admin_creds,
@@ -603,7 +604,7 @@ static BOOL create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
*domain_name= talloc_steal(mem_ctx, *domain_name);
*user_sid = talloc_steal(mem_ctx, *user_sid);
- ret = True;
+ ret = true;
done:
talloc_free(tmp_ctx);
return ret;
@@ -613,7 +614,7 @@ static BOOL create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
* Delete a test user
*/
-static BOOL delete_user(struct smbcli_state *cli,
+static bool delete_user(struct smbcli_state *cli,
struct cli_credentials *admin_creds,
const char *username)
{
@@ -622,11 +623,11 @@ static BOOL delete_user(struct smbcli_state *cli,
char *dom_name;
struct dcerpc_pipe *samr_pipe;
struct policy_handle *user_handle;
- BOOL ret = False;
+ bool ret = false;
if ((mem_ctx = talloc_init("leave")) == NULL) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
status = get_usr_handle(cli, mem_ctx, admin_creds,
@@ -648,12 +649,12 @@ static BOOL delete_user(struct smbcli_state *cli,
status = dcerpc_samr_DeleteUser(samr_pipe, mem_ctx, &d);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("samr_DeleteUser failed\n");
+ d_printf("samr_DeleteUser failed %s\n", nt_errstr(status));
goto done;
}
}
- ret = True;
+ ret = true;
done:
talloc_free(mem_ctx);
@@ -664,8 +665,8 @@ static BOOL delete_user(struct smbcli_state *cli,
* Do a Samba3-style join
*/
-static BOOL join3(struct smbcli_state *cli,
- BOOL use_level25,
+static bool join3(struct smbcli_state *cli,
+ bool use_level25,
struct cli_credentials *admin_creds,
struct cli_credentials *wks_creds)
{
@@ -674,11 +675,11 @@ static BOOL join3(struct smbcli_state *cli,
char *dom_name;
struct dcerpc_pipe *samr_pipe;
struct policy_handle *wks_handle;
- BOOL ret = False;
+ bool ret = false;
if ((mem_ctx = talloc_init("join3")) == NULL) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
status = get_usr_handle(
@@ -787,7 +788,7 @@ static BOOL join3(struct smbcli_state *cli,
}
}
- ret = True;
+ ret = true;
done:
talloc_free(mem_ctx);
@@ -798,12 +799,12 @@ static BOOL join3(struct smbcli_state *cli,
* Do a ReqChallenge/Auth2 and get the wks creds
*/
-static BOOL auth2(struct smbcli_state *cli,
+static bool auth2(struct smbcli_state *cli,
struct cli_credentials *wks_cred)
{
TALLOC_CTX *mem_ctx;
struct dcerpc_pipe *net_pipe;
- BOOL result = False;
+ bool result = false;
NTSTATUS status;
struct netr_ServerReqChallenge r;
struct netr_Credential netr_cli_creds;
@@ -817,7 +818,7 @@ static BOOL auth2(struct smbcli_state *cli,
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
d_printf("talloc_new failed\n");
- return False;
+ return false;
}
net_pipe = dcerpc_pipe_init(mem_ctx,
@@ -893,7 +894,7 @@ static BOOL auth2(struct smbcli_state *cli,
cli_credentials_set_netlogon_creds(wks_cred, creds_state);
- result = True;
+ result = true;
done:
talloc_free(mem_ctx);
@@ -905,20 +906,20 @@ static BOOL auth2(struct smbcli_state *cli,
* login, and change the wks password
*/
-static BOOL schan(struct smbcli_state *cli,
+static bool schan(struct smbcli_state *cli,
struct cli_credentials *wks_creds,
struct cli_credentials *user_creds)
{
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- BOOL ret = False;
+ bool ret = false;
struct dcerpc_pipe *net_pipe;
int i;
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
d_printf("talloc_new failed\n");
- return False;
+ return false;
}
net_pipe = dcerpc_pipe_init(mem_ctx,
@@ -1092,7 +1093,7 @@ static BOOL schan(struct smbcli_state *cli,
CRED_SPECIFIED);
}
- ret = True;
+ ret = true;
done:
talloc_free(mem_ctx);
return ret;
@@ -1102,13 +1103,13 @@ static BOOL schan(struct smbcli_state *cli,
* Delete the wks account again
*/
-static BOOL leave(struct smbcli_state *cli,
+static bool leave(struct smbcli_state *cli,
struct cli_credentials *admin_creds,
struct cli_credentials *wks_creds)
{
char *wks_name = talloc_asprintf(
NULL, "%s$", cli_credentials_get_workstation(wks_creds));
- BOOL ret;
+ bool ret;
ret = delete_user(cli, admin_creds, wks_name);
talloc_free(wks_name);
@@ -1119,11 +1120,11 @@ static BOOL leave(struct smbcli_state *cli,
* Test the Samba3 DC code a bit. Join, do some schan netlogon ops, leave
*/
-BOOL torture_netlogon_samba3(struct torture_context *torture)
+bool torture_netlogon_samba3(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- BOOL ret = False;
+ bool ret = false;
struct smbcli_state *cli;
struct cli_credentials *anon_creds;
struct cli_credentials *wks_creds;
@@ -1139,7 +1140,7 @@ BOOL torture_netlogon_samba3(struct torture_context *torture)
if (mem_ctx == NULL) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
if (!(anon_creds = create_anon_creds(mem_ctx))) {
@@ -1162,7 +1163,7 @@ BOOL torture_netlogon_samba3(struct torture_context *torture)
goto done;
}
- cli_credentials_set_conf(wks_creds);
+ cli_credentials_set_conf(wks_creds, global_loadparm);
cli_credentials_set_secure_channel_type(wks_creds, SEC_CHAN_WKSTA);
cli_credentials_set_username(wks_creds, wks_name, CRED_SPECIFIED);
cli_credentials_set_workstation(wks_creds, wks_name, CRED_SPECIFIED);
@@ -1170,7 +1171,7 @@ BOOL torture_netlogon_samba3(struct torture_context *torture)
generate_random_str(wks_creds, 8),
CRED_SPECIFIED);
- if (!join3(cli, False, cmdline_credentials, wks_creds)) {
+ if (!join3(cli, false, cmdline_credentials, wks_creds)) {
d_printf("join failed\n");
goto done;
}
@@ -1205,7 +1206,7 @@ BOOL torture_netlogon_samba3(struct torture_context *torture)
goto done;
}
- ret = True;
+ ret = true;
done:
talloc_free(mem_ctx);
@@ -1217,19 +1218,19 @@ BOOL torture_netlogon_samba3(struct torture_context *torture)
* credentials
*/
-static BOOL test_join3(TALLOC_CTX *mem_ctx,
- BOOL use_level25,
+static bool test_join3(TALLOC_CTX *mem_ctx,
+ bool use_level25,
struct cli_credentials *smb_creds,
struct cli_credentials *samr_creds,
const char *wks_name)
{
NTSTATUS status;
- BOOL ret = False;
+ bool ret = false;
struct smbcli_state *cli;
struct cli_credentials *wks_creds;
status = smbcli_full_connection(mem_ctx, &cli,
- lp_parm_string(-1, "torture", "host"),
+ lp_parm_string(global_loadparm, NULL, "torture", "host"),
"IPC$", NULL, smb_creds, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
@@ -1243,7 +1244,7 @@ static BOOL test_join3(TALLOC_CTX *mem_ctx,
goto done;
}
- cli_credentials_set_conf(wks_creds);
+ cli_credentials_set_conf(wks_creds, global_loadparm);
cli_credentials_set_secure_channel_type(wks_creds, SEC_CHAN_WKSTA);
cli_credentials_set_username(wks_creds, wks_name, CRED_SPECIFIED);
cli_credentials_set_workstation(wks_creds, wks_name, CRED_SPECIFIED);
@@ -1272,7 +1273,7 @@ static BOOL test_join3(TALLOC_CTX *mem_ctx,
talloc_free(cli);
- ret = True;
+ ret = true;
done:
return ret;
@@ -1283,10 +1284,10 @@ static BOOL test_join3(TALLOC_CTX *mem_ctx,
* session key in the setpassword routine. Test the join by doing the auth2.
*/
-BOOL torture_samba3_sessionkey(struct torture_context *torture)
+bool torture_samba3_sessionkey(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
- BOOL ret = False;
+ bool ret = false;
struct cli_credentials *anon_creds;
const char *wks_name;
@@ -1296,7 +1297,7 @@ BOOL torture_samba3_sessionkey(struct torture_context *torture)
if (mem_ctx == NULL) {
d_printf("talloc_init failed\n");
- return False;
+ return false;
}
if (!(anon_creds = create_anon_creds(mem_ctx))) {
@@ -1304,56 +1305,56 @@ BOOL torture_samba3_sessionkey(struct torture_context *torture)
goto done;
}
- ret = True;
+ ret = true;
- if (!torture_setting_bool(torture, "samba3", False)) {
+ if (!torture_setting_bool(torture, "samba3", false)) {
/* Samba3 in the build farm right now does this happily. Need
* to fix :-) */
- if (test_join3(mem_ctx, False, anon_creds, NULL, wks_name)) {
+ if (test_join3(mem_ctx, false, anon_creds, NULL, wks_name)) {
d_printf("join using anonymous bind on an anonymous smb "
"connection succeeded -- HUH??\n");
- ret = False;
+ ret = false;
}
}
- if (!test_join3(mem_ctx, False, anon_creds, cmdline_credentials,
+ if (!test_join3(mem_ctx, false, anon_creds, cmdline_credentials,
wks_name)) {
d_printf("join using ntlmssp bind on an anonymous smb "
"connection failed\n");
- ret = False;
+ ret = false;
}
- if (!test_join3(mem_ctx, False, cmdline_credentials, NULL, wks_name)) {
+ if (!test_join3(mem_ctx, false, cmdline_credentials, NULL, wks_name)) {
d_printf("join using anonymous bind on an authenticated smb "
"connection failed\n");
- ret = False;
+ ret = false;
}
- if (!test_join3(mem_ctx, False, cmdline_credentials,
+ if (!test_join3(mem_ctx, false, cmdline_credentials,
cmdline_credentials,
wks_name)) {
d_printf("join using ntlmssp bind on an authenticated smb "
"connection failed\n");
- ret = False;
+ ret = false;
}
/*
* The following two are tests for setuserinfolevel 25
*/
- if (!test_join3(mem_ctx, True, anon_creds, cmdline_credentials,
+ if (!test_join3(mem_ctx, true, anon_creds, cmdline_credentials,
wks_name)) {
d_printf("join using ntlmssp bind on an anonymous smb "
"connection failed\n");
- ret = False;
+ ret = false;
}
- if (!test_join3(mem_ctx, True, cmdline_credentials, NULL, wks_name)) {
+ if (!test_join3(mem_ctx, true, cmdline_credentials, NULL, wks_name)) {
d_printf("join using anonymous bind on an authenticated smb "
"connection failed\n");
- ret = False;
+ ret = false;
}
done:
@@ -1546,7 +1547,7 @@ NTSTATUS secondary_tcon(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- if (!(result = smbcli_tree_init(session, mem_ctx, False))) {
+ if (!(result = smbcli_tree_init(session, mem_ctx, false))) {
talloc_free(tmp_ctx);
return NT_STATUS_NO_MEMORY;
}
@@ -1576,12 +1577,12 @@ NTSTATUS secondary_tcon(TALLOC_CTX *mem_ctx,
* Test the getusername behaviour
*/
-BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
+bool torture_samba3_rpc_getusername(struct torture_context *torture)
{
NTSTATUS status;
struct smbcli_state *cli;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct dom_sid *user_sid;
struct dom_sid *created_sid;
struct cli_credentials *anon_creds;
@@ -1589,7 +1590,7 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
char *domain_name;
if (!(mem_ctx = talloc_new(torture))) {
- return False;
+ return false;
}
status = smbcli_full_connection(
@@ -1598,21 +1599,21 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
if (!(user_sid = whoami(mem_ctx, cli->tree))) {
d_printf("(%s) whoami on auth'ed connection failed\n",
__location__);
- ret = False;
+ ret = false;
}
talloc_free(cli);
if (!(anon_creds = create_anon_creds(mem_ctx))) {
d_printf("(%s) create_anon_creds failed\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1622,14 +1623,14 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) anon smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
if (!(user_sid = whoami(mem_ctx, cli->tree))) {
d_printf("(%s) whoami on anon connection failed\n",
__location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1638,16 +1639,16 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
d_printf("(%s) Anon lsa_GetUserName returned %s, expected "
"S-1-5-7", __location__,
dom_sid_string(mem_ctx, user_sid));
- ret = False;
+ ret = false;
}
if (!(user_creds = cli_credentials_init(mem_ctx))) {
d_printf("(%s) cli_credentials_init failed\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
- cli_credentials_set_conf(user_creds);
+ cli_credentials_set_conf(user_creds, global_loadparm);
cli_credentials_set_username(user_creds, "torture_username",
CRED_SPECIFIED);
cli_credentials_set_password(user_creds,
@@ -1659,7 +1660,7 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
cli_credentials_get_password(user_creds),
&domain_name, &created_sid)) {
d_printf("(%s) create_user failed\n", __location__);
- ret = False;
+ ret = false;
goto done;
}
@@ -1671,7 +1672,7 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
struct smb_composite_sesssetup setup;
struct smbcli_tree *tree;
- session2 = smbcli_session_init(cli->transport, mem_ctx, False);
+ session2 = smbcli_session_init(cli->transport, mem_ctx, false);
if (session2 == NULL) {
d_printf("(%s) smbcli_session_init failed\n",
__location__);
@@ -1687,7 +1688,7 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) session setup with new user failed: "
"%s\n", __location__, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
session2->vuid = setup.out.vuid;
@@ -1696,14 +1697,14 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
"IPC$", &tree))) {
d_printf("(%s) secondary_tcon failed\n",
__location__);
- ret = False;
+ ret = false;
goto done;
}
if (!(user_sid = whoami(mem_ctx, tree))) {
d_printf("(%s) whoami on user connection failed\n",
__location__);
- ret = False;
+ ret = false;
goto delete;
}
@@ -1715,14 +1716,14 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
dom_sid_string(mem_ctx, user_sid));
if (!dom_sid_equal(created_sid, user_sid)) {
- ret = False;
+ ret = false;
}
delete:
if (!delete_user(cli, cmdline_credentials,
cli_credentials_get_username(user_creds))) {
d_printf("(%s) delete_user failed\n", __location__);
- ret = False;
+ ret = false;
}
done:
@@ -1730,14 +1731,14 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture)
return ret;
}
-static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char *sharename)
{
NTSTATUS status;
struct srvsvc_NetShareGetInfo r;
uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007, 1501 };
int i;
- BOOL ret = True;
+ bool ret = true;
r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s",
dcerpc_server_name(p));
@@ -1756,14 +1757,14 @@ static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("NetShareGetInfo level %u on share '%s' failed"
" - %s\n", r.in.level, r.in.share_name,
nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
if (!W_ERROR_IS_OK(r.out.result)) {
printf("NetShareGetInfo level %u on share '%s' failed "
"- %s\n", r.in.level, r.in.share_name,
win_errstr(r.out.result));
- ret = False;
+ ret = false;
continue;
}
}
@@ -1771,7 +1772,7 @@ static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char **one_sharename)
{
NTSTATUS status;
@@ -1779,7 +1780,7 @@ static BOOL test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct srvsvc_NetShareCtr0 c0;
uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007 };
int i;
- BOOL ret = True;
+ bool ret = true;
r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
r.in.ctr.ctr0 = &c0;
@@ -1798,7 +1799,7 @@ static BOOL test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("NetShareEnum level %u failed - %s\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
if (!W_ERROR_IS_OK(r.out.result)) {
@@ -1817,24 +1818,24 @@ static BOOL test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-BOOL torture_samba3_rpc_srvsvc(struct torture_context *torture)
+bool torture_samba3_rpc_srvsvc(struct torture_context *torture)
{
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
const char *sharename = NULL;
struct smbcli_state *cli;
NTSTATUS status;
if (!(mem_ctx = talloc_new(torture))) {
- return False;
+ return false;
}
if (!(torture_open_connection_share(
mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
"IPC$", NULL))) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
status = pipe_bind_smb(mem_ctx, cli->tree, "\\pipe\\srvsvc",
@@ -1842,7 +1843,7 @@ BOOL torture_samba3_rpc_srvsvc(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) could not bind to srvsvc pipe: %s\n",
__location__, nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
@@ -1966,7 +1967,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx,
return status;
}
-BOOL try_tcon(TALLOC_CTX *mem_ctx,
+bool try_tcon(TALLOC_CTX *mem_ctx,
struct security_descriptor *orig_sd,
struct smbcli_session *session,
const char *sharename, const struct dom_sid *user_sid,
@@ -1979,18 +1980,18 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx,
uint32_t rid;
struct security_descriptor *sd;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
if (!(tmp_ctx = talloc_new(mem_ctx))) {
d_printf("talloc_new failed\n");
- return False;
+ return false;
}
status = secondary_tcon(tmp_ctx, session, sharename, &rmdir_tree);
if (!NT_STATUS_IS_OK(status)) {
d_printf("first tcon to delete dir failed\n");
talloc_free(tmp_ctx);
- return False;
+ return false;
}
smbcli_rmdir(rmdir_tree, "sharesec_testdir");
@@ -1999,7 +2000,7 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx,
&domain_sid, &rid))) {
d_printf("dom_sid_split_rid failed\n");
talloc_free(tmp_ctx);
- return False;
+ return false;
}
sd = security_descriptor_create(
@@ -2011,7 +2012,7 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx,
if (sd == NULL) {
d_printf("security_descriptor_create failed\n");
talloc_free(tmp_ctx);
- return False;
+ return false;
}
status = set_sharesec(mem_ctx, session, sharename, sd);
@@ -2019,14 +2020,14 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx,
d_printf("custom set_sharesec failed: %s\n",
nt_errstr(status));
talloc_free(tmp_ctx);
- return False;
+ return false;
}
status = secondary_tcon(tmp_ctx, session, sharename, &tree);
if (!NT_STATUS_EQUAL(status, expected_tcon)) {
d_printf("Expected %s, got %s\n", nt_errstr(expected_tcon),
nt_errstr(status));
- ret = False;
+ ret = false;
goto done;
}
@@ -2039,7 +2040,7 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(status, expected_mkdir)) {
d_printf("(%s) Expected %s, got %s\n", __location__,
nt_errstr(expected_mkdir), nt_errstr(status));
- ret = False;
+ ret = false;
}
done:
@@ -2050,23 +2051,23 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx,
d_printf("custom set_sharesec failed: %s\n",
nt_errstr(status));
talloc_free(tmp_ctx);
- return False;
+ return false;
}
talloc_free(tmp_ctx);
return ret;
}
-BOOL torture_samba3_rpc_sharesec(struct torture_context *torture)
+bool torture_samba3_rpc_sharesec(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct smbcli_state *cli;
struct security_descriptor *sd;
struct dom_sid *user_sid;
if (!(mem_ctx = talloc_new(torture))) {
- return False;
+ return false;
}
if (!(torture_open_connection_share(
@@ -2074,13 +2075,13 @@ BOOL torture_samba3_rpc_sharesec(struct torture_context *torture)
"IPC$", NULL))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (!(user_sid = whoami(mem_ctx, cli->tree))) {
d_printf("whoami failed\n");
talloc_free(mem_ctx);
- return False;
+ return false;
}
sd = get_sharesec(mem_ctx, cli->session, torture_setting_string(torture,
@@ -2103,10 +2104,10 @@ BOOL torture_samba3_rpc_sharesec(struct torture_context *torture)
return ret;
}
-BOOL torture_samba3_rpc_lsa(struct torture_context *torture)
+bool torture_samba3_rpc_lsa(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct smbcli_state *cli;
struct dcerpc_pipe *p;
struct policy_handle lsa_handle;
@@ -2114,7 +2115,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture)
struct dom_sid *domain_sid;
if (!(mem_ctx = talloc_new(torture))) {
- return False;
+ return false;
}
if (!(torture_open_connection_share(
@@ -2122,7 +2123,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture)
"IPC$", NULL))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
- return False;
+ return false;
}
status = pipe_bind_smb(mem_ctx, cli->tree, "\\lsarpc",
@@ -2131,7 +2132,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture)
d_printf("(%s) pipe_bind_smb failed: %s\n", __location__,
nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
{
@@ -2148,7 +2149,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture)
d_printf("(%s) dcerpc_lsa_OpenPolicy2 failed: %s\n",
__location__, nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
@@ -2170,7 +2171,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture)
"failed: %s\n", __location__,
levels[i], nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (levels[i] == 5) {
domain_sid = r.out.info->account_domain.sid;
@@ -2265,7 +2266,7 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree,
return NT_STATUS_OK;
}
-static BOOL enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe,
+static bool enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe,
const char *servername, int level, int *num_printers)
{
struct spoolss_EnumPrinters r;
@@ -2282,20 +2283,20 @@ static BOOL enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe,
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) dcerpc_spoolss_EnumPrinters failed: %s\n",
__location__, nt_errstr(status));
- return False;
+ return false;
}
if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
d_printf("(%s) EnumPrinters unexpected return code %s, should "
"be WERR_INSUFFICIENT_BUFFER\n", __location__,
win_errstr(r.out.result));
- return False;
+ return false;
}
blob = data_blob_talloc_zero(mem_ctx, r.out.needed);
if (blob.data == NULL) {
d_printf("(%s) data_blob_talloc failed\n", __location__);
- return False;
+ return false;
}
r.in.buffer = &blob;
@@ -2306,12 +2307,12 @@ static BOOL enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe,
d_printf("(%s) dcerpc_spoolss_EnumPrinters failed: %s, "
"%s\n", __location__, nt_errstr(status),
win_errstr(r.out.result));
- return False;
+ return false;
}
*num_printers = r.out.count;
- return True;
+ return true;
}
static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe,
@@ -2378,10 +2379,10 @@ static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe,
return NT_STATUS_OK;
}
-BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
+bool torture_samba3_rpc_spoolss(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct smbcli_state *cli;
struct dcerpc_pipe *p;
NTSTATUS status;
@@ -2392,7 +2393,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
char *servername;
if (!(mem_ctx = talloc_new(torture))) {
- return False;
+ return false;
}
if (!(torture_open_connection_share(
@@ -2400,7 +2401,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
"IPC$", NULL))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
- return False;
+ return false;
}
status = get_servername(mem_ctx, cli->tree, &servername);
@@ -2408,19 +2409,19 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
d_fprintf(stderr, "(%s) get_servername returned %s\n",
__location__, nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (!NT_STATUS_IS_OK(find_printers(mem_ctx, cli->tree,
&printers, &num_printers))) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (num_printers == 0) {
d_printf("Did not find printers\n");
talloc_free(mem_ctx);
- return True;
+ return true;
}
status = pipe_bind_smb(mem_ctx, cli->tree, "\\spoolss",
@@ -2429,12 +2430,12 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
d_printf("(%s) pipe_bind_smb failed: %s\n", __location__,
nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
ZERO_STRUCT(userlevel1);
userlevel1.client = talloc_asprintf(
- mem_ctx, "\\\\%s", lp_netbios_name());
+ mem_ctx, "\\\\%s", lp_netbios_name(global_loadparm));
userlevel1.user = cli_credentials_get_username(cmdline_credentials);
userlevel1.build = 2600;
userlevel1.major = 3;
@@ -2459,7 +2460,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
"%s, %s\n", __location__, nt_errstr(status),
win_errstr(r.out.result));
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
@@ -2475,7 +2476,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
"%s, %s\n", __location__, nt_errstr(status),
win_errstr(r.out.result));
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
@@ -2497,7 +2498,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
"%s, %s\n", __location__, nt_errstr(status),
win_errstr(r.out.result));
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
@@ -2510,7 +2511,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) getprinterinfo %d failed: %s\n",
__location__, i, nt_errstr(status));
- ret = False;
+ ret = false;
}
}
}
@@ -2526,7 +2527,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
d_printf("(%s) dcerpc_spoolss_ClosePrinter failed: "
"%s\n", __location__, nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
@@ -2536,14 +2537,14 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
&num_enumerated)) {
d_printf("(%s) enumprinters failed\n", __location__);
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (num_printers != num_enumerated) {
d_printf("(%s) netshareenum gave %d printers, "
"enumprinters lvl 1 gave %d\n", __location__,
num_printers, num_enumerated);
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
@@ -2553,14 +2554,14 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
&num_enumerated)) {
d_printf("(%s) enumprinters failed\n", __location__);
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (num_printers != num_enumerated) {
d_printf("(%s) netshareenum gave %d printers, "
"enumprinters lvl 2 gave %d\n", __location__,
num_printers, num_enumerated);
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
@@ -2569,7 +2570,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
return ret;
}
-BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture)
+bool torture_samba3_rpc_wkssvc(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx;
struct smbcli_state *cli;
@@ -2578,7 +2579,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture)
char *servername;
if (!(mem_ctx = talloc_new(torture))) {
- return False;
+ return false;
}
if (!(torture_open_connection_share(
@@ -2586,7 +2587,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture)
"IPC$", NULL))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
- return False;
+ return false;
}
status = get_servername(mem_ctx, cli->tree, &servername);
@@ -2594,7 +2595,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture)
d_fprintf(stderr, "(%s) get_servername returned %s\n",
__location__, nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
status = pipe_bind_smb(mem_ctx, cli->tree, "\\wkssvc",
@@ -2603,7 +2604,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture)
d_printf("(%s) pipe_bind_smb failed: %s\n", __location__,
nt_errstr(status));
talloc_free(mem_ctx);
- return False;
+ return false;
}
{
@@ -2622,7 +2623,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture)
"%s, %s\n", __location__, nt_errstr(status),
win_errstr(r.out.result));
talloc_free(mem_ctx);
- return False;
+ return false;
}
if (strcmp(servername,
@@ -2632,12 +2633,12 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture)
__location__, servername,
r.out.info->info100->server_name);
talloc_free(mem_ctx);
- return False;
+ return false;
}
}
talloc_free(mem_ctx);
- return True;
+ return true;
}
static NTSTATUS winreg_close(struct dcerpc_pipe *p,
@@ -2766,14 +2767,14 @@ static NTSTATUS enumkeys(struct dcerpc_pipe *p, struct policy_handle *handle,
talloc_free(tmp_ctx);
r.in.enum_index += 1;
- } while(True);
+ } while(true);
return NT_STATUS_OK;
}
typedef NTSTATUS (*winreg_open_fn)(struct dcerpc_pipe *, TALLOC_CTX *, void *);
-static BOOL test_Open3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_Open3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char *name, winreg_open_fn open_fn)
{
struct policy_handle handle;
@@ -2788,7 +2789,7 @@ static BOOL test_Open3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
d_printf("(%s) %s failed: %s, %s\n", __location__, name,
nt_errstr(status), win_errstr(r.out.result));
- return False;
+ return false;
}
enumkeys(p, &handle, mem_ctx, 4);
@@ -2797,18 +2798,18 @@ static BOOL test_Open3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) dcerpc_CloseKey failed: %s\n",
__location__, nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_samba3_rpc_winreg(struct torture_context *torture)
+bool torture_samba3_rpc_winreg(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct {
const char *name;
winreg_open_fn fn;
@@ -2828,7 +2829,7 @@ BOOL torture_samba3_rpc_winreg(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
#if 1
@@ -2836,7 +2837,7 @@ BOOL torture_samba3_rpc_winreg(struct torture_context *torture)
#else
for (i = 0; i < ARRAY_SIZE(open_fns); i++) {
if (!test_Open3(p, mem_ctx, open_fns[i].name, open_fns[i].fn))
- ret = False;
+ ret = false;
}
#endif
diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c
index da74067336..aa0f6de788 100644
--- a/source4/torture/rpc/samlogon.c
+++ b/source4/torture/rpc/samlogon.c
@@ -31,6 +31,7 @@
#include "torture/rpc/rpc.h"
#include "auth/gensec/schannel_proto.h"
#include "libcli/auth/libcli_auth.h"
+#include "param/param.h"
#define TEST_MACHINE_NAME "samlogontest"
#define TEST_USER_NAME "samlogontestuser"
@@ -61,7 +62,7 @@ struct samlogon_state {
struct netr_Authenticator auth, auth2;
struct creds_CredentialState *creds;
NTSTATUS expected_error;
- BOOL old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */
+ bool old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */
DATA_BLOB chall;
};
@@ -262,10 +263,10 @@ static NTSTATUS check_samlogon(struct samlogon_state *samlogon_state,
* Test the normal 'LM and NTLM' combination
*/
-static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm_break break_which, char **error_string)
+static bool test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm_break break_which, char **error_string)
{
- BOOL pass = True;
- BOOL lm_good;
+ bool pass = true;
+ bool lm_good;
NTSTATUS nt_status;
DATA_BLOB lm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24);
DATA_BLOB nt_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24);
@@ -306,11 +307,11 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm
if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) {
/* for 'long' passwords, the LM password is invalid */
if (break_which == NO_NT && !lm_good) {
- return True;
+ return true;
}
/* for 'old' passwords, we allow the server to be OK or wrong password */
if (samlogon_state->old_password) {
- return True;
+ return true;
}
return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH));
} else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) {
@@ -318,16 +319,16 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm
} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
SAFE_FREE(*error_string);
asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
- return False;
+ return false;
} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
- return True;
+ return true;
} else if (!NT_STATUS_IS_OK(nt_status)) {
- return False;
+ return false;
}
if (break_which == NO_NT && !lm_good) {
*error_string = strdup("LM password is 'long' (> 14 chars and therefore invalid) but login did not fail!");
- return False;
+ return false;
}
if (memcmp(lm_hash, lm_key,
@@ -337,7 +338,7 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm
dump_data(1, lm_key, 8);
d_printf("expected:\n");
dump_data(1, lm_hash, 8);
- pass = False;
+ pass = false;
}
switch (break_which) {
@@ -353,7 +354,7 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm
dump_data(1, user_session_key, sizeof(user_session_key));
d_printf("expected:\n");
dump_data(1, lm_key_expected, sizeof(lm_key_expected));
- pass = False;
+ pass = false;
}
break;
}
@@ -365,7 +366,7 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm
dump_data(1, user_session_key, 16);
d_printf("expected:\n");
dump_data(1, session_key.data, session_key.length);
- pass = False;
+ pass = false;
}
}
return pass;
@@ -375,7 +376,7 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm
* Test LM authentication, no NT response supplied
*/
-static BOOL test_lm(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lm(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lm_ntlm_broken(samlogon_state, NO_NT, error_string);
@@ -385,7 +386,7 @@ static BOOL test_lm(struct samlogon_state *samlogon_state, char **error_string)
* Test the NTLM response only, no LM.
*/
-static BOOL test_ntlm(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlm(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lm_ntlm_broken(samlogon_state, NO_LM, error_string);
}
@@ -394,10 +395,10 @@ static BOOL test_ntlm(struct samlogon_state *samlogon_state, char **error_string
* Test the NTLM response only, but in the LM field.
*/
-static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_string)
{
- BOOL lm_good;
- BOOL pass = True;
+ bool lm_good;
+ bool pass = true;
NTSTATUS nt_status;
DATA_BLOB nt_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24);
DATA_BLOB session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16);
@@ -433,17 +434,17 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_
if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) {
/* for 'old' passwords, we allow the server to be OK or wrong password */
if (samlogon_state->old_password) {
- return True;
+ return true;
}
- return False;
+ return false;
} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
SAFE_FREE(*error_string);
asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
- return False;
+ return false;
} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
- return True;
+ return true;
} else if (!NT_STATUS_IS_OK(nt_status)) {
- return False;
+ return false;
}
if (lm_good) {
@@ -454,7 +455,7 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_
dump_data(1, lm_key, 8);
d_printf("expected:\n");
dump_data(1, lm_hash, 8);
- pass = False;
+ pass = false;
}
#if 0
} else {
@@ -465,7 +466,7 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_
dump_data(1, lm_key, 8);
d_printf("expected:\n");
dump_data(1, session_key.data, 8);
- pass = False;
+ pass = false;
}
#endif
}
@@ -480,7 +481,7 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_
dump_data(1, user_session_key, sizeof(user_session_key));
d_printf("expected:\n");
dump_data(1, lm_key_expected, sizeof(lm_key_expected));
- pass = False;
+ pass = false;
}
}
return pass;
@@ -490,10 +491,10 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_
* Test the NTLM response only, but in the both the NT and LM fields.
*/
-static BOOL test_ntlm_in_both(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlm_in_both(struct samlogon_state *samlogon_state, char **error_string)
{
- BOOL pass = True;
- BOOL lm_good;
+ bool pass = true;
+ bool lm_good;
NTSTATUS nt_status;
DATA_BLOB nt_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24);
DATA_BLOB session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16);
@@ -530,21 +531,21 @@ static BOOL test_ntlm_in_both(struct samlogon_state *samlogon_state, char **erro
if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) {
/* for 'old' passwords, we allow the server to be OK or wrong password */
if (samlogon_state->old_password) {
- return True;
+ return true;
}
- return False;
+ return false;
} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
SAFE_FREE(*error_string);
asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
- return False;
+ return false;
} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
- return True;
+ return true;
} else if (!NT_STATUS_IS_OK(nt_status)) {
- return False;
+ return false;
}
if (!NT_STATUS_IS_OK(nt_status)) {
- return False;
+ return false;
}
if (memcmp(lm_hash, lm_key,
@@ -554,7 +555,7 @@ static BOOL test_ntlm_in_both(struct samlogon_state *samlogon_state, char **erro
dump_data(1, lm_key, 8);
d_printf("expected:\n");
dump_data(1, lm_hash, 8);
- pass = False;
+ pass = false;
}
if (memcmp(session_key.data, user_session_key,
sizeof(user_session_key)) != 0) {
@@ -563,7 +564,7 @@ static BOOL test_ntlm_in_both(struct samlogon_state *samlogon_state, char **erro
dump_data(1, user_session_key, 16);
d_printf("expected:\n");
dump_data(1, session_key.data, session_key.length);
- pass = False;
+ pass = false;
}
@@ -579,18 +580,18 @@ enum ntlmv2_domain {
NO_DOMAIN
};
-static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
+static bool test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
enum ntlm_break break_which,
enum ntlmv2_domain ntlmv2_domain,
char **error_string)
{
- BOOL pass = True;
+ bool pass = true;
NTSTATUS nt_status;
DATA_BLOB ntlmv2_response = data_blob(NULL, 0);
DATA_BLOB lmv2_response = data_blob(NULL, 0);
DATA_BLOB lmv2_session_key = data_blob(NULL, 0);
DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0);
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, TEST_MACHINE_NAME, lp_workgroup());
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, TEST_MACHINE_NAME, lp_workgroup(global_loadparm));
uint8_t lm_session_key[8];
uint8_t user_session_key[16];
@@ -607,7 +608,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
&lmv2_response, &ntlmv2_response,
&lmv2_session_key, &ntlmv2_session_key)) {
data_blob_free(&names_blob);
- return False;
+ return false;
}
break;
case NO_DOMAIN:
@@ -618,7 +619,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
&lmv2_response, &ntlmv2_response,
&lmv2_session_key, &ntlmv2_session_key)) {
data_blob_free(&names_blob);
- return False;
+ return false;
}
break;
}
@@ -641,7 +642,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) {
/* for 'old' passwords, we allow the server to be OK or wrong password */
if (samlogon_state->old_password) {
- return True;
+ return true;
}
return break_which == BREAK_BOTH;
} else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) {
@@ -649,11 +650,11 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
SAFE_FREE(*error_string);
asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
- return False;
+ return false;
} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
- return True;
+ return true;
} else if (!NT_STATUS_IS_OK(nt_status)) {
- return False;
+ return false;
}
@@ -666,7 +667,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
dump_data(1, user_session_key, 16);
d_printf("expected:\n");
dump_data(1, lmv2_session_key.data, ntlmv2_session_key.length);
- pass = False;
+ pass = false;
}
if (memcmp(lmv2_session_key.data, lm_session_key,
sizeof(lm_session_key)) != 0) {
@@ -675,7 +676,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
dump_data(1, lm_session_key, 8);
d_printf("expected:\n");
dump_data(1, lmv2_session_key.data, 8);
- pass = False;
+ pass = false;
}
break;
default:
@@ -688,7 +689,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
dump_data(1, user_session_key, 16);
d_printf("expected:\n");
dump_data(1, ntlmv2_session_key.data, ntlmv2_session_key.length);
- pass = False;
+ pass = false;
} else {
d_printf("USER (NTLMv2) Session Key does not match expectations!\n");
@@ -696,7 +697,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
dump_data(1, user_session_key, 16);
d_printf("expected:\n");
dump_data(1, ntlmv2_session_key.data, ntlmv2_session_key.length);
- pass = False;
+ pass = false;
}
}
if (memcmp(ntlmv2_session_key.data, lm_session_key,
@@ -708,14 +709,14 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
dump_data(1, lm_session_key, 8);
d_printf("expected:\n");
dump_data(1, ntlmv2_session_key.data, 8);
- pass = False;
+ pass = false;
} else {
d_printf("LM (NTLMv2) Session Key does not match expectations!\n");
d_printf("lm_session_key:\n");
dump_data(1, lm_session_key, 8);
d_printf("expected:\n");
dump_data(1, ntlmv2_session_key.data, 8);
- pass = False;
+ pass = false;
}
}
}
@@ -727,23 +728,23 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
* Test the NTLM and LMv2 responses
*/
-static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
+static bool test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
enum ntlm_break break_which,
enum ntlmv2_domain ntlmv2_domain,
char **error_string)
{
- BOOL pass = True;
+ bool pass = true;
NTSTATUS nt_status;
DATA_BLOB ntlmv2_response = data_blob(NULL, 0);
DATA_BLOB lmv2_response = data_blob(NULL, 0);
DATA_BLOB lmv2_session_key = data_blob(NULL, 0);
DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0);
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, lp_netbios_name(), lp_workgroup());
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, lp_netbios_name(global_loadparm), lp_workgroup(global_loadparm));
DATA_BLOB ntlm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24);
DATA_BLOB ntlm_session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16);
- BOOL lm_good;
+ bool lm_good;
uint8_t lm_hash[16];
uint8_t lm_session_key[8];
uint8_t user_session_key[16];
@@ -773,7 +774,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
&lmv2_response, &ntlmv2_response,
&lmv2_session_key, &ntlmv2_session_key)) {
data_blob_free(&names_blob);
- return False;
+ return false;
}
break;
case NO_DOMAIN:
@@ -785,7 +786,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
&lmv2_response, &ntlmv2_response,
&lmv2_session_key, &ntlmv2_session_key)) {
data_blob_free(&names_blob);
- return False;
+ return false;
}
break;
}
@@ -809,7 +810,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) {
/* for 'old' passwords, we allow the server to be OK or wrong password */
if (samlogon_state->old_password) {
- return True;
+ return true;
}
return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH));
} else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) {
@@ -817,11 +818,11 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
SAFE_FREE(*error_string);
asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
- return False;
+ return false;
} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
- return True;
+ return true;
} else if (!NT_STATUS_IS_OK(nt_status)) {
- return False;
+ return false;
}
switch (break_which) {
@@ -833,7 +834,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
dump_data(1, user_session_key, 16);
d_printf("expected:\n");
dump_data(1, lmv2_session_key.data, ntlmv2_session_key.length);
- pass = False;
+ pass = false;
}
if (memcmp(lmv2_session_key.data, lm_session_key,
sizeof(lm_session_key)) != 0) {
@@ -842,7 +843,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
dump_data(1, lm_session_key, 8);
d_printf("expected:\n");
dump_data(1, lmv2_session_key.data, 8);
- pass = False;
+ pass = false;
}
break;
case BREAK_LM:
@@ -853,7 +854,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
dump_data(1, user_session_key, 16);
d_printf("expected:\n");
dump_data(1, ntlm_session_key.data, ntlm_session_key.length);
- pass = False;
+ pass = false;
}
if (lm_good) {
if (memcmp(lm_hash, lm_session_key,
@@ -863,7 +864,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
dump_data(1, lm_session_key, 8);
d_printf("expected:\n");
dump_data(1, lm_hash, 8);
- pass = False;
+ pass = false;
}
} else {
static const uint8_t zeros[8];
@@ -874,7 +875,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
dump_data(1, lm_session_key, 8);
d_printf("expected:\n");
dump_data(1, zeros, 8);
- pass = False;
+ pass = false;
}
}
break;
@@ -886,7 +887,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
dump_data(1, user_session_key, 16);
d_printf("expected:\n");
dump_data(1, ntlm_session_key.data, ntlm_session_key.length);
- pass = False;
+ pass = false;
}
if (memcmp(ntlm_session_key.data, lm_session_key,
sizeof(lm_session_key)) != 0) {
@@ -895,7 +896,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
dump_data(1, lm_session_key, 8);
d_printf("expected:\n");
dump_data(1, ntlm_session_key.data, 8);
- pass = False;
+ pass = false;
}
}
@@ -906,13 +907,13 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
* Test the NTLMv2 and LMv2 responses
*/
-static BOOL test_lmv2_ntlmv2(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2_ntlmv2(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_NONE, UPPER_DOMAIN, error_string);
}
#if 0
-static BOOL test_lmv2_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_NONE, NO_DOMAIN, error_string);
}
@@ -922,12 +923,12 @@ static BOOL test_lmv2_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char
* Test the LMv2 response only
*/
-static BOOL test_lmv2(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, NO_NT, UPPER_DOMAIN, error_string);
}
-static BOOL test_lmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, NO_NT, NO_DOMAIN, error_string);
}
@@ -936,93 +937,93 @@ static BOOL test_lmv2_no_dom(struct samlogon_state *samlogon_state, char **error
* Test the NTLMv2 response only
*/
-static BOOL test_ntlmv2(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlmv2(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, NO_LM, UPPER_DOMAIN, error_string);
}
-static BOOL test_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, NO_LM, NO_DOMAIN, error_string);
}
-static BOOL test_lm_ntlm(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lm_ntlm(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lm_ntlm_broken(samlogon_state, BREAK_NONE, error_string);
}
-static BOOL test_ntlm_lm_broken(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlm_lm_broken(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lm_ntlm_broken(samlogon_state, BREAK_LM, error_string);
}
-static BOOL test_ntlm_ntlm_broken(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlm_ntlm_broken(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lm_ntlm_broken(samlogon_state, BREAK_NT, error_string);
}
-static BOOL test_lm_ntlm_both_broken(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lm_ntlm_both_broken(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lm_ntlm_broken(samlogon_state, BREAK_BOTH, error_string);
}
-static BOOL test_ntlmv2_lmv2_broken(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlmv2_lmv2_broken(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_LM, UPPER_DOMAIN, error_string);
}
-static BOOL test_ntlmv2_lmv2_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlmv2_lmv2_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_LM, NO_DOMAIN, error_string);
}
-static BOOL test_ntlmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_NT, UPPER_DOMAIN, error_string);
}
#if 0
-static BOOL test_ntlmv2_ntlmv2_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlmv2_ntlmv2_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_NT, NO_DOMAIN, error_string);
}
#endif
-static BOOL test_ntlmv2_both_broken(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlmv2_both_broken(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_BOTH, UPPER_DOMAIN, error_string);
}
-static BOOL test_ntlmv2_both_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlmv2_both_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_BOTH, NO_DOMAIN, error_string);
}
-static BOOL test_lmv2_ntlm_both_broken(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2_ntlm_both_broken(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlm_broken(samlogon_state, BREAK_BOTH, UPPER_DOMAIN, error_string);
}
-static BOOL test_lmv2_ntlm_both_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2_ntlm_both_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlm_broken(samlogon_state, BREAK_BOTH, NO_DOMAIN, error_string);
}
-static BOOL test_lmv2_ntlm_break_ntlm(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2_ntlm_break_ntlm(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlm_broken(samlogon_state, BREAK_NT, UPPER_DOMAIN, error_string);
}
-static BOOL test_lmv2_ntlm_break_ntlm_no_dom(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2_ntlm_break_ntlm_no_dom(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlm_broken(samlogon_state, BREAK_NT, NO_DOMAIN, error_string);
}
-static BOOL test_lmv2_ntlm_break_lm(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2_ntlm_break_lm(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlm_broken(samlogon_state, BREAK_LM, UPPER_DOMAIN, error_string);
}
-static BOOL test_lmv2_ntlm_break_lm_no_dom(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_lmv2_ntlm_break_lm_no_dom(struct samlogon_state *samlogon_state, char **error_string)
{
return test_lmv2_ntlm_broken(samlogon_state, BREAK_LM, NO_DOMAIN, error_string);
}
@@ -1035,14 +1036,14 @@ static BOOL test_lmv2_ntlm_break_lm_no_dom(struct samlogon_state *samlogon_state
* (NETLOGON is the wrong place).
*/
-static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_string)
+static bool test_ntlm2(struct samlogon_state *samlogon_state, char **error_string)
{
- BOOL pass = True;
+ bool pass = true;
NTSTATUS nt_status;
DATA_BLOB lm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24);
DATA_BLOB nt_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24);
- BOOL lm_good;
+ bool lm_good;
uint8_t lm_key[8];
uint8_t nt_hash[16];
uint8_t lm_hash[16];
@@ -1092,17 +1093,17 @@ static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin
if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) {
/* for 'old' passwords, we allow the server to be OK or wrong password */
if (samlogon_state->old_password) {
- return True;
+ return true;
}
- return False;
+ return false;
} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
SAFE_FREE(*error_string);
asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
- return False;
+ return false;
} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
- return True;
+ return true;
} else if (!NT_STATUS_IS_OK(nt_status)) {
- return False;
+ return false;
}
if (lm_good) {
@@ -1113,7 +1114,7 @@ static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin
dump_data(1, lm_key, 8);
d_printf("expected:\n");
dump_data(1, lm_hash, 8);
- pass = False;
+ pass = false;
}
} else {
static const uint8_t zeros[8];
@@ -1124,7 +1125,7 @@ static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin
dump_data(1, lm_key, 8);
d_printf("expected:\n");
dump_data(1, zeros, 8);
- pass = False;
+ pass = false;
}
}
if (memcmp(nt_key, user_session_key, 16) != 0) {
@@ -1133,12 +1134,12 @@ static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin
dump_data(1, user_session_key, sizeof(user_session_key));
d_printf("expected:\n");
dump_data(1, nt_key, sizeof(nt_key));
- pass = False;
+ pass = false;
}
return pass;
}
-static BOOL test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_break break_which, char **error_string)
+static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_break break_which, char **error_string)
{
NTSTATUS nt_status;
DATA_BLOB nt_response = data_blob(NULL, 0);
@@ -1152,7 +1153,7 @@ static BOOL test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
uint8_t lm_hash[16];
static const uint8_t zeros[8];
DATA_BLOB chall = data_blob_talloc(samlogon_state->mem_ctx, zeros, sizeof(zeros));
- BOOL lm_good = E_deshash(samlogon_state->password, lm_hash);
+ bool lm_good = E_deshash(samlogon_state->password, lm_hash);
ZERO_STRUCT(user_session_key);
@@ -1189,11 +1190,11 @@ static BOOL test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) {
/* for 'old' passwords, we allow the server to be OK or wrong password */
if (samlogon_state->old_password) {
- return True;
+ return true;
}
/* for 'long' passwords, the LM password is invalid */
if (break_which == NO_NT && !lm_good) {
- return True;
+ return true;
}
return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH));
} else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) {
@@ -1201,42 +1202,42 @@ static BOOL test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
SAFE_FREE(*error_string);
asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
- return False;
+ return false;
} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
- return True;
+ return true;
} else if (!NT_STATUS_IS_OK(nt_status)) {
- return False;
+ return false;
}
if (break_which == NO_NT && !lm_good) {
*error_string = strdup("LM password is 'long' (> 14 chars and therefore invalid) but login did not fail!");
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_plaintext_none_broken(struct samlogon_state *samlogon_state,
+static bool test_plaintext_none_broken(struct samlogon_state *samlogon_state,
char **error_string) {
return test_plaintext(samlogon_state, BREAK_NONE, error_string);
}
-static BOOL test_plaintext_lm_broken(struct samlogon_state *samlogon_state,
+static bool test_plaintext_lm_broken(struct samlogon_state *samlogon_state,
char **error_string) {
return test_plaintext(samlogon_state, BREAK_LM, error_string);
}
-static BOOL test_plaintext_nt_broken(struct samlogon_state *samlogon_state,
+static bool test_plaintext_nt_broken(struct samlogon_state *samlogon_state,
char **error_string) {
return test_plaintext(samlogon_state, BREAK_NT, error_string);
}
-static BOOL test_plaintext_nt_only(struct samlogon_state *samlogon_state,
+static bool test_plaintext_nt_only(struct samlogon_state *samlogon_state,
char **error_string) {
return test_plaintext(samlogon_state, NO_LM, error_string);
}
-static BOOL test_plaintext_lm_only(struct samlogon_state *samlogon_state,
+static bool test_plaintext_lm_only(struct samlogon_state *samlogon_state,
char **error_string) {
return test_plaintext(samlogon_state, NO_NT, error_string);
}
@@ -1260,63 +1261,63 @@ static BOOL test_plaintext_lm_only(struct samlogon_state *samlogon_state,
*/
static const struct ntlm_tests {
- BOOL (*fn)(struct samlogon_state *, char **);
+ bool (*fn)(struct samlogon_state *, char **);
const char *name;
- BOOL expect_fail;
+ bool expect_fail;
} test_table[] = {
- {test_lmv2_ntlmv2, "NTLMv2 and LMv2", False},
+ {test_lmv2_ntlmv2, "NTLMv2 and LMv2", false},
#if 0
- {test_lmv2_ntlmv2_no_dom, "NTLMv2 and LMv2 (no domain)", False},
+ {test_lmv2_ntlmv2_no_dom, "NTLMv2 and LMv2 (no domain)", false},
#endif
- {test_lm, "LM", False},
- {test_lm_ntlm, "LM and NTLM", False},
- {test_lm_ntlm_both_broken, "LM and NTLM, both broken", False},
- {test_ntlm, "NTLM", False},
- {test_ntlm_in_lm, "NTLM in LM", False},
- {test_ntlm_in_both, "NTLM in both", False},
- {test_ntlmv2, "NTLMv2", False},
- {test_ntlmv2_no_dom, "NTLMv2 (no domain)", False},
- {test_lmv2, "LMv2", False},
- {test_lmv2_no_dom, "LMv2 (no domain)", False},
- {test_ntlmv2_lmv2_broken, "NTLMv2 and LMv2, LMv2 broken", False},
- {test_ntlmv2_lmv2_broken_no_dom, "NTLMv2 and LMv2, LMv2 broken (no domain)", False},
- {test_ntlmv2_ntlmv2_broken, "NTLMv2 and LMv2, NTLMv2 broken", False},
+ {test_lm, "LM", false},
+ {test_lm_ntlm, "LM and NTLM", false},
+ {test_lm_ntlm_both_broken, "LM and NTLM, both broken", false},
+ {test_ntlm, "NTLM", false},
+ {test_ntlm_in_lm, "NTLM in LM", false},
+ {test_ntlm_in_both, "NTLM in both", false},
+ {test_ntlmv2, "NTLMv2", false},
+ {test_ntlmv2_no_dom, "NTLMv2 (no domain)", false},
+ {test_lmv2, "LMv2", false},
+ {test_lmv2_no_dom, "LMv2 (no domain)", false},
+ {test_ntlmv2_lmv2_broken, "NTLMv2 and LMv2, LMv2 broken", false},
+ {test_ntlmv2_lmv2_broken_no_dom, "NTLMv2 and LMv2, LMv2 broken (no domain)", false},
+ {test_ntlmv2_ntlmv2_broken, "NTLMv2 and LMv2, NTLMv2 broken", false},
#if 0
- {test_ntlmv2_ntlmv2_broken_no_dom, "NTLMv2 and LMv2, NTLMv2 broken (no domain)", False},
+ {test_ntlmv2_ntlmv2_broken_no_dom, "NTLMv2 and LMv2, NTLMv2 broken (no domain)", false},
#endif
- {test_ntlmv2_both_broken, "NTLMv2 and LMv2, both broken", False},
- {test_ntlmv2_both_broken_no_dom, "NTLMv2 and LMv2, both broken (no domain)", False},
- {test_ntlm_lm_broken, "NTLM and LM, LM broken", False},
- {test_ntlm_ntlm_broken, "NTLM and LM, NTLM broken", False},
- {test_ntlm2, "NTLM2 (NTLMv2 session security)", False},
- {test_lmv2_ntlm_both_broken, "LMv2 and NTLM, both broken", False},
- {test_lmv2_ntlm_both_broken_no_dom, "LMv2 and NTLM, both broken (no domain)", False},
- {test_lmv2_ntlm_break_ntlm, "LMv2 and NTLM, NTLM broken", False},
- {test_lmv2_ntlm_break_ntlm_no_dom, "LMv2 and NTLM, NTLM broken (no domain)", False},
- {test_lmv2_ntlm_break_lm, "LMv2 and NTLM, LMv2 broken", False},
- {test_lmv2_ntlm_break_lm_no_dom, "LMv2 and NTLM, LMv2 broken (no domain)", False},
- {test_plaintext_none_broken, "Plaintext", False},
- {test_plaintext_lm_broken, "Plaintext LM broken", False},
- {test_plaintext_nt_broken, "Plaintext NT broken", False},
- {test_plaintext_nt_only, "Plaintext NT only", False},
- {test_plaintext_lm_only, "Plaintext LM only", False},
+ {test_ntlmv2_both_broken, "NTLMv2 and LMv2, both broken", false},
+ {test_ntlmv2_both_broken_no_dom, "NTLMv2 and LMv2, both broken (no domain)", false},
+ {test_ntlm_lm_broken, "NTLM and LM, LM broken", false},
+ {test_ntlm_ntlm_broken, "NTLM and LM, NTLM broken", false},
+ {test_ntlm2, "NTLM2 (NTLMv2 session security)", false},
+ {test_lmv2_ntlm_both_broken, "LMv2 and NTLM, both broken", false},
+ {test_lmv2_ntlm_both_broken_no_dom, "LMv2 and NTLM, both broken (no domain)", false},
+ {test_lmv2_ntlm_break_ntlm, "LMv2 and NTLM, NTLM broken", false},
+ {test_lmv2_ntlm_break_ntlm_no_dom, "LMv2 and NTLM, NTLM broken (no domain)", false},
+ {test_lmv2_ntlm_break_lm, "LMv2 and NTLM, LMv2 broken", false},
+ {test_lmv2_ntlm_break_lm_no_dom, "LMv2 and NTLM, LMv2 broken (no domain)", false},
+ {test_plaintext_none_broken, "Plaintext", false},
+ {test_plaintext_lm_broken, "Plaintext LM broken", false},
+ {test_plaintext_nt_broken, "Plaintext NT broken", false},
+ {test_plaintext_nt_only, "Plaintext NT only", false},
+ {test_plaintext_lm_only, "Plaintext LM only", false},
{NULL, NULL}
};
/*
try a netlogon SamLogon
*/
-static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct creds_CredentialState *creds,
const char *comment,
const char *account_domain, const char *account_name,
const char *plain_pass, uint32_t parameter_control,
- NTSTATUS expected_error, BOOL old_password,
+ NTSTATUS expected_error, bool old_password,
int n_subtests)
{
TALLOC_CTX *fn_ctx = talloc_named(mem_ctx, 0, "test_SamLogon function-level context");
int i, v, l, f;
- BOOL ret = True;
+ bool ret = true;
int validation_levels[] = {2,3,6};
int logon_levels[] = { 2, 6 };
int function_levels[] = {
@@ -1383,7 +1384,7 @@ static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
d_printf(" failed (expected, test incomplete): %s\n", error_string);
} else {
d_printf(" failed: %s\n", error_string);
- ret = False;
+ ret = false;
}
SAFE_FREE(error_string);
}
@@ -1399,7 +1400,7 @@ static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
/*
test an ADS style interactive domain logon
*/
-BOOL test_InteractiveLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_InteractiveLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct creds_CredentialState *creds,
const char *comment,
const char *workstation_name,
@@ -1455,7 +1456,7 @@ BOOL test_InteractiveLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|| !creds_client_check(creds, &r.out.return_authenticator->cred)) {
d_printf("Credential chaining failed\n");
talloc_free(fn_ctx);
- return False;
+ return false;
}
talloc_free(fn_ctx);
@@ -1463,22 +1464,22 @@ BOOL test_InteractiveLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(expected_error, status)) {
d_printf("[%s]\\[%s] netr_LogonSamLogonWithFlags - expected %s got %s\n",
account_domain, account_name, nt_errstr(expected_error), nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_rpc_samlogon(struct torture_context *torture)
+bool torture_rpc_samlogon(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
struct dcerpc_binding *b;
struct cli_credentials *machine_credentials;
TALLOC_CTX *mem_ctx = talloc_init("torture_rpc_netlogon");
- BOOL ret = True;
+ bool ret = true;
struct test_join *join_ctx = NULL;
struct test_join *user_ctx = NULL, *user_ctx_wrong_wks = NULL, *user_ctx_wrong_time = NULL;
char *user_password, *user_password_wrong_wks, *user_password_wrong_time;
@@ -1508,10 +1509,10 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
&machine_credentials);
if (!join_ctx) {
d_printf("Failed to join as Workstation\n");
- return False;
+ return false;
}
- userdomain = torture_setting_string(torture, "userdomain", lp_workgroup());
+ userdomain = torture_setting_string(torture, "userdomain", lp_workgroup(global_loadparm));
user_ctx = torture_create_testuser(torture,
TEST_USER_NAME,
@@ -1520,14 +1521,14 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
(const char **)&user_password);
if (!user_ctx) {
d_printf("Failed to create a test user\n");
- return False;
+ return false;
}
old_user_password = user_password;
test_ChangePasswordUser3(torture_join_samr_pipe(user_ctx), mem_ctx,
TEST_USER_NAME, 16 /* > 14 */, &user_password,
- NULL, 0, False);
+ NULL, 0, false);
user_ctx_wrong_wks = torture_create_testuser(torture,
TEST_USER_NAME_WRONG_WKS,
@@ -1536,7 +1537,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
(const char **)&user_password_wrong_wks);
if (!user_ctx_wrong_wks) {
d_printf("Failed to create a test user (wrong workstation test)\n");
- return False;
+ return false;
}
ZERO_STRUCT(u);
@@ -1550,7 +1551,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
status = dcerpc_samr_SetUserInfo(torture_join_samr_pipe(user_ctx_wrong_wks), mem_ctx, &s);
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo (list of workstations) failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto failed;
}
@@ -1561,7 +1562,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
(const char **)&user_password_wrong_time);
if (!user_ctx_wrong_time) {
d_printf("Failed to create a test user (wrong workstation test)\n");
- return False;
+ return false;
}
ZERO_STRUCT(u);
@@ -1572,18 +1573,18 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
u.info21.fields_present = SAMR_FIELD_WORKSTATIONS | SAMR_FIELD_LOGON_HOURS;
u.info21.workstations.string = TEST_MACHINE_NAME;
u.info21.logon_hours.units_per_week = 168;
- u.info21.logon_hours.bits = talloc_zero_size(mem_ctx, 168);
+ u.info21.logon_hours.bits = talloc_zero_array(mem_ctx, uint8_t, 168);
status = dcerpc_samr_SetUserInfo(torture_join_samr_pipe(user_ctx_wrong_time), mem_ctx, &s);
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo (logon times and list of workstations) failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto failed;
}
status = torture_rpc_binding(torture, &b);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto failed;
}
@@ -1599,13 +1600,13 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
d_printf("RPC pipe connect as domain member failed: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto failed;
}
status = dcerpc_schannel_creds(p->conn->security_state.generic_state, mem_ctx, &creds);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto failed;
}
@@ -1616,18 +1617,18 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
const char *domain;
const char *username;
const char *password;
- BOOL network_login;
+ bool network_login;
NTSTATUS expected_interactive_error;
NTSTATUS expected_network_error;
uint32_t parameter_control;
- BOOL old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */
+ bool old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */
} usercreds[] = {
{
.comment = "domain\\user",
.domain = cli_credentials_get_domain(cmdline_credentials),
.username = cli_credentials_get_username(cmdline_credentials),
.password = cli_credentials_get_password(cmdline_credentials),
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_OK,
.expected_network_error = NT_STATUS_OK
},
@@ -1636,7 +1637,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
.domain = cli_credentials_get_realm(cmdline_credentials),
.username = cli_credentials_get_username(cmdline_credentials),
.password = cli_credentials_get_password(cmdline_credentials),
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_OK,
.expected_network_error = NT_STATUS_OK
},
@@ -1649,7 +1650,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
cli_credentials_get_domain(cmdline_credentials)
),
.password = cli_credentials_get_password(cmdline_credentials),
- .network_login = False, /* works for some things, but not NTLMv2. Odd */
+ .network_login = false, /* works for some things, but not NTLMv2. Odd */
.expected_interactive_error = NT_STATUS_OK,
.expected_network_error = NT_STATUS_OK
},
@@ -1662,7 +1663,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
cli_credentials_get_realm(cmdline_credentials)
),
.password = cli_credentials_get_password(cmdline_credentials),
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_OK,
.expected_network_error = NT_STATUS_OK
},
@@ -1671,7 +1672,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
.domain = cli_credentials_get_domain(machine_credentials),
.username = cli_credentials_get_username(machine_credentials),
.password = cli_credentials_get_password(machine_credentials),
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_NO_SUCH_USER,
.parameter_control = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT
},
@@ -1680,7 +1681,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
.domain = cli_credentials_get_domain(machine_credentials),
.username = cli_credentials_get_username(machine_credentials),
.password = cli_credentials_get_password(machine_credentials),
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_NO_SUCH_USER,
.expected_network_error = NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT
},
@@ -1689,7 +1690,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
.domain = cli_credentials_get_realm(machine_credentials),
.username = cli_credentials_get_username(machine_credentials),
.password = cli_credentials_get_password(machine_credentials),
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_NO_SUCH_USER,
.parameter_control = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT
},
@@ -1702,7 +1703,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
cli_credentials_get_domain(machine_credentials)
),
.password = cli_credentials_get_password(machine_credentials),
- .network_login = False, /* works for some things, but not NTLMv2. Odd */
+ .network_login = false, /* works for some things, but not NTLMv2. Odd */
.expected_interactive_error = NT_STATUS_NO_SUCH_USER,
.parameter_control = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT
},
@@ -1715,7 +1716,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
cli_credentials_get_realm(machine_credentials)
),
.password = cli_credentials_get_password(machine_credentials),
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_NO_SUCH_USER,
.parameter_control = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT
},
@@ -1724,7 +1725,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
.domain = userdomain,
.username = TEST_USER_NAME,
.password = user_password,
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_OK,
.expected_network_error = NT_STATUS_OK
},
@@ -1734,9 +1735,9 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
.username = talloc_asprintf(mem_ctx,
"%s@%s",
TEST_USER_NAME,
- lp_realm()),
+ lp_realm(global_loadparm)),
.password = user_password,
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_OK,
.expected_network_error = NT_STATUS_OK
},
@@ -1748,7 +1749,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
TEST_USER_NAME,
userdomain),
.password = user_password,
- .network_login = False, /* works for some things, but not NTLMv2. Odd */
+ .network_login = false, /* works for some things, but not NTLMv2. Odd */
.expected_interactive_error = NT_STATUS_OK,
.expected_network_error = NT_STATUS_OK
},
@@ -1758,17 +1759,17 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
.domain = userdomain,
.username = TEST_USER_NAME,
.password = old_user_password,
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_WRONG_PASSWORD,
.expected_network_error = NT_STATUS_OK,
- .old_password = True
+ .old_password = true
},
{
.comment = "test user (wong workstation): domain\\user",
.domain = userdomain,
.username = TEST_USER_NAME_WRONG_WKS,
.password = user_password_wrong_wks,
- .network_login = True,
+ .network_login = true,
.expected_interactive_error = NT_STATUS_INVALID_WORKSTATION,
.expected_network_error = NT_STATUS_INVALID_WORKSTATION
}
@@ -1785,7 +1786,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
usercreds[ci].password,
usercreds[ci].parameter_control,
usercreds[ci].expected_interactive_error)) {
- ret = False;
+ ret = false;
}
if (usercreds[ci].network_login) {
@@ -1798,7 +1799,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
usercreds[ci].expected_network_error,
usercreds[ci].old_password,
0)) {
- ret = False;
+ ret = false;
}
}
}
@@ -1818,7 +1819,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
usercreds[0].password,
usercreds[0].parameter_control,
usercreds[0].expected_interactive_error)) {
- ret = False;
+ ret = false;
}
if (usercreds[0].network_login) {
@@ -1831,7 +1832,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
usercreds[0].expected_network_error,
usercreds[0].old_password,
1)) {
- ret = False;
+ ret = false;
}
}
}
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
index 8d3164967a..ec70c91570 100644
--- a/source4/torture/rpc/samr.c
+++ b/source4/torture/rpc/samr.c
@@ -28,6 +28,7 @@
#include "libcli/auth/libcli_auth.h"
#include "libcli/security/security.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
#define TEST_ACCOUNT_NAME "samrtorturetest"
#define TEST_ALIASNAME "samrtorturetestalias"
@@ -41,16 +42,16 @@ enum torture_samr_choice {
TORTURE_SAMR_OTHER
};
-static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle);
-static BOOL test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle);
-static BOOL test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle);
-static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char *acct_name,
struct policy_handle *domain_handle, char **password);
@@ -59,7 +60,7 @@ static void init_lsa_String(struct lsa_String *string, const char *s)
string->string = s;
}
-BOOL test_samr_handle_Close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_samr_handle_Close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -71,21 +72,21 @@ BOOL test_samr_handle_Close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Close(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Close handle failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_Shutdown(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_Shutdown(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_Shutdown r;
- if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
+ if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) {
printf("samr_Shutdown disabled - enable dangerous tests to use\n");
- return True;
+ return true;
}
r.in.connect_handle = handle;
@@ -95,13 +96,13 @@ static BOOL test_Shutdown(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Shutdown(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("samr_Shutdown failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_SetDsrmPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetDsrmPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -109,9 +110,9 @@ static BOOL test_SetDsrmPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct lsa_String string;
struct samr_Password hash;
- if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
+ if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) {
printf("samr_SetDsrmPassword disabled - enable dangerous tests to use\n");
- return True;
+ return true;
}
E_md4hash("TeSTDSRM123", hash.hash);
@@ -127,14 +128,14 @@ static BOOL test_SetDsrmPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_SetDsrmPassword(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
printf("samr_SetDsrmPassword failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -147,39 +148,39 @@ static BOOL test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_QuerySecurity(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("QuerySecurity failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (r.out.sdbuf == NULL) {
- return False;
+ return false;
}
s.in.handle = handle;
s.in.sec_info = 7;
s.in.sdbuf = r.out.sdbuf;
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping SetSecurity test against Samba4\n");
- return True;
+ return true;
}
status = dcerpc_samr_SetSecurity(p, mem_ctx, &s);
if (!NT_STATUS_IS_OK(status)) {
printf("SetSecurity failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_samr_QuerySecurity(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("QuerySecurity failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, uint32_t base_acct_flags,
const char *base_account_name)
{
@@ -189,7 +190,7 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_QueryUserInfo q;
struct samr_QueryUserInfo q0;
union samr_UserInfo u;
- BOOL ret = True;
+ bool ret = true;
const char *test_account_name;
uint32_t user_extra_flags = 0;
@@ -213,7 +214,7 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) { \
printf(#call " level %u failed - %s (%s)\n", \
r.in.level, nt_errstr(status), __location__); \
- ret = False; \
+ ret = false; \
break; \
}
@@ -221,15 +222,15 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if ((s1 && !s2) || (s2 && !s1) || strcmp(s1, s2)) { \
printf("Failed to set %s to '%s' (%s)\n", \
#field, s2, __location__); \
- ret = False; \
+ ret = false; \
break; \
}
#define INT_EQUAL(i1, i2, field) \
if (i1 != i2) { \
- printf("Failed to set %s to 0x%x - got 0x%x (%s)\n", \
- #field, i2, i1, __location__); \
- ret = False; \
+ printf("Failed to set %s to 0x%llx - got 0x%llx (%s)\n", \
+ #field, (unsigned long long)i2, (unsigned long long)i1, __location__); \
+ ret = false; \
break; \
}
@@ -373,23 +374,40 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
TEST_USERINFO_STRING(14, workstations, 21, workstations, "14workstation21", 0);
TEST_USERINFO_STRING(21, workstations, 21, workstations, "21workstation21",
SAMR_FIELD_WORKSTATIONS);
+ TEST_USERINFO_STRING(21, workstations, 3, workstations, "21workstation3",
+ SAMR_FIELD_WORKSTATIONS);
+ TEST_USERINFO_STRING(21, workstations, 5, workstations, "21workstation5",
+ SAMR_FIELD_WORKSTATIONS);
+ TEST_USERINFO_STRING(21, workstations, 14, workstations, "21workstation14",
+ SAMR_FIELD_WORKSTATIONS);
TEST_USERINFO_STRING(20, parameters, 21, parameters, "xx20-21 parameters", 0);
TEST_USERINFO_STRING(21, parameters, 21, parameters, "xx21-21 parameters",
SAMR_FIELD_PARAMETERS);
+ TEST_USERINFO_STRING(21, parameters, 20, parameters, "xx21-20 parameters",
+ SAMR_FIELD_PARAMETERS);
+ TEST_USERINFO_INT(2, country_code, 2, country_code, __LINE__, 0);
TEST_USERINFO_INT(2, country_code, 21, country_code, __LINE__, 0);
TEST_USERINFO_INT(21, country_code, 21, country_code, __LINE__,
SAMR_FIELD_COUNTRY_CODE);
+ TEST_USERINFO_INT(21, country_code, 2, country_code, __LINE__,
+ SAMR_FIELD_COUNTRY_CODE);
TEST_USERINFO_INT(2, code_page, 21, code_page, __LINE__, 0);
TEST_USERINFO_INT(21, code_page, 21, code_page, __LINE__,
SAMR_FIELD_CODE_PAGE);
+ TEST_USERINFO_INT(21, code_page, 2, code_page, __LINE__,
+ SAMR_FIELD_CODE_PAGE);
TEST_USERINFO_INT(17, acct_expiry, 21, acct_expiry, __LINE__, 0);
TEST_USERINFO_INT(17, acct_expiry, 5, acct_expiry, __LINE__, 0);
TEST_USERINFO_INT(21, acct_expiry, 21, acct_expiry, __LINE__,
SAMR_FIELD_ACCT_EXPIRY);
+ TEST_USERINFO_INT(21, acct_expiry, 5, acct_expiry, __LINE__,
+ SAMR_FIELD_ACCT_EXPIRY);
+ TEST_USERINFO_INT(21, acct_expiry, 17, acct_expiry, __LINE__,
+ SAMR_FIELD_ACCT_EXPIRY);
TEST_USERINFO_INT(4, logon_hours.bits[3], 3, logon_hours.bits[3], 1, 0);
TEST_USERINFO_INT(4, logon_hours.bits[3], 5, logon_hours.bits[3], 2, 0);
@@ -397,7 +415,7 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
TEST_USERINFO_INT(21, logon_hours.bits[3], 21, logon_hours.bits[3], 4,
SAMR_FIELD_LOGON_HOURS);
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping Set Account Flag tests against Samba4\n");
return ret;
}
@@ -493,13 +511,13 @@ static char *samr_rand_pass_fixed_len(TALLOC_CTX *mem_ctx, int len)
return s;
}
-static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, char **password)
{
NTSTATUS status;
struct samr_SetUserInfo s;
union samr_UserInfo u;
- BOOL ret = True;
+ bool ret = true;
DATA_BLOB session_key;
char *newpass;
struct samr_GetUserPwInfo pwp;
@@ -524,7 +542,7 @@ static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo level %u - no session key - %s\n",
s.in.level, nt_errstr(status));
- return False;
+ return false;
}
arcfour_crypt_blob(u.info24.password.data, 516, &session_key);
@@ -535,7 +553,7 @@ static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo level %u failed - %s\n",
s.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
} else {
*password = newpass;
}
@@ -544,14 +562,14 @@ static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, uint32_t fields_present,
char **password)
{
NTSTATUS status;
struct samr_SetUserInfo s;
union samr_UserInfo u;
- BOOL ret = True;
+ bool ret = true;
DATA_BLOB session_key;
char *newpass;
struct samr_GetUserPwInfo pwp;
@@ -578,7 +596,7 @@ static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo level %u - no session key - %s\n",
s.in.level, nt_errstr(status));
- return False;
+ return false;
}
arcfour_crypt_blob(u.info23.password.data, 516, &session_key);
@@ -589,7 +607,7 @@ static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo level %u failed - %s\n",
s.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
} else {
*password = newpass;
}
@@ -600,7 +618,7 @@ static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo level %u - no session key - %s\n",
s.in.level, nt_errstr(status));
- return False;
+ return false;
}
/* This should break the key nicely */
@@ -613,21 +631,21 @@ static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("SetUserInfo level %u should have failed with WRONG_PASSWORD- %s\n",
s.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, bool makeshort,
char **password)
{
NTSTATUS status;
struct samr_SetUserInfo s;
union samr_UserInfo u;
- BOOL ret = True;
+ bool ret = true;
DATA_BLOB session_key;
DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16);
uint8_t confounder[16];
@@ -658,7 +676,7 @@ static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo level %u - no session key - %s\n",
s.in.level, nt_errstr(status));
- return False;
+ return false;
}
generate_random_buffer((uint8_t *)confounder, 16);
@@ -677,7 +695,7 @@ static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo level %u failed - %s\n",
s.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
} else {
*password = newpass;
}
@@ -694,7 +712,7 @@ static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("SetUserInfo level %u should have failed with WRONG_PASSWORD: %s\n",
s.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
} else {
*password = newpass;
}
@@ -702,14 +720,14 @@ static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, uint32_t fields_present,
char **password)
{
NTSTATUS status;
struct samr_SetUserInfo s;
union samr_UserInfo u;
- BOOL ret = True;
+ bool ret = true;
DATA_BLOB session_key;
DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16);
struct MD5Context ctx;
@@ -739,7 +757,7 @@ static BOOL test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo level %u - no session key - %s\n",
s.in.level, nt_errstr(status));
- return False;
+ return false;
}
generate_random_buffer((uint8_t *)confounder, 16);
@@ -758,7 +776,7 @@ static BOOL test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo level %u failed - %s\n",
s.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
} else {
*password = newpass;
}
@@ -775,13 +793,13 @@ static BOOL test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("SetUserInfo level %u should have failed with WRONG_PASSWORD- %s\n",
s.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -789,7 +807,7 @@ static BOOL test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_QueryAliasInfo q;
uint16_t levels[] = {2, 3};
int i;
- BOOL ret = True;
+ bool ret = true;
/* Ignoring switch level 1, as that includes the number of members for the alias
* and setting this to a wrong value might have negative consequences
@@ -811,7 +829,7 @@ static BOOL test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetAliasInfo level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
q.in.alias_handle = handle;
@@ -821,19 +839,19 @@ static BOOL test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryAliasInfo level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_GetGroupsForUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetGroupsForUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *user_handle)
{
struct samr_GetGroupsForUser r;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("testing GetGroupsForUser\n");
@@ -842,19 +860,19 @@ static BOOL test_GetGroupsForUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_GetGroupsForUser(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetGroupsForUser failed - %s\n",nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct lsa_String *domain_name)
{
NTSTATUS status;
struct samr_GetDomPwInfo r;
- BOOL ret = True;
+ bool ret = true;
r.in.domain_name = domain_name;
printf("Testing GetDomPwInfo with name %s\n", r.in.domain_name->string);
@@ -862,7 +880,7 @@ static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetDomPwInfo failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
r.in.domain_name->string = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
@@ -871,7 +889,7 @@ static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetDomPwInfo failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
r.in.domain_name->string = "\\\\__NONAME__";
@@ -880,7 +898,7 @@ static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetDomPwInfo failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
r.in.domain_name->string = "\\\\Builtin";
@@ -889,19 +907,19 @@ static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetDomPwInfo failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_GetUserPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetUserPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_GetUserPwInfo r;
- BOOL ret = True;
+ bool ret = true;
printf("Testing GetUserPwInfo\n");
@@ -910,7 +928,7 @@ static BOOL test_GetUserPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_GetUserPwInfo(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetUserPwInfo failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
@@ -1006,12 +1024,12 @@ static NTSTATUS test_OpenUser_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
#if 0
-static BOOL test_ChangePasswordNT3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_ChangePasswordNT3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_ChangePasswordUser r;
- BOOL ret = True;
+ bool ret = true;
struct samr_Password hash1, hash2, hash3, hash4, hash5, hash6;
struct policy_handle user_handle;
char *oldpass = "test";
@@ -1021,7 +1039,7 @@ static BOOL test_ChangePasswordNT3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = test_OpenUser_byname(p, mem_ctx, handle, "testuser", &user_handle);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
printf("Testing ChangePasswordUser for user 'testuser'\n");
@@ -1056,30 +1074,30 @@ static BOOL test_ChangePasswordNT3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("ChangePasswordUser failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
return ret;
}
#endif
-static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char *acct_name,
struct policy_handle *handle, char **password)
{
NTSTATUS status;
struct samr_ChangePasswordUser r;
- BOOL ret = True;
+ bool ret = true;
struct samr_Password hash1, hash2, hash3, hash4, hash5, hash6;
struct policy_handle user_handle;
char *oldpass;
uint8_t old_nt_hash[16], new_nt_hash[16];
uint8_t old_lm_hash[16], new_lm_hash[16];
- BOOL changed = True;
+ bool changed = true;
char *newpass;
struct samr_GetUserPwInfo pwp;
@@ -1087,7 +1105,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = test_OpenUser_byname(p, mem_ctx, handle, acct_name, &user_handle);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
pwp.in.user_handle = &user_handle;
@@ -1101,7 +1119,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!*password) {
printf("Failing ChangePasswordUser as old password was NULL. Previous test failed?\n");
- return False;
+ return false;
}
oldpass = *password;
@@ -1135,7 +1153,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we broke the LM hash, got %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
/* Unbreak the LM hash */
@@ -1158,7 +1176,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we broke the NT hash, got %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
/* Unbreak the NT hash */
@@ -1181,7 +1199,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we broke the LM cross-hash, got %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
/* Unbreak the LM cross */
@@ -1204,7 +1222,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we broke the NT cross-hash, got %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
/* Unbreak the NT cross */
@@ -1233,11 +1251,11 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r);
if (NT_STATUS_IS_OK(status)) {
- changed = True;
+ changed = true;
*password = newpass;
} else if (!NT_STATUS_EQUAL(NT_STATUS_PASSWORD_RESTRICTION, status)) {
printf("ChangePasswordUser failed: expected NT_STATUS_OK, or at least NT_STATUS_PASSWORD_RESTRICTION, got %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
oldpass = newpass;
@@ -1271,11 +1289,11 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r);
if (NT_STATUS_IS_OK(status)) {
- changed = True;
+ changed = true;
*password = newpass;
} else if (!NT_STATUS_EQUAL(NT_STATUS_PASSWORD_RESTRICTION, status)) {
printf("ChangePasswordUser failed: expected NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED, got %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
oldpass = newpass;
@@ -1312,9 +1330,9 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("ChangePasswordUser returned: %s perhaps min password age? (not fatal)\n", nt_errstr(status));
} else if (!NT_STATUS_IS_OK(status)) {
printf("ChangePasswordUser failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
- changed = True;
+ changed = true;
*password = newpass;
}
@@ -1336,26 +1354,26 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("ChangePasswordUser returned: %s perhaps min password age? (not fatal)\n", nt_errstr(status));
} else if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we already changed the password, got %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
}
if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char *acct_name,
struct policy_handle *handle, char **password)
{
NTSTATUS status;
struct samr_OemChangePasswordUser2 r;
- BOOL ret = True;
+ bool ret = true;
struct samr_Password lm_verifier;
struct samr_CryptPassword lm_pass;
struct lsa_AsciiString server, account, account_bad;
@@ -1375,7 +1393,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
if (!*password) {
printf("Failing OemChangePasswordUser2 as old password was NULL. Previous test failed?\n");
- return False;
+ return false;
}
oldpass = *password;
@@ -1411,7 +1429,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
&& !NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD (or at least 'PASSWORD_RESTRICTON') for invalid password verifier - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
encode_pw_buffer(lm_pass.data, newpass, STR_ASCII);
@@ -1433,7 +1451,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
&& !NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD (or at least 'PASSWORD_RESTRICTON') for invalidly encrpted password - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
encode_pw_buffer(lm_pass.data, newpass, STR_ASCII);
@@ -1450,7 +1468,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
&& !NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
printf("ChangePasswordUser3 failed, should have returned INVALID_PARAMETER (or at least 'PASSWORD_RESTRICTON') for no supplied validation hash - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
/* This shouldn't be a valid name */
@@ -1462,7 +1480,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
printf("ChangePasswordUser3 failed, should have returned INVALID_PARAMETER for no supplied validation hash and invalid user - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
/* This shouldn't be a valid name */
@@ -1476,7 +1494,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD for invalid user - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
/* This shouldn't be a valid name */
@@ -1490,7 +1508,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
printf("ChangePasswordUser3 failed, should have returned INVALID_PARAMETER for no supplied password and invalid user - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
E_deshash(oldpass, old_lm_hash);
@@ -1510,7 +1528,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
printf("OemChangePasswordUser2 returned: %s perhaps min password age? (not fatal)\n", nt_errstr(status));
} else if (!NT_STATUS_IS_OK(status)) {
printf("OemChangePasswordUser2 failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
*password = newpass;
}
@@ -1519,14 +1537,14 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
}
-static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char *acct_name,
char **password,
char *newpass, bool allow_password_restriction)
{
NTSTATUS status;
struct samr_ChangePasswordUser2 r;
- BOOL ret = True;
+ bool ret = true;
struct lsa_String server, account;
struct samr_CryptPassword nt_pass, lm_pass;
struct samr_Password nt_verifier, lm_verifier;
@@ -1545,7 +1563,7 @@ static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!*password) {
printf("Failing ChangePasswordUser3 as old password was NULL. Previous test failed?\n");
- return False;
+ return false;
}
oldpass = *password;
@@ -1589,7 +1607,7 @@ static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("ChangePasswordUser2 returned: %s perhaps min password age? (not fatal)\n", nt_errstr(status));
} else if (!NT_STATUS_IS_OK(status)) {
printf("ChangePasswordUser2 failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
*password = newpass;
}
@@ -1598,17 +1616,17 @@ static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char *account_string,
int policy_min_pw_len,
char **password,
const char *newpass,
NTTIME last_password_change,
- BOOL handle_reject_reason)
+ bool handle_reject_reason)
{
NTSTATUS status;
struct samr_ChangePasswordUser3 r;
- BOOL ret = True;
+ bool ret = true;
struct lsa_String server, account, account_bad;
struct samr_CryptPassword nt_pass, lm_pass;
struct samr_Password nt_verifier, lm_verifier;
@@ -1626,14 +1644,14 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
} else {
newpass = samr_rand_pass_fixed_len(mem_ctx, policy_min_pw_len);
}
- } while (check_password_quality(newpass) == False);
+ } while (check_password_quality(newpass) == false);
} else {
printf("Using password '%s'\n", newpass);
}
if (!*password) {
printf("Failing ChangePasswordUser3 as old password was NULL. Previous test failed?\n");
- return False;
+ return false;
}
oldpass = *password;
@@ -1671,7 +1689,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
(!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD))) {
printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD (or at least 'PASSWORD_RESTRICTON') for invalid password verifier - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
encode_pw_buffer(lm_pass.data, newpass, STR_UNICODE);
@@ -1700,7 +1718,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
(!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD))) {
printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD (or at least 'PASSWORD_RESTRICTON') for invalidly encrpted password - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
/* This shouldn't be a valid name */
@@ -1711,7 +1729,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD for invalid username - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
E_md4hash(oldpass, old_nt_hash);
@@ -1751,7 +1769,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (r.out.reject && (r.out.reject->reason != SAMR_REJECT_OTHER)) {
printf("expected SAMR_REJECT_OTHER (%d), got %d\n",
SAMR_REJECT_OTHER, r.out.reject->reason);
- return False;
+ return false;
}
}
@@ -1770,7 +1788,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (r.out.reject->reason != SAMR_REJECT_OTHER) {
printf("expected SAMR_REJECT_OTHER (%d), got %d\n",
SAMR_REJECT_OTHER, r.out.reject->reason);
- return False;
+ return false;
}
} else if ((r.out.dominfo->min_password_length > 0) &&
@@ -1779,7 +1797,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (r.out.reject->reason != SAMR_REJECT_TOO_SHORT) {
printf("expected SAMR_REJECT_TOO_SHORT (%d), got %d\n",
SAMR_REJECT_TOO_SHORT, r.out.reject->reason);
- return False;
+ return false;
}
} else if ((r.out.dominfo->password_history_length > 0) &&
@@ -1788,14 +1806,14 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (r.out.reject->reason != SAMR_REJECT_IN_HISTORY) {
printf("expected SAMR_REJECT_IN_HISTORY (%d), got %d\n",
SAMR_REJECT_IN_HISTORY, r.out.reject->reason);
- return False;
+ return false;
}
} else if (r.out.dominfo->password_properties & DOMAIN_PASSWORD_COMPLEX) {
if (r.out.reject->reason != SAMR_REJECT_COMPLEXITY) {
printf("expected SAMR_REJECT_COMPLEXITY (%d), got %d\n",
SAMR_REJECT_COMPLEXITY, r.out.reject->reason);
- return False;
+ return false;
}
}
@@ -1804,7 +1822,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
/* retry with adjusted size */
return test_ChangePasswordUser3(p, mem_ctx, account_string,
r.out.dominfo->min_password_length,
- password, NULL, 0, False);
+ password, NULL, 0, false);
}
@@ -1812,13 +1830,13 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (r.out.reject && r.out.reject->reason != SAMR_REJECT_OTHER) {
printf("expected SAMR_REJECT_OTHER (%d), got %d\n",
SAMR_REJECT_OTHER, r.out.reject->reason);
- return False;
+ return false;
}
/* Perhaps the server has a 'min password age' set? */
} else if (!NT_STATUS_IS_OK(status)) {
printf("ChangePasswordUser3 failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
*password = talloc_strdup(mem_ctx, newpass);
}
@@ -1827,13 +1845,13 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-static BOOL test_GetMembersInAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetMembersInAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *alias_handle)
{
struct samr_GetMembersInAlias r;
struct lsa_SidArray sids;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("Testing GetMembersInAlias\n");
@@ -1844,20 +1862,20 @@ static BOOL test_GetMembersInAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("GetMembersInAlias failed - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *alias_handle,
const struct dom_sid *domain_sid)
{
struct samr_AddAliasMember r;
struct samr_DeleteAliasMember d;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct dom_sid *sid;
sid = dom_sid_add_rid(mem_ctx, domain_sid, 512);
@@ -1869,7 +1887,7 @@ static BOOL test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_AddAliasMember(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("AddAliasMember failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
d.in.alias_handle = alias_handle;
@@ -1878,19 +1896,19 @@ static BOOL test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_DeleteAliasMember(p, mem_ctx, &d);
if (!NT_STATUS_IS_OK(status)) {
printf("DelAliasMember failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *alias_handle)
{
struct samr_AddMultipleMembersToAlias a;
struct samr_RemoveMultipleMembersFromAlias r;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct lsa_SidArray sids;
printf("testing AddMultipleMembersToAlias\n");
@@ -1907,7 +1925,7 @@ static BOOL test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *me
status = dcerpc_samr_AddMultipleMembersToAlias(p, mem_ctx, &a);
if (!NT_STATUS_IS_OK(status)) {
printf("AddMultipleMembersToAlias failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
@@ -1918,14 +1936,14 @@ static BOOL test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *me
status = dcerpc_samr_RemoveMultipleMembersFromAlias(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("RemoveMultipleMembersFromAlias failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
/* strange! removing twice doesn't give any error */
status = dcerpc_samr_RemoveMultipleMembersFromAlias(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("RemoveMultipleMembersFromAlias failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
/* but removing an alias that isn't there does */
@@ -1934,18 +1952,18 @@ static BOOL test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *me
status = dcerpc_samr_RemoveMultipleMembersFromAlias(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
printf("RemoveMultipleMembersFromAlias failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_TestPrivateFunctionsUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_TestPrivateFunctionsUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *user_handle)
{
struct samr_TestPrivateFunctionsUser r;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("Testing TestPrivateFunctionsUser\n");
@@ -1954,14 +1972,14 @@ static BOOL test_TestPrivateFunctionsUser(struct dcerpc_pipe *p, TALLOC_CTX *mem
status = dcerpc_samr_TestPrivateFunctionsUser(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(NT_STATUS_NOT_IMPLEMENTED, status)) {
printf("TestPrivateFunctionsUser failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *user_handle,
struct policy_handle *domain_handle,
uint32_t base_acct_flags,
@@ -1970,7 +1988,7 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
TALLOC_CTX *user_ctx;
char *password = NULL;
- BOOL ret = True;
+ bool ret = true;
int i;
const uint32_t password_fields[] = {
SAMR_FIELD_PASSWORD,
@@ -1983,32 +2001,32 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
switch (which_ops) {
case TORTURE_SAMR_USER_ATTRIBUTES:
if (!test_QuerySecurity(p, user_ctx, user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryUserInfo(p, user_ctx, user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryUserInfo2(p, user_ctx, user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_SetUserInfo(p, user_ctx, user_handle, base_acct_flags,
base_acct_name)) {
- ret = False;
+ ret = false;
}
if (!test_GetUserPwInfo(p, user_ctx, user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_TestPrivateFunctionsUser(p, user_ctx, user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_SetUserPass(p, user_ctx, user_handle, &password)) {
- ret = False;
+ ret = false;
}
break;
case TORTURE_SAMR_PASSWORDS:
@@ -2023,53 +2041,53 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
/* Workstation trust accounts don't seem to need to honour password quality policy */
if (!test_SetUserPassEx(p, user_ctx, user_handle, true, &password)) {
- ret = False;
+ ret = false;
}
- if (!test_ChangePasswordUser2(p, user_ctx, base_acct_name, &password, simple_pass, False)) {
- ret = False;
+ if (!test_ChangePasswordUser2(p, user_ctx, base_acct_name, &password, simple_pass, false)) {
+ ret = false;
}
/* reset again, to allow another 'user' password change */
if (!test_SetUserPassEx(p, user_ctx, user_handle, true, &password)) {
- ret = False;
+ ret = false;
}
/* Try a 'short' password */
- if (!test_ChangePasswordUser2(p, user_ctx, base_acct_name, &password, samr_rand_pass(mem_ctx, 4), False)) {
- ret = False;
+ if (!test_ChangePasswordUser2(p, user_ctx, base_acct_name, &password, samr_rand_pass(mem_ctx, 4), false)) {
+ ret = false;
}
}
for (i = 0; password_fields[i]; i++) {
if (!test_SetUserPass_23(p, user_ctx, user_handle, password_fields[i], &password)) {
- ret = False;
+ ret = false;
}
/* check it was set right */
- if (!test_ChangePasswordUser3(p, user_ctx, base_acct_name, 0, &password, NULL, 0, False)) {
- ret = False;
+ if (!test_ChangePasswordUser3(p, user_ctx, base_acct_name, 0, &password, NULL, 0, false)) {
+ ret = false;
}
}
for (i = 0; password_fields[i]; i++) {
if (!test_SetUserPass_25(p, user_ctx, user_handle, password_fields[i], &password)) {
- ret = False;
+ ret = false;
}
/* check it was set right */
- if (!test_ChangePasswordUser3(p, user_ctx, base_acct_name, 0, &password, NULL, 0, False)) {
- ret = False;
+ if (!test_ChangePasswordUser3(p, user_ctx, base_acct_name, 0, &password, NULL, 0, false)) {
+ ret = false;
}
}
if (!test_SetUserPassEx(p, user_ctx, user_handle, false, &password)) {
- ret = False;
+ ret = false;
}
if (!test_ChangePassword(p, user_ctx, base_acct_name, domain_handle, &password)) {
- ret = False;
+ ret = false;
}
break;
@@ -2081,47 +2099,47 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_alias_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_alias_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *alias_handle,
const struct dom_sid *domain_sid)
{
- BOOL ret = True;
+ bool ret = true;
if (!test_QuerySecurity(p, mem_ctx, alias_handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryAliasInfo(p, mem_ctx, alias_handle)) {
- ret = False;
+ ret = false;
}
if (!test_SetAliasInfo(p, mem_ctx, alias_handle)) {
- ret = False;
+ ret = false;
}
if (!test_AddMemberToAlias(p, mem_ctx, alias_handle, domain_sid)) {
- ret = False;
+ ret = false;
}
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping MultipleMembers Alias tests against Samba4\n");
return ret;
}
if (!test_AddMultipleMembersToAlias(p, mem_ctx, alias_handle)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_DeleteUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DeleteUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *user_handle)
{
struct samr_DeleteUser d;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("Testing DeleteUser\n");
d.in.user_handle = user_handle;
@@ -2130,13 +2148,13 @@ static BOOL test_DeleteUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_DeleteUser(p, mem_ctx, &d);
if (!NT_STATUS_IS_OK(status)) {
printf("DeleteUser failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-BOOL test_DeleteUser_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_DeleteUser_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char *name)
{
NTSTATUS status;
@@ -2161,15 +2179,15 @@ BOOL test_DeleteUser_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
goto failed;
}
- return True;
+ return true;
failed:
printf("DeleteUser_byname(%s) failed - %s\n", name, nt_errstr(status));
- return False;
+ return false;
}
-static BOOL test_DeleteGroup_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DeleteGroup_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char *name)
{
NTSTATUS status;
@@ -2199,15 +2217,15 @@ static BOOL test_DeleteGroup_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
goto failed;
}
- return True;
+ return true;
failed:
printf("DeleteGroup_byname(%s) failed - %s\n", name, nt_errstr(status));
- return False;
+ return false;
}
-static BOOL test_DeleteAlias_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DeleteAlias_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle, const char *name)
{
NTSTATUS status;
@@ -2239,19 +2257,19 @@ static BOOL test_DeleteAlias_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
goto failed;
}
- return True;
+ return true;
failed:
printf("DeleteAlias_byname(%s) failed - %s\n", name, nt_errstr(status));
- return False;
+ return false;
}
-static BOOL test_DeleteAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DeleteAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *alias_handle)
{
struct samr_DeleteDomAlias d;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("Testing DeleteAlias\n");
d.in.alias_handle = alias_handle;
@@ -2260,13 +2278,13 @@ static BOOL test_DeleteAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_DeleteDomAlias(p, mem_ctx, &d);
if (!NT_STATUS_IS_OK(status)) {
printf("DeleteAlias failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
struct policy_handle *alias_handle,
const struct dom_sid *domain_sid)
@@ -2275,7 +2293,7 @@ static BOOL test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_CreateDomAlias r;
struct lsa_String name;
uint32_t rid;
- BOOL ret = True;
+ bool ret = true;
init_lsa_String(&name, TEST_ALIASNAME);
r.in.domain_handle = domain_handle;
@@ -2290,53 +2308,53 @@ static BOOL test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
printf("Server refused create of '%s'\n", r.in.alias_name->string);
- return True;
+ return true;
}
if (NT_STATUS_EQUAL(status, NT_STATUS_ALIAS_EXISTS)) {
if (!test_DeleteAlias_byname(p, mem_ctx, domain_handle, r.in.alias_name->string)) {
- return False;
+ return false;
}
status = dcerpc_samr_CreateDomAlias(p, mem_ctx, &r);
}
if (!NT_STATUS_IS_OK(status)) {
printf("CreateAlias failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!test_alias_ops(p, mem_ctx, alias_handle, domain_sid)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char *acct_name,
struct policy_handle *domain_handle, char **password)
{
- BOOL ret = True;
+ bool ret = true;
if (!*password) {
- return False;
+ return false;
}
if (!test_ChangePasswordUser(p, mem_ctx, acct_name, domain_handle, password)) {
- ret = False;
+ ret = false;
}
- if (!test_ChangePasswordUser2(p, mem_ctx, acct_name, password, 0, True)) {
- ret = False;
+ if (!test_ChangePasswordUser2(p, mem_ctx, acct_name, password, 0, true)) {
+ ret = false;
}
if (!test_OemChangePasswordUser2(p, mem_ctx, acct_name, domain_handle, password)) {
- ret = False;
+ ret = false;
}
/* test what happens when setting the old password again */
- if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, *password, 0, True)) {
- ret = False;
+ if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, *password, 0, true)) {
+ ret = false;
}
{
@@ -2347,8 +2365,8 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
memset(simple_pass, *v, sizeof(simple_pass) - 1);
/* test what happens when picking a simple password */
- if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, simple_pass, 0, True)) {
- ret = False;
+ if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, simple_pass, 0, true)) {
+ ret = false;
}
}
@@ -2369,7 +2387,7 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("testing samr_QueryDomainInfo level 1\n");
status = dcerpc_samr_QueryDomainInfo(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
s.in.domain_handle = domain_handle;
@@ -2389,13 +2407,13 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("testing samr_SetDomainInfo level 1\n");
status = dcerpc_samr_SetDomainInfo(p, mem_ctx, &s);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
printf("calling test_ChangePasswordUser3 with too short password\n");
- if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, len - 1, password, NULL, 0, True)) {
- ret = False;
+ if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, len - 1, password, NULL, 0, true)) {
+ ret = false;
}
s.in.info->info1.min_password_length = len_old;
@@ -2405,7 +2423,7 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("testing samr_SetDomainInfo level 1\n");
status = dcerpc_samr_SetDomainInfo(p, mem_ctx, &s);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
}
@@ -2425,7 +2443,7 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupNames(p, mem_ctx, &n);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupNames failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r.in.domain_handle = domain_handle;
@@ -2436,7 +2454,7 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenUser(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenUser(%u) failed - %s\n", n.out.rids.ids[0], nt_errstr(status));
- return False;
+ return false;
}
q.in.user_handle = &user_handle;
@@ -2445,31 +2463,31 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_QueryUserInfo(p, mem_ctx, &q);
if (!NT_STATUS_IS_OK(status)) {
printf("QueryUserInfo failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
printf("calling test_ChangePasswordUser3 with too early password change\n");
if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL,
- q.out.info->info5.last_password_change, True)) {
- ret = False;
+ q.out.info->info5.last_password_change, true)) {
+ ret = false;
}
}
/* we change passwords twice - this has the effect of verifying
they were changed correctly for the final call */
- if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL, 0, True)) {
- ret = False;
+ if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL, 0, true)) {
+ ret = false;
}
- if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL, 0, True)) {
- ret = False;
+ if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL, 0, true)) {
+ ret = false;
}
return ret;
}
-static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
struct policy_handle *user_handle_out,
enum torture_samr_choice which_ops)
@@ -2486,7 +2504,7 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
/* This call creates a 'normal' account - check that it really does */
const uint32_t acct_flags = ACB_NORMAL;
struct lsa_String name;
- BOOL ret = True;
+ bool ret = true;
struct policy_handle user_handle;
user_ctx = talloc_named(mem_ctx, 0, "test_CreateUser2 per-user context");
@@ -2505,20 +2523,20 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
printf("Server refused create of '%s': %s\n", r.in.account_name->string, nt_errstr(status));
talloc_free(user_ctx);
- return True;
+ return true;
}
if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
if (!test_DeleteUser_byname(p, user_ctx, domain_handle, r.in.account_name->string)) {
talloc_free(user_ctx);
- return False;
+ return false;
}
status = dcerpc_samr_CreateUser(p, user_ctx, &r);
}
if (!NT_STATUS_IS_OK(status)) {
talloc_free(user_ctx);
printf("CreateUser failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else {
q.in.user_handle = &user_handle;
q.in.level = 16;
@@ -2527,19 +2545,19 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryUserInfo level %u failed - %s\n",
q.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
} else {
if ((q.out.info->info16.acct_flags & acct_flags) != acct_flags) {
printf("QuerUserInfo level 16 failed, it returned 0x%08x when we expected flags of 0x%08x\n",
q.out.info->info16.acct_flags,
acct_flags);
- ret = False;
+ ret = false;
}
}
if (!test_user_ops(p, user_ctx, &user_handle, domain_handle,
acct_flags, name.string, which_ops)) {
- ret = False;
+ ret = false;
}
if (user_handle_out) {
@@ -2553,7 +2571,7 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_DeleteUser(p, user_ctx, &d);
if (!NT_STATUS_IS_OK(status)) {
printf("DeleteUser failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
}
@@ -2565,7 +2583,7 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle, enum torture_samr_choice which_ops)
{
NTSTATUS status;
@@ -2575,7 +2593,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle user_handle;
uint32_t rid;
struct lsa_String name;
- BOOL ret = True;
+ bool ret = true;
int i;
struct {
@@ -2627,7 +2645,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
} else if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
if (!test_DeleteUser_byname(p, user_ctx, domain_handle, r.in.account_name->string)) {
talloc_free(user_ctx);
- ret = False;
+ ret = false;
continue;
}
status = dcerpc_samr_CreateUser2(p, user_ctx, &r);
@@ -2636,7 +2654,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(status, account_types[i].nt_status)) {
printf("CreateUser2 failed gave incorrect error return - %s (should be %s)\n",
nt_errstr(status), nt_errstr(account_types[i].nt_status));
- ret = False;
+ ret = false;
}
if (NT_STATUS_IS_OK(status)) {
@@ -2647,34 +2665,34 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryUserInfo level %u failed - %s\n",
q.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
} else {
if ((q.out.info->info5.acct_flags & acct_flags) != acct_flags) {
printf("QuerUserInfo level 5 failed, it returned 0x%08x when we expected flags of 0x%08x\n",
q.out.info->info5.acct_flags,
acct_flags);
- ret = False;
+ ret = false;
}
switch (acct_flags) {
case ACB_SVRTRUST:
if (q.out.info->info5.primary_gid != DOMAIN_RID_DCS) {
printf("QuerUserInfo level 5: DC should have had Primary Group %d, got %d\n",
DOMAIN_RID_DCS, q.out.info->info5.primary_gid);
- ret = False;
+ ret = false;
}
break;
case ACB_WSTRUST:
if (q.out.info->info5.primary_gid != DOMAIN_RID_DOMAIN_MEMBERS) {
printf("QuerUserInfo level 5: Domain Member should have had Primary Group %d, got %d\n",
DOMAIN_RID_DOMAIN_MEMBERS, q.out.info->info5.primary_gid);
- ret = False;
+ ret = false;
}
break;
case ACB_NORMAL:
if (q.out.info->info5.primary_gid != DOMAIN_RID_USERS) {
printf("QuerUserInfo level 5: Users should have had Primary Group %d, got %d\n",
DOMAIN_RID_USERS, q.out.info->info5.primary_gid);
- ret = False;
+ ret = false;
}
break;
}
@@ -2682,7 +2700,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!test_user_ops(p, user_ctx, &user_handle, domain_handle,
acct_flags, name.string, which_ops)) {
- ret = False;
+ ret = false;
}
printf("Testing DeleteUser (createuser2 test)\n");
@@ -2693,7 +2711,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_DeleteUser(p, user_ctx, &d);
if (!NT_STATUS_IS_OK(status)) {
printf("DeleteUser failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
}
talloc_free(user_ctx);
@@ -2702,14 +2720,14 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_QueryAliasInfo r;
uint16_t levels[] = {1, 2, 3};
int i;
- BOOL ret = True;
+ bool ret = true;
for (i=0;i<ARRAY_SIZE(levels);i++) {
printf("Testing QueryAliasInfo level %u\n", levels[i]);
@@ -2721,21 +2739,21 @@ static BOOL test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryAliasInfo level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_QueryGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_QueryGroupInfo r;
uint16_t levels[] = {1, 2, 3, 4, 5};
int i;
- BOOL ret = True;
+ bool ret = true;
for (i=0;i<ARRAY_SIZE(levels);i++) {
printf("Testing QueryGroupInfo level %u\n", levels[i]);
@@ -2747,19 +2765,19 @@ static BOOL test_QueryGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryGroupInfo level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_QueryGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_QueryGroupMember r;
- BOOL ret = True;
+ bool ret = true;
printf("Testing QueryGroupMember\n");
@@ -2768,14 +2786,14 @@ static BOOL test_QueryGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_QueryGroupMember(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("QueryGroupInfo failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -2784,7 +2802,7 @@ static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
uint16_t levels[] = {1, 2, 3, 4};
uint16_t set_ok[] = {0, 1, 1, 1};
int i;
- BOOL ret = True;
+ bool ret = true;
for (i=0;i<ARRAY_SIZE(levels);i++) {
printf("Testing QueryGroupInfo level %u\n", levels[i]);
@@ -2796,7 +2814,7 @@ static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryGroupInfo level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
printf("Testing SetGroupInfo level %u\n", levels[i]);
@@ -2824,14 +2842,14 @@ static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetGroupInfo level %u failed - %s\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
} else {
if (!NT_STATUS_EQUAL(NT_STATUS_INVALID_INFO_CLASS, status)) {
printf("SetGroupInfo level %u gave %s - should have been NT_STATUS_INVALID_INFO_CLASS\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
}
@@ -2840,7 +2858,7 @@ static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -2848,7 +2866,7 @@ static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 16, 17, 20, 21};
int i;
- BOOL ret = True;
+ bool ret = true;
for (i=0;i<ARRAY_SIZE(levels);i++) {
printf("Testing QueryUserInfo level %u\n", levels[i]);
@@ -2860,14 +2878,14 @@ static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryUserInfo level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -2875,7 +2893,7 @@ static BOOL test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 16, 17, 20, 21};
int i;
- BOOL ret = True;
+ bool ret = true;
for (i=0;i<ARRAY_SIZE(levels);i++) {
printf("Testing QueryUserInfo2 level %u\n", levels[i]);
@@ -2887,20 +2905,20 @@ static BOOL test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryUserInfo2 level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_OpenUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_OpenUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, uint32_t rid)
{
NTSTATUS status;
struct samr_OpenUser r;
struct policy_handle user_handle;
- BOOL ret = True;
+ bool ret = true;
printf("Testing OpenUser(%u)\n", rid);
@@ -2912,43 +2930,43 @@ static BOOL test_OpenUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenUser(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(status));
- return False;
+ return false;
}
if (!test_QuerySecurity(p, mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryUserInfo(p, mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryUserInfo2(p, mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_GetUserPwInfo(p, mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_GetGroupsForUser(p,mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_OpenGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_OpenGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, uint32_t rid)
{
NTSTATUS status;
struct samr_OpenGroup r;
struct policy_handle group_handle;
- BOOL ret = True;
+ bool ret = true;
printf("Testing OpenGroup(%u)\n", rid);
@@ -2960,35 +2978,35 @@ static BOOL test_OpenGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenGroup(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenGroup(%u) failed - %s\n", rid, nt_errstr(status));
- return False;
+ return false;
}
if (!test_QuerySecurity(p, mem_ctx, &group_handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryGroupInfo(p, mem_ctx, &group_handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryGroupMember(p, mem_ctx, &group_handle)) {
- ret = False;
+ ret = false;
}
if (!test_samr_handle_Close(p, mem_ctx, &group_handle)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_OpenAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_OpenAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, uint32_t rid)
{
NTSTATUS status;
struct samr_OpenAlias r;
struct policy_handle alias_handle;
- BOOL ret = True;
+ bool ret = true;
printf("Testing OpenAlias(%u)\n", rid);
@@ -3000,29 +3018,29 @@ static BOOL test_OpenAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenAlias(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenAlias(%u) failed - %s\n", rid, nt_errstr(status));
- return False;
+ return false;
}
if (!test_QuerySecurity(p, mem_ctx, &alias_handle)) {
- ret = False;
+ ret = false;
}
if (!test_QueryAliasInfo(p, mem_ctx, &alias_handle)) {
- ret = False;
+ ret = false;
}
if (!test_GetMembersInAlias(p, mem_ctx, &alias_handle)) {
- ret = False;
+ ret = false;
}
if (!test_samr_handle_Close(p, mem_ctx, &alias_handle)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, uint32_t rid,
uint32_t acct_flag_mask)
{
@@ -3030,7 +3048,7 @@ static BOOL check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_OpenUser r;
struct samr_QueryUserInfo q;
struct policy_handle user_handle;
- BOOL ret = True;
+ bool ret = true;
printf("Testing OpenUser(%u)\n", rid);
@@ -3042,7 +3060,7 @@ static BOOL check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenUser(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(status));
- return False;
+ return false;
}
q.in.user_handle = &user_handle;
@@ -3052,30 +3070,30 @@ static BOOL check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryUserInfo level 16 failed - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
} else {
if ((acct_flag_mask & q.out.info->info16.acct_flags) == 0) {
printf("Server failed to filter for 0x%x, allowed 0x%x (%d) on EnumDomainUsers\n",
acct_flag_mask, q.out.info->info16.acct_flags, rid);
- ret = False;
+ ret = false;
}
}
if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status = STATUS_MORE_ENTRIES;
struct samr_EnumDomainUsers r;
uint32_t mask, resume_handle=0;
int i, mask_idx;
- BOOL ret = True;
+ bool ret = true;
struct samr_LookupNames n;
struct samr_LookupRids lr ;
uint32_t masks[] = {ACB_NORMAL, ACB_DOMTRUST, ACB_WSTRUST,
@@ -3096,12 +3114,12 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES) &&
!NT_STATUS_IS_OK(status)) {
printf("EnumDomainUsers failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!r.out.sam) {
printf("EnumDomainUsers failed: r.out.sam unexpectedly NULL\n");
- return False;
+ return false;
}
if (r.out.sam->count == 0) {
@@ -3111,10 +3129,10 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
for (i=0;i<r.out.sam->count;i++) {
if (mask) {
if (!check_mask(p, mem_ctx, handle, r.out.sam->entries[i].idx, mask)) {
- ret = False;
+ ret = false;
}
} else if (!test_OpenUser(p, mem_ctx, handle, r.out.sam->entries[i].idx)) {
- ret = False;
+ ret = false;
}
}
}
@@ -3129,7 +3147,7 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupNames(p, mem_ctx, &n);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupNames failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
@@ -3143,7 +3161,7 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupRids(p, mem_ctx, &lr);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupRids failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
@@ -3152,7 +3170,7 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
/*
try blasting the server with a bunch of sync requests
*/
-static BOOL test_EnumDomainUsers_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_EnumDomainUsers_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -3162,9 +3180,9 @@ static BOOL test_EnumDomainUsers_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct
#define ASYNC_COUNT 100
struct rpc_request *req[ASYNC_COUNT];
- if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
+ if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) {
printf("samr async test disabled - enable dangerous tests to use\n");
- return True;
+ return true;
}
printf("Testing EnumDomainUsers_async\n");
@@ -3184,23 +3202,23 @@ static BOOL test_EnumDomainUsers_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct
if (!NT_STATUS_IS_OK(status)) {
printf("EnumDomainUsers[%d] failed - %s\n",
i, nt_errstr(status));
- return False;
+ return false;
}
}
printf("%d async requests OK\n", i);
- return True;
+ return true;
}
-static BOOL test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_EnumDomainGroups r;
uint32_t resume_handle=0;
int i;
- BOOL ret = True;
+ bool ret = true;
printf("Testing EnumDomainGroups\n");
@@ -3212,30 +3230,30 @@ static BOOL test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_EnumDomainGroups(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumDomainGroups failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!r.out.sam) {
- return False;
+ return false;
}
for (i=0;i<r.out.sam->count;i++) {
if (!test_OpenGroup(p, mem_ctx, handle, r.out.sam->entries[i].idx)) {
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_EnumDomainAliases(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_EnumDomainAliases(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_EnumDomainAliases r;
uint32_t resume_handle=0;
int i;
- BOOL ret = True;
+ bool ret = true;
printf("Testing EnumDomainAliases\n");
@@ -3247,28 +3265,28 @@ static BOOL test_EnumDomainAliases(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_EnumDomainAliases(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumDomainAliases failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!r.out.sam) {
- return False;
+ return false;
}
for (i=0;i<r.out.sam->count;i++) {
if (!test_OpenAlias(p, mem_ctx, handle, r.out.sam->entries[i].idx)) {
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_GetDisplayEnumerationIndex(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetDisplayEnumerationIndex(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_GetDisplayEnumerationIndex r;
- BOOL ret = True;
+ bool ret = true;
uint16_t levels[] = {1, 2, 3, 4, 5};
uint16_t ok_lvl[] = {1, 1, 1, 0, 0};
int i;
@@ -3287,7 +3305,7 @@ static BOOL test_GetDisplayEnumerationIndex(struct dcerpc_pipe *p, TALLOC_CTX *m
!NT_STATUS_EQUAL(NT_STATUS_NO_MORE_ENTRIES, status)) {
printf("GetDisplayEnumerationIndex level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
init_lsa_String(&r.in.name, "zzzzzzzz");
@@ -3297,19 +3315,19 @@ static BOOL test_GetDisplayEnumerationIndex(struct dcerpc_pipe *p, TALLOC_CTX *m
if (ok_lvl[i] && !NT_STATUS_EQUAL(NT_STATUS_NO_MORE_ENTRIES, status)) {
printf("GetDisplayEnumerationIndex level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_GetDisplayEnumerationIndex2 r;
- BOOL ret = True;
+ bool ret = true;
uint16_t levels[] = {1, 2, 3, 4, 5};
uint16_t ok_lvl[] = {1, 1, 1, 0, 0};
int i;
@@ -3327,7 +3345,7 @@ static BOOL test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX *
!NT_STATUS_EQUAL(NT_STATUS_NO_MORE_ENTRIES, status)) {
printf("GetDisplayEnumerationIndex2 level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
init_lsa_String(&r.in.name, "zzzzzzzz");
@@ -3336,7 +3354,7 @@ static BOOL test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX *
if (ok_lvl[i] && !NT_STATUS_EQUAL(NT_STATUS_NO_MORE_ENTRIES, status)) {
printf("GetDisplayEnumerationIndex2 level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
@@ -3349,23 +3367,23 @@ static BOOL test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX *
} else if ((s1.string && !s2.string) || (s2.string && !s1.string) || strcmp(s1.string, s2.string)) { \
printf("%s mismatch for %s: %s != %s (%s)\n", \
#s1, user.string, s1.string, s2.string, __location__); \
- ret = False; \
+ ret = false; \
}
#define INT_EQUAL_QUERY(s1, s2, user) \
if (s1 != s2) { \
- printf("%s mismatch for %s: 0x%x != 0x%x (%s)\n", \
- #s1, user.string, (unsigned int)s1, (unsigned int)s2, __location__); \
- ret = False; \
+ printf("%s mismatch for %s: 0x%llx != 0x%llx (%s)\n", \
+ #s1, user.string, (unsigned long long)s1, (unsigned long long)s2, __location__); \
+ ret = false; \
}
-static BOOL test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_QueryDisplayInfo *querydisplayinfo,
bool *seen_testuser)
{
struct samr_OpenUser r;
struct samr_QueryUserInfo q;
struct policy_handle user_handle;
- int i, ret = True;
+ int i, ret = true;
NTSTATUS status;
r.in.domain_handle = querydisplayinfo->in.domain_handle;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -3399,7 +3417,7 @@ static BOOL test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct
status = dcerpc_samr_OpenUser(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenUser(%u) failed - %s\n", r.in.rid, nt_errstr(status));
- return False;
+ return false;
}
}
@@ -3408,7 +3426,7 @@ static BOOL test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct
status = dcerpc_samr_QueryUserInfo(p, mem_ctx, &q);
if (!NT_STATUS_IS_OK(status)) {
printf("QueryUserInfo(%u) failed - %s\n", r.in.rid, nt_errstr(status));
- return False;
+ return false;
}
switch (querydisplayinfo->in.level) {
@@ -3448,26 +3466,26 @@ static BOOL test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct
q.out.info->info21.account_name.string,
querydisplayinfo->out.info.info2.entries[i].acct_flags,
q.out.info->info21.acct_flags);
- return False;
+ return false;
}
break;
}
if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) {
- return False;
+ return false;
}
}
return ret;
}
-static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_QueryDisplayInfo r;
struct samr_QueryDomainInfo dom_info;
- BOOL ret = True;
+ bool ret = true;
uint16_t levels[] = {1, 2, 3, 4, 5};
int i;
bool seen_testuser = false;
@@ -3487,18 +3505,18 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES) && !NT_STATUS_IS_OK(status)) {
printf("QueryDisplayInfo level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
switch (r.in.level) {
case 1:
if (!test_each_DisplayInfo_user(p, mem_ctx, &r, &seen_testuser)) {
- ret = False;
+ ret = false;
}
r.in.start_idx += r.out.info.info1.count;
break;
case 2:
if (!test_each_DisplayInfo_user(p, mem_ctx, &r, NULL)) {
- ret = False;
+ ret = false;
}
r.in.start_idx += r.out.info.info2.count;
break;
@@ -3520,7 +3538,7 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryDomainInfo level %u failed - %s\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
break;
}
switch (r.in.level) {
@@ -3530,14 +3548,14 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("QueryDomainInfo indicates that QueryDisplayInfo returned more users (%d/%d) than the domain %s is said to contain!\n",
r.in.start_idx, dom_info.out.info->info2.num_groups,
dom_info.out.info->info2.domain_name.string);
- ret = False;
+ ret = false;
}
if (!seen_testuser) {
struct policy_handle user_handle;
if (NT_STATUS_IS_OK(test_OpenUser_byname(p, mem_ctx, handle, TEST_ACCOUNT_NAME, &user_handle))) {
printf("Didn't find test user " TEST_ACCOUNT_NAME " in enumeration of %s\n",
dom_info.out.info->info2.domain_name.string);
- ret = False;
+ ret = false;
test_samr_handle_Close(p, mem_ctx, &user_handle);
}
}
@@ -3548,7 +3566,7 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("QueryDomainInfo indicates that QueryDisplayInfo didn't return all (%d/%d) the groups in %s\n",
r.in.start_idx, dom_info.out.info->info2.num_groups,
dom_info.out.info->info2.domain_name.string);
- ret = False;
+ ret = false;
}
break;
@@ -3559,12 +3577,12 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_QueryDisplayInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryDisplayInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_QueryDisplayInfo2 r;
- BOOL ret = True;
+ bool ret = true;
uint16_t levels[] = {1, 2, 3, 4, 5};
int i;
@@ -3581,19 +3599,19 @@ static BOOL test_QueryDisplayInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryDisplayInfo2 level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_QueryDisplayInfo3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryDisplayInfo3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_QueryDisplayInfo3 r;
- BOOL ret = True;
+ bool ret = true;
uint16_t levels[] = {1, 2, 3, 4, 5};
int i;
@@ -3610,7 +3628,7 @@ static BOOL test_QueryDisplayInfo3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryDisplayInfo3 level %u failed - %s\n",
levels[i], nt_errstr(status));
- ret = False;
+ ret = false;
}
}
@@ -3618,12 +3636,12 @@ static BOOL test_QueryDisplayInfo3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-static BOOL test_QueryDisplayInfo_continue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryDisplayInfo_continue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_QueryDisplayInfo r;
- BOOL ret = True;
+ bool ret = true;
printf("Testing QueryDisplayInfo continuation\n");
@@ -3647,7 +3665,7 @@ static BOOL test_QueryDisplayInfo_continue(struct dcerpc_pipe *p, TALLOC_CTX *me
!NT_STATUS_IS_OK(status)) {
printf("QueryDisplayInfo level %u failed - %s\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
break;
}
r.in.start_idx++;
@@ -3658,7 +3676,7 @@ static BOOL test_QueryDisplayInfo_continue(struct dcerpc_pipe *p, TALLOC_CTX *me
return ret;
}
-static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -3667,7 +3685,7 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13};
uint16_t set_ok[] = {1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0};
int i;
- BOOL ret = True;
+ bool ret = true;
const char *domain_comment = talloc_asprintf(mem_ctx,
"Tortured by Samba4 RPC-SAMR: %s",
timestring(mem_ctx, time(NULL)));
@@ -3681,7 +3699,7 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetDomainInfo level %u (set comment) failed - %s\n",
r.in.level, nt_errstr(status));
- return False;
+ return false;
}
for (i=0;i<ARRAY_SIZE(levels);i++) {
@@ -3694,7 +3712,7 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryDomainInfo level %u failed - %s\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
@@ -3703,12 +3721,12 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (strcmp(r.out.info->info2.comment.string, domain_comment) != 0) {
printf("QueryDomainInfo level %u returned different comment (%s, expected %s)\n",
levels[i], r.out.info->info2.comment.string, domain_comment);
- ret = False;
+ ret = false;
}
if (!r.out.info->info2.primary.string) {
printf("QueryDomainInfo level %u returned no PDC name\n",
levels[i]);
- ret = False;
+ ret = false;
} else if (r.out.info->info2.role == SAMR_ROLE_DOMAIN_PDC) {
if (dcerpc_server_name(p) && strcasecmp_m(dcerpc_server_name(p), r.out.info->info2.primary.string) != 0) {
printf("QueryDomainInfo level %u returned different PDC name (%s) compared to server name (%s), despite claiming to be the PDC\n",
@@ -3720,21 +3738,21 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (strcmp(r.out.info->info4.comment.string, domain_comment) != 0) {
printf("QueryDomainInfo level %u returned different comment (%s, expected %s)\n",
levels[i], r.out.info->info4.comment.string, domain_comment);
- ret = False;
+ ret = false;
}
break;
case 6:
if (!r.out.info->info6.primary.string) {
printf("QueryDomainInfo level %u returned no PDC name\n",
levels[i]);
- ret = False;
+ ret = false;
}
break;
case 11:
if (strcmp(r.out.info->info11.info2.comment.string, domain_comment) != 0) {
printf("QueryDomainInfo level %u returned different comment (%s, expected %s)\n",
levels[i], r.out.info->info11.info2.comment.string, domain_comment);
- ret = False;
+ ret = false;
}
break;
}
@@ -3750,14 +3768,14 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("SetDomainInfo level %u failed - %s\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
} else {
if (!NT_STATUS_EQUAL(NT_STATUS_INVALID_INFO_CLASS, status)) {
printf("SetDomainInfo level %u gave %s - should have been NT_STATUS_INVALID_INFO_CLASS\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
}
@@ -3766,7 +3784,7 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryDomainInfo level %u failed - %s\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
}
@@ -3775,14 +3793,14 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-static BOOL test_QueryDomainInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_QueryDomainInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
struct samr_QueryDomainInfo2 r;
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13};
int i;
- BOOL ret = True;
+ bool ret = true;
for (i=0;i<ARRAY_SIZE(levels);i++) {
printf("Testing QueryDomainInfo2 level %u\n", levels[i]);
@@ -3794,17 +3812,17 @@ static BOOL test_QueryDomainInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryDomainInfo2 level %u failed - %s\n",
r.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
}
- return True;
+ return true;
}
/* Test whether querydispinfo level 5 and enumdomgroups return the same
set of group names. */
-static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
struct samr_EnumDomainGroups q1;
@@ -3812,7 +3830,7 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
NTSTATUS status;
uint32_t resume_handle=0;
int i;
- BOOL ret = True;
+ bool ret = true;
int num_names = 0;
const char **names = NULL;
@@ -3841,11 +3859,11 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("EnumDomainGroups failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!q1.out.sam) {
- return False;
+ return false;
}
q2.in.domain_handle = handle;
@@ -3865,14 +3883,14 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
for (i=0; i<q2.out.info.info5.count; i++) {
int j;
const char *name = q2.out.info.info5.entries[i].account_name.string;
- BOOL found = False;
+ bool found = false;
for (j=0; j<num_names; j++) {
if (names[j] == NULL)
continue;
/* Hmm. No strequal in samba4 */
if (strequal(names[j], name)) {
names[j] = NULL;
- found = True;
+ found = true;
break;
}
}
@@ -3880,7 +3898,7 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!found) {
printf("QueryDisplayInfo gave name [%s] that EnumDomainGroups did not\n",
name);
- ret = False;
+ ret = false;
}
}
q2.in.start_idx += q2.out.info.info5.count;
@@ -3889,26 +3907,26 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
printf("QueryDisplayInfo level 5 failed - %s\n",
nt_errstr(status));
- ret = False;
+ ret = false;
}
for (i=0; i<num_names; i++) {
if (names[i] != NULL) {
printf("EnumDomainGroups gave name [%s] that QueryDisplayInfo did not\n",
names[i]);
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL test_DeleteDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DeleteDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *group_handle)
{
struct samr_DeleteDomainGroup d;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("Testing DeleteDomainGroup\n");
@@ -3918,18 +3936,18 @@ static BOOL test_DeleteDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_DeleteDomainGroup(p, mem_ctx, &d);
if (!NT_STATUS_IS_OK(status)) {
printf("DeleteDomainGroup failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_TestPrivateFunctionsDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_TestPrivateFunctionsDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle)
{
struct samr_TestPrivateFunctionsDomain r;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("Testing TestPrivateFunctionsDomain\n");
@@ -3938,19 +3956,19 @@ static BOOL test_TestPrivateFunctionsDomain(struct dcerpc_pipe *p, TALLOC_CTX *m
status = dcerpc_samr_TestPrivateFunctionsDomain(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(NT_STATUS_NOT_IMPLEMENTED, status)) {
printf("TestPrivateFunctionsDomain failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct dom_sid *domain_sid,
struct policy_handle *domain_handle)
{
struct samr_RidToSid r;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct dom_sid *calc_sid;
int rids[] = { 0, 42, 512, 10200 };
int i;
@@ -3966,7 +3984,7 @@ static BOOL test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_RidToSid(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("RidToSid for %d failed - %s\n", rids[i], nt_errstr(status));
- ret = False;
+ ret = false;
} else {
calc_sid = dom_sid_add_rid(calc_sid, calc_sid, rids[i]);
@@ -3974,7 +3992,7 @@ static BOOL test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("RidToSid for %d failed - got %s, expected %s\n", rids[i],
dom_sid_string(mem_ctx, r.out.sid),
dom_sid_string(mem_ctx, calc_sid));
- ret = False;
+ ret = false;
}
}
}
@@ -3982,12 +4000,12 @@ static BOOL test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_GetBootKeyInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetBootKeyInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle)
{
struct samr_GetBootKeyInformation r;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
printf("Testing GetBootKeyInformation\n");
@@ -4002,7 +4020,7 @@ static BOOL test_GetBootKeyInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct
return ret;
}
-static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
struct policy_handle *group_handle)
{
@@ -4011,13 +4029,13 @@ static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_DeleteGroupMember d;
struct samr_QueryGroupMember q;
struct samr_SetMemberAttributesOfGroup s;
- BOOL ret = True;
+ bool ret = true;
uint32_t rid;
status = test_LookupName(p, mem_ctx, domain_handle, TEST_ACCOUNT_NAME, &rid);
if (!NT_STATUS_IS_OK(status)) {
printf("test_AddGroupMember looking up name " TEST_ACCOUNT_NAME " failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
r.in.group_handle = group_handle;
@@ -4033,23 +4051,23 @@ static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_EQUAL(NT_STATUS_MEMBER_NOT_IN_GROUP, status)) {
printf("DeleteGroupMember gave %s - should be NT_STATUS_MEMBER_NOT_IN_GROUP\n",
nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_samr_AddGroupMember(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("AddGroupMember failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_samr_AddGroupMember(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(NT_STATUS_MEMBER_IN_GROUP, status)) {
printf("AddGroupMember gave %s - should be NT_STATUS_MEMBER_IN_GROUP\n",
nt_errstr(status));
- return False;
+ return false;
}
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping SetMemberAttributesOfGroup test against Samba4\n");
} else {
/* this one is quite strange. I am using random inputs in the
@@ -4062,7 +4080,7 @@ static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_SetMemberAttributesOfGroup(p, mem_ctx, &s);
if (!NT_STATUS_IS_OK(status)) {
printf("SetMemberAttributesOfGroup failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
}
@@ -4071,33 +4089,33 @@ static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_QueryGroupMember(p, mem_ctx, &q);
if (!NT_STATUS_IS_OK(status)) {
printf("QueryGroupMember failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_samr_DeleteGroupMember(p, mem_ctx, &d);
if (!NT_STATUS_IS_OK(status)) {
printf("DeleteGroupMember failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_samr_AddGroupMember(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("AddGroupMember failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
return ret;
}
-static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle, struct policy_handle *group_handle)
{
NTSTATUS status;
struct samr_CreateDomainGroup r;
uint32_t rid;
struct lsa_String name;
- BOOL ret = True;
+ bool ret = true;
init_lsa_String(&name, TEST_GROUPNAME);
@@ -4114,7 +4132,7 @@ static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
printf("Server refused create of '%s'\n", r.in.name->string);
ZERO_STRUCTP(group_handle);
- return True;
+ return true;
}
if (NT_STATUS_EQUAL(status, NT_STATUS_GROUP_EXISTS)) {
@@ -4122,7 +4140,7 @@ static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("CreateDomainGroup failed: Could not delete domain group %s - %s\n", r.in.name->string,
nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r);
}
@@ -4131,22 +4149,22 @@ static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("CreateDomainGroup failed: Could not delete user %s - %s\n", r.in.name->string,
nt_errstr(status));
- return False;
+ return false;
}
status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r);
}
if (!NT_STATUS_IS_OK(status)) {
printf("CreateDomainGroup failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!test_AddGroupMember(p, mem_ctx, domain_handle, group_handle)) {
printf("CreateDomainGroup failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
if (!test_SetGroupInfo(p, mem_ctx, group_handle)) {
- ret = False;
+ ret = false;
}
return ret;
@@ -4156,7 +4174,7 @@ static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
/*
its not totally clear what this does. It seems to accept any sid you like.
*/
-static BOOL test_RemoveMemberFromForeignDomain(struct dcerpc_pipe *p,
+static bool test_RemoveMemberFromForeignDomain(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle)
{
@@ -4169,18 +4187,18 @@ static BOOL test_RemoveMemberFromForeignDomain(struct dcerpc_pipe *p,
status = dcerpc_samr_RemoveMemberFromForeignDomain(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("RemoveMemberFromForeignDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle);
-static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct dom_sid *sid,
enum torture_samr_choice which_ops)
{
@@ -4190,7 +4208,7 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle alias_handle;
struct policy_handle user_handle;
struct policy_handle group_handle;
- BOOL ret = True;
+ bool ret = true;
ZERO_STRUCT(alias_handle);
ZERO_STRUCT(user_handle);
@@ -4207,7 +4225,7 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_OpenDomain(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
/* run the domain tests with the main handle closed - this tests
@@ -4238,7 +4256,7 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
ret &= test_QueryDisplayInfo3(p, mem_ctx, &domain_handle);
ret &= test_QueryDisplayInfo_continue(p, mem_ctx, &domain_handle);
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
printf("skipping GetDisplayEnumerationIndex test against Samba4\n");
} else {
ret &= test_GetDisplayEnumerationIndex(p, mem_ctx, &domain_handle);
@@ -4253,17 +4271,17 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!policy_handle_empty(&user_handle) &&
!test_DeleteUser(p, mem_ctx, &user_handle)) {
- ret = False;
+ ret = false;
}
if (!policy_handle_empty(&alias_handle) &&
!test_DeleteAlias(p, mem_ctx, &alias_handle)) {
- ret = False;
+ ret = false;
}
if (!policy_handle_empty(&group_handle) &&
!test_DeleteDomainGroup(p, mem_ctx, &group_handle)) {
- ret = False;
+ ret = false;
}
ret &= test_samr_handle_Close(p, mem_ctx, &domain_handle);
@@ -4278,7 +4296,7 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
-static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char *domain,
enum torture_samr_choice which_ops)
{
@@ -4286,7 +4304,7 @@ static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_LookupDomain r;
struct lsa_String n1;
struct lsa_String n2;
- BOOL ret = True;
+ bool ret = true;
printf("Testing LookupDomain(%s)\n", domain);
@@ -4298,7 +4316,7 @@ static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupDomain(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(NT_STATUS_INVALID_PARAMETER, status)) {
printf("failed: LookupDomain expected NT_STATUS_INVALID_PARAMETER - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
init_lsa_String(&n2, "xxNODOMAINxx");
@@ -4306,7 +4324,7 @@ static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupDomain(p, mem_ctx, &r);
if (!NT_STATUS_EQUAL(NT_STATUS_NO_SUCH_DOMAIN, status)) {
printf("failed: LookupDomain expected NT_STATUS_NO_SUCH_DOMAIN - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
r.in.connect_handle = handle;
@@ -4317,29 +4335,29 @@ static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupDomain(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupDomain failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
if (!test_GetDomPwInfo(p, mem_ctx, &n1)) {
- ret = False;
+ ret = false;
}
if (!test_OpenDomain(p, mem_ctx, handle, r.out.sid, which_ops)) {
- ret = False;
+ ret = false;
}
return ret;
}
-static BOOL test_EnumDomains(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_EnumDomains(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, enum torture_samr_choice which_ops)
{
NTSTATUS status;
struct samr_EnumDomains r;
uint32_t resume_handle = 0;
int i;
- BOOL ret = True;
+ bool ret = true;
r.in.connect_handle = handle;
r.in.resume_handle = &resume_handle;
@@ -4349,31 +4367,31 @@ static BOOL test_EnumDomains(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_EnumDomains(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumDomains failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!r.out.sam) {
- return False;
+ return false;
}
for (i=0;i<r.out.sam->count;i++) {
if (!test_LookupDomain(p, mem_ctx, handle,
r.out.sam->entries[i].name.string, which_ops)) {
- ret = False;
+ ret = false;
}
}
status = dcerpc_samr_EnumDomains(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumDomains failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
return ret;
}
-static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -4384,7 +4402,7 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_Connect5 r5;
union samr_ConnectInfo info;
struct policy_handle h;
- BOOL ret = True, got_handle = False;
+ bool ret = true, got_handle = false;
printf("testing samr_Connect\n");
@@ -4395,9 +4413,9 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Connect(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
- got_handle = True;
+ got_handle = true;
*handle = h;
}
@@ -4410,12 +4428,12 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Connect2(p, mem_ctx, &r2);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect2 failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
if (got_handle) {
test_samr_handle_Close(p, mem_ctx, handle);
}
- got_handle = True;
+ got_handle = true;
*handle = h;
}
@@ -4429,12 +4447,12 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Connect3(p, mem_ctx, &r3);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect3 failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
if (got_handle) {
test_samr_handle_Close(p, mem_ctx, handle);
}
- got_handle = True;
+ got_handle = true;
*handle = h;
}
@@ -4448,12 +4466,12 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Connect4(p, mem_ctx, &r4);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect4 failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
if (got_handle) {
test_samr_handle_Close(p, mem_ctx, handle);
}
- got_handle = True;
+ got_handle = true;
*handle = h;
}
@@ -4472,12 +4490,12 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_Connect5(p, mem_ctx, &r5);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect5 failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
} else {
if (got_handle) {
test_samr_handle_Close(p, mem_ctx, handle);
}
- got_handle = True;
+ got_handle = true;
*handle = h;
}
@@ -4485,16 +4503,16 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-BOOL torture_rpc_samr(struct torture_context *torture)
+bool torture_rpc_samr(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- BOOL ret = True;
+ bool ret = true;
struct policy_handle handle;
status = torture_rpc_connection(torture, &p, &ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ret &= test_Connect(p, torture, &handle);
@@ -4513,16 +4531,16 @@ BOOL torture_rpc_samr(struct torture_context *torture)
}
-BOOL torture_rpc_samr_users(struct torture_context *torture)
+bool torture_rpc_samr_users(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- BOOL ret = True;
+ bool ret = true;
struct policy_handle handle;
status = torture_rpc_connection(torture, &p, &ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ret &= test_Connect(p, torture, &handle);
@@ -4541,16 +4559,16 @@ BOOL torture_rpc_samr_users(struct torture_context *torture)
}
-BOOL torture_rpc_samr_passwords(struct torture_context *torture)
+bool torture_rpc_samr_passwords(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- BOOL ret = True;
+ bool ret = true;
struct policy_handle handle;
status = torture_rpc_connection(torture, &p, &ndr_table_samr);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ret &= test_Connect(p, torture, &handle);
diff --git a/source4/torture/rpc/samr_accessmask.c b/source4/torture/rpc/samr_accessmask.c
new file mode 100644
index 0000000000..c444187cfc
--- /dev/null
+++ b/source4/torture/rpc/samr_accessmask.c
@@ -0,0 +1,658 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for accessmasks on the SAMR pipe
+
+ Copyright (C) Ronnie Sahlberg 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 "torture/torture.h"
+#include "librpc/gen_ndr/ndr_samr_c.h"
+#include "torture/rpc/rpc.h"
+#include "param/param.h"
+#include "libcli/security/security.h"
+#include "librpc/gen_ndr/ndr_security.h"
+
+
+/* test user created to test the ACLs associated to SAMR objects */
+#define TEST_USER_NAME "samr_testuser"
+
+
+static NTSTATUS torture_samr_Close(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *h)
+{
+ NTSTATUS status;
+ struct samr_Close cl;
+
+ cl.in.handle = h;
+ cl.out.handle = h;
+ status = dcerpc_samr_Close(p, tctx, &cl);
+
+ return status;
+}
+
+static NTSTATUS torture_samr_Connect5(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ uint32_t mask, struct policy_handle *h)
+{
+ NTSTATUS status;
+ struct samr_Connect5 r5;
+ union samr_ConnectInfo info;
+
+ info.info1.unknown1 = 0;
+ info.info1.unknown2 = 0;
+ r5.in.system_name = "";
+ r5.in.level = 1;
+ r5.in.info = &info;
+ r5.out.info = &info;
+ r5.out.connect_handle = h;
+ r5.in.access_mask = mask;
+
+ status = dcerpc_samr_Connect5(p, tctx, &r5);
+
+ return status;
+}
+
+/* check which bits in accessmask allows us to connect to the server */
+static bool test_samr_accessmask_Connect5(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ NTSTATUS status;
+ struct policy_handle h;
+ int i;
+ uint32_t mask;
+
+ printf("testing which bits in accessmask allows us to connect\n");
+ mask = 1;
+ for (i=0;i<33;i++) {
+ printf("testing Connect5 with access mask 0x%08x", mask);
+ status = torture_samr_Connect5(tctx, p, mask, &h);
+ mask <<= 1;
+
+ switch (i) {
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ case 26:
+ case 27:
+ printf(" expecting to fail");
+ /* of only one of these bits are set we expect to
+ fail by default
+ */
+ if(!NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) {
+ printf("Connect5 failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ break;
+ default:
+ /* these bits set are expected to succeed by default */
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Connect5 failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ status = torture_samr_Close(tctx, p, &h);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Close failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ break;
+ }
+ printf(" OK\n");
+ }
+
+ return true;
+}
+
+/* check which bits in accessmask allows us to EnumDomains()
+ by default we must specify at least one of :
+ SAMR/EnumDomains
+ Maximum
+ GenericAll
+ GenericRead
+ in the access mask to Connect5() in order to be allowed to perform
+ EnumDomains() on the policy handle returned from Connect5()
+*/
+static bool test_samr_accessmask_EnumDomains(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ NTSTATUS status;
+ struct samr_EnumDomains ed;
+ struct policy_handle ch;
+ int i;
+ uint32_t mask;
+ uint32_t resume_handle = 0;
+
+ printf("testing which bits in Connect5 accessmask allows us to EnumDomains\n");
+ mask = 1;
+ for (i=0;i<33;i++) {
+ printf("testing Connect5/EnumDomains with access mask 0x%08x", mask);
+ status = torture_samr_Connect5(tctx, p, mask, &ch);
+ mask <<= 1;
+
+ switch (i) {
+ case 4: /* SAMR/EnumDomains */
+ case 25: /* Maximum */
+ case 28: /* GenericAll */
+ case 31: /* GenericRead */
+ /* these bits set are expected to succeed by default */
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Connect5 failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ ed.in.connect_handle = &ch;
+ ed.in.resume_handle = &resume_handle;
+ ed.in.buf_size = (uint32_t)-1;
+ ed.out.resume_handle = &resume_handle;
+
+ status = dcerpc_samr_EnumDomains(p, tctx, &ed);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("EnumDomains failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ status = torture_samr_Close(tctx, p, &ch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Close failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ break;
+ default:
+ printf(" expecting to fail");
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf(" OK\n");
+ continue;
+ }
+
+ ed.in.connect_handle = &ch;
+ ed.in.resume_handle = &resume_handle;
+ ed.in.buf_size = (uint32_t)-1;
+ ed.out.resume_handle = &resume_handle;
+
+ status = dcerpc_samr_EnumDomains(p, tctx, &ed);
+ if(!NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) {
+ printf("EnumDomains failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ status = torture_samr_Close(tctx, p, &ch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Close failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ break;
+ }
+ printf(" OK\n");
+ }
+
+ return true;
+}
+
+
+/*
+ * test how ACLs affect how/if a user can connect to the SAMR service
+ *
+ * samr_SetSecurity() returns SUCCESS when changing the ACL for
+ * a policy handle got from Connect5() but the ACL is not changed on
+ * the server
+ */
+static bool test_samr_connect_user_acl(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *test_credentials,
+ const struct dom_sid *test_sid)
+
+{
+ NTSTATUS status;
+ struct policy_handle ch;
+ struct policy_handle uch;
+ struct samr_QuerySecurity qs;
+ struct samr_SetSecurity ss;
+ struct security_ace ace;
+ struct security_descriptor *sd;
+ struct sec_desc_buf sdb;
+ bool ret = true;
+ int sd_size;
+ struct dcerpc_pipe *test_p;
+ const char *binding = torture_setting_string(tctx, "binding", NULL);
+
+ printf("testing ACLs to allow/prevent users to connect to SAMR");
+
+ /* connect to SAMR */
+ status = torture_samr_Connect5(tctx, p, SEC_FLAG_MAXIMUM_ALLOWED, &ch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Connect5 failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+
+ /* get the current ACL for the SAMR policy handle */
+ qs.in.handle = &ch;
+ qs.in.sec_info = SECINFO_DACL;
+ status = dcerpc_samr_QuerySecurity(p, tctx, &qs);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("QuerySecurity failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+
+ /* how big is the security descriptor? */
+ sd_size = qs.out.sdbuf->sd_size;
+
+
+ /* add an ACE to the security descriptor to deny the user the
+ * 'connect to server' right
+ */
+ sd = qs.out.sdbuf->sd;
+ ace.type = SEC_ACE_TYPE_ACCESS_DENIED;
+ ace.flags = 0;
+ ace.access_mask = SAMR_ACCESS_CONNECT_TO_SERVER;
+ ace.trustee = *test_sid;
+ status = security_descriptor_dacl_add(sd, &ace);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to add ACE to security descriptor\n");
+ ret = false;
+ }
+ ss.in.handle = &ch;
+ ss.in.sec_info = SECINFO_DACL;
+ ss.in.sdbuf = &sdb;
+ sdb.sd = sd;
+ status = dcerpc_samr_SetSecurity(p, tctx, &ss);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("SetSecurity failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+
+
+ /* Try to connect as the test user */
+ status = dcerpc_pipe_connect(tctx,
+ &test_p, binding, &ndr_table_samr,
+ test_credentials, NULL);
+ /* connect to SAMR as the user */
+ status = torture_samr_Connect5(tctx, test_p, SEC_FLAG_MAXIMUM_ALLOWED, &uch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Connect5 failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ /* disconnec the user */
+ talloc_free(test_p);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+
+ /* read the sequrity descriptor back. it should not have changed
+ * eventhough samr_SetSecurity returned SUCCESS
+ */
+ status = dcerpc_samr_QuerySecurity(p, tctx, &qs);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("QuerySecurity failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+ if (sd_size != qs.out.sdbuf->sd_size) {
+ printf("security descriptor changed\n");
+ ret = false;
+ }
+
+
+ status = torture_samr_Close(tctx, p, &ch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Close failed - %s\n", nt_errstr(status));
+ ret = false;
+ }
+
+ if (ret == true) {
+ printf(" OK\n");
+ }
+ return ret;
+}
+
+/*
+ * test if the ACLs are enforced for users.
+ * a normal testuser only gets the rights provided in hte ACL for
+ * Everyone which does not include the SAMR_ACCESS_SHUTDOWN_SERVER
+ * right. If the ACLs are checked when a user connects
+ * a testuser that requests the accessmask with only this bit set
+ * the connect should fail.
+ */
+static bool test_samr_connect_user_acl_enforced(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct cli_credentials *test_credentials,
+ const struct dom_sid *test_sid)
+
+{
+ NTSTATUS status;
+ struct policy_handle uch;
+ bool ret = true;
+ struct dcerpc_pipe *test_p;
+ const char *binding = torture_setting_string(tctx, "binding", NULL);
+
+ printf("testing if ACLs are enforced for non domain admin users when connecting to SAMR");
+
+
+ status = dcerpc_pipe_connect(tctx,
+ &test_p, binding, &ndr_table_samr,
+ test_credentials, NULL);
+
+ /* connect to SAMR as the user */
+ status = torture_samr_Connect5(tctx, test_p, SAMR_ACCESS_SHUTDOWN_SERVER, &uch);
+ if (NT_STATUS_IS_OK(status)) {
+ printf("Connect5 failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ printf(" OK\n");
+
+ /* disconnec the user */
+ talloc_free(test_p);
+
+ return ret;
+}
+
+/* check which bits in accessmask allows us to LookupDomain()
+ by default we must specify at least one of :
+ in the access mask to Connect5() in order to be allowed to perform
+ case 5: samr/opendomain
+ case 25: Maximum
+ case 28: GenericAll
+ case 29: GenericExecute
+ LookupDomain() on the policy handle returned from Connect5()
+*/
+static bool test_samr_accessmask_LookupDomain(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ NTSTATUS status;
+ struct samr_LookupDomain ld;
+ struct policy_handle ch;
+ struct lsa_String dn;
+ int i;
+ uint32_t mask;
+
+ printf("testing which bits in Connect5 accessmask allows us to LookupDomain\n");
+ mask = 1;
+ for (i=0;i<33;i++) {
+ printf("testing Connect5/LookupDomain with access mask 0x%08x", mask);
+ status = torture_samr_Connect5(tctx, p, mask, &ch);
+ mask <<= 1;
+
+ switch (i) {
+ case 5:
+ case 25: /* Maximum */
+ case 28: /* GenericAll */
+ case 29: /* GenericExecute */
+ /* these bits set are expected to succeed by default */
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Connect5 failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ ld.in.connect_handle = &ch;
+ ld.in.domain_name = &dn;
+ dn.string = lp_workgroup(global_loadparm);
+
+ status = dcerpc_samr_LookupDomain(p, tctx, &ld);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("LookupDomain failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ status = torture_samr_Close(tctx, p, &ch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Close failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ break;
+ default:
+ printf(" expecting to fail");
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf(" OK\n");
+ continue;
+ }
+
+ ld.in.connect_handle = &ch;
+ ld.in.domain_name = &dn;
+ dn.string = lp_workgroup(global_loadparm);
+
+ status = dcerpc_samr_LookupDomain(p, tctx, &ld);
+ if(!NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) {
+ printf("LookupDomain failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ status = torture_samr_Close(tctx, p, &ch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Close failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ break;
+ }
+ printf(" OK\n");
+ }
+
+ return true;
+}
+
+/* check which bits in accessmask allows us to OpenDomain()
+ by default we must specify at least one of :
+ samr/opendomain
+ Maximum
+ GenericAll
+ GenericExecute
+ in the access mask to Connect5() in order to be allowed to perform
+ OpenDomain() on the policy handle returned from Connect5()
+*/
+static bool test_samr_accessmask_OpenDomain(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ NTSTATUS status;
+ struct samr_LookupDomain ld;
+ struct samr_OpenDomain od;
+ struct policy_handle ch;
+ struct policy_handle dh;
+ struct lsa_String dn;
+ int i;
+ uint32_t mask;
+
+
+ /* first we must grab the sid of the domain */
+ status = torture_samr_Connect5(tctx, p, SEC_FLAG_MAXIMUM_ALLOWED, &ch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Connect5 failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ ld.in.connect_handle = &ch;
+ ld.in.domain_name = &dn;
+ dn.string = lp_workgroup(global_loadparm);
+ status = dcerpc_samr_LookupDomain(p, tctx, &ld);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("LookupDomain failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+
+
+ printf("testing which bits in Connect5 accessmask allows us to OpenDomain\n");
+ mask = 1;
+ for (i=0;i<33;i++) {
+ printf("testing Connect5/OpenDomain with access mask 0x%08x", mask);
+ status = torture_samr_Connect5(tctx, p, mask, &ch);
+ mask <<= 1;
+
+ switch (i) {
+ case 5:
+ case 25: /* Maximum */
+ case 28: /* GenericAll */
+ case 29: /* GenericExecute */
+ /* these bits set are expected to succeed by default */
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Connect5 failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ od.in.connect_handle = &ch;
+ od.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ od.in.sid = ld.out.sid;
+ od.out.domain_handle = &dh;
+
+ status = dcerpc_samr_OpenDomain(p, tctx, &od);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("OpenDomain failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ status = torture_samr_Close(tctx, p, &dh);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Close failed - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ status = torture_samr_Close(tctx, p, &ch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Close failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ break;
+ default:
+ printf(" expecting to fail");
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf(" OK\n");
+ continue;
+ }
+
+ status = torture_samr_Close(tctx, p, &ch);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Close failed - %s\n", nt_errstr(status));
+ return false;
+ }
+ break;
+ }
+ printf(" OK\n");
+ }
+
+ return true;
+}
+
+static bool test_samr_connect(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ void *testuser;
+ const char *testuser_passwd;
+ struct cli_credentials *test_credentials;
+ bool ret = true;
+ const struct dom_sid *test_sid;
+
+ /* create a test user */
+ testuser = torture_create_testuser(tctx, TEST_USER_NAME, lp_workgroup(global_loadparm),
+ ACB_NORMAL, &testuser_passwd);
+ if (!testuser) {
+ printf("Failed to create test user\n");
+ return false;
+ }
+ test_credentials = cli_credentials_init(tctx);
+ cli_credentials_set_workstation(test_credentials, "localhost", CRED_SPECIFIED);
+ cli_credentials_set_domain(test_credentials, lp_workgroup(global_loadparm),
+ CRED_SPECIFIED);
+ cli_credentials_set_username(test_credentials, TEST_USER_NAME, CRED_SPECIFIED);
+ cli_credentials_set_password(test_credentials, testuser_passwd, CRED_SPECIFIED);
+ test_sid = torture_join_user_sid(testuser);
+
+
+ /* test which bits in the accessmask to Connect5
+ will allow us to connect to the server
+ */
+ if (!test_samr_accessmask_Connect5(tctx, p)) {
+ ret = false;
+ }
+
+
+ /* test which bits in the accessmask to Connect5 will allow
+ * us to call EnumDomains()
+ */
+ if (!test_samr_accessmask_EnumDomains(tctx, p)) {
+ ret = false;
+ }
+
+ /* test which bits in the accessmask to Connect5 will allow
+ * us to call LookupDomain()
+ */
+ if (!test_samr_accessmask_LookupDomain(tctx, p)) {
+ ret = false;
+ }
+
+
+ /* test which bits in the accessmask to Connect5 will allow
+ * us to call OpenDomain()
+ */
+ if (!test_samr_accessmask_OpenDomain(tctx, p)) {
+ ret = false;
+ }
+
+
+ /* test if ACLs can be changed for the policy handle
+ * returned by Connect5
+ */
+ if (!test_samr_connect_user_acl(tctx, p, test_credentials, test_sid)) {
+ ret = false;
+ }
+
+ /* test if the ACLs that are reported from the Connect5
+ * policy handle is enforced.
+ * i.e. an ordinary user only has the same rights as Everybody
+ * ReadControl
+ * Samr/OpenDomain
+ * Samr/EnumDomains
+ * Samr/ConnectToServer
+ * is granted and should therefore not be able to connect when
+ * requesting SAMR_ACCESS_SHUTDOWN_SERVER
+ */
+ if (!test_samr_connect_user_acl_enforced(tctx, p, test_credentials, test_sid)) {
+ ret = false;
+ }
+
+
+
+ /* remove the test user */
+ torture_leave_domain(testuser);
+
+ return ret;
+}
+
+struct torture_suite *torture_rpc_samr_accessmask(TALLOC_CTX *mem_ctx)
+{
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "SAMR_ACCESSMASK");
+ struct torture_rpc_tcase *tcase;
+
+ tcase = torture_suite_add_rpc_iface_tcase(suite, "samr",
+ &ndr_table_samr);
+
+ torture_rpc_tcase_add_test(tcase, "CONNECT", test_samr_connect);
+
+ return suite;
+}
diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c
index 358bf8791a..6f76e3b58b 100644
--- a/source4/torture/rpc/samsync.c
+++ b/source4/torture/rpc/samsync.c
@@ -36,6 +36,7 @@
#include "librpc/gen_ndr/ndr_lsa_c.h"
#include "librpc/gen_ndr/ndr_samr_c.h"
#include "librpc/gen_ndr/ndr_security.h"
+#include "param/param.h"
#define TEST_MACHINE_NAME "samsynctest"
#define TEST_WKSTA_MACHINE_NAME "samsynctest2"
@@ -67,7 +68,7 @@ static NTSTATUS test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
sizeof(ninfo.challenge));
if (nt_hash) {
ninfo.nt.length = 24;
- ninfo.nt.data = talloc_size(mem_ctx, 24);
+ ninfo.nt.data = talloc_array(mem_ctx, uint8_t, 24);
SMBOWFencrypt(nt_hash->hash, ninfo.challenge, ninfo.nt.data);
} else {
ninfo.nt.length = 0;
@@ -76,7 +77,7 @@ static NTSTATUS test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (lm_hash) {
ninfo.lm.length = 24;
- ninfo.lm.data = talloc_size(mem_ctx, 24);
+ ninfo.lm.data = talloc_array(mem_ctx, uint8_t, 24);
SMBOWFencrypt(lm_hash->hash, ninfo.challenge, ninfo.lm.data);
} else {
ninfo.lm.length = 0;
@@ -222,21 +223,21 @@ static struct sec_desc_buf *samsync_query_lsa_sec_desc(TALLOC_CTX *mem_ctx,
__location__, \
(long long)i1, (long long)i1, \
(long long)i2, (long long)i2);\
- ret = False;\
+ ret = false;\
} \
} while (0)
#define TEST_INT_EQUAL(i1, i2) do {\
if (i1 != i2) {\
printf("%s: integer mismatch: " #i1 ": 0x%08x (%d) != " #i2 ": 0x%08x (%d)\n", \
__location__, i1, i1, i2, i2); \
- ret = False;\
+ ret = false;\
} \
} while (0)
#define TEST_TIME_EQUAL(t1, t2) do {\
if (t1 != t2) {\
printf("%s: NTTIME mismatch: " #t1 ":%s != " #t2 ": %s\n", \
__location__, nt_time_string(mem_ctx, t1), nt_time_string(mem_ctx, t2));\
- ret = False;\
+ ret = false;\
} \
} while (0)
@@ -245,7 +246,7 @@ static struct sec_desc_buf *samsync_query_lsa_sec_desc(TALLOC_CTX *mem_ctx,
&& strcmp_safe(s1.string, s2.string) != 0) {\
printf("%s: string mismatch: " #s1 ":%s != " #s2 ": %s\n", \
__location__, s1.string, s2.string);\
- ret = False;\
+ ret = false;\
} \
} while (0)
@@ -253,7 +254,7 @@ static struct sec_desc_buf *samsync_query_lsa_sec_desc(TALLOC_CTX *mem_ctx,
if (!dom_sid_equal(s1, s2)) {\
printf("%s: dom_sid mismatch: " #s1 ":%s != " #s2 ": %s\n", \
__location__, dom_sid_string(mem_ctx, s1), dom_sid_string(mem_ctx, s2));\
- ret = False;\
+ ret = false;\
} \
} while (0)
@@ -265,19 +266,19 @@ static struct sec_desc_buf *samsync_query_lsa_sec_desc(TALLOC_CTX *mem_ctx,
handle); \
if (!sdbuf || !sdbuf->sd) { \
printf("Could not obtain security descriptor to match " #sd1 "\n");\
- ret = False; \
+ ret = false; \
} else {\
if (!security_descriptor_mask_equal(sd1.sd, sdbuf->sd, \
~SEC_DESC_SACL_PRESENT)) {\
printf("Security Descriptor Mismatch for %s:\n", #sd1);\
ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, "SamSync", sd1.sd);\
ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, "SamR", sdbuf->sd);\
- ret = False;\
+ ret = false;\
}\
}\
} while (0)
-static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
+static bool samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
int database_id, struct netr_DELTA_ENUM *delta)
{
struct netr_DELTA_DOMAIN *domain = delta->delta_union.domain;
@@ -286,7 +287,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13};
NTSTATUS nt_status;
int i;
- BOOL ret = True;
+ bool ret = true;
samsync_state->seq_num[database_id] =
domain->sequence_num;
@@ -300,7 +301,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam
break;
case SAM_DATABASE_PRIVS:
printf("DOMAIN entry on privs DB!\n");
- return False;
+ return false;
break;
}
@@ -311,7 +312,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam
if (strcasecmp_m(samsync_state->domain_name[database_id], domain->domain_name.string) != 0) {
printf("Domain has name varies!: %s != %s\n", samsync_state->domain_name[database_id],
domain->domain_name.string);
- return False;
+ return false;
}
}
@@ -338,7 +339,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam
if (!NT_STATUS_IS_OK(nt_status)) {
printf("QueryDomainInfo level %u failed - %s\n",
q[levels[i]].in.level, nt_errstr(nt_status));
- return False;
+ return false;
}
}
@@ -366,7 +367,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam
return ret;
}
-static BOOL samsync_handle_policy(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
+static bool samsync_handle_policy(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
int database_id, struct netr_DELTA_ENUM *delta)
{
struct netr_DELTA_POLICY *policy = delta->delta_union.policy;
@@ -381,23 +382,23 @@ static BOOL samsync_handle_policy(TALLOC_CTX *mem_ctx, struct samsync_state *sam
if (strcasecmp_m(samsync_state->domain_name[SAM_DATABASE_DOMAIN], policy->primary_domain_name.string) != 0) {
printf("PRIMARY domain has name varies between DOMAIN and POLICY!: %s != %s\n", samsync_state->domain_name[SAM_DATABASE_DOMAIN],
policy->primary_domain_name.string);
- return False;
+ return false;
}
}
if (!dom_sid_equal(samsync_state->sid[SAM_DATABASE_DOMAIN], policy->sid)) {
printf("Domain SID from POLICY (%s) does not match domain sid from SAMR (%s)\n",
dom_sid_string(mem_ctx, policy->sid), dom_sid_string(mem_ctx, samsync_state->sid[SAM_DATABASE_DOMAIN]));
- return False;
+ return false;
}
printf("\tsequence_nums[%d/PRIVS]=%llu\n",
database_id,
(long long)samsync_state->seq_num[database_id]);
- return True;
+ return true;
}
-static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
+static bool samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
int database_id, struct netr_DELTA_ENUM *delta)
{
uint32_t rid = delta->delta_id_union.rid;
@@ -410,7 +411,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
const char *domain = samsync_state->domain_name[database_id];
const char *username = user->account_name.string;
NTSTATUS nt_status;
- BOOL ret = True;
+ bool ret = true;
struct samr_OpenUser r;
struct samr_QueryUserInfo q;
@@ -419,7 +420,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
struct samr_GetGroupsForUser getgroups;
if (!samsync_state->domain_name || !samsync_state->domain_handle[database_id]) {
printf("SamSync needs domain information before the users\n");
- return False;
+ return false;
}
r.in.domain_handle = samsync_state->domain_handle[database_id];
@@ -430,7 +431,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
nt_status = dcerpc_samr_OpenUser(samsync_state->p_samr, mem_ctx, &r);
if (!NT_STATUS_IS_OK(nt_status)) {
printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(nt_status));
- return False;
+ return false;
}
q.in.user_handle = &user_handle;
@@ -442,7 +443,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
if (!NT_STATUS_IS_OK(nt_status)) {
printf("QueryUserInfo level %u failed - %s\n",
q.in.level, nt_errstr(nt_status));
- ret = False;
+ ret = false;
}
getgroups.in.user_handle = &user_handle;
@@ -451,22 +452,22 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
if (!NT_STATUS_IS_OK(nt_status)) {
printf("GetGroupsForUser failed - %s\n",
nt_errstr(nt_status));
- ret = False;
+ ret = false;
}
if (!test_samr_handle_Close(samsync_state->p_samr, mem_ctx, &user_handle)) {
printf("samr_handle_Close failed - %s\n",
nt_errstr(nt_status));
- ret = False;
+ ret = false;
}
if (!ret) {
- return False;
+ return false;
}
if (!NT_STATUS_IS_OK(nt_status)) {
printf("QueryUserInfo level %u failed - %s\n",
q.in.level, nt_errstr(nt_status));
- return False;
+ return false;
}
TEST_STRING_EQUAL(q.out.info->info21.account_name, user->account_name);
@@ -489,7 +490,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
if (memcmp(q.out.info->info21.logon_hours.bits, user->logon_hours.bits,
q.out.info->info21.logon_hours.units_per_week/8) != 0) {
printf("Logon hours mismatch\n");
- ret = False;
+ ret = false;
}
}
@@ -507,7 +508,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
if (user->acct_flags & ACB_PWNOEXP) {
if (q.out.info->info21.acct_flags & ACB_PW_EXPIRED) {
printf("ACB flags mismatch: both expired and no expiry!\n");
- ret = False;
+ ret = false;
}
if (q.out.info->info21.force_password_change != (NTTIME)0x7FFFFFFFFFFFFFFFULL) {
printf("ACB flags mismatch: no password expiry, but force password change 0x%016llx (%lld) != 0x%016llx (%lld)\n",
@@ -515,7 +516,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
(unsigned long long)q.out.info->info21.force_password_change,
(unsigned long long)0x7FFFFFFFFFFFFFFFULL, (unsigned long long)0x7FFFFFFFFFFFFFFFULL
);
- ret = False;
+ ret = false;
}
}
@@ -561,7 +562,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
#if 0
dump_data(0, data.data, data.length);
#endif
- return False;
+ return false;
}
}
@@ -584,39 +585,39 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
if (NT_STATUS_EQUAL(nt_status, NT_STATUS_ACCOUNT_DISABLED)) {
if (user->acct_flags & ACB_DISABLED) {
- return True;
+ return true;
}
} else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT)) {
if (user->acct_flags & ACB_WSTRUST) {
- return True;
+ return true;
}
} else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT)) {
if (user->acct_flags & ACB_SVRTRUST) {
- return True;
+ return true;
}
} else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT)) {
if (user->acct_flags & ACB_DOMTRUST) {
- return True;
+ return true;
}
} else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT)) {
if (user->acct_flags & ACB_DOMTRUST) {
- return True;
+ return true;
}
} else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_ACCOUNT_LOCKED_OUT)) {
if (user->acct_flags & ACB_AUTOLOCK) {
- return True;
+ return true;
}
} else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_PASSWORD_EXPIRED)) {
if (q.out.info->info21.acct_flags & ACB_PW_EXPIRED) {
- return True;
+ return true;
}
} else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD)) {
if (!lm_hash_p && !nt_hash_p) {
- return True;
+ return true;
}
} else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_PASSWORD_MUST_CHANGE)) {
/* We would need to know the server's current time to test this properly */
- return True;
+ return true;
} else if (NT_STATUS_IS_OK(nt_status)) {
TEST_INT_EQUAL(user->rid, info3->base.rid);
TEST_INT_EQUAL(user->primary_gid, info3->base.primary_gid);
@@ -659,7 +660,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
if (getgroups.out.rids->count == info3->base.groups.count) {
int i, j;
int count = getgroups.out.rids->count;
- BOOL *matched = talloc_zero_array(mem_ctx, BOOL, getgroups.out.rids->count);
+ bool *matched = talloc_zero_array(mem_ctx, bool, getgroups.out.rids->count);
for (i = 0; i < count; i++) {
for (j = 0; j < count; j++) {
@@ -667,14 +668,14 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
info3->base.groups.rids[j].rid)
&& (getgroups.out.rids->rids[i].attributes ==
info3->base.groups.rids[j].attributes)) {
- matched[i] = True;
+ matched[i] = true;
}
}
}
for (i = 0; i < getgroups.out.rids->count; i++) {
- if (matched[i] == False) {
- ret = False;
+ if (matched[i] == false) {
+ ret = false;
printf("Could not find group RID %u found in getgroups in NETLOGON reply\n",
getgroups.out.rids->rids[i].rid);
}
@@ -684,18 +685,18 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
} else {
printf("Could not validate password for user %s\\%s: %s\n",
domain, username, nt_errstr(nt_status));
- return False;
+ return false;
}
- return False;
+ return false;
}
-static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
+static bool samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
int database_id, struct netr_DELTA_ENUM *delta)
{
uint32_t rid = delta->delta_id_union.rid;
struct netr_DELTA_ALIAS *alias = delta->delta_union.alias;
NTSTATUS nt_status;
- BOOL ret = True;
+ bool ret = true;
struct samr_OpenAlias r;
struct samr_QueryAliasInfo q;
@@ -703,7 +704,7 @@ static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *sams
if (!samsync_state->domain_name || !samsync_state->domain_handle[database_id]) {
printf("SamSync needs domain information before the users\n");
- return False;
+ return false;
}
r.in.domain_handle = samsync_state->domain_handle[database_id];
@@ -714,7 +715,7 @@ static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *sams
nt_status = dcerpc_samr_OpenAlias(samsync_state->p_samr, mem_ctx, &r);
if (!NT_STATUS_IS_OK(nt_status)) {
printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(nt_status));
- return False;
+ return false;
}
q.in.alias_handle = &alias_handle;
@@ -724,13 +725,13 @@ static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *sams
nt_status = dcerpc_samr_QueryAliasInfo(samsync_state->p_samr, mem_ctx, &q);
if (!test_samr_handle_Close(samsync_state->p_samr, mem_ctx, &alias_handle)) {
- return False;
+ return false;
}
if (!NT_STATUS_IS_OK(nt_status)) {
printf("QueryAliasInfo level %u failed - %s\n",
q.in.level, nt_errstr(nt_status));
- return False;
+ return false;
}
TEST_STRING_EQUAL(q.out.info->all.name, alias->alias_name);
@@ -738,13 +739,13 @@ static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *sams
return ret;
}
-static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
+static bool samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
int database_id, struct netr_DELTA_ENUM *delta)
{
uint32_t rid = delta->delta_id_union.rid;
struct netr_DELTA_GROUP *group = delta->delta_union.group;
NTSTATUS nt_status;
- BOOL ret = True;
+ bool ret = true;
struct samr_OpenGroup r;
struct samr_QueryGroupInfo q;
@@ -752,7 +753,7 @@ static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *sams
if (!samsync_state->domain_name || !samsync_state->domain_handle[database_id]) {
printf("SamSync needs domain information before the users\n");
- return False;
+ return false;
}
r.in.domain_handle = samsync_state->domain_handle[database_id];
@@ -763,7 +764,7 @@ static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *sams
nt_status = dcerpc_samr_OpenGroup(samsync_state->p_samr, mem_ctx, &r);
if (!NT_STATUS_IS_OK(nt_status)) {
printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(nt_status));
- return False;
+ return false;
}
q.in.group_handle = &group_handle;
@@ -773,13 +774,13 @@ static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *sams
nt_status = dcerpc_samr_QueryGroupInfo(samsync_state->p_samr, mem_ctx, &q);
if (!test_samr_handle_Close(samsync_state->p_samr, mem_ctx, &group_handle)) {
- return False;
+ return false;
}
if (!NT_STATUS_IS_OK(nt_status)) {
printf("QueryGroupInfo level %u failed - %s\n",
q.in.level, nt_errstr(nt_status));
- return False;
+ return false;
}
TEST_STRING_EQUAL(q.out.info->all.name, group->group_name);
@@ -788,7 +789,7 @@ static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *sams
return ret;
}
-static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
+static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
int database_id, struct netr_DELTA_ENUM *delta)
{
struct netr_DELTA_SECRET *secret = delta->delta_union.secret;
@@ -802,7 +803,7 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam
struct lsa_DATA_BUF_PTR bufp2;
NTTIME new_mtime;
NTTIME old_mtime;
- BOOL ret = True;
+ bool ret = true;
DATA_BLOB lsa_blob1, lsa_blob_out, session_key;
NTSTATUS status;
@@ -831,7 +832,7 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam
status = dcerpc_lsa_OpenSecret(samsync_state->p_lsa, mem_ctx, &o);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenSecret failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
/*
@@ -841,7 +842,7 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam
status = dcerpc_fetch_session_key(samsync_state->p_lsa, &session_key);
if (!NT_STATUS_IS_OK(status)) {
printf("dcerpc_fetch_session_key failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
@@ -861,10 +862,10 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam
status = dcerpc_lsa_QuerySecret(samsync_state->p_lsa, mem_ctx, &q);
if (NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) {
/* some things are just off limits */
- return True;
+ return true;
} else if (!NT_STATUS_IS_OK(status)) {
printf("QuerySecret failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (q.out.old_val->buf == NULL) {
@@ -876,24 +877,24 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam
status = sess_decrypt_blob(mem_ctx, &lsa_blob1, &session_key, &lsa_blob_out);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to decrypt secrets OLD blob: %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!q.out.old_mtime) {
printf("OLD mtime not available on LSA for secret %s\n", old->name);
- ret = False;
+ ret = false;
}
if (old->mtime != *q.out.old_mtime) {
printf("OLD mtime on secret %s does not match between SAMSYNC (%s) and LSA (%s)\n",
old->name, nt_time_string(mem_ctx, old->mtime),
nt_time_string(mem_ctx, *q.out.old_mtime));
- ret = False;
+ ret = false;
}
if (old->secret.length != lsa_blob_out.length) {
printf("Returned secret %s doesn't match: %d != %d\n",
old->name, (int)old->secret.length, (int)lsa_blob_out.length);
- ret = False;
+ ret = false;
} else if (memcmp(lsa_blob_out.data,
old->secret.data, old->secret.length) != 0) {
printf("Returned secret %s doesn't match: \n",
@@ -902,7 +903,7 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam
dump_data(1, old->secret.data, old->secret.length);
DEBUG(1, ("LSA Secret:\n"));
dump_data(1, lsa_blob_out.data, lsa_blob_out.length);
- ret = False;
+ ret = false;
}
}
@@ -916,24 +917,24 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam
status = sess_decrypt_blob(mem_ctx, &lsa_blob1, &session_key, &lsa_blob_out);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to decrypt secrets OLD blob\n");
- return False;
+ return false;
}
if (!q.out.new_mtime) {
printf("NEW mtime not available on LSA for secret %s\n", new->name);
- ret = False;
+ ret = false;
}
if (new->mtime != *q.out.new_mtime) {
printf("NEW mtime on secret %s does not match between SAMSYNC (%s) and LSA (%s)\n",
new->name, nt_time_string(mem_ctx, new->mtime),
nt_time_string(mem_ctx, *q.out.new_mtime));
- ret = False;
+ ret = false;
}
if (new->secret.length != lsa_blob_out.length) {
printf("Returned secret %s doesn't match: %d != %d\n",
new->name, (int)new->secret.length, (int)lsa_blob_out.length);
- ret = False;
+ ret = false;
} else if (memcmp(lsa_blob_out.data,
new->secret.data, new->secret.length) != 0) {
printf("Returned secret %s doesn't match: \n",
@@ -942,18 +943,18 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam
dump_data(1, new->secret.data, new->secret.length);
DEBUG(1, ("LSA Secret:\n"));
dump_data(1, lsa_blob_out.data, lsa_blob_out.length);
- ret = False;
+ ret = false;
}
}
return ret;
}
-static BOOL samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
+static bool samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
int database_id, struct netr_DELTA_ENUM *delta)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct netr_DELTA_TRUSTED_DOMAIN *trusted_domain = delta->delta_union.trusted_domain;
struct dom_sid *dom_sid = delta->delta_id_union.sid;
@@ -976,7 +977,7 @@ static BOOL samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st
status = dcerpc_lsa_OpenTrustedDomain(samsync_state->p_lsa, mem_ctx, &t);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenTrustedDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
for (i=0; i< ARRAY_SIZE(levels); i++) {
@@ -990,7 +991,7 @@ static BOOL samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st
}
printf("QueryInfoTrustedDomain level %d failed - %s\n",
levels[i], nt_errstr(status));
- return False;
+ return false;
}
info[levels[i]] = q.out.info;
}
@@ -1011,11 +1012,11 @@ static BOOL samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st
return ret;
}
-static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
+static bool samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
int database_id, struct netr_DELTA_ENUM *delta)
{
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct netr_DELTA_ACCOUNT *account = delta->delta_union.account;
struct dom_sid *dom_sid = delta->delta_id_union.sid;
@@ -1026,7 +1027,7 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa
int i, j;
- BOOL *found_priv_in_lsa;
+ bool *found_priv_in_lsa;
a.in.handle = samsync_state->lsa_handle;
a.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -1036,31 +1037,31 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa
status = dcerpc_lsa_OpenAccount(samsync_state->p_lsa, mem_ctx, &a);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenTrustedDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
TEST_SEC_DESC_EQUAL(account->sdbuf, lsa, &acct_handle);
- found_priv_in_lsa = talloc_zero_array(mem_ctx, BOOL, account->privilege_entries);
+ found_priv_in_lsa = talloc_zero_array(mem_ctx, bool, account->privilege_entries);
e.in.handle = &acct_handle;
status = dcerpc_lsa_EnumPrivsAccount(samsync_state->p_lsa, mem_ctx, &e);
if (!NT_STATUS_IS_OK(status)) {
printf("EnumPrivsAccount failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if ((account->privilege_entries && !e.out.privs)) {
printf("Account %s has privileges in SamSync, but not LSA\n",
dom_sid_string(mem_ctx, dom_sid));
- return False;
+ return false;
}
if (!account->privilege_entries && e.out.privs && e.out.privs->count) {
printf("Account %s has privileges in LSA, but not SamSync\n",
dom_sid_string(mem_ctx, dom_sid));
- return False;
+ return false;
}
TEST_INT_EQUAL(account->privilege_entries, e.out.privs->count);
@@ -1072,16 +1073,16 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa
status = dcerpc_lsa_LookupPrivName(samsync_state->p_lsa, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("\nLookupPrivName failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (!r.out.name) {
printf("\nLookupPrivName failed to return a name\n");
- return False;
+ return false;
}
for (j=0;j<account->privilege_entries; j++) {
if (strcmp(r.out.name->string, account->privilege_name[j].string) == 0) {
- found_priv_in_lsa[j] = True;
+ found_priv_in_lsa[j] = true;
break;
}
}
@@ -1090,7 +1091,7 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa
if (!found_priv_in_lsa[j]) {
printf("Privilage %s on account %s not found in LSA\n", account->privilege_name[j].string,
dom_sid_string(mem_ctx, dom_sid));
- ret = False;
+ ret = false;
}
}
return ret;
@@ -1099,7 +1100,7 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa
/*
try a netlogon DatabaseSync
*/
-static BOOL test_DatabaseSync(struct samsync_state *samsync_state,
+static bool test_DatabaseSync(struct samsync_state *samsync_state,
TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
@@ -1107,7 +1108,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state,
struct netr_DatabaseSync r;
const enum netr_SamDatabaseID database_ids[] = {SAM_DATABASE_DOMAIN, SAM_DATABASE_BUILTIN, SAM_DATABASE_PRIVS};
int i, d;
- BOOL ret = True;
+ bool ret = true;
struct samsync_trusted_domain *t;
struct samsync_secret *s;
@@ -1132,7 +1133,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state,
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
printf("DatabaseSync - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
break;
}
@@ -1149,56 +1150,56 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state,
if (!samsync_handle_domain(delta_ctx, samsync_state,
r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) {
printf("Failed to handle DELTA_DOMAIN\n");
- ret = False;
+ ret = false;
}
break;
case NETR_DELTA_GROUP:
if (!samsync_handle_group(delta_ctx, samsync_state,
r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) {
printf("Failed to handle DELTA_USER\n");
- ret = False;
+ ret = false;
}
break;
case NETR_DELTA_USER:
if (!samsync_handle_user(delta_ctx, samsync_state,
r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) {
printf("Failed to handle DELTA_USER\n");
- ret = False;
+ ret = false;
}
break;
case NETR_DELTA_ALIAS:
if (!samsync_handle_alias(delta_ctx, samsync_state,
r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) {
printf("Failed to handle DELTA_ALIAS\n");
- ret = False;
+ ret = false;
}
break;
case NETR_DELTA_POLICY:
if (!samsync_handle_policy(delta_ctx, samsync_state,
r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) {
printf("Failed to handle DELTA_POLICY\n");
- ret = False;
+ ret = false;
}
break;
case NETR_DELTA_TRUSTED_DOMAIN:
if (!samsync_handle_trusted_domain(delta_ctx, samsync_state,
r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) {
printf("Failed to handle DELTA_TRUSTED_DOMAIN\n");
- ret = False;
+ ret = false;
}
break;
case NETR_DELTA_ACCOUNT:
if (!samsync_handle_account(delta_ctx, samsync_state,
r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) {
printf("Failed to handle DELTA_ACCOUNT\n");
- ret = False;
+ ret = false;
}
break;
case NETR_DELTA_SECRET:
if (!samsync_handle_secret(delta_ctx, samsync_state,
r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) {
printf("Failed to handle DELTA_SECRET\n");
- ret = False;
+ ret = false;
}
break;
case NETR_DELTA_GROUP_MEMBER:
@@ -1219,7 +1220,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state,
case NETR_DELTA_MODIFY_COUNT:
default:
printf("Uxpected delta type %d\n", r.out.delta_enum_array->delta_enum[d].delta_type);
- ret = False;
+ ret = false;
break;
}
talloc_free(delta_ctx);
@@ -1232,7 +1233,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state,
domain = samsync_state->domain_name[SAM_DATABASE_DOMAIN];
if (!domain) {
printf("Never got a DOMAIN object in samsync!\n");
- return False;
+ return false;
}
trustdom_ctx = talloc_named(mem_ctx, 0, "test_DatabaseSync Trusted domains context");
@@ -1263,7 +1264,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state,
if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT)) {
printf("Verifiction of trust password to %s: should have failed (nologon interdomain trust account), instead: %s\n",
t->name, nt_errstr(nt_status));
- ret = False;
+ ret = false;
}
/* break it */
@@ -1279,7 +1280,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state,
if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD)) {
printf("Verifiction of trust password to %s: should have failed (wrong password), instead: %s\n",
t->name, nt_errstr(nt_status));
- ret = False;
+ ret = false;
}
break;
@@ -1294,14 +1295,14 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state,
/*
try a netlogon DatabaseDeltas
*/
-static BOOL test_DatabaseDeltas(struct samsync_state *samsync_state, TALLOC_CTX *mem_ctx)
+static bool test_DatabaseDeltas(struct samsync_state *samsync_state, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
TALLOC_CTX *loop_ctx;
struct netr_DatabaseDeltas r;
const uint32_t database_ids[] = {0, 1, 2};
int i;
- BOOL ret = True;
+ bool ret = true;
r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(samsync_state->p));
r.in.computername = TEST_MACHINE_NAME;
@@ -1333,7 +1334,7 @@ static BOOL test_DatabaseDeltas(struct samsync_state *samsync_state, TALLOC_CTX
!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES) &&
!NT_STATUS_EQUAL(status, NT_STATUS_SYNCHRONIZATION_REQUIRED)) {
printf("DatabaseDeltas - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
if (!creds_client_check(samsync_state->creds, &r.out.return_authenticator.cred)) {
@@ -1352,7 +1353,7 @@ static BOOL test_DatabaseDeltas(struct samsync_state *samsync_state, TALLOC_CTX
/*
try a netlogon DatabaseSync2
*/
-static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct creds_CredentialState *creds)
{
NTSTATUS status;
@@ -1360,7 +1361,7 @@ static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct netr_DatabaseSync2 r;
const uint32_t database_ids[] = {0, 1, 2};
int i;
- BOOL ret = True;
+ bool ret = true;
r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
r.in.computername = TEST_MACHINE_NAME;
@@ -1382,7 +1383,7 @@ static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
printf("DatabaseSync2 - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
if (!creds_client_check(creds, &r.out.return_authenticator.cred)) {
@@ -1399,11 +1400,11 @@ static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
-BOOL torture_rpc_samsync(struct torture_context *torture)
+bool torture_rpc_samsync(struct torture_context *torture)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct test_join *join_ctx;
struct test_join *join_ctx2;
struct test_join *user_ctx;
@@ -1430,30 +1431,30 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
mem_ctx = talloc_init("torture_rpc_netlogon");
test_machine_account = talloc_asprintf(mem_ctx, "%s$", TEST_MACHINE_NAME);
- join_ctx = torture_create_testuser(torture, test_machine_account, lp_workgroup(), ACB_SVRTRUST,
+ join_ctx = torture_create_testuser(torture, test_machine_account,
+ lp_workgroup(global_loadparm), ACB_SVRTRUST,
&machine_password);
if (!join_ctx) {
talloc_free(mem_ctx);
printf("Failed to join as BDC\n");
- return False;
+ return false;
}
test_wksta_machine_account = talloc_asprintf(mem_ctx, "%s$", TEST_WKSTA_MACHINE_NAME);
- join_ctx2 = torture_create_testuser(torture, test_wksta_machine_account, lp_workgroup(), ACB_WSTRUST,
- &wksta_machine_password);
+ join_ctx2 = torture_create_testuser(torture, test_wksta_machine_account, lp_workgroup(global_loadparm), ACB_WSTRUST, &wksta_machine_password);
if (!join_ctx2) {
talloc_free(mem_ctx);
printf("Failed to join as member\n");
- return False;
+ return false;
}
user_ctx = torture_create_testuser(torture, TEST_USER_NAME,
- lp_workgroup(),
+ lp_workgroup(global_loadparm),
ACB_NORMAL, NULL);
if (!user_ctx) {
talloc_free(mem_ctx);
printf("Failed to create test account\n");
- return False;
+ return false;
}
samsync_state = talloc_zero(mem_ctx, struct samsync_state);
@@ -1468,14 +1469,14 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
status = dcerpc_samr_Connect(samsync_state->p_samr, mem_ctx, &c);
if (!NT_STATUS_IS_OK(status)) {
printf("samr_Connect failed\n");
- ret = False;
+ ret = false;
goto failed;
}
- domain_policy = samsync_open_domain(mem_ctx, samsync_state, lp_workgroup(), NULL);
+ domain_policy = samsync_open_domain(mem_ctx, samsync_state, lp_workgroup(global_loadparm), NULL);
if (!domain_policy) {
printf("samrsync_open_domain failed\n");
- ret = False;
+ ret = false;
goto failed;
}
@@ -1490,14 +1491,14 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
status = dcerpc_samr_SetDomainInfo(samsync_state->p_samr, mem_ctx, &s);
if (!test_samr_handle_Close(samsync_state->p_samr, mem_ctx, domain_policy)) {
- ret = False;
+ ret = false;
goto failed;
}
if (!NT_STATUS_IS_OK(status)) {
printf("SetDomainInfo level %u failed - %s\n",
s.in.level, nt_errstr(status));
- ret = False;
+ ret = false;
goto failed;
}
@@ -1507,7 +1508,7 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
&ndr_table_lsarpc);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto failed;
}
@@ -1531,13 +1532,13 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
status = dcerpc_lsa_OpenPolicy2(samsync_state->p_lsa, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenPolicy2 failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto failed;
}
status = torture_rpc_binding(torture, &b);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto failed;
}
@@ -1547,7 +1548,7 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
credentials = cli_credentials_init(mem_ctx);
cli_credentials_set_workstation(credentials, TEST_MACHINE_NAME, CRED_SPECIFIED);
- cli_credentials_set_domain(credentials, lp_workgroup(), CRED_SPECIFIED);
+ cli_credentials_set_domain(credentials, lp_workgroup(global_loadparm), CRED_SPECIFIED);
cli_credentials_set_username(credentials, test_machine_account, CRED_SPECIFIED);
cli_credentials_set_password(credentials, machine_password, CRED_SPECIFIED);
cli_credentials_set_secure_channel_type(credentials,
@@ -1560,21 +1561,21 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto failed;
}
status = dcerpc_schannel_creds(samsync_state->p->conn->security_state.generic_state,
samsync_state, &samsync_state->creds);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
}
status = torture_rpc_binding(torture, &b_netlogon_wksta);
if (!NT_STATUS_IS_OK(status)) {
- ret = False;
+ ret = false;
goto failed;
}
@@ -1584,7 +1585,7 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
credentials_wksta = cli_credentials_init(mem_ctx);
cli_credentials_set_workstation(credentials_wksta, TEST_WKSTA_MACHINE_NAME, CRED_SPECIFIED);
- cli_credentials_set_domain(credentials_wksta, lp_workgroup(), CRED_SPECIFIED);
+ cli_credentials_set_domain(credentials_wksta, lp_workgroup(global_loadparm), CRED_SPECIFIED);
cli_credentials_set_username(credentials_wksta, test_wksta_machine_account, CRED_SPECIFIED);
cli_credentials_set_password(credentials_wksta, wksta_machine_password, CRED_SPECIFIED);
cli_credentials_set_secure_channel_type(credentials_wksta,
@@ -1598,7 +1599,7 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
goto failed;
}
@@ -1606,22 +1607,22 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
samsync_state, &samsync_state->creds_netlogon_wksta);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to obtail schanel creds!\n");
- ret = False;
+ ret = false;
}
if (!test_DatabaseSync(samsync_state, mem_ctx)) {
printf("DatabaseSync failed\n");
- ret = False;
+ ret = false;
}
if (!test_DatabaseDeltas(samsync_state, mem_ctx)) {
printf("DatabaseDeltas failed\n");
- ret = False;
+ ret = false;
}
if (!test_DatabaseSync2(samsync_state->p, mem_ctx, samsync_state->creds)) {
printf("DatabaseSync2 failed\n");
- ret = False;
+ ret = false;
}
failed:
diff --git a/source4/torture/rpc/scanner.c b/source4/torture/rpc/scanner.c
index b2dd99fd66..630e9cf1e4 100644
--- a/source4/torture/rpc/scanner.c
+++ b/source4/torture/rpc/scanner.c
@@ -24,11 +24,12 @@
#include "librpc/gen_ndr/ndr_mgmt_c.h"
#include "librpc/ndr/ndr_table.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
/*
work out how many calls there are for an interface
*/
-static BOOL test_num_calls(struct torture_context *tctx,
+static bool test_num_calls(struct torture_context *tctx,
const struct ndr_interface_table *iface,
TALLOC_CTX *mem_ctx,
struct ndr_syntax_id *id)
@@ -51,7 +52,7 @@ static BOOL test_num_calls(struct torture_context *tctx,
printf("Failed to connect to '%s' on '%s' - %s\n",
uuid_str, iface->name, nt_errstr(status));
talloc_free(uuid_str);
- return True;
+ return true;
}
/* make null calls */
@@ -59,7 +60,7 @@ static BOOL test_num_calls(struct torture_context *tctx,
memset(stub_in.data, 0xFF, stub_in.length);
for (i=0;i<200;i++) {
- status = dcerpc_request(p, NULL, i, False, mem_ctx, &stub_in, &stub_out);
+ status = dcerpc_request(p, NULL, i, false, mem_ctx, &stub_in, &stub_out);
if (!NT_STATUS_IS_OK(status) &&
p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) {
break;
@@ -88,30 +89,27 @@ static BOOL test_num_calls(struct torture_context *tctx,
done:
talloc_free(p);
- return True;
+ return true;
}
-BOOL torture_rpc_scanner(struct torture_context *torture)
+bool torture_rpc_scanner(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx, *loop_ctx;
- BOOL ret = True;
+ TALLOC_CTX *loop_ctx;
+ bool ret = true;
const struct ndr_interface_list *l;
struct dcerpc_binding *b;
- mem_ctx = talloc_init("torture_rpc_scanner");
-
status = torture_rpc_binding(torture, &b);
if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- return False;
+ return false;
}
for (l=ndr_table_list();l;l=l->next) {
- loop_ctx = talloc_named(mem_ctx, 0, "torture_rpc_scanner loop context");
+ loop_ctx = talloc_named(torture, 0, "torture_rpc_scanner loop context");
/* some interfaces are not mappable */
if (l->table->num_calls == 0 ||
strcmp(l->table->name, "mgmt") == 0) {
@@ -122,7 +120,7 @@ BOOL torture_rpc_scanner(struct torture_context *torture)
printf("\nTesting pipe '%s'\n", l->table->name);
if (b->transport == NCACN_IP_TCP) {
- status = dcerpc_epm_map_binding(mem_ctx, b, l->table, NULL);
+ status = dcerpc_epm_map_binding(torture, b, l->table, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to map port for uuid %s\n",
GUID_string(loop_ctx, &l->table->syntax_id.uuid));
@@ -133,17 +131,17 @@ BOOL torture_rpc_scanner(struct torture_context *torture)
b->endpoint = talloc_strdup(b, l->table->name);
}
- lp_set_cmdline("torture:binding", dcerpc_binding_string(mem_ctx, b));
+ lp_set_cmdline(global_loadparm, "torture:binding", dcerpc_binding_string(torture, b));
status = torture_rpc_connection(torture, &p, &ndr_table_mgmt);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(loop_ctx);
- ret = False;
+ ret = false;
continue;
}
- if (!test_inq_if_ids(torture, p, mem_ctx, test_num_calls, l->table)) {
- ret = False;
+ if (!test_inq_if_ids(torture, p, torture, test_num_calls, l->table)) {
+ ret = false;
}
}
diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c
index e072e592d1..a1a83c69d7 100644
--- a/source4/torture/rpc/schannel.c
+++ b/source4/torture/rpc/schannel.c
@@ -30,13 +30,14 @@
#include "libcli/auth/libcli_auth.h"
#include "libcli/security/security.h"
#include "system/filesys.h"
+#include "param/param.h"
#define TEST_MACHINE_NAME "schannel"
/*
try a netlogon SamLogon
*/
-BOOL test_netlogon_ex_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_netlogon_ex_ops(struct dcerpc_pipe *p, struct torture_context *tctx,
struct cli_credentials *credentials,
struct creds_CredentialState *creds)
{
@@ -45,17 +46,16 @@ BOOL test_netlogon_ex_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct netr_NetworkInfo ninfo;
DATA_BLOB names_blob, chal, lm_resp, nt_resp;
int i;
- BOOL ret = True;
int flags = CLI_CRED_NTLM_AUTH;
- if (lp_client_lanman_auth()) {
+ if (lp_client_lanman_auth(global_loadparm)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
- if (lp_client_ntlmv2_auth()) {
+ if (lp_client_ntlmv2_auth(global_loadparm)) {
flags |= CLI_CRED_NTLMv2_AUTH;
}
- cli_credentials_get_ntlm_username_domain(cmdline_credentials, mem_ctx,
+ cli_credentials_get_ntlm_username_domain(cmdline_credentials, tctx,
&ninfo.identity_info.account_name.string,
&ninfo.identity_info.domain_name.string);
@@ -64,20 +64,17 @@ BOOL test_netlogon_ex_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
chal = data_blob_const(ninfo.challenge,
sizeof(ninfo.challenge));
- names_blob = NTLMv2_generate_names_blob(mem_ctx, cli_credentials_get_workstation(credentials),
+ names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials),
cli_credentials_get_domain(credentials));
- status = cli_credentials_get_ntlm_response(cmdline_credentials, mem_ctx,
+ status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx,
&flags,
chal,
names_blob,
&lm_resp, &nt_resp,
NULL, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- printf("cli_credentials_get_ntlm_response failed: %s\n",
- nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status,
+ "cli_credentials_get_ntlm_response failed");
ninfo.lm.data = lm_resp.data;
ninfo.lm.length = lm_resp.length;
@@ -90,32 +87,31 @@ BOOL test_netlogon_ex_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
ninfo.identity_info.logon_id_high = 0;
ninfo.identity_info.workstation.string = cli_credentials_get_workstation(credentials);
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.computer_name = cli_credentials_get_workstation(credentials);
r.in.logon_level = 2;
r.in.logon.network = &ninfo;
r.in.flags = 0;
- printf("Testing LogonSamLogonEx with name %s\n", ninfo.identity_info.account_name.string);
+ torture_comment(tctx,
+ "Testing LogonSamLogonEx with name %s\n",
+ ninfo.identity_info.account_name.string);
for (i=2;i<3;i++) {
r.in.validation_level = i;
- status = dcerpc_netr_LogonSamLogonEx(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LogonSamLogon failed: %s\n",
- nt_errstr(status));
- return False;
- }
+ status = dcerpc_netr_LogonSamLogonEx(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "LogonSamLogon failed");
}
- return ret;
+ return true;
}
/*
do some samr ops using the schannel connection
*/
-static BOOL test_samr_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_samr_ops(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct samr_GetDomPwInfo r;
@@ -126,7 +122,7 @@ static BOOL test_samr_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
struct policy_handle handle;
struct policy_handle domain_handle;
- name.string = lp_workgroup();
+ name.string = lp_workgroup(global_loadparm);
r.in.domain_name = &name;
connect.in.system_name = 0;
@@ -135,25 +131,25 @@ static BOOL test_samr_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
printf("Testing Connect and OpenDomain on BUILTIN\n");
- status = dcerpc_samr_Connect(p, mem_ctx, &connect);
+ status = dcerpc_samr_Connect(p, tctx, &connect);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
printf("Connect failed (expected, schannel mapped to anonymous): %s\n",
nt_errstr(status));
} else {
printf("Connect failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
} else {
opendom.in.connect_handle = &handle;
opendom.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- opendom.in.sid = dom_sid_parse_talloc(mem_ctx, "S-1-5-32");
+ opendom.in.sid = dom_sid_parse_talloc(tctx, "S-1-5-32");
opendom.out.domain_handle = &domain_handle;
- status = dcerpc_samr_OpenDomain(p, mem_ctx, &opendom);
+ status = dcerpc_samr_OpenDomain(p, tctx, &opendom);
if (!NT_STATUS_IS_OK(status)) {
printf("OpenDomain failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
}
@@ -161,27 +157,27 @@ static BOOL test_samr_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
/* do several ops to test credential chaining */
for (i=0;i<5;i++) {
- status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r);
+ status = dcerpc_samr_GetDomPwInfo(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
printf("GetDomPwInfo op %d failed - %s\n", i, nt_errstr(status));
- return False;
+ return false;
}
}
}
- return True;
+ return true;
}
/*
do some lsa ops using the schannel connection
*/
-static BOOL test_lsa_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_lsa_ops(struct torture_context *tctx, struct dcerpc_pipe *p)
{
struct lsa_GetUserName r;
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
struct lsa_StringPointer authority_name_p;
printf("\nTesting GetUserName\n");
@@ -192,36 +188,36 @@ static BOOL test_lsa_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
authority_name_p.string = NULL;
/* do several ops to test credential chaining and various operations */
- status = dcerpc_lsa_GetUserName(p, mem_ctx, &r);
+ status = dcerpc_lsa_GetUserName(p, tctx, &r);
if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
printf("not considering %s to be an error\n", nt_errstr(status));
} else if (!NT_STATUS_IS_OK(status)) {
printf("GetUserName failed - %s\n", nt_errstr(status));
- return False;
+ return false;
} else {
if (!r.out.account_name) {
- return False;
+ return false;
}
if (strcmp(r.out.account_name->string, "ANONYMOUS LOGON") != 0) {
printf("GetUserName returned wrong user: %s, expected %s\n",
r.out.account_name->string, "ANONYMOUS LOGON");
- return False;
+ return false;
}
if (!r.out.authority_name || !r.out.authority_name->string) {
- return False;
+ return false;
}
if (strcmp(r.out.authority_name->string->string, "NT AUTHORITY") != 0) {
printf("GetUserName returned wrong user: %s, expected %s\n",
r.out.authority_name->string->string, "NT AUTHORITY");
- return False;
+ return false;
}
}
- if (!test_many_LookupSids(p, mem_ctx, NULL)) {
+ if (!test_many_LookupSids(p, tctx, NULL)) {
printf("LsaLookupSids3 failed!\n");
- return False;
+ return false;
}
return ret;
@@ -231,15 +227,13 @@ static BOOL test_lsa_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
/*
test a schannel connection with the given flags
*/
-static BOOL test_schannel(TALLOC_CTX *mem_ctx,
+static bool test_schannel(struct torture_context *tctx,
uint16_t acct_flags, uint32_t dcerpc_flags,
int i)
{
- BOOL ret = True;
-
struct test_join *join_ctx;
NTSTATUS status;
- const char *binding = lp_parm_string(-1, "torture", "binding");
+ const char *binding = lp_parm_string(global_loadparm, NULL, "torture", "binding");
struct dcerpc_binding *b;
struct dcerpc_pipe *p = NULL;
struct dcerpc_pipe *p_netlogon = NULL;
@@ -250,105 +244,71 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx,
struct creds_CredentialState *creds;
struct cli_credentials *credentials;
- TALLOC_CTX *test_ctx = talloc_named(mem_ctx, 0, "test_schannel context");
-
- join_ctx = torture_join_domain(talloc_asprintf(mem_ctx, "%s%d", TEST_MACHINE_NAME, i),
+ join_ctx = torture_join_domain(talloc_asprintf(tctx, "%s%d", TEST_MACHINE_NAME, i),
acct_flags, &credentials);
- if (!join_ctx) {
- printf("Failed to join domain with acct_flags=0x%x\n", acct_flags);
- talloc_free(test_ctx);
- return False;
- }
+ torture_assert(tctx, join_ctx != NULL, "Failed to join domain");
- status = dcerpc_parse_binding(test_ctx, binding, &b);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Bad binding string %s\n", binding);
- goto failed;
- }
+ status = dcerpc_parse_binding(tctx, binding, &b);
+ torture_assert_ntstatus_ok(tctx, status, "Bad binding string");
b->flags &= ~DCERPC_AUTH_OPTIONS;
b->flags |= dcerpc_flags;
- status = dcerpc_pipe_connect_b(test_ctx, &p, b, &ndr_table_samr,
+ status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr,
credentials, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect with schannel: %s\n", nt_errstr(status));
- goto failed;
- }
+ torture_assert_ntstatus_ok(tctx, status,
+ "Failed to connect with schannel");
- if (!test_samr_ops(p, test_ctx)) {
- printf("Failed to process schannel secured SAMR ops\n");
- ret = False;
- }
+ torture_assert(tctx, test_samr_ops(tctx, p),
+ "Failed to process schannel secured SAMR ops");
/* Also test that when we connect to the netlogon pipe, that
* the credentials we setup on the first pipe are valid for
* the second */
/* Swap the binding details from SAMR to NETLOGON */
- status = dcerpc_epm_map_binding(test_ctx, b, &ndr_table_netlogon, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL);
+ torture_assert_ntstatus_ok(tctx, status, "epm map");
status = dcerpc_secondary_connection(p, &p_netlogon,
b);
-
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ torture_assert_ntstatus_ok(tctx, status, "seconday connection");
status = dcerpc_bind_auth(p_netlogon, &ndr_table_netlogon,
credentials, DCERPC_AUTH_TYPE_SCHANNEL,
dcerpc_auth_level(p->conn),
NULL);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ torture_assert_ntstatus_ok(tctx, status, "bind auth");
- status = dcerpc_schannel_creds(p_netlogon->conn->security_state.generic_state, test_ctx, &creds);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ status = dcerpc_schannel_creds(p_netlogon->conn->security_state.generic_state, tctx, &creds);
+ torture_assert_ntstatus_ok(tctx, status, "schannel creds");
/* do a couple of logins */
- if (!test_netlogon_ops(p_netlogon, test_ctx, credentials, creds)) {
- printf("Failed to process schannel secured NETLOGON ops\n");
- ret = False;
- }
+ torture_assert(tctx, test_netlogon_ops(p_netlogon, tctx, credentials, creds),
+ "Failed to process schannel secured NETLOGON ops");
- if (!test_netlogon_ex_ops(p_netlogon, test_ctx, credentials, creds)) {
- printf("Failed to process schannel secured NETLOGON EX ops\n");
- ret = False;
- }
+ torture_assert(tctx, test_netlogon_ex_ops(p_netlogon, tctx, credentials, creds),
+ "Failed to process schannel secured NETLOGON EX ops");
/* Swap the binding details from SAMR to LSARPC */
- status = dcerpc_epm_map_binding(test_ctx, b, &ndr_table_lsarpc, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, NULL);
+ torture_assert_ntstatus_ok(tctx, status, "epm map");
status = dcerpc_secondary_connection(p, &p_lsa,
b);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ torture_assert_ntstatus_ok(tctx, status, "seconday connection");
status = dcerpc_bind_auth(p_lsa, &ndr_table_lsarpc,
credentials, DCERPC_AUTH_TYPE_SCHANNEL,
dcerpc_auth_level(p->conn),
NULL);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ torture_assert_ntstatus_ok(tctx, status, "bind auth");
- if (!test_lsa_ops(p_lsa, test_ctx)) {
- printf("Failed to process schannel secured LSA ops\n");
- ret = False;
- }
+ torture_assert(tctx, test_lsa_ops(tctx, p_lsa),
+ "Failed to process schannel secured LSA ops");
/* Drop the socket, we want to start from scratch */
talloc_free(p);
@@ -356,39 +316,28 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx,
/* Now see what we are still allowed to do */
- status = dcerpc_parse_binding(test_ctx, binding, &b);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Bad binding string %s\n", binding);
- goto failed;
- }
+ status = dcerpc_parse_binding(tctx, binding, &b);
+ torture_assert_ntstatus_ok(tctx, status, "Bad binding string");
b->flags &= ~DCERPC_AUTH_OPTIONS;
b->flags |= dcerpc_flags;
- status = dcerpc_pipe_connect_b(test_ctx, &p_samr2, b, &ndr_table_samr,
+ status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr,
credentials, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect with schannel: %s\n", nt_errstr(status));
- goto failed;
- }
+ torture_assert_ntstatus_ok(tctx, status,
+ "Failed to connect with schannel");
/* do a some SAMR operations. We have *not* done a new serverauthenticate */
- if (!test_samr_ops(p_samr2, test_ctx)) {
- printf("Failed to process schannel secured SAMR ops (on fresh connection)\n");
- goto failed;
- }
+ torture_assert (tctx, test_samr_ops(tctx, p_samr2),
+ "Failed to process schannel secured SAMR ops (on fresh connection)");
/* Swap the binding details from SAMR to NETLOGON */
- status = dcerpc_epm_map_binding(test_ctx, b, &ndr_table_netlogon, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL);
+ torture_assert_ntstatus_ok(tctx, status, "epm");
status = dcerpc_secondary_connection(p_samr2, &p_netlogon2,
b);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ torture_assert_ntstatus_ok(tctx, status, "seconday connection");
/* and now setup an SCHANNEL bind on netlogon */
status = dcerpc_bind_auth(p_netlogon2, &ndr_table_netlogon,
@@ -396,22 +345,17 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx,
dcerpc_auth_level(p_samr2->conn),
NULL);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
+ torture_assert_ntstatus_ok(tctx, status, "auth failed");
/* Try the schannel-only SamLogonEx operation */
- if (!test_netlogon_ex_ops(p_netlogon2, test_ctx, credentials, creds)) {
- printf("Failed to process schannel secured NETLOGON EX ops (on fresh connection)\n");
- ret = False;
- }
+ torture_assert(tctx, test_netlogon_ex_ops(p_netlogon2, tctx, credentials, creds),
+ "Failed to process schannel secured NETLOGON EX ops (on fresh connection)");
+
/* And the more traditional style, proving that the
* credentials chaining state is fully present */
- if (!test_netlogon_ops(p_netlogon2, test_ctx, credentials, creds)) {
- printf("Failed to process schannel secured NETLOGON ops (on fresh connection)\n");
- ret = False;
- }
+ torture_assert(tctx, test_netlogon_ops(p_netlogon2, tctx, credentials, creds),
+ "Failed to process schannel secured NETLOGON ops (on fresh connection)");
/* Drop the socket, we want to start from scratch (again) */
talloc_free(p_samr2);
@@ -419,31 +363,22 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx,
/* We don't want schannel for this test */
b->flags &= ~DCERPC_AUTH_OPTIONS;
- status = dcerpc_pipe_connect_b(test_ctx, &p_netlogon3, b, &ndr_table_netlogon,
+ status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon,
credentials, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect without schannel: %s\n", nt_errstr(status));
- goto failed;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
- if (test_netlogon_ex_ops(p_netlogon3, test_ctx, credentials, creds)) {
- printf("Processed NOT schannel secured NETLOGON EX ops without SCHANNEL (unsafe)\n");
- ret = False;
- }
+ torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds),
+ "Processed NOT schannel secured NETLOGON EX ops without SCHANNEL (unsafe)");
- if (!test_netlogon_ops(p_netlogon3, test_ctx, credentials, creds)) {
- printf("Failed to processed NOT schannel secured NETLOGON ops without new ServerAuth\n");
- ret = False;
- }
+ /* Required because the previous call will mark the current context as having failed */
+ tctx->last_result = TORTURE_OK;
+ tctx->last_reason = NULL;
- torture_leave_domain(join_ctx);
- talloc_free(test_ctx);
- return ret;
+ torture_assert(tctx, test_netlogon_ops(p_netlogon3, tctx, credentials, creds),
+ "Failed to processed NOT schannel secured NETLOGON ops without new ServerAuth");
-failed:
torture_leave_domain(join_ctx);
- talloc_free(test_ctx);
- return False;
+ return true;
}
@@ -451,10 +386,9 @@ failed:
/*
a schannel test suite
*/
-BOOL torture_rpc_schannel(struct torture_context *torture)
+bool torture_rpc_schannel(struct torture_context *torture)
{
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
+ bool ret = true;
struct {
uint16_t acct_flags;
uint32_t dcerpc_flags;
@@ -470,112 +404,77 @@ BOOL torture_rpc_schannel(struct torture_context *torture)
};
int i;
- mem_ctx = talloc_init("torture_rpc_schannel");
-
for (i=0;i<ARRAY_SIZE(tests);i++) {
- if (!test_schannel(mem_ctx,
+ if (!test_schannel(torture,
tests[i].acct_flags, tests[i].dcerpc_flags,
i)) {
- printf("Failed with acct_flags=0x%x dcerpc_flags=0x%x \n",
+ torture_comment(torture, "Failed with acct_flags=0x%x dcerpc_flags=0x%x \n",
tests[i].acct_flags, tests[i].dcerpc_flags);
- ret = False;
- break;
+ ret = false;
}
}
- talloc_free(mem_ctx);
-
return ret;
}
/*
test two schannel connections
*/
-BOOL torture_rpc_schannel2(struct torture_context *torture)
+bool torture_rpc_schannel2(struct torture_context *torture)
{
- BOOL ret = True;
- TALLOC_CTX *mem_ctx = talloc_new(torture);
struct test_join *join_ctx;
NTSTATUS status;
const char *binding = torture_setting_string(torture, "binding", NULL);
struct dcerpc_binding *b;
struct dcerpc_pipe *p1 = NULL, *p2 = NULL;
struct cli_credentials *credentials1, *credentials2;
- uint16_t acct_flags = ACB_WSTRUST;
uint32_t dcerpc_flags = DCERPC_SCHANNEL | DCERPC_SIGN;
- TALLOC_CTX *test_ctx = talloc_named(mem_ctx, 0, "test_schannel2 context");
-
- join_ctx = torture_join_domain(talloc_asprintf(mem_ctx, "%s2", TEST_MACHINE_NAME),
- acct_flags, &credentials1);
- if (!join_ctx) {
- printf("Failed to join domain with acct_flags=0x%x\n", acct_flags);
- talloc_free(test_ctx);
- return False;
- }
- credentials2 = talloc_memdup(mem_ctx, credentials1, sizeof(*credentials1));
+ join_ctx = torture_join_domain(talloc_asprintf(torture, "%s2", TEST_MACHINE_NAME),
+ ACB_WSTRUST, &credentials1);
+ torture_assert(torture, join_ctx != NULL,
+ "Failed to join domain with acct_flags=ACB_WSTRUST");
+
+ credentials2 = (struct cli_credentials *)talloc_memdup(torture, credentials1, sizeof(*credentials1));
credentials1->netlogon_creds = NULL;
credentials2->netlogon_creds = NULL;
- status = dcerpc_parse_binding(test_ctx, binding, &b);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Bad binding string %s\n", binding);
- goto failed;
- }
+ status = dcerpc_parse_binding(torture, binding, &b);
+ torture_assert_ntstatus_ok(torture, status, "Bad binding string");
b->flags &= ~DCERPC_AUTH_OPTIONS;
b->flags |= dcerpc_flags;
printf("Opening first connection\n");
- status = dcerpc_pipe_connect_b(test_ctx, &p1, b, &ndr_table_netlogon,
+ status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon,
credentials1, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect with schannel: %s\n", nt_errstr(status));
- goto failed;
- }
+ torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
- printf("Opening second connection\n");
- status = dcerpc_pipe_connect_b(test_ctx, &p2, b, &ndr_table_netlogon,
+ torture_comment(torture, "Opening second connection\n");
+ status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon,
credentials2, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect with schannel: %s\n", nt_errstr(status));
- goto failed;
- }
+ torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
credentials1->netlogon_creds = NULL;
credentials2->netlogon_creds = NULL;
- printf("Testing logon on pipe1\n");
- if (!test_netlogon_ex_ops(p1, test_ctx, credentials1, NULL)) {
- printf("Failed to process schannel secured NETLOGON ops\n");
- ret = False;
- }
-
- printf("Testing logon on pipe2\n");
- if (!test_netlogon_ex_ops(p2, test_ctx, credentials2, NULL)) {
- printf("Failed to process schannel secured NETLOGON ops\n");
- ret = False;
- }
+ torture_comment(torture, "Testing logon on pipe1\n");
+ if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL))
+ return false;
- printf("Again on pipe1\n");
- if (!test_netlogon_ex_ops(p1, test_ctx, credentials1, NULL)) {
- printf("Failed to process schannel secured NETLOGON ops\n");
- ret = False;
- }
+ torture_comment(torture, "Testing logon on pipe2\n");
+ if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL))
+ return false;
- printf("Again on pipe2\n");
- if (!test_netlogon_ex_ops(p2, test_ctx, credentials2, NULL)) {
- printf("Failed to process schannel secured NETLOGON ops\n");
- ret = False;
- }
+ torture_comment(torture, "Again on pipe1\n");
+ if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL))
+ return false;
- torture_leave_domain(join_ctx);
- talloc_free(test_ctx);
- return ret;
+ torture_comment(torture, "Again on pipe2\n");
+ if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL))
+ return false;
-failed:
torture_leave_domain(join_ctx);
- talloc_free(test_ctx);
- return False;
+ return true;
}
diff --git a/source4/torture/rpc/session_key.c b/source4/torture/rpc/session_key.c
index c4b31be8a7..69dc8da6c1 100644
--- a/source4/torture/rpc/session_key.c
+++ b/source4/torture/rpc/session_key.c
@@ -25,14 +25,16 @@
#include "libcli/auth/libcli_auth.h"
#include "torture/rpc/rpc.h"
+#include "lib/cmdline/popt_common.h"
+#include "param/param.h"
static void init_lsa_String(struct lsa_String *name, const char *s)
{
name->string = s;
}
-static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx,
+static bool test_CreateSecret_basic(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -44,7 +46,6 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p,
struct lsa_DATA_BUF buf1;
struct lsa_DATA_BUF_PTR bufp1;
DATA_BLOB enc_key;
- BOOL ret = True;
DATA_BLOB session_key;
NTTIME old_mtime, new_mtime;
DATA_BLOB blob1, blob2;
@@ -52,9 +53,9 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p,
char *secret2;
char *secname;
- secname = talloc_asprintf(mem_ctx, "torturesecret-%u", (uint_t)random());
+ secname = talloc_asprintf(tctx, "torturesecret-%u", (uint_t)random());
- printf("Testing CreateSecret of %s\n", secname);
+ torture_comment(tctx, "Testing CreateSecret of %s\n", secname);
init_lsa_String(&r.in.name, secname);
@@ -62,17 +63,11 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p,
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
r.out.sec_handle = &sec_handle;
- status = dcerpc_lsa_CreateSecret(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("CreateSecret failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_lsa_CreateSecret(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "CreateSecret failed");
status = dcerpc_fetch_session_key(p, &session_key);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_fetch_session_key failed - %s\n", nt_errstr(status));
- ret = False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_fetch_session_key failed");
enc_key = sess_encrypt_string(secret1, &session_key);
@@ -83,13 +78,10 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p,
r3.in.new_val->length = enc_key.length;
r3.in.new_val->size = enc_key.length;
- printf("Testing SetSecret\n");
+ torture_comment(tctx, "Testing SetSecret\n");
- status = dcerpc_lsa_SetSecret(p, mem_ctx, &r3);
- if (!NT_STATUS_IS_OK(status)) {
- printf("SetSecret failed - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_lsa_SetSecret(p, tctx, &r3);
+ torture_assert_ntstatus_ok(tctx, status, "SetSecret failed");
r3.in.sec_handle = &sec_handle;
r3.in.new_val = &buf1;
@@ -101,13 +93,11 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p,
/* break the encrypted data */
enc_key.data[0]++;
- printf("Testing SetSecret with broken key\n");
+ torture_comment(tctx, "Testing SetSecret with broken key\n");
- status = dcerpc_lsa_SetSecret(p, mem_ctx, &r3);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_UNKNOWN_REVISION)) {
- printf("SetSecret should have failed UNKNOWN_REVISION - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_lsa_SetSecret(p, tctx, &r3);
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_UNKNOWN_REVISION,
+ "SetSecret should have failed UNKNOWN_REVISION");
data_blob_free(&enc_key);
@@ -123,73 +113,115 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p,
bufp1.buf = NULL;
- printf("Testing QuerySecret\n");
- status = dcerpc_lsa_QuerySecret(p, mem_ctx, &r4);
- if (!NT_STATUS_IS_OK(status)) {
- printf("QuerySecret failed - %s\n", nt_errstr(status));
- ret = False;
- } else {
- if (r4.out.new_val == NULL || r4.out.new_val->buf == NULL) {
- printf("No secret buffer returned\n");
- ret = False;
- } else {
- blob1.data = r4.out.new_val->buf->data;
- blob1.length = r4.out.new_val->buf->size;
-
- blob2 = data_blob_talloc(mem_ctx, NULL, blob1.length);
-
- secret2 = sess_decrypt_string(mem_ctx, &blob1, &session_key);
-
- if (strcmp(secret1, secret2) != 0) {
- printf("Returned secret '%s' doesn't match '%s'\n",
- secret2, secret1);
- ret = False;
- }
- }
- }
+ torture_comment(tctx, "Testing QuerySecret\n");
+ status = dcerpc_lsa_QuerySecret(p, tctx, &r4);
+ torture_assert_ntstatus_ok(tctx, status, "QuerySecret failed");
+ if (r4.out.new_val == NULL || r4.out.new_val->buf == NULL)
+ torture_fail(tctx, "No secret buffer returned");
+ blob1.data = r4.out.new_val->buf->data;
+ blob1.length = r4.out.new_val->buf->size;
+
+ blob2 = data_blob_talloc(tctx, NULL, blob1.length);
+
+ secret2 = sess_decrypt_string(tctx, &blob1, &session_key);
+
+ torture_assert_str_equal(tctx, secret1, secret2, "Returned secret invalid");
d.in.handle = &sec_handle;
- status = dcerpc_lsa_Delete(p, mem_ctx, &d);
- if (!NT_STATUS_IS_OK(status)) {
- printf("delete should have returned OKINVALID_HANDLE - %s\n", nt_errstr(status));
- ret = False;
- }
- return ret;
+ status = dcerpc_lsa_Delete(p, tctx, &d);
+ torture_assert_ntstatus_ok(tctx, status, "delete should have returned OKINVALID_HANDLE");
+ return true;
}
+struct secret_settings {
+ uint32_t bindoptions;
+ bool keyexchange;
+ bool ntlm2;
+ bool lm_key;
+};
-/* TEST session key correctness by pushing and pulling secrets */
-
-BOOL torture_rpc_lsa_secrets(struct torture_context *torture)
+static bool test_secrets(struct torture_context *torture, const void *_data)
{
- NTSTATUS status;
struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
struct policy_handle *handle;
+ struct dcerpc_binding *binding;
+ const struct secret_settings *settings =
+ (const struct secret_settings *)_data;
+
+ lp_set_cmdline(global_loadparm, "ntlmssp client:keyexchange", settings->keyexchange?"True":"False");
+ lp_set_cmdline(global_loadparm, "ntlmssp_client:ntlm2", settings->ntlm2?"True":"False");
+ lp_set_cmdline(global_loadparm, "ntlmssp_client:lm_key", settings->lm_key?"True":"False");
- mem_ctx = talloc_init("torture_rpc_lsa_secrets");
+ torture_assert_ntstatus_ok(torture, torture_rpc_binding(torture, &binding),
+ "Getting bindoptions");
- status = torture_rpc_connection(torture,
- &p,
- &ndr_table_lsarpc);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- return False;
+ binding->flags |= settings->bindoptions;
+
+ torture_assert_ntstatus_ok(torture,
+ dcerpc_pipe_connect_b(torture, &p, binding, &ndr_table_lsarpc, cmdline_credentials, NULL),
+ "connect");
+
+ if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
+ return false;
}
- if (test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
- if (!handle) {
- printf("OpenPolicy2 failed. This test cannot run against this server\n");
- ret = False;
- } else if (!test_CreateSecret_basic(p, mem_ctx, handle)) {
- ret = False;
- }
- } else {
- return False;
+ torture_assert(torture, handle, "OpenPolicy2 failed. This test cannot run against this server");
+
+ if (!test_CreateSecret_basic(p, torture, handle)) {
+ return false;
}
- talloc_free(mem_ctx);
+ return true;
+}
+
+static struct torture_tcase *add_test(struct torture_suite *suite, uint32_t bindoptions,
+ bool keyexchange, bool ntlm2, bool lm_key)
+{
+ char *name = NULL;
+ struct secret_settings *settings;
+
+ settings = talloc_zero(suite, struct secret_settings);
+ settings->bindoptions = bindoptions;
+
+ if (bindoptions == DCERPC_PUSH_BIGENDIAN)
+ name = talloc_strdup(suite, "bigendian");
+ else if (bindoptions == DCERPC_SEAL)
+ name = talloc_strdup(suite, "seal");
+ else if (bindoptions == 0)
+ name = talloc_strdup(suite, "none");
+ else
+ name = talloc_strdup(suite, "unknown");
+
+ name = talloc_asprintf_append_buffer(name, " keyexchange:%s", keyexchange?"yes":"no");
+ settings->keyexchange = keyexchange;
+
+ name = talloc_asprintf_append_buffer(name, " ntlm2:%s", ntlm2?"yes":"no");
+ settings->ntlm2 = ntlm2;
+
+ name = talloc_asprintf_append_buffer(name, " lm_key:%s", lm_key?"yes":"no");
+ settings->lm_key = lm_key;
+
+ return torture_suite_add_simple_tcase(suite, name, test_secrets, settings);
+}
+
+static const bool bool_vals[] = { true, false };
+
+/* TEST session key correctness by pushing and pulling secrets */
+struct torture_suite *torture_rpc_lsa_secrets(TALLOC_CTX *mem_ctx)
+{
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "SECRETS");
+ int keyexchange, ntlm2, lm_key;
+
+ for (keyexchange = 0; keyexchange < ARRAY_SIZE(bool_vals); keyexchange++) {
+ for (ntlm2 = 0; ntlm2 < ARRAY_SIZE(bool_vals); ntlm2++) {
+ for (lm_key = 0; lm_key < ARRAY_SIZE(bool_vals); lm_key++) {
+ add_test(suite, DCERPC_PUSH_BIGENDIAN, bool_vals[keyexchange], bool_vals[ntlm2],
+ bool_vals[lm_key]);
+ add_test(suite, DCERPC_SEAL, bool_vals[keyexchange], bool_vals[ntlm2], bool_vals[lm_key]);
+ add_test(suite, 0, bool_vals[keyexchange], bool_vals[ntlm2], bool_vals[lm_key]);
+ }
+ }
+ }
- return ret;
+ return suite;
}
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 0bf0ee87a1..9cc42241d2 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -4,6 +4,7 @@
Copyright (C) Tim Potter 2003
Copyright (C) Stefan Metzmacher 2005
+ Copyright (C) Jelmer Vernooij 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
@@ -25,8 +26,6 @@
#include "librpc/gen_ndr/ndr_spoolss_c.h"
struct test_spoolss_context {
- struct dcerpc_pipe *p;
-
/* print server handle */
struct policy_handle server_handle;
@@ -51,109 +50,58 @@ struct test_spoolss_context {
union spoolss_PrinterInfo *printers[6];
};
-#define COMPARE_STRING(c,r,e) do {\
- BOOL _ok = True;\
- if (c.e && !r.e) _ok = False;\
- if (!c.e && r.e) _ok = False;\
- if (c.e && r.e && strcmp_safe(c.e, r.e) != 0) _ok = False;\
- if (!_ok){\
- printf("%s: " #c "." #e " [%s] doesn't match " #r "." #e " [%s]\n",\
- __location__, c.e, r.e);\
- ret = False;\
- }\
-} while(0)
+#define COMPARE_STRING(tctx, c,r,e) \
+ torture_assert_str_equal(tctx, c.e, r.e, "invalid value")
/* not every compiler supports __typeof__() */
#if (__GNUC__ >= 3)
#define _CHECK_FIELD_SIZE(c,r,e,type) do {\
if (sizeof(__typeof__(c.e)) != sizeof(type)) { \
- printf(__location__ ":" #c "." #e "field is not " #type "\n"); \
- smb_panic(__location__ ":" #c "." #e "field is not " #type ); \
- ret = False; \
+ torture_fail(tctx, #c "." #e "field is not " #type "\n"); \
}\
if (sizeof(__typeof__(r.e)) != sizeof(type)) { \
- printf(__location__ ":" #r "." #e "field is not " #type "\n"); \
- smb_panic(__location__ ":" #r "." #e "field is not " #type ); \
- ret = False; \
+ torture_fail(tctx, #r "." #e "field is not " #type "\n"); \
}\
} while(0)
#else
#define _CHECK_FIELD_SIZE(c,r,e,type) do {} while(0)
#endif
-#if 0 /* unused */
-#define COMPARE_UINT16(c,r,e) do {\
- _CHECK_FIELD_SIZE(c,r,e,uint16_t); \
- if (c.e != r.e){\
- printf("%s: " #c "." #e " 0x%04X (%u) doesn't match " #r "." #e " 0x%04X (%u)\n",\
- __location__, c.e, c.e, r.e, r.e);\
- ret = False;\
- }\
+#define COMPARE_UINT32(tctx, c, r, e) do {\
+ _CHECK_FIELD_SIZE(c, r, e, uint32_t); \
+ torture_assert_int_equal(tctx, c.e, r.e, "invalid value"); \
} while(0)
-#endif
-#define COMPARE_UINT32(c,r,e) do {\
- _CHECK_FIELD_SIZE(c,r,e,uint32_t); \
- if (c.e != r.e){\
- printf("%s: " #c "." #e " 0x%08X (%u) doesn't match " #r "." #e " 0x%08X (%u)\n",\
- __location__, c.e, c.e, r.e, r.e);\
- ret = False;\
- }\
-} while(0)
+#define COMPARE_STRING_ARRAY(tctx, c,r,e)
-#if 0 /* unused */
-#define COMPARE_UINT64(c,r,e) do {\
- _CHECK_FIELD_SIZE(c,r,e,uint64_t); \
- if (c.e != r.e){\
- printf("%s: " #c "." #e " 0x%016llX (%llu) doesn't match " #r "." #e " 0x%016llX (%llu)\n",\
- __location__, c.e, c.e, r.e, r.e);\
- ret = False;\
- }\
-} while(0)
-#endif
-
-/* TODO: ! */
-#if 0 /* unused */
-#define COMPARE_SEC_DESC(c,r,e)
-#define COMPARE_SPOOLSS_TIME(c,r,e)
-#endif
-#define COMPARE_STRING_ARRAY(c,r,e)
-
-static BOOL test_OpenPrinter_server(struct test_spoolss_context *ctx)
+static bool test_OpenPrinter_server(struct torture_context *tctx, struct dcerpc_pipe *p, struct test_spoolss_context *ctx)
{
NTSTATUS status;
struct spoolss_OpenPrinter op;
- BOOL ret = True;
- op.in.printername = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(ctx->p));
+ op.in.printername = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p));
op.in.datatype = NULL;
op.in.devmode_ctr.devmode= NULL;
op.in.access_mask = 0;
op.out.handle = &ctx->server_handle;
- printf("\nTesting OpenPrinter(%s)\n", op.in.printername);
+ torture_comment(tctx, "Testing OpenPrinter(%s)\n", op.in.printername);
- status = dcerpc_spoolss_OpenPrinter(ctx->p, ctx, &op);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_OpenPrinter failed - %s\n", nt_errstr(status));
- ret = False;
- }
- if (!W_ERROR_IS_OK(op.out.result)) {
- printf("OpenPrinter(%s) failed - %s\n",
- op.in.printername, win_errstr(op.out.result));
- ret = False;
- }
+ status = dcerpc_spoolss_OpenPrinter(p, ctx, &op);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_OpenPrinter failed");
+ torture_assert_werr_ok(tctx, op.out.result, "dcerpc_spoolss_OpenPrinter failed");
- return ret;
+ return true;
}
-static BOOL test_EnumPorts(struct test_spoolss_context *ctx)
+static bool test_EnumPorts(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct test_spoolss_context *ctx)
{
NTSTATUS status;
struct spoolss_EnumPorts r;
uint16_t levels[] = { 1, 2 };
int i, j;
- BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -164,43 +112,26 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx)
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing EnumPorts level %u\n", r.in.level);
+ torture_comment(tctx, "Testing EnumPorts level %u\n", r.in.level);
- status = dcerpc_spoolss_EnumPorts(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumPorts failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumPorts(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPorts failed");
if (W_ERROR_IS_OK(r.out.result)) {
/* TODO: do some more checks here */
continue;
}
- if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- printf("EnumPorts unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
+ "EnumPorts unexpected return code");
blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumPorts(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumPorts failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumPorts(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPorts failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("EnumPorts failed - %s\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "EnumPorts failed");
ctx->port_count[level] = r.out.count;
ctx->ports[level] = r.out.info;
@@ -209,14 +140,10 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx)
for (i=1;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
int old_level = levels[i-1];
- if (ctx->port_count[level] != ctx->port_count[old_level]) {
- printf("EnumPorts level[%d] returns [%u] ports, but level[%d] returns [%u]\n",
- level, ctx->port_count[level], old_level, ctx->port_count[old_level]);
- ret = False;
- }
+ torture_assert_int_equal(tctx, ctx->port_count[level], ctx->port_count[old_level],
+ "EnumPorts invalid value");
}
/* if the array sizes are not the same we would maybe segfault in the following code */
- if (!ret) return ret;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -225,7 +152,7 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx)
union spoolss_PortInfo *ref = &ctx->ports[2][j];
switch (level) {
case 1:
- COMPARE_STRING(cur->info1, ref->info2, port_name);
+ COMPARE_STRING(tctx, cur->info1, ref->info2, port_name);
break;
case 2:
/* level 2 is our reference, and it makes no sense to compare it to itself */
@@ -234,10 +161,12 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx)
}
}
- return True;
+ return true;
}
-static BOOL test_GetPrinterDriverDirectory(struct test_spoolss_context *ctx)
+static bool test_GetPrinterDriverDirectory(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct test_spoolss_context *ctx)
{
NTSTATUS status;
struct spoolss_GetPrinterDriverDirectory r;
@@ -255,14 +184,13 @@ static BOOL test_GetPrinterDriverDirectory(struct test_spoolss_context *ctx)
.server = ""
},{
.level = 1,
- .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(ctx->p))
+ .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p))
},{
.level = 1024,
- .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(ctx->p))
+ .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p))
}
};
int i;
- BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i].level;
@@ -274,51 +202,36 @@ static BOOL test_GetPrinterDriverDirectory(struct test_spoolss_context *ctx)
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing GetPrinterDriverDirectory level %u\n", r.in.level);
+ torture_comment(tctx, "Testing GetPrinterDriverDirectory level %u\n", r.in.level);
- status = dcerpc_spoolss_GetPrinterDriverDirectory(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_GetPrinterDriverDirectory failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
- if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- printf("GetPrinterDriverDirectory unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_GetPrinterDriverDirectory(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status,
+ "dcerpc_spoolss_GetPrinterDriverDirectory failed");
+ torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
+ "GetPrinterDriverDirectory unexpected return code");
blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_GetPrinterDriverDirectory(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_GetPrinterDriverDirectory failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_GetPrinterDriverDirectory(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_GetPrinterDriverDirectory failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("GetPrinterDriverDirectory failed - %s\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "GetPrinterDriverDirectory failed");
}
- return True;
+ return true;
}
-static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx)
+static bool test_EnumPrinterDrivers(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct test_spoolss_context *ctx)
{
NTSTATUS status;
struct spoolss_EnumPrinterDrivers r;
uint16_t levels[] = { 1, 2, 3, 4, 5, 6 };
int i, j;
- BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -330,43 +243,27 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx)
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing EnumPrinterDrivers level %u\n", r.in.level);
+ torture_comment(tctx, "Testing EnumPrinterDrivers level %u\n", r.in.level);
- status = dcerpc_spoolss_EnumPrinterDrivers(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumPrinterDrivers failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumPrinterDrivers(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status,
+ "dcerpc_spoolss_EnumPrinterDrivers failed");
if (W_ERROR_IS_OK(r.out.result)) {
/* TODO: do some more checks here */
continue;
}
- if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- printf("EnumPrinterDrivers unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
+ "EnumPrinterDrivers failed");
blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumPrinterDrivers(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumPrinterDrivers failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumPrinterDrivers(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinterDrivers failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("EnumPrinterDrivers failed - %s\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "EnumPrinterDrivers failed");
ctx->driver_count[level] = r.out.count;
ctx->drivers[level] = r.out.info;
@@ -375,14 +272,9 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx)
for (i=1;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
int old_level = levels[i-1];
- if (ctx->driver_count[level] != ctx->driver_count[old_level]) {
- printf("EnumPrinterDrivers level[%d] returns [%u] drivers, but level[%d] returns [%u]\n",
- level, ctx->driver_count[level], old_level, ctx->driver_count[old_level]);
- ret = False;
- }
+ torture_assert_int_equal(tctx, ctx->driver_count[level], ctx->driver_count[old_level],
+ "EnumPrinterDrivers invalid value");
}
- /* if the array sizes are not the same we would maybe segfault in the following code */
- if (!ret) return ret;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -391,51 +283,51 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx)
union spoolss_DriverInfo *ref = &ctx->drivers[6][j];
switch (level) {
case 1:
- COMPARE_STRING(cur->info1, ref->info6, driver_name);
+ COMPARE_STRING(tctx, cur->info1, ref->info6, driver_name);
break;
case 2:
- COMPARE_UINT32(cur->info2, ref->info6, version);
- COMPARE_STRING(cur->info2, ref->info6, driver_name);
- COMPARE_STRING(cur->info2, ref->info6, architecture);
- COMPARE_STRING(cur->info2, ref->info6, driver_path);
- COMPARE_STRING(cur->info2, ref->info6, data_file);
- COMPARE_STRING(cur->info2, ref->info6, config_file);
+ COMPARE_UINT32(tctx, cur->info2, ref->info6, version);
+ COMPARE_STRING(tctx, cur->info2, ref->info6, driver_name);
+ COMPARE_STRING(tctx, cur->info2, ref->info6, architecture);
+ COMPARE_STRING(tctx, cur->info2, ref->info6, driver_path);
+ COMPARE_STRING(tctx, cur->info2, ref->info6, data_file);
+ COMPARE_STRING(tctx, cur->info2, ref->info6, config_file);
break;
case 3:
- COMPARE_UINT32(cur->info3, ref->info6, version);
- COMPARE_STRING(cur->info3, ref->info6, driver_name);
- COMPARE_STRING(cur->info3, ref->info6, architecture);
- COMPARE_STRING(cur->info3, ref->info6, driver_path);
- COMPARE_STRING(cur->info3, ref->info6, data_file);
- COMPARE_STRING(cur->info3, ref->info6, config_file);
- COMPARE_STRING(cur->info3, ref->info6, help_file);
- COMPARE_STRING_ARRAY(cur->info3, ref->info6, dependent_files);
- COMPARE_STRING(cur->info3, ref->info6, monitor_name);
- COMPARE_STRING(cur->info3, ref->info6, default_datatype);
+ COMPARE_UINT32(tctx, cur->info3, ref->info6, version);
+ COMPARE_STRING(tctx, cur->info3, ref->info6, driver_name);
+ COMPARE_STRING(tctx, cur->info3, ref->info6, architecture);
+ COMPARE_STRING(tctx, cur->info3, ref->info6, driver_path);
+ COMPARE_STRING(tctx, cur->info3, ref->info6, data_file);
+ COMPARE_STRING(tctx, cur->info3, ref->info6, config_file);
+ COMPARE_STRING(tctx, cur->info3, ref->info6, help_file);
+ COMPARE_STRING_ARRAY(tctx, cur->info3, ref->info6, dependent_files);
+ COMPARE_STRING(tctx, cur->info3, ref->info6, monitor_name);
+ COMPARE_STRING(tctx, cur->info3, ref->info6, default_datatype);
break;
case 4:
- COMPARE_UINT32(cur->info4, ref->info6, version);
- COMPARE_STRING(cur->info4, ref->info6, driver_name);
- COMPARE_STRING(cur->info4, ref->info6, architecture);
- COMPARE_STRING(cur->info4, ref->info6, driver_path);
- COMPARE_STRING(cur->info4, ref->info6, data_file);
- COMPARE_STRING(cur->info4, ref->info6, config_file);
- COMPARE_STRING(cur->info4, ref->info6, help_file);
- COMPARE_STRING_ARRAY(cur->info4, ref->info6, dependent_files);
- COMPARE_STRING(cur->info4, ref->info6, monitor_name);
- COMPARE_STRING(cur->info4, ref->info6, default_datatype);
- COMPARE_STRING_ARRAY(cur->info4, ref->info6, previous_names);
+ COMPARE_UINT32(tctx, cur->info4, ref->info6, version);
+ COMPARE_STRING(tctx, cur->info4, ref->info6, driver_name);
+ COMPARE_STRING(tctx, cur->info4, ref->info6, architecture);
+ COMPARE_STRING(tctx, cur->info4, ref->info6, driver_path);
+ COMPARE_STRING(tctx, cur->info4, ref->info6, data_file);
+ COMPARE_STRING(tctx, cur->info4, ref->info6, config_file);
+ COMPARE_STRING(tctx, cur->info4, ref->info6, help_file);
+ COMPARE_STRING_ARRAY(tctx, cur->info4, ref->info6, dependent_files);
+ COMPARE_STRING(tctx, cur->info4, ref->info6, monitor_name);
+ COMPARE_STRING(tctx, cur->info4, ref->info6, default_datatype);
+ COMPARE_STRING_ARRAY(tctx, cur->info4, ref->info6, previous_names);
break;
case 5:
- COMPARE_UINT32(cur->info5, ref->info6, version);
- COMPARE_STRING(cur->info5, ref->info6, driver_name);
- COMPARE_STRING(cur->info5, ref->info6, architecture);
- COMPARE_STRING(cur->info5, ref->info6, driver_path);
- COMPARE_STRING(cur->info5, ref->info6, data_file);
- COMPARE_STRING(cur->info5, ref->info6, config_file);
- /*COMPARE_UINT32(cur->info5, ref->info6, driver_attributes);*/
- /*COMPARE_UINT32(cur->info5, ref->info6, config_version);*/
- /*TODO: ! COMPARE_UINT32(cur->info5, ref->info6, driver_version); */
+ COMPARE_UINT32(tctx, cur->info5, ref->info6, version);
+ COMPARE_STRING(tctx, cur->info5, ref->info6, driver_name);
+ COMPARE_STRING(tctx, cur->info5, ref->info6, architecture);
+ COMPARE_STRING(tctx, cur->info5, ref->info6, driver_path);
+ COMPARE_STRING(tctx, cur->info5, ref->info6, data_file);
+ COMPARE_STRING(tctx, cur->info5, ref->info6, config_file);
+ /*COMPARE_UINT32(tctx, cur->info5, ref->info6, driver_attributes);*/
+ /*COMPARE_UINT32(tctx, cur->info5, ref->info6, config_version);*/
+ /*TODO: ! COMPARE_UINT32(tctx, cur->info5, ref->info6, driver_version); */
break;
case 6:
/* level 6 is our reference, and it makes no sense to compare it to itself */
@@ -444,16 +336,17 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx)
}
}
- return ret;
+ return true;
}
-static BOOL test_EnumMonitors(struct test_spoolss_context *ctx)
+static bool test_EnumMonitors(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct test_spoolss_context *ctx)
{
NTSTATUS status;
struct spoolss_EnumMonitors r;
uint16_t levels[] = { 1, 2 };
int i, j;
- BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -464,43 +357,26 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx)
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing EnumMonitors level %u\n", r.in.level);
+ torture_comment(tctx, "Testing EnumMonitors level %u\n", r.in.level);
- status = dcerpc_spoolss_EnumMonitors(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumMonitors failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumMonitors(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumMonitors failed");
if (W_ERROR_IS_OK(r.out.result)) {
/* TODO: do some more checks here */
continue;
}
- if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- printf("EnumMonitors unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
+ "EnumMonitors failed");
blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumMonitors(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumMonitors failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumMonitors(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumMonitors failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("EnumMonitors failed - %s\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "EnumMonitors failed");
ctx->monitor_count[level] = r.out.count;
ctx->monitors[level] = r.out.info;
@@ -509,14 +385,9 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx)
for (i=1;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
int old_level = levels[i-1];
- if (ctx->monitor_count[level] != ctx->monitor_count[old_level]) {
- printf("EnumMonitors level[%d] returns [%u] monitors, but level[%d] returns [%u]\n",
- level, ctx->monitor_count[level], old_level, ctx->monitor_count[old_level]);
- ret = False;
- }
+ torture_assert_int_equal(tctx, ctx->monitor_count[level], ctx->monitor_count[old_level],
+ "EnumMonitors invalid value");
}
- /* if the array sizes are not the same we would maybe segfault in the following code */
- if (!ret) return ret;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -525,7 +396,7 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx)
union spoolss_MonitorInfo *ref = &ctx->monitors[2][j];
switch (level) {
case 1:
- COMPARE_STRING(cur->info1, ref->info2, monitor_name);
+ COMPARE_STRING(tctx, cur->info1, ref->info2, monitor_name);
break;
case 2:
/* level 2 is our reference, and it makes no sense to compare it to itself */
@@ -534,16 +405,17 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx)
}
}
- return ret;
+ return true;
}
-static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx)
+static bool test_EnumPrintProcessors(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct test_spoolss_context *ctx)
{
NTSTATUS status;
struct spoolss_EnumPrintProcessors r;
uint16_t levels[] = { 1 };
int i, j;
- BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -555,43 +427,26 @@ static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx)
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing EnumPrintProcessors level %u\n", r.in.level);
+ torture_comment(tctx, "Testing EnumPrintProcessors level %u\n", r.in.level);
- status = dcerpc_spoolss_EnumPrintProcessors(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumPrintProcessors failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumPrintProcessors(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrintProcessors failed");
if (W_ERROR_IS_OK(r.out.result)) {
/* TODO: do some more checks here */
continue;
}
- if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- printf("EnumPrintProcessors unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
+ "EnumPrintProcessors unexpected return code");
blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumPrintProcessors(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumPrintProcessors failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumPrintProcessors(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrintProcessors failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("EnumPrintProcessors failed - %s\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "EnumPrintProcessors failed");
ctx->print_processor_count[level] = r.out.count;
ctx->print_processors[level] = r.out.info;
@@ -600,14 +455,9 @@ static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx)
for (i=1;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
int old_level = levels[i-1];
- if (ctx->print_processor_count[level] != ctx->print_processor_count[old_level]) {
- printf("EnumPrintProcessors level[%d] returns [%u] print_processors, but level[%d] returns [%u]\n",
- level, ctx->print_processor_count[level], old_level, ctx->print_processor_count[old_level]);
- ret = False;
- }
+ torture_assert_int_equal(tctx, ctx->print_processor_count[level], ctx->print_processor_count[old_level],
+ "EnumPrintProcessors failed");
}
- /* if the array sizes are not the same we would maybe segfault in the following code */
- if (!ret) return ret;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -624,16 +474,17 @@ static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx)
}
}
- return ret;
+ return true;
}
-static BOOL test_EnumPrinters(struct test_spoolss_context *ctx)
+static bool test_EnumPrinters(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct test_spoolss_context *ctx)
{
struct spoolss_EnumPrinters r;
NTSTATUS status;
uint16_t levels[] = { 0, 1, 2, 4, 5 };
int i, j;
- BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -645,42 +496,26 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx)
r.in.buffer = NULL;
r.in.offered = 0;
- printf("\nTesting EnumPrinters level %u\n", r.in.level);
+ torture_comment(tctx, "Testing EnumPrinters level %u\n", r.in.level);
- status = dcerpc_spoolss_EnumPrinters(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumPrinters failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumPrinters(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinters failed");
if (W_ERROR_IS_OK(r.out.result)) {
/* TODO: do some more checks here */
continue;
}
- if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- printf("EnumPrinters unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
+ "EnumPrinters unexpected return code");
blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumPrinters(ctx->p, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EnumPrinters failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumPrinters(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinters failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("EnumPrinters failed - %s\n",
- win_errstr(r.out.result));
- continue;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "EnumPrinters failed");
ctx->printer_count[level] = r.out.count;
ctx->printers[level] = r.out.info;
@@ -689,14 +524,9 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx)
for (i=1;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
int old_level = levels[i-1];
- if (ctx->printer_count[level] != ctx->printer_count[old_level]) {
- printf("EnumPrinters level[%d] returns [%u] printers, but level[%d] returns [%u]\n",
- level, ctx->printer_count[level], old_level, ctx->printer_count[old_level]);
- ret = False;
- }
+ torture_assert_int_equal(tctx, ctx->printer_count[level], ctx->printer_count[old_level],
+ "EnumPrinters invalid value");
}
- /* if the array sizes are not the same we would maybe segfault in the following code */
- if (!ret) return ret;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
@@ -705,56 +535,56 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx)
union spoolss_PrinterInfo *ref = &ctx->printers[2][j];
switch (level) {
case 0:
- COMPARE_STRING(cur->info0, ref->info2, printername);
- COMPARE_STRING(cur->info0, ref->info2, servername);
- COMPARE_UINT32(cur->info0, ref->info2, cjobs);
- /*COMPARE_UINT32(cur->info0, ref->info2, total_jobs);
- COMPARE_UINT32(cur->info0, ref->info2, total_bytes);
+ COMPARE_STRING(tctx, cur->info0, ref->info2, printername);
+ COMPARE_STRING(tctx, cur->info0, ref->info2, servername);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, cjobs);
+ /*COMPARE_UINT32(tctx, cur->info0, ref->info2, total_jobs);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, total_bytes);
COMPARE_SPOOLSS_TIME(cur->info0, ref->info2, spoolss_Time time);
- COMPARE_UINT32(cur->info0, ref->info2, global_counter);
- COMPARE_UINT32(cur->info0, ref->info2, total_pages);
- COMPARE_UINT32(cur->info0, ref->info2, version);
- COMPARE_UINT32(cur->info0, ref->info2, unknown10);
- COMPARE_UINT32(cur->info0, ref->info2, unknown11);
- COMPARE_UINT32(cur->info0, ref->info2, unknown12);
- COMPARE_UINT32(cur->info0, ref->info2, session_counter);
- COMPARE_UINT32(cur->info0, ref->info2, unknown14);
- COMPARE_UINT32(cur->info0, ref->info2, printer_errors);
- COMPARE_UINT32(cur->info0, ref->info2, unknown16);
- COMPARE_UINT32(cur->info0, ref->info2, unknown17);
- COMPARE_UINT32(cur->info0, ref->info2, unknown18);
- COMPARE_UINT32(cur->info0, ref->info2, unknown19);
- COMPARE_UINT32(cur->info0, ref->info2, change_id);
- COMPARE_UINT32(cur->info0, ref->info2, unknown21);*/
- COMPARE_UINT32(cur->info0, ref->info2, status);
- /*COMPARE_UINT32(cur->info0, ref->info2, unknown23);
- COMPARE_UINT32(cur->info0, ref->info2, c_setprinter);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, global_counter);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, total_pages);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, version);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown10);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown11);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown12);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, session_counter);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown14);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, printer_errors);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown16);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown17);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown18);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown19);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, change_id);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown21);*/
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, status);
+ /*COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown23);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, c_setprinter);
COMPARE_UINT16(cur->info0, ref->info2, unknown25);
COMPARE_UINT16(cur->info0, ref->info2, unknown26);
- COMPARE_UINT32(cur->info0, ref->info2, unknown27);
- COMPARE_UINT32(cur->info0, ref->info2, unknown28);
- COMPARE_UINT32(cur->info0, ref->info2, unknown29);*/
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown27);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown28);
+ COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown29);*/
break;
case 1:
- /*COMPARE_UINT32(cur->info1, ref->info2, flags);*/
- /*COMPARE_STRING(cur->info1, ref->info2, name);*/
- /*COMPARE_STRING(cur->info1, ref->info2, description);*/
- COMPARE_STRING(cur->info1, ref->info2, comment);
+ /*COMPARE_UINT32(tctx, cur->info1, ref->info2, flags);*/
+ /*COMPARE_STRING(tctx, cur->info1, ref->info2, name);*/
+ /*COMPARE_STRING(tctx, cur->info1, ref->info2, description);*/
+ COMPARE_STRING(tctx, cur->info1, ref->info2, comment);
break;
case 2:
/* level 2 is our reference, and it makes no sense to compare it to itself */
break;
case 4:
- COMPARE_STRING(cur->info4, ref->info2, printername);
- COMPARE_STRING(cur->info4, ref->info2, servername);
- COMPARE_UINT32(cur->info4, ref->info2, attributes);
+ COMPARE_STRING(tctx, cur->info4, ref->info2, printername);
+ COMPARE_STRING(tctx, cur->info4, ref->info2, servername);
+ COMPARE_UINT32(tctx, cur->info4, ref->info2, attributes);
break;
case 5:
- COMPARE_STRING(cur->info5, ref->info2, printername);
- COMPARE_STRING(cur->info5, ref->info2, portname);
- COMPARE_UINT32(cur->info5, ref->info2, attributes);
- /*COMPARE_UINT32(cur->info5, ref->info2, device_not_selected_timeout);
- COMPARE_UINT32(cur->info5, ref->info2, transmission_retry_timeout);*/
+ COMPARE_STRING(tctx, cur->info5, ref->info2, printername);
+ COMPARE_STRING(tctx, cur->info5, ref->info2, portname);
+ COMPARE_UINT32(tctx, cur->info5, ref->info2, attributes);
+ /*COMPARE_UINT32(tctx, cur->info5, ref->info2, device_not_selected_timeout);
+ COMPARE_UINT32(tctx, cur->info5, ref->info2, transmission_retry_timeout);*/
break;
}
}
@@ -764,17 +594,17 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx)
* - verify that the port of a printer was in the list returned by EnumPorts
*/
- return ret;
+ return true;
}
-static BOOL test_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetPrinter(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
struct policy_handle *handle)
{
NTSTATUS status;
struct spoolss_GetPrinter r;
uint16_t levels[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
int i;
- BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
r.in.handle = handle;
@@ -782,43 +612,31 @@ static BOOL test_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing GetPrinter level %u\n", r.in.level);
+ torture_comment(tctx, "Testing GetPrinter level %u\n", r.in.level);
- status = dcerpc_spoolss_GetPrinter(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetPrinter failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_GetPrinter(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_GetPrinter(p, mem_ctx, &r);
+ status = dcerpc_spoolss_GetPrinter(p, tctx, &r);
}
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetPrinter failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("GetPrinter failed - %s\n",
- win_errstr(r.out.result));
- ret = False;
- continue;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "GetPrinter failed");
}
- return ret;
+ return true;
}
-static BOOL test_ClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_ClosePrinter(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
{
NTSTATUS status;
struct spoolss_ClosePrinter r;
@@ -826,18 +644,16 @@ static BOOL test_ClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.handle = handle;
r.out.handle = handle;
- printf("Testing ClosePrinter\n");
+ torture_comment(tctx, "Testing ClosePrinter\n");
- status = dcerpc_spoolss_ClosePrinter(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ClosePrinter failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_ClosePrinter(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed");
- return True;
+ return true;
}
-static BOOL test_GetForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetForm(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
struct policy_handle *handle,
const char *form_name)
{
@@ -850,109 +666,79 @@ static BOOL test_GetForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing GetForm\n");
+ torture_comment(tctx, "Testing GetForm\n");
- status = dcerpc_spoolss_GetForm(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetForm failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_GetForm(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetForm failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_GetForm(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetForm failed - %s\n",
- nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_GetForm(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetForm failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("GetForm failed - %s\n",
- win_errstr(r.out.result));
- return False;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "GetForm failed");
- if (!r.out.info) {
- printf("No form info returned\n");
- return False;
- }
+ torture_assert(tctx, r.out.info, "No form info returned");
}
+ torture_assert_werr_ok(tctx, r.out.result, "GetForm failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("GetForm failed - %s\n",
- win_errstr(r.out.result));
- return False;
- }
-
- return True;
+ return true;
}
-static BOOL test_EnumForms(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, BOOL print_server)
+static bool test_EnumForms(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle, bool print_server)
{
NTSTATUS status;
struct spoolss_EnumForms r;
- BOOL ret = True;
+ bool ret = true;
r.in.handle = handle;
r.in.level = 1;
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing EnumForms\n");
+ torture_comment(tctx, "Testing EnumForms\n");
- status = dcerpc_spoolss_EnumForms(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumForms failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_EnumForms(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
- if (print_server && W_ERROR_EQUAL(r.out.result,WERR_BADFID)) {
- printf("EnumForms on the PrintServer isn't supported by test server (NT4)\n");
- return True;
- }
+ if (print_server && W_ERROR_EQUAL(r.out.result, WERR_BADFID))
+ torture_fail(tctx, "EnumForms on the PrintServer isn't supported by test server (NT4)");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
union spoolss_FormInfo *info;
int j;
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumForms(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumForms(p, tctx, &r);
- if (!r.out.info) {
- printf("No forms returned\n");
- return False;
- }
+ torture_assert(tctx, r.out.info, "No forms returned");
info = r.out.info;
for (j = 0; j < r.out.count; j++) {
- if (!print_server) ret &= test_GetForm(p, mem_ctx, handle, info[j].info1.form_name);
+ if (!print_server)
+ ret &= test_GetForm(tctx, p, handle, info[j].info1.form_name);
}
}
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumForms failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("EnumForms failed - %s\n", win_errstr(r.out.result));
- return False;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "EnumForms failed");
- return True;
+ return true;
}
-static BOOL test_DeleteForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DeleteForm(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
struct policy_handle *handle,
const char *form_name)
{
@@ -962,29 +748,24 @@ static BOOL test_DeleteForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.handle = handle;
r.in.form_name = form_name;
- status = dcerpc_spoolss_DeleteForm(p, mem_ctx, &r);
+ status = dcerpc_spoolss_DeleteForm(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("DeleteForm failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "DeleteForm failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DeleteForm failed - %s\n", win_errstr(r.out.result));
- return False;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "DeleteForm failed");
- return True;
+ return true;
}
-static BOOL test_AddForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, BOOL print_server)
+static bool test_AddForm(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle, bool print_server)
{
struct spoolss_AddForm r;
struct spoolss_AddFormInfo1 addform;
const char *form_name = "testform3";
NTSTATUS status;
- BOOL ret = True;
+ bool ret = true;
r.in.handle = handle;
r.in.level = 1;
@@ -998,19 +779,13 @@ static BOOL test_AddForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
addform.area.right = 45;
addform.area.bottom = 15;
- status = dcerpc_spoolss_AddForm(p, mem_ctx, &r);
+ status = dcerpc_spoolss_AddForm(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("AddForm failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "AddForm failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("AddForm failed - %s\n", win_errstr(r.out.result));
- goto done;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "AddForm failed");
- if (!print_server) ret &= test_GetForm(p, mem_ctx, handle, form_name);
+ if (!print_server) ret &= test_GetForm(tctx, p, handle, form_name);
{
struct spoolss_SetForm sf;
@@ -1027,92 +802,71 @@ static BOOL test_AddForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
setform.size.width = 1234;
- status = dcerpc_spoolss_SetForm(p, mem_ctx, &sf);
+ status = dcerpc_spoolss_SetForm(p, tctx, &sf);
- if (!NT_STATUS_IS_OK(status)) {
- printf("SetForm failed - %s\n", nt_errstr(status));
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(tctx, status, "SetForm failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("SetForm failed - %s\n",
- win_errstr(r.out.result));
- ret = False;
- goto done;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "SetForm failed");
}
- if (!print_server) ret &= test_GetForm(p, mem_ctx, handle, form_name);
+ if (!print_server) ret &= test_GetForm(tctx, p, handle, form_name);
- done:
- if (!test_DeleteForm(p, mem_ctx, handle, form_name)) {
- printf("DeleteForm failed\n");
- ret = False;
+ if (!test_DeleteForm(tctx, p, handle, form_name)) {
+ ret = false;
}
return ret;
}
-static BOOL test_EnumPorts_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_EnumPorts_old(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct spoolss_EnumPorts r;
- r.in.servername = talloc_asprintf(mem_ctx, "\\\\%s",
+ r.in.servername = talloc_asprintf(tctx, "\\\\%s",
dcerpc_server_name(p));
r.in.level = 2;
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing EnumPorts\n");
+ torture_comment(tctx, "Testing EnumPorts\n");
- status = dcerpc_spoolss_EnumPorts(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumPorts(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPorts failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "EnumPorts failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumPorts(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPorts failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_EnumPorts(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "EnumPorts failed");
- if (!r.out.info) {
- printf("No ports returned\n");
- return False;
- }
+ torture_assert(tctx, r.out.info, "No ports returned");
}
- return True;
+ return true;
}
-static BOOL test_AddPort(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_AddPort(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct spoolss_AddPort r;
- r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s",
+ r.in.server_name = talloc_asprintf(tctx, "\\\\%s",
dcerpc_server_name(p));
r.in.unknown = 0;
r.in.monitor_name = "foo";
- printf ("Testing AddPort\n");
+ torture_comment(tctx, "Testing AddPort\n");
- status = dcerpc_spoolss_AddPort(p, mem_ctx, &r);
+ status = dcerpc_spoolss_AddPort(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("AddPort failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "AddPort failed");
/* win2k3 returns WERR_NOT_SUPPORTED */
@@ -1120,16 +874,17 @@ static BOOL test_AddPort(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
if (!W_ERROR_IS_OK(r.out.result)) {
printf("AddPort failed - %s\n", win_errstr(r.out.result));
- return False;
+ return false;
}
#endif
- return True;
+ return true;
}
-static BOOL test_GetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, uint32_t job_id)
+static bool test_GetJob(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle, uint32_t job_id)
{
NTSTATUS status;
struct spoolss_GetJob r;
@@ -1140,33 +895,29 @@ static BOOL test_GetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing GetJob\n");
+ torture_comment(tctx, "Testing GetJob\n");
- status = dcerpc_spoolss_GetJob(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetJob failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_GetJob(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetJob failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_GetJob(p, mem_ctx, &r);
+ status = dcerpc_spoolss_GetJob(p, tctx, &r);
- if (!r.out.info) {
- printf("No job info returned\n");
- return False;
- }
+ torture_assert(tctx, r.out.info, "No job info returned");
}
- return True;
+ return true;
}
-static BOOL test_SetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, uint32_t job_id, enum spoolss_JobControl command)
+static bool test_SetJob(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle, uint32_t job_id,
+ enum spoolss_JobControl command)
{
NTSTATUS status;
struct spoolss_SetJob r;
@@ -1176,23 +927,18 @@ static BOOL test_SetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.ctr = NULL;
r.in.command = command;
- printf("Testing SetJob\n");
+ torture_comment(tctx, "Testing SetJob\n");
- status = dcerpc_spoolss_SetJob(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("SetJob failed - %s\n", nt_errstr(status));
- return False;
- }
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("SetJob failed - %s\n", win_errstr(r.out.result));
- return False;
- }
+ status = dcerpc_spoolss_SetJob(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "SetJob failed");
+ torture_assert_werr_ok(tctx, r.out.result, "SetJob failed");
- return True;
+ return true;
}
-static BOOL test_EnumJobs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_EnumJobs(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
{
NTSTATUS status;
struct spoolss_EnumJobs r;
@@ -1204,50 +950,44 @@ static BOOL test_EnumJobs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.buffer = NULL;
r.in.offered = 0;
- printf("Testing EnumJobs\n");
+ torture_comment(tctx, "Testing EnumJobs\n");
- status = dcerpc_spoolss_EnumJobs(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumJobs(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumJobs failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "EnumJobs failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
union spoolss_JobInfo *info;
int j;
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumJobs(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumJobs(p, tctx, &r);
- if (!r.out.info) {
- printf("No jobs returned\n");
- return True;
- }
+ torture_assert(tctx, r.out.info, "No jobs returned");
info = r.out.info;
for (j = 0; j < r.out.count; j++) {
- test_GetJob(p, mem_ctx, handle, info[j].info1.job_id);
- test_SetJob(p, mem_ctx, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_PAUSE);
- test_SetJob(p, mem_ctx, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_RESUME);
+ test_GetJob(tctx, p, handle, info[j].info1.job_id);
+ test_SetJob(tctx, p, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_PAUSE);
+ test_SetJob(tctx, p, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_RESUME);
}
- } else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("EnumJobs failed - %s\n", win_errstr(r.out.result));
- return False;
+ } else {
+ torture_assert_werr_ok(tctx, r.out.result, "EnumJobs failed");
}
- return True;
+ return true;
}
-static BOOL test_DoPrintTest(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_DoPrintTest(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
struct spoolss_StartDocPrinter s;
struct spoolss_DocumentInfo1 info1;
@@ -1258,7 +998,7 @@ static BOOL test_DoPrintTest(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
int i;
uint32_t job_id;
- printf("Testing StartDocPrinter\n");
+ torture_comment(tctx, "Testing StartDocPrinter\n");
s.in.handle = handle;
s.in.level = 1;
@@ -1267,86 +1007,58 @@ static BOOL test_DoPrintTest(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
info1.output_file = NULL;
info1.datatype = "RAW";
- status = dcerpc_spoolss_StartDocPrinter(p, mem_ctx, &s);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_StartDocPrinter failed - %s\n", nt_errstr(status));
- return False;
- }
- if (!W_ERROR_IS_OK(s.out.result)) {
- printf("StartDocPrinter failed - %s\n", win_errstr(s.out.result));
- return False;
- }
+ status = dcerpc_spoolss_StartDocPrinter(p, tctx, &s);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_StartDocPrinter failed");
+ torture_assert_werr_ok(tctx, s.out.result, "StartDocPrinter failed");
job_id = s.out.job_id;
for (i=1; i < 4; i++) {
- printf("Testing StartPagePrinter: Page[%d]\n", i);
+ torture_comment(tctx, "Testing StartPagePrinter: Page[%d]\n", i);
sp.in.handle = handle;
- status = dcerpc_spoolss_StartPagePrinter(p, mem_ctx, &sp);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_StartPagePrinter failed - %s\n", nt_errstr(status));
- return False;
- }
- if (!W_ERROR_IS_OK(sp.out.result)) {
- printf("StartPagePrinter failed - %s\n", win_errstr(sp.out.result));
- return False;
- }
+ status = dcerpc_spoolss_StartPagePrinter(p, tctx, &sp);
+ torture_assert_ntstatus_ok(tctx, status,
+ "dcerpc_spoolss_StartPagePrinter failed");
+ torture_assert_werr_ok(tctx, sp.out.result, "StartPagePrinter failed");
- printf("Testing WritePrinter: Page[%d]\n", i);
+ torture_comment(tctx, "Testing WritePrinter: Page[%d]\n", i);
w.in.handle = handle;
- w.in.data = data_blob_string_const(talloc_asprintf(mem_ctx,"TortureTestPage: %d\nData\n",i));
+ w.in.data = data_blob_string_const(talloc_asprintf(tctx,"TortureTestPage: %d\nData\n",i));
- status = dcerpc_spoolss_WritePrinter(p, mem_ctx, &w);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_WritePrinter failed - %s\n", nt_errstr(status));
- return False;
- }
- if (!W_ERROR_IS_OK(w.out.result)) {
- printf("WritePrinter failed - %s\n", win_errstr(w.out.result));
- return False;
- }
+ status = dcerpc_spoolss_WritePrinter(p, tctx, &w);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_WritePrinter failed");
+ torture_assert_werr_ok(tctx, w.out.result, "WritePrinter failed");
- printf("Testing EndPagePrinter: Page[%d]\n", i);
+ torture_comment(tctx, "Testing EndPagePrinter: Page[%d]\n", i);
ep.in.handle = handle;
- status = dcerpc_spoolss_EndPagePrinter(p, mem_ctx, &ep);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EndPagePrinter failed - %s\n", nt_errstr(status));
- return False;
- }
- if (!W_ERROR_IS_OK(ep.out.result)) {
- printf("EndPagePrinter failed - %s\n", win_errstr(ep.out.result));
- return False;
- }
+ status = dcerpc_spoolss_EndPagePrinter(p, tctx, &ep);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EndPagePrinter failed");
+ torture_assert_werr_ok(tctx, ep.out.result, "EndPagePrinter failed");
}
- printf("Testing EndDocPrinter\n");
+ torture_comment(tctx, "Testing EndDocPrinter\n");
e.in.handle = handle;
- status = dcerpc_spoolss_EndDocPrinter(p, mem_ctx, &e);
- if (!NT_STATUS_IS_OK(status)) {
- printf("dcerpc_spoolss_EndDocPrinter failed - %s\n", nt_errstr(status));
- return False;
- }
- if (!W_ERROR_IS_OK(e.out.result)) {
- printf("EndDocPrinter failed - %s\n", win_errstr(e.out.result));
- return False;
- }
+ status = dcerpc_spoolss_EndDocPrinter(p, tctx, &e);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EndDocPrinter failed");
+ torture_assert_werr_ok(tctx, e.out.result, "EndDocPrinter failed");
- ret &= test_EnumJobs(p, mem_ctx, handle);
+ ret &= test_EnumJobs(tctx, p, handle);
- ret &= test_SetJob(p, mem_ctx, handle, job_id, SPOOLSS_JOB_CONTROL_DELETE);
+ ret &= test_SetJob(tctx, p, handle, job_id, SPOOLSS_JOB_CONTROL_DELETE);
return ret;
}
-static BOOL test_PausePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_PausePrinter(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
{
NTSTATUS status;
struct spoolss_SetPrinter r;
@@ -1358,25 +1070,20 @@ static BOOL test_PausePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.secdesc_ctr.sd = NULL;
r.in.command = SPOOLSS_PRINTER_CONTROL_PAUSE;
- printf("Testing SetPrinter: SPOOLSS_PRINTER_CONTROL_PAUSE\n");
+ torture_comment(tctx, "Testing SetPrinter: SPOOLSS_PRINTER_CONTROL_PAUSE\n");
- status = dcerpc_spoolss_SetPrinter(p, mem_ctx, &r);
+ status = dcerpc_spoolss_SetPrinter(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("SetPrinter failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "SetPrinter failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("SetPrinter failed - %s\n", win_errstr(r.out.result));
- return False;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "SetPrinter failed");
- return True;
+ return true;
}
-static BOOL test_ResumePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_ResumePrinter(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
{
NTSTATUS status;
struct spoolss_SetPrinter r;
@@ -1388,24 +1095,19 @@ static BOOL test_ResumePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.secdesc_ctr.sd = NULL;
r.in.command = SPOOLSS_PRINTER_CONTROL_RESUME;
- printf("Testing SetPrinter: SPOOLSS_PRINTER_CONTROL_RESUME\n");
+ torture_comment(tctx, "Testing SetPrinter: SPOOLSS_PRINTER_CONTROL_RESUME\n");
- status = dcerpc_spoolss_SetPrinter(p, mem_ctx, &r);
+ status = dcerpc_spoolss_SetPrinter(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("SetPrinter failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "SetPrinter failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("SetPrinter failed - %s\n", win_errstr(r.out.result));
- return False;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "SetPrinter failed");
- return True;
+ return true;
}
-static BOOL test_GetPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetPrinterData(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
struct policy_handle *handle,
const char *value_name)
{
@@ -1416,35 +1118,25 @@ static BOOL test_GetPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.value_name = value_name;
r.in.offered = 0;
- printf("Testing GetPrinterData\n");
+ torture_comment(tctx, "Testing GetPrinterData\n");
- status = dcerpc_spoolss_GetPrinterData(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetPrinterData failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_GetPrinterData(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed");
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_GetPrinterData(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetPrinterData failed - %s\n",
- nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_GetPrinterData(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("GetPrinterData failed - %s\n",
- win_errstr(r.out.result));
- return False;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "GetPrinterData failed");
}
- return True;
+ return true;
}
-static BOOL test_GetPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetPrinterDataEx(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
struct policy_handle *handle,
const char *key_name,
const char *value_name)
@@ -1457,40 +1149,30 @@ static BOOL test_GetPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.value_name = value_name;
r.in.offered = 0;
- printf("Testing GetPrinterDataEx\n");
+ torture_comment(tctx, "Testing GetPrinterDataEx\n");
- status = dcerpc_spoolss_GetPrinterDataEx(p, mem_ctx, &r);
+ status = dcerpc_spoolss_GetPrinterDataEx(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_NET_WRITE_FAULT) &&
p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) {
- printf("GetPrinterDataEx not supported by server\n");
- return True;
+ torture_skip(tctx, "GetPrinterDataEx not supported by server\n");
}
- printf("GetPrinterDataEx failed - %s\n", nt_errstr(status));
- return False;
+ torture_assert_ntstatus_ok(tctx, status, "GetPrinterDataEx failed");
}
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_GetPrinterDataEx(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetPrinterDataEx failed - %s\n",
- nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_GetPrinterDataEx(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetPrinterDataEx failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("GetPrinterDataEx failed - %s\n",
- win_errstr(r.out.result));
- return False;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "GetPrinterDataEx failed");
}
- return True;
+ return true;
}
-static BOOL test_EnumPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_EnumPrinterData(struct torture_context *tctx, struct dcerpc_pipe *p,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -1507,38 +1189,33 @@ static BOOL test_EnumPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.data_size = &data_size;
r.out.data_size = &data_size;
- printf("Testing EnumPrinterData\n");
+ torture_comment(tctx, "Testing EnumPrinterData\n");
- status = dcerpc_spoolss_EnumPrinterData(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumPrinterData(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPrinterData failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "EnumPrinterData failed");
r.in.value_offered = r.out.value_needed;
- status = dcerpc_spoolss_EnumPrinterData(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumPrinterData(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPrinterData failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "EnumPrinterData failed");
- test_GetPrinterData(p, mem_ctx, handle, r.out.value_name);
+ test_GetPrinterData(tctx, p, handle, r.out.value_name);
- test_GetPrinterDataEx(
- p, mem_ctx, handle, "PrinterDriverData",
+ test_GetPrinterDataEx(tctx,
+ p, handle, "PrinterDriverData",
r.out.value_name);
r.in.enum_index++;
} while (W_ERROR_IS_OK(r.out.result));
- return True;
+ return true;
}
-static BOOL test_EnumPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_EnumPrinterDataEx(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
struct policy_handle *handle)
{
NTSTATUS status;
@@ -1548,28 +1225,23 @@ static BOOL test_EnumPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.key_name = "PrinterDriverData";
r.in.offered = 0;
- printf("Testing EnumPrinterDataEx\n");
+ torture_comment(tctx, "Testing EnumPrinterDataEx\n");
- status = dcerpc_spoolss_EnumPrinterDataEx(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPrinterDataEx failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed");
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumPrinterDataEx(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPrinterDataEx failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed");
- return True;
+ return true;
}
-static BOOL test_DeletePrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DeletePrinterData(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
struct policy_handle *handle,
const char *value_name)
{
@@ -1579,20 +1251,18 @@ static BOOL test_DeletePrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.handle = handle;
r.in.value_name = value_name;
- printf("Testing DeletePrinterData\n");
+ torture_comment(tctx, "Testing DeletePrinterData\n");
- status = dcerpc_spoolss_DeletePrinterData(p, mem_ctx, &r);
+ status = dcerpc_spoolss_DeletePrinterData(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("DeletePrinterData failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "DeletePrinterData failed");
- return True;
+ return true;
}
-static BOOL test_SetPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_SetPrinterData(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
{
NTSTATUS status;
struct spoolss_SetPrinterData r;
@@ -1603,84 +1273,69 @@ static BOOL test_SetPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.type = SPOOLSS_PRINTER_DATA_TYPE_STRING;
r.in.data.string = "dog";
- printf("Testing SetPrinterData\n");
+ torture_comment(tctx, "Testing SetPrinterData\n");
- status = dcerpc_spoolss_SetPrinterData(p, mem_ctx, &r);
+ status = dcerpc_spoolss_SetPrinterData(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("SetPrinterData failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "SetPrinterData failed");
- if (!test_GetPrinterData(p, mem_ctx, handle, value_name)) {
- return False;
+ if (!test_GetPrinterData(tctx, p, handle, value_name)) {
+ return false;
}
- if (!test_DeletePrinterData(p, mem_ctx, handle, value_name)) {
- return False;
+ if (!test_DeletePrinterData(tctx, p, handle, value_name)) {
+ return false;
}
- return True;
+ return true;
}
-static BOOL test_SecondaryClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_SecondaryClosePrinter(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
struct policy_handle *handle)
{
NTSTATUS status;
struct dcerpc_binding *b;
struct dcerpc_pipe *p2;
- BOOL ret = True;
+ bool ret = true;
/* only makes sense on SMB */
if (p->conn->transport.transport != NCACN_NP) {
- return True;
+ return true;
}
- printf("testing close on secondary pipe\n");
+ torture_comment(tctx, "testing close on secondary pipe\n");
- status = dcerpc_parse_binding(mem_ctx, p->conn->binding_string, &b);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to parse dcerpc binding '%s'\n", p->conn->binding_string);
- return False;
- }
+ status = dcerpc_parse_binding(tctx, p->conn->binding_string, &b);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to parse dcerpc binding");
status = dcerpc_secondary_connection(p, &p2, b);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to create secondary connection\n");
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create secondary connection");
status = dcerpc_bind_auth_none(p2, &ndr_table_spoolss);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to create bind on secondary connection\n");
- talloc_free(p2);
-
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to create bind on secondary connection");
- if (test_ClosePrinter(p2, mem_ctx, handle)) {
- printf("ERROR: Allowed close on secondary connection!\n");
- ret = False;
+ if (test_ClosePrinter(tctx, p2, handle)) {
+ torture_comment(tctx, "ERROR: Allowed close on secondary connection!\n");
+ ret = false;
}
- if (p2->last_fault_code != DCERPC_FAULT_CONTEXT_MISMATCH) {
- printf("Unexpected fault code 0x%x - expected 0x%x\n",
- p2->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH);
- ret = False;
- }
+ torture_assert_int_equal(tctx, p2->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH,
+ "Unexpected fault code");
talloc_free(p2);
- return ret;
+ return true;
}
-static BOOL test_OpenPrinter_badname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *name)
+static bool test_OpenPrinter_badname(struct torture_context *tctx,
+ struct dcerpc_pipe *p, const char *name)
{
NTSTATUS status;
struct spoolss_OpenPrinter op;
struct spoolss_OpenPrinterEx opEx;
struct policy_handle handle;
- BOOL ret = True;
+ bool ret = true;
op.in.printername = name;
op.in.datatype = NULL;
@@ -1688,20 +1343,17 @@ static BOOL test_OpenPrinter_badname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
op.in.access_mask = 0;
op.out.handle = &handle;
- printf("\nTesting OpenPrinter(%s) with bad name\n", op.in.printername);
+ torture_comment(tctx, "\nTesting OpenPrinter(%s) with bad name\n", op.in.printername);
- status = dcerpc_spoolss_OpenPrinter(p, mem_ctx, &op);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenPrinter failed - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_spoolss_OpenPrinter(p, tctx, &op);
+ torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed");
if (!W_ERROR_EQUAL(WERR_INVALID_PRINTER_NAME,op.out.result)) {
- printf("OpenPrinter(%s) unexpected result[%s] should be WERR_INVALID_PRINTER_NAME\n",
+ torture_comment(tctx, "OpenPrinter(%s) unexpected result[%s] should be WERR_INVALID_PRINTER_NAME\n",
name, win_errstr(op.out.result));
}
if (W_ERROR_IS_OK(op.out.result)) {
- ret &=test_ClosePrinter(p, mem_ctx, &handle);
+ ret &=test_ClosePrinter(tctx, p, &handle);
}
opEx.in.printername = name;
@@ -1712,91 +1364,62 @@ static BOOL test_OpenPrinter_badname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
opEx.in.userlevel.level1 = NULL;
opEx.out.handle = &handle;
- printf("\nTesting OpenPrinterEx(%s) with bad name\n", opEx.in.printername);
+ torture_comment(tctx, "Testing OpenPrinterEx(%s) with bad name\n", opEx.in.printername);
- status = dcerpc_spoolss_OpenPrinterEx(p, mem_ctx, &opEx);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenPrinter failed - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_spoolss_OpenPrinterEx(p, tctx, &opEx);
+ torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed");
if (!W_ERROR_EQUAL(WERR_INVALID_PRINTER_NAME,opEx.out.result)) {
- printf("OpenPrinterEx(%s) unexpected result[%s] should be WERR_INVALID_PRINTER_NAME\n",
+ torture_comment(tctx, "OpenPrinterEx(%s) unexpected result[%s] should be WERR_INVALID_PRINTER_NAME\n",
name, win_errstr(opEx.out.result));
}
if (W_ERROR_IS_OK(opEx.out.result)) {
- ret &=test_ClosePrinter(p, mem_ctx, &handle);
+ ret &=test_ClosePrinter(tctx, p, &handle);
}
return ret;
}
-static BOOL test_OpenPrinter_badnames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
-{
- BOOL ret = True;
- char *name;
-
- ret &= test_OpenPrinter_badname(p, mem_ctx, "__INVALID_PRINTER__");
- ret &= test_OpenPrinter_badname(p, mem_ctx, "\\\\__INVALID_HOST__");
- ret &= test_OpenPrinter_badname(p, mem_ctx, "");
- ret &= test_OpenPrinter_badname(p, mem_ctx, "\\\\\\");
- ret &= test_OpenPrinter_badname(p, mem_ctx, "\\\\\\__INVALID_PRINTER__");
-
- name = talloc_asprintf(mem_ctx, "\\\\%s\\", dcerpc_server_name(p));
- ret &= test_OpenPrinter_badname(p, mem_ctx, name);
- talloc_free(name);
-
- name = talloc_asprintf(mem_ctx, "\\\\%s\\__INVALID_PRINTER__", dcerpc_server_name(p));
- ret &= test_OpenPrinter_badname(p, mem_ctx, name);
- talloc_free(name);
-
- return ret;
-}
-
-static BOOL test_OpenPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_OpenPrinter(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
const char *name)
{
NTSTATUS status;
struct spoolss_OpenPrinter r;
struct policy_handle handle;
- BOOL ret = True;
+ bool ret = true;
- r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s", dcerpc_server_name(p), name);
+ r.in.printername = talloc_asprintf(tctx, "\\\\%s\\%s", dcerpc_server_name(p), name);
r.in.datatype = NULL;
r.in.devmode_ctr.devmode= NULL;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
r.out.handle = &handle;
- printf("\nTesting OpenPrinter(%s)\n", r.in.printername);
+ torture_comment(tctx, "Testing OpenPrinter(%s)\n", r.in.printername);
- status = dcerpc_spoolss_OpenPrinter(p, mem_ctx, &r);
+ status = dcerpc_spoolss_OpenPrinter(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenPrinter failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("OpenPrinter failed - %s\n", win_errstr(r.out.result));
- return False;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "OpenPrinter failed");
- if (!test_GetPrinter(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_GetPrinter(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_SecondaryClosePrinter(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_SecondaryClosePrinter(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_ClosePrinter(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_ClosePrinter(tctx, p, &handle)) {
+ ret = false;
}
return ret;
}
-static BOOL call_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool call_OpenPrinterEx(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
const char *name, struct policy_handle *handle)
{
struct spoolss_OpenPrinterEx r;
@@ -1804,10 +1427,10 @@ static BOOL call_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
NTSTATUS status;
if (name && name[0]) {
- r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
+ r.in.printername = talloc_asprintf(tctx, "\\\\%s\\%s",
dcerpc_server_name(p), name);
} else {
- r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s",
+ r.in.printername = talloc_asprintf(tctx, "\\\\%s",
dcerpc_server_name(p));
}
@@ -1826,87 +1449,82 @@ static BOOL call_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
userlevel1.minor = 3;
userlevel1.processor = 4;
- printf("Testing OpenPrinterEx(%s)\n", r.in.printername);
+ torture_comment(tctx, "Testing OpenPrinterEx(%s)\n", r.in.printername);
- status = dcerpc_spoolss_OpenPrinterEx(p, mem_ctx, &r);
+ status = dcerpc_spoolss_OpenPrinterEx(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenPrinterEx failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "OpenPrinterEx failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("OpenPrinterEx failed - %s\n", win_errstr(r.out.result));
- return False;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "OpenPrinterEx failed");
- return True;
+ return true;
}
-static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_OpenPrinterEx(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
const char *name)
{
struct policy_handle handle;
- BOOL ret = True;
+ bool ret = true;
- if (!call_OpenPrinterEx(p, mem_ctx, name, &handle)) {
- return False;
+ if (!call_OpenPrinterEx(tctx, p, name, &handle)) {
+ return false;
}
- if (!test_GetPrinter(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_GetPrinter(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_EnumForms(p, mem_ctx, &handle, False)) {
- ret = False;
+ if (!test_EnumForms(tctx, p, &handle, false)) {
+ ret = false;
}
- if (!test_AddForm(p, mem_ctx, &handle, False)) {
- ret = False;
+ if (!test_AddForm(tctx, p, &handle, false)) {
+ ret = false;
}
- if (!test_EnumPrinterData(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_EnumPrinterData(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_EnumPrinterDataEx(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_EnumPrinterDataEx(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_PausePrinter(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_PausePrinter(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_DoPrintTest(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_DoPrintTest(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_ResumePrinter(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_ResumePrinter(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_SetPrinterData(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_SetPrinterData(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_SecondaryClosePrinter(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_SecondaryClosePrinter(tctx, p, &handle)) {
+ ret = false;
}
- if (!test_ClosePrinter(p, mem_ctx, &handle)) {
- ret = False;
+ if (!test_ClosePrinter(tctx, p, &handle)) {
+ ret = false;
}
return ret;
}
-static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_EnumPrinters_old(struct torture_context *tctx, struct dcerpc_pipe *p)
{
struct spoolss_EnumPrinters r;
NTSTATUS status;
uint16_t levels[] = {1, 2, 4, 5};
int i;
- BOOL ret = True;
+ bool ret = true;
for (i=0;i<ARRAY_SIZE(levels);i++) {
union spoolss_PrinterInfo *info;
@@ -1918,38 +1536,26 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.buffer = NULL;
r.in.offered = 0;
- printf("\nTesting EnumPrinters level %u\n", r.in.level);
+ torture_comment(tctx, "Testing EnumPrinters level %u\n", r.in.level);
- status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPrinters failed - %s\n", nt_errstr(status));
- ret = False;
- continue;
- }
+ status = dcerpc_spoolss_EnumPrinters(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumPrinters(p, tctx, &r);
}
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPrinters failed - %s\n",
- nt_errstr(status));
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("EnumPrinters failed - %s\n",
- win_errstr(r.out.result));
- continue;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "EnumPrinters failed");
if (!r.out.info) {
- printf("No printers returned\n");
- continue;
+ torture_comment(tctx, "No printers returned\n");
+ return true;
}
info = r.out.info;
@@ -1957,14 +1563,14 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
for (j=0;j<r.out.count;j++) {
if (r.in.level == 1) {
/* the names appear to be comma-separated name lists? */
- char *name = talloc_strdup(mem_ctx, info[j].info1.name);
+ char *name = talloc_strdup(tctx, info[j].info1.name);
char *comma = strchr(name, ',');
if (comma) *comma = 0;
- if (!test_OpenPrinter(p, mem_ctx, name)) {
- ret = False;
+ if (!test_OpenPrinter(tctx, p, name)) {
+ ret = false;
}
- if (!test_OpenPrinterEx(p, mem_ctx, name)) {
- ret = False;
+ if (!test_OpenPrinterEx(tctx, p, name)) {
+ ret = false;
}
}
}
@@ -1974,7 +1580,7 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
}
#if 0
-static BOOL test_GetPrinterDriver2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_GetPrinterDriver2(struct dcerpc_pipe *p,
struct policy_handle *handle,
const char *driver_name)
{
@@ -1991,134 +1597,163 @@ static BOOL test_GetPrinterDriver2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf("Testing GetPrinterDriver2\n");
- status = dcerpc_spoolss_GetPrinterDriver2(p, mem_ctx, &r);
+ status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("GetPrinterDriver2 failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_GetPrinterDriver2(p, mem_ctx, &r);
+ status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r);
}
if (!NT_STATUS_IS_OK(status)) {
printf("GetPrinterDriver2 failed - %s\n",
nt_errstr(status));
- return False;
+ return false;
}
if (!W_ERROR_IS_OK(r.out.result)) {
printf("GetPrinterDriver2 failed - %s\n",
win_errstr(r.out.result));
- return False;
+ return false;
}
- return True;
+ return true;
}
#endif
-static BOOL test_EnumPrinterDrivers_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_EnumPrinterDrivers_old(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
struct spoolss_EnumPrinterDrivers r;
NTSTATUS status;
uint16_t levels[] = {1, 2, 3, 4, 5, 6};
int i;
- BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
- r.in.server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.environment = "Windows NT x86";
r.in.level = levels[i];
r.in.buffer = NULL;
r.in.offered = 0;
- printf("\nTesting EnumPrinterDrivers level %u\n", r.in.level);
+ torture_comment(tctx, "Testing EnumPrinterDrivers level %u\n", r.in.level);
- status = dcerpc_spoolss_EnumPrinterDrivers(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumPrinterDrivers(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPrinterDrivers failed - %s\n",
- nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDrivers failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
r.in.offered = r.out.needed;
- status = dcerpc_spoolss_EnumPrinterDrivers(p, mem_ctx, &r);
+ status = dcerpc_spoolss_EnumPrinterDrivers(p, tctx, &r);
}
- if (!NT_STATUS_IS_OK(status)) {
- printf("EnumPrinterDrivers failed - %s\n",
- nt_errstr(status));
- ret = False;
- break;
- }
+ torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDrivers failed");
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("EnumPrinterDrivers failed - %s\n",
- win_errstr(r.out.result));
- ret = False;
- break;
- }
+ torture_assert_werr_ok(tctx, r.out.result, "EnumPrinterDrivers failed");
if (!r.out.info) {
- printf("No printer drivers returned\n");
+ torture_comment(tctx, "No printer drivers returned\n");
break;
}
}
- return ret;
+ return true;
+}
+
+/** Test that makes sure that calling ReplyOpenPrinter()
+ * on Samba 4 will cause an irpc broadcast call.
+ */
+static bool test_ReplyOpenPrinter(struct torture_context *tctx,
+ struct dcerpc_pipe *pipe)
+{
+ struct spoolss_ReplyOpenPrinter r;
+ struct spoolss_ReplyClosePrinter s;
+ struct policy_handle h;
+
+ r.in.server_name = "earth";
+ r.in.printer_local = 2;
+ r.in.type = REG_DWORD;
+ r.in.unknown1 = 0;
+ r.in.unknown2 = 0;
+ r.out.handle = &h;
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_spoolss_ReplyOpenPrinter(pipe, tctx, &r),
+ "spoolss_ReplyOpenPrinter call failed");
+
+ torture_assert_werr_ok(tctx, r.out.result, "error return code");
+
+ s.in.handle = &h;
+ s.out.handle = &h;
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_spoolss_ReplyClosePrinter(pipe, tctx, &s),
+ "spoolss_ReplyClosePrinter call failed");
+
+ torture_assert_werr_ok(tctx, r.out.result, "error return code");
+
+ return true;
}
bool torture_rpc_spoolss(struct torture_context *torture)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- BOOL ret = True;
+ NTSTATUS status;
+ struct dcerpc_pipe *p;
+ bool ret = true;
struct test_spoolss_context *ctx;
status = torture_rpc_connection(torture, &p, &ndr_table_spoolss);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ctx = talloc_zero(torture, struct test_spoolss_context);
- ctx->p = p;
-
- ret &= test_OpenPrinter_server(ctx);
-
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "W3SvcInstalled");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "BeepEnabled");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "EventLog");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "NetPopup");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "NetPopupToComputer");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "MajorVersion");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "MinorVersion");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "DefaultSpoolDirectory");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "Architecture");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "DsPresent");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "OSVersion");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "OSVersionEx");
- ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "DNSMachineName");
- ret &= test_EnumForms(ctx->p, ctx, &ctx->server_handle, True);
- ret &= test_AddForm(ctx->p, ctx, &ctx->server_handle, True);
- ret &= test_EnumPorts(ctx);
- ret &= test_GetPrinterDriverDirectory(ctx);
- ret &= test_EnumPrinterDrivers(ctx);
- ret &= test_EnumMonitors(ctx);
- ret &= test_EnumPrintProcessors(ctx);
- ret &= test_EnumPrinters(ctx);
- ret &= test_OpenPrinter_badnames(p, torture);
- ret &= test_AddPort(p, torture);
- ret &= test_EnumPorts_old(p, torture);
- ret &= test_EnumPrinters_old(p, torture);
- ret &= test_EnumPrinterDrivers_old(p, torture);
+
+ ret &= test_OpenPrinter_server(torture, p, ctx);
+
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "W3SvcInstalled");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "BeepEnabled");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "EventLog");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "NetPopup");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "NetPopupToComputer");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "MajorVersion");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "MinorVersion");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "DefaultSpoolDirectory");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "Architecture");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "DsPresent");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "OSVersion");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "OSVersionEx");
+ ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "DNSMachineName");
+ ret &= test_EnumForms(torture, p, &ctx->server_handle, true);
+ ret &= test_AddForm(torture, p, &ctx->server_handle, true);
+ ret &= test_EnumPorts(torture, p, ctx);
+ ret &= test_GetPrinterDriverDirectory(torture, p, ctx);
+ ret &= test_EnumPrinterDrivers(torture, p, ctx);
+ ret &= test_EnumMonitors(torture, p, ctx);
+ ret &= test_EnumPrintProcessors(torture, p, ctx);
+ ret &= test_EnumPrinters(torture, p, ctx);
+ ret &= test_OpenPrinter_badname(torture, p, "__INVALID_PRINTER__");
+ ret &= test_OpenPrinter_badname(torture, p, "\\\\__INVALID_HOST__");
+ ret &= test_OpenPrinter_badname(torture, p, "");
+ ret &= test_OpenPrinter_badname(torture, p, "\\\\\\");
+ ret &= test_OpenPrinter_badname(torture, p, "\\\\\\__INVALID_PRINTER__");
+ ret &= test_OpenPrinter_badname(torture, p, talloc_asprintf(torture, "\\\\%s\\", dcerpc_server_name(p)));
+ ret &= test_OpenPrinter_badname(torture, p,
+ talloc_asprintf(torture, "\\\\%s\\__INVALID_PRINTER__", dcerpc_server_name(p)));
+
+
+ ret &= test_AddPort(torture, p);
+ ret &= test_EnumPorts_old(torture, p);
+ ret &= test_EnumPrinters_old(torture, p);
+ ret &= test_EnumPrinterDrivers_old(torture, p);
+ ret &= test_ReplyOpenPrinter(torture, p);
return ret;
}
diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c
new file mode 100644
index 0000000000..e44c2a874b
--- /dev/null
+++ b/source4/torture/rpc/spoolss_notify.c
@@ -0,0 +1,296 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for spoolss rpc notify operations
+
+ Copyright (C) Jelmer Vernooij 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#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"
+#include "lib/events/events.h"
+#include "smbd/process_model.h"
+#include "smb_server/smb_server.h"
+#include "lib/socket/netif.h"
+#include "dlinklist.h"
+#include "ntvfs/ntvfs.h"
+#include "param/param.h"
+
+static NTSTATUS spoolss__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
+{
+ return NT_STATUS_OK;
+}
+
+static void spoolss__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
+{
+}
+
+static NTSTATUS spoolss__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
+{
+ NTSTATUS status;
+ uint16_t opnum = dce_call->pkt.u.request.opnum;
+
+ dce_call->fault_code = 0;
+
+ if (opnum >= ndr_table_spoolss.num_calls) {
+ dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
+ return NT_STATUS_NET_WRITE_FAULT;
+ }
+
+ *r = talloc_size(mem_ctx, ndr_table_spoolss.calls[opnum].struct_size);
+ NT_STATUS_HAVE_NO_MEMORY(*r);
+
+ /* unravel the NDR for the packet */
+ status = ndr_table_spoolss.calls[opnum].ndr_pull(pull, NDR_IN, *r);
+ if (!NT_STATUS_IS_OK(status)) {
+ dcerpc_log_packet(&ndr_table_spoolss, opnum, NDR_IN,
+ &dce_call->pkt.u.request.stub_and_verifier);
+ dce_call->fault_code = DCERPC_FAULT_NDR;
+ return NT_STATUS_NET_WRITE_FAULT;
+ }
+
+ return NT_STATUS_OK;
+}
+
+/* FIXME: What context does this belong in ? -- JRV20070903 */
+static struct received_packet {
+ uint16_t opnum;
+ void *r;
+ struct received_packet *prev, *next;
+} *received_packets = NULL;
+
+
+static NTSTATUS spoolss__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
+{
+ uint16_t opnum = dce_call->pkt.u.request.opnum;
+ struct received_packet *rp;
+
+ rp = talloc_zero(mem_ctx, struct received_packet);
+ rp->opnum = opnum;
+ rp->r = talloc_reference(mem_ctx, r);
+
+ DLIST_ADD_END(received_packets, rp, struct received_packet *);
+
+ switch (opnum) {
+ case 58: {
+ struct spoolss_ReplyOpenPrinter *r2 = (struct spoolss_ReplyOpenPrinter *)r;
+ r2->out.result = WERR_OK;
+ break;
+ }
+
+ default:
+ dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
+ break;
+ }
+
+ if (dce_call->fault_code != 0) {
+ dcerpc_log_packet(&ndr_table_spoolss, opnum, NDR_IN,
+ &dce_call->pkt.u.request.stub_and_verifier);
+ return NT_STATUS_NET_WRITE_FAULT;
+ }
+ return NT_STATUS_OK;
+}
+
+
+static NTSTATUS spoolss__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
+{
+ return NT_STATUS_OK;
+}
+
+
+static NTSTATUS spoolss__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
+{
+ NTSTATUS status;
+ uint16_t opnum = dce_call->pkt.u.request.opnum;
+
+ status = ndr_table_spoolss.calls[opnum].ndr_push(push, NDR_OUT, r);
+ if (!NT_STATUS_IS_OK(status)) {
+ dce_call->fault_code = DCERPC_FAULT_NDR;
+ return NT_STATUS_NET_WRITE_FAULT;
+ }
+
+ return NT_STATUS_OK;
+}
+
+const static struct dcesrv_interface notify_test_spoolss_interface = {
+ .name = "spoolss",
+ .syntax_id = {{0x12345678,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xab}},1.0},
+ .bind = spoolss__op_bind,
+ .unbind = spoolss__op_unbind,
+ .ndr_pull = spoolss__op_ndr_pull,
+ .dispatch = spoolss__op_dispatch,
+ .reply = spoolss__op_reply,
+ .ndr_push = spoolss__op_ndr_push
+};
+
+static bool spoolss__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
+{
+ if (notify_test_spoolss_interface.syntax_id.if_version == if_version &&
+ GUID_equal(&notify_test_spoolss_interface.syntax_id.uuid, uuid)) {
+ memcpy(iface,&notify_test_spoolss_interface, sizeof(*iface));
+ return true;
+ }
+
+ return false;
+}
+
+static bool spoolss__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
+{
+ if (strcmp(notify_test_spoolss_interface.name, name)==0) {
+ memcpy(iface, &notify_test_spoolss_interface, sizeof(*iface));
+ return true;
+ }
+
+ return false;
+}
+
+static NTSTATUS spoolss__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
+{
+ int i;
+
+ for (i=0;i<ndr_table_spoolss.endpoints->count;i++) {
+ NTSTATUS ret;
+ const char *name = ndr_table_spoolss.endpoints->names[i];
+
+ ret = dcesrv_interface_register(dce_ctx, name, &notify_test_spoolss_interface, NULL);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(1,("spoolss_op_init_server: failed to register endpoint '%s'\n",name));
+ return ret;
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
+static bool test_RFFPCNEx(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ struct spoolss_OpenPrinter q;
+ struct spoolss_RemoteFindFirstPrinterChangeNotifyEx r;
+ struct dcesrv_endpoint_server ep_server;
+ NTSTATUS status;
+ struct dcesrv_context *dce_ctx;
+ const char *endpoints[] = { "spoolss", NULL };
+ struct spoolss_NotifyOptionsContainer t1;
+ struct spoolss_ClosePrinter cp;
+
+ struct policy_handle handle;
+ const char *address;
+
+ ZERO_STRUCT(q);
+
+ q.in.printername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+ q.in.datatype = NULL;
+ q.in.devmode_ctr.devmode= NULL;
+ q.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ q.out.handle = &handle;
+
+ torture_comment(tctx, "Testing OpenPrinter(%s)\n", q.in.printername);
+
+ status = dcerpc_spoolss_OpenPrinter(p, tctx, &q);
+
+ torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed");
+
+ torture_assert_werr_ok(tctx, q.out.result, "OpenPrinter failed");
+
+ /* Start DCE/RPC server */
+
+ /* fill in our name */
+ ep_server.name = "spoolss";
+
+ /* fill in all the operations */
+ ep_server.init_server = spoolss__op_init_server;
+
+ ep_server.interface_by_uuid = spoolss__op_interface_by_uuid;
+ ep_server.interface_by_name = spoolss__op_interface_by_name;
+
+ torture_assert_ntstatus_ok(tctx, dcerpc_register_ep_server(&ep_server),
+ "unable to register spoolss server");
+
+ lp_set_cmdline(global_loadparm, "dcerpc endpoint servers", "spoolss");
+
+ address = iface_n_ip(0);
+ torture_comment(tctx, "Listening for callbacks on %s\n", address);
+ status = smbsrv_add_socket(p->conn->event_ctx, &single_ops, address);
+ torture_assert_ntstatus_ok(tctx, status, "starting smb server");
+
+ status = dcesrv_init_context(tctx, endpoints, &dce_ctx);
+ torture_assert_ntstatus_ok(tctx, status,
+ "unable to initialize DCE/RPC server");
+
+
+ r.in.flags = 0;
+ r.in.str = talloc_asprintf(tctx, "\\\\%s", address);
+ r.in.options = 0;
+ r.in.printer_local = 123;
+ t1.version = 2;
+ t1.flags = 0;
+ t1.count = 2;
+ t1.options = talloc_zero_array(tctx, struct spoolss_NotifyOptionsArray, 2);
+ t1.options[0].type = SPOOLSS_NOTIFY_PRINTER;
+ t1.options[0].count = 1;
+ t1.options[0].fields = talloc_array(t1.options, enum spoolss_Field, 1);
+ t1.options[0].fields[0] = SPOOLSS_FIELD_SERVER_NAME;
+
+ t1.options[1].type = SPOOLSS_NOTIFY_JOB;
+ t1.options[1].count = 1;
+ t1.options[1].fields = talloc_array(t1.options, enum spoolss_Field, 1);
+ t1.options[1].fields[0] = SPOOLSS_FIELD_PRINTER_NAME;
+
+ r.in.t1 = &t1;
+ r.in.handle = &handle;
+
+
+ status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(p, tctx, &r);
+
+ torture_assert_ntstatus_ok(tctx, status, "FFPCNEx failed");
+
+ torture_assert_werr_ok(tctx, r.out.result, "error return code for FFPCNEx");
+
+ cp.in.handle = &handle;
+ cp.out.handle = &handle;
+
+ torture_comment(tctx, "Testing ClosePrinter\n");
+
+ status = dcerpc_spoolss_ClosePrinter(p, tctx, &cp);
+ torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed");
+
+ /* We should've had an incoming packet 58 (ReplyOpenPrinter) */
+ torture_assert(tctx, received_packets != NULL, "no packets received");
+ torture_assert_int_equal(tctx, received_packets->opnum, 58, "invalid opnum");
+
+ /* Shut down DCE/RPC server */
+ talloc_free(dce_ctx);
+
+ return true;
+}
+
+struct torture_suite *torture_rpc_spoolss_notify(TALLOC_CTX *mem_ctx)
+{
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "SPOOLSS-NOTIFY");
+
+ struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite,
+ "notify", &ndr_table_spoolss);
+
+ ntvfs_init();
+ torture_rpc_tcase_add_test(tcase, "testRFFPCNEx", test_RFFPCNEx);
+
+ return suite;
+}
diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c
index a51dc96876..1fe1221b0d 100644
--- a/source4/torture/rpc/srvsvc.c
+++ b/source4/torture/rpc/srvsvc.c
@@ -27,70 +27,52 @@
/**************************/
/* srvsvc_NetCharDev */
/**************************/
-static BOOL test_NetCharDevGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_NetCharDevGetInfo(struct dcerpc_pipe *p, struct torture_context *tctx,
const char *devname)
{
NTSTATUS status;
struct srvsvc_NetCharDevGetInfo r;
uint32_t levels[] = {0, 1};
int i;
- BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.device_name = devname;
for (i=0;i<ARRAY_SIZE(levels);i++) {
ZERO_STRUCT(r.out);
r.in.level = levels[i];
- d_printf("testing NetCharDevGetInfo level %u on device '%s'\n",
+ torture_comment(tctx, "testing NetCharDevGetInfo level %u on device '%s'\n",
r.in.level, r.in.device_name);
- status = dcerpc_srvsvc_NetCharDevGetInfo(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetCharDevGetInfo level %u on device '%s' failed - %s\n",
- r.in.level, r.in.device_name, nt_errstr(status));
- ret = False;
- continue;
- }
- if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetCharDevGetInfo level %u on device '%s' failed - %s\n",
- r.in.level, r.in.device_name, win_errstr(r.out.result));
- continue;
- }
+ status = dcerpc_srvsvc_NetCharDevGetInfo(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "NetCharDevGetInfo failed");
+ torture_assert_werr_ok(tctx, r.out.result, "NetCharDevGetInfo failed");
}
- return ret;
+ return true;
}
-static BOOL test_NetCharDevControl(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_NetCharDevControl(struct dcerpc_pipe *p, struct torture_context *tctx,
const char *devname)
{
NTSTATUS status;
struct srvsvc_NetCharDevControl r;
uint32_t opcodes[] = {0, 1};
int i;
- BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.device_name = devname;
for (i=0;i<ARRAY_SIZE(opcodes);i++) {
ZERO_STRUCT(r.out);
r.in.opcode = opcodes[i];
- d_printf("testing NetCharDevControl opcode %u on device '%s'\n",
+ torture_comment(tctx, "testing NetCharDevControl opcode %u on device '%s'\n",
r.in.opcode, r.in.device_name);
- status = dcerpc_srvsvc_NetCharDevControl(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetCharDevControl opcode %u failed - %s\n", r.in.opcode, nt_errstr(status));
- ret = False;
- continue;
- }
- if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetCharDevControl opcode %u failed - %s\n", r.in.opcode, win_errstr(r.out.result));
- continue;
- }
+ status = dcerpc_srvsvc_NetCharDevControl(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "NetCharDevControl failed");
+ torture_assert_werr_ok(tctx, r.out.result, "NetCharDevControl failed");
}
- return ret;
+ return true;
}
static bool test_NetCharDevEnum(struct torture_context *tctx,
@@ -101,7 +83,6 @@ static bool test_NetCharDevEnum(struct torture_context *tctx,
struct srvsvc_NetCharDevCtr0 c0;
uint32_t levels[] = {0, 1};
int i;
- BOOL ret = True;
r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.ctr.ctr0 = &c0;
@@ -113,18 +94,13 @@ static bool test_NetCharDevEnum(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
int j;
-
ZERO_STRUCT(r.out);
r.in.level = levels[i];
- printf("testing NetCharDevEnum level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetCharDevEnum level %u\n", r.in.level);
status = dcerpc_srvsvc_NetCharDevEnum(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetCharDevEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetCharDevEnum failed");
if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetCharDevEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
+ torture_comment(tctx, "NetCharDevEnum failed: %s\n", win_errstr(r.out.result));
continue;
}
@@ -134,58 +110,48 @@ static bool test_NetCharDevEnum(struct torture_context *tctx,
const char *device;
device = r.out.ctr.ctr1->array[j].device;
if (!test_NetCharDevGetInfo(p, tctx, device)) {
- ret = False;
+ return false;
}
if (!test_NetCharDevControl(p, tctx, device)) {
- ret = False;
+ return false;
}
}
}
}
- return ret;
+ return true;
}
/**************************/
/* srvsvc_NetCharDevQ */
/**************************/
-static BOOL test_NetCharDevQGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_NetCharDevQGetInfo(struct dcerpc_pipe *p, struct torture_context *tctx,
const char *devicequeue)
{
NTSTATUS status;
struct srvsvc_NetCharDevQGetInfo r;
uint32_t levels[] = {0, 1};
int i;
- BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.queue_name = devicequeue;
- r.in.user = talloc_asprintf(mem_ctx,"Administrator");
+ r.in.user = talloc_asprintf(tctx,"Administrator");
for (i=0;i<ARRAY_SIZE(levels);i++) {
ZERO_STRUCT(r.out);
r.in.level = levels[i];
- d_printf("testing NetCharDevQGetInfo level %u on devicequeue '%s'\n",
+ torture_comment(tctx, "testing NetCharDevQGetInfo level %u on devicequeue '%s'\n",
r.in.level, r.in.queue_name);
- status = dcerpc_srvsvc_NetCharDevQGetInfo(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetCharDevQGetInfo level %u on devicequeue '%s' failed - %s\n",
- r.in.level, r.in.queue_name, nt_errstr(status));
- ret = False;
- continue;
- }
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("NetCharDevQGetInfo level %u on devicequeue '%s' failed - %s\n",
- r.in.level, r.in.queue_name, win_errstr(r.out.result));
- continue;
- }
+ status = dcerpc_srvsvc_NetCharDevQGetInfo(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "NetCharDevQGetInfo failed");
+ torture_assert_werr_ok(tctx, r.out.result, "NetCharDevQGetInfo failed");
}
- return ret;
+ return true;
}
#if 0
-static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
const char *devicequeue)
{
NTSTATUS status;
@@ -193,7 +159,7 @@ static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
uint32_t parm_error;
uint32_t levels[] = {0, 1};
int i;
- BOOL ret = True;
+ bool ret = true;
r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
r.in.queue_name = devicequeue;
@@ -225,7 +191,7 @@ static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
d_printf("NetCharDevQSetInfo level %u on devicequeue '%s' failed - %s\n",
r.in.level, r.in.queue_name, nt_errstr(status));
- ret = False;
+ ret = false;
continue;
}
if (!W_ERROR_IS_OK(r.out.result)) {
@@ -239,15 +205,14 @@ static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
#endif
-static BOOL test_NetCharDevQEnum(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+static bool test_NetCharDevQEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetCharDevQEnum r;
struct srvsvc_NetCharDevQCtr0 c0;
uint32_t levels[] = {0, 1};
int i;
- BOOL ret = True;
r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.user = talloc_asprintf(tctx,"%s","Administrator");
@@ -262,15 +227,11 @@ static BOOL test_NetCharDevQEnum(struct torture_context *tctx,
ZERO_STRUCT(r.out);
r.in.level = levels[i];
- printf("testing NetCharDevQEnum level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetCharDevQEnum level %u\n", r.in.level);
status = dcerpc_srvsvc_NetCharDevQEnum(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetCharDevQEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetCharDevQEnum failed");
if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetCharDevQEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
+ torture_comment(tctx, "NetCharDevQEnum failed: %s\n", win_errstr(r.out.result));
continue;
}
@@ -280,27 +241,26 @@ static BOOL test_NetCharDevQEnum(struct torture_context *tctx,
const char *device;
device = r.out.ctr.ctr1->array[j].device;
if (!test_NetCharDevQGetInfo(p, tctx, device)) {
- ret = False;
+ return false;
}
}
}
}
- return ret;
+ return true;
}
/**************************/
/* srvsvc_NetConn */
/**************************/
-static BOOL test_NetConnEnum(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+static bool test_NetConnEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetConnEnum r;
struct srvsvc_NetConnCtr0 c0;
uint32_t levels[] = {0, 1};
int i;
- BOOL ret = True;
r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.path = talloc_asprintf(tctx,"%s","ADMIN$");
@@ -313,34 +273,28 @@ static BOOL test_NetConnEnum(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
ZERO_STRUCT(r.out);
r.in.level = levels[i];
- d_printf("testing NetConnEnum level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetConnEnum level %u\n", r.in.level);
status = dcerpc_srvsvc_NetConnEnum(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetConnEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetConnEnum failed");
if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetConnEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
- continue;
+ torture_comment(tctx, "NetConnEnum failed: %s\n", win_errstr(r.out.result));
}
}
- return ret;
+ return true;
}
/**************************/
/* srvsvc_NetFile */
/**************************/
-static BOOL test_NetFileEnum(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+static bool test_NetFileEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetFileEnum r;
struct srvsvc_NetFileCtr3 c3;
uint32_t levels[] = {2, 3};
int i;
- BOOL ret = True;
r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.path = NULL;
@@ -354,34 +308,28 @@ static BOOL test_NetFileEnum(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
ZERO_STRUCT(r.out);
r.in.level = levels[i];
- d_printf("testing NetFileEnum level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetFileEnum level %u\n", r.in.level);
status = dcerpc_srvsvc_NetFileEnum(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetFileEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetFileEnum failed");
if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetFileEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
- continue;
+ torture_comment(tctx, "NetFileEnum failed: %s\n", win_errstr(r.out.result));
}
}
- return ret;
+ return true;
}
/**************************/
/* srvsvc_NetSess */
/**************************/
-static BOOL test_NetSessEnum(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+static bool test_NetSessEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetSessEnum r;
struct srvsvc_NetSessCtr0 c0;
uint32_t levels[] = {0, 1, 2, 10, 502};
int i;
- BOOL ret = True;
r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.client = NULL;
@@ -395,49 +343,37 @@ static BOOL test_NetSessEnum(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
ZERO_STRUCT(r.out);
r.in.level = levels[i];
- d_printf("testing NetSessEnum level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetSessEnum level %u\n", r.in.level);
status = dcerpc_srvsvc_NetSessEnum(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetSessEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetSessEnum failed");
if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetSessEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
- continue;
+ torture_comment(tctx, "NetSessEnum failed: %s\n", win_errstr(r.out.result));
}
}
- return ret;
+ return true;
}
/**************************/
/* srvsvc_NetShare */
/**************************/
-static BOOL test_NetShareCheck(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_NetShareCheck(struct dcerpc_pipe *p, struct torture_context *tctx,
const char *device_name)
{
NTSTATUS status;
struct srvsvc_NetShareCheck r;
- BOOL ret = True;
- r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.device_name = device_name;
- d_printf("testing NetShareCheck on device '%s'\n", r.in.device_name);
-
- status = dcerpc_srvsvc_NetShareCheck(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_srvsvc_NetShareCheck on device '%s' failed - %s\n",
- r.in.device_name, nt_errstr(status));
- ret = False;
- } else if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetShareCheck on device '%s' failed - %s\n",
- r.in.device_name, win_errstr(r.out.result));
- ret = False;
- }
+ torture_comment(tctx,
+ "testing NetShareCheck on device '%s'\n", r.in.device_name);
- return ret;
+ status = dcerpc_srvsvc_NetShareCheck(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_srvsvc_NetShareCheck failed");
+ torture_assert_werr_ok(tctx, r.out.result, "NetShareCheck failed");
+
+ return true;
}
static bool test_NetShareGetInfo(struct torture_context *tctx,
@@ -459,7 +395,6 @@ static bool test_NetShareGetInfo(struct torture_context *tctx,
{ 1005, WERR_OK, WERR_OK },
};
int i;
- BOOL ret = True;
r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.share_name = sharename;
@@ -472,32 +407,21 @@ static bool test_NetShareGetInfo(struct torture_context *tctx,
if (admin) expected = levels[i].admin_status;
ZERO_STRUCT(r.out);
- d_printf("testing NetShareGetInfo level %u on share '%s'\n",
+ torture_comment(tctx, "testing NetShareGetInfo level %u on share '%s'\n",
r.in.level, r.in.share_name);
status = dcerpc_srvsvc_NetShareGetInfo(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
- r.in.level, r.in.share_name, nt_errstr(status));
- ret = False;
- continue;
- }
- if (!W_ERROR_EQUAL(r.out.result, expected)) {
- d_printf("NetShareGetInfo level %u on share '%s' failed - %s (expected %s)\n",
- r.in.level, r.in.share_name, win_errstr(r.out.result),
- win_errstr(expected));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetShareGetInfo failed");
+ torture_assert_werr_equal(tctx, r.out.result, expected, "NetShareGetInfo failed");
if (r.in.level != 2) continue;
if (!r.out.info.info2 || !r.out.info.info2->path) continue;
if (!test_NetShareCheck(p, tctx, r.out.info.info2->path)) {
- ret = False;
+ return false;
}
}
- return ret;
+ return true;
}
static bool test_NetShareGetInfoAdminFull(struct torture_context *tctx,
@@ -536,11 +460,6 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx,
{ 1501, WERR_OK },
};
int i;
- BOOL ret = True;
-
- if (!torture_setting_bool(tctx, "dangerous", false))
- torture_skip(tctx,
- "NetShareAddSetDel disabled - enable dangerous tests to use\n");
a.in.server_unc = r.in.server_unc = q.in.server_unc = d.in.server_unc =
talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
@@ -560,15 +479,8 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx,
a.in.parm_error = NULL;
status = dcerpc_srvsvc_NetShareAdd(p, tctx, &a);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetShareAdd level 2 on share 'testshare' failed - %s\n",
- nt_errstr(status));
- return False;
- } else if (!W_ERROR_EQUAL(a.out.result, WERR_OK)) {
- d_printf("NetShareAdd level 2 on share 'testshare' failed - %s\n",
- win_errstr(a.out.result));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetShareAdd level 2 on share 'testshare' failed");
+ torture_assert_werr_ok(tctx, a.out.result, "NetShareAdd level 2 on share 'testshare' failed");
r.in.parm_error = NULL;
@@ -579,7 +491,7 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx,
r.in.level = levels[i].level;
ZERO_STRUCT(r.out);
- d_printf("testing NetShareSetInfo level %u on share '%s'\n",
+ torture_comment(tctx, "testing NetShareSetInfo level %u on share '%s'\n",
r.in.level, r.in.share_name);
switch (levels[i].level) {
@@ -648,73 +560,45 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx,
}
status = dcerpc_srvsvc_NetShareSetInfo(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
- r.in.level, r.in.share_name, nt_errstr(status));
- ret = False;
- continue;
- } else if (!W_ERROR_EQUAL(r.out.result, levels[i].expected)) {
- d_printf("NetShareSetInfo level %u on share '%s' failed - %s (expected %s)\n",
- r.in.level, r.in.share_name, win_errstr(r.out.result),
- win_errstr(levels[i].expected));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetShareGetInfo failed");
+ torture_assert_werr_equal(tctx, r.out.result, levels[i].expected, "NetShareSetInfo failed");
q.in.share_name = r.in.share_name;
status = dcerpc_srvsvc_NetShareGetInfo(p, tctx, &q);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
- q.in.level, q.in.share_name, nt_errstr(status));
- ret = False;
- continue;
- } else if (!W_ERROR_EQUAL(q.out.result, WERR_OK)) {
- d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n",
- q.in.level, q.in.share_name, win_errstr(q.out.result));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetShareGetInfo failed");
+ torture_assert_werr_ok(tctx, q.out.result, "NetShareGetInfo failed");
+
+ torture_assert_str_equal(tctx, q.out.info.info502->name, r.in.share_name,
+ "share name invalid");
- if (strcmp(q.out.info.info502->name, r.in.share_name) != 0) {
- ret = False;
- }
switch (levels[i].level) {
case 0:
break;
case 1:
- if (strcmp(q.out.info.info502->comment, "test comment 1") != 0)
- ret = False;
+ torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 1", "comment");
break;
case 2:
- if (strcmp(q.out.info.info502->comment, "test comment 2") != 0)
- ret = False;
- if (q.out.info.info2->max_users != 2)
- ret = False;
- if (strcmp(q.out.info.info2->path, "C:\\") != 0)
- ret = False;
+ torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 2", "comment");
+ torture_assert_int_equal(tctx, q.out.info.info2->max_users, 2, "max users");
+ torture_assert_str_equal(tctx, q.out.info.info2->path, "C:\\", "path");
break;
case 501:
- if (strcmp(q.out.info.info501->comment, "test comment 501") != 0)
- ret = False;
+ torture_assert_str_equal(tctx, q.out.info.info501->comment, "test comment 501", "comment");
break;
case 502:
- if (strcmp(q.out.info.info502->comment, "test comment 502") != 0)
- ret = False;
- if (q.out.info.info2->max_users != 502)
- ret = False;
- if (strcmp(q.out.info.info2->path, "C:\\") != 0)
- ret = False;
+ torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 502", "comment");
+ torture_assert_int_equal(tctx, q.out.info.info2->max_users, 502, "max users");
+ torture_assert_str_equal(tctx, q.out.info.info2->path, "C:\\", "path");
break;
case 1004:
- if (strcmp(q.out.info.info502->comment, "test comment 1004") != 0)
- ret = False;
+ torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 1004",
+ "comment");
break;
case 1005:
break;
case 1006:
- if (q.out.info.info2->max_users != 1006)
- ret = False;
+ torture_assert_int_equal(tctx, q.out.info.info2->max_users, 1006, "Max users");
break;
/* case 1007:
break;
@@ -728,17 +612,10 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx,
d.in.reserved = 0;
status = dcerpc_srvsvc_NetShareDel(p, tctx, &d);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetShareDel on share 'testshare502' failed - %s\n",
- nt_errstr(status));
- ret = False;
- } else if (!W_ERROR_EQUAL(a.out.result, WERR_OK)) {
- d_printf("NetShareDel on share 'testshare502' failed - %s\n",
- win_errstr(d.out.result));
- ret = False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetShareDel on share 'testshare502' failed");
+ torture_assert_werr_ok(tctx, a.out.result, "NetShareDel on share 'testshare502' failed");
- return ret;
+ return true;
}
/**************************/
@@ -763,7 +640,6 @@ static bool test_NetShareEnumAll(struct torture_context *tctx,
{ 502, WERR_ACCESS_DENIED, WERR_OK },
};
int i;
- BOOL ret = True;
uint32_t resume_handle;
ZERO_STRUCT(c0);
@@ -785,19 +661,10 @@ static bool test_NetShareEnumAll(struct torture_context *tctx,
ZERO_STRUCT(r.out);
resume_handle = 0;
- d_printf("testing NetShareEnumAll level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetShareEnumAll level %u\n", r.in.level);
status = dcerpc_srvsvc_NetShareEnumAll(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetShareEnumAll level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
- if (!W_ERROR_EQUAL(r.out.result, expected)) {
- d_printf("NetShareEnumAll level %u failed - %s (expected %s)\n",
- r.in.level, win_errstr(r.out.result),
- win_errstr(expected));
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetShareEnumAll failed");
+ torture_assert_werr_equal(tctx, r.out.result, expected, "NetShareEnumAll failed");
/* call srvsvc_NetShareGetInfo for each returned share */
if (r.in.level == 2 && r.out.ctr.ctr2) {
@@ -805,13 +672,13 @@ static bool test_NetShareEnumAll(struct torture_context *tctx,
const char *name;
name = r.out.ctr.ctr2->array[j].name;
if (!test_NetShareGetInfo(tctx, p, name, admin)) {
- ret = False;
+ return false;
}
}
}
}
- return ret;
+ return true;
}
static bool test_NetShareEnumAllFull(struct torture_context *tctx,
@@ -844,7 +711,6 @@ static bool test_NetShareEnum(struct torture_context *tctx,
{ 502, WERR_ACCESS_DENIED, WERR_OK },
};
int i;
- BOOL ret = True;
r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
r.in.ctr.ctr0 = &c0;
@@ -862,22 +728,13 @@ static bool test_NetShareEnum(struct torture_context *tctx,
ZERO_STRUCT(r.out);
- d_printf("testing NetShareEnum level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetShareEnum level %u\n", r.in.level);
status = dcerpc_srvsvc_NetShareEnum(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetShareEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
- if (!W_ERROR_EQUAL(r.out.result, expected)) {
- d_printf("NetShareEnum level %u failed - %s (expected %s)\n",
- r.in.level, win_errstr(r.out.result),
- win_errstr(expected));
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetShareEnum failed");
+ torture_assert_werr_equal(tctx, r.out.result, expected, "NetShareEnum failed");
}
- return ret;
+ return true;
}
static bool test_NetShareEnumFull(struct torture_context *tctx,
@@ -896,14 +753,13 @@ static bool test_NetShareEnumAnon(struct torture_context *tctx,
/* srvsvc_NetSrv */
/**************************/
static bool test_NetSrvGetInfo(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetSrvGetInfo r;
struct srvsvc_NetSrvInfo503 i503;
uint32_t levels[] = {100, 101, 102, 502, 503};
int i;
- BOOL ret = True;
uint32_t resume_handle;
ZERO_STRUCT(i503);
@@ -914,33 +770,27 @@ static bool test_NetSrvGetInfo(struct torture_context *tctx,
ZERO_STRUCT(r.out);
resume_handle = 0;
r.in.level = levels[i];
- d_printf("testing NetSrvGetInfo level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetSrvGetInfo level %u\n", r.in.level);
status = dcerpc_srvsvc_NetSrvGetInfo(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetSrvGetInfo failed");
if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
- continue;
+ torture_comment(tctx, "NetSrvGetInfo failed: %s\n", win_errstr(r.out.result));
}
}
- return ret;
+ return true;
}
/**************************/
/* srvsvc_NetDisk */
/**************************/
-static BOOL test_NetDiskEnum(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+static bool test_NetDiskEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetDiskEnum r;
uint32_t levels[] = {0};
int i;
- BOOL ret = True;
uint32_t resume_handle=0;
ZERO_STRUCT(r.in);
@@ -950,37 +800,28 @@ static BOOL test_NetDiskEnum(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
ZERO_STRUCT(r.out);
r.in.level = levels[i];
- d_printf("testing NetDiskEnum level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetDiskEnum level %u\n", r.in.level);
status = dcerpc_srvsvc_NetDiskEnum(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- NDR_PRINT_OUT_DEBUG(srvsvc_NetDiskEnum, &r);
- d_printf("NetDiskEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
- if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetDiskEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetDiskEnum failed");
+ torture_assert_werr_ok(tctx, r.out.result, "NetDiskEnum failed");
}
- return ret;
+ return true;
}
/**************************/
/* srvsvc_NetTransport */
/**************************/
static bool test_NetTransportEnum(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetTransportEnum r;
struct srvsvc_NetTransportCtr0 c0;
uint32_t levels[] = {0, 1};
int i;
- BOOL ret = True;
- r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
+ r.in.server_unc = talloc_asprintf(tctx,"\\\\%s", dcerpc_server_name(p));
r.in.transports.ctr0 = &c0;
r.in.transports.ctr0->count = 0;
r.in.transports.ctr0->array = NULL;
@@ -990,46 +831,35 @@ static bool test_NetTransportEnum(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
ZERO_STRUCT(r.out);
r.in.level = levels[i];
- d_printf("testing NetTransportEnum level %u\n", r.in.level);
+ torture_comment(tctx, "testing NetTransportEnum level %u\n", r.in.level);
status = dcerpc_srvsvc_NetTransportEnum(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetTransportEnum level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetTransportEnum failed");
if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetTransportEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
- continue;
+ torture_comment(tctx, "unexpected result: %s\n", win_errstr(r.out.result));
}
}
- return ret;
+ return true;
}
/**************************/
/* srvsvc_NetRemoteTOD */
/**************************/
-static BOOL test_NetRemoteTOD(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+static bool test_NetRemoteTOD(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct srvsvc_NetRemoteTOD r;
- BOOL ret = True;
r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
ZERO_STRUCT(r.out);
- d_printf("testing NetRemoteTOD\n");
+ torture_comment(tctx, "testing NetRemoteTOD\n");
status = dcerpc_srvsvc_NetRemoteTOD(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("NetRemoteTOD failed - %s\n", nt_errstr(status));
- ret = False;
- }
- if (!W_ERROR_IS_OK(r.out.result)) {
- d_printf("NetRemoteTOD failed - %s\n", win_errstr(r.out.result));
- }
+ torture_assert_ntstatus_ok(tctx, status, "NetRemoteTOD failed");
+ torture_assert_werr_ok(tctx, r.out.result, "NetRemoteTOD failed");
- return ret;
+ return true;
}
/**************************/
@@ -1108,7 +938,7 @@ again:
}
if (!W_ERROR_IS_OK(r.out.result)) {
- invalidc = talloc_asprintf_append(invalidc, "%c", (char)n);
+ invalidc = talloc_asprintf_append_buffer(invalidc, "%c", (char)n);
}
talloc_free(name);
@@ -1125,13 +955,14 @@ again:
r.in.flags = 0x0;
}
- return True;
+ return true;
}
struct torture_suite *torture_rpc_srvsvc(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "SRVSVC");
struct torture_rpc_tcase *tcase;
+ struct torture_test *test;
tcase = torture_suite_add_rpc_iface_tcase(suite, "srvsvc (admin access)", &ndr_table_srvsvc);
@@ -1147,8 +978,9 @@ struct torture_suite *torture_rpc_srvsvc(TALLOC_CTX *mem_ctx)
torture_rpc_tcase_add_test(tcase, "NetRemoteTOD", test_NetRemoteTOD);
torture_rpc_tcase_add_test(tcase, "NetShareEnum", test_NetShareEnumFull);
torture_rpc_tcase_add_test(tcase, "NetShareGetInfo", test_NetShareGetInfoAdminFull);
- torture_rpc_tcase_add_test(tcase, "NetShareAddSetDel",
- test_NetShareAddSetDel);
+ test = torture_rpc_tcase_add_test(tcase, "NetShareAddSetDel",
+ test_NetShareAddSetDel);
+ test->dangerous = true;
torture_rpc_tcase_add_test(tcase, "NetNameValidate", test_NetNameValidate);
tcase = torture_suite_add_anon_rpc_iface_tcase(suite,
diff --git a/source4/torture/rpc/svcctl.c b/source4/torture/rpc/svcctl.c
index 2f2b4ec485..c9006baaf5 100644
--- a/source4/torture/rpc/svcctl.c
+++ b/source4/torture/rpc/svcctl.c
@@ -80,7 +80,7 @@ static bool test_EnumServicesStatus(struct torture_context *tctx, struct dcerpc_
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
r.in.buf_size = *r.out.bytes_needed;
- r.out.service = talloc_size(tctx, *r.out.bytes_needed);
+ r.out.service = talloc_array(tctx, uint8_t, *r.out.bytes_needed);
status = dcerpc_svcctl_EnumServicesStatusW(p, tctx, &r);
diff --git a/source4/torture/rpc/testjoin.c b/source4/torture/rpc/testjoin.c
index 56a0fccde4..725799f2dd 100644
--- a/source4/torture/rpc/testjoin.c
+++ b/source4/torture/rpc/testjoin.c
@@ -36,6 +36,7 @@
#include "libcli/auth/libcli_auth.h"
#include "torture/rpc/rpc.h"
#include "libcli/security/security.h"
+#include "param/param.h"
struct test_join {
struct dcerpc_pipe *p;
@@ -125,7 +126,7 @@ struct test_join *torture_create_testuser(struct torture_context *torture,
int policy_min_pw_len = 0;
struct test_join *join;
char *random_pw;
- const char *dc_binding = lp_parm_string(-1, "torture", "dc_binding");
+ const char *dc_binding = lp_parm_string(global_loadparm, NULL, "torture", "dc_binding");
join = talloc(NULL, struct test_join);
if (join == NULL) {
@@ -275,7 +276,8 @@ again:
u.info21.description.string = talloc_asprintf(join,
"Samba4 torture account created by host %s: %s",
- lp_netbios_name(), timestring(join, time(NULL)));
+ lp_netbios_name(global_loadparm),
+ timestring(join, time(NULL)));
printf("Resetting ACB flags, force pw change time\n");
@@ -326,9 +328,9 @@ _PUBLIC_ struct test_join *torture_join_domain(const char *machine_name,
tj->libnet_r = libnet_r;
libnet_ctx->cred = cmdline_credentials;
- libnet_r->in.binding = lp_parm_string(-1, "torture", "binding");
+ libnet_r->in.binding = lp_parm_string(global_loadparm, NULL, "torture", "binding");
if (!libnet_r->in.binding) {
- libnet_r->in.binding = talloc_asprintf(libnet_r, "ncacn_np:%s", lp_parm_string(-1, "torture", "host"));
+ libnet_r->in.binding = talloc_asprintf(libnet_r, "ncacn_np:%s", lp_parm_string(global_loadparm, NULL, "torture", "host"));
}
libnet_r->in.level = LIBNET_JOINDOMAIN_SPECIFIED;
libnet_r->in.netbios_name = machine_name;
@@ -339,7 +341,7 @@ _PUBLIC_ struct test_join *torture_join_domain(const char *machine_name,
}
libnet_r->in.acct_type = acct_flags;
- libnet_r->in.recreate_account = True;
+ libnet_r->in.recreate_account = true;
status = libnet_JoinDomain(libnet_ctx, libnet_r, libnet_r);
if (!NT_STATUS_IS_OK(status)) {
@@ -381,7 +383,7 @@ _PUBLIC_ struct test_join *torture_join_domain(const char *machine_name,
u.info21.description.string = talloc_asprintf(tj,
"Samba4 torture account created by host %s: %s",
- lp_netbios_name(), timestring(tj, time(NULL)));
+ lp_netbios_name(global_loadparm), timestring(tj, time(NULL)));
status = dcerpc_samr_SetUserInfo(tj->p, tj, &s);
if (!NT_STATUS_IS_OK(status)) {
@@ -389,7 +391,7 @@ _PUBLIC_ struct test_join *torture_join_domain(const char *machine_name,
}
*machine_credentials = cli_credentials_init(tj);
- cli_credentials_set_conf(*machine_credentials);
+ cli_credentials_set_conf(*machine_credentials, global_loadparm);
cli_credentials_set_workstation(*machine_credentials, machine_name, CRED_SPECIFIED);
cli_credentials_set_domain(*machine_credentials, libnet_r->out.domain_name, CRED_SPECIFIED);
if (libnet_r->out.realm) {
diff --git a/source4/torture/rpc/unixinfo.c b/source4/torture/rpc/unixinfo.c
index 80d7d96a9e..cbe8cf0ff1 100644
--- a/source4/torture/rpc/unixinfo.c
+++ b/source4/torture/rpc/unixinfo.c
@@ -42,7 +42,7 @@ static bool test_sidtouid(struct torture_context *tctx, struct dcerpc_pipe *p)
if (NT_STATUS_EQUAL(NT_STATUS_NONE_MAPPED, status)) {
} else torture_assert_ntstatus_ok(tctx, status, "SidToUid failed");
- return True;
+ return true;
}
/*
@@ -125,12 +125,12 @@ static bool test_gidtosid(struct torture_context *tctx, struct dcerpc_pipe *p)
return true;
}
-struct torture_suite *torture_rpc_unixinfo(void)
+struct torture_suite *torture_rpc_unixinfo(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite;
struct torture_rpc_tcase *tcase;
- suite = torture_suite_create(talloc_autofree_context(), "UNIXINFO");
+ suite = torture_suite_create(mem_ctx, "UNIXINFO");
tcase = torture_suite_add_rpc_iface_tcase(suite, "unixinfo",
&ndr_table_unixinfo);
diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c
index a3d671c489..e29d0b74dd 100644
--- a/source4/torture/rpc/winreg.c
+++ b/source4/torture/rpc/winreg.c
@@ -1,20 +1,20 @@
-/*
+/*
Unix SMB/CIFS implementation.
test suite for winreg rpc operations
Copyright (C) Tim Potter 2003
Copyright (C) Jelmer Vernooij 2004-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/>.
*/
@@ -32,9 +32,9 @@
#define TEST_KEY3 TEST_KEY_BASE "\\with a subkey"
#define TEST_SUBKEY TEST_KEY3 "\\subkey"
-static void init_initshutdown_String(TALLOC_CTX *mem_ctx,
- struct initshutdown_String *name,
- const char *s)
+static void init_initshutdown_String(TALLOC_CTX *mem_ctx,
+ struct initshutdown_String *name,
+ const char *s)
{
name->name = talloc(mem_ctx, struct initshutdown_String_sub);
name->name->name = s;
@@ -52,8 +52,8 @@ static void init_winreg_String(struct winreg_String *name, const char *s)
}
}
-static bool test_GetVersion(struct dcerpc_pipe *p,
- struct torture_context *tctx,
+static bool test_GetVersion(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
struct policy_handle *handle)
{
struct winreg_GetVersion r;
@@ -64,16 +64,16 @@ static bool test_GetVersion(struct dcerpc_pipe *p,
r.out.version = &v;
torture_assert_ntstatus_ok(tctx, dcerpc_winreg_GetVersion(p, tctx, &r),
- "GetVersion failed");
+ "GetVersion failed");
torture_assert_werr_ok(tctx, r.out.result, "GetVersion failed");
return true;
}
-static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p,
- struct torture_context *tctx,
- struct policy_handle *handle)
+static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
+ struct policy_handle *handle)
{
struct winreg_NotifyChangeKeyValue r;
@@ -84,13 +84,13 @@ static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p,
init_winreg_String(&r.in.string1, NULL);
init_winreg_String(&r.in.string2, NULL);
- torture_assert_ntstatus_ok(tctx,
- dcerpc_winreg_NotifyChangeKeyValue(p, tctx, &r),
- "NotifyChangeKeyValue failed");
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_winreg_NotifyChangeKeyValue(p, tctx, &r),
+ "NotifyChangeKeyValue failed");
if (!W_ERROR_IS_OK(r.out.result)) {
- torture_comment(tctx,
- "NotifyChangeKeyValue failed - %s - not considering\n", win_errstr(r.out.result));
+ torture_comment(tctx,
+ "NotifyChangeKeyValue failed - %s - not considering\n", win_errstr(r.out.result));
return true;
}
@@ -98,7 +98,7 @@ static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p,
}
static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx,
- struct policy_handle *handle, const char *name,
+ struct policy_handle *handle, const char *name,
const char *class)
{
struct winreg_CreateKey r;
@@ -107,7 +107,7 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx,
r.in.handle = handle;
r.out.new_handle = &newhandle;
- init_winreg_String(&r.in.name, name);
+ init_winreg_String(&r.in.name, name);
init_winreg_String(&r.in.keyclass, class);
r.in.options = 0x0;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -115,7 +115,7 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx,
r.in.secdesc = NULL;
torture_assert_ntstatus_ok(tctx, dcerpc_winreg_CreateKey(p, tctx, &r),
- "CreateKey failed");
+ "CreateKey failed");
torture_assert_werr_ok(tctx, r.out.result, "CreateKey failed");
@@ -126,9 +126,9 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx,
/*
createkey testing with a SD
*/
-static bool test_CreateKey_sd(struct dcerpc_pipe *p,
- struct torture_context *tctx,
- struct policy_handle *handle, const char *name,
+static bool test_CreateKey_sd(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
+ struct policy_handle *handle, const char *name,
const char *class, struct policy_handle *newhandle)
{
struct winreg_CreateKey r;
@@ -145,10 +145,10 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p,
SEC_ACE_FLAG_OBJECT_INHERIT,
NULL);
- torture_assert_ntstatus_ok(tctx,
- ndr_push_struct_blob(&sdblob, tctx, sd,
- (ndr_push_flags_fn_t)ndr_push_security_descriptor),
- "Failed to push security_descriptor ?!\n");
+ torture_assert_ntstatus_ok(tctx,
+ ndr_push_struct_blob(&sdblob, tctx, sd,
+ (ndr_push_flags_fn_t)ndr_push_security_descriptor),
+ "Failed to push security_descriptor ?!\n");
secbuf.sd.data = sdblob.data;
secbuf.sd.len = sdblob.length;
@@ -158,7 +158,7 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p,
r.in.handle = handle;
r.out.new_handle = newhandle;
- init_winreg_String(&r.in.name, name);
+ init_winreg_String(&r.in.name, name);
init_winreg_String(&r.in.keyclass, class);
r.in.options = 0x0;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -166,16 +166,16 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p,
r.in.secdesc = &secbuf;
torture_assert_ntstatus_ok(tctx, dcerpc_winreg_CreateKey(p, tctx, &r),
- "CreateKey with sd failed");
+ "CreateKey with sd failed");
torture_assert_werr_ok(tctx, r.out.result, "CreateKey with sd failed");
return true;
}
-static bool test_GetKeySecurity(struct dcerpc_pipe *p,
- struct torture_context *tctx,
- struct policy_handle *handle)
+static bool test_GetKeySecurity(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
+ struct policy_handle *handle)
{
struct winreg_GetKeySecurity r;
struct security_descriptor sd;
@@ -189,17 +189,17 @@ static bool test_GetKeySecurity(struct dcerpc_pipe *p,
r.in.sec_info = SECINFO_OWNER | SECINFO_GROUP | SECINFO_DACL;
torture_assert_ntstatus_ok(tctx, dcerpc_winreg_GetKeySecurity(p, tctx, &r),
- "GetKeySecurity failed");
+ "GetKeySecurity failed");
torture_assert_werr_ok(tctx, r.out.result, "GetKeySecurity failed");
sdblob.data = r.out.sd->data;
sdblob.length = r.out.sd->len;
- torture_assert_ntstatus_ok(tctx,
- ndr_pull_struct_blob(&sdblob, tctx, &sd,
- (ndr_pull_flags_fn_t)ndr_pull_security_descriptor),
- "pull_security_descriptor failed");
+ torture_assert_ntstatus_ok(tctx,
+ ndr_pull_struct_blob(&sdblob, tctx, &sd,
+ (ndr_pull_flags_fn_t)ndr_pull_security_descriptor),
+ "pull_security_descriptor failed");
if (p->conn->flags & DCERPC_DEBUG_PRINT_OUT) {
NDR_PRINT_DEBUG(security_descriptor, &sd);
@@ -208,7 +208,7 @@ static bool test_GetKeySecurity(struct dcerpc_pipe *p,
return true;
}
-static bool test_CloseKey(struct dcerpc_pipe *p, struct torture_context *tctx,
+static bool test_CloseKey(struct dcerpc_pipe *p, struct torture_context *tctx,
struct policy_handle *handle)
{
struct winreg_CloseKey r;
@@ -216,14 +216,14 @@ static bool test_CloseKey(struct dcerpc_pipe *p, struct torture_context *tctx,
r.in.handle = r.out.handle = handle;
torture_assert_ntstatus_ok(tctx, dcerpc_winreg_CloseKey(p, tctx, &r),
- "CloseKey failed");
+ "CloseKey failed");
torture_assert_werr_ok(tctx, r.out.result, "CloseKey failed");
return true;
}
-static bool test_FlushKey(struct dcerpc_pipe *p, struct torture_context *tctx,
+static bool test_FlushKey(struct dcerpc_pipe *p, struct torture_context *tctx,
struct policy_handle *handle)
{
struct winreg_FlushKey r;
@@ -231,7 +231,7 @@ static bool test_FlushKey(struct dcerpc_pipe *p, struct torture_context *tctx,
r.in.handle = handle;
torture_assert_ntstatus_ok(tctx, dcerpc_winreg_FlushKey(p, tctx, &r),
- "FlushKey failed");
+ "FlushKey failed");
torture_assert_werr_ok(tctx, r.out.result, "FlushKey failed");
@@ -251,7 +251,7 @@ static bool test_OpenKey(struct dcerpc_pipe *p, struct torture_context *tctx,
r.out.handle = key_handle;
torture_assert_ntstatus_ok(tctx, dcerpc_winreg_OpenKey(p, tctx, &r),
- "OpenKey failed");
+ "OpenKey failed");
torture_assert_werr_ok(tctx, r.out.result, "OpenKey failed");
@@ -279,7 +279,7 @@ static bool test_DeleteKey(struct dcerpc_pipe *p, struct torture_context *tctx,
struct winreg_DeleteKey r;
r.in.handle = handle;
- init_winreg_String(&r.in.key, key);
+ init_winreg_String(&r.in.key, key);
status = dcerpc_winreg_DeleteKey(p, tctx, &r);
@@ -291,7 +291,7 @@ static bool test_DeleteKey(struct dcerpc_pipe *p, struct torture_context *tctx,
/* DeleteKey on a key with subkey(s) should
* return WERR_ACCESS_DENIED. */
-static bool test_DeleteKeyWithSubkey(struct dcerpc_pipe *p,
+static bool test_DeleteKeyWithSubkey(struct dcerpc_pipe *p,
struct torture_context *tctx,
struct policy_handle *handle, const char *key)
{
@@ -301,16 +301,16 @@ static bool test_DeleteKeyWithSubkey(struct dcerpc_pipe *p,
init_winreg_String(&r.in.key, key);
torture_assert_ntstatus_ok(tctx, dcerpc_winreg_DeleteKey(p, tctx, &r),
- "DeleteKeyWithSubkey failed");
+ "DeleteKeyWithSubkey failed");
- torture_assert_werr_equal(tctx, r.out.result, WERR_ACCESS_DENIED,
- "DeleteKeyWithSubkey failed");
+ torture_assert_werr_equal(tctx, r.out.result, WERR_ACCESS_DENIED,
+ "DeleteKeyWithSubkey failed");
return true;
}
-static bool test_QueryInfoKey(struct dcerpc_pipe *p,
- struct torture_context *tctx,
+static bool test_QueryInfoKey(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
struct policy_handle *handle, char *class)
{
struct winreg_QueryInfoKey r;
@@ -331,13 +331,13 @@ static bool test_QueryInfoKey(struct dcerpc_pipe *p,
r.out.last_changed_time = &last_changed_time;
r.out.classname = talloc(tctx, struct winreg_String);
-
+
r.in.classname = talloc(tctx, struct winreg_String);
init_winreg_String(r.in.classname, class);
-
- torture_assert_ntstatus_ok(tctx,
- dcerpc_winreg_QueryInfoKey(p, tctx, &r),
- "QueryInfoKey failed");
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_winreg_QueryInfoKey(p, tctx, &r),
+ "QueryInfoKey failed");
torture_assert_werr_ok(tctx, r.out.result, "QueryInfoKey failed");
@@ -375,11 +375,10 @@ static bool test_EnumKey(struct dcerpc_pipe *p, struct torture_context *tctx,
struct policy_handle key_handle;
torture_comment(tctx, "EnumKey: %d: %s\n", r.in.enum_index,
- r.out.name->name);
+ r.out.name->name);
- if (!test_OpenKey(
- p, tctx, handle, r.out.name->name,
- &key_handle)) {
+ if (!test_OpenKey(p, tctx, handle, r.out.name->name,
+ &key_handle)) {
} else {
test_key(p, tctx, &key_handle, depth + 1);
}
@@ -391,7 +390,7 @@ static bool test_EnumKey(struct dcerpc_pipe *p, struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "EnumKey failed");
- if (!W_ERROR_IS_OK(r.out.result) &&
+ if (!W_ERROR_IS_OK(r.out.result) &&
!W_ERROR_EQUAL(r.out.result, WERR_NO_MORE_ITEMS)) {
torture_fail(tctx, "EnumKey failed");
}
@@ -399,10 +398,10 @@ static bool test_EnumKey(struct dcerpc_pipe *p, struct torture_context *tctx,
return true;
}
-static bool test_QueryMultipleValues(struct dcerpc_pipe *p,
- struct torture_context *tctx,
- struct policy_handle *handle,
- const char *valuename)
+static bool test_QueryMultipleValues(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
+ struct policy_handle *handle,
+ const char *valuename)
{
struct winreg_QueryMultipleValues r;
NTSTATUS status;
@@ -419,13 +418,13 @@ static bool test_QueryMultipleValues(struct dcerpc_pipe *p,
r.in.num_values = 1;
r.in.buffer_size = r.out.buffer_size = talloc(tctx, uint32_t);
*r.in.buffer_size = bufsize;
- do {
+ do {
*r.in.buffer_size = bufsize;
- r.in.buffer = r.out.buffer = talloc_zero_array(tctx, uint8_t,
+ r.in.buffer = r.out.buffer = talloc_zero_array(tctx, uint8_t,
*r.in.buffer_size);
status = dcerpc_winreg_QueryMultipleValues(p, tctx, &r);
-
+
if(NT_STATUS_IS_ERR(status))
torture_fail(tctx, "QueryMultipleValues failed");
@@ -438,10 +437,10 @@ static bool test_QueryMultipleValues(struct dcerpc_pipe *p,
return true;
}
-static bool test_QueryValue(struct dcerpc_pipe *p,
- struct torture_context *tctx,
- struct policy_handle *handle,
- const char *valuename)
+static bool test_QueryValue(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
+ struct policy_handle *handle,
+ const char *valuename)
{
struct winreg_QueryValue r;
NTSTATUS status;
@@ -467,7 +466,8 @@ static bool test_QueryValue(struct dcerpc_pipe *p,
}
static bool test_EnumValue(struct dcerpc_pipe *p, struct torture_context *tctx,
- struct policy_handle *handle, int max_valnamelen, int max_valbufsize)
+ struct policy_handle *handle, int max_valnamelen,
+ int max_valbufsize)
{
struct winreg_EnumValue r;
enum winreg_Type type = 0;
@@ -487,10 +487,11 @@ static bool test_EnumValue(struct dcerpc_pipe *p, struct torture_context *tctx,
r.in.value = &buf8;
r.in.length = &zero;
r.in.size = &size;
-
+
do {
- torture_assert_ntstatus_ok(tctx, dcerpc_winreg_EnumValue(p, tctx, &r),
- "EnumValue failed");
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_winreg_EnumValue(p, tctx, &r),
+ "EnumValue failed");
if (W_ERROR_IS_OK(r.out.result)) {
ret &= test_QueryValue(p, tctx, handle, r.out.name->name);
@@ -501,22 +502,22 @@ static bool test_EnumValue(struct dcerpc_pipe *p, struct torture_context *tctx,
} while (W_ERROR_IS_OK(r.out.result));
torture_assert_werr_equal(tctx, r.out.result, WERR_NO_MORE_ITEMS,
- "EnumValue failed");
+ "EnumValue failed");
return ret;
}
-static bool test_AbortSystemShutdown(struct dcerpc_pipe *p,
- struct torture_context *tctx)
+static bool test_AbortSystemShutdown(struct dcerpc_pipe *p,
+ struct torture_context *tctx)
{
struct winreg_AbortSystemShutdown r;
uint16_t server = 0x0;
r.in.server = &server;
-
- torture_assert_ntstatus_ok(tctx,
- dcerpc_winreg_AbortSystemShutdown(p, tctx, &r),
- "AbortSystemShutdown failed");
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_winreg_AbortSystemShutdown(p, tctx, &r),
+ "AbortSystemShutdown failed");
torture_assert_werr_ok(tctx, r.out.result, "AbortSystemShutdown failed");
@@ -524,15 +525,11 @@ static bool test_AbortSystemShutdown(struct dcerpc_pipe *p,
}
static bool test_InitiateSystemShutdown(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+ struct dcerpc_pipe *p)
{
struct winreg_InitiateSystemShutdown r;
uint16_t hostname = 0x0;
- if (!torture_setting_bool(tctx, "dangerous", false))
- torture_skip(tctx,
- "winreg_InitiateShutdown disabled - enable dangerous tests to use");
-
r.in.hostname = &hostname;
r.in.message = talloc(tctx, struct initshutdown_String);
init_initshutdown_String(tctx, r.in.message, "spottyfood");
@@ -540,9 +537,9 @@ static bool test_InitiateSystemShutdown(struct torture_context *tctx,
r.in.timeout = 30;
r.in.reboot = 1;
- torture_assert_ntstatus_ok(tctx,
- dcerpc_winreg_InitiateSystemShutdown(p, tctx, &r),
- "InitiateSystemShutdown failed");
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_winreg_InitiateSystemShutdown(p, tctx, &r),
+ "InitiateSystemShutdown failed");
torture_assert_werr_ok(tctx, r.out.result, "InitiateSystemShutdown failed");
@@ -551,15 +548,11 @@ static bool test_InitiateSystemShutdown(struct torture_context *tctx,
static bool test_InitiateSystemShutdownEx(struct torture_context *tctx,
- struct dcerpc_pipe *p)
+ struct dcerpc_pipe *p)
{
struct winreg_InitiateSystemShutdownEx r;
uint16_t hostname = 0x0;
- if (!torture_setting_bool(tctx, "dangerous", false))
- torture_skip(tctx,
- "winreg_InitiateShutdownEx disabled - enable dangerous tests to use");
-
r.in.hostname = &hostname;
r.in.message = talloc(tctx, struct initshutdown_String);
init_initshutdown_String(tctx, r.in.message, "spottyfood");
@@ -568,18 +561,18 @@ static bool test_InitiateSystemShutdownEx(struct torture_context *tctx,
r.in.reboot = 1;
r.in.reason = 0;
- torture_assert_ntstatus_ok(tctx,
+ torture_assert_ntstatus_ok(tctx,
dcerpc_winreg_InitiateSystemShutdownEx(p, tctx, &r),
"InitiateSystemShutdownEx failed");
- torture_assert_werr_ok(tctx, r.out.result,
- "InitiateSystemShutdownEx failed");
+ torture_assert_werr_ok(tctx, r.out.result,
+ "InitiateSystemShutdownEx failed");
return test_AbortSystemShutdown(p, tctx);
}
#define MAX_DEPTH 2 /* Only go this far down the tree */
-static bool test_key(struct dcerpc_pipe *p, struct torture_context *tctx,
+static bool test_key(struct dcerpc_pipe *p, struct torture_context *tctx,
struct policy_handle *handle, int depth)
{
if (depth == MAX_DEPTH)
@@ -590,7 +583,7 @@ static bool test_key(struct dcerpc_pipe *p, struct torture_context *tctx,
if (!test_NotifyChangeKeyValue(p, tctx, handle)) {
}
-
+
if (!test_GetKeySecurity(p, tctx, handle)) {
}
@@ -607,7 +600,7 @@ static bool test_key(struct dcerpc_pipe *p, struct torture_context *tctx,
typedef NTSTATUS (*winreg_open_fn)(struct dcerpc_pipe *, TALLOC_CTX *, void *);
-static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
+static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
void *userdata)
{
struct policy_handle handle, newhandle;
@@ -620,9 +613,9 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
r.in.system_name = 0;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
r.out.handle = &handle;
-
- torture_assert_ntstatus_ok(tctx, open_fn(p, tctx, &r),
- "open");
+
+ torture_assert_ntstatus_ok(tctx, open_fn(p, tctx, &r),
+ "open");
test_Cleanup(p, tctx, &handle, TEST_KEY1);
test_Cleanup(p, tctx, &handle, TEST_KEY2);
@@ -642,8 +635,8 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
}
if (created && !test_OpenKey(p, tctx, &handle, TEST_KEY1, &newhandle))
- torture_fail(tctx,
- "CreateKey failed (OpenKey after Create didn't work)\n");
+ torture_fail(tctx,
+ "CreateKey failed (OpenKey after Create didn't work)\n");
if (created && !test_DeleteKey(p, tctx, &handle, TEST_KEY1)) {
torture_comment(tctx, "DeleteKey failed\n");
@@ -657,10 +650,10 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
ret = false;
}
- if (created && deleted &&
+ if (created && deleted &&
test_OpenKey(p, tctx, &handle, TEST_KEY1, &newhandle)) {
- torture_comment(tctx,
- "DeleteKey failed (OpenKey after Delete worked)\n");
+ torture_comment(tctx,
+ "DeleteKey failed (OpenKey after Delete worked)\n");
ret = false;
}
@@ -669,8 +662,8 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
ret = false;
}
- if (created && test_CreateKey_sd(p, tctx, &handle, TEST_KEY2,
- NULL, &newhandle)) {
+ if (created && test_CreateKey_sd(p, tctx, &handle, TEST_KEY2,
+ NULL, &newhandle)) {
created2 = true;
}
@@ -693,21 +686,21 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
created3 = true;
}
- if (created3 &&
- test_CreateKey(p, tctx, &handle, TEST_SUBKEY, NULL))
+ if (created3 &&
+ test_CreateKey(p, tctx, &handle, TEST_SUBKEY, NULL))
{
created_subkey = true;
}
- if (created_subkey &&
- !test_DeleteKeyWithSubkey(p, tctx, &handle, TEST_KEY3))
+ if (created_subkey &&
+ !test_DeleteKeyWithSubkey(p, tctx, &handle, TEST_KEY3))
{
printf("DeleteKeyWithSubkey failed "
"(DeleteKey didn't return ACCESS_DENIED)\n");
ret = false;
}
- if (created_subkey &&
+ if (created_subkey &&
!test_DeleteKey(p, tctx, &handle, TEST_SUBKEY))
{
printf("DeleteKey failed\n");
@@ -749,19 +742,22 @@ struct torture_suite *torture_rpc_winreg(TALLOC_CTX *mem_ctx)
int i;
struct torture_rpc_tcase *tcase;
struct torture_suite *suite = torture_suite_create(mem_ctx, "WINREG");
+ struct torture_test *test;
- tcase = torture_suite_add_rpc_iface_tcase(suite, "winreg",
- &ndr_table_winreg);
+ tcase = torture_suite_add_rpc_iface_tcase(suite, "winreg",
+ &ndr_table_winreg);
- torture_rpc_tcase_add_test(tcase, "InitiateSystemShutdown",
- test_InitiateSystemShutdown);
+ test = torture_rpc_tcase_add_test(tcase, "InitiateSystemShutdown",
+ test_InitiateSystemShutdown);
+ test->dangerous = true;
- torture_rpc_tcase_add_test(tcase, "InitiateSystemShutdownEx",
- test_InitiateSystemShutdownEx);
+ test = torture_rpc_tcase_add_test(tcase, "InitiateSystemShutdownEx",
+ test_InitiateSystemShutdownEx);
+ test->dangerous = true;
for (i = 0; i < ARRAY_SIZE(open_fns); i++) {
- torture_rpc_tcase_add_test_ex(tcase, open_fns[i].name, test_Open,
- open_fns[i].fn);
+ torture_rpc_tcase_add_test_ex(tcase, open_fns[i].name,
+ test_Open, open_fns[i].fn);
}
return suite;
diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c
index 62d273e623..796b180ddf 100644
--- a/source4/torture/smb2/connect.c
+++ b/source4/torture/smb2/connect.c
@@ -25,6 +25,7 @@
#include "libcli/smb2/smb2_calls.h"
#include "torture/torture.h"
#include "torture/smb2/proto.h"
+#include "param/param.h"
/*
send a close
@@ -73,9 +74,9 @@ static NTSTATUS torture_smb2_write(struct smb2_tree *tree, struct smb2_handle ha
DATA_BLOB data;
int i;
- if (lp_parm_bool(-1, "torture", "dangerous", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) {
data = data_blob_talloc(tree, NULL, 160000);
- } else if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ } else if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
data = data_blob_talloc(tree, NULL, UINT16_MAX);
} else {
data = data_blob_talloc(tree, NULL, 120000);
@@ -188,7 +189,7 @@ static struct smb2_handle torture_smb2_create(struct smb2_tree *tree,
/*
basic testing of SMB2 connection calls
*/
-BOOL torture_smb2_connect(struct torture_context *torture)
+bool torture_smb2_connect(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
@@ -196,7 +197,7 @@ BOOL torture_smb2_connect(struct torture_context *torture)
NTSTATUS status;
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
h1 = torture_smb2_create(tree, "test9.dat");
@@ -204,56 +205,56 @@ BOOL torture_smb2_connect(struct torture_context *torture)
status = torture_smb2_write(tree, h1);
if (!NT_STATUS_IS_OK(status)) {
printf("Write failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = torture_smb2_close(tree, h1);
if (!NT_STATUS_IS_OK(status)) {
printf("Close failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = torture_smb2_close(tree, h2);
if (!NT_STATUS_IS_OK(status)) {
printf("Close failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = smb2_util_close(tree, h1);
if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED)) {
printf("close should have closed the handle - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = smb2_tdis(tree);
if (!NT_STATUS_IS_OK(status)) {
printf("tdis failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = smb2_tdis(tree);
if (!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) {
printf("tdis should have disabled session - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = smb2_logoff(tree->session);
if (!NT_STATUS_IS_OK(status)) {
printf("Logoff failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = smb2_logoff(tree->session);
if (!NT_STATUS_EQUAL(status, NT_STATUS_USER_SESSION_DELETED)) {
printf("Logoff should have disabled session - %s\n", nt_errstr(status));
- return False;
+ return false;
}
status = smb2_keepalive(tree->session->transport);
if (!NT_STATUS_IS_OK(status)) {
printf("keepalive failed? - %s\n", nt_errstr(status));
- return False;
+ return false;
}
talloc_free(mem_ctx);
- return True;
+ return true;
}
diff --git a/source4/torture/smb2/dir.c b/source4/torture/smb2/dir.c
index 428683522a..eb24dd0884 100644
--- a/source4/torture/smb2/dir.c
+++ b/source4/torture/smb2/dir.c
@@ -29,19 +29,19 @@
/*
test find continue
*/
-static BOOL torture_smb2_find_dir(struct smb2_tree *tree)
+static bool torture_smb2_find_dir(struct smb2_tree *tree)
{
struct smb2_handle handle;
NTSTATUS status;
int i;
struct smb2_find f;
- BOOL ret = True;
+ bool ret = true;
union smb_search_data *d;
uint_t count;
status = smb2_util_roothandle(tree, &handle);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ZERO_STRUCT(f);
@@ -75,14 +75,14 @@ static BOOL torture_smb2_find_dir(struct smb2_tree *tree)
/*
basic testing of directory listing with continue
*/
-BOOL torture_smb2_dir(struct torture_context *torture)
+bool torture_smb2_dir(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
- BOOL ret = True;
+ bool ret = true;
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
ret &= torture_smb2_find_dir(tree);
diff --git a/source4/torture/smb2/find.c b/source4/torture/smb2/find.c
index 2b4bde7865..654866dfb5 100644
--- a/source4/torture/smb2/find.c
+++ b/source4/torture/smb2/find.c
@@ -49,7 +49,7 @@ static struct {
printf("(%s) %s/%s should be 0x%llx - 0x%llx\n", __location__, \
#call_name, #field, \
(long long)io.all_info2.out.field, (long long)d->stype.field); \
- ret = False; \
+ ret = false; \
}} while (0)
#define CHECK_CONST_STRING(call_name, stype, field, str) do { \
@@ -58,7 +58,7 @@ static struct {
printf("(%s) %s/%s should be '%s' - '%s'\n", __location__, \
#call_name, #field, \
str, d->stype.field.s); \
- ret = False; \
+ ret = false; \
}} while (0)
static union smb_search_data *find_level(const char *name)
@@ -75,26 +75,26 @@ static union smb_search_data *find_level(const char *name)
/*
test find levels
*/
-static BOOL torture_smb2_find_levels(struct smb2_tree *tree)
+static bool torture_smb2_find_levels(struct smb2_tree *tree)
{
struct smb2_handle handle;
NTSTATUS status;
int i;
struct smb2_find f;
- BOOL ret = True;
+ bool ret = true;
union smb_fileinfo io;
const char *alt_name;
status = smb2_create_complex_file(tree, FNAME, &handle);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION;
io.generic.in.file.handle = handle;
status = smb2_getinfo_file(tree, tree, &io);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
alt_name = talloc_strdup(tree, io.alt_name_info.out.fname.s);
@@ -102,12 +102,12 @@ static BOOL torture_smb2_find_levels(struct smb2_tree *tree)
io.generic.in.file.handle = handle;
status = smb2_getinfo_file(tree, tree, &io);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
status = smb2_util_roothandle(tree, &handle);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
ZERO_STRUCT(f);
@@ -130,7 +130,7 @@ static BOOL torture_smb2_find_levels(struct smb2_tree *tree)
if (count != 1) {
printf("Expected count 1 - got %d in %s\n", count, levels[i].name);
- ret = False;
+ ret = false;
}
levels[i].data = d[0];
@@ -195,20 +195,20 @@ static BOOL torture_smb2_find_levels(struct smb2_tree *tree)
/* basic testing of all SMB2 find levels
*/
-BOOL torture_smb2_find(struct torture_context *torture)
+bool torture_smb2_find(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
status = torture_setup_complex_file(tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
torture_setup_complex_file(tree, FNAME ":streamtwo");
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index fc59d1ac30..9ed0b9ddb5 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -26,6 +26,8 @@
#include "torture/torture.h"
#include "torture/smb2/proto.h"
+#include "param/param.h"
+
static struct {
const char *name;
uint16_t level;
@@ -75,7 +77,7 @@ static struct {
/*
test fileinfo levels
*/
-static BOOL torture_smb2_fileinfo(struct smb2_tree *tree)
+static bool torture_smb2_fileinfo(struct smb2_tree *tree)
{
struct smb2_handle hfile, hdir;
NTSTATUS status;
@@ -103,7 +105,7 @@ static BOOL torture_smb2_fileinfo(struct smb2_tree *tree)
file_levels[i].dinfo.query_secdesc.in.secinfo_flags = 0x7;
}
if (file_levels[i].level == RAW_FILEINFO_SMB2_ALL_EAS) {
- if (lp_parm_bool(-1, "torture", "samba4", False)) {
+ if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
continue;
}
file_levels[i].finfo.all_eas.in.continue_flags =
@@ -129,17 +131,17 @@ static BOOL torture_smb2_fileinfo(struct smb2_tree *tree)
}
}
- return True;
+ return true;
failed:
- return False;
+ return false;
}
/*
test fsinfo levels
*/
-static BOOL torture_smb2_fsinfo(struct smb2_tree *tree)
+static bool torture_smb2_fsinfo(struct smb2_tree *tree)
{
int i;
NTSTATUS status;
@@ -149,7 +151,7 @@ static BOOL torture_smb2_fsinfo(struct smb2_tree *tree)
status = smb2_util_roothandle(tree, &handle);
if (!NT_STATUS_IS_OK(status)) {
printf("Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status));
- return False;
+ return false;
}
for (i=0;i<ARRAY_SIZE(fs_levels);i++) {
@@ -158,35 +160,35 @@ static BOOL torture_smb2_fsinfo(struct smb2_tree *tree)
fs_levels[i].status = smb2_getinfo_fs(tree, tree, &fs_levels[i].info);
if (!NT_STATUS_IS_OK(fs_levels[i].status)) {
printf("%s failed - %s\n", fs_levels[i].name, nt_errstr(fs_levels[i].status));
- return False;
+ return false;
}
}
- return True;
+ return true;
}
/* basic testing of all SMB2 getinfo levels
*/
-BOOL torture_smb2_getinfo(struct torture_context *torture)
+bool torture_smb2_getinfo(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
status = torture_setup_complex_file(tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
torture_setup_complex_file(tree, FNAME ":streamtwo");
status = torture_setup_complex_dir(tree, DNAME);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return false;
}
torture_setup_complex_file(tree, DNAME ":streamtwo");
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index 9f426c3aa8..98e412817b 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -32,7 +32,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -40,13 +40,13 @@
if ((v) != (correct)) { \
printf("(%s) Incorrect value %s=%d - should be %d\n", \
__location__, #v, v, correct); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
-static BOOL test_valid_request(struct torture_context *torture, struct smb2_tree *tree)
+static bool test_valid_request(struct torture_context *torture, struct smb2_tree *tree)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
struct smb2_handle h;
uint8_t buf[200];
@@ -194,11 +194,11 @@ struct test_lock_read_write_state {
NTSTATUS read_h2_status;
};
-static BOOL test_lock_read_write(struct torture_context *torture,
+static bool test_lock_read_write(struct torture_context *torture,
struct smb2_tree *tree,
struct test_lock_read_write_state *s)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
struct smb2_handle h1, h2;
uint8_t buf[200];
@@ -317,7 +317,7 @@ done:
return ret;
}
-static BOOL test_lock_rw_none(struct torture_context *torture, struct smb2_tree *tree)
+static bool test_lock_rw_none(struct torture_context *torture, struct smb2_tree *tree)
{
struct test_lock_read_write_state s = {
.fname = "lock_rw_none.dat",
@@ -331,7 +331,7 @@ static BOOL test_lock_rw_none(struct torture_context *torture, struct smb2_tree
return test_lock_read_write(torture, tree, &s);
}
-static BOOL test_lock_rw_shared(struct torture_context *torture, struct smb2_tree *tree)
+static bool test_lock_rw_shared(struct torture_context *torture, struct smb2_tree *tree)
{
struct test_lock_read_write_state s = {
.fname = "lock_rw_shared.dat",
@@ -345,7 +345,7 @@ static BOOL test_lock_rw_shared(struct torture_context *torture, struct smb2_tre
return test_lock_read_write(torture, tree, &s);
}
-static BOOL test_lock_rw_exclusiv(struct torture_context *torture, struct smb2_tree *tree)
+static bool test_lock_rw_exclusiv(struct torture_context *torture, struct smb2_tree *tree)
{
struct test_lock_read_write_state s = {
.fname = "lock_rw_exclusiv.dat",
diff --git a/source4/torture/smb2/maxwrite.c b/source4/torture/smb2/maxwrite.c
index d4a77ad3ca..588a49221e 100644
--- a/source4/torture/smb2/maxwrite.c
+++ b/source4/torture/smb2/maxwrite.c
@@ -111,7 +111,7 @@ static NTSTATUS torture_smb2_write(TALLOC_CTX *mem_ctx,
/*
basic testing of SMB2 connection calls
*/
-BOOL torture_smb2_maxwrite(struct torture_context *torture)
+bool torture_smb2_maxwrite(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
@@ -119,17 +119,17 @@ BOOL torture_smb2_maxwrite(struct torture_context *torture)
NTSTATUS status;
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
h1 = torture_smb2_create(tree, FNAME);
status = torture_smb2_write(mem_ctx, tree, h1);
if (!NT_STATUS_IS_OK(status)) {
printf("Write failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
talloc_free(mem_ctx);
- return True;
+ return true;
}
diff --git a/source4/torture/smb2/notify.c b/source4/torture/smb2/notify.c
index 505b316d8e..cabe81ca71 100644
--- a/source4/torture/smb2/notify.c
+++ b/source4/torture/smb2/notify.c
@@ -33,7 +33,7 @@
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -41,7 +41,7 @@
if ((v) != (correct)) { \
printf("(%s) Incorrect value %s=%d - should be %d\n", \
__location__, #v, v, correct); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -49,15 +49,15 @@
if (!field.s || strcmp(field.s, value)) { \
printf("(%s) %s [%s] != %s\n", \
__location__, #field, field.s, value); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
#define FNAME "smb2-notify01.dat"
-static BOOL test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree)
+static bool test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree)
{
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
struct smb2_handle dh;
struct smb2_notify n;
@@ -188,14 +188,14 @@ done:
/* basic testing of SMB2 notify
*/
-BOOL torture_smb2_notify(struct torture_context *torture)
+bool torture_smb2_notify(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
- BOOL ret = True;
+ bool ret = true;
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
ret &= test_valid_request(mem_ctx, tree);
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index 83893608f9..f3e4d5cd36 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -35,7 +35,7 @@
/*
scan for valid SMB2 getinfo levels
*/
-BOOL torture_smb2_getinfo_scan(struct torture_context *torture)
+bool torture_smb2_getinfo_scan(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
@@ -45,20 +45,20 @@ BOOL torture_smb2_getinfo_scan(struct torture_context *torture)
int c, i;
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
status = torture_setup_complex_file(tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to setup complex file '%s'\n", FNAME);
- return False;
+ return false;
}
torture_setup_complex_file(tree, FNAME ":2ndstream");
status = torture_setup_complex_dir(tree, DNAME);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to setup complex dir '%s'\n", DNAME);
- return False;
+ return false;
}
torture_setup_complex_file(tree, DNAME ":2ndstream");
@@ -97,13 +97,13 @@ BOOL torture_smb2_getinfo_scan(struct torture_context *torture)
talloc_free(mem_ctx);
- return True;
+ return true;
}
/*
scan for valid SMB2 setinfo levels
*/
-BOOL torture_smb2_setinfo_scan(struct torture_context *torture)
+bool torture_smb2_setinfo_scan(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
@@ -113,13 +113,13 @@ BOOL torture_smb2_setinfo_scan(struct torture_context *torture)
int c, i;
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
status = torture_setup_complex_file(tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to setup complex file '%s'\n", FNAME);
- return False;
+ return false;
}
torture_setup_complex_file(tree, FNAME ":2ndstream");
@@ -143,14 +143,14 @@ BOOL torture_smb2_setinfo_scan(struct torture_context *torture)
talloc_free(mem_ctx);
- return True;
+ return true;
}
/*
scan for valid SMB2 scan levels
*/
-BOOL torture_smb2_find_scan(struct torture_context *torture)
+bool torture_smb2_find_scan(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
@@ -160,13 +160,13 @@ BOOL torture_smb2_find_scan(struct torture_context *torture)
int i;
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
status = smb2_util_roothandle(tree, &handle);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to open roothandle - %s\n", nt_errstr(status));
- return False;
+ return false;
}
ZERO_STRUCT(io);
@@ -191,13 +191,13 @@ BOOL torture_smb2_find_scan(struct torture_context *torture)
talloc_free(mem_ctx);
- return True;
+ return true;
}
/*
scan for valid SMB2 opcodes
*/
-BOOL torture_smb2_scan(struct torture_context *torture)
+bool torture_smb2_scan(struct torture_context *torture)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
@@ -212,13 +212,13 @@ BOOL torture_smb2_scan(struct torture_context *torture)
event_context_find(mem_ctx));
if (!NT_STATUS_IS_OK(status)) {
printf("Connection failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
tree->session->transport->options.timeout = 3;
for (opcode=0;opcode<1000;opcode++) {
- req = smb2_request_init_tree(tree, opcode, 2, False, 0);
+ req = smb2_request_init_tree(tree, opcode, 2, false, 0);
SSVAL(req->out.body, 0, 0);
smb2_transport_send(req);
if (!smb2_request_receive(req)) {
@@ -227,7 +227,7 @@ BOOL torture_smb2_scan(struct torture_context *torture)
event_context_find(mem_ctx));
if (!NT_STATUS_IS_OK(status)) {
printf("Connection failed - %s\n", nt_errstr(status));
- return False;
+ return false;
}
tree->session->transport->options.timeout = 3;
} else {
@@ -238,5 +238,5 @@ BOOL torture_smb2_scan(struct torture_context *torture)
talloc_free(mem_ctx);
- return True;
+ return true;
}
diff --git a/source4/torture/smb2/setinfo.c b/source4/torture/smb2/setinfo.c
index 88e8d07604..6a81f13f67 100644
--- a/source4/torture/smb2/setinfo.c
+++ b/source4/torture/smb2/setinfo.c
@@ -36,10 +36,10 @@
for each call we test that it succeeds, and where possible test
for consistency between the calls.
*/
-BOOL torture_smb2_setinfo(struct torture_context *torture)
+bool torture_smb2_setinfo(struct torture_context *torture)
{
struct smb2_tree *tree;
- BOOL ret = True;
+ bool ret = true;
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_handle handle;
char *fname;
@@ -60,7 +60,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture)
fname_new = talloc_asprintf(mem_ctx, BASEDIR "fnum_test_new_%d.txt", n);
if (!torture_smb2_connection(mem_ctx, &tree)) {
- return False;
+ return false;
}
#define RECREATE_FILE(fname) do { \
@@ -69,7 +69,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture)
if (!NT_STATUS_IS_OK(status)) { \
printf("(%s) ERROR: open of %s failed (%s)\n", \
__location__, fname, nt_errstr(status)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -87,7 +87,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture)
if (!NT_STATUS_EQUAL(status, rightstatus)) { \
printf("(%s) %s - %s (should be %s)\n", __location__, #call, \
nt_errstr(status), nt_errstr(rightstatus)); \
- ret = False; \
+ ret = false; \
goto done; \
} \
} while (0)
@@ -99,7 +99,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture)
status2 = smb2_getinfo_file(tree, mem_ctx, &finfo2); \
if (!NT_STATUS_IS_OK(status2)) { \
printf("(%s) %s - %s\n", __location__, #call, nt_errstr(status2)); \
- ret = False; \
+ ret = false; \
goto done; \
} \
}} while (0)
@@ -111,7 +111,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture)
call_name, #stype, #field, \
(uint_t)value, (uint_t)finfo2.stype.out.field); \
torture_smb2_all_info(tree, handle); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -125,7 +125,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture)
printf("\t%s", timestring(mem_ctx, value)); \
printf("\t%s\n", nt_time_string(mem_ctx, finfo2.stype.out.field)); \
torture_smb2_all_info(tree, handle); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -133,7 +133,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture)
if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
+ ret = false; \
goto done; \
}} while (0)
@@ -262,7 +262,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture)
NDR_PRINT_DEBUG(security_descriptor, finfo2.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd);
- ret = False;
+ ret = false;
}
printf("remove it again\n");
@@ -281,7 +281,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture)
NDR_PRINT_DEBUG(security_descriptor, finfo2.query_secdesc.out.sd);
printf("expected:\n");
NDR_PRINT_DEBUG(security_descriptor, sd);
- ret = False;
+ ret = false;
}
done:
diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index 5e680fbcec..705f10a841 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -26,6 +26,10 @@
#include "lib/events/events.h"
#include "system/time.h"
#include "librpc/gen_ndr/ndr_security.h"
+#include "param/param.h"
+
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
/*
@@ -90,7 +94,7 @@ NTSTATUS smb2_util_write(struct smb2_tree *tree,
create a complex file/dir using the SMB2 protocol
*/
static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
- struct smb2_handle *handle, BOOL dir)
+ struct smb2_handle *handle, bool dir)
{
TALLOC_CTX *tmp_ctx = talloc_new(tree);
char buf[7] = "abc";
@@ -195,7 +199,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname,
struct smb2_handle *handle)
{
- return smb2_create_complex(tree, fname, handle, False);
+ return smb2_create_complex(tree, fname, handle, false);
}
/*
@@ -204,7 +208,7 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname,
NTSTATUS smb2_create_complex_dir(struct smb2_tree *tree, const char *fname,
struct smb2_handle *handle)
{
- return smb2_create_complex(tree, fname, handle, True);
+ return smb2_create_complex(tree, fname, handle, true);
}
/*
@@ -298,11 +302,11 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
/*
open a smb2 connection
*/
-BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree)
+bool torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree)
{
NTSTATUS status;
- const char *host = lp_parm_string(-1, "torture", "host");
- const char *share = lp_parm_string(-1, "torture", "share");
+ const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share");
struct cli_credentials *credentials = cmdline_credentials;
status = smb2_connect(mem_ctx, host, share, credentials, tree,
@@ -310,9 +314,9 @@ BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree)
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
host, share, nt_errstr(status));
- return False;
+ return false;
}
- return True;
+ return true;
}
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index d461828431..ea563f7d63 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -34,6 +34,7 @@
#include "build.h"
#include "lib/util/dlinklist.h"
#include "librpc/rpc/dcerpc.h"
+#include "param/param.h"
static bool run_matching(struct torture_context *torture,
const char *prefix,
@@ -130,33 +131,33 @@ static void parse_dns(const char *dns)
/* retrievieng the userdn */
p = strchr_m(dns, '#');
if (!p) {
- lp_set_cmdline("torture:ldap_userdn", "");
- lp_set_cmdline("torture:ldap_basedn", "");
- lp_set_cmdline("torture:ldap_secret", "");
+ lp_set_cmdline(global_loadparm, "torture:ldap_userdn", "");
+ lp_set_cmdline(global_loadparm, "torture:ldap_basedn", "");
+ lp_set_cmdline(global_loadparm, "torture:ldap_secret", "");
return;
}
userdn = strndup(dns, p - dns);
- lp_set_cmdline("torture:ldap_userdn", userdn);
+ lp_set_cmdline(global_loadparm, "torture:ldap_userdn", userdn);
/* retrieve the basedn */
d = p + 1;
p = strchr_m(d, '#');
if (!p) {
- lp_set_cmdline("torture:ldap_basedn", "");
- lp_set_cmdline("torture:ldap_secret", "");
+ lp_set_cmdline(global_loadparm, "torture:ldap_basedn", "");
+ lp_set_cmdline(global_loadparm, "torture:ldap_secret", "");
return;
}
basedn = strndup(d, p - d);
- lp_set_cmdline("torture:ldap_basedn", basedn);
+ lp_set_cmdline(global_loadparm, "torture:ldap_basedn", basedn);
/* retrieve the secret */
p = p + 1;
if (!p) {
- lp_set_cmdline("torture:ldap_secret", "");
+ lp_set_cmdline(global_loadparm, "torture:ldap_secret", "");
return;
}
secret = strdup(p);
- lp_set_cmdline("torture:ldap_secret", secret);
+ lp_set_cmdline(global_loadparm, "torture:ldap_secret", secret);
printf ("%s - %s - %s\n", userdn, basedn, secret);
@@ -168,6 +169,9 @@ static void print_test_list(void)
struct torture_suite *s;
struct torture_tcase *t;
+ if (torture_root == NULL)
+ return;
+
for (o = torture_root->children; o; o = o->next) {
for (s = o->children; s; s = s->next) {
printf("%s-%s\n", o->name, s->name);
@@ -179,7 +183,7 @@ static void print_test_list(void)
}
}
-static void usage(poptContext pc)
+_NORETURN_ static void usage(poptContext pc)
{
struct torture_suite *o;
struct torture_suite *s;
@@ -238,6 +242,11 @@ static void usage(poptContext pc)
printf("Tests are:");
+ if (torture_root == NULL) {
+ printf("NO TESTS LOADED\n");
+ exit(1);
+ }
+
for (o = torture_root->children; o; o = o->next) {
printf("\n%s (%s):\n ", o->description, o->name);
@@ -266,7 +275,7 @@ static void usage(poptContext pc)
exit(1);
}
-static void max_runtime_handler(int sig)
+_NORETURN_ static void max_runtime_handler(int sig)
{
DEBUG(0,("maximum runtime exceeded for smbtorture - terminating\n"));
exit(1);
@@ -275,22 +284,22 @@ static void max_runtime_handler(int sig)
struct timeval last_suite_started;
static void simple_suite_start(struct torture_context *ctx,
- struct torture_suite *suite)
+ struct torture_suite *suite)
{
last_suite_started = timeval_current();
printf("Running %s\n", suite->name);
}
static void simple_suite_finish(struct torture_context *ctx,
- struct torture_suite *suite)
+ struct torture_suite *suite)
{
printf("%s took %g secs\n\n", suite->name,
timeval_elapsed(&last_suite_started));
}
-static void simple_test_result (struct torture_context *context,
- enum torture_result res, const char *reason)
+static void simple_test_result(struct torture_context *context,
+ enum torture_result res, const char *reason)
{
switch (res) {
case TORTURE_OK:
@@ -309,14 +318,14 @@ static void simple_test_result (struct torture_context *context,
}
}
-static void simple_comment (struct torture_context *test,
- const char *comment)
+static void simple_comment(struct torture_context *test,
+ const char *comment)
{
printf("%s", comment);
}
static void simple_warning(struct torture_context *test,
- const char *comment)
+ const char *comment)
{
fprintf(stderr, "WARNING: %s\n", comment);
}
@@ -335,19 +344,19 @@ static void subunit_init(struct torture_context *ctx)
}
static void subunit_suite_start(struct torture_context *ctx,
- struct torture_suite *suite)
+ struct torture_suite *suite)
{
}
-static void subunit_test_start (struct torture_context *ctx,
- struct torture_tcase *tcase,
- struct torture_test *test)
+static void subunit_test_start(struct torture_context *ctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
{
printf("test: %s\n", test->name);
}
-static void subunit_test_result (struct torture_context *context,
- enum torture_result res, const char *reason)
+static void subunit_test_result(struct torture_context *context,
+ enum torture_result res, const char *reason)
{
switch (res) {
case TORTURE_OK:
@@ -368,22 +377,29 @@ static void subunit_test_result (struct torture_context *context,
printf("\n");
}
-static void subunit_comment (struct torture_context *test,
- const char *comment)
+static void subunit_comment(struct torture_context *test,
+ const char *comment)
{
fprintf(stderr, "%s", comment);
}
+static void subunit_warning(struct torture_context *test,
+ const char *comment)
+{
+ fprintf(stderr, "WARNING!: %s\n", comment);
+}
+
const static struct torture_ui_ops subunit_ui_ops = {
.init = subunit_init,
.comment = subunit_comment,
+ .warning = subunit_warning,
.test_start = subunit_test_start,
.test_result = subunit_test_result,
.suite_start = subunit_suite_start
};
static void quiet_suite_start(struct torture_context *ctx,
- struct torture_suite *suite)
+ struct torture_suite *suite)
{
int i;
ctx->quiet = true;
@@ -393,13 +409,13 @@ static void quiet_suite_start(struct torture_context *ctx,
}
static void quiet_suite_finish(struct torture_context *ctx,
- struct torture_suite *suite)
+ struct torture_suite *suite)
{
putchar('\n');
}
-static void quiet_test_result (struct torture_context *context,
- enum torture_result res, const char *reason)
+static void quiet_test_result(struct torture_context *context,
+ enum torture_result res, const char *reason)
{
fflush(stdout);
switch (res) {
@@ -442,7 +458,7 @@ void run_shell(struct torture_context *tctx)
fprintf(stderr, "Usage: set <variable> <value>\n");
} else {
char *name = talloc_asprintf(NULL, "torture:%s", argv[1]);
- lp_set_cmdline(name, argv[2]);
+ lp_set_cmdline(global_loadparm, name, argv[2]);
talloc_free(name);
}
} else if (!strcmp(argv[0], "help")) {
@@ -477,9 +493,10 @@ int main(int argc,char *argv[])
static const char *target = "other";
struct dcerpc_binding *binding_struct;
NTSTATUS status;
- int shell = False;
+ int shell = false;
static const char *ui_ops_name = "simple";
const char *basedir = NULL;
+ const char *extra_module = NULL;
static int list_tests = 0;
char *host = NULL, *share = NULL;
enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS, OPT_LIST,
@@ -502,7 +519,8 @@ int main(int argc,char *argv[])
{"parse-dns", 'D', POPT_ARG_STRING, NULL, OPT_DNS, "parse-dns", NULL},
{"dangerous", 'X', POPT_ARG_NONE, NULL, OPT_DANGEROUS,
"run dangerous tests (eg. wiping out password database)", NULL},
- {"shell", 0, POPT_ARG_NONE, &shell, True, "Run shell", NULL},
+ {"load-module", 0, POPT_ARG_STRING, &extra_module, 0, "load tests from DSO file", "SOFILE"},
+ {"shell", 0, POPT_ARG_NONE, &shell, true, "Run shell", NULL},
{"target", 'T', POPT_ARG_STRING, &target, 0, "samba3|samba4|other", NULL},
{"async", 'a', POPT_ARG_NONE, NULL, OPT_ASYNC,
"run async tests", NULL},
@@ -530,36 +548,36 @@ int main(int argc,char *argv[])
while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_LOADFILE:
- lp_set_cmdline("torture:loadfile", poptGetOptArg(pc));
+ lp_set_cmdline(global_loadparm, "torture:loadfile", poptGetOptArg(pc));
break;
case OPT_UNCLIST:
- lp_set_cmdline("torture:unclist", poptGetOptArg(pc));
+ lp_set_cmdline(global_loadparm, "torture:unclist", poptGetOptArg(pc));
break;
case OPT_TIMELIMIT:
- lp_set_cmdline("torture:timelimit", poptGetOptArg(pc));
+ lp_set_cmdline(global_loadparm, "torture:timelimit", poptGetOptArg(pc));
break;
case OPT_NUMPROGS:
- lp_set_cmdline("torture:nprocs", poptGetOptArg(pc));
+ lp_set_cmdline(global_loadparm, "torture:nprocs", poptGetOptArg(pc));
break;
case OPT_DNS:
parse_dns(poptGetOptArg(pc));
break;
case OPT_DANGEROUS:
- lp_set_cmdline("torture:dangerous", "Yes");
+ lp_set_cmdline(global_loadparm, "torture:dangerous", "Yes");
break;
case OPT_ASYNC:
- lp_set_cmdline("torture:async", "Yes");
+ lp_set_cmdline(global_loadparm, "torture:async", "Yes");
break;
case OPT_SMB_PORTS:
- lp_set_cmdline("smb ports", poptGetOptArg(pc));
+ lp_set_cmdline(global_loadparm, "smb ports", poptGetOptArg(pc));
break;
}
}
if (strcmp(target, "samba3") == 0) {
- lp_set_cmdline("torture:samba3", "true");
+ lp_set_cmdline(global_loadparm, "torture:samba3", "true");
} else if (strcmp(target, "samba4") == 0) {
- lp_set_cmdline("torture:samba4", "true");
+ lp_set_cmdline(global_loadparm, "torture:samba4", "true");
}
if (max_runtime) {
@@ -572,9 +590,24 @@ int main(int argc,char *argv[])
alarm(max_runtime);
}
- torture_init();
ldb_global_init();
+ if (extra_module != NULL) {
+ init_module_fn fn = load_module(talloc_autofree_context(), poptGetOptArg(pc));
+
+ if (fn == NULL)
+ d_printf("Unable to load module from %s\n", poptGetOptArg(pc));
+ else {
+ status = fn();
+ if (NT_STATUS_IS_ERR(status)) {
+ d_printf("Error initializing module %s: %s\n",
+ poptGetOptArg(pc), nt_errstr(status));
+ }
+ }
+ } else {
+ torture_init();
+ }
+
if (list_tests) {
print_test_list();
return 0;
@@ -609,12 +642,14 @@ int main(int argc,char *argv[])
usage(pc);
return false;
}
- lp_set_cmdline("torture:host", binding_struct->host);
- lp_set_cmdline("torture:share", "IPC$");
- lp_set_cmdline("torture:binding", argv_new[1]);
+ lp_set_cmdline(global_loadparm, "torture:host", binding_struct->host);
+ if (lp_parm_string(global_loadparm, NULL, "torture", "share") == NULL)
+ lp_set_cmdline(global_loadparm, "torture:share", "IPC$");
+ lp_set_cmdline(global_loadparm, "torture:binding", argv_new[1]);
} else {
- lp_set_cmdline("torture:host", host);
- lp_set_cmdline("torture:share", share);
+ lp_set_cmdline(global_loadparm, "torture:host", host);
+ lp_set_cmdline(global_loadparm, "torture:share", share);
+ lp_set_cmdline(global_loadparm, "torture:binding", host);
}
if (!strcmp(ui_ops_name, "simple")) {
@@ -629,7 +664,20 @@ int main(int argc,char *argv[])
}
torture = torture_context_init(talloc_autofree_context(), ui_ops);
- torture->outputdir = basedir;
+ if (basedir != NULL) {
+ if (basedir[0] != '/') {
+ fprintf(stderr, "Please specify an absolute path to --basedir\n");
+ return 1;
+ }
+ torture->outputdir = basedir;
+ } else {
+ char *pwd = talloc_size(torture, PATH_MAX);
+ if (!getcwd(pwd, PATH_MAX)) {
+ fprintf(stderr, "Unable to determine current working directory\n");
+ return 1;
+ }
+ torture->outputdir = pwd;
+ }
if (argc_new == 0) {
printf("You must specify a test to run, or 'ALL'\n");
@@ -643,7 +691,7 @@ int main(int argc,char *argv[])
}
}
- if (torture->returncode) {
+ if (torture->returncode && correct) {
return(0);
} else {
return(1);
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 9231fe45ed..44a0d3b4c2 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -25,6 +25,7 @@
#include "lib/util/dlinklist.h"
#include "auth/credentials/credentials.h"
#include "lib/cmdline/popt_common.h"
+#include "param/param.h"
_PUBLIC_ int torture_numops=10;
_PUBLIC_ int torture_entries=1000;
@@ -39,6 +40,9 @@ bool torture_register_suite(struct torture_suite *suite)
if (!suite)
return true;
+ if (torture_root == NULL)
+ torture_root = talloc_zero(talloc_autofree_context(), struct torture_suite);
+
return torture_suite_add_suite(torture_root, suite);
}
@@ -61,11 +65,8 @@ struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
int torture_init(void)
{
init_module_fn static_init[] = STATIC_torture_MODULES;
- init_module_fn *shared_init = load_samba_modules(NULL, "torture");
+ init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "torture");
- torture_root = talloc_zero(talloc_autofree_context(),
- struct torture_suite);
-
run_init_functions(static_init);
run_init_functions(shared_init);
diff --git a/source4/torture/ui.c b/source4/torture/ui.c
index 92e03fff19..5d00b664f4 100644
--- a/source4/torture/ui.c
+++ b/source4/torture/ui.c
@@ -22,6 +22,27 @@
#include "torture/ui.h"
#include "torture/torture.h"
#include "lib/util/dlinklist.h"
+#include "param/param.h"
+#include "system/filesys.h"
+
+/**
+ create a temporary directory.
+*/
+_PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx,
+ const char *prefix,
+ char **tempdir)
+{
+ SMB_ASSERT(tctx->outputdir != NULL);
+
+ *tempdir = talloc_asprintf(tctx, "%s/%s.XXXXXX", tctx->outputdir, prefix);
+ NT_STATUS_HAVE_NO_MEMORY(*tempdir);
+
+ if (mkdtemp(*tempdir) == NULL) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ return NT_STATUS_OK;
+}
void torture_comment(struct torture_context *context, const char *comment, ...)
{
@@ -62,6 +83,11 @@ void torture_result(struct torture_context *context,
va_start(ap, fmt);
+ if (context->last_reason) {
+ torture_warning(context, "%s", context->last_reason);
+ talloc_free(context->last_reason);
+ }
+
context->last_result = result;
context->last_reason = talloc_vasprintf(context, fmt, ap);
va_end(ap);
@@ -79,20 +105,20 @@ struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name)
}
void torture_tcase_set_fixture(struct torture_tcase *tcase,
- BOOL (*setup) (struct torture_context *, void **),
- BOOL (*teardown) (struct torture_context *, void *))
+ bool (*setup) (struct torture_context *, void **),
+ bool (*teardown) (struct torture_context *, void *))
{
tcase->setup = setup;
tcase->teardown = teardown;
}
static bool wrap_test_with_testcase(struct torture_context *torture_ctx,
- struct torture_tcase *tcase,
- struct torture_test *test)
+ struct torture_tcase *tcase,
+ struct torture_test *test)
{
bool (*fn) (struct torture_context *,
- const void *tcase_data,
- const void *test_data);
+ const void *tcase_data,
+ const void *test_data);
fn = test->fn;
@@ -112,7 +138,7 @@ struct torture_test *torture_tcase_add_test(struct torture_tcase *tcase,
test->description = NULL;
test->run = wrap_test_with_testcase;
test->fn = run;
- test->dangerous = False;
+ test->dangerous = false;
test->data = data;
DLIST_ADD_END(tcase->tests, test, struct torture_test *);
@@ -129,7 +155,7 @@ bool torture_suite_init_tcase(struct torture_suite *suite,
tcase->description = NULL;
tcase->setup = NULL;
tcase->teardown = NULL;
- tcase->fixture_persistent = True;
+ tcase->fixture_persistent = true;
tcase->tests = NULL;
DLIST_ADD_END(suite->testcases, tcase, struct torture_tcase *);
@@ -149,10 +175,10 @@ struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite,
return tcase;
}
-BOOL torture_run_suite(struct torture_context *context,
+bool torture_run_suite(struct torture_context *context,
struct torture_suite *suite)
{
- BOOL ret = True;
+ bool ret = true;
struct torture_tcase *tcase;
struct torture_suite *tsuite;
char *old_testname;
@@ -164,7 +190,7 @@ BOOL torture_run_suite(struct torture_context *context,
old_testname = context->active_testname;
if (old_testname != NULL)
context->active_testname = talloc_asprintf(context, "%s-%s",
- old_testname, suite->name);
+ old_testname, suite->name);
else
context->active_testname = talloc_strdup(context, suite->name);
@@ -219,46 +245,58 @@ void torture_ui_test_result(struct torture_context *context,
context->returncode = false;
}
-static BOOL internal_torture_run_test(struct torture_context *context,
+static bool internal_torture_run_test(struct torture_context *context,
struct torture_tcase *tcase,
struct torture_test *test,
- BOOL already_setup)
+ bool already_setup)
{
- BOOL ret;
+ bool success;
char *old_testname;
- if (test->dangerous && !torture_setting_bool(context, "dangerous", False)) {
- torture_result(context, TORTURE_SKIP,
- "disabled %s - enable dangerous tests to use", test->name);
- return True;
- }
-
- if (!already_setup && tcase->setup &&
- !tcase->setup(context, &(tcase->data)))
- return False;
-
if (tcase == NULL || strcmp(test->name, tcase->name) != 0) {
old_testname = context->active_testname;
- context->active_testname = talloc_asprintf(context, "%s-%s",
- old_testname, test->name);
+ context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, test->name);
}
+
context->active_tcase = tcase;
context->active_test = test;
torture_ui_test_start(context, tcase, test);
-
context->last_reason = NULL;
context->last_result = TORTURE_OK;
- ret = test->run(context, tcase, test);
- if (!ret && context->last_result == TORTURE_OK) {
- if (context->last_reason == NULL)
- context->last_reason = talloc_strdup(context, "Unknown error/failure");
+ if (!already_setup && tcase->setup &&
+ !tcase->setup(context, &(tcase->data))) {
+ if (context->last_reason == NULL)
+ context->last_reason = talloc_strdup(context, "Setup failure");
context->last_result = TORTURE_ERROR;
+ success = false;
+ } else if (test->dangerous &&
+ !torture_setting_bool(context, "dangerous", false)) {
+ context->last_result = TORTURE_SKIP;
+ context->last_reason = talloc_asprintf(context,
+ "disabled %s - enable dangerous tests to use", test->name);
+ success = true;
+ } else {
+ success = test->run(context, tcase, test);
+
+ if (!success && context->last_result == TORTURE_OK) {
+ if (context->last_reason == NULL)
+ context->last_reason = talloc_strdup(context, "Unknown error/failure");
+ context->last_result = TORTURE_ERROR;
+ }
+ }
+
+ if (!already_setup && tcase->teardown && !tcase->teardown(context, tcase->data)) {
+ if (context->last_reason == NULL)
+ context->last_reason = talloc_strdup(context, "Setup failure");
+ context->last_result = TORTURE_ERROR;
+ success = false;
}
- torture_ui_test_result(context, context->last_result, context->last_reason);
+ torture_ui_test_result(context, context->last_result,
+ context->last_reason);
talloc_free(context->last_reason);
@@ -269,34 +307,35 @@ static BOOL internal_torture_run_test(struct torture_context *context,
context->active_test = NULL;
context->active_tcase = NULL;
- if (!already_setup && tcase->teardown && !tcase->teardown(context, tcase->data))
- return False;
-
- return ret;
+ return success;
}
-BOOL torture_run_tcase(struct torture_context *context,
+bool torture_run_tcase(struct torture_context *context,
struct torture_tcase *tcase)
{
- BOOL ret = True;
+ bool ret = true;
char *old_testname;
struct torture_test *test;
context->level++;
context->active_tcase = tcase;
- if (context->ui_ops->tcase_start)
+ if (context->ui_ops->tcase_start)
context->ui_ops->tcase_start(context, tcase);
if (tcase->fixture_persistent && tcase->setup
&& !tcase->setup(context, &tcase->data)) {
- ret = False;
+ /* FIXME: Use torture ui ops for reporting this error */
+ fprintf(stderr, "Setup failed: ");
+ if (context->last_reason != NULL)
+ fprintf(stderr, "%s", context->last_reason);
+ fprintf(stderr, "\n");
+ ret = false;
goto done;
}
old_testname = context->active_testname;
- context->active_testname = talloc_asprintf(context, "%s-%s",
- old_testname, tcase->name);
+ context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, tcase->name);
for (test = tcase->tests; test; test = test->next) {
ret &= internal_torture_run_test(context, tcase, test,
tcase->fixture_persistent);
@@ -306,7 +345,7 @@ BOOL torture_run_tcase(struct torture_context *context,
if (tcase->fixture_persistent && tcase->teardown &&
!tcase->teardown(context, tcase->data))
- ret = False;
+ ret = false;
done:
context->active_tcase = NULL;
@@ -319,35 +358,35 @@ done:
return ret;
}
-BOOL torture_run_test(struct torture_context *context,
+bool torture_run_test(struct torture_context *context,
struct torture_tcase *tcase,
struct torture_test *test)
{
- return internal_torture_run_test(context, tcase, test, False);
+ return internal_torture_run_test(context, tcase, test, false);
}
int torture_setting_int(struct torture_context *test, const char *name,
int default_value)
{
- return lp_parm_int(-1, "torture", name, default_value);
+ return lp_parm_int(global_loadparm, NULL, "torture", name, default_value);
}
double torture_setting_double(struct torture_context *test, const char *name,
double default_value)
{
- return lp_parm_double(-1, "torture", name, default_value);
+ return lp_parm_double(global_loadparm, NULL, "torture", name, default_value);
}
bool torture_setting_bool(struct torture_context *test, const char *name,
bool default_value)
{
- return lp_parm_bool(-1, "torture", name, default_value);
+ return lp_parm_bool(global_loadparm, NULL, "torture", name, default_value);
}
const char *torture_setting_string(struct torture_context *test, const char *name,
const char *default_value)
{
- const char *ret = lp_parm_string(-1, "torture", name);
+ const char *ret = lp_parm_string(global_loadparm, NULL, "torture", name);
if (ret == NULL)
return default_value;
diff --git a/source4/torture/ui.h b/source4/torture/ui.h
index 289fad5930..71c2122315 100644
--- a/source4/torture/ui.h
+++ b/source4/torture/ui.h
@@ -87,7 +87,7 @@ struct torture_context
bool returncode;
- char *outputdir;
+ const char *outputdir;
int level;
struct event_context *ev;
};
diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c
index 1e063fbe8f..882dc7a084 100644
--- a/source4/torture/unix/unix_info2.c
+++ b/source4/torture/unix/unix_info2.c
@@ -67,7 +67,7 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx)
return cli;
}
-static BOOL check_unix_info2(struct torture_context *torture,
+static bool check_unix_info2(struct torture_context *torture,
struct unix_info2 *info2)
{
printf("\tcreate_time=0x%016llu flags=0x%08x mask=0x%08x\n",
@@ -75,7 +75,7 @@ static BOOL check_unix_info2(struct torture_context *torture,
info2->file_flags, info2->flags_mask);
if (info2->file_flags == 0) {
- return True;
+ return true;
}
/* If we have any file_flags set, they must be within the range
@@ -88,7 +88,7 @@ static BOOL check_unix_info2(struct torture_context *torture,
info2->file_flags, info2->flags_mask);
}
- return True;
+ return true;
}
static NTSTATUS set_path_info2(void *mem_ctx,
@@ -122,7 +122,7 @@ static NTSTATUS set_path_info2(void *mem_ctx,
return smb_raw_setpathinfo(cli->tree, &sfinfo);
}
-static BOOL query_file_path_info2(void *mem_ctx,
+static bool query_file_path_info2(void *mem_ctx,
struct torture_context *torture,
struct smbcli_state *cli,
int fnum,
@@ -163,13 +163,13 @@ static BOOL query_file_path_info2(void *mem_ctx,
info2->flags_mask = finfo.unix_info2.out.flags_mask;
if (!check_unix_info2(torture, info2)) {
- return False;
+ return false;
}
- return True;
+ return true;
}
-static BOOL query_file_info2(void *mem_ctx,
+static bool query_file_info2(void *mem_ctx,
struct torture_context *torture,
struct smbcli_state *cli,
int fnum,
@@ -179,7 +179,7 @@ static BOOL query_file_info2(void *mem_ctx,
fnum, NULL, info2);
}
-static BOOL query_path_info2(void *mem_ctx,
+static bool query_path_info2(void *mem_ctx,
struct torture_context *torture,
struct smbcli_state *cli,
const char *fname,
@@ -189,7 +189,7 @@ static BOOL query_path_info2(void *mem_ctx,
-1, fname, info2);
}
-static BOOL search_callback(void *private, const union smb_search_data *fdata)
+static bool search_callback(void *private, const union smb_search_data *fdata)
{
struct unix_info2 *info2 = (struct unix_info2 *)private;
@@ -210,10 +210,10 @@ static BOOL search_callback(void *private, const union smb_search_data *fdata)
info2->file_flags = fdata->unix_info2.file_flags;
info2->flags_mask = fdata->unix_info2.flags_mask;
- return True;
+ return true;
}
-static BOOL find_single_info2(void *mem_ctx,
+static bool find_single_info2(void *mem_ctx,
struct torture_context *torture,
struct smbcli_state *cli,
const char *fname,
@@ -267,7 +267,7 @@ static void set_no_metadata_change(struct unix_info2 *info2)
((uint64_t)SMB_SIZE_NO_CHANGE_HI << 32) | SMB_SIZE_NO_CHANGE_LO;
}
-static BOOL verify_setinfo_flags(void *mem_ctx,
+static bool verify_setinfo_flags(void *mem_ctx,
struct torture_context *torture,
struct smbcli_state *cli,
const char *fname)
@@ -276,11 +276,11 @@ static BOOL verify_setinfo_flags(void *mem_ctx,
uint32_t smb_fmask;
int i;
- BOOL ret = True;
+ bool ret = true;
NTSTATUS status;
if (!query_path_info2(mem_ctx, torture, cli, fname, &info2)) {
- return False;
+ return false;
}
smb_fmask = info2.flags_mask;
@@ -302,7 +302,7 @@ static BOOL verify_setinfo_flags(void *mem_ctx,
if (!query_path_info2(mem_ctx, torture, cli,
fname, &info2)) {
- return False;
+ return false;
}
ASSERT_FLAGS_MATCH(&info2, 1 << i);
@@ -339,7 +339,7 @@ static int create_file(struct smbcli_state *cli, const char * fname)
0, 0);
}
-static BOOL match_info2(struct torture_context *torture,
+static bool match_info2(struct torture_context *torture,
const struct unix_info2 *pinfo,
const struct unix_info2 *finfo)
{
@@ -382,13 +382,13 @@ static BOOL match_info2(struct torture_context *torture,
torture_assert_u64_equal(torture, finfo->create_time, pinfo->create_time,
"create_time mismatch");
- return True;
+ return true;
}
#define FILENAME "\\smb_unix_info2.txt"
-BOOL unix_torture_unix_info2(struct torture_context *torture)
+bool unix_torture_unix_info2(struct torture_context *torture)
{
void *mem_ctx;
struct smbcli_state *cli;
@@ -401,7 +401,7 @@ BOOL unix_torture_unix_info2(struct torture_context *torture)
if (!(cli = connect_to_server(torture))) {
talloc_free(mem_ctx);
- return False;
+ return false;
}
smbcli_unlink(cli->tree, FILENAME);
@@ -442,7 +442,7 @@ BOOL unix_torture_unix_info2(struct torture_context *torture)
smbcli_unlink(cli->tree, FILENAME);
torture_close_connection(cli);
talloc_free(mem_ctx);
- return True;
+ return true;
fail:
@@ -450,7 +450,7 @@ fail:
smbcli_unlink(cli->tree, FILENAME);
torture_close_connection(cli);
talloc_free(mem_ctx);
- return False;
+ return false;
}
diff --git a/source4/torture/unix/whoami.c b/source4/torture/unix/whoami.c
index 8322e57bd1..f45d2345db 100644
--- a/source4/torture/unix/whoami.c
+++ b/source4/torture/unix/whoami.c
@@ -24,6 +24,7 @@
#include "libcli/raw/interfaces.h"
#include "lib/cmdline/popt_common.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
/* Size (in bytes) of the required fields in the SMBwhoami response. */
#define WHOAMI_REQUIRED_SIZE 40
@@ -71,8 +72,8 @@ static struct smbcli_state *connect_to_server(void *mem_ctx,
NTSTATUS status;
struct smbcli_state *cli;
- const char *host = lp_parm_string(-1, "torture", "host");
- const char *share = lp_parm_string(-1, "torture", "share");
+ const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host");
+ const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share");
status = smbcli_full_connection(mem_ctx, &cli,
host, share, NULL,
@@ -87,7 +88,7 @@ static struct smbcli_state *connect_to_server(void *mem_ctx,
return cli;
}
-static BOOL sid_parse(void *mem_ctx,
+static bool sid_parse(void *mem_ctx,
struct torture_context *torture,
DATA_BLOB *data, size_t *offset,
struct dom_sid **psid)
@@ -125,10 +126,10 @@ static BOOL sid_parse(void *mem_ctx,
(*offset) += 4;
}
- return True;
+ return true;
}
-static BOOL smb_raw_query_posix_whoami(void *mem_ctx,
+static bool smb_raw_query_posix_whoami(void *mem_ctx,
struct torture_context *torture,
struct smbcli_state *cli,
struct smb_whoami *whoami,
@@ -204,7 +205,7 @@ static BOOL smb_raw_query_posix_whoami(void *mem_ctx,
"invalid SID count");
torture_assert_int_equal(torture, whoami->num_sid_bytes, 0,
"invalid SID byte count");
- return True;
+ return true;
}
if (whoami->num_gids != 0) {
@@ -232,7 +233,7 @@ static BOOL smb_raw_query_posix_whoami(void *mem_ctx,
if (tp.out.data.length == offset) {
torture_assert_int_equal(torture, whoami->num_sids, 0,
"invalid SID count");
- return True;
+ return true;
}
/* All the remaining bytes must be the SID list. */
@@ -251,7 +252,7 @@ static BOOL smb_raw_query_posix_whoami(void *mem_ctx,
if (!sid_parse(mem_ctx, torture,
&tp.out.data, &offset,
&whoami->sid_list[i])) {
- return False;
+ return false;
}
}
@@ -261,10 +262,10 @@ static BOOL smb_raw_query_posix_whoami(void *mem_ctx,
torture_assert_int_equal(torture, tp.out.data.length, offset,
"trailing garbage bytes");
- return True;
+ return true;
}
-BOOL torture_unix_whoami(struct torture_context *torture)
+bool torture_unix_whoami(struct torture_context *torture)
{
struct smbcli_state *cli;
struct cli_credentials *anon_credentials;
@@ -331,11 +332,11 @@ BOOL torture_unix_whoami(struct torture_context *torture)
}
talloc_free(mem_ctx);
- return True;
+ return true;
fail:
talloc_free(mem_ctx);
- return False;
+ return false;
}
diff --git a/source4/torture/util.c b/source4/torture/util.c
index f6287e34d6..0e9dda42fa 100644
--- a/source4/torture/util.c
+++ b/source4/torture/util.c
@@ -25,24 +25,9 @@
#include "libcli/raw/libcliraw.h"
/**
- create a temporary directory.
-*/
-_PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx,
- const char *prefix,
- char **tempdir)
-{
- *tempdir = talloc_asprintf(tctx, "%s/%s.XXXXXX", tctx->outputdir, prefix);
-
- if (mkdtemp(*tempdir) == NULL)
- return NT_STATUS_UNSUCCESSFUL;
-
- return NT_STATUS_OK;
-}
-
-/**
check if 2 NTTIMEs are equal.
*/
-BOOL nt_time_equal(NTTIME *t1, NTTIME *t2)
+bool nt_time_equal(NTTIME *t1, NTTIME *t2)
{
return *t1 == *t2;
}
@@ -61,7 +46,7 @@ NTSTATUS torture_second_tcon(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- result = smbcli_tree_init(session, tmp_ctx, False);
+ result = smbcli_tree_init(session, tmp_ctx, false);
if (result == NULL) {
talloc_free(tmp_ctx);
return NT_STATUS_NO_MEMORY;
diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c
index d077b3b515..21cdba89eb 100644
--- a/source4/torture/util_smb.c
+++ b/source4/torture/util_smb.c
@@ -31,6 +31,7 @@
#include "torture/torture.h"
#include "util/dlinklist.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
/**
@@ -42,9 +43,9 @@ _PUBLIC_ bool torture_setup_dir(struct smbcli_state *cli, const char *dname)
if (smbcli_deltree(cli->tree, dname) == -1 ||
NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, dname))) {
printf("Unable to setup %s - %s\n", dname, smbcli_errstr(cli->tree));
- return False;
+ return false;
}
- return True;
+ return true;
}
/*
@@ -286,13 +287,13 @@ bool wire_bad_flags(struct smb_wire_string *str, int flags, struct smbcli_transp
{
bool server_unicode;
int len;
- if (!str || !str->s) return True;
+ if (!str || !str->s) return true;
len = strlen(str->s);
if (flags & STR_TERMINATE) len++;
- server_unicode = (transport->negotiate.capabilities&CAP_UNICODE)?True:False;
- if (getenv("CLI_FORCE_ASCII") || !lp_unicode()) {
- server_unicode = False;
+ server_unicode = (transport->negotiate.capabilities&CAP_UNICODE)?true:false;
+ if (getenv("CLI_FORCE_ASCII") || !lp_unicode(global_loadparm)) {
+ server_unicode = false;
}
if ((flags & STR_UNICODE) || server_unicode) {
@@ -303,9 +304,9 @@ bool wire_bad_flags(struct smb_wire_string *str, int flags, struct smbcli_transp
if (str->private_length != len) {
printf("Expected wire_length %d but got %d for '%s'\n",
len, str->private_length, str->s);
- return True;
+ return true;
}
- return False;
+ return false;
}
/*
@@ -384,7 +385,7 @@ NTSTATUS torture_set_sparse(struct smbcli_tree *tree, int fnum)
nt.ntioctl.level = RAW_IOCTL_NTIOCTL;
nt.ntioctl.in.function = FSCTL_SET_SPARSE;
nt.ntioctl.in.file.fnum = fnum;
- nt.ntioctl.in.fsctl = True;
+ nt.ntioctl.in.fsctl = true;
nt.ntioctl.in.filter = 0;
nt.ntioctl.in.max_data = 0;
nt.ntioctl.in.blob = data_blob(NULL, 0);
@@ -475,15 +476,15 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx,
cmdline_credentials, ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to open connection - %s\n", nt_errstr(status));
- return False;
+ return false;
}
- (*c)->transport->options.use_oplocks = lp_parm_bool(-1, "torture",
- "use_oplocks", False);
- (*c)->transport->options.use_level2_oplocks = lp_parm_bool(-1, "torture",
- "use_level2_oplocks", False);
+ (*c)->transport->options.use_oplocks = lp_parm_bool(global_loadparm, NULL, "torture",
+ "use_oplocks", false);
+ (*c)->transport->options.use_level2_oplocks = lp_parm_bool(global_loadparm, NULL, "torture",
+ "use_level2_oplocks", false);
- return True;
+ return true;
}
_PUBLIC_ bool torture_get_conn_index(int conn_index,
@@ -494,29 +495,29 @@ _PUBLIC_ bool torture_get_conn_index(int conn_index,
int num_unc_names = 0;
const char *p;
- (*host) = talloc_strdup(mem_ctx, lp_parm_string(-1, "torture", "host"));
- (*share) = talloc_strdup(mem_ctx, lp_parm_string(-1, "torture", "share"));
+ (*host) = talloc_strdup(mem_ctx, lp_parm_string(global_loadparm, NULL, "torture", "host"));
+ (*share) = talloc_strdup(mem_ctx, lp_parm_string(global_loadparm, NULL, "torture", "share"));
- p = lp_parm_string(-1, "torture", "unclist");
+ p = lp_parm_string(global_loadparm, NULL, "torture", "unclist");
if (!p) {
- return True;
+ return true;
}
unc_list = file_lines_load(p, &num_unc_names, NULL);
if (!unc_list || num_unc_names <= 0) {
DEBUG(0,("Failed to load unc names list from '%s'\n", p));
- return False;
+ return false;
}
if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names],
mem_ctx, host, share)) {
DEBUG(0, ("Failed to parse UNC name %s\n",
unc_list[conn_index % num_unc_names]));
- return False;
+ return false;
}
talloc_free(unc_list);
- return True;
+ return true;
}
@@ -529,7 +530,7 @@ _PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c,
bool ret;
if (!torture_get_conn_index(conn_index, ev, &host, &share)) {
- return False;
+ return false;
}
ret = torture_open_connection_share(NULL, c, host, share, ev);
@@ -549,11 +550,11 @@ _PUBLIC_ bool torture_open_connection(struct smbcli_state **c, int conn_index)
_PUBLIC_ bool torture_close_connection(struct smbcli_state *c)
{
- bool ret = True;
- if (!c) return True;
+ bool ret = true;
+ if (!c) return true;
if (NT_STATUS_IS_ERR(smbcli_tdis(c))) {
printf("tdis failed (%s)\n", smbcli_errstr(c->tree));
- ret = False;
+ ret = false;
}
talloc_free(c);
return ret;
@@ -576,17 +577,17 @@ _PUBLIC_ bool check_error(const char *location, struct smbcli_state *c,
printf(" expected %s or %s (at %s)\n",
nt_errstr(NT_STATUS_DOS(eclass, ecode)),
nt_errstr(nterr), location);
- return False;
+ return false;
}
} else {
if (!NT_STATUS_EQUAL(nterr, status)) {
printf("unexpected error code %s\n", nt_errstr(status));
printf(" expected %s (at %s)\n", nt_errstr(nterr), location);
- return False;
+ return false;
}
}
- return True;
+ return true;
}
static struct smbcli_state *current_cli;
@@ -608,7 +609,7 @@ double torture_create_procs(struct torture_context *tctx,
double start_time_limit = 10 + (torture_nprocs * 1.5);
struct timeval tv;
- *result = True;
+ *result = true;
synccount = 0;
@@ -628,7 +629,7 @@ double torture_create_procs(struct torture_context *tctx,
for (i = 0; i < torture_nprocs; i++) {
child_status[i] = 0;
- child_status_out[i] = True;
+ child_status_out[i] = true;
}
tv = timeval_current();
@@ -642,7 +643,7 @@ double torture_create_procs(struct torture_context *tctx,
srandom(((int)mypid) ^ ((int)time(NULL)));
asprintf(&myname, "CLIENT%d", i);
- lp_set_cmdline("netbios name", myname);
+ lp_set_cmdline(global_loadparm, "netbios name", myname);
free(myname);
@@ -683,7 +684,7 @@ double torture_create_procs(struct torture_context *tctx,
if (synccount != torture_nprocs) {
printf("FAILED TO START %d CLIENTS (started %d)\n", torture_nprocs, synccount);
- *result = False;
+ *result = false;
return timeval_elapsed(&tv);
}
@@ -703,7 +704,7 @@ double torture_create_procs(struct torture_context *tctx,
int ret;
while ((ret=waitpid(0, &status, 0)) == -1 && errno == EINTR) /* noop */ ;
if (ret == -1 || WEXITSTATUS(status) != 0) {
- *result = False;
+ *result = false;
}
}
@@ -711,7 +712,7 @@ double torture_create_procs(struct torture_context *tctx,
for (i=0;i<torture_nprocs;i++) {
if (!child_status_out[i]) {
- *result = False;
+ *result = false;
}
}
return timeval_elapsed(&tv);
@@ -829,10 +830,9 @@ static bool wrap_simple_1smb_test(struct torture_context *torture_ctx,
}
_PUBLIC_ struct torture_test *torture_suite_add_1smb_test(
- struct torture_suite *suite,
- const char *name,
- bool (*run) (struct torture_context *,
- struct smbcli_state *))
+ struct torture_suite *suite,
+ const char *name,
+ bool (*run) (struct torture_context *, struct smbcli_state *))
{
struct torture_test *test;
struct torture_tcase *tcase;
diff --git a/source4/torture/winbind/config.mk b/source4/torture/winbind/config.mk
new file mode 100644
index 0000000000..b64b0647fc
--- /dev/null
+++ b/source4/torture/winbind/config.mk
@@ -0,0 +1,15 @@
+
+#################################
+# Start SUBSYSTEM TORTURE_WINBIND
+[MODULE::TORTURE_WINBIND]
+SUBSYSTEM = torture
+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
+#################################
diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
new file mode 100644
index 0000000000..dd7a1850ab
--- /dev/null
+++ b/source4/torture/winbind/struct_based.c
@@ -0,0 +1,1051 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB torture tester - winbind struct based protocol
+ Copyright (C) Stefan Metzmacher 2007
+ Copyright (C) Michael Adam 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 "pstring.h"
+#include "torture/torture.h"
+#include "torture/winbind/proto.h"
+#include "nsswitch/winbind_client.h"
+#include "libcli/security/security.h"
+#include "librpc/gen_ndr/netlogon.h"
+#include "param/param.h"
+#include "auth/pam_errors.h"
+
+#define DO_STRUCT_REQ_REP_EXT(op,req,rep,expected,strict,warnaction,cmt) do { \
+ NSS_STATUS __got, __expected = (expected); \
+ __got = winbindd_request_response(op, req, rep); \
+ if (__got != __expected) { \
+ const char *__cmt = (cmt); \
+ if (strict) { \
+ torture_result(torture, TORTURE_FAIL, \
+ __location__ ": " __STRING(op) \
+ " returned %d, expected %d%s%s", \
+ __got, __expected, \
+ (__cmt) ? ": " : "", \
+ (__cmt) ? (__cmt) : ""); \
+ return false; \
+ } else { \
+ torture_warning(torture, \
+ __location__ ": " __STRING(op) \
+ " returned %d, expected %d%s%s", \
+ __got, __expected, \
+ (__cmt) ? ": " : "", \
+ (__cmt) ? (__cmt) : ""); \
+ warnaction; \
+ } \
+ } \
+} while(0)
+
+#define DO_STRUCT_REQ_REP(op,req,rep) do { \
+ bool __noop = false; \
+ DO_STRUCT_REQ_REP_EXT(op,req,rep,NSS_STATUS_SUCCESS,true,__noop=true,NULL); \
+} while (0)
+
+static bool torture_winbind_struct_interface_version(struct torture_context *torture)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ torture_comment(torture, "Running WINBINDD_INTERFACE_VERSION (struct based)\n");
+
+ DO_STRUCT_REQ_REP(WINBINDD_INTERFACE_VERSION, &req, &rep);
+
+ torture_assert_int_equal(torture,
+ rep.data.interface_version,
+ WINBIND_INTERFACE_VERSION,
+ "winbind server and client doesn't match");
+
+ return true;
+}
+
+static bool torture_winbind_struct_ping(struct torture_context *torture)
+{
+ struct timeval tv = timeval_current();
+ int timelimit = torture_setting_int(torture, "timelimit", 5);
+ uint32_t total = 0;
+
+ torture_comment(torture,
+ "Running WINBINDD_PING (struct based) for %d seconds\n",
+ timelimit);
+
+ while (timeval_elapsed(&tv) < timelimit) {
+ DO_STRUCT_REQ_REP(WINBINDD_PING, NULL, NULL);
+ total++;
+ }
+
+ torture_comment(torture,
+ "%u (%.1f/s) WINBINDD_PING (struct based)\n",
+ total, total / timeval_elapsed(&tv));
+
+ return true;
+}
+
+
+static char winbind_separator(struct torture_context *torture)
+{
+ struct winbindd_response rep;
+
+ ZERO_STRUCT(rep);
+
+ DO_STRUCT_REQ_REP(WINBINDD_INFO, NULL, &rep);
+
+ return rep.data.info.winbind_separator;
+}
+
+static bool torture_winbind_struct_info(struct torture_context *torture)
+{
+ struct winbindd_response rep;
+ const char *separator;
+
+ ZERO_STRUCT(rep);
+
+ torture_comment(torture, "Running WINBINDD_INFO (struct based)\n");
+
+ DO_STRUCT_REQ_REP(WINBINDD_INFO, NULL, &rep);
+
+ separator = torture_setting_string(torture,
+ "winbindd separator",
+ lp_winbind_separator(global_loadparm));
+ torture_assert_int_equal(torture,
+ rep.data.info.winbind_separator,
+ *separator,
+ "winbind separator doesn't match");
+
+ torture_comment(torture, "Samba Version '%s'\n",
+ rep.data.info.samba_version);
+
+ return true;
+}
+
+static bool torture_winbind_struct_priv_pipe_dir(struct torture_context *torture)
+{
+ struct winbindd_response rep;
+ const char *default_dir;
+ const char *expected_dir;
+ const char *got_dir;
+
+ ZERO_STRUCT(rep);
+
+ torture_comment(torture, "Running WINBINDD_PRIV_PIPE_DIR (struct based)\n");
+
+ DO_STRUCT_REQ_REP(WINBINDD_PRIV_PIPE_DIR, NULL, &rep);
+
+ got_dir = (const char *)rep.extra_data.data;
+
+ torture_assert(torture, got_dir, "NULL WINBINDD_PRIV_PIPE_DIR\n");
+
+ default_dir = lock_path(torture, global_loadparm,
+ WINBINDD_PRIV_SOCKET_SUBDIR);
+ expected_dir = torture_setting_string(torture,
+ "winbindd private pipe dir",
+ default_dir);
+
+ torture_assert_str_equal(torture, got_dir, expected_dir,
+ "WINBINDD_PRIV_PIPE_DIR doesn't match");
+
+ SAFE_FREE(rep.extra_data.data);
+ return true;
+}
+
+static bool torture_winbind_struct_netbios_name(struct torture_context *torture)
+{
+ struct winbindd_response rep;
+ const char *expected;
+
+ ZERO_STRUCT(rep);
+
+ torture_comment(torture, "Running WINBINDD_NETBIOS_NAME (struct based)\n");
+
+ DO_STRUCT_REQ_REP(WINBINDD_NETBIOS_NAME, NULL, &rep);
+
+ expected = torture_setting_string(torture,
+ "winbindd netbios name",
+ lp_netbios_name(global_loadparm));
+
+ torture_assert_str_equal(torture,
+ rep.data.netbios_name, expected,
+ "winbindd's netbios name doesn't match");
+
+ return true;
+}
+
+static bool get_winbind_domain(struct torture_context *torture, char **domain)
+{
+ struct winbindd_response rep;
+
+ ZERO_STRUCT(rep);
+
+ DO_STRUCT_REQ_REP(WINBINDD_DOMAIN_NAME, NULL, &rep);
+
+ *domain = talloc_strdup(torture, rep.data.domain_name);
+ torture_assert(torture, domain, "talloc error");
+
+ return true;
+}
+
+static bool torture_winbind_struct_domain_name(struct torture_context *torture)
+{
+ const char *expected;
+ char *domain;
+
+ torture_comment(torture, "Running WINBINDD_DOMAIN_NAME (struct based)\n");
+
+ expected = torture_setting_string(torture,
+ "winbindd netbios domain",
+ lp_workgroup(global_loadparm));
+
+ get_winbind_domain(torture, &domain);
+
+ torture_assert_str_equal(torture, domain, expected,
+ "winbindd's netbios domain doesn't match");
+
+ return true;
+}
+
+static bool torture_winbind_struct_check_machacc(struct torture_context *torture)
+{
+ bool ok;
+ bool strict = torture_setting_bool(torture, "strict mode", false);
+ struct winbindd_response rep;
+
+ ZERO_STRUCT(rep);
+
+ torture_comment(torture, "Running WINBINDD_CHECK_MACHACC (struct based)\n");
+
+ ok = true;
+ DO_STRUCT_REQ_REP_EXT(WINBINDD_CHECK_MACHACC, NULL, &rep,
+ NSS_STATUS_SUCCESS, strict, ok = false,
+ "WINBINDD_CHECK_MACHACC");
+
+ if (!ok) {
+ torture_assert(torture,
+ strlen(rep.data.auth.nt_status_string)>0,
+ "Failed with empty nt_status_string");
+
+ torture_warning(torture,"%s:%s:%s:%d\n",
+ nt_errstr(NT_STATUS(rep.data.auth.nt_status)),
+ rep.data.auth.nt_status_string,
+ rep.data.auth.error_string,
+ rep.data.auth.pam_error);
+ return true;
+ }
+
+ torture_assert_ntstatus_ok(torture,
+ NT_STATUS(rep.data.auth.nt_status),
+ "WINBINDD_CHECK_MACHACC ok: nt_status");
+
+ torture_assert_str_equal(torture,
+ rep.data.auth.nt_status_string,
+ nt_errstr(NT_STATUS_OK),
+ "WINBINDD_CHECK_MACHACC ok:nt_status_string");
+
+ torture_assert_str_equal(torture,
+ rep.data.auth.error_string,
+ nt_errstr(NT_STATUS_OK),
+ "WINBINDD_CHECK_MACHACC ok: error_string");
+
+ torture_assert_int_equal(torture,
+ rep.data.auth.pam_error,
+ nt_status_to_pam(NT_STATUS_OK),
+ "WINBINDD_CHECK_MACHACC ok: pam_error");
+
+ return true;
+}
+
+struct torture_trust_domain {
+ const char *netbios_name;
+ const char *dns_name;
+ struct dom_sid *sid;
+};
+
+static bool get_trusted_domains(struct torture_context *torture,
+ struct torture_trust_domain **_d)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ struct torture_trust_domain *d = NULL;
+ uint32_t dcount = 0;
+ fstring line;
+ const char *extra_data;
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
+
+ extra_data = (char *)rep.extra_data.data;
+ torture_assert(torture, extra_data, "NULL trust list");
+
+ while (next_token(&extra_data, line, "\n", sizeof(fstring))) {
+ char *p, *lp;
+
+ d = talloc_realloc(torture, d,
+ struct torture_trust_domain,
+ dcount + 2);
+ ZERO_STRUCT(d[dcount+1]);
+
+ lp = line;
+ p = strchr(lp, '\\');
+ torture_assert(torture, p, "missing 1st '\\' in line");
+ *p = 0;
+ d[dcount].netbios_name = talloc_strdup(d, lp);
+ torture_assert(torture, strlen(d[dcount].netbios_name) > 0,
+ "empty netbios_name");
+
+ lp = p+1;
+ p = strchr(lp, '\\');
+ torture_assert(torture, p, "missing 2nd '\\' in line");
+ *p = 0;
+ d[dcount].dns_name = talloc_strdup(d, lp);
+ /* it's ok to have an empty dns_name */
+
+ lp = p+1;
+ d[dcount].sid = dom_sid_parse_talloc(d, lp);
+ torture_assert(torture, d[dcount].sid,
+ "failed to parse sid");
+
+ dcount++;
+ }
+ SAFE_FREE(rep.extra_data.data);
+
+ torture_assert(torture, dcount >= 2,
+ "The list of trusted domain should contain 2 entries");
+
+ *_d = d;
+ return true;
+}
+
+static bool torture_winbind_struct_list_trustdom(struct torture_context *torture)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ char *list1;
+ char *list2;
+ bool ok;
+ struct torture_trust_domain *listd = NULL;
+ uint32_t i;
+
+ torture_comment(torture, "Running WINBINDD_LIST_TRUSTDOM (struct based)\n");
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ req.data.list_all_domains = false;
+
+ 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);
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ req.data.list_all_domains = true;
+
+ 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
+ */
+ torture_assert_str_equal(torture, list2, list1, "list_all_domains not ignored");
+
+ SAFE_FREE(list1);
+ SAFE_FREE(list2);
+
+ ok = get_trusted_domains(torture, &listd);
+ torture_assert(torture, ok, "failed to get trust list");
+
+ for (i=0; listd[i].netbios_name; i++) {
+ if (i == 0) {
+ struct dom_sid *builtin_sid;
+
+ builtin_sid = dom_sid_parse_talloc(torture, SID_BUILTIN);
+
+ torture_assert_str_equal(torture,
+ listd[i].netbios_name,
+ NAME_BUILTIN,
+ "first domain should be 'BUILTIN'");
+
+ torture_assert_str_equal(torture,
+ listd[i].dns_name,
+ "",
+ "BUILTIN domain should not have a dns name");
+
+ ok = dom_sid_equal(builtin_sid,
+ listd[i].sid);
+ torture_assert(torture, ok, "BUILTIN domain should have S-1-5-32");
+
+ continue;
+ }
+
+ /*
+ * TODO: verify the content of the 2nd and 3rd (in member server mode)
+ * domain entries
+ */
+ }
+
+ return true;
+}
+
+static bool torture_winbind_struct_domain_info(struct torture_context *torture)
+{
+ bool ok;
+ struct torture_trust_domain *listd = NULL;
+ uint32_t i;
+
+ torture_comment(torture, "Running WINBINDD_DOMAIN_INFO (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++) {
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ struct dom_sid *sid;
+ char *flagstr = talloc_strdup(torture," ");
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ fstrcpy(req.domain_name, listd[i].netbios_name);
+
+ DO_STRUCT_REQ_REP(WINBINDD_DOMAIN_INFO, &req, &rep);
+
+ torture_assert_str_equal(torture,
+ rep.data.domain_info.name,
+ listd[i].netbios_name,
+ "Netbios domain name doesn't match");
+
+ torture_assert_str_equal(torture,
+ rep.data.domain_info.alt_name,
+ listd[i].dns_name,
+ "DNS domain name doesn't match");
+
+ sid = dom_sid_parse_talloc(torture, rep.data.domain_info.sid);
+ torture_assert(torture, sid, "Failed to parse SID");
+
+ ok = dom_sid_equal(listd[i].sid, sid);
+ torture_assert(torture, ok, "SID's doesn't match");
+
+ if (rep.data.domain_info.primary) {
+ flagstr = talloc_strdup_append(flagstr, "PR ");
+ }
+
+ if (rep.data.domain_info.active_directory) {
+ torture_assert(torture,
+ strlen(rep.data.domain_info.alt_name)>0,
+ "Active Directory without DNS name");
+ flagstr = talloc_strdup_append(flagstr, "AD ");
+ }
+
+ if (rep.data.domain_info.native_mode) {
+ torture_assert(torture,
+ rep.data.domain_info.active_directory,
+ "Native-Mode, but no Active Directory");
+ flagstr = talloc_strdup_append(flagstr, "NA ");
+ }
+
+ torture_comment(torture, "DOMAIN '%s' => '%s' [%s]\n",
+ rep.data.domain_info.name,
+ rep.data.domain_info.alt_name,
+ flagstr);
+ }
+
+ return true;
+}
+
+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;
+
+ 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++) {
+ struct winbindd_request req;
+ struct winbindd_response rep;
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ fstrcpy(req.domain_name, listd[i].netbios_name);
+
+ ok = true;
+ DO_STRUCT_REQ_REP_EXT(WINBINDD_GETDCNAME, &req, &rep,
+ NSS_STATUS_SUCCESS,
+ (i <2 || strict), ok = false,
+ talloc_asprintf(torture, "DOMAIN '%s'",
+ req.domain_name));
+ if (!ok) continue;
+
+ /* TODO: check rep.data.dc_name; */
+ torture_comment(torture, "DOMAIN '%s' => DCNAME '%s'\n",
+ req.domain_name, rep.data.dc_name);
+ }
+
+ return true;
+}
+
+static bool torture_winbind_struct_dsgetdcname(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 count = 0;
+
+ torture_comment(torture, "Running WINBINDD_DSGETDCNAME (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++) {
+ struct winbindd_request req;
+ struct winbindd_response rep;
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ if (strlen(listd[i].dns_name) == 0) continue;
+
+ /*
+ * TODO: remove this and let winbindd give no dns name
+ * for NT4 domains
+ */
+ if (strcmp(listd[i].dns_name, listd[i].netbios_name) == 0) {
+ continue;
+ }
+
+ fstrcpy(req.domain_name, listd[i].dns_name);
+
+ /* TODO: test more flag combinations */
+ req.flags = DS_DIRECTORY_SERVICE_REQUIRED;
+
+ ok = true;
+ DO_STRUCT_REQ_REP_EXT(WINBINDD_DSGETDCNAME, &req, &rep,
+ NSS_STATUS_SUCCESS,
+ strict, ok = false,
+ talloc_asprintf(torture, "DOMAIN '%s'",
+ req.domain_name));
+ if (!ok) continue;
+
+ /* TODO: check rep.data.dc_name; */
+ torture_comment(torture, "DOMAIN '%s' => DCNAME '%s'\n",
+ req.domain_name, rep.data.dc_name);
+
+ count++;
+ }
+
+ if (count == 0) {
+ torture_warning(torture, "WINBINDD_DSGETDCNAME"
+ " was not tested with %d non-AD domains",
+ i);
+ }
+
+ if (strict) {
+ torture_assert(torture, count > 0,
+ "WiNBINDD_DSGETDCNAME was not tested");
+ }
+
+ return true;
+}
+
+static bool get_user_list(struct torture_context *torture, char ***users)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ char **u = NULL;
+ uint32_t count;
+ fstring name;
+ const char *extra_data;
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ DO_STRUCT_REQ_REP(WINBINDD_LIST_USERS, &req, &rep);
+
+ extra_data = (char *)rep.extra_data.data;
+ torture_assert(torture, extra_data, "NULL extra data");
+
+ for(count = 0;
+ next_token(&extra_data, name, ",", sizeof(fstring));
+ count++)
+ {
+ u = talloc_realloc(torture, u, char *, count + 2);
+ u[count+1] = NULL;
+ u[count] = talloc_strdup(u, name);
+ }
+
+ SAFE_FREE(rep.extra_data.data);
+
+ *users = u;
+ return true;
+}
+
+static bool torture_winbind_struct_list_users(struct torture_context *torture)
+{
+ char **users;
+ uint32_t count;
+ bool ok;
+
+ torture_comment(torture, "Running WINBINDD_LIST_USERS (struct based)\n");
+
+ ok = get_user_list(torture, &users);
+ torture_assert(torture, ok, "failed to get group list");
+
+ for (count = 0; users[count]; count++) { }
+
+ torture_comment(torture, "got %d users\n", count);
+
+ return true;
+}
+
+static bool get_group_list(struct torture_context *torture, char ***groups)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ char **g = NULL;
+ uint32_t count;
+ fstring name;
+ const char *extra_data;
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ DO_STRUCT_REQ_REP(WINBINDD_LIST_GROUPS, &req, &rep);
+
+ extra_data = (char *)rep.extra_data.data;
+ torture_assert(torture, extra_data, "NULL extra data");
+
+ for(count = 0;
+ next_token(&extra_data, name, ",", sizeof(fstring));
+ count++)
+ {
+ g = talloc_realloc(torture, g, char *, count + 2);
+ g[count+1] = NULL;
+ g[count] = talloc_strdup(g, name);
+ }
+
+ SAFE_FREE(rep.extra_data.data);
+
+ *groups = g;
+ return true;
+}
+
+static bool torture_winbind_struct_list_groups(struct torture_context *torture)
+{
+ char **groups;
+ uint32_t count;
+ bool ok;
+
+ torture_comment(torture, "Running WINBINDD_LIST_GROUPS (struct based)\n");
+
+ ok = get_group_list(torture, &groups);
+ torture_assert(torture, ok, "failed to get group list");
+
+ for (count = 0; groups[count]; count++) { }
+
+ torture_comment(torture, "got %d groups\n", count);
+
+ return true;
+}
+
+struct torture_domain_sequence {
+ const char *netbios_name;
+ uint32_t seq;
+};
+
+static bool get_sequence_numbers(struct torture_context *torture,
+ struct torture_domain_sequence **seqs)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ bool ok;
+ const char *extra_data;
+ fstring line;
+ uint32_t count = 0;
+ struct torture_domain_sequence *s = NULL;
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep);
+
+ extra_data = (char *)rep.extra_data.data;
+ torture_assert(torture, extra_data, "NULL sequence list");
+
+ while (next_token(&extra_data, line, "\n", sizeof(fstring))) {
+ char *p, *lp;
+ uint32_t seq;
+
+ s = talloc_realloc(torture, s, struct torture_domain_sequence,
+ count + 2);
+ ZERO_STRUCT(s[count+1]);
+
+ lp = line;
+ p = strchr(lp, ' ');
+ torture_assert(torture, p, "invalid line format");
+ *p = 0;
+ s[count].netbios_name = talloc_strdup(s, lp);
+
+ lp = p+1;
+ torture_assert(torture, strncmp(lp, ": ", 2) == 0,
+ "invalid line format");
+ lp += 2;
+ if (strcmp(lp, "DISCONNECTED") == 0) {
+ seq = (uint32_t)-1;
+ } else {
+ seq = (uint32_t)strtol(lp, &p, 10);
+ torture_assert(torture, (*p == '\0'),
+ "invalid line format");
+ torture_assert(torture, (seq != (uint32_t)-1),
+ "sequence number -1 encountered");
+ }
+ s[count].seq = seq;
+
+ count++;
+ }
+ SAFE_FREE(rep.extra_data.data);
+
+ torture_assert(torture, count >= 2, "The list of domain sequence "
+ "numbers should contain 2 entries");
+
+ *seqs = s;
+ return true;
+}
+
+static bool torture_winbind_struct_show_sequence(struct torture_context *torture)
+{
+ bool ok;
+ uint32_t i;
+ struct torture_trust_domain *domlist = NULL;
+ struct torture_domain_sequence *s = NULL;
+
+ torture_comment(torture, "Running WINBINDD_SHOW_SEQUENCE (struct based)\n");
+
+ ok = get_sequence_numbers(torture, &s);
+ torture_assert(torture, ok, "failed to get list of sequence numbers");
+
+ ok = get_trusted_domains(torture, &domlist);
+ torture_assert(torture, ok, "failed to get trust list");
+
+ for (i=0; domlist[i].netbios_name; i++) {
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ uint32_t seq;
+
+ torture_assert(torture, s[i].netbios_name,
+ "more domains recieved in second run");
+ torture_assert_str_equal(torture, domlist[i].netbios_name,
+ s[i].netbios_name,
+ "inconsistent order of domain lists");
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+ fstrcpy(req.domain_name, domlist[i].netbios_name);
+
+ DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep);
+
+ seq = rep.data.sequence_number;
+
+ if (i == 0) {
+ torture_assert(torture, (seq != (uint32_t)-1),
+ "BUILTIN domain disconnected");
+ } else if (i == 1) {
+ torture_assert(torture, (seq != (uint32_t)-1),
+ "local domain disconnected");
+ }
+
+
+ if (seq == (uint32_t)-1) {
+ torture_comment(torture, " * %s : DISCONNECTED\n",
+ req.domain_name);
+ } else {
+ torture_comment(torture, " * %s : %d\n",
+ req.domain_name, seq);
+ }
+ torture_assert(torture, (seq >= s[i].seq),
+ "illegal sequence number encountered");
+ }
+
+ return true;
+}
+
+static bool torture_winbind_struct_setpwent(struct torture_context *torture)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+
+ torture_comment(torture, "Running WINBINDD_SETPWENT (struct based)\n");
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ DO_STRUCT_REQ_REP(WINBINDD_SETPWENT, &req, &rep);
+
+ return true;
+}
+
+static bool torture_winbind_struct_getpwent(struct torture_context *torture)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ struct winbindd_pw *pwent;
+
+ torture_comment(torture, "Running WINBINDD_GETPWENT (struct based)\n");
+
+ torture_comment(torture, " - Running WINBINDD_SETPWENT first\n");
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+ DO_STRUCT_REQ_REP(WINBINDD_SETPWENT, &req, &rep);
+
+ torture_comment(torture, " - Running WINBINDD_GETPWENT now\n");
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+ req.data.num_entries = 1;
+ DO_STRUCT_REQ_REP(WINBINDD_GETPWENT, &req, &rep);
+ pwent = (struct winbindd_pw *)rep.extra_data.data;
+ torture_assert(torture, (pwent != NULL), "NULL pwent");
+ torture_comment(torture, "name: %s, uid: %d, gid: %d, shell: %s\n",
+ pwent->pw_name, pwent->pw_uid, pwent->pw_gid,
+ pwent->pw_shell);
+
+ return true;
+}
+
+static bool torture_winbind_struct_endpwent(struct torture_context *torture)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+
+ torture_comment(torture, "Running WINBINDD_ENDPWENT (struct based)\n");
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ DO_STRUCT_REQ_REP(WINBINDD_ENDPWENT, &req, &rep);
+
+ return true;
+}
+
+/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
+ form DOMAIN/user into a domain and a user */
+
+static bool parse_domain_user(struct torture_context *torture,
+ const char *domuser, fstring domain,
+ fstring user)
+{
+ char *p = strchr(domuser, winbind_separator(torture));
+ char *dom;
+
+ if (!p) {
+ /* Maybe it was a UPN? */
+ if ((p = strchr(domuser, '@')) != NULL) {
+ fstrcpy(domain, "");
+ fstrcpy(user, domuser);
+ return true;
+ }
+
+ fstrcpy(user, domuser);
+ get_winbind_domain(torture, &dom);
+ fstrcpy(domain, dom);
+ return true;
+ }
+
+ fstrcpy(user, p+1);
+ fstrcpy(domain, domuser);
+ domain[PTR_DIFF(p, domuser)] = 0;
+ strupper_m(domain);
+
+ return true;
+}
+
+static bool lookup_name_sid_list(struct torture_context *torture, char **list)
+{
+ uint32_t count;
+
+ for (count = 0; list[count]; count++) {
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ char *sid;
+ char *name;
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ parse_domain_user(torture, list[count], req.data.name.dom_name,
+ req.data.name.name);
+
+ DO_STRUCT_REQ_REP(WINBINDD_LOOKUPNAME, &req, &rep);
+
+ sid = talloc_strdup(torture, rep.data.sid.sid);
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ fstrcpy(req.data.sid, sid);
+
+ DO_STRUCT_REQ_REP(WINBINDD_LOOKUPSID, &req, &rep);
+
+ name = talloc_asprintf(torture, "%s%c%s",
+ rep.data.name.dom_name,
+ winbind_separator(torture),
+ rep.data.name.name);
+
+ torture_assert_casestr_equal(torture, list[count], name,
+ "LOOKUP_SID after LOOKUP_NAME != id");
+
+#if 0
+ torture_comment(torture, " %s -> %s -> %s\n", list[count],
+ sid, name);
+#endif
+
+ talloc_free(sid);
+ talloc_free(name);
+ }
+
+ return true;
+}
+
+static bool name_is_in_list(const char *name, const char **list)
+{
+ uint32_t count;
+
+ for (count = 0; list[count]; count++) {
+ if (strequal(name, list[count])) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool torture_winbind_struct_lookup_name_sid(struct torture_context *torture)
+{
+ struct winbindd_request req;
+ struct winbindd_response rep;
+ const char *invalid_sid = "S-0-0-7";
+ char *domain;
+ const char *invalid_user = "noone";
+ char *invalid_name;
+ bool strict = torture_setting_bool(torture, "strict mode", false);
+ char **users;
+ char **groups;
+ uint32_t count;
+ bool ok;
+
+ torture_comment(torture, "Running WINBINDD_LOOKUP_NAME_SID (struct based)\n");
+
+ ok = get_user_list(torture, &users);
+ torture_assert(torture, ok, "failed to retrieve list of users");
+ lookup_name_sid_list(torture, users);
+
+ ok = get_group_list(torture, &groups);
+ torture_assert(torture, ok, "failed to retrieve list of groups");
+ lookup_name_sid_list(torture, groups);
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ fstrcpy(req.data.sid, invalid_sid);
+
+ ok = true;
+ DO_STRUCT_REQ_REP_EXT(WINBINDD_LOOKUPSID, &req, &rep,
+ NSS_STATUS_NOTFOUND,
+ strict,
+ ok=false,
+ talloc_asprintf(torture,
+ "invalid sid %s was resolved",
+ invalid_sid));
+
+ ZERO_STRUCT(req);
+ ZERO_STRUCT(rep);
+
+ /* try to find an invalid name... */
+
+ count = 0;
+ get_winbind_domain(torture, &domain);
+ do {
+ count++;
+ invalid_name = talloc_asprintf(torture, "%s\\%s%u",
+ domain,
+ invalid_user, count);
+ } while(name_is_in_list(invalid_name, (const char **)users) ||
+ name_is_in_list(invalid_name, (const char **)groups));
+
+ fstrcpy(req.data.name.dom_name, domain);
+ fstrcpy(req.data.name.name,
+ talloc_asprintf(torture, "%s%u", invalid_user,
+ count));
+
+ ok = true;
+ DO_STRUCT_REQ_REP_EXT(WINBINDD_LOOKUPNAME, &req, &rep,
+ NSS_STATUS_NOTFOUND,
+ strict,
+ ok=false,
+ talloc_asprintf(torture,
+ "invalid name %s was resolved",
+ invalid_name));
+
+ talloc_free(users);
+ talloc_free(groups);
+
+ return true;
+}
+
+struct torture_suite *torture_winbind_struct_init(void)
+{
+ struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "STRUCT");
+
+ torture_suite_add_simple_test(suite, "INTERFACE_VERSION", torture_winbind_struct_interface_version);
+ torture_suite_add_simple_test(suite, "PING", torture_winbind_struct_ping);
+ torture_suite_add_simple_test(suite, "INFO", torture_winbind_struct_info);
+ torture_suite_add_simple_test(suite, "PRIV_PIPE_DIR", torture_winbind_struct_priv_pipe_dir);
+ torture_suite_add_simple_test(suite, "NETBIOS_NAME", torture_winbind_struct_netbios_name);
+ torture_suite_add_simple_test(suite, "DOMAIN_NAME", torture_winbind_struct_domain_name);
+ torture_suite_add_simple_test(suite, "CHECK_MACHACC", torture_winbind_struct_check_machacc);
+ torture_suite_add_simple_test(suite, "LIST_TRUSTDOM", torture_winbind_struct_list_trustdom);
+ torture_suite_add_simple_test(suite, "DOMAIN_INFO", torture_winbind_struct_domain_info);
+ torture_suite_add_simple_test(suite, "GETDCNAME", torture_winbind_struct_getdcname);
+ torture_suite_add_simple_test(suite, "DSGETDCNAME", torture_winbind_struct_dsgetdcname);
+ torture_suite_add_simple_test(suite, "LIST_USERS", torture_winbind_struct_list_users);
+ torture_suite_add_simple_test(suite, "LIST_GROUPS", torture_winbind_struct_list_groups);
+ torture_suite_add_simple_test(suite, "SHOW_SEQUENCE", torture_winbind_struct_show_sequence);
+ torture_suite_add_simple_test(suite, "SETPWENT", torture_winbind_struct_setpwent);
+ torture_suite_add_simple_test(suite, "GETPWENT", torture_winbind_struct_getpwent);
+ torture_suite_add_simple_test(suite, "ENDPWENT", torture_winbind_struct_endpwent);
+ torture_suite_add_simple_test(suite, "LOOKUP_NAME_SID", torture_winbind_struct_lookup_name_sid);
+
+ suite->description = talloc_strdup(suite, "WINBIND - struct based protocol tests");
+
+ return suite;
+}
diff --git a/source4/torture/winbind/winbind.c b/source4/torture/winbind/winbind.c
new file mode 100644
index 0000000000..e283602337
--- /dev/null
+++ b/source4/torture/winbind/winbind.c
@@ -0,0 +1,35 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB torture tester
+ Copyright (C) Stefan Metzmacher 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 "torture/torture.h"
+#include "torture/winbind/proto.h"
+
+NTSTATUS torture_winbind_init(void)
+{
+ struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "WINBIND");
+
+ torture_suite_add_suite(suite, torture_winbind_struct_init());
+
+ suite->description = talloc_strdup(suite, "WINBIND tests");
+
+ torture_register_suite(suite);
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c
index ae5c130638..c3f9332537 100644
--- a/source4/utils/getntacl.c
+++ b/source4/utils/getntacl.c
@@ -62,7 +62,7 @@ static NTSTATUS get_ntacl(char *filename, struct xattr_NTACL **ntacl,
return NT_STATUS_INTERNAL_ERROR;
}
- blob.data = talloc_size(*ntacl, size);
+ blob.data = talloc_array(*ntacl, uint8_t, size);
size = wrap_getxattr(filename, XATTR_NTACL_NAME, blob.data, size);
if (size < 0) {
fprintf(stderr, "get_ntacl: %s\n", strerror(errno));
diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c
index 98bf19d234..1352fb7d9b 100644
--- a/source4/utils/net/net_join.c
+++ b/source4/utils/net/net_join.c
@@ -23,6 +23,7 @@
#include "utils/net/net.h"
#include "libnet/libnet.h"
#include "libcli/security/security.h"
+#include "param/param.h"
int net_join(struct net_context *ctx, int argc, const char **argv)
{
@@ -66,7 +67,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
return -1;
}
/* prepare parameters for the join */
- r->in.netbios_name = lp_netbios_name();
+ r->in.netbios_name = lp_netbios_name(global_loadparm);
r->in.domain_name = domain_name;
r->in.join_type = secure_channel_type;
r->in.level = LIBNET_JOIN_AUTOMATIC;
diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c
index e9f48f8d41..ada5b839b7 100644
--- a/source4/utils/nmblookup.c
+++ b/source4/utils/nmblookup.c
@@ -34,12 +34,12 @@
static struct {
const char *broadcast_address;
const char *unicast_address;
- BOOL find_master;
- BOOL wins_lookup;
- BOOL node_status;
- BOOL root_port;
- BOOL lookup_by_ip;
- BOOL case_sensitive;
+ bool find_master;
+ bool wins_lookup;
+ bool node_status;
+ bool root_port;
+ bool lookup_by_ip;
+ bool case_sensitive;
} options;
/*
@@ -86,23 +86,23 @@ static char *node_status_flags(TALLOC_CTX *mem_ctx, uint16_t flags)
ret = talloc_asprintf(mem_ctx, "%s %s", group, type);
if (flags & NBT_NM_DEREGISTER) {
- ret = talloc_asprintf_append(ret, " <DEREGISTERING>");
+ ret = talloc_asprintf_append_buffer(ret, " <DEREGISTERING>");
}
if (flags & NBT_NM_CONFLICT) {
- ret = talloc_asprintf_append(ret, " <CONFLICT>");
+ ret = talloc_asprintf_append_buffer(ret, " <CONFLICT>");
}
if (flags & NBT_NM_ACTIVE) {
- ret = talloc_asprintf_append(ret, " <ACTIVE>");
+ ret = talloc_asprintf_append_buffer(ret, " <ACTIVE>");
}
if (flags & NBT_NM_PERMANENT) {
- ret = talloc_asprintf_append(ret, " <PERMANENT>");
+ ret = talloc_asprintf_append_buffer(ret, " <PERMANENT>");
}
return ret;
}
/* do a single node status */
-static BOOL do_node_status(struct nbt_name_socket *nbtsock,
+static bool do_node_status(struct nbt_name_socket *nbtsock,
const char *addr)
{
struct nbt_name_status io;
@@ -133,10 +133,10 @@ static BOOL do_node_status(struct nbt_name_socket *nbtsock,
io.out.status.statistics.unit_id[3],
io.out.status.statistics.unit_id[4],
io.out.status.statistics.unit_id[5]);
- return True;
+ return true;
}
- return False;
+ return false;
}
/* do a single node query */
@@ -144,7 +144,7 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock,
const char *addr,
const char *node_name,
enum nbt_name_type node_type,
- BOOL broadcast)
+ bool broadcast)
{
struct nbt_name_query io;
NTSTATUS status;
@@ -176,7 +176,7 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock,
}
-static BOOL process_one(const char *name)
+static bool process_one(const char *name)
{
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
enum nbt_name_type node_type = NBT_NAME_CLIENT;
@@ -184,7 +184,7 @@ static BOOL process_one(const char *name)
struct socket_address *all_zero_addr;
struct nbt_name_socket *nbtsock;
NTSTATUS status = NT_STATUS_OK;
- BOOL ret = True;
+ bool ret = true;
if (!options.case_sensitive) {
name = strupper_talloc(tmp_ctx, name);
@@ -214,14 +214,14 @@ static BOOL process_one(const char *name)
if (!all_zero_addr) {
talloc_free(tmp_ctx);
- return False;
+ return false;
}
status = socket_listen(nbtsock->sock, all_zero_addr, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to bind to local port 137 - %s\n", nt_errstr(status));
talloc_free(tmp_ctx);
- return False;
+ return false;
}
}
@@ -232,22 +232,22 @@ static BOOL process_one(const char *name)
}
if (options.broadcast_address) {
- status = do_node_query(nbtsock, options.broadcast_address, node_name, node_type, True);
+ status = do_node_query(nbtsock, options.broadcast_address, node_name, node_type, true);
} else if (options.unicast_address) {
- status = do_node_query(nbtsock, options.unicast_address, node_name, node_type, False);
+ status = do_node_query(nbtsock, options.unicast_address, node_name, node_type, false);
} else {
int i, num_interfaces = iface_count();
for (i=0;i<num_interfaces;i++) {
const char *bcast = iface_n_bcast(i);
if (bcast == NULL) continue;
- status = do_node_query(nbtsock, bcast, node_name, node_type, True);
+ status = do_node_query(nbtsock, bcast, node_name, node_type, true);
if (NT_STATUS_IS_OK(status)) break;
}
}
if (!NT_STATUS_IS_OK(status)) {
printf("Lookup failed - %s\n", nt_errstr(status));
- ret = False;
+ ret = false;
}
talloc_free(tmp_ctx);
@@ -259,7 +259,7 @@ static BOOL process_one(const char *name)
*/
int main(int argc, const char *argv[])
{
- BOOL ret = True;
+ bool ret = true;
poptContext pc;
int opt;
enum {
@@ -316,22 +316,22 @@ int main(int argc, const char *argv[])
options.unicast_address = poptGetOptArg(pc);
break;
case OPT_FIND_MASTER:
- options.find_master = True;
+ options.find_master = true;
break;
case OPT_WINS_LOOKUP:
- options.wins_lookup = True;
+ options.wins_lookup = true;
break;
case OPT_NODE_STATUS:
- options.node_status = True;
+ options.node_status = true;
break;
case OPT_ROOT_PORT:
- options.root_port = True;
+ options.root_port = true;
break;
case OPT_LOOKUP_BY_IP:
- options.lookup_by_ip = True;
+ options.lookup_by_ip = true;
break;
case OPT_CASE_SENSITIVE:
- options.case_sensitive = True;
+ options.case_sensitive = true;
break;
}
}
diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c
index f999995daf..c51b35aa03 100644
--- a/source4/utils/ntlm_auth.c
+++ b/source4/utils/ntlm_auth.c
@@ -37,6 +37,7 @@
#include "lib/messaging/messaging.h"
#include "lib/messaging/irpc.h"
#include "auth/ntlmssp/ntlmssp.h"
+#include "param/param.h"
#define INITIAL_BUFFER_SIZE 300
#define MAX_BUFFER_SIZE 63000
@@ -120,21 +121,21 @@ static void mux_printf(unsigned int mux_id, const char *format, ...)
/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
form DOMAIN/user into a domain and a user */
-static BOOL parse_ntlm_auth_domain_user(const char *domuser, fstring domain,
+static bool parse_ntlm_auth_domain_user(const char *domuser, fstring domain,
fstring user)
{
- char *p = strchr(domuser,*lp_winbind_separator());
+ char *p = strchr(domuser,*lp_winbind_separator(global_loadparm));
if (!p) {
- return False;
+ return false;
}
fstrcpy(user, p+1);
fstrcpy(domain, domuser);
domain[PTR_DIFF(p, domuser)] = 0;
- return True;
+ return true;
}
/**
@@ -167,8 +168,8 @@ static void base64_decode_inplace(char *s)
/* Authenticate a user with a plaintext password */
-static BOOL check_plaintext_auth(const char *user, const char *pass,
- BOOL stdout_diagnostics)
+static bool check_plaintext_auth(const char *user, const char *pass,
+ bool stdout_diagnostics)
{
return (strcmp(pass, opt_password) == 0);
}
@@ -219,7 +220,7 @@ static NTSTATUS local_pw_check_specified(const char *username,
if (unix_name) {
asprintf(unix_name,
"%s%c%s", domain,
- *lp_winbind_separator(),
+ *lp_winbind_separator(global_loadparm),
username);
}
} else {
@@ -244,7 +245,7 @@ static void manage_squid_basic_request(enum stdio_helper_mode stdio_helper_mode,
char *user, *pass;
user=buf;
- pass=memchr(buf,' ',length);
+ pass = memchr(buf, ' ', length);
if (!pass) {
DEBUG(2, ("Password not found. Denying access\n"));
mux_printf(mux_id, "ERR\n");
@@ -258,7 +259,7 @@ static void manage_squid_basic_request(enum stdio_helper_mode stdio_helper_mode,
rfc1738_unescape(pass);
}
- if (check_plaintext_auth(user, pass, False)) {
+ if (check_plaintext_auth(user, pass, false)) {
mux_printf(mux_id, "OK\n");
} else {
mux_printf(mux_id, "ERR\n");
@@ -324,17 +325,35 @@ static const char *get_password(struct cli_credentials *credentials)
return password;
}
+/**
+ Check if a string is part of a list.
+**/
+static bool in_list(const char *s, const char *list, bool casesensitive)
+{
+ pstring tok;
+ const char *p=list;
+
+ if (!list)
+ return false;
+
+ while (next_token(&p, tok, LIST_SEP, sizeof(tok))) {
+ if ((casesensitive?strcmp:strcasecmp_m)(tok,s) == 0)
+ return true;
+ }
+ return false;
+}
+
static void gensec_want_feature_list(struct gensec_security *state, char* feature_list)
{
- if (in_list("NTLMSSP_FEATURE_SESSION_KEY", feature_list, True)) {
+ if (in_list("NTLMSSP_FEATURE_SESSION_KEY", feature_list, true)) {
DEBUG(10, ("want GENSEC_FEATURE_SESSION_KEY\n"));
gensec_want_feature(state, GENSEC_FEATURE_SESSION_KEY);
}
- if (in_list("NTLMSSP_FEATURE_SIGN", feature_list, True)) {
+ if (in_list("NTLMSSP_FEATURE_SIGN", feature_list, true)) {
DEBUG(10, ("want GENSEC_FEATURE_SIGN\n"));
gensec_want_feature(state, GENSEC_FEATURE_SIGN);
}
- if (in_list("NTLMSSP_FEATURE_SEAL", feature_list, True)) {
+ if (in_list("NTLMSSP_FEATURE_SEAL", feature_list, true)) {
DEBUG(10, ("want GENSEC_FEATURE_SEAL\n"));
gensec_want_feature(state, GENSEC_FEATURE_SEAL);
}
@@ -357,7 +376,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
struct messaging_context *msg;
NTSTATUS nt_status;
- BOOL first = False;
+ bool first = false;
const char *reply_code;
struct cli_credentials *creds;
@@ -367,7 +386,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
TALLOC_CTX *mem_ctx;
if (*private) {
- state = *private;
+ state = (struct gensec_ntlm_state *)*private;
} else {
state = talloc_zero(NULL, struct gensec_ntlm_state);
if (!state) {
@@ -442,7 +461,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
if (!ev) {
exit(1);
}
- msg = messaging_client_init(state, ev);
+ msg = messaging_client_init(state, lp_messaging_path(state, global_loadparm), ev);
if (!msg) {
exit(1);
}
@@ -455,7 +474,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
}
creds = cli_credentials_init(state->gensec_state);
- cli_credentials_set_conf(creds);
+ cli_credentials_set_conf(creds, global_loadparm);
if (opt_username) {
cli_credentials_set_username(creds, opt_username, CRED_SPECIFIED);
}
@@ -489,12 +508,12 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
case GSS_SPNEGO_SERVER:
nt_status = gensec_start_mech_by_oid(state->gensec_state, GENSEC_OID_SPNEGO);
if (!in.length) {
- first = True;
+ first = true;
}
break;
case NTLMSSP_CLIENT_1:
if (!in.length) {
- first = True;
+ first = true;
}
/* fall through */
case SQUID_2_5_NTLMSSP:
@@ -550,7 +569,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
struct security_token *token = session_info->security_token;
const char *sidstr = dom_sid_string(session_info,
token->sids[i]);
- grouplist = talloc_asprintf_append(grouplist, "%s,", sidstr);
+ grouplist = talloc_asprintf_append_buffer(grouplist, "%s,", sidstr);
}
mux_printf(mux_id, "GL %s\n", grouplist);
@@ -640,7 +659,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
reply_code = "AF";
reply_arg = talloc_asprintf(state->gensec_state,
"%s%s%s", session_info->server_info->domain_name,
- lp_winbind_separator(), session_info->server_info->account_name);
+ lp_winbind_separator(global_loadparm), session_info->server_info->account_name);
talloc_free(session_info);
}
} else if (state->gensec_state->gensec_role == GENSEC_CLIENT) {
@@ -682,8 +701,8 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod
static char *username;
static char *domain;
static char *plaintext_password;
- static BOOL ntlm_server_1_user_session_key;
- static BOOL ntlm_server_1_lm_session_key;
+ static bool ntlm_server_1_user_session_key;
+ static bool ntlm_server_1_lm_session_key;
if (strequal(buf, ".")) {
if (!full_username && !username) {
@@ -691,12 +710,12 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod
} else if (plaintext_password) {
/* handle this request as plaintext */
if (!full_username) {
- if (asprintf(&full_username, "%s%c%s", domain, *lp_winbind_separator(), username) == -1) {
+ if (asprintf(&full_username, "%s%c%s", domain, *lp_winbind_separator(global_loadparm), username) == -1) {
mux_printf(mux_id, "Error: Out of memory in asprintf!\n.\n");
return;
}
}
- if (check_plaintext_auth(full_username, plaintext_password, False)) {
+ if (check_plaintext_auth(full_username, plaintext_password, false)) {
mux_printf(mux_id, "Authenticated: Yes\n");
} else {
mux_printf(mux_id, "Authenticated: No\n");
@@ -726,7 +745,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod
}
if (!domain) {
- domain = smb_xstrdup(lp_workgroup());
+ domain = smb_xstrdup(lp_workgroup(global_loadparm));
}
if (ntlm_server_1_lm_session_key)
@@ -738,7 +757,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod
if (!NT_STATUS_IS_OK(
local_pw_check_specified(username,
domain,
- lp_netbios_name(),
+ lp_netbios_name(global_loadparm),
&challenge,
&lm_response,
&nt_response,
@@ -789,8 +808,8 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod
SAFE_FREE(username);
SAFE_FREE(domain);
SAFE_FREE(plaintext_password);
- ntlm_server_1_user_session_key = False;
- ntlm_server_1_lm_session_key = False;
+ ntlm_server_1_user_session_key = false;
+ ntlm_server_1_lm_session_key = false;
mux_printf(mux_id, ".\n");
return;
@@ -883,8 +902,7 @@ static void manage_squid_request(enum stdio_helper_mode helper_mode,
static void *normal_private;
void **private;
- buf = talloc(NULL, char);
- buf[0] = '\0';
+ buf = talloc_strdup(NULL, "");
if (buf == NULL) {
DEBUG(0, ("Failed to allocate memory for reading the input "
@@ -907,7 +925,7 @@ static void manage_squid_request(enum stdio_helper_mode helper_mode,
exit(0);
}
- buf = talloc_append_string(buf, buf, tmp);
+ buf = talloc_strdup_append_buffer(buf, tmp);
buf_size += INITIAL_BUFFER_SIZE;
if (buf_size > MAX_BUFFER_SIZE) {
@@ -1066,7 +1084,7 @@ int main(int argc, const char **argv)
gensec_init();
if (opt_domain == NULL) {
- opt_domain = lp_workgroup();
+ opt_domain = lp_workgroup(global_loadparm);
}
if (helper_protocol) {
@@ -1093,7 +1111,7 @@ int main(int argc, const char **argv)
}
if (opt_workstation == NULL) {
- opt_workstation = lp_netbios_name();
+ opt_workstation = lp_netbios_name(global_loadparm);
}
if (!opt_password) {
@@ -1103,8 +1121,8 @@ int main(int argc, const char **argv)
{
char *user;
- asprintf(&user, "%s%c%s", opt_domain, *lp_winbind_separator(), opt_username);
- if (!check_plaintext_auth(user, opt_password, True)) {
+ asprintf(&user, "%s%c%s", opt_domain, *lp_winbind_separator(global_loadparm), opt_username);
+ if (!check_plaintext_auth(user, opt_password, true)) {
return 1;
}
}
diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c
index 886b51300f..71ff937a51 100644
--- a/source4/utils/testparm.c
+++ b/source4/utils/testparm.c
@@ -36,6 +36,7 @@
#include "system/filesys.h"
#include "lib/cmdline/popt_common.h"
#include "lib/socket/socket.h"
+#include "param/param.h"
/***********************************************
@@ -43,28 +44,28 @@
configuration settings.
************************************************/
-static int do_global_checks(void)
+static int do_global_checks(struct loadparm_context *lp_ctx)
{
int ret = 0;
- if (!directory_exist(lp_lockdir())) {
+ if (!directory_exist(lp_lockdir(lp_ctx))) {
fprintf(stderr, "ERROR: lock directory %s does not exist\n",
- lp_lockdir());
+ lp_lockdir(lp_ctx));
ret = 1;
}
- if (!directory_exist(lp_piddir())) {
+ if (!directory_exist(lp_piddir(lp_ctx))) {
fprintf(stderr, "ERROR: pid directory %s does not exist\n",
- lp_piddir());
+ lp_piddir(lp_ctx));
ret = 1;
}
- if (strlen(lp_winbind_separator()) != 1) {
+ if (strlen(lp_winbind_separator(lp_ctx)) != 1) {
fprintf(stderr,"ERROR: the 'winbind separator' parameter must be a single character.\n");
ret = 1;
}
- if (*lp_winbind_separator() == '+') {
+ if (*lp_winbind_separator(lp_ctx) == '+') {
fprintf(stderr,"'winbind separator = +' might cause problems with group membership.\n");
}
@@ -136,22 +137,23 @@ static int do_global_checks(void)
*/
/* We need this to force the output */
- lp_set_cmdline("log level", "2");
+ lp_set_cmdline(global_loadparm, "log level", "2");
- fprintf(stderr,"Load smb config files from %s\n",lp_configfile());
+ fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm));
- if (!lp_load()) {
+ if (!lp_load(lp_configfile(global_loadparm))) {
fprintf(stderr,"Error loading services.\n");
return(1);
}
fprintf(stderr,"Loaded services file OK.\n");
- ret = do_global_checks();
+ ret = do_global_checks(global_loadparm);
- for (s=0;s<lp_numservices();s++) {
- if (lp_snum_ok(s))
- if (strlen(lp_servicename(s)) > 12) {
+ for (s=0;s<lp_numservices(global_loadparm);s++) {
+ struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
+ if (service != NULL)
+ if (strlen(lp_servicename(lp_servicebynum(global_loadparm, s))) > 12) {
fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" );
fprintf(stderr, "These may not be accessible to some older clients.\n" );
fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" );
@@ -159,10 +161,11 @@ static int do_global_checks(void)
}
}
- for (s=0;s<lp_numservices();s++) {
- if (lp_snum_ok(s)) {
- const char **deny_list = lp_hostsdeny(s);
- const char **allow_list = lp_hostsallow(s);
+ for (s=0;s<lp_numservices(global_loadparm);s++) {
+ struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
+ if (service != NULL) {
+ const char **deny_list = lp_hostsdeny(service);
+ const char **allow_list = lp_hostsallow(service);
int i;
if(deny_list) {
for (i=0; deny_list[i]; i++) {
@@ -170,7 +173,7 @@ static int do_global_checks(void)
char *hasquery = strchr_m(deny_list[i], '?');
if(hasstar || hasquery) {
fprintf(stderr,"Invalid character %c in hosts deny list (%s) for service %s.\n",
- hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(s) );
+ hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(service) );
}
}
}
@@ -181,7 +184,7 @@ static int do_global_checks(void)
char *hasquery = strchr_m(allow_list[i], '?');
if(hasstar || hasquery) {
fprintf(stderr,"Invalid character %c in hosts allow list (%s) for service %s.\n",
- hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(s) );
+ hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(service) );
}
}
}
@@ -196,42 +199,39 @@ static int do_global_checks(void)
getc(stdin);
}
if (section_name || parameter_name) {
- BOOL isGlobal = False;
+ struct loadparm_service *service = NULL;
if (!section_name) {
section_name = GLOBAL_NAME;
- isGlobal = True;
- } else if ((isGlobal=!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
- (s=lp_servicenumber(section_name)) == -1) {
+ service = NULL;
+ } else if ((!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
+ (service=lp_service(global_loadparm, section_name)) == NULL) {
fprintf(stderr,"Unknown section %s\n",
section_name);
return(1);
}
if (!parameter_name) {
- if (isGlobal == True) {
- lp_dump(stdout, show_defaults, 0);
- } else {
- lp_dump_one(stdout, show_defaults, s);
- }
+ lp_dump_one(stdout, show_defaults, service);
} else {
- ret = !lp_dump_a_parameter(s, parameter_name, stdout, isGlobal);
+ ret = !lp_dump_a_parameter(global_loadparm, s, parameter_name, stdout, (service == NULL));
}
} else {
- lp_dump(stdout, show_defaults, lp_numservices());
+ lp_dump(global_loadparm, stdout, show_defaults, lp_numservices(global_loadparm));
}
return(ret);
}
if(cname && caddr){
/* this is totally ugly, a real `quick' hack */
- for (s=0;s<lp_numservices();s++) {
- if (lp_snum_ok(s)) {
- if (allow_access(NULL, lp_hostsdeny(-1), lp_hostsallow(-1), cname, caddr)
- && allow_access(NULL, lp_hostsdeny(s), lp_hostsallow(s), cname, caddr)) {
+ for (s=0;s<lp_numservices(global_loadparm);s++) {
+ struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
+ if (service != NULL) {
+ if (allow_access(NULL, lp_hostsdeny(NULL), lp_hostsallow(NULL), cname, caddr)
+ && allow_access(NULL, lp_hostsdeny(service), lp_hostsallow(service), cname, caddr)) {
fprintf(stderr,"Allow connection from %s (%s) to %s\n",
- cname,caddr,lp_servicename(s));
+ cname,caddr,lp_servicename(service));
} else {
fprintf(stderr,"Deny connection from %s (%s) to %s\n",
- cname,caddr,lp_servicename(s));
+ cname,caddr,lp_servicename(service));
}
}
}
diff --git a/source4/web_server/http.c b/source4/web_server/http.c
index 502d5de2d0..67329fba7e 100644
--- a/source4/web_server/http.c
+++ b/source4/web_server/http.c
@@ -32,11 +32,10 @@
#include "lib/util/dlinklist.h"
#include "lib/tls/tls.h"
#include "scripting/ejs/smbcalls.h"
+#include "param/param.h"
#define SAMBA_SESSION_KEY "SambaSessionId"
#define HTTP_PREAUTH_URI "/scripting/preauth.esp"
-#define JSONRPC_REQUEST "/services"
-#define JSONRPC_SERVER "/request.esp"
/* state of the esp subsystem for a specific request */
struct esp_state {
@@ -83,7 +82,7 @@ static void http_output_headers(struct websrv_context *web)
web->output.response_code, response_string);
if (s == NULL) return;
for (i=0;web->output.headers[i];i++) {
- s = talloc_asprintf_append(s, "%s\r\n", web->output.headers[i]);
+ s = talloc_asprintf_append_buffer(s, "%s\r\n", web->output.headers[i]);
}
/* work out the content length */
@@ -93,7 +92,7 @@ static void http_output_headers(struct websrv_context *web)
fstat(web->output.fd, &st);
content_length += st.st_size;
}
- s = talloc_asprintf_append(s, "Content-Length: %u\r\n\r\n", content_length);
+ s = talloc_asprintf_append_buffer(s, "Content-Length: %u\r\n\r\n", content_length);
if (s == NULL) return;
b = web->output.content;
@@ -126,7 +125,7 @@ static const char *http_local_path(struct websrv_context *web,
if (path == NULL) return NULL;
if (directory_exist(path)) {
- path = talloc_asprintf_append(path, "/index.esp");
+ path = talloc_asprintf_append_buffer(path, "/index.esp");
}
return path;
}
@@ -151,7 +150,7 @@ static int http_readFile(EspHandle handle,
fd = open(path, O_RDONLY);
if (fd == -1 || fstat(fd, &st) != 0 || !S_ISREG(st.st_mode)) goto failed;
- *buf = talloc_size(handle, st.st_size+1);
+ *buf = talloc_array(handle, char, st.st_size+1);
if (*buf == NULL) goto failed;
if (read(fd, *buf, st.st_size) != st.st_size) goto failed;
@@ -170,12 +169,12 @@ failed:
return -1;
}
-static int http_readFileFromWebappsDir(EspHandle handle,
+static int http_readFileFromSwatDir(EspHandle handle,
char **buf,
int *len,
const char *path)
{
- return http_readFile(handle, buf, len, path, lp_webapps_directory());
+ return http_readFile(handle, buf, len, path, lp_swat_directory(global_loadparm));
}
@@ -357,7 +356,7 @@ void http_error(struct websrv_context *web, int code, const char *info)
http_output_headers(web);
EVENT_FD_NOT_READABLE(web->conn->event.fde);
EVENT_FD_WRITEABLE(web->conn->event.fde);
- web->output.output_pending = True;
+ web->output.output_pending = true;
}
/*
@@ -389,7 +388,7 @@ static void http_simple_request(struct websrv_context *web)
const char *path;
struct stat st;
- path = http_local_path(web, url, lp_webapps_directory());
+ path = http_local_path(web, url, lp_swat_directory(global_loadparm));
if (path == NULL) goto invalid;
/* looks ok */
@@ -453,7 +452,7 @@ static void http_setup_arrays(struct esp_state *esp)
if (web->session) {
SETVAR(ESP_REQUEST_OBJ, "SESSION_ID", web->session->id);
}
- SETVAR(ESP_REQUEST_OBJ, "COOKIE_SUPPORT", web->input.cookie?"True":"False");
+ SETVAR(ESP_REQUEST_OBJ, "COOKIE_SUPPORT", web->input.cookie?"true":"false");
SETVAR(ESP_HEADERS_OBJ, "HTTP_REFERER", web->input.referer);
SETVAR(ESP_HEADERS_OBJ, "HOST", web->input.host);
@@ -471,11 +470,11 @@ static void http_setup_arrays(struct esp_state *esp)
talloc_asprintf(esp, "%u", socket_address->port));
}
- SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_webapps_directory());
+ SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_swat_directory(global_loadparm));
SETVAR(ESP_SERVER_OBJ, "SERVER_PROTOCOL", tls_enabled(web->conn->socket)?"https":"http");
SETVAR(ESP_SERVER_OBJ, "SERVER_SOFTWARE", "SAMBA");
SETVAR(ESP_SERVER_OBJ, "GATEWAY_INTERFACE", "CGI/1.1");
- SETVAR(ESP_SERVER_OBJ, "TLS_SUPPORT", tls_support(edata->tls_params)?"True":"False");
+ SETVAR(ESP_SERVER_OBJ, "TLS_SUPPORT", tls_support(edata->tls_params)?"true":"false");
}
#if HAVE_SETJMP_H
@@ -516,7 +515,7 @@ static void esp_request(struct esp_state *esp, const char *url)
int res;
char *emsg = NULL, *buf;
- if (http_readFile(web, &buf, &size, url, lp_webapps_directory()) != 0) {
+ if (http_readFile(web, &buf, &size, url, lp_swat_directory(global_loadparm)) != 0) {
http_error_unix(web, url);
return;
}
@@ -538,97 +537,25 @@ static void esp_request(struct esp_state *esp, const char *url)
}
/*
- process a JSON RPC request
-*/
-static void jsonrpc_request(struct esp_state *esp)
-{
- struct websrv_context *web = esp->web;
- const char *path = http_local_path(web,
- JSONRPC_SERVER,
- lp_jsonrpc_services_dir());
- MprVar *global;
- MprVar v;
- MprVar temp;
- int size;
- int res;
- char *emsg = NULL;
- char *emsg2 = NULL;
- char *buf;
- char *error_script =
- "error.setOrigin(jsonrpc.Constant.ErrorOrigin.Server); "
- "error.setError(jsonrpc.Constant.ErrorCode.UnexpectedOutput, "
- " global.errorString);"
- "error.Send();";
-
- /* Ensure we got a valid path. */
- if (path == NULL) {
- /* should never occur */
- http_error(esp->web, 500, "Internal server error");
- return;
- }
-
- /* Ensure that the JSON-RPC server request script exists */
- if (!file_exist(path)) {
- http_error_unix(esp->web, path);
- return;
- }
-
- /* Call the server request script */
- if (http_readFile(web, &buf, &size,
- JSONRPC_SERVER, lp_jsonrpc_services_dir()) != 0) {
- http_error_unix(web, JSONRPC_SERVER);
- return;
- }
-
-#if HAVE_SETJMP_H
- if (setjmp(ejs_exception_buf) != 0) {
- http_error(web, 500, exception_reason);
- return;
- }
-#endif
-
- res = espProcessRequest(esp->req, JSONRPC_SERVER, buf, &emsg);
- if (res != 0 && emsg) {
- /* Save the error in a string accessible from javascript */
- global = ejsGetGlobalObject(0);
- v = mprString(emsg);
- mprCreateProperty(global, "errorString", &v);
-
- /* Create and send a JsonRpcError object */
- if (ejsEvalScript(0,
- error_script,
- &temp,
- &emsg2) != 0) {
- http_writeBlock(web, "<pre>", 5);
- http_writeBlock(web, emsg, strlen(emsg));
- http_writeBlock(web, "</pre>", 6);
- }
- }
- talloc_free(buf);
-}
-
-/*
perform pre-authentication on every page if /scripting/preauth.esp
exists. If this script generates any non-whitepace output at all,
then we don't run the requested URL.
- note that the preauth is run even for static pages such as images, but not
- for JSON-RPC service requests which do their own authentication via the
- JSON-RPC server.
+ note that the preauth is run even for static pages such as images
*/
-static BOOL http_preauth(struct esp_state *esp)
+static bool http_preauth(struct esp_state *esp)
{
const char *path = http_local_path(esp->web,
HTTP_PREAUTH_URI,
- lp_webapps_directory());
+ lp_swat_directory(global_loadparm));
int i;
if (path == NULL) {
http_error(esp->web, 500, "Internal server error");
- return False;
+ return false;
}
if (!file_exist(path)) {
/* if the preath script is not installed then allow access */
- return True;
+ return true;
}
esp_request(esp, HTTP_PREAUTH_URI);
for (i=0;i<esp->web->output.content.length;i++) {
@@ -637,11 +564,11 @@ static BOOL http_preauth(struct esp_state *esp)
to be html, so that we can show the login page for
failed access to images */
http_setHeader(esp->web, "Content-Type: text/html", 0);
- return False;
+ return false;
}
}
data_blob_free(&esp->web->output.content);
- return True;
+ return true;
}
@@ -777,7 +704,7 @@ static void http_setup_session(struct esp_state *esp)
const char *key = NULL;
struct esp_data *edata = talloc_get_type(esp->web->task->private, struct esp_data);
struct session_data *s;
- BOOL generated_key = False;
+ bool generated_key = false;
/* look for our session key */
if (cookie && (p = strstr(cookie, session_key)) &&
@@ -790,7 +717,7 @@ static void http_setup_session(struct esp_state *esp)
key = esp->web->input.session_key;
} else if (key == NULL) {
key = generate_random_str_list(esp, 16, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
- generated_key = True;
+ generated_key = true;
}
/* try to find this session in the existing session list */
@@ -807,12 +734,12 @@ static void http_setup_session(struct esp_state *esp)
s->data = NULL;
s->te = NULL;
s->edata = edata;
- s->lifetime = lp_parm_int(-1, "web", "sessiontimeout", 900);
+ s->lifetime = lp_parm_int(global_loadparm, NULL, "web", "sessiontimeout", 900);
DLIST_ADD(edata->sessions, s);
talloc_set_destructor(s, session_destructor);
if (!generated_key) {
mprSetPropertyValue(&esp->variables[ESP_REQUEST_OBJ],
- "SESSION_EXPIRED", mprCreateStringVar("True", 0));
+ "SESSION_EXPIRED", mprCreateStringVar("true", 0));
}
}
@@ -833,7 +760,7 @@ static const struct Esp esp_control = {
.setHeader = http_setHeader,
.redirect = http_redirect,
.setResponseCode = http_setResponseCode,
- .readFile = http_readFileFromWebappsDir,
+ .readFile = http_readFileFromSwatDir,
.mapToStorage = http_mapToStorage,
.setCookie = http_setCookie,
.createSession = http_createSession,
@@ -857,8 +784,7 @@ void http_process_input(struct websrv_context *web)
const char *file_type = NULL;
enum page_type {
page_type_simple,
- page_type_esp,
- page_type_jsonrpc
+ page_type_esp
};
enum page_type page_type;
const struct {
@@ -872,7 +798,7 @@ void http_process_input(struct websrv_context *web)
{"txt", "text/plain"},
{"ico", "image/x-icon"},
{"css", "text/css"},
- {"esp", "text/html", True}
+ {"esp", "text/html", true}
};
/*
@@ -944,35 +870,21 @@ void http_process_input(struct websrv_context *web)
esp->req = espCreateRequest(web, web->input.url, esp->variables);
if (esp->req == NULL) goto internal_error;
- /*
- * Work out the mime type. First, we see if the request is a JSON-RPC
- * service request. If not, we look at the extension.
- */
- if (strncmp(web->input.url,
- JSONRPC_REQUEST,
- sizeof(JSONRPC_REQUEST) - 1) == 0 &&
- (web->input.url[sizeof(JSONRPC_REQUEST) - 1] == '\0' ||
- web->input.url[sizeof(JSONRPC_REQUEST) - 1] == '/')) {
- page_type = page_type_jsonrpc;
- file_type = "text/json";
-
- } else {
- p = strrchr(web->input.url, '.');
- if (p == NULL) {
- page_type = page_type_esp;
- file_type = "text/html";
- }
- for (i=0;p && i<ARRAY_SIZE(mime_types);i++) {
+ p = strrchr(web->input.url, '.');
+ if (p == NULL) {
+ page_type = page_type_esp;
+ file_type = "text/html";
+ }
+ for (i=0;p && i<ARRAY_SIZE(mime_types);i++) {
if (strcmp(mime_types[i].extension, p+1) == 0) {
- page_type = mime_types[i].page_type;
- file_type = mime_types[i].mime_type;
+ page_type = mime_types[i].page_type;
+ file_type = mime_types[i].mime_type;
}
- }
- if (file_type == NULL) {
+ }
+ if (file_type == NULL) {
page_type = page_type_simple;
file_type = "text/html";
- }
- }
+ }
/* setup basic headers */
http_setResponseCode(web, 200);
@@ -1001,10 +913,6 @@ void http_process_input(struct websrv_context *web)
esp_request(esp, web->input.url);
}
break;
-
- case page_type_jsonrpc:
- jsonrpc_request(esp);
- break;
}
if (web->conn == NULL) {
@@ -1016,7 +924,7 @@ void http_process_input(struct websrv_context *web)
if (!web->output.output_pending) {
http_output_headers(web);
EVENT_FD_WRITEABLE(web->conn->event.fde);
- web->output.output_pending = True;
+ web->output.output_pending = true;
}
/* copy any application data to long term storage in edata */
@@ -1070,11 +978,11 @@ internal_error:
NTSTATUS http_parse_header(struct websrv_context *web, const char *line)
{
if (line[0] == 0) {
- web->input.end_of_headers = True;
+ web->input.end_of_headers = true;
} else if (strncasecmp(line,"GET ", 4)==0) {
web->input.url = talloc_strndup(web, &line[4], strcspn(&line[4], " \t"));
} else if (strncasecmp(line,"POST ", 5)==0) {
- web->input.post_request = True;
+ web->input.post_request = true;
web->input.url = talloc_strndup(web, &line[5], strcspn(&line[5], " \t"));
} else if (strchr(line, ':') == NULL) {
http_error(web, 400, "This server only accepts GET and POST requests");
diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c
index f9031433d3..2e80339871 100644
--- a/source4/web_server/web_server.c
+++ b/source4/web_server/web_server.c
@@ -29,6 +29,7 @@
#include "system/network.h"
#include "lib/socket/netif.h"
#include "lib/tls/tls.h"
+#include "param/param.h"
/* don't allow connections to hang around forever */
#define HTTP_TIMEOUT 120
@@ -84,7 +85,7 @@ static void websrv_recv(struct stream_connection *conn, uint16_t flags)
/* parse any lines that are available */
b = web->input.partial;
while (!web->input.end_of_headers &&
- (p=memchr(b.data, '\n', b.length))) {
+ (p=(uint8_t *)memchr(b.data, '\n', b.length))) {
const char *line = (const char *)b.data;
*p = 0;
if (p != b.data && p[-1] == '\r') {
@@ -240,7 +241,7 @@ static const struct stream_server_ops web_stream_ops = {
static void websrv_task_init(struct task_server *task)
{
NTSTATUS status;
- uint16_t port = lp_web_port();
+ uint16_t port = lp_web_port(global_loadparm);
const struct model_ops *model_ops;
task_server_set_title(task, "task[websrv]");
@@ -249,7 +250,7 @@ static void websrv_task_init(struct task_server *task)
model_ops = process_model_byname("single");
if (!model_ops) goto failed;
- if (lp_interfaces() && lp_bind_interfaces_only()) {
+ if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) {
int num_interfaces = iface_count();
int i;
for(i = 0; i < num_interfaces; i++) {
@@ -263,7 +264,7 @@ static void websrv_task_init(struct task_server *task)
} else {
status = stream_setup_socket(task->event_ctx, model_ops,
&web_stream_ops,
- "ipv4", lp_socket_address(),
+ "ipv4", lp_socket_address(global_loadparm),
&port, task);
if (!NT_STATUS_IS_OK(status)) goto failed;
}
diff --git a/source4/winbind/wb_cmd_getpwent.c b/source4/winbind/wb_cmd_getpwent.c
index e4023dbad7..980a8a4d92 100644
--- a/source4/winbind/wb_cmd_getpwent.c
+++ b/source4/winbind/wb_cmd_getpwent.c
@@ -25,7 +25,6 @@
#include "winbind/wb_async_helpers.h"
#include "winbind/wb_helper.h"
#include "smbd/service_task.h"
-#include "nsswitch/winbindd_nss.h"
#include "libnet/libnet_proto.h"
struct cmd_getpwent_state {
diff --git a/source4/winbind/wb_cmd_getpwnam.c b/source4/winbind/wb_cmd_getpwnam.c
index b1933aa2c5..653b598ac3 100644
--- a/source4/winbind/wb_cmd_getpwnam.c
+++ b/source4/winbind/wb_cmd_getpwnam.c
@@ -25,9 +25,8 @@
#include "winbind/wb_async_helpers.h"
#include "winbind/wb_helper.h"
#include "smbd/service_task.h"
-#include "nsswitch/winbindd_nss.h"
#include "libnet/libnet_proto.h"
-#include "param/proto.h"
+#include "param/param.h"
#include "libcli/security/proto.h"
struct cmd_getpwnam_state {
@@ -125,12 +124,12 @@ static void cmd_getpwnam_recv_user_info(struct composite_context *ctx)
WBSRV_SAMBA3_SET_STRING(pw->pw_name, user_info->out.account_name);
WBSRV_SAMBA3_SET_STRING(pw->pw_passwd, "*");
WBSRV_SAMBA3_SET_STRING(pw->pw_gecos, user_info->out.full_name);
- WBSRV_SAMBA3_SET_STRING(pw->pw_dir, lp_template_homedir());
+ WBSRV_SAMBA3_SET_STRING(pw->pw_dir, lp_template_homedir(global_loadparm));
all_string_sub(pw->pw_dir, "%WORKGROUP%", state->workgroup_name,
sizeof(fstring) - 1);
all_string_sub(pw->pw_dir, "%ACCOUNTNAME%", user_info->out.account_name,
sizeof(fstring) - 1);
- WBSRV_SAMBA3_SET_STRING(pw->pw_shell, lp_template_shell());
+ WBSRV_SAMBA3_SET_STRING(pw->pw_shell, lp_template_shell(global_loadparm));
state->group_sid = dom_sid_dup(state, user_info->out.primary_group_sid);
if(composite_nomem(state->group_sid, state->ctx)) return;
diff --git a/source4/winbind/wb_cmd_getpwuid.c b/source4/winbind/wb_cmd_getpwuid.c
index 1a59b5486e..339f7e896c 100644
--- a/source4/winbind/wb_cmd_getpwuid.c
+++ b/source4/winbind/wb_cmd_getpwuid.c
@@ -25,9 +25,8 @@
#include "winbind/wb_async_helpers.h"
#include "winbind/wb_helper.h"
#include "smbd/service_task.h"
-#include "nsswitch/winbindd_nss.h"
#include "libnet/libnet_proto.h"
-#include "param/proto.h"
+#include "param/param.h"
#include "libcli/security/proto.h"
#include "auth/credentials/credentials.h"
@@ -149,12 +148,12 @@ static void cmd_getpwuid_recv_user_info(struct composite_context *ctx)
WBSRV_SAMBA3_SET_STRING(pw->pw_name, user_info->out.account_name);
WBSRV_SAMBA3_SET_STRING(pw->pw_passwd, "*");
WBSRV_SAMBA3_SET_STRING(pw->pw_gecos, user_info->out.full_name);
- WBSRV_SAMBA3_SET_STRING(pw->pw_dir, lp_template_homedir());
+ WBSRV_SAMBA3_SET_STRING(pw->pw_dir, lp_template_homedir(global_loadparm));
all_string_sub(pw->pw_dir, "%WORKGROUP%", state->workgroup,
sizeof(fstring) - 1);
all_string_sub(pw->pw_dir, "%ACCOUNTNAME%", user_info->out.account_name,
sizeof(fstring) - 1);
- WBSRV_SAMBA3_SET_STRING(pw->pw_shell, lp_template_shell());
+ WBSRV_SAMBA3_SET_STRING(pw->pw_shell, lp_template_shell(global_loadparm));
pw->pw_uid = state->uid;
diff --git a/source4/winbind/wb_cmd_list_users.c b/source4/winbind/wb_cmd_list_users.c
index 9260a42207..f67f133488 100644
--- a/source4/winbind/wb_cmd_list_users.c
+++ b/source4/winbind/wb_cmd_list_users.c
@@ -25,7 +25,6 @@
#include "winbind/wb_async_helpers.h"
#include "winbind/wb_helper.h"
#include "smbd/service_task.h"
-#include "nsswitch/winbindd_nss.h"
#include "libnet/libnet_proto.h"
struct cmd_list_users_state {
@@ -144,7 +143,7 @@ static void cmd_list_users_recv_user_list(struct composite_context *ctx)
for (i = 0; i < user_list->out.count; ++i) {
DEBUG(5, ("Appending user '%s'\n", user_list->out.users[i].username));
- state->result = talloc_asprintf_append(state->result, "%s,",
+ state->result = talloc_asprintf_append_buffer(state->result, "%s,",
user_list->out.users[i].username);
}
diff --git a/source4/winbind/wb_cmd_setpwent.c b/source4/winbind/wb_cmd_setpwent.c
index ac6caee6f0..50ab2fdff6 100644
--- a/source4/winbind/wb_cmd_setpwent.c
+++ b/source4/winbind/wb_cmd_setpwent.c
@@ -25,7 +25,6 @@
#include "winbind/wb_async_helpers.h"
#include "winbind/wb_helper.h"
#include "smbd/service_task.h"
-#include "nsswitch/winbindd_nss.h"
#include "libnet/libnet_proto.h"
struct cmd_setpwent_state {
diff --git a/source4/winbind/wb_dom_info.c b/source4/winbind/wb_dom_info.c
index 5ec8f1a159..13d446897e 100644
--- a/source4/winbind/wb_dom_info.c
+++ b/source4/winbind/wb_dom_info.c
@@ -30,6 +30,7 @@
#include "librpc/gen_ndr/samr.h"
#include "lib/messaging/irpc.h"
#include "libcli/finddcs.h"
+#include "param/param.h"
struct get_dom_info_state {
struct composite_context *ctx;
@@ -67,7 +68,8 @@ struct composite_context *wb_get_dom_info_send(TALLOC_CTX *mem_ctx,
if (dom_sid == NULL) goto failed;
ctx = finddcs_send(mem_ctx, domain_name, NBT_NAME_LOGON,
- dom_sid, lp_name_resolve_order(), service->task->event_ctx,
+ dom_sid, lp_name_resolve_order(global_loadparm),
+ service->task->event_ctx,
service->task->msg_ctx);
if (ctx == NULL) goto failed;
diff --git a/source4/winbind/wb_dom_info_trusted.c b/source4/winbind/wb_dom_info_trusted.c
index 9982a16d74..23436fa67a 100644
--- a/source4/winbind/wb_dom_info_trusted.c
+++ b/source4/winbind/wb_dom_info_trusted.c
@@ -27,6 +27,7 @@
#include "smbd/service_task.h"
#include "librpc/gen_ndr/ndr_netlogon_c.h"
#include "libcli/libcli.h"
+#include "param/param.h"
struct trusted_dom_info_state {
struct composite_context *ctx;
@@ -192,7 +193,7 @@ static void trusted_dom_info_recv_dcname(struct rpc_request *req)
make_nbt_name(&name, state->info->dcs[0].name, 0x20);
ctx = resolve_name_send(&name, state->service->task->event_ctx,
- lp_name_resolve_order());
+ lp_name_resolve_order(global_loadparm));
composite_continue(state->ctx, ctx, trusted_dom_info_recv_dcaddr,
state);
diff --git a/source4/winbind/wb_init_domain.c b/source4/winbind/wb_init_domain.c
index da03f0d406..7d050d5c67 100644
--- a/source4/winbind/wb_init_domain.c
+++ b/source4/winbind/wb_init_domain.c
@@ -38,6 +38,7 @@
#include "libcli/ldap/ldap_client.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
/*
* Initialize a domain:
@@ -150,7 +151,7 @@ struct composite_context *wb_init_domain_send(TALLOC_CTX *mem_ctx,
cli_credentials_set_event_context(state->domain->libnet_ctx->cred, service->task->event_ctx);
- cli_credentials_set_conf(state->domain->libnet_ctx->cred);
+ cli_credentials_set_conf(state->domain->libnet_ctx->cred, global_loadparm);
/* Connect the machine account to the credentials */
state->ctx->status =
@@ -162,14 +163,14 @@ struct composite_context *wb_init_domain_send(TALLOC_CTX *mem_ctx,
state->domain->netlogon_pipe = NULL;
if ((!cli_credentials_is_anonymous(state->domain->libnet_ctx->cred)) &&
- ((lp_server_role() == ROLE_DOMAIN_MEMBER) ||
- (lp_server_role() == ROLE_DOMAIN_CONTROLLER)) &&
+ ((lp_server_role(global_loadparm) == ROLE_DOMAIN_MEMBER) ||
+ (lp_server_role(global_loadparm) == ROLE_DOMAIN_CONTROLLER)) &&
(dom_sid_equal(state->domain->info->sid,
state->service->primary_sid))) {
state->domain->netlogon_binding->flags |= DCERPC_SCHANNEL;
/* For debugging, it can be a real pain if all the traffic is encrypted */
- if (lp_winbind_sealed_pipes()) {
+ if (lp_winbind_sealed_pipes(global_loadparm)) {
state->domain->netlogon_binding->flags |= (DCERPC_SIGN | DCERPC_SEAL );
} else {
state->domain->netlogon_binding->flags |= (DCERPC_SIGN);
@@ -215,7 +216,7 @@ static void init_domain_recv_netlogonpipe(struct composite_context *ctx)
state->domain->lsa_binding = init_domain_binding(state, &ndr_table_lsarpc);
/* For debugging, it can be a real pain if all the traffic is encrypted */
- if (lp_winbind_sealed_pipes()) {
+ if (lp_winbind_sealed_pipes(global_loadparm)) {
state->domain->lsa_binding->flags |= (DCERPC_SIGN | DCERPC_SEAL );
} else {
state->domain->lsa_binding->flags |= (DCERPC_SIGN);
diff --git a/source4/winbind/wb_irpc.c b/source4/winbind/wb_irpc.c
index 59399a9aef..5d7f7fd7a6 100644
--- a/source4/winbind/wb_irpc.c
+++ b/source4/winbind/wb_irpc.c
@@ -54,7 +54,7 @@ static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg,
ctx->async.fn = wb_irpc_SamLogon_callback;
ctx->async.private_data = s;
- msg->defer_reply = True;
+ msg->defer_reply = true;
return NT_STATUS_OK;
}
diff --git a/source4/winbind/wb_pam_auth.c b/source4/winbind/wb_pam_auth.c
index 4874254eff..4a9be62228 100644
--- a/source4/winbind/wb_pam_auth.c
+++ b/source4/winbind/wb_pam_auth.c
@@ -29,6 +29,7 @@
#include "librpc/gen_ndr/ndr_netlogon.h"
#include "librpc/gen_ndr/ndr_netlogon_c.h"
#include "librpc/gen_ndr/winbind.h"
+#include "param/param.h"
/* Oh, there is so much to keep an eye on when authenticating a user. Oh my! */
struct pam_auth_crap_state {
@@ -171,7 +172,7 @@ static void pam_auth_crap_recv_logon(struct composite_context *ctx)
state->unix_username = talloc_asprintf(state, "%s%s%s",
state->domain_name,
- lp_winbind_separator(),
+ lp_winbind_separator(global_loadparm),
state->user_name);
if (composite_nomem(state->unix_username, state->ctx)) return;
@@ -216,11 +217,11 @@ struct composite_context *wb_cmd_pam_auth_send(TALLOC_CTX *mem_ctx,
DATA_BLOB chal, nt_resp, lm_resp, names_blob;
int flags = CLI_CRED_NTLM_AUTH;
- if (lp_client_lanman_auth()) {
+ if (lp_client_lanman_auth(global_loadparm)) {
flags |= CLI_CRED_LANMAN_AUTH;
}
- if (lp_client_ntlmv2_auth()) {
+ if (lp_client_ntlmv2_auth(global_loadparm)) {
flags |= CLI_CRED_NTLMv2_AUTH;
}
@@ -230,7 +231,7 @@ struct composite_context *wb_cmd_pam_auth_send(TALLOC_CTX *mem_ctx,
if (!credentials) {
return NULL;
}
- cli_credentials_set_conf(credentials);
+ cli_credentials_set_conf(credentials, global_loadparm);
cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
diff --git a/source4/winbind/wb_samba3_cmd.c b/source4/winbind/wb_samba3_cmd.c
index af361794ed..4c8a9f9355 100644
--- a/source4/winbind/wb_samba3_cmd.c
+++ b/source4/winbind/wb_samba3_cmd.c
@@ -21,8 +21,6 @@
*/
#include "includes.h"
-#include "nsswitch/winbind_nss_config.h"
-#include "nsswitch/winbindd_nss.h"
#include "winbind/wb_server.h"
#include "winbind/wb_async_helpers.h"
#include "winbind/wb_helper.h"
@@ -31,6 +29,7 @@
#include "librpc/gen_ndr/netlogon.h"
#include "libcli/security/security.h"
#include "auth/pam_errors.h"
+#include "param/param.h"
/*
Send off the reply to an async Samba3 query, handling filling in the PAM, NTSTATUS and string errors.
@@ -87,7 +86,7 @@ NTSTATUS wbsrv_samba3_interface_version(struct wbsrv_samba3_call *s3call)
NTSTATUS wbsrv_samba3_info(struct wbsrv_samba3_call *s3call)
{
s3call->response.result = WINBINDD_OK;
- s3call->response.data.info.winbind_separator = *lp_winbind_separator();
+ s3call->response.data.info.winbind_separator = *lp_winbind_separator(global_loadparm);
WBSRV_SAMBA3_SET_STRING(s3call->response.data.info.samba_version,
SAMBA_VERSION_STRING);
return NT_STATUS_OK;
@@ -97,7 +96,7 @@ NTSTATUS wbsrv_samba3_domain_name(struct wbsrv_samba3_call *s3call)
{
s3call->response.result = WINBINDD_OK;
WBSRV_SAMBA3_SET_STRING(s3call->response.data.domain_name,
- lp_workgroup());
+ lp_workgroup(global_loadparm));
return NT_STATUS_OK;
}
@@ -105,7 +104,7 @@ NTSTATUS wbsrv_samba3_netbios_name(struct wbsrv_samba3_call *s3call)
{
s3call->response.result = WINBINDD_OK;
WBSRV_SAMBA3_SET_STRING(s3call->response.data.netbios_name,
- lp_netbios_name());
+ lp_netbios_name(global_loadparm));
return NT_STATUS_OK;
}
@@ -113,7 +112,7 @@ 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, WINBINDD_SAMBA3_PRIVILEGED_SOCKET);
+ smbd_tmp_path(s3call, global_loadparm, WINBINDD_SAMBA3_PRIVILEGED_SOCKET);
NT_STATUS_HAVE_NO_MEMORY(s3call->response.extra_data.data);
return NT_STATUS_OK;
}
@@ -253,7 +252,7 @@ static void userdomgroups_recv_groups(struct composite_context *ctx)
}
for (i=0; i<num_sids; i++) {
- sids_string = talloc_asprintf_append(
+ sids_string = talloc_asprintf_append_buffer(
sids_string, "%s\n", dom_sid_string(s3call, sids[i]));
}
@@ -320,7 +319,7 @@ static void usersids_recv_sids(struct composite_context *ctx)
}
for (i=0; i<num_sids; i++) {
- sids_string = talloc_asprintf_append(
+ sids_string = talloc_asprintf_append_buffer(
sids_string, "%s\n", dom_sid_string(s3call, sids[i]));
if (sids_string == NULL) {
status = NT_STATUS_NO_MEMORY;
@@ -621,7 +620,7 @@ static void list_trustdom_recv_doms(struct composite_context *ctx)
}
for (i=0; i<num_domains; i++) {
- result = talloc_asprintf_append(
+ result = talloc_asprintf_append_buffer(
result, "%s\\%s\\%s",
domains[i]->name, domains[i]->name,
dom_sid_string(s3call, domains[i]->sid));
diff --git a/source4/winbind/wb_samba3_protocol.c b/source4/winbind/wb_samba3_protocol.c
index 9bf19ebf6e..b252273cb6 100644
--- a/source4/winbind/wb_samba3_protocol.c
+++ b/source4/winbind/wb_samba3_protocol.c
@@ -20,8 +20,6 @@
*/
#include "includes.h"
-#include "nsswitch/winbind_nss_config.h"
-#include "nsswitch/winbindd_nss.h"
#include "winbind/wb_server.h"
#include "smbd/service_stream.h"
#include "lib/stream/packet.h"
@@ -223,8 +221,8 @@ static NTSTATUS wbsrv_samba3_push_reply(struct wbsrv_samba3_call *call, TALLOC_C
uint8_t *extra_data;
size_t extra_data_len = 0;
- extra_data = call->response.extra_data.data;
- if (extra_data) {
+ extra_data = (uint8_t *)call->response.extra_data.data;
+ if (extra_data != NULL) {
extra_data_len = call->response.length -
sizeof(call->response);
}
diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c
index 3793275aa3..6d002902d3 100644
--- a/source4/winbind/wb_server.c
+++ b/source4/winbind/wb_server.c
@@ -31,6 +31,7 @@
#include "lib/stream/packet.h"
#include "smbd/service.h"
#include "param/secrets.h"
+#include "param/param.h"
void wbsrv_terminate_connection(struct wbsrv_connection *wbconn, const char *reason)
{
@@ -128,7 +129,7 @@ static void winbind_task_init(struct task_server *task)
}
/* Make sure the directory for the Samba3 socket exists, and is of the correct permissions */
- if (!directory_create_or_exist(lp_winbindd_socket_directory(), geteuid(), 0755)) {
+ if (!directory_create_or_exist(lp_winbindd_socket_directory(global_loadparm), geteuid(), 0755)) {
task_server_terminate(task,
"Cannot create winbindd pipe directory");
return;
@@ -139,7 +140,7 @@ static void winbind_task_init(struct task_server *task)
service->task = task;
service->primary_sid = secrets_get_domain_sid(service,
- lp_workgroup());
+ lp_workgroup(global_loadparm));
if (service->primary_sid == NULL) {
task_server_terminate(
task, nt_errstr(NT_STATUS_CANT_ACCESS_DOMAIN_INFO));
@@ -150,11 +151,11 @@ static void winbind_task_init(struct task_server *task)
listen_socket = talloc(service, struct wbsrv_listen_socket);
if (!listen_socket) goto nomem;
listen_socket->socket_path = talloc_asprintf(listen_socket, "%s/%s",
- lp_winbindd_socket_directory(),
+ lp_winbindd_socket_directory(global_loadparm),
WINBINDD_SAMBA3_SOCKET);
if (!listen_socket->socket_path) goto nomem;
listen_socket->service = service;
- listen_socket->privileged = False;
+ listen_socket->privileged = false;
status = stream_setup_socket(task->event_ctx, model_ops,
&wbsrv_ops, "unix",
listen_socket->socket_path, &port,
@@ -165,11 +166,11 @@ static void winbind_task_init(struct task_server *task)
listen_socket = talloc(service, struct wbsrv_listen_socket);
if (!listen_socket) goto nomem;
listen_socket->socket_path =
- smbd_tmp_path(listen_socket,
+ smbd_tmp_path(listen_socket, global_loadparm,
WINBINDD_SAMBA3_PRIVILEGED_SOCKET);
if (!listen_socket->socket_path) goto nomem;
listen_socket->service = service;
- listen_socket->privileged = True;
+ listen_socket->privileged = true;
status = stream_setup_socket(task->event_ctx, model_ops,
&wbsrv_ops, "unix",
listen_socket->socket_path, &port,
diff --git a/source4/winbind/wb_server.h b/source4/winbind/wb_server.h
index 7e9ee2feae..369fe025a9 100644
--- a/source4/winbind/wb_server.h
+++ b/source4/winbind/wb_server.h
@@ -20,7 +20,7 @@
*/
#include "nsswitch/winbind_nss_config.h"
-#include "nsswitch/winbindd_nss.h"
+#include "nsswitch/winbind_struct_protocol.h"
#include "libnet/libnet.h"
#define WINBINDD_SAMBA3_SOCKET "pipe"
diff --git a/source4/winbind/wb_sid2domain.c b/source4/winbind/wb_sid2domain.c
index 257a1afdc0..8336449602 100644
--- a/source4/winbind/wb_sid2domain.c
+++ b/source4/winbind/wb_sid2domain.c
@@ -26,6 +26,7 @@
#include "winbind/wb_async_helpers.h"
#include "libcli/security/security.h"
#include "lib/util/dlinklist.h"
+#include "param/param.h"
static struct wbsrv_domain *find_domain_from_sid(struct wbsrv_service *service,
const struct dom_sid *sid)
@@ -84,7 +85,7 @@ struct composite_context *wb_sid2domain_send(TALLOC_CTX *mem_ctx,
if (dom_sid_equal(service->primary_sid, sid) ||
dom_sid_in_domain(service->primary_sid, sid)) {
- ctx = wb_get_dom_info_send(state, service, lp_workgroup(),
+ ctx = wb_get_dom_info_send(state, service, lp_workgroup(global_loadparm),
service->primary_sid);
if (ctx == NULL) goto failed;
ctx->async.fn = sid2domain_recv_dom_info;
diff --git a/source4/winbind/wb_utils.c b/source4/winbind/wb_utils.c
index 5938bb391d..dfd09a98fe 100644
--- a/source4/winbind/wb_utils.c
+++ b/source4/winbind/wb_utils.c
@@ -20,19 +20,20 @@
*/
#include "includes.h"
+#include "param/param.h"
/* Split a domain\\user string into it's parts, because the client supplies it
* as one string.
* TODO: We probably will need to handle other formats later. */
-BOOL wb_samba3_split_username(TALLOC_CTX *mem_ctx, const char *domuser,
+bool wb_samba3_split_username(TALLOC_CTX *mem_ctx, const char *domuser,
char **domain, char **user)
{
- char *p = strchr(domuser, *lp_winbind_separator());
+ char *p = strchr(domuser, *lp_winbind_separator(global_loadparm));
if (p == NULL) {
- *domain = talloc_strdup(mem_ctx, lp_workgroup());
+ *domain = talloc_strdup(mem_ctx, lp_workgroup(global_loadparm));
} else {
*domain = talloc_strndup(mem_ctx, domuser,
PTR_DIFF(p, domuser));
diff --git a/source4/wrepl_server/wrepl_apply_records.c b/source4/wrepl_server/wrepl_apply_records.c
index 2779bf02a3..380b77517f 100644
--- a/source4/wrepl_server/wrepl_apply_records.c
+++ b/source4/wrepl_server/wrepl_apply_records.c
@@ -75,77 +75,77 @@ static enum _R_ACTION replace_same_owner(struct winsdb_record *r1, struct wrepl_
return R_DO_REPLACE;
}
-static BOOL r_1_is_subset_of_2_address_list(struct winsdb_record *r1, struct wrepl_name *r2, BOOL check_owners)
+static bool r_1_is_subset_of_2_address_list(struct winsdb_record *r1, struct wrepl_name *r2, bool check_owners)
{
uint32_t i,j;
size_t len = winsdb_addr_list_length(r1->addresses);
for (i=0; i < len; i++) {
- BOOL found = False;
+ bool found = false;
for (j=0; j < r2->num_addresses; j++) {
if (strcmp(r1->addresses[i]->address, r2->addresses[j].address) != 0) {
continue;
}
if (check_owners && strcmp(r1->addresses[i]->wins_owner, r2->addresses[j].owner) != 0) {
- return False;
+ return false;
}
- found = True;
+ found = true;
break;
}
- if (!found) return False;
+ if (!found) return false;
}
- return True;
+ return true;
}
-static BOOL r_1_is_superset_of_2_address_list(struct winsdb_record *r1, struct wrepl_name *r2, BOOL check_owners)
+static bool r_1_is_superset_of_2_address_list(struct winsdb_record *r1, struct wrepl_name *r2, bool check_owners)
{
uint32_t i,j;
size_t len = winsdb_addr_list_length(r1->addresses);
for (i=0; i < r2->num_addresses; i++) {
- BOOL found = False;
+ bool found = false;
for (j=0; j < len; j++) {
if (strcmp(r2->addresses[i].address, r1->addresses[j]->address) != 0) {
continue;
}
if (check_owners && strcmp(r2->addresses[i].owner, r1->addresses[j]->wins_owner) != 0) {
- return False;
+ return false;
}
- found = True;
+ found = true;
break;
}
- if (!found) return False;
+ if (!found) return false;
}
- return True;
+ return true;
}
-static BOOL r_1_is_same_as_2_address_list(struct winsdb_record *r1, struct wrepl_name *r2, BOOL check_owners)
+static bool r_1_is_same_as_2_address_list(struct winsdb_record *r1, struct wrepl_name *r2, bool check_owners)
{
size_t len = winsdb_addr_list_length(r1->addresses);
if (len != r2->num_addresses) {
- return False;
+ return false;
}
return r_1_is_superset_of_2_address_list(r1, r2, check_owners);
}
-static BOOL r_contains_addrs_from_owner(struct winsdb_record *r1, const char *owner)
+static bool r_contains_addrs_from_owner(struct winsdb_record *r1, const char *owner)
{
uint32_t i;
size_t len = winsdb_addr_list_length(r1->addresses);
for (i=0; i < len; i++) {
if (strcmp(r1->addresses[i]->wins_owner, owner) == 0) {
- return True;
+ return true;
}
}
- return False;
+ return false;
}
/*
@@ -310,12 +310,12 @@ static enum _R_ACTION replace_sgroup_replica_vs_X_replica(struct winsdb_record *
return R_NOT_REPLACE;
}
- if (r_1_is_superset_of_2_address_list(r1, r2, True)) {
+ if (r_1_is_superset_of_2_address_list(r1, r2, true)) {
/* NOT REPLACE */
return R_NOT_REPLACE;
}
- if (r_1_is_same_as_2_address_list(r1, r2, False)) {
+ if (r_1_is_same_as_2_address_list(r1, r2, false)) {
/* REPLACE */
return R_DO_REPLACE;
}
@@ -433,7 +433,7 @@ static enum _R_ACTION replace_unique_owned_vs_X_replica(struct winsdb_record *r1
* is unique,active,replica or mhomed,active,replica
*/
- if (r_1_is_subset_of_2_address_list(r1, r2, False)) {
+ if (r_1_is_subset_of_2_address_list(r1, r2, false)) {
/*
* if r1 has a subset(or same) of the addresses of r2
* <=>
@@ -559,7 +559,7 @@ static enum _R_ACTION replace_sgroup_owned_vs_X_replica(struct winsdb_record *r1
return R_DO_PROPAGATE;
}
- if (r_1_is_same_as_2_address_list(r1, r2, True)) {
+ if (r_1_is_same_as_2_address_list(r1, r2, true)) {
/*
* as we're the old owner and the addresses and their
* owners are identical
@@ -645,7 +645,7 @@ static enum _R_ACTION replace_mhomed_owned_vs_X_replica(struct winsdb_record *r1
* is unique,active,replica or mhomed,active,replica
*/
- if (r_1_is_subset_of_2_address_list(r1, r2, False)) {
+ if (r_1_is_subset_of_2_address_list(r1, r2, false)) {
/*
* if r1 has a subset(or same) of the addresses of r2
* <=>
@@ -695,7 +695,7 @@ static NTSTATUS r_do_add(struct wreplsrv_partner *partner,
replica->addresses[i].address,
replica->addresses[i].owner,
rec->expire_time,
- False);
+ false);
NT_STATUS_HAVE_NO_MEMORY(rec->addresses);
}
@@ -740,7 +740,7 @@ static NTSTATUS r_do_replace(struct wreplsrv_partner *partner,
replica->addresses[i].address,
replica->addresses[i].owner,
rec->expire_time,
- False);
+ false);
NT_STATUS_HAVE_NO_MEMORY(rec->addresses);
}
@@ -842,17 +842,17 @@ static NTSTATUS r_do_mhomed_merge(struct wreplsrv_partner *partner,
replica->addresses[i].address,
replica->addresses[i].owner,
merge->expire_time,
- False);
+ false);
NT_STATUS_HAVE_NO_MEMORY(merge->addresses);
}
len = winsdb_addr_list_length(rec->addresses);
for (i=0; i < len; i++) {
- BOOL found = False;
+ bool found = false;
for (j=0; j < replica->num_addresses; j++) {
if (strcmp(replica->addresses[j].address, rec->addresses[i]->address) == 0) {
- found = True;
+ found = true;
break;
}
}
@@ -863,7 +863,7 @@ static NTSTATUS r_do_mhomed_merge(struct wreplsrv_partner *partner,
rec->addresses[i]->address,
rec->addresses[i]->wins_owner,
rec->addresses[i]->expire_time,
- False);
+ false);
NT_STATUS_HAVE_NO_MEMORY(merge->addresses);
}
@@ -955,9 +955,9 @@ static void r_do_challenge_handler(struct irpc_request *ireq)
NTSTATUS status;
struct r_do_challenge_state *state = talloc_get_type(ireq->async.private,
struct r_do_challenge_state);
- BOOL old_is_subset = False;
- BOOL new_is_subset = False;
- BOOL found = False;
+ bool old_is_subset = false;
+ bool new_is_subset = false;
+ bool found = false;
uint32_t i,j;
uint32_t num_rec_addrs;
@@ -974,17 +974,17 @@ static void r_do_challenge_handler(struct irpc_request *ireq)
}
for (i=0; i < state->replica.num_addresses; i++) {
- found = False;
- new_is_subset = True;
+ found = false;
+ new_is_subset = true;
for (j=0; j < state->r.out.num_addrs; j++) {
if (strcmp(state->replica.addresses[i].address, state->r.out.addrs[j].addr) == 0) {
- found = True;
+ found = true;
break;
}
}
if (found) continue;
- new_is_subset = False;
+ new_is_subset = false;
break;
}
@@ -996,17 +996,17 @@ static void r_do_challenge_handler(struct irpc_request *ireq)
num_rec_addrs = winsdb_addr_list_length(state->rec->addresses);
for (i=0; i < num_rec_addrs; i++) {
- found = False;
- old_is_subset = True;
+ found = false;
+ old_is_subset = true;
for (j=0; j < state->r.out.num_addrs; j++) {
if (strcmp(state->rec->addresses[i]->address, state->r.out.addrs[j].addr) == 0) {
- found = True;
+ found = true;
break;
}
}
if (found) continue;
- old_is_subset = False;
+ old_is_subset = false;
break;
}
@@ -1189,8 +1189,8 @@ static NTSTATUS r_do_sgroup_merge(struct wreplsrv_partner *partner,
uint32_t i,j;
uint8_t ret;
size_t len;
- BOOL changed_old_addrs = False;
- BOOL become_owner = True;
+ bool changed_old_addrs = false;
+ bool become_owner = true;
merge = talloc(mem_ctx, struct winsdb_record);
NT_STATUS_HAVE_NO_MEMORY(merge);
@@ -1210,17 +1210,17 @@ static NTSTATUS r_do_sgroup_merge(struct wreplsrv_partner *partner,
len = winsdb_addr_list_length(rec->addresses);
for (i=0; i < len; i++) {
- BOOL found = False;
+ bool found = false;
for (j=0; j < replica->num_addresses; j++) {
if (strcmp(rec->addresses[i]->address, replica->addresses[j].address) != 0) {
continue;
}
- found = True;
+ found = true;
if (strcmp(rec->addresses[i]->wins_owner, replica->addresses[j].owner) != 0) {
- changed_old_addrs = True;
+ changed_old_addrs = true;
break;
}
break;
@@ -1231,7 +1231,7 @@ static NTSTATUS r_do_sgroup_merge(struct wreplsrv_partner *partner,
* it won't be added to the merged record
*/
if (!found && strcmp(rec->addresses[i]->wins_owner, owner->address) == 0) {
- changed_old_addrs = True;
+ changed_old_addrs = true;
continue;
}
@@ -1245,7 +1245,7 @@ static NTSTATUS r_do_sgroup_merge(struct wreplsrv_partner *partner,
rec->addresses[i]->address,
rec->addresses[i]->wins_owner,
rec->addresses[i]->expire_time,
- False);
+ false);
NT_STATUS_HAVE_NO_MEMORY(merge->addresses);
}
@@ -1255,18 +1255,18 @@ static NTSTATUS r_do_sgroup_merge(struct wreplsrv_partner *partner,
replica->addresses[i].address,
replica->addresses[i].owner,
merge->expire_time,
- False);
+ false);
NT_STATUS_HAVE_NO_MEMORY(merge->addresses);
}
/* we the old addresses change changed we don't become the owner */
if (changed_old_addrs) {
- become_owner = False;
+ become_owner = false;
}
/* if we're the owner of the old record, we'll be the owner of the new one too */
if (strcmp(rec->wins_owner, partner->service->wins_db->local_owner)==0) {
- become_owner = True;
+ become_owner = true;
}
/*
@@ -1274,7 +1274,7 @@ static NTSTATUS r_do_sgroup_merge(struct wreplsrv_partner *partner,
*/
len = winsdb_addr_list_length(merge->addresses);
if (len == 0) {
- become_owner = True;
+ become_owner = true;
}
/*
@@ -1306,9 +1306,9 @@ static NTSTATUS wreplsrv_apply_one_record(struct wreplsrv_partner *partner,
NTSTATUS status;
struct winsdb_record *rec = NULL;
enum _R_ACTION action = R_INVALID;
- BOOL same_owner = False;
- BOOL replica_vs_replica = False;
- BOOL local_vs_replica = False;
+ bool same_owner = false;
+ bool replica_vs_replica = false;
+ bool local_vs_replica = false;
status = winsdb_lookup(partner->service->wins_db,
&replica->name, mem_ctx, &rec);
@@ -1318,11 +1318,11 @@ static NTSTATUS wreplsrv_apply_one_record(struct wreplsrv_partner *partner,
NT_STATUS_NOT_OK_RETURN(status);
if (strcmp(rec->wins_owner, partner->service->wins_db->local_owner)==0) {
- local_vs_replica = True;
+ local_vs_replica = true;
} else if (strcmp(rec->wins_owner, owner->address)==0) {
- same_owner = True;
+ same_owner = true;
} else {
- replica_vs_replica = True;
+ replica_vs_replica = true;
}
if (rec->is_static && !same_owner) {
diff --git a/source4/wrepl_server/wrepl_in_call.c b/source4/wrepl_server/wrepl_in_call.c
index 75ac4a6e31..0508c306e0 100644
--- a/source4/wrepl_server/wrepl_in_call.c
+++ b/source4/wrepl_server/wrepl_in_call.c
@@ -61,7 +61,7 @@ static NTSTATUS wreplsrv_in_start_association(struct wreplsrv_in_call *call)
}
#endif
- call->wreplconn->assoc_ctx.stopped = False;
+ call->wreplconn->assoc_ctx.stopped = false;
call->wreplconn->assoc_ctx.our_ctx = WREPLSRV_VALID_ASSOC_CTX;
call->wreplconn->assoc_ctx.peer_ctx = start->assoc_ctx;
@@ -90,7 +90,7 @@ static NTSTATUS wreplsrv_in_stop_assoc_ctx(struct wreplsrv_in_call *call)
{
struct wrepl_stop *stop_out = &call->rep_packet.message.stop;
- call->wreplconn->assoc_ctx.stopped = True;
+ call->wreplconn->assoc_ctx.stopped = true;
call->rep_packet.mess_type = WREPL_STOP_ASSOCIATION;
stop_out->reason = 4;
@@ -120,7 +120,7 @@ static NTSTATUS wreplsrv_in_stop_association(struct wreplsrv_in_call *call)
}
/* this will cause to not receive packets anymore and terminate the connection if the reply is send */
- call->terminate_after_send = True;
+ call->terminate_after_send = true;
return wreplsrv_in_stop_assoc_ctx(call);
}
@@ -133,7 +133,7 @@ static NTSTATUS wreplsrv_in_table_query(struct wreplsrv_in_call *call)
repl_out->command = WREPL_REPL_TABLE_REPLY;
return wreplsrv_fill_wrepl_table(service, call, table_out,
- service->wins_db->local_owner, True);
+ service->wins_db->local_owner, true);
}
static int wreplsrv_in_sort_wins_name(struct wrepl_wins_name *n1,
diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c
index 9b0f5522e5..1178eb766e 100644
--- a/source4/wrepl_server/wrepl_in_connection.c
+++ b/source4/wrepl_server/wrepl_in_connection.c
@@ -31,6 +31,7 @@
#include "smbd/process_model.h"
#include "system/network.h"
#include "lib/socket/netif.h"
+#include "param/param.h"
void wreplsrv_terminate_in_connection(struct wreplsrv_in_connection *wreplconn, const char *reason)
{
@@ -269,7 +270,7 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service)
return NT_STATUS_INTERNAL_ERROR;
}
- if (lp_interfaces() && lp_bind_interfaces_only()) {
+ if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) {
int num_interfaces = iface_count();
int i;
@@ -288,7 +289,7 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service)
}
}
} else {
- address = lp_socket_address();
+ address = lp_socket_address(global_loadparm);
status = stream_setup_socket(task->event_ctx, model_ops, &wreplsrv_stream_ops,
"ipv4", address, &port, service);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/wrepl_server/wrepl_out_helpers.c b/source4/wrepl_server/wrepl_out_helpers.c
index 9675c5abd0..2599ef4d09 100644
--- a/source4/wrepl_server/wrepl_out_helpers.c
+++ b/source4/wrepl_server/wrepl_out_helpers.c
@@ -138,7 +138,7 @@ static struct composite_context *wreplsrv_out_connect_send(struct wreplsrv_partn
struct wreplsrv_service *service = partner->service;
struct wreplsrv_out_connect_state *state = NULL;
struct wreplsrv_out_connection **wreplconnp = &wreplconn;
- BOOL cached_connection = False;
+ bool cached_connection = false;
c = talloc_zero(partner, struct composite_context);
if (!c) goto failed;
@@ -153,11 +153,11 @@ static struct composite_context *wreplsrv_out_connect_send(struct wreplsrv_partn
c->private_data = state;
if (type == WINSREPL_PARTNER_PUSH) {
- cached_connection = True;
+ cached_connection = true;
wreplconn = partner->push.wreplconn;
wreplconnp = &partner->push.wreplconn;
} else if (type == WINSREPL_PARTNER_PULL) {
- cached_connection = True;
+ cached_connection = true;
wreplconn = partner->pull.wreplconn;
wreplconnp = &partner->pull.wreplconn;
}
@@ -572,7 +572,7 @@ static NTSTATUS wreplsrv_pull_cycle_next_owner_do_work(struct wreplsrv_pull_cycl
struct wreplsrv_owner *local_owner;
uint32_t i;
uint64_t old_max_version = 0;
- BOOL do_pull = False;
+ bool do_pull = false;
for (i=state->current; i < state->table_io.out.num_owners; i++) {
current_owner = wreplsrv_find_owner(state->io->in.partner->service,
@@ -593,7 +593,7 @@ static NTSTATUS wreplsrv_pull_cycle_next_owner_do_work(struct wreplsrv_pull_cycl
* so fetch them
*/
if (!local_owner) {
- do_pull = True;
+ do_pull = true;
break;
}
@@ -603,7 +603,7 @@ static NTSTATUS wreplsrv_pull_cycle_next_owner_do_work(struct wreplsrv_pull_cycl
* fetch them
*/
if (current_owner->owner.max_version > local_owner->owner.max_version) {
- do_pull = True;
+ do_pull = true;
old_max_version = local_owner->owner.max_version;
break;
}
@@ -829,7 +829,7 @@ struct wreplsrv_push_notify_state {
struct composite_context *c;
struct wreplsrv_push_notify_io *io;
enum wrepl_replication_cmd command;
- BOOL full_table;
+ bool full_table;
struct wrepl_send_ctrl ctrl;
struct wrepl_request *req;
struct wrepl_packet req_packet;
@@ -946,7 +946,7 @@ static NTSTATUS wreplsrv_push_notify_inform(struct wreplsrv_push_notify_state *s
NT_STATUS_NOT_OK_RETURN(status);
/* we won't get a reply to a inform message */
- state->ctrl.send_only = True;
+ state->ctrl.send_only = true;
state->req = wrepl_request_send(state->wreplconn->sock, req, &state->ctrl);
NT_STATUS_HAVE_NO_MEMORY(state->req);
@@ -968,16 +968,16 @@ static NTSTATUS wreplsrv_push_notify_wait_connect(struct wreplsrv_push_notify_st
switch (state->command) {
case WREPL_REPL_UPDATE:
- state->full_table = True;
+ state->full_table = true;
return wreplsrv_push_notify_update(state);
case WREPL_REPL_UPDATE2:
- state->full_table = False;
+ state->full_table = false;
return wreplsrv_push_notify_update(state);
case WREPL_REPL_INFORM:
- state->full_table = True;
+ state->full_table = true;
return wreplsrv_push_notify_inform(state);
case WREPL_REPL_INFORM2:
- state->full_table = False;
+ state->full_table = false;
return wreplsrv_push_notify_inform(state);
default:
return NT_STATUS_INTERNAL_ERROR;
diff --git a/source4/wrepl_server/wrepl_out_push.c b/source4/wrepl_server/wrepl_out_push.c
index 897b515f77..8f0c409662 100644
--- a/source4/wrepl_server/wrepl_out_push.c
+++ b/source4/wrepl_server/wrepl_out_push.c
@@ -25,7 +25,7 @@
#include "libcli/composite/composite.h"
#include "nbt_server/wins/winsdb.h"
-static void wreplsrv_out_partner_push(struct wreplsrv_partner *partner, BOOL propagate);
+static void wreplsrv_out_partner_push(struct wreplsrv_partner *partner, bool propagate);
static void wreplsrv_push_handler_creq(struct composite_context *creq)
{
@@ -62,7 +62,7 @@ done:
talloc_free(old_notify_io);
}
-static void wreplsrv_out_partner_push(struct wreplsrv_partner *partner, BOOL propagate)
+static void wreplsrv_out_partner_push(struct wreplsrv_partner *partner, bool propagate)
{
/* a push for this partner is currently in progress, so we're done */
if (partner->push.creq) return;
@@ -137,7 +137,7 @@ NTSTATUS wreplsrv_out_push_run(struct wreplsrv_service *service)
/* if the configured change count isn't reached, go to the next partner */
if (change_count < partner->push.change_count) continue;
- wreplsrv_out_partner_push(partner, False);
+ wreplsrv_out_partner_push(partner, false);
}
return NT_STATUS_OK;
diff --git a/source4/wrepl_server/wrepl_scavenging.c b/source4/wrepl_server/wrepl_scavenging.c
index 9b4ae18fe7..a5cd36797d 100644
--- a/source4/wrepl_server/wrepl_scavenging.c
+++ b/source4/wrepl_server/wrepl_scavenging.c
@@ -59,9 +59,9 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi
const char *old_state=NULL;
const char *new_state=NULL;
uint32_t modify_flags;
- BOOL modify_record;
- BOOL delete_record;
- BOOL delete_tombstones;
+ bool modify_record;
+ bool delete_record;
+ bool delete_tombstones;
struct timeval tombstone_extra_time;
now_timestr = ldb_timestring(tmp_mem, now);
@@ -94,8 +94,8 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi
talloc_free(res->msgs[i]);
modify_flags = 0;
- modify_record = False;
- delete_record = False;
+ modify_record = false;
+ delete_record = false;
switch (rec->state) {
case WREPL_STATE_ACTIVE:
@@ -107,7 +107,7 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi
rec->expire_time= service->config.tombstone_interval + now;
}
modify_flags = 0;
- modify_record = True;
+ modify_record = true;
break;
case WREPL_STATE_RELEASED:
@@ -116,7 +116,7 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi
rec->state = WREPL_STATE_TOMBSTONE;
rec->expire_time= service->config.tombstone_timeout + now;
modify_flags = WINSDB_FLAG_ALLOC_VERSION | WINSDB_FLAG_TAKE_OWNERSHIP;
- modify_record = True;
+ modify_record = true;
break;
case WREPL_STATE_TOMBSTONE:
@@ -124,7 +124,7 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi
new_state = "tombstone";
if (!delete_tombstones) break;
new_state = "deleted";
- delete_record = True;
+ delete_record = true;
break;
case WREPL_STATE_RESERVED:
@@ -173,9 +173,9 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s
const char *old_state=NULL;
const char *new_state=NULL;
uint32_t modify_flags;
- BOOL modify_record;
- BOOL delete_record;
- BOOL delete_tombstones;
+ bool modify_record;
+ bool delete_record;
+ bool delete_tombstones;
struct timeval tombstone_extra_time;
now_timestr = ldb_timestring(tmp_mem, now);
@@ -208,8 +208,8 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s
talloc_free(res->msgs[i]);
modify_flags = 0;
- modify_record = False;
- delete_record = False;
+ modify_record = false;
+ delete_record = false;
switch (rec->state) {
case WREPL_STATE_ACTIVE:
@@ -223,7 +223,7 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s
rec->state = WREPL_STATE_TOMBSTONE;
rec->expire_time= service->config.tombstone_timeout + now;
modify_flags = 0;
- modify_record = True;
+ modify_record = true;
break;
case WREPL_STATE_TOMBSTONE:
@@ -231,7 +231,7 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s
new_state = "tombstone";
if (!delete_tombstones) break;
new_state = "deleted";
- delete_record = True;
+ delete_record = true;
break;
case WREPL_STATE_RESERVED:
@@ -282,9 +282,9 @@ static void verify_handler(struct irpc_request *ireq)
const char *new_state = "active";
const char *new_owner = "replica";
uint32_t modify_flags = 0;
- BOOL modify_record = False;
- BOOL delete_record = False;
- BOOL different = False;
+ bool modify_record = false;
+ bool delete_record = false;
+ bool different = false;
int ret;
NTSTATUS status;
uint32_t i, j;
@@ -298,25 +298,25 @@ static void verify_handler(struct irpc_request *ireq)
*/
status = irpc_call_recv(ireq);
if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
- delete_record = True;
+ delete_record = true;
new_state = "deleted";
} else if (NT_STATUS_IS_OK(status) && rec->type != WREPL_TYPE_GROUP) {
for (i=0; i < s->r.out.num_addrs; i++) {
- BOOL found = False;
+ bool found = false;
for (j=0; rec->addresses[j]; j++) {
if (strcmp(s->r.out.addrs[i].addr, rec->addresses[j]->address) == 0) {
- found = True;
+ found = true;
break;
}
}
if (!found) {
- different = True;
+ different = true;
break;
}
}
} else if (NT_STATUS_IS_OK(status) && rec->type == WREPL_TYPE_GROUP) {
if (s->r.out.num_addrs != 1 || strcmp(s->r.out.addrs[0].addr, "255.255.255.255") != 0) {
- different = True;
+ different = true;
}
}
@@ -336,7 +336,7 @@ static void verify_handler(struct irpc_request *ireq)
for (i=0; rec->addresses[i]; i++) {
rec->addresses[i]->expire_time = rec->expire_time;
}
- modify_record = True;
+ modify_record = true;
modify_flags = WINSDB_FLAG_ALLOC_VERSION | WINSDB_FLAG_TAKE_OWNERSHIP;
new_state = "tombstone";
new_owner = "owned";
@@ -346,7 +346,7 @@ static void verify_handler(struct irpc_request *ireq)
for (i=0; rec->addresses[i]; i++) {
rec->addresses[i]->expire_time = rec->expire_time;
}
- modify_record = True;
+ modify_record = true;
modify_flags = 0;
new_state = "active";
}
@@ -468,14 +468,14 @@ NTSTATUS wreplsrv_scavenging_run(struct wreplsrv_service *service)
{
NTSTATUS status;
TALLOC_CTX *tmp_mem;
- BOOL skip_first_run = False;
+ bool skip_first_run = false;
if (!timeval_expired(&service->scavenging.next_run)) {
return NT_STATUS_OK;
}
if (timeval_is_zero(&service->scavenging.next_run)) {
- skip_first_run = True;
+ skip_first_run = true;
}
service->scavenging.next_run = timeval_current_ofs(service->config.scavenging_interval, 0);
@@ -498,25 +498,25 @@ NTSTATUS wreplsrv_scavenging_run(struct wreplsrv_service *service)
tmp_mem = talloc_new(service);
NT_STATUS_HAVE_NO_MEMORY(tmp_mem);
- service->scavenging.processing = True;
+ service->scavenging.processing = true;
status = wreplsrv_scavenging_owned_records(service,tmp_mem);
- service->scavenging.processing = False;
+ service->scavenging.processing = false;
talloc_free(tmp_mem);
NT_STATUS_NOT_OK_RETURN(status);
tmp_mem = talloc_new(service);
NT_STATUS_HAVE_NO_MEMORY(tmp_mem);
- service->scavenging.processing = True;
+ service->scavenging.processing = true;
status = wreplsrv_scavenging_replica_non_active_records(service, tmp_mem);
- service->scavenging.processing = False;
+ service->scavenging.processing = false;
talloc_free(tmp_mem);
NT_STATUS_NOT_OK_RETURN(status);
tmp_mem = talloc_new(service);
NT_STATUS_HAVE_NO_MEMORY(tmp_mem);
- service->scavenging.processing = True;
+ service->scavenging.processing = true;
status = wreplsrv_scavenging_replica_active_records(service, tmp_mem);
- service->scavenging.processing = False;
+ service->scavenging.processing = false;
talloc_free(tmp_mem);
NT_STATUS_NOT_OK_RETURN(status);
diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c
index dfbc97a6b7..be606b2a0c 100644
--- a/source4/wrepl_server/wrepl_server.c
+++ b/source4/wrepl_server/wrepl_server.c
@@ -31,10 +31,13 @@
#include "ldb/include/ldb_errors.h"
#include "auth/auth.h"
#include "db_wrap.h"
+#include "param/param.h"
static struct ldb_context *wins_config_db_connect(TALLOC_CTX *mem_ctx)
{
- return ldb_wrap_connect(mem_ctx, private_path(mem_ctx, lp_wins_config_url()),
+ return ldb_wrap_connect(mem_ctx, global_loadparm, private_path(mem_ctx,
+ global_loadparm,
+ lp_wins_config_url(global_loadparm)),
system_session(mem_ctx), NULL, 0, NULL);
}
@@ -81,26 +84,26 @@ static NTSTATUS wreplsrv_open_winsdb(struct wreplsrv_service *service)
}
/* the default renew interval is 6 days */
- service->config.renew_interval = lp_parm_int(-1,"wreplsrv","renew_interval", 6*24*60*60);
+ service->config.renew_interval = lp_parm_int(global_loadparm, NULL,"wreplsrv","renew_interval", 6*24*60*60);
/* the default tombstone (extinction) interval is 6 days */
- service->config.tombstone_interval= lp_parm_int(-1,"wreplsrv","tombstone_interval", 6*24*60*60);
+ service->config.tombstone_interval= lp_parm_int(global_loadparm, NULL,"wreplsrv","tombstone_interval", 6*24*60*60);
/* the default tombstone (extinction) timeout is 1 day */
- service->config.tombstone_timeout = lp_parm_int(-1,"wreplsrv","tombstone_timeout", 1*24*60*60);
+ service->config.tombstone_timeout = lp_parm_int(global_loadparm, NULL,"wreplsrv","tombstone_timeout", 1*24*60*60);
/* the default tombstone extra timeout is 3 days */
- service->config.tombstone_extra_timeout = lp_parm_int(-1,"wreplsrv","tombstone_extra_timeout", 3*24*60*60);
+ service->config.tombstone_extra_timeout = lp_parm_int(global_loadparm, NULL,"wreplsrv","tombstone_extra_timeout", 3*24*60*60);
/* the default verify interval is 24 days */
- service->config.verify_interval = lp_parm_int(-1,"wreplsrv","verify_interval", 24*24*60*60);
+ service->config.verify_interval = lp_parm_int(global_loadparm, NULL,"wreplsrv","verify_interval", 24*24*60*60);
/* the default scavenging interval is 'renew_interval/2' */
- service->config.scavenging_interval=lp_parm_int(-1,"wreplsrv","scavenging_interval",
+ service->config.scavenging_interval=lp_parm_int(global_loadparm, NULL,"wreplsrv","scavenging_interval",
service->config.renew_interval/2);
/* the maximun interval to the next periodic processing event */
- service->config.periodic_interval = lp_parm_int(-1,"wreplsrv","periodic_interval", 15);
+ service->config.periodic_interval = lp_parm_int(global_loadparm, NULL,"wreplsrv","periodic_interval", 15);
return NT_STATUS_OK;
}
@@ -195,7 +198,7 @@ NTSTATUS wreplsrv_load_partners(struct wreplsrv_service *service)
WINSREPL_DEFAULT_PULL_RETRY_INTERVAL);
partner->push.change_count = ldb_msg_find_attr_as_uint(res->msgs[i], "pushChangeCount",
WINSREPL_DEFAULT_PUSH_CHANGE_COUNT);
- partner->push.use_inform = ldb_msg_find_attr_as_uint(res->msgs[i], "pushUseInform", False);
+ partner->push.use_inform = ldb_msg_find_attr_as_uint(res->msgs[i], "pushUseInform", false);
DEBUG(3,("wreplsrv_load_partners: found partner: %s type: 0x%X\n",
partner->address, partner->type));
@@ -215,7 +218,7 @@ NTSTATUS wreplsrv_fill_wrepl_table(struct wreplsrv_service *service,
TALLOC_CTX *mem_ctx,
struct wrepl_table *table_out,
const char *initiator,
- BOOL full_table)
+ bool full_table)
{
struct wreplsrv_owner *cur;
uint32_t i = 0;
@@ -493,7 +496,7 @@ static void wreplsrv_task_init(struct task_server *task)
*/
static NTSTATUS wreplsrv_init(struct event_context *event_ctx, const struct model_ops *model_ops)
{
- if (!lp_wins_support()) {
+ if (!lp_wins_support(global_loadparm)) {
return NT_STATUS_OK;
}