summaryrefslogtreecommitdiffstats
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-06-24 16:26:23 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-06-24 16:26:23 +1000
commit6da26870e0ae5acd6ff49a30ec2f6886b44d095e (patch)
tree850c71039563c16a5d563c47e7ba2ab645baf198 /source3
parent6925a799d04c6fa59dd2ddef1f5510f9bb7d17d1 (diff)
parent2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 (diff)
downloadsamba-4.0.0alpha16.tar.gz
samba-4.0.0alpha16.tar.xz
samba-4.0.0alpha16.zip
Merge 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 as Samba-4.0alpha16samba-4.0.0alpha16
Diffstat (limited to 'source3')
-rw-r--r--source3/.clang_complete24
-rw-r--r--source3/Makefile-smbtorture42
-rw-r--r--source3/Makefile.in207
-rw-r--r--source3/auth/auth_builtin.c6
-rw-r--r--source3/auth/auth_domain.c13
-rw-r--r--source3/auth/auth_netlogond.c10
-rw-r--r--source3/auth/auth_ntlmssp.c4
-rw-r--r--source3/auth/auth_sam.c5
-rw-r--r--source3/auth/auth_samba4.c118
-rw-r--r--source3/auth/auth_script.c22
-rw-r--r--source3/auth/auth_server.c41
-rw-r--r--source3/auth/auth_unix.c3
-rw-r--r--source3/auth/auth_util.c19
-rw-r--r--source3/auth/auth_wbc.c2
-rw-r--r--source3/auth/auth_winbind.c2
-rw-r--r--source3/auth/check_samsec.c2
-rw-r--r--source3/auth/pass_check.c16
-rw-r--r--source3/auth/proto.h36
-rw-r--r--source3/auth/server_info.c2
-rw-r--r--source3/auth/server_info_sam.c6
-rw-r--r--source3/auth/token_util.c11
-rw-r--r--source3/auth/wscript_build25
-rw-r--r--source3/build/charset.py10
-rw-r--r--source3/build/wscript2
-rw-r--r--source3/client/client.c121
-rw-r--r--source3/client/client_proto.h2
-rw-r--r--source3/client/clitar.c114
-rw-r--r--source3/client/dnsbrowse.c2
-rw-r--r--source3/client/smbspool.c18
-rw-r--r--source3/configure.in140
-rw-r--r--source3/dynconfig.c86
-rw-r--r--source3/groupdb/mapping.c7
-rw-r--r--source3/groupdb/mapping_tdb.c23
-rw-r--r--source3/groupdb/proto.h27
-rw-r--r--source3/include/ads.h1
-rw-r--r--source3/include/async_smb.h4
-rw-r--r--source3/include/autoconf/README5
-rw-r--r--source3/include/client.h21
-rw-r--r--source3/include/ctdb_packet.h (renamed from source3/include/packet.h)36
-rw-r--r--source3/include/ctdbd_conn.h2
-rw-r--r--source3/include/dbwrap.h2
-rw-r--r--source3/include/dynconfig.h100
-rw-r--r--source3/include/includes.h66
-rw-r--r--source3/include/interfaces.h49
-rw-r--r--source3/include/krb5_env.h24
-rw-r--r--source3/include/krb5_protos.h33
-rw-r--r--source3/include/libsmb_internal.h2
-rw-r--r--source3/include/mangle.h19
-rw-r--r--source3/include/messages.h7
-rw-r--r--source3/include/nss_info.h7
-rw-r--r--source3/include/nt_printing.h6
-rw-r--r--source3/include/ntdomain.h47
-rw-r--r--source3/include/ntioctl.h12
-rw-r--r--source3/include/popt_common.h2
-rw-r--r--source3/include/printing.h5
-rw-r--r--source3/include/proto.h1253
-rw-r--r--source3/include/pthreadpool.h42
-rw-r--r--source3/include/smb.h73
-rw-r--r--source3/include/smb_krb5.h30
-rw-r--r--source3/include/smb_ldap.h39
-rw-r--r--source3/include/smb_macros.h40
-rw-r--r--source3/include/trans2.h429
-rw-r--r--source3/include/util_tdb.h10
-rw-r--r--source3/include/vfs.h8
-rw-r--r--source3/include/vfs_macros.h11
-rw-r--r--source3/intl/lang_tdb.c5
-rw-r--r--source3/intl/lang_tdb.h23
-rw-r--r--source3/lib/access.c33
-rw-r--r--source3/lib/addrchange.c1
-rw-r--r--source3/lib/adt_tree.c4
-rw-r--r--source3/lib/bitmap.c4
-rw-r--r--source3/lib/charcnv.c257
-rw-r--r--source3/lib/ctdb_packet.c (renamed from source3/lib/packet.c)53
-rw-r--r--source3/lib/ctdbd_conn.c70
-rw-r--r--source3/lib/dbwrap.c61
-rw-r--r--source3/lib/dbwrap_ctdb.c23
-rw-r--r--source3/lib/dbwrap_file.c10
-rw-r--r--source3/lib/dbwrap_rbt.c2
-rw-r--r--source3/lib/dbwrap_tdb.c13
-rw-r--r--source3/lib/dbwrap_util.c70
-rw-r--r--source3/lib/dprintf.c128
-rw-r--r--source3/lib/dummyparam.c (renamed from source3/lib/dummyroot.c)17
-rw-r--r--source3/lib/errmap_unix.c113
-rw-r--r--source3/lib/eventlog/eventlog.c13
-rw-r--r--source3/lib/eventlog/eventlog.h2
-rw-r--r--source3/lib/eventlog/proto.h27
-rw-r--r--source3/lib/events.c23
-rw-r--r--source3/lib/filename_util.c7
-rw-r--r--source3/lib/fncall.c7
-rw-r--r--source3/lib/g_lock.c13
-rw-r--r--source3/lib/gencache.c72
-rw-r--r--source3/lib/idmap_cache.h25
-rw-r--r--source3/lib/interface.c4
-rw-r--r--source3/lib/interfaces.c299
-rw-r--r--source3/lib/memcache.c2
-rw-r--r--source3/lib/messages.c8
-rw-r--r--source3/lib/messages_ctdbd.c5
-rw-r--r--source3/lib/messages_local.c15
-rw-r--r--source3/lib/module.c8
-rw-r--r--source3/lib/ms_fnmatch.c9
-rw-r--r--source3/lib/namearray.c39
-rw-r--r--source3/lib/netapi/cm.c5
-rw-r--r--source3/lib/netapi/group.c8
-rw-r--r--source3/lib/netapi/libnetapi.h19
-rw-r--r--source3/lib/netapi/localgroup.c6
-rw-r--r--source3/lib/netapi/netapi.c51
-rw-r--r--source3/lib/netapi/netapi.h9
-rw-r--r--source3/lib/netapi/netapi_private.h2
-rw-r--r--source3/lib/netapi/samr.c2
-rw-r--r--source3/lib/netapi/serverinfo.c26
-rw-r--r--source3/lib/netapi/share.c4
-rw-r--r--source3/lib/netapi/user.c14
-rw-r--r--source3/lib/popt_common.c8
-rw-r--r--source3/lib/privileges.h27
-rw-r--r--source3/lib/pthreadpool/Makefile9
-rw-r--r--source3/lib/pthreadpool/pthreadpool.c (renamed from source3/lib/pthreadpool.c)296
-rw-r--r--source3/lib/pthreadpool/pthreadpool.h97
-rw-r--r--source3/lib/pthreadpool/tests.c362
-rw-r--r--source3/lib/pthreadpool/wscript_build11
-rw-r--r--source3/lib/secdesc.c712
-rw-r--r--source3/lib/server_mutex.c4
-rw-r--r--source3/lib/serverid.c7
-rw-r--r--source3/lib/sessionid_tdb.c1
-rw-r--r--source3/lib/sharesec.c3
-rw-r--r--source3/lib/smbconf/smbconf_init.c20
-rw-r--r--source3/lib/smbconf/smbconf_init.h2
-rw-r--r--source3/lib/smbconf/smbconf_reg.c405
-rw-r--r--source3/lib/smbconf/smbconf_reg.h2
-rw-r--r--source3/lib/smbconf/testsuite.c70
-rw-r--r--source3/lib/smbd_shim.c (renamed from source3/lib/dummysmbd.c)54
-rw-r--r--source3/lib/smbd_shim.h56
-rw-r--r--source3/lib/smbldap.c18
-rw-r--r--source3/lib/string_init.c77
-rw-r--r--source3/lib/substitute.c139
-rw-r--r--source3/lib/substitute_generic.c116
-rw-r--r--source3/lib/system.c181
-rw-r--r--source3/lib/talloc_dict.c1
-rw-r--r--source3/lib/tallocmsg.c2
-rw-r--r--source3/lib/tdb_validate.c17
-rw-r--r--source3/lib/tdb_validate.h2
-rw-r--r--source3/lib/tldap.c18
-rw-r--r--source3/lib/tldap_util.c4
-rw-r--r--source3/lib/util.c652
-rw-r--r--source3/lib/util_builtin.c1
-rw-r--r--source3/lib/util_cmdline.c4
-rw-r--r--source3/lib/util_malloc.c171
-rw-r--r--source3/lib/util_names.c133
-rw-r--r--source3/lib/util_nttoken.c4
-rw-r--r--source3/lib/util_sid.c2
-rw-r--r--source3/lib/util_sock.c397
-rw-r--r--source3/lib/util_str.c764
-rw-r--r--source3/lib/util_tdb.c296
-rw-r--r--source3/lib/util_tsock.c2
-rw-r--r--source3/lib/winbind_util.c12
-rw-r--r--source3/lib/wins_srv.c42
-rw-r--r--source3/libads/ads_ldap_protos.h28
-rw-r--r--source3/libads/ads_proto.h36
-rw-r--r--source3/libads/ads_status.c1
-rw-r--r--source3/libads/ads_status.h26
-rw-r--r--source3/libads/authdata.c2
-rw-r--r--source3/libads/cldap.c14
-rw-r--r--source3/libads/cldap.h31
-rw-r--r--source3/libads/dns.c25
-rw-r--r--source3/libads/dns.h37
-rw-r--r--source3/libads/kerberos.c45
-rw-r--r--source3/libads/kerberos_keytab.c14
-rw-r--r--source3/libads/kerberos_proto.h36
-rw-r--r--source3/libads/kerberos_util.c6
-rw-r--r--source3/libads/kerberos_verify.c6
-rw-r--r--source3/libads/ldap.c145
-rw-r--r--source3/libads/ldap_printer.c6
-rw-r--r--source3/libads/ldap_schema.c6
-rw-r--r--source3/libads/ldap_schema.h25
-rw-r--r--source3/libads/ldap_utils.c2
-rw-r--r--source3/libads/ndr.c2
-rw-r--r--source3/libads/sasl.c6
-rw-r--r--source3/libgpo/gpext/registry.c6
-rw-r--r--source3/libgpo/gpext/scripts.c6
-rw-r--r--source3/libgpo/gpext/security.c2
-rw-r--r--source3/libgpo/gpext/wscript_build1
-rw-r--r--source3/libgpo/gpo_filesync.c9
-rw-r--r--source3/libgpo/gpo_proto.h24
-rw-r--r--source3/libgpo/gpo_reg.c10
-rw-r--r--source3/libnet/libnet_dssync.c8
-rw-r--r--source3/libnet/libnet_dssync_keytab.c6
-rw-r--r--source3/libnet/libnet_dssync_passdb.c16
-rw-r--r--source3/libnet/libnet_join.c90
-rw-r--r--source3/libnet/libnet_join.h25
-rw-r--r--source3/libnet/libnet_keytab.c2
-rw-r--r--source3/libnet/libnet_samsync.c7
-rw-r--r--source3/libnet/libnet_samsync_ldif.c37
-rw-r--r--source3/libnet/libnet_samsync_passdb.c12
-rw-r--r--source3/librpc/crypto/cli_spnego.c2
-rw-r--r--source3/librpc/crypto/gse.c135
-rw-r--r--source3/librpc/crypto/gse.h3
-rw-r--r--source3/librpc/crypto/gse_krb5.c2
-rw-r--r--source3/librpc/idl/messaging.idl1
-rw-r--r--source3/librpc/idl/notify.idl84
-rw-r--r--source3/librpc/idl/server_id.idl25
-rw-r--r--source3/librpc/idl/wscript_build4
-rw-r--r--source3/librpc/ndr/util.h4
-rw-r--r--source3/librpc/rpc/dcerpc.h23
-rw-r--r--source3/librpc/rpc/dcerpc_ep.c7
-rw-r--r--source3/librpc/rpc/dcerpc_helpers.c1
-rw-r--r--source3/librpc/rpc/rpc_common.c2
-rw-r--r--source3/librpc/wscript_build10
-rw-r--r--source3/libsmb/async_smb.c158
-rw-r--r--source3/libsmb/cli_np_tstream.c75
-rw-r--r--source3/libsmb/cliconnect.c1690
-rw-r--r--source3/libsmb/clidfs.c52
-rw-r--r--source3/libsmb/clidgram.c12
-rw-r--r--source3/libsmb/clidgram.h26
-rw-r--r--source3/libsmb/clientgen.c377
-rw-r--r--source3/libsmb/clierror.c39
-rw-r--r--source3/libsmb/clifile.c504
-rw-r--r--source3/libsmb/clifsinfo.c15
-rw-r--r--source3/libsmb/clikrb5.c130
-rw-r--r--source3/libsmb/clilist.c25
-rw-r--r--source3/libsmb/climessage.c2
-rw-r--r--source3/libsmb/clioplock.c5
-rw-r--r--source3/libsmb/cliprint.c13
-rw-r--r--source3/libsmb/cliquota.c15
-rw-r--r--source3/libsmb/clirap.c20
-rw-r--r--source3/libsmb/clirap.h2
-rw-r--r--source3/libsmb/clirap2.c1
-rw-r--r--source3/libsmb/clireadwrite.c263
-rw-r--r--source3/libsmb/clisecdesc.c2
-rw-r--r--source3/libsmb/clisigning.c1
-rw-r--r--source3/libsmb/clistr.c6
-rw-r--r--source3/libsmb/clitrans.c234
-rw-r--r--source3/libsmb/dsgetdcname.c24
-rw-r--r--source3/libsmb/errormap.c1213
-rw-r--r--source3/libsmb/errormap_wbc.h26
-rw-r--r--source3/libsmb/libsmb.h (renamed from source3/librpc/ndr/util.c)28
-rw-r--r--source3/libsmb/libsmb_cache.c1
-rw-r--r--source3/libsmb/libsmb_context.c13
-rw-r--r--source3/libsmb/libsmb_dir.c42
-rw-r--r--source3/libsmb/libsmb_file.c17
-rw-r--r--source3/libsmb/libsmb_misc.c1
-rw-r--r--source3/libsmb/libsmb_path.c2
-rw-r--r--source3/libsmb/libsmb_printjob.c1
-rw-r--r--source3/libsmb/libsmb_server.c110
-rw-r--r--source3/libsmb/libsmb_stat.c5
-rw-r--r--source3/libsmb/libsmb_xattr.c209
-rw-r--r--source3/libsmb/namequery.c896
-rw-r--r--source3/libsmb/nmblib.c60
-rw-r--r--source3/libsmb/nmblib.h29
-rw-r--r--source3/libsmb/nterr.c802
-rw-r--r--source3/libsmb/ntlmssp.c4
-rw-r--r--source3/libsmb/passchange.c53
-rw-r--r--source3/libsmb/proto.h854
-rw-r--r--source3/libsmb/read_smb.c134
-rw-r--r--source3/libsmb/read_smb.h34
-rw-r--r--source3/libsmb/samlogon_cache.c20
-rw-r--r--source3/libsmb/smb_seal.c44
-rw-r--r--source3/libsmb/smb_share_modes.c46
-rw-r--r--source3/libsmb/smbsock_connect.c21
-rw-r--r--source3/libsmb/trusts_util.c11
-rw-r--r--source3/libsmb/unexpected.c9
-rw-r--r--source3/locale/net/de.po4
-rw-r--r--source3/locking/brlock.c26
-rw-r--r--source3/locking/locking.c80
-rw-r--r--source3/locking/posix.c11
-rw-r--r--source3/locking/proto.h26
-rw-r--r--source3/m4/aclocal.m410
-rw-r--r--source3/m4/samba_version.m42
-rw-r--r--source3/modules/CP437.c135
-rw-r--r--source3/modules/CP850.c121
-rw-r--r--source3/modules/charset_macosxfs.c604
-rw-r--r--source3/modules/gpfs.c19
-rw-r--r--source3/modules/nfs4_acls.c74
-rw-r--r--source3/modules/nfs4_acls.h3
-rw-r--r--source3/modules/onefs_acl.c2
-rw-r--r--source3/modules/onefs_cbrl.c2
-rw-r--r--source3/modules/onefs_open.c14
-rw-r--r--source3/modules/onefs_streams.c4
-rw-r--r--source3/modules/vfs_acl_common.c33
-rw-r--r--source3/modules/vfs_acl_tdb.c3
-rw-r--r--source3/modules/vfs_acl_xattr.c2
-rw-r--r--source3/modules/vfs_afsacl.c20
-rw-r--r--source3/modules/vfs_aio_fork.c10
-rw-r--r--source3/modules/vfs_audit.c6
-rw-r--r--source3/modules/vfs_cap.c6
-rw-r--r--source3/modules/vfs_default.c13
-rw-r--r--source3/modules/vfs_dirsort.c2
-rw-r--r--source3/modules/vfs_expand_msdfs.c2
-rw-r--r--source3/modules/vfs_extd_audit.c6
-rw-r--r--source3/modules/vfs_fileid.c4
-rw-r--r--source3/modules/vfs_full_audit.c21
-rw-r--r--source3/modules/vfs_gpfs.c55
-rw-r--r--source3/modules/vfs_gpfs.h12
-rw-r--r--source3/modules/vfs_gpfs_hsm_notify.c110
-rw-r--r--source3/modules/vfs_hpuxacl.c8
-rw-r--r--source3/modules/vfs_notify_fam.c2
-rw-r--r--source3/modules/vfs_preopen.c10
-rw-r--r--source3/modules/vfs_recycle.c32
-rw-r--r--source3/modules/vfs_scannedonly.c47
-rw-r--r--source3/modules/vfs_shadow_copy.c7
-rw-r--r--source3/modules/vfs_shadow_copy2.c1811
-rw-r--r--source3/modules/vfs_smb_traffic_analyzer.c30
-rw-r--r--source3/modules/vfs_smb_traffic_analyzer.h2
-rw-r--r--source3/modules/vfs_streams_depot.c4
-rw-r--r--source3/modules/vfs_streams_xattr.c12
-rw-r--r--source3/modules/vfs_time_audit.c12
-rw-r--r--source3/modules/vfs_tsmsm.c2
-rw-r--r--source3/modules/vfs_xattr_tdb.c11
-rw-r--r--source3/modules/weird.c134
-rw-r--r--source3/modules/wscript_build86
-rw-r--r--source3/nmbd/nmbd.c6
-rw-r--r--source3/nmbd/nmbd.h25
-rw-r--r--source3/nmbd/nmbd_become_dmb.c12
-rw-r--r--source3/nmbd/nmbd_become_lmb.c30
-rw-r--r--source3/nmbd/nmbd_browsesync.c12
-rw-r--r--source3/nmbd/nmbd_elections.c10
-rw-r--r--source3/nmbd/nmbd_incomingdgrams.c36
-rw-r--r--source3/nmbd/nmbd_incomingrequests.c10
-rw-r--r--source3/nmbd/nmbd_logonnames.c8
-rw-r--r--source3/nmbd/nmbd_packets.c39
-rw-r--r--source3/nmbd/nmbd_processlogon.c31
-rw-r--r--source3/nmbd/nmbd_proto.h47
-rw-r--r--source3/nmbd/nmbd_sendannounce.c34
-rw-r--r--source3/nmbd/nmbd_subnetdb.c2
-rw-r--r--source3/nmbd/nmbd_synclists.c34
-rw-r--r--source3/nmbd/nmbd_winsserver.c7
-rw-r--r--source3/nmbd/nmbd_workgroupdb.c4
-rw-r--r--source3/pam_smbpass/support.c8
-rw-r--r--source3/pam_smbpass/wscript_build3
-rw-r--r--source3/param/loadparm.c925
-rw-r--r--source3/param/loadparm_ctx.c68
-rw-r--r--source3/param/service.c276
-rw-r--r--source3/passdb/login_cache.c5
-rw-r--r--source3/passdb/lookup_sid.c14
-rw-r--r--source3/passdb/machine_account_secrets.c59
-rw-r--r--source3/passdb/machine_sid.c8
-rw-r--r--source3/passdb/machine_sid.h21
-rw-r--r--source3/passdb/passdb.c17
-rw-r--r--source3/passdb/pdb_get_set.c5
-rw-r--r--source3/passdb/pdb_interface.c108
-rw-r--r--source3/passdb/pdb_ipa.c6
-rw-r--r--source3/passdb/pdb_ldap.c28
-rw-r--r--source3/passdb/pdb_samba4.c2100
-rw-r--r--source3/passdb/pdb_smbpasswd.c8
-rw-r--r--source3/passdb/pdb_tdb.c1
-rw-r--r--source3/passdb/pdb_wbc_sam.c2
-rw-r--r--source3/passdb/proto.h40
-rw-r--r--source3/passdb/secrets.c5
-rw-r--r--source3/passdb/wscript_build13
-rw-r--r--source3/printing/load.h24
-rw-r--r--source3/printing/lpq_parse.c3
-rw-r--r--source3/printing/notify.c19
-rw-r--r--source3/printing/nt_printing.c33
-rw-r--r--source3/printing/nt_printing_ads.c5
-rw-r--r--source3/printing/nt_printing_migrate.c20
-rw-r--r--source3/printing/nt_printing_tdb.c31
-rw-r--r--source3/printing/pcap.c24
-rw-r--r--source3/printing/pcap.h27
-rw-r--r--source3/printing/print_aix.c4
-rw-r--r--source3/printing/print_cups.c192
-rw-r--r--source3/printing/print_generic.c16
-rw-r--r--source3/printing/print_iprint.c2
-rw-r--r--source3/printing/print_standard.c15
-rw-r--r--source3/printing/print_svid.c2
-rw-r--r--source3/printing/printer_list.c43
-rw-r--r--source3/printing/printer_list.h8
-rw-r--r--source3/printing/printing.c55
-rw-r--r--source3/printing/printing_db.c3
-rw-r--r--source3/printing/printspoolss.c1
-rw-r--r--source3/printing/spoolssd.c3
-rw-r--r--source3/printing/tests/vlp.c9
-rw-r--r--source3/registry/reg_api.c6
-rw-r--r--source3/registry/reg_backend_current_version.c4
-rw-r--r--source3/registry/reg_backend_db.c63
-rw-r--r--source3/registry/reg_objects.c13
-rw-r--r--source3/registry/reg_parse.c2
-rw-r--r--source3/registry/reg_parse_internal.c9
-rw-r--r--source3/registry/reg_parse_internal.h7
-rw-r--r--source3/registry/reg_perfcount.c41
-rw-r--r--source3/registry/reg_util_internal.c7
-rw-r--r--source3/registry/reg_util_token.c2
-rw-r--r--source3/registry/regfio.c23
-rw-r--r--source3/rpc_client/cli_lsarpc.c16
-rw-r--r--source3/rpc_client/cli_netlogon.c24
-rw-r--r--source3/rpc_client/cli_netlogon.h26
-rw-r--r--source3/rpc_client/cli_pipe.c30
-rw-r--r--source3/rpc_client/cli_pipe_schannel.c3
-rw-r--r--source3/rpc_client/cli_spoolss.c5
-rw-r--r--source3/rpc_client/cli_spoolss.h29
-rw-r--r--source3/rpc_client/cli_winreg.c24
-rw-r--r--source3/rpc_client/cli_winreg_int.c1
-rw-r--r--source3/rpc_client/cli_winreg_int.h1
-rw-r--r--source3/rpc_client/init_lsa.h24
-rw-r--r--source3/rpc_client/init_netlogon.h24
-rw-r--r--source3/rpc_client/init_samr.h23
-rw-r--r--source3/rpc_client/init_spoolss.h22
-rw-r--r--source3/rpc_client/rpc_transport_np.c1
-rw-r--r--source3/rpc_client/rpc_transport_sock.c2
-rw-r--r--source3/rpc_client/rpc_transport_tstream.c7
-rw-r--r--source3/rpc_client/util_netlogon.h24
-rw-r--r--source3/rpc_server/dcesrv_gssapi.c71
-rw-r--r--source3/rpc_server/dfs/srv_dfs_nt.c38
-rw-r--r--source3/rpc_server/dssetup/srv_dssetup_nt.c4
-rw-r--r--source3/rpc_server/echo/srv_echo_nt.c6
-rw-r--r--source3/rpc_server/epmapper/srv_epmapper.c3
-rw-r--r--source3/rpc_server/epmd.c6
-rw-r--r--source3/rpc_server/eventlog/srv_eventlog_nt.c6
-rw-r--r--source3/rpc_server/initshutdown/srv_initshutdown_nt.c2
-rw-r--r--source3/rpc_server/lsa/srv_lsa_nt.c58
-rw-r--r--source3/rpc_server/netlogon/srv_netlog_nt.c20
-rw-r--r--source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c2
-rw-r--r--source3/rpc_server/rpc_contexts.c40
-rw-r--r--source3/rpc_server/rpc_contexts.h28
-rw-r--r--source3/rpc_server/rpc_ep_setup.c89
-rw-r--r--source3/rpc_server/rpc_ep_setup.h2
-rw-r--r--source3/rpc_server/rpc_handles.c51
-rw-r--r--source3/rpc_server/rpc_ncacn_np.c98
-rw-r--r--source3/rpc_server/rpc_ncacn_np.h15
-rw-r--r--source3/rpc_server/rpc_server.c59
-rw-r--r--source3/rpc_server/rpc_server.h4
-rw-r--r--source3/rpc_server/samr/srv_samr_nt.c69
-rw-r--r--source3/rpc_server/samr/srv_samr_util.c11
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_nt.c147
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_nt.h40
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_util.c21
-rw-r--r--source3/rpc_server/srv_access_check.h34
-rw-r--r--source3/rpc_server/srv_pipe.c174
-rw-r--r--source3/rpc_server/srv_pipe.h33
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c32
-rw-r--r--source3/rpc_server/srv_pipe_hnd.h51
-rw-r--r--source3/rpc_server/srv_pipe_register.c3
-rw-r--r--source3/rpc_server/srv_pipe_register.h39
-rw-r--r--source3/rpc_server/srvsvc/srv_srvsvc_nt.c139
-rw-r--r--source3/rpc_server/svcctl/srv_svcctl_nt.c33
-rw-r--r--source3/rpc_server/svcctl/srv_svcctl_nt.h33
-rw-r--r--source3/rpc_server/winreg/srv_winreg_nt.c5
-rw-r--r--source3/rpc_server/wkssvc/srv_wkssvc_nt.c24
-rw-r--r--source3/rpc_server/wscript_build32
-rw-r--r--source3/rpcclient/cmd_drsuapi.c2
-rw-r--r--source3/rpcclient/cmd_lsarpc.c10
-rw-r--r--source3/rpcclient/cmd_netlogon.c12
-rw-r--r--source3/rpcclient/cmd_samr.c12
-rw-r--r--source3/rpcclient/cmd_spoolss.c10
-rw-r--r--source3/rpcclient/rpcclient.c20
-rw-r--r--source3/script/mkbuildoptions-waf.awk2
-rw-r--r--source3/script/mkbuildoptions.awk4
-rwxr-xr-xsource3/script/tests/test_net_registry_roundtrip.sh4
-rwxr-xr-xsource3/script/tests/test_pthreadpool.sh20
-rwxr-xr-xsource3/script/tests/test_smbclient_s3.sh106
-rw-r--r--source3/selftest/knownfail24
-rw-r--r--source3/selftest/ktest-secrets.tdb2bin0 -> 14592 bytes
-rw-r--r--source3/selftest/quick1
-rw-r--r--source3/selftest/skip46
-rwxr-xr-xsource3/selftest/tests.py30
-rw-r--r--source3/smbd/aio.c13
-rw-r--r--source3/smbd/avahi_register.c2
-rw-r--r--source3/smbd/blocking.c15
-rw-r--r--source3/smbd/close.c2
-rw-r--r--source3/smbd/conn.c234
-rw-r--r--source3/smbd/conn_idle.c207
-rw-r--r--source3/smbd/conn_msg.c49
-rw-r--r--source3/smbd/connection.c13
-rw-r--r--source3/smbd/dfree.c2
-rw-r--r--source3/smbd/dir.c18
-rw-r--r--source3/smbd/dmapi.c6
-rw-r--r--source3/smbd/dosmode.c90
-rw-r--r--source3/smbd/error.c12
-rw-r--r--source3/smbd/file_access.c5
-rw-r--r--source3/smbd/fileio.c6
-rw-r--r--source3/smbd/filename.c4
-rw-r--r--source3/smbd/files.c6
-rw-r--r--source3/smbd/globals.c48
-rw-r--r--source3/smbd/globals.h3
-rw-r--r--source3/smbd/ipc.c13
-rw-r--r--source3/smbd/lanman.c52
-rw-r--r--source3/smbd/mangle_hash.c16
-rw-r--r--source3/smbd/mangle_hash2.c2
-rw-r--r--source3/smbd/message.c4
-rw-r--r--source3/smbd/msdfs.c33
-rw-r--r--source3/smbd/msg_idmap.c2
-rw-r--r--source3/smbd/negprot.c17
-rw-r--r--source3/smbd/notify.c6
-rw-r--r--source3/smbd/notify_internal.c10
-rw-r--r--source3/smbd/ntquotas.c7
-rw-r--r--source3/smbd/nttrans.c35
-rw-r--r--source3/smbd/open.c247
-rw-r--r--source3/smbd/oplock.c18
-rw-r--r--source3/smbd/oplock_irix.c2
-rw-r--r--source3/smbd/oplock_linux.c2
-rw-r--r--source3/smbd/oplock_onefs.c2
-rw-r--r--source3/smbd/password.c8
-rw-r--r--source3/smbd/perfcount.c2
-rw-r--r--source3/smbd/pipes.c11
-rw-r--r--source3/smbd/posix_acls.c6
-rw-r--r--source3/smbd/process.c130
-rw-r--r--source3/smbd/proto.h83
-rw-r--r--source3/smbd/quotas.c1
-rw-r--r--source3/smbd/reply.c93
-rw-r--r--source3/smbd/seal.c5
-rw-r--r--source3/smbd/server.c85
-rw-r--r--source3/smbd/server_exit.c2
-rw-r--r--source3/smbd/server_reload.c6
-rw-r--r--source3/smbd/service.c229
-rw-r--r--source3/smbd/session.c4
-rw-r--r--source3/smbd/sesssetup.c37
-rw-r--r--source3/smbd/signing.c4
-rw-r--r--source3/smbd/smb2_break.c1
-rw-r--r--source3/smbd/smb2_create.c1
-rw-r--r--source3/smbd/smb2_find.c3
-rw-r--r--source3/smbd/smb2_flush.c1
-rw-r--r--source3/smbd/smb2_getinfo.c1
-rw-r--r--source3/smbd/smb2_ioctl.c133
-rw-r--r--source3/smbd/smb2_lock.c7
-rw-r--r--source3/smbd/smb2_negprot.c4
-rw-r--r--source3/smbd/smb2_notify.c1
-rw-r--r--source3/smbd/smb2_read.c6
-rw-r--r--source3/smbd/smb2_server.c21
-rw-r--r--source3/smbd/smb2_sesssetup.c2
-rw-r--r--source3/smbd/smb2_setinfo.c1
-rw-r--r--source3/smbd/smb2_tcon.c2
-rw-r--r--source3/smbd/smb2_write.c4
-rw-r--r--source3/smbd/srvstr.c2
-rw-r--r--source3/smbd/statcache.c5
-rw-r--r--source3/smbd/trans2.c176
-rw-r--r--source3/smbd/uid.c59
-rw-r--r--source3/smbd/vfs.c87
-rwxr-xr-xsource3/stf/info3cache.py54
-rw-r--r--source3/stf/sambalib.py39
-rwxr-xr-xsource3/stf/strings.py149
-rw-r--r--source3/stf/unicodenames.py31
-rw-r--r--source3/torture/cmd_vfs.c9
-rw-r--r--source3/torture/denytest.c23
-rw-r--r--source3/torture/locktest.c39
-rw-r--r--source3/torture/locktest2.c3
-rw-r--r--source3/torture/mangle_test.c45
-rw-r--r--source3/torture/masktest.c55
-rw-r--r--source3/torture/msgtest.c2
-rw-r--r--source3/torture/nbench.c4
-rw-r--r--source3/torture/nbio.c40
-rw-r--r--source3/torture/pdbtest.c83
-rw-r--r--source3/torture/proto.h4
-rw-r--r--source3/torture/scanner.c5
-rw-r--r--source3/torture/t_strcmp.c6
-rw-r--r--source3/torture/test_async_echo.c1
-rw-r--r--source3/torture/test_case_insensitive.c1
-rw-r--r--source3/torture/test_notify_online.c294
-rw-r--r--source3/torture/test_nttrans_create.c108
-rw-r--r--source3/torture/test_posix_append.c16
-rw-r--r--source3/torture/test_smbsock_any_connect.c2
-rw-r--r--source3/torture/torture.c2180
-rw-r--r--source3/torture/utable.c12
-rw-r--r--source3/torture/vfstest.c14
-rw-r--r--source3/torture/wbc_async.c2
-rw-r--r--source3/utils/eventlogadm.c13
-rw-r--r--source3/utils/net.c20
-rw-r--r--source3/utils/net.h2
-rw-r--r--source3/utils/net_ads.c54
-rw-r--r--source3/utils/net_cache.c2
-rw-r--r--source3/utils/net_conf.c306
-rw-r--r--source3/utils/net_dom.c1
-rw-r--r--source3/utils/net_file.c2
-rw-r--r--source3/utils/net_g_lock.c4
-rw-r--r--source3/utils/net_group.c2
-rw-r--r--source3/utils/net_groupmap.c44
-rw-r--r--source3/utils/net_help.c2
-rw-r--r--source3/utils/net_idmap.c1
-rw-r--r--source3/utils/net_idmap_check.c5
-rw-r--r--source3/utils/net_join.c2
-rw-r--r--source3/utils/net_lookup.c6
-rw-r--r--source3/utils/net_printing.c19
-rw-r--r--source3/utils/net_proto.h1
-rw-r--r--source3/utils/net_rap.c5
-rw-r--r--source3/utils/net_registry.c147
-rw-r--r--source3/utils/net_rpc.c69
-rw-r--r--source3/utils/net_rpc_join.c13
-rw-r--r--source3/utils/net_rpc_printer.c133
-rw-r--r--source3/utils/net_rpc_registry.c21
-rw-r--r--source3/utils/net_rpc_rights.c6
-rw-r--r--source3/utils/net_rpc_samsync.c18
-rw-r--r--source3/utils/net_rpc_shell.c5
-rw-r--r--source3/utils/net_rpc_trust.c30
-rw-r--r--source3/utils/net_serverid.c16
-rw-r--r--source3/utils/net_share.c2
-rw-r--r--source3/utils/net_time.c21
-rw-r--r--source3/utils/net_user.c2
-rw-r--r--source3/utils/net_usershare.c2
-rw-r--r--source3/utils/net_util.c7
-rw-r--r--source3/utils/netlookup.c5
-rw-r--r--source3/utils/nmblookup.c24
-rw-r--r--source3/utils/ntlm_auth.c18
-rw-r--r--source3/utils/sharesec.c2
-rw-r--r--source3/utils/smbcacls.c12
-rw-r--r--source3/utils/smbcontrol.c13
-rw-r--r--source3/utils/smbcquotas.c3
-rw-r--r--source3/utils/smbget.c3
-rw-r--r--source3/utils/smbpasswd.c5
-rw-r--r--source3/utils/smbtree.c1
-rw-r--r--source3/utils/status.c2
-rw-r--r--source3/utils/testparm.c30
-rw-r--r--source3/web/cgi.c4
-rw-r--r--source3/web/diagnose.c11
-rw-r--r--source3/web/startstop.c2
-rw-r--r--source3/web/swat.c4
-rw-r--r--source3/winbindd/idmap.c2
-rw-r--r--source3/winbindd/idmap_ad.c6
-rw-r--r--source3/winbindd/idmap_adex/cell_util.c6
-rw-r--r--source3/winbindd/idmap_adex/domain_util.c4
-rw-r--r--source3/winbindd/idmap_adex/gc_util.c22
-rw-r--r--source3/winbindd/idmap_adex/likewise_cell.c2
-rw-r--r--source3/winbindd/idmap_adex/provider_unified.c4
-rw-r--r--source3/winbindd/idmap_autorid.c24
-rw-r--r--source3/winbindd/idmap_hash/idmap_hash.c2
-rw-r--r--source3/winbindd/idmap_hash/mapfile.c4
-rw-r--r--source3/winbindd/idmap_ldap.c20
-rw-r--r--source3/winbindd/idmap_proto.h29
-rw-r--r--source3/winbindd/idmap_rid.c2
-rw-r--r--source3/winbindd/idmap_tdb.c19
-rw-r--r--source3/winbindd/idmap_tdb2.c1
-rw-r--r--source3/winbindd/nss_info.c2
-rw-r--r--source3/winbindd/wb_fill_pwent.c12
-rw-r--r--source3/winbindd/wb_getgrsid.c9
-rw-r--r--source3/winbindd/wb_getpwsid.c9
-rw-r--r--source3/winbindd/wb_gettoken.c9
-rw-r--r--source3/winbindd/wb_group_members.c18
-rw-r--r--source3/winbindd/wb_lookupname.c3
-rw-r--r--source3/winbindd/wb_lookupsid.c3
-rw-r--r--source3/winbindd/wb_lookupsids.c96
-rw-r--r--source3/winbindd/wb_lookupuseraliases.c2
-rw-r--r--source3/winbindd/wb_next_grent.c6
-rw-r--r--source3/winbindd/wb_next_pwent.c3
-rw-r--r--source3/winbindd/wb_sid2gid.c3
-rw-r--r--source3/winbindd/wb_sid2uid.c3
-rw-r--r--source3/winbindd/winbindd.c22
-rw-r--r--source3/winbindd/winbindd.h2
-rw-r--r--source3/winbindd/winbindd_ads.c16
-rw-r--r--source3/winbindd/winbindd_cache.c55
-rw-r--r--source3/winbindd/winbindd_ccache_access.c2
-rw-r--r--source3/winbindd/winbindd_cm.c45
-rw-r--r--source3/winbindd/winbindd_cred_cache.c4
-rw-r--r--source3/winbindd/winbindd_creds.c4
-rw-r--r--source3/winbindd/winbindd_dual.c68
-rw-r--r--source3/winbindd/winbindd_dual_ndr.c4
-rw-r--r--source3/winbindd/winbindd_dual_srv.c10
-rw-r--r--source3/winbindd/winbindd_getdcname.c3
-rw-r--r--source3/winbindd/winbindd_getgrgid.c6
-rw-r--r--source3/winbindd/winbindd_getgrnam.c6
-rw-r--r--source3/winbindd/winbindd_getgroups.c6
-rw-r--r--source3/winbindd/winbindd_getpwent.c3
-rw-r--r--source3/winbindd/winbindd_getpwnam.c6
-rw-r--r--source3/winbindd/winbindd_getpwsid.c3
-rw-r--r--source3/winbindd/winbindd_getpwuid.c6
-rw-r--r--source3/winbindd/winbindd_getsidaliases.c3
-rw-r--r--source3/winbindd/winbindd_getuserdomgroups.c3
-rw-r--r--source3/winbindd/winbindd_getusersids.c3
-rw-r--r--source3/winbindd/winbindd_gid_to_sid.c3
-rw-r--r--source3/winbindd/winbindd_group.c4
-rw-r--r--source3/winbindd/winbindd_lookupname.c3
-rw-r--r--source3/winbindd/winbindd_lookupsids.c3
-rw-r--r--source3/winbindd/winbindd_misc.c2
-rw-r--r--source3/winbindd/winbindd_msrpc.c89
-rw-r--r--source3/winbindd/winbindd_ndr.c2
-rw-r--r--source3/winbindd/winbindd_pam.c32
-rw-r--r--source3/winbindd/winbindd_pam_auth_crap.c2
-rw-r--r--source3/winbindd/winbindd_proto.h17
-rw-r--r--source3/winbindd/winbindd_rpc.c25
-rw-r--r--source3/winbindd/winbindd_samr.c3
-rw-r--r--source3/winbindd/winbindd_show_sequence.c6
-rw-r--r--source3/winbindd/winbindd_sid_to_gid.c3
-rw-r--r--source3/winbindd/winbindd_sid_to_uid.c3
-rw-r--r--source3/winbindd/winbindd_sids_to_xids.c14
-rw-r--r--source3/winbindd/winbindd_uid_to_sid.c3
-rw-r--r--source3/winbindd/winbindd_util.c27
-rw-r--r--source3/winbindd/winbindd_wins.c204
-rw-r--r--source3/winbindd/winbindd_wins_byip.c135
-rw-r--r--source3/winbindd/winbindd_wins_byname.c149
-rw-r--r--source3/winbindd/wscript_build9
-rw-r--r--source3/wscript83
-rwxr-xr-xsource3/wscript_build419
676 files changed, 19895 insertions, 19029 deletions
diff --git a/source3/.clang_complete b/source3/.clang_complete
index c3f2f30dd7d..46925f9b8a2 100644
--- a/source3/.clang_complete
+++ b/source3/.clang_complete
@@ -1,2 +1,22 @@
--I. -I./.. -Iinclude -I./../lib/replace -I./../lib/tevent -I./librpc -I./../lib/talloc -I../lib/tdb/include
--Iinclude/includes.h.gch
+-I.
+-I./..
+-I./../lib
+-I./../lib/replace
+-I./../lib/talloc
+-I./../lib/tevent
+-I./../lib/popt
+-I./../lib/iniparser/src
+-I./../lib/popt
+-I./../lib/tdb/include
+-I./../lib/tdb_compat
+-I./include/autoconf
+-I./include
+-I./librpc
+-I./lib
+-DDEBUG_PASSWORD
+-DDEVELOPER
+-DHAVE_CONFIG_H
+-D_GNU_SOURCE
+-D_SAMBA_BUILD_=3
+-D_REENTRANT
+-DUSING_SMBCONTROL
diff --git a/source3/Makefile-smbtorture4 b/source3/Makefile-smbtorture4
index 4a1bed7eabf..0dc4706944f 100644
--- a/source3/Makefile-smbtorture4
+++ b/source3/Makefile-smbtorture4
@@ -6,7 +6,7 @@ SAMBA4_BINARIES="smbtorture,ndrdump"
samba4-configure:
@(cd .. && \
CFLAGS='' $(WAF) reconfigure || \
- CFLAGS='' $(WAF) configure --enable-socket-wrapper --enable-nss-wrapper --enable-uid-wrapper --nonshared-binary=$(SAMBA4_BINARIES) --enable-auto-reconfigure )
+ CFLAGS='' $(WAF) configure --enable-socket-wrapper --enable-nss-wrapper --enable-uid-wrapper --nonshared-binary=$(SAMBA4_BINARIES) --enable-auto-reconfigure --enable-developer)
.PHONY: samba4-configure
diff --git a/source3/Makefile.in b/source3/Makefile.in
index e503112392a..59f9032ea2b 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -97,6 +97,7 @@ TDBTOOL = @TDBTOOL@
TDBDUMP = @TDBDUMP@
TDBRESTORE = @TDBRESTORE@
TDBTORTURE = @TDBTORTURE@
+PTHREADPOOLTEST = @PTHREADPOOLTEST@
INSTALLCMD=@INSTALL@
INSTALLLIBCMD_SH=@INSTALLLIBCMD_SH@
@@ -139,6 +140,7 @@ CONFIGDIR = @configdir@
VARDIR = @localstatedir@
MANDIR = @mandir@
DATADIR = @datadir@
+SETUPDIR = @datadir@/setup
# The permissions to give the executables and other data
INSTALLPERMS_BIN = 0755
@@ -209,7 +211,9 @@ PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" \
-DCACHEDIR=\"$(CACHEDIR)\" \
-DSTATEDIR=\"$(STATEDIR)\" \
-DNMBDSOCKETDIR=\"$(NMBDSOCKETDIR)\" \
- -DLOCALEDIR=\"$(LOCALEDIR)\"
+ -DLOCALEDIR=\"$(LOCALEDIR)\" \
+ -DDATADIR=\"$(DATADIR)\" \
+ -DSETUPDIR=\"$(SETUPDIR)\"
# Note that all executable programs now provide for an optional executable suffix.
@@ -230,7 +234,7 @@ TORTURE_PROGS = bin/smbtorture@EXEEXT@ bin/msgtest@EXEEXT@ \
bin/masktest@EXEEXT@ bin/locktest@EXEEXT@ \
bin/locktest2@EXEEXT@ bin/nsstest@EXEEXT@ bin/vfstest@EXEEXT@ \
bin/pdbtest@EXEEXT@ $(TALLOCTORT) bin/replacetort@EXEEXT@ \
- $(TDBTORTURE) \
+ $(TDBTORTURE) $(PTHREADPOOLTEST) \
bin/smbconftort@EXEEXT@ bin/vlp@EXEEXT@
BIN_PROGS = @EXTRA_BIN_PROGS@ \
@@ -268,6 +272,7 @@ EXTRA_ALL_TARGETS = @EXTRA_ALL_TARGETS@
######################################################################
TDB_LIB_OBJ = lib/util_tdb.o ../lib/util/util_tdb.o \
+ ../lib/util/tdb_wrap.o \
lib/dbwrap.o lib/dbwrap_tdb.o \
lib/dbwrap_ctdb.o \
lib/g_lock.o \
@@ -317,7 +322,7 @@ LIBNDR_OBJ = ../librpc/ndr/ndr_basic.o \
../librpc/ndr/ndr_sec_helper.o \
../librpc/ndr/ndr_string.o \
../librpc/ndr/uuid.o \
- librpc/ndr/util.o \
+ ../librpc/ndr/util.o \
librpc/gen_ndr/ndr_server_id.o \
librpc/gen_ndr/ndr_dcerpc.o
@@ -416,7 +421,7 @@ LIBSAMBAUTIL_OBJ = \
UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
../lib/util/xfile.o ../lib/util/util_strlist.o \
../lib/util/util_file.o ../lib/util/data_blob.o \
- ../lib/util/util.o ../lib/util/fsusage.o \
+ ../lib/util/util.o ../lib/util/util_paths.o ../lib/util/fsusage.o \
../lib/util/params.o ../lib/util/talloc_stack.o \
../lib/util/genrand.o ../lib/util/util_net.o \
../lib/util/become_daemon.o ../lib/util/system.o \
@@ -424,7 +429,7 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
../lib/util/tevent_werror.o \
../lib/util/smb_threads.o ../lib/util/util_id.o \
../lib/util/blocking.o ../lib/util/rfc1738.o \
- ../lib/util/select.o ../lib/util/util_pw.o
+ ../lib/util/select.o ../lib/util/util_pw.o ../lib/util/server_id.o
CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
@@ -434,38 +439,43 @@ CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
lib/messages.o librpc/gen_ndr/ndr_messaging.o lib/messages_local.o \
- lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o \
- lib/interfaces.o lib/memcache.o \
+ lib/messages_ctdbd.o lib/ctdb_packet.o lib/ctdbd_conn.o \
+ ../lib/socket/interfaces.o lib/memcache.o \
lib/talloc_dict.o \
lib/serverid.o \
lib/util_sconn.o \
lib/util_transfer_file.o ../lib/async_req/async_sock.o \
lib/addrchange.o \
$(TDB_LIB_OBJ) \
- $(VERSION_OBJ) lib/charcnv.o ../lib/util/charset/convert_string.o lib/fstring.o ../lib/util/debug.o ../lib/util/debug_s3.o ../lib/util/fault.o \
+ $(VERSION_OBJ) lib/charcnv.o ../lib/util/charset/convert_string.o \
+ ../lib/util/charset/pull_push.o \
+ lib/fstring.o ../lib/util/debug.o ../lib/util/debug_s3.o ../lib/util/fault.o \
lib/interface.o lib/pidfile.o lib/dumpcore.o \
lib/system.o lib/sendfile.o lib/recvfile.o lib/time.o \
lib/username.o \
../libds/common/flag_mapping.o \
lib/access.o lib/smbrun.o \
- lib/bitmap.o lib/dprintf.o $(UTIL_REG_OBJ) \
- lib/wins_srv.o \
+ lib/bitmap.o ../lib/util/dprintf.o $(UTIL_REG_OBJ) \
+ lib/wins_srv.o lib/string_init.o \
lib/util_str.o ../lib/util/util_str_common.o \
+ ../lib/util/util_str.o \
../lib/util/base64.o lib/util_sid.o \
+ ../lib/util/charset/util_unistr.o \
../lib/util/charset/util_unistr_w.o ../lib/util/charset/codepoints.o ../lib/util/charset/util_str.o lib/util_file.o \
- lib/util.o lib/util_cmdline.o lib/util_names.o \
+ lib/util.o lib/util_malloc.o lib/namearray.o lib/util_cmdline.o lib/util_names.o \
lib/util_sock.o lib/sock_exec.o lib/util_sec.o \
- lib/substitute.o lib/dbwrap_util.o \
- lib/ms_fnmatch.o lib/errmap_unix.o \
+ lib/substitute.o lib/substitute_generic.o ../lib/util/substitute.o lib/dbwrap_util.o \
+ lib/ms_fnmatch.o ../lib/util/ms_fnmatch.o lib/errmap_unix.o ../libcli/util/errmap_unix.o \
lib/tallocmsg.o lib/dmallocmsg.o \
libsmb/clisigning.o libsmb/smb_signing.o \
../lib/util/charset/iconv.o intl/lang_tdb.o \
lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \
lib/sessionid_tdb.o \
lib/module.o lib/events.o @LIBTEVENT_OBJ0@ \
+ @CCAN_OBJ@ \
lib/server_contexts.o \
lib/ldap_escape.o @CHARSET_STATIC@ \
- lib/secdesc.o ../libcli/security/access_check.o \
+ ../libcli/security/secdesc.o ../libcli/security/access_check.o \
../libcli/security/secace.o ../libcli/security/object_tree.o \
../libcli/security/sddl.o \
../libcli/security/secacl.o @PTHREADPOOL_OBJ@ \
@@ -473,9 +483,10 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
libads/krb5_errs.o lib/system_smbd.o lib/audit.o $(LIBNDR_OBJ) \
lib/file_id.o lib/idmap_cache.o \
../libcli/security/dom_sid.o ../libcli/security/security_descriptor.o \
- ../libcli/security/security_token.o ../libcli/security/util_sid.o
+ ../libcli/security/security_token.o ../libcli/security/util_sid.o \
+ ../libcli/smb/util.o
-LIB_DUMMY_OBJ = lib/dummysmbd.o lib/dummyroot.o
+LIB_DUMMY_OBJ = lib/smbd_shim.o lib/dummyparam.o
LIB_NONSMBD_OBJ = $(LIB_OBJ) $(LIB_DUMMY_OBJ)
READLINE_OBJ = ../libcli/smbreadline/smbreadline.o
@@ -484,7 +495,7 @@ READLINE_OBJ = ../libcli/smbreadline/smbreadline.o
# Be sure to include them into your application
POPT_LIB_OBJ = lib/popt_common.o
-PARAM_WITHOUT_REG_OBJ = dynconfig.o param/loadparm.o param/loadparm_server_role.o param/util.o lib/sharesec.o lib/ldap_debug_handler.o
+PARAM_WITHOUT_REG_OBJ = ../dynconfig/dynconfig.o param/loadparm.o param/loadparm_server_role.o param/util.o lib/sharesec.o lib/ldap_debug_handler.o
PARAM_REG_ADD_OBJ = $(REG_SMBCONF_OBJ) $(LIBSMBCONF_OBJ) $(PRIVILEGES_BASIC_OBJ)
PARAM_OBJ = $(PARAM_WITHOUT_REG_OBJ) $(PARAM_REG_ADD_OBJ)
@@ -511,7 +522,7 @@ LIBADS_OBJ = libads/ldap.o \
libads/disp_sec.o libads/ldap_utils.o \
libads/ldap_schema.o libads/util.o libads/ndr.o
-LIBADS_SERVER_OBJ = libads/kerberos_verify.o libads/authdata.o ../libcli/auth/kerberos_pac.o \
+LIBADS_SERVER_OBJ = libads/kerberos_verify.o libads/authdata.o ../auth/kerberos/kerberos_pac.o \
../librpc/ndr/ndr_krb5pac.o \
librpc/gen_ndr/ndr_krb5pac.o
@@ -528,12 +539,12 @@ LIBNBT_OBJ = ../libcli/nbt/nbtname.o \
../librpc/ndr/ndr_svcctl.o
LIBNMB_OBJ = libsmb/unexpected.o libsmb/namecache.o libsmb/nmblib.o \
- libsmb/namequery.o ../libcli/nbt/lmhosts.o libsmb/conncache.o \
+ libsmb/namequery.o ../libcli/nbt/lmhosts.o ../libcli/dns/dns_hosts_file.o libsmb/conncache.o \
libads/dns.o libads/sitename_cache.o
-NTERR_OBJ = libsmb/nterr.o libsmb/smberr.o
+NTERR_OBJ = ../libcli/util/nterr.o libsmb/smberr.o
DOSERR_OBJ = ../libcli/util/doserr.o
-ERRORMAP_OBJ = libsmb/errormap.o
+ERRORMAP_OBJ = ../libcli/util/errormap.o libsmb/errormap.o
DCE_RPC_ERR_OBJ = ../librpc/rpc/dcerpc_error.o
LIBSMB_ERR_OBJ0 = $(NTERR_OBJ) $(DOSERR_OBJ) $(ERRORMAP_OBJ) $(DCE_RPC_ERR_OBJ)
@@ -585,6 +596,7 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
libsmb/clistr.o libsmb/cliquota.o libsmb/clifsinfo.o libsmb/clidfs.o \
libsmb/clioplock.o libsmb/clirap2.o \
libsmb/smb_seal.o libsmb/async_smb.o \
+ libsmb/read_smb.o \
libsmb/cli_np_tstream.o \
libsmb/smbsock_connect.o \
$(LIBSAMBA_OBJ) \
@@ -597,6 +609,7 @@ LIBMSRPC_OBJ = $(SCHANNEL_OBJ) \
rpc_client/cli_pipe.o \
librpc/crypto/gse_krb5.o \
librpc/crypto/gse.o \
+ ../auth/kerberos/gssapi_pac.o \
librpc/crypto/cli_spnego.o \
librpc/rpc/rpc_common.o \
rpc_client/rpc_transport_np.o \
@@ -715,7 +728,8 @@ NPA_TSTREAM_OBJ = ../libcli/named_pipe_auth/npa_tstream.o \
../auth/auth_sam_reply.o librpc/gen_ndr/ndr_auth.o ../librpc/ndr/ndr_auth.o
RPC_NCACN_NP = rpc_server/srv_pipe_register.o rpc_server/rpc_ncacn_np.o \
- rpc_server/rpc_handles.o rpc_server/srv_access_check.o
+ rpc_server/rpc_handles.o rpc_server/rpc_contexts.o \
+ rpc_server/srv_access_check.o
RPC_SERVICE = rpc_server/rpc_server.o
@@ -767,10 +781,10 @@ PASSDB_OBJ = $(PASSDB_GET_SET_OBJ) passdb/passdb.o passdb/pdb_interface.o \
lib/util_nscd.o lib/winbind_util.o $(SERVER_MUTEX_OBJ) \
passdb/pdb_util.o
-DEVEL_HELP_WEIRD_OBJ = modules/weird.o
-CP850_OBJ = modules/CP850.o
-CP437_OBJ = modules/CP437.o
-CHARSET_MACOSXFS_OBJ = modules/charset_macosxfs.o
+DEVEL_HELP_WEIRD_OBJ = ../lib/util/charset/weird.o
+CP850_OBJ = ../lib/util/charset/CP850.o
+CP437_OBJ = ../lib/util/charset/CP437.o
+CHARSET_MACOSXFS_OBJ = ../lib/util/charset/charset_macosxfs.o
GROUPDB_OBJ = groupdb/mapping.o groupdb/mapping_tdb.o
@@ -820,6 +834,7 @@ VFS_CACHEPRIME_OBJ = modules/vfs_cacheprime.o
VFS_PREALLOC_OBJ = modules/vfs_prealloc.o
VFS_COMMIT_OBJ = modules/vfs_commit.o
VFS_GPFS_OBJ = modules/vfs_gpfs.o modules/gpfs.o modules/nfs4_acls.o
+VFS_GPFS_HSM_NOTIFY_OBJ = modules/vfs_gpfs_hsm_notify.o
VFS_NOTIFY_FAM_OBJ = modules/vfs_notify_fam.o
VFS_READAHEAD_OBJ = modules/vfs_readahead.o
VFS_TSMSM_OBJ = modules/vfs_tsmsm.o
@@ -877,7 +892,7 @@ BUILDOPT_OBJ = smbd/build_options.o
SMBD_OBJ_SRV = smbd/server_reload.o \
smbd/files.o smbd/connection.o \
smbd/utmp.o smbd/session.o \
- smbd/dfree.o smbd/dir.o smbd/password.o smbd/conn.o \
+ smbd/dfree.o smbd/dir.o smbd/password.o smbd/conn.o smbd/conn_idle.o smbd/conn_msg.o \
smbd/share_access.o smbd/fileio.o \
smbd/ipc.o smbd/lanman.o smbd/negprot.o \
smbd/message.o smbd/nttrans.o smbd/pipes.o \
@@ -886,12 +901,13 @@ SMBD_OBJ_SRV = smbd/server_reload.o \
smbd/blocking.o smbd/sec_ctx.o smbd/srvstr.o \
smbd/vfs.o smbd/perfcount.o smbd/statcache.o smbd/seal.o \
smbd/posix_acls.o lib/sysacls.o \
- smbd/process.o smbd/service.o smbd/error.o \
+ smbd/process.o smbd/service.o param/service.o smbd/error.o \
rpc_server/epmd.o \
printing/printspoolss.o printing/spoolssd.o \
lib/sysquotas.o lib/sysquotas_linux.o \
lib/sysquotas_xfs.o lib/sysquotas_4A.o \
lib/sysquotas_nfs.o \
+ lib/smbd_shim.o \
smbd/fake_file.o \
smbd/quotas.o smbd/ntquotas.o $(AFS_OBJ) smbd/msdfs.o \
$(AFS_SETTOKEN_OBJ) smbd/aio.o smbd/statvfs.o \
@@ -1023,6 +1039,7 @@ PDBEDIT_OBJ = utils/pdbedit.o $(PASSWD_UTIL_OBJ) $(PARAM_OBJ) $(PASSDB_OBJ) \
$(LIBSAMBA_OBJ) $(LIBTSOCKET_OBJ) \
$(LIB_NONSMBD_OBJ) $(GROUPDB_OBJ) \
$(LIBCLI_LDAP_NDR_OBJ) \
+ $(DRSUAPI_OBJ) $(LIBNDR_GEN_OBJ0) \
$(POPT_LIB_OBJ) $(SMBLDAP_OBJ) ../lib/util/asn1.o
SMBGET_OBJ = utils/smbget.o $(POPT_LIB_OBJ) $(LIBSMBCLIENT_OBJ1)
@@ -1129,6 +1146,9 @@ SMBCONFTORT_OBJ = $(SMBCONFTORT_OBJ0) \
$(LIBSMB_ERR_OBJ) \
$(POPT_LIB_OBJ)
+PTHREADPOOLTEST_OBJ = lib/pthreadpool/pthreadpool.o \
+ lib/pthreadpool/tests.o
+
LIBNET_OBJ = libnet/libnet_join.o \
libnet/libnet_keytab.o \
librpc/gen_ndr/ndr_libnet_join.o
@@ -1214,6 +1234,8 @@ SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o torture/scanner.o torture/uta
torture/nbench.o \
torture/test_async_echo.o \
torture/test_smbsock_any_connect.o \
+ torture/test_nttrans_create.o \
+ torture/test_notify_online.o \
torture/test_addrchange.o \
torture/test_case_insensitive.o \
torture/test_posix_append.o
@@ -1302,6 +1324,7 @@ PAM_SMBPASS_OBJ_0 = pam_smbpass/pam_smb_auth.o pam_smbpass/pam_smb_passwd.o \
pam_smbpass/pam_smb_acct.o pam_smbpass/support.o ../lib/util/asn1.o
PAM_SMBPASS_OBJ = $(PAM_SMBPASS_OBJ_0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
$(SMBLDAP_OBJ) $(LIBSAMBA_OBJ) \
+ $(DRSUAPI_OBJ) $(LIBNDR_GEN_OBJ0) \
$(LIBTSOCKET_OBJ) $(PAM_ERRORS_OBJ)
IDMAP_RW_OBJ = winbindd/idmap_rw.o
@@ -1330,7 +1353,8 @@ WINBINDD_OBJ1 = \
winbindd/winbindd_pam.o \
winbindd/winbindd_misc.o \
winbindd/winbindd_cm.o \
- winbindd/winbindd_wins.o \
+ winbindd/winbindd_wins_byip.o \
+ winbindd/winbindd_wins_byname.o \
winbindd/winbindd_msrpc.o \
winbindd/winbindd_rpc.o \
winbindd/winbindd_reconnect.o \
@@ -1483,6 +1507,7 @@ NTLM_AUTH_OBJ = ${NTLM_AUTH_OBJ1} $(LIBSAMBA_OBJ) $(POPT_LIB_OBJ) \
$(SMBLDAP_OBJ) $(LIBNMB_OBJ) \
$(WBCOMMON_OBJ) \
$(LIBCLI_LDAP_NDR_OBJ) \
+ $(DRSUAPI_OBJ) \
$(LIBNDR_GEN_OBJ0) $(LIBNDR_NETLOGON_OBJ) @BUILD_INIPARSER@
@@ -1567,6 +1592,8 @@ replacetort : SHOWFLAGS bin/replacetort@EXEEXT@
smbconftort : SHOWFLAGS bin/smbconftort@EXEEXT@
+pthreadpooltest : SHOWFLAGS bin/pthreadpooltest@EXEEXT@
+
timelimit : SHOWFLAGS bin/timelimit@EXEEXT@
nsswitch : SHOWFLAGS bin/winbindd@EXEEXT@ bin/wbinfo@EXEEXT@ @WINBIND_NSS@ \
@@ -1583,12 +1610,10 @@ modules:: SHOWFLAGS $(MODULES)
IDL_FILES = librpc/idl/messaging.idl \
librpc/idl/libnetapi.idl \
- librpc/idl/notify.idl \
librpc/idl/wbint.idl \
librpc/idl/perfcount.idl \
librpc/idl/secrets.idl \
- librpc/idl/libnet_join.idl \
- librpc/idl/server_id.idl
+ librpc/idl/libnet_join.idl
samba3-idl::
@PIDL_OUTPUTDIR="librpc/gen_ndr" PIDL_ARGS="$(PIDL_ARGS)" CPP="$(CPP)" PIDL="../pidl/pidl" \
@@ -1690,7 +1715,7 @@ BINARY_PREREQS = bin/.dummy
# but since we also require "make install prefix=/opt/samba" *not* to
# rebuild it's a bit hard.
-dynconfig.o: dynconfig.c Makefile
+../dynconfig/dynconfig.o: ../dynconfig/dynconfig.c Makefile
@echo Compiling $*.c
@$(COMPILE_CC_PATH) && exit 0;\
echo "The following command failed:" 1>&2;\
@@ -1748,16 +1773,16 @@ lib/version.o: lib/version.c include/version.h
echo "$(COMPILE_CC_PATH)" 1>&2;\
$(COMPILE_CC_PATH) >/dev/null 2>&1
-smbd/build_options.o: smbd/build_options.c Makefile include/config.h include/build_env.h include/proto.h
+smbd/build_options.o: smbd/build_options.c Makefile include/autoconf/config.h include/build_env.h include/proto.h
@echo Compiling $*.c
@$(COMPILE_CC_PATH) && exit 0;\
echo "The following command failed:" 1>&2;\
echo "$(COMPILE_CC_PATH)" 1>&2;\
$(COMPILE_CC_PATH) >/dev/null 2>&1
-smbd/build_options.c: include/config.h.in script/mkbuildoptions.awk
+smbd/build_options.c: include/autoconf/config.h.in script/mkbuildoptions.awk
@echo Generating $@
- @dir=smbd $(MAKEDIR) && $(AWK) -f $(srcdir)/script/mkbuildoptions.awk > $(builddir)/smbd/build_options.c < $(srcdir)/include/config.h.in
+ @dir=smbd $(MAKEDIR) && $(AWK) -f $(srcdir)/script/mkbuildoptions.awk > $(builddir)/smbd/build_options.c < $(srcdir)/include/autoconf/config.h.in
bin/.dummy:
@if (: >> $@ || : > $@) >/dev/null 2>&1; then :; else \
@@ -1852,11 +1877,11 @@ bin/smbpasswd@EXEEXT@: $(BINARY_PREREQS) $(SMBPASSWD_OBJ) @BUILD_POPT@ $(LIBTALL
$(DYNEXP) $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \
$(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(LIBWBCLIENT_LIBS) $(ZLIB_LIBS)
-bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT)
+bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT) $(ZLIB_LIBS)
@echo Linking $@
@$(CC) -o $@ $(PDBEDIT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \
$(POPT_LIBS) $(PASSDB_LIBS) $(LDAP_LIBS) $(LIBTALLOC_LIBS) \
- $(LIBTDB_LIBS) $(LIBWBCLIENT_LIBS)
+ $(LIBTDB_LIBS) $(LIBWBCLIENT_LIBS) $(ZLIB_LIBS)
bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT)
@echo Linking $@
@@ -1892,6 +1917,10 @@ bin/smbconftort@EXEEXT@: $(SMBCONFTORT_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB)
$(DYNEXP) $(LIBS) $(LDAP_LIBS) $(POPT_LIBS) \
$(LIBTALLOC_LIBS) $(LIBTDB_LIBS)
+bin/pthreadpooltest@EXEEXT@: $(PTHREADPOOLTEST_OBJ)
+ @echo Linking $@
+ @$(CC) -o $@ $(PTHREADPOOLTEST_OBJ) $(LDFLAGS) -lpthread
+
bin/masktest@EXEEXT@: $(BINARY_PREREQS) $(MASKTEST_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT)
@echo Linking $@
@$(CC) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) \
@@ -2008,7 +2037,9 @@ LIBTALLOC_OBJ = $(LIBTALLOC_OBJ0) $(LIBREPLACE_OBJ)
LIBTALLOC_SHARED_TARGET=@LIBTALLOC_SHARED_TARGET@
LIBTALLOC_SOVER=@LIBTALLOC_SOVER@
+LIBTALLOC_FULLVER=@LIBTALLOC_FULLVER@
LIBTALLOC_SHARED_TARGET_SONAME=$(LIBTALLOC_SHARED_TARGET).$(LIBTALLOC_SOVER)
+LIBTALLOC_SHARED_TARGET_FULLVER=$(LIBTALLOC_SHARED_TARGET).$(LIBTALLOC_FULLVER)
LIBTALLOC_STATIC_TARGET=@LIBTALLOC_STATIC_TARGET@
LIBTALLOC_SYMS=$(srcdir)/exports/libtalloc.@SYMSEXT@
LIBTALLOC_HEADERS=$(srcdir)/@tallocdir@/talloc.h
@@ -2020,7 +2051,12 @@ $(LIBTALLOC_SHARED_TARGET_SONAME): $(BINARY_PREREQS) $(LIBTALLOC_OBJ) $(LIBTALLO
@echo Linking shared library $@
@$(SHLD_DSO) $(LIBTALLOC_OBJ) $(LIBREPLACE_LIBS) @SONAMEFLAG@`basename $@`
-$(LIBTALLOC_SHARED_TARGET): $(LIBTALLOC_SHARED_TARGET_SONAME)
+$(LIBTALLOC_SHARED_TARGET_FULLVER): $(LIBTALLOC_SHARED_TARGET_SONAME)
+ @rm -f $@
+ @mv -f $(LIBTALLOC_SHARED_TARGET_SONAME) $@
+ @ln -f -s `basename $@` $(LIBTALLOC_SHARED_TARGET_SONAME)
+
+$(LIBTALLOC_SHARED_TARGET): $(LIBTALLOC_SHARED_TARGET_FULLVER)
@rm -f $@
@ln -f -s `basename $(LIBTALLOC_SHARED_TARGET_SONAME)` $@
@@ -2038,8 +2074,13 @@ cleanlibtalloc::
installlibtalloc:: installdirs libtalloc
@$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(LIBDIR)
- -$(INSTALLLIBCMD_SH) $(LIBTALLOC_SHARED_TARGET_SONAME) $(DESTDIR)$(LIBDIR)
+ -$(INSTALLLIBCMD_SH) $(LIBTALLOC_SHARED_TARGET_FULLVER) $(DESTDIR)$(LIBDIR)
@rm -f $(DESTDIR)$(LIBDIR)/`basename $(LIBTALLOC_SHARED_TARGET)`
+ @rm -f $(DESTDIR)$(LIBDIR)/`basename $(LIBTALLOC_SHARED_TARGET_SONAME)`
+ -if test -r $(LIBTALLOC_SHARED_TARGET_FULLVER) ; then \
+ ln -f -s `basename $(LIBTALLOC_SHARED_TARGET_FULLVER)` \
+ $(DESTDIR)$(LIBDIR)/`basename $(LIBTALLOC_SHARED_TARGET_SONAME)` ; \
+ fi
-if test -r $(LIBTALLOC_SHARED_TARGET_SONAME) ; then \
ln -f -s `basename $(LIBTALLOC_SHARED_TARGET_SONAME)` \
$(DESTDIR)$(LIBDIR)/`basename $(LIBTALLOC_SHARED_TARGET)` ; \
@@ -2062,15 +2103,17 @@ shlibs test_shlibs: @LIBTALLOC_SHARED@
showlibtalloc:
@echo ""
- @echo "LIBTALLOC_SHARED = @LIBTALLOC_SHARED@"
- @echo "LIBTALLOC_STATIC = @LIBTALLOC_STATIC@"
- @echo "LIBTALLOC_LIBS = $(LIBTALLOC_LIBS)"
+ @echo "LIBTALLOC_SHARED = @LIBTALLOC_SHARED@"
+ @echo "LIBTALLOC_STATIC = @LIBTALLOC_STATIC@"
+ @echo "LIBTALLOC_LIBS = $(LIBTALLOC_LIBS)"
@echo ""
- @echo "LIBTALLOC_SHARED_TARGET = $(LIBTALLOC_SHARED_TARGET)"
- @echo "LIBTALLOC_SOVER = $(LIBTALLOC_SOVER)"
- @echo "LIBTALLOC_SHARED TARGET_SONAME = $(LIBTALLOC_SHARED_TARGET_SONAME)"
- @echo "LIBTALLOC_STATIC_TARGET = $(LIBTALLOC_STATIC_TARGET)"
- @echo "LIBTALLOC = $(LIBTALLOC)"
+ @echo "LIBTALLOC_SHARED_TARGET = $(LIBTALLOC_SHARED_TARGET)"
+ @echo "LIBTALLOC_SOVER = $(LIBTALLOC_SOVER)"
+ @echo "LIBTALLOC_FULLVER = $(LIBTALLOC_FULLVER)"
+ @echo "LIBTALLOC_SHARED TARGET_SONAME = $(LIBTALLOC_SHARED_TARGET_SONAME)"
+ @echo "LIBTALLOC_SHARED TARGET_FULLVER = $(LIBTALLOC_SHARED_TARGET_FULLVER)"
+ @echo "LIBTALLOC_STATIC_TARGET = $(LIBTALLOC_STATIC_TARGET)"
+ @echo "LIBTALLOC = $(LIBTALLOC)"
showlibs:: showlibtalloc
@@ -2085,7 +2128,9 @@ LIBTDB_OBJ = $(LIBTDB_OBJ0) $(LIBREPLACE_OBJ)
LIBTDB_SHARED_TARGET=@LIBTDB_SHARED_TARGET@
LIBTDB_SOVER=@LIBTDB_SOVER@
+LIBTDB_FULLVER=@LIBTDB_FULLVER@
LIBTDB_SHARED_TARGET_SONAME=$(LIBTDB_SHARED_TARGET).$(LIBTDB_SOVER)
+LIBTDB_SHARED_TARGET_FULLVER=$(LIBTDB_SHARED_TARGET).$(LIBTDB_FULLVER)
LIBTDB_STATIC_TARGET=@LIBTDB_STATIC_TARGET@
LIBTDB_SYMS=$(srcdir)/exports/libtdb.@SYMSEXT@
LIBTDB_HEADERS=$(srcdir)/@tdbdir@/include/tdb.h
@@ -2093,12 +2138,18 @@ LIBTDB_HEADERS=$(srcdir)/@tdbdir@/include/tdb.h
$(LIBTDB_SYMS): $(LIBTDB_HEADERS)
@$(MKSYMS_SH) $(AWK) $@ $(LIBTDB_HEADERS)
+
$(LIBTDB_SHARED_TARGET_SONAME): $(BINARY_PREREQS) $(LIBTDB_OBJ) $(LIBTDB_SYMS)
@echo Linking shared library $@
@$(SHLD_DSO) $(LIBTDB_OBJ) $(LIBREPLACE_LIBS) $(TDB_DEPS) \
@SONAMEFLAG@`basename $@`
-$(LIBTDB_SHARED_TARGET): $(LIBTDB_SHARED_TARGET_SONAME)
+$(LIBTDB_SHARED_TARGET_FULLVER): $(LIBTDB_SHARED_TARGET_SONAME)
+ @rm -f $@
+ @mv -f $(LIBTDB_SHARED_TARGET_SONAME) $(LIBTDB_SHARED_TARGET_FULLVER)
+ @ln -f -s `basename $(LIBTDB_SHARED_TARGET_FULLVER)` $(LIBTDB_SHARED_TARGET_SONAME)
+
+$(LIBTDB_SHARED_TARGET): $(LIBTDB_SHARED_TARGET_FULLVER)
@rm -f $@
@ln -f -s `basename $(LIBTDB_SHARED_TARGET_SONAME)` $@
@@ -2118,8 +2169,13 @@ cleanlibtdb::
installlibtdb:: installdirs libtdb
@$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(LIBDIR)
- -$(INSTALLLIBCMD_SH) $(LIBTDB_SHARED_TARGET_SONAME) $(DESTDIR)$(LIBDIR)
+ -$(INSTALLLIBCMD_SH) $(LIBTDB_SHARED_TARGET_FULLVER) $(DESTDIR)$(LIBDIR)
@rm -f $(DESTDIR)$(LIBDIR)/`basename $(LIBTDB_SHARED_TARGET)`
+ @rm -f $(DESTDIR)$(LIBDIR)/`basename $(LIBTDB_SHARED_TARGET_SONAME)`
+ -if test -r $(LIBTDB_SHARED_TARGET_FULLVER) ; then \
+ ln -f -s `basename $(LIBTDB_SHARED_TARGET_FULLVER)` \
+ $(DESTDIR)$(LIBDIR)/`basename $(LIBTDB_SHARED_TARGET_SONAME)` ; \
+ fi
-if test -r $(LIBTDB_SHARED_TARGET_SONAME) ; then \
ln -f -s `basename $(LIBTDB_SHARED_TARGET_SONAME)` \
$(DESTDIR)$(LIBDIR)/`basename $(LIBTDB_SHARED_TARGET)` ; \
@@ -2142,15 +2198,17 @@ shlibs test_shlibs: @LIBTDB_SHARED@
showlibtdb:
@echo ""
- @echo "LIBTDB_SHARED = @LIBTDB_SHARED@"
- @echo "LIBTDB_STATIC = @LIBTDB_STATIC@"
- @echo "LIBTDB_LIBS = $(LIBTDB_LIBS)"
+ @echo "LIBTDB_SHARED = @LIBTDB_SHARED@"
+ @echo "LIBTDB_STATIC = @LIBTDB_STATIC@"
+ @echo "LIBTDB_LIBS = $(LIBTDB_LIBS)"
@echo ""
- @echo "LIBTDB_SHARED_TARGET = $(LIBTDB_SHARED_TARGET)"
- @echo "LIBTDB_SOVER = $(LIBTDB_SOVER)"
- @echo "LIBTDB_SHARED TARGET_SONAME = $(LIBTDB_SHARED_TARGET_SONAME)"
- @echo "LIBTDB_STATIC_TARGET = $(LIBTDB_STATIC_TARGET)"
- @echo "LIBTDB = $(LIBTDB)"
+ @echo "LIBTDB_SHARED_TARGET = $(LIBTDB_SHARED_TARGET)"
+ @echo "LIBTDB_SOVER = $(LIBTDB_SOVER)"
+ @echo "LIBTDB_FULLVER = $(LIBTDB_FULLVER)"
+ @echo "LIBTDB_SHARED TARGET_SONAME = $(LIBTDB_SHARED_TARGET_SONAME)"
+ @echo "LIBTDB_SHARED TARGET_FULLVER = $(LIBTDB_SHARED_TARGET_FULLVER)"
+ @echo "LIBTDB_STATIC_TARGET = $(LIBTDB_STATIC_TARGET)"
+ @echo "LIBTDB = $(LIBTDB)"
showlibs:: showlibtdb
@@ -2176,6 +2234,7 @@ LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) \
LIBWBCLIENT_SHARED_TARGET=@LIBWBCLIENT_SHARED_TARGET@
LIBWBCLIENT_SOVER=@LIBWBCLIENT_SOVER@
+LIBWBCLIENT_FULLVER=@LIBWBCLIENT_FULLVER@
LIBWBCLIENT_SHARED_TARGET_SONAME=$(LIBWBCLIENT_SHARED_TARGET).$(LIBWBCLIENT_SOVER)
LIBWBCLIENT_STATIC_TARGET=@LIBWBCLIENT_STATIC_TARGET@
LIBWBCLIENT_SYMS=$(srcdir)/exports/libwbclient.@SYMSEXT@
@@ -2238,6 +2297,7 @@ showlibwbclient:
@echo ""
@echo "LIBWBCLIENT_SHARED_TARGET = $(LIBWBCLIENT_SHARED_TARGET)"
@echo "LIBWBCLIENT_SOVER = $(LIBWBCLIENT_SOVER)"
+ @echo "LIBWBCLIENT_FULLVER = $(LIBWBCLIENT_FULLVER)"
@echo "LIBWBCLIENT_SHARED TARGET_SONAME = $(LIBWBCLIENT_SHARED_TARGET_SONAME)"
@echo "LIBWBCLIENT_STATIC_TARGET = $(LIBWBCLIENT_STATIC_TARGET)"
@echo "LIBWBCLIENT = $(LIBWBCLIENT)"
@@ -2254,6 +2314,7 @@ showlibs:: showlibwbclient
LIBADDNS_SHARED_TARGET=@LIBADDNS_SHARED_TARGET@
LIBADDNS_SOVER=@LIBADDNS_SOVER@
+LIBADDNS_FULLVER=@LIBADDNS_FULLVER@
LIBADDNS_SHARED_TARGET_SONAME=$(LIBADDNS_SHARED_TARGET).$(LIBADDNS_SOVER)
LIBADDNS_STATIC_TARGET=@LIBADDNS_STATIC_TARGET@
LIBADDNS=@LIBADDNS_STATIC@ @LIBADDNS_SHARED@
@@ -2311,6 +2372,7 @@ showlibaddns:
@echo ""
@echo "LIBADDNS_SHARED_TARGET = $(LIBADDNS_SHARED_TARGET)"
@echo "LIBADDNS_SOVER = $(LIBADDNS_SOVER)"
+ @echo "LIBADDNS_FULLVER = $(LIBADDNS_FULLVER)"
@echo "LIBADDNS_SHARED TARGET_SONAME = $(LIBADDNS_SHARED_TARGET_SONAME)"
@echo "LIBADDNS_STATIC_TARGET = $(LIBADDNS_STATIC_TARGET)"
@echo "LIBADDNS = $(LIBADDNS)"
@@ -2361,6 +2423,7 @@ LIBNETAPI_OBJ = $(LIBNETAPI_OBJ0) $(LIBNET_OBJ) \
LIBNETAPI_SHARED_TARGET=@LIBNETAPI_SHARED_TARGET@
LIBNETAPI_SOVER=@LIBNETAPI_SOVER@
+LIBNETAPI_FULLVER=@LIBNETAPI_FULLVER@
LIBNETAPI_SHARED_TARGET_SONAME=$(LIBNETAPI_SHARED_TARGET).$(LIBNETAPI_SOVER)
LIBNETAPI_STATIC_TARGET=@LIBNETAPI_STATIC_TARGET@
LIBNETAPI_SYMS=$(srcdir)/exports/libnetapi.@SYMSEXT@
@@ -2425,6 +2488,7 @@ showlibnetapi:
@echo ""
@echo "LIBNETAPI_SHARED_TARGET = $(LIBNETAPI_SHARED_TARGET)"
@echo "LIBNETAPI_SOVER = $(LIBNETAPI_SOVER)"
+ @echo "LIBNETAPI_FULLVER = $(LIBNETAPI_FULLVER)"
@echo "LIBNETAPI_SHARED TARGET_SONAME = $(LIBNETAPI_SHARED_TARGET_SONAME)"
@echo "LIBNETAPI_STATIC_TARGET = $(LIBNETAPI_STATIC_TARGET)"
@echo "LIBNETAPI = $(LIBNETAPI)"
@@ -2439,6 +2503,7 @@ showlibs:: showlibnetapi
LIBSMBCLIENT_SHARED_TARGET=@LIBSMBCLIENT_SHARED_TARGET@
LIBSMBCLIENT_SOVER=@LIBSMBCLIENT_SOVER@
+LIBSMBCLIENT_FULLVER=@LIBSMBCLIENT_FULLVER@
LIBSMBCLIENT_SHARED_TARGET_SONAME=$(LIBSMBCLIENT_SHARED_TARGET).$(LIBSMBCLIENT_SOVER)
LIBSMBCLIENT_STATIC_TARGET=@LIBSMBCLIENT_STATIC_TARGET@
LIBSMBCLIENT=@LIBSMBCLIENT_STATIC@ @LIBSMBCLIENT_SHARED@
@@ -2507,6 +2572,7 @@ showlibsmbclient:
@echo ""
@echo "LIBSMBCLIENT_SHARED_TARGET = $(LIBSMBCLIENT_SHARED_TARGET)"
@echo "LIBSMBCLIENT_SOVER = $(LIBSMBCLIENT_SOVER)"
+ @echo "LIBSMBCLIENT_FULLVER = $(LIBSMBCLIENT_FULLVER)"
@echo "LIBSMBCLIENT_SHARED TARGET_SONAME = $(LIBSMBCLIENT_SHARED_TARGET_SONAME)"
@echo "LIBSMBCLIENT_STATIC_TARGET = $(LIBSMBCLIENT_STATIC_TARGET)"
@echo "LIBSMBCLIENT = $(LIBSMBCLIENT)"
@@ -2519,12 +2585,13 @@ showlibs:: showlibsmbclient
#
#-------------------------------------------------------------------
-LIBSMBSHAREMODES_OBJ0 = libsmb/smb_share_modes.o
+LIBSMBSHAREMODES_OBJ0 = libsmb/smb_share_modes.o ../lib/ccan/hash/hash.o
LIBSMBSHAREMODES_OBJ = $(LIBSMBSHAREMODES_OBJ0)
LIBSMBSHAREMODES_SHARED_TARGET=@LIBSMBSHAREMODES_SHARED_TARGET@
LIBSMBSHAREMODES_SOVER=@LIBSMBSHAREMODES_SOVER@
+LIBSMBSHAREMODES_FULLVER=@LIBSMBSHAREMODES_FULLVER@
LIBSMBSHAREMODES_SHARED_TARGET_SONAME=$(LIBSMBSHAREMODES_SHARED_TARGET).$(LIBSMBSHAREMODES_SOVER)
LIBSMBSHAREMODES_STATIC_TARGET=@LIBSMBSHAREMODES_STATIC_TARGET@
LIBSMBSHAREMODES=@LIBSMBSHAREMODES_STATIC@ @LIBSMBSHAREMODES_SHARED@
@@ -2589,6 +2656,7 @@ showlibsmbsharemodes:
@echo ""
@echo "LIBSMBSHAREMODES_SHARED_TARGET = $(LIBSMBSHAREMODES_SHARED_TARGET)"
@echo "LIBSMBSHAREMODES_SOVER = $(LIBSMBSHAREMODES_SOVER)"
+ @echo "LIBSMBSHAREMODES_FULLVER = $(LIBSMBSHAREMODES_FULLVER)"
@echo "LIBSMBSHAREMODES_SHARED TARGET_SONAME = $(LIBSMBSHAREMODES_SHARED_TARGET_SONAME)"
@echo "LIBSMBSHAREMODES_STATIC_TARGET = $(LIBSMBSHAREMODES_STATIC_TARGET)"
@echo "LIBSMBSHAREMODES = $(LIBSMBSHAREMODES)"
@@ -2952,6 +3020,10 @@ bin/gpfs.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_GPFS_OBJ)
@echo "Building plugin $@"
@$(SHLD_MODULE) $(VFS_GPFS_OBJ)
+bin/gpfs_hsm_notify.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_GPFS_HSM_NOTIFY_OBJ)
+ @echo "Building plugin $@"
+ @$(SHLD_MODULE) $(VFS_GPFS_HSM_NOTIFY_OBJ)
+
bin/notify_fam.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_NOTIFY_FAM_OBJ)
@echo "Building plugin $@"
@$(SHLD_MODULE) $(VFS_NOTIFY_FAM_OBJ) @SMB_FAM_LIBS@
@@ -3049,17 +3121,17 @@ bin/wbinfo@EXEEXT@: $(BINARY_PREREQS) $(WBINFO_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(
$(LIBWBCLIENT_LIBS)
bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \
- $(LIB_NONSMBD_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT)
+ $(LIB_NONSMBD_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT) $(ZLIB_LIBS)
@echo Linking $@
@$(CC) -o $@ $(LDFLAGS) $(DYNEXP) $(NTLM_AUTH_OBJ) \
- $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBS) \
+ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBS) $(ZLIB_LIBS) \
$(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \
$(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(LIBWBCLIENT_LIBS) @INIPARSERLIBS@
-bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) $(LIBCLI_LDAP_NDR_OBJ) $(LIBTALLOC) $(LIBWBCLIENT) $(LIBTDB)
+bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) $(LIBCLI_LDAP_NDR_OBJ) $(LIBTALLOC) $(LIBWBCLIENT) $(LIBTDB) $(ZLIB_LIBS)
@echo "Linking shared library $@"
@$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) $(LIBCLI_LDAP_NDR_OBJ) -lpam $(DYNEXP) \
- $(LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \
+ $(LIBS) $(LDAP_LIBS) $(NSCD_LIBS) $(ZLIB_LIBS) \
$(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(LIBWBCLIENT_LIBS)
bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) $(LIBTALLOC) $(LIBTDB)
@@ -3291,16 +3363,13 @@ uninstallpammodules::
rm -f "$(DESTDIR)/$(PAMMODULESDIR)/$${module}.@SHLIBEXT@"; \
done
-# Toplevel clean files
-TOPFILES=dynconfig.o localedir.o
-
cleanlibs::
-rm -f ../lib/*/*.o ../lib/*/*/*.o \
../lib/*/*.ho \
../libcli/*.o ../libcli/*/*.o ../libcli/*/*/*.o \
../librpc/*/*.o \
../libgpo/*.o ../libgpo/*/*.o \
- ../libds/*.o ../libds/*/*.o
+ ../libds/*.o ../libds/*/*.o ../dynconfig/*.o
clean:: cleanlibs
-rm -f include/build_env.h
@@ -3339,12 +3408,12 @@ realclean:: clean
distclean:: realclean
-rm -f smbadduser
- -rm -f include/config.h Makefile
+ -rm -f include/autoconf/config.h Makefile
-rm -f config.status config.cache so_locations
-rm -rf .deps TAGS
realdistclean:: distclean
- -rm -f include/config.h.in
+ -rm -f include/autoconf/config.h.in
-rm -f include/version.h
-rm -f configure
diff --git a/source3/auth/auth_builtin.c b/source3/auth/auth_builtin.c
index afe71ee2a60..cfe89495a01 100644
--- a/source3/auth/auth_builtin.c
+++ b/source3/auth/auth_builtin.c
@@ -57,7 +57,7 @@ static NTSTATUS auth_init_guest(struct auth_context *auth_context, const char *o
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -117,7 +117,7 @@ static NTSTATUS auth_init_name_to_ntstatus(struct auth_context *auth_context, co
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -171,7 +171,7 @@ static NTSTATUS auth_init_fixed_challenge(struct auth_context *auth_context, con
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c
index 5824d91a0a2..c18a81ab579 100644
--- a/source3/auth/auth_domain.c
+++ b/source3/auth/auth_domain.c
@@ -26,6 +26,7 @@
#include "rpc_client/cli_netlogon.h"
#include "secrets.h"
#include "passdb.h"
+#include "libsmb/libsmb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
@@ -68,7 +69,7 @@ void attempt_machine_password_change(void)
DEBUG(0,("attempt_machine_password_change: unable to lock "
"the machine account password for machine %s in "
"domain %s.\n",
- global_myname(), lp_workgroup() ));
+ lp_netbios_name(), lp_workgroup() ));
return;
}
@@ -76,7 +77,7 @@ void attempt_machine_password_change(void)
trust_passwd_hash, &lct, NULL)) {
DEBUG(0,("attempt_machine_password_change: unable to read the "
"machine account password for %s in domain %s.\n",
- global_myname(), lp_workgroup()));
+ lp_netbios_name(), lp_workgroup()));
TALLOC_FREE(lock);
return;
}
@@ -145,7 +146,7 @@ static NTSTATUS connect_to_domain_password_server(struct cli_state **cli,
}
/* Attempt connection */
- result = cli_full_connection(cli, global_myname(), dc_name, dc_ss, 0,
+ result = cli_full_connection(cli, lp_netbios_name(), dc_name, dc_ss, 0,
"IPC$", "IPC", "", "", "", 0, Undefined);
if (!NT_STATUS_IS_OK(result)) {
@@ -218,7 +219,7 @@ machine %s. Error was : %s.\n", dc_name, nt_errstr(result)));
result = rpccli_netlogon_setup_creds(netlogon_pipe,
dc_name, /* server name */
domain, /* domain */
- global_myname(), /* client name */
+ lp_netbios_name(), /* client name */
account_name, /* machine account name */
machine_pwd,
sec_chan_type,
@@ -418,7 +419,7 @@ static NTSTATUS auth_init_ntdomain(struct auth_context *auth_context, const char
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -524,7 +525,7 @@ static NTSTATUS auth_init_trustdomain(struct auth_context *auth_context, const c
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/auth/auth_netlogond.c b/source3/auth/auth_netlogond.c
index 8e332c8e5aa..7fb037457e7 100644
--- a/source3/auth/auth_netlogond.c
+++ b/source3/auth/auth_netlogond.c
@@ -133,7 +133,7 @@ static NTSTATUS netlogond_validate(TALLOC_CTX *mem_ctx,
p, p,
user_info->logon_parameters, /* flags such as 'allow
* workstation logon' */
- global_myname(), /* server name */
+ lp_netbios_name(), /* server name */
user_info->client.account_name, /* user name logging on. */
user_info->client.domain_name, /* domain name */
user_info->workstation_name, /* workstation name */
@@ -234,7 +234,7 @@ static NTSTATUS mymachinepw(uint8_t pwd[16])
DEBUG(10, ("default_nc = %s\n", default_nc));
myname = talloc_asprintf_strupper_m(talloc_tos(), "%s$",
- global_myname());
+ lp_netbios_name());
if (myname == NULL) {
DEBUG(10, ("talloc failed\n"));
status = NT_STATUS_NO_MEMORY;
@@ -375,8 +375,8 @@ static NTSTATUS check_netlogond_security(const struct auth_context *auth_context
dump_data(10, machine_password, 16);
status = rpccli_netlogon_setup_creds(
- p, global_myname(), lp_workgroup(), global_myname(),
- global_myname(), machine_password, SEC_CHAN_BDC, &neg_flags);
+ p, lp_netbios_name(), lp_workgroup(), lp_netbios_name(),
+ lp_netbios_name(), machine_password, SEC_CHAN_BDC, &neg_flags);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("rpccli_netlogon_setup_creds failed: %s\n",
@@ -429,7 +429,7 @@ static NTSTATUS auth_init_netlogond(struct auth_context *auth_context,
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
index 58974210dd9..1fecc0988ea 100644
--- a/source3/auth/auth_ntlmssp.c
+++ b/source3/auth/auth_ntlmssp.c
@@ -184,13 +184,13 @@ NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state)
struct auth_ntlmssp_state *ans;
struct auth_context *auth_context;
- if ((enum server_types)lp_server_role() == ROLE_STANDALONE) {
+ if ((enum server_role)lp_server_role() == ROLE_STANDALONE) {
is_standalone = true;
} else {
is_standalone = false;
}
- netbios_name = global_myname();
+ netbios_name = lp_netbios_name();
netbios_domain = lp_workgroup();
/* This should be a 'netbios domain -> DNS domain' mapping */
dns_domain = get_mydnsdomname(talloc_tos());
diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c
index 8d2300dda74..7faa8de0275 100644
--- a/source3/auth/auth_sam.c
+++ b/source3/auth/auth_sam.c
@@ -22,7 +22,6 @@
#include "includes.h"
#include "auth.h"
-#include "../libcli/auth/libcli_auth.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
@@ -45,7 +44,7 @@ static NTSTATUS auth_init_sam_ignoredomain(struct auth_context *auth_context, co
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -109,7 +108,7 @@ static NTSTATUS auth_init_sam(struct auth_context *auth_context, const char *par
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/auth/auth_samba4.c b/source3/auth/auth_samba4.c
new file mode 100644
index 00000000000..03b7884068d
--- /dev/null
+++ b/source3/auth/auth_samba4.c
@@ -0,0 +1,118 @@
+/*
+ Unix SMB/CIFS implementation.
+ Authenticate against Samba4's auth subsystem
+ Copyright (C) Volker Lendecke 2008
+ Copyright (C) Andrew Bartlett 2010
+
+ 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 "source3/include/auth.h"
+#include "source4/auth/auth.h"
+#include "auth/auth_sam_reply.h"
+#include "param/param.h"
+#include "source4/lib/events/events.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_AUTH
+
+static NTSTATUS check_samba4_security(const struct auth_context *auth_context,
+ void *my_private_data,
+ TALLOC_CTX *mem_ctx,
+ const struct auth_usersupplied_info *user_info,
+ struct auth_serversupplied_info **server_info)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct netr_SamInfo3 *info3 = NULL;
+ NTSTATUS nt_status;
+ struct auth_user_info_dc *user_info_dc;
+ struct auth4_context *auth4_context;
+ struct loadparm_context *lp_ctx;
+
+ lp_ctx = loadparm_init_s3(frame, loadparm_s3_context());
+ if (lp_ctx == NULL) {
+ DEBUG(10, ("loadparm_init_s3 failed\n"));
+ talloc_free(frame);
+ return NT_STATUS_INVALID_SERVER_STATE;
+ }
+
+ /* We create a private tevent context here to avoid nested loops in
+ * the s3 one, as that may not be expected */
+ nt_status = auth_context_create(mem_ctx,
+ s4_event_context_init(frame), NULL,
+ lp_ctx,
+ &auth4_context);
+ NT_STATUS_NOT_OK_RETURN(nt_status);
+
+ nt_status = auth_context_set_challenge(auth4_context, auth_context->challenge.data, "auth_samba4");
+ NT_STATUS_NOT_OK_RETURN_AND_FREE(nt_status, auth4_context);
+
+ nt_status = auth_check_password(auth4_context, auth4_context, user_info, &user_info_dc);
+ NT_STATUS_NOT_OK_RETURN_AND_FREE(nt_status, auth4_context);
+
+ nt_status = auth_convert_user_info_dc_saminfo3(mem_ctx,
+ user_info_dc,
+ &info3);
+ if (NT_STATUS_IS_OK(nt_status)) {
+ /* We need the strings from the server_info to be valid as long as the info3 is around */
+ talloc_steal(info3, user_info_dc);
+ }
+ talloc_free(auth4_context);
+
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ goto done;
+ }
+
+ nt_status = make_server_info_info3(mem_ctx, user_info->client.account_name,
+ user_info->mapped.domain_name, server_info,
+ info3);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ DEBUG(10, ("make_server_info_info3 failed: %s\n",
+ nt_errstr(nt_status)));
+ TALLOC_FREE(frame);
+ return nt_status;
+ }
+
+ nt_status = NT_STATUS_OK;
+
+ done:
+ TALLOC_FREE(frame);
+ return nt_status;
+}
+
+/* module initialisation */
+static NTSTATUS auth_init_samba4(struct auth_context *auth_context,
+ const char *param,
+ auth_methods **auth_method)
+{
+ struct auth_methods *result;
+
+ result = talloc_zero(auth_context, struct auth_methods);
+ if (result == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ result->name = "samba4";
+ result->auth = check_samba4_security;
+
+ *auth_method = result;
+ return NT_STATUS_OK;
+}
+
+NTSTATUS auth_samba4_init(void)
+{
+ smb_register_auth(AUTH_INTERFACE_VERSION, "samba4",
+ auth_init_samba4);
+ return NT_STATUS_OK;
+}
diff --git a/source3/auth/auth_script.c b/source3/auth/auth_script.c
index ad973106b1c..4432ff4aecc 100644
--- a/source3/auth/auth_script.c
+++ b/source3/auth/auth_script.c
@@ -74,32 +74,32 @@ static NTSTATUS script_check_user_credentials(const struct auth_context *auth_co
return NT_STATUS_NO_MEMORY;
}
- safe_strcpy( secret_str, user_info->mapped.domain_name, secret_str_len - 1);
- safe_strcat( secret_str, "\n", secret_str_len - 1);
- safe_strcat( secret_str, user_info->client.account_name, secret_str_len - 1);
- safe_strcat( secret_str, "\n", secret_str_len - 1);
+ strlcpy( secret_str, user_info->mapped.domain_name, secret_str_len);
+ strlcat( secret_str, "\n", secret_str_len);
+ strlcat( secret_str, user_info->client.account_name, secret_str_len);
+ strlcat( secret_str, "\n", secret_str_len);
for (i = 0; i < 8; i++) {
slprintf(&hex_str[i*2], 3, "%02X", auth_context->challenge.data[i]);
}
- safe_strcat( secret_str, hex_str, secret_str_len - 1);
- safe_strcat( secret_str, "\n", secret_str_len - 1);
+ strlcat( secret_str, hex_str, secret_str_len);
+ strlcat( secret_str, "\n", secret_str_len);
if (user_info->password.response.lanman.data) {
for (i = 0; i < 24; i++) {
slprintf(&hex_str[i*2], 3, "%02X", user_info->password.response.lanman.data[i]);
}
- safe_strcat( secret_str, hex_str, secret_str_len - 1);
+ strlcat( secret_str, hex_str, secret_str_len);
}
- safe_strcat( secret_str, "\n", secret_str_len - 1);
+ strlcat( secret_str, "\n", secret_str_len);
if (user_info->password.response.nt.data) {
for (i = 0; i < 24; i++) {
slprintf(&hex_str[i*2], 3, "%02X", user_info->password.response.nt.data[i]);
}
- safe_strcat( secret_str, hex_str, secret_str_len - 1);
+ strlcat( secret_str, hex_str, secret_str_len);
}
- safe_strcat( secret_str, "\n", secret_str_len - 1);
+ strlcat( secret_str, "\n", secret_str_len);
DEBUG(10,("script_check_user_credentials: running %s with parameters:\n%s\n",
script, secret_str ));
@@ -124,7 +124,7 @@ static NTSTATUS auth_init_script(struct auth_context *auth_context, const char *
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index 5dc8ea7f04b..da380db01ad 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -22,6 +22,7 @@
#include "auth.h"
#include "system/passwd.h"
#include "smbd/smbd.h"
+#include "libsmb/libsmb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
@@ -43,12 +44,6 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
struct named_mutex *mutex = NULL;
NTSTATUS status;
- if (!(cli = cli_initialise()))
- return NULL;
-
- /* security = server just can't function with spnego */
- cli->use_spnego = False;
-
pserver = talloc_strdup(mem_ctx, lp_passwordserver());
p = pserver;
@@ -63,12 +58,18 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
}
strupper_m(desthost);
+ if (strequal(desthost, myhostname())) {
+ DEBUG(1,("Password server loop - disabling "
+ "password server %s\n", desthost));
+ continue;
+ }
+
if(!resolve_name( desthost, &dest_ss, 0x20, false)) {
DEBUG(1,("server_cryptkey: Can't resolve address for %s\n",desthost));
continue;
}
- if (ismyaddr((struct sockaddr *)&dest_ss)) {
+ if (ismyaddr((struct sockaddr *)(void *)&dest_ss)) {
DEBUG(1,("Password server loop - disabling password server %s\n",desthost));
continue;
}
@@ -80,11 +81,11 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
mutex = grab_named_mutex(talloc_tos(), desthost, 10);
if (mutex == NULL) {
- cli_shutdown(cli);
return NULL;
}
- status = cli_connect(cli, desthost, &dest_ss);
+ status = cli_connect_nb(desthost, &dest_ss, 0, 0x20,
+ lp_netbios_name(), Undefined, &cli);
if (NT_STATUS_IS_OK(status)) {
DEBUG(3,("connected to password server %s\n",desthost));
connected_ok = True;
@@ -97,21 +98,11 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
if (!connected_ok) {
DEBUG(0,("password server not available\n"));
- cli_shutdown(cli);
return NULL;
}
- if (!attempt_netbios_session_request(&cli, global_myname(),
- desthost, &dest_ss)) {
- TALLOC_FREE(mutex);
- DEBUG(1,("password server fails session request\n"));
- cli_shutdown(cli);
- return NULL;
- }
-
- if (strequal(desthost,myhostname())) {
- exit_server_cleanly("Password server loop!");
- }
+ /* security = server just can't function with spnego */
+ cli->use_spnego = False;
DEBUG(3,("got session\n"));
@@ -258,7 +249,7 @@ static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_conte
/* The return must be allocated on the caller's mem_ctx, as our own will be
destoyed just after the call. */
- return data_blob_talloc((TALLOC_CTX *)auth_context, cli->secblob.data,8);
+ return data_blob_talloc(discard_const_p(TALLOC_CTX, auth_context), cli->secblob.data,8);
} else {
return data_blob_null;
}
@@ -341,7 +332,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
baduser = talloc_asprintf(mem_ctx,
"%s%s",
INVALID_USER_PREFIX,
- global_myname());
+ lp_netbios_name());
if (!baduser) {
return NT_STATUS_NO_MEMORY;
}
@@ -426,7 +417,7 @@ use this machine as the password server.\n"));
}
/* if logged in as guest then reject */
- if ((SVAL(cli->inbuf,smb_vwv2) & 1) != 0) {
+ if (cli->is_guestlogin) {
DEBUG(1,("password server %s gave us guest only\n", cli->desthost));
nt_status = NT_STATUS_LOGON_FAILURE;
}
@@ -461,7 +452,7 @@ static NTSTATUS auth_init_smbserver(struct auth_context *auth_context, const cha
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/auth/auth_unix.c b/source3/auth/auth_unix.c
index 8f9eacf76b3..36956986c59 100644
--- a/source3/auth/auth_unix.c
+++ b/source3/auth/auth_unix.c
@@ -20,7 +20,6 @@
#include "includes.h"
#include "auth.h"
#include "system/passwd.h"
-#include "../librpc/gen_ndr/samr.h"
#include "smbd/globals.h"
#undef DBGC_CLASS
@@ -74,7 +73,7 @@ static NTSTATUS auth_init_unix(struct auth_context *auth_context, const char* pa
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index b7ec9fff704..64c290eb048 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -23,7 +23,6 @@
#include "includes.h"
#include "auth.h"
-#include "smbd/globals.h"
#include "../libcli/auth/libcli_auth.h"
#include "../lib/crypto/arcfour.h"
#include "rpc_client/init_lsa.h"
@@ -520,7 +519,7 @@ NTSTATUS create_local_token(TALLOC_CTX *mem_ctx,
t = session_info->security_token;
- ids = TALLOC_ARRAY(talloc_tos(), struct wbcUnixId,
+ ids = talloc_array(talloc_tos(), struct wbcUnixId,
t->num_sids);
if (ids == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -669,7 +668,7 @@ NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
return NT_STATUS_NO_MEMORY;
}
- status = samu_to_SamInfo3(result, sampass, global_myname(),
+ status = samu_to_SamInfo3(result, sampass, lp_netbios_name(),
&result->info3, &result->extra);
TALLOC_FREE(sampass);
if (!NT_STATUS_IS_OK(status)) {
@@ -759,7 +758,7 @@ static NTSTATUS make_new_server_info_guest(struct auth_serversupplied_info **ses
struct auth_serversupplied_info *server_info;
static const char zeros[16] = {0};
const char *guest_account = lp_guestaccount();
- const char *domain = global_myname();
+ const char *domain = lp_netbios_name();
struct netr_SamInfo3 info3;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
@@ -774,6 +773,8 @@ static NTSTATUS make_new_server_info_guest(struct auth_serversupplied_info **ses
status = get_guest_info3(tmp_ctx, &info3);
if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("get_guest_info3 failed with %s\n",
+ nt_errstr(status)));
goto done;
}
@@ -783,6 +784,8 @@ static NTSTATUS make_new_server_info_guest(struct auth_serversupplied_info **ses
&server_info,
&info3);
if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("make_server_info_info3 failed with %s\n",
+ nt_errstr(status)));
goto done;
}
@@ -794,8 +797,8 @@ static NTSTATUS make_new_server_info_guest(struct auth_serversupplied_info **ses
status = create_local_token(tmp_ctx, server_info, NULL, session_info);
TALLOC_FREE(server_info);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(10, ("create_local_token failed: %s\n",
- nt_errstr(status)));
+ DEBUG(0, ("create_local_token failed: %s\n",
+ nt_errstr(status)));
goto done;
}
talloc_steal(NULL, *session_info);
@@ -812,7 +815,7 @@ static NTSTATUS make_new_server_info_guest(struct auth_serversupplied_info **ses
status = NT_STATUS_OK;
done:
TALLOC_FREE(tmp_ctx);
- return NT_STATUS_OK;
+ return status;
}
/***************************************************************************
@@ -908,7 +911,7 @@ struct auth_serversupplied_info *copy_serverinfo(TALLOC_CTX *mem_ctx,
dst->utok.gid = src->utok.gid;
dst->utok.ngroups = src->utok.ngroups;
if (src->utok.ngroups != 0) {
- dst->utok.groups = (gid_t *)TALLOC_MEMDUP(
+ dst->utok.groups = (gid_t *)talloc_memdup(
dst, src->utok.groups,
sizeof(gid_t)*dst->utok.ngroups);
} else {
diff --git a/source3/auth/auth_wbc.c b/source3/auth/auth_wbc.c
index 61500402293..1b70042d909 100644
--- a/source3/auth/auth_wbc.c
+++ b/source3/auth/auth_wbc.c
@@ -182,7 +182,7 @@ static NTSTATUS auth_init_wbc(struct auth_context *auth_context, const char *par
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/auth/auth_winbind.c b/source3/auth/auth_winbind.c
index 21433535415..d4ace2c9193 100644
--- a/source3/auth/auth_winbind.c
+++ b/source3/auth/auth_winbind.c
@@ -142,7 +142,7 @@ static NTSTATUS auth_init_winbind(struct auth_context *auth_context, const char
{
struct auth_methods *result;
- result = TALLOC_ZERO_P(auth_context, struct auth_methods);
+ result = talloc_zero(auth_context, struct auth_methods);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/auth/check_samsec.c b/source3/auth/check_samsec.c
index c4bcda4b1b7..2d3cb657859 100644
--- a/source3/auth/check_samsec.c
+++ b/source3/auth/check_samsec.c
@@ -531,7 +531,7 @@ NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
goto done;
}
- info3 = TALLOC_ZERO_P(mem_ctx, struct netr_SamInfo3);
+ info3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
if (info3 == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
diff --git a/source3/auth/pass_check.c b/source3/auth/pass_check.c
index a7a1c3d8f5d..714cc968a78 100644
--- a/source3/auth/pass_check.c
+++ b/source3/auth/pass_check.c
@@ -502,8 +502,8 @@ it assumes the string starts lowercased
****************************************************************************/
static NTSTATUS string_combinations2(char *s, int offset,
NTSTATUS (*fn)(const char *s,
- void *private_data),
- int N, void *private_data)
+ const void *private_data),
+ int N, const void *private_data)
{
int len = strlen(s);
int i;
@@ -540,8 +540,8 @@ it assumes the string starts lowercased
****************************************************************************/
static NTSTATUS string_combinations(char *s,
NTSTATUS (*fn)(const char *s,
- void *private_data),
- int N, void *private_data)
+ const void *private_data),
+ int N, const void *private_data)
{
int n;
NTSTATUS nt_status;
@@ -558,7 +558,7 @@ static NTSTATUS string_combinations(char *s,
/****************************************************************************
core of password checking routine
****************************************************************************/
-static NTSTATUS password_check(const char *password, void *private_data)
+static NTSTATUS password_check(const char *password, const void *private_data)
{
#ifdef WITH_PAM
const char *rhost = (const char *)private_data;
@@ -840,7 +840,7 @@ NTSTATUS pass_check(const struct passwd *pass,
#endif /* defined(WITH_PAM) */
/* try it as it came to us */
- nt_status = password_check(password, (void *)rhost);
+ nt_status = password_check(password, (const void *)rhost);
if NT_STATUS_IS_OK(nt_status) {
return (nt_status);
} else if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD)) {
@@ -868,7 +868,7 @@ NTSTATUS pass_check(const struct passwd *pass,
/* try all lowercase if it's currently all uppercase */
if (strhasupper(pass2)) {
strlower_m(pass2);
- nt_status = password_check(pass2, (void *)rhost);
+ nt_status = password_check(pass2, (const void *)rhost);
if (NT_STATUS_IS_OK(nt_status)) {
return (nt_status);
}
@@ -883,7 +883,7 @@ NTSTATUS pass_check(const struct passwd *pass,
strlower_m(pass2);
nt_status = string_combinations(pass2, password_check, level,
- (void *)rhost);
+ (const void *)rhost);
if (NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
diff --git a/source3/auth/proto.h b/source3/auth/proto.h
index b88bb8c6265..46846ac9074 100644
--- a/source3/auth/proto.h
+++ b/source3/auth/proto.h
@@ -1,3 +1,37 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Password and authentication handling
+ *
+ * Copyright (C) Andrew Tridgell 1992-2001
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-2000
+ * Copyright (C) Jeremy Allison 1997-2001
+ * Copyright (C) John H Terpsta 1999-2001
+ * Copyright (C) Tim Potter 2000
+ * Copyright (C) Andrew Bartlett 2001-2003
+ * Copyright (C) Jelmer Vernooij 2002
+ * Copyright (C) Rafal Szczesniak 2002
+ * Copyright (C) Gerald Carter 2003
+ * Copyright (C) Volker Lendecke 2006,2010
+ * Copyright (C) Michael Adam 2007
+ * Copyright (C) Dan Sledz 2009
+ * Copyright (C) Simo Sorce 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _AUTH_PROTO_H_
+#define _AUTH_PROTO_H_
/* The following definitions come from auth/auth.c */
@@ -270,3 +304,5 @@ NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
bool mapped_to_guest, bool username_was_mapped,
DATA_BLOB *session_key,
struct auth_serversupplied_info **session_info);
+
+#endif /* _AUTH_PROTO_H_ */
diff --git a/source3/auth/server_info.c b/source3/auth/server_info.c
index 440e45c8e5c..a53e556d283 100644
--- a/source3/auth/server_info.c
+++ b/source3/auth/server_info.c
@@ -45,7 +45,7 @@ struct auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx)
{
struct auth_serversupplied_info *result;
- result = TALLOC_ZERO_P(mem_ctx, struct auth_serversupplied_info);
+ result = talloc_zero(mem_ctx, struct auth_serversupplied_info);
if (result == NULL) {
DEBUG(0, ("talloc failed\n"));
return NULL;
diff --git a/source3/auth/server_info_sam.c b/source3/auth/server_info_sam.c
index 5fd78a30fa7..261e3de8f2d 100644
--- a/source3/auth/server_info_sam.c
+++ b/source3/auth/server_info_sam.c
@@ -23,8 +23,6 @@
#include "includes.h"
#include "auth.h"
-#include "smbd/globals.h"
-#include "../libcli/auth/libcli_auth.h"
#include "nsswitch/winbind_client.h"
#include "passdb.h"
@@ -51,7 +49,7 @@ static bool is_our_machine_account(const char *username)
return false;
}
truncname[ulen-1] = '\0';
- ret = strequal(truncname, global_myname());
+ ret = strequal(truncname, lp_netbios_name());
SAFE_FREE(truncname);
return ret;
}
@@ -79,7 +77,7 @@ NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
return NT_STATUS_NO_SUCH_USER;
}
- status = samu_to_SamInfo3(result, sampass, global_myname(),
+ status = samu_to_SamInfo3(result, sampass, lp_netbios_name(),
&result->info3, &result->extra);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(result);
diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c
index da4745d8339..22df21f5ed4 100644
--- a/source3/auth/token_util.c
+++ b/source3/auth/token_util.c
@@ -31,7 +31,6 @@
#include "../librpc/gen_ndr/netlogon.h"
#include "../libcli/security/security.h"
#include "../lib/util/util_pw.h"
-#include "lib/winbind_util.h"
#include "passdb.h"
#include "lib/privileges.h"
@@ -339,7 +338,7 @@ struct security_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
DEBUG(10, ("Create local NT token for %s\n",
sid_string_dbg(user_sid)));
- if (!(result = TALLOC_ZERO_P(mem_ctx, struct security_token))) {
+ if (!(result = talloc_zero(mem_ctx, struct security_token))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
@@ -694,9 +693,9 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
num_group_sids = getgroups_num_group_sids;
if (num_group_sids) {
- group_sids = TALLOC_ARRAY(tmp_ctx, struct dom_sid, num_group_sids);
+ group_sids = talloc_array(tmp_ctx, struct dom_sid, num_group_sids);
if (group_sids == NULL) {
- DEBUG(1, ("TALLOC_ARRAY failed\n"));
+ DEBUG(1, ("talloc_array failed\n"));
result = NT_STATUS_NO_MEMORY;
goto done;
}
@@ -733,9 +732,9 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
}
num_group_sids = 1;
- group_sids = TALLOC_ARRAY(tmp_ctx, struct dom_sid, num_group_sids);
+ group_sids = talloc_array(tmp_ctx, struct dom_sid, num_group_sids);
if (group_sids == NULL) {
- DEBUG(1, ("TALLOC_ARRAY failed\n"));
+ DEBUG(1, ("talloc_array failed\n"));
result = NT_STATUS_NO_MEMORY;
goto done;
}
diff --git a/source3/auth/wscript_build b/source3/auth/wscript_build
index 8bf20515261..74d870fc1b5 100644
--- a/source3/auth/wscript_build
+++ b/source3/auth/wscript_build
@@ -16,16 +16,20 @@ AUTH_SRC = '''auth.c
bld.SAMBA3_SUBSYSTEM('TOKEN_UTIL',
source='token_util.c',
+ deps='samba-util',
vars=locals())
+bld.SAMBA3_SUBSYSTEM('USER_UTIL',
+ source='user_util.c',
+ deps='TOKEN_UTIL')
+
bld.SAMBA3_SUBSYSTEM('AUTH_COMMON',
source='''auth_util.c
- user_util.c
check_samsec.c
server_info.c
server_info_sam.c
- user_info.c
- user_util.c''',
+ user_info.c''',
+ deps='TOKEN_UTIL DCUTIL USER_UTIL',
vars=locals())
bld.SAMBA3_SUBSYSTEM('auth',
@@ -36,6 +40,7 @@ bld.SAMBA3_SUBSYSTEM('auth',
bld.SAMBA3_MODULE('auth_sam',
subsystem='auth',
source=AUTH_SAM_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('auth_sam'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('auth_sam'))
@@ -43,6 +48,7 @@ bld.SAMBA3_MODULE('auth_sam',
bld.SAMBA3_MODULE('auth_unix',
subsystem='auth',
source=AUTH_UNIX_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('auth_unix'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('auth_unix'))
@@ -50,6 +56,7 @@ bld.SAMBA3_MODULE('auth_unix',
bld.SAMBA3_MODULE('auth_winbind',
subsystem='auth',
source=AUTH_WINBIND_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('auth_winbind'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('auth_winbind'))
@@ -57,6 +64,7 @@ bld.SAMBA3_MODULE('auth_winbind',
bld.SAMBA3_MODULE('auth_wbc',
subsystem='auth',
source=AUTH_WBC_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('auth_wbc'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('auth_wbc'))
@@ -64,6 +72,7 @@ bld.SAMBA3_MODULE('auth_wbc',
bld.SAMBA3_MODULE('auth_server',
subsystem='auth',
source=AUTH_SERVER_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('auth_server'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('auth_server'))
@@ -79,6 +88,7 @@ bld.SAMBA3_MODULE('auth_domain',
bld.SAMBA3_MODULE('auth_builtin',
subsystem='auth',
source=AUTH_BUILTIN_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('auth_builtin'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('auth_builtin'))
@@ -96,3 +106,12 @@ bld.SAMBA3_MODULE('auth_script',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('auth_script'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('auth_script'))
+
+bld.SAMBA3_MODULE('auth_samba4',
+ subsystem='auth',
+ source='auth_samba4.c',
+ init_function='',
+ deps='auth4',
+ allow_undefined_symbols=False,
+ internal_module=bld.SAMBA3_IS_STATIC_MODULE('auth_samba4'),
+ enabled=bld.SAMBA3_IS_ENABLED_MODULE('auth_samba4'))
diff --git a/source3/build/charset.py b/source3/build/charset.py
index 03ba2493677..44852a6c52a 100644
--- a/source3/build/charset.py
+++ b/source3/build/charset.py
@@ -8,7 +8,6 @@ def CHECK_SAMBA3_CHARSET(conf, crossbuild=False):
'''
if conf.CHECK_ICONV(define='HAVE_NATIVE_ICONV'):
default_dos_charset=False
- default_display_charset=False
default_unix_charset=False
# check for default dos charset name
@@ -17,12 +16,6 @@ def CHECK_SAMBA3_CHARSET(conf, crossbuild=False):
default_dos_charset=charset
break
- # check for default display charset name
- for charset in ['ASCII', '646']:
- if conf.CHECK_CHARSET_EXISTS(charset, headers='iconv.h'):
- default_display_charset=charset
- break
-
# check for default unix charset name
for charset in ['UTF-8', 'UTF8']:
if conf.CHECK_CHARSET_EXISTS(charset, headers='iconv.h'):
@@ -37,16 +30,13 @@ def CHECK_SAMBA3_CHARSET(conf, crossbuild=False):
# match the results we get at runtime anyway.
if crossbuild:
default_dos_charset="CP850"
- default_display_charset="ASCII"
default_unix_charset="UTF-8"
# TODO: this used to warn about the set charset on cross builds
conf.DEFINE('DEFAULT_DOS_CHARSET', default_dos_charset, quote=True)
- conf.DEFINE('DEFAULT_DISPLAY_CHARSET', default_display_charset, quote=True)
conf.DEFINE('DEFAULT_UNIX_CHARSET', default_unix_charset, quote=True)
else:
conf.DEFINE('DEFAULT_DOS_CHARSET', "ASCII", quote=True)
- conf.DEFINE('DEFAULT_DISPLAY_CHARSET', "ASCII", quote=True)
conf.DEFINE('DEFAULT_UNIX_CHARSET', "UTF8", quote=True)
diff --git a/source3/build/wscript b/source3/build/wscript
index d370daf8996..b9c6bd264c8 100644
--- a/source3/build/wscript
+++ b/source3/build/wscript
@@ -42,7 +42,7 @@ def configure(conf):
def build(bld):
cflags = dynconfig_cflags(bld)
bld.SAMBA3_SUBSYSTEM('DYNCONFIG',
- '../dynconfig.c',
+ '../../dynconfig/dynconfig.c',
deps='replace talloc tdb popt',
cflags=cflags)
diff --git a/source3/client/client.c b/source3/client/client.c
index a12f8a29653..b485df7741a 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -32,6 +32,7 @@
#include "../libcli/smbreadline/smbreadline.h"
#include "../libcli/security/security.h"
#include "system/select.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "trans2.h"
#include "libsmb/nmblib.h"
@@ -48,7 +49,6 @@ extern char tar_type;
static int port = 0;
static char *service;
static char *desthost;
-static char *calling_name;
static bool grepable = false;
static char *cmdstr = NULL;
const char *cmd_ptr = NULL;
@@ -505,7 +505,7 @@ static bool do_this_one(struct file_info *finfo)
return false;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
return true;
}
@@ -520,7 +520,7 @@ static bool do_this_one(struct file_info *finfo)
return false;
}
- if ((archive_level==1 || archive_level==2) && !(finfo->mode & aARCH)) {
+ if ((archive_level==1 || archive_level==2) && !(finfo->mode & FILE_ATTRIBUTE_ARCHIVE)) {
DEBUG(3,("archive %s failed\n", finfo->name));
return false;
}
@@ -547,7 +547,7 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin
if (!showacls) {
d_printf(" %-30s%7.7s %8.0f %s",
finfo->name,
- attrib_string(finfo->mode),
+ attrib_string(talloc_tos(), finfo->mode),
(double)finfo->size,
time_to_asc(t));
dir_total += finfo->size;
@@ -569,7 +569,7 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin
}
/* print file meta date header */
d_printf( "FILENAME:%s\n", finfo->name);
- d_printf( "MODE:%s\n", attrib_string(finfo->mode));
+ d_printf( "MODE:%s\n", attrib_string(talloc_tos(), finfo->mode));
d_printf( "SIZE:%.0f\n", (double)finfo->size);
d_printf( "MTIME:%s", time_to_asc(t));
status = cli_ntcreate(cli_state, afname, 0,
@@ -702,7 +702,7 @@ static void add_to_do_list_queue(const char *entry)
}
}
if (do_list_queue) {
- safe_strcpy_base(do_list_queue + do_list_queue_end,
+ strlcpy_base(do_list_queue + do_list_queue_end,
entry, do_list_queue, do_list_queue_size);
do_list_queue_end = new_end;
DEBUG(4,("added %s to do_list_queue (start=%d, end=%d)\n",
@@ -752,7 +752,7 @@ static NTSTATUS do_list_helper(const char *mntpoint, struct file_info *f,
*dir_end = '\0';
}
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
if (do_list_dirs && do_this_one(f)) {
status = do_list_fn(cli_state, f, dir);
if (!NT_STATUS_IS_OK(status)) {
@@ -924,7 +924,7 @@ NTSTATUS do_list(const char *mask,
static int cmd_dir(void)
{
TALLOC_CTX *ctx = talloc_tos();
- uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
char *mask = NULL;
char *buf = NULL;
int rc = 1;
@@ -974,7 +974,7 @@ static int cmd_dir(void)
static int cmd_du(void)
{
TALLOC_CTX *ctx = talloc_tos();
- uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
char *mask = NULL;
char *buf = NULL;
NTSTATUS status;
@@ -1147,8 +1147,8 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
close(handle);
}
- if (archive_level >= 2 && (attr & aARCH)) {
- cli_setatr(cli, rname, attr & ~(uint16)aARCH, 0);
+ if (archive_level >= 2 && (attr & FILE_ATTRIBUTE_ARCHIVE)) {
+ cli_setatr(cli, rname, attr & ~(uint16)FILE_ATTRIBUTE_ARCHIVE, 0);
}
{
@@ -1233,7 +1233,7 @@ static NTSTATUS do_mget(struct cli_state *cli_state, struct file_info *finfo,
return NT_STATUS_UNSUCCESSFUL;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
if (asprintf(&quest,
"Get directory %s? ",finfo->name) < 0) {
return NT_STATUS_NO_MEMORY;
@@ -1251,7 +1251,7 @@ static NTSTATUS do_mget(struct cli_state *cli_state, struct file_info *finfo,
}
SAFE_FREE(quest);
- if (!(finfo->mode & aDIR)) {
+ if (!(finfo->mode & FILE_ATTRIBUTE_DIRECTORY)) {
rname = talloc_asprintf(ctx,
"%s%s",
client_get_cur_dir(),
@@ -1306,7 +1306,7 @@ static NTSTATUS do_mget(struct cli_state *cli_state, struct file_info *finfo,
return NT_STATUS_NO_MEMORY;
}
- status = do_list(mget_mask, aSYSTEM | aHIDDEN | aDIR,do_mget,false, true);
+ status = do_list(mget_mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,do_mget,false, true);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -1395,13 +1395,13 @@ static int cmd_more(void)
static int cmd_mget(void)
{
TALLOC_CTX *ctx = talloc_tos();
- uint16 attribute = aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
char *mget_mask = NULL;
char *buf = NULL;
NTSTATUS status = NT_STATUS_OK;
if (recurse) {
- attribute |= aDIR;
+ attribute |= FILE_ATTRIBUTE_DIRECTORY;
}
abort_mget = false;
@@ -1605,7 +1605,7 @@ static int cmd_altname(void)
static char *attr_str(TALLOC_CTX *mem_ctx, uint16_t mode)
{
- char *attrs = TALLOC_ZERO_ARRAY(mem_ctx, char, 17);
+ char *attrs = talloc_zero_array(mem_ctx, char, 17);
int i = 0;
if (!(mode & FILE_ATTRIBUTE_NORMAL)) {
@@ -2306,12 +2306,12 @@ static NTSTATUS do_del(struct cli_state *cli_state, struct file_info *finfo,
return NT_STATUS_NO_MEMORY;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
TALLOC_FREE(mask);
return NT_STATUS_OK;
}
- status = cli_unlink(cli_state, mask, aSYSTEM | aHIDDEN);
+ status = cli_unlink(cli_state, mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!NT_STATUS_IS_OK(status)) {
d_printf("%s deleting remote file %s\n",
nt_errstr(status), mask);
@@ -2330,10 +2330,10 @@ static int cmd_del(void)
char *mask = NULL;
char *buf = NULL;
NTSTATUS status = NT_STATUS_OK;
- uint16 attribute = aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
if (recurse) {
- attribute |= aDIR;
+ attribute |= FILE_ATTRIBUTE_DIRECTORY;
}
mask = talloc_strdup(ctx, client_get_cur_dir());
@@ -3875,11 +3875,12 @@ static int cmd_lcd(void)
buf, strerror(errno));
}
}
- d = TALLOC_ARRAY(ctx, char, PATH_MAX+1);
+ d = sys_getwd();
if (!d) {
return 1;
}
- DEBUG(2,("the local directory is now %s\n",sys_getwd(d)));
+ DEBUG(2,("the local directory is now %s\n",d));
+ SAFE_FREE(d);
return 0;
}
@@ -4516,7 +4517,7 @@ static NTSTATUS completion_remote_filter(const char *mnt,
return NT_STATUS_OK;
}
- if ((info->dirmask[0] == 0) && !(f->mode & aDIR))
+ if ((info->dirmask[0] == 0) && !(f->mode & FILE_ATTRIBUTE_DIRECTORY))
info->matches[info->count] = SMB_STRDUP(f->name);
else {
TALLOC_CTX *ctx = talloc_stackframe();
@@ -4532,7 +4533,7 @@ static NTSTATUS completion_remote_filter(const char *mnt,
TALLOC_FREE(ctx);
return NT_STATUS_NO_MEMORY;
}
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
tmp = talloc_asprintf_append(tmp, "%s",
CLI_DIRSEP_STR);
}
@@ -4546,7 +4547,7 @@ static NTSTATUS completion_remote_filter(const char *mnt,
if (info->matches[info->count] == NULL) {
return NT_STATUS_OK;
}
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
smb_readline_ca_char(0);
}
if (info->count == 1) {
@@ -4629,7 +4630,7 @@ static char **remote_completion(const char *text, int len)
if (!cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli, &targetpath)) {
goto cleanup;
}
- status = cli_list(targetcli, targetpath, aDIR | aSYSTEM | aHIDDEN,
+ status = cli_list(targetcli, targetpath, FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
completion_remote_filter, (void *)&info);
if (!NT_STATUS_IS_OK(status)) {
goto cleanup;
@@ -5036,46 +5037,16 @@ static int do_tar_op(const char *base_directory)
static int do_message_op(struct user_auth_info *a_info)
{
- struct sockaddr_storage ss;
- struct nmb_name called, calling;
- fstring server_name;
- char name_type_hex[10];
- int msg_port;
NTSTATUS status;
- make_nmb_name(&calling, calling_name, 0x0);
- make_nmb_name(&called , desthost, name_type);
-
- fstrcpy(server_name, desthost);
- snprintf(name_type_hex, sizeof(name_type_hex), "#%X", name_type);
- fstrcat(server_name, name_type_hex);
-
- zero_sockaddr(&ss);
- if (have_ip)
- ss = dest_ss;
-
- /* we can only do messages over port 139 (to windows clients at least) */
-
- msg_port = port ? port : 139;
-
- if (!(cli=cli_initialise())) {
- d_printf("Connection to %s failed\n", desthost);
- return 1;
- }
- cli_set_port(cli, msg_port);
-
- status = cli_connect(cli, server_name, &ss);
+ status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL,
+ port ? port : 139, name_type,
+ lp_netbios_name(), Undefined, &cli);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status));
return 1;
}
- if (!cli_session_request(cli, &calling, &called)) {
- d_printf("session request failed\n");
- cli_shutdown(cli);
- return 1;
- }
-
send_message(get_cmdline_auth_info_username(a_info));
cli_shutdown(cli);
@@ -5096,7 +5067,6 @@ static int do_message_op(struct user_auth_info *a_info)
poptContext pc;
char *p;
int rc = 0;
- fstring new_workgroup;
bool tar_opt = false;
bool service_opt = false;
struct poptOption long_options[] = {
@@ -5126,12 +5096,6 @@ static int do_message_op(struct user_auth_info *a_info)
exit(ENOMEM);
}
- /* initialize the workgroup name so we can determine whether or
- not it was set by a command line option */
-
- set_global_myworkgroup( "" );
- set_global_myname( "" );
-
/* set default debug level to 1 regardless of what smb.conf sets */
setup_logging( "smbclient", DEBUG_DEFAULT_STDERR );
load_case_tables();
@@ -5277,18 +5241,6 @@ static int do_message_op(struct user_auth_info *a_info)
poptGetArg(pc));
}
- /* save the workgroup...
-
- FIXME!! do we need to do this for other options as well
- (or maybe a generic way to keep lp_load() from overwriting
- everything)? */
-
- fstrcpy( new_workgroup, lp_workgroup() );
- calling_name = talloc_strdup(frame, global_myname() );
- if (!calling_name) {
- exit(ENOMEM);
- }
-
if ( override_logfile )
setup_logging( lp_logfile(), DEBUG_FILE );
@@ -5322,17 +5274,6 @@ static int do_message_op(struct user_auth_info *a_info)
}
}
- if ( strlen(new_workgroup) != 0 ) {
- set_global_myworkgroup( new_workgroup );
- }
-
- if ( strlen(calling_name) != 0 ) {
- set_global_myname( calling_name );
- } else {
- TALLOC_FREE(calling_name);
- calling_name = talloc_strdup(frame, global_myname() );
- }
-
smb_encrypt = get_cmdline_auth_info_smb_encrypt(auth_info);
if (!init_names()) {
fprintf(stderr, "init_names() failed\n");
diff --git a/source3/client/client_proto.h b/source3/client/client_proto.h
index fa3ca40d6b7..d119014abdc 100644
--- a/source3/client/client_proto.h
+++ b/source3/client/client_proto.h
@@ -23,6 +23,8 @@
#ifndef _CLIENT_PROTO_H_
#define _CLIENT_PROTO_H_
+struct cli_state;
+struct file_info;
/* The following definitions come from client/client.c */
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index b46115becf3..4dc202e17ea 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -38,6 +38,7 @@
#include "system/filesys.h"
#include "clitar.h"
#include "client/client_proto.h"
+#include "libsmb/libsmb.h"
static int clipfind(char **aret, int ret, char *tok);
@@ -70,7 +71,7 @@ extern struct cli_state *cli;
#define ATTRSET 1
#define ATTRRESET 0
-static uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
+static uint16 attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
#ifndef CLIENT_TIMEOUT
#define CLIENT_TIMEOUT (30*1000)
@@ -101,7 +102,7 @@ char tar_type='\0';
static char **cliplist=NULL;
static int clipn=0;
static bool must_free_cliplist = False;
-extern const char *cmd_ptr;
+extern char *cmd_ptr;
extern bool lowercase;
extern uint16 cnum;
@@ -136,23 +137,6 @@ static void unfixtarname(char *tptr, char *fp, int l, bool first);
* tar specific utitlities
*/
-/*******************************************************************
-Create a string of size size+1 (for the null)
-*******************************************************************/
-
-static char *string_create_s(int size)
-{
- char *tmp;
-
- tmp = (char *)SMB_MALLOC(size+1);
-
- if (tmp == NULL) {
- DEBUG(0, ("Out of memory in string_create_s\n"));
- }
-
- return(tmp);
-}
-
/****************************************************************************
Write a tar header to buffer
****************************************************************************/
@@ -197,7 +181,7 @@ static void writetarheader(int f, const char *aname, uint64_t size, time_t mtime
/* write out a "standard" tar format header */
hb.dbuf.name[NAMSIZ-1]='\0';
- safe_strcpy(hb.dbuf.mode, amode, sizeof(hb.dbuf.mode)-1);
+ strlcpy(hb.dbuf.mode, amode ? amode : "", sizeof(hb.dbuf.mode));
oct_it((uint64_t)0, 8, hb.dbuf.uid);
oct_it((uint64_t)0, 8, hb.dbuf.gid);
oct_it((uint64_t) size, 13, hb.dbuf.size);
@@ -263,12 +247,12 @@ static long readtarheader(union hblock *hb, file_info2 *finfo, const char *prefi
return -1;
}
- if ((finfo->name = string_create_s(strlen(prefix) + strlen(hb -> dbuf.name) + 3)) == NULL) {
+ if ((finfo->name = SMB_MALLOC(strlen(prefix) + strlen(hb -> dbuf.name) + 4)) == NULL) {
DEBUG(0, ("Out of space creating file_info2 for %s\n", hb -> dbuf.name));
return(-1);
}
- safe_strcpy(finfo->name, prefix, strlen(prefix) + strlen(hb -> dbuf.name) + 3);
+ strlcpy(finfo->name, prefix, strlen(prefix) + strlen(hb -> dbuf.name) + 4);
/* use l + 1 to do the null too; do prefix - prefcnt to zap leading slash */
unfixtarname(finfo->name + strlen(prefix), hb->dbuf.name,
@@ -294,7 +278,7 @@ of link other than a GNUtar Longlink - ignoring\n"));
if ((unoct(hb->dbuf.mode, sizeof(hb->dbuf.mode)) & S_IFDIR) ||
(*(finfo->name+strlen(finfo->name)-1) == '\\')) {
- finfo->mode=aDIR;
+ finfo->mode=FILE_ATTRIBUTE_DIRECTORY;
} else {
finfo->mode=0; /* we don't care about mode at the moment, we'll
* just make it a regular file */
@@ -521,14 +505,16 @@ static bool ensurepath(const char *fname)
/* ensures path exists */
char *partpath, *ffname;
+ size_t fnamelen = strlen(fname)+1;
const char *p=fname;
char *basehack;
char *saveptr;
+ NTSTATUS status;
DEBUG(5, ( "Ensurepath called with: %s\n", fname));
- partpath = string_create_s(strlen(fname));
- ffname = string_create_s(strlen(fname));
+ partpath = SMB_MALLOC(fnamelen);
+ ffname = SMB_MALLOC(fnamelen);
if ((partpath == NULL) || (ffname == NULL)){
DEBUG(0, ("Out of memory in ensurepath: %s\n", fname));
@@ -541,7 +527,7 @@ static bool ensurepath(const char *fname)
/* fname copied to ffname so can strtok_r */
- safe_strcpy(ffname, fname, strlen(fname));
+ strlcpy(ffname, fname, fnamelen);
/* do a `basename' on ffname, so don't try and make file name directory */
if ((basehack=strrchr_m(ffname, '\\')) == NULL) {
@@ -555,20 +541,22 @@ static bool ensurepath(const char *fname)
p=strtok_r(ffname, "\\", &saveptr);
while (p) {
- safe_strcat(partpath, p, strlen(fname) + 1);
+ strlcat(partpath, p, fnamelen);
- if (!NT_STATUS_IS_OK(cli_chkpath(cli, partpath))) {
- if (!NT_STATUS_IS_OK(cli_mkdir(cli, partpath))) {
+ status = cli_chkpath(cli, partpath);
+ if (!NT_STATUS_IS_OK(status)) {
+ status = cli_mkdir(cli, partpath);
+ if (!NT_STATUS_IS_OK(status)) {
SAFE_FREE(partpath);
SAFE_FREE(ffname);
- DEBUG(0, ("Error mkdir %s\n", cli_errstr(cli)));
+ DEBUG(0, ("Error mkdir %s\n", nt_errstr(status)));
return False;
} else {
DEBUG(3, ("mkdirhiering %s\n", partpath));
}
}
- safe_strcat(partpath, "\\", strlen(fname) + 1);
+ strlcat(partpath, "\\", fnamelen);
p = strtok_r(NULL, "/\\", &saveptr);
}
@@ -596,6 +584,7 @@ static int padit(char *buf, uint64_t bufsize, uint64_t padsize)
static void do_setrattr(char *name, uint16 attr, int set)
{
uint16 oldattr;
+ NTSTATUS status;
if (!NT_STATUS_IS_OK(cli_getatr(cli, name, &oldattr, NULL, NULL))) {
return;
@@ -607,8 +596,9 @@ static void do_setrattr(char *name, uint16 attr, int set)
attr = oldattr & ~attr;
}
- if (!NT_STATUS_IS_OK(cli_setatr(cli, name, attr, 0))) {
- DEBUG(1,("setatr failed: %s\n", cli_errstr(cli)));
+ status = cli_setatr(cli, name, attr, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("setatr failed: %s\n", nt_errstr(status)));
}
}
@@ -671,28 +661,26 @@ static NTSTATUS do_atar(const char *rname_in, char *lname,
status = cli_open(cli, rname, O_RDONLY, DENY_NONE, &fnum);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("%s opening remote file %s (%s)\n",
- cli_errstr(cli),rname, client_get_cur_dir()));
+ nt_errstr(status),rname, client_get_cur_dir()));
goto cleanup;
}
- finfo.name = string_create_s(strlen(rname));
+ finfo.name = smb_xstrdup(rname);
if (finfo.name == NULL) {
DEBUG(0, ("Unable to allocate space for finfo.name in do_atar\n"));
status = NT_STATUS_NO_MEMORY;
goto cleanup;
}
- safe_strcpy(finfo.name,rname, strlen(rname));
-
DEBUG(3,("file %s attrib 0x%X\n",finfo.name,finfo.mode));
- if (tar_inc && !(finfo.mode & aARCH)) {
+ if (tar_inc && !(finfo.mode & FILE_ATTRIBUTE_ARCHIVE)) {
DEBUG(4, ("skipping %s - archive bit not set\n", finfo.name));
shallitime=0;
- } else if (!tar_system && (finfo.mode & aSYSTEM)) {
+ } else if (!tar_system && (finfo.mode & FILE_ATTRIBUTE_SYSTEM)) {
DEBUG(4, ("skipping %s - system bit is set\n", finfo.name));
shallitime=0;
- } else if (!tar_hidden && (finfo.mode & aHIDDEN)) {
+ } else if (!tar_hidden && (finfo.mode & FILE_ATTRIBUTE_HIDDEN)) {
DEBUG(4, ("skipping %s - hidden bit is set\n", finfo.name));
shallitime=0;
} else {
@@ -784,7 +772,7 @@ static NTSTATUS do_atar(const char *rname_in, char *lname,
/* if shallitime is true then we didn't skip */
if (tar_reset && !dry_run)
- (void) do_setrattr(finfo.name, aARCH, ATTRRESET);
+ (void) do_setrattr(finfo.name, FILE_ATTRIBUTE_ARCHIVE, ATTRRESET);
clock_gettime_mono(&tp_end);
this_time = (tp_end.tv_sec - tp_start.tv_sec)*1000 + (tp_end.tv_nsec - tp_start.tv_nsec)/1000000;
@@ -852,7 +840,7 @@ static NTSTATUS do_tar(struct cli_state *cli_state, struct file_info *finfo,
TALLOC_FREE(exclaim);
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
char *saved_curdir = NULL;
char *new_cd = NULL;
char *mtar_mask = NULL;
@@ -934,9 +922,12 @@ static void unfixtarname(char *tptr, char *fp, int l, bool first)
fp++;
l--;
}
+ if (l <= 0) {
+ return;
+ }
}
- safe_strcpy(tptr, fp, l);
+ strlcpy(tptr, fp, l);
string_replace(tptr, '/', '\\');
}
@@ -1045,8 +1036,12 @@ static int get_file(file_info2 finfo)
dsize = MIN(dsize, rsize); /* Should be only what is left */
DEBUG(5, ("writing %i bytes, bpos = %i ...\n", dsize, bpos));
- if (cli_write(cli, fnum, 0, buffer_p + bpos, pos, dsize) != dsize) {
- DEBUG(0, ("Error writing remote file\n"));
+ status = cli_writeall(cli, fnum, 0,
+ (uint8_t *)(buffer_p + bpos), pos,
+ dsize, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Error writing remote file: %s\n",
+ nt_errstr(status)));
return 0;
}
@@ -1092,10 +1087,10 @@ static int get_file(file_info2 finfo)
}
/* Now close the file ... */
-
- if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
+ status = cli_close(cli, fnum);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Error %s closing remote file\n",
- cli_errstr(cli)));
+ nt_errstr(status)));
return(False);
}
@@ -1166,7 +1161,8 @@ static char *get_longfilename(file_info2 finfo)
return(NULL);
}
- unfixtarname(longname + offset, buffer_p, MIN(TBLOCK, finfo.size), first--);
+ unfixtarname(longname + offset, buffer_p,
+ namesize - offset, first--);
DEBUG(5, ("UnfixedName: %s, buffer: %s\n", longname, buffer_p));
offset += TBLOCK;
@@ -1301,7 +1297,7 @@ int cmd_block(void)
char *buf;
int block;
- if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ if (!next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
DEBUG(0, ("blocksize <n>\n"));
return 1;
}
@@ -1326,7 +1322,7 @@ int cmd_tarmode(void)
TALLOC_CTX *ctx = talloc_tos();
char *buf;
- while (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ while (next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
if (strequal(buf, "full"))
tar_inc=False;
else if (strequal(buf, "inc"))
@@ -1376,7 +1372,7 @@ int cmd_setmode(void)
attra[0] = attra[1] = 0;
- if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ if (!next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
DEBUG(0, ("setmode <filename> <[+|-]rsha>\n"));
return 1;
}
@@ -1389,7 +1385,7 @@ int cmd_setmode(void)
return 1;
}
- while (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ while (next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
q=buf;
while(*q) {
@@ -1401,16 +1397,16 @@ int cmd_setmode(void)
direct=0;
break;
case 'r':
- attra[direct]|=aRONLY;
+ attra[direct]|=FILE_ATTRIBUTE_READONLY;
break;
case 'h':
- attra[direct]|=aHIDDEN;
+ attra[direct]|=FILE_ATTRIBUTE_HIDDEN;
break;
case 's':
- attra[direct]|=aSYSTEM;
+ attra[direct]|=FILE_ATTRIBUTE_SYSTEM;
break;
case 'a':
- attra[direct]|=aARCH;
+ attra[direct]|=FILE_ATTRIBUTE_ARCHIVE;
break;
default:
DEBUG(0, ("setmode <filename> <perm=[+|-]rsha>\n"));
@@ -1491,7 +1487,7 @@ int cmd_tar(void)
int argcl = 0;
int ret;
- if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ if (!next_token_talloc(ctx, (const char **)&cmd_ptr,&buf,NULL)) {
DEBUG(0,("tar <c|x>[IXbgan] <filename>\n"));
return 1;
}
@@ -1717,7 +1713,7 @@ static int read_inclusion_file(char *filename)
}
}
- safe_strcpy(inclusion_buffer + inclusion_buffer_sofar, buf, inclusion_buffer_size - inclusion_buffer_sofar);
+ strlcpy(inclusion_buffer + inclusion_buffer_sofar, buf, inclusion_buffer_size - inclusion_buffer_sofar);
inclusion_buffer_sofar += strlen(buf) + 1;
clipn++;
}
diff --git a/source3/client/dnsbrowse.c b/source3/client/dnsbrowse.c
index c252b253438..03f87afe140 100644
--- a/source3/client/dnsbrowse.c
+++ b/source3/client/dnsbrowse.c
@@ -124,7 +124,7 @@ do_smb_browse_reply(DNSServiceRef sdRef, DNSServiceFlags flags,
return;
}
- bresult = TALLOC_ARRAY(talloc_tos(), struct mdns_smbsrv_result, 1);
+ bresult = talloc_array(talloc_tos(), struct mdns_smbsrv_result, 1);
if (bresult == NULL) {
return;
}
diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
index 98c350d7ddb..e16086dd679 100644
--- a/source3/client/smbspool.c
+++ b/source3/client/smbspool.c
@@ -25,6 +25,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "system/passwd.h"
+#include "libsmb/libsmb.h"
/*
* Starting with CUPS 1.3, Kerberos support is provided by cupsd including
@@ -595,14 +596,19 @@ smb_print(struct cli_state * cli, /* I - SMB connection */
tbytes = 0;
while ((nbytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
- if (cli_write(cli, fnum, 0, buffer, tbytes, nbytes) != nbytes) {
- int status = get_exit_code(cli, cli_nt_error(cli));
-
- fprintf(stderr, "ERROR: Error writing spool: %s\n", cli_errstr(cli));
- fprintf(stderr, "DEBUG: Returning status %d...\n", status);
+ NTSTATUS status;
+
+ status = cli_writeall(cli, fnum, 0, (uint8_t *)buffer,
+ tbytes, nbytes, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ int ret = get_exit_code(cli, status);
+ fprintf(stderr, "ERROR: Error writing spool: %s\n",
+ nt_errstr(status));
+ fprintf(stderr, "DEBUG: Returning status %d...\n",
+ ret);
cli_close(cli, fnum);
- return (status);
+ return (ret);
}
tbytes += nbytes;
}
diff --git a/source3/configure.in b/source3/configure.in
index b2c1856becc..814c7356d2a 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -6,7 +6,7 @@ AC_PREREQ(2.54)
AC_INIT([Samba],[3],[samba-technical@samba.org])
AC_CONFIG_SRCDIR([include/includes.h])
-AC_CONFIG_HEADER(include/config.h)
+AC_CONFIG_HEADER(include/autoconf/config.h)
AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h])
case "$PATH" in
@@ -26,6 +26,7 @@ AC_LIBREPLACE_CC_CHECKS
AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
m4_include(../lib/tevent/libtevent.m4)
+m4_include(../lib/ccan/libccan.m4)
LIBTEVENT_OBJ0=""
for obj in ${TEVENT_OBJ}; do
@@ -34,11 +35,13 @@ done
AC_SUBST(LIBTEVENT_OBJ0)
LIBS="${LIBS} ${TEVENT_LIBS}"
-SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include -I. -I${srcdir-.}"
+SAMBA_CPPFLAGS="-Iinclude/autoconf -Iinclude -I${srcdir-.}/include -I. -I${srcdir-.}"
SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/replace"
SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TEVENT_CFLAGS}"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${CCAN_CFLAGS}"
SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/.."
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/tdb_compat"
SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/popt"
@@ -73,6 +76,7 @@ AC_SUBST(LIBWBCLIENT_SHARED)
AC_SUBST(LIBWBCLIENT_STATIC_TARGET)
AC_SUBST(LIBWBCLIENT_STATIC)
AC_SUBST(LIBWBCLIENT_SOVER)
+AC_SUBST(LIBWBCLIENT_FULLVER)
AC_SUBST(LIBWBCLIENT)
AC_SUBST(LIBWBCLIENT_LIBS)
@@ -196,7 +200,14 @@ AC_ARG_WITH(profiling-data,
)
dnl Checks for programs.
-smbtorture4_possible=yes
+AC_ARG_ENABLE(smbtorture4,
+ [AS_HELP_STRING([--enable-smbtorture4], [Enable building smbtorture4 (default=auto)])])
+
+if test x$enable_smbtorture4 != xno; then
+ smbtorture4_possible=yes
+else
+ smbtorture4_possible=no
+fi
AC_PROG_INSTALL
AC_PROG_AWK
@@ -518,6 +529,8 @@ case "$host_os" in
AC_MSG_RESULT([no large file support])
;;
5.*)
+ LDFLAGS="$LDFLAGS -lthread"
+ CPPFLAGS="$CPPFLAGS -D_REENTRANT"
AC_MSG_RESULT([enabling large file support])
if test "$ac_cv_prog_gcc" = yes; then
${CC-cc} -v >conftest.c 2>&1
@@ -525,20 +538,17 @@ case "$host_os" in
rm -fr conftest.c
case "$ac_cv_gcc_compiler_version_number" in
*"gcc version 2.6"*|*"gcc version 2.7"*)
- CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
- LDFLAGS="$LDFLAGS -lthread"
+ CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
;;
*)
- CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
- LDFLAGS="$LDFLAGS -lthread"
+ CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
;;
esac
else
- CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
- LDFLAGS="$LDFLAGS -lthread"
+ CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
fi
@@ -1081,7 +1091,7 @@ AC_CHECK_FUNCS(getpwent_r)
AC_CHECK_FUNCS(getdents64)
AC_CHECK_FUNCS(setenv strcasecmp fcvt fcvtl)
AC_CHECK_FUNCS(syslog vsyslog timegm)
-AC_CHECK_FUNCS(setlocale nl_langinfo)
+AC_CHECK_FUNCS(setlocale)
AC_CHECK_FUNCS(nanosleep,,[AC_CHECK_LIB_EXT(rt, LIBS, nanosleep)])
AC_CHECK_FUNCS(lutimes futimes utimensat futimens)
AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
@@ -1090,7 +1100,7 @@ AC_CHECK_HEADERS(sys/mman.h)
# setbuffer, shmget, shm_open are needed for smbtorture
AC_CHECK_FUNCS(shmget shm_open)
AC_CHECK_FUNCS(gettext dgettext)
-AC_CHECK_FUNCS(bindtextdomain textdomain)
+AC_CHECK_FUNCS(bindtextdomain textdomain bind_textdomain_codeset)
AC_CHECK_FUNCS(strupr)
# Find a method of generating a stack trace
@@ -1118,6 +1128,7 @@ AC_CHECK_HEADERS(gpfs_gpl.h)
if test x"$ac_cv_header_gpfs_gpl_h" = x"yes"; then
AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL headers are available])
default_shared_modules="$default_shared_modules vfs_gpfs"
+ default_shared_modules="$default_shared_modules vfs_gpfs_hsm_notify"
fi
#############################################
@@ -1411,6 +1422,14 @@ AC_CHECK_LIB(resolv, dn_expand)
AC_CHECK_LIB(resolv, _dn_expand)
AC_CHECK_LIB(resolv, __dn_expand)
+AC_TRY_COMPILE([#include <resolv.h>],
+ [struct __res_state s; res_ninit(&s);],
+ ac_cv_have_res_ninit=yes,ac_cv_have_res_ninit=no)
+
+if test x"$ac_cv_have_res_ninit" = x"yes"; then
+ AC_DEFINE(HAVE_RES_NINIT, 1, [Whether we have res_ninit])
+fi
+
#
# Check for the functions putprpwnam, set_auth_parameters,
# getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
@@ -2072,8 +2091,11 @@ LINK_LIBSMBCLIENT=STATIC
# TODO: for talloc and tdb (at least), these should
# be extracted from their respective source directories
#
-AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc], [Enable external talloc [default=auto]])],
-[ enable_external_libtalloc=$enableval ], [ enable_external_libtalloc=auto ])
+AC_ARG_ENABLE(external_libtalloc,
+ [AS_HELP_STRING([--enable-external-libtalloc],
+ [Enable external talloc [default=auto]])],
+ [ enable_external_libtalloc=$enableval ],
+ [ enable_external_libtalloc=auto ])
if test "x$enable_external_libtalloc" != xno
then
@@ -2090,8 +2112,11 @@ fi
if test "x$enable_external_libtalloc" = xno
then
m4_include(../lib/talloc/libtalloc.m4)
- LINK_LIBTALLOC=STATIC
- SMB_LIBRARY(talloc, 2)
+ if test x"$USESHARED" == x"no" ; then
+ LINK_LIBTALLOC=STATIC
+ fi
+ LIBTALLOCVERSION=`grep ^VERSION ${tallocdir}/wscript | sed -e "s/'//g" -e 's/.* //'`
+ SMB_LIBRARY(talloc, 2, ${LIBTALLOCVERSION})
LIBTALLOC_OBJ0=""
for obj in ${TALLOC_OBJ}; do
LIBTALLOC_OBJ0="${LIBTALLOC_OBJ0} ${tallocdir}/${obj}"
@@ -2108,8 +2133,8 @@ fi
AC_ARG_ENABLE(external_libtdb,
[AS_HELP_STRING([--enable-external-libtdb],
[Enable external tdb [default=auto]])],
- [ enable_external_libtalloc=$enableval ],
- [ enable_external_libtalloc=auto ])
+ [ enable_external_libtdb=$enableval ],
+ [ enable_external_libtdb=auto ])
if test "x$enable_external_libtdb" != xno
then
@@ -2128,8 +2153,11 @@ AC_SUBST(LIBTDB_OBJ0)
if test "x$enable_external_libtdb" = xno
then
m4_include(../lib/tdb/libtdb.m4)
- LINK_LIBTDB=STATIC
- SMB_LIBRARY(tdb, 1)
+ if test x"$USESHARED" == x"no" ; then
+ LINK_LIBTDB=STATIC
+ fi
+ LIBTDBVERSION=`grep ^VERSION ${tdbdir}/wscript | sed -e "s/'//g" -e 's/.* //'`
+ SMB_LIBRARY(tdb, 1, ${LIBTDBVERSION})
LIBTDB_OBJ0=""
LIBTDB_LIBS="$LIBTDB_LIBS $TDB_DEPS"
for obj in ${TDB_OBJ}; do
@@ -2164,7 +2192,7 @@ fi
SMB_LIBRARY(netapi, 0)
SMB_LIBRARY(smbclient, 0)
SMB_LIBRARY(smbsharemodes, 0)
-SMB_LIBRARY(addns, 0, no, [undefined API])
+SMB_LIBRARY(addns, 0, [], no, [undefined API])
@@ -2577,6 +2605,17 @@ if test x"$samba_cv_HAVE_LINUX_FALLOCATE64" = x"yes" && test x"$ac_cv_func_fallo
AC_DEFINE(HAVE_LINUX_FALLOCATE64,1,[Whether the Linux 'fallocate64' function is available])
fi
+AC_CACHE_CHECK([for getcwd takes NULL],samba_cv_GETCWD_TAKES_NULL,[
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+main() { char *s = getcwd(NULL,0); if (s) exit(0); exit(1); }],
+samba_cv_GETCWD_TAKES_NULL=yes,samba_cv_GETCWD_TAKES_NULL=no,samba_cv_GETCWD_TAKES_NULL=cross)])
+if test x"$samba_cv_GETCWD_TAKES_NULL" = x"yes"; then
+ AC_DEFINE(GETCWD_TAKES_NULL,1,[Whether the getcwd function takes NULL as an argument])
+fi
+
ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
AC_ARG_WITH(libiconv,
[AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
@@ -2654,7 +2693,6 @@ for i in $ICONV_LOOK_DIRS ; do
export LDFLAGS LIBS CPPFLAGS
default_dos_charset=no
- default_display_charset=no
default_unix_charset=no
# check for default dos charset name
@@ -2666,15 +2704,6 @@ for i in $ICONV_LOOK_DIRS ; do
fi
done
- # check for default display charset name
- for j in ASCII 646 ; do
- rjs_CHARSET($j)
- default_display_charset="$ICONV_CHARSET"
- if test x"$default_display_charset" = x"$j"; then
- break
- fi
- done
-
# check for default unix charset name
for j in UTF-8 UTF8 ; do
rjs_CHARSET($j)
@@ -2686,15 +2715,12 @@ for i in $ICONV_LOOK_DIRS ; do
if test "$default_dos_charset" != "no" -a \
"$default_dos_charset" != "cross" -a \
- "$default_display_charset" != "no" -a \
- "$default_display_charset" != "cross" -a \
"$default_unix_charset" != "no" -a \
"$default_unix_charset" != "cross"
then
samba_cv_HAVE_NATIVE_ICONV=yes
else
if test "$default_dos_charset" = "cross" -o \
- "$default_display_charset" = "cross" -o \
"$default_unix_charset" = "cross"
then
samba_cv_HAVE_NATIVE_ICONV=cross
@@ -2711,11 +2737,10 @@ for i in $ICONV_LOOK_DIRS ; do
# match the results we get at runtime anyway.
if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"cross" ; then
default_dos_charset="CP850"
- default_display_charset="ASCII"
default_unix_charset="UTF-8"
samba_cv_HAVE_NATIVE_ICONV=yes
AC_MSG_WARN(assuming the libiconv in $iconv_current_LDFLAGS can convert)
- AC_MSG_WARN([$default_dos_charset, $default_display_charset and $default_unix_charset to UCS-16LE])
+ AC_MSG_WARN([$default_dos_charset and $default_unix_charset to UCS-16LE])
fi
if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then
@@ -2734,12 +2759,10 @@ for i in $ICONV_LOOK_DIRS ; do
# Turn the #defines into string literals
default_dos_charset="\"$default_dos_charset\""
- default_display_charset="\"$default_display_charset\""
default_unix_charset="\"$default_unix_charset\""
AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
- AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
break
@@ -2761,7 +2784,6 @@ if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; th
AC_MSG_WARN([Sufficient support for iconv function was not found.
Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
- AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
fi
@@ -3571,16 +3593,16 @@ else
# Check to see whether there is enough LDAP functionality to be able
# to build AD support.
-# HPUX only has ldap_init; ok, we take care of this in smbldap.c
+# HPUX and Solaris only has ldap_init; ok, we take care of this in smbldap.c
case "$host_os" in
- *hpux*)
+ *hpux* | *solaris*)
AC_CHECK_FUNC_EXT(ldap_init,$LDAP_LIBS)
if test x"$ac_cv_func_ext_ldap_init" != x"yes"; then
if test x"$with_ads_support" = x"yes"; then
- AC_MSG_ERROR(Active Directory support on HPUX requires ldap_init)
+ AC_MSG_ERROR(Active Directory support on HPUX or Solaris requires ldap_init)
elif test x"$with_ads_support" = x"auto"; then
- AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
+ AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX or Solaris))
with_ads_support=no
fi
fi
@@ -3630,7 +3652,6 @@ if test x"$with_ads_support" != x"no"; then
;;
yes)
AC_MSG_RESULT(/usr)
- FOUND_KRB5=yes
;;
*)
AC_MSG_RESULT($withval)
@@ -3719,6 +3740,21 @@ if test x"$with_ads_support" != x"no"; then
fi
fi
+ if test x$FOUND_KRB5 = x"no"; then
+ #################################################
+ # see if this box has Solaris MIT kerberos implementation
+ AC_MSG_CHECKING(for Solaris MIT kerberos)
+ if test -x "$KRB5CONFIG" && $KRB5CONFIG --version | grep -s Solaris | grep -s MIT > /dev/null ; then
+ FOUND_KRB5=yes
+ KRB5_LIBS="-lgss -lkrb5"
+ KRB5_CFLAGS="`$KRB5CONFIG --cflags`"
+ KRB5_CPPFLAGS="`$KRB5CONFIG --cflags`"
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ fi
+
ac_save_CFLAGS=$CFLAGS
ac_save_CPPFLAGS=$CPPFLAGS
ac_save_LDFLAGS=$LDFLAGS
@@ -3783,7 +3819,7 @@ if test x"$with_ads_support" != x"no"; then
# now check for gssapi headers. This is also done here to allow for
# different kerberos include paths
- AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h)
+ AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h gssapi/gssapi_krb5.h com_err.h)
##################################################################
# we might need the k5crypto and com_err libraries on some systems
@@ -3808,6 +3844,7 @@ if test x"$with_ads_support" != x"no"; then
# now see if we can find the gssapi libs in standard paths
if test x"$have_gssapi" != x"yes"; then
AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
+ AC_CHECK_LIB_EXT(gss, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
AC_CHECK_FUNC_EXT(gss_wrap_iov, $KRB5_LIBS)
fi
@@ -3861,6 +3898,15 @@ if test x"$with_ads_support" != x"no"; then
AC_CHECK_FUNC_EXT(krb5_get_host_realm, $KRB5_LIBS)
AC_CHECK_FUNC_EXT(krb5_free_host_realm, $KRB5_LIBS)
AC_CHECK_FUNC_EXT(gss_krb5_import_cred, $KRB5_LIBS)
+ AC_CHECK_FUNC_EXT(gss_get_name_attribute, $KRB5_LIBS)
+ AC_CHECK_FUNC_EXT(gss_mech_krb5, $KRB5_LIBS)
+ AC_CHECK_FUNC_EXT(gss_oid_equal, $KRB5_LIBS)
+ AC_CHECK_FUNC_EXT(gss_inquire_sec_context_by_oid, $KRB5_LIBS)
+
+ # This is for FreeBSD (and possibly others). gss_mech_krb5 is a
+ # #define to GSS_KRB5_MECHANISM, which is defined in -lgssapi_krb5
+ AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS, GSS_KRB5_MECHANISM,
+ [KRB5_LIBS="$KRB5_LIBS -lgssapi_krb5"])
# MIT krb5 1.8 does not expose this call (yet)
AC_CHECK_DECLS(krb5_get_credentials_for_user, [], [], [#include <krb5.h>])
@@ -6364,6 +6410,7 @@ else
LIBWBCLIENT_SHARED_TARGET=bin/libwbclient.$SHLIBEXT
LIBWBCLIENT_STATIC_TARGET=bin/libwbclient.a
LIBWBCLIENT_SOVER=0
+ LIBWBCLIENT_FULLVER=0
if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then
NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
## Only worry about libwbclient if we have shared
@@ -6647,7 +6694,9 @@ if test x"$enable_pthreadpool" = x"yes" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; t
LIBS="$LIBS $PTHREAD_LDFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
AC_DEFINE(WITH_PTHREADPOOL, 1, [Whether to include pthreadpool helpers])
- AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool.o")
+ AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool/pthreadpool.o")
+ PTHREADPOOLTEST="bin/pthreadpooltest\$(EXEEXT)"
+ AC_SUBST(PTHREADPOOLTEST)
fi
#################################################
@@ -6870,6 +6919,7 @@ SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", V
SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_gpfs_hsm_notify, \$(VFS_GPFS_PREFETCH_OBJ), "bin/gpfs_hsm_notify.$SHLIBEXT", VFS)
SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS)
SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
diff --git a/source3/dynconfig.c b/source3/dynconfig.c
deleted file mode 100644
index 32f64a6e22c..00000000000
--- a/source3/dynconfig.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) 2001 by Martin Pool <mbp@samba.org>
- Copyright (C) 2003 by Jim McDonough <jmcd@us.ibm.com>
- Copyright (C) 2007 by Jeremy Allison <jra@samba.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-/**
- * @file dynconfig.c
- *
- * @brief Global configurations, initialized to configured defaults.
- *
- * This file should be the only file that depends on path
- * configuration (--prefix, etc), so that if ./configure is re-run,
- * all programs will be appropriately updated. Everything else in
- * Samba should import extern variables from here, rather than relying
- * on preprocessor macros.
- *
- * Eventually some of these may become even more variable, so that
- * they can for example consistently be set across the whole of Samba
- * by command-line parameters, config file entries, or environment
- * variables.
- *
- * @todo Perhaps eventually these should be merged into the parameter
- * table? There's kind of a chicken-and-egg situation there...
- **/
-
-#define DEFINE_DYN_CONFIG_PARAM(name) \
-static char *dyn_##name; \
-\
- const char *get_dyn_##name(void) \
-{\
- if (dyn_##name == NULL) {\
- return name;\
- }\
- return dyn_##name;\
-}\
-\
- const char *set_dyn_##name(const char *newpath) \
-{\
- if (dyn_##name) {\
- SAFE_FREE(dyn_##name);\
- }\
- dyn_##name = SMB_STRDUP(newpath);\
- return dyn_##name;\
-}\
-\
- bool is_default_dyn_##name(void) \
-{\
- return (dyn_##name == NULL);\
-}
-
-DEFINE_DYN_CONFIG_PARAM(SBINDIR)
-DEFINE_DYN_CONFIG_PARAM(BINDIR)
-DEFINE_DYN_CONFIG_PARAM(SWATDIR)
-DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/
-DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/
-DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/
-DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR)
-DEFINE_DYN_CONFIG_PARAM(LIBDIR)
-DEFINE_DYN_CONFIG_PARAM(MODULESDIR)
-DEFINE_DYN_CONFIG_PARAM(SHLIBEXT)
-DEFINE_DYN_CONFIG_PARAM(LOCKDIR)
-DEFINE_DYN_CONFIG_PARAM(STATEDIR) /** Persistent state files. Default LOCKDIR */
-DEFINE_DYN_CONFIG_PARAM(CACHEDIR) /** Temporary cache files. Default LOCKDIR */
-DEFINE_DYN_CONFIG_PARAM(PIDDIR)
-DEFINE_DYN_CONFIG_PARAM(NMBDSOCKETDIR)
-DEFINE_DYN_CONFIG_PARAM(NCALRPCDIR)
-DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE)
-DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR)
-DEFINE_DYN_CONFIG_PARAM(LOCALEDIR)
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 3646e04d0a3..70c96f186ce 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -26,6 +26,7 @@
#include "groupdb/mapping.h"
#include "../libcli/security/security.h"
#include "lib/winbind_util.h"
+#include "tdb_compat.h"
static const struct mapping_backend *backend;
@@ -634,7 +635,7 @@ NTSTATUS pdb_default_alias_memberships(struct pdb_methods *methods,
return NT_STATUS_OK;
}
- *pp_alias_rids = TALLOC_ARRAY(mem_ctx, uint32, num_alias_sids);
+ *pp_alias_rids = talloc_array(mem_ctx, uint32, num_alias_sids);
if (*pp_alias_rids == NULL)
return NT_STATUS_NO_MEMORY;
@@ -777,8 +778,8 @@ NTSTATUS pdb_create_builtin_alias(uint32 rid)
map.gid = gid;
sid_copy(&map.sid, &sid);
map.sid_name_use = SID_NAME_ALIAS;
- fstrcpy(map.nt_name, groupname);
- fstrcpy(map.comment, "");
+ strlcpy(map.nt_name, groupname, sizeof(map.nt_name));
+ strlcpy(map.comment, "", sizeof(map.comment));
status = pdb_add_group_mapping_entry(&map);
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index 1137b8f6587..fc195cb3487 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -25,6 +25,7 @@
#include "passdb.h"
#include "groupdb/mapping.h"
#include "dbwrap.h"
+#include "util_tdb.h"
#include "../libcli/security/security.h"
static struct db_context *db; /* used for driver files */
@@ -144,7 +145,7 @@ static bool add_mapping_entry(GROUP_MAP *map, int flag)
len = tdb_pack(NULL, 0, "ddff",
map->gid, map->sid_name_use, map->nt_name, map->comment);
- buf = TALLOC_ARRAY(key, char, len);
+ buf = talloc_array(key, char, len);
if (!buf) {
TALLOC_FREE(key);
return false;
@@ -848,7 +849,7 @@ static int convert_ldb_record(TDB_CONTEXT *ltdb, TDB_DATA key,
p += len + 1;
num_vals = pull_uint32(p, 0);
- if (StrCaseCmp(name, "member") == 0) {
+ if (strcasecmp_m(name, "member") == 0) {
num_mem = num_vals;
members = talloc_array(tmp_ctx, struct dom_sid, num_mem);
if (members == NULL) {
@@ -881,30 +882,30 @@ static int convert_ldb_record(TDB_CONTEXT *ltdb, TDB_DATA key,
/* we ignore unknown or uninteresting attributes
* (objectclass, etc.) */
- if (StrCaseCmp(name, "gidNumber") == 0) {
+ if (strcasecmp_m(name, "gidNumber") == 0) {
map.gid = strtoul(val, &q, 10);
if (*q) {
errno = EIO;
goto failed;
}
- } else if (StrCaseCmp(name, "sid") == 0) {
+ } else if (strcasecmp_m(name, "sid") == 0) {
if (!string_to_sid(&map.sid, val)) {
errno = EIO;
goto failed;
}
- } else if (StrCaseCmp(name, "sidNameUse") == 0) {
+ } else if (strcasecmp_m(name, "sidNameUse") == 0) {
map.sid_name_use = strtoul(val, &q, 10);
if (*q) {
errno = EIO;
goto failed;
}
- } else if (StrCaseCmp(name, "ntname") == 0) {
+ } else if (strcasecmp_m(name, "ntname") == 0) {
strlcpy(map.nt_name, val,
- sizeof(map.nt_name) -1);
- } else if (StrCaseCmp(name, "comment") == 0) {
+ sizeof(map.nt_name));
+ } else if (strcasecmp_m(name, "comment") == 0) {
strlcpy(map.comment, val,
- sizeof(map.comment) -1);
- } else if (StrCaseCmp(name, "member") == 0) {
+ sizeof(map.comment));
+ } else if (strcasecmp_m(name, "member") == 0) {
if (!string_to_sid(&members[j], val)) {
errno = EIO;
goto failed;
@@ -959,7 +960,7 @@ static bool mapping_switch(const char *ldb_path)
/* ldb is just a very fancy tdb, read out raw data and perform
* conversion */
ret = tdb_traverse(ltdb, convert_ldb_record, NULL);
- if (ret == -1) goto failed;
+ if (ret < 0) goto failed;
if (ltdb) {
tdb_close(ltdb);
diff --git a/source3/groupdb/proto.h b/source3/groupdb/proto.h
index 11162e6d3c7..db07d4d64f5 100644
--- a/source3/groupdb/proto.h
+++ b/source3/groupdb/proto.h
@@ -1,3 +1,28 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Group Mapping Database
+ *
+ * Copyright (C) Andrew Tridgell 1992-2006
+ * Copyright (C) Jean François Micouleau 1998-2001
+ * Copyright (C) Gerald Carter 2006
+ * Copyright (C) Volker Lendecke 2006
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GROUPDB_PROTO_H_
+#define _GROUPDB_PROTO_H_
/* The following definitions come from groupdb/mapping.c */
@@ -73,3 +98,5 @@ NTSTATUS pdb_create_builtin_alias(uint32 rid);
/* The following definitions come from groupdb/mapping_tdb.c */
const struct mapping_backend *groupdb_tdb_init(void);
+
+#endif /* _GROUPDB_PROTO_H_ */
diff --git a/source3/include/ads.h b/source3/include/ads.h
index ee6e5b8649b..8a8ce28e530 100644
--- a/source3/include/ads.h
+++ b/source3/include/ads.h
@@ -6,6 +6,7 @@
basically this is a wrapper around ldap
*/
+#include "libads/ads_status.h"
#include "smb_ldap.h"
struct ads_struct;
diff --git a/source3/include/async_smb.h b/source3/include/async_smb.h
index d2303cc7036..1685d4985d4 100644
--- a/source3/include/async_smb.h
+++ b/source3/include/async_smb.h
@@ -20,7 +20,7 @@
#ifndef __ASYNC_SMB_H__
#define __ASYNC_SMB_H__
-#include "includes.h"
+struct cli_state;
/*
* Fetch an error out of a NBT packet
@@ -51,6 +51,8 @@ void cli_smb_req_unset_pending(struct tevent_req *req);
bool cli_smb_req_set_pending(struct tevent_req *req);
uint16_t cli_smb_req_mid(struct tevent_req *req);
void cli_smb_req_set_mid(struct tevent_req *req, uint16_t mid);
+uint32_t cli_smb_req_seqnum(struct tevent_req *req);
+void cli_smb_req_set_seqnum(struct tevent_req *req, uint32_t seqnum);
struct tevent_req *cli_smb_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct cli_state *cli,
uint8_t smb_command, uint8_t additional_flags,
diff --git a/source3/include/autoconf/README b/source3/include/autoconf/README
new file mode 100644
index 00000000000..21afbc70eab
--- /dev/null
+++ b/source3/include/autoconf/README
@@ -0,0 +1,5 @@
+This directory added so that the autoconf build can generate a
+config.h in a location that the recursive waf build for smbtorture
+won't find.
+
+Andrew Bartlett \ No newline at end of file
diff --git a/source3/include/client.h b/source3/include/client.h
index 9e4a61dbacb..a853e90af64 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -46,13 +46,6 @@ struct print_job_info {
time_t t;
};
-struct cli_state_seqnum {
- struct cli_state_seqnum *prev, *next;
- uint16_t mid;
- uint32_t seqnum;
- bool persistent;
-};
-
struct cli_state {
/**
* A list of subsidiary connections for DFS.
@@ -71,7 +64,7 @@ struct cli_state {
int rap_error;
int privileges;
- fstring desthost;
+ char *desthost;
/* The credentials used to open the cli_state connection. */
char *domain;
@@ -83,12 +76,12 @@ struct cli_state {
* ones returned by the server if
* the protocol > NT1.
*/
- fstring server_type;
- fstring server_os;
- fstring server_domain;
+ char *server_type;
+ char *server_os;
+ char *server_domain;
- fstring share;
- fstring dev;
+ char *share;
+ char *dev;
struct nmb_name called;
struct nmb_name calling;
struct sockaddr_storage dest_ss;
@@ -103,12 +96,12 @@ struct cli_state {
size_t max_xmit;
size_t max_mux;
char *outbuf;
- struct cli_state_seqnum *seqnum;
char *inbuf;
unsigned int bufsize;
int initialised;
int win95;
bool is_samba;
+ bool is_guestlogin;
uint32 capabilities;
/* What the server offered. */
uint32_t server_posix_capabilities;
diff --git a/source3/include/packet.h b/source3/include/ctdb_packet.h
index c96a8017f89..026b23f90e4 100644
--- a/source3/include/packet.h
+++ b/source3/include/ctdb_packet.h
@@ -1,6 +1,6 @@
-/*
+/*
Unix SMB/CIFS implementation.
- Packet handling
+ CTDB Packet handling
Copyright (C) Volker Lendecke 2007
This program is free software; you can redistribute it and/or modify
@@ -18,35 +18,35 @@
*/
/*
- * A packet context is a wrapper around a bidirectional file descriptor,
+ * A ctdb_packet context is a wrapper around a bidirectional file descriptor,
* hiding the handling of individual requests.
*/
-struct packet_context;
+struct ctdb_packet_context;
/*
- * Initialize a packet context. The fd is given to the packet context, meaning
- * that it is automatically closed when the packet context is freed.
+ * Initialize a ctdb_packet context. The fd is given to the ctdb_packet context, meaning
+ * that it is automatically closed when the ctdb_packet context is freed.
*/
-struct packet_context *packet_init(TALLOC_CTX *mem_ctx, int fd);
+struct ctdb_packet_context *ctdb_packet_init(TALLOC_CTX *mem_ctx, int fd);
/*
* Pull data from the fd
*/
-NTSTATUS packet_fd_read(struct packet_context *ctx);
+NTSTATUS ctdb_packet_fd_read(struct ctdb_packet_context *ctx);
/*
* Sync read, wait for the next chunk
*/
-NTSTATUS packet_fd_read_sync(struct packet_context *ctx, int timeout);
+NTSTATUS ctdb_packet_fd_read_sync_timeout(struct ctdb_packet_context *ctx, int timeout);
/*
- * Handle an incoming packet:
+ * Handle an incoming ctdb_packet:
* Return False if none is available
* Otherwise return True and store the callback result in *status
* Callback must either talloc_move or talloc_free buf
*/
-bool packet_handler(struct packet_context *ctx,
+bool ctdb_packet_handler(struct ctdb_packet_context *ctx,
bool (*full_req)(const uint8_t *buf,
size_t available,
size_t *length,
@@ -59,27 +59,27 @@ bool packet_handler(struct packet_context *ctx,
/*
* How many bytes of outgoing data do we have pending?
*/
-size_t packet_outgoing_bytes(struct packet_context *ctx);
+size_t ctdb_packet_outgoing_bytes(struct ctdb_packet_context *ctx);
/*
* Push data to the fd
*/
-NTSTATUS packet_fd_write(struct packet_context *ctx);
+NTSTATUS ctdb_packet_fd_write(struct ctdb_packet_context *ctx);
/*
* Sync flush all outgoing bytes
*/
-NTSTATUS packet_flush(struct packet_context *ctx);
+NTSTATUS ctdb_packet_flush(struct ctdb_packet_context *ctx);
/*
* Send a list of DATA_BLOBs
*
- * Example: packet_send(ctx, 2, data_blob_const(&size, sizeof(size)),
+ * Example: ctdb_packet_send(ctx, 2, data_blob_const(&size, sizeof(size)),
* data_blob_const(buf, size));
*/
-NTSTATUS packet_send(struct packet_context *ctx, int num_blobs, ...);
+NTSTATUS ctdb_packet_send(struct ctdb_packet_context *ctx, int num_blobs, ...);
/*
- * Get the packet context's file descriptor
+ * Get the ctdb_packet context's file descriptor
*/
-int packet_get_fd(struct packet_context *ctx);
+int ctdb_packet_get_fd(struct ctdb_packet_context *ctx);
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index ef291fb4ad6..3d712674e01 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -20,6 +20,8 @@
#ifndef _CTDBD_CONN_H
#define _CTDBD_CONN_H
+#include "tdb_compat.h"
+
struct ctdbd_connection;
struct messaging_context;
struct messaging_rec;
diff --git a/source3/include/dbwrap.h b/source3/include/dbwrap.h
index ef35b0071d0..303a5549381 100644
--- a/source3/include/dbwrap.h
+++ b/source3/include/dbwrap.h
@@ -20,6 +20,8 @@
#ifndef __DBWRAP_H__
#define __DBWRAP_H__
+#include "tdb_compat.h"
+
struct db_record {
TDB_DATA key, value;
NTSTATUS (*store)(struct db_record *rec, TDB_DATA data, int flag);
diff --git a/source3/include/dynconfig.h b/source3/include/dynconfig.h
deleted file mode 100644
index d0e42dc9f51..00000000000
--- a/source3/include/dynconfig.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) 2001 by Martin Pool <mbp@samba.org>
- Copyright (C) 2003 by Jim McDonough <jmcd@us.ibm.com>
-
- 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/>.
-*/
-
-/**
- * @file dynconfig.h
- *
- * @brief Exported global configurations.
- **/
-
-const char *get_dyn_SBINDIR(void);
-const char *set_dyn_SBINDIR(const char *newpath);
-bool is_default_dyn_SBINDIR(void);
-
-const char *get_dyn_BINDIR(void);
-const char *set_dyn_BINDIR(const char *newpath);
-bool is_default_dyn_BINDIR(void);
-
-const char *get_dyn_SWATDIR(void);
-const char *set_dyn_SWATDIR(const char *newpath);
-bool is_default_dyn_SWATDIR(void);
-
-const char *get_dyn_CONFIGFILE(void);
-const char *set_dyn_CONFIGFILE(const char *newpath);
-bool is_default_dyn_CONFIGFILE(void);
-
-const char *get_dyn_LOGFILEBASE(void);
-const char *set_dyn_LOGFILEBASE(const char *newpath);
-bool is_default_dyn_LOGFILEBASE(void);
-
-const char *get_dyn_LMHOSTSFILE(void);
-const char *set_dyn_LMHOSTSFILE(const char *newpath);
-bool is_default_dyn_LMHOSTSFILE(void);
-
-const char *get_dyn_CODEPAGEDIR(void);
-const char *set_dyn_CODEPAGEDIR(const char *newpath);
-bool is_default_dyn_CODEPAGEDIR(void);
-
-const char *get_dyn_LIBDIR(void);
-const char *set_dyn_LIBDIR(const char *newpath);
-bool is_default_dyn_LIBDIR(void);
-
-const char *get_dyn_MODULESDIR(void);
-const char *set_dyn_MODULESDIR(const char *newpath);
-bool is_default_dyn_MODULESDIR(void);
-
-const char *get_dyn_SHLIBEXT(void);
-const char *set_dyn_SHLIBEXT(const char *newpath);
-bool is_default_dyn_SHLIBEXT(void);
-
-const char *get_dyn_LOCKDIR(void);
-const char *set_dyn_LOCKDIR(const char *newpath);
-bool is_default_dyn_LOCKDIR(void);
-
-const char *get_dyn_STATEDIR(void);
-const char *set_dyn_STATEDIR(const char *newpath);
-bool is_default_dyn_STATEDIR(void);
-
-const char *get_dyn_CACHEDIR(void);
-const char *set_dyn_CACHEDIR(const char *newpath);
-bool is_default_dyn_CACHEDIR(void);
-
-const char *get_dyn_PIDDIR(void);
-const char *set_dyn_PIDDIR(const char *newpath);
-bool is_default_dyn_PIDDIR(void);
-
-const char *get_dyn_NMBDSOCKETDIR(void);
-const char *set_dyn_NMBDSOCKETDIR(const char *newpath);
-bool is_default_dyn_NMBDSOCKETDIR(void);
-
-const char *get_dyn_NCALRPCDIR(void);
-const char *set_dyn_NCALRPCDIR(const char *newpath);
-bool is_default_dyn_NCALRPCDIR(void);
-
-const char *get_dyn_SMB_PASSWD_FILE(void);
-const char *set_dyn_SMB_PASSWD_FILE(const char *newpath);
-bool is_default_dyn_SMB_PASSWD_FILE(void);
-
-const char *get_dyn_PRIVATE_DIR(void);
-const char *set_dyn_PRIVATE_DIR(const char *newpath);
-bool is_default_dyn_PRIVATE_DIR(void);
-
-const char *get_dyn_LOCALEDIR(void);
-const char *set_dyn_LOCALEDIR(const char *newpath);
-bool is_default_dyn_LOCALEDIR(void);
diff --git a/source3/include/includes.h b/source3/include/includes.h
index a76942faad5..08d5d96ab55 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -173,10 +173,6 @@
#include <aio.h>
#endif
-#ifdef WITH_MADVISE_PROTECTED
-#include <sys/mman.h>
-#endif
-
/* Special macros that are no-ops except when run under Valgrind on
* x86. They've moved a little bit from valgrind 1.0.4 to 1.9.4 */
#if HAVE_VALGRIND_MEMCHECK_H
@@ -308,10 +304,10 @@ typedef sig_atomic_t volatile SIG_ATOMIC_T;
#endif
#ifdef LARGE_SMB_INO_T
-#define SINO_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), SIVAL((p),(ofs)+4,(v)>>32))
-#define INO_T_VAL(p, ofs) ((SMB_INO_T)(((uint64_t)(IVAL(p,ofs)))| (((uint64_t)(IVAL(p,(ofs)+4))) << 32)))
+#define SINO_T_VAL(p, ofs, v) SBVAL(p, ofs, v)
+#define INO_T_VAL(p, ofs) ((SMB_INO_T)BVAL(p, ofs))
#else
-#define SINO_T_VAL(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
+#define SINO_T_VAL(p, ofs, v) SBVAL(p, ofs, ((uint64_t)(v)) & UINT32_MAX)
#define INO_T_VAL(p, ofs) ((SMB_INO_T)(IVAL((p),(ofs))))
#endif
@@ -323,11 +319,10 @@ typedef sig_atomic_t volatile SIG_ATOMIC_T;
# endif
#endif
-#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
-#define BIG_UINT(p, ofs) ((((uint64_t) IVAL(p,(ofs)+4))<<32)|IVAL(p,ofs))
-#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((uint64_t)(IVAL((buf),(off)))) & ((uint64_t)0xFFFFFFFF)) | \
- (( ((uint64_t)(IVAL((buf),(off+4)))) & ((uint64_t)0xFFFFFFFF) ) << 32 ) )
-
+/* TODO: remove this macros */
+#define SBIG_UINT(p, ofs, v) SBVAL(p, ofs, v)
+#define BIG_UINT(p, ofs) BVAL(p, ofs)
+#define IVAL2_TO_SMB_BIG_UINT(p, ofs) BVAL(p, ofs)
/* this should really be a 64 bit type if possible */
typedef uint64_t br_off;
@@ -515,53 +510,30 @@ typedef char fstring[FSTRING_LEN];
#include "../lib/util/attr.h"
#include "../lib/util/tsort.h"
#include "../lib/util/dlinklist.h"
-#include <tdb.h>
-#include "util_tdb.h"
#include <talloc.h>
#include "event.h"
-#include "../lib/util/tevent_unix.h"
-#include "../lib/util/tevent_ntstatus.h"
-#include "../lib/tsocket/tsocket.h"
#include "../lib/util/data_blob.h"
#include "../lib/util/time.h"
#include "../lib/util/debug.h"
#include "../lib/util/debug_s3.h"
-#include "libads/ads_status.h"
+#include "../libcli/util/ntstatus.h"
#include "../libcli/util/error.h"
#include "../lib/util/charset/charset.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#include "locking.h"
#include "smb_perfcount.h"
#include "smb.h"
#include "../lib/util/byteorder.h"
-#include "client.h"
-
#include "module.h"
#include "../lib/util/talloc_stack.h"
#include "../lib/util/smb_threads.h"
#include "../lib/util/smb_threads_internal.h"
-/*
- * Reasons for cache flush.
- */
-
-enum flush_reason_enum {
- SEEK_FLUSH,
- READ_FLUSH,
- WRITE_FLUSH,
- READRAW_FLUSH,
- OPLOCK_RELEASE_FLUSH,
- CLOSE_FLUSH,
- SYNC_FLUSH,
- SIZECHANGE_FLUSH,
- /* NUM_FLUSH_REASONS must remain the last value in the enumeration. */
- NUM_FLUSH_REASONS};
-
/***** prototypes *****/
#ifndef NO_PROTO_H
#include "proto.h"
@@ -606,15 +578,6 @@ enum flush_reason_enum {
#endif
-#if HAVE_KERNEL_SHARE_MODES
-#ifndef LOCK_MAND
-#define LOCK_MAND 32 /* This is a mandatory flock */
-#define LOCK_READ 64 /* ... Which allows concurrent read operations */
-#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
-#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
-#endif
-#endif
-
#define MAX_SEC_CTX_DEPTH 8 /* Maximum number of security contexts */
@@ -645,8 +608,6 @@ void sys_adminlog(int priority, const char *format_str, ...) PRINTF_ATTRIBUTE(2,
/* PRINTFLIKE2 */
int fstr_sprintf(fstring s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-int d_vfprintf(FILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
-
int smb_xvasprintf(char **ptr, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
int asprintf_strupper_m(char **strp, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
@@ -685,20 +646,11 @@ char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...) PRINTF_ATT
#undef HAVE_MMAP
#endif
-#ifndef CONST_DISCARD
-#define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
-#endif
-
void dump_core(void) _NORETURN_;
void exit_server(const char *const reason) _NORETURN_;
void exit_server_cleanly(const char *const reason) _NORETURN_;
void exit_server_fault(void) _NORETURN_;
-#if defined(HAVE_IPV6)
-void in6_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
- struct in6_addr ip);
-#endif
-
/* samba3 doesn't use uwrap yet */
#define uwrap_enabled() 0
diff --git a/source3/include/interfaces.h b/source3/include/interfaces.h
deleted file mode 100644
index 6ba0e21f6dd..00000000000
--- a/source3/include/interfaces.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Machine customisation and include handling
- Copyright (C) Jeremy Allison <jra@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/>.
-*/
-/*
- This structure is used by lib/interfaces.c to return the list of network
- interfaces on the machine
-*/
-
-#ifndef _INTERFACES_H
-#define _INTERFACES_H
-
-#include "../replace/replace.h"
-#include "../replace/system/network.h"
-
-struct iface_struct {
- char name[16];
- int flags;
- struct sockaddr_storage ip;
- struct sockaddr_storage netmask;
- struct sockaddr_storage bcast;
-};
-
-bool make_netmask(struct sockaddr_storage *pss_out,
- const struct sockaddr_storage *pss_in,
- unsigned long masklen);
-void make_bcast(struct sockaddr_storage *pss_out,
- const struct sockaddr_storage *pss_in,
- const struct sockaddr_storage *nmask);
-void make_net(struct sockaddr_storage *pss_out,
- const struct sockaddr_storage *pss_in,
- const struct sockaddr_storage *nmask);
-int get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces);
-
-#endif
diff --git a/source3/include/krb5_env.h b/source3/include/krb5_env.h
index aa967953928..0022da839c1 100644
--- a/source3/include/krb5_env.h
+++ b/source3/include/krb5_env.h
@@ -1,2 +1,26 @@
+/*
+ Samba Unix/Linux SMB client library
+
+ Copyright (C) 2010 Günther Deschner
+
+ 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 _INCLUDE_KRB5_ENV_H_
+#define _INCLUDE_KRB5_ENV_H_
+
/* Kerberos environment variable names */
#define KRB5_ENV_CCNAME "KRB5CCNAME"
+
+#endif /* _INCLUDE_KRB5_ENV_H_ */
diff --git a/source3/include/krb5_protos.h b/source3/include/krb5_protos.h
index d80e77d2eb6..37fc1c6cd51 100644
--- a/source3/include/krb5_protos.h
+++ b/source3/include/krb5_protos.h
@@ -1,3 +1,28 @@
+/*
+ Unix SMB/CIFS implementation.
+ simple kerberos5 routines for active directory
+ Copyright (C) Andrew Tridgell 2001
+ Copyright (C) Luke Howard 2002-2003
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
+ Copyright (C) Guenther Deschner 2005-2009
+
+ 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 _INCLUDE_KRB5_PROTOS_H_
+#define _INCLUDE_KRB5_PROTOS_H_
+
struct PAC_DATA;
struct PAC_SIGNATURE_DATA;
@@ -39,6 +64,8 @@ void krb5_free_unparsed_name(krb5_context ctx, char *val);
#define initialize_krb5_error_table()
#endif
+/* The following definitions come from libsmb/clikrb5.c */
+
/* Samba wrapper function for krb5 functionality. */
bool setup_kaddr( krb5_address *pkaddr, struct sockaddr_storage *paddr);
int create_kerberos_key_from_string(krb5_context context, krb5_principal host_princ, krb5_data *password, krb5_keyblock *key, krb5_enctype enctype, bool no_salt);
@@ -131,3 +158,9 @@ int cli_krb5_get_ticket(TALLOC_CTX *mem_ctx,
time_t *tgs_expire,
const char *impersonate_princ_s);
+bool unwrap_edata_ntstatus(TALLOC_CTX *mem_ctx,
+ DATA_BLOB *edata,
+ DATA_BLOB *edata_out);
+bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_pac_data);
+
+#endif /* _INCLUDE_KRB5_PROTOS_H_ */
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index 61dc95e0ad6..7f16ab6859b 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -366,7 +366,7 @@ SMBC_close_ctx(SMBCCTX *context,
bool
SMBC_getatr(SMBCCTX * context,
SMBCSRV *srv,
- char *path,
+ const char *path,
uint16 *mode,
SMB_OFF_T *size,
struct timespec *create_time_ts,
diff --git a/source3/include/mangle.h b/source3/include/mangle.h
index c07b852453e..7c4602b4eba 100644
--- a/source3/include/mangle.h
+++ b/source3/include/mangle.h
@@ -1,3 +1,22 @@
+/*
+ Unix SMB/CIFS implementation.
+ Name mangling interface
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#ifndef _MANGLE_H_
#define _MANGLE_H_
/*
diff --git a/source3/include/messages.h b/source3/include/messages.h
index a78599055d2..41d5bb19fdb 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -49,13 +49,6 @@
/*
- * Virtual Node Numbers are identifying a node within a cluster. Ctdbd sets
- * this, we retrieve our vnn from it.
- */
-
-#define NONCLUSTER_VNN (0xFFFFFFFF)
-
-/*
* ctdb gives us 64-bit server ids for messaging_send. This is done to avoid
* pid clashes and to be able to register for special messages like "all
* smbds".
diff --git a/source3/include/nss_info.h b/source3/include/nss_info.h
index bf66ef0a8cc..f92937e990d 100644
--- a/source3/include/nss_info.h
+++ b/source3/include/nss_info.h
@@ -95,5 +95,12 @@ NTSTATUS nss_map_from_alias( TALLOC_CTX *mem_ctx, const char *domain,
NTSTATUS nss_close( const char *parameters );
+/* The following definitions come from winbindd/nss_info.c */
+
+
+/* The following definitions come from winbindd/nss_info_template.c */
+
+NTSTATUS nss_info_template_init( void );
+
#endif /* _IDMAP_NSS_H_ */
diff --git a/source3/include/nt_printing.h b/source3/include/nt_printing.h
index 02a72b32f19..ad6262ecff0 100644
--- a/source3/include/nt_printing.h
+++ b/source3/include/nt_printing.h
@@ -23,7 +23,7 @@
#define NT_PRINTING_H_
#include "client.h"
-#include "../librpc/gen_ndr/srv_spoolss.h"
+#include "../librpc/gen_ndr/spoolss.h"
#ifndef SAMBA_PRINTER_PORT_NAME
#define SAMBA_PRINTER_PORT_NAME "Samba Printer Port"
@@ -169,11 +169,11 @@ bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
bool delete_driver_files(const struct auth_serversupplied_info *server_info,
const struct spoolss_DriverInfo8 *r);
-WERROR move_driver_to_download_area(struct pipes_struct *p,
+WERROR move_driver_to_download_area(struct auth_serversupplied_info *session_info,
struct spoolss_AddDriverInfoCtr *r);
WERROR clean_up_driver_struct(TALLOC_CTX *mem_ctx,
- struct pipes_struct *rpc_pipe,
+ struct auth_serversupplied_info *session_info,
struct spoolss_AddDriverInfoCtr *r);
void map_printer_permissions(struct security_descriptor *sd);
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index 077924d6f48..ff728736d48 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -86,7 +86,8 @@ typedef struct pipe_rpc_fns {
const struct api_struct *cmds;
int n_cmds;
- uint32 context_id;
+ uint32_t context_id;
+ struct ndr_syntax_id syntax;
} PIPE_RPC_FNS;
@@ -97,20 +98,6 @@ typedef struct pipe_rpc_fns {
struct gse_context;
-/* auth state for all bind types. */
-
-struct pipe_auth_data {
- enum dcerpc_AuthType auth_type;
- enum dcerpc_AuthLevel auth_level;
-
- void *auth_ctx;
-
- /* Only the client code uses these 3 for now */
- char *domain;
- char *user_name;
- DATA_BLOB user_session_key;
-};
-
struct dcesrv_ep_entry_list;
/*
@@ -129,7 +116,6 @@ struct pipes_struct {
struct auth_serversupplied_info *session_info;
struct messaging_context *msg_ctx;
- struct ndr_syntax_id syntax;
struct dcesrv_ep_entry_list *ep_entries;
/* linked list of rpc dispatch tables associated
@@ -207,4 +193,33 @@ struct api_struct {
bool (*fn) (struct pipes_struct *);
};
+/* The following definitions come from rpc_server/rpc_handles.c */
+
+size_t num_pipe_handles(struct pipes_struct *p);
+bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *syntax);
+bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
+bool find_policy_by_hnd(struct pipes_struct *p, const struct policy_handle *hnd,
+ void **data_p);
+bool close_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd);
+void close_policy_by_pipe(struct pipes_struct *p);
+bool pipe_access_check(struct pipes_struct *p);
+
+void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,
+ uint32_t access_granted, size_t data_size,
+ const char *type, NTSTATUS *pstatus);
+#define policy_handle_create(_p, _hnd, _access, _type, _pstatus) \
+ (_type *)_policy_handle_create((_p), (_hnd), (_access), sizeof(_type), #_type, \
+ (_pstatus))
+
+void *_policy_handle_find(struct pipes_struct *p,
+ const struct policy_handle *hnd,
+ uint32_t access_required, uint32_t *paccess_granted,
+ const char *name, const char *location,
+ NTSTATUS *pstatus);
+#define policy_handle_find(_p, _hnd, _access_required, _access_granted, _type, _pstatus) \
+ (_type *)_policy_handle_find((_p), (_hnd), (_access_required), \
+ (_access_granted), #_type, __location__, (_pstatus))
+
+#include "rpc_server/srv_pipe_register.h"
+
#endif /* _NT_DOMAIN_H */
diff --git a/source3/include/ntioctl.h b/source3/include/ntioctl.h
index 41b1dcefa25..131d596dedf 100644
--- a/source3/include/ntioctl.h
+++ b/source3/include/ntioctl.h
@@ -2,17 +2,17 @@
Unix SMB/CIFS implementation.
NT ioctl code constants
Copyright (C) Andrew Tridgell 2002
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -69,6 +69,7 @@
#endif
+#define IO_REPARSE_TAG_SYMLINK 0xA000000C
#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
#define IO_REPARSE_TAG_HSM 0xC0000004
#define IO_REPARSE_TAG_SIS 0x80000007
@@ -77,13 +78,12 @@
/* For FSCTL_GET_SHADOW_COPY_DATA ...*/
typedef char SHADOW_COPY_LABEL[25];
-typedef struct shadow_copy_data {
- TALLOC_CTX *mem_ctx;
+struct shadow_copy_data {
/* Total number of shadow volumes currently mounted */
uint32 num_volumes;
/* Concatenated list of labels */
SHADOW_COPY_LABEL *labels;
-} SHADOW_COPY_DATA;
+};
#endif /* _NTIOCTL_H */
diff --git a/source3/include/popt_common.h b/source3/include/popt_common.h
index 70d7278f01d..10dd2f4ebee 100644
--- a/source3/include/popt_common.h
+++ b/source3/include/popt_common.h
@@ -42,7 +42,7 @@ extern const struct poptOption popt_common_dynconfig[];
#define POPT_COMMON_CONFIGFILE { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile, 0, "Common samba config:", NULL },
#define POPT_COMMON_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL },
#define POPT_COMMON_DYNCONFIG { NULL, 0, POPT_ARG_INCLUDE_TABLE, \
- CONST_DISCARD(poptOption *, popt_common_dynconfig), 0, \
+ discard_const_p(poptOption, popt_common_dynconfig), 0, \
"Build-time configuration overrides:", NULL },
#define POPT_COMMON_DEBUGLEVEL { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debuglevel, 0, "Common samba debugging:", NULL },
#define POPT_COMMON_OPTION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_option, 0, "Common samba commandline config:", NULL },
diff --git a/source3/include/printing.h b/source3/include/printing.h
index 084c699c5bd..1bbb72c7be6 100644
--- a/source3/include/printing.h
+++ b/source3/include/printing.h
@@ -24,6 +24,7 @@
This file defines the low-level printing system interfaces used by the
SAMBA printing subsystem.
*/
+#include "tdb_compat.h"
/* Extra fields above "LPQ_PRINTING" are used to map extra NT status codes. */
@@ -160,7 +161,7 @@ extern struct printif iprint_printif;
struct tdb_print_db {
struct tdb_print_db *next, *prev;
- TDB_CONTEXT *tdb;
+ struct tdb_context *tdb;
int ref_count;
fstring printer_name;
};
@@ -249,7 +250,7 @@ uint32_t print_parse_jobid(const char *fname);
struct tdb_print_db *get_print_db_byname(const char *printername);
void release_print_db( struct tdb_print_db *pdb);
void close_all_print_db(void);
-TDB_DATA get_printer_notify_pid_list(TDB_CONTEXT *tdb, const char *printer_name, bool cleanlist);
+TDB_DATA get_printer_notify_pid_list(struct tdb_context *tdb, const char *printer_name, bool cleanlist);
void print_queue_receive(struct messaging_context *msg,
void *private_data,
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 36f0235b02f..90dbafc96c9 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -73,19 +73,6 @@ int bitmap_find(struct bitmap *bm, unsigned ofs);
/* The following definitions come from lib/charcnv.c */
void gfree_charcnv(void);
-void init_iconv(void);
-bool convert_string(charset_t from, charset_t to,
- void const *src, size_t srclen,
- void *dest, size_t destlen,
- size_t *converted_size);
-bool convert_string_error(charset_t from, charset_t to,
- void const *src, size_t srclen,
- void *dest, size_t destlen,
- size_t *converted_size);
-char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *s);
-char *strupper_talloc(TALLOC_CTX *ctx, const char *s);
-char *talloc_strdup_lower(TALLOC_CTX *ctx, const char *s);
-char *strlower_talloc(TALLOC_CTX *ctx, const char *s);
size_t ucs2_align(const void *base_ptr, const void *p, int flags);
size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags);
size_t push_ascii_fstring(void *dest, const char *src);
@@ -93,17 +80,6 @@ size_t push_ascii_nstring(void *dest, const char *src);
size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
size_t pull_ascii_fstring(char *dest, const void *src);
size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src);
-size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags);
-bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
- size_t *converted_size);
-bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src,
- size_t *converted_size);
-bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
- size_t *converted_size);
-bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src,
- size_t *converted_size);
-bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
- size_t *converted_size);
size_t push_string_check_fn(void *dest, const char *src,
size_t dest_len, int flags);
size_t push_string_base(const char *base, uint16 flags2,
@@ -232,7 +208,6 @@ void init_modules(void);
int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
bool is_case_sensitive);
-int gen_fnmatch(const char *pattern, const char *string);
/* The following definitions come from lib/pidfile.c */
@@ -252,47 +227,6 @@ ssize_t sys_recvfile(int fromfd,
size_t count);
ssize_t drain_socket(int sockfd, size_t count);
-/* The following definitions come from lib/secdesc.c */
-
-uint32_t get_sec_info(const struct security_descriptor *sd);
-struct security_descriptor *sec_desc_merge(TALLOC_CTX *ctx, struct security_descriptor *new_sdb, struct security_descriptor *old_sdb);
-struct sec_desc_buf *sec_desc_merge_buf(TALLOC_CTX *ctx, struct sec_desc_buf *new_sdb, struct sec_desc_buf *old_sdb);
-struct security_descriptor *make_sec_desc(TALLOC_CTX *ctx,
- enum security_descriptor_revision revision,
- uint16 type,
- const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
- struct security_acl *sacl, struct security_acl *dacl, size_t *sd_size);
-struct security_descriptor *dup_sec_desc(TALLOC_CTX *ctx, const struct security_descriptor *src);
-NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
- struct security_descriptor *secdesc,
- uint8 **data, size_t *len);
-NTSTATUS marshall_sec_desc_buf(TALLOC_CTX *mem_ctx,
- struct sec_desc_buf *secdesc_buf,
- uint8_t **data, size_t *len);
-NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
- struct security_descriptor **psecdesc);
-NTSTATUS unmarshall_sec_desc_buf(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
- struct sec_desc_buf **psecdesc_buf);
-struct security_descriptor *make_standard_sec_desc(TALLOC_CTX *ctx, const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
- struct security_acl *dacl, size_t *sd_size);
-struct sec_desc_buf *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, struct security_descriptor *sec_desc);
-struct sec_desc_buf *dup_sec_desc_buf(TALLOC_CTX *ctx, struct sec_desc_buf *src);
-NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, const struct dom_sid *sid, uint32 mask, size_t *sd_size);
-NTSTATUS sec_desc_mod_sid(struct security_descriptor *sd, struct dom_sid *sid, uint32 mask);
-NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, struct dom_sid *sid, size_t *sd_size);
-bool sd_has_inheritable_components(const struct security_descriptor *parent_ctr, bool container);
-NTSTATUS se_create_child_secdesc(TALLOC_CTX *ctx,
- struct security_descriptor **ppsd,
- size_t *psize,
- const struct security_descriptor *parent_ctr,
- const struct dom_sid *owner_sid,
- const struct dom_sid *group_sid,
- bool container);
-NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
- struct sec_desc_buf **ppsdb,
- const struct security_descriptor *parent_ctr,
- bool container);
-
/* The following definitions come from lib/sendfile.c */
ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
@@ -386,60 +320,6 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
SMB_ACL_T acl_d);
int sys_acl_delete_def_file(vfs_handle_struct *handle,
const char *path);
-SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
- const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
-int sys_acl_set_file(vfs_handle_struct *handle,
- const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
-int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- SMB_ACL_T acl_d);
-int sys_acl_delete_def_file(vfs_handle_struct *handle,
- const char *path);
-SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
- const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
-int sys_acl_set_file(vfs_handle_struct *handle,
- const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
-int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- SMB_ACL_T acl_d);
-int sys_acl_delete_def_file(vfs_handle_struct *handle,
- const char *path);
-SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
- const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
-int sys_acl_set_file(vfs_handle_struct *handle,
- const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
-int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- SMB_ACL_T acl_d);
-int sys_acl_delete_def_file(vfs_handle_struct *handle,
- const char *path);
-SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
- const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
-int sys_acl_set_file(vfs_handle_struct *handle,
- const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
-int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- SMB_ACL_T acl_d);
-int sys_acl_delete_def_file(vfs_handle_struct *handle,
- const char *path);
-SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
- const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
-int sys_acl_set_file(vfs_handle_struct *handle,
- const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
-int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- SMB_ACL_T acl_d);
-int sys_acl_delete_def_file(vfs_handle_struct *handle,
- const char *path);
-SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
- const char *path_p, SMB_ACL_TYPE_T type);
-SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
-int sys_acl_set_file(vfs_handle_struct *handle,
- const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
-int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
- SMB_ACL_T acl_d);
-int sys_acl_delete_def_file(vfs_handle_struct *handle,
- const char *path);
int no_acl_syscall_error(int err);
/* The following definitions come from lib/sysquotas.c */
@@ -464,7 +344,6 @@ int sys_set_nfs_quota(const char *path, const char *bdev,
/* The following definitions come from lib/system.c */
-void *sys_memalign( size_t align, size_t size );
int sys_usleep(long usecs);
ssize_t sys_read(int fd, void *buf, size_t count);
ssize_t sys_write(int fd, const void *buf, size_t count);
@@ -504,7 +383,7 @@ void sys_rewinddir(SMB_STRUCT_DIR *dirp);
int sys_closedir(SMB_STRUCT_DIR *dirp);
int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
int sys_waitpid(pid_t pid,int *status,int options);
-char *sys_getwd(char *s);
+char *sys_getwd(void);
void set_effective_capability(enum smbd_capability capability);
void drop_effective_capability(enum smbd_capability capability);
long sys_random(void);
@@ -542,15 +421,18 @@ int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb);
int sys_aio_error(const SMB_STRUCT_AIOCB *aiocb);
int sys_aio_fsync(int op, SMB_STRUCT_AIOCB *aiocb);
int sys_aio_suspend(const SMB_STRUCT_AIOCB * const cblist[], int n, const struct timespec *timeout);
-int sys_getpeereid( int s, uid_t *uid);
-int sys_getnameinfo(const struct sockaddr *psa,
- socklen_t salen,
- char *host,
- size_t hostlen,
- char *service,
- size_t servlen,
- int flags);
-int sys_connect(int fd, const struct sockaddr * addr);
+
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_STAT64)
+struct stat64;
+void init_stat_ex_from_stat (struct stat_ex *dst,
+ const struct stat64 *src,
+ bool fake_dir_create_times);
+#else
+struct stat;
+void init_stat_ex_from_stat (struct stat_ex *dst,
+ const struct stat *src,
+ bool fake_dir_create_times);
+#endif
/* The following definitions come from lib/system_smbd.c */
@@ -616,11 +498,6 @@ char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
/* The following definitions come from lib/util_names.c */
-void gfree_netbios_names(void);
-bool set_global_myname(const char *myname);
-const char *global_myname(void);
-bool set_global_myworkgroup(const char *myworkgroup);
-const char *lp_workgroup(void);
const char *get_global_sam_name(void);
/* The following definitions come from lib/util.c */
@@ -628,8 +505,6 @@ const char *get_global_sam_name(void);
enum protocol_types get_Protocol(void);
void set_Protocol(enum protocol_types p);
bool all_zero(const uint8_t *ptr, size_t size);
-bool set_global_scope(const char *scope);
-const char *global_scope(void);
void gfree_names(void);
void gfree_all( void );
const char *my_netbios_names(int i);
@@ -640,8 +515,7 @@ bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
bool socket_exist(const char *fname);
uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
SMB_OFF_T get_file_size(char *file_name);
-char *attrib_string(uint16 mode);
-void show_msg(char *buf);
+void show_msg(const char *buf);
void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num);
void smb_setlen(char *buf,int len);
int set_message_bcc(char *buf,int num_bytes);
@@ -692,14 +566,11 @@ int set_maxfiles(int requested_max);
int smb_mkstemp(char *name_template);
void *smb_xmalloc_array(size_t size, unsigned int count);
char *myhostname(void);
+char *myhostname_upper(void);
char *lock_path(const char *name);
char *pid_path(const char *name);
-char *lib_path(const char *name);
-char *modules_path(const char *name);
-char *data_path(const char *name);
char *state_path(const char *name);
char *cache_path(const char *name);
-const char *shlib_ext(void);
bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
const char **name);
bool ms_has_wild(const char *s);
@@ -722,7 +593,6 @@ bool cluster_id_equal(const struct server_id *id1,
const struct server_id *id2);
bool procid_is_me(const struct server_id *pid);
struct server_id interpret_pid(const char *pid_string);
-char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid);
char *procid_str_static(const struct server_id *pid);
bool procid_valid(const struct server_id *pid);
bool procid_is_local(const struct server_id *pid);
@@ -736,17 +606,13 @@ void split_domain_user(TALLOC_CTX *mem_ctx,
const char *full_name,
char **domain,
char **user);
-void *_talloc_zero_zeronull(const void *ctx, size_t size, const char *name);
-void *_talloc_memdup_zeronull(const void *t, const void *p, size_t size, const char *name);
-void *_talloc_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
-void *_talloc_zero_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
-void *talloc_zeronull(const void *context, size_t size, const char *name);
const char *strip_hostname(const char *s);
bool tevent_req_poll_ntstatus(struct tevent_req *req,
struct tevent_context *ev,
NTSTATUS *status);
bool any_nt_status_not_ok(NTSTATUS err1, NTSTATUS err2, NTSTATUS *result);
int timeval_to_msec(struct timeval t);
+char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname);
/* The following definitions come from lib/util_cmdline.c */
@@ -936,6 +802,7 @@ struct tevent_req *getaddrinfo_send(TALLOC_CTX *mem_ctx,
int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res);
int poll_one_fd(int fd, int events, int timeout, int *revents);
int poll_intr_one_fd(int fd, int events, int timeout, int *revents);
+struct tstream_context;
struct tevent_req *tstream_read_packet_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct tstream_context *stream,
@@ -950,8 +817,6 @@ ssize_t tstream_read_packet_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
/* The following definitions come from lib/util_str.c */
bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize);
-int StrCaseCmp(const char *s, const char *t);
-int StrnCaseCmp(const char *s, const char *t, size_t len);
bool strnequal(const char *s1,const char *s2,size_t n);
bool strcsequal(const char *s1,const char *s2);
void strnorm(char *s, int case_default);
@@ -961,22 +826,10 @@ size_t str_charnum(const char *s);
bool trim_char(char *s,char cfront,char cback);
bool strhasupper(const char *s);
bool strhaslower(const char *s);
-char *safe_strcpy_fn(char *dest,
- const char *src,
- size_t maxlength);
-char *safe_strcat_fn(char *dest,
- const char *src,
- size_t maxlength);
char *StrnCpy(char *dest,const char *src,size_t n);
bool in_list(const char *s, const char *list, bool casesensitive);
void string_free(char **s);
bool string_set(char **dest,const char *src);
-void string_sub2(char *s,const char *pattern, const char *insert, size_t len,
- bool remove_unsafe_characters, bool replace_once,
- bool allow_trailing_dollar);
-void string_sub_once(char *s, const char *pattern,
- const char *insert, size_t len);
-void string_sub(char *s,const char *pattern, const char *insert, size_t len);
void fstring_sub(char *s,const char *pattern,const char *insert);
char *realloc_string_sub2(char *string,
const char *pattern,
@@ -1023,7 +876,7 @@ char *ipstr_list_make(char **ipstr_list,
int ipstr_list_parse(const char *ipstr_list, struct ip_service **ip_list);
void ipstr_list_free(char* ipstr_list);
uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr);
-SMB_OFF_T conv_str_size(const char * str);
+uint64_t conv_str_size(const char * str);
bool add_string_to_array(TALLOC_CTX *mem_ctx,
const char *str, const char ***strings,
int *num);
@@ -1032,7 +885,6 @@ void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
int asprintf_strupper_m(char **strp, const char *fmt, ...);
char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...);
char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...);
-char *sstring_sub(const char *src, char front, char back);
bool validate_net_name( const char *name,
const char *invalid_chars,
int max_len);
@@ -1053,746 +905,10 @@ unsigned wins_srv_count(void);
char **wins_srv_tags(void);
void wins_srv_tags_free(char **list);
struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip);
+bool wins_server_tag_ips(const char *tag, TALLOC_CTX *mem_ctx,
+ struct in_addr **pservers, int *pnum_servers);
unsigned wins_srv_count_tag(const char *tag);
-/* The following definitions come from libsmb/cliconnect.c */
-
-ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
- const char *pass, const char *user_domain,
- const char * dest_realm);
-
-NTSTATUS cli_session_setup(struct cli_state *cli,
- const char *user,
- const char *pass, int passlen,
- const char *ntpass, int ntpasslen,
- const char *workgroup);
-struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- struct tevent_req **psmbreq);
-struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli);
-NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
-struct tevent_req *cli_ulogoff_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli);
-NTSTATUS cli_ulogoff_recv(struct tevent_req *req);
-NTSTATUS cli_ulogoff(struct cli_state *cli);
-struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *share, const char *dev,
- const char *pass, int passlen,
- struct tevent_req **psmbreq);
-struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *share, const char *dev,
- const char *pass, int passlen);
-NTSTATUS cli_tcon_andx_recv(struct tevent_req *req);
-NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share,
- const char *dev, const char *pass, int passlen);
-struct tevent_req *cli_tdis_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli);
-NTSTATUS cli_tdis_recv(struct tevent_req *req);
-NTSTATUS cli_tdis(struct cli_state *cli);
-NTSTATUS cli_negprot(struct cli_state *cli);
-struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli);
-NTSTATUS cli_negprot_recv(struct tevent_req *req);
-bool cli_session_request(struct cli_state *cli,
- struct nmb_name *calling, struct nmb_name *called);
-NTSTATUS cli_connect(struct cli_state *cli,
- const char *host,
- struct sockaddr_storage *dest_ss);
-NTSTATUS cli_start_connection(struct cli_state **output_cli,
- const char *my_name,
- const char *dest_host,
- struct sockaddr_storage *dest_ss, int port,
- int signing_state, int flags);
-NTSTATUS cli_full_connection(struct cli_state **output_cli,
- const char *my_name,
- const char *dest_host,
- struct sockaddr_storage *dest_ss, int port,
- const char *service, const char *service_type,
- const char *user, const char *domain,
- const char *password, int flags,
- int signing_state);
-bool attempt_netbios_session_request(struct cli_state **ppcli, const char *srchost, const char *desthost,
- struct sockaddr_storage *pdest_ss);
-NTSTATUS cli_raw_tcon(struct cli_state *cli,
- const char *service, const char *pass, const char *dev,
- uint16 *max_xmit, uint16 *tid);
-struct cli_state *get_ipc_connect(char *server,
- struct sockaddr_storage *server_ss,
- const struct user_auth_info *user_info);
-struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
- struct ip_service *mb_ip,
- const struct user_auth_info *user_info,
- char **pp_workgroup_out);
-struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
- const struct user_auth_info *user_info,
- char **pp_workgroup_out);
-
-/* The following definitions come from libsmb/clidfs.c */
-
-NTSTATUS cli_cm_force_encryption(struct cli_state *c,
- const char *username,
- const char *password,
- const char *domain,
- const char *sharename);
-struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
- struct cli_state *referring_cli,
- const char *server,
- const char *share,
- const struct user_auth_info *auth_info,
- bool show_hdr,
- bool force_encrypt,
- int max_protocol,
- int port,
- int name_type);
-void cli_cm_display(const struct cli_state *c);
-struct client_dfs_referral;
-NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
- struct cli_state *cli,
- const char *path,
- struct client_dfs_referral **refs,
- size_t *num_refs,
- size_t *consumed);
-bool cli_resolve_path(TALLOC_CTX *ctx,
- const char *mountpt,
- const struct user_auth_info *dfs_auth_info,
- struct cli_state *rootcli,
- const char *path,
- struct cli_state **targetcli,
- char **pp_targetpath);
-
-bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
- struct cli_state *cli,
- const char *sharename,
- char **pp_newserver,
- char **pp_newshare,
- bool force_encrypt,
- const char *username,
- const char *password,
- const char *domain);
-
-/* The following definitions come from libsmb/clientgen.c */
-
-int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
-unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
-void cli_set_port(struct cli_state *cli, int port);
-bool cli_state_seqnum_persistent(struct cli_state *cli,
- uint16_t mid);
-bool cli_state_seqnum_remove(struct cli_state *cli,
- uint16_t mid);
-bool cli_receive_smb(struct cli_state *cli);
-bool cli_send_smb(struct cli_state *cli);
-bool cli_send_smb_direct_writeX(struct cli_state *cli,
- const char *p,
- size_t extradata);
-void cli_setup_packet_buf(struct cli_state *cli, char *buf);
-void cli_setup_packet(struct cli_state *cli);
-void cli_setup_bcc(struct cli_state *cli, void *p);
-NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain);
-NTSTATUS cli_set_username(struct cli_state *cli, const char *username);
-NTSTATUS cli_set_password(struct cli_state *cli, const char *password);
-NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password);
-struct cli_state *cli_initialise(void);
-struct cli_state *cli_initialise_ex(int signing_state);
-void cli_nt_pipes_close(struct cli_state *cli);
-void cli_shutdown(struct cli_state *cli);
-void cli_sockopt(struct cli_state *cli, const char *options);
-uint16 cli_setpid(struct cli_state *cli, uint16 pid);
-bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
-struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
- struct cli_state *cli, uint16_t num_echos,
- DATA_BLOB data);
-NTSTATUS cli_echo_recv(struct tevent_req *req);
-NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
-bool cli_ucs2(struct cli_state *cli);
-bool is_andx_req(uint8_t cmd);
-NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
- uint8_t smb_command, uint8_t additional_flags,
- uint8_t wct, uint16_t *vwv,
- uint32_t num_bytes, const uint8_t *bytes,
- struct tevent_req **result_parent,
- uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
- uint32_t *pnum_bytes, uint8_t **pbytes);
-
-/* The following definitions come from libsmb/clierror.c */
-
-const char *cli_errstr(struct cli_state *cli);
-NTSTATUS cli_nt_error(struct cli_state *cli);
-void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode);
-int cli_errno(struct cli_state *cli);
-bool cli_is_error(struct cli_state *cli);
-bool cli_is_nt_error(struct cli_state *cli);
-bool cli_is_dos_error(struct cli_state *cli);
-NTSTATUS cli_get_nt_error(struct cli_state *cli);
-void cli_set_nt_error(struct cli_state *cli, NTSTATUS status);
-void cli_reset_error(struct cli_state *cli);
-bool cli_state_is_connected(struct cli_state *cli);
-
-/* The following definitions come from libsmb/clifile.c */
-
-struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli,
- uint16_t level,
- const char *path,
- uint8_t *data,
- size_t data_len);
-NTSTATUS cli_setpathinfo_recv(struct tevent_req *req);
-NTSTATUS cli_setpathinfo(struct cli_state *cli,
- uint16_t level,
- const char *path,
- uint8_t *data,
- size_t data_len);
-
-struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *oldname,
- const char *newname);
-NTSTATUS cli_posix_symlink_recv(struct tevent_req *req);
-NTSTATUS cli_posix_symlink(struct cli_state *cli,
- const char *oldname,
- const char *newname);
-struct tevent_req *cli_posix_readlink_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname,
- size_t len);
-NTSTATUS cli_posix_readlink_recv(struct tevent_req *req, struct cli_state *cli,
- char *retpath, size_t len);
-NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname,
- char *linkpath, size_t len);
-struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *oldname,
- const char *newname);
-NTSTATUS cli_posix_hardlink_recv(struct tevent_req *req);
-NTSTATUS cli_posix_hardlink(struct cli_state *cli,
- const char *oldname,
- const char *newname);
-uint32_t unix_perms_to_wire(mode_t perms);
-mode_t wire_perms_to_unix(uint32_t perms);
-struct tevent_req *cli_posix_getfacl_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname);
-NTSTATUS cli_posix_getfacl_recv(struct tevent_req *req,
- TALLOC_CTX *mem_ctx,
- size_t *prb_size,
- char **retbuf);
-NTSTATUS cli_posix_getfacl(struct cli_state *cli,
- const char *fname,
- TALLOC_CTX *mem_ctx,
- size_t *prb_size,
- char **retbuf);
-struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname);
-NTSTATUS cli_posix_stat_recv(struct tevent_req *req,
- SMB_STRUCT_STAT *sbuf);
-NTSTATUS cli_posix_stat(struct cli_state *cli,
- const char *fname,
- SMB_STRUCT_STAT *sbuf);
-struct tevent_req *cli_posix_chmod_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname,
- mode_t mode);
-NTSTATUS cli_posix_chmod_recv(struct tevent_req *req);
-NTSTATUS cli_posix_chmod(struct cli_state *cli, const char *fname, mode_t mode);
-struct tevent_req *cli_posix_chown_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname,
- uid_t uid,
- gid_t gid);
-NTSTATUS cli_posix_chown_recv(struct tevent_req *req);
-NTSTATUS cli_posix_chown(struct cli_state *cli,
- const char *fname,
- uid_t uid,
- gid_t gid);
-struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname_src,
- const char *fname_dst);
-NTSTATUS cli_rename_recv(struct tevent_req *req);
-NTSTATUS cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
-struct tevent_req *cli_ntrename_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname_src,
- const char *fname_dst);
-NTSTATUS cli_ntrename_recv(struct tevent_req *req);
-NTSTATUS cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
-
-struct tevent_req *cli_nt_hardlink_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname_src,
- const char *fname_dst);
-NTSTATUS cli_nt_hardlink_recv(struct tevent_req *req);
-NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
-
-struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname,
- uint16_t mayhave_attrs);
-NTSTATUS cli_unlink_recv(struct tevent_req *req);
-NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
-
-struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *dname);
-NTSTATUS cli_mkdir_recv(struct tevent_req *req);
-NTSTATUS cli_mkdir(struct cli_state *cli, const char *dname);
-struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *dname);
-NTSTATUS cli_rmdir_recv(struct tevent_req *req);
-NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname);
-struct tevent_req *cli_nt_delete_on_close_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum,
- bool flag);
-NTSTATUS cli_nt_delete_on_close_recv(struct tevent_req *req);
-NTSTATUS cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
-struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname,
- uint32_t CreatFlags,
- uint32_t DesiredAccess,
- uint32_t FileAttributes,
- uint32_t ShareAccess,
- uint32_t CreateDisposition,
- uint32_t CreateOptions,
- uint8_t SecurityFlags);
-NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum);
-NTSTATUS cli_ntcreate(struct cli_state *cli,
- const char *fname,
- uint32_t CreatFlags,
- uint32_t DesiredAccess,
- uint32_t FileAttributes,
- uint32_t ShareAccess,
- uint32_t CreateDisposition,
- uint32_t CreateOptions,
- uint8_t SecurityFlags,
- uint16_t *pfid);
-uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
- size_t str_len, size_t *pconverted_size);
-uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
- const uint8_t *bytes, size_t num_bytes);
-struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli, const char *fname,
- int flags, int share_mode,
- struct tevent_req **psmbreq);
-struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
- struct cli_state *cli, const char *fname,
- int flags, int share_mode);
-NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *fnum);
-NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
-struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli, uint16_t fnum,
- struct tevent_req **psubreq);
-struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli, uint16_t fnum);
-NTSTATUS cli_close_recv(struct tevent_req *req);
-NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum);
-struct tevent_req *cli_ftruncate_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum,
- uint64_t size);
-NTSTATUS cli_ftruncate_recv(struct tevent_req *req);
-NTSTATUS cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
-NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
- uint32_t offset, uint32_t len,
- int timeout, unsigned char locktype);
-bool cli_lock(struct cli_state *cli, uint16_t fnum,
- uint32_t offset, uint32_t len, int timeout, enum brl_type lock_type);
-struct tevent_req *cli_unlock_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum,
- uint64_t offset,
- uint64_t len);
-NTSTATUS cli_unlock_recv(struct tevent_req *req);
-NTSTATUS cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len);
-bool cli_lock64(struct cli_state *cli, uint16_t fnum,
- uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type);
-struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum,
- uint64_t offset,
- uint64_t len);
-NTSTATUS cli_unlock64_recv(struct tevent_req *req);
-NTSTATUS cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
-struct tevent_req *cli_posix_lock_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum,
- uint64_t offset,
- uint64_t len,
- bool wait_lock,
- enum brl_type lock_type);
-NTSTATUS cli_posix_lock_recv(struct tevent_req *req);
-NTSTATUS cli_posix_lock(struct cli_state *cli, uint16_t fnum,
- uint64_t offset, uint64_t len,
- bool wait_lock, enum brl_type lock_type);
-struct tevent_req *cli_posix_unlock_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum,
- uint64_t offset,
- uint64_t len);
-NTSTATUS cli_posix_unlock_recv(struct tevent_req *req);
-NTSTATUS cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
-struct tevent_req *cli_getattrE_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum);
-NTSTATUS cli_getattrE_recv(struct tevent_req *req,
- uint16_t *attr,
- SMB_OFF_T *size,
- time_t *change_time,
- time_t *access_time,
- time_t *write_time);
-NTSTATUS cli_getattrE(struct cli_state *cli,
- uint16_t fnum,
- uint16_t *attr,
- SMB_OFF_T *size,
- time_t *change_time,
- time_t *access_time,
- time_t *write_time);
-struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum,
- time_t change_time,
- time_t access_time,
- time_t write_time);
-NTSTATUS cli_setattrE_recv(struct tevent_req *req);
-NTSTATUS cli_setattrE(struct cli_state *cli,
- uint16_t fnum,
- time_t change_time,
- time_t access_time,
- time_t write_time);
-struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname);
-NTSTATUS cli_getatr_recv(struct tevent_req *req,
- uint16_t *attr,
- SMB_OFF_T *size,
- time_t *write_time);
-NTSTATUS cli_getatr(struct cli_state *cli,
- const char *fname,
- uint16_t *attr,
- SMB_OFF_T *size,
- time_t *write_time);
-struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname,
- uint16_t attr,
- time_t mtime);
-NTSTATUS cli_setatr_recv(struct tevent_req *req);
-NTSTATUS cli_setatr(struct cli_state *cli,
- const char *fname,
- uint16_t attr,
- time_t mtime);
-struct tevent_req *cli_chkpath_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname);
-NTSTATUS cli_chkpath_recv(struct tevent_req *req);
-NTSTATUS cli_chkpath(struct cli_state *cli, const char *path);
-struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli);
-NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
- int *avail);
-NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
-struct tevent_req *cli_ctemp_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *path);
-NTSTATUS cli_ctemp_recv(struct tevent_req *req,
- TALLOC_CTX *ctx,
- uint16_t *pfnum,
- char **outfile);
-NTSTATUS cli_ctemp(struct cli_state *cli,
- TALLOC_CTX *ctx,
- const char *path,
- uint16_t *pfnum,
- char **out_path);
-NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob);
-NTSTATUS cli_set_ea_path(struct cli_state *cli, const char *path,
- const char *ea_name, const char *ea_val,
- size_t ea_len);
-NTSTATUS cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum,
- const char *ea_name, const char *ea_val,
- size_t ea_len);
-struct tevent_req *cli_get_ea_list_path_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli,
- const char *fname);
-NTSTATUS cli_get_ea_list_path_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
- size_t *pnum_eas, struct ea_struct **peas);
-NTSTATUS cli_get_ea_list_path(struct cli_state *cli, const char *path,
- TALLOC_CTX *ctx,
- size_t *pnum_eas,
- struct ea_struct **pea_list);
-struct tevent_req *cli_posix_open_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname,
- int flags,
- mode_t mode);
-NTSTATUS cli_posix_open_recv(struct tevent_req *req, uint16_t *pfnum);
-NTSTATUS cli_posix_open(struct cli_state *cli, const char *fname,
- int flags, mode_t mode, uint16_t *fnum);
-struct tevent_req *cli_posix_mkdir_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname,
- mode_t mode);
-NTSTATUS cli_posix_mkdir_recv(struct tevent_req *req);
-NTSTATUS cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode);
-
-struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname);
-NTSTATUS cli_posix_unlink_recv(struct tevent_req *req);
-NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname);
-
-struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *fname);
-NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
-NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname);
-struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli, uint16_t fnum,
- uint32_t buffer_size,
- uint32_t completion_filter, bool recursive);
-NTSTATUS cli_notify_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
- uint32_t *pnum_changes,
- struct notify_change **pchanges);
-
-/* The following definitions come from libsmb/clifsinfo.c */
-
-struct tevent_req *cli_unix_extensions_version_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli);
-NTSTATUS cli_unix_extensions_version_recv(struct tevent_req *req,
- uint16_t *pmajor, uint16_t *pminor,
- uint32_t *pcaplow,
- uint32_t *pcaphigh);
-NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
- uint16 *pminor, uint32 *pcaplow,
- uint32 *pcaphigh);
-struct tevent_req *cli_set_unix_extensions_capabilities_send(
- TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
- uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh);
-NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req);
-NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
- uint16 major, uint16 minor,
- uint32 caplow, uint32 caphigh);
-struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli);
-NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr);
-NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
-NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name,
- uint32 *pserial_number, time_t *pdate);
-NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
- uint64_t *total_allocation_units,
- uint64_t *caller_allocation_units,
- uint64_t *actual_allocation_units,
- uint64_t *sectors_per_allocation_unit,
- uint64_t *bytes_per_sector);
-NTSTATUS cli_get_posix_fs_info(struct cli_state *cli,
- uint32 *optimal_transfer_size,
- uint32 *block_size,
- uint64_t *total_blocks,
- uint64_t *blocks_available,
- uint64_t *user_blocks_available,
- uint64_t *total_file_nodes,
- uint64_t *free_file_nodes,
- uint64_t *fs_identifier);
-NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
- const char *user,
- const char *pass,
- const char *domain);
-NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli);
-NTSTATUS cli_force_encryption(struct cli_state *c,
- const char *username,
- const char *password,
- const char *domain);
-
-/* The following definitions come from libsmb/clikrb5.c */
-
-bool unwrap_edata_ntstatus(TALLOC_CTX *mem_ctx,
- DATA_BLOB *edata,
- DATA_BLOB *edata_out);
-bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_pac_data);
-
-/* The following definitions come from libsmb/clilist.c */
-
-NTSTATUS cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
- NTSTATUS (*fn)(const char *, struct file_info *,
- const char *, void *), void *state);
-NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
- uint16_t attribute, int info_level,
- NTSTATUS (*fn)(const char *mnt, struct file_info *finfo,
- const char *mask, void *private_data),
- void *private_data);
-struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli,
- const char *mask,
- uint16_t attribute,
- uint16_t info_level);
-NTSTATUS cli_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
- struct file_info **finfo, size_t *num_finfo);
-NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
- NTSTATUS (*fn)(const char *, struct file_info *, const char *,
- void *), void *state);
-
-/* The following definitions come from libsmb/climessage.c */
-
-struct tevent_req *cli_message_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli,
- const char *host, const char *username,
- const char *message);
-NTSTATUS cli_message_recv(struct tevent_req *req);
-NTSTATUS cli_message(struct cli_state *cli, const char *host,
- const char *username, const char *message);
-
-/* The following definitions come from libsmb/clioplock.c */
-
-struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli,
- uint16_t fnum, uint8_t level);
-NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
-NTSTATUS cli_oplock_ack(struct cli_state *cli, uint16_t fnum, unsigned char level);
-void cli_oplock_handler(struct cli_state *cli,
- NTSTATUS (*handler)(struct cli_state *, uint16_t, unsigned char));
-
-/* The following definitions come from libsmb/cliprint.c */
-
-int cli_print_queue(struct cli_state *cli,
- void (*fn)(struct print_job_info *));
-int cli_printjob_del(struct cli_state *cli, int job);
-
-/* The following definitions come from libsmb/cliquota.c */
-
-NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum);
-void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
-NTSTATUS cli_get_user_quota(struct cli_state *cli, int quota_fnum,
- SMB_NTQUOTA_STRUCT *pqt);
-NTSTATUS cli_set_user_quota(struct cli_state *cli, int quota_fnum,
- SMB_NTQUOTA_STRUCT *pqt);
-NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
- SMB_NTQUOTA_LIST **pqt_list);
-NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum,
- SMB_NTQUOTA_STRUCT *pqt);
-NTSTATUS cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum,
- SMB_NTQUOTA_STRUCT *pqt);
-
-/* The following definitions come from libsmb/clireadwrite.c */
-
-struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli, uint16_t fnum,
- off_t offset, size_t size,
- struct tevent_req **psmbreq);
-struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli, uint16_t fnum,
- off_t offset, size_t size);
-NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
- uint8_t **rcvbuf);
-struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum, off_t start_offset,
- SMB_OFF_T size, size_t window_size,
- NTSTATUS (*sink)(char *buf, size_t n,
- void *priv),
- void *priv);
-NTSTATUS cli_pull_recv(struct tevent_req *req, SMB_OFF_T *received);
-NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
- off_t start_offset, SMB_OFF_T size, size_t window_size,
- NTSTATUS (*sink)(char *buf, size_t n, void *priv),
- void *priv, SMB_OFF_T *received);
-ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
- off_t offset, size_t size);
-ssize_t cli_write(struct cli_state *cli,
- uint16_t fnum, uint16 write_mode,
- const char *buf, off_t offset, size_t size);
-NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
- off_t offset, size_t size1, size_t *ptotal);
-struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli, uint16_t fnum,
- uint16_t mode, const uint8_t *buf,
- off_t offset, size_t size,
- struct tevent_req **reqs_before,
- int num_reqs_before,
- struct tevent_req **psmbreq);
-struct tevent_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli, uint16_t fnum,
- uint16_t mode, const uint8_t *buf,
- off_t offset, size_t size);
-NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten);
-
-struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
- struct cli_state *cli,
- uint16_t fnum, uint16_t mode,
- off_t start_offset, size_t window_size,
- size_t (*source)(uint8_t *buf, size_t n,
- void *priv),
- void *priv);
-NTSTATUS cli_push_recv(struct tevent_req *req);
-NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
- off_t start_offset, size_t window_size,
- size_t (*source)(uint8_t *buf, size_t n, void *priv),
- void *priv);
-
-/* The following definitions come from libsmb/clisecdesc.c */
-
-struct security_descriptor *cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
- TALLOC_CTX *mem_ctx);
-NTSTATUS cli_set_secdesc(struct cli_state *cli, uint16_t fnum,
- struct security_descriptor *sd);
-
/* The following definitions come from libsmb/clispnego.c */
DATA_BLOB spnego_gen_negTokenInit(TALLOC_CTX *ctx,
@@ -1836,57 +952,6 @@ DATA_BLOB spnego_gen_auth_response_and_mic(TALLOC_CTX *ctx,
bool spnego_mech_list_blob(TALLOC_CTX *mem_ctx,
char **oid_list, DATA_BLOB *data);
-/* The following definitions come from libsmb/clistr.c */
-
-size_t clistr_push_fn(struct cli_state *cli,
- void *dest,
- const char *src,
- int dest_len,
- int flags);
-size_t clistr_pull_fn(const char *inbuf,
- char *dest,
- const void *src,
- int dest_len,
- int src_len,
- int flags);
-size_t clistr_pull_talloc(TALLOC_CTX *ctx,
- const char *base,
- uint16_t flags2,
- char **pp_dest,
- const void *src,
- int src_len,
- int flags);
-size_t clistr_align_out(struct cli_state *cli, const void *p, int flags);
-
-/* The following definitions come from libsmb/clitrans.c */
-
-struct tevent_req *cli_trans_send(
- TALLOC_CTX *mem_ctx, struct event_context *ev,
- struct cli_state *cli, uint8_t cmd,
- const char *pipe_name, uint16_t fid, uint16_t function, int flags,
- uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
- uint8_t *param, uint32_t num_param, uint32_t max_param,
- uint8_t *data, uint32_t num_data, uint32_t max_data);
-NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
- uint16_t *recv_flags2,
- uint16_t **setup, uint8_t min_setup,
- uint8_t *num_setup,
- uint8_t **param, uint32_t min_param,
- uint32_t *num_param,
- uint8_t **data, uint32_t min_data,
- uint32_t *num_data);
-NTSTATUS cli_trans(TALLOC_CTX *mem_ctx, struct cli_state *cli,
- uint8_t trans_cmd,
- const char *pipe_name, uint16_t fid, uint16_t function,
- int flags,
- uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
- uint8_t *param, uint32_t num_param, uint32_t max_param,
- uint8_t *data, uint32_t num_data, uint32_t max_data,
- uint16_t *recv_flags2,
- uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
- uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
- uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
-
/* The following definitions come from libsmb/conncache.c */
NTSTATUS check_negative_conn_cache( const char *domain, const char *server);
@@ -1909,9 +974,6 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
/* The following definitions come from libsmb/errormap.c */
NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode);
-void ntstatus_to_dos(NTSTATUS ntstatus, uint8 *eclass, uint32 *ecode);
-NTSTATUS werror_to_ntstatus(WERROR error);
-WERROR ntstatus_to_werror(NTSTATUS error);
NTSTATUS map_nt_error_from_gss(uint32 gss_maj, uint32 minor);
/* The following definitions come from libsmb/namecache.c */
@@ -1974,13 +1036,29 @@ NTSTATUS name_query(const char *name, int name_type,
TALLOC_CTX *mem_ctx,
struct sockaddr_storage **addrs,
int *num_addrs, uint8_t *flags);
+struct tevent_req *name_resolve_bcast_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ const char *name,
+ int name_type);
+NTSTATUS name_resolve_bcast_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **addrs,
+ int *num_addrs);
NTSTATUS name_resolve_bcast(const char *name,
int name_type,
- struct ip_service **return_iplist,
+ TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **return_iplist,
int *return_count);
+struct tevent_req *resolve_wins_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ const char *name,
+ int name_type);
+NTSTATUS resolve_wins_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **addrs,
+ int *num_addrs, uint8_t *flags);
NTSTATUS resolve_wins(const char *name,
int name_type,
- struct ip_service **return_iplist,
+ TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **return_iplist,
int *return_count);
NTSTATUS internal_resolve_name(const char *name,
int name_type,
@@ -2016,14 +1094,6 @@ bool get_dc_name(const char *domain,
fstring srv_name,
struct sockaddr_storage *ss_out);
-/* The following definitions come from libsmb/nterr.c */
-
-const char *nt_errstr(NTSTATUS nt_code);
-const char *get_friendly_nt_error_msg(NTSTATUS nt_code);
-const char *get_nt_error_c_code(NTSTATUS nt_code);
-NTSTATUS nt_status_string_to_code(const char *nt_status_str);
-NTSTATUS nt_status_squash(NTSTATUS nt_status);
-
/* The following definitions come from libsmb/ntlmssp.c */
struct ntlmssp_state;
NTSTATUS ntlmssp_set_username(struct ntlmssp_state *ntlmssp_state, const char *user) ;
@@ -2064,38 +1134,6 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3);
struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct dom_sid *user_sid);
bool netsamlogon_cache_have(const struct dom_sid *user_sid);
-/* The following definitions come from libsmb/smb_seal.c */
-
-NTSTATUS get_enc_ctx_num(const uint8_t *buf, uint16 *p_enc_ctx_num);
-bool common_encryption_on(struct smb_trans_enc_state *es);
-NTSTATUS common_ntlm_decrypt_buffer(struct ntlmssp_state *ntlmssp_state, char *buf);
-NTSTATUS common_ntlm_encrypt_buffer(struct ntlmssp_state *ntlmssp_state,
- uint16 enc_ctx_num,
- char *buf,
- char **ppbuf_out);
-NTSTATUS common_encrypt_buffer(struct smb_trans_enc_state *es, char *buffer, char **buf_out);
-NTSTATUS common_decrypt_buffer(struct smb_trans_enc_state *es, char *buf);
-void common_free_encryption_state(struct smb_trans_enc_state **pp_es);
-void common_free_enc_buffer(struct smb_trans_enc_state *es, char *buf);
-bool cli_encryption_on(struct cli_state *cli);
-void cli_free_encryption_context(struct cli_state *cli);
-void cli_free_enc_buffer(struct cli_state *cli, char *buf);
-NTSTATUS cli_decrypt_message(struct cli_state *cli);
-NTSTATUS cli_encrypt_message(struct cli_state *cli, char *buf, char **buf_out);
-
-/* The following definitions come from libsmb/clisigning.c */
-
-bool cli_simple_set_signing(struct cli_state *cli,
- const DATA_BLOB user_session_key,
- const DATA_BLOB response);
-bool cli_temp_set_signing(struct cli_state *cli);
-void cli_calculate_sign_mac(struct cli_state *cli, char *buf, uint32_t *seqnum);
-bool cli_check_sign_mac(struct cli_state *cli, const char *buf, uint32_t seqnum);
-bool client_is_signing_on(struct cli_state *cli);
-bool client_is_signing_allowed(struct cli_state *cli);
-bool client_is_signing_mandatory(struct cli_state *cli);
-void cli_set_signing_negotiated(struct cli_state *cli);
-
/* The following definitions come from libsmb/smberr.c */
const char *smb_dos_err_name(uint8 e_class, uint16 num);
@@ -2131,22 +1169,15 @@ bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain,
struct dom_sid **sids );
NTSTATUS change_trust_account_password( const char *domain, const char *remote_machine);
-/* The following definitions come from modules/vfs_default.c */
-
-ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size);
-ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size);
-NTSTATUS vfs_default_init(void);
-
/* The following definitions come from param/loadparm.c */
-char *lp_smb_ports(void);
-char *lp_dos_charset(void);
-char *lp_unix_charset(void);
-char *lp_display_charset(void);
+const char *lp_smb_ports(void);
+const char *lp_dos_charset(void);
+const char *lp_unix_charset(void);
char *lp_logfile(void);
char *lp_configfile(void);
-char *lp_smb_passwd_file(void);
-char *lp_private_dir(void);
+const char *lp_smb_passwd_file(void);
+const char *lp_private_dir(void);
char *lp_serverstring(void);
int lp_printcap_cache_time(void);
char *lp_addport_cmd(void);
@@ -2154,14 +1185,14 @@ char *lp_enumports_cmd(void);
char *lp_addprinter_cmd(void);
char *lp_deleteprinter_cmd(void);
char *lp_os2_driver_map(void);
-char *lp_lockdir(void);
-char *lp_statedir(void);
-char *lp_cachedir(void);
-char *lp_piddir(void);
+const char *lp_lockdir(void);
+const char *lp_statedir(void);
+const char *lp_cachedir(void);
+const char *lp_piddir(void);
char *lp_mangling_method(void);
int lp_mangle_prefix(void);
-char *lp_utmpdir(void);
-char *lp_wtmpdir(void);
+const char *lp_utmpdir(void);
+const char *lp_wtmpdir(void);
bool lp_utmp(void);
char *lp_rootdir(void);
char *lp_defaultservice(void);
@@ -2171,9 +1202,13 @@ char *lp_set_quota_command(void);
char *lp_auto_services(void);
char *lp_passwd_program(void);
char *lp_passwd_chat(void);
-char *lp_passwordserver(void);
-char *lp_name_resolve_order(void);
-char *lp_realm(void);
+const char *lp_passwordserver(void);
+const char *lp_name_resolve_order(void);
+const char *lp_netbios_scope(void);
+const char *lp_netbios_name(void);
+const char *lp_workgroup(void);
+const char *lp_realm(void);
+const char *lp_dnsdomain(void);
const char *lp_afs_username_map(void);
int lp_afs_token_lifetime(void);
char *lp_log_nt_token_command(void);
@@ -2316,7 +1351,7 @@ bool lp_send_spnego_principal(void);
bool lp_hostname_lookups(void);
bool lp_change_notify(const struct share_params *p );
bool lp_kernel_change_notify(const struct share_params *p );
-char * lp_dedicated_keytab_file(void);
+const char * lp_dedicated_keytab_file(void);
int lp_kerberos_method(void);
bool lp_defer_sharing_violations(void);
bool lp_enable_privileges(void);
@@ -2552,9 +1587,11 @@ bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal);
struct parm_struct *lp_get_parameter(const char *param_name);
struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters);
bool lp_snum_ok(int iService);
-void lp_add_one_printer(const char *name, const char *comment, void *pdata);
+void lp_add_one_printer(const char *name, const char *comment,
+ const char *location, void *pdata);
bool lp_loaded(void);
-void lp_killunused(bool (*snumused) (int));
+void lp_killunused(struct smbd_server_connection *sconn,
+ bool (*snumused) (struct smbd_server_connection *, int));
void lp_kill_all_services(void);
void lp_killservice(int iServiceIn);
const char* server_role_str(uint32 role);
@@ -2570,7 +1607,7 @@ enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
struct security_descriptor **ppsd,
bool *pallow_guest);
int load_usershare_service(const char *servicename);
-int load_usershare_shares(void);
+int load_usershare_shares(struct smbd_server_connection *sconn);
void gfree_loadparm(void);
void lp_set_in_client(bool b);
bool lp_is_in_client(void);
@@ -2592,10 +1629,6 @@ int lp_servicenumber(const char *pszServiceName);
bool share_defined(const char *service_name);
struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
const char *sharename);
-struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx);
-struct share_params *next_share(struct share_iterator *list);
-struct share_params *next_printer(struct share_iterator *list);
-struct share_params *snum2params_static(int snum);
const char *volume_label(int snum);
bool lp_domain_master(void);
bool lp_domain_master_true_or_auto(void);
@@ -2603,8 +1636,6 @@ bool lp_preferred_master(void);
void lp_remove_service(int snum);
void lp_copy_service(int snum, const char *new_name);
int lp_default_server_announce(void);
-int lp_major_announce_version(void);
-int lp_minor_announce_version(void);
void lp_set_name_resolve_order(const char *new_order);
const char *lp_printername(int snum);
void lp_set_logfile(const char *name);
@@ -2613,6 +1644,7 @@ const char *lp_printcapname(void);
bool lp_disable_spoolss( void );
void lp_set_spoolss_state( uint32 state );
uint32 lp_get_spoolss_state( void );
+struct smb_signing_state;
bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state);
void set_use_sendfile(int snum, bool val);
void set_store_dos_attributes(int snum, bool val);
@@ -2625,7 +1657,11 @@ int lp_min_receive_file_size(void);
char* lp_perfcount_module(void);
void lp_set_passdb_backend(const char *backend);
void widelinks_warning(int snum);
-char *lp_ncalrpc_dir(void);
+const char *lp_ncalrpc_dir(void);
+
+/* The following definitions come from param/loadparm_ctx.c */
+
+const struct loadparm_s3_context *loadparm_s3_context(void);
/* The following definitions come from param/loadparm_server_role.c */
@@ -2637,145 +1673,6 @@ void set_server_role(void);
uint32 get_int_param( const char* param );
char* get_string_param( const char* param );
-/* The following definitions come from librpc/rpc/rpc_common.c */
-struct ndr_interface_table;
-bool smb_register_ndr_interface(const struct ndr_interface_table *interface);
-const struct ndr_interface_table *get_iface_from_syntax(
- const struct ndr_syntax_id *syntax);
-const char *get_pipe_name_from_syntax(TALLOC_CTX *mem_ctx,
- const struct ndr_syntax_id *syntax);
-
-/* The following definitions come from rpc_server/rpc_ncacn_np.c */
-struct auth_serversupplied_info;
-struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
- const struct ndr_syntax_id *syntax,
- struct client_address *client_id,
- const struct auth_serversupplied_info *session_info,
- struct messaging_context *msg_ctx);
-struct dcerpc_binding_handle;
-NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
- const struct ndr_interface_table *ndr_table,
- struct client_address *client_id,
- const struct auth_serversupplied_info *session_info,
- struct messaging_context *msg_ctx,
- struct dcerpc_binding_handle **binding_handle);
-NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
- const struct ndr_syntax_id *abstract_syntax,
- const struct auth_serversupplied_info *serversupplied_info,
- struct client_address *client_id,
- struct messaging_context *msg_ctx,
- struct rpc_pipe_client **presult);
-NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
- const struct ndr_syntax_id *syntax,
- const struct auth_serversupplied_info *session_info,
- struct client_address *client_id,
- struct messaging_context *msg_ctx,
- struct rpc_pipe_client **cli_pipe);
-
-/* The following definitions come from rpc_server/rpc_handles.c */
-
-size_t num_pipe_handles(struct pipes_struct *p);
-bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *syntax);
-bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
-bool find_policy_by_hnd(struct pipes_struct *p, const struct policy_handle *hnd,
- void **data_p);
-bool close_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd);
-void close_policy_by_pipe(struct pipes_struct *p);
-bool pipe_access_check(struct pipes_struct *p);
-
-void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,
- uint32_t access_granted, size_t data_size,
- const char *type, NTSTATUS *pstatus);
-#define policy_handle_create(_p, _hnd, _access, _type, _pstatus) \
- (_type *)_policy_handle_create((_p), (_hnd), (_access), sizeof(_type), #_type, \
- (_pstatus))
-
-void *_policy_handle_find(struct pipes_struct *p,
- const struct policy_handle *hnd,
- uint32_t access_required, uint32_t *paccess_granted,
- const char *name, const char *location,
- NTSTATUS *pstatus);
-#define policy_handle_find(_p, _hnd, _access_required, _access_granted, _type, _pstatus) \
- (_type *)_policy_handle_find((_p), (_hnd), (_access_required), \
- (_access_granted), #_type, __location__, (_pstatus))
-
-
-/* The following definitions come from rpc_server/srv_rpc_register.c */
-
-struct rpc_srv_callbacks {
- bool (*init)(void *private_data);
- bool (*shutdown)(void *private_data);
- void *private_data;
-};
-
-struct api_struct;
-NTSTATUS rpc_srv_register(int version, const char *clnt,
- const char *srv,
- const struct ndr_interface_table *iface,
- const struct api_struct *cmds, int size,
- const struct rpc_srv_callbacks *rpc_srv_cb);
-
-NTSTATUS rpc_srv_unregister(const struct ndr_interface_table *iface);
-
-/* The following definitions come from rpc_server/srv_pipe.c */
-struct ncacn_packet;
-bool create_next_pdu(struct pipes_struct *p);
-bool api_pipe_bind_auth3(struct pipes_struct *p, struct ncacn_packet *pkt);
-bool setup_fault_pdu(struct pipes_struct *p, NTSTATUS status);
-NTSTATUS rpc_pipe_register_commands(int version, const char *clnt,
- const char *srv,
- const struct ndr_syntax_id *interface,
- const struct api_struct *cmds, int size);
-bool is_known_pipename(const char *cli_filename, struct ndr_syntax_id *syntax);
-
-/* The following definitions come from rpc_server/srv_pipe_hnd.c */
-
-struct pipes_struct *get_first_internal_pipe(void);
-struct pipes_struct *get_next_internal_pipe(struct pipes_struct *p);
-bool check_open_pipes(void);
-int close_internal_rpc_pipe_hnd(struct pipes_struct *p);
-
-bool fsp_is_np(struct files_struct *fsp);
-struct tsocket_address;
-NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
- const struct tsocket_address *local_address,
- const struct tsocket_address *remote_address,
- struct client_address *client_id,
- struct auth_serversupplied_info *session_info,
- struct messaging_context *msg_ctx,
- struct fake_file_handle **phandle);
-bool np_read_in_progress(struct fake_file_handle *handle);
-struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
- struct fake_file_handle *handle,
- const uint8_t *data, size_t len);
-NTSTATUS np_write_recv(struct tevent_req *req, ssize_t *pnwritten);
-struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
- struct fake_file_handle *handle,
- uint8_t *data, size_t len);
-NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
- bool *is_data_outstanding);
-
-ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n);
-
-/* The following definitions come from rpc_server/srv_spoolss_nt.c */
-void srv_spoolss_cleanup(void);
-
-void do_drv_upgrade_printer(struct messaging_context *msg,
- void *private_data,
- uint32_t msg_type,
- struct server_id server_id,
- DATA_BLOB *data);
-void update_monitored_printq_cache(struct messaging_context *msg_ctx);
-
-/* The following definitions come from rpc_server/srv_srvsvc_nt.c */
-
-char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname);
-
-/* The following definitions come from rpc_server/srv_svcctl_nt.c */
-
-bool init_service_op_table( void );
-bool shutdown_service_op_table(void);
-
/* The following definitions come from lib/server_contexts.c */
struct tevent_context *server_event_context(void);
void server_event_context_free(void);
@@ -2800,13 +1697,6 @@ int sessionid_traverse_read(int (*fn)(const char *key,
char *stdin_new_passwd( void);
char *get_pass( const char *prompt, bool stdin_get);
-/* The following definitions come from winbindd/nss_info.c */
-
-
-/* The following definitions come from winbindd/nss_info_template.c */
-
-NTSTATUS nss_info_template_init( void );
-
/* The following definitions come from lib/avahi.c */
struct AvahiPoll *tevent_avahi_poll(TALLOC_CTX *mem_ctx,
@@ -2837,7 +1727,7 @@ NTSTATUS smbsock_connect_recv(struct tevent_req *req, int *sock,
NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port,
const char *called_name, int called_type,
const char *calling_name, int calling_type,
- int *pfd, uint16_t *ret_port);
+ int *pfd, uint16_t *ret_port, int sec_timeout);
struct tevent_req *smbsock_any_connect_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -2856,6 +1746,7 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs,
int *calling_types,
size_t num_addrs,
uint16_t port,
+ int sec_timeout,
int *pfd, size_t *chosen_index,
uint16_t *chosen_port);
@@ -2909,7 +1800,7 @@ void unbecome_root(void);
/* The following definitions come from lib/dummysmbd.c */
int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out);
-bool conn_snum_used(int snum);
+bool conn_snum_used(struct smbd_server_connection *sconn, int snum);
void cancel_pending_lock_requests_by_fid(files_struct *fsp,
struct byte_range_lock *br_lck,
enum file_close_type close_type);
@@ -2918,7 +1809,7 @@ void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
NTSTATUS can_delete_directory(struct connection_struct *conn,
const char *dirname);
bool change_to_root_user(void);
-struct event_context *smbd_event_context(void);
+void smbd_set_server_fd(int fd);
void contend_level2_oplocks_begin(files_struct *fsp,
enum level2_contention_type type);
void contend_level2_oplocks_end(files_struct *fsp,
diff --git a/source3/include/pthreadpool.h b/source3/include/pthreadpool.h
deleted file mode 100644
index 7ef7ddf4192..00000000000
--- a/source3/include/pthreadpool.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * threadpool implementation based on pthreads
- * Copyright (C) Volker Lendecke 2009
- *
- * 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 __PTHREADPOOL_H__
-#define __PTHREADPOOL_H__
-
-struct pthreadpool;
-
-int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult);
-int pthreadpool_destroy(struct pthreadpool *pool);
-
-/*
- * Add a job to a pthreadpool.
- */
-int pthreadpool_add_job(struct pthreadpool *pool, int job_id,
- void (*fn)(void *private_data), void *private_data);
-
-/*
- * Get the signalling fd out of a thread pool. This fd will become readable
- * when a job is finished. The job that finished can be retrieved via
- * pthreadpool_finished_job().
- */
-int pthreadpool_sig_fd(struct pthreadpool *pool);
-int pthreadpool_finished_job(struct pthreadpool *pool);
-
-#endif
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 8ebde2f4adc..589dfd78c3c 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -27,6 +27,7 @@
#define _SMB_H
#include "libcli/smb/smb_common.h"
+#include "libds/common/roles.h"
/* logged when starting the various Samba daemons */
#define COPYRIGHT_STARTUP_MESSAGE "Copyright Andrew Tridgell and the Samba Team 1992-2011"
@@ -85,14 +86,6 @@ enum smb_read_errors {
#define DIR_STRUCT_SIZE 43
-/* these define the attribute byte as seen by DOS */
-#define aRONLY (1L<<0) /* 0x01 */
-#define aHIDDEN (1L<<1) /* 0x02 */
-#define aSYSTEM (1L<<2) /* 0x04 */
-#define aVOLID (1L<<3) /* 0x08 */
-#define aDIR (1L<<4) /* 0x10 */
-#define aARCH (1L<<5) /* 0x20 */
-
/* deny modes */
#define DENY_DOS 0
#define DENY_ALL 1
@@ -404,10 +397,6 @@ struct share_params {
int service;
};
-struct share_iterator {
- int next_id;
-};
-
typedef struct connection_struct {
struct connection_struct *next, *prev;
struct smbd_server_connection *sconn; /* can be NULL */
@@ -1084,26 +1073,6 @@ struct bitmap {
#define FILE_SHARE_WRITE 2
#define FILE_SHARE_DELETE 4
-/* FileAttributesField */
-#define FILE_ATTRIBUTE_READONLY 0x001L
-#define FILE_ATTRIBUTE_HIDDEN 0x002L
-#define FILE_ATTRIBUTE_SYSTEM 0x004L
-#define FILE_ATTRIBUTE_DIRECTORY 0x010L
-#define FILE_ATTRIBUTE_ARCHIVE 0x020L
-#define FILE_ATTRIBUTE_NORMAL 0x080L
-#define FILE_ATTRIBUTE_TEMPORARY 0x100L
-#define FILE_ATTRIBUTE_SPARSE 0x200L
-#define FILE_ATTRIBUTE_REPARSE_POINT 0x400L
-#define FILE_ATTRIBUTE_COMPRESSED 0x800L
-#define FILE_ATTRIBUTE_OFFLINE 0x1000L
-#define FILE_ATTRIBUTE_NONINDEXED 0x2000L
-#define FILE_ATTRIBUTE_ENCRYPTED 0x4000L
-#define SAMBA_ATTRIBUTES_MASK (FILE_ATTRIBUTE_READONLY|\
- FILE_ATTRIBUTE_HIDDEN|\
- FILE_ATTRIBUTE_SYSTEM|\
- FILE_ATTRIBUTE_DIRECTORY|\
- FILE_ATTRIBUTE_ARCHIVE)
-
/* Flags - combined with attributes. */
#define FILE_FLAG_WRITE_THROUGH 0x80000000L
#define FILE_FLAG_NO_BUFFERING 0x20000000L
@@ -1232,7 +1201,7 @@ struct bitmap {
/* where to find the base of the SMB packet proper */
-#define smb_base(buf) (((char *)(buf))+4)
+#define smb_base(buf) (((const char *)(buf))+4)
/* we don't allow server strings to be longer than 48 characters as
otherwise NT will not honour the announce packets */
@@ -1267,8 +1236,8 @@ char *strdup(char *s);
* This may change again in Samba-3.0 after further testing. JHT
*/
-#define DEFAULT_MAJOR_VERSION 0x04
-#define DEFAULT_MINOR_VERSION 0x09
+#define SAMBA_MAJOR_NBT_ANNOUNCE_VERSION 0x04
+#define SAMBA_MINOR_NBT_ANNOUNCE_VERSION 0x09
/* Browser Election Values */
#define BROWSER_ELECTION_VERSION 0x010f
@@ -1323,17 +1292,6 @@ enum protocol_types {
PROTOCOL_SMB2
};
-/* security levels */
-enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN,SEC_ADS};
-
-/* server roles */
-enum server_types {
- ROLE_STANDALONE,
- ROLE_DOMAIN_MEMBER,
- ROLE_DOMAIN_BDC,
- ROLE_DOMAIN_PDC
-};
-
/* printing types */
enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ,
@@ -1584,13 +1542,6 @@ typedef struct user_struct {
struct auth_ntlmssp_state *auth_ntlmssp_state;
} user_struct;
-struct unix_error_map {
- int unix_error;
- int dos_class;
- int dos_code;
- NTSTATUS nt_error;
-};
-
/*
Do you want session setups at user level security with a invalid
password to be rejected or allowed in as guest? WinNT rejects them
@@ -1736,4 +1687,20 @@ struct deferred_open_record;
/* Used inside aio code. */
struct aio_extra;
+/*
+ * Reasons for cache flush.
+ */
+
+enum flush_reason_enum {
+ SEEK_FLUSH,
+ READ_FLUSH,
+ WRITE_FLUSH,
+ READRAW_FLUSH,
+ OPLOCK_RELEASE_FLUSH,
+ CLOSE_FLUSH,
+ SYNC_FLUSH,
+ SIZECHANGE_FLUSH,
+ /* NUM_FLUSH_REASONS must remain the last value in the enumeration. */
+ NUM_FLUSH_REASONS};
+
#endif /* _SMB_H */
diff --git a/source3/include/smb_krb5.h b/source3/include/smb_krb5.h
index d87dc79ff9f..bc9996c541d 100644
--- a/source3/include/smb_krb5.h
+++ b/source3/include/smb_krb5.h
@@ -1,3 +1,25 @@
+/*
+ Unix SMB/CIFS implementation.
+ simple kerberos5 routines for active directory
+ Copyright (C) Andrew Tridgell 2001
+ Copyright (C) Luke Howard 2002-2003
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
+ Copyright (C) Guenther Deschner 2005-2009
+
+ 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 _HEADER_smb_krb5_h
#define _HEADER_smb_krb5_h
@@ -14,14 +36,6 @@
#include "libcli/auth/krb5_wrap.h"
-#if HAVE_GSSAPI_GSSAPI_H
-#include <gssapi/gssapi.h>
-#elif HAVE_GSSAPI_GSSAPI_GENERIC_H
-#include <gssapi/gssapi_generic.h>
-#elif HAVE_GSSAPI_H
-#include <gssapi.h>
-#endif
-
#ifndef KRB5_ADDR_NETBIOS
#define KRB5_ADDR_NETBIOS 0x14
#endif
diff --git a/source3/include/smb_ldap.h b/source3/include/smb_ldap.h
index 45e586859db..594f0158629 100644
--- a/source3/include/smb_ldap.h
+++ b/source3/include/smb_ldap.h
@@ -1,3 +1,25 @@
+/*
+ Unix SMB/CIFS implementation.
+ Copyright (C) Andrew Tridgell 2001
+ Copyright (C) Remus Koos 2001
+ Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
+ Copyright (C) Guenther Deschner 2005
+ Copyright (C) Gerald Carter 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#ifndef _SMB_LDAP_H
#define _SMB_LDAP_H
@@ -22,6 +44,20 @@ typedef int ber_int_t;
#ifndef LDAP_CONST
#define LDAP_CONST const
#endif
+
+#ifdef HAVE_LDAP_PVT_H
+#include <ldap_pvt.h>
+#endif /* HAVE_LDAP_PVT_H */
+
+#ifdef HAVE_LDAP_INIT_FD
+int ldap_init_fd(ber_socket_t fd, int proto, char *uri, LDAP **ldp);
+#endif
+
+/* function declarations not included in proto.h */
+LDAP *ldap_open_with_timeout(const char *server,
+ struct sockaddr_storage *ss,
+ int port, unsigned int to);
+
#ifndef LDAP_OPT_SUCCESS
#define LDAP_OPT_SUCCESS 0
#endif
@@ -36,9 +72,6 @@ typedef int ber_int_t;
#define LDAPS_PORT 636
#endif
-/* function declarations not included in proto.h */
-LDAP *ldap_open_with_timeout(const char *server, int port, unsigned int to);
-
#endif /* HAVE_LDAP_H */
#ifndef HAVE_LDAP
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 93bda975bf9..37ea1b42925 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -28,11 +28,11 @@
#define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
/* for readability... */
-#define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0)
-#define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0)
-#define IS_DOS_ARCHIVE(test_mode) (((test_mode) & aARCH) != 0)
-#define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0)
-#define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0)
+#define IS_DOS_READONLY(test_mode) (((test_mode) & FILE_ATTRIBUTE_READONLY) != 0)
+#define IS_DOS_DIR(test_mode) (((test_mode) & FILE_ATTRIBUTE_DIRECTORY) != 0)
+#define IS_DOS_ARCHIVE(test_mode) (((test_mode) & FILE_ATTRIBUTE_ARCHIVE) != 0)
+#define IS_DOS_SYSTEM(test_mode) (((test_mode) & FILE_ATTRIBUTE_SYSTEM) != 0)
+#define IS_DOS_HIDDEN(test_mode) (((test_mode) & FILE_ATTRIBUTE_HIDDEN) != 0)
#define SMB_WARN(condition, message) \
((condition) ? (void)0 : \
@@ -123,6 +123,7 @@
/* Extra macros added by Ying Chen at IBM - speed increase by inlining. */
#define smb_buf(buf) (((char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2)
+#define smb_buf_const(buf) (((const char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2)
#define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2))
/* the remaining number of bytes in smb buffer 'buf' from pointer 'p'. */
@@ -217,39 +218,12 @@ copy an IP address from one buffer to another
#define SMB_XMALLOC_P(type) (type *)smb_xmalloc_array(sizeof(type),1)
#define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count))
-/* The new talloc is paranoid malloc checker safe. */
-
-#if 0
-
-Disable these now we have checked all code paths and ensured
-NULL returns on zero request. JRA.
-
-#define TALLOC(ctx, size) talloc_zeronull(ctx, size, __location__)
-#define TALLOC_P(ctx, type) (type *)talloc_zeronull(ctx, sizeof(type), #type)
-#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array_zeronull(ctx, sizeof(type), count, #type)
-#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup_zeronull(ctx, ptr, size, __location__)
-#define TALLOC_ZERO(ctx, size) _talloc_zero_zeronull(ctx, size, __location__)
-#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero_zeronull(ctx, sizeof(type), #type)
-#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array_zeronull(ctx, sizeof(type), count, #type)
-#define TALLOC_SIZE(ctx, size) talloc_zeronull(ctx, size, __location__)
-#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero_zeronull(ctx, size, __location__)
-
-#else
-
#define TALLOC(ctx, size) talloc_named_const(ctx, size, __location__)
-#define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
-#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
-#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup(ctx, ptr, size, __location__)
#define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__)
-#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
-#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)
#define TALLOC_SIZE(ctx, size) talloc_named_const(ctx, size, __location__)
#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__)
-#endif
-
#define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__)
-#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type)
#define talloc_destroy(ctx) talloc_free(ctx)
#ifndef TALLOC_FREE
#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
@@ -312,7 +286,7 @@ NULL returns on zero request. JRA.
#define ADD_TO_ARRAY(mem_ctx, type, elem, array, num) \
do { \
*(array) = ((mem_ctx) != NULL) ? \
- TALLOC_REALLOC_ARRAY(mem_ctx, (*(array)), type, (*(num))+1) : \
+ talloc_realloc(mem_ctx, (*(array)), type, (*(num))+1) : \
SMB_REALLOC_ARRAY((*(array)), type, (*(num))+1); \
SMB_ASSERT((*(array)) != NULL); \
(*(array))[*(num)] = (elem); \
diff --git a/source3/include/trans2.h b/source3/include/trans2.h
index 076780dec0c..7a8c411396f 100644
--- a/source3/include/trans2.h
+++ b/source3/include/trans2.h
@@ -355,433 +355,4 @@ Byte offset Type name description
#define FLAG_TRANS2_FIND_CONTINUE 0x8
#define FLAG_TRANS2_FIND_BACKUP_INTENT 0x10
-/* UNIX CIFS Extensions - created by HP */
-/*
- * UNIX CIFS Extensions have the range 0x200 - 0x2FF reserved.
- * Supposedly Microsoft have agreed to this.
- */
-
-#define MIN_UNIX_INFO_LEVEL 0x200
-#define MAX_UNIX_INFO_LEVEL 0x2FF
-
-#define INFO_LEVEL_IS_UNIX(level) (((level) >= MIN_UNIX_INFO_LEVEL) && ((level) <= MAX_UNIX_INFO_LEVEL))
-
-#define SMB_QUERY_FILE_UNIX_BASIC 0x200 /* UNIX File Info*/
-#define SMB_SET_FILE_UNIX_BASIC 0x200
-#define SMB_SET_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */
-
-#define SMB_MODE_NO_CHANGE 0xFFFFFFFF /* file mode value which */
- /* means "don't change it" */
-#define SMB_UID_NO_CHANGE 0xFFFFFFFF
-#define SMB_GID_NO_CHANGE 0xFFFFFFFF
-
-#define SMB_SIZE_NO_CHANGE_LO 0xFFFFFFFF
-#define SMB_SIZE_NO_CHANGE_HI 0xFFFFFFFF
-
-#define SMB_TIME_NO_CHANGE_LO 0xFFFFFFFF
-#define SMB_TIME_NO_CHANGE_HI 0xFFFFFFFF
-
-/*
-Offset Size Name
-0 LARGE_INTEGER EndOfFile File size
-8 LARGE_INTEGER Blocks Number of bytes used on disk (st_blocks).
-16 LARGE_INTEGER CreationTime Creation time
-24 LARGE_INTEGER LastAccessTime Last access time
-32 LARGE_INTEGER LastModificationTime Last modification time
-40 LARGE_INTEGER Uid Numeric user id for the owner
-48 LARGE_INTEGER Gid Numeric group id of owner
-56 ULONG Type Enumeration specifying the pathname type:
- 0 -- File
- 1 -- Directory
- 2 -- Symbolic link
- 3 -- Character device
- 4 -- Block device
- 5 -- FIFO (named pipe)
- 6 -- Unix domain socket
-
-60 LARGE_INTEGER devmajor Major device number if type is device
-68 LARGE_INTEGER devminor Minor device number if type is device
-76 LARGE_INTEGER uniqueid This is a server-assigned unique id for the file. The client
- will typically map this onto an inode number. The scope of
- uniqueness is the share.
-84 LARGE_INTEGER permissions Standard UNIX file permissions - see below.
-92 LARGE_INTEGER nlinks The number of directory entries that map to this entry
- (number of hard links)
-
-100 - end.
-*/
-
-#define SMB_FILE_UNIX_BASIC_SIZE 100
-
-/* UNIX filetype mappings. */
-
-#define UNIX_TYPE_FILE 0
-#define UNIX_TYPE_DIR 1
-#define UNIX_TYPE_SYMLINK 2
-#define UNIX_TYPE_CHARDEV 3
-#define UNIX_TYPE_BLKDEV 4
-#define UNIX_TYPE_FIFO 5
-#define UNIX_TYPE_SOCKET 6
-#define UNIX_TYPE_UNKNOWN 0xFFFFFFFF
-
-/*
- * Oh this is fun. "Standard UNIX permissions" has no
- * meaning in POSIX. We need to define the mapping onto
- * and off the wire as this was not done in the original HP
- * spec. JRA.
- */
-
-#define UNIX_X_OTH 0000001
-#define UNIX_W_OTH 0000002
-#define UNIX_R_OTH 0000004
-#define UNIX_X_GRP 0000010
-#define UNIX_W_GRP 0000020
-#define UNIX_R_GRP 0000040
-#define UNIX_X_USR 0000100
-#define UNIX_W_USR 0000200
-#define UNIX_R_USR 0000400
-#define UNIX_STICKY 0001000
-#define UNIX_SET_GID 0002000
-#define UNIX_SET_UID 0004000
-
-/* Masks for the above */
-#define UNIX_OTH_MASK 0000007
-#define UNIX_GRP_MASK 0000070
-#define UNIX_USR_MASK 0000700
-#define UNIX_PERM_MASK 0000777
-#define UNIX_EXTRA_MASK 0007000
-#define UNIX_ALL_MASK 0007777
-
-/* Flags for chflags (CIFS_UNIX_EXTATTR_CAP capability) and
- * SMB_QUERY_FILE_UNIX_INFO2.
- */
-#define EXT_SECURE_DELETE 0x00000001
-#define EXT_ENABLE_UNDELETE 0x00000002
-#define EXT_SYNCHRONOUS 0x00000004
-#define EXT_IMMUTABLE 0x00000008
-#define EXT_OPEN_APPEND_ONLY 0x00000010
-#define EXT_DO_NOT_BACKUP 0x00000020
-#define EXT_NO_UPDATE_ATIME 0x00000040
-#define EXT_HIDDEN 0x00000080
-
-#define SMB_QUERY_FILE_UNIX_LINK 0x201
-#define SMB_SET_FILE_UNIX_LINK 0x201
-#define SMB_SET_FILE_UNIX_HLINK 0x203
-/* SMB_QUERY_POSIX_ACL 0x204 see below */
-#define SMB_QUERY_XATTR 0x205 /* need for non-user XATTRs */
-#define SMB_QUERY_ATTR_FLAGS 0x206 /* chflags, chattr */
-#define SMB_SET_ATTR_FLAGS 0x206
-#define SMB_QUERY_POSIX_PERMISSION 0x207
-/* Only valid for qfileinfo */
-#define SMB_QUERY_POSIX_LOCK 0x208
-/* Only valid for setfileinfo */
-#define SMB_SET_POSIX_LOCK 0x208
-
-/* The set info levels for POSIX path operations. */
-#define SMB_POSIX_PATH_OPEN 0x209
-#define SMB_POSIX_PATH_UNLINK 0x20A
-
-#define SMB_QUERY_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */
-#define SMB_SET_FILE_UNIX_INFO2 0x20B
-
-/*
-SMB_QUERY_FILE_UNIX_INFO2 is SMB_QUERY_FILE_UNIX_BASIC with create
-time and file flags appended. The corresponding info level for
-findfirst/findnext is SMB_FIND_FILE_UNIX_INFO2.
- Size Offset Value
- ---------------------
- 0 LARGE_INTEGER EndOfFile File size
- 8 LARGE_INTEGER Blocks Number of blocks used on disk
- 16 LARGE_INTEGER ChangeTime Attribute change time
- 24 LARGE_INTEGER LastAccessTime Last access time
- 32 LARGE_INTEGER LastModificationTime Last modification time
- 40 LARGE_INTEGER Uid Numeric user id for the owner
- 48 LARGE_INTEGER Gid Numeric group id of owner
- 56 ULONG Type Enumeration specifying the file type
- 60 LARGE_INTEGER devmajor Major device number if type is device
- 68 LARGE_INTEGER devminor Minor device number if type is device
- 76 LARGE_INTEGER uniqueid This is a server-assigned unique id
- 84 LARGE_INTEGER permissions Standard UNIX permissions
- 92 LARGE_INTEGER nlinks Number of hard links
- 100 LARGE_INTEGER CreationTime Create/birth time
- 108 ULONG FileFlags File flags enumeration
- 112 ULONG FileFlagsMask Mask of valid flags
-*/
-
-/* Transact 2 Find First levels */
-#define SMB_FIND_FILE_UNIX 0x202
-#define SMB_FIND_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */
-
-#define SMB_FILE_UNIX_INFO2_SIZE 116
-
-/*
- Info level for TRANS2_QFSINFO - returns version of CIFS UNIX extensions, plus
- 64-bits worth of capability fun :-).
- Use the same info level for TRANS2_SETFSINFO
-*/
-
-#define SMB_QUERY_CIFS_UNIX_INFO 0x200
-#define SMB_SET_CIFS_UNIX_INFO 0x200
-
-/* Returns or sets the following.
-
- UINT16 major version number
- UINT16 minor version number
- LARGE_INTEGER capability bitfield
-
-*/
-
-#define CIFS_UNIX_MAJOR_VERSION 1
-#define CIFS_UNIX_MINOR_VERSION 0
-
-#define CIFS_UNIX_FCNTL_LOCKS_CAP 0x1
-#define CIFS_UNIX_POSIX_ACLS_CAP 0x2
-#define CIFS_UNIX_XATTTR_CAP 0x4 /* for support of other xattr
- namespaces such as system,
- security and trusted */
-#define CIFS_UNIX_EXTATTR_CAP 0x8 /* for support of chattr
- (chflags) and lsattr */
-#define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x10 /* Use POSIX pathnames on the wire. */
-#define CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP 0x20 /* We can cope with POSIX open/mkdir/unlink etc. */
-#define CIFS_UNIX_LARGE_READ_CAP 0x40 /* We can cope with 24 bit reads in readX. */
-#define CIFS_UNIX_LARGE_WRITE_CAP 0x80 /* We can cope with 24 bit writes in writeX. */
-#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x100 /* We can do SPNEGO negotiations for encryption. */
-#define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x200 /* We *must* SPNEGO negotiations for encryption. */
-
-#define SMB_QUERY_POSIX_FS_INFO 0x201
-
-/* Returns FILE_SYSTEM_POSIX_INFO struct as follows
- (NB For undefined values return -1 in that field)
- le32 OptimalTransferSize; bsize on some os, iosize on other os, This
- is a hint to the client about best size. Server
- can return -1 if no preference, ie if SMB
- negotiated size is adequate for optimal
- read/write performance
- le32 BlockSize; (often 512 bytes) NB: BlockSize * TotalBlocks = disk space
- le64 TotalBlocks; redundant with other infolevels but easy to ret here
- le64 BlocksAvail; although redundant, easy to return
- le64 UserBlocksAvail; bavail
- le64 TotalFileNodes;
- le64 FreeFileNodes;
- le64 FileSysIdentifier; fsid
- (NB statfs field Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call)
- (NB statfs field flags can come from FILE_SYSTEM_DEVICE_INFO call)
-*/
-
-#define SMB_QUERY_POSIX_WHO_AM_I 0x202 /* QFS Info */
-/* returns:
- __u32 flags; 0 = Authenticated user 1 = GUEST
- __u32 mask; which flags bits server understands ie 0x0001
- __u64 unix_user_id;
- __u64 unix_user_gid;
- __u32 number_of_supplementary_gids; may be zero
- __u32 number_of_sids; may be zero
- __u32 length_of_sid_array; in bytes - may be zero
- __u32 pad; reserved - MBZ
- __u64 gid_array[0]; may be empty
- __u8 * psid_list may be empty
-*/
-
-/* ... more as we think of them :-). */
-
-/* SMB POSIX ACL definitions. */
-/* Wire format is (all little endian) :
-
-[2 bytes] - Version number.
-[2 bytes] - Number of ACE entries to follow.
-[2 bytes] - Number of default ACE entries to follow.
--------------------------------------
-^
-|
-ACE entries
-|
-v
--------------------------------------
-^
-|
-Default ACE entries
-|
-v
--------------------------------------
-
-Where an ACE entry looks like :
-
-[1 byte] - Entry type.
-
-Entry types are :
-
-ACL_USER_OBJ 0x01
-ACL_USER 0x02
-ACL_GROUP_OBJ 0x04
-ACL_GROUP 0x08
-ACL_MASK 0x10
-ACL_OTHER 0x20
-
-[1 byte] - permissions (perm_t)
-
-perm_t types are :
-
-ACL_READ 0x04
-ACL_WRITE 0x02
-ACL_EXECUTE 0x01
-
-[8 bytes] - uid/gid to apply this permission to.
-
-In the same format as the uid/gid fields in the other
-UNIX extensions definitions. Use 0xFFFFFFFFFFFFFFFF for
-the MASK and OTHER entry types.
-
-If the Number of ACE entries for either file or default ACE's
-is set to 0xFFFF this means ignore this kind of ACE (and the
-number of entries sent will be zero.
-
-*/
-
-#define SMB_QUERY_POSIX_WHOAMI 0x202
-
-enum smb_whoami_flags {
- SMB_WHOAMI_GUEST = 0x1 /* Logged in as (or squashed to) guest */
-};
-
-/* Mask of which WHOAMI bits are valid. This should make it easier for clients
- * to cope with servers that have different sets of WHOAMI flags (as more get
- * added).
- */
-#define SMB_WHOAMI_MASK 0x00000001
-
-/*
- SMBWhoami - Query the user mapping performed by the server for the
- connected tree. This is a subcommand of the TRANS2_QFSINFO.
-
- Returns:
- 4 bytes unsigned - mapping flags (smb_whoami_flags)
- 4 bytes unsigned - flags mask
-
- 8 bytes unsigned - primary UID
- 8 bytes unsigned - primary GID
- 4 bytes unsigned - number of supplementary GIDs
- 4 bytes unsigned - number of SIDs
- 4 bytes unsigned - SID list byte count
- 4 bytes - pad / reserved (must be zero)
-
- 8 bytes unsigned[] - list of GIDs (may be empty)
- struct dom_sid[] - list of SIDs (may be empty)
-*/
-
-/*
- * The following trans2 is done between client and server
- * as a FSINFO call to set up the encryption state for transport
- * encryption.
- * This is a subcommand of the TRANS2_QFSINFO.
- *
- * The request looks like :
- *
- * [data block] -> SPNEGO framed GSSAPI request.
- *
- * The reply looks like :
- *
- * [data block] -> SPNEGO framed GSSAPI reply - if error
- * is NT_STATUS_OK then we're done, if it's
- * NT_STATUS_MORE_PROCESSING_REQUIRED then the
- * client needs to keep going. If it's an
- * error it can be any NT_STATUS error.
- *
- */
-
-#define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203 /* QFSINFO */
-
-
-/* The query/set info levels for POSIX ACLs. */
-#define SMB_QUERY_POSIX_ACL 0x204
-#define SMB_SET_POSIX_ACL 0x204
-
-/* Current on the wire ACL version. */
-#define SMB_POSIX_ACL_VERSION 1
-
-/* ACE entry type. */
-#define SMB_POSIX_ACL_USER_OBJ 0x01
-#define SMB_POSIX_ACL_USER 0x02
-#define SMB_POSIX_ACL_GROUP_OBJ 0x04
-#define SMB_POSIX_ACL_GROUP 0x08
-#define SMB_POSIX_ACL_MASK 0x10
-#define SMB_POSIX_ACL_OTHER 0x20
-
-/* perm_t types. */
-#define SMB_POSIX_ACL_READ 0x04
-#define SMB_POSIX_ACL_WRITE 0x02
-#define SMB_POSIX_ACL_EXECUTE 0x01
-
-#define SMB_POSIX_ACL_HEADER_SIZE 6
-#define SMB_POSIX_ACL_ENTRY_SIZE 10
-
-#define SMB_POSIX_IGNORE_ACE_ENTRIES 0xFFFF
-
-/* Definition of data block of SMB_SET_POSIX_LOCK */
-/*
- [2 bytes] lock_type - 0 = Read, 1 = Write, 2 = Unlock
- [2 bytes] lock_flags - 1 = Wait (only valid for setlock)
- [4 bytes] pid = locking context.
- [8 bytes] start = unsigned 64 bits.
- [8 bytes] length = unsigned 64 bits.
-*/
-
-#define POSIX_LOCK_TYPE_OFFSET 0
-#define POSIX_LOCK_FLAGS_OFFSET 2
-#define POSIX_LOCK_PID_OFFSET 4
-#define POSIX_LOCK_START_OFFSET 8
-#define POSIX_LOCK_LEN_OFFSET 16
-#define POSIX_LOCK_DATA_SIZE 24
-
-#define POSIX_LOCK_FLAG_NOWAIT 0
-#define POSIX_LOCK_FLAG_WAIT 1
-
-#define POSIX_LOCK_TYPE_READ 0
-#define POSIX_LOCK_TYPE_WRITE 1
-#define POSIX_LOCK_TYPE_UNLOCK 2
-
-/* SMB_POSIX_PATH_OPEN "open_mode" definitions. */
-#define SMB_O_RDONLY 0x1
-#define SMB_O_WRONLY 0x2
-#define SMB_O_RDWR 0x4
-
-#define SMB_ACCMODE 0x7
-
-#define SMB_O_CREAT 0x10
-#define SMB_O_EXCL 0x20
-#define SMB_O_TRUNC 0x40
-#define SMB_O_APPEND 0x80
-#define SMB_O_SYNC 0x100
-#define SMB_O_DIRECTORY 0x200
-#define SMB_O_NOFOLLOW 0x400
-#define SMB_O_DIRECT 0x800
-
-/* Definition of request data block for SMB_POSIX_PATH_OPEN */
-/*
- [4 bytes] flags (as smb_ntcreate_Flags).
- [4 bytes] open_mode - SMB_O_xxx flags above.
- [8 bytes] mode_t (permissions) - same encoding as "Standard UNIX permissions" above in SMB_SET_FILE_UNIX_BASIC.
- [2 bytes] ret_info_level - optimization. Info level to be returned.
-*/
-
-/* Definition of reply data block for SMB_POSIX_PATH_OPEN */
-
-#define SMB_NO_INFO_LEVEL_RETURNED 0xFFFF
-
-/*
- [2 bytes] - flags field. Identical to flags reply for oplock response field in SMBNTCreateX)
- [2 bytes] - FID returned.
- [4 bytes] - CreateAction (same as in NTCreateX response).
- [2 bytes] - reply info level - as requested or 0xFFFF if not available.
- [2 bytes] - padding (must be zero)
- [n bytes] - info level reply - if available.
-*/
-
-/* Definition of request data block for SMB_POSIX_UNLINK */
-/*
- [2 bytes] flags (defined below).
-*/
-
-#define SMB_POSIX_UNLINK_FILE_TARGET 0
-#define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1
-
#endif
diff --git a/source3/include/util_tdb.h b/source3/include/util_tdb.h
index 3bdb6977d87..f127cea1ea5 100644
--- a/source3/include/util_tdb.h
+++ b/source3/include/util_tdb.h
@@ -20,16 +20,12 @@
#ifndef __TDBUTIL_H__
#define __TDBUTIL_H__
-#include <tdb.h>
+#include "tdb_compat.h"
#include <talloc.h> /* for tdb_wrap_open() */
#include "../libcli/util/ntstatus.h" /* for map_nt_error_from_tdb() */
#include "../../lib/util/util_tdb.h"
-struct tdb_wrap {
- struct tdb_context *tdb;
-};
-
int tdb_chainlock_with_timeout( struct tdb_context *tdb, TDB_DATA key,
unsigned int timeout);
int tdb_lock_bystring_with_timeout(struct tdb_context *tdb, const char *keyval,
@@ -51,10 +47,6 @@ bool tdb_pack_append(TALLOC_CTX *mem_ctx, uint8 **buf, size_t *len,
struct tdb_context *tdb_open_log(const char *name, int hash_size,
int tdb_flags, int open_flags, mode_t mode);
-struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
- const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode);
-
NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err);
int tdb_data_cmp(TDB_DATA t1, TDB_DATA t2);
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 185bc7687c8..5c7e4e52bc4 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -134,7 +134,9 @@
to split out the two possible uses. JRA. */
/* Leave at 28 - not yet released. Add fdopendir. JRA. */
/* Leave at 28 - not yet released. Rename open function to open_fn. - gd */
-#define SMB_VFS_INTERFACE_VERSION 28
+/* Leave at 28 - not yet released. Make getwd function always return malloced memory. JRA. */
+/* Bump to version 29 - Samba 3.6.0 will ship with interface version 28. */
+#define SMB_VFS_INTERFACE_VERSION 29
/*
All intercepted VFS operations must be declared as static functions inside module source
@@ -250,7 +252,7 @@ struct vfs_fn_pointers {
int (*fchown)(struct vfs_handle_struct *handle, struct files_struct *fsp, uid_t uid, gid_t gid);
int (*lchown)(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid);
int (*chdir)(struct vfs_handle_struct *handle, const char *path);
- char *(*getwd)(struct vfs_handle_struct *handle, char *buf);
+ char *(*getwd)(struct vfs_handle_struct *handle);
int (*ntimes)(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
struct smb_file_time *ft);
@@ -613,7 +615,7 @@ int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
int smb_vfs_call_lchown(struct vfs_handle_struct *handle, const char *path,
uid_t uid, gid_t gid);
int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path);
-char *smb_vfs_call_getwd(struct vfs_handle_struct *handle, char *buf);
+char *smb_vfs_call_getwd(struct vfs_handle_struct *handle);
int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
struct smb_file_time *ft);
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index d04be9b5aae..c7686f1db52 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -239,10 +239,10 @@
#define SMB_VFS_NEXT_CHDIR(handle, path) \
smb_vfs_call_chdir((handle)->next, (path))
-#define SMB_VFS_GETWD(conn, buf) \
- smb_vfs_call_getwd((conn)->vfs_handles, (buf))
-#define SMB_VFS_NEXT_GETWD(handle, buf) \
- smb_vfs_call_getwd((handle)->next, (buf))
+#define SMB_VFS_GETWD(conn) \
+ smb_vfs_call_getwd((conn)->vfs_handles)
+#define SMB_VFS_NEXT_GETWD(handle) \
+ smb_vfs_call_getwd((handle)->next)
#define SMB_VFS_NTIMES(conn, path, ts) \
smb_vfs_call_ntimes((conn)->vfs_handles, (path), (ts))
@@ -364,9 +364,6 @@
#define SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx, mapped_name) \
smb_vfs_call_translate_name((handle)->next, (name), (direction), (mem_ctx), (mapped_name))
-#define SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock) \
- smb_vfs_call_strict_unlock((handle)->next, (fsp), (plock))
-
#define SMB_VFS_FGET_NT_ACL(fsp, security_info, ppdesc) \
smb_vfs_call_fget_nt_acl((fsp)->conn->vfs_handles, (fsp), (security_info), (ppdesc))
#define SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc) \
diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c
index 8fcb9f2bfc8..6070e29e5ad 100644
--- a/source3/intl/lang_tdb.c
+++ b/source3/intl/lang_tdb.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "intl/lang_tdb.h"
+#include "util_tdb.h"
static TDB_CONTEXT *tdb;
@@ -130,7 +131,7 @@ bool lang_tdb_init(const char *lang)
return True;
if (asprintf(&msg_path, "%s.msg",
- data_path((const char *)lang)) == -1) {
+ data_path(talloc_tos(), (const char *)lang)) == -1) {
DEBUG(0, ("asprintf failed\n"));
goto done;
}
@@ -236,7 +237,7 @@ const char *lang_msg(const char *msgid)
void lang_msg_free(const char *msgstr)
{
if (!tdb) return;
- free((void *)msgstr);
+ free(discard_const_p(void, msgstr));
}
/*
diff --git a/source3/intl/lang_tdb.h b/source3/intl/lang_tdb.h
index da246846d0d..2f9c3f19e56 100644
--- a/source3/intl/lang_tdb.h
+++ b/source3/intl/lang_tdb.h
@@ -1,3 +1,24 @@
+/*
+ Unix SMB/CIFS implementation.
+ tdb based replacement for gettext
+ 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 _INTL_LANG_TDB_H_
+#define _INTL_LANG_TDB_H_
/* The following definitions come from intl/lang_tdb.c */
@@ -5,3 +26,5 @@ bool lang_tdb_init(const char *lang);
const char *lang_msg(const char *msgid);
void lang_msg_free(const char *msgstr);
char *lang_tdb_current(void);
+
+#endif /* _INTL_LANG_TDB_H_ */
diff --git a/source3/lib/access.c b/source3/lib/access.c
index a7475a5edc3..044c079cc5e 100644
--- a/source3/lib/access.c
+++ b/source3/lib/access.c
@@ -12,7 +12,7 @@
#include "includes.h"
#include "memcache.h"
-#include "interfaces.h"
+#include "lib/socket/interfaces.h"
#define NAME_INDEX 0
#define ADDR_INDEX 1
@@ -182,29 +182,32 @@ static bool string_match(const char *tok,const char *s)
bool client_match(const char *tok, const void *item)
{
const char **client = (const char **)item;
+ const char *tok_addr = tok;
+ const char *cli_addr = client[ADDR_INDEX];
+
+ /*
+ * tok and client[ADDR_INDEX] can be an IPv4 mapped to IPv6,
+ * we try and match the IPv4 part of address only.
+ * Bug #5311 and #7383.
+ */
+
+ if (strnequal(tok_addr, "::ffff:",7)) {
+ tok_addr += 7;
+ }
+
+ if (strnequal(cli_addr,"::ffff:",7)) {
+ cli_addr += 7;
+ }
/*
* Try to match the address first. If that fails, try to match the host
* name if available.
*/
- if (string_match(tok, client[ADDR_INDEX])) {
+ if (string_match(tok_addr, cli_addr)) {
return true;
}
- if (strnequal(client[ADDR_INDEX],"::ffff:",7) &&
- !strnequal(tok, "::ffff:",7)) {
- /* client[ADDR_INDEX] is an IPv4 mapped to IPv6, but
- * the list item is not. Try and match the IPv4 part of
- * address only. This will happen a lot on IPv6 enabled
- * systems with IPv4 allow/deny lists in smb.conf.
- * Bug #5311. JRA.
- */
- if (string_match(tok, (client[ADDR_INDEX])+7)) {
- return true;
- }
- }
-
if (client[NAME_INDEX][0] != 0) {
if (string_match(tok, client[NAME_INDEX])) {
return true;
diff --git a/source3/lib/addrchange.c b/source3/lib/addrchange.c
index bd4bfbaa460..a5d20419535 100644
--- a/source3/lib/addrchange.c
+++ b/source3/lib/addrchange.c
@@ -18,6 +18,7 @@
#include "includes.h"
#include "lib/addrchange.h"
+#include "../lib/util/tevent_ntstatus.h"
#if HAVE_LINUX_RTNETLINK_H
diff --git a/source3/lib/adt_tree.c b/source3/lib/adt_tree.c
index 6d481613c7b..de7f2d26372 100644
--- a/source3/lib/adt_tree.c
+++ b/source3/lib/adt_tree.c
@@ -134,7 +134,7 @@ static struct tree_node *pathtree_birth_child(struct tree_node *node,
/* the strings should never match assuming that we
have called pathtree_find_child() first */
- if ( StrCaseCmp( infant->key, node->children[i-1]->key ) > 0 ) {
+ if ( strcasecmp_m( infant->key, node->children[i-1]->key ) > 0 ) {
DEBUG(11,("pathtree_birth_child: storing infant in i == [%d]\n",
i));
node->children[i] = infant;
@@ -183,7 +183,7 @@ static struct tree_node *pathtree_find_child(struct tree_node *node,
DEBUG(11,("pathtree_find_child: child key => [%s]\n",
node->children[i]->key));
- result = StrCaseCmp( node->children[i]->key, key );
+ result = strcasecmp_m( node->children[i]->key, key );
if ( result == 0 )
next = node->children[i];
diff --git a/source3/lib/bitmap.c b/source3/lib/bitmap.c
index bd56b4aad1a..5216b05c585 100644
--- a/source3/lib/bitmap.c
+++ b/source3/lib/bitmap.c
@@ -29,12 +29,12 @@ struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n)
{
struct bitmap *bm;
- bm = TALLOC_P(mem_ctx, struct bitmap);
+ bm = talloc(mem_ctx, struct bitmap);
if (!bm) return NULL;
bm->n = n;
- bm->b = TALLOC_ZERO_ARRAY(bm, uint32, (n+31)/32);
+ bm->b = talloc_zero_array(bm, uint32, (n+31)/32);
if (!bm->b) {
TALLOC_FREE(bm);
return NULL;
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index f6fed8d1ec5..17e836dfe0f 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -31,112 +31,6 @@ void gfree_charcnv(void)
}
/**
- * Initialize iconv conversion descriptors.
- *
- * This is called the first time it is needed, and also called again
- * every time the configuration is reloaded, because the charset or
- * codepage might have changed.
- **/
-void init_iconv(void)
-{
- global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
- lp_unix_charset(), lp_display_charset(),
- true, global_iconv_handle);
-}
-
-/**
- talloc_strdup() a unix string to upper case.
-**/
-
-char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *s)
-{
- char *out_buffer = talloc_strdup(ctx,s);
- const unsigned char *p = (const unsigned char *)s;
- unsigned char *q = (unsigned char *)out_buffer;
-
- if (!q) {
- return NULL;
- }
-
- /* this is quite a common operation, so we want it to be
- fast. We optimise for the ascii case, knowing that all our
- supported multi-byte character sets are ascii-compatible
- (ie. they match for the first 128 chars) */
-
- while (*p) {
- if (*p & 0x80)
- break;
- *q++ = toupper_ascii_fast(*p);
- p++;
- }
-
- if (*p) {
- /* MB case. */
- size_t converted_size, converted_size2;
- smb_ucs2_t *ubuf = NULL;
-
- /* We're not using the ascii buffer above. */
- TALLOC_FREE(out_buffer);
-
- if (!convert_string_talloc(ctx, CH_UNIX, CH_UTF16LE, s,
- strlen(s)+1, (void *)&ubuf,
- &converted_size))
- {
- return NULL;
- }
-
- strupper_w(ubuf);
-
- if (!convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX, ubuf,
- converted_size, (void *)&out_buffer,
- &converted_size2))
- {
- TALLOC_FREE(ubuf);
- return NULL;
- }
-
- /* Don't need the intermediate buffer
- * anymore.
- */
- TALLOC_FREE(ubuf);
- }
-
- return out_buffer;
-}
-
-char *strupper_talloc(TALLOC_CTX *ctx, const char *s) {
- return talloc_strdup_upper(ctx, s);
-}
-
-
-char *talloc_strdup_lower(TALLOC_CTX *ctx, const char *s)
-{
- size_t converted_size;
- smb_ucs2_t *buffer = NULL;
- char *out_buffer;
-
- if (!push_ucs2_talloc(ctx, &buffer, s, &converted_size)) {
- return NULL;
- }
-
- strlower_w(buffer);
-
- if (!pull_ucs2_talloc(ctx, &out_buffer, buffer, &converted_size)) {
- TALLOC_FREE(buffer);
- return NULL;
- }
-
- TALLOC_FREE(buffer);
-
- return out_buffer;
-}
-
-char *strlower_talloc(TALLOC_CTX *ctx, const char *s) {
- return talloc_strdup_lower(ctx, s);
-}
-
-
-/**
* Copy a string from a char* unix src to a dos codepage string destination.
*
* @return the number of bytes occupied by the string in the destination.
@@ -189,15 +83,6 @@ size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags)
Push and malloc an ascii string. src and dest null terminated.
********************************************************************/
-bool push_ascii_talloc(TALLOC_CTX *mem_ctx, char **dest, const char *src, size_t *converted_size)
-{
- size_t src_len = strlen(src)+1;
-
- *dest = NULL;
- return convert_string_talloc(mem_ctx, CH_UNIX, CH_DOS, src, src_len,
- (void **)dest, converted_size);
-}
-
/**
* Copy a string from a dos codepage source to a unix char* destination.
*
@@ -317,7 +202,7 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
/* Have we got space to append the '\0' ? */
if (size <= dest_len) {
/* No, realloc. */
- dest = TALLOC_REALLOC_ARRAY(ctx, dest, char,
+ dest = talloc_realloc(ctx, dest, char,
dest_len+1);
if (!dest) {
/* talloc fail. */
@@ -354,7 +239,7 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
* destination.
**/
-size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags)
+static size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags)
{
size_t len=0;
size_t src_len;
@@ -413,48 +298,6 @@ size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_
}
-/**
- * Copy a string from a unix char* src to a UCS2 destination,
- * allocating a buffer using talloc().
- *
- * @param dest always set at least to NULL
- * @parm converted_size set to the number of bytes occupied by the string in
- * the destination on success.
- *
- * @return true if new buffer was correctly allocated, and string was
- * converted.
- **/
-bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src,
- size_t *converted_size)
-{
- size_t src_len = strlen(src)+1;
-
- *dest = NULL;
- return convert_string_talloc(ctx, CH_UNIX, CH_UTF16LE, src, src_len,
- (void **)dest, converted_size);
-}
-
-
-/**
- * Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL
- * @parm converted_size set to the number of bytes occupied by the string in
- * the destination on success.
- *
- * @return true if new buffer was correctly allocated, and string was
- * converted.
- **/
-
-bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
- size_t *converted_size)
-{
- size_t src_len = strlen(src)+1;
-
- *dest = NULL;
- return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len,
- (void**)dest, converted_size);
-}
/**
Copy a string from a ucs2 source to a unix char* destination.
@@ -606,7 +449,7 @@ static size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
/* Have we got space to append the '\0' ? */
if (size <= dest_len) {
/* No, realloc. */
- dest = TALLOC_REALLOC_ARRAY(ctx, dest, char,
+ dest = talloc_realloc(ctx, dest, char,
dest_len+1);
if (!dest) {
/* talloc fail. */
@@ -627,70 +470,6 @@ static size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
}
/**
- * Copy a string from a UCS2 src to a unix char * destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL
- * @parm converted_size set to the number of bytes occupied by the string in
- * the destination on success.
- *
- * @return true if new buffer was correctly allocated, and string was
- * converted.
- **/
-
-bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src,
- size_t *converted_size)
-{
- size_t src_len = (strlen_w(src)+1) * sizeof(smb_ucs2_t);
-
- *dest = NULL;
- return convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX, src, src_len,
- (void **)dest, converted_size);
-}
-
-/**
- * Copy a string from a UTF-8 src to a unix char * destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL
- * @parm converted_size set to the number of bytes occupied by the string in
- * the destination on success.
- *
- * @return true if new buffer was correctly allocated, and string was
- * converted.
- **/
-
-bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
- size_t *converted_size)
-{
- size_t src_len = strlen(src)+1;
-
- *dest = NULL;
- return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len,
- (void **)dest, converted_size);
-}
-
-
-/**
- * Copy a string from a DOS src to a unix char * destination, allocating a buffer using talloc
- *
- * @param dest always set at least to NULL
- * @parm converted_size set to the number of bytes occupied by the string in
- * the destination on success.
- *
- * @return true if new buffer was correctly allocated, and string was
- * converted.
- **/
-
-bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
- size_t *converted_size)
-{
- size_t src_len = strlen(src)+1;
-
- *dest = NULL;
- return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len,
- (void **)dest, converted_size);
-}
-
-/**
Copy a string from a char* src to a unicode or ascii
dos codepage destination choosing unicode or ascii based on the
flags supplied
@@ -742,36 +521,6 @@ size_t push_string_base(const char *base, uint16 flags2,
}
/**
- Copy a string from a char* src to a unicode or ascii
- dos codepage destination choosing unicode or ascii based on the
- flags supplied
- Return the number of bytes occupied by the string in the destination.
- flags can have:
- STR_TERMINATE means include the null termination.
- STR_UPPER means uppercase in the destination.
- STR_ASCII use ascii even with unicode packet.
- STR_NOALIGN means don't do alignment.
- dest_len is the maximum length allowed in the destination. If dest_len
- is -1 then no maxiumum is used.
-**/
-
-ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags)
-{
- size_t ret;
-
- if (!(flags & STR_ASCII) && \
- (flags & STR_UNICODE)) {
- ret = push_ucs2(NULL, dest, src, dest_len, flags);
- } else {
- ret = push_ascii(dest, src, dest_len, flags);
- }
- if (ret == (size_t)-1) {
- return -1;
- }
- return ret;
-}
-
-/**
Copy a string from a unicode or ascii source (depending on
the packet flags) to a char* destination.
Flags can have:
diff --git a/source3/lib/packet.c b/source3/lib/ctdb_packet.c
index 133983d3d43..17c70ff2d67 100644
--- a/source3/lib/packet.c
+++ b/source3/lib/ctdb_packet.c
@@ -1,6 +1,6 @@
-/*
+/*
Unix SMB/CIFS implementation.
- Packet handling
+ CTDB Packet handling
Copyright (C) Volker Lendecke 2007
This program is free software; you can redistribute it and/or modify
@@ -21,9 +21,9 @@
#include "../lib/util/select.h"
#include "system/filesys.h"
#include "system/select.h"
-#include "packet.h"
+#include "ctdb_packet.h"
-struct packet_context {
+struct ctdb_packet_context {
int fd;
DATA_BLOB in, out;
};
@@ -31,32 +31,32 @@ struct packet_context {
/*
* Close the underlying fd
*/
-static int packet_context_destructor(struct packet_context *ctx)
+static int ctdb_packet_context_destructor(struct ctdb_packet_context *ctx)
{
return close(ctx->fd);
}
/*
- * Initialize a packet context. The fd is given to the packet context, meaning
- * that it is automatically closed when the packet context is freed.
+ * Initialize a ctdb_packet context. The fd is given to the ctdb_packet context, meaning
+ * that it is automatically closed when the ctdb_packet context is freed.
*/
-struct packet_context *packet_init(TALLOC_CTX *mem_ctx, int fd)
+struct ctdb_packet_context *ctdb_packet_init(TALLOC_CTX *mem_ctx, int fd)
{
- struct packet_context *result;
+ struct ctdb_packet_context *result;
- if (!(result = TALLOC_ZERO_P(mem_ctx, struct packet_context))) {
+ if (!(result = talloc_zero(mem_ctx, struct ctdb_packet_context))) {
return NULL;
}
result->fd = fd;
- talloc_set_destructor(result, packet_context_destructor);
+ talloc_set_destructor(result, ctdb_packet_context_destructor);
return result;
}
/*
* Pull data from the fd
*/
-NTSTATUS packet_fd_read(struct packet_context *ctx)
+NTSTATUS ctdb_packet_fd_read(struct ctdb_packet_context *ctx)
{
int res, available;
size_t new_size;
@@ -82,7 +82,7 @@ NTSTATUS packet_fd_read(struct packet_context *ctx)
return NT_STATUS_NO_MEMORY;
}
- if (!(in = TALLOC_REALLOC_ARRAY(ctx, ctx->in.data, uint8, new_size))) {
+ if (!(in = talloc_realloc(ctx, ctx->in.data, uint8, new_size))) {
DEBUG(10, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
@@ -105,7 +105,7 @@ NTSTATUS packet_fd_read(struct packet_context *ctx)
return NT_STATUS_OK;
}
-NTSTATUS packet_fd_read_sync(struct packet_context *ctx, int timeout)
+NTSTATUS ctdb_packet_fd_read_sync_timeout(struct ctdb_packet_context *ctx, int timeout)
{
int res, revents;
@@ -124,10 +124,10 @@ NTSTATUS packet_fd_read_sync(struct packet_context *ctx, int timeout)
return NT_STATUS_IO_TIMEOUT;
}
- return packet_fd_read(ctx);
+ return ctdb_packet_fd_read(ctx);
}
-bool packet_handler(struct packet_context *ctx,
+bool ctdb_packet_handler(struct ctdb_packet_context *ctx,
bool (*full_req)(const uint8_t *buf,
size_t available,
size_t *length,
@@ -153,7 +153,7 @@ bool packet_handler(struct packet_context *ctx,
ctx->in.data = NULL;
ctx->in.length = 0;
} else {
- buf = (uint8_t *)TALLOC_MEMDUP(ctx, ctx->in.data, length);
+ buf = (uint8_t *)talloc_memdup(ctx, ctx->in.data, length);
if (buf == NULL) {
*status = NT_STATUS_NO_MEMORY;
return true;
@@ -171,7 +171,7 @@ bool packet_handler(struct packet_context *ctx,
/*
* How many bytes of outgoing data do we have pending?
*/
-size_t packet_outgoing_bytes(struct packet_context *ctx)
+size_t ctdb_packet_outgoing_bytes(struct ctdb_packet_context *ctx)
{
return ctx->out.length;
}
@@ -179,7 +179,7 @@ size_t packet_outgoing_bytes(struct packet_context *ctx)
/*
* Push data to the fd
*/
-NTSTATUS packet_fd_write(struct packet_context *ctx)
+NTSTATUS ctdb_packet_fd_write(struct ctdb_packet_context *ctx)
{
ssize_t sent;
@@ -200,10 +200,10 @@ NTSTATUS packet_fd_write(struct packet_context *ctx)
/*
* Sync flush all outgoing bytes
*/
-NTSTATUS packet_flush(struct packet_context *ctx)
+NTSTATUS ctdb_packet_flush(struct ctdb_packet_context *ctx)
{
while (ctx->out.length != 0) {
- NTSTATUS status = packet_fd_write(ctx);
+ NTSTATUS status = ctdb_packet_fd_write(ctx);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -214,10 +214,10 @@ NTSTATUS packet_flush(struct packet_context *ctx)
/*
* Send a list of DATA_BLOBs
*
- * Example: packet_send(ctx, 2, data_blob_const(&size, sizeof(size)),
+ * Example: ctdb_packet_send(ctx, 2, data_blob_const(&size, sizeof(size)),
* data_blob_const(buf, size));
*/
-NTSTATUS packet_send(struct packet_context *ctx, int num_blobs, ...)
+NTSTATUS ctdb_packet_send(struct ctdb_packet_context *ctx, int num_blobs, ...)
{
va_list ap;
int i;
@@ -245,7 +245,7 @@ NTSTATUS packet_send(struct packet_context *ctx, int num_blobs, ...)
return NT_STATUS_OK;
}
- if (!(out = TALLOC_REALLOC_ARRAY(ctx, ctx->out.data, uint8, len))) {
+ if (!(out = talloc_realloc(ctx, ctx->out.data, uint8, len))) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
@@ -266,10 +266,9 @@ NTSTATUS packet_send(struct packet_context *ctx, int num_blobs, ...)
}
/*
- * Get the packet context's file descriptor
+ * Get the ctdb_packet context's file descriptor
*/
-int packet_get_fd(struct packet_context *ctx)
+int ctdb_packet_get_fd(struct ctdb_packet_context *ctx)
{
return ctx->fd;
}
-
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index a81691a8c9f..79dc1f246aa 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -19,11 +19,12 @@
*/
#include "includes.h"
+#include "util_tdb.h"
#ifdef CLUSTER_SUPPORT
#include "ctdbd_conn.h"
-#include "packet.h"
+#include "ctdb_packet.h"
#include "messages.h"
/* paths to these include files come from --with-ctdb= in configure */
@@ -35,7 +36,7 @@ struct ctdbd_connection {
uint32 reqid;
uint32 our_vnn;
uint64 rand_srvid;
- struct packet_context *pkt;
+ struct ctdb_packet_context *pkt;
struct fd_event *fde;
void (*release_ip_handler)(const char *ip_addr, void *private_data);
@@ -168,9 +169,9 @@ uint32 ctdbd_vnn(const struct ctdbd_connection *conn)
*/
static NTSTATUS ctdbd_connect(TALLOC_CTX *mem_ctx,
- struct packet_context **presult)
+ struct ctdb_packet_context **presult)
{
- struct packet_context *result;
+ struct ctdb_packet_context *result;
const char *sockname = lp_ctdbd_socket();
struct sockaddr_un addr;
int fd;
@@ -196,7 +197,7 @@ static NTSTATUS ctdbd_connect(TALLOC_CTX *mem_ctx,
return map_nt_error_from_unix(errno);
}
- if (!(result = packet_init(mem_ctx, fd))) {
+ if (!(result = ctdb_packet_init(mem_ctx, fd))) {
close(fd);
return NT_STATUS_NO_MEMORY;
}
@@ -271,7 +272,7 @@ struct req_pull_state {
};
/*
- * Pull a ctdb request out of the incoming packet queue
+ * Pull a ctdb request out of the incoming ctdb_packet queue
*/
static NTSTATUS ctdb_req_pull(uint8_t *buf, size_t length,
@@ -303,7 +304,7 @@ static struct messaging_rec *ctdb_pull_messaging_rec(TALLOC_CTX *mem_ctx,
cluster_fatal("got invalid msg length");
}
- if (!(result = TALLOC_P(mem_ctx, struct messaging_rec))) {
+ if (!(result = talloc(mem_ctx, struct messaging_rec))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
@@ -329,14 +330,14 @@ static struct messaging_rec *ctdb_pull_messaging_rec(TALLOC_CTX *mem_ctx,
return result;
}
-static NTSTATUS ctdb_packet_fd_read_sync(struct packet_context *ctx)
+static NTSTATUS ctdb_packet_fd_read_sync(struct ctdb_packet_context *ctx)
{
int timeout = lp_ctdb_timeout();
if (timeout == 0) {
timeout = -1;
}
- return packet_fd_read_sync(ctx, timeout);
+ return ctdb_packet_fd_read_sync_timeout(ctx, timeout);
}
/*
@@ -364,7 +365,7 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32 reqid,
}
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("packet_fd_read failed: %s\n", nt_errstr(status)));
+ DEBUG(0, ("ctdb_packet_fd_read failed: %s\n", nt_errstr(status)));
cluster_fatal("ctdbd died\n");
}
@@ -373,7 +374,7 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32 reqid,
ZERO_STRUCT(state);
state.mem_ctx = mem_ctx;
- if (!packet_handler(conn->pkt, ctdb_req_complete, ctdb_req_pull,
+ if (!ctdb_packet_handler(conn->pkt, ctdb_req_complete, ctdb_req_pull,
&state, &status)) {
/*
* Not enough data
@@ -383,7 +384,7 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32 reqid,
}
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("Could not read packet: %s\n", nt_errstr(status)));
+ DEBUG(0, ("Could not read ctdb_packet: %s\n", nt_errstr(status)));
cluster_fatal("ctdbd died\n");
}
@@ -432,7 +433,7 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32 reqid,
goto next_pkt;
}
- msg_state = TALLOC_P(NULL, struct deferred_msg_state);
+ msg_state = talloc(NULL, struct deferred_msg_state);
if (msg_state == NULL) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(hdr);
@@ -493,7 +494,7 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
struct ctdbd_connection *conn;
NTSTATUS status;
- if (!(conn = TALLOC_ZERO_P(mem_ctx, struct ctdbd_connection))) {
+ if (!(conn = talloc_zero(mem_ctx, struct ctdbd_connection))) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
@@ -583,7 +584,7 @@ struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn)
int ctdbd_conn_get_fd(struct ctdbd_connection *conn)
{
- return packet_get_fd(conn->pkt);
+ return ctdb_packet_get_fd(conn->pkt);
}
/*
@@ -674,14 +675,14 @@ static void ctdbd_socket_handler(struct event_context *event_ctx,
NTSTATUS status;
- status = packet_fd_read(conn->pkt);
+ status = ctdb_packet_fd_read(conn->pkt);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("packet_fd_read failed: %s\n", nt_errstr(status)));
cluster_fatal("ctdbd died\n");
}
- while (packet_handler(conn->pkt, ctdb_req_complete,
+ while (ctdb_packet_handler(conn->pkt, ctdb_req_complete,
ctdb_handle_message, conn, &status)) {
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("could not handle incoming message: %s\n",
@@ -701,7 +702,7 @@ NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
SMB_ASSERT(conn->fde == NULL);
if (!(conn->fde = event_add_fd(msg_ctx->event_ctx, conn,
- packet_get_fd(conn->pkt),
+ ctdb_packet_get_fd(conn->pkt),
EVENT_FD_READ,
ctdbd_socket_handler,
conn))) {
@@ -758,17 +759,17 @@ NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
DEBUG(10, ("ctdbd_messaging_send: Sending ctdb packet\n"));
ctdb_packet_dump(&r.hdr);
- status = packet_send(
+ status = ctdb_packet_send(
conn->pkt, 2,
data_blob_const(&r, offsetof(struct ctdb_req_message, data)),
blob);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("packet_send failed: %s\n", nt_errstr(status)));
+ DEBUG(0, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
goto fail;
}
- status = packet_flush(conn->pkt);
+ status = ctdb_packet_flush(conn->pkt);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
@@ -823,17 +824,17 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
ctdb_packet_dump(&req.hdr);
- status = packet_send(
+ status = ctdb_packet_send(
conn->pkt, 2,
data_blob_const(&req, offsetof(struct ctdb_req_control, data)),
data_blob_const(data.dptr, data.dsize));
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("packet_send failed: %s\n", nt_errstr(status)));
+ DEBUG(3, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
goto fail;
}
- status = packet_flush(conn->pkt);
+ status = ctdb_packet_flush(conn->pkt);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
@@ -1005,17 +1006,17 @@ NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32 db_id,
DEBUG(10, ("ctdbd_migrate: Sending ctdb packet\n"));
ctdb_packet_dump(&req.hdr);
- status = packet_send(
+ status = ctdb_packet_send(
conn->pkt, 2,
data_blob_const(&req, offsetof(struct ctdb_req_call, data)),
data_blob_const(key.dptr, key.dsize));
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("packet_send failed: %s\n", nt_errstr(status)));
+ DEBUG(3, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
return status;
}
- status = packet_flush(conn->pkt);
+ status = ctdb_packet_flush(conn->pkt);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
@@ -1064,17 +1065,17 @@ NTSTATUS ctdbd_fetch(struct ctdbd_connection *conn, uint32 db_id,
req.db_id = db_id;
req.keylen = key.dsize;
- status = packet_send(
+ status = ctdb_packet_send(
conn->pkt, 2,
data_blob_const(&req, offsetof(struct ctdb_req_call, data)),
data_blob_const(key.dptr, key.dsize));
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("packet_send failed: %s\n", nt_errstr(status)));
+ DEBUG(3, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
return status;
}
- status = packet_flush(conn->pkt);
+ status = ctdb_packet_flush(conn->pkt);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
@@ -1235,7 +1236,7 @@ NTSTATUS ctdbd_traverse(uint32 db_id,
status = NT_STATUS_OK;
- if (packet_handler(conn->pkt, ctdb_req_complete,
+ if (ctdb_packet_handler(conn->pkt, ctdb_req_complete,
ctdb_traverse_handler, &state, &status)) {
if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
@@ -1268,7 +1269,7 @@ NTSTATUS ctdbd_traverse(uint32 db_id,
}
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("packet_fd_read_sync failed: %s\n", nt_errstr(status)));
+ DEBUG(0, ("ctdb_packet_fd_read_sync failed: %s\n", nt_errstr(status)));
cluster_fatal("ctdbd died\n");
}
}
@@ -1357,6 +1358,11 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
}
conn->release_ip_handler = release_ip_handler;
+ /*
+ * store the IP address of the server socket for later
+ * comparison in release_ip()
+ */
+ conn->release_ip_priv = private_data;
/*
* We want to be told about IP releases
diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c
index 4e7346c2c4f..83fc40efacf 100644
--- a/source3/lib/dbwrap.c
+++ b/source3/lib/dbwrap.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "dbwrap.h"
+#include "util_tdb.h"
#ifdef CLUSTER_SUPPORT
#include "ctdb_private.h"
#endif
@@ -156,63 +157,3 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
return result;
}
-
-NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key)
-{
- struct db_record *rec;
- NTSTATUS status;
-
- rec = db->fetch_locked(db, talloc_tos(), key);
- if (rec == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- status = rec->delete_rec(rec);
- TALLOC_FREE(rec);
- return status;
-}
-
-NTSTATUS dbwrap_store(struct db_context *db, TDB_DATA key,
- TDB_DATA data, int flags)
-{
- struct db_record *rec;
- NTSTATUS status;
-
- rec = db->fetch_locked(db, talloc_tos(), key);
- if (rec == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- status = rec->store(rec, data, flags);
- TALLOC_FREE(rec);
- return status;
-}
-
-TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
- TDB_DATA key)
-{
- TDB_DATA result;
-
- if (db->fetch(db, mem_ctx, key, &result) == -1) {
- return make_tdb_data(NULL, 0);
- }
-
- return result;
-}
-
-NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key)
-{
- return dbwrap_delete(db, string_term_tdb_data(key));
-}
-
-NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key,
- TDB_DATA data, int flags)
-{
- return dbwrap_store(db, string_term_tdb_data(key), data, flags);
-}
-
-TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx,
- const char *key)
-{
- return dbwrap_fetch(db, mem_ctx, string_term_tdb_data(key));
-}
-
diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c
index f9a7dd6a6ff..255a6730203 100644
--- a/source3/lib/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap_ctdb.c
@@ -20,6 +20,8 @@
#include "includes.h"
#include "system/filesys.h"
+#include "lib/util/tdb_wrap.h"
+#include "util_tdb.h"
#ifdef CLUSTER_SUPPORT
#include "ctdb.h"
#include "ctdb_private.h"
@@ -89,7 +91,7 @@ static NTSTATUS db_ctdb_ltdb_fetch(struct db_ctdb_ctx *db,
TDB_DATA rec;
NTSTATUS status;
- rec = tdb_fetch(db->wtdb->tdb, key);
+ rec = tdb_fetch_compat(db->wtdb->tdb, key);
if (rec.dsize < sizeof(struct ctdb_ltdb_header)) {
status = NT_STATUS_NOT_FOUND;
if (data) {
@@ -537,7 +539,7 @@ static struct db_record *db_ctdb_fetch_locked_transaction(struct db_ctdb_ctx *ct
return result;
}
- ctdb_data = tdb_fetch(ctx->wtdb->tdb, key);
+ ctdb_data = tdb_fetch_compat(ctx->wtdb->tdb, key);
if (ctdb_data.dptr == NULL) {
/* create the record */
result->value = tdb_null;
@@ -623,7 +625,7 @@ static NTSTATUS db_ctdb_transaction_store(struct db_ctdb_transaction_handle *h,
if (!pull_newest_from_marshall_buffer(h->m_write, key, &header,
NULL, NULL)) {
- rec = tdb_fetch(h->ctx->wtdb->tdb, key);
+ rec = tdb_fetch_compat(h->ctx->wtdb->tdb, key);
if (rec.dptr != NULL) {
memcpy(&header, rec.dptr,
@@ -992,10 +994,7 @@ static int db_ctdb_record_destr(struct db_record* data)
hex_encode_talloc(data, (unsigned char *)data->key.dptr,
data->key.dsize)));
- if (tdb_chainunlock(crec->ctdb_ctx->wtdb->tdb, data->key) != 0) {
- DEBUG(0, ("tdb_chainunlock failed\n"));
- return -1;
- }
+ tdb_chainunlock(crec->ctdb_ctx->wtdb->tdb, data->key);
threshold = lp_ctdb_locktime_warn_threshold();
if (threshold != 0) {
@@ -1023,7 +1022,7 @@ static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx,
return NULL;
}
- if (!(crec = TALLOC_ZERO_P(result, struct db_ctdb_rec))) {
+ if (!(crec = talloc_zero(result, struct db_ctdb_rec))) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(result);
return NULL;
@@ -1064,7 +1063,7 @@ again:
result->delete_rec = db_ctdb_delete;
talloc_set_destructor(result, db_ctdb_record_destr);
- ctdb_data = tdb_fetch(ctx->wtdb->tdb, key);
+ ctdb_data = tdb_fetch_compat(ctx->wtdb->tdb, key);
/*
* See if we have a valid record and we are the dmaster. If so, we can
@@ -1164,7 +1163,7 @@ static int db_ctdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
}
/* try a direct fetch */
- ctdb_data = tdb_fetch(ctx->wtdb->tdb, key);
+ ctdb_data = tdb_fetch_compat(ctx->wtdb->tdb, key);
/*
* See if we have a valid record and we are the dmaster. If so, we can
@@ -1363,13 +1362,13 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
return NULL;
}
- if (!(result = TALLOC_ZERO_P(mem_ctx, struct db_context))) {
+ if (!(result = talloc_zero(mem_ctx, struct db_context))) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(result);
return NULL;
}
- if (!(db_ctdb = TALLOC_P(result, struct db_ctdb_ctx))) {
+ if (!(db_ctdb = talloc(result, struct db_ctdb_ctx))) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(result);
return NULL;
diff --git a/source3/lib/dbwrap_file.c b/source3/lib/dbwrap_file.c
index 69ad8e4b20c..6ecd72810de 100644
--- a/source3/lib/dbwrap_file.c
+++ b/source3/lib/dbwrap_file.c
@@ -80,12 +80,12 @@ static struct db_record *db_file_fetch_locked(struct db_context *db,
SMB_ASSERT(ctx->locked_record == NULL);
again:
- if (!(result = TALLOC_P(mem_ctx, struct db_record))) {
+ if (!(result = talloc(mem_ctx, struct db_record))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
- if (!(file = TALLOC_P(result, struct db_locked_file))) {
+ if (!(file = talloc(result, struct db_locked_file))) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(result);
return NULL;
@@ -168,7 +168,7 @@ static struct db_record *db_file_fetch_locked(struct db_context *db,
if (statbuf.st_size != 0) {
result->value.dsize = statbuf.st_size;
- result->value.dptr = TALLOC_ARRAY(result, uint8,
+ result->value.dptr = talloc_array(result, uint8,
statbuf.st_size);
if (result->value.dptr == NULL) {
DEBUG(1, ("talloc failed\n"));
@@ -348,12 +348,12 @@ struct db_context *db_open_file(TALLOC_CTX *mem_ctx,
struct db_context *result = NULL;
struct db_file_ctx *ctx;
- if (!(result = TALLOC_ZERO_P(mem_ctx, struct db_context))) {
+ if (!(result = talloc_zero(mem_ctx, struct db_context))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
- if (!(ctx = TALLOC_P(result, struct db_file_ctx))) {
+ if (!(ctx = talloc(result, struct db_file_ctx))) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(result);
return NULL;
diff --git a/source3/lib/dbwrap_rbt.c b/source3/lib/dbwrap_rbt.c
index af88c79e6a4..fd6e988864b 100644
--- a/source3/lib/dbwrap_rbt.c
+++ b/source3/lib/dbwrap_rbt.c
@@ -400,7 +400,7 @@ struct db_context *db_open_rbt(TALLOC_CTX *mem_ctx)
return NULL;
}
- result->private_data = TALLOC_ZERO_P(result, struct db_rbt_ctx);
+ result->private_data = talloc_zero(result, struct db_rbt_ctx);
if (result->private_data == NULL) {
TALLOC_FREE(result);
diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c
index 4cdc1930eed..2efb3dfe39d 100644
--- a/source3/lib/dbwrap_tdb.c
+++ b/source3/lib/dbwrap_tdb.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "dbwrap.h"
+#include "lib/util/tdb_wrap.h"
struct db_tdb_ctx {
struct tdb_wrap *wtdb;
@@ -42,10 +43,7 @@ static int db_tdb_record_destr(struct db_record* data)
hex_encode_talloc(data, (unsigned char *)data->key.dptr,
data->key.dsize)));
- if (tdb_chainunlock(ctx->wtdb->tdb, data->key) != 0) {
- DEBUG(0, ("tdb_chainunlock failed\n"));
- return -1;
- }
+ tdb_chainunlock(ctx->wtdb->tdb, data->key);
return 0;
}
@@ -329,7 +327,8 @@ static int db_tdb_transaction_cancel(struct db_context *db)
{
struct db_tdb_ctx *db_ctx =
talloc_get_type_abort(db->private_data, struct db_tdb_ctx);
- return tdb_transaction_cancel(db_ctx->wtdb->tdb);
+ tdb_transaction_cancel(db_ctx->wtdb->tdb);
+ return 0;
}
struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
@@ -340,13 +339,13 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
struct db_context *result = NULL;
struct db_tdb_ctx *db_tdb;
- result = TALLOC_ZERO_P(mem_ctx, struct db_context);
+ result = talloc_zero(mem_ctx, struct db_context);
if (result == NULL) {
DEBUG(0, ("talloc failed\n"));
goto fail;
}
- result->private_data = db_tdb = TALLOC_P(result, struct db_tdb_ctx);
+ result->private_data = db_tdb = talloc(result, struct db_tdb_ctx);
if (db_tdb == NULL) {
DEBUG(0, ("talloc failed\n"));
goto fail;
diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c
index 35f8a14d0d4..effcf40c6b3 100644
--- a/source3/lib/dbwrap_util.c
+++ b/source3/lib/dbwrap_util.c
@@ -3,7 +3,10 @@
Utility functions for the dbwrap API
Copyright (C) Volker Lendecke 2007
Copyright (C) Michael Adam 2009
-
+ Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2006
+
+ Major code contributions from Aleksey Fedoseev (fedoseev@ru.ibm.com)
+
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
@@ -21,6 +24,7 @@
#include "includes.h"
#include "dbwrap.h"
+#include "util_tdb.h"
int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr)
{
@@ -429,7 +433,7 @@ static NTSTATUS dbwrap_trans_traverse_action(struct db_context* db, void* privat
int ret = db->traverse(db, ctx->f, ctx->private_data);
- return (ret == -1) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK;
+ return (ret < 0) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK;
}
NTSTATUS dbwrap_trans_traverse(struct db_context *db,
@@ -448,9 +452,69 @@ NTSTATUS dbwrap_traverse(struct db_context *db,
void *private_data)
{
int ret = db->traverse(db, f, private_data);
- return (ret == -1) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK;
+ return (ret < 0) ? NT_STATUS_INTERNAL_DB_CORRUPTION : NT_STATUS_OK;
+}
+
+
+
+NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key)
+{
+ struct db_record *rec;
+ NTSTATUS status;
+
+ rec = db->fetch_locked(db, talloc_tos(), key);
+ if (rec == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ status = rec->delete_rec(rec);
+ TALLOC_FREE(rec);
+ return status;
+}
+
+NTSTATUS dbwrap_store(struct db_context *db, TDB_DATA key,
+ TDB_DATA data, int flags)
+{
+ struct db_record *rec;
+ NTSTATUS status;
+
+ rec = db->fetch_locked(db, talloc_tos(), key);
+ if (rec == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = rec->store(rec, data, flags);
+ TALLOC_FREE(rec);
+ return status;
}
+TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
+ TDB_DATA key)
+{
+ TDB_DATA result;
+
+ if (db->fetch(db, mem_ctx, key, &result) != 0) {
+ return make_tdb_data(NULL, 0);
+ }
+
+ return result;
+}
+
+NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key)
+{
+ return dbwrap_delete(db, string_term_tdb_data(key));
+}
+
+NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key,
+ TDB_DATA data, int flags)
+{
+ return dbwrap_store(db, string_term_tdb_data(key), data, flags);
+}
+
+TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx,
+ const char *key)
+{
+ return dbwrap_fetch(db, mem_ctx, string_term_tdb_data(key));
+}
diff --git a/source3/lib/dprintf.c b/source3/lib/dprintf.c
deleted file mode 100644
index ad3c79a8d52..00000000000
--- a/source3/lib/dprintf.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- display print functions
- 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/>.
-*/
-
-
-/*
- this module provides functions for printing internal strings in the "display charset"
- This charset may be quite different from the chosen unix charset
-
- Eventually these functions will need to take care of column count constraints
-
- The d_ prefix on print functions in Samba refers to the display character set
- conversion
-*/
-
-#include "includes.h"
-#include "intl/lang_tdb.h"
-
- int d_vfprintf(FILE *f, const char *format, va_list ap)
-{
- char *p = NULL, *p2 = NULL;
- int ret, maxlen, clen;
- size_t size = 0;
- const char *msgstr;
- va_list ap2;
-
- va_copy(ap2, ap);
-
- /* do any message translations */
- msgstr = lang_msg(format);
- if (!msgstr) {
- ret = -1;
- goto out;
- }
-
- ret = vasprintf(&p, msgstr, ap2);
-
- lang_msg_free(msgstr);
-
- if (ret <= 0) {
- ret = -1;
- goto out;
- }
-
- /* now we have the string in unix format, convert it to the display
- charset, but beware of it growing */
- maxlen = ret*2;
-again:
- p2 = (char *)SMB_MALLOC(maxlen);
- if (!p2) {
- ret = -1;
- goto out;
- }
-
- if (!convert_string(CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen, &size)) {
- ret = -1;
- goto out;
- }
- clen = size;
-
- if (clen >= maxlen) {
- /* it didn't fit - try a larger buffer */
- maxlen *= 2;
- SAFE_FREE(p2);
- goto again;
- }
-
- /* good, its converted OK */
- ret = fwrite(p2, 1, clen, f);
-out:
-
- SAFE_FREE(p);
- SAFE_FREE(p2);
- va_end(ap2);
-
- return ret;
-}
-
-
- int d_fprintf(FILE *f, const char *format, ...)
-{
- int ret;
- va_list ap;
-
- va_start(ap, format);
- ret = d_vfprintf(f, format, ap);
- va_end(ap);
-
- return ret;
-}
-
-static FILE *outfile;
-
- int d_printf(const char *format, ...)
-{
- int ret;
- va_list ap;
-
- if (!outfile) outfile = stdout;
-
- va_start(ap, format);
- ret = d_vfprintf(outfile, format, ap);
- va_end(ap);
-
- return ret;
-}
-
-/* interactive programs need a way of tell d_*() to write to stderr instead
- of stdout */
-void display_set_stderr(void)
-{
- outfile = stderr;
-}
diff --git a/source3/lib/dummyroot.c b/source3/lib/dummyparam.c
index 64ea75814a1..bad5d56ffc5 100644
--- a/source3/lib/dummyroot.c
+++ b/source3/lib/dummyparam.c
@@ -1,19 +1,19 @@
-/*
+/*
Unix SMB/CIFS implementation.
RPC pipe client
- Copyright (C) Tim Potter 2003
+ Copyright (C) Gerald (Jerry) Carter 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/>.
*/
@@ -23,12 +23,13 @@
#include "includes.h"
-void become_root(void)
+int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out)
{
- return;
+ return -1;
}
-void unbecome_root(void)
+bool conn_snum_used(struct smbd_server_connection *sconn,
+ int snum)
{
- return;
+ return False;
}
diff --git a/source3/lib/errmap_unix.c b/source3/lib/errmap_unix.c
index b4a98f96342..ea195474ef7 100644
--- a/source3/lib/errmap_unix.c
+++ b/source3/lib/errmap_unix.c
@@ -24,91 +24,93 @@
/* Mapping from Unix, to NT error numbers */
-const struct unix_error_map unix_dos_nt_errmap[] = {
- { EPERM, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED },
- { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED },
- { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND },
- { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_NOT_A_DIRECTORY },
- { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR },
- { EBADF, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE },
- { EINVAL, ERRSRV, ERRsrverror, NT_STATUS_INVALID_PARAMETER },
- { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION},
- { ENFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES },
- { EMFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES },
- { ENOSPC, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
- { ENOMEM, ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY },
- { EISDIR, ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY},
- { EMLINK, ERRDOS, ERRgeneral, NT_STATUS_TOO_MANY_LINKS },
- { EINTR, ERRHRD, ERRgeneral, NT_STATUS_RETRY },
- { ENOSYS, ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED },
+static const struct {
+ int unix_error;
+ NTSTATUS nt_error;
+} unix_nt_errmap[] = {
+ { EAGAIN, NT_STATUS_NETWORK_BUSY },
+ { EINTR, NT_STATUS_RETRY },
+#ifdef ENOBUFS
+ { ENOBUFS, NT_STATUS_INSUFFICIENT_RESOURCES },
+#endif
+#ifdef EWOULDBLOCK
+ { EWOULDBLOCK, NT_STATUS_NETWORK_BUSY },
+#endif
+ { EPERM, NT_STATUS_ACCESS_DENIED },
+ { EACCES, NT_STATUS_ACCESS_DENIED },
+ { ENOENT, NT_STATUS_OBJECT_NAME_NOT_FOUND },
+ { ENOTDIR, NT_STATUS_NOT_A_DIRECTORY },
+ { EIO, NT_STATUS_IO_DEVICE_ERROR },
+ { EBADF, NT_STATUS_INVALID_HANDLE },
+ { EINVAL, NT_STATUS_INVALID_PARAMETER },
+ { EEXIST, NT_STATUS_OBJECT_NAME_COLLISION},
+ { ENFILE, NT_STATUS_TOO_MANY_OPENED_FILES },
+ { EMFILE, NT_STATUS_TOO_MANY_OPENED_FILES },
+ { ENOSPC, NT_STATUS_DISK_FULL },
+ { ENOMEM, NT_STATUS_NO_MEMORY },
+ { EISDIR, NT_STATUS_FILE_IS_A_DIRECTORY},
+#ifdef EPIPE
+ { EPIPE, NT_STATUS_PIPE_BROKEN},
+#endif
+ { EMLINK, NT_STATUS_TOO_MANY_LINKS },
+ { ENOSYS, NT_STATUS_NOT_SUPPORTED },
#ifdef ELOOP
- { ELOOP, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND },
+ { ELOOP, NT_STATUS_OBJECT_PATH_NOT_FOUND },
#endif
#ifdef EFTYPE
- { EFTYPE, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND },
+ { EFTYPE, NT_STATUS_OBJECT_PATH_NOT_FOUND },
#endif
#ifdef EDQUOT
- { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, /* Windows apps need this, not NT_STATUS_QUOTA_EXCEEDED */
+ { EDQUOT, NT_STATUS_DISK_FULL }, /* Windows apps need this, not NT_STATUS_QUOTA_EXCEEDED */
#endif
#ifdef ENOTEMPTY
- { ENOTEMPTY, ERRDOS, ERRnoaccess, NT_STATUS_DIRECTORY_NOT_EMPTY },
+ { ENOTEMPTY, NT_STATUS_DIRECTORY_NOT_EMPTY },
#endif
#ifdef EXDEV
- { EXDEV, ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE },
+ { EXDEV, NT_STATUS_NOT_SAME_DEVICE },
#endif
#ifdef EROFS
- { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED },
+ { EROFS, NT_STATUS_ACCESS_DENIED },
#endif
#ifdef ENAMETOOLONG
- { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID },
+ { ENAMETOOLONG, NT_STATUS_OBJECT_NAME_INVALID },
#endif
#ifdef EFBIG
- { EFBIG, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
-#endif
-#ifdef ENOBUFS
- { ENOBUFS, ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES },
+ { EFBIG, NT_STATUS_DISK_FULL },
#endif
- { EAGAIN, ERRDOS, 111, NT_STATUS_NETWORK_BUSY },
#ifdef EADDRINUSE
- { EADDRINUSE, ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
+ { EADDRINUSE, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
#endif
#ifdef ENETUNREACH
- { ENETUNREACH, ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE},
+ { ENETUNREACH, NT_STATUS_NETWORK_UNREACHABLE},
#endif
#ifdef EHOSTUNREACH
- { EHOSTUNREACH, ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE},
+ { EHOSTUNREACH, NT_STATUS_HOST_UNREACHABLE},
#endif
#ifdef ECONNREFUSED
- { ECONNREFUSED, ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED},
+ { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED},
#endif
#ifdef ETIMEDOUT
- { ETIMEDOUT, ERRHRD, 121, NT_STATUS_IO_TIMEOUT},
+ { ETIMEDOUT, NT_STATUS_IO_TIMEOUT},
#endif
#ifdef ECONNABORTED
- { ECONNABORTED, ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED},
+ { ECONNABORTED, NT_STATUS_CONNECTION_ABORTED},
#endif
#ifdef ECONNRESET
- { ECONNRESET, ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_RESET},
+ { ECONNRESET, NT_STATUS_CONNECTION_RESET},
#endif
#ifdef ENODEV
- { ENODEV, ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST},
-#endif
-#ifdef EPIPE
- { EPIPE, ERRDOS, 109, NT_STATUS_PIPE_BROKEN},
-#endif
-#ifdef EWOULDBLOCK
- { EWOULDBLOCK, ERRDOS, 111, NT_STATUS_NETWORK_BUSY },
+ { ENODEV, NT_STATUS_DEVICE_DOES_NOT_EXIST},
#endif
#ifdef ENOATTR
- { ENOATTR, ERRDOS, ERRbadfile, NT_STATUS_NOT_FOUND },
+ { ENOATTR, NT_STATUS_NOT_FOUND },
#endif
#ifdef ECANCELED
- { ECANCELED, ERRDOS, ERRbadfid, NT_STATUS_CANCELLED},
+ { ECANCELED, NT_STATUS_CANCELLED},
#endif
#ifdef ENOTSUP
- { ENOTSUP, ERRSRV, ERRnosupport, NT_STATUS_NOT_SUPPORTED},
+ { ENOTSUP, NT_STATUS_NOT_SUPPORTED},
#endif
- { 0, 0, 0, NT_STATUS_OK }
};
/*********************************************************************
@@ -131,22 +133,16 @@ NTSTATUS map_nt_error_from_unix(int unix_error)
}
/* Look through list */
- while(unix_dos_nt_errmap[i].unix_error != 0) {
- if (unix_dos_nt_errmap[i].unix_error == unix_error)
- return unix_dos_nt_errmap[i].nt_error;
- i++;
+ for (i=0;i<ARRAY_SIZE(unix_nt_errmap);i++) {
+ if (unix_nt_errmap[i].unix_error == unix_error) {
+ return unix_nt_errmap[i].nt_error;
+ }
}
/* Default return */
return NT_STATUS_ACCESS_DENIED;
}
-/* Convert a Unix error code to a WERROR. */
-WERROR unix_to_werror(int unix_error)
-{
- return ntstatus_to_werror(map_nt_error_from_unix(unix_error));
-}
-
/* Return a UNIX errno from a NT status code */
static const struct {
NTSTATUS status;
@@ -257,7 +253,6 @@ static const struct {
#ifdef EXDEV
{NT_STATUS_NOT_SAME_DEVICE, EXDEV},
#endif
- {NT_STATUS(0), 0}
};
int map_errno_from_nt_status(NTSTATUS status)
@@ -272,7 +267,7 @@ int map_errno_from_nt_status(NTSTATUS status)
return 0;
}
- for (i=0;nt_errno_map[i].error;i++) {
+ for (i=0;i<ARRAY_SIZE(nt_errno_map);i++) {
if (NT_STATUS_V(nt_errno_map[i].status) ==
NT_STATUS_V(status)) {
return nt_errno_map[i].error;
diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c
index 4941199c5ea..67583b8666c 100644
--- a/source3/lib/eventlog/eventlog.c
+++ b/source3/lib/eventlog/eventlog.c
@@ -24,6 +24,7 @@
#include "system/filesys.h"
#include "lib/eventlog/eventlog.h"
#include "../libcli/security/security.h"
+#include "util_tdb.h"
/* maintain a list of open eventlog tdbs with reference counts */
@@ -202,7 +203,7 @@ static bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32_t needed,
/* read a record, add the amt to nbytes */
key.dsize = sizeof(int32_t);
key.dptr = (unsigned char *)&i;
- ret = tdb_fetch( the_tdb, key );
+ ret = tdb_fetch_compat( the_tdb, key );
if ( ret.dsize == 0 ) {
DEBUG( 8,
( "Can't find a record for the key, record [%d]\n",
@@ -415,7 +416,7 @@ ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only )
return ptr;
}
- if ( !(tdb_node = TALLOC_ZERO_P( NULL, ELOG_TDB)) ) {
+ if ( !(tdb_node = talloc_zero( NULL, ELOG_TDB)) ) {
DEBUG(0,("elog_open_tdb: talloc() failure!\n"));
tdb_close( tdb );
return NULL;
@@ -678,7 +679,7 @@ struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx,
key.dptr = (unsigned char *)&srecno;
key.dsize = sizeof(int32_t);
- data = tdb_fetch(tdb, key);
+ data = tdb_fetch_compat(tdb, key);
if (data.dsize == 0) {
DEBUG(8,("evlog_pull_record_tdb: "
"Can't find a record for the key, record %d\n",
@@ -780,7 +781,7 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx,
/* lock */
ret = tdb_lock_bystring_with_timeout(tdb, EVT_NEXT_RECORD, 1);
- if (ret == -1) {
+ if (ret != 0) {
return NT_STATUS_LOCK_NOT_GRANTED;
}
@@ -803,13 +804,13 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx,
ebuf.dptr = blob.data;
ret = tdb_store(tdb, kbuf, ebuf, 0);
- if (ret == -1) {
+ if (ret != 0) {
tdb_unlock_bystring(tdb, EVT_NEXT_RECORD);
return NT_STATUS_EVENTLOG_FILE_CORRUPT;
}
ret = tdb_store_int32(tdb, EVT_NEXT_RECORD, r->record_number + 1);
- if (ret == -1) {
+ if (ret != 0) {
tdb_unlock_bystring(tdb, EVT_NEXT_RECORD);
return NT_STATUS_EVENTLOG_FILE_CORRUPT;
}
diff --git a/source3/lib/eventlog/eventlog.h b/source3/lib/eventlog/eventlog.h
index 29c25c31222..694732d184a 100644
--- a/source3/lib/eventlog/eventlog.h
+++ b/source3/lib/eventlog/eventlog.h
@@ -17,6 +17,8 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "tdb_compat.h"
+
/* Defines for TDB keys */
#define EVT_OLDEST_ENTRY "INFO/oldest_entry"
#define EVT_NEXT_RECORD "INFO/next_record"
diff --git a/source3/lib/eventlog/proto.h b/source3/lib/eventlog/proto.h
index 21790d0795c..d3341ce16d8 100644
--- a/source3/lib/eventlog/proto.h
+++ b/source3/lib/eventlog/proto.h
@@ -1,3 +1,28 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Eventlog utility routines
+ *
+ * Copyright (C) Marcin Krzysztof Porwit 2005
+ * Copyright (C) Brian Moran 2005
+ * Copyright (C) Gerald (Jerry) Carter 2005
+ * Copyright (C) Guenther Deschner 2009
+ *
+ * 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 _LIB_EVENTLOG_PROTO_H_
+#define _LIB_EVENTLOG_PROTO_H_
/* The following definitions come from lib/eventlog/eventlog.c */
@@ -33,3 +58,5 @@ NTSTATUS evlog_convert_tdb_to_evt(TALLOC_CTX *mem_ctx,
ELOG_TDB *etdb,
DATA_BLOB *blob_p,
uint32_t *num_records_p);
+
+#endif /* _LIB_EVENTLOG_PROTO_H_ */
diff --git a/source3/lib/events.c b/source3/lib/events.c
index e461ebe977c..f077f585812 100644
--- a/source3/lib/events.c
+++ b/source3/lib/events.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
-#include <tevent_internal.h>
+#include "lib/tevent/tevent_internal.h"
#include "../lib/util/select.h"
#include "system/select.h"
@@ -42,7 +42,7 @@ static struct tevent_poll_private *tevent_get_poll_private(
state = (struct tevent_poll_private *)ev->additional_data;
if (state == NULL) {
- state = TALLOC_ZERO_P(ev, struct tevent_poll_private);
+ state = talloc_zero(ev, struct tevent_poll_private);
ev->additional_data = (void *)state;
if (state == NULL) {
DEBUG(10, ("talloc failed\n"));
@@ -90,7 +90,7 @@ bool event_add_to_poll_args(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
idx_len = max_fd+1;
if (talloc_array_length(state->pollfd_idx) < idx_len) {
- state->pollfd_idx = TALLOC_REALLOC_ARRAY(
+ state->pollfd_idx = talloc_realloc(
state, state->pollfd_idx, int, idx_len);
if (state->pollfd_idx == NULL) {
DEBUG(10, ("talloc_realloc failed\n"));
@@ -107,7 +107,7 @@ bool event_add_to_poll_args(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
*/
if (talloc_array_length(fds) < num_pollfds + num_fds + 1) {
- fds = TALLOC_REALLOC_ARRAY(mem_ctx, fds, struct pollfd,
+ fds = talloc_realloc(mem_ctx, fds, struct pollfd,
num_pollfds + num_fds + 1);
if (fds == NULL) {
DEBUG(10, ("talloc_realloc failed\n"));
@@ -258,7 +258,20 @@ bool run_events_poll(struct tevent_context *ev, int pollrtn,
return false;
}
- if (pfd->revents & (POLLIN|POLLHUP|POLLERR)) {
+ if (pfd->revents & (POLLHUP|POLLERR)) {
+ /* If we only wait for EVENT_FD_WRITE, we
+ should not tell the event handler about it,
+ and remove the writable flag, as we only
+ report errors when waiting for read events
+ to match the select behavior. */
+ if (!(fde->flags & EVENT_FD_READ)) {
+ EVENT_FD_NOT_WRITEABLE(fde);
+ continue;
+ }
+ flags |= EVENT_FD_READ;
+ }
+
+ if (pfd->revents & POLLIN) {
flags |= EVENT_FD_READ;
}
if (pfd->revents & POLLOUT) {
diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c
index f12ca2d781b..2405183d53b 100644
--- a/source3/lib/filename_util.c
+++ b/source3/lib/filename_util.c
@@ -17,7 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
-#include "smbd/smbd.h"
/**
* XXX: This is temporary and there should be no callers of this outside of
@@ -61,8 +60,8 @@ NTSTATUS create_synthetic_smb_fname(TALLOC_CTX *ctx, const char *base_name,
ZERO_STRUCT(smb_fname_loc);
/* Setup the base_name/stream_name. */
- smb_fname_loc.base_name = CONST_DISCARD(char *, base_name);
- smb_fname_loc.stream_name = CONST_DISCARD(char *, stream_name);
+ smb_fname_loc.base_name = discard_const_p(char, base_name);
+ smb_fname_loc.stream_name = discard_const_p(char, stream_name);
/* Copy the psbuf if one was given. */
if (psbuf)
@@ -203,5 +202,5 @@ bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname)
return false;
}
- return StrCaseCmp(smb_fname->stream_name, "::$DATA") == 0;
+ return strcasecmp_m(smb_fname->stream_name, "::$DATA") == 0;
}
diff --git a/source3/lib/fncall.c b/source3/lib/fncall.c
index e810b6814ed..6e6b7c92504 100644
--- a/source3/lib/fncall.c
+++ b/source3/lib/fncall.c
@@ -18,10 +18,11 @@
*/
#include "includes.h"
+#include "../lib/util/tevent_unix.h"
#if WITH_PTHREADPOOL
-#include "pthreadpool.h"
+#include "lib/pthreadpool/pthreadpool.h"
struct fncall_state {
struct fncall_context *ctx;
@@ -86,7 +87,7 @@ struct fncall_context *fncall_context_init(TALLOC_CTX *mem_ctx,
}
talloc_set_destructor(ctx, fncall_context_destructor);
- ctx->sig_fd = pthreadpool_sig_fd(ctx->pool);
+ ctx->sig_fd = pthreadpool_signal_fd(ctx->pool);
if (ctx->sig_fd == -1) {
TALLOC_FREE(ctx);
return NULL;
@@ -265,7 +266,7 @@ struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
return tevent_req_post(req, ev);
}
if (!fncall_set_pending(req, state->ctx, ev)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return tevent_req_post(req, ev);
}
return req;
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 184da9b4fde..006ee3698cc 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "g_lock.h"
+#include "util_tdb.h"
#include "ctdbd_conn.h"
#include "../lib/util/select.h"
#include "system/select.h"
@@ -107,7 +108,7 @@ static bool g_lock_parse(TALLOC_CTX *mem_ctx, TDB_DATA data,
DEBUG(10, ("locks:\n"));
for (i=0; i<num_locks; i++) {
DEBUGADD(10, ("%s: %s %s\n",
- procid_str(talloc_tos(), &locks[i].pid),
+ server_id_str(talloc_tos(), &locks[i].pid),
((locks[i].lock_type & 1) == G_LOCK_READ) ?
"read" : "write",
(locks[i].lock_type & G_LOCK_PENDING) ?
@@ -117,7 +118,7 @@ static bool g_lock_parse(TALLOC_CTX *mem_ctx, TDB_DATA data,
&& !process_exists(locks[i].pid)) {
DEBUGADD(10, ("lock owner %s died -- discarding\n",
- procid_str(talloc_tos(),
+ server_id_str(talloc_tos(),
&locks[i].pid)));
if (i < (num_locks-1)) {
@@ -145,7 +146,7 @@ static void g_lock_cleanup(int *pnum_locks, struct g_lock_rec *locks)
continue;
}
DEBUGADD(10, ("%s does not exist -- discarding\n",
- procid_str(talloc_tos(), &locks[i].pid)));
+ server_id_str(talloc_tos(), &locks[i].pid)));
if (i < (num_locks-1)) {
locks[i] = locks[num_locks-1];
@@ -392,7 +393,7 @@ NTSTATUS g_lock_lock(struct g_lock_ctx *ctx, const char *name,
* sys_poll and in the clustering case we might have to add
* the ctdb fd. This avoids the realloc then.
*/
- pollfds = TALLOC_ARRAY(talloc_tos(), struct pollfd, 2);
+ pollfds = talloc_array(talloc_tos(), struct pollfd, 2);
if (pollfds == NULL) {
status = NT_STATUS_NO_MEMORY;
break;
@@ -495,7 +496,7 @@ static void g_lock_got_retry(struct messaging_context *msg,
bool *pretry = (bool *)private_data;
DEBUG(10, ("Got retry message from pid %s\n",
- procid_str(talloc_tos(), &server_id)));
+ server_id_str(talloc_tos(), &server_id)));
*pretry = true;
}
@@ -586,7 +587,7 @@ static NTSTATUS g_lock_force_unlock(struct g_lock_ctx *ctx, const char *name,
&data_blob_null);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("sending retry to %s failed: %s\n",
- procid_str(talloc_tos(),
+ server_id_str(talloc_tos(),
&locks[i].pid),
nt_errstr(status)));
} else {
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 67c37f34e73..31ead7be7e3 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -24,6 +24,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "system/glob.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_TDB
@@ -80,14 +81,10 @@ again:
return false;
}
first_try = false;
- DEBUG(0, ("gencache_init: tdb_check(%s) failed - retry after CLEAR_IF_FIRST\n",
+ DEBUG(0, ("gencache_init: tdb_check(%s) failed - retry after truncate\n",
cache_fname));
- cache = tdb_open_log(cache_fname, 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, open_flags, 0644);
- if (cache) {
- tdb_close(cache);
- cache = NULL;
- goto again;
- }
+ truncate(cache_fname, 0);
+ goto again;
}
}
@@ -125,7 +122,7 @@ again:
static TDB_DATA last_stabilize_key(void)
{
TDB_DATA result;
- result.dptr = (uint8_t *)"@LAST_STABILIZED";
+ result.dptr = discard_const_p(uint8_t, "@LAST_STABILIZED");
result.dsize = 17;
return result;
}
@@ -209,7 +206,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob,
*/
last_stabilize = 0;
- databuf = tdb_fetch(cache_notrans, last_stabilize_key());
+ databuf = tdb_fetch_compat(cache_notrans, last_stabilize_key());
if ((databuf.dptr != NULL)
&& (databuf.dptr[databuf.dsize-1] == '\0')) {
last_stabilize = atoi((char *)databuf.dptr);
@@ -347,11 +344,11 @@ bool gencache_parse(const char *keystr,
state.private_data = private_data;
ret = tdb_parse_record(cache_notrans, key, gencache_parse_fn, &state);
- if (ret != -1) {
+ if (ret == 0) {
return true;
}
ret = tdb_parse_record(cache, key, gencache_parse_fn, &state);
- return (ret != -1);
+ return (ret == 0);
}
struct gencache_get_data_blob_state {
@@ -464,9 +461,14 @@ bool gencache_stabilize(void)
}
res = tdb_transaction_start_nonblock(cache);
- if (res == -1) {
-
- if (tdb_error(cache) == TDB_ERR_NOLOCK) {
+ if (res != 0) {
+
+#if BUILD_TDB2
+ if (res == TDB_ERR_LOCK)
+#else
+ if (tdb_error(cache) == TDB_ERR_NOLOCK)
+#endif
+ {
/*
* Someone else already does the stabilize,
* this does not have to be done twice
@@ -475,15 +477,15 @@ bool gencache_stabilize(void)
}
DEBUG(10, ("Could not start transaction on gencache.tdb: "
- "%s\n", tdb_errorstr(cache)));
+ "%s\n", tdb_errorstr_compat(cache)));
return false;
}
res = tdb_transaction_start(cache_notrans);
- if (res == -1) {
+ if (res != 0) {
tdb_transaction_cancel(cache);
DEBUG(10, ("Could not start transaction on "
"gencache_notrans.tdb: %s\n",
- tdb_errorstr(cache_notrans)));
+ tdb_errorstr_compat(cache_notrans)));
return false;
}
@@ -491,36 +493,30 @@ bool gencache_stabilize(void)
state.written = false;
res = tdb_traverse(cache_notrans, stabilize_fn, &state);
- if ((res == -1) || state.error) {
- if ((tdb_transaction_cancel(cache_notrans) == -1)
- || (tdb_transaction_cancel(cache) == -1)) {
- smb_panic("tdb_transaction_cancel failed\n");
- }
+ if ((res < 0) || state.error) {
+ tdb_transaction_cancel(cache_notrans);
+ tdb_transaction_cancel(cache);
return false;
}
if (!state.written) {
- if ((tdb_transaction_cancel(cache_notrans) == -1)
- || (tdb_transaction_cancel(cache) == -1)) {
- smb_panic("tdb_transaction_cancel failed\n");
- }
+ tdb_transaction_cancel(cache_notrans);
+ tdb_transaction_cancel(cache);
return true;
}
res = tdb_transaction_commit(cache);
- if (res == -1) {
+ if (res != 0) {
DEBUG(10, ("tdb_transaction_commit on gencache.tdb failed: "
- "%s\n", tdb_errorstr(cache)));
- if (tdb_transaction_cancel(cache_notrans) == -1) {
- smb_panic("tdb_transaction_cancel failed\n");
- }
+ "%s\n", tdb_errorstr_compat(cache)));
+ tdb_transaction_cancel(cache_notrans);
return false;
}
res = tdb_transaction_commit(cache_notrans);
- if (res == -1) {
+ if (res != 0) {
DEBUG(10, ("tdb_transaction_commit on gencache.tdb failed: "
- "%s\n", tdb_errorstr(cache)));
+ "%s\n", tdb_errorstr_compat(cache)));
return false;
}
@@ -551,7 +547,7 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val,
}
if ((timeout < time(NULL)) || (val.dsize == 0)) {
res = tdb_delete(cache, key);
- if ((res == -1) && (tdb_error(cache) == TDB_ERR_NOEXIST)) {
+ if ((res != 0) && (tdb_error(cache) == TDB_ERR_NOEXIST)) {
res = 0;
} else {
state->written = true;
@@ -563,16 +559,16 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val,
}
}
- if (res == -1) {
+ if (res != 0) {
DEBUG(10, ("Transfer to gencache.tdb failed: %s\n",
- tdb_errorstr(cache)));
+ tdb_errorstr_compat(cache)));
state->error = true;
return -1;
}
- if (tdb_delete(cache_notrans, key) == -1) {
+ if (tdb_delete(cache_notrans, key) != 0) {
DEBUG(10, ("tdb_delete from gencache_notrans.tdb failed: "
- "%s\n", tdb_errorstr(cache_notrans)));
+ "%s\n", tdb_errorstr_compat(cache_notrans)));
state->error = true;
return -1;
}
diff --git a/source3/lib/idmap_cache.h b/source3/lib/idmap_cache.h
index af2ba82bf8d..1a62dba64fc 100644
--- a/source3/lib/idmap_cache.h
+++ b/source3/lib/idmap_cache.h
@@ -1,3 +1,26 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * ID Mapping Cache
+ *
+ * Copyright (C) Volker Lendecke 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _LIB_IDMAP_CACHE_H_
+#define _LIB_IDMAP_CACHE_H_
+
/* The following definitions come from lib/idmap_cache.c */
bool idmap_cache_find_sid2uid(const struct dom_sid *sid, uid_t *puid,
@@ -12,3 +35,5 @@ void idmap_cache_set_sid2gid(const struct dom_sid *sid, gid_t gid);
bool idmap_cache_del_uid(uid_t uid);
bool idmap_cache_del_gid(gid_t gid);
bool idmap_cache_del_sid(const struct dom_sid *sid);
+
+#endif /* _LIB_IDMAP_CACHE_H_ */
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index 30e94069a52..39dc9cb04c2 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
-#include "interfaces.h"
+#include "lib/socket/interfaces.h"
static struct iface_struct *probed_ifaces;
static int total_probed;
@@ -305,7 +305,7 @@ static void add_interface(const struct iface_struct *ifs)
char addr[INET6_ADDRSTRLEN];
struct interface *iface;
- if (iface_find((struct sockaddr *)&ifs->ip, False)) {
+ if (iface_find((const struct sockaddr *)&ifs->ip, False)) {
DEBUG(3,("add_interface: not adding duplicate interface %s\n",
print_sockaddr(addr, sizeof(addr), &ifs->ip) ));
return;
diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c
deleted file mode 100644
index e40eaa91425..00000000000
--- a/source3/lib/interfaces.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- return a list of network interfaces
- Copyright (C) Andrew Tridgell 1998
- Copyright (C) Jeremy Allison 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 "interfaces.h"
-
-/****************************************************************************
- Create a struct sockaddr_storage with the netmask bits set to 1.
-****************************************************************************/
-
-bool make_netmask(struct sockaddr_storage *pss_out,
- const struct sockaddr_storage *pss_in,
- unsigned long masklen)
-{
- *pss_out = *pss_in;
- /* Now apply masklen bits of mask. */
-#if defined(HAVE_IPV6)
- if (pss_in->ss_family == AF_INET6) {
- char *p = (char *)&((struct sockaddr_in6 *)pss_out)->sin6_addr;
- unsigned int i;
-
- if (masklen > 128) {
- return false;
- }
- for (i = 0; masklen >= 8; masklen -= 8, i++) {
- *p++ = 0xff;
- }
- /* Deal with the partial byte. */
- *p++ &= (0xff & ~(0xff>>masklen));
- i++;
- for (;i < sizeof(struct in6_addr); i++) {
- *p++ = '\0';
- }
- return true;
- }
-#endif
- if (pss_in->ss_family == AF_INET) {
- if (masklen > 32) {
- return false;
- }
- ((struct sockaddr_in *)pss_out)->sin_addr.s_addr =
- htonl(((0xFFFFFFFFL >> masklen) ^ 0xFFFFFFFFL));
- return true;
- }
- return false;
-}
-
-/****************************************************************************
- Create a struct sockaddr_storage set to the broadcast or network adress from
- an incoming sockaddr_storage.
-****************************************************************************/
-
-static void make_bcast_or_net(struct sockaddr_storage *pss_out,
- const struct sockaddr_storage *pss_in,
- const struct sockaddr_storage *nmask,
- bool make_bcast_p)
-{
- unsigned int i = 0, len = 0;
- char *pmask = NULL;
- char *p = NULL;
- *pss_out = *pss_in;
-
- /* Set all zero netmask bits to 1. */
-#if defined(HAVE_IPV6)
- if (pss_in->ss_family == AF_INET6) {
- p = (char *)&((struct sockaddr_in6 *)pss_out)->sin6_addr;
- pmask = (char *)&((struct sockaddr_in6 *)nmask)->sin6_addr;
- len = 16;
- }
-#endif
- if (pss_in->ss_family == AF_INET) {
- p = (char *)&((struct sockaddr_in *)pss_out)->sin_addr;
- pmask = (char *)&((struct sockaddr_in *)nmask)->sin_addr;
- len = 4;
- }
-
- for (i = 0; i < len; i++, p++, pmask++) {
- if (make_bcast_p) {
- *p = (*p & *pmask) | (*pmask ^ 0xff);
- } else {
- /* make_net */
- *p = (*p & *pmask);
- }
- }
-}
-
-void make_bcast(struct sockaddr_storage *pss_out,
- const struct sockaddr_storage *pss_in,
- const struct sockaddr_storage *nmask)
-{
- make_bcast_or_net(pss_out, pss_in, nmask, true);
-}
-
-void make_net(struct sockaddr_storage *pss_out,
- const struct sockaddr_storage *pss_in,
- const struct sockaddr_storage *nmask)
-{
- make_bcast_or_net(pss_out, pss_in, nmask, false);
-}
-
-/****************************************************************************
- Try the "standard" getifaddrs/freeifaddrs interfaces.
- Also gets IPv6 interfaces.
-****************************************************************************/
-
-/****************************************************************************
- Get the netmask address for a local interface.
-****************************************************************************/
-
-static int _get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
-{
- struct iface_struct *ifaces;
- struct ifaddrs *iflist = NULL;
- struct ifaddrs *ifptr = NULL;
- int count;
- int total = 0;
- size_t copy_size;
-
- if (getifaddrs(&iflist) < 0) {
- return -1;
- }
-
- count = 0;
- for (ifptr = iflist; ifptr != NULL; ifptr = ifptr->ifa_next) {
- if (!ifptr->ifa_addr || !ifptr->ifa_netmask) {
- continue;
- }
- if (!(ifptr->ifa_flags & IFF_UP)) {
- continue;
- }
- count += 1;
- }
-
- ifaces = talloc_array(mem_ctx, struct iface_struct, count);
- if (ifaces == NULL) {
- errno = ENOMEM;
- return -1;
- }
-
- /* Loop through interfaces, looking for given IP address */
- for (ifptr = iflist; ifptr != NULL; ifptr = ifptr->ifa_next) {
-
- if (!ifptr->ifa_addr || !ifptr->ifa_netmask) {
- continue;
- }
-
- /* Check the interface is up. */
- if (!(ifptr->ifa_flags & IFF_UP)) {
- continue;
- }
-
- memset(&ifaces[total], '\0', sizeof(ifaces[total]));
-
- copy_size = sizeof(struct sockaddr_in);
-
- ifaces[total].flags = ifptr->ifa_flags;
-
-#if defined(HAVE_IPV6)
- if (ifptr->ifa_addr->sa_family == AF_INET6) {
- copy_size = sizeof(struct sockaddr_in6);
- }
-#endif
-
- memcpy(&ifaces[total].ip, ifptr->ifa_addr, copy_size);
- memcpy(&ifaces[total].netmask, ifptr->ifa_netmask, copy_size);
-
- if (ifaces[total].flags & (IFF_BROADCAST|IFF_LOOPBACK)) {
- make_bcast(&ifaces[total].bcast,
- &ifaces[total].ip,
- &ifaces[total].netmask);
- } else if ((ifaces[total].flags & IFF_POINTOPOINT) &&
- ifptr->ifa_dstaddr ) {
- memcpy(&ifaces[total].bcast,
- ifptr->ifa_dstaddr,
- copy_size);
- } else {
- continue;
- }
-
- strlcpy(ifaces[total].name, ifptr->ifa_name,
- sizeof(ifaces[total].name));
- total++;
- }
-
- freeifaddrs(iflist);
-
- *pifaces = ifaces;
- return total;
-}
-
-static int iface_comp(struct iface_struct *i1, struct iface_struct *i2)
-{
- int r;
-
-#if defined(HAVE_IPV6)
- /*
- * If we have IPv6 - sort these interfaces lower
- * than any IPv4 ones.
- */
- if (i1->ip.ss_family == AF_INET6 &&
- i2->ip.ss_family == AF_INET) {
- return -1;
- } else if (i1->ip.ss_family == AF_INET &&
- i2->ip.ss_family == AF_INET6) {
- return 1;
- }
-
- if (i1->ip.ss_family == AF_INET6) {
- struct sockaddr_in6 *s1 = (struct sockaddr_in6 *)&i1->ip;
- struct sockaddr_in6 *s2 = (struct sockaddr_in6 *)&i2->ip;
-
- r = memcmp(&s1->sin6_addr,
- &s2->sin6_addr,
- sizeof(struct in6_addr));
- if (r) {
- return r;
- }
-
- s1 = (struct sockaddr_in6 *)&i1->netmask;
- s2 = (struct sockaddr_in6 *)&i2->netmask;
-
- r = memcmp(&s1->sin6_addr,
- &s2->sin6_addr,
- sizeof(struct in6_addr));
- if (r) {
- return r;
- }
- }
-#endif
-
- /* AIX uses __ss_family instead of ss_family inside of
- sockaddr_storage. Instead of trying to figure out which field to
- use, we can just cast it to a sockaddr.
- */
-
- if (((struct sockaddr *)&i1->ip)->sa_family == AF_INET) {
- struct sockaddr_in *s1 = (struct sockaddr_in *)&i1->ip;
- struct sockaddr_in *s2 = (struct sockaddr_in *)&i2->ip;
-
- r = ntohl(s1->sin_addr.s_addr) -
- ntohl(s2->sin_addr.s_addr);
- if (r) {
- return r;
- }
-
- s1 = (struct sockaddr_in *)&i1->netmask;
- s2 = (struct sockaddr_in *)&i2->netmask;
-
- return ntohl(s1->sin_addr.s_addr) -
- ntohl(s2->sin_addr.s_addr);
- }
- return 0;
-}
-
-/* this wrapper is used to remove duplicates from the interface list generated
- above */
-int get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
-{
- struct iface_struct *ifaces;
- int total, i, j;
-
- total = _get_interfaces(mem_ctx, &ifaces);
- if (total <= 0) return total;
-
- /* now we need to remove duplicates */
- TYPESAFE_QSORT(ifaces, total, iface_comp);
-
- for (i=1;i<total;) {
- if (iface_comp(&ifaces[i-1], &ifaces[i]) == 0) {
- for (j=i-1;j<total-1;j++) {
- ifaces[j] = ifaces[j+1];
- }
- total--;
- } else {
- i++;
- }
- }
-
- *pifaces = ifaces;
- return total;
-}
-
diff --git a/source3/lib/memcache.c b/source3/lib/memcache.c
index 425861ed77a..88453f32dd8 100644
--- a/source3/lib/memcache.c
+++ b/source3/lib/memcache.c
@@ -72,7 +72,7 @@ struct memcache *memcache_init(TALLOC_CTX *mem_ctx, size_t max_size)
{
struct memcache *result;
- result = TALLOC_ZERO_P(mem_ctx, struct memcache);
+ result = talloc_zero(mem_ctx, struct memcache);
if (result == NULL) {
return NULL;
}
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 4335554c2a0..76c1090b819 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -112,7 +112,7 @@ static int traverse_fn(struct db_record *rec, const struct server_id *id,
* the msg has already been deleted from the messages.tdb.*/
status = messaging_send_buf(msg_all->msg_ctx, *id, msg_all->msg_type,
- (uint8 *)msg_all->buf, msg_all->len);
+ (const uint8 *)msg_all->buf, msg_all->len);
if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
@@ -184,7 +184,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
struct messaging_context *ctx;
NTSTATUS status;
- if (!(ctx = TALLOC_ZERO_P(mem_ctx, struct messaging_context))) {
+ if (!(ctx = talloc_zero(mem_ctx, struct messaging_context))) {
return NULL;
}
@@ -205,7 +205,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
status = messaging_ctdbd_init(ctx, ctx, &ctx->remote);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(2, ("messaging_ctdb_init failed: %s\n",
+ DEBUG(2, ("messaging_ctdbd_init failed: %s\n",
nt_errstr(status)));
TALLOC_FREE(ctx);
return NULL;
@@ -257,7 +257,7 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx,
&msg_ctx->remote);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("messaging_ctdb_init failed: %s\n",
+ DEBUG(1, ("messaging_ctdbd_init failed: %s\n",
nt_errstr(status)));
return status;
}
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 3e2fde0b8fd..b9ee049d01d 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "messages.h"
+#include "util_tdb.h"
#ifdef CLUSTER_SUPPORT
@@ -104,12 +105,12 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
struct messaging_ctdbd_context *ctx;
NTSTATUS status;
- if (!(result = TALLOC_P(mem_ctx, struct messaging_backend))) {
+ if (!(result = talloc(mem_ctx, struct messaging_backend))) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
- if (!(ctx = TALLOC_P(result, struct messaging_ctdbd_context))) {
+ if (!(ctx = talloc(result, struct messaging_ctdbd_context))) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
diff --git a/source3/lib/messages_local.c b/source3/lib/messages_local.c
index 18074cdd925..455f3d34766 100644
--- a/source3/lib/messages_local.c
+++ b/source3/lib/messages_local.c
@@ -45,6 +45,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "messages.h"
+#include "lib/util/tdb_wrap.h"
struct messaging_tdb_context {
struct messaging_context *msg_ctx;
@@ -86,12 +87,12 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
struct messaging_backend *result;
struct messaging_tdb_context *ctx;
- if (!(result = TALLOC_P(mem_ctx, struct messaging_backend))) {
+ if (!(result = talloc(mem_ctx, struct messaging_backend))) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
- ctx = TALLOC_ZERO_P(result, struct messaging_tdb_context);
+ ctx = talloc_zero(result, struct messaging_tdb_context);
if (!ctx) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(result);
@@ -186,11 +187,11 @@ static NTSTATUS messaging_tdb_fetch(TDB_CONTEXT *msg_tdb,
DATA_BLOB blob;
enum ndr_err_code ndr_err;
- if (!(result = TALLOC_ZERO_P(mem_ctx, struct messaging_array))) {
+ if (!(result = talloc_zero(mem_ctx, struct messaging_array))) {
return NT_STATUS_NO_MEMORY;
}
- data = tdb_fetch(msg_tdb, key);
+ data = tdb_fetch_compat(msg_tdb, key);
if (data.dptr == NULL) {
*presult = result;
@@ -351,7 +352,7 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
key = message_key_pid(frame, pid);
- if (tdb_chainlock(tdb->tdb, key) == -1) {
+ if (tdb_chainlock(tdb->tdb, key) != 0) {
TALLOC_FREE(frame);
return NT_STATUS_LOCK_NOT_GRANTED;
}
@@ -370,7 +371,7 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
goto done;
}
- if (!(rec = TALLOC_REALLOC_ARRAY(talloc_tos(), msg_array->messages,
+ if (!(rec = talloc_realloc(talloc_tos(), msg_array->messages,
struct messaging_rec,
msg_array->num_messages+1))) {
status = NT_STATUS_NO_MEMORY;
@@ -419,7 +420,7 @@ static NTSTATUS retrieve_all_messages(TDB_CONTEXT *msg_tdb,
TDB_DATA key = message_key_pid(mem_ctx, id);
NTSTATUS status;
- if (tdb_chainlock(msg_tdb, key) == -1) {
+ if (tdb_chainlock(msg_tdb, key) != 0) {
TALLOC_FREE(key.dptr);
return NT_STATUS_LOCK_NOT_GRANTED;
}
diff --git a/source3/lib/module.c b/source3/lib/module.c
index de136680092..bec4fddefdc 100644
--- a/source3/lib/module.c
+++ b/source3/lib/module.c
@@ -117,10 +117,10 @@ NTSTATUS smb_probe_module(const char *subsystem, const char *module)
}
full_path = talloc_asprintf(ctx,
- "%s/%s.%s",
- modules_path(subsystem),
- module,
- shlib_ext());
+ "%s/%s.%s",
+ modules_path(ctx, subsystem),
+ module,
+ shlib_ext());
if (!full_path) {
TALLOC_FREE(ctx);
return NT_STATUS_NO_MEMORY;
diff --git a/source3/lib/ms_fnmatch.c b/source3/lib/ms_fnmatch.c
index 31c66953a96..f02354bfd7d 100644
--- a/source3/lib/ms_fnmatch.c
+++ b/source3/lib/ms_fnmatch.c
@@ -166,7 +166,7 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
if (is_case_sensitive) {
return strcmp(pattern, string);
} else {
- return StrCaseCmp(pattern, string);
+ return strcasecmp_m(pattern, string);
}
}
@@ -229,10 +229,3 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
TALLOC_FREE(s);
return ret;
}
-
-
-/* a generic fnmatch function - uses for non-CIFS pattern matching */
-int gen_fnmatch(const char *pattern, const char *string)
-{
- return ms_fnmatch(pattern, string, true, False);
-}
diff --git a/source3/lib/namearray.c b/source3/lib/namearray.c
new file mode 100644
index 00000000000..e5c3bd983b5
--- /dev/null
+++ b/source3/lib/namearray.c
@@ -0,0 +1,39 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 2001-2007
+ Copyright (C) Simo Sorce 2001
+ Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
+ Copyright (C) James Peach 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+/****************************************************************************
+ Routine to free a namearray.
+****************************************************************************/
+
+void free_namearray(name_compare_entry *name_array)
+{
+ int i;
+
+ if(name_array == NULL)
+ return;
+
+ for(i=0; name_array[i].name!=NULL; i++)
+ SAFE_FREE(name_array[i].name);
+ SAFE_FREE(name_array);
+}
diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c
index 290194ba2d9..47ccf8bb7a3 100644
--- a/source3/lib/netapi/cm.c
+++ b/source3/lib/netapi/cm.c
@@ -22,6 +22,7 @@
#include "lib/netapi/netapi.h"
#include "lib/netapi/netapi_private.h"
+#include "libsmb/libsmb.h"
#include "rpc_client/cli_pipe.h"
/********************************************************************
@@ -121,7 +122,7 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
return WERR_CAN_NOT_COMPLETE;
}
- p = TALLOC_ZERO_P(ctx, struct client_ipc_connection);
+ p = talloc_zero(ctx, struct client_ipc_connection);
if (p == NULL) {
return WERR_NOMEM;
}
@@ -187,7 +188,7 @@ static NTSTATUS pipe_cm_connect(TALLOC_CTX *mem_ctx,
struct client_pipe_connection *p;
NTSTATUS status;
- p = TALLOC_ZERO_ARRAY(mem_ctx, struct client_pipe_connection, 1);
+ p = talloc_zero_array(mem_ctx, struct client_pipe_connection, 1);
if (!p) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c
index 4295d9f7bbf..710ec3790f2 100644
--- a/source3/lib/netapi/group.c
+++ b/source3/lib/netapi/group.c
@@ -1157,7 +1157,7 @@ static WERROR convert_samr_disp_groups_to_GROUP_INFO_0_buffer(TALLOC_CTX *mem_ct
struct GROUP_INFO_0 *g0;
int i;
- g0 = TALLOC_ZERO_ARRAY(mem_ctx, struct GROUP_INFO_0, groups->count);
+ g0 = talloc_zero_array(mem_ctx, struct GROUP_INFO_0, groups->count);
W_ERROR_HAVE_NO_MEMORY(g0);
for (i=0; i<groups->count; i++) {
@@ -1183,7 +1183,7 @@ static WERROR convert_samr_disp_groups_to_GROUP_INFO_1_buffer(TALLOC_CTX *mem_ct
struct GROUP_INFO_1 *g1;
int i;
- g1 = TALLOC_ZERO_ARRAY(mem_ctx, struct GROUP_INFO_1, groups->count);
+ g1 = talloc_zero_array(mem_ctx, struct GROUP_INFO_1, groups->count);
W_ERROR_HAVE_NO_MEMORY(g1);
for (i=0; i<groups->count; i++) {
@@ -1211,7 +1211,7 @@ static WERROR convert_samr_disp_groups_to_GROUP_INFO_2_buffer(TALLOC_CTX *mem_ct
struct GROUP_INFO_2 *g2;
int i;
- g2 = TALLOC_ZERO_ARRAY(mem_ctx, struct GROUP_INFO_2, groups->count);
+ g2 = talloc_zero_array(mem_ctx, struct GROUP_INFO_2, groups->count);
W_ERROR_HAVE_NO_MEMORY(g2);
for (i=0; i<groups->count; i++) {
@@ -1242,7 +1242,7 @@ static WERROR convert_samr_disp_groups_to_GROUP_INFO_3_buffer(TALLOC_CTX *mem_ct
struct GROUP_INFO_3 *g3;
int i;
- g3 = TALLOC_ZERO_ARRAY(mem_ctx, struct GROUP_INFO_3, groups->count);
+ g3 = talloc_zero_array(mem_ctx, struct GROUP_INFO_3, groups->count);
W_ERROR_HAVE_NO_MEMORY(g3);
for (i=0; i<groups->count; i++) {
diff --git a/source3/lib/netapi/libnetapi.h b/source3/lib/netapi/libnetapi.h
index 2711558dbc1..e832deaccc7 100644
--- a/source3/lib/netapi/libnetapi.h
+++ b/source3/lib/netapi/libnetapi.h
@@ -1,3 +1,22 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * NetApi Support
+ * Copyright (C) Guenther Deschner 2007-2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef __LIBNETAPI_LIBNETAPI__
#define __LIBNETAPI_LIBNETAPI__
NET_API_STATUS NetJoinDomain(const char * server /* [in] [unique] */,
diff --git a/source3/lib/netapi/localgroup.c b/source3/lib/netapi/localgroup.c
index 51f4e1d7459..816afc230ff 100644
--- a/source3/lib/netapi/localgroup.c
+++ b/source3/lib/netapi/localgroup.c
@@ -610,7 +610,7 @@ static WERROR map_buffer_to_alias_info(TALLOC_CTX *mem_ctx,
struct LOCALGROUP_INFO_1002 *info1002;
union samr_AliasInfo *info = NULL;
- info = TALLOC_ZERO_P(mem_ctx, union samr_AliasInfo);
+ info = talloc_zero(mem_ctx, union samr_AliasInfo);
W_ERROR_HAVE_NO_MEMORY(info);
switch (level) {
@@ -1115,7 +1115,7 @@ static WERROR NetLocalGroupModifyMembers_r(struct libnetapi_ctx *ctx,
ZERO_STRUCT(domain_handle);
ZERO_STRUCT(alias_handle);
- member_sids = TALLOC_ZERO_ARRAY(ctx, struct dom_sid,
+ member_sids = talloc_zero_array(ctx, struct dom_sid,
r->in.total_entries);
W_ERROR_HAVE_NO_MEMORY(member_sids);
@@ -1344,7 +1344,7 @@ static WERROR NetLocalGroupModifyMembers_r(struct libnetapi_ctx *ctx,
werr = WERR_OK;
done:
- if (is_valid_policy_hnd(&alias_handle)) {
+ if (b && is_valid_policy_hnd(&alias_handle)) {
dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result);
}
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c
index cd590273ce2..14259864ae2 100644
--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -24,7 +24,6 @@
#include "krb5_env.h"
struct libnetapi_ctx *stat_ctx = NULL;
-TALLOC_CTX *frame = NULL;
static bool libnetapi_initialized = false;
/****************************************************************
@@ -38,7 +37,7 @@ static NET_API_STATUS libnetapi_init_private_context(struct libnetapi_ctx *ctx)
return W_ERROR_V(WERR_INVALID_PARAM);
}
- priv = TALLOC_ZERO_P(ctx, struct libnetapi_private_ctx);
+ priv = talloc_zero(ctx, struct libnetapi_private_ctx);
if (!priv) {
return W_ERROR_V(WERR_NOMEM);
}
@@ -57,6 +56,8 @@ were not expecting it.
NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
{
+ NET_API_STATUS ret;
+ TALLOC_CTX *frame;
if (stat_ctx && libnetapi_initialized) {
*context = stat_ctx;
return NET_API_STATUS_SUCCESS;
@@ -76,7 +77,7 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
lp_set_cmdline("log level", "0");
setup_logging("libnetapi", DEBUG_STDERR);
- if (!lp_load(get_dyn_CONFIGFILE(), true, false, false, false)) {
+ if (!lp_load(get_dyn_CONFIGFILE(), true, false, false, true)) {
TALLOC_FREE(frame);
fprintf(stderr, "error loading %s\n", get_dyn_CONFIGFILE() );
return W_ERROR_V(WERR_GENERAL_FAILURE);
@@ -88,7 +89,9 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
BlockSignals(True, SIGPIPE);
- return libnetapi_net_init(context);
+ ret = libnetapi_net_init(context);
+ TALLOC_FREE(frame);
+ return ret;
}
/****************************************************************
@@ -105,7 +108,7 @@ NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context)
struct libnetapi_ctx *ctx = NULL;
char *krb5_cc_env = NULL;
- frame = talloc_stackframe();
+ TALLOC_CTX *frame = talloc_stackframe();
ctx = talloc_zero(frame, struct libnetapi_ctx);
if (!ctx) {
@@ -117,14 +120,14 @@ NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context)
krb5_cc_env = getenv(KRB5_ENV_CCNAME);
if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) {
- ctx->krb5_cc_env = talloc_strdup(frame, "MEMORY:libnetapi");
+ ctx->krb5_cc_env = talloc_strdup(ctx, "MEMORY:libnetapi");
setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1);
}
if (getenv("USER")) {
- ctx->username = talloc_strdup(frame, getenv("USER"));
+ ctx->username = talloc_strdup(ctx, getenv("USER"));
} else {
- ctx->username = talloc_strdup(frame, "");
+ ctx->username = talloc_strdup(ctx, "");
}
if (!ctx->username) {
TALLOC_FREE(frame);
@@ -140,8 +143,10 @@ NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context)
libnetapi_initialized = true;
+ talloc_steal(NULL, ctx);
*context = stat_ctx = ctx;
-
+
+ TALLOC_FREE(frame);
return NET_API_STATUS_SUCCESS;
}
@@ -187,8 +192,10 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
secrets_shutdown();
+ if (ctx == stat_ctx) {
+ stat_ctx = NULL;
+ }
TALLOC_FREE(ctx);
- TALLOC_FREE(frame);
gfree_debugsyms();
@@ -202,10 +209,14 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
const char *debuglevel)
{
+ TALLOC_CTX *frame = talloc_stackframe();
ctx->debuglevel = talloc_strdup(ctx, debuglevel);
+
if (!lp_set_cmdline("log level", debuglevel)) {
+ TALLOC_FREE(frame);
return W_ERROR_V(WERR_GENERAL_FAILURE);
}
+ TALLOC_FREE(frame);
return NET_API_STATUS_SUCCESS;
}
@@ -272,15 +283,22 @@ NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx)
}
/****************************************************************
+Return a libnetapi error as a string, caller must free with NetApiBufferFree
****************************************************************/
-const char *libnetapi_errstr(NET_API_STATUS status)
+char *libnetapi_errstr(NET_API_STATUS status)
{
+ TALLOC_CTX *frame = talloc_stackframe();
+ char *ret;
if (status & 0xc0000000) {
- return get_friendly_nt_error_msg(NT_STATUS(status));
+ ret = talloc_strdup(NULL,
+ get_friendly_nt_error_msg(NT_STATUS(status)));
+ } else {
+ ret = talloc_strdup(NULL,
+ get_friendly_werror_msg(W_ERROR(status)));
}
-
- return get_friendly_werror_msg(W_ERROR(status));
+ TALLOC_FREE(frame);
+ return ret;
}
/****************************************************************
@@ -304,9 +322,10 @@ NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx,
}
/****************************************************************
+Return a libnetapi_errstr(), caller must free with NetApiBufferFree
****************************************************************/
-const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
+char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
NET_API_STATUS status_in)
{
NET_API_STATUS status;
@@ -320,7 +339,7 @@ const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
}
if (tmp_ctx->error_string) {
- return tmp_ctx->error_string;
+ return talloc_strdup(NULL, tmp_ctx->error_string);
}
return libnetapi_errstr(status_in);
diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h
index 9e1549df0eb..620d8cf5910 100644
--- a/source3/lib/netapi/netapi.h
+++ b/source3/lib/netapi/netapi.h
@@ -1411,15 +1411,18 @@ NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx);
/****************************************************************
+Return a specific libnetapi error as a string, caller must free with NetApiBufferFree
****************************************************************/
-const char *libnetapi_errstr(NET_API_STATUS status);
+char *libnetapi_errstr(NET_API_STATUS status);
/****************************************************************
+Return the last libnetapi error as a string, caller must free with NetApiBufferFree
+ctx is optional
****************************************************************/
-const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
- NET_API_STATUS status);
+char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
+ NET_API_STATUS status);
/****************************************************************
NetApiBufferAllocate
diff --git a/source3/lib/netapi/netapi_private.h b/source3/lib/netapi/netapi_private.h
index 7559c615647..349287b9e96 100644
--- a/source3/lib/netapi/netapi_private.h
+++ b/source3/lib/netapi/netapi_private.h
@@ -29,6 +29,8 @@
} \
return fn ## _r(ctx, r);
+struct dcerpc_binding_handle;
+
struct libnetapi_private_ctx {
struct {
const char *domain_name;
diff --git a/source3/lib/netapi/samr.c b/source3/lib/netapi/samr.c
index 544698004a0..1c3a94ee9cd 100644
--- a/source3/lib/netapi/samr.c
+++ b/source3/lib/netapi/samr.c
@@ -240,7 +240,7 @@ WERROR libnetapi_samr_open_builtin_domain(struct libnetapi_ctx *mem_ctx,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
connect_handle,
builtin_mask,
- CONST_DISCARD(struct dom_sid *, &global_sid_Builtin),
+ discard_const_p(struct dom_sid, &global_sid_Builtin),
builtin_handle,
&result);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c
index 22c7df69d12..4b11339f945 100644
--- a/source3/lib/netapi/serverinfo.c
+++ b/source3/lib/netapi/serverinfo.c
@@ -36,9 +36,9 @@ static WERROR NetServerGetInfo_l_101(struct libnetapi_ctx *ctx,
struct SERVER_INFO_101 i;
i.sv101_platform_id = PLATFORM_ID_NT;
- i.sv101_name = global_myname();
- i.sv101_version_major = lp_major_announce_version();
- i.sv101_version_minor = lp_minor_announce_version();
+ i.sv101_name = lp_netbios_name();
+ i.sv101_version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ i.sv101_version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
i.sv101_type = lp_default_server_announce();
i.sv101_comment = lp_serverstring();
@@ -540,7 +540,8 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx,
static WERROR NetServerSetInfo_l_1005(struct libnetapi_ctx *ctx,
struct NetServerSetInfo *r)
{
- WERROR werr;
+ WERROR werr = WERR_OK;
+ sbcErr err;
struct smbconf_ctx *conf_ctx;
struct srvsvc_NetSrvInfo1005 *info1005;
@@ -563,13 +564,24 @@ static WERROR NetServerSetInfo_l_1005(struct libnetapi_ctx *ctx,
return WERR_NOT_SUPPORTED;
}
- werr = smbconf_init_reg(ctx, &conf_ctx, NULL);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init_reg(ctx, &conf_ctx, NULL);
+ if (!SBC_ERROR_IS_OK(err)) {
+ libnetapi_set_error_string(ctx,
+ "Could not initialize backend: %s",
+ sbcErrorString(err));
+ werr = WERR_NO_SUCH_SERVICE;
goto done;
}
- werr = smbconf_set_global_parameter(conf_ctx, "server string",
+ err = smbconf_set_global_parameter(conf_ctx, "server string",
info1005->comment);
+ if (!SBC_ERROR_IS_OK(err)) {
+ libnetapi_set_error_string(ctx,
+ "Could not set global parameter: %s",
+ sbcErrorString(err));
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
done:
smbconf_shutdown(conf_ctx);
diff --git a/source3/lib/netapi/share.c b/source3/lib/netapi/share.c
index c4ed1549ce7..d12fa1cf0c0 100644
--- a/source3/lib/netapi/share.c
+++ b/source3/lib/netapi/share.c
@@ -141,7 +141,7 @@ static NTSTATUS map_SHARE_INFO_buffer_to_srvsvc_share_info(TALLOC_CTX *mem_ctx,
case 2:
i2 = (struct SHARE_INFO_2 *)buffer;
- s2 = TALLOC_P(mem_ctx, struct srvsvc_NetShareInfo2);
+ s2 = talloc(mem_ctx, struct srvsvc_NetShareInfo2);
NT_STATUS_HAVE_NO_MEMORY(s2);
s2->name = i2->shi2_netname;
@@ -159,7 +159,7 @@ static NTSTATUS map_SHARE_INFO_buffer_to_srvsvc_share_info(TALLOC_CTX *mem_ctx,
case 1004:
i1004 = (struct SHARE_INFO_1004 *)buffer;
- s1004 = TALLOC_P(mem_ctx, struct srvsvc_NetShareInfo1004);
+ s1004 = talloc(mem_ctx, struct srvsvc_NetShareInfo1004);
NT_STATUS_HAVE_NO_MEMORY(s1004);
s1004->comment = i1004->shi1004_remark;
diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c
index 63be7ac7512..3003a393971 100644
--- a/source3/lib/netapi/user.c
+++ b/source3/lib/netapi/user.c
@@ -322,7 +322,7 @@ static NTSTATUS set_user_info_USER_INFO_X(TALLOC_CTX *ctx,
25,
&user_info,
&result);
- if (NT_STATUS_EQUAL(status, NT_STATUS(DCERPC_FAULT_INVALID_TAG))) {
+ if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) {
user_info.info23.info = info21;
@@ -575,7 +575,7 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
status = dcerpc_samr_OpenDomain(b, talloc_tos(),
&connect_handle,
SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- CONST_DISCARD(struct dom_sid *, &global_sid_Builtin),
+ discard_const_p(struct dom_sid, &global_sid_Builtin),
&builtin_handle,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -1436,7 +1436,7 @@ static WERROR convert_samr_dispinfo_to_NET_DISPLAY_USER(TALLOC_CTX *mem_ctx,
struct NET_DISPLAY_USER *user = NULL;
int i;
- user = TALLOC_ZERO_ARRAY(mem_ctx,
+ user = talloc_zero_array(mem_ctx,
struct NET_DISPLAY_USER,
info->count);
W_ERROR_HAVE_NO_MEMORY(user);
@@ -1480,7 +1480,7 @@ static WERROR convert_samr_dispinfo_to_NET_DISPLAY_MACHINE(TALLOC_CTX *mem_ctx,
struct NET_DISPLAY_MACHINE *machine = NULL;
int i;
- machine = TALLOC_ZERO_ARRAY(mem_ctx,
+ machine = talloc_zero_array(mem_ctx,
struct NET_DISPLAY_MACHINE,
info->count);
W_ERROR_HAVE_NO_MEMORY(machine);
@@ -1522,7 +1522,7 @@ static WERROR convert_samr_dispinfo_to_NET_DISPLAY_GROUP(TALLOC_CTX *mem_ctx,
struct NET_DISPLAY_GROUP *group = NULL;
int i;
- group = TALLOC_ZERO_ARRAY(mem_ctx,
+ group = talloc_zero_array(mem_ctx,
struct NET_DISPLAY_GROUP,
info->count);
W_ERROR_HAVE_NO_MEMORY(group);
@@ -3137,7 +3137,6 @@ WERROR NetUserSetGroups_r(struct libnetapi_ctx *ctx,
size_t num_del_rids = 0;
uint32_t *member_rids = NULL;
- size_t num_member_rids = 0;
struct GROUP_USERS_INFO_0 *i0 = NULL;
struct GROUP_USERS_INFO_1 *i1 = NULL;
@@ -3263,7 +3262,6 @@ WERROR NetUserSetGroups_r(struct libnetapi_ctx *ctx,
}
member_rids = group_rids.ids;
- num_member_rids = group_rids.count;
status = dcerpc_samr_GetGroupsForUser(b, talloc_tos(),
&user_handle,
@@ -3574,7 +3572,7 @@ WERROR NetUserGetLocalGroups_r(struct libnetapi_ctx *ctx,
}
sid_array.num_sids = rid_array->count + 1;
- sid_array.sids = TALLOC_ARRAY(ctx, struct lsa_SidPtr, sid_array.num_sids);
+ sid_array.sids = talloc_array(ctx, struct lsa_SidPtr, sid_array.num_sids);
if (!sid_array.sids) {
werr = WERR_NOMEM;
goto done;
diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index 128b9c18706..0c8f691c255 100644
--- a/source3/lib/popt_common.c
+++ b/source3/lib/popt_common.c
@@ -129,7 +129,7 @@ static void popt_common_callback(poptContext con,
case 'n':
if (arg) {
- set_global_myname(arg);
+ lp_set_cmdline("netbios name", arg);
}
break;
@@ -143,13 +143,13 @@ static void popt_common_callback(poptContext con,
case 'i':
if (arg) {
- set_global_scope(arg);
+ lp_set_cmdline("netbios scope", arg);
}
break;
case 'W':
if (arg) {
- set_global_myworkgroup(arg);
+ lp_set_cmdline("workgroup", arg);
}
break;
}
@@ -473,7 +473,7 @@ static void get_credentials_file(struct user_auth_info *auth_info,
} else if (strwicmp("username", param) == 0) {
set_cmdline_auth_info_username(auth_info, val);
} else if (strwicmp("domain", param) == 0) {
- set_global_myworkgroup(val);
+ set_cmdline_auth_info_domain(auth_info, val);
}
memset(buf, 0, sizeof(buf));
}
diff --git a/source3/lib/privileges.h b/source3/lib/privileges.h
index 13bc3eb0830..ca2a7c98331 100644
--- a/source3/lib/privileges.h
+++ b/source3/lib/privileges.h
@@ -1,3 +1,28 @@
+/*
+ Unix SMB/CIFS implementation.
+ Privileges handling functions
+ Copyright (C) Jean François Micouleau 1998-2001
+ Copyright (C) Simo Sorce 2002-2003
+ Copyright (C) Gerald (Jerry) Carter 2005
+ 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/>.
+*/
+
+#ifndef _LIB_PRIVILEGES_H_
+#define _LIB_PRIVILEGES_H_
+
#include "../libcli/security/privileges.h"
/* The following definitions come from lib/privileges.c */
@@ -16,3 +41,5 @@ NTSTATUS privilege_create_account(const struct dom_sid *sid );
NTSTATUS privilege_delete_account(const struct dom_sid *sid);
bool is_privileged_sid( const struct dom_sid *sid );
bool grant_all_privileges( const struct dom_sid *sid );
+
+#endif /* _LIB_PRIVILEGES_H_ */
diff --git a/source3/lib/pthreadpool/Makefile b/source3/lib/pthreadpool/Makefile
new file mode 100644
index 00000000000..48626bd2c0a
--- /dev/null
+++ b/source3/lib/pthreadpool/Makefile
@@ -0,0 +1,9 @@
+all: tests
+
+CFLAGS=-O3 -g -Wall
+
+pthreadpool.o: pthreadpool.c pthreadpool.h
+ gcc -c -O3 -o pthreadpool.o pthreadpool.c -I../../..
+
+tests: tests.o pthreadpool.o
+ gcc -o tests tests.o pthreadpool.o -lpthread \ No newline at end of file
diff --git a/source3/lib/pthreadpool.c b/source3/lib/pthreadpool/pthreadpool.c
index b62bab0a2ee..9981ed25ae6 100644
--- a/source3/lib/pthreadpool.c
+++ b/source3/lib/pthreadpool/pthreadpool.c
@@ -26,8 +26,10 @@
#include <signal.h>
#include <assert.h>
#include <fcntl.h>
+#include <sys/time.h>
#include "pthreadpool.h"
+#include "lib/util/dlinklist.h"
struct pthreadpool_job {
struct pthreadpool_job *next;
@@ -38,6 +40,11 @@ struct pthreadpool_job {
struct pthreadpool {
/*
+ * List pthreadpools for fork safety
+ */
+ struct pthreadpool *prev, *next;
+
+ /*
* Control access to this struct
*/
pthread_mutex_t mutex;
@@ -78,13 +85,18 @@ struct pthreadpool {
int num_idle;
/*
- * An array of threads that require joining, the array has
- * "max_threads" elements. It contains "num_exited" ids.
+ * An array of threads that require joining.
*/
int num_exited;
- pthread_t exited[1]; /* We alloc more */
+ pthread_t *exited; /* We alloc more */
};
+static pthread_mutex_t pthreadpools_mutex = PTHREAD_MUTEX_INITIALIZER;
+static struct pthreadpool *pthreadpools = NULL;
+static pthread_once_t pthreadpool_atfork_initialized = PTHREAD_ONCE_INIT;
+
+static void pthreadpool_prep_atfork(void);
+
/*
* Initialize a thread pool
*/
@@ -92,18 +104,24 @@ struct pthreadpool {
int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult)
{
struct pthreadpool *pool;
- size_t size;
int ret;
- size = sizeof(struct pthreadpool) + max_threads * sizeof(pthread_t);
-
- pool = (struct pthreadpool *)malloc(size);
+ pool = (struct pthreadpool *)malloc(sizeof(struct pthreadpool));
if (pool == NULL) {
return ENOMEM;
}
+ ret = pipe(pool->sig_pipe);
+ if (ret == -1) {
+ int err = errno;
+ free(pool);
+ return err;
+ }
+
ret = pthread_mutex_init(&pool->mutex, NULL);
if (ret != 0) {
+ close(pool->sig_pipe[0]);
+ close(pool->sig_pipe[1]);
free(pool);
return ret;
}
@@ -111,6 +129,8 @@ int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult)
ret = pthread_cond_init(&pool->condvar, NULL);
if (ret != 0) {
pthread_mutex_destroy(&pool->mutex);
+ close(pool->sig_pipe[0]);
+ close(pool->sig_pipe[1]);
free(pool);
return ret;
}
@@ -119,46 +139,126 @@ int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult)
pool->jobs = pool->last_job = NULL;
pool->num_threads = 0;
pool->num_exited = 0;
+ pool->exited = NULL;
pool->max_threads = max_threads;
pool->num_idle = 0;
- pool->sig_pipe[0] = -1;
- pool->sig_pipe[1] = -1;
+
+ ret = pthread_mutex_lock(&pthreadpools_mutex);
+ if (ret != 0) {
+ pthread_cond_destroy(&pool->condvar);
+ pthread_mutex_destroy(&pool->mutex);
+ close(pool->sig_pipe[0]);
+ close(pool->sig_pipe[1]);
+ free(pool);
+ return ret;
+ }
+ DLIST_ADD(pthreadpools, pool);
+
+ ret = pthread_mutex_unlock(&pthreadpools_mutex);
+ assert(ret == 0);
+
+ pthread_once(&pthreadpool_atfork_initialized, pthreadpool_prep_atfork);
*presult = pool;
+
return 0;
}
-/*
- * Create and return a file descriptor which becomes readable when a job has
- * finished
- */
-
-int pthreadpool_sig_fd(struct pthreadpool *pool)
+static void pthreadpool_prepare(void)
{
- int result, ret;
+ int ret;
+ struct pthreadpool *pool;
- ret = pthread_mutex_lock(&pool->mutex);
- if (ret != 0) {
- errno = ret;
- return -1;
+ ret = pthread_mutex_lock(&pthreadpools_mutex);
+ assert(ret == 0);
+
+ pool = pthreadpools;
+
+ while (pool != NULL) {
+ ret = pthread_mutex_lock(&pool->mutex);
+ assert(ret == 0);
+ pool = pool->next;
}
+}
- if (pool->sig_pipe[0] != -1) {
- result = pool->sig_pipe[0];
- goto done;
+static void pthreadpool_parent(void)
+{
+ int ret;
+ struct pthreadpool *pool;
+
+ pool = DLIST_TAIL(pthreadpools);
+
+ while (1) {
+ ret = pthread_mutex_unlock(&pool->mutex);
+ assert(ret == 0);
+
+ if (pool == pthreadpools) {
+ break;
+ }
+ pool = pool->prev;
}
- ret = pipe(pool->sig_pipe);
- if (ret == -1) {
- result = -1;
- goto done;
+ ret = pthread_mutex_unlock(&pthreadpools_mutex);
+ assert(ret == 0);
+}
+
+static void pthreadpool_child(void)
+{
+ int ret;
+ struct pthreadpool *pool;
+
+ pool = DLIST_TAIL(pthreadpools);
+
+ while (1) {
+ close(pool->sig_pipe[0]);
+ close(pool->sig_pipe[1]);
+
+ ret = pipe(pool->sig_pipe);
+ assert(ret == 0);
+
+ pool->num_threads = 0;
+
+ pool->num_exited = 0;
+ free(pool->exited);
+ pool->exited = NULL;
+
+ pool->num_idle = 0;
+
+ while (pool->jobs != NULL) {
+ struct pthreadpool_job *job;
+ job = pool->jobs;
+ pool->jobs = job->next;
+ free(job);
+ }
+ pool->last_job = NULL;
+
+ ret = pthread_mutex_unlock(&pool->mutex);
+ assert(ret == 0);
+
+ if (pool == pthreadpools) {
+ break;
+ }
+ pool = pool->prev;
}
- result = pool->sig_pipe[0];
-done:
- ret = pthread_mutex_unlock(&pool->mutex);
+ ret = pthread_mutex_unlock(&pthreadpools_mutex);
assert(ret == 0);
- return result;
+}
+
+static void pthreadpool_prep_atfork(void)
+{
+ pthread_atfork(pthreadpool_prepare, pthreadpool_parent,
+ pthreadpool_child);
+}
+
+/*
+ * Return the file descriptor which becomes readable when a job has
+ * finished
+ */
+
+int pthreadpool_signal_fd(struct pthreadpool *pool)
+{
+ return pool->sig_pipe[0];
}
/*
@@ -173,6 +273,11 @@ static void pthreadpool_join_children(struct pthreadpool *pool)
pthread_join(pool->exited[i], NULL);
}
pool->num_exited = 0;
+
+ /*
+ * Deliberately not free and NULL pool->exited. That will be
+ * re-used by realloc later.
+ */
}
/*
@@ -181,59 +286,21 @@ static void pthreadpool_join_children(struct pthreadpool *pool)
int pthreadpool_finished_job(struct pthreadpool *pool)
{
- int result, ret, fd;
+ int result;
ssize_t nread;
- ret = pthread_mutex_lock(&pool->mutex);
- if (ret != 0) {
- errno = ret;
- return -1;
- }
-
- /*
- * Just some cleanup under the mutex
- */
- pthreadpool_join_children(pool);
-
- fd = pool->sig_pipe[0];
-
- ret = pthread_mutex_unlock(&pool->mutex);
- assert(ret == 0);
-
- if (fd == -1) {
- errno = EINVAL;
- return -1;
- }
-
nread = -1;
errno = EINTR;
while ((nread == -1) && (errno == EINTR)) {
- nread = read(fd, &result, sizeof(int));
+ nread = read(pool->sig_pipe[0], &result, sizeof(int));
}
-
- /*
- * TODO: handle nread > 0 && nread < sizeof(int)
- */
-
- /*
- * Lock the mutex to provide a memory barrier for data from the worker
- * thread to the main thread. The pipe access itself does not have to
- * be locked, for sizeof(int) the write to a pipe is atomic, and only
- * one thread reads from it. But we need to lock the mutex briefly
- * even if we don't do anything under the lock, to make sure we can
- * see all memory the helper thread has written.
- */
-
- ret = pthread_mutex_lock(&pool->mutex);
- if (ret == -1) {
- errno = ret;
- return -1;
+ if (nread == -1) {
+ return errno;
+ }
+ if (nread != sizeof(int)) {
+ return EINVAL;
}
-
- ret = pthread_mutex_unlock(&pool->mutex);
- assert(ret == 0);
-
return result;
}
@@ -250,6 +317,12 @@ int pthreadpool_destroy(struct pthreadpool *pool)
return ret;
}
+ if ((pool->jobs != NULL) || pool->shutdown) {
+ ret = pthread_mutex_unlock(&pool->mutex);
+ assert(ret == 0);
+ return EBUSY;
+ }
+
if (pool->num_threads > 0) {
/*
* We have active threads, tell them to finish, wait for that.
@@ -294,14 +367,31 @@ int pthreadpool_destroy(struct pthreadpool *pool)
ret = pthread_mutex_destroy(&pool->mutex);
ret1 = pthread_cond_destroy(&pool->condvar);
- if ((ret == 0) && (ret1 == 0)) {
- free(pool);
+ if (ret != 0) {
+ return ret;
+ }
+ if (ret1 != 0) {
+ return ret1;
}
+ ret = pthread_mutex_lock(&pthreadpools_mutex);
if (ret != 0) {
return ret;
}
- return ret1;
+ DLIST_REMOVE(pthreadpools, pool);
+ ret = pthread_mutex_unlock(&pthreadpools_mutex);
+ assert(ret == 0);
+
+ close(pool->sig_pipe[0]);
+ pool->sig_pipe[0] = -1;
+
+ close(pool->sig_pipe[1]);
+ pool->sig_pipe[1] = -1;
+
+ free(pool->exited);
+ free(pool);
+
+ return 0;
}
/*
@@ -309,7 +399,19 @@ int pthreadpool_destroy(struct pthreadpool *pool)
*/
static void pthreadpool_server_exit(struct pthreadpool *pool)
{
+ pthread_t *exited;
+
pool->num_threads -= 1;
+
+ exited = (pthread_t *)realloc(
+ pool->exited, sizeof(pthread_t *) * (pool->num_exited + 1));
+
+ if (exited == NULL) {
+ /* lost a thread status */
+ return;
+ }
+ pool->exited = exited;
+
pool->exited[pool->num_exited] = pthread_self();
pool->num_exited += 1;
}
@@ -325,7 +427,7 @@ static void *pthreadpool_server(void *arg)
}
while (1) {
- struct timespec timeout;
+ struct timespec ts;
struct pthreadpool_job *job;
/*
@@ -333,14 +435,14 @@ static void *pthreadpool_server(void *arg)
* time, exit this thread.
*/
- timeout.tv_sec = time(NULL) + 1;
- timeout.tv_nsec = 0;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ ts.tv_sec += 1;
while ((pool->jobs == NULL) && (pool->shutdown == 0)) {
pool->num_idle += 1;
res = pthread_cond_timedwait(
- &pool->condvar, &pool->mutex, &timeout);
+ &pool->condvar, &pool->mutex, &ts);
pool->num_idle -= 1;
if (res == ETIMEDOUT) {
@@ -363,7 +465,6 @@ static void *pthreadpool_server(void *arg)
job = pool->jobs;
if (job != NULL) {
- int fd = pool->sig_pipe[1];
ssize_t written;
/*
@@ -376,7 +477,7 @@ static void *pthreadpool_server(void *arg)
}
/*
- * Do the work with the mutex unlocked :-)
+ * Do the work with the mutex unlocked
*/
res = pthread_mutex_unlock(&pool->mutex);
@@ -384,17 +485,14 @@ static void *pthreadpool_server(void *arg)
job->fn(job->private_data);
- written = sizeof(int);
+ written = write(pool->sig_pipe[1], &job->id,
+ sizeof(int));
+
+ free(job);
res = pthread_mutex_lock(&pool->mutex);
assert(res == 0);
- if (fd != -1) {
- written = write(fd, &job->id, sizeof(int));
- }
-
- free(job);
-
if (written != sizeof(int)) {
pthreadpool_server_exit(pool);
pthread_mutex_unlock(&pool->mutex);
@@ -447,6 +545,17 @@ int pthreadpool_add_job(struct pthreadpool *pool, int job_id,
return res;
}
+ if (pool->shutdown) {
+ /*
+ * Protect against the pool being shut down while
+ * trying to add a job
+ */
+ res = pthread_mutex_unlock(&pool->mutex);
+ assert(res == 0);
+ free(job);
+ return EINVAL;
+ }
+
/*
* Just some cleanup under the mutex
*/
@@ -472,7 +581,8 @@ int pthreadpool_add_job(struct pthreadpool *pool, int job_id,
return res;
}
- if (pool->num_threads >= pool->max_threads) {
+ if ((pool->max_threads != 0) &&
+ (pool->num_threads >= pool->max_threads)) {
/*
* No more new threads, we just queue the request
*/
diff --git a/source3/lib/pthreadpool/pthreadpool.h b/source3/lib/pthreadpool/pthreadpool.h
new file mode 100644
index 00000000000..79704ea3853
--- /dev/null
+++ b/source3/lib/pthreadpool/pthreadpool.h
@@ -0,0 +1,97 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * threadpool implementation based on pthreads
+ * Copyright (C) Volker Lendecke 2009,2011
+ *
+ * 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 __PTHREADPOOL_H__
+#define __PTHREADPOOL_H__
+
+struct pthreadpool;
+
+/**
+ * @defgroup pthreadpool The pthreadpool API
+ *
+ * This API provides a way to run threadsafe functions in a helper
+ * thread. It is initially intended to run getaddrinfo asynchronously.
+ */
+
+
+/**
+ * @brief Create a pthreadpool
+ *
+ * A struct pthreadpool is the basis for for running threads in the
+ * background.
+ *
+ * @param[in] max_threads Maximum parallelism in this pool
+ * @param[out] presult Pointer to the threadpool returned
+ * @return success: 0, failure: errno
+ *
+ * max_threads=0 means unlimited parallelism. The caller has to take
+ * care to not overload the system.
+ */
+int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult);
+
+/**
+ * @brief Destroy a pthreadpool
+ *
+ * Destroy a pthreadpool. If jobs are still active, this returns
+ * EBUSY.
+ *
+ * @param[in] pool The pool to destroy
+ * @return success: 0, failure: errno
+ */
+int pthreadpool_destroy(struct pthreadpool *pool);
+
+/**
+ * @brief Add a job to a pthreadpool
+ *
+ * This adds a job to a pthreadpool. The job can be identified by
+ * job_id. This integer will be returned from
+ * pthreadpool_finished_job() then the job is completed.
+ *
+ * @param[in] pool The pool to run the job on
+ * @param[in] job_id A custom identifier
+ * @param[in] fn The function to run asynchronously
+ * @param[in] private_data Pointer passed to fn
+ * @return success: 0, failure: errno
+ */
+int pthreadpool_add_job(struct pthreadpool *pool, int job_id,
+ void (*fn)(void *private_data), void *private_data);
+
+/**
+ * @brief Get the signalling fd from a pthreadpool
+ *
+ * Completion of a job is indicated by readability of the fd retuned
+ * by pthreadpool_signal_fd().
+ *
+ * @param[in] pool The pool in question
+ * @return The fd to listen on for readability
+ */
+int pthreadpool_signal_fd(struct pthreadpool *pool);
+
+/**
+ * @brief Get the job_id of a finished job
+ *
+ * This blocks until a job has finished unless the fd returned by
+ * pthreadpool_signal_fd() is readable.
+ *
+ * @param[in] pool The pool to query for finished jobs
+ * @return The job_id of the finished job
+ */
+int pthreadpool_finished_job(struct pthreadpool *pool);
+
+#endif
diff --git a/source3/lib/pthreadpool/tests.c b/source3/lib/pthreadpool/tests.c
new file mode 100644
index 00000000000..667ee01784e
--- /dev/null
+++ b/source3/lib/pthreadpool/tests.c
@@ -0,0 +1,362 @@
+#include <stdio.h>
+#include <string.h>
+#include <poll.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <unistd.h>
+#include "pthreadpool.h"
+
+static int test_init(void)
+{
+ struct pthreadpool *p;
+ int ret;
+
+ ret = pthreadpool_init(1, &p);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_init failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+ ret = pthreadpool_destroy(p);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_init failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+ return 0;
+}
+
+static void test_sleep(void *ptr)
+{
+ int *ptimeout = (int *)ptr;
+ int ret;
+ ret = poll(NULL, 0, *ptimeout);
+ if (ret != 0) {
+ fprintf(stderr, "poll returned %d (%s)\n",
+ ret, strerror(errno));
+ }
+}
+
+static int test_jobs(int num_threads, int num_jobs)
+{
+ char *finished;
+ struct pthreadpool *p;
+ int timeout = 1;
+ int i, ret;
+
+ finished = (char *)calloc(1, num_jobs);
+ if (finished == NULL) {
+ fprintf(stderr, "calloc failed\n");
+ return -1;
+ }
+
+ ret = pthreadpool_init(num_threads, &p);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_init failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+
+ for (i=0; i<num_jobs; i++) {
+ ret = pthreadpool_add_job(p, i, test_sleep, &timeout);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_add_job failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+ }
+
+ for (i=0; i<num_jobs; i++) {
+ ret = pthreadpool_finished_job(p);
+ if ((ret < 0) || (ret >= num_jobs)) {
+ fprintf(stderr, "invalid job number %d\n", ret);
+ return -1;
+ }
+ finished[ret] += 1;
+ }
+
+ for (i=0; i<num_jobs; i++) {
+ if (finished[i] != 1) {
+ fprintf(stderr, "finished[%d] = %d\n",
+ i, finished[i]);
+ return -1;
+ }
+ }
+
+ ret = pthreadpool_destroy(p);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_destroy failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+
+ free(finished);
+ return 0;
+}
+
+static int test_busydestroy(void)
+{
+ struct pthreadpool *p;
+ int timeout = 50;
+ struct pollfd pfd;
+ int ret;
+
+ ret = pthreadpool_init(1, &p);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_init failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+ ret = pthreadpool_add_job(p, 1, test_sleep, &timeout);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_add_job failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+ ret = pthreadpool_destroy(p);
+ if (ret != EBUSY) {
+ fprintf(stderr, "Could destroy a busy pool\n");
+ return -1;
+ }
+
+ pfd.fd = pthreadpool_signal_fd(p);
+ pfd.events = POLLIN|POLLERR;
+
+ poll(&pfd, 1, -1);
+
+ ret = pthreadpool_destroy(p);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_destroy failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+ return 0;
+}
+
+struct threaded_state {
+ pthread_t tid;
+ struct pthreadpool *p;
+ int start_job;
+ int num_jobs;
+ int timeout;
+};
+
+static void *test_threaded_worker(void *p)
+{
+ struct threaded_state *state = (struct threaded_state *)p;
+ int i;
+
+ for (i=0; i<state->num_jobs; i++) {
+ int ret = pthreadpool_add_job(state->p, state->start_job + i,
+ test_sleep, &state->timeout);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_add_job failed: %s\n",
+ strerror(ret));
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+static int test_threaded_addjob(int num_pools, int num_threads, int poolsize,
+ int num_jobs)
+{
+ struct pthreadpool **pools;
+ struct threaded_state *states;
+ struct threaded_state *state;
+ struct pollfd *pfds;
+ char *finished;
+ pid_t child;
+ int i, ret, poolnum;
+ int received;
+
+ states = calloc(num_threads, sizeof(struct threaded_state));
+ if (states == NULL) {
+ fprintf(stderr, "calloc failed\n");
+ return -1;
+ }
+
+ finished = calloc(num_threads * num_jobs, 1);
+ if (finished == NULL) {
+ fprintf(stderr, "calloc failed\n");
+ return -1;
+ }
+
+ pools = calloc(num_pools, sizeof(struct pthreadpool *));
+ if (pools == NULL) {
+ fprintf(stderr, "calloc failed\n");
+ return -1;
+ }
+
+ pfds = calloc(num_pools, sizeof(struct pollfd));
+ if (pfds == NULL) {
+ fprintf(stderr, "calloc failed\n");
+ return -1;
+ }
+
+ for (i=0; i<num_pools; i++) {
+ ret = pthreadpool_init(poolsize, &pools[i]);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_init failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+ pfds[i].fd = pthreadpool_signal_fd(pools[i]);
+ pfds[i].events = POLLIN|POLLHUP;
+ }
+
+ poolnum = 0;
+
+ for (i=0; i<num_threads; i++) {
+ state = &states[i];
+
+ state->p = pools[poolnum];
+ poolnum = (poolnum + 1) % num_pools;
+
+ state->num_jobs = num_jobs;
+ state->timeout = 1;
+ state->start_job = i * num_jobs;
+
+ ret = pthread_create(&state->tid, NULL, test_threaded_worker,
+ state);
+ if (ret != 0) {
+ fprintf(stderr, "pthread_create failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+ }
+
+ if (random() % 1) {
+ poll(NULL, 0, 1);
+ }
+
+ child = fork();
+ if (child < 0) {
+ fprintf(stderr, "fork failed: %s\n", strerror(errno));
+ return -1;
+ }
+ if (child == 0) {
+ for (i=0; i<num_pools; i++) {
+ ret = pthreadpool_destroy(pools[i]);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_destroy failed: "
+ "%s\n", strerror(ret));
+ exit(1);
+ }
+ }
+ /* child */
+ exit(0);
+ }
+
+ for (i=0; i<num_threads; i++) {
+ ret = pthread_join(states[i].tid, NULL);
+ if (ret != 0) {
+ fprintf(stderr, "pthread_join(%d) failed: %s\n",
+ i, strerror(ret));
+ return -1;
+ }
+ }
+
+ received = 0;
+
+ while (received < num_threads*num_jobs) {
+ int j;
+
+ ret = poll(pfds, num_pools, 1000);
+ if (ret == -1) {
+ fprintf(stderr, "poll failed: %s\n",
+ strerror(errno));
+ return -1;
+ }
+ if (ret == 0) {
+ fprintf(stderr, "\npoll timed out\n");
+ break;
+ }
+
+ for (j=0; j<num_pools; j++) {
+
+ if ((pfds[j].revents & (POLLIN|POLLHUP)) == 0) {
+ continue;
+ }
+
+ ret = pthreadpool_finished_job(pools[j]);
+ if ((ret < 0) || (ret >= num_jobs * num_threads)) {
+ fprintf(stderr, "invalid job number %d\n",
+ ret);
+ return -1;
+ }
+ finished[ret] += 1;
+ received += 1;
+ }
+ }
+
+ for (i=0; i<num_threads*num_jobs; i++) {
+ if (finished[i] != 1) {
+ fprintf(stderr, "finished[%d] = %d\n",
+ i, finished[i]);
+ return -1;
+ }
+ }
+
+ for (i=0; i<num_pools; i++) {
+ ret = pthreadpool_destroy(pools[i]);
+ if (ret != 0) {
+ fprintf(stderr, "pthreadpool_destroy failed: %s\n",
+ strerror(ret));
+ return -1;
+ }
+ }
+
+ free(pfds);
+ free(pools);
+ free(states);
+ free(finished);
+
+ return 0;
+}
+
+int main(void)
+{
+ int ret;
+
+ ret = test_init();
+ if (ret != 0) {
+ fprintf(stderr, "test_init failed\n");
+ return 1;
+ }
+
+ ret = test_jobs(10, 10000);
+ if (ret != 0) {
+ fprintf(stderr, "test_jobs failed\n");
+ return 1;
+ }
+
+ ret = test_busydestroy();
+ if (ret != 0) {
+ fprintf(stderr, "test_busydestroy failed\n");
+ return 1;
+ }
+
+ /*
+ * Test 10 threads adding jobs on a single pool
+ */
+ ret = test_threaded_addjob(1, 10, 5, 5000);
+ if (ret != 0) {
+ fprintf(stderr, "test_jobs failed\n");
+ return 1;
+ }
+
+ /*
+ * Test 10 threads on 3 pools to verify our fork handling
+ * works right.
+ */
+ ret = test_threaded_addjob(3, 10, 5, 5000);
+ if (ret != 0) {
+ fprintf(stderr, "test_jobs failed\n");
+ return 1;
+ }
+
+ printf("success\n");
+ return 0;
+}
diff --git a/source3/lib/pthreadpool/wscript_build b/source3/lib/pthreadpool/wscript_build
new file mode 100644
index 00000000000..611ff5a4331
--- /dev/null
+++ b/source3/lib/pthreadpool/wscript_build
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+bld.SAMBA3_SUBSYSTEM('PTHREADPOOL',
+ source='pthreadpool.c',
+ deps='pthread rt',
+ enabled=bld.env.WITH_PTHREADPOOL)
+
+bld.SAMBA3_BINARY('pthreadpooltest',
+ source='tests.c',
+ deps='PTHREADPOOL',
+ enabled=bld.env.WITH_PTHREADPOOL)
diff --git a/source3/lib/secdesc.c b/source3/lib/secdesc.c
deleted file mode 100644
index 001eccb5763..00000000000
--- a/source3/lib/secdesc.c
+++ /dev/null
@@ -1,712 +0,0 @@
-/*
- * Unix SMB/Netbios implementation.
- * SEC_DESC handling functions
- * Copyright (C) Andrew Tridgell 1992-1998,
- * Copyright (C) Jeremy R. Allison 1995-2003.
- * Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
- * Copyright (C) Paul Ashton 1997-1998.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "includes.h"
-#include "../librpc/gen_ndr/ndr_security.h"
-#include "../libcli/security/security.h"
-
-#define ALL_SECURITY_INFORMATION (SECINFO_OWNER|SECINFO_GROUP|\
- SECINFO_DACL|SECINFO_SACL|\
- SECINFO_UNPROTECTED_SACL|\
- SECINFO_UNPROTECTED_DACL|\
- SECINFO_PROTECTED_SACL|\
- SECINFO_PROTECTED_DACL)
-
-/* Map generic permissions to file object specific permissions */
-
-const struct generic_mapping file_generic_mapping = {
- FILE_GENERIC_READ,
- FILE_GENERIC_WRITE,
- FILE_GENERIC_EXECUTE,
- FILE_GENERIC_ALL
-};
-
-/*******************************************************************
- Given a security_descriptor return the sec_info.
-********************************************************************/
-
-uint32_t get_sec_info(const struct security_descriptor *sd)
-{
- uint32_t sec_info = ALL_SECURITY_INFORMATION;
-
- SMB_ASSERT(sd);
-
- if (sd->owner_sid == NULL) {
- sec_info &= ~SECINFO_OWNER;
- }
- if (sd->group_sid == NULL) {
- sec_info &= ~SECINFO_GROUP;
- }
- if (sd->sacl == NULL) {
- sec_info &= ~SECINFO_SACL;
- }
- if (sd->dacl == NULL) {
- sec_info &= ~SECINFO_DACL;
- }
-
- return sec_info;
-}
-
-
-/*******************************************************************
- Merge part of security descriptor old_sec in to the empty sections of
- security descriptor new_sec.
-********************************************************************/
-
-struct sec_desc_buf *sec_desc_merge_buf(TALLOC_CTX *ctx, struct sec_desc_buf *new_sdb, struct sec_desc_buf *old_sdb)
-{
- struct dom_sid *owner_sid, *group_sid;
- struct sec_desc_buf *return_sdb;
- struct security_acl *dacl, *sacl;
- struct security_descriptor *psd = NULL;
- uint16 secdesc_type;
- size_t secdesc_size;
-
- /* Copy over owner and group sids. There seems to be no flag for
- this so just check the pointer values. */
-
- owner_sid = new_sdb->sd->owner_sid ? new_sdb->sd->owner_sid :
- old_sdb->sd->owner_sid;
-
- group_sid = new_sdb->sd->group_sid ? new_sdb->sd->group_sid :
- old_sdb->sd->group_sid;
-
- secdesc_type = new_sdb->sd->type;
-
- /* Ignore changes to the system ACL. This has the effect of making
- changes through the security tab audit button not sticking.
- Perhaps in future Samba could implement these settings somehow. */
-
- sacl = NULL;
- secdesc_type &= ~SEC_DESC_SACL_PRESENT;
-
- /* Copy across discretionary ACL */
-
- if (secdesc_type & SEC_DESC_DACL_PRESENT) {
- dacl = new_sdb->sd->dacl;
- } else {
- dacl = old_sdb->sd->dacl;
- }
-
- /* Create new security descriptor from bits */
-
- psd = make_sec_desc(ctx, new_sdb->sd->revision, secdesc_type,
- owner_sid, group_sid, sacl, dacl, &secdesc_size);
-
- return_sdb = make_sec_desc_buf(ctx, secdesc_size, psd);
-
- return(return_sdb);
-}
-
-struct security_descriptor *sec_desc_merge(TALLOC_CTX *ctx, struct security_descriptor *new_sdb, struct security_descriptor *old_sdb)
-{
- struct dom_sid *owner_sid, *group_sid;
- struct security_acl *dacl, *sacl;
- struct security_descriptor *psd = NULL;
- uint16 secdesc_type;
- size_t secdesc_size;
-
- /* Copy over owner and group sids. There seems to be no flag for
- this so just check the pointer values. */
-
- owner_sid = new_sdb->owner_sid ? new_sdb->owner_sid :
- old_sdb->owner_sid;
-
- group_sid = new_sdb->group_sid ? new_sdb->group_sid :
- old_sdb->group_sid;
-
- secdesc_type = new_sdb->type;
-
- /* Ignore changes to the system ACL. This has the effect of making
- changes through the security tab audit button not sticking.
- Perhaps in future Samba could implement these settings somehow. */
-
- sacl = NULL;
- secdesc_type &= ~SEC_DESC_SACL_PRESENT;
-
- /* Copy across discretionary ACL */
-
- if (secdesc_type & SEC_DESC_DACL_PRESENT) {
- dacl = new_sdb->dacl;
- } else {
- dacl = old_sdb->dacl;
- }
-
- /* Create new security descriptor from bits */
- psd = make_sec_desc(ctx, new_sdb->revision, secdesc_type,
- owner_sid, group_sid, sacl, dacl, &secdesc_size);
-
- return psd;
-}
-
-/*******************************************************************
- Creates a struct security_descriptor structure
-********************************************************************/
-
-#define SEC_DESC_HEADER_SIZE (2 * sizeof(uint16) + 4 * sizeof(uint32))
-
-struct security_descriptor *make_sec_desc(TALLOC_CTX *ctx,
- enum security_descriptor_revision revision,
- uint16 type,
- const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
- struct security_acl *sacl, struct security_acl *dacl, size_t *sd_size)
-{
- struct security_descriptor *dst;
- uint32 offset = 0;
-
- *sd_size = 0;
-
- if(( dst = TALLOC_ZERO_P(ctx, struct security_descriptor)) == NULL)
- return NULL;
-
- dst->revision = revision;
- dst->type = type;
-
- if (sacl)
- dst->type |= SEC_DESC_SACL_PRESENT;
- if (dacl)
- dst->type |= SEC_DESC_DACL_PRESENT;
-
- dst->owner_sid = NULL;
- dst->group_sid = NULL;
- dst->sacl = NULL;
- dst->dacl = NULL;
-
- if(owner_sid && ((dst->owner_sid = dom_sid_dup(dst,owner_sid)) == NULL))
- goto error_exit;
-
- if(grp_sid && ((dst->group_sid = dom_sid_dup(dst,grp_sid)) == NULL))
- goto error_exit;
-
- if(sacl && ((dst->sacl = dup_sec_acl(dst, sacl)) == NULL))
- goto error_exit;
-
- if(dacl && ((dst->dacl = dup_sec_acl(dst, dacl)) == NULL))
- goto error_exit;
-
- offset = SEC_DESC_HEADER_SIZE;
-
- /*
- * Work out the linearization sizes.
- */
-
- if (dst->sacl != NULL) {
- offset += dst->sacl->size;
- }
- if (dst->dacl != NULL) {
- offset += dst->dacl->size;
- }
-
- if (dst->owner_sid != NULL) {
- offset += ndr_size_dom_sid(dst->owner_sid, 0);
- }
-
- if (dst->group_sid != NULL) {
- offset += ndr_size_dom_sid(dst->group_sid, 0);
- }
-
- *sd_size = (size_t)offset;
- return dst;
-
-error_exit:
-
- *sd_size = 0;
- return NULL;
-}
-
-/*******************************************************************
- Duplicate a struct security_descriptor structure.
-********************************************************************/
-
-struct security_descriptor *dup_sec_desc(TALLOC_CTX *ctx, const struct security_descriptor *src)
-{
- size_t dummy;
-
- if(src == NULL)
- return NULL;
-
- return make_sec_desc( ctx, src->revision, src->type,
- src->owner_sid, src->group_sid, src->sacl,
- src->dacl, &dummy);
-}
-
-/*******************************************************************
- Convert a secdesc into a byte stream
-********************************************************************/
-NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
- struct security_descriptor *secdesc,
- uint8 **data, size_t *len)
-{
- DATA_BLOB blob;
- enum ndr_err_code ndr_err;
-
- ndr_err = ndr_push_struct_blob(
- &blob, mem_ctx, secdesc,
- (ndr_push_flags_fn_t)ndr_push_security_descriptor);
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(0, ("ndr_push_security_descriptor failed: %s\n",
- ndr_errstr(ndr_err)));
- return ndr_map_error2ntstatus(ndr_err);
- }
-
- *data = blob.data;
- *len = blob.length;
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
- Convert a secdesc_buf into a byte stream
-********************************************************************/
-
-NTSTATUS marshall_sec_desc_buf(TALLOC_CTX *mem_ctx,
- struct sec_desc_buf *secdesc_buf,
- uint8_t **data, size_t *len)
-{
- DATA_BLOB blob;
- enum ndr_err_code ndr_err;
-
- ndr_err = ndr_push_struct_blob(
- &blob, mem_ctx, secdesc_buf,
- (ndr_push_flags_fn_t)ndr_push_sec_desc_buf);
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(0, ("ndr_push_sec_desc_buf failed: %s\n",
- ndr_errstr(ndr_err)));
- return ndr_map_error2ntstatus(ndr_err);
- }
-
- *data = blob.data;
- *len = blob.length;
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
- Parse a byte stream into a secdesc
-********************************************************************/
-NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
- struct security_descriptor **psecdesc)
-{
- DATA_BLOB blob;
- enum ndr_err_code ndr_err;
- struct security_descriptor *result;
-
- if ((data == NULL) || (len == 0)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- result = TALLOC_ZERO_P(mem_ctx, struct security_descriptor);
- if (result == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- blob = data_blob_const(data, len);
-
- ndr_err = ndr_pull_struct_blob(&blob, result, result,
- (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(0, ("ndr_pull_security_descriptor failed: %s\n",
- ndr_errstr(ndr_err)));
- TALLOC_FREE(result);
- return ndr_map_error2ntstatus(ndr_err);
- }
-
- *psecdesc = result;
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
- Parse a byte stream into a sec_desc_buf
-********************************************************************/
-
-NTSTATUS unmarshall_sec_desc_buf(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
- struct sec_desc_buf **psecdesc_buf)
-{
- DATA_BLOB blob;
- enum ndr_err_code ndr_err;
- struct sec_desc_buf *result;
-
- if ((data == NULL) || (len == 0)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- result = TALLOC_ZERO_P(mem_ctx, struct sec_desc_buf);
- if (result == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- blob = data_blob_const(data, len);
-
- ndr_err = ndr_pull_struct_blob(&blob, result, result,
- (ndr_pull_flags_fn_t)ndr_pull_sec_desc_buf);
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(0, ("ndr_pull_sec_desc_buf failed: %s\n",
- ndr_errstr(ndr_err)));
- TALLOC_FREE(result);
- return ndr_map_error2ntstatus(ndr_err);
- }
-
- *psecdesc_buf = result;
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
- Creates a struct security_descriptor structure with typical defaults.
-********************************************************************/
-
-struct security_descriptor *make_standard_sec_desc(TALLOC_CTX *ctx, const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
- struct security_acl *dacl, size_t *sd_size)
-{
- return make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1,
- SEC_DESC_SELF_RELATIVE, owner_sid, grp_sid, NULL,
- dacl, sd_size);
-}
-
-/*******************************************************************
- Creates a struct sec_desc_buf structure.
-********************************************************************/
-
-struct sec_desc_buf *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, struct security_descriptor *sec_desc)
-{
- struct sec_desc_buf *dst;
-
- if((dst = TALLOC_ZERO_P(ctx, struct sec_desc_buf)) == NULL)
- return NULL;
-
- /* max buffer size (allocated size) */
- dst->sd_size = (uint32)len;
-
- if(sec_desc && ((dst->sd = dup_sec_desc(ctx, sec_desc)) == NULL)) {
- return NULL;
- }
-
- return dst;
-}
-
-/*******************************************************************
- Duplicates a struct sec_desc_buf structure.
-********************************************************************/
-
-struct sec_desc_buf *dup_sec_desc_buf(TALLOC_CTX *ctx, struct sec_desc_buf *src)
-{
- if(src == NULL)
- return NULL;
-
- return make_sec_desc_buf( ctx, src->sd_size, src->sd);
-}
-
-/*******************************************************************
- Add a new SID with its permissions to struct security_descriptor.
-********************************************************************/
-
-NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, const struct dom_sid *sid, uint32 mask, size_t *sd_size)
-{
- struct security_descriptor *sd = 0;
- struct security_acl *dacl = 0;
- struct security_ace *ace = 0;
- NTSTATUS status;
-
- if (!ctx || !psd || !sid || !sd_size)
- return NT_STATUS_INVALID_PARAMETER;
-
- *sd_size = 0;
-
- status = sec_ace_add_sid(ctx, &ace, psd[0]->dacl->aces, &psd[0]->dacl->num_aces, sid, mask);
-
- if (!NT_STATUS_IS_OK(status))
- return status;
-
- if (!(dacl = make_sec_acl(ctx, psd[0]->dacl->revision, psd[0]->dacl->num_aces, ace)))
- return NT_STATUS_UNSUCCESSFUL;
-
- if (!(sd = make_sec_desc(ctx, psd[0]->revision, psd[0]->type, psd[0]->owner_sid,
- psd[0]->group_sid, psd[0]->sacl, dacl, sd_size)))
- return NT_STATUS_UNSUCCESSFUL;
-
- *psd = sd;
- sd = 0;
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
- Modify a SID's permissions in a struct security_descriptor.
-********************************************************************/
-
-NTSTATUS sec_desc_mod_sid(struct security_descriptor *sd, struct dom_sid *sid, uint32 mask)
-{
- NTSTATUS status;
-
- if (!sd || !sid)
- return NT_STATUS_INVALID_PARAMETER;
-
- status = sec_ace_mod_sid(sd->dacl->aces, sd->dacl->num_aces, sid, mask);
-
- if (!NT_STATUS_IS_OK(status))
- return status;
-
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
- Delete a SID from a struct security_descriptor.
-********************************************************************/
-
-NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, struct dom_sid *sid, size_t *sd_size)
-{
- struct security_descriptor *sd = 0;
- struct security_acl *dacl = 0;
- struct security_ace *ace = 0;
- NTSTATUS status;
-
- if (!ctx || !psd[0] || !sid || !sd_size)
- return NT_STATUS_INVALID_PARAMETER;
-
- *sd_size = 0;
-
- status = sec_ace_del_sid(ctx, &ace, psd[0]->dacl->aces, &psd[0]->dacl->num_aces, sid);
-
- if (!NT_STATUS_IS_OK(status))
- return status;
-
- if (!(dacl = make_sec_acl(ctx, psd[0]->dacl->revision, psd[0]->dacl->num_aces, ace)))
- return NT_STATUS_UNSUCCESSFUL;
-
- if (!(sd = make_sec_desc(ctx, psd[0]->revision, psd[0]->type, psd[0]->owner_sid,
- psd[0]->group_sid, psd[0]->sacl, dacl, sd_size)))
- return NT_STATUS_UNSUCCESSFUL;
-
- *psd = sd;
- sd = 0;
- return NT_STATUS_OK;
-}
-
-/*
- * Determine if an struct security_ace is inheritable
- */
-
-static bool is_inheritable_ace(const struct security_ace *ace,
- bool container)
-{
- if (!container) {
- return ((ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT) != 0);
- }
-
- if (ace->flags & SEC_ACE_FLAG_CONTAINER_INHERIT) {
- return true;
- }
-
- if ((ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT) &&
- !(ace->flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT)) {
- return true;
- }
-
- return false;
-}
-
-/*
- * Does a security descriptor have any inheritable components for
- * the newly created type ?
- */
-
-bool sd_has_inheritable_components(const struct security_descriptor *parent_ctr, bool container)
-{
- unsigned int i;
- const struct security_acl *the_acl = parent_ctr->dacl;
-
- for (i = 0; i < the_acl->num_aces; i++) {
- const struct security_ace *ace = &the_acl->aces[i];
-
- if (is_inheritable_ace(ace, container)) {
- return true;
- }
- }
- return false;
-}
-
-/* Create a child security descriptor using another security descriptor as
- the parent container. This child object can either be a container or
- non-container object. */
-
-NTSTATUS se_create_child_secdesc(TALLOC_CTX *ctx,
- struct security_descriptor **ppsd,
- size_t *psize,
- const struct security_descriptor *parent_ctr,
- const struct dom_sid *owner_sid,
- const struct dom_sid *group_sid,
- bool container)
-{
- struct security_acl *new_dacl = NULL, *the_acl = NULL;
- struct security_ace *new_ace_list = NULL;
- unsigned int new_ace_list_ndx = 0, i;
-
- *ppsd = NULL;
- *psize = 0;
-
- /* Currently we only process the dacl when creating the child. The
- sacl should also be processed but this is left out as sacls are
- not implemented in Samba at the moment.*/
-
- the_acl = parent_ctr->dacl;
-
- if (the_acl->num_aces) {
- if (2*the_acl->num_aces < the_acl->num_aces) {
- return NT_STATUS_NO_MEMORY;
- }
-
- if (!(new_ace_list = TALLOC_ARRAY(ctx, struct security_ace,
- 2*the_acl->num_aces))) {
- return NT_STATUS_NO_MEMORY;
- }
- } else {
- new_ace_list = NULL;
- }
-
- for (i = 0; i < the_acl->num_aces; i++) {
- const struct security_ace *ace = &the_acl->aces[i];
- struct security_ace *new_ace = &new_ace_list[new_ace_list_ndx];
- const struct dom_sid *ptrustee = &ace->trustee;
- const struct dom_sid *creator = NULL;
- uint8 new_flags = ace->flags;
-
- if (!is_inheritable_ace(ace, container)) {
- continue;
- }
-
- /* see the RAW-ACLS inheritance test for details on these rules */
- if (!container) {
- new_flags = 0;
- } else {
- new_flags &= ~SEC_ACE_FLAG_INHERIT_ONLY;
-
- if (!(new_flags & SEC_ACE_FLAG_CONTAINER_INHERIT)) {
- new_flags |= SEC_ACE_FLAG_INHERIT_ONLY;
- }
- if (new_flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT) {
- new_flags = 0;
- }
- }
-
- /* The CREATOR sids are special when inherited */
- if (dom_sid_equal(ptrustee, &global_sid_Creator_Owner)) {
- creator = &global_sid_Creator_Owner;
- ptrustee = owner_sid;
- } else if (dom_sid_equal(ptrustee, &global_sid_Creator_Group)) {
- creator = &global_sid_Creator_Group;
- ptrustee = group_sid;
- }
-
- if (creator && container &&
- (new_flags & SEC_ACE_FLAG_CONTAINER_INHERIT)) {
-
- /* First add the regular ACE entry. */
- init_sec_ace(new_ace, ptrustee, ace->type,
- ace->access_mask, 0);
-
- DEBUG(5,("se_create_child_secdesc(): %s:%d/0x%02x/0x%08x"
- " inherited as %s:%d/0x%02x/0x%08x\n",
- sid_string_dbg(&ace->trustee),
- ace->type, ace->flags, ace->access_mask,
- sid_string_dbg(&new_ace->trustee),
- new_ace->type, new_ace->flags,
- new_ace->access_mask));
-
- new_ace_list_ndx++;
-
- /* Now add the extra creator ACE. */
- new_ace = &new_ace_list[new_ace_list_ndx];
-
- ptrustee = creator;
- new_flags |= SEC_ACE_FLAG_INHERIT_ONLY;
- } else if (container &&
- !(ace->flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT)) {
- ptrustee = &ace->trustee;
- }
-
- init_sec_ace(new_ace, ptrustee, ace->type,
- ace->access_mask, new_flags);
-
- DEBUG(5, ("se_create_child_secdesc(): %s:%d/0x%02x/0x%08x "
- " inherited as %s:%d/0x%02x/0x%08x\n",
- sid_string_dbg(&ace->trustee),
- ace->type, ace->flags, ace->access_mask,
- sid_string_dbg(&ace->trustee),
- new_ace->type, new_ace->flags,
- new_ace->access_mask));
-
- new_ace_list_ndx++;
- }
-
- /* Create child security descriptor to return */
- if (new_ace_list_ndx) {
- new_dacl = make_sec_acl(ctx,
- NT4_ACL_REVISION,
- new_ace_list_ndx,
- new_ace_list);
-
- if (!new_dacl) {
- return NT_STATUS_NO_MEMORY;
- }
- }
-
- *ppsd = make_sec_desc(ctx,
- SECURITY_DESCRIPTOR_REVISION_1,
- SEC_DESC_SELF_RELATIVE|SEC_DESC_DACL_PRESENT,
- owner_sid,
- group_sid,
- NULL,
- new_dacl,
- psize);
- if (!*ppsd) {
- return NT_STATUS_NO_MEMORY;
- }
- return NT_STATUS_OK;
-}
-
-NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
- struct sec_desc_buf **ppsdb,
- const struct security_descriptor *parent_ctr,
- bool container)
-{
- NTSTATUS status;
- size_t size = 0;
- struct security_descriptor *sd = NULL;
-
- *ppsdb = NULL;
- status = se_create_child_secdesc(ctx,
- &sd,
- &size,
- parent_ctr,
- parent_ctr->owner_sid,
- parent_ctr->group_sid,
- container);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- *ppsdb = make_sec_desc_buf(ctx, size, sd);
- if (!*ppsdb) {
- return NT_STATUS_NO_MEMORY;
- }
- return NT_STATUS_OK;
-}
diff --git a/source3/lib/server_mutex.c b/source3/lib/server_mutex.c
index 1ba9d6a65be..dc658191970 100644
--- a/source3/lib/server_mutex.c
+++ b/source3/lib/server_mutex.c
@@ -20,6 +20,8 @@
#include "includes.h"
#include "system/filesys.h"
+#include "lib/util/tdb_wrap.h"
+#include "util_tdb.h"
/* For reasons known only to MS, many of their NT/Win2k versions
need serialised access only. Two connections at the same time
@@ -68,7 +70,7 @@ struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
}
if (tdb_lock_bystring_with_timeout(result->tdb->tdb, name,
- timeout) == -1) {
+ timeout) != 0) {
DEBUG(1, ("Could not get the lock for %s\n", name));
TALLOC_FREE(result);
return NULL;
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index f13c66e2c91..1a1141265a1 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -20,10 +20,13 @@
#include "includes.h"
#include "system/filesys.h"
#include "serverid.h"
+#include "util_tdb.h"
#include "dbwrap.h"
+#include "lib/util/tdb_wrap.h"
struct serverid_key {
pid_t pid;
+ uint32_t task_id;
uint32_t vnn;
};
@@ -70,6 +73,7 @@ static void serverid_fill_key(const struct server_id *id,
{
ZERO_STRUCTP(key);
key->pid = id->pid;
+ key->task_id = id->task_id;
key->vnn = id->vnn;
}
@@ -246,7 +250,7 @@ bool serverid_exists(const struct server_id *id)
state.id = id;
state.exists = false;
- if (db->parse_record(db, tdbkey, server_exists_parse, &state) == -1) {
+ if (db->parse_record(db, tdbkey, server_exists_parse, &state) != 0) {
return false;
}
return state.exists;
@@ -273,6 +277,7 @@ static bool serverid_rec_parse(const struct db_record *rec,
memcpy(&data, rec->value.dptr, sizeof(data));
id->pid = key.pid;
+ id->task_id = key.task_id;
id->vnn = key.vnn;
id->unique_id = data.unique_id;
*msg_flags = data.msg_flags;
diff --git a/source3/lib/sessionid_tdb.c b/source3/lib/sessionid_tdb.c
index ab54ec9ca5f..de3ccab26ae 100644
--- a/source3/lib/sessionid_tdb.c
+++ b/source3/lib/sessionid_tdb.c
@@ -21,6 +21,7 @@
#include "system/filesys.h"
#include "dbwrap.h"
#include "session.h"
+#include "util_tdb.h"
static struct db_context *session_db_ctx(void)
{
diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c
index c84e8fa00b2..ed971a97a6c 100644
--- a/source3/lib/sharesec.c
+++ b/source3/lib/sharesec.c
@@ -22,6 +22,7 @@
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_security.h"
#include "dbwrap.h"
+#include "util_tdb.h"
/*******************************************************************
Create the share security tdb.
@@ -462,7 +463,7 @@ bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, struct security_d
/* Add the number of ',' characters to get the number of aces. */
num_aces += count_chars(pacl,',');
- ace_list = TALLOC_ARRAY(ctx, struct security_ace, num_aces);
+ ace_list = talloc_array(ctx, struct security_ace, num_aces);
if (!ace_list) {
return False;
}
diff --git a/source3/lib/smbconf/smbconf_init.c b/source3/lib/smbconf/smbconf_init.c
index 36c51de5f03..2587a4fc53d 100644
--- a/source3/lib/smbconf/smbconf_init.c
+++ b/source3/lib/smbconf/smbconf_init.c
@@ -34,28 +34,28 @@
* - "registry" or "reg"
* - "txt" or "file"
*/
-WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *source)
{
- WERROR werr;
+ sbcErr err;
char *backend = NULL;
char *path = NULL;
char *sep;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
if (conf_ctx == NULL) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
if ((source == NULL) || (*source == '\0')) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
backend = talloc_strdup(tmp_ctx, source);
if (backend == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
@@ -69,16 +69,16 @@ WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
}
if (strequal(backend, "registry") || strequal(backend, "reg")) {
- werr = smbconf_init_reg(mem_ctx, conf_ctx, path);
+ err = smbconf_init_reg(mem_ctx, conf_ctx, path);
} else if (strequal(backend, "file") || strequal(backend, "txt")) {
- werr = smbconf_init_txt(mem_ctx, conf_ctx, path);
+ err = smbconf_init_txt(mem_ctx, conf_ctx, path);
} else if (sep == NULL) {
/*
* If no separator was given in the source, and the string is
* not a known backend, assume file backend and use the source
* string as a path argument.
*/
- werr = smbconf_init_txt(mem_ctx, conf_ctx, backend);
+ err = smbconf_init_txt(mem_ctx, conf_ctx, backend);
} else {
/*
* Separator was specified but this is not a known backend.
@@ -87,10 +87,10 @@ WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
* This may occur with an include directive like this:
* 'include = /path/to/file.%T'
*/
- werr = smbconf_init_txt(mem_ctx, conf_ctx, source);
+ err = smbconf_init_txt(mem_ctx, conf_ctx, source);
}
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
diff --git a/source3/lib/smbconf/smbconf_init.h b/source3/lib/smbconf/smbconf_init.h
index abd62df2045..45ea8096240 100644
--- a/source3/lib/smbconf/smbconf_init.h
+++ b/source3/lib/smbconf/smbconf_init.h
@@ -26,7 +26,7 @@ struct smbconf_ctx;
* intialization dispatcher function.
* takes source string in the form of "backend:path"
*/
-WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *source);
#endif /* _LIBSMBCONF_INIT_H_ */
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index 67df03cbd2d..92dbcbae1c1 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -83,7 +83,7 @@ static bool smbconf_reg_valname_valid(const char *valname)
/**
* Open a subkey of the base key (i.e a service)
*/
-static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
+static sbcErr smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
struct smbconf_ctx *ctx,
const char *servicename,
uint32 desired_access,
@@ -93,16 +93,18 @@ static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
if (servicename == NULL) {
*key = rpd(ctx)->base_key;
- return WERR_OK;
+ return SBC_ERR_OK;
}
werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
desired_access, key);
-
if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
- werr = WERR_NO_SUCH_SERVICE;
+ return SBC_ERR_NO_SUCH_SERVICE;
+ }
+ if (!W_ERROR_IS_OK(werr)) {
+ return SBC_ERR_NOMEM;
}
- return werr;
+ return SBC_ERR_OK;
}
/**
@@ -127,12 +129,13 @@ static bool smbconf_value_exists(struct registry_key *key, const char *param)
/**
* create a subkey of the base key (i.e. a service...)
*/
-static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
+static sbcErr smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
struct smbconf_ctx *ctx,
const char * subkeyname,
struct registry_key **newkey)
{
- WERROR werr = WERR_OK;
+ WERROR werr;
+ sbcErr err = SBC_ERR_OK;
TALLOC_CTX *create_ctx;
enum winreg_CreateAction action = REG_ACTION_NONE;
@@ -145,26 +148,28 @@ static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
REG_KEY_WRITE, newkey, &action);
if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
DEBUG(10, ("Key '%s' already exists.\n", subkeyname));
- werr = WERR_FILE_EXISTS;
+ err = SBC_ERR_FILE_EXISTS;
}
if (!W_ERROR_IS_OK(werr)) {
DEBUG(5, ("Error creating key %s: %s\n",
subkeyname, win_errstr(werr)));
+ err = SBC_ERR_UNKNOWN_FAILURE;
}
talloc_free(create_ctx);
- return werr;
+ return err;
}
/**
* add a value to a key.
*/
-static WERROR smbconf_reg_set_value(struct registry_key *key,
+static sbcErr smbconf_reg_set_value(struct registry_key *key,
const char *valname,
const char *valstr)
{
struct registry_value val;
WERROR werr = WERR_OK;
+ sbcErr err;
char *subkeyname;
const char *canon_valname;
const char *canon_valstr;
@@ -180,14 +185,14 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
DEBUG(5, ("invalid value '%s' given for "
"parameter '%s'\n", valstr, valname));
}
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
if (smbconf_reg_valname_forbidden(canon_valname)) {
DEBUG(5, ("Parameter '%s' not allowed in registry.\n",
canon_valname));
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
@@ -195,7 +200,7 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) {
DEBUG(5, ("Invalid registry key '%s' given as "
"smbconf section.\n", key->key->name));
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
subkeyname++;
@@ -205,7 +210,7 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
DEBUG(5, ("Global parameter '%s' not allowed in "
"service definition ('%s').\n", canon_valname,
subkeyname));
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
@@ -213,7 +218,7 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
val.type = REG_SZ;
if (!push_reg_sz(talloc_tos(), &val.data, canon_valstr)) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
@@ -222,37 +227,41 @@ static WERROR smbconf_reg_set_value(struct registry_key *key,
DEBUG(5, ("Error adding value '%s' to "
"key '%s': %s\n",
canon_valname, key->key->name, win_errstr(werr)));
+ err = SBC_ERR_NOMEM;
+ goto done;
}
+ err = SBC_ERR_OK;
done:
- return werr;
+ return err;
}
-static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
+static sbcErr smbconf_reg_set_multi_sz_value(struct registry_key *key,
const char *valname,
const uint32_t num_strings,
const char **strings)
{
WERROR werr;
+ sbcErr err = SBC_ERR_OK;
struct registry_value *value;
uint32_t count;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
const char **array;
if (strings == NULL) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
array = talloc_zero_array(tmp_ctx, const char *, num_strings + 1);
if (array == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
- value = TALLOC_ZERO_P(tmp_ctx, struct registry_value);
+ value = talloc_zero(tmp_ctx, struct registry_value);
if (value == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
@@ -261,13 +270,13 @@ static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
for (count = 0; count < num_strings; count++) {
array[count] = talloc_strdup(value, strings[count]);
if (array[count] == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
}
if (!push_reg_multi_sz(value, &value->data, array)) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
@@ -275,11 +284,12 @@ static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
if (!W_ERROR_IS_OK(werr)) {
DEBUG(5, ("Error adding value '%s' to key '%s': %s\n",
valname, key->key->name, win_errstr(werr)));
+ err = SBC_ERR_ACCESS_DENIED;
}
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
/**
@@ -342,12 +352,13 @@ static char *smbconf_format_registry_value(TALLOC_CTX *mem_ctx,
return result;
}
-static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
+static sbcErr smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
struct registry_key *key,
uint32_t *num_includes,
char ***includes)
{
WERROR werr;
+ sbcErr err;
uint32_t count;
struct registry_value *value = NULL;
char **tmp_includes = NULL;
@@ -358,31 +369,33 @@ static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
/* no includes */
*num_includes = 0;
*includes = NULL;
- werr = WERR_OK;
+ err = SBC_ERR_OK;
goto done;
}
werr = reg_queryvalue(tmp_ctx, key, INCLUDES_VALNAME, &value);
if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_ACCESS_DENIED;
goto done;
}
if (value->type != REG_MULTI_SZ) {
/* wrong type -- ignore */
+ err = SBC_ERR_OK;
goto done;
}
if (!pull_reg_multi_sz(tmp_ctx, &value->data, &array)) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
for (count = 0; array[count] != NULL; count++) {
- werr = smbconf_add_string_to_array(tmp_ctx,
+ err = smbconf_add_string_to_array(tmp_ctx,
&tmp_includes,
count,
array[count]);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
}
@@ -390,7 +403,7 @@ static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
if (count > 0) {
*includes = talloc_move(mem_ctx, &tmp_includes);
if (*includes == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
*num_includes = count;
@@ -399,16 +412,17 @@ static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
*includes = NULL;
}
+ err = SBC_ERR_OK;
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
/**
* Get the values of a key as a list of value names
* and a list of value strings (ordered)
*/
-static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
+static sbcErr smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
struct registry_key *key,
uint32_t *num_values,
char ***value_names,
@@ -416,6 +430,7 @@ static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
{
TALLOC_CTX *tmp_ctx = NULL;
WERROR werr = WERR_OK;
+ sbcErr err;
uint32_t count;
struct registry_value *valvalue = NULL;
char *valname = NULL;
@@ -428,7 +443,7 @@ static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
if ((num_values == NULL) || (value_names == NULL) ||
(value_strings == NULL))
{
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
@@ -445,42 +460,44 @@ static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
continue;
}
- werr = smbconf_add_string_to_array(tmp_ctx,
- &tmp_valnames,
- tmp_num_values, valname);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_add_string_to_array(tmp_ctx,
+ &tmp_valnames,
+ tmp_num_values, valname);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
valstring = smbconf_format_registry_value(tmp_ctx, valvalue);
- werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
- tmp_num_values, valstring);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
+ tmp_num_values, valstring);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
tmp_num_values++;
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ err = SBC_ERR_NOMEM;
goto done;
}
/* now add the includes at the end */
- werr = smbconf_reg_get_includes_internal(tmp_ctx, key, &num_includes,
+ err = smbconf_reg_get_includes_internal(tmp_ctx, key, &num_includes,
&includes);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
+
for (count = 0; count < num_includes; count++) {
- werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valnames,
- tmp_num_values, "include");
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_add_string_to_array(tmp_ctx, &tmp_valnames,
+ tmp_num_values, "include");
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
- werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
- tmp_num_values,
- includes[count]);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
+ tmp_num_values,
+ includes[count]);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
@@ -498,7 +515,7 @@ static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
static bool smbconf_reg_key_has_values(struct registry_key *key)
@@ -527,9 +544,10 @@ static bool smbconf_reg_key_has_values(struct registry_key *key)
/**
* delete all values from a key
*/
-static WERROR smbconf_reg_delete_values(struct registry_key *key)
+static sbcErr smbconf_reg_delete_values(struct registry_key *key)
{
WERROR werr;
+ sbcErr err;
char *valname;
struct registry_value *valvalue;
uint32_t count;
@@ -542,6 +560,7 @@ static WERROR smbconf_reg_delete_values(struct registry_key *key)
{
werr = reg_deletevalue(key, valname);
if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_ACCESS_DENIED;
goto done;
}
}
@@ -550,14 +569,15 @@ static WERROR smbconf_reg_delete_values(struct registry_key *key)
"Error enumerating values of %s: %s\n",
key->key->name,
win_errstr(werr)));
+ err = SBC_ERR_ACCESS_DENIED;
goto done;
}
- werr = WERR_OK;
+ err = SBC_ERR_OK;
done:
talloc_free(mem_ctx);
- return werr;
+ return err;
}
/**********************************************************************
@@ -569,9 +589,10 @@ done:
/**
* initialize the registry smbconf backend
*/
-static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
+static sbcErr smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
{
WERROR werr = WERR_OK;
+ sbcErr err;
struct security_token *token;
if (path == NULL) {
@@ -579,26 +600,28 @@ static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
}
ctx->path = talloc_strdup(ctx, path);
if (ctx->path == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
- ctx->data = TALLOC_ZERO_P(ctx, struct reg_private_data);
+ ctx->data = talloc_zero(ctx, struct reg_private_data);
werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
if (!W_ERROR_IS_OK(werr)) {
DEBUG(1, ("Error creating admin token\n"));
+ err = SBC_ERR_UNKNOWN_FAILURE;
goto done;
}
rpd(ctx)->open = false;
werr = registry_init_smbconf(path);
if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_BADFILE;
goto done;
}
- werr = ctx->ops->open_conf(ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = ctx->ops->open_conf(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
DEBUG(1, ("Error opening the registry.\n"));
goto done;
}
@@ -607,11 +630,12 @@ static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
KEY_ENUMERATE_SUB_KEYS | REG_KEY_WRITE,
token, &rpd(ctx)->base_key);
if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_UNKNOWN_FAILURE;
goto done;
}
done:
- return werr;
+ return err;
}
static int smbconf_reg_shutdown(struct smbconf_ctx *ctx)
@@ -640,19 +664,21 @@ static bool smbconf_reg_is_writeable(struct smbconf_ctx *ctx)
return true;
}
-static WERROR smbconf_reg_open(struct smbconf_ctx *ctx)
+static sbcErr smbconf_reg_open(struct smbconf_ctx *ctx)
{
WERROR werr;
if (rpd(ctx)->open) {
- return WERR_OK;
+ return SBC_ERR_OK;
}
werr = regdb_open();
- if (W_ERROR_IS_OK(werr)) {
- rpd(ctx)->open = true;
+ if (!W_ERROR_IS_OK(werr)) {
+ return SBC_ERR_BADFILE;
}
- return werr;
+
+ rpd(ctx)->open = true;
+ return SBC_ERR_OK;
}
static int smbconf_reg_close(struct smbconf_ctx *ctx)
@@ -682,7 +708,7 @@ static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
return;
}
- if (!W_ERROR_IS_OK(ctx->ops->open_conf(ctx))) {
+ if (!SBC_ERROR_IS_OK(ctx->ops->open_conf(ctx))) {
return;
}
@@ -692,10 +718,11 @@ static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
/**
* Drop the whole configuration (restarting empty) - registry version
*/
-static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
+static sbcErr smbconf_reg_drop(struct smbconf_ctx *ctx)
{
char *path, *p;
WERROR werr = WERR_OK;
+ sbcErr err = SBC_ERR_OK;
struct registry_key *parent_key = NULL;
struct registry_key *new_key = NULL;
TALLOC_CTX* mem_ctx = talloc_stackframe();
@@ -705,46 +732,51 @@ static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
if (!W_ERROR_IS_OK(werr)) {
DEBUG(1, ("Error creating admin token\n"));
+ err = SBC_ERR_UNKNOWN_FAILURE;
goto done;
}
path = talloc_strdup(mem_ctx, ctx->path);
if (path == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
p = strrchr(path, '\\');
if (p == NULL) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
*p = '\0';
werr = reg_open_path(mem_ctx, path, REG_KEY_WRITE, token,
&parent_key);
-
if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_IO_FAILURE;
goto done;
}
werr = reg_deletekey_recursive(parent_key, p+1);
-
if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_IO_FAILURE;
goto done;
}
werr = reg_createkey(mem_ctx, parent_key, p+1, REG_KEY_WRITE,
&new_key, &action);
+ if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_IO_FAILURE;
+ goto done;
+ }
done:
talloc_free(mem_ctx);
- return werr;
+ return err;
}
/**
* get the list of share names defined in the configuration.
* registry version.
*/
-static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
uint32_t *num_shares,
char ***share_names)
@@ -752,13 +784,13 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
uint32_t count;
uint32_t added_count = 0;
TALLOC_CTX *tmp_ctx = NULL;
- WERROR werr = WERR_OK;
+ WERROR werr;
+ sbcErr err = SBC_ERR_OK;
char *subkey_name = NULL;
char **tmp_share_names = NULL;
if ((num_shares == NULL) || (share_names == NULL)) {
- werr = WERR_INVALID_PARAM;
- goto done;
+ return SBC_ERR_INVALID_PARAM;
}
tmp_ctx = talloc_stackframe();
@@ -766,9 +798,9 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
/* if there are values in the base key, return NULL as share name */
if (smbconf_reg_key_has_values(rpd(ctx)->base_key)) {
- werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
+ err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
0, NULL);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
added_count++;
@@ -776,9 +808,9 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
/* make sure "global" is always listed first */
if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
- werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
- added_count, GLOBAL_NAME);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
+ added_count, GLOBAL_NAME);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
added_count++;
@@ -794,19 +826,20 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
continue;
}
- werr = smbconf_add_string_to_array(tmp_ctx,
+ err = smbconf_add_string_to_array(tmp_ctx,
&tmp_share_names,
added_count,
subkey_name);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
added_count++;
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ err = SBC_ERR_NO_MORE_ITEMS;
goto done;
}
- werr = WERR_OK;
+ err = SBC_ERR_OK;
*num_shares = added_count;
if (added_count > 0) {
@@ -817,7 +850,7 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
/**
@@ -827,13 +860,13 @@ static bool smbconf_reg_share_exists(struct smbconf_ctx *ctx,
const char *servicename)
{
bool ret = false;
- WERROR werr = WERR_OK;
+ sbcErr err;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct registry_key *key = NULL;
- werr = smbconf_reg_open_service_key(mem_ctx, ctx, servicename,
- REG_KEY_READ, &key);
- if (W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(mem_ctx, ctx, servicename,
+ REG_KEY_READ, &key);
+ if (SBC_ERROR_IS_OK(err)) {
ret = true;
}
@@ -844,286 +877,330 @@ static bool smbconf_reg_share_exists(struct smbconf_ctx *ctx,
/**
* Add a service if it does not already exist - registry version
*/
-static WERROR smbconf_reg_create_share(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_create_share(struct smbconf_ctx *ctx,
const char *servicename)
{
- WERROR werr;
+ sbcErr err;
struct registry_key *key = NULL;
if (servicename == NULL) {
- return WERR_OK;
+ return SBC_ERR_OK;
}
- werr = smbconf_reg_create_service_key(talloc_tos(), ctx,
- servicename, &key);
+ err = smbconf_reg_create_service_key(talloc_tos(), ctx,
+ servicename, &key);
talloc_free(key);
- return werr;
+ return err;
}
/**
* get a definition of a share (service) from configuration.
*/
-static WERROR smbconf_reg_get_share(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_get_share(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *servicename,
struct smbconf_service **service)
{
- WERROR werr = WERR_OK;
+ sbcErr err;
struct registry_key *key = NULL;
struct smbconf_service *tmp_service = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename,
- REG_KEY_READ, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename,
+ REG_KEY_READ, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
- tmp_service = TALLOC_ZERO_P(tmp_ctx, struct smbconf_service);
+ tmp_service = talloc_zero(tmp_ctx, struct smbconf_service);
if (tmp_service == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
if (servicename != NULL) {
tmp_service->name = talloc_strdup(tmp_service, servicename);
if (tmp_service->name == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
}
- werr = smbconf_reg_get_values(tmp_service, key,
- &(tmp_service->num_params),
- &(tmp_service->param_names),
- &(tmp_service->param_values));
-
- if (W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_get_values(tmp_service, key,
+ &(tmp_service->num_params),
+ &(tmp_service->param_names),
+ &(tmp_service->param_values));
+ if (SBC_ERROR_IS_OK(err)) {
*service = talloc_move(mem_ctx, &tmp_service);
}
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
/**
* delete a service from configuration
*/
-static WERROR smbconf_reg_delete_share(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_delete_share(struct smbconf_ctx *ctx,
const char *servicename)
{
- WERROR werr = WERR_OK;
+ WERROR werr;
+ sbcErr err = SBC_ERR_OK;
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (servicename != NULL) {
werr = reg_deletekey_recursive(rpd(ctx)->base_key, servicename);
+ if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_ACCESS_DENIED;
+ }
} else {
- werr = smbconf_reg_delete_values(rpd(ctx)->base_key);
+ err = smbconf_reg_delete_values(rpd(ctx)->base_key);
}
talloc_free(mem_ctx);
- return werr;
+ return err;
}
/**
* set a configuration parameter to the value provided.
*/
-static WERROR smbconf_reg_set_parameter(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_set_parameter(struct smbconf_ctx *ctx,
const char *service,
const char *param,
const char *valstr)
{
- WERROR werr;
+ sbcErr err;
struct registry_key *key = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
- REG_KEY_WRITE, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_WRITE, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
- werr = smbconf_reg_set_value(key, param, valstr);
+ err = smbconf_reg_set_value(key, param, valstr);
done:
talloc_free(mem_ctx);
- return werr;
+ return err;
}
/**
* get the value of a configuration parameter as a string
*/
-static WERROR smbconf_reg_get_parameter(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_get_parameter(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *service,
const char *param,
char **valstr)
{
WERROR werr = WERR_OK;
+ sbcErr err;
struct registry_key *key = NULL;
struct registry_value *value = NULL;
- werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
- REG_KEY_READ, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_READ, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
if (!smbconf_reg_valname_valid(param)) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
if (!smbconf_value_exists(key, param)) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
werr = reg_queryvalue(mem_ctx, key, param, &value);
if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_NOMEM;
goto done;
}
*valstr = smbconf_format_registry_value(mem_ctx, value);
-
if (*valstr == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
}
done:
talloc_free(key);
talloc_free(value);
- return werr;
+ return err;
}
/**
* delete a parameter from configuration
*/
-static WERROR smbconf_reg_delete_parameter(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_delete_parameter(struct smbconf_ctx *ctx,
const char *service,
const char *param)
{
struct registry_key *key = NULL;
- WERROR werr = WERR_OK;
+ WERROR werr;
+ sbcErr err;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
- REG_KEY_ALL, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_ALL, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
if (!smbconf_reg_valname_valid(param)) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_INVALID_PARAM;
goto done;
}
if (!smbconf_value_exists(key, param)) {
- werr = WERR_INVALID_PARAM;
+ err = SBC_ERR_OK;
goto done;
}
werr = reg_deletevalue(key, param);
+ if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_ACCESS_DENIED;
+ }
done:
talloc_free(mem_ctx);
- return werr;
+ return err;
}
-static WERROR smbconf_reg_get_includes(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_get_includes(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *service,
uint32_t *num_includes,
char ***includes)
{
- WERROR werr;
+ sbcErr err;
struct registry_key *key = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
- REG_KEY_READ, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
+ REG_KEY_READ, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
- werr = smbconf_reg_get_includes_internal(mem_ctx, key, num_includes,
+ err = smbconf_reg_get_includes_internal(mem_ctx, key, num_includes,
includes);
+ if (!SBC_ERROR_IS_OK(err)) {
+ goto done;
+ }
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
-static WERROR smbconf_reg_set_includes(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_set_includes(struct smbconf_ctx *ctx,
const char *service,
uint32_t num_includes,
const char **includes)
{
WERROR werr = WERR_OK;
+ sbcErr err;
struct registry_key *key = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
- REG_KEY_ALL, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
+ REG_KEY_ALL, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
if (num_includes == 0) {
if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
+ err = SBC_ERR_OK;
goto done;
}
werr = reg_deletevalue(key, INCLUDES_VALNAME);
+ if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_ACCESS_DENIED;
+ goto done;
+ }
} else {
- werr = smbconf_reg_set_multi_sz_value(key, INCLUDES_VALNAME,
+ err = smbconf_reg_set_multi_sz_value(key, INCLUDES_VALNAME,
num_includes, includes);
}
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
-static WERROR smbconf_reg_delete_includes(struct smbconf_ctx *ctx,
+static sbcErr smbconf_reg_delete_includes(struct smbconf_ctx *ctx,
const char *service)
{
- WERROR werr = WERR_OK;
+ WERROR werr;
+ sbcErr err;
struct registry_key *key = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
- werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
- REG_KEY_ALL, &key);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
+ REG_KEY_ALL, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
+ err = SBC_ERR_OK;
goto done;
}
werr = reg_deletevalue(key, INCLUDES_VALNAME);
+ if (!W_ERROR_IS_OK(werr)) {
+ err = SBC_ERR_ACCESS_DENIED;
+ goto done;
+ }
-
+ err = SBC_ERR_OK;
done:
talloc_free(tmp_ctx);
- return werr;
+ return err;
}
-static WERROR smbconf_reg_transaction_start(struct smbconf_ctx *ctx)
+static sbcErr smbconf_reg_transaction_start(struct smbconf_ctx *ctx)
{
- return regdb_transaction_start();
+ WERROR werr;
+
+ werr = regdb_transaction_start();
+ if (!W_ERROR_IS_OK(werr)) {
+ return SBC_ERR_IO_FAILURE;
+ }
+
+ return SBC_ERR_OK;
}
-static WERROR smbconf_reg_transaction_commit(struct smbconf_ctx *ctx)
+static sbcErr smbconf_reg_transaction_commit(struct smbconf_ctx *ctx)
{
- return regdb_transaction_commit();
+ WERROR werr;
+
+ werr = regdb_transaction_commit();
+ if (!W_ERROR_IS_OK(werr)) {
+ return SBC_ERR_IO_FAILURE;
+ }
+
+ return SBC_ERR_OK;
}
-static WERROR smbconf_reg_transaction_cancel(struct smbconf_ctx *ctx)
+static sbcErr smbconf_reg_transaction_cancel(struct smbconf_ctx *ctx)
{
- return regdb_transaction_cancel();
+ WERROR werr;
+
+ werr = regdb_transaction_cancel();
+ if (!W_ERROR_IS_OK(werr)) {
+ return SBC_ERR_IO_FAILURE;
+ }
+
+ return SBC_ERR_OK;
}
struct smbconf_ops smbconf_ops_reg = {
@@ -1156,7 +1233,7 @@ struct smbconf_ops smbconf_ops_reg = {
* initialize the smbconf registry backend
* the only function that is exported from this module
*/
-WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *path)
{
return smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_reg);
diff --git a/source3/lib/smbconf/smbconf_reg.h b/source3/lib/smbconf/smbconf_reg.h
index 7f54b6e32db..2c49057a946 100644
--- a/source3/lib/smbconf/smbconf_reg.h
+++ b/source3/lib/smbconf/smbconf_reg.h
@@ -26,7 +26,7 @@ struct smbconf_ctx;
* initialization functions for the registry backend modules
*/
-WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
+sbcErr smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *path);
diff --git a/source3/lib/smbconf/testsuite.c b/source3/lib/smbconf/testsuite.c
index 80754dd20c3..c2a9a59cbef 100644
--- a/source3/lib/smbconf/testsuite.c
+++ b/source3/lib/smbconf/testsuite.c
@@ -40,17 +40,17 @@ static void print_strings(const char *prefix,
static bool test_get_includes(struct smbconf_ctx *ctx)
{
- WERROR werr;
+ sbcErr err;
bool ret = false;
uint32_t num_includes = 0;
char **includes = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
printf("TEST: get_includes\n");
- werr = smbconf_get_global_includes(ctx, mem_ctx,
- &num_includes, &includes);
- if (!W_ERROR_IS_OK(werr)) {
- printf("FAIL: get_includes - %s\n", win_errstr(werr));
+ err = smbconf_get_global_includes(ctx, mem_ctx,
+ &num_includes, &includes);
+ if (!SBC_ERROR_IS_OK(err)) {
+ printf("FAIL: get_includes - %s\n", sbcErrorString(err));
goto done;
}
@@ -68,7 +68,7 @@ done:
static bool test_set_get_includes(struct smbconf_ctx *ctx)
{
- WERROR werr;
+ sbcErr err;
uint32_t count;
bool ret = false;
const char *set_includes[] = {
@@ -82,18 +82,18 @@ static bool test_set_get_includes(struct smbconf_ctx *ctx)
printf("TEST: set_get_includes\n");
- werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
+ if (!SBC_ERROR_IS_OK(err)) {
printf("FAIL: get_set_includes (setting includes) - %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
- werr = smbconf_get_global_includes(ctx, mem_ctx, &get_num_includes,
- &get_includes);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_global_includes(ctx, mem_ctx, &get_num_includes,
+ &get_includes);
+ if (!SBC_ERROR_IS_OK(err)) {
printf("FAIL: get_set_includes (getting includes) - %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -125,7 +125,7 @@ done:
static bool test_delete_includes(struct smbconf_ctx *ctx)
{
- WERROR werr;
+ sbcErr err;
bool ret = false;
const char *set_includes[] = {
"/path/to/include",
@@ -137,25 +137,25 @@ static bool test_delete_includes(struct smbconf_ctx *ctx)
printf("TEST: delete_includes\n");
- werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
+ if (!SBC_ERROR_IS_OK(err)) {
printf("FAIL: delete_includes (setting includes) - %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
- werr = smbconf_delete_global_includes(ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_delete_global_includes(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
printf("FAIL: delete_includes (deleting includes) - %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
- werr = smbconf_get_global_includes(ctx, mem_ctx, &get_num_includes,
- &get_includes);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_global_includes(ctx, mem_ctx, &get_num_includes,
+ &get_includes);
+ if (!SBC_ERROR_IS_OK(err)) {
printf("FAIL: delete_includes (getting includes) - %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -164,10 +164,10 @@ static bool test_delete_includes(struct smbconf_ctx *ctx)
goto done;
}
- werr = smbconf_delete_global_includes(ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_delete_global_includes(ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
printf("FAIL: delete_includes (delete empty includes) - "
- "%s\n", win_errstr(werr));
+ "%s\n", sbcErrorString(err));
goto done;
}
@@ -203,7 +203,7 @@ static bool create_conf_file(const char *filename)
static bool torture_smbconf_txt(void)
{
- WERROR werr;
+ sbcErr err;
bool ret = true;
const char *filename = "/tmp/smb.conf.smbconf_testsuite";
struct smbconf_ctx *conf_ctx = NULL;
@@ -217,9 +217,9 @@ static bool torture_smbconf_txt(void)
}
printf("TEST: init\n");
- werr = smbconf_init_txt(mem_ctx, &conf_ctx, filename);
- if (!W_ERROR_IS_OK(werr)) {
- printf("FAIL: text backend failed: %s\n", win_errstr(werr));
+ err = smbconf_init_txt(mem_ctx, &conf_ctx, filename);
+ if (!SBC_ERROR_IS_OK(err)) {
+ printf("FAIL: text backend failed: %s\n", sbcErrorString(err));
ret = false;
goto done;
}
@@ -245,7 +245,7 @@ done:
static bool torture_smbconf_reg(void)
{
- WERROR werr;
+ sbcErr err;
bool ret = true;
struct smbconf_ctx *conf_ctx = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -253,9 +253,9 @@ static bool torture_smbconf_reg(void)
printf("test: registry backend\n");
printf("TEST: init\n");
- werr = smbconf_init_reg(mem_ctx, &conf_ctx, NULL);
- if (!W_ERROR_IS_OK(werr)) {
- printf("FAIL: init failed: %s\n", win_errstr(werr));
+ err = smbconf_init_reg(mem_ctx, &conf_ctx, NULL);
+ if (!SBC_ERROR_IS_OK(err)) {
+ printf("FAIL: init failed: %s\n", sbcErrorString(err));
ret = false;
goto done;
}
diff --git a/source3/lib/dummysmbd.c b/source3/lib/smbd_shim.c
index 2465e6552bc..72ae366ec36 100644
--- a/source3/lib/dummysmbd.c
+++ b/source3/lib/smbd_shim.c
@@ -3,6 +3,7 @@
RPC pipe client
Copyright (C) Gerald (Jerry) Carter 2004.
+ Copyright (C) Andrew Bartlett 2011.
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
@@ -18,48 +19,55 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Stupid dummy functions required due to the horrible dependency mess
+/* Shim functions required due to the horrible dependency mess
in Samba. */
#include "includes.h"
+#include "smbd_shim.h"
+#include "smbd/proto.h"
-int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out)
-{
- return -1;
-}
+static struct smbd_shim shim;
-bool conn_snum_used(int snum)
+void set_smbd_shim(const struct smbd_shim *shim_functions)
{
- return False;
+ shim = *shim_functions;
}
void cancel_pending_lock_requests_by_fid(files_struct *fsp,
struct byte_range_lock *br_lck,
enum file_close_type close_type)
{
+ if (shim.cancel_pending_lock_requests_by_fid) {
+
+ shim.cancel_pending_lock_requests_by_fid(fsp, br_lck, close_type);
+ }
}
void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
const char *name)
{
+ if (shim.send_stat_cache_delete_message) {
+ shim.send_stat_cache_delete_message(msg_ctx, name);
+ }
}
NTSTATUS can_delete_directory(struct connection_struct *conn,
const char *dirname)
{
+ if (shim.can_delete_directory) {
+ return shim.can_delete_directory(conn, dirname);
+ }
return NT_STATUS_OK;
}
bool change_to_root_user(void)
{
+ if (shim.change_to_root_user) {
+ return shim.change_to_root_user();
+ }
return false;
}
-struct event_context *smbd_event_context(void)
-{
- return NULL;
-}
-
/**
* The following two functions need to be called from inside the low-level BRL
* code for oplocks correctness in smbd. Since other utility binaries also
@@ -70,11 +78,33 @@ struct event_context *smbd_event_context(void)
void contend_level2_oplocks_begin(files_struct *fsp,
enum level2_contention_type type)
{
+ if (shim.contend_level2_oplocks_begin) {
+ shim.contend_level2_oplocks_begin(fsp, type);
+ }
return;
}
void contend_level2_oplocks_end(files_struct *fsp,
enum level2_contention_type type)
{
+ if (shim.contend_level2_oplocks_end) {
+ shim.contend_level2_oplocks_end(fsp, type);
+ }
+ return;
+}
+
+void become_root(void)
+{
+ if (shim.become_root) {
+ shim.become_root();
+ }
+ return;
+}
+
+void unbecome_root(void)
+{
+ if (shim.unbecome_root) {
+ shim.unbecome_root();
+ }
return;
}
diff --git a/source3/lib/smbd_shim.h b/source3/lib/smbd_shim.h
new file mode 100644
index 00000000000..89cae2b694d
--- /dev/null
+++ b/source3/lib/smbd_shim.h
@@ -0,0 +1,56 @@
+/*
+ Unix SMB/CIFS implementation.
+ RPC pipe client
+
+ Copyright (C) Gerald (Jerry) Carter 2004.
+ Copyright (C) Andrew Bartlett 2011.
+
+ 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/>.
+*/
+
+/*
+ shim functions are used required to allow library code to have
+ references to smbd specific code. The smbd daemon sets up the set
+ of function calls that it wants used by calling
+ set_smbd_shim(). Other executables don't make this call, and get
+ default (dummy) versions of these functions.
+*/
+
+struct smbd_shim
+{
+ void (*cancel_pending_lock_requests_by_fid)(files_struct *fsp,
+ struct byte_range_lock *br_lck,
+ enum file_close_type close_type);
+ void (*send_stat_cache_delete_message)(struct messaging_context *msg_ctx,
+ const char *name);
+
+ NTSTATUS (*can_delete_directory)(struct connection_struct *conn,
+ const char *dirname);
+
+ bool (*change_to_root_user)(void);
+
+ void (*contend_level2_oplocks_begin)(files_struct *fsp,
+ enum level2_contention_type type);
+
+ void (*contend_level2_oplocks_end)(files_struct *fsp,
+ enum level2_contention_type type);
+
+ void (*become_root)(void);
+
+ void (*unbecome_root)(void);
+};
+
+void set_smbd_shim(const struct smbd_shim *shim_functions);
+
+
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index fe432374641..38c7b207f56 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -239,7 +239,7 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
i++;
i++;
- names = TALLOC_ARRAY( mem_ctx, const char*, i );
+ names = talloc_array( mem_ctx, const char*, i );
if ( !names ) {
DEBUG(0,("get_attr_list: out of memory\n"));
return NULL;
@@ -405,7 +405,7 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
return NULL;
}
- if (StrCaseCmp(tmp, result) < 0) {
+ if (strcasecmp_m(tmp, result) < 0) {
TALLOC_FREE(result);
result = tmp;
} else {
@@ -474,7 +474,7 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
return;
}
- handle = TALLOC_P(mem_ctx, LDAPMessage *);
+ handle = talloc(mem_ctx, LDAPMessage *);
SMB_ASSERT(handle != NULL);
*handle = result;
@@ -494,7 +494,7 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
return;
}
- handle = TALLOC_P(mem_ctx, LDAPMod **);
+ handle = talloc(mem_ctx, LDAPMod **);
SMB_ASSERT(handle != NULL);
*handle = mod;
@@ -654,7 +654,7 @@ static void smbldap_make_mod_internal(LDAP *ldap_struct, LDAPMessage *existing,
equal = (newblob && (data_blob_cmp(&oldblob, newblob) == 0));
} else {
/* all of our string attributes are case insensitive */
- equal = (newval && (StrCaseCmp(oldval, newval) == 0));
+ equal = (newval && (strcasecmp_m(oldval, newval) == 0));
}
if (equal) {
@@ -1480,7 +1480,7 @@ static int smbldap_search_ext(struct smbldap_state *ldap_state,
while (another_ldap_try(ldap_state, &rc, &attempts, endtime)) {
rc = ldap_search_ext_s(ldap_state->ldap_struct, base, scope,
utf8_filter,
- CONST_DISCARD(char **, attrs),
+ discard_const_p(char *, attrs),
attrsonly, sctrls, cctrls, &timeout,
sizelimit, res);
if (rc != LDAP_SUCCESS) {
@@ -1562,7 +1562,7 @@ int smbldap_search_paged(struct smbldap_state *ldap_state,
}
ber_flatten(cookie_be, &cookie_bv);
- pr.ldctl_oid = CONST_DISCARD(char *, ADS_PAGE_CTL_OID);
+ pr.ldctl_oid = discard_const_p(char, ADS_PAGE_CTL_OID);
pr.ldctl_iscritical = (char) critical;
pr.ldctl_value.bv_len = cookie_bv->bv_len;
pr.ldctl_value.bv_val = cookie_bv->bv_val;
@@ -1862,7 +1862,7 @@ NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx, struct event_context *event_ctx,
const char *location,
struct smbldap_state **smbldap_state)
{
- *smbldap_state = TALLOC_ZERO_P(mem_ctx, struct smbldap_state);
+ *smbldap_state = talloc_zero(mem_ctx, struct smbldap_state);
if (!*smbldap_state) {
DEBUG(0, ("talloc() failed for ldapsam private_data!\n"));
return NT_STATUS_NO_MEMORY;
@@ -1924,7 +1924,7 @@ static bool smbldap_check_root_dse(LDAP *ld, const char **attrs, const char *val
}
rc = ldap_search_s(ld, "", LDAP_SCOPE_BASE,
- "(objectclass=*)", CONST_DISCARD(char **, attrs), 0 , &msg);
+ "(objectclass=*)", discard_const_p(char *, attrs), 0 , &msg);
if (rc != LDAP_SUCCESS) {
DEBUG(3,("smbldap_check_root_dse: Could not search rootDSE\n"));
diff --git a/source3/lib/string_init.c b/source3/lib/string_init.c
new file mode 100644
index 00000000000..40a6ef059ba
--- /dev/null
+++ b/source3/lib/string_init.c
@@ -0,0 +1,77 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+
+ Copyright (C) Andrew Tridgell 1992-2001
+ Copyright (C) Simo Sorce 2001-2002
+ Copyright (C) Martin Pool 2003
+ Copyright (C) James Peach 2006
+ Copyright (C) Jeremy Allison 1992-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"
+
+/* this is used to prevent lots of mallocs of size 1 */
+static const char null_string[] = "";
+
+/**
+ Set a string value, allocing the space for the string
+**/
+
+static bool string_init(char **dest,const char *src)
+{
+ size_t l;
+
+ if (!src)
+ src = "";
+
+ l = strlen(src);
+
+ if (l == 0) {
+ *dest = discard_const_p(char, null_string);
+ } else {
+ (*dest) = SMB_STRDUP(src);
+ if ((*dest) == NULL) {
+ DEBUG(0,("Out of memory in string_init\n"));
+ return false;
+ }
+ }
+ return(true);
+}
+
+/**
+ Free a string value.
+**/
+
+void string_free(char **s)
+{
+ if (!s || !(*s))
+ return;
+ if (*s == null_string)
+ *s = NULL;
+ SAFE_FREE(*s);
+}
+
+/**
+ Set a string value, deallocating any existing space, and allocing the space
+ for the string
+**/
+
+bool string_set(char **dest,const char *src)
+{
+ string_free(dest);
+ return(string_init(dest,src));
+}
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index e72a8c3b616..df217bc03f7 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -80,7 +80,7 @@ bool set_local_machine_name(const char *local_name, bool perm)
const char *get_local_machine_name(void)
{
if (!local_machine || !*local_machine) {
- return global_myname();
+ return lp_netbios_name();
}
return local_machine;
@@ -324,105 +324,6 @@ static char * realloc_expand_env_var(char *str, char *p)
}
/*******************************************************************
-*******************************************************************/
-
-static char *longvar_domainsid( void )
-{
- struct dom_sid sid;
- fstring tmp;
- char *sid_string;
-
- if ( !secrets_fetch_domain_sid( lp_workgroup(), &sid ) ) {
- return NULL;
- }
-
- sid_string = SMB_STRDUP( sid_to_fstring( tmp, &sid ) );
-
- if ( !sid_string ) {
- DEBUG(0,("longvar_domainsid: failed to dup SID string!\n"));
- }
-
- return sid_string;
-}
-
-/*******************************************************************
-*******************************************************************/
-
-struct api_longvar {
- const char *name;
- char* (*fn)( void );
-};
-
-static struct api_longvar longvar_table[] = {
- { "DomainSID", longvar_domainsid },
- { NULL, NULL }
-};
-
-static char *get_longvar_val( const char *varname )
-{
- int i;
-
- DEBUG(7,("get_longvar_val: expanding variable [%s]\n", varname));
-
- for ( i=0; longvar_table[i].name; i++ ) {
- if ( strequal( longvar_table[i].name, varname ) ) {
- return longvar_table[i].fn();
- }
- }
-
- return NULL;
-}
-
-/*******************************************************************
- Expand the long smb.conf variable names given a pointer to a %(NAME).
- Return the number of characters by which the pointer should be advanced.
- When this is called p points at the '%' character.
-********************************************************************/
-
-static char *realloc_expand_longvar(char *str, char *p)
-{
- fstring varname;
- char *value;
- char *q, *r;
- int copylen;
-
- if ( p[0] != '%' || p[1] != '(' ) {
- return str;
- }
-
- /* Look for the terminating ')'.*/
-
- if ((q = strchr_m(p,')')) == NULL) {
- DEBUG(0,("realloc_expand_longvar: Unterminated environment variable [%s]\n", p));
- return str;
- }
-
- /* Extract the name from within the %(NAME) string.*/
-
- r = p+2;
- copylen = MIN( (q-r), (sizeof(varname)-1) );
- strncpy(varname, r, copylen);
- varname[copylen] = '\0';
-
- if ((value = get_longvar_val(varname)) == NULL) {
- DEBUG(0,("realloc_expand_longvar: Variable [%s] not set. Skipping\n", varname));
- return str;
- }
-
- /* Copy the full %(NAME) into envname so it can be replaced.*/
-
- copylen = MIN( (q+1-p),(sizeof(varname)-1) );
- strncpy( varname, p, copylen );
- varname[copylen] = '\0';
- r = realloc_string_sub(str, varname, value);
- SAFE_FREE( value );
-
- /* skip over the %(varname) */
-
- return r;
-}
-
-/*******************************************************************
Patch from jkf@soton.ac.uk
Added this to implement %p (NIS auto-map version of %H)
*******************************************************************/
@@ -489,7 +390,7 @@ static const char *automount_server(const char *user_name)
if (local_machine_name && *local_machine_name) {
server_name = talloc_strdup(ctx, local_machine_name);
} else {
- server_name = talloc_strdup(ctx, global_myname());
+ server_name = talloc_strdup(ctx, lp_netbios_name());
}
if (!server_name) {
@@ -632,13 +533,13 @@ static char *alloc_sub_basic(const char *smb_name, const char *domain_name,
sub_sockaddr[0] ? sub_sockaddr : "0.0.0.0");
break;
case 'L' :
- if ( StrnCaseCmp(p, "%LOGONSERVER%", strlen("%LOGONSERVER%")) == 0 ) {
+ if ( strncasecmp_m(p, "%LOGONSERVER%", strlen("%LOGONSERVER%")) == 0 ) {
break;
}
if (local_machine_name && *local_machine_name) {
a_string = realloc_string_sub(a_string, "%L", local_machine_name);
} else {
- a_string = realloc_string_sub(a_string, "%L", global_myname());
+ a_string = realloc_string_sub(a_string, "%L", lp_netbios_name());
}
break;
case 'N':
@@ -680,9 +581,6 @@ static char *alloc_sub_basic(const char *smb_name, const char *domain_name,
case '$' :
a_string = realloc_expand_env_var(a_string, p); /* Expand environment variables */
break;
- case '(':
- a_string = realloc_expand_longvar( a_string, p );
- break;
case 'V' :
slprintf(vnnstr,sizeof(vnnstr)-1, "%u", get_my_vnn());
a_string = realloc_string_sub(a_string, "%V", vnnstr);
@@ -926,3 +824,32 @@ char *standard_sub_conn(TALLOC_CTX *ctx, connection_struct *conn, const char *st
"",
str);
}
+
+/******************************************************************************
+ version of standard_sub_basic() for string lists; uses talloc_sub_basic()
+ for the work
+ *****************************************************************************/
+
+bool str_list_sub_basic( char **list, const char *smb_name,
+ const char *domain_name )
+{
+ TALLOC_CTX *ctx = list;
+ char *s, *tmpstr;
+
+ while ( *list ) {
+ s = *list;
+ tmpstr = talloc_sub_basic(ctx, smb_name, domain_name, s);
+ if ( !tmpstr ) {
+ DEBUG(0,("str_list_sub_basic: "
+ "alloc_sub_basic() return NULL!\n"));
+ return false;
+ }
+
+ TALLOC_FREE(*list);
+ *list = tmpstr;
+
+ list++;
+ }
+
+ return true;
+}
diff --git a/source3/lib/substitute_generic.c b/source3/lib/substitute_generic.c
new file mode 100644
index 00000000000..fa347fb8157
--- /dev/null
+++ b/source3/lib/substitute_generic.c
@@ -0,0 +1,116 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+
+ Copyright (C) Andrew Tridgell 1992-2001
+ Copyright (C) Simo Sorce 2001-2002
+ Copyright (C) Martin Pool 2003
+ Copyright (C) James Peach 2006
+ Copyright (C) Jeremy Allison 1992-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"
+
+void fstring_sub(char *s,const char *pattern,const char *insert)
+{
+ string_sub(s, pattern, insert, sizeof(fstring));
+}
+
+/**
+ Similar to string_sub2, but it will accept only allocated strings
+ and may realloc them so pay attention at what you pass on no
+ pointers inside strings, no const may be passed
+ as string.
+**/
+
+char *realloc_string_sub2(char *string,
+ const char *pattern,
+ const char *insert,
+ bool remove_unsafe_characters,
+ bool allow_trailing_dollar)
+{
+ char *p, *in;
+ char *s;
+ ssize_t ls,lp,li,ld, i;
+
+ if (!insert || !pattern || !*pattern || !string || !*string)
+ return NULL;
+
+ s = string;
+
+ in = SMB_STRDUP(insert);
+ if (!in) {
+ DEBUG(0, ("realloc_string_sub: out of memory!\n"));
+ return NULL;
+ }
+ ls = (ssize_t)strlen(s);
+ lp = (ssize_t)strlen(pattern);
+ li = (ssize_t)strlen(insert);
+ ld = li - lp;
+ for (i=0;i<li;i++) {
+ switch (in[i]) {
+ case '$':
+ /* allow a trailing $
+ * (as in machine accounts) */
+ if (allow_trailing_dollar && (i == li - 1 )) {
+ break;
+ }
+ case '`':
+ case '"':
+ case '\'':
+ case ';':
+ case '%':
+ case '\r':
+ case '\n':
+ if ( remove_unsafe_characters ) {
+ in[i] = '_';
+ break;
+ }
+ default:
+ /* ok */
+ break;
+ }
+ }
+
+ while ((p = strstr_m(s,pattern))) {
+ if (ld > 0) {
+ int offset = PTR_DIFF(s,string);
+ string = (char *)SMB_REALLOC(string, ls + ld + 1);
+ if (!string) {
+ DEBUG(0, ("realloc_string_sub: "
+ "out of memory!\n"));
+ SAFE_FREE(in);
+ return NULL;
+ }
+ p = string + offset + (p - s);
+ }
+ if (li != lp) {
+ memmove(p+li,p+lp,strlen(p+lp)+1);
+ }
+ memcpy(p, in, li);
+ s = p + li;
+ ls += ld;
+ }
+ SAFE_FREE(in);
+ return string;
+}
+
+char *realloc_string_sub(char *string,
+ const char *pattern,
+ const char *insert)
+{
+ return realloc_string_sub2(string, pattern, insert, true, false);
+}
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 52b64772666..2f7a55f48c1 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -48,42 +48,6 @@
/*******************************************************************
- A wrapper for memalign
-********************************************************************/
-
-void *sys_memalign( size_t align, size_t size )
-{
-#if defined(HAVE_POSIX_MEMALIGN)
- void *p = NULL;
- int ret = posix_memalign( &p, align, size );
- if ( ret == 0 )
- return p;
-
- return NULL;
-#elif defined(HAVE_MEMALIGN)
- return memalign( align, size );
-#else
- /* On *BSD systems memaligns doesn't exist, but memory will
- * be aligned on allocations of > pagesize. */
-#if defined(SYSCONF_SC_PAGESIZE)
- size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
-#elif defined(HAVE_GETPAGESIZE)
- size_t pagesize = (size_t)getpagesize();
-#else
- size_t pagesize = (size_t)-1;
-#endif
- if (pagesize == (size_t)-1) {
- DEBUG(0,("memalign functionalaity not available on this platform!\n"));
- return NULL;
- }
- if (size < pagesize) {
- size = pagesize;
- }
- return SMB_MALLOC(size);
-#endif
-}
-
-/*******************************************************************
A wrapper for usleep in case we don't have one.
********************************************************************/
@@ -545,13 +509,13 @@ void update_stat_ex_create_time(struct stat_ex *dst,
}
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_STAT64)
-static void init_stat_ex_from_stat (struct stat_ex *dst,
- const struct stat64 *src,
- bool fake_dir_create_times)
+void init_stat_ex_from_stat (struct stat_ex *dst,
+ const struct stat64 *src,
+ bool fake_dir_create_times)
#else
-static void init_stat_ex_from_stat (struct stat_ex *dst,
- const struct stat *src,
- bool fake_dir_create_times)
+void init_stat_ex_from_stat (struct stat_ex *dst,
+ const struct stat *src,
+ bool fake_dir_create_times)
#endif
{
dst->st_ex_dev = src->st_dev;
@@ -833,6 +797,15 @@ FILE *sys_fopen(const char *path, const char *type)
}
+#if HAVE_KERNEL_SHARE_MODES
+#ifndef LOCK_MAND
+#define LOCK_MAND 32 /* This is a mandatory flock */
+#define LOCK_READ 64 /* ... Which allows concurrent read operations */
+#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
+#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
+#endif
+#endif
+
/*******************************************************************
A flock() wrapper that will perform the kernel flock.
********************************************************************/
@@ -986,18 +959,45 @@ int sys_waitpid(pid_t pid,int *status,int options)
}
/*******************************************************************
- System wrapper for getwd
+ System wrapper for getwd. Always returns MALLOC'ed memory, or NULL
+ on error (malloc fail usually).
********************************************************************/
-char *sys_getwd(char *s)
+char *sys_getwd(void)
{
- char *wd;
-#ifdef HAVE_GETCWD
- wd = (char *)getcwd(s, PATH_MAX);
+#ifdef GETCWD_TAKES_NULL
+ return getcwd(NULL, 0);
+#elif HAVE_GETCWD
+ char *wd = NULL, *s = NULL;
+ size_t allocated = PATH_MAX;
+
+ while (1) {
+ s = SMB_REALLOC_ARRAY(s, char, allocated);
+ if (s == NULL) {
+ return NULL;
+ }
+ wd = getcwd(s, allocated);
+ if (wd) {
+ break;
+ }
+ if (errno != ERANGE) {
+ SAFE_FREE(s);
+ break;
+ }
+ allocated *= 2;
+ if (allocated < PATH_MAX) {
+ SAFE_FREE(s);
+ break;
+ }
+ }
+ return wd;
#else
- wd = (char *)getwd(s);
+ char *s = SMB_MALLOC_ARRAY(char, PATH_MAX);
+ if (s == NULL) {
+ return NULL;
+ }
+ return getwd(s);
#endif
- return wd;
}
#if defined(HAVE_POSIX_CAPABILITIES)
@@ -1382,7 +1382,7 @@ static char **extract_args(TALLOC_CTX *mem_ctx, const char *command)
TALLOC_FREE(trunc_cmd);
- if (!(argl = TALLOC_ARRAY(mem_ctx, char *, argcl + 1))) {
+ if (!(argl = talloc_array(mem_ctx, char *, argcl + 1))) {
goto nomem;
}
@@ -2367,7 +2367,7 @@ static ssize_t solaris_list_xattr(int attrdirfd, char *list, size_t size)
dirp = fdopendir(newfd);
while ((de = readdir(dirp))) {
- size_t listlen = strlen(de->d_name);
+ size_t listlen = strlen(de->d_name) + 1;
if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) {
/* we don't want "." and ".." here: */
DEBUG(10,("skipped EA %s\n",de->d_name));
@@ -2376,18 +2376,16 @@ static ssize_t solaris_list_xattr(int attrdirfd, char *list, size_t size)
if (size == 0) {
/* return the current size of the list of extended attribute names*/
- len += listlen + 1;
+ len += listlen;
} else {
/* check size and copy entrieѕ + nul into list. */
- if ((len + listlen + 1) > size) {
+ if ((len + listlen) > size) {
errno = ERANGE;
len = -1;
break;
} else {
- safe_strcpy(list + len, de->d_name, listlen);
+ strlcpy(list + len, de->d_name, listlen);
len += listlen;
- list[len] = '\0';
- ++len;
}
}
}
@@ -2633,74 +2631,3 @@ int sys_aio_suspend(const SMB_STRUCT_AIOCB * const cblist[], int n, const struct
return -1;
}
#endif /* WITH_AIO */
-
-int sys_getpeereid( int s, uid_t *uid)
-{
-#if defined(HAVE_PEERCRED)
- struct ucred cred;
- socklen_t cred_len = sizeof(struct ucred);
- int ret;
-
- ret = getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void *)&cred, &cred_len);
- if (ret != 0) {
- return -1;
- }
-
- if (cred_len != sizeof(struct ucred)) {
- errno = EINVAL;
- return -1;
- }
-
- *uid = cred.uid;
- return 0;
-#else
-#if defined(HAVE_GETPEEREID)
- gid_t gid;
- return getpeereid(s, uid, &gid);
-#endif
- errno = ENOSYS;
- return -1;
-#endif
-}
-
-int sys_getnameinfo(const struct sockaddr *psa,
- socklen_t salen,
- char *host,
- size_t hostlen,
- char *service,
- size_t servlen,
- int flags)
-{
- /*
- * For Solaris we must make sure salen is the
- * correct length for the incoming sa_family.
- */
-
- if (salen == sizeof(struct sockaddr_storage)) {
- salen = sizeof(struct sockaddr_in);
-#if defined(HAVE_IPV6)
- if (psa->sa_family == AF_INET6) {
- salen = sizeof(struct sockaddr_in6);
- }
-#endif
- }
- return getnameinfo(psa, salen, host, hostlen, service, servlen, flags);
-}
-
-int sys_connect(int fd, const struct sockaddr * addr)
-{
- socklen_t salen = (socklen_t)-1;
-
- if (addr->sa_family == AF_INET) {
- salen = sizeof(struct sockaddr_in);
- } else if (addr->sa_family == AF_UNIX) {
- salen = sizeof(struct sockaddr_un);
- }
-#if defined(HAVE_IPV6)
- else if (addr->sa_family == AF_INET6) {
- salen = sizeof(struct sockaddr_in6);
- }
-#endif
-
- return connect(fd, addr, salen);
-}
diff --git a/source3/lib/talloc_dict.c b/source3/lib/talloc_dict.c
index cbe5c7b5c2a..95ae0a3260d 100644
--- a/source3/lib/talloc_dict.c
+++ b/source3/lib/talloc_dict.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "dbwrap.h"
#include "talloc_dict.h"
+#include "util_tdb.h"
struct talloc_dict {
struct db_context *db;
diff --git a/source3/lib/tallocmsg.c b/source3/lib/tallocmsg.c
index da380c93355..9a0ce8ada18 100644
--- a/source3/lib/tallocmsg.c
+++ b/source3/lib/tallocmsg.c
@@ -65,7 +65,7 @@ static void msg_pool_usage_helper(const void *ptr, int depth, int max_depth, int
(unsigned long)talloc_total_blocks(ptr),
talloc_reference_count(ptr),
MIN(50, talloc_get_size(ptr)),
- (char *)ptr);
+ (const char *)ptr);
return;
}
diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c
index b91ea7af834..385f4d0ef81 100644
--- a/source3/lib/tdb_validate.c
+++ b/source3/lib/tdb_validate.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "system/filesys.h"
+#include "util_tdb.h"
#include "tdb_validate.h"
/*
@@ -50,12 +51,13 @@ static int tdb_validate_child(struct tdb_context *tdb,
* but I don't want to change all the callers...
*/
ret = tdb_check(tdb, NULL, NULL);
- if (ret == -1) {
+ if (ret != 0) {
v_status.tdb_error = True;
v_status.success = False;
goto out;
}
+#ifndef BUILD_TDB2
/* Check if the tdb's freelist is good. */
if (tdb_validate_freelist(tdb, &num_entries) == -1) {
v_status.bad_freelist = True;
@@ -65,12 +67,13 @@ static int tdb_validate_child(struct tdb_context *tdb,
DEBUG(10,("tdb_validate_child: tdb %s freelist has %d entries\n",
tdb_name(tdb), num_entries));
+#endif
/* Now traverse the tdb to validate it. */
num_entries = tdb_traverse(tdb, validate_fn, (void *)&v_status);
if (!v_status.success) {
goto out;
- } else if (num_entries == -1) {
+ } else if (num_entries < 0) {
v_status.tdb_error = True;
v_status.success = False;
goto out;
@@ -288,8 +291,14 @@ static int tdb_backup(TALLOC_CTX *ctx, const char *src_path,
}
unlink(tmp_path);
- dst_tdb = tdb_open_log(tmp_path,
- hash_size ? hash_size : tdb_hash_size(src_tdb),
+
+#ifndef BUILD_TDB2
+ if (!hash_size) {
+ hash_size = tdb_hash_size(src_tdb);
+ }
+#endif
+
+ dst_tdb = tdb_open_log(tmp_path, hash_size,
TDB_DEFAULT, O_RDWR | O_CREAT | O_EXCL,
st.st_mode & 0777);
if (dst_tdb == NULL) {
diff --git a/source3/lib/tdb_validate.h b/source3/lib/tdb_validate.h
index 3e7c20d04cf..5bb043d2924 100644
--- a/source3/lib/tdb_validate.h
+++ b/source3/lib/tdb_validate.h
@@ -23,7 +23,7 @@
#define __TDB_VALIDATE_H__
#include "lib/replace/replace.h"
-#include <tdb.h>
+#include "tdb_compat.h"
/**
* Flag field for keeping track of the status of a validation.
diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c
index cd1dea52ba5..8b04d006367 100644
--- a/source3/lib/tldap.c
+++ b/source3/lib/tldap.c
@@ -20,6 +20,8 @@
#include "includes.h"
#include "tldap.h"
#include "../lib/util/asn1.h"
+#include "../lib/tsocket/tsocket.h"
+#include "../lib/util/tevent_unix.h"
static int tldap_simple_recv(struct tevent_req *req);
@@ -187,7 +189,7 @@ bool tldap_context_setattr(struct tldap_context *ld,
struct tldap_ctx_attribute *tmp, *attr;
char *tmpname;
int num_attrs;
- void **pptr = (void **)_pptr;
+ void **pptr = (void **)discard_const_p(void,_pptr);
attr = tldap_context_findattr(ld, name);
if (attr != NULL) {
@@ -539,7 +541,7 @@ static void tldap_msg_sent(struct tevent_req *subreq)
}
if (!tldap_msg_set_pending(req)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
}
@@ -933,10 +935,10 @@ struct tevent_req *tldap_simple_bind_send(TALLOC_CTX *mem_ctx,
DATA_BLOB cred;
if (passwd != NULL) {
- cred.data = (uint8_t *)passwd;
+ cred.data = discard_const_p(uint8_t, passwd);
cred.length = strlen(passwd);
} else {
- cred.data = (uint8_t *)"";
+ cred.data = discard_const_p(uint8_t, "");
cred.length = 0;
}
return tldap_sasl_bind_send(mem_ctx, ev, ld, dn, NULL, &cred, NULL, 0,
@@ -954,10 +956,10 @@ int tldap_simple_bind(struct tldap_context *ld, const char *dn,
DATA_BLOB cred;
if (passwd != NULL) {
- cred.data = (uint8_t *)passwd;
+ cred.data = discard_const_p(uint8_t, passwd);
cred.length = strlen(passwd);
} else {
- cred.data = (uint8_t *)"";
+ cred.data = discard_const_p(uint8_t, "");
cred.length = 0;
}
return tldap_sasl_bind(ld, dn, NULL, &cred, NULL, 0, NULL, 0);
@@ -1373,7 +1375,7 @@ static bool tldap_push_filter_basic(struct tldap_context *ld,
return false;
}
- if (StrnCaseCmp(dn, "dn:", 3) != 0) {
+ if (strncasecmp_m(dn, "dn:", 3) != 0) {
if (rule == e) {
rule = dn;
dn = NULL;
@@ -1701,7 +1703,7 @@ static void tldap_search_done(struct tevent_req *subreq)
case TLDAP_RES_SEARCH_ENTRY:
case TLDAP_RES_SEARCH_REFERENCE:
if (!tldap_msg_set_pending(subreq)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
tevent_req_notify_callback(req);
diff --git a/source3/lib/tldap_util.c b/source3/lib/tldap_util.c
index 0c22d6564e5..6b9f912e277 100644
--- a/source3/lib/tldap_util.c
+++ b/source3/lib/tldap_util.c
@@ -300,7 +300,7 @@ static int compare_utf8_blobs(const DATA_BLOB *d1, const DATA_BLOB *d2)
TALLOC_FREE(s1);
return 0;
}
- ret = StrCaseCmp(s1, s2);
+ ret = strcasecmp_m(s1, s2);
TALLOC_FREE(s2);
TALLOC_FREE(s1);
return ret;
@@ -325,7 +325,7 @@ bool tldap_make_mod_fmt(struct tldap_message *existing, TALLOC_CTX *mem_ctx,
blob.length = strlen(newval);
if (blob.length != 0) {
- blob.data = CONST_DISCARD(uint8_t *, newval);
+ blob.data = discard_const_p(uint8_t, newval);
}
ret = tldap_make_mod_blob_int(existing, mem_ctx, pmods, pnum_mods,
attrib, blob, compare_utf8_blobs);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 0bb46db05f6..b8fc319a6ff 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -24,9 +24,11 @@
#include "includes.h"
#include "system/passwd.h"
#include "system/filesys.h"
+#include "util_tdb.h"
#include "ctdbd_conn.h"
#include "../lib/util/util_pw.h"
#include "messages.h"
+#include <ccan/hash/hash.h>
/* Max allowable allococation - 256mb - 0x10000000 */
#define MAX_ALLOC_SIZE (1024*1024*256)
@@ -71,87 +73,6 @@ void set_Protocol(enum protocol_types p)
static enum remote_arch_types ra_type = RA_UNKNOWN;
-/***********************************************************************
- Definitions for all names.
-***********************************************************************/
-
-static char *smb_scope;
-static int smb_num_netbios_names;
-static char **smb_my_netbios_names;
-
-/***********************************************************************
- Allocate and set scope. Ensure upper case.
-***********************************************************************/
-
-bool set_global_scope(const char *scope)
-{
- SAFE_FREE(smb_scope);
- smb_scope = SMB_STRDUP(scope);
- if (!smb_scope)
- return False;
- strupper_m(smb_scope);
- return True;
-}
-
-/*********************************************************************
- Ensure scope is never null string.
-*********************************************************************/
-
-const char *global_scope(void)
-{
- if (!smb_scope)
- set_global_scope("");
- return smb_scope;
-}
-
-static void free_netbios_names_array(void)
-{
- int i;
-
- for (i = 0; i < smb_num_netbios_names; i++)
- SAFE_FREE(smb_my_netbios_names[i]);
-
- SAFE_FREE(smb_my_netbios_names);
- smb_num_netbios_names = 0;
-}
-
-static bool allocate_my_netbios_names_array(size_t number)
-{
- free_netbios_names_array();
-
- smb_num_netbios_names = number + 1;
- smb_my_netbios_names = SMB_MALLOC_ARRAY( char *, smb_num_netbios_names );
-
- if (!smb_my_netbios_names)
- return False;
-
- memset(smb_my_netbios_names, '\0', sizeof(char *) * smb_num_netbios_names);
- return True;
-}
-
-static bool set_my_netbios_names(const char *name, int i)
-{
- SAFE_FREE(smb_my_netbios_names[i]);
-
- smb_my_netbios_names[i] = SMB_STRDUP(name);
- if (!smb_my_netbios_names[i])
- return False;
- strupper_m(smb_my_netbios_names[i]);
- return True;
-}
-
-/***********************************************************************
- Free memory allocated to global objects
-***********************************************************************/
-
-void gfree_names(void)
-{
- gfree_netbios_names();
- SAFE_FREE( smb_scope );
- free_netbios_names_array();
- free_local_machine_name();
-}
-
void gfree_all( void )
{
gfree_names();
@@ -161,87 +82,6 @@ void gfree_all( void )
gfree_debugsyms();
}
-const char *my_netbios_names(int i)
-{
- return smb_my_netbios_names[i];
-}
-
-bool set_netbios_aliases(const char **str_array)
-{
- size_t namecount;
-
- /* Work out the max number of netbios aliases that we have */
- for( namecount=0; str_array && (str_array[namecount] != NULL); namecount++ )
- ;
-
- if ( global_myname() && *global_myname())
- namecount++;
-
- /* Allocate space for the netbios aliases */
- if (!allocate_my_netbios_names_array(namecount))
- return False;
-
- /* Use the global_myname string first */
- namecount=0;
- if ( global_myname() && *global_myname()) {
- set_my_netbios_names( global_myname(), namecount );
- namecount++;
- }
-
- if (str_array) {
- size_t i;
- for ( i = 0; str_array[i] != NULL; i++) {
- size_t n;
- bool duplicate = False;
-
- /* Look for duplicates */
- for( n=0; n<namecount; n++ ) {
- if( strequal( str_array[i], my_netbios_names(n) ) ) {
- duplicate = True;
- break;
- }
- }
- if (!duplicate) {
- if (!set_my_netbios_names(str_array[i], namecount))
- return False;
- namecount++;
- }
- }
- }
- return True;
-}
-
-/****************************************************************************
- Common name initialization code.
-****************************************************************************/
-
-bool init_names(void)
-{
- int n;
-
- if (global_myname() == NULL || *global_myname() == '\0') {
- if (!set_global_myname(myhostname())) {
- DEBUG( 0, ( "init_names: malloc fail.\n" ) );
- return False;
- }
- }
-
- if (!set_netbios_aliases(lp_netbios_aliases())) {
- DEBUG( 0, ( "init_names: malloc fail.\n" ) );
- return False;
- }
-
- set_local_machine_name(global_myname(),false);
-
- DEBUG( 5, ("Netbios name list:-\n") );
- for( n=0; my_netbios_names(n); n++ ) {
- DEBUGADD( 5, ("my_netbios_names[%d]=\"%s\"\n",
- n, my_netbios_names(n) ) );
- }
-
- return( True );
-}
-
/*******************************************************************
Check if a file exists - call vfs_file_exist for samba files.
********************************************************************/
@@ -295,30 +135,10 @@ SMB_OFF_T get_file_size(char *file_name)
}
/*******************************************************************
- Return a string representing an attribute for a file.
-********************************************************************/
-
-char *attrib_string(uint16 mode)
-{
- fstring attrstr;
-
- attrstr[0] = 0;
-
- if (mode & aVOLID) fstrcat(attrstr,"V");
- if (mode & aDIR) fstrcat(attrstr,"D");
- if (mode & aARCH) fstrcat(attrstr,"A");
- if (mode & aHIDDEN) fstrcat(attrstr,"H");
- if (mode & aSYSTEM) fstrcat(attrstr,"S");
- if (mode & aRONLY) fstrcat(attrstr,"R");
-
- return talloc_strdup(talloc_tos(), attrstr);
-}
-
-/*******************************************************************
Show a smb message structure.
********************************************************************/
-void show_msg(char *buf)
+void show_msg(const char *buf)
{
int i;
int bcc=0;
@@ -355,7 +175,7 @@ void show_msg(char *buf)
if (DEBUGLEVEL < 50)
bcc = MIN(bcc, 512);
- dump_data(10, (uint8 *)smb_buf(buf), bcc);
+ dump_data(10, (const uint8 *)smb_buf_const(buf), bcc);
}
/*******************************************************************
@@ -407,7 +227,7 @@ ssize_t message_push_blob(uint8 **outbuf, DATA_BLOB blob)
size_t newlen = smb_len(*outbuf) + 4 + blob.length;
uint8 *tmp;
- if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, *outbuf, uint8, newlen))) {
+ if (!(tmp = talloc_realloc(NULL, *outbuf, uint8, newlen))) {
DEBUG(0, ("talloc failed\n"));
return -1;
}
@@ -586,7 +406,7 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
set_need_random_reseed();
/* tdb needs special fork handling */
- if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) {
+ if (tdb_reopen_all(parent_longlived ? 1 : 0) != 0) {
DEBUG(0,("tdb_reopen_all failed.\n"));
status = NT_STATUS_OPEN_FAILED;
goto done;
@@ -611,149 +431,6 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
return status;
}
-#if defined(PARANOID_MALLOC_CHECKER)
-
-/****************************************************************************
- Internal malloc wrapper. Externally visible.
-****************************************************************************/
-
-void *malloc_(size_t size)
-{
- if (size == 0) {
- return NULL;
- }
-#undef malloc
- return malloc(size);
-#define malloc(s) __ERROR_DONT_USE_MALLOC_DIRECTLY
-}
-
-/****************************************************************************
- Internal calloc wrapper. Not externally visible.
-****************************************************************************/
-
-static void *calloc_(size_t count, size_t size)
-{
- if (size == 0 || count == 0) {
- return NULL;
- }
-#undef calloc
- return calloc(count, size);
-#define calloc(n,s) __ERROR_DONT_USE_CALLOC_DIRECTLY
-}
-
-/****************************************************************************
- Internal realloc wrapper. Not externally visible.
-****************************************************************************/
-
-static void *realloc_(void *ptr, size_t size)
-{
-#undef realloc
- return realloc(ptr, size);
-#define realloc(p,s) __ERROR_DONT_USE_RELLOC_DIRECTLY
-}
-
-#endif /* PARANOID_MALLOC_CHECKER */
-
-/****************************************************************************
- Type-safe memalign
-****************************************************************************/
-
-void *memalign_array(size_t el_size, size_t align, unsigned int count)
-{
- if (count >= MAX_ALLOC_SIZE/el_size) {
- return NULL;
- }
-
- return sys_memalign(align, el_size*count);
-}
-
-/****************************************************************************
- Type-safe calloc.
-****************************************************************************/
-
-void *calloc_array(size_t size, size_t nmemb)
-{
- if (nmemb >= MAX_ALLOC_SIZE/size) {
- return NULL;
- }
- if (size == 0 || nmemb == 0) {
- return NULL;
- }
-#if defined(PARANOID_MALLOC_CHECKER)
- return calloc_(nmemb, size);
-#else
- return calloc(nmemb, size);
-#endif
-}
-
-/****************************************************************************
- Expand a pointer to be a particular size.
- Note that this version of Realloc has an extra parameter that decides
- whether to free the passed in storage on allocation failure or if the
- new size is zero.
-
- This is designed for use in the typical idiom of :
-
- p = SMB_REALLOC(p, size)
- if (!p) {
- return error;
- }
-
- and not to have to keep track of the old 'p' contents to free later, nor
- to worry if the size parameter was zero. In the case where NULL is returned
- we guarentee that p has been freed.
-
- If free later semantics are desired, then pass 'free_old_on_error' as False which
- guarentees that the old contents are not freed on error, even if size == 0. To use
- this idiom use :
-
- tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size);
- if (!tmp) {
- SAFE_FREE(p);
- return error;
- } else {
- p = tmp;
- }
-
- Changes were instigated by Coverity error checking. JRA.
-****************************************************************************/
-
-void *Realloc(void *p, size_t size, bool free_old_on_error)
-{
- void *ret=NULL;
-
- if (size == 0) {
- if (free_old_on_error) {
- SAFE_FREE(p);
- }
- DEBUG(2,("Realloc asked for 0 bytes\n"));
- return NULL;
- }
-
-#if defined(PARANOID_MALLOC_CHECKER)
- if (!p) {
- ret = (void *)malloc_(size);
- } else {
- ret = (void *)realloc_(p,size);
- }
-#else
- if (!p) {
- ret = (void *)malloc(size);
- } else {
- ret = (void *)realloc(p,size);
- }
-#endif
-
- if (!ret) {
- if (free_old_on_error && p) {
- SAFE_FREE(p);
- }
- DEBUG(0,("Memory allocation error: failed to expand to %d bytes\n",(int)size));
- }
-
- return(ret);
-}
-
/****************************************************************************
(Hopefully) efficient array append.
****************************************************************************/
@@ -1318,7 +995,7 @@ bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensit
}
} else {
if((case_sensitive && (strcmp(last_component, namelist->name) == 0))||
- (!case_sensitive && (StrCaseCmp(last_component, namelist->name) == 0))) {
+ (!case_sensitive && (strcasecmp_m(last_component, namelist->name) == 0))) {
DEBUG(8,("is_in_path: match succeeded\n"));
return True;
}
@@ -1334,25 +1011,31 @@ bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensit
passing to is_in_path(). We do this for
speed so we can pre-parse all the names in the list
and don't do it for each call to is_in_path().
- namelist is modified here and is assumed to be
- a copy owned by the caller.
We also check if the entry contains a wildcard to
remove a potentially expensive call to mask_match
if possible.
********************************************************************/
-void set_namearray(name_compare_entry **ppname_array, const char *namelist)
+void set_namearray(name_compare_entry **ppname_array, const char *namelist_in)
{
char *name_end;
- char *nameptr = (char *)namelist;
+ char *namelist;
+ char *nameptr;
int num_entries = 0;
int i;
(*ppname_array) = NULL;
- if((nameptr == NULL ) || ((nameptr != NULL) && (*nameptr == '\0')))
+ if((namelist_in == NULL ) || ((namelist_in != NULL) && (*namelist_in == '\0')))
return;
+ namelist = talloc_strdup(talloc_tos(), namelist_in);
+ if (namelist == NULL) {
+ DEBUG(0,("set_namearray: talloc fail\n"));
+ return;
+ }
+ nameptr = namelist;
+
/* We need to make two passes over the string. The
first to count the number of elements, the second
to split it.
@@ -1378,16 +1061,19 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist)
num_entries++;
}
- if(num_entries == 0)
+ if(num_entries == 0) {
+ talloc_free(namelist);
return;
+ }
if(( (*ppname_array) = SMB_MALLOC_ARRAY(name_compare_entry, num_entries + 1)) == NULL) {
DEBUG(0,("set_namearray: malloc fail\n"));
+ talloc_free(namelist);
return;
}
/* Now copy out the names */
- nameptr = (char *)namelist;
+ nameptr = namelist;
i = 0;
while(*nameptr) {
if ( *nameptr == '/' ) {
@@ -1409,6 +1095,7 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist)
(*ppname_array)[i].is_wild = ms_has_wild(nameptr);
if(((*ppname_array)[i].name = SMB_STRDUP(nameptr)) == NULL) {
DEBUG(0,("set_namearray: malloc fail (1)\n"));
+ talloc_free(namelist);
return;
}
@@ -1419,25 +1106,10 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist)
(*ppname_array)[i].name = NULL;
+ talloc_free(namelist);
return;
}
-/****************************************************************************
- Routine to free a namearray.
-****************************************************************************/
-
-void free_namearray(name_compare_entry *name_array)
-{
- int i;
-
- if(name_array == NULL)
- return;
-
- for(i=0; name_array[i].name!=NULL; i++)
- SAFE_FREE(name_array[i].name);
- SAFE_FREE(name_array);
-}
-
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_LOCKING
@@ -1635,8 +1307,9 @@ const char *tab_depth(int level, int depth)
int str_checksum(const char *s)
{
- TDB_DATA key = string_tdb_data(s);
- return tdb_jenkins_hash(&key);
+ if (s == NULL)
+ return 0;
+ return hash(s, strlen(s), 0);
}
/*****************************************************************
@@ -1785,6 +1458,22 @@ char *myhostname(void)
return ret;
}
+/*****************************************************************
+ Get local hostname and cache result.
+*****************************************************************/
+
+char *myhostname_upper(void)
+{
+ char *name;
+ static char *ret;
+ if (ret == NULL) {
+ name = get_myname(talloc_tos());
+ ret = strupper_talloc(NULL, name);
+ talloc_free(name);
+ }
+ return ret;
+}
+
/**
* @brief Returns an absolute path to a file concatenating the provided
* @a rootpath and @a basename
@@ -1843,45 +1532,6 @@ char *pid_path(const char *name)
}
/**
- * @brief Returns an absolute path to a file in the Samba lib directory.
- *
- * @param name File to find, relative to LIBDIR.
- *
- * @retval Pointer to a string containing the full path.
- **/
-
-char *lib_path(const char *name)
-{
- return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_LIBDIR(), name);
-}
-
-/**
- * @brief Returns an absolute path to a file in the Samba modules directory.
- *
- * @param name File to find, relative to MODULESDIR.
- *
- * @retval Pointer to a string containing the full path.
- **/
-
-char *modules_path(const char *name)
-{
- return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_MODULESDIR(), name);
-}
-
-/**
- * @brief Returns an absolute path to a file in the Samba data directory.
- *
- * @param name File to find, relative to CODEPAGEDIR.
- *
- * @retval Pointer to a talloc'ed string containing the full path.
- **/
-
-char *data_path(const char *name)
-{
- return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_CODEPAGEDIR(), name);
-}
-
-/**
* @brief Returns an absolute path to a file in the Samba state directory.
*
* @param name File to find, relative to STATEDIR.
@@ -1907,17 +1557,6 @@ char *cache_path(const char *name)
return xx_path(name, lp_cachedir());
}
-/**
- * @brief Returns the platform specific shared library extension.
- *
- * @retval Pointer to a const char * containing the extension.
- **/
-
-const char *shlib_ext(void)
-{
- return get_dyn_SHLIBEXT();
-}
-
/*******************************************************************
Given a filename - get its directory name
********************************************************************/
@@ -1942,7 +1581,7 @@ bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
len = p-dir;
- if (!(*parent = (char *)TALLOC_MEMDUP(mem_ctx, dir, len+1))) {
+ if (!(*parent = (char *)talloc_memdup(mem_ctx, dir, len+1))) {
return False;
}
(*parent)[len] = '\0';
@@ -2211,7 +1850,7 @@ bool name_to_fqdn(fstring fqdn, const char *name)
}
}
}
- if (full && (StrCaseCmp(full, "localhost.localdomain") == 0)) {
+ if (full && (strcasecmp_m(full, "localhost.localdomain") == 0)) {
DEBUG(1, ("WARNING: your /etc/hosts file may be broken!\n"));
DEBUGADD(1, (" Specifing the machine hostname for address 127.0.0.1 may lead\n"));
DEBUGADD(1, (" to Kerberos authentication problems as localhost.localdomain\n"));
@@ -2303,6 +1942,7 @@ struct server_id pid_to_procid(pid_t pid)
{
struct server_id result;
result.pid = pid;
+ result.task_id = 0;
result.unique_id = my_unique_id;
result.vnn = my_vnn;
return result;
@@ -2317,6 +1957,8 @@ bool procid_equal(const struct server_id *p1, const struct server_id *p2)
{
if (p1->pid != p2->pid)
return False;
+ if (p1->task_id != p2->task_id)
+ return False;
if (p1->vnn != p2->vnn)
return False;
return True;
@@ -2332,6 +1974,8 @@ bool procid_is_me(const struct server_id *pid)
{
if (pid->pid != sys_getpid())
return False;
+ if (pid->task_id != 0)
+ return False;
if (pid->vnn != my_vnn)
return False;
return True;
@@ -2340,52 +1984,45 @@ bool procid_is_me(const struct server_id *pid)
struct server_id interpret_pid(const char *pid_string)
{
struct server_id result;
- int pid;
- unsigned int vnn;
- if (sscanf(pid_string, "%u:%d", &vnn, &pid) == 2) {
+ unsigned long long pid;
+ unsigned int vnn, task_id = 0;
+
+ ZERO_STRUCT(result);
+
+ /* We accept various forms with 1, 2 or 3 component forms
+ * because the server_id_str() can print different forms, and
+ * we want backwards compatibility for scripts that may call
+ * smbclient. */
+ if (sscanf(pid_string, "%u:%llu.%u", &vnn, &pid, &task_id) == 3) {
result.vnn = vnn;
result.pid = pid;
- }
- else if (sscanf(pid_string, "%d", &pid) == 1) {
+ result.task_id = task_id;
+ } else if (sscanf(pid_string, "%u:%llu", &vnn, &pid) == 2) {
+ result.vnn = vnn;
+ result.pid = pid;
+ result.task_id = 0;
+ } else if (sscanf(pid_string, "%llu.%u", &pid, &task_id) == 2) {
result.vnn = get_my_vnn();
result.pid = pid;
- }
- else {
+ result.task_id = task_id;
+ } else if (sscanf(pid_string, "%llu", &pid) == 1) {
+ result.vnn = get_my_vnn();
+ result.pid = pid;
+ } else {
result.vnn = NONCLUSTER_VNN;
- result.pid = -1;
+ result.pid = (uint64_t)-1;
}
- /* Assigning to result.pid may have overflowed
- Map negative pid to -1: i.e. error */
- if (result.pid < 0) {
- result.pid = -1;
- }
- result.unique_id = 0;
return result;
}
-char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid)
-{
- if (pid->vnn == NONCLUSTER_VNN) {
- return talloc_asprintf(mem_ctx,
- "%d",
- (int)pid->pid);
- }
- else {
- return talloc_asprintf(mem_ctx,
- "%u:%d",
- (unsigned)pid->vnn,
- (int)pid->pid);
- }
-}
-
char *procid_str_static(const struct server_id *pid)
{
- return procid_str(talloc_tos(), pid);
+ return server_id_str(talloc_tos(), pid);
}
bool procid_valid(const struct server_id *pid)
{
- return (pid->pid != -1);
+ return (pid->pid != (uint64_t)-1);
}
bool procid_is_local(const struct server_id *pid)
@@ -2519,111 +2156,6 @@ void split_domain_user(TALLOC_CTX *mem_ctx,
}
}
-#if 0
-
-Disable these now we have checked all code paths and ensured
-NULL returns on zero request. JRA.
-
-/****************************************************************
- talloc wrapper functions that guarentee a null pointer return
- if size == 0.
-****************************************************************/
-
-#ifndef MAX_TALLOC_SIZE
-#define MAX_TALLOC_SIZE 0x10000000
-#endif
-
-/*
- * talloc and zero memory.
- * - returns NULL if size is zero.
- */
-
-void *_talloc_zero_zeronull(const void *ctx, size_t size, const char *name)
-{
- void *p;
-
- if (size == 0) {
- return NULL;
- }
-
- p = talloc_named_const(ctx, size, name);
-
- if (p) {
- memset(p, '\0', size);
- }
-
- return p;
-}
-
-/*
- * memdup with a talloc.
- * - returns NULL if size is zero.
- */
-
-void *_talloc_memdup_zeronull(const void *t, const void *p, size_t size, const char *name)
-{
- void *newp;
-
- if (size == 0) {
- return NULL;
- }
-
- newp = talloc_named_const(t, size, name);
- if (newp) {
- memcpy(newp, p, size);
- }
-
- return newp;
-}
-
-/*
- * alloc an array, checking for integer overflow in the array size.
- * - returns NULL if count or el_size are zero.
- */
-
-void *_talloc_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name)
-{
- if (count >= MAX_TALLOC_SIZE/el_size) {
- return NULL;
- }
-
- if (el_size == 0 || count == 0) {
- return NULL;
- }
-
- return talloc_named_const(ctx, el_size * count, name);
-}
-
-/*
- * alloc an zero array, checking for integer overflow in the array size
- * - returns NULL if count or el_size are zero.
- */
-
-void *_talloc_zero_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name)
-{
- if (count >= MAX_TALLOC_SIZE/el_size) {
- return NULL;
- }
-
- if (el_size == 0 || count == 0) {
- return NULL;
- }
-
- return _talloc_zero(ctx, el_size * count, name);
-}
-
-/*
- * Talloc wrapper that returns NULL if size == 0.
- */
-void *talloc_zeronull(const void *context, size_t size, const char *name)
-{
- if (size == 0) {
- return NULL;
- }
- return talloc_named_const(context, size, name);
-}
-#endif
-
/****************************************************************
strip off leading '\\' from a hostname
****************************************************************/
@@ -2672,3 +2204,37 @@ int timeval_to_msec(struct timeval t)
{
return t.tv_sec * 1000 + (t.tv_usec+999) / 1000;
}
+
+/*******************************************************************
+ Check a given DOS pathname is valid for a share.
+********************************************************************/
+
+char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname)
+{
+ char *ptr = NULL;
+
+ if (!dos_pathname) {
+ return NULL;
+ }
+
+ ptr = talloc_strdup(ctx, dos_pathname);
+ if (!ptr) {
+ return NULL;
+ }
+ /* Convert any '\' paths to '/' */
+ unix_format(ptr);
+ ptr = unix_clean_name(ctx, ptr);
+ if (!ptr) {
+ return NULL;
+ }
+
+ /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */
+ if (strlen(ptr) > 2 && ptr[1] == ':' && ptr[0] != '/')
+ ptr += 2;
+
+ /* Only absolute paths allowed. */
+ if (*ptr != '/')
+ return NULL;
+
+ return ptr;
+}
diff --git a/source3/lib/util_builtin.c b/source3/lib/util_builtin.c
index e1b990619b4..b370a76c691 100644
--- a/source3/lib/util_builtin.c
+++ b/source3/lib/util_builtin.c
@@ -18,7 +18,6 @@
*/
#include "includes.h"
-#include "passdb.h"
#include "../libcli/security/security.h"
struct rid_name_map {
diff --git a/source3/lib/util_cmdline.c b/source3/lib/util_cmdline.c
index cb0b79a5d30..39f136821ce 100644
--- a/source3/lib/util_cmdline.c
+++ b/source3/lib/util_cmdline.c
@@ -34,7 +34,7 @@ struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx)
{
struct user_auth_info *result;
- result = TALLOC_ZERO_P(mem_ctx, struct user_auth_info);
+ result = talloc_zero(mem_ctx, struct user_auth_info);
if (result == NULL) {
return NULL;
}
@@ -228,7 +228,7 @@ bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_inf
return false;
}
- if (asprintf(&account, "%s$@%s", global_myname(), lp_realm()) < 0) {
+ if (asprintf(&account, "%s$@%s", lp_netbios_name(), lp_realm()) < 0) {
return false;
}
diff --git a/source3/lib/util_malloc.c b/source3/lib/util_malloc.c
new file mode 100644
index 00000000000..c052adc41bb
--- /dev/null
+++ b/source3/lib/util_malloc.c
@@ -0,0 +1,171 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 2001-2007
+ Copyright (C) Simo Sorce 2001
+ Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
+ Copyright (C) James Peach 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+
+/* Max allowable allococation - 256mb - 0x10000000 */
+#define MAX_ALLOC_SIZE (1024*1024*256)
+
+#if defined(PARANOID_MALLOC_CHECKER)
+
+/****************************************************************************
+ Internal malloc wrapper. Externally visible.
+****************************************************************************/
+
+void *malloc_(size_t size)
+{
+ if (size == 0) {
+ return NULL;
+ }
+#undef malloc
+ return malloc(size);
+#define malloc(s) __ERROR_DONT_USE_MALLOC_DIRECTLY
+}
+
+/****************************************************************************
+ Internal calloc wrapper. Not externally visible.
+****************************************************************************/
+
+static void *calloc_(size_t count, size_t size)
+{
+ if (size == 0 || count == 0) {
+ return NULL;
+ }
+#undef calloc
+ return calloc(count, size);
+#define calloc(n,s) __ERROR_DONT_USE_CALLOC_DIRECTLY
+}
+
+/****************************************************************************
+ Internal realloc wrapper. Not externally visible.
+****************************************************************************/
+
+static void *realloc_(void *ptr, size_t size)
+{
+#undef realloc
+ return realloc(ptr, size);
+#define realloc(p,s) __ERROR_DONT_USE_RELLOC_DIRECTLY
+}
+
+#endif /* PARANOID_MALLOC_CHECKER */
+
+/****************************************************************************
+ Type-safe memalign
+****************************************************************************/
+
+void *memalign_array(size_t el_size, size_t align, unsigned int count)
+{
+ if (count >= MAX_ALLOC_SIZE/el_size) {
+ return NULL;
+ }
+
+ return sys_memalign(align, el_size*count);
+}
+
+/****************************************************************************
+ Type-safe calloc.
+****************************************************************************/
+
+void *calloc_array(size_t size, size_t nmemb)
+{
+ if (nmemb >= MAX_ALLOC_SIZE/size) {
+ return NULL;
+ }
+ if (size == 0 || nmemb == 0) {
+ return NULL;
+ }
+#if defined(PARANOID_MALLOC_CHECKER)
+ return calloc_(nmemb, size);
+#else
+ return calloc(nmemb, size);
+#endif
+}
+
+/****************************************************************************
+ Expand a pointer to be a particular size.
+ Note that this version of Realloc has an extra parameter that decides
+ whether to free the passed in storage on allocation failure or if the
+ new size is zero.
+
+ This is designed for use in the typical idiom of :
+
+ p = SMB_REALLOC(p, size)
+ if (!p) {
+ return error;
+ }
+
+ and not to have to keep track of the old 'p' contents to free later, nor
+ to worry if the size parameter was zero. In the case where NULL is returned
+ we guarentee that p has been freed.
+
+ If free later semantics are desired, then pass 'free_old_on_error' as False which
+ guarentees that the old contents are not freed on error, even if size == 0. To use
+ this idiom use :
+
+ tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size);
+ if (!tmp) {
+ SAFE_FREE(p);
+ return error;
+ } else {
+ p = tmp;
+ }
+
+ Changes were instigated by Coverity error checking. JRA.
+****************************************************************************/
+
+void *Realloc(void *p, size_t size, bool free_old_on_error)
+{
+ void *ret=NULL;
+
+ if (size == 0) {
+ if (free_old_on_error) {
+ SAFE_FREE(p);
+ }
+ DEBUG(2,("Realloc asked for 0 bytes\n"));
+ return NULL;
+ }
+
+#if defined(PARANOID_MALLOC_CHECKER)
+ if (!p) {
+ ret = (void *)malloc_(size);
+ } else {
+ ret = (void *)realloc_(p,size);
+ }
+#else
+ if (!p) {
+ ret = (void *)malloc(size);
+ } else {
+ ret = (void *)realloc(p,size);
+ }
+#endif
+
+ if (!ret) {
+ if (free_old_on_error && p) {
+ SAFE_FREE(p);
+ }
+ DEBUG(0,("Memory allocation error: failed to expand to %d bytes\n",(int)size));
+ }
+
+ return(ret);
+}
+
diff --git a/source3/lib/util_names.c b/source3/lib/util_names.c
index bd6e5c12026..0e128eab1cd 100644
--- a/source3/lib/util_names.c
+++ b/source3/lib/util_names.c
@@ -6,7 +6,7 @@
Copyright (C) Simo Sorce 2001
Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
Copyright (C) James Peach 2006
- Copyright (C) Andrew Bartlett 2010
+ Copyright (C) Andrew Bartlett 2010-2011
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
@@ -24,45 +24,131 @@
#include "includes.h"
-static char *smb_myname;
-static char *smb_myworkgroup;
-
/***********************************************************************
- Allocate and set myname. Ensure upper case.
+ Definitions for all names.
***********************************************************************/
-bool set_global_myname(const char *myname)
+static int smb_num_netbios_names;
+static char **smb_my_netbios_names;
+
+static void free_netbios_names_array(void)
+{
+ int i;
+
+ for (i = 0; i < smb_num_netbios_names; i++)
+ SAFE_FREE(smb_my_netbios_names[i]);
+
+ SAFE_FREE(smb_my_netbios_names);
+ smb_num_netbios_names = 0;
+}
+
+static bool allocate_my_netbios_names_array(size_t number)
{
- SAFE_FREE(smb_myname);
- smb_myname = SMB_STRDUP(myname);
- if (!smb_myname)
+ free_netbios_names_array();
+
+ smb_num_netbios_names = number + 1;
+ smb_my_netbios_names = SMB_MALLOC_ARRAY( char *, smb_num_netbios_names );
+
+ if (!smb_my_netbios_names)
return False;
- strupper_m(smb_myname);
+
+ memset(smb_my_netbios_names, '\0', sizeof(char *) * smb_num_netbios_names);
return True;
}
-const char *global_myname(void)
+static bool set_my_netbios_names(const char *name, int i)
{
- return smb_myname;
+ SAFE_FREE(smb_my_netbios_names[i]);
+
+ smb_my_netbios_names[i] = SMB_STRDUP(name);
+ if (!smb_my_netbios_names[i])
+ return False;
+ strupper_m(smb_my_netbios_names[i]);
+ return True;
}
/***********************************************************************
- Allocate and set myworkgroup. Ensure upper case.
+ Free memory allocated to global objects
***********************************************************************/
-bool set_global_myworkgroup(const char *myworkgroup)
+void gfree_names(void)
+{
+ free_netbios_names_array();
+ free_local_machine_name();
+}
+
+const char *my_netbios_names(int i)
+{
+ return smb_my_netbios_names[i];
+}
+
+bool set_netbios_aliases(const char **str_array)
{
- SAFE_FREE(smb_myworkgroup);
- smb_myworkgroup = SMB_STRDUP(myworkgroup);
- if (!smb_myworkgroup)
+ size_t namecount;
+
+ /* Work out the max number of netbios aliases that we have */
+ for( namecount=0; str_array && (str_array[namecount] != NULL); namecount++ )
+ ;
+
+ if ( lp_netbios_name() && *lp_netbios_name())
+ namecount++;
+
+ /* Allocate space for the netbios aliases */
+ if (!allocate_my_netbios_names_array(namecount))
return False;
- strupper_m(smb_myworkgroup);
+
+ /* Use the global_myname string first */
+ namecount=0;
+ if ( lp_netbios_name() && *lp_netbios_name()) {
+ set_my_netbios_names( lp_netbios_name(), namecount );
+ namecount++;
+ }
+
+ if (str_array) {
+ size_t i;
+ for ( i = 0; str_array[i] != NULL; i++) {
+ size_t n;
+ bool duplicate = False;
+
+ /* Look for duplicates */
+ for( n=0; n<namecount; n++ ) {
+ if( strequal( str_array[i], my_netbios_names(n) ) ) {
+ duplicate = True;
+ break;
+ }
+ }
+ if (!duplicate) {
+ if (!set_my_netbios_names(str_array[i], namecount))
+ return False;
+ namecount++;
+ }
+ }
+ }
return True;
}
-const char *lp_workgroup(void)
+/****************************************************************************
+ Common name initialization code.
+****************************************************************************/
+
+bool init_names(void)
{
- return smb_myworkgroup;
+ int n;
+
+ if (!set_netbios_aliases(lp_netbios_aliases())) {
+ DEBUG( 0, ( "init_names: malloc fail.\n" ) );
+ return False;
+ }
+
+ set_local_machine_name(lp_netbios_name(),false);
+
+ DEBUG( 5, ("Netbios name list:-\n") );
+ for( n=0; my_netbios_names(n); n++ ) {
+ DEBUGADD( 5, ("my_netbios_names[%d]=\"%s\"\n",
+ n, my_netbios_names(n) ) );
+ }
+
+ return( True );
}
/******************************************************************
@@ -75,11 +161,6 @@ const char *get_global_sam_name(void)
if (IS_DC) {
return lp_workgroup();
}
- return global_myname();
+ return lp_netbios_name();
}
-void gfree_netbios_names(void)
-{
- SAFE_FREE( smb_myname );
- SAFE_FREE( smb_myworkgroup );
-}
diff --git a/source3/lib/util_nttoken.c b/source3/lib/util_nttoken.c
index 2fd0f088ab7..ffa858d7794 100644
--- a/source3/lib/util_nttoken.c
+++ b/source3/lib/util_nttoken.c
@@ -39,7 +39,7 @@ struct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_t
if (!ptoken)
return NULL;
- token = TALLOC_ZERO_P(mem_ctx, struct security_token);
+ token = talloc_zero(mem_ctx, struct security_token);
if (token == NULL) {
DEBUG(0, ("talloc failed\n"));
return NULL;
@@ -80,7 +80,7 @@ NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
- token = TALLOC_ZERO_P(mem_ctx, struct security_token);
+ token = talloc_zero(mem_ctx, struct security_token);
NT_STATUS_HAVE_NO_MEMORY(token);
for (i=0; i < token_1->num_sids; i++) {
diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c
index ef46a38f8aa..f080d3dfb0c 100644
--- a/source3/lib/util_sid.c
+++ b/source3/lib/util_sid.c
@@ -121,7 +121,7 @@ char *sid_binstring_hex(const struct dom_sid *sid)
if (!buf)
return NULL;
sid_linearize(buf, len, sid);
- hex_encode(buf, len, &s);
+ hex_encode((const unsigned char *)buf, len, &s);
free(buf);
return s;
}
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 71f6a8f29c9..9b8632b181a 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -24,158 +24,9 @@
#include "memcache.h"
#include "../lib/async_req/async_sock.h"
#include "../lib/util/select.h"
-#include "interfaces.h"
-
-/****************************************************************************
- Get a port number in host byte order from a sockaddr_storage.
-****************************************************************************/
-
-uint16_t get_sockaddr_port(const struct sockaddr_storage *pss)
-{
- uint16_t port = 0;
-
- if (pss->ss_family != AF_INET) {
-#if defined(HAVE_IPV6)
- /* IPv6 */
- const struct sockaddr_in6 *sa6 =
- (const struct sockaddr_in6 *)pss;
- port = ntohs(sa6->sin6_port);
-#endif
- } else {
- const struct sockaddr_in *sa =
- (const struct sockaddr_in *)pss;
- port = ntohs(sa->sin_port);
- }
- return port;
-}
-
-/****************************************************************************
- Print out an IPv4 or IPv6 address from a struct sockaddr_storage.
-****************************************************************************/
-
-static char *print_sockaddr_len(char *dest,
- size_t destlen,
- const struct sockaddr *psa,
- socklen_t psalen)
-{
- if (destlen > 0) {
- dest[0] = '\0';
- }
- (void)sys_getnameinfo(psa,
- psalen,
- dest, destlen,
- NULL, 0,
- NI_NUMERICHOST);
- return dest;
-}
-
-/****************************************************************************
- Print out an IPv4 or IPv6 address from a struct sockaddr_storage.
-****************************************************************************/
-
-char *print_sockaddr(char *dest,
- size_t destlen,
- const struct sockaddr_storage *psa)
-{
- return print_sockaddr_len(dest, destlen, (struct sockaddr *)psa,
- sizeof(struct sockaddr_storage));
-}
-
-/****************************************************************************
- Print out a canonical IPv4 or IPv6 address from a struct sockaddr_storage.
-****************************************************************************/
-
-char *print_canonical_sockaddr(TALLOC_CTX *ctx,
- const struct sockaddr_storage *pss)
-{
- char addr[INET6_ADDRSTRLEN];
- char *dest = NULL;
- int ret;
-
- /* Linux getnameinfo() man pages says port is unitialized if
- service name is NULL. */
-
- ret = sys_getnameinfo((const struct sockaddr *)pss,
- sizeof(struct sockaddr_storage),
- addr, sizeof(addr),
- NULL, 0,
- NI_NUMERICHOST);
- if (ret != 0) {
- return NULL;
- }
-
- if (pss->ss_family != AF_INET) {
-#if defined(HAVE_IPV6)
- dest = talloc_asprintf(ctx, "[%s]", addr);
-#else
- return NULL;
-#endif
- } else {
- dest = talloc_asprintf(ctx, "%s", addr);
- }
-
- return dest;
-}
-
-/****************************************************************************
- Return the string of an IP address (IPv4 or IPv6).
-****************************************************************************/
-
-static const char *get_socket_addr(int fd, char *addr_buf, size_t addr_len)
-{
- struct sockaddr_storage sa;
- socklen_t length = sizeof(sa);
-
- /* Ok, returning a hard coded IPv4 address
- * is bogus, but it's just as bogus as a
- * zero IPv6 address. No good choice here.
- */
-
- strlcpy(addr_buf, "0.0.0.0", addr_len);
-
- if (fd == -1) {
- return addr_buf;
- }
-
- if (getsockname(fd, (struct sockaddr *)&sa, &length) < 0) {
- DEBUG(0,("getsockname failed. Error was %s\n",
- strerror(errno) ));
- return addr_buf;
- }
-
- return print_sockaddr_len(addr_buf, addr_len, (struct sockaddr *)&sa, length);
-}
-
-/****************************************************************************
- Return the port number we've bound to on a socket.
-****************************************************************************/
-
-int get_socket_port(int fd)
-{
- struct sockaddr_storage sa;
- socklen_t length = sizeof(sa);
-
- if (fd == -1) {
- return -1;
- }
-
- if (getsockname(fd, (struct sockaddr *)&sa, &length) < 0) {
- int level = (errno == ENOTCONN) ? 2 : 0;
- DEBUG(level, ("getsockname failed. Error was %s\n",
- strerror(errno)));
- return -1;
- }
-
-#if defined(HAVE_IPV6)
- if (sa.ss_family == AF_INET6) {
- return ntohs(((struct sockaddr_in6 *)&sa)->sin6_port);
- }
-#endif
- if (sa.ss_family == AF_INET) {
- return ntohs(((struct sockaddr_in *)&sa)->sin_port);
- }
- return -1;
-}
+#include "lib/socket/interfaces.h"
+#include "../lib/util/tevent_unix.h"
+#include "../lib/util/tevent_ntstatus.h"
const char *client_name(int fd)
{
@@ -187,11 +38,6 @@ const char *client_addr(int fd, char *addr, size_t addrlen)
return get_peer_addr(fd,addr,addrlen);
}
-const char *client_socket_addr(int fd, char *addr, size_t addr_len)
-{
- return get_socket_addr(fd, addr, addr_len);
-}
-
#if 0
/* Not currently used. JRA. */
int client_socket_port(int fd)
@@ -232,166 +78,6 @@ bool is_a_socket(int fd)
return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
}
-enum SOCK_OPT_TYPES {OPT_BOOL,OPT_INT,OPT_ON};
-
-typedef struct smb_socket_option {
- const char *name;
- int level;
- int option;
- int value;
- int opttype;
-} smb_socket_option;
-
-static const smb_socket_option socket_options[] = {
- {"SO_KEEPALIVE", SOL_SOCKET, SO_KEEPALIVE, 0, OPT_BOOL},
- {"SO_REUSEADDR", SOL_SOCKET, SO_REUSEADDR, 0, OPT_BOOL},
- {"SO_BROADCAST", SOL_SOCKET, SO_BROADCAST, 0, OPT_BOOL},
-#ifdef TCP_NODELAY
- {"TCP_NODELAY", IPPROTO_TCP, TCP_NODELAY, 0, OPT_BOOL},
-#endif
-#ifdef TCP_KEEPCNT
- {"TCP_KEEPCNT", IPPROTO_TCP, TCP_KEEPCNT, 0, OPT_INT},
-#endif
-#ifdef TCP_KEEPIDLE
- {"TCP_KEEPIDLE", IPPROTO_TCP, TCP_KEEPIDLE, 0, OPT_INT},
-#endif
-#ifdef TCP_KEEPINTVL
- {"TCP_KEEPINTVL", IPPROTO_TCP, TCP_KEEPINTVL, 0, OPT_INT},
-#endif
-#ifdef IPTOS_LOWDELAY
- {"IPTOS_LOWDELAY", IPPROTO_IP, IP_TOS, IPTOS_LOWDELAY, OPT_ON},
-#endif
-#ifdef IPTOS_THROUGHPUT
- {"IPTOS_THROUGHPUT", IPPROTO_IP, IP_TOS, IPTOS_THROUGHPUT, OPT_ON},
-#endif
-#ifdef SO_REUSEPORT
- {"SO_REUSEPORT", SOL_SOCKET, SO_REUSEPORT, 0, OPT_BOOL},
-#endif
-#ifdef SO_SNDBUF
- {"SO_SNDBUF", SOL_SOCKET, SO_SNDBUF, 0, OPT_INT},
-#endif
-#ifdef SO_RCVBUF
- {"SO_RCVBUF", SOL_SOCKET, SO_RCVBUF, 0, OPT_INT},
-#endif
-#ifdef SO_SNDLOWAT
- {"SO_SNDLOWAT", SOL_SOCKET, SO_SNDLOWAT, 0, OPT_INT},
-#endif
-#ifdef SO_RCVLOWAT
- {"SO_RCVLOWAT", SOL_SOCKET, SO_RCVLOWAT, 0, OPT_INT},
-#endif
-#ifdef SO_SNDTIMEO
- {"SO_SNDTIMEO", SOL_SOCKET, SO_SNDTIMEO, 0, OPT_INT},
-#endif
-#ifdef SO_RCVTIMEO
- {"SO_RCVTIMEO", SOL_SOCKET, SO_RCVTIMEO, 0, OPT_INT},
-#endif
-#ifdef TCP_FASTACK
- {"TCP_FASTACK", IPPROTO_TCP, TCP_FASTACK, 0, OPT_INT},
-#endif
-#ifdef TCP_QUICKACK
- {"TCP_QUICKACK", IPPROTO_TCP, TCP_QUICKACK, 0, OPT_BOOL},
-#endif
-#ifdef TCP_KEEPALIVE_THRESHOLD
- {"TCP_KEEPALIVE_THRESHOLD", IPPROTO_TCP, TCP_KEEPALIVE_THRESHOLD, 0, OPT_INT},
-#endif
-#ifdef TCP_KEEPALIVE_ABORT_THRESHOLD
- {"TCP_KEEPALIVE_ABORT_THRESHOLD", IPPROTO_TCP, TCP_KEEPALIVE_ABORT_THRESHOLD, 0, OPT_INT},
-#endif
- {NULL,0,0,0,0}};
-
-/****************************************************************************
- Print socket options.
-****************************************************************************/
-
-static void print_socket_options(int s)
-{
- int value;
- socklen_t vlen = 4;
- const smb_socket_option *p = &socket_options[0];
-
- /* wrapped in if statement to prevent streams
- * leak in SCO Openserver 5.0 */
- /* reported on samba-technical --jerry */
- if ( DEBUGLEVEL >= 5 ) {
- DEBUG(5,("Socket options:\n"));
- for (; p->name != NULL; p++) {
- if (getsockopt(s, p->level, p->option,
- (void *)&value, &vlen) == -1) {
- DEBUGADD(5,("\tCould not test socket option %s.\n",
- p->name));
- } else {
- DEBUGADD(5,("\t%s = %d\n",
- p->name,value));
- }
- }
- }
- }
-
-/****************************************************************************
- Set user socket options.
-****************************************************************************/
-
-void set_socket_options(int fd, const char *options)
-{
- TALLOC_CTX *ctx = talloc_stackframe();
- char *tok;
-
- while (next_token_talloc(ctx, &options, &tok," \t,")) {
- int ret=0,i;
- int value = 1;
- char *p;
- bool got_value = false;
-
- if ((p = strchr_m(tok,'='))) {
- *p = 0;
- value = atoi(p+1);
- got_value = true;
- }
-
- for (i=0;socket_options[i].name;i++)
- if (strequal(socket_options[i].name,tok))
- break;
-
- if (!socket_options[i].name) {
- DEBUG(0,("Unknown socket option %s\n",tok));
- continue;
- }
-
- switch (socket_options[i].opttype) {
- case OPT_BOOL:
- case OPT_INT:
- ret = setsockopt(fd,socket_options[i].level,
- socket_options[i].option,
- (char *)&value,sizeof(int));
- break;
-
- case OPT_ON:
- if (got_value)
- DEBUG(0,("syntax error - %s "
- "does not take a value\n",tok));
-
- {
- int on = socket_options[i].value;
- ret = setsockopt(fd,socket_options[i].level,
- socket_options[i].option,
- (char *)&on,sizeof(int));
- }
- break;
- }
-
- if (ret != 0) {
- /* be aware that some systems like Solaris return
- * EINVAL to a setsockopt() call when the client
- * sent a RST previously - no need to worry */
- DEBUG(2,("Failed to set socket option %s (Error %s)\n",
- tok, strerror(errno) ));
- }
- }
-
- TALLOC_FREE(ctx);
- print_socket_options(fd);
-}
-
/****************************************************************************
Read from a socket.
****************************************************************************/
@@ -571,7 +257,7 @@ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt)
* discarding elements.
*/
- iov_copy = (struct iovec *)TALLOC_MEMDUP(
+ iov_copy = (struct iovec *)talloc_memdup(
talloc_tos(), orig_iov, sizeof(struct iovec) * iovcnt);
if (iov_copy == NULL) {
@@ -620,7 +306,7 @@ ssize_t write_data(int fd, const char *buffer, size_t N)
{
struct iovec iov;
- iov.iov_base = CONST_DISCARD(void *, buffer);
+ iov.iov_base = discard_const_p(void, buffer);
iov.iov_len = N;
return write_data_iov(fd, &iov, 1);
}
@@ -787,6 +473,32 @@ int open_socket_in(int type,
#endif /* SO_REUSEPORT */
}
+#ifdef HAVE_IPV6
+ /*
+ * As IPV6_V6ONLY is the default on some systems,
+ * we better try to be consistent and always use it.
+ *
+ * This also avoids using IPv4 via AF_INET6 sockets
+ * and makes sure %I never resolves to a '::ffff:192.168.0.1'
+ * string.
+ */
+ if (sock.ss_family == AF_INET6) {
+ int val = 1;
+ int ret;
+
+ ret = setsockopt(res, IPPROTO_IPV6, IPV6_V6ONLY,
+ (const void *)&val, sizeof(val));
+ if (ret == -1) {
+ if(DEBUGLVL(0)) {
+ dbgtext("open_socket_in(): IPV6_ONLY failed: ");
+ dbgtext("%s\n", strerror(errno));
+ }
+ close(res);
+ return -1;
+ }
+ }
+#endif
+
/* now we've got a socket - we need to bind it */
if (bind(res, (struct sockaddr *)&sock, slen) == -1 ) {
if( DEBUGLVL(dlevel) && (port == SMB_PORT1 ||
@@ -812,7 +524,7 @@ struct open_socket_out_state {
struct sockaddr_storage ss;
socklen_t salen;
uint16_t port;
- int wait_nsec;
+ int wait_usec;
};
static void open_socket_out_connected(struct tevent_req *subreq);
@@ -848,7 +560,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
state->ev = ev;
state->ss = *pss;
state->port = port;
- state->wait_nsec = 10000;
+ state->wait_usec = 10000;
state->salen = -1;
state->fd = socket(state->ss.ss_family, SOCK_STREAM, 0);
@@ -859,7 +571,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
talloc_set_destructor(state, open_socket_out_state_destructor);
if (!tevent_req_set_endtime(
- result, ev, timeval_current_ofs(0, timeout*1000))) {
+ result, ev, timeval_current_ofs_msec(timeout))) {
goto fail;
}
@@ -896,7 +608,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
if ((subreq == NULL)
|| !tevent_req_set_endtime(
subreq, state->ev,
- timeval_current_ofs(0, state->wait_nsec))) {
+ timeval_current_ofs(0, state->wait_usec))) {
goto fail;
}
tevent_req_set_callback(subreq, open_socket_out_connected, result);
@@ -938,8 +650,8 @@ static void open_socket_out_connected(struct tevent_req *subreq)
* retry
*/
- if (state->wait_nsec < 250000) {
- state->wait_nsec *= 1.5;
+ if (state->wait_usec < 250000) {
+ state->wait_usec *= 1.5;
}
subreq = async_connect_send(state, state->ev, state->fd,
@@ -950,7 +662,7 @@ static void open_socket_out_connected(struct tevent_req *subreq)
}
if (!tevent_req_set_endtime(
subreq, state->ev,
- timeval_current_ofs(0, state->wait_nsec))) {
+ timeval_current_ofs_usec(state->wait_usec))) {
tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
@@ -1248,7 +960,7 @@ static bool matchname(const char *remotehost,
continue;
}
if (sockaddr_equal((const struct sockaddr *)res->ai_addr,
- (struct sockaddr *)pss)) {
+ (const struct sockaddr *)pss)) {
freeaddrinfo(ailist);
return true;
}
@@ -1454,14 +1166,21 @@ int create_pipe_sock(const char *socket_dir,
} else {
/* Check ownership and permission on existing directory */
if (!S_ISDIR(st.st_mode)) {
- DEBUG(0, ("socket directory %s isn't a directory\n",
+ DEBUG(0, ("socket directory '%s' isn't a directory\n",
socket_dir));
goto out_umask;
}
- if ((st.st_uid != sec_initial_uid()) ||
- ((st.st_mode & 0777) != dir_perms)) {
- DEBUG(0, ("invalid permissions on socket directory "
- "%s\n", socket_dir));
+ if (st.st_uid != sec_initial_uid()) {
+ DEBUG(0, ("invalid ownership on directory "
+ "'%s'\n", socket_dir));
+ umask(old_umask);
+ goto out_umask;
+ }
+ if ((st.st_mode & 0777) != dir_perms) {
+ DEBUG(0, ("invalid permissions on directory "
+ "'%s': has 0%o should be 0%o\n", socket_dir,
+ (st.st_mode & 0777), dir_perms));
+ umask(old_umask);
goto out_umask;
}
}
@@ -1602,13 +1321,13 @@ static bool is_my_ipaddr(const char *ipaddr_str)
return false;
}
- if (ismyaddr((struct sockaddr *)&ss)) {
- return true;
+ if (is_zero_addr(&ss)) {
+ return false;
}
- if (is_zero_addr(&ss) ||
- is_loopback_addr((struct sockaddr *)&ss)) {
- return false;
+ if (ismyaddr((struct sockaddr *)&ss) ||
+ is_loopback_addr((struct sockaddr *)&ss)) {
+ return true;
}
n = get_interfaces(talloc_tos(), &nics);
@@ -1651,7 +1370,7 @@ bool is_myname_or_ipaddr(const char *s)
}
/* Optimize for the common case */
- if (strequal(servername, global_myname())) {
+ if (strequal(servername, lp_netbios_name())) {
return true;
}
@@ -1802,7 +1521,7 @@ int poll_one_fd(int fd, int events, int timeout, int *revents)
int ret;
int saved_errno;
- fds = TALLOC_ZERO_ARRAY(talloc_tos(), struct pollfd, 2);
+ fds = talloc_zero_array(talloc_tos(), struct pollfd, 2);
if (fds == NULL) {
errno = ENOMEM;
return -1;
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 88a3d703f4d..a348b389e86 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -36,164 +36,6 @@ const char toupper_ascii_fast_table[128] = {
};
/**
- * Case insensitive string compararison.
- *
- * iconv does not directly give us a way to compare strings in
- * arbitrary unix character sets -- all we can is convert and then
- * compare. This is expensive.
- *
- * As an optimization, we do a first pass that considers only the
- * prefix of the strings that is entirely 7-bit. Within this, we
- * check whether they have the same value.
- *
- * Hopefully this will often give the answer without needing to copy.
- * In particular it should speed comparisons to literal ascii strings
- * or comparisons of strings that are "obviously" different.
- *
- * If we find a non-ascii character we fall back to converting via
- * iconv.
- *
- * This should never be slower than convering the whole thing, and
- * often faster.
- *
- * A different optimization would be to compare for bitwise equality
- * in the binary encoding. (It would be possible thought hairy to do
- * both simultaneously.) But in that case if they turn out to be
- * different, we'd need to restart the whole thing.
- *
- * Even better is to implement strcasecmp for each encoding and use a
- * function pointer.
- **/
-int StrCaseCmp(const char *s, const char *t)
-{
-
- const char *ps, *pt;
- size_t size;
- smb_ucs2_t *buffer_s, *buffer_t;
- int ret;
-
- for (ps = s, pt = t; ; ps++, pt++) {
- char us, ut;
-
- if (!*ps && !*pt)
- return 0; /* both ended */
- else if (!*ps)
- return -1; /* s is a prefix */
- else if (!*pt)
- return +1; /* t is a prefix */
- else if ((*ps & 0x80) || (*pt & 0x80))
- /* not ascii anymore, do it the hard way
- * from here on in */
- break;
-
- us = toupper_ascii_fast(*ps);
- ut = toupper_ascii_fast(*pt);
- if (us == ut)
- continue;
- else if (us < ut)
- return -1;
- else if (us > ut)
- return +1;
- }
-
- if (!push_ucs2_talloc(talloc_tos(), &buffer_s, ps, &size)) {
- return strcmp(ps, pt);
- /* Not quite the right answer, but finding the right one
- under this failure case is expensive, and it's pretty
- close */
- }
-
- if (!push_ucs2_talloc(talloc_tos(), &buffer_t, pt, &size)) {
- TALLOC_FREE(buffer_s);
- return strcmp(ps, pt);
- /* Not quite the right answer, but finding the right one
- under this failure case is expensive, and it's pretty
- close */
- }
-
- ret = strcasecmp_w(buffer_s, buffer_t);
- TALLOC_FREE(buffer_s);
- TALLOC_FREE(buffer_t);
- return ret;
-}
-
-
-/**
- Case insensitive string compararison, length limited.
-**/
-int StrnCaseCmp(const char *s, const char *t, size_t len)
-{
- size_t n = 0;
- const char *ps, *pt;
- size_t size;
- smb_ucs2_t *buffer_s, *buffer_t;
- int ret;
-
- for (ps = s, pt = t; n < len ; ps++, pt++, n++) {
- char us, ut;
-
- if (!*ps && !*pt)
- return 0; /* both ended */
- else if (!*ps)
- return -1; /* s is a prefix */
- else if (!*pt)
- return +1; /* t is a prefix */
- else if ((*ps & 0x80) || (*pt & 0x80))
- /* not ascii anymore, do it the
- * hard way from here on in */
- break;
-
- us = toupper_ascii_fast(*ps);
- ut = toupper_ascii_fast(*pt);
- if (us == ut)
- continue;
- else if (us < ut)
- return -1;
- else if (us > ut)
- return +1;
- }
-
- if (n == len) {
- return 0;
- }
-
- if (!push_ucs2_talloc(talloc_tos(), &buffer_s, ps, &size)) {
- return strncmp(ps, pt, len-n);
- /* Not quite the right answer, but finding the right one
- under this failure case is expensive,
- and it's pretty close */
- }
-
- if (!push_ucs2_talloc(talloc_tos(), &buffer_t, pt, &size)) {
- TALLOC_FREE(buffer_s);
- return strncmp(ps, pt, len-n);
- /* Not quite the right answer, but finding the right one
- under this failure case is expensive,
- and it's pretty close */
- }
-
- ret = strncasecmp_w(buffer_s, buffer_t, len-n);
- TALLOC_FREE(buffer_s);
- TALLOC_FREE(buffer_t);
- return ret;
-}
-
-/**
- * Compare 2 strings.
- *
- * @note The comparison is case-insensitive.
- **/
-bool strequal(const char *s1, const char *s2)
-{
- if (s1 == s2)
- return(true);
- if (!s1 || !s2)
- return(false);
-
- return(StrCaseCmp(s1,s2)==0);
-}
-
-/**
* Compare 2 strings up to and including the nth char.
*
* @note The comparison is case-insensitive.
@@ -205,7 +47,7 @@ bool strnequal(const char *s1,const char *s2,size_t n)
if (!s1 || !s2 || !n)
return(false);
- return(StrnCaseCmp(s1,s2,n)==0);
+ return(strncasecmp_m(s1,s2,n)==0);
}
/**
@@ -328,77 +170,6 @@ bool trim_char(char *s,char cfront,char cback)
}
/**
- Safe string copy into a known length string. maxlength does not
- include the terminating zero.
-**/
-
-char *safe_strcpy_fn(char *dest,
- const char *src,
- size_t maxlength)
-{
- size_t len;
-
- if (!dest) {
- smb_panic("ERROR: NULL dest in safe_strcpy");
- }
-
- if (!src) {
- *dest = 0;
- return dest;
- }
-
- len = strnlen(src, maxlength+1);
-
- if (len > maxlength) {
- DEBUG(0,("ERROR: string overflow by "
- "%lu (%lu - %lu) in safe_strcpy [%.50s]\n",
- (unsigned long)(len-maxlength), (unsigned long)len,
- (unsigned long)maxlength, src));
- len = maxlength;
- }
-
- memmove(dest, src, len);
- dest[len] = 0;
- return dest;
-}
-
-/**
- Safe string cat into a string. maxlength does not
- include the terminating zero.
-**/
-char *safe_strcat_fn(char *dest,
- const char *src,
- size_t maxlength)
-{
- size_t src_len, dest_len;
-
- if (!dest) {
- smb_panic("ERROR: NULL dest in safe_strcat");
- }
-
- if (!src)
- return dest;
-
- src_len = strnlen(src, maxlength + 1);
- dest_len = strnlen(dest, maxlength + 1);
-
- if (src_len + dest_len > maxlength) {
- DEBUG(0,("ERROR: string overflow by %d "
- "in safe_strcat [%.50s]\n",
- (int)(src_len + dest_len - maxlength), src));
- if (maxlength > dest_len) {
- memcpy(&dest[dest_len], src, maxlength - dest_len);
- }
- dest[maxlength] = 0;
- return NULL;
- }
-
- memcpy(&dest[dest_len], src, src_len);
- dest[dest_len + src_len] = 0;
- return dest;
-}
-
-/**
Like strncpy but always null terminates. Make sure there is room!
The variable n should always be one less than the available size.
**/
@@ -446,7 +217,7 @@ bool in_list(const char *s, const char *list, bool casesensitive)
break;
}
} else {
- if (StrCaseCmp(tok,s) == 0) {
+ if (strcasecmp_m(tok,s) == 0) {
ret = true;
break;
}
@@ -456,235 +227,6 @@ bool in_list(const char *s, const char *list, bool casesensitive)
return ret;
}
-/* this is used to prevent lots of mallocs of size 1 */
-static const char null_string[] = "";
-
-/**
- Set a string value, allocing the space for the string
-**/
-
-static bool string_init(char **dest,const char *src)
-{
- size_t l;
-
- if (!src)
- src = "";
-
- l = strlen(src);
-
- if (l == 0) {
- *dest = CONST_DISCARD(char*, null_string);
- } else {
- (*dest) = SMB_STRDUP(src);
- if ((*dest) == NULL) {
- DEBUG(0,("Out of memory in string_init\n"));
- return false;
- }
- }
- return(true);
-}
-
-/**
- Free a string value.
-**/
-
-void string_free(char **s)
-{
- if (!s || !(*s))
- return;
- if (*s == null_string)
- *s = NULL;
- SAFE_FREE(*s);
-}
-
-/**
- Set a string value, deallocating any existing space, and allocing the space
- for the string
-**/
-
-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!
-
- This routine looks for pattern in s and replaces it with
- insert. It may do multiple replacements or just one.
-
- Any of " ; ' $ or ` in the insert string are replaced with _
- if len==0 then the string cannot be extended. This is different from the old
- use of len==0 which was for no length checks to be done.
-**/
-
-void string_sub2(char *s,const char *pattern, const char *insert, size_t len,
- bool remove_unsafe_characters, bool replace_once,
- bool allow_trailing_dollar)
-{
- char *p;
- ssize_t ls,lp,li, i;
-
- if (!insert || !pattern || !*pattern || !s)
- return;
-
- ls = (ssize_t)strlen(s);
- lp = (ssize_t)strlen(pattern);
- li = (ssize_t)strlen(insert);
-
- if (len == 0)
- len = ls + 1; /* len is number of *bytes* */
-
- while (lp <= ls && (p = strstr_m(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),
- pattern, (int)len));
- break;
- }
- if (li != lp) {
- memmove(p+li,p+lp,strlen(p+lp)+1);
- }
- for (i=0;i<li;i++) {
- switch (insert[i]) {
- case '$':
- /* allow a trailing $
- * (as in machine accounts) */
- if (allow_trailing_dollar && (i == li - 1 )) {
- p[i] = insert[i];
- break;
- }
- case '`':
- case '"':
- case '\'':
- case ';':
- case '%':
- case '\r':
- case '\n':
- if ( remove_unsafe_characters ) {
- p[i] = '_';
- /* yes this break should be here
- * since we want to fall throw if
- * not replacing unsafe chars */
- break;
- }
- default:
- p[i] = insert[i];
- }
- }
- s = p + li;
- ls += (li-lp);
-
- if (replace_once)
- break;
- }
-}
-
-void string_sub_once(char *s, const char *pattern,
- const char *insert, size_t len)
-{
- string_sub2( s, pattern, insert, len, true, true, false );
-}
-
-void string_sub(char *s,const char *pattern, const char *insert, size_t len)
-{
- string_sub2( s, pattern, insert, len, true, false, false );
-}
-
-void fstring_sub(char *s,const char *pattern,const char *insert)
-{
- string_sub(s, pattern, insert, sizeof(fstring));
-}
-
-/**
- Similar to string_sub2, but it will accept only allocated strings
- and may realloc them so pay attention at what you pass on no
- pointers inside strings, no const may be passed
- as string.
-**/
-
-char *realloc_string_sub2(char *string,
- const char *pattern,
- const char *insert,
- bool remove_unsafe_characters,
- bool allow_trailing_dollar)
-{
- char *p, *in;
- char *s;
- ssize_t ls,lp,li,ld, i;
-
- if (!insert || !pattern || !*pattern || !string || !*string)
- return NULL;
-
- s = string;
-
- in = SMB_STRDUP(insert);
- if (!in) {
- DEBUG(0, ("realloc_string_sub: out of memory!\n"));
- return NULL;
- }
- ls = (ssize_t)strlen(s);
- lp = (ssize_t)strlen(pattern);
- li = (ssize_t)strlen(insert);
- ld = li - lp;
- for (i=0;i<li;i++) {
- switch (in[i]) {
- case '$':
- /* allow a trailing $
- * (as in machine accounts) */
- if (allow_trailing_dollar && (i == li - 1 )) {
- break;
- }
- case '`':
- case '"':
- case '\'':
- case ';':
- case '%':
- case '\r':
- case '\n':
- if ( remove_unsafe_characters ) {
- in[i] = '_';
- break;
- }
- default:
- /* ok */
- break;
- }
- }
-
- while ((p = strstr_m(s,pattern))) {
- if (ld > 0) {
- int offset = PTR_DIFF(s,string);
- string = (char *)SMB_REALLOC(string, ls + ld + 1);
- if (!string) {
- DEBUG(0, ("realloc_string_sub: "
- "out of memory!\n"));
- SAFE_FREE(in);
- return NULL;
- }
- p = string + offset + (p - s);
- }
- if (li != lp) {
- memmove(p+li,p+lp,strlen(p+lp)+1);
- }
- memcpy(p, in, li);
- s = p + li;
- ls += ld;
- }
- SAFE_FREE(in);
- return string;
-}
-
-char *realloc_string_sub(char *string,
- const char *pattern,
- const char *insert)
-{
- return realloc_string_sub2(string, pattern, insert, true, false);
-}
-
/*
* Internal guts of talloc_string_sub and talloc_all_string_sub.
* talloc version of string_sub2.
@@ -715,7 +257,7 @@ char *talloc_string_sub2(TALLOC_CTX *mem_ctx, const char *src,
s = string;
- in = SMB_STRDUP(insert);
+ in = talloc_strdup(mem_ctx, insert);
if (!in) {
DEBUG(0, ("talloc_string_sub2: ENOMEM\n"));
return NULL;
@@ -758,7 +300,7 @@ char *talloc_string_sub2(TALLOC_CTX *mem_ctx, const char *src,
if (!string) {
DEBUG(0, ("talloc_string_sub: out of "
"memory!\n"));
- SAFE_FREE(in);
+ TALLOC_FREE(in);
return NULL;
}
p = string + offset + (p - s);
@@ -774,7 +316,7 @@ char *talloc_string_sub2(TALLOC_CTX *mem_ctx, const char *src,
break;
}
}
- SAFE_FREE(in);
+ TALLOC_FREE(in);
return string;
}
@@ -789,48 +331,6 @@ char *talloc_string_sub(TALLOC_CTX *mem_ctx,
true, false, false);
}
-/**
- Similar to string_sub() but allows for any character to be substituted.
- Use with caution!
- if len==0 then the string cannot be extended. This is different from the old
- use of len==0 which was for no length checks to be done.
-**/
-
-void all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
-{
- char *p;
- ssize_t ls,lp,li;
-
- if (!insert || !pattern || !s)
- return;
-
- ls = (ssize_t)strlen(s);
- lp = (ssize_t)strlen(pattern);
- li = (ssize_t)strlen(insert);
-
- if (!*pattern)
- return;
-
- if (len == 0)
- len = ls + 1; /* len is number of *bytes* */
-
- while (lp <= ls && (p = strstr_m(s,pattern))) {
- if (ls + (li-lp) >= len) {
- DEBUG(0,("ERROR: string overflow by "
- "%d in all_string_sub(%.50s, %d)\n",
- (int)(ls + (li-lp) - len),
- pattern, (int)len));
- break;
- }
- if (li != lp) {
- memmove(p+li,p+lp,strlen(p+lp)+1);
- }
- memcpy(p, insert, li);
- s = p + li;
- ls += (li-lp);
- }
-}
-
char *talloc_all_string_sub(TALLOC_CTX *ctx,
const char *src,
const char *pattern,
@@ -898,93 +398,12 @@ char *strnrchr_m(const char *s, char c, unsigned int n)
/* Too hard to try and get right. */
return NULL;
}
- ret = (char *)(s+strlen(s2));
+ ret = discard_const_p(char, (s+strlen(s2)));
TALLOC_FREE(ws);
TALLOC_FREE(s2);
return ret;
}
-/***********************************************************************
- strstr_m - We convert via ucs2 for now.
-***********************************************************************/
-
-char *strstr_m(const char *src, const char *findstr)
-{
- smb_ucs2_t *p;
- smb_ucs2_t *src_w, *find_w;
- const char *s;
- char *s2;
- char *retp;
-
- size_t converted_size, findstr_len = 0;
-
- /* for correctness */
- if (!findstr[0]) {
- return (char*)src;
- }
-
- /* Samba does single character findstr calls a *lot*. */
- if (findstr[1] == '\0')
- return strchr_m(src, *findstr);
-
- /* We optimise for the ascii case, knowing that all our
- supported multi-byte character sets are ascii-compatible
- (ie. they match for the first 128 chars) */
-
- for (s = src; *s && !(((unsigned char)s[0]) & 0x80); s++) {
- if (*s == *findstr) {
- if (!findstr_len)
- findstr_len = strlen(findstr);
-
- if (strncmp(s, findstr, findstr_len) == 0) {
- return (char *)s;
- }
- }
- }
-
- if (!*s)
- return NULL;
-
-#if 1 /* def BROKEN_UNICODE_COMPOSE_CHARACTERS */
- /* 'make check' fails unless we do this */
-
- /* With compose characters we must restart from the beginning. JRA. */
- s = src;
-#endif
-
- if (!push_ucs2_talloc(talloc_tos(), &src_w, src, &converted_size)) {
- DEBUG(0,("strstr_m: src malloc fail\n"));
- return NULL;
- }
-
- if (!push_ucs2_talloc(talloc_tos(), &find_w, findstr, &converted_size)) {
- TALLOC_FREE(src_w);
- DEBUG(0,("strstr_m: find malloc fail\n"));
- return NULL;
- }
-
- p = strstr_w(src_w, find_w);
-
- if (!p) {
- TALLOC_FREE(src_w);
- TALLOC_FREE(find_w);
- return NULL;
- }
-
- *p = 0;
- if (!pull_ucs2_talloc(talloc_tos(), &s2, src_w, &converted_size)) {
- TALLOC_FREE(src_w);
- TALLOC_FREE(find_w);
- DEBUG(0,("strstr_m: dest malloc fail\n"));
- return NULL;
- }
- retp = (char *)(s+strlen(s2));
- TALLOC_FREE(src_w);
- TALLOC_FREE(find_w);
- TALLOC_FREE(s2);
- return retp;
-}
-
static bool unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen)
{
size_t size;
@@ -1005,6 +424,36 @@ static bool unix_strlower(const char *src, size_t srclen, char *dest, size_t des
return ret;
}
+#if 0 /* Alternate function that avoid talloc calls for ASCII and non ASCII */
+
+/**
+ Convert a string to lower case.
+**/
+_PUBLIC_ void strlower_m(char *s)
+{
+ char *d;
+ struct smb_iconv_handle *iconv_handle;
+
+ iconv_handle = get_iconv_handle();
+
+ d = s;
+
+ while (*s) {
+ size_t c_size, c_size2;
+ codepoint_t c = next_codepoint_handle(iconv_handle, s, &c_size);
+ c_size2 = push_codepoint_handle(iconv_handle, d, tolower_m(c));
+ if (c_size2 > c_size) {
+ DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strlower_m\n",
+ c, tolower_m(c), (int)c_size, (int)c_size2));
+ smb_panic("codepoint expansion in strlower_m\n");
+ }
+ s += c_size;
+ d += c_size2;
+ }
+ *d = 0;
+}
+
+#endif
/**
Convert a string to lower case.
@@ -1060,6 +509,37 @@ static bool unix_strupper(const char *src, size_t srclen, char *dest, size_t des
return ret;
}
+#if 0 /* Alternate function that avoid talloc calls for ASCII and non ASCII */
+
+/**
+ Convert a string to UPPER case.
+**/
+_PUBLIC_ void strupper_m(char *s)
+{
+ char *d;
+ struct smb_iconv_handle *iconv_handle;
+
+ iconv_handle = get_iconv_handle();
+
+ d = s;
+
+ while (*s) {
+ size_t c_size, c_size2;
+ codepoint_t c = next_codepoint_handle(iconv_handle, s, &c_size);
+ c_size2 = push_codepoint_handle(iconv_handle, d, toupper_m(c));
+ if (c_size2 > c_size) {
+ DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strupper_m\n",
+ c, toupper_m(c), (int)c_size, (int)c_size2));
+ smb_panic("codepoint expansion in strupper_m\n");
+ }
+ s += c_size;
+ d += c_size2;
+ }
+ *d = 0;
+}
+
+#endif
+
/**
Convert a string to upper case.
**/
@@ -1116,35 +596,6 @@ int fstr_sprintf(fstring s, const char *fmt, ...)
#define S_LIST_ABS 16 /* List Allocation Block Size */
/******************************************************************************
- version of standard_sub_basic() for string lists; uses talloc_sub_basic()
- for the work
- *****************************************************************************/
-
-bool str_list_sub_basic( char **list, const char *smb_name,
- const char *domain_name )
-{
- TALLOC_CTX *ctx = list;
- char *s, *tmpstr;
-
- while ( *list ) {
- s = *list;
- tmpstr = talloc_sub_basic(ctx, smb_name, domain_name, s);
- if ( !tmpstr ) {
- DEBUG(0,("str_list_sub_basic: "
- "alloc_sub_basic() return NULL!\n"));
- return false;
- }
-
- TALLOC_FREE(*list);
- *list = tmpstr;
-
- list++;
- }
-
- return true;
-}
-
-/******************************************************************************
substitute a specific pattern in a string list
*****************************************************************************/
@@ -1173,7 +624,7 @@ bool str_list_substitute(char **list, const char *pattern, const char *insert)
t = *list;
d = p -t;
if (ld) {
- t = TALLOC_ARRAY(ctx, char, ls +ld +1);
+ t = talloc_array(ctx, char, ls +ld +1);
if (!t) {
DEBUG(0,("str_list_substitute: "
"Unable to allocate memory"));
@@ -1415,25 +866,16 @@ uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr)
*
* Returns 0 if the string can't be converted.
*/
-SMB_OFF_T conv_str_size(const char * str)
+uint64_t conv_str_size(const char * str)
{
- SMB_OFF_T lval_orig;
- SMB_OFF_T lval;
+ uint64_t lval;
char * end;
if (str == NULL || *str == '\0') {
return 0;
}
-#ifdef HAVE_STRTOULL
- if (sizeof(SMB_OFF_T) == 8) {
- lval = strtoull(str, &end, 10 /* base */);
- } else {
- lval = strtoul(str, &end, 10 /* base */);
- }
-#else
- lval = strtoul(str, &end, 10 /* base */);
-#endif
+ lval = strtoull(str, &end, 10 /* base */);
if (end == NULL || end == str) {
return 0;
@@ -1443,35 +885,24 @@ SMB_OFF_T conv_str_size(const char * str)
return lval;
}
- lval_orig = lval;
-
if (strwicmp(end, "K") == 0) {
- lval *= (SMB_OFF_T)1024;
+ lval *= 1024ULL;
} else if (strwicmp(end, "M") == 0) {
- lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024);
+ lval *= (1024ULL * 1024ULL);
} else if (strwicmp(end, "G") == 0) {
- lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
- (SMB_OFF_T)1024);
+ lval *= (1024ULL * 1024ULL *
+ 1024ULL);
} else if (strwicmp(end, "T") == 0) {
- lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
- (SMB_OFF_T)1024 * (SMB_OFF_T)1024);
+ lval *= (1024ULL * 1024ULL *
+ 1024ULL * 1024ULL);
} else if (strwicmp(end, "P") == 0) {
- lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
- (SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
- (SMB_OFF_T)1024);
+ lval *= (1024ULL * 1024ULL *
+ 1024ULL * 1024ULL *
+ 1024ULL);
} else {
return 0;
}
- /*
- * Primitive attempt to detect wrapping on platforms with
- * 4-byte SMB_OFF_T. It's better to let the caller handle a
- * failure than some random number.
- */
- if (lval_orig <= lval) {
- return 0;
- }
-
return lval;
}
@@ -1495,7 +926,7 @@ void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
if (*bufsize == 0)
*bufsize = 128;
- *string = TALLOC_ARRAY(mem_ctx, char, *bufsize);
+ *string = talloc_array(mem_ctx, char, *bufsize);
if (*string == NULL)
goto error;
}
@@ -1517,7 +948,7 @@ void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
}
if (increased) {
- *string = TALLOC_REALLOC_ARRAY(mem_ctx, *string, char,
+ *string = talloc_realloc(mem_ctx, *string, char,
*bufsize);
if (*string == NULL) {
goto error;
@@ -1589,33 +1020,6 @@ char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...)
}
-/*
- Returns the substring from src between the first occurrence of
- the char "front" and the first occurence of the char "back".
- Mallocs the return string which must be freed. Not for use
- with wide character strings.
-*/
-char *sstring_sub(const char *src, char front, char back)
-{
- char *temp1, *temp2, *temp3;
- ptrdiff_t len;
-
- temp1 = strchr(src, front);
- if (temp1 == NULL) return NULL;
- temp2 = strchr(src, back);
- if (temp2 == NULL) return NULL;
- len = temp2 - temp1;
- if (len <= 0) return NULL;
- temp3 = (char*)SMB_MALLOC(len);
- if (temp3 == NULL) {
- DEBUG(1,("Malloc failure in sstring_sub\n"));
- return NULL;
- }
- memcpy(temp3, temp1+1, len-1);
- temp3[len-1] = '\0';
- return temp3;
-}
-
/********************************************************************
Check a string for any occurrences of a specified list of invalid
characters.
@@ -1825,7 +1229,7 @@ char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string,
if (!string || !*string)
return NULL;
- list = TALLOC_ARRAY(mem_ctx, char *, S_LIST_ABS+1);
+ list = talloc_array(mem_ctx, char *, S_LIST_ABS+1);
if (list == NULL) {
return NULL;
}
@@ -1849,7 +1253,7 @@ char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string,
lsize += S_LIST_ABS;
- tmp = TALLOC_REALLOC_ARRAY(mem_ctx, list, char *,
+ tmp = talloc_realloc(mem_ctx, list, char *,
lsize + 1);
if (tmp == NULL) {
DEBUG(0,("str_list_make: "
diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c
index a9290ab94ae..ade46bf18ec 100644
--- a/source3/lib/util_tdb.c
+++ b/source3/lib/util_tdb.c
@@ -21,11 +21,108 @@
#include "includes.h"
#include "system/filesys.h"
+#include "util_tdb.h"
+
#undef malloc
#undef realloc
#undef calloc
#undef strdup
+#ifdef BUILD_TDB2
+static struct flock flock_struct;
+
+/* Return a value which is none of v1, v2 or v3. */
+static inline short int invalid_value(short int v1, short int v2, short int v3)
+{
+ short int try = (v1+v2+v3)^((v1+v2+v3) << 16);
+ while (try == v1 || try == v2 || try == v3)
+ try++;
+ return try;
+}
+
+/* We invalidate in as many ways as we can, so the OS rejects it */
+static void invalidate_flock_struct(int signum)
+{
+ flock_struct.l_type = invalid_value(F_RDLCK, F_WRLCK, F_UNLCK);
+ flock_struct.l_whence = invalid_value(SEEK_SET, SEEK_CUR, SEEK_END);
+ flock_struct.l_start = -1;
+ /* A large negative. */
+ flock_struct.l_len = (((off_t)1 << (sizeof(off_t)*CHAR_BIT - 1)) + 1);
+}
+
+static int timeout_lock(int fd, int rw, off_t off, off_t len, bool waitflag,
+ void *_timeout)
+{
+ int ret, saved_errno;
+ unsigned int timeout = *(unsigned int *)_timeout;
+
+ flock_struct.l_type = rw;
+ flock_struct.l_whence = SEEK_SET;
+ flock_struct.l_start = off;
+ flock_struct.l_len = len;
+
+ CatchSignal(SIGALRM, invalidate_flock_struct);
+ alarm(timeout);
+
+ for (;;) {
+ if (waitflag)
+ ret = fcntl(fd, F_SETLKW, &flock_struct);
+ else
+ ret = fcntl(fd, F_SETLK, &flock_struct);
+
+ if (ret == 0)
+ break;
+
+ /* Not signalled? Something else went wrong. */
+ if (flock_struct.l_len == len) {
+ if (errno == EAGAIN || errno == EINTR)
+ continue;
+ saved_errno = errno;
+ break;
+ } else {
+ saved_errno = EINTR;
+ break;
+ }
+ }
+
+ alarm(0);
+ errno = saved_errno;
+ return ret;
+}
+
+static int tdb_chainlock_with_timeout_internal(struct tdb_context *tdb,
+ TDB_DATA key,
+ unsigned int timeout,
+ int rw_type)
+{
+ union tdb_attribute locking;
+ enum TDB_ERROR ecode;
+
+ if (timeout) {
+ locking.base.attr = TDB_ATTRIBUTE_FLOCK;
+ ecode = tdb_get_attribute(tdb, &locking);
+ if (ecode != TDB_SUCCESS)
+ return ecode;
+
+ /* Replace locking function with our own. */
+ locking.flock.data = &timeout;
+ locking.flock.lock = timeout_lock;
+
+ ecode = tdb_set_attribute(tdb, &locking);
+ if (ecode != TDB_SUCCESS)
+ return ecode;
+ }
+ if (rw_type == F_RDLCK)
+ ecode = tdb_chainlock_read(tdb, key);
+ else
+ ecode = tdb_chainlock(tdb, key);
+
+ if (timeout) {
+ tdb_unset_attribute(tdb, TDB_ATTRIBUTE_FLOCK);
+ }
+ return ecode == TDB_SUCCESS ? 0 : -1;
+}
+#else
/* these are little tdb utility functions that are meant to make
dealing with a tdb database a little less cumbersome in Samba */
@@ -65,7 +162,7 @@ static int tdb_chainlock_with_timeout_internal( TDB_CONTEXT *tdb, TDB_DATA key,
alarm(0);
tdb_setalarm_sigptr(tdb, NULL);
CatchSignal(SIGALRM, SIG_IGN);
- if (gotalarm && (ret == -1)) {
+ if (gotalarm && (ret != 0)) {
DEBUG(0,("tdb_chainlock_with_timeout_internal: alarm (%u) timed out for key %s in tdb %s\n",
timeout, key.dptr, tdb_name(tdb)));
/* TODO: If we time out waiting for a lock, it might
@@ -76,11 +173,12 @@ static int tdb_chainlock_with_timeout_internal( TDB_CONTEXT *tdb, TDB_DATA key,
}
}
- return ret;
+ return ret == 0 ? 0 : -1;
}
+#endif /* TDB1 */
/****************************************************************************
- Write lock a chain. Return -1 if timeout or lock failed.
+ Write lock a chain. Return non-zero if timeout or lock failed.
****************************************************************************/
int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int timeout)
@@ -97,7 +195,7 @@ int tdb_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval,
}
/****************************************************************************
- Read lock a chain by string. Return -1 if timeout or lock failed.
+ Read lock a chain by string. Return non-zero if timeout or lock failed.
****************************************************************************/
int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout)
@@ -229,7 +327,7 @@ bool tdb_pack_append(TALLOC_CTX *mem_ctx, uint8 **buf, size_t *len,
va_end(ap);
if (mem_ctx != NULL) {
- *buf = TALLOC_REALLOC_ARRAY(mem_ctx, *buf, uint8,
+ *buf = talloc_realloc(mem_ctx, *buf, uint8,
(*len) + len1);
} else {
*buf = SMB_REALLOC_ARRAY(*buf, uint8, (*len) + len1);
@@ -370,6 +468,14 @@ int tdb_unpack(const uint8 *buf, int bufsize, const char *fmt, ...)
Log tdb messages via DEBUG().
****************************************************************************/
+#ifdef BUILD_TDB2
+static void tdb_log(TDB_CONTEXT *tdb, enum tdb_log_level level,
+ const char *message, void *unused)
+{
+ DEBUG((int)level, ("tdb(%s): %s",
+ tdb_name(tdb) ? tdb_name(tdb) : "unnamed", message));
+}
+#else
static void tdb_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, const char *format, ...)
{
va_list ap;
@@ -386,6 +492,7 @@ static void tdb_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, const char *fo
DEBUG((int)level, ("tdb(%s): %s", tdb_name(tdb) ? tdb_name(tdb) : "unnamed", ptr));
SAFE_FREE(ptr);
}
+#endif /* TDB1 */
/****************************************************************************
Like tdb_open() but also setup a logging function that redirects to
@@ -396,14 +503,10 @@ TDB_CONTEXT *tdb_open_log(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode)
{
TDB_CONTEXT *tdb;
- struct tdb_logging_context log_ctx;
if (!lp_use_mmap())
tdb_flags |= TDB_NOMMAP;
- log_ctx.log_fn = tdb_log;
- log_ctx.log_private = NULL;
-
if ((hash_size == 0) && (name != NULL)) {
const char *base = strrchr_m(name, '/');
if (base != NULL) {
@@ -415,8 +518,8 @@ TDB_CONTEXT *tdb_open_log(const char *name, int hash_size, int tdb_flags,
hash_size = lp_parm_int(-1, "tdb_hashsize", base, 0);
}
- tdb = tdb_open_ex(name, hash_size, tdb_flags,
- open_flags, mode, &log_ctx, NULL);
+ tdb = tdb_open_compat(name, hash_size, tdb_flags,
+ open_flags, mode, tdb_log, NULL);
if (!tdb)
return NULL;
@@ -440,9 +543,7 @@ int tdb_trans_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
if ((res = tdb_store(tdb, key, dbuf, flag)) != 0) {
DEBUG(10, ("tdb_store failed\n"));
- if (tdb_transaction_cancel(tdb) != 0) {
- smb_panic("Cancelling transaction failed");
- }
+ tdb_transaction_cancel(tdb);
return res;
}
@@ -469,9 +570,7 @@ int tdb_trans_delete(struct tdb_context *tdb, TDB_DATA key)
if ((res = tdb_delete(tdb, key)) != 0) {
DEBUG(10, ("tdb_delete failed\n"));
- if (tdb_transaction_cancel(tdb) != 0) {
- smb_panic("Cancelling transaction failed");
- }
+ tdb_transaction_cancel(tdb);
return res;
}
@@ -482,165 +581,6 @@ int tdb_trans_delete(struct tdb_context *tdb, TDB_DATA key)
return res;
}
-/*
- Log tdb messages via DEBUG().
-*/
-static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
- const char *format, ...) PRINTF_ATTRIBUTE(3,4);
-
-static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
- const char *format, ...)
-{
- va_list ap;
- char *ptr = NULL;
- int debuglevel = 0;
- int ret;
-
- switch (level) {
- case TDB_DEBUG_FATAL:
- debuglevel = 0;
- break;
- case TDB_DEBUG_ERROR:
- debuglevel = 1;
- break;
- case TDB_DEBUG_WARNING:
- debuglevel = 2;
- break;
- case TDB_DEBUG_TRACE:
- debuglevel = 5;
- break;
- default:
- debuglevel = 0;
- }
-
- va_start(ap, format);
- ret = vasprintf(&ptr, format, ap);
- va_end(ap);
-
- if (ret != -1) {
- const char *name = tdb_name(tdb);
- DEBUG(debuglevel, ("tdb(%s): %s", name ? name : "unnamed", ptr));
- free(ptr);
- }
-}
-
-struct tdb_wrap_private {
- struct tdb_context *tdb;
- const char *name;
- struct tdb_wrap_private *next, *prev;
-};
-
-static struct tdb_wrap_private *tdb_list;
-
-/* destroy the last connection to a tdb */
-static int tdb_wrap_private_destructor(struct tdb_wrap_private *w)
-{
- tdb_close(w->tdb);
- DLIST_REMOVE(tdb_list, w);
- return 0;
-}
-
-static struct tdb_wrap_private *tdb_wrap_private_open(TALLOC_CTX *mem_ctx,
- const char *name,
- int hash_size,
- int tdb_flags,
- int open_flags,
- mode_t mode)
-{
- struct tdb_wrap_private *result;
- struct tdb_logging_context log_ctx;
-
- result = talloc(mem_ctx, struct tdb_wrap_private);
- if (result == NULL) {
- return NULL;
- }
- result->name = talloc_strdup(result, name);
- if (result->name == NULL) {
- goto fail;
- }
-
- log_ctx.log_fn = tdb_wrap_log;
-
- if (!lp_use_mmap()) {
- tdb_flags |= TDB_NOMMAP;
- }
-
- if ((hash_size == 0) && (name != NULL)) {
- const char *base;
- base = strrchr_m(name, '/');
-
- if (base != NULL) {
- base += 1;
- } else {
- base = name;
- }
- hash_size = lp_parm_int(-1, "tdb_hashsize", base, 0);
- }
-
- result->tdb = tdb_open_ex(name, hash_size, tdb_flags,
- open_flags, mode, &log_ctx, NULL);
- if (result->tdb == NULL) {
- goto fail;
- }
- talloc_set_destructor(result, tdb_wrap_private_destructor);
- DLIST_ADD(tdb_list, result);
- return result;
-
-fail:
- TALLOC_FREE(result);
- return NULL;
-}
-
-/*
- wrapped connection to a tdb database
- to close just talloc_free() the tdb_wrap pointer
- */
-struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
- const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode)
-{
- struct tdb_wrap *result;
- struct tdb_wrap_private *w;
-
- result = talloc(mem_ctx, struct tdb_wrap);
- if (result == NULL) {
- return NULL;
- }
-
- for (w=tdb_list;w;w=w->next) {
- if (strcmp(name, w->name) == 0) {
- break;
- }
- }
-
- if (w == NULL) {
- w = tdb_wrap_private_open(result, name, hash_size, tdb_flags,
- open_flags, mode);
- } else {
- /*
- * Correctly use talloc_reference: The tdb will be
- * closed when "w" is being freed. The caller never
- * sees "w", so an incorrect use of talloc_free(w)
- * instead of calling talloc_unlink is not possible.
- * To avoid having to refcount ourselves, "w" will
- * have multiple parents that hang off all the
- * tdb_wrap's being returned from here. Those parents
- * can be freed without problem.
- */
- if (talloc_reference(result, w) == NULL) {
- goto fail;
- }
- }
- if (w == NULL) {
- goto fail;
- }
- result->tdb = w->tdb;
- return result;
-fail:
- TALLOC_FREE(result);
- return NULL;
-}
-
NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err)
{
NTSTATUS result = NT_STATUS_INTERNAL_ERROR;
@@ -672,6 +612,7 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err)
result = NT_STATUS_FILE_LOCK_CONFLICT;
break;
+#ifndef BUILD_TDB2
case TDB_ERR_NOLOCK:
case TDB_ERR_LOCK_TIMEOUT:
/*
@@ -679,6 +620,7 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err)
*/
result = NT_STATUS_FILE_LOCK_CONFLICT;
break;
+#endif
case TDB_ERR_NOEXIST:
result = NT_STATUS_NOT_FOUND;
break;
@@ -688,9 +630,11 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err)
case TDB_ERR_RDONLY:
result = NT_STATUS_ACCESS_DENIED;
break;
+#ifndef BUILD_TDB2
case TDB_ERR_NESTING:
result = NT_STATUS_INTERNAL_ERROR;
break;
+#endif
};
return result;
}
diff --git a/source3/lib/util_tsock.c b/source3/lib/util_tsock.c
index 1cb88c67bd0..35a97f5e692 100644
--- a/source3/lib/util_tsock.c
+++ b/source3/lib/util_tsock.c
@@ -18,6 +18,8 @@
*/
#include "includes.h"
+#include "../lib/tsocket/tsocket.h"
+#include "../lib/util/tevent_unix.h"
struct tstream_read_packet_state {
struct tevent_context *ev;
diff --git a/source3/lib/winbind_util.c b/source3/lib/winbind_util.c
index f30bcfc6126..b458ebe8472 100644
--- a/source3/lib/winbind_util.c
+++ b/source3/lib/winbind_util.c
@@ -237,15 +237,15 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx,
}
*domain_name = talloc_strdup(mem_ctx, dom_name);
- *names = TALLOC_ARRAY(mem_ctx, const char*, num_rids);
- *types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_rids);
+ *names = talloc_array(mem_ctx, const char*, num_rids);
+ *types = talloc_array(mem_ctx, enum lsa_SidType, num_rids);
for(i=0; i<num_rids; i++) {
(*names)[i] = talloc_strdup(*names, namelist[i]);
(*types)[i] = (enum lsa_SidType)name_types[i];
}
- wbcFreeMemory(CONST_DISCARD(char*, dom_name));
+ wbcFreeMemory(discard_const_p(char, dom_name));
wbcFreeMemory(namelist);
wbcFreeMemory(name_types);
@@ -284,7 +284,7 @@ bool winbind_get_groups(TALLOC_CTX * mem_ctx, const char *account, uint32_t *num
if (ret != WBC_ERR_SUCCESS)
return false;
- *_groups = TALLOC_ARRAY(mem_ctx, gid_t, ngroups);
+ *_groups = talloc_array(mem_ctx, gid_t, ngroups);
if (*_groups == NULL) {
wbcFreeMemory(group_list);
return false;
@@ -313,7 +313,7 @@ bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
memcpy(&domain_sid, dom_sid, sizeof(*dom_sid));
- sid_list = TALLOC_ARRAY(mem_ctx, struct wbcDomainSid, num_members);
+ sid_list = talloc_array(mem_ctx, struct wbcDomainSid, num_members);
for (i=0; i < num_members; i++) {
memcpy(&sid_list[i], &members[i], sizeof(sid_list[i]));
@@ -328,7 +328,7 @@ bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
return false;
}
- *pp_alias_rids = TALLOC_ARRAY(mem_ctx, uint32_t, num_rids);
+ *pp_alias_rids = talloc_array(mem_ctx, uint32_t, num_rids);
if (*pp_alias_rids == NULL) {
wbcFreeMemory(rids);
return false;
diff --git a/source3/lib/wins_srv.c b/source3/lib/wins_srv.c
index 6676f02e947..f9e8f3b0e1a 100644
--- a/source3/lib/wins_srv.c
+++ b/source3/lib/wins_srv.c
@@ -328,6 +328,48 @@ struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip)
return t_ip.ip;
}
+bool wins_server_tag_ips(const char *tag, TALLOC_CTX *mem_ctx,
+ struct in_addr **pservers, int *pnum_servers)
+{
+ const char **list;
+ int i, num_servers;
+ struct in_addr *servers;
+
+ list = lp_wins_server_list();
+ if ((list == NULL) || (list[0] == NULL)) {
+ return false;
+ }
+
+ num_servers = 0;
+
+ for (i=0; list[i] != NULL; i++) {
+ struct tagged_ip t_ip;
+ parse_ip(&t_ip, list[i]);
+ if (strcmp(tag, t_ip.tag) == 0) {
+ num_servers += 1;
+ }
+ }
+
+ servers = talloc_array(mem_ctx, struct in_addr, num_servers);
+ if (servers == NULL) {
+ return false;
+ }
+
+ num_servers = 0;
+
+ for (i=0; list[i] != NULL; i++) {
+ struct tagged_ip t_ip;
+ parse_ip(&t_ip, list[i]);
+ if (strcmp(tag, t_ip.tag) == 0) {
+ servers[num_servers] = t_ip.ip;
+ num_servers += 1;
+ }
+ }
+ *pnum_servers = num_servers;
+ *pservers = servers;
+ return true;
+}
+
/*
return a count of the number of IPs for a particular tag, including
diff --git a/source3/libads/ads_ldap_protos.h b/source3/libads/ads_ldap_protos.h
index 03869fe5c99..0fb71349948 100644
--- a/source3/libads/ads_ldap_protos.h
+++ b/source3/libads/ads_ldap_protos.h
@@ -1,4 +1,30 @@
/*
+ Unix SMB/CIFS implementation.
+ ads (active directory) utility library
+ Copyright (C) Andrew Tridgell 2001
+ Copyright (C) Remus Koos 2001
+ Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
+ Copyright (C) Guenther Deschner 2005
+ Copyright (C) Gerald Carter 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _LIBADS_ADS_LDAP_PROTOS_H_
+#define _LIBADS_ADS_LDAP_PROTOS_H_
+
+/*
* Prototypes for ads
*/
@@ -112,3 +138,5 @@ ADS_STATUS ads_get_joinable_ous(ADS_STRUCT *ads,
TALLOC_CTX *mem_ctx,
char ***ous,
size_t *num_ous);
+
+#endif /* _LIBADS_ADS_LDAP_PROTOS_H_ */
diff --git a/source3/libads/ads_proto.h b/source3/libads/ads_proto.h
index ed702de8a6c..324fa2a9cc1 100644
--- a/source3/libads/ads_proto.h
+++ b/source3/libads/ads_proto.h
@@ -1,3 +1,37 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * ads (active directory) utility library
+ *
+ * Copyright (C) Andrew Bartlett 2001
+ * Copyright (C) Andrew Tridgell 2001
+ * Copyright (C) Remus Koos (remuskoos@yahoo.com) 2001
+ * Copyright (C) Alexey Kotovich 2002
+ * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002-2003
+ * Copyright (C) Luke Howard 2003
+ * Copyright (C) Guenther Deschner 2003-2008
+ * Copyright (C) Rakesh Patel 2004
+ * Copyright (C) Dan Perry 2004
+ * Copyright (C) Jeremy Allison 2004
+ * Copyright (C) Gerald Carter 2006
+ * 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/>.
+ */
+
+#ifndef _LIBADS_ADS_PROTO_H_
+#define _LIBADS_ADS_PROTO_H_
+
/* The following definitions come from libads/ads_struct.c */
char *ads_build_path(const char *realm, const char *sep, const char *field, int reverse);
@@ -152,3 +186,5 @@ ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads,
/* The following definitions come from libads/util.c */
ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_principal);
+
+#endif /* _LIBADS_ADS_PROTO_H_ */
diff --git a/source3/libads/ads_status.c b/source3/libads/ads_status.c
index b99464118de..a9e59edaddb 100644
--- a/source3/libads/ads_status.c
+++ b/source3/libads/ads_status.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "smb_krb5.h"
#include "smb_ldap.h"
+#include "libads/ads_status.h"
/*
build a ADS_STATUS structure
diff --git a/source3/libads/ads_status.h b/source3/libads/ads_status.h
index 4c27e16f50e..ff7c1036380 100644
--- a/source3/libads/ads_status.h
+++ b/source3/libads/ads_status.h
@@ -1,3 +1,27 @@
+/*
+ Unix SMB/CIFS implementation.
+ ads (active directory) utility library
+ Copyright (C) Andrew Tridgell 2001
+ Copyright (C) Remus Koos 2001
+ Copyright (C) Andrew Bartlett 2001
+
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _LIBADS_ADS_STATUS_H_
+#define _LIBADS_ADS_STATUS_H_
/* there are 5 possible types of errors the ads subsystem can produce */
enum ads_error_type {ENUM_ADS_ERROR_KRB5, ENUM_ADS_ERROR_GSS,
@@ -40,3 +64,5 @@ ADS_STATUS ads_build_nt_error(enum ads_error_type etype,
NTSTATUS ads_ntstatus(ADS_STATUS status);
const char *ads_errstr(ADS_STATUS status);
NTSTATUS gss_err_to_ntstatus(uint32 maj, uint32 min);
+
+#endif /* _LIBADS_ADS_STATUS_H_ */
diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c
index 6f49b857da7..44279a24d77 100644
--- a/source3/libads/authdata.c
+++ b/source3/libads/authdata.c
@@ -78,7 +78,7 @@ NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx,
NT_STATUS_HAVE_NO_MEMORY(auth_princ);
local_service = talloc_asprintf(mem_ctx, "%s$@%s",
- global_myname(), lp_realm());
+ lp_netbios_name(), lp_realm());
NT_STATUS_HAVE_NO_MEMORY(local_service);
ret = kerberos_kinit_password_ext(auth_princ,
diff --git a/source3/libads/cldap.c b/source3/libads/cldap.c
index 5d2e900c05a..03fa17c26fd 100644
--- a/source3/libads/cldap.c
+++ b/source3/libads/cldap.c
@@ -30,7 +30,7 @@
*******************************************************************/
bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
- const char *server,
+ struct sockaddr_storage *ss,
const char *realm,
uint32_t nt_version,
struct netlogon_samlogon_response **_reply)
@@ -39,18 +39,12 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
struct cldap_netlogon io;
struct netlogon_samlogon_response *reply;
NTSTATUS status;
- struct sockaddr_storage ss;
char addrstr[INET6_ADDRSTRLEN];
const char *dest_str;
int ret;
struct tsocket_address *dest_addr;
- if (!interpret_string_addr_prefer_ipv4(&ss, server, 0)) {
- DEBUG(2,("Failed to resolve[%s] into an address for cldap\n",
- server));
- return false;
- }
- dest_str = print_sockaddr(addrstr, sizeof(addrstr), &ss);
+ dest_str = print_sockaddr(addrstr, sizeof(addrstr), ss);
ret = tsocket_address_inet_from_strings(mem_ctx, "ip",
dest_str, LDAP_PORT,
@@ -113,7 +107,7 @@ failed:
*******************************************************************/
bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx,
- const char *server,
+ struct sockaddr_storage *ss,
const char *realm,
struct NETLOGON_SAM_LOGON_RESPONSE_EX *reply5)
{
@@ -121,7 +115,7 @@ bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx,
struct netlogon_samlogon_response *reply = NULL;
bool ret;
- ret = ads_cldap_netlogon(mem_ctx, server, realm, nt_version, &reply);
+ ret = ads_cldap_netlogon(mem_ctx, ss, realm, nt_version, &reply);
if (!ret) {
return false;
}
diff --git a/source3/libads/cldap.h b/source3/libads/cldap.h
index e2d05ce7313..60e1c56038d 100644
--- a/source3/libads/cldap.h
+++ b/source3/libads/cldap.h
@@ -1,12 +1,39 @@
+/*
+ Samba Unix/Linux SMB client library
+ net ads cldap functions
+ Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
+ Copyright (C) 2003 Jim McDonough (jmcd@us.ibm.com)
+ Copyright (C) 2008 Guenther Deschner (gd@samba.org)
+ Copyright (C) 2009 Stefan Metzmacher (metze@samba.org)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _LIBADS_CLDAP_H_
+#define _LIBADS_CLDAP_H_
+
#include "../libcli/netlogon/netlogon.h"
/* The following definitions come from libads/cldap.c */
bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
- const char *server,
+ struct sockaddr_storage *ss,
const char *realm,
uint32_t nt_version,
struct netlogon_samlogon_response **reply);
bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx,
- const char *server,
+ struct sockaddr_storage *ss,
const char *realm,
struct NETLOGON_SAM_LOGON_RESPONSE_EX *reply5);
+
+#endif /* _LIBADS_CLDAP_H_ */
diff --git a/source3/libads/dns.c b/source3/libads/dns.c
index 113e63710bd..5eae10ec285 100644
--- a/source3/libads/dns.c
+++ b/source3/libads/dns.c
@@ -328,7 +328,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
buf_len = resp_len * sizeof(uint8);
if (buf_len) {
- if ((buffer = TALLOC_ARRAY(ctx, uint8, buf_len))
+ if ((buffer = talloc_array(ctx, uint8, buf_len))
== NULL ) {
DEBUG(0,("ads_dns_lookup_srv: "
"talloc() failed!\n"));
@@ -401,11 +401,19 @@ static NTSTATUS ads_dns_lookup_srv( TALLOC_CTX *ctx,
int rrnum;
int idx = 0;
NTSTATUS status;
+ const char *dns_hosts_file;
if ( !ctx || !name || !dclist ) {
return NT_STATUS_INVALID_PARAMETER;
}
+ dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
+ if (dns_hosts_file) {
+ return resolve_dns_hosts_file_as_dns_rr(dns_hosts_file,
+ name, true, ctx,
+ dclist, numdcs);
+ }
+
/* Send the request. May have to loop several times in case
of large replies */
@@ -434,7 +442,7 @@ static NTSTATUS ads_dns_lookup_srv( TALLOC_CTX *ctx,
answer_count));
if (answer_count) {
- if ((dcs = TALLOC_ZERO_ARRAY(ctx, struct dns_rr_srv,
+ if ((dcs = talloc_zero_array(ctx, struct dns_rr_srv,
answer_count)) == NULL ) {
DEBUG(0,("ads_dns_lookup_srv: "
"talloc() failure for %d char*'s\n",
@@ -526,13 +534,13 @@ static NTSTATUS ads_dns_lookup_srv( TALLOC_CTX *ctx,
/* allocate new memory */
if (dcs[i].num_ips == 0) {
- if ((dcs[i].ss_s = TALLOC_ARRAY(dcs,
+ if ((dcs[i].ss_s = talloc_array(dcs,
struct sockaddr_storage, 1 ))
== NULL ) {
return NT_STATUS_NO_MEMORY;
}
} else {
- if ((tmp_ss_s = TALLOC_REALLOC_ARRAY(dcs,
+ if ((tmp_ss_s = talloc_realloc(dcs,
dcs[i].ss_s,
struct sockaddr_storage,
dcs[i].num_ips+1))
@@ -590,11 +598,18 @@ NTSTATUS ads_dns_lookup_ns(TALLOC_CTX *ctx,
int rrnum;
int idx = 0;
NTSTATUS status;
+ const char *dns_hosts_file;
if ( !ctx || !dnsdomain || !nslist ) {
return NT_STATUS_INVALID_PARAMETER;
}
+ dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
+ if (dns_hosts_file) {
+ DEBUG(1, ("NO 'NS' lookup available when using resolv:host file"));
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
/* Send the request. May have to loop several times in case
of large replies */
@@ -623,7 +638,7 @@ NTSTATUS ads_dns_lookup_ns(TALLOC_CTX *ctx,
answer_count));
if (answer_count) {
- if ((nsarray = TALLOC_ARRAY(ctx, struct dns_rr_ns,
+ if ((nsarray = talloc_array(ctx, struct dns_rr_ns,
answer_count)) == NULL ) {
DEBUG(0,("ads_dns_lookup_ns: "
"talloc() failure for %d char*'s\n",
diff --git a/source3/libads/dns.h b/source3/libads/dns.h
index b747e97bb77..f53153ba263 100644
--- a/source3/libads/dns.h
+++ b/source3/libads/dns.h
@@ -20,42 +20,7 @@
#ifndef _ADS_DNS_H
#define _ADS_DNS_H
-/* DNS query section in replies */
-
-struct dns_query {
- const char *hostname;
- uint16 type;
- uint16 in_class;
-};
-
-/* DNS RR record in reply */
-
-struct dns_rr {
- const char *hostname;
- uint16 type;
- uint16 in_class;
- uint32 ttl;
- uint16 rdatalen;
- uint8 *rdata;
-};
-
-/* SRV records */
-
-struct dns_rr_srv {
- const char *hostname;
- uint16 priority;
- uint16 weight;
- uint16 port;
- size_t num_ips;
- struct sockaddr_storage *ss_s; /* support multi-homed hosts */
-};
-
-/* NS records */
-
-struct dns_rr_ns {
- const char *hostname;
- struct sockaddr_storage ss;
-};
+#include "libcli/dns/dns.h"
/* The following definitions come from libads/dns.c */
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c
index d496ade71b0..913d6900493 100644
--- a/source3/libads/kerberos.c
+++ b/source3/libads/kerberos.c
@@ -223,8 +223,8 @@ int kerberos_kinit_password_ext(const char *principal,
krb5_get_init_creds_opt_set_address_list(opt, addr->addrs);
}
- if ((code = krb5_get_init_creds_password(ctx, &my_creds, me, CONST_DISCARD(char *,password),
- kerb_prompter, CONST_DISCARD(char *,password),
+ if ((code = krb5_get_init_creds_password(ctx, &my_creds, me, discard_const_p(char,password),
+ kerb_prompter, discard_const_p(char, password),
0, NULL, opt))) {
goto out;
}
@@ -352,7 +352,7 @@ char* kerberos_standard_des_salt( void )
{
fstring salt;
- fstr_sprintf( salt, "host/%s.%s@", global_myname(), lp_realm() );
+ fstr_sprintf( salt, "host/%s.%s@", lp_netbios_name(), lp_realm() );
strlower_m( salt );
fstrcat( salt, lp_realm() );
@@ -958,22 +958,37 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
/* Insanity, sheer insanity..... */
if (strequal(realm, lp_realm())) {
- char linkpath[PATH_MAX+1];
- int lret;
-
- lret = readlink(SYSTEM_KRB5_CONF_PATH, linkpath, sizeof(linkpath)-1);
- if (lret != -1) {
- linkpath[lret] = '\0';
- }
-
- if (lret != -1 || strcmp(linkpath, fname) == 0) {
- /* Symlink already exists. */
- goto done;
+ SMB_STRUCT_STAT sbuf;
+
+ if (sys_lstat(SYSTEM_KRB5_CONF_PATH, &sbuf, false) == 0) {
+ if (S_ISLNK(sbuf.st_ex_mode) && sbuf.st_ex_size) {
+ int lret;
+ size_t alloc_size = sbuf.st_ex_size + 1;
+ char *linkpath = talloc_array(talloc_tos(), char,
+ alloc_size);
+ if (!linkpath) {
+ goto done;
+ }
+ lret = readlink(SYSTEM_KRB5_CONF_PATH, linkpath,
+ alloc_size - 1);
+ if (lret == -1) {
+ TALLOC_FREE(linkpath);
+ goto done;
+ }
+ linkpath[lret] = '\0';
+
+ if (strcmp(linkpath, fname) == 0) {
+ /* Symlink already exists. */
+ TALLOC_FREE(linkpath);
+ goto done;
+ }
+ TALLOC_FREE(linkpath);
+ }
}
/* Try and replace with a symlink. */
if (symlink(fname, SYSTEM_KRB5_CONF_PATH) == -1) {
- const char *newpath = SYSTEM_KRB5_CONF_PATH ## ".saved";
+ const char *newpath = SYSTEM_KRB5_CONF_PATH ".saved";
if (errno != EEXIST) {
DEBUG(0,("create_local_private_krb5_conf_for_domain: symlink "
"of %s to %s failed. Errno %s\n",
diff --git a/source3/libads/kerberos_keytab.c b/source3/libads/kerberos_keytab.c
index 6e1b7c08fe7..7654c666f4f 100644
--- a/source3/libads/kerberos_keytab.c
+++ b/source3/libads/kerberos_keytab.c
@@ -316,7 +316,7 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc)
goto out;
}
- my_fqdn = ads_get_dnshostname(ads, tmpctx, global_myname());
+ my_fqdn = ads_get_dnshostname(ads, tmpctx, lp_netbios_name());
if (!my_fqdn) {
DEBUG(0, (__location__ ": unable to determine machine "
"account's dns name in AD!\n"));
@@ -324,7 +324,7 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc)
goto out;
}
- machine_name = ads_get_samaccountname(ads, tmpctx, global_myname());
+ machine_name = ads_get_samaccountname(ads, tmpctx, lp_netbios_name());
if (!machine_name) {
DEBUG(0, (__location__ ": unable to determine machine "
"account's short name in AD!\n"));
@@ -380,7 +380,7 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc)
"'%s'\n", princ_s));
aderr = ads_add_service_principal_name(ads,
- global_myname(), my_fqdn, srvPrinc);
+ lp_netbios_name(), my_fqdn, srvPrinc);
if (!ADS_ERR_OK(aderr)) {
DEBUG(1, (__location__ ": failed to "
"ads_add_service_principal_name.\n"));
@@ -389,7 +389,7 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc)
}
}
- kvno = (krb5_kvno)ads_get_machine_kvno(ads, global_myname());
+ kvno = (krb5_kvno)ads_get_machine_kvno(ads, lp_netbios_name());
if (kvno == -1) {
/* -1 indicates failure, everything else is OK */
DEBUG(1, (__location__ ": ads_get_machine_kvno failed to "
@@ -458,7 +458,7 @@ int ads_keytab_flush(ADS_STRUCT *ads)
goto out;
}
- kvno = (krb5_kvno)ads_get_machine_kvno(ads, global_myname());
+ kvno = (krb5_kvno)ads_get_machine_kvno(ads, lp_netbios_name());
if (kvno == -1) {
/* -1 indicates a failure */
DEBUG(1, (__location__ ": Error determining the kvno.\n"));
@@ -472,7 +472,7 @@ int ads_keytab_flush(ADS_STRUCT *ads)
goto out;
}
- aderr = ads_clear_service_principal_names(ads, global_myname());
+ aderr = ads_clear_service_principal_names(ads, lp_netbios_name());
if (!ADS_ERR_OK(aderr)) {
DEBUG(1, (__location__ ": Error while clearing service "
"principal listings in LDAP.\n"));
@@ -547,7 +547,7 @@ int ads_keytab_create_default(ADS_STRUCT *ads)
goto done;
}
- machine_name = talloc_strdup(tmpctx, global_myname());
+ machine_name = talloc_strdup(tmpctx, lp_netbios_name());
if (!machine_name) {
ret = -1;
goto done;
diff --git a/source3/libads/kerberos_proto.h b/source3/libads/kerberos_proto.h
index afd57fe220c..406669cc49f 100644
--- a/source3/libads/kerberos_proto.h
+++ b/source3/libads/kerberos_proto.h
@@ -1,5 +1,39 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * kerberos utility library
+ *
+ * Copyright (C) Andrew Tridgell 2001
+ * Copyright (C) Remus Koos (remuskoos@yahoo.com) 2001
+ * Copyright (C) Luke Howard 2002-2003
+ * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
+ * Copyright (C) Guenther Deschner 2003-2008
+ * Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
+ * Copyright (C) Jeremy Allison 2004,2007
+ * Copyright (C) Stefan Metzmacher 2004-2005
+ * Copyright (C) Nalin Dahyabhai <nalin@redhat.com> 2004
+ * Copyright (C) Gerald Carter 2006
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _LIBADS_KERBEROS_PROTO_H_
+#define _LIBADS_KERBEROS_PROTO_H_
+
struct PAC_LOGON_INFO;
+#include "libads/ads_status.h"
+
/* The following definitions come from libads/kerberos_verify.c */
NTSTATUS ads_verify_ticket(TALLOC_CTX *mem_ctx,
@@ -67,3 +101,5 @@ ADS_STATUS kerberos_set_password(const char *kpasswd_server,
const char *auth_principal, const char *auth_password,
const char *target_principal, const char *new_password,
int time_offset);
+
+#endif /* _LIBADS_KERBEROS_PROTO_H_ */
diff --git a/source3/libads/kerberos_util.c b/source3/libads/kerberos_util.c
index 4762e1b9143..4935da8e79c 100644
--- a/source3/libads/kerberos_util.c
+++ b/source3/libads/kerberos_util.c
@@ -72,13 +72,13 @@ int ads_kinit_password(ADS_STRUCT *ads)
account_name = lp_workgroup();
} else {
/* always use the sAMAccountName for security = domain */
- /* global_myname()$@REA.LM */
+ /* lp_netbios_name()$@REA.LM */
if ( lp_security() == SEC_DOMAIN ) {
- fstr_sprintf( acct_name, "%s$", global_myname() );
+ fstr_sprintf( acct_name, "%s$", lp_netbios_name() );
account_name = acct_name;
}
else
- /* This looks like host/global_myname()@REA.LM */
+ /* This looks like host/lp_netbios_name()@REA.LM */
account_name = ads->auth.user_name;
}
diff --git a/source3/libads/kerberos_verify.c b/source3/libads/kerberos_verify.c
index fab38dc4deb..f11ea884778 100644
--- a/source3/libads/kerberos_verify.c
+++ b/source3/libads/kerberos_verify.c
@@ -151,10 +151,10 @@ static bool ads_keytab_verify_ticket(krb5_context context,
* clients might want to use for authenticating to the file
* service. We allow name$,{host,cifs}/{name,fqdn,name.REALM}. */
- fstrcpy(my_name, global_myname());
+ fstrcpy(my_name, lp_netbios_name());
my_fqdn[0] = '\0';
- name_to_fqdn(my_fqdn, global_myname());
+ name_to_fqdn(my_fqdn, lp_netbios_name());
err = asprintf(&valid_princ_formats[0],
"%s$@%s", my_name, lp_realm());
@@ -534,7 +534,7 @@ NTSTATUS ads_verify_ticket(TALLOC_CTX *mem_ctx,
krb5_auth_con_setflags( context, auth_context, flags );
}
- if (asprintf(&host_princ_s, "%s$", global_myname()) == -1) {
+ if (asprintf(&host_princ_s, "%s$", lp_netbios_name()) == -1) {
goto out;
}
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 90c645c44ad..128c1337600 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -59,14 +59,47 @@ static void gotalarm_sig(int signum)
gotalarm = 1;
}
- LDAP *ldap_open_with_timeout(const char *server, int port, unsigned int to)
+ LDAP *ldap_open_with_timeout(const char *server,
+ struct sockaddr_storage *ss,
+ int port, unsigned int to)
{
LDAP *ldp = NULL;
-
DEBUG(10, ("Opening connection to LDAP server '%s:%d', timeout "
"%u seconds\n", server, port, to));
+#if defined(HAVE_LDAP_INIT_FD) && defined(SOCKET_WRAPPER)
+ /* Only use this private LDAP function if we are in make test,
+ * as this is the best way to get the emulated TCP socket into
+ * OpenLDAP */
+ if (socket_wrapper_dir() != NULL) {
+ int fd, ldap_err;
+ NTSTATUS status;
+ char *uri;
+
+ status = open_socket_out(ss, port, to, &fd);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return NULL;
+ }
+
+#ifndef LDAP_PROTO_TCP
+#define LDAP_PROTO_TCP 1
+#endif
+ uri = talloc_asprintf(talloc_tos(), "ldap://%s:%u", server, port);
+ if (uri == NULL) {
+ return NULL;
+ }
+ ldap_err = ldap_init_fd(fd, LDAP_PROTO_TCP, uri, &ldp);
+ talloc_free(uri);
+
+ if (ldap_err != LDAP_SUCCESS) {
+ return NULL;
+ }
+ return ldp;
+ }
+#endif
+
/* Setup timeout */
gotalarm = 0;
CatchSignal(SIGALRM, gotalarm_sig);
@@ -196,45 +229,32 @@ bool ads_closest_dc(ADS_STRUCT *ads)
*/
static bool ads_try_connect(ADS_STRUCT *ads, const char *server, bool gc)
{
- char *srv;
struct NETLOGON_SAM_LOGON_RESPONSE_EX cldap_reply;
TALLOC_CTX *frame = talloc_stackframe();
bool ret = false;
+ struct sockaddr_storage ss;
+ char addr[INET6_ADDRSTRLEN];
if (!server || !*server) {
TALLOC_FREE(frame);
return False;
}
- if (!is_ipaddress(server)) {
- struct sockaddr_storage ss;
- char addr[INET6_ADDRSTRLEN];
-
- if (!resolve_name(server, &ss, 0x20, true)) {
- DEBUG(5,("ads_try_connect: unable to resolve name %s\n",
- server ));
- TALLOC_FREE(frame);
- return false;
- }
- print_sockaddr(addr, sizeof(addr), &ss);
- srv = talloc_strdup(frame, addr);
- } else {
- /* this copes with inet_ntoa brokenness */
- srv = talloc_strdup(frame, server);
- }
-
- if (!srv) {
+ if (!resolve_name(server, &ss, 0x20, true)) {
+ DEBUG(5,("ads_try_connect: unable to resolve name %s\n",
+ server ));
TALLOC_FREE(frame);
return false;
}
+ print_sockaddr(addr, sizeof(addr), &ss);
DEBUG(5,("ads_try_connect: sending CLDAP request to %s (realm: %s)\n",
- srv, ads->server.realm));
+ addr, ads->server.realm));
ZERO_STRUCT( cldap_reply );
- if ( !ads_cldap_netlogon_5(frame, srv, ads->server.realm, &cldap_reply ) ) {
- DEBUG(3,("ads_try_connect: CLDAP request %s failed.\n", srv));
+ if ( !ads_cldap_netlogon_5(frame, &ss, ads->server.realm, &cldap_reply ) ) {
+ DEBUG(3,("ads_try_connect: CLDAP request %s failed.\n", addr));
ret = false;
goto out;
}
@@ -243,7 +263,7 @@ static bool ads_try_connect(ADS_STRUCT *ads, const char *server, bool gc)
if ( !(cldap_reply.server_type & NBT_SERVER_LDAP) ) {
DEBUG(1,("ads_try_connect: %s's CLDAP reply says it is not an LDAP server!\n",
- srv));
+ addr));
ret = false;
goto out;
}
@@ -273,13 +293,7 @@ static bool ads_try_connect(ADS_STRUCT *ads, const char *server, bool gc)
ads->server.workgroup = SMB_STRDUP(cldap_reply.domain_name);
ads->ldap.port = gc ? LDAP_GC_PORT : LDAP_PORT;
- if (!interpret_string_addr(&ads->ldap.ss, srv, 0)) {
- DEBUG(1,("ads_try_connect: unable to convert %s "
- "to an address\n",
- srv));
- ret = false;
- goto out;
- }
+ ads->ldap.ss = ss;
/* Store our site name. */
sitename_store( cldap_reply.domain_name, cldap_reply.client_site);
@@ -515,7 +529,7 @@ ADS_STATUS ads_connect_gc(ADS_STRUCT *ads)
TALLOC_CTX *frame = talloc_stackframe();
struct dns_rr_srv *gcs_list;
int num_gcs;
- char *realm = ads->server.realm;
+ const char *realm = ads->server.realm;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
int i;
@@ -643,7 +657,7 @@ got_connection:
/* Must use the userPrincipalName value here or sAMAccountName
and not servicePrincipalName; found by Guenther Deschner */
- if (asprintf(&ads->auth.user_name, "%s$", global_myname() ) == -1) {
+ if (asprintf(&ads->auth.user_name, "%s$", lp_netbios_name() ) == -1) {
DEBUG(0,("ads_connect: asprintf fail.\n"));
ads->auth.user_name = NULL;
}
@@ -658,18 +672,6 @@ got_connection:
ads->auth.kdc_server = SMB_STRDUP(addr);
}
-#if KRB5_DNS_HACK
- /* this is a really nasty hack to avoid ADS DNS problems. It needs a patch
- to MIT kerberos to work (tridge) */
- {
- char *env = NULL;
- if (asprintf(&env, "KRB5_KDC_ADDRESS_%s", ads->config.realm) > 0) {
- setenv(env, ads->auth.kdc_server, 1);
- free(env);
- }
- }
-#endif
-
/* If the caller() requested no LDAP bind, then we are done */
if (ads->auth.flags & ADS_AUTH_NO_BIND) {
@@ -686,6 +688,7 @@ got_connection:
/* Otherwise setup the TCP LDAP session */
ads->ldap.ld = ldap_open_with_timeout(ads->config.ldap_server_name,
+ &ads->ldap.ss,
ads->ldap.port, lp_ldap_timeout());
if (ads->ldap.ld == NULL) {
status = ADS_ERROR(LDAP_OPERATIONS_ERROR);
@@ -781,13 +784,13 @@ static struct berval *dup_berval(TALLOC_CTX *ctx, const struct berval *in_val)
if (!in_val) return NULL;
- value = TALLOC_ZERO_P(ctx, struct berval);
+ value = talloc_zero(ctx, struct berval);
if (value == NULL)
return NULL;
if (in_val->bv_len == 0) return value;
value->bv_len = in_val->bv_len;
- value->bv_val = (char *)TALLOC_MEMDUP(ctx, in_val->bv_val,
+ value->bv_val = (char *)talloc_memdup(ctx, in_val->bv_val,
in_val->bv_len);
return value;
}
@@ -804,7 +807,7 @@ static struct berval **ads_dup_values(TALLOC_CTX *ctx,
if (!in_vals) return NULL;
for (i=0; in_vals[i]; i++)
; /* count values */
- values = TALLOC_ZERO_ARRAY(ctx, struct berval *, i+1);
+ values = talloc_zero_array(ctx, struct berval *, i+1);
if (!values) return NULL;
for (i=0; in_vals[i]; i++) {
@@ -825,7 +828,7 @@ static char **ads_push_strvals(TALLOC_CTX *ctx, const char **in_vals)
if (!in_vals) return NULL;
for (i=0; in_vals[i]; i++)
; /* count values */
- values = TALLOC_ZERO_ARRAY(ctx, char *, i+1);
+ values = talloc_zero_array(ctx, char *, i+1);
if (!values) return NULL;
for (i=0; in_vals[i]; i++) {
@@ -849,7 +852,7 @@ static char **ads_pull_strvals(TALLOC_CTX *ctx, const char **in_vals)
if (!in_vals) return NULL;
for (i=0; in_vals[i]; i++)
; /* count values */
- values = TALLOC_ZERO_ARRAY(ctx, char *, i+1);
+ values = talloc_zero_array(ctx, char *, i+1);
if (!values) return NULL;
for (i=0; in_vals[i]; i++) {
@@ -937,21 +940,21 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
ber_printf(cookie_be, "{io}", (ber_int_t) 1000, "", 0);
}
ber_flatten(cookie_be, &cookie_bv);
- PagedResults.ldctl_oid = CONST_DISCARD(char *, ADS_PAGE_CTL_OID);
+ PagedResults.ldctl_oid = discard_const_p(char, ADS_PAGE_CTL_OID);
PagedResults.ldctl_iscritical = (char) 1;
PagedResults.ldctl_value.bv_len = cookie_bv->bv_len;
PagedResults.ldctl_value.bv_val = cookie_bv->bv_val;
- NoReferrals.ldctl_oid = CONST_DISCARD(char *, ADS_NO_REFERRALS_OID);
+ NoReferrals.ldctl_oid = discard_const_p(char, ADS_NO_REFERRALS_OID);
NoReferrals.ldctl_iscritical = (char) 0;
NoReferrals.ldctl_value.bv_len = 0;
- NoReferrals.ldctl_value.bv_val = CONST_DISCARD(char *, "");
+ NoReferrals.ldctl_value.bv_val = discard_const_p(char, "");
if (external_control &&
(strequal(external_control->control, ADS_EXTENDED_DN_OID) ||
strequal(external_control->control, ADS_SD_FLAGS_OID))) {
- ExternalCtrl.ldctl_oid = CONST_DISCARD(char *, external_control->control);
+ ExternalCtrl.ldctl_oid = discard_const_p(char, external_control->control);
ExternalCtrl.ldctl_iscritical = (char) external_control->critical;
/* win2k does not accept a ldctl_value beeing passed in */
@@ -1382,7 +1385,7 @@ ADS_MODLIST ads_init_mods(TALLOC_CTX *ctx)
#define ADS_MODLIST_ALLOC_SIZE 10
LDAPMod **mods;
- if ((mods = TALLOC_ZERO_ARRAY(ctx, LDAPMod *, ADS_MODLIST_ALLOC_SIZE + 1)))
+ if ((mods = talloc_zero_array(ctx, LDAPMod *, ADS_MODLIST_ALLOC_SIZE + 1)))
/* -1 is safety to make sure we don't go over the end.
need to reset it to NULL before doing ldap modify */
mods[ADS_MODLIST_ALLOC_SIZE] = (LDAPMod *) -1;
@@ -1419,7 +1422,7 @@ static ADS_STATUS ads_modlist_add(TALLOC_CTX *ctx, ADS_MODLIST *mods,
for (curmod=0; modlist[curmod] && modlist[curmod] != (LDAPMod *) -1;
curmod++);
if (modlist[curmod] == (LDAPMod *) -1) {
- if (!(modlist = TALLOC_REALLOC_ARRAY(ctx, modlist, LDAPMod *,
+ if (!(modlist = talloc_realloc(ctx, modlist, LDAPMod *,
curmod+ADS_MODLIST_ALLOC_SIZE+1)))
return ADS_ERROR(LDAP_NO_MEMORY);
memset(&modlist[curmod], 0,
@@ -1428,7 +1431,7 @@ static ADS_STATUS ads_modlist_add(TALLOC_CTX *ctx, ADS_MODLIST *mods,
*mods = (ADS_MODLIST)modlist;
}
- if (!(modlist[curmod] = TALLOC_ZERO_P(ctx, LDAPMod)))
+ if (!(modlist[curmod] = talloc_zero(ctx, LDAPMod)))
return ADS_ERROR(LDAP_NO_MEMORY);
modlist[curmod]->mod_type = talloc_strdup(ctx, name);
if (mod_op & LDAP_MOD_BVALUES) {
@@ -1521,7 +1524,7 @@ ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods)
non-existent attribute (but allowable for the object) to run
*/
LDAPControl PermitModify = {
- CONST_DISCARD(char *, ADS_PERMIT_MODIFY_OID),
+ discard_const_p(char, ADS_PERMIT_MODIFY_OID),
{0, NULL},
(char) 1};
LDAPControl *controls[2];
@@ -2225,7 +2228,7 @@ static bool ads_dump_field(ADS_STRUCT *ads, char *field, void **values, void *da
}
for (i=0; handlers[i].name; i++) {
- if (StrCaseCmp(handlers[i].name, field) == 0) {
+ if (strcasecmp_m(handlers[i].name, field) == 0) {
if (!values) /* first time, indicate string or not */
return handlers[i].string;
handlers[i].handler(ads, field, (struct berval **) values);
@@ -2430,7 +2433,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
*num_values = ldap_count_values(values);
- ret = TALLOC_ARRAY(mem_ctx, char *, *num_values + 1);
+ ret = talloc_array(mem_ctx, char *, *num_values + 1);
if (!ret) {
ldap_value_free(values);
return NULL;
@@ -2543,7 +2546,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
return NULL;
}
- strings = TALLOC_REALLOC_ARRAY(mem_ctx, current_strings, char *,
+ strings = talloc_realloc(mem_ctx, current_strings, char *,
*num_strings + num_new_strings);
if (strings == NULL) {
@@ -2666,7 +2669,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
/* nop */ ;
if (i) {
- (*sids) = TALLOC_ARRAY(mem_ctx, struct dom_sid, i);
+ (*sids) = talloc_array(mem_ctx, struct dom_sid, i);
if (!(*sids)) {
ldap_value_free_len(values);
return 0;
@@ -2854,7 +2857,7 @@ ADS_STATUS ads_current_time(ADS_STRUCT *ads)
if (ads->config.current_time != 0) {
ads->auth.time_offset = ads->config.current_time - time(NULL);
- DEBUG(4,("time offset is %d seconds\n", ads->auth.time_offset));
+ DEBUG(4,("KDC time offset is %d seconds\n", ads->auth.time_offset));
}
ads_msgfree(ads, res);
@@ -3284,7 +3287,7 @@ ADS_STATUS ads_get_sid_from_extended_dn(TALLOC_CTX *mem_ctx,
return 0;
}
- (*sids) = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, dn_count + 1);
+ (*sids) = talloc_zero_array(mem_ctx, struct dom_sid, dn_count + 1);
if (!(*sids)) {
TALLOC_FREE(dn_strings);
return 0;
@@ -3322,10 +3325,10 @@ char* ads_get_dnshostname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine
int count = 0;
char *name = NULL;
- status = ads_find_machine_acct(ads, &res, global_myname());
+ status = ads_find_machine_acct(ads, &res, lp_netbios_name());
if (!ADS_ERR_OK(status)) {
DEBUG(0,("ads_get_dnshostname: Failed to find account for %s\n",
- global_myname()));
+ lp_netbios_name()));
goto out;
}
@@ -3357,7 +3360,7 @@ char* ads_get_upn( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name )
status = ads_find_machine_acct(ads, &res, machine_name);
if (!ADS_ERR_OK(status)) {
DEBUG(0,("ads_get_upn: Failed to find account for %s\n",
- global_myname()));
+ lp_netbios_name()));
goto out;
}
@@ -3386,10 +3389,10 @@ char* ads_get_samaccountname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *mach
int count = 0;
char *name = NULL;
- status = ads_find_machine_acct(ads, &res, global_myname());
+ status = ads_find_machine_acct(ads, &res, lp_netbios_name());
if (!ADS_ERR_OK(status)) {
DEBUG(0,("ads_get_dnshostname: Failed to find account for %s\n",
- global_myname()));
+ lp_netbios_name()));
goto out;
}
@@ -3482,7 +3485,7 @@ ADS_STATUS ads_leave_realm(ADS_STRUCT *ads, const char *hostname)
pldap_control[0] = &ldap_control;
memset(&ldap_control, 0, sizeof(LDAPControl));
- ldap_control.ldctl_oid = (char *)LDAP_SERVER_TREE_DELETE_OID;
+ ldap_control.ldctl_oid = discard_const_p(char, LDAP_SERVER_TREE_DELETE_OID);
/* hostname must be lowercase */
host = SMB_STRDUP(hostname);
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c
index 235ef7f9547..8ff9f9bdc9d 100644
--- a/source3/libads/ldap_printer.c
+++ b/source3/libads/ldap_printer.c
@@ -22,9 +22,7 @@
#include "rpc_client/rpc_client.h"
#include "../librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_client/cli_spoolss.h"
-#include "registry.h"
#include "registry/reg_objects.h"
-#include "nt_printing.h"
#ifdef HAVE_ADS
@@ -201,7 +199,7 @@ static bool map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
};
if (num_vals) {
- str_values = TALLOC_ARRAY(ctx, char *, num_vals + 1);
+ str_values = talloc_array(ctx, char *, num_vals + 1);
if (!str_values) {
return False;
}
@@ -291,7 +289,7 @@ static void map_regval_to_ads(TALLOC_CTX *ctx, ADS_MODLIST *mods,
int i;
for (i=0; map[i].valname; i++) {
- if (StrCaseCmp(map[i].valname, regval_name(value)) == 0) {
+ if (strcasecmp_m(map[i].valname, regval_name(value)) == 0) {
if (!map[i].fn(ctx, mods, value)) {
DEBUG(5, ("Add of value %s to modlist failed\n", regval_name(value)));
} else {
diff --git a/source3/libads/ldap_schema.c b/source3/libads/ldap_schema.c
index 51aac14906c..7368be830fb 100644
--- a/source3/libads/ldap_schema.c
+++ b/source3/libads/ldap_schema.c
@@ -76,11 +76,11 @@ static ADS_STATUS ads_get_attrnames_by_oids(ADS_STRUCT *ads,
goto out;
}
- if (((*names) = TALLOC_ARRAY(mem_ctx, char *, *count)) == NULL) {
+ if (((*names) = talloc_array(mem_ctx, char *, *count)) == NULL) {
status = ADS_ERROR(LDAP_NO_MEMORY);
goto out;
}
- if (((*OIDs_out) = TALLOC_ARRAY(mem_ctx, char *, *count)) == NULL) {
+ if (((*OIDs_out) = talloc_array(mem_ctx, char *, *count)) == NULL) {
status = ADS_ERROR(LDAP_NO_MEMORY);
goto out;
}
@@ -252,7 +252,7 @@ ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx,
return ADS_ERROR(LDAP_NO_MEMORY);
}
- if ( (schema = TALLOC_P(mem_ctx, struct posix_schema)) == NULL ) {
+ if ( (schema = talloc(mem_ctx, struct posix_schema)) == NULL ) {
TALLOC_FREE( ctx );
return ADS_ERROR(LDAP_NO_MEMORY);
}
diff --git a/source3/libads/ldap_schema.h b/source3/libads/ldap_schema.h
index 44964dd1c15..fc4ed078085 100644
--- a/source3/libads/ldap_schema.h
+++ b/source3/libads/ldap_schema.h
@@ -1,3 +1,26 @@
+/*
+ Unix SMB/CIFS implementation.
+ ads (active directory) utility library
+ Copyright (C) Guenther Deschner 2005-2007
+ Copyright (C) Gerald (Jerry) Carter 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _LIBADS_LDAP_SCHEMA_H_
+#define _LIBADS_LDAP_SCHEMA_H_
+
/* used to remember the names of the posix attributes in AD */
/* see the rfc2307 & sfu nss backends */
@@ -55,3 +78,5 @@ ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx,
ADS_STRUCT *ads,
enum wb_posix_mapping map_type,
struct posix_schema **s ) ;
+
+#endif /* _LIBADS_LDAP_SCHEMA_H_ */
diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c
index ab77abdd16b..2f1c1b8e0a5 100644
--- a/source3/libads/ldap_utils.c
+++ b/source3/libads/ldap_utils.c
@@ -242,7 +242,7 @@ ADS_STATUS ads_ranged_search(ADS_STRUCT *ads,
*num_strings = 0;
*strings = NULL;
- attrs = TALLOC_ARRAY(mem_ctx, const char *, 3);
+ attrs = talloc_array(mem_ctx, const char *, 3);
ADS_ERROR_HAVE_NO_MEMORY(attrs);
attrs[0] = talloc_strdup(mem_ctx, range_attr);
diff --git a/source3/libads/ndr.c b/source3/libads/ndr.c
index c6b11213961..c667aa36376 100644
--- a/source3/libads/ndr.c
+++ b/source3/libads/ndr.c
@@ -22,7 +22,7 @@
#include "includes.h"
#include "ads.h"
#include "../librpc/gen_ndr/ndr_netlogon.h"
-#include "librpc/ndr/util.h"
+#include "../librpc/ndr/libndr.h"
static void ndr_print_ads_auth_flags(struct ndr_print *ndr, const char *name, uint32_t r)
{
diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c
index e7daa8aec63..45cf569c791 100644
--- a/source3/libads/sasl.c
+++ b/source3/libads/sasl.c
@@ -141,7 +141,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
struct ntlmssp_state *ntlmssp_state;
nt_status = ntlmssp_client_start(NULL,
- global_myname(),
+ lp_netbios_name(),
lp_workgroup(),
lp_client_ntlmv2_auth(),
&ntlmssp_state);
@@ -388,7 +388,7 @@ static ADS_STATUS ads_sasl_spnego_gsskrb5_bind(ADS_STRUCT *ads, const gss_name_t
uint32 minor_status;
int gss_rc, rc;
gss_OID_desc krb5_mech_type =
- {9, CONST_DISCARD(char *, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02") };
+ {9, discard_const_p(char, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02") };
gss_OID mech_type = &krb5_mech_type;
gss_OID actual_mech_type = GSS_C_NULL_OID;
const char *spnego_mechs[] = {OID_KERBEROS5_OLD, OID_KERBEROS5, OID_NTLMSSP, NULL};
@@ -722,7 +722,7 @@ static ADS_STATUS ads_generate_service_principal(ADS_STRUCT *ads,
gss_buffer_desc input_name;
/* GSS_KRB5_NT_PRINCIPAL_NAME */
gss_OID_desc nt_principal =
- {10, CONST_DISCARD(char *, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01")};
+ {10, discard_const_p(char, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01")};
uint32 minor_status;
int gss_rc;
#endif
diff --git a/source3/libgpo/gpext/registry.c b/source3/libgpo/gpext/registry.c
index eb49b19b203..b0ec7b88d90 100644
--- a/source3/libgpo/gpext/registry.c
+++ b/source3/libgpo/gpext/registry.c
@@ -111,14 +111,14 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
ZERO_STRUCTP(*reg_entry);
- data = TALLOC_ZERO_P(mem_ctx, struct registry_value);
+ data = talloc_zero(mem_ctx, struct registry_value);
if (!data)
return false;
data->type = r->type;
data->data = data_blob_talloc(data, r->data, r->size);
- entry = TALLOC_ZERO_P(mem_ctx, struct gp_registry_entry);
+ entry = talloc_zero(mem_ctx, struct gp_registry_entry);
if (!entry)
return false;
@@ -327,7 +327,7 @@ static NTSTATUS registry_get_reg_config(TALLOC_CTX *mem_ctx,
{ NULL, REG_NONE, NULL }
};
- info = TALLOC_ZERO_P(mem_ctx, struct gp_extension_reg_info);
+ info = talloc_zero(mem_ctx, struct gp_extension_reg_info);
NT_STATUS_HAVE_NO_MEMORY(info);
status = gp_ext_info_add_entry(mem_ctx, GP_EXT_NAME,
diff --git a/source3/libgpo/gpext/scripts.c b/source3/libgpo/gpext/scripts.c
index 3e977378ee4..0b6748507a7 100644
--- a/source3/libgpo/gpext/scripts.c
+++ b/source3/libgpo/gpext/scripts.c
@@ -62,7 +62,7 @@ static NTSTATUS scripts_get_reg_config(TALLOC_CTX *mem_ctx,
{ NULL, REG_NONE, NULL },
};
- info = TALLOC_ZERO_P(mem_ctx, struct gp_extension_reg_info);
+ info = talloc_zero(mem_ctx, struct gp_extension_reg_info);
NT_STATUS_HAVE_NO_MEMORY(info);
status = gp_ext_info_add_entry(mem_ctx, GP_EXT_NAME,
@@ -89,10 +89,10 @@ static NTSTATUS generate_gp_registry_entry(TALLOC_CTX *mem_ctx,
struct gp_registry_entry *entry = NULL;
struct registry_value *data = NULL;
- entry = TALLOC_ZERO_P(mem_ctx, struct gp_registry_entry);
+ entry = talloc_zero(mem_ctx, struct gp_registry_entry);
NT_STATUS_HAVE_NO_MEMORY(entry);
- data = TALLOC_ZERO_P(mem_ctx, struct registry_value);
+ data = talloc_zero(mem_ctx, struct registry_value);
NT_STATUS_HAVE_NO_MEMORY(data);
data->type = data_type;
diff --git a/source3/libgpo/gpext/security.c b/source3/libgpo/gpext/security.c
index dea0de33f93..b68840d2f6a 100644
--- a/source3/libgpo/gpext/security.c
+++ b/source3/libgpo/gpext/security.c
@@ -202,7 +202,7 @@ static NTSTATUS security_get_reg_config(TALLOC_CTX *mem_ctx,
{ NULL, REG_NONE, NULL }
};
- info = TALLOC_ZERO_P(mem_ctx, struct gp_extension_reg_info);
+ info = talloc_zero(mem_ctx, struct gp_extension_reg_info);
NT_STATUS_HAVE_NO_MEMORY(info);
status = gp_ext_info_add_entry(mem_ctx, GP_EXT_NAME,
diff --git a/source3/libgpo/gpext/wscript_build b/source3/libgpo/gpext/wscript_build
index bfdb4d0bf6b..3c835dd8cd0 100644
--- a/source3/libgpo/gpext/wscript_build
+++ b/source3/libgpo/gpext/wscript_build
@@ -8,6 +8,7 @@ GPEXT_SRC = '''../../../libgpo/gpext/gpext.c'''
bld.SAMBA3_SUBSYSTEM('gpext',
source=GPEXT_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_MODULE('gpext_registry',
diff --git a/source3/libgpo/gpo_filesync.c b/source3/libgpo/gpo_filesync.c
index be964a201e4..91e1c2725ac 100644
--- a/source3/libgpo/gpo_filesync.c
+++ b/source3/libgpo/gpo_filesync.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "system/filesys.h"
+#include "libsmb/libsmb.h"
#include "../libgpo/gpo.h"
#include "libgpo/gpo_proto.h"
@@ -150,7 +151,7 @@ static NTSTATUS gpo_sync_func(const char *mnt,
DEBUG(5,("gpo_sync_func: got mask: [%s], name: [%s]\n",
mask, info->name));
- if (info->mode & aDIR) {
+ if (info->mode & FILE_ATTRIBUTE_DIRECTORY) {
DEBUG(3,("got dir: [%s]\n", info->name));
@@ -226,9 +227,9 @@ NTSTATUS gpo_sync_directories(TALLOC_CTX *mem_ctx,
ctx.mem_ctx = mem_ctx;
ctx.cli = cli;
- ctx.remote_path = CONST_DISCARD(char *, nt_path);
- ctx.local_path = CONST_DISCARD(char *, local_path);
- ctx.attribute = (aSYSTEM | aHIDDEN | aDIR);
+ ctx.remote_path = discard_const_p(char, nt_path);
+ ctx.local_path = discard_const_p(char, local_path);
+ ctx.attribute = (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY);
ctx.mask = talloc_asprintf(mem_ctx,
"%s\\*",
diff --git a/source3/libgpo/gpo_proto.h b/source3/libgpo/gpo_proto.h
index 8bc5874c9dd..fa2f87338d2 100644
--- a/source3/libgpo/gpo_proto.h
+++ b/source3/libgpo/gpo_proto.h
@@ -1,3 +1,25 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Group Policy Object Support
+ *
+ * Copyright (C) Guenther Deschner 2006-2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * 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 _LIBGPO_GPO_PROTO_H_
+#define _LIBGPO_GPO_PROTO_H_
/* The following definitions come from libgpo/gpo_filesync.c */
@@ -75,3 +97,5 @@ WERROR reg_apply_registry_entry(TALLOC_CTX *mem_ctx,
struct gp_registry_entry *entry,
const struct security_token *token,
uint32_t flags);
+
+#endif /* _LIBGPO_GPO_PROTO_H_ */
diff --git a/source3/libgpo/gpo_reg.c b/source3/libgpo/gpo_reg.c
index d9fcd43cafc..5142e919cc9 100644
--- a/source3/libgpo/gpo_reg.c
+++ b/source3/libgpo/gpo_reg.c
@@ -36,7 +36,7 @@ struct security_token *registry_create_system_token(TALLOC_CTX *mem_ctx)
{
struct security_token *token = NULL;
- token = TALLOC_ZERO_P(mem_ctx, struct security_token);
+ token = talloc_zero(mem_ctx, struct security_token);
if (!token) {
DEBUG(1,("talloc failed\n"));
return NULL;
@@ -74,7 +74,7 @@ WERROR gp_init_reg_ctx(TALLOC_CTX *mem_ctx,
return werr;
}
- tmp_ctx = TALLOC_ZERO_P(mem_ctx, struct gp_registry_context);
+ tmp_ctx = talloc_zero(mem_ctx, struct gp_registry_context);
W_ERROR_HAVE_NO_MEMORY(tmp_ctx);
if (token) {
@@ -395,7 +395,7 @@ static WERROR gp_reg_read_groupmembership(TALLOC_CTX *mem_ctx,
int num_token_sids = 0;
struct security_token *tmp_token = NULL;
- tmp_token = TALLOC_ZERO_P(mem_ctx, struct security_token);
+ tmp_token = talloc_zero(mem_ctx, struct security_token);
W_ERROR_HAVE_NO_MEMORY(tmp_token);
path = gp_reg_groupmembership_path(mem_ctx, object_sid, flags);
@@ -602,7 +602,7 @@ static WERROR gp_read_reg_gpo(TALLOC_CTX *mem_ctx,
return WERR_INVALID_PARAM;
}
- gpo = TALLOC_ZERO_P(mem_ctx, struct GROUP_POLICY_OBJECT);
+ gpo = talloc_zero(mem_ctx, struct GROUP_POLICY_OBJECT);
W_ERROR_HAVE_NO_MEMORY(gpo);
werr = gp_read_reg_gpovals(mem_ctx, key, gpo);
@@ -901,7 +901,7 @@ bool add_gp_registry_entry_to_array(TALLOC_CTX *mem_ctx,
struct gp_registry_entry **entries,
size_t *num)
{
- *entries = TALLOC_REALLOC_ARRAY(mem_ctx, *entries,
+ *entries = talloc_realloc(mem_ctx, *entries,
struct gp_registry_entry,
(*num)+1);
diff --git a/source3/libnet/libnet_dssync.c b/source3/libnet/libnet_dssync.c
index 47ceff15092..c768226e8ba 100644
--- a/source3/libnet/libnet_dssync.c
+++ b/source3/libnet/libnet_dssync.c
@@ -54,7 +54,7 @@ NTSTATUS libnet_dssync_init_context(TALLOC_CTX *mem_ctx,
{
struct dssync_context *ctx;
- ctx = TALLOC_ZERO_P(mem_ctx, struct dssync_context);
+ ctx = talloc_zero(mem_ctx, struct dssync_context);
NT_STATUS_HAVE_NO_MEMORY(ctx);
talloc_set_destructor(ctx, libnet_dssync_free_context);
@@ -339,7 +339,7 @@ static NTSTATUS libnet_dssync_build_request(TALLOC_CTX *mem_ctx,
level = 5;
}
- nc = TALLOC_ZERO_P(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
+ nc = talloc_zero(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
if (!nc) {
status = NT_STATUS_NO_MEMORY;
goto fail;
@@ -351,7 +351,7 @@ static NTSTATUS libnet_dssync_build_request(TALLOC_CTX *mem_ctx,
if (!ctx->single_object_replication &&
!ctx->force_full_replication && utdv)
{
- cursors = TALLOC_ZERO_P(mem_ctx,
+ cursors = talloc_zero(mem_ctx,
struct drsuapi_DsReplicaCursorCtrEx);
if (!cursors) {
status = NT_STATUS_NO_MEMORY;
@@ -442,7 +442,7 @@ static NTSTATUS libnet_dssync_getncchanges(TALLOC_CTX *mem_ctx,
struct dcerpc_binding_handle *b = ctx->cli->binding_handle;
if (!ctx->single_object_replication) {
- new_utdv = TALLOC_ZERO_P(mem_ctx, struct replUpToDateVectorBlob);
+ new_utdv = talloc_zero(mem_ctx, struct replUpToDateVectorBlob);
if (!new_utdv) {
status = NT_STATUS_NO_MEMORY;
goto out;
diff --git a/source3/libnet/libnet_dssync_keytab.c b/source3/libnet/libnet_dssync_keytab.c
index 65085cd96eb..763f8baf4d6 100644
--- a/source3/libnet/libnet_dssync_keytab.c
+++ b/source3/libnet/libnet_dssync_keytab.c
@@ -200,7 +200,7 @@ static NTSTATUS parse_supplemental_credentials(TALLOC_CTX *mem_ctx,
goto done;
}
- pkb = TALLOC_ZERO_P(mem_ctx, struct package_PrimaryKerberosBlob);
+ pkb = talloc_zero(mem_ctx, struct package_PrimaryKerberosBlob);
if (!pkb) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -276,7 +276,7 @@ static NTSTATUS parse_object(TALLOC_CTX *mem_ctx,
if (attr->attid == DRSUAPI_ATTID_servicePrincipalName) {
uint32_t count;
num_spns = attr->value_ctr.num_values;
- spn = TALLOC_ARRAY(mem_ctx, char *, num_spns);
+ spn = talloc_array(mem_ctx, char *, num_spns);
for (count = 0; count < num_spns; count++) {
blob = attr->value_ctr.values[count].blob;
pull_string_talloc(spn, NULL, 0,
@@ -387,7 +387,7 @@ static NTSTATUS parse_object(TALLOC_CTX *mem_ctx,
entry = libnet_keytab_search(ctx, principal, 0, ENCTYPE_NULL,
mem_ctx);
if (entry) {
- name = (char *)TALLOC_MEMDUP(mem_ctx,
+ name = (char *)talloc_memdup(mem_ctx,
entry->password.data,
entry->password.length);
if (!name) {
diff --git a/source3/libnet/libnet_dssync_passdb.c b/source3/libnet/libnet_dssync_passdb.c
index ab347567f14..b8675d3d988 100644
--- a/source3/libnet/libnet_dssync_passdb.c
+++ b/source3/libnet/libnet_dssync_passdb.c
@@ -20,10 +20,10 @@
#include "includes.h"
#include "system/passwd.h"
#include "libnet/libnet_dssync.h"
-#include "libnet/libnet_samsync.h"
#include "../libcli/security/security.h"
#include "../libds/common/flags.h"
#include "../librpc/gen_ndr/ndr_drsuapi.h"
+#include "util_tdb.h"
#include "dbwrap.h"
#include "../libds/common/flag_mapping.h"
#include "passdb.h"
@@ -106,7 +106,7 @@ static struct dssync_passdb_obj *dssync_search_obj_by_guid(struct dssync_passdb
TDB_DATA key;
TDB_DATA data;
- key = make_tdb_data((const uint8_t *)(void *)guid,
+ key = make_tdb_data((const uint8_t *)(const void *)guid,
sizeof(*guid));
ret = db->fetch(db, talloc_tos(), key, &data);
@@ -1531,11 +1531,11 @@ static NTSTATUS handle_alias_object(struct dssync_passdb *pctx,
map.sid_name_use = SID_NAME_ALIAS;
}
- fstrcpy(map.nt_name, name);
+ strlcpy(map.nt_name, name, sizeof(map.nt_name));
if (description) {
- fstrcpy(map.comment, comment);
+ strlcpy(map.comment, comment, sizeof(map.comment));
} else {
- fstrcpy(map.comment, "");
+ strlcpy(map.comment, "", sizeof(map.comment));
}
if (insert)
@@ -1636,11 +1636,11 @@ static NTSTATUS handle_group_object(struct dssync_passdb *pctx,
map.gid = grp->gr_gid;
map.sid = group_sid;
map.sid_name_use = SID_NAME_DOM_GRP;
- fstrcpy(map.nt_name, name);
+ strlcpy(map.nt_name, name, sizeof(map.nt_name));
if (description) {
- fstrcpy(map.comment, comment);
+ strlcpy(map.comment, comment, sizeof(map.comment));
} else {
- fstrcpy(map.comment, "");
+ strlcpy(map.comment, "", sizeof(map.comment));
}
if (insert)
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 1e866c3dd19..16c068c66ee 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -38,6 +38,7 @@
#include "krb5_env.h"
#include "../libcli/security/security.h"
#include "passdb.h"
+#include "libsmb/libsmb.h"
/****************************************************************
****************************************************************/
@@ -1074,7 +1075,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
&user_info,
&result);
- if (NT_STATUS_EQUAL(status, NT_STATUS(DCERPC_FAULT_INVALID_TAG))) {
+ if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) {
/* retry with level 24 */
@@ -1291,7 +1292,7 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx,
struct samr_Ids user_rids;
struct samr_Ids name_types;
union samr_UserInfo *info = NULL;
- struct dcerpc_binding_handle *b;
+ struct dcerpc_binding_handle *b = NULL;
ZERO_STRUCT(sam_pol);
ZERO_STRUCT(domain_pol);
@@ -1432,7 +1433,7 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx,
dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
done:
- if (pipe_hnd) {
+ if (pipe_hnd && b) {
if (is_valid_policy_hnd(&domain_pol)) {
dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
}
@@ -1454,40 +1455,61 @@ done:
static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
{
- WERROR werr;
+ WERROR werr = WERR_OK;
+ sbcErr err;
struct smbconf_ctx *ctx;
- werr = smbconf_init_reg(r, &ctx, NULL);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init_reg(r, &ctx, NULL);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
goto done;
}
if (!(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE)) {
- werr = smbconf_set_global_parameter(ctx, "security", "user");
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "security", "user");
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
- werr = smbconf_set_global_parameter(ctx, "workgroup",
- r->in.domain_name);
+ err = smbconf_set_global_parameter(ctx, "workgroup",
+ r->in.domain_name);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
smbconf_delete_global_parameter(ctx, "realm");
goto done;
}
- werr = smbconf_set_global_parameter(ctx, "security", "domain");
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "security", "domain");
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
- werr = smbconf_set_global_parameter(ctx, "workgroup",
- r->out.netbios_domain_name);
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "workgroup",
+ r->out.netbios_domain_name);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
if (r->out.domain_is_ad) {
- werr = smbconf_set_global_parameter(ctx, "security", "ads");
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "security", "ads");
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
- werr = smbconf_set_global_parameter(ctx, "realm",
- r->out.dns_domain_name);
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "realm",
+ r->out.dns_domain_name);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
}
done:
@@ -1501,20 +1523,28 @@ static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
static WERROR do_unjoin_modify_vals_config(struct libnet_UnjoinCtx *r)
{
WERROR werr = WERR_OK;
+ sbcErr err;
struct smbconf_ctx *ctx;
- werr = smbconf_init_reg(r, &ctx, NULL);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init_reg(r, &ctx, NULL);
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
goto done;
}
if (r->in.unjoin_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
- werr = smbconf_set_global_parameter(ctx, "security", "user");
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_set_global_parameter(ctx, "security", "user");
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
- werr = smbconf_delete_global_parameter(ctx, "workgroup");
- W_ERROR_NOT_OK_GOTO_DONE(werr);
+ err = smbconf_delete_global_parameter(ctx, "workgroup");
+ if (!SBC_ERROR_IS_OK(err)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
smbconf_delete_global_parameter(ctx, "realm");
}
@@ -1741,7 +1771,7 @@ static int libnet_destroy_JoinCtx(struct libnet_JoinCtx *r)
}
krb5_cc_env = getenv(KRB5_ENV_CCNAME);
- if (krb5_cc_env && StrCaseCmp(krb5_cc_env, "MEMORY:libnetjoin")) {
+ if (krb5_cc_env && strcasecmp_m(krb5_cc_env, "MEMORY:libnetjoin")) {
unsetenv(KRB5_ENV_CCNAME);
}
@@ -1760,7 +1790,7 @@ static int libnet_destroy_UnjoinCtx(struct libnet_UnjoinCtx *r)
}
krb5_cc_env = getenv(KRB5_ENV_CCNAME);
- if (krb5_cc_env && StrCaseCmp(krb5_cc_env, "MEMORY:libnetjoin")) {
+ if (krb5_cc_env && strcasecmp_m(krb5_cc_env, "MEMORY:libnetjoin")) {
unsetenv(KRB5_ENV_CCNAME);
}
@@ -1783,7 +1813,7 @@ WERROR libnet_init_JoinCtx(TALLOC_CTX *mem_ctx,
talloc_set_destructor(ctx, libnet_destroy_JoinCtx);
- ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname());
+ ctx->in.machine_name = talloc_strdup(mem_ctx, lp_netbios_name());
W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name);
krb5_cc_env = getenv(KRB5_ENV_CCNAME);
@@ -1816,7 +1846,7 @@ WERROR libnet_init_UnjoinCtx(TALLOC_CTX *mem_ctx,
talloc_set_destructor(ctx, libnet_destroy_UnjoinCtx);
- ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname());
+ ctx->in.machine_name = talloc_strdup(mem_ctx, lp_netbios_name());
W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name);
krb5_cc_env = getenv(KRB5_ENV_CCNAME);
diff --git a/source3/libnet/libnet_join.h b/source3/libnet/libnet_join.h
index 5659828a5ca..dccf03b715b 100644
--- a/source3/libnet/libnet_join.h
+++ b/source3/libnet/libnet_join.h
@@ -1,3 +1,26 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * libnet Join Support
+ * Copyright (C) Gerald (Jerry) Carter 2006
+ * Copyright (C) Guenther Deschner 2007-2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _LIBNET_LIBNET_JOIN_H_
+#define _LIBNET_LIBNET_JOIN_H_
+
/* The following definitions come from libnet/libnet_join.c */
NTSTATUS libnet_join_ok(const char *netbios_domain_name,
@@ -11,3 +34,5 @@ WERROR libnet_Join(TALLOC_CTX *mem_ctx,
struct libnet_JoinCtx *r);
WERROR libnet_Unjoin(TALLOC_CTX *mem_ctx,
struct libnet_UnjoinCtx *r);
+
+#endif /* _LIBNET_LIBNET_JOIN_H_ */
diff --git a/source3/libnet/libnet_keytab.c b/source3/libnet/libnet_keytab.c
index f395c975e5c..6349c2291f7 100644
--- a/source3/libnet/libnet_keytab.c
+++ b/source3/libnet/libnet_keytab.c
@@ -66,7 +66,7 @@ krb5_error_code libnet_keytab_init(TALLOC_CTX *mem_ctx,
struct libnet_keytab_context *r;
- r = TALLOC_ZERO_P(mem_ctx, struct libnet_keytab_context);
+ r = talloc_zero(mem_ctx, struct libnet_keytab_context);
if (!r) {
return ENOMEM;
}
diff --git a/source3/libnet/libnet_samsync.c b/source3/libnet/libnet_samsync.c
index 1141bed730b..75fc329e0af 100644
--- a/source3/libnet/libnet_samsync.c
+++ b/source3/libnet/libnet_samsync.c
@@ -23,7 +23,6 @@
#include "includes.h"
#include "libnet/libnet_samsync.h"
-#include "../lib/crypto/crypto.h"
#include "../libcli/samsync/samsync.h"
#include "../libcli/auth/libcli_auth.h"
#include "rpc_client/rpc_client.h"
@@ -71,7 +70,7 @@ NTSTATUS libnet_samsync_init_context(TALLOC_CTX *mem_ctx,
*ctx_p = NULL;
- ctx = TALLOC_ZERO_P(mem_ctx, struct samsync_context);
+ ctx = talloc_zero(mem_ctx, struct samsync_context);
NT_STATUS_HAVE_NO_MEMORY(ctx);
if (domain_sid) {
@@ -204,7 +203,7 @@ static NTSTATUS libnet_samsync_delta(TALLOC_CTX *mem_ctx,
NTSTATUS result, status;
NTSTATUS callback_status;
const char *logon_server = ctx->cli->desthost;
- const char *computername = global_myname();
+ const char *computername = lp_netbios_name();
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
uint16_t restart_state = 0;
@@ -405,7 +404,7 @@ NTSTATUS pull_netr_AcctLockStr(TALLOC_CTX *mem_ctx,
*str_p = NULL;
- str = TALLOC_ZERO_P(mem_ctx, struct netr_AcctLockStr);
+ str = talloc_zero(mem_ctx, struct netr_AcctLockStr);
if (!str) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/libnet/libnet_samsync_ldif.c b/source3/libnet/libnet_samsync_ldif.c
index 4154a07fdab..f535e28e338 100644
--- a/source3/libnet/libnet_samsync_ldif.c
+++ b/source3/libnet/libnet_samsync_ldif.c
@@ -68,6 +68,33 @@ struct samsync_ldif_context {
int num_alloced;
};
+/*
+ Returns the substring from src between the first occurrence of
+ the char "front" and the first occurence of the char "back".
+ Mallocs the return string which must be freed. Not for use
+ with wide character strings.
+*/
+static char *sstring_sub(const char *src, char front, char back)
+{
+ char *temp1, *temp2, *temp3;
+ ptrdiff_t len;
+
+ temp1 = strchr(src, front);
+ if (temp1 == NULL) return NULL;
+ temp2 = strchr(src, back);
+ if (temp2 == NULL) return NULL;
+ len = temp2 - temp1;
+ if (len <= 0) return NULL;
+ temp3 = (char*)SMB_MALLOC(len);
+ if (temp3 == NULL) {
+ DEBUG(1,("Malloc failure in sstring_sub\n"));
+ return NULL;
+ }
+ memcpy(temp3, temp1+1, len-1);
+ temp3[len-1] = '\0';
+ return temp3;
+}
+
/****************************************************************
****************************************************************/
@@ -919,7 +946,7 @@ static NTSTATUS ldif_init_context(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
- r = TALLOC_ZERO_P(mem_ctx, struct samsync_ldif_context);
+ r = talloc_zero(mem_ctx, struct samsync_ldif_context);
NT_STATUS_HAVE_NO_MEMORY(r);
/* Get the ldap suffix */
@@ -966,8 +993,8 @@ static NTSTATUS ldif_init_context(TALLOC_CTX *mem_ctx,
}
/* Allocate initial memory for groupmap and accountmap arrays */
- r->groupmap = TALLOC_ZERO_ARRAY(mem_ctx, GROUPMAP, 8);
- r->accountmap = TALLOC_ZERO_ARRAY(mem_ctx, ACCOUNTMAP, 8);
+ r->groupmap = talloc_zero_array(mem_ctx, GROUPMAP, 8);
+ r->accountmap = talloc_zero_array(mem_ctx, ACCOUNTMAP, 8);
if (r->groupmap == NULL || r->accountmap == NULL) {
DEBUG(1,("GROUPMAP talloc failed\n"));
status = NT_STATUS_NO_MEMORY;
@@ -1173,12 +1200,12 @@ static NTSTATUS ldif_realloc_maps(TALLOC_CTX *mem_ctx,
uint32_t num_entries)
{
/* Re-allocate memory for groupmap and accountmap arrays */
- l->groupmap = TALLOC_REALLOC_ARRAY(mem_ctx,
+ l->groupmap = talloc_realloc(mem_ctx,
l->groupmap,
GROUPMAP,
num_entries + l->num_alloced);
- l->accountmap = TALLOC_REALLOC_ARRAY(mem_ctx,
+ l->accountmap = talloc_realloc(mem_ctx,
l->accountmap,
ACCOUNTMAP,
num_entries + l->num_alloced);
diff --git a/source3/libnet/libnet_samsync_passdb.c b/source3/libnet/libnet_samsync_passdb.c
index b579723f6fd..0cf2ed3323d 100644
--- a/source3/libnet/libnet_samsync_passdb.c
+++ b/source3/libnet/libnet_samsync_passdb.c
@@ -428,11 +428,11 @@ static NTSTATUS fetch_group_info(TALLOC_CTX *mem_ctx,
map.gid = grp->gr_gid;
map.sid = group_sid;
map.sid_name_use = SID_NAME_DOM_GRP;
- fstrcpy(map.nt_name, name);
+ strlcpy(map.nt_name, name, sizeof(map.nt_name));
if (r->description.string) {
- fstrcpy(map.comment, comment);
+ strlcpy(map.comment, comment, sizeof(map.comment));
} else {
- fstrcpy(map.comment, "");
+ strlcpy(map.comment, "", sizeof(map.comment));
}
if (insert)
@@ -476,7 +476,7 @@ static NTSTATUS fetch_group_mem_info(TALLOC_CTX *mem_ctx,
d_printf("Group members of %s: ", grp->gr_name);
if (r->num_rids) {
- if ((nt_members = TALLOC_ZERO_ARRAY(mem_ctx, char *, r->num_rids)) == NULL) {
+ if ((nt_members = talloc_zero_array(mem_ctx, char *, r->num_rids)) == NULL) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
@@ -617,8 +617,8 @@ static NTSTATUS fetch_alias_info(TALLOC_CTX *mem_ctx,
else
map.sid_name_use = SID_NAME_ALIAS;
- fstrcpy(map.nt_name, name);
- fstrcpy(map.comment, comment);
+ strlcpy(map.nt_name, name, sizeof(map.nt_name));
+ strlcpy(map.comment, comment, sizeof(map.comment));
if (insert)
pdb_add_group_mapping_entry(&map);
diff --git a/source3/librpc/crypto/cli_spnego.c b/source3/librpc/crypto/cli_spnego.c
index bf58e25d9a8..e4fdf315aaf 100644
--- a/source3/librpc/crypto/cli_spnego.c
+++ b/source3/librpc/crypto/cli_spnego.c
@@ -99,7 +99,7 @@ NTSTATUS spnego_ntlmssp_init_client(TALLOC_CTX *mem_ctx,
sp_ctx->mech = SPNEGO_NTLMSSP;
status = auth_ntlmssp_client_start(sp_ctx,
- global_myname(),
+ lp_netbios_name(),
lp_workgroup(),
lp_client_ntlmv2_auth(),
&sp_ctx->mech_ctx.ntlmssp_state);
diff --git a/source3/librpc/crypto/gse.c b/source3/librpc/crypto/gse.c
index 0d9eead082e..c311c774d42 100644
--- a/source3/librpc/crypto/gse.c
+++ b/source3/librpc/crypto/gse.c
@@ -27,12 +27,6 @@
#include "smb_krb5.h"
#include "gse_krb5.h"
-#include <gssapi/gssapi.h>
-#include <gssapi/gssapi_krb5.h>
-#ifdef HAVE_GSSAPI_GSSAPI_EXT_H
-#include <gssapi/gssapi_ext.h>
-#endif
-
#ifndef GSS_KRB5_INQ_SSPI_SESSION_KEY_OID
#define GSS_KRB5_INQ_SSPI_SESSION_KEY_OID_LENGTH 11
#define GSS_KRB5_INQ_SSPI_SESSION_KEY_OID "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x05\x05"
@@ -62,16 +56,6 @@ gss_OID_desc gse_authz_data_oid = {
(void *)GSE_EXTRACT_RELEVANT_AUTHZ_DATA_OID
};
-#ifndef GSS_KRB5_EXTRACT_AUTHTIME_FROM_SEC_CONTEXT_OID
-#define GSS_KRB5_EXTRACT_AUTHTIME_FROM_SEC_CONTEXT_OID_LENGTH 11
-#define GSS_KRB5_EXTRACT_AUTHTIME_FROM_SEC_CONTEXT_OID "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x05\x0c"
-#endif
-
-gss_OID_desc gse_authtime_oid = {
- GSS_KRB5_EXTRACT_AUTHTIME_FROM_SEC_CONTEXT_OID_LENGTH,
- (void *)GSS_KRB5_EXTRACT_AUTHTIME_FROM_SEC_CONTEXT_OID
-};
-
static char *gse_errstr(TALLOC_CTX *mem_ctx, OM_uint32 maj, OM_uint32 min);
struct gse_context {
@@ -95,6 +79,24 @@ struct gse_context {
bool authenticated;
};
+#ifndef HAVE_GSS_OID_EQUAL
+
+static bool gss_oid_equal(const gss_OID o1, const gss_OID o2)
+{
+ if (o1 == o2) {
+ return true;
+ }
+ if ((o1 == NULL && o2 != NULL) || (o1 != NULL && o2 == NULL)) {
+ return false;
+ }
+ if (o1->length != o2->length) {
+ return false;
+ }
+ return memcmp(o1->elements, o2->elements, o1->length) == false;
+}
+
+#endif
+
/* free non talloc dependent contexts */
static int gse_context_destructor(void *ptr)
{
@@ -135,10 +137,19 @@ static int gse_context_destructor(void *ptr)
gss_maj = gss_release_cred(&gss_min,
&gse_ctx->delegated_creds);
}
- if (gse_ctx->ret_mech) {
- gss_maj = gss_release_oid(&gss_min,
- &gse_ctx->ret_mech);
- }
+
+ /* MIT and Heimdal differ as to if you can call
+ * gss_release_oid() on this OID, generated by
+ * gss_{accept,init}_sec_context(). However, as long as the
+ * oid is gss_mech_krb5 (which it always is at the moment),
+ * then this is a moot point, as both declare this particular
+ * OID static, and so no memory is lost. This assert is in
+ * place to ensure that the programmer who wishes to extend
+ * this code to EAP or other GSS mechanisms determines an
+ * implementation-dependent way of releasing any dynamically
+ * allocated OID */
+ SMB_ASSERT(gss_oid_equal(&gse_ctx->gss_mech, GSS_C_NO_OID) || gss_oid_equal(&gse_ctx->gss_mech, gss_mech_krb5));
+
return 0;
}
@@ -348,8 +359,6 @@ NTSTATUS gse_init_server(TALLOC_CTX *mem_ctx,
OM_uint32 gss_maj, gss_min;
krb5_error_code ret;
NTSTATUS status;
- const char *ktname;
- gss_OID_set_desc mech_set;
status = gse_context_init(mem_ctx, do_sign, do_seal,
NULL, add_gss_c_flags, &gse_ctx);
@@ -379,24 +388,27 @@ NTSTATUS gse_init_server(TALLOC_CTX *mem_ctx,
* This call sets the default keytab for the whole server, not
* just for this context. Need to find a way that does not alter
* the state of the whole server ... */
+ {
+ const char *ktname;
+ gss_OID_set_desc mech_set;
- ret = smb_krb5_keytab_name(gse_ctx, gse_ctx->k5ctx,
+ ret = smb_krb5_keytab_name(gse_ctx, gse_ctx->k5ctx,
gse_ctx->keytab, &ktname);
- if (ret) {
- status = NT_STATUS_INTERNAL_ERROR;
- goto done;
- }
+ if (ret) {
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto done;
+ }
- ret = gsskrb5_register_acceptor_identity(ktname);
- if (ret) {
- status = NT_STATUS_INTERNAL_ERROR;
- goto done;
- }
+ ret = gsskrb5_register_acceptor_identity(ktname);
+ if (ret) {
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto done;
+ }
- mech_set.count = 1;
- mech_set.elements = &gse_ctx->gss_mech;
-
- gss_maj = gss_acquire_cred(&gss_min,
+ mech_set.count = 1;
+ mech_set.elements = &gse_ctx->gss_mech;
+
+ gss_maj = gss_acquire_cred(&gss_min,
GSS_C_NO_NAME,
GSS_C_INDEFINITE,
&mech_set,
@@ -404,11 +416,12 @@ NTSTATUS gse_init_server(TALLOC_CTX *mem_ctx,
&gse_ctx->creds,
NULL, NULL);
- if (gss_maj) {
- DEBUG(0, ("gss_acquire_creds failed with [%s]\n",
- gse_errstr(gse_ctx, gss_maj, gss_min)));
- status = NT_STATUS_INTERNAL_ERROR;
- goto done;
+ if (gss_maj) {
+ DEBUG(0, ("gss_acquire_creds failed with [%s]\n",
+ gse_errstr(gse_ctx, gss_maj, gss_min)));
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto done;
+ }
}
#endif
status = NT_STATUS_OK;
@@ -692,42 +705,15 @@ NTSTATUS gse_get_authz_data(struct gse_context *gse_ctx,
return NT_STATUS_OK;
}
-NTSTATUS gse_get_authtime(struct gse_context *gse_ctx, time_t *authtime)
+NTSTATUS gse_get_pac_blob(struct gse_context *gse_ctx,
+ TALLOC_CTX *mem_ctx, DATA_BLOB *pac_blob)
{
- OM_uint32 gss_min, gss_maj;
- gss_buffer_set_t set = GSS_C_NO_BUFFER_SET;
- int32_t tkttime;
-
if (!gse_ctx->authenticated) {
return NT_STATUS_ACCESS_DENIED;
}
- gss_maj = gss_inquire_sec_context_by_oid(
- &gss_min, gse_ctx->gss_ctx,
- &gse_authtime_oid, &set);
- if (gss_maj) {
- DEBUG(0, ("gss_inquire_sec_context_by_oid failed [%s]\n",
- gse_errstr(talloc_tos(), gss_maj, gss_min)));
- return NT_STATUS_NOT_FOUND;
- }
-
- if ((set == GSS_C_NO_BUFFER_SET) || (set->count != 1) != 0) {
- DEBUG(0, ("gss_inquire_sec_context_by_oid returned unknown "
- "data in results.\n"));
- return NT_STATUS_INTERNAL_ERROR;
- }
-
- if (set->elements[0].length != sizeof(int32_t)) {
- DEBUG(0, ("Invalid authtime size!\n"));
- return NT_STATUS_INTERNAL_ERROR;
- }
-
- tkttime = *((int32_t *)set->elements[0].value);
-
- gss_maj = gss_release_buffer_set(&gss_min, &set);
-
- *authtime = (time_t)tkttime;
- return NT_STATUS_OK;
+ return gssapi_obtain_pac_blob(mem_ctx, gse_ctx->gss_ctx,
+ gse_ctx->client_name, pac_blob);
}
size_t gse_get_signature_length(struct gse_context *gse_ctx,
@@ -982,7 +968,8 @@ NTSTATUS gse_get_authz_data(struct gse_context *gse_ctx,
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS gse_get_authtime(struct gse_context *gse_ctx, time_t *authtime)
+NTSTATUS gse_get_pac_blob(struct gse_context *gse_ctx,
+ TALLOC_CTX *mem_ctx, DATA_BLOB *pac_blob)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
@@ -1017,4 +1004,4 @@ NTSTATUS gse_sigcheck(TALLOC_CTX *mem_ctx, struct gse_context *gse_ctx,
return NT_STATUS_NOT_IMPLEMENTED;
}
-#endif /* HAVE_KRB5 && HAVE_GSSAPI_EXT_H && HAVE_GSS_WRAP_IOV */
+#endif /* HAVE_KRB5 && HAVE_GSS_WRAP_IOV */
diff --git a/source3/librpc/crypto/gse.h b/source3/librpc/crypto/gse.h
index fbcf5b6e10d..27cc2e92559 100644
--- a/source3/librpc/crypto/gse.h
+++ b/source3/librpc/crypto/gse.h
@@ -56,7 +56,8 @@ NTSTATUS gse_get_client_name(struct gse_context *gse_ctx,
TALLOC_CTX *mem_ctx, char **client_name);
NTSTATUS gse_get_authz_data(struct gse_context *gse_ctx,
TALLOC_CTX *mem_ctx, DATA_BLOB *pac);
-NTSTATUS gse_get_authtime(struct gse_context *gse_ctx, time_t *authtime);
+NTSTATUS gse_get_pac_blob(struct gse_context *gse_ctx,
+ TALLOC_CTX *mem_ctx, DATA_BLOB *pac_blob);
size_t gse_get_signature_length(struct gse_context *gse_ctx,
int seal, size_t payload_size);
diff --git a/source3/librpc/crypto/gse_krb5.c b/source3/librpc/crypto/gse_krb5.c
index 830d517bc7c..81a9a075967 100644
--- a/source3/librpc/crypto/gse_krb5.c
+++ b/source3/librpc/crypto/gse_krb5.c
@@ -90,7 +90,7 @@ static krb5_error_code get_host_principal(krb5_context krbctx,
char *host_princ_s = NULL;
int err;
- err = asprintf(&host_princ_s, "%s$@%s", global_myname(), lp_realm());
+ err = asprintf(&host_princ_s, "%s$@%s", lp_netbios_name(), lp_realm());
if (err == -1) {
return -1;
}
diff --git a/source3/librpc/idl/messaging.idl b/source3/librpc/idl/messaging.idl
index 8618d53c9a2..0c0672c7a6d 100644
--- a/source3/librpc/idl/messaging.idl
+++ b/source3/librpc/idl/messaging.idl
@@ -75,7 +75,6 @@ interface messaging
/* cluster reconfigure events */
MSG_SMB_BRL_VALIDATE = 0x0311,
- MSG_SMB_RELEASE_IP = 0x0312,
/*Close a specific file given a share entry. */
MSG_SMB_CLOSE_FILE = 0x0313,
diff --git a/source3/librpc/idl/notify.idl b/source3/librpc/idl/notify.idl
deleted file mode 100644
index 0776ed107cc..00000000000
--- a/source3/librpc/idl/notify.idl
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "idl_types.h"
-
-import "file_id.idl", "server_id.idl";
-
-/*
- IDL structures for notify change code
-
- this defines the structures used in the notify database code, and
- the change notify buffers
-*/
-
-[
- pointer_default(unique)
-]
-interface notify
-{
-
- /* structure used in the notify database */
- typedef [public] struct {
- server_id server;
- uint32 filter; /* filter to apply in this directory */
- uint32 subdir_filter; /* filter to apply in child directories */
- uint32 dir_fd; /* fd of open directory */
- file_id dir_id; /* file_id of open directory */
- utf8string path;
- uint32 path_len; /* saves some computation on search */
- pointer private_data;
- } notify_entry;
-
- typedef [public] struct {
- uint32 num_entries;
- notify_entry entries[num_entries];
- } notify_entry_array;
-
- /*
- to allow for efficient search for matching entries, we
- divide them by the directory depth, with a separate array
- per depth. The entries within each depth are sorted by path,
- allowing for a bisection search.
-
- The max_mask and max_mask_subdir at each depth is the
- bitwise or of the filters and subdir filters for all entries
- at that depth. This allows a depth to be quickly skipped if
- no entries will match the target filter
- */
- typedef struct {
- uint32 max_mask;
- uint32 max_mask_subdir;
- uint32 num_entries;
- notify_entry entries[num_entries];
- } notify_depth;
-
- typedef [public] struct {
- uint32 num_depths;
- notify_depth depth[num_depths];
- } notify_array;
-
- /* structure sent between servers in notify messages */
- typedef [public] struct {
- uint32 action;
- utf8string path;
- pointer private_data;
- } notify_event;
-
- typedef [v1_enum] enum {
- FILE_ACTION_ADDED = 0x00000001,
- FILE_ACTION_REMOVED = 0x00000002,
- FILE_ACTION_MODIFIED = 0x00000003,
- FILE_ACTION_RENAMED_OLD_NAME = 0x00000004,
- FILE_ACTION_RENAMED_NEW_NAME = 0x00000005,
- FILE_ACTION_ADDED_STREAM = 0x00000006,
- FILE_ACTION_REMOVED_STREAM = 0x00000007,
- FILE_ACTION_MODIFIED_STREAM = 0x00000008
- } FILE_NOTIFY_ACTION;
-
- /* structure sent at the CIFS layer */
- /* Align on 4-byte boundary according to MS-CIFS 2.2.7.4.2 */
- typedef [public,gensize,flag(NDR_ALIGN4)] struct {
- uint32 NextEntryOffset;
- FILE_NOTIFY_ACTION Action;
- [value(strlen_m(FileName1)*2)] uint32 FileNameLength;
- [charset(UTF16),flag(STR_NOTERM)] uint16 FileName1[FileNameLength];
- } FILE_NOTIFY_INFORMATION;
-}
diff --git a/source3/librpc/idl/server_id.idl b/source3/librpc/idl/server_id.idl
deleted file mode 100644
index ed727881c73..00000000000
--- a/source3/librpc/idl/server_id.idl
+++ /dev/null
@@ -1,25 +0,0 @@
-[
- pointer_default(unique)
-]
-interface server_id
-{
-
- /* used to look like the following, note that unique_id was not
- * marshalled at all...
-
- struct server_id {
- pid_t pid;
- #ifdef CLUSTER_SUPPORT
- uint32 vnn;
- #endif
- uint64_t unique_id;
- };
-
- */
-
- typedef [public] struct {
- uint32 pid;
- uint32 vnn;
- udlong unique_id;
- } server_id;
-}
diff --git a/source3/librpc/idl/wscript_build b/source3/librpc/idl/wscript_build
index 5a8dc31980b..3e07542320d 100644
--- a/source3/librpc/idl/wscript_build
+++ b/source3/librpc/idl/wscript_build
@@ -5,8 +5,8 @@ import os
topinclude=os.path.join(bld.srcnode.abspath(), 'librpc/idl')
bld.SAMBA_PIDL_LIST('PIDL',
- '''messaging.idl libnetapi.idl notify.idl
- perfcount.idl secrets.idl libnet_join.idl server_id.idl''',
+ '''messaging.idl libnetapi.idl
+ perfcount.idl secrets.idl libnet_join.idl''',
options='--includedir=%s --header --ndr-parser' % topinclude,
output_dir='../gen_ndr')
diff --git a/source3/librpc/ndr/util.h b/source3/librpc/ndr/util.h
deleted file mode 100644
index 3bf9c0eb438..00000000000
--- a/source3/librpc/ndr/util.h
+++ /dev/null
@@ -1,4 +0,0 @@
-
-/* The following definitions come from librpc/ndr/util.c */
-
-_PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss);
diff --git a/source3/librpc/rpc/dcerpc.h b/source3/librpc/rpc/dcerpc.h
index 0a6ddaca173..d7e8e0c193d 100644
--- a/source3/librpc/rpc/dcerpc.h
+++ b/source3/librpc/rpc/dcerpc.h
@@ -33,7 +33,20 @@
#define SMB_RPC_INTERFACE_VERSION 1
struct NL_AUTH_MESSAGE;
-struct pipe_auth_data;
+
+/* auth state for all bind types. */
+
+struct pipe_auth_data {
+ enum dcerpc_AuthType auth_type;
+ enum dcerpc_AuthLevel auth_level;
+
+ void *auth_ctx;
+
+ /* Only the client code uses these 3 for now */
+ char *domain;
+ char *user_name;
+ DATA_BLOB user_session_key;
+};
/* The following definitions come from librpc/rpc/dcerpc_helpers.c */
NTSTATUS dcerpc_push_ncacn_packet(TALLOC_CTX *mem_ctx,
@@ -75,4 +88,12 @@ NTSTATUS dcerpc_check_auth(struct pipe_auth_data *auth,
DATA_BLOB *raw_pkt,
size_t *pad_len);
+/* The following definitions come from librpc/rpc/rpc_common.c */
+
+bool smb_register_ndr_interface(const struct ndr_interface_table *interface);
+const struct ndr_interface_table *get_iface_from_syntax(
+ const struct ndr_syntax_id *syntax);
+const char *get_pipe_name_from_syntax(TALLOC_CTX *mem_ctx,
+ const struct ndr_syntax_id *syntax);
+
#endif /* __S3_DCERPC_H__ */
diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c
index 76f7e91fb05..3d1acbbee22 100644
--- a/source3/librpc/rpc/dcerpc_ep.c
+++ b/source3/librpc/rpc/dcerpc_ep.c
@@ -23,6 +23,7 @@
#include "../librpc/gen_ndr/ndr_epmapper_c.h"
#include "rpc_client/cli_pipe.h"
#include "auth.h"
+#include "rpc_server/rpc_ncacn_np.h"
#define EPM_MAX_ANNOTATION_SIZE 64
@@ -77,7 +78,7 @@ NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx,
switch (b->transport) {
case NCACN_NP:
- b->host = talloc_asprintf(b, "\\\\%s", global_myname());
+ b->host = talloc_asprintf(b, "\\\\%s", lp_netbios_name());
if (b->host == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -168,7 +169,7 @@ static NTSTATUS ep_register(TALLOC_CTX *mem_ctx,
"rpc_server", "epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
static struct client_address client_id;
strlcpy(client_id.addr, "localhost", sizeof(client_id.addr));
@@ -185,7 +186,7 @@ static NTSTATUS ep_register(TALLOC_CTX *mem_ctx,
"epmapper (%s)", nt_errstr(status)));
goto done;
}
- } else if (StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ } else if (strcasecmp_m(rpcsrv_type, "daemon") == 0) {
/* Connect to the endpoint mapper locally */
ncalrpc_sock = talloc_asprintf(tmp_ctx,
"%s/%s",
diff --git a/source3/librpc/rpc/dcerpc_helpers.c b/source3/librpc/rpc/dcerpc_helpers.c
index 7e6990c0add..7520d767ba1 100644
--- a/source3/librpc/rpc/dcerpc_helpers.c
+++ b/source3/librpc/rpc/dcerpc_helpers.c
@@ -28,7 +28,6 @@
#include "ntlmssp_wrap.h"
#include "librpc/crypto/gse.h"
#include "librpc/crypto/spnego.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_PARSE
diff --git a/source3/librpc/rpc/rpc_common.c b/source3/librpc/rpc/rpc_common.c
index ed0320adf09..65e3205f62a 100644
--- a/source3/librpc/rpc/rpc_common.c
+++ b/source3/librpc/rpc/rpc_common.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "../librpc/gen_ndr/ndr_schannel.h"
+#include "librpc/rpc/dcerpc.h"
#include "../librpc/gen_ndr/ndr_lsa.h"
#include "../librpc/gen_ndr/ndr_dssetup.h"
#include "../librpc/gen_ndr/ndr_samr.h"
diff --git a/source3/librpc/wscript_build b/source3/librpc/wscript_build
index d99936cc166..a4af551e7f2 100644
--- a/source3/librpc/wscript_build
+++ b/source3/librpc/wscript_build
@@ -10,21 +10,11 @@ bld.SAMBA3_SUBSYSTEM('NDR_LIBNET_JOIN',
public_deps='ndr'
)
-bld.SAMBA3_SUBSYSTEM('NDR_SERVER_ID',
- source='gen_ndr/ndr_server_id.c',
- public_deps='ndr'
- )
-
bld.SAMBA3_SUBSYSTEM('NDR_MESSAGING',
source='gen_ndr/ndr_messaging.c',
public_deps='ndr NDR_SERVER_ID'
)
-bld.SAMBA3_SUBSYSTEM('NDR_NOTIFY3',
- source='gen_ndr/ndr_notify.c',
- public_deps='ndr NDR_FILE_ID NDR_SERVER_ID'
- )
-
bld.SAMBA3_SUBSYSTEM('NDR_SECRETS',
source='gen_ndr/ndr_secrets.c',
public_deps='ndr'
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 8af5aa10461..ee15caee7a5 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -18,97 +18,14 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "../lib/async_req/async_sock.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "../lib/util/tevent_unix.h"
#include "async_smb.h"
#include "smb_crypt.h"
#include "libsmb/nmblib.h"
-
-/*
- * Read an smb packet asynchronously, discard keepalives
- */
-
-struct read_smb_state {
- struct tevent_context *ev;
- int fd;
- uint8_t *buf;
-};
-
-static ssize_t read_smb_more(uint8_t *buf, size_t buflen, void *private_data);
-static void read_smb_done(struct tevent_req *subreq);
-
-static struct tevent_req *read_smb_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- int fd)
-{
- struct tevent_req *result, *subreq;
- struct read_smb_state *state;
-
- result = tevent_req_create(mem_ctx, &state, struct read_smb_state);
- if (result == NULL) {
- return NULL;
- }
- state->ev = ev;
- state->fd = fd;
-
- subreq = read_packet_send(state, ev, fd, 4, read_smb_more, NULL);
- if (subreq == NULL) {
- goto fail;
- }
- tevent_req_set_callback(subreq, read_smb_done, result);
- return result;
- fail:
- TALLOC_FREE(result);
- return NULL;
-}
-
-static ssize_t read_smb_more(uint8_t *buf, size_t buflen, void *private_data)
-{
- if (buflen > 4) {
- return 0; /* We've been here, we're done */
- }
- return smb_len_large(buf);
-}
-
-static void read_smb_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(
- subreq, struct tevent_req);
- struct read_smb_state *state = tevent_req_data(
- req, struct read_smb_state);
- ssize_t len;
- int err;
-
- len = read_packet_recv(subreq, state, &state->buf, &err);
- TALLOC_FREE(subreq);
- if (len == -1) {
- tevent_req_error(req, err);
- return;
- }
-
- if (CVAL(state->buf, 0) == SMBkeepalive) {
- subreq = read_packet_send(state, state->ev, state->fd, 4,
- read_smb_more, NULL);
- if (tevent_req_nomem(subreq, req)) {
- return;
- }
- tevent_req_set_callback(subreq, read_smb_done, req);
- return;
- }
- tevent_req_done(req);
-}
-
-static ssize_t read_smb_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
- uint8_t **pbuf, int *perrno)
-{
- struct read_smb_state *state = tevent_req_data(
- req, struct read_smb_state);
-
- if (tevent_req_is_unix_error(req, perrno)) {
- return -1;
- }
- *pbuf = talloc_move(mem_ctx, &state->buf);
- return talloc_get_size(*pbuf);
-}
+#include "read_smb.h"
/**
* Fetch an error out of a NBT packet
@@ -236,6 +153,14 @@ void cli_smb_req_unset_pending(struct tevent_req *req)
int num_pending = talloc_array_length(cli->pending);
int i;
+ if (state->mid != 0) {
+ /*
+ * This is a [nt]trans[2] request which waits
+ * for more than one reply.
+ */
+ return;
+ }
+
if (num_pending == 1) {
/*
* The pending read_smb tevent_req is a child of
@@ -263,9 +188,7 @@ void cli_smb_req_unset_pending(struct tevent_req *req)
/*
* Remove ourselves from the cli->pending array
*/
- if (num_pending > 1) {
- cli->pending[i] = cli->pending[num_pending-1];
- }
+ cli->pending[i] = cli->pending[num_pending-1];
/*
* No NULL check here, we're shrinking by sizeof(void *), and
@@ -278,6 +201,13 @@ void cli_smb_req_unset_pending(struct tevent_req *req)
static int cli_smb_req_destructor(struct tevent_req *req)
{
+ struct cli_smb_state *state = tevent_req_data(
+ req, struct cli_smb_state);
+ /*
+ * Make sure we really remove it from
+ * the pending array on destruction.
+ */
+ state->mid = 0;
cli_smb_req_unset_pending(req);
return 0;
}
@@ -340,6 +270,20 @@ void cli_smb_req_set_mid(struct tevent_req *req, uint16_t mid)
state->mid = mid;
}
+uint32_t cli_smb_req_seqnum(struct tevent_req *req)
+{
+ struct cli_smb_state *state = tevent_req_data(
+ req, struct cli_smb_state);
+ return state->seqnum;
+}
+
+void cli_smb_req_set_seqnum(struct tevent_req *req, uint32_t seqnum)
+{
+ struct cli_smb_state *state = tevent_req_data(
+ req, struct cli_smb_state);
+ state->seqnum = seqnum;
+}
+
static size_t iov_len(const struct iovec *iov, int count)
{
size_t result = 0;
@@ -423,9 +367,9 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
state->iov_count = iov_count + 3;
if (cli->timeout) {
- endtime = timeval_current_ofs(0, cli->timeout * 1000);
+ endtime = timeval_current_ofs_msec(cli->timeout);
if (!tevent_req_set_endtime(result, ev, endtime)) {
- tevent_req_nomem(NULL, result);
+ tevent_req_oom(result);
}
}
return result;
@@ -496,8 +440,8 @@ static NTSTATUS cli_smb_req_iov_send(struct tevent_req *req,
if (buf == NULL) {
return NT_STATUS_NO_MEMORY;
}
- status = cli_encrypt_message(state->cli, (char *)buf,
- &enc_buf);
+ status = common_encrypt_buffer(state->cli->trans_enc_state,
+ (char *)buf, &enc_buf);
TALLOC_FREE(buf);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Error in encrypting client message: %s\n",
@@ -544,7 +488,7 @@ struct tevent_req *cli_smb_send(TALLOC_CTX *mem_ctx,
struct iovec iov;
NTSTATUS status;
- iov.iov_base = CONST_DISCARD(void *, bytes);
+ iov.iov_base = discard_const_p(void, bytes);
iov.iov_len = num_bytes;
req = cli_smb_req_create(mem_ctx, ev, cli, smb_command,
@@ -712,7 +656,7 @@ static void cli_smb_received(struct tevent_req *subreq)
if (state->chained_requests == NULL) {
state->inbuf = talloc_move(state, &inbuf);
talloc_set_destructor(req, NULL);
- cli_smb_req_destructor(req);
+ cli_smb_req_unset_pending(req);
state->chain_num = 0;
state->chain_length = 1;
tevent_req_done(req);
@@ -756,7 +700,7 @@ static void cli_smb_received(struct tevent_req *subreq)
while (talloc_array_length(cli->pending) > 0) {
req = cli->pending[0];
talloc_set_destructor(req, NULL);
- cli_smb_req_destructor(req);
+ cli_smb_req_unset_pending(req);
tevent_req_nterror(req, status);
}
}
@@ -779,6 +723,24 @@ NTSTATUS cli_smb_recv(struct tevent_req *req,
}
if (state->inbuf == NULL) {
+ if (min_wct != 0) {
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+ if (pinbuf) {
+ *pinbuf = NULL;
+ }
+ if (pwct) {
+ *pwct = 0;
+ }
+ if (pvwv) {
+ *pvwv = NULL;
+ }
+ if (pnum_bytes) {
+ *pnum_bytes = 0;
+ }
+ if (pbytes) {
+ *pbytes = NULL;
+ }
/* This was a request without a reply */
return NT_STATUS_OK;
}
@@ -821,6 +783,8 @@ NTSTATUS cli_smb_recv(struct tevent_req *req,
status = cli_pull_error((char *)state->inbuf);
+ cli_set_error(state->cli, status);
+
if (!have_andx_command((char *)state->inbuf, wct_ofs)) {
if ((cmd == SMBsesssetupX)
diff --git a/source3/libsmb/cli_np_tstream.c b/source3/libsmb/cli_np_tstream.c
index 1f9e5ffd36e..7521181ec80 100644
--- a/source3/libsmb/cli_np_tstream.c
+++ b/source3/libsmb/cli_np_tstream.c
@@ -19,7 +19,8 @@
#include "includes.h"
#include "system/network.h"
-#include "../util/tevent_unix.h"
+#include "libsmb/libsmb.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "../lib/tsocket/tsocket.h"
#include "../lib/tsocket/tsocket_internal.h"
#include "cli_np_tstream.h"
@@ -27,9 +28,24 @@
static const struct tstream_context_ops tstream_cli_np_ops;
/*
- * Window uses 1024 hardcoded for read size and trans max data
+ * Windows uses 4280 (the max xmit/recv size negotiated on DCERPC).
+ * This is fits into the max_xmit negotiated at the SMB layer.
+ *
+ * On the sending side they may use SMBtranss if the request does not
+ * fit into a single SMBtrans call.
+ *
+ * Windows uses 1024 as max data size of a SMBtrans request and then
+ * possibly reads the rest of the DCERPC fragment (up to 3256 bytes)
+ * via a SMBreadX.
+ *
+ * For now we just ask for the full 4280 bytes (max data size) in the SMBtrans
+ * request to get the whole fragment at once (like samba 3.5.x and below did.
+ *
+ * It is important that we use do SMBwriteX with the size of a full fragment,
+ * otherwise we may get NT_STATUS_PIPE_BUSY on the SMBtrans request
+ * from NT4 servers. (See bug #8195)
*/
-#define TSTREAM_CLI_NP_BUF_SIZE 1024
+#define TSTREAM_CLI_NP_MAX_BUF_SIZE 4280
struct tstream_cli_np {
struct cli_state *cli;
@@ -47,7 +63,7 @@ struct tstream_cli_np {
struct {
off_t ofs;
size_t left;
- uint8_t buf[TSTREAM_CLI_NP_BUF_SIZE];
+ uint8_t *buf;
} read, write;
};
@@ -347,9 +363,26 @@ static void tstream_cli_np_writev_write_next(struct tevent_req *req)
tstream_context_data(state->stream,
struct tstream_cli_np);
struct tevent_req *subreq;
+ size_t i;
+ size_t left = 0;
+
+ for (i=0; i < state->count; i++) {
+ left += state->vector[i].iov_len;
+ }
+
+ if (left == 0) {
+ TALLOC_FREE(cli_nps->write.buf);
+ tevent_req_done(req);
+ return;
+ }
cli_nps->write.ofs = 0;
- cli_nps->write.left = TSTREAM_CLI_NP_BUF_SIZE;
+ cli_nps->write.left = MIN(left, TSTREAM_CLI_NP_MAX_BUF_SIZE);
+ cli_nps->write.buf = talloc_realloc(cli_nps, cli_nps->write.buf,
+ uint8_t, cli_nps->write.left);
+ if (tevent_req_nomem(cli_nps->write.buf, req)) {
+ return;
+ }
/*
* copy the pending buffer first
@@ -375,11 +408,6 @@ static void tstream_cli_np_writev_write_next(struct tevent_req *req)
state->ret += len;
}
- if (cli_nps->write.ofs == 0) {
- tevent_req_done(req);
- return;
- }
-
if (cli_nps->trans.active && state->count == 0) {
cli_nps->trans.active = false;
cli_nps->trans.write_req = req;
@@ -478,9 +506,8 @@ static void tstream_cli_np_writev_disconnect_done(struct tevent_req *subreq)
tevent_req_data(req, struct tstream_cli_np_writev_state);
struct tstream_cli_np *cli_nps =
tstream_context_data(state->stream, struct tstream_cli_np);
- NTSTATUS status;
- status = cli_close_recv(subreq);
+ cli_close_recv(subreq);
TALLOC_FREE(subreq);
cli_nps->cli = NULL;
@@ -619,6 +646,10 @@ static void tstream_cli_np_readv_read_next(struct tevent_req *req)
state->ret += len;
}
+ if (cli_nps->read.left == 0) {
+ TALLOC_FREE(cli_nps->read.buf);
+ }
+
if (state->count == 0) {
tevent_req_done(req);
return;
@@ -637,7 +668,7 @@ static void tstream_cli_np_readv_read_next(struct tevent_req *req)
}
subreq = cli_read_andx_send(state, state->ev, cli_nps->cli,
- cli_nps->fnum, 0, TSTREAM_CLI_NP_BUF_SIZE);
+ cli_nps->fnum, 0, TSTREAM_CLI_NP_MAX_BUF_SIZE);
if (tevent_req_nomem(subreq, req)) {
return;
}
@@ -673,7 +704,7 @@ static void tstream_cli_np_readv_trans_start(struct tevent_req *req)
NULL, 0, 0,
cli_nps->write.buf,
cli_nps->write.ofs,
- TSTREAM_CLI_NP_BUF_SIZE);
+ TSTREAM_CLI_NP_MAX_BUF_SIZE);
if (tevent_req_nomem(subreq, req)) {
return;
}
@@ -713,7 +744,7 @@ static void tstream_cli_np_readv_trans_done(struct tevent_req *subreq)
return;
}
- if (received > TSTREAM_CLI_NP_BUF_SIZE) {
+ if (received > TSTREAM_CLI_NP_MAX_BUF_SIZE) {
tstream_cli_np_readv_disconnect_now(req, EIO, __location__);
return;
}
@@ -725,8 +756,7 @@ static void tstream_cli_np_readv_trans_done(struct tevent_req *subreq)
cli_nps->read.ofs = 0;
cli_nps->read.left = received;
- memcpy(cli_nps->read.buf, rcvbuf, received);
- TALLOC_FREE(rcvbuf);
+ cli_nps->read.buf = talloc_move(cli_nps, &rcvbuf);
if (cli_nps->trans.write_req == NULL) {
tstream_cli_np_readv_read_next(req);
@@ -788,7 +818,7 @@ static void tstream_cli_np_readv_read_done(struct tevent_req *subreq)
return;
}
- if (received > TSTREAM_CLI_NP_BUF_SIZE) {
+ if (received > TSTREAM_CLI_NP_MAX_BUF_SIZE) {
TALLOC_FREE(subreq);
tstream_cli_np_readv_disconnect_now(req, EIO, __location__);
return;
@@ -802,6 +832,12 @@ static void tstream_cli_np_readv_read_done(struct tevent_req *subreq)
cli_nps->read.ofs = 0;
cli_nps->read.left = received;
+ cli_nps->read.buf = talloc_array(cli_nps, uint8_t, received);
+ if (cli_nps->read.buf == NULL) {
+ TALLOC_FREE(subreq);
+ tevent_req_nomem(cli_nps->read.buf, req);
+ return;
+ }
memcpy(cli_nps->read.buf, rcvbuf, received);
TALLOC_FREE(subreq);
@@ -852,9 +888,8 @@ static void tstream_cli_np_readv_disconnect_done(struct tevent_req *subreq)
tevent_req_data(req, struct tstream_cli_np_readv_state);
struct tstream_cli_np *cli_nps =
tstream_context_data(state->stream, struct tstream_cli_np);
- NTSTATUS status;
- status = cli_close_recv(subreq);
+ cli_close_recv(subreq);
TALLOC_FREE(subreq);
cli_nps->cli = NULL;
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index e3d97b60fa7..62e3a35a369 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -3,6 +3,8 @@
client connect/disconnect routines
Copyright (C) Andrew Tridgell 1994-1998
Copyright (C) Andrew Bartlett 2001-2003
+ Copyright (C) Volker Lendecke 2011
+ Copyright (C) Jeremy Allison 2011
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
@@ -19,6 +21,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "popt_common.h"
#include "../libcli/auth/libcli_auth.h"
#include "../libcli/auth/spnego.h"
@@ -26,8 +29,10 @@
#include "../libcli/auth/ntlmssp.h"
#include "libads/kerberos_proto.h"
#include "krb5_env.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
#include "libsmb/nmblib.h"
+#include "read_smb.h"
static const struct {
int prot;
@@ -47,6 +52,40 @@ static const struct {
#define STAR_SMBSERVER "*SMBSERVER"
+/********************************************************
+ Utility function to ensure we always return at least
+ a valid char * pointer to an empty string for the
+ cli->server_os, cli->server_type and cli->server_domain
+ strings.
+*******************************************************/
+
+static NTSTATUS smb_bytes_talloc_string(struct cli_state *cli,
+ char *inbuf,
+ char **dest,
+ uint8_t *src,
+ size_t srclen,
+ ssize_t *destlen)
+{
+ *destlen = clistr_pull_talloc(cli,
+ inbuf,
+ SVAL(inbuf, smb_flg2),
+ dest,
+ (char *)src,
+ srclen,
+ STR_TERMINATE);
+ if (*destlen == -1) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (*dest == NULL) {
+ *dest = talloc_strdup(cli, "");
+ if (*dest == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+ return NT_STATUS_OK;
+}
+
/**
* Set the user session key for a connection
* @param cli The cli structure to add it too
@@ -63,86 +102,267 @@ static void cli_set_session_key (struct cli_state *cli, const DATA_BLOB session_
Do an old lanman2 style session setup.
****************************************************************************/
-static NTSTATUS cli_session_setup_lanman2(struct cli_state *cli,
- const char *user,
- const char *pass, size_t passlen,
- const char *workgroup)
+struct cli_session_setup_lanman2_state {
+ struct cli_state *cli;
+ uint16_t vwv[10];
+ const char *user;
+};
+
+static void cli_session_setup_lanman2_done(struct tevent_req *subreq);
+
+static struct tevent_req *cli_session_setup_lanman2_send(
+ TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct cli_state *cli, const char *user,
+ const char *pass, size_t passlen,
+ const char *workgroup)
{
+ struct tevent_req *req, *subreq;
+ struct cli_session_setup_lanman2_state *state;
DATA_BLOB lm_response = data_blob_null;
- NTSTATUS status;
- fstring pword;
- char *p;
+ uint16_t *vwv;
+ uint8_t *bytes;
+ char *tmp;
- if (passlen > sizeof(pword)-1) {
- return NT_STATUS_INVALID_PARAMETER;
+ req = tevent_req_create(mem_ctx, &state,
+ struct cli_session_setup_lanman2_state);
+ if (req == NULL) {
+ return NULL;
}
+ state->cli = cli;
+ state->user = user;
+ vwv = state->vwv;
- /* LANMAN servers predate NT status codes and Unicode and ignore those
- smb flags so we must disable the corresponding default capabilities
- that would otherwise cause the Unicode and NT Status flags to be
- set (and even returned by the server) */
+ /*
+ * LANMAN servers predate NT status codes and Unicode and
+ * ignore those smb flags so we must disable the corresponding
+ * default capabilities that would otherwise cause the Unicode
+ * and NT Status flags to be set (and even returned by the
+ * server)
+ */
cli->capabilities &= ~(CAP_UNICODE | CAP_STATUS32);
- /* if in share level security then don't send a password now */
- if (!(cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL))
+ /*
+ * if in share level security then don't send a password now
+ */
+ if (!(cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
passlen = 0;
+ }
- if (passlen > 0 && (cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) && passlen != 24) {
- /* Encrypted mode needed, and non encrypted password supplied. */
+ if (passlen > 0
+ && (cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE)
+ && passlen != 24) {
+ /*
+ * Encrypted mode needed, and non encrypted password
+ * supplied.
+ */
lm_response = data_blob(NULL, 24);
- if (!SMBencrypt(pass, cli->secblob.data,(uchar *)lm_response.data)) {
- DEBUG(1, ("Password is > 14 chars in length, and is therefore incompatible with Lanman authentication\n"));
- return NT_STATUS_ACCESS_DENIED;
+ if (tevent_req_nomem(lm_response.data, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ if (!SMBencrypt(pass, cli->secblob.data,
+ (uint8_t *)lm_response.data)) {
+ DEBUG(1, ("Password is > 14 chars in length, and is "
+ "therefore incompatible with Lanman "
+ "authentication\n"));
+ tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
+ return tevent_req_post(req, ev);
}
- } else if ((cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) && passlen == 24) {
- /* Encrypted mode needed, and encrypted password supplied. */
+ } else if ((cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE)
+ && passlen == 24) {
+ /*
+ * Encrypted mode needed, and encrypted password
+ * supplied.
+ */
lm_response = data_blob(pass, passlen);
+ if (tevent_req_nomem(lm_response.data, req)) {
+ return tevent_req_post(req, ev);
+ }
} else if (passlen > 0) {
- /* Plaintext mode needed, assume plaintext supplied. */
- passlen = clistr_push(cli, pword, pass, sizeof(pword), STR_TERMINATE);
+ uint8_t *buf;
+ size_t converted_size;
+ /*
+ * Plaintext mode needed, assume plaintext supplied.
+ */
+ buf = talloc_array(talloc_tos(), uint8_t, 0);
+ buf = smb_bytes_push_str(buf, cli_ucs2(cli), pass, passlen+1,
+ &converted_size);
+ if (tevent_req_nomem(buf, req)) {
+ return tevent_req_post(req, ev);
+ }
lm_response = data_blob(pass, passlen);
+ TALLOC_FREE(buf);
+ if (tevent_req_nomem(lm_response.data, req)) {
+ return tevent_req_post(req, ev);
+ }
}
- /* send a session setup command */
- memset(cli->outbuf,'\0',smb_size);
- cli_set_message(cli->outbuf,10, 0, True);
- SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
- cli_setup_packet(cli);
+ SCVAL(vwv+0, 0, 0xff);
+ SCVAL(vwv+0, 1, 0);
+ SSVAL(vwv+1, 0, 0);
+ SSVAL(vwv+2, 0, CLI_BUFFER_SIZE);
+ SSVAL(vwv+3, 0, 2);
+ SSVAL(vwv+4, 0, 1);
+ SIVAL(vwv+5, 0, cli->sesskey);
+ SSVAL(vwv+7, 0, lm_response.length);
- SCVAL(cli->outbuf,smb_vwv0,0xFF);
- SSVAL(cli->outbuf,smb_vwv2,cli->max_xmit);
- SSVAL(cli->outbuf,smb_vwv3,2);
- SSVAL(cli->outbuf,smb_vwv4,1);
- SIVAL(cli->outbuf,smb_vwv5,cli->sesskey);
- SSVAL(cli->outbuf,smb_vwv7,lm_response.length);
+ bytes = talloc_array(state, uint8_t, lm_response.length);
+ if (tevent_req_nomem(bytes, req)) {
+ return tevent_req_post(req, ev);
+ }
+ if (lm_response.length != 0) {
+ memcpy(bytes, lm_response.data, lm_response.length);
+ }
+ data_blob_free(&lm_response);
- p = smb_buf(cli->outbuf);
- memcpy(p,lm_response.data,lm_response.length);
- p += lm_response.length;
- p += clistr_push(cli, p, user, -1, STR_TERMINATE|STR_UPPER);
- p += clistr_push(cli, p, workgroup, -1, STR_TERMINATE|STR_UPPER);
- p += clistr_push(cli, p, "Unix", -1, STR_TERMINATE);
- p += clistr_push(cli, p, "Samba", -1, STR_TERMINATE);
- cli_setup_bcc(cli, p);
+ tmp = talloc_strdup_upper(talloc_tos(), user);
+ if (tevent_req_nomem(tmp, req)) {
+ return tevent_req_post(req, ev);
+ }
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), tmp, strlen(tmp)+1,
+ NULL);
+ TALLOC_FREE(tmp);
- if (!cli_send_smb(cli) || !cli_receive_smb(cli)) {
- return cli_nt_error(cli);
+ tmp = talloc_strdup_upper(talloc_tos(), workgroup);
+ if (tevent_req_nomem(tmp, req)) {
+ return tevent_req_post(req, ev);
}
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), tmp, strlen(tmp)+1,
+ NULL);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "Unix", 5, NULL);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "Samba", 6, NULL);
- show_msg(cli->inbuf);
+ if (tevent_req_nomem(bytes, req)) {
+ return tevent_req_post(req, ev);
+ }
- if (cli_is_error(cli)) {
- return cli_nt_error(cli);
+ subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 10, vwv,
+ talloc_get_size(bytes), bytes);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
}
+ tevent_req_set_callback(subreq, cli_session_setup_lanman2_done, req);
+ return req;
+}
- /* use the returned vuid from now on */
- cli->vuid = SVAL(cli->inbuf,smb_uid);
- status = cli_set_username(cli, user);
+static void cli_session_setup_lanman2_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct cli_session_setup_lanman2_state *state = tevent_req_data(
+ req, struct cli_session_setup_lanman2_state);
+ struct cli_state *cli = state->cli;
+ uint32_t num_bytes;
+ uint8_t *in;
+ char *inbuf;
+ uint8_t *bytes;
+ uint8_t *p;
+ NTSTATUS status;
+ ssize_t ret;
+ uint8_t wct;
+ uint16_t *vwv;
+
+ status = cli_smb_recv(subreq, state, &in, 3, &wct, &vwv,
+ &num_bytes, &bytes);
+ TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
- return status;
+ tevent_req_nterror(req, status);
+ return;
}
- return NT_STATUS_OK;
+
+ inbuf = (char *)in;
+ p = bytes;
+
+ cli->vuid = SVAL(inbuf, smb_uid);
+ cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_os,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_type,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_domain,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
+
+ if (strstr(cli->server_type, "Samba")) {
+ cli->is_samba = True;
+ }
+ status = cli_set_username(cli, state->user);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ tevent_req_done(req);
+}
+
+static NTSTATUS cli_session_setup_lanman2_recv(struct tevent_req *req)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
+
+static NTSTATUS cli_session_setup_lanman2(struct cli_state *cli, const char *user,
+ const char *pass, size_t passlen,
+ const char *workgroup)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct event_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ if (cli_has_async_calls(cli)) {
+ /*
+ * Can't use sync call while an async call is in flight
+ */
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
+ }
+ ev = event_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = cli_session_setup_lanman2_send(frame, ev, cli, user, pass, passlen,
+ workgroup);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = cli_session_setup_lanman2_recv(req);
+ fail:
+ TALLOC_FREE(frame);
+ return status;
}
/****************************************************************************
@@ -267,8 +487,11 @@ static void cli_session_setup_guest_done(struct tevent_req *subreq)
uint8_t *bytes;
uint8_t *p;
NTSTATUS status;
+ ssize_t ret;
+ uint8_t wct;
+ uint16_t *vwv;
- status = cli_smb_recv(subreq, state, &in, 0, NULL, NULL,
+ status = cli_smb_recv(subreq, state, &in, 3, &wct, &vwv,
&num_bytes, &bytes);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
@@ -280,13 +503,46 @@ static void cli_session_setup_guest_done(struct tevent_req *subreq)
p = bytes;
cli->vuid = SVAL(inbuf, smb_uid);
+ cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_os,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_type,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
- p += clistr_pull(inbuf, cli->server_os, (char *)p, sizeof(fstring),
- bytes+num_bytes-p, STR_TERMINATE);
- p += clistr_pull(inbuf, cli->server_type, (char *)p, sizeof(fstring),
- bytes+num_bytes-p, STR_TERMINATE);
- p += clistr_pull(inbuf, cli->server_domain, (char *)p, sizeof(fstring),
- bytes+num_bytes-p, STR_TERMINATE);
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_domain,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
if (strstr(cli->server_type, "Samba")) {
cli->is_samba = True;
@@ -340,9 +596,6 @@ static NTSTATUS cli_session_setup_guest(struct cli_state *cli)
status = cli_session_setup_guest_recv(req);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -350,82 +603,201 @@ static NTSTATUS cli_session_setup_guest(struct cli_state *cli)
Do a NT1 plaintext session setup.
****************************************************************************/
-static NTSTATUS cli_session_setup_plaintext(struct cli_state *cli,
- const char *user, const char *pass,
- const char *workgroup)
+struct cli_session_setup_plain_state {
+ struct cli_state *cli;
+ uint16_t vwv[13];
+ const char *user;
+};
+
+static void cli_session_setup_plain_done(struct tevent_req *subreq);
+
+static struct tevent_req *cli_session_setup_plain_send(
+ TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct cli_state *cli,
+ const char *user, const char *pass, const char *workgroup)
{
- uint32 capabilities = cli_session_setup_capabilities(cli);
- char *p;
+ struct tevent_req *req, *subreq;
+ struct cli_session_setup_plain_state *state;
+ uint16_t *vwv;
+ uint8_t *bytes;
+ size_t passlen;
+ char *version;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct cli_session_setup_plain_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->cli = cli;
+ state->user = user;
+ vwv = state->vwv;
+
+ SCVAL(vwv+0, 0, 0xff);
+ SCVAL(vwv+0, 1, 0);
+ SSVAL(vwv+1, 0, 0);
+ SSVAL(vwv+2, 0, CLI_BUFFER_SIZE);
+ SSVAL(vwv+3, 0, 2);
+ SSVAL(vwv+4, 0, cli->pid);
+ SIVAL(vwv+5, 0, cli->sesskey);
+ SSVAL(vwv+7, 0, 0);
+ SSVAL(vwv+8, 0, 0);
+ SSVAL(vwv+9, 0, 0);
+ SSVAL(vwv+10, 0, 0);
+ SIVAL(vwv+11, 0, cli_session_setup_capabilities(cli));
+
+ bytes = talloc_array(state, uint8_t, 0);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), pass, strlen(pass)+1,
+ &passlen);
+ if (tevent_req_nomem(bytes, req)) {
+ return tevent_req_post(req, ev);
+ }
+ SSVAL(vwv + (cli_ucs2(cli) ? 8 : 7), 0, passlen);
+
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli),
+ user, strlen(user)+1, NULL);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli),
+ workgroup, strlen(workgroup)+1, NULL);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli),
+ "Unix", 5, NULL);
+
+ version = talloc_asprintf(talloc_tos(), "Samba %s",
+ samba_version_string());
+ if (tevent_req_nomem(version, req)){
+ return tevent_req_post(req, ev);
+ }
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli),
+ version, strlen(version)+1, NULL);
+ TALLOC_FREE(version);
+
+ if (tevent_req_nomem(bytes, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 13, vwv,
+ talloc_get_size(bytes), bytes);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, cli_session_setup_plain_done, req);
+ return req;
+}
+
+static void cli_session_setup_plain_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct cli_session_setup_plain_state *state = tevent_req_data(
+ req, struct cli_session_setup_plain_state);
+ struct cli_state *cli = state->cli;
+ uint32_t num_bytes;
+ uint8_t *in;
+ char *inbuf;
+ uint8_t *bytes;
+ uint8_t *p;
NTSTATUS status;
- fstring lanman;
-
- fstr_sprintf( lanman, "Samba %s", samba_version_string());
-
- memset(cli->outbuf, '\0', smb_size);
- cli_set_message(cli->outbuf,13,0,True);
- SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
- cli_setup_packet(cli);
-
- SCVAL(cli->outbuf,smb_vwv0,0xFF);
- SSVAL(cli->outbuf,smb_vwv2,CLI_BUFFER_SIZE);
- SSVAL(cli->outbuf,smb_vwv3,2);
- SSVAL(cli->outbuf,smb_vwv4,cli->pid);
- SIVAL(cli->outbuf,smb_vwv5,cli->sesskey);
- SSVAL(cli->outbuf,smb_vwv8,0);
- SIVAL(cli->outbuf,smb_vwv11,capabilities);
- p = smb_buf(cli->outbuf);
-
- /* check wether to send the ASCII or UNICODE version of the password */
-
- if ( (capabilities & CAP_UNICODE) == 0 ) {
- p += clistr_push(cli, p, pass, -1, STR_TERMINATE); /* password */
- SSVAL(cli->outbuf,smb_vwv7,PTR_DIFF(p, smb_buf(cli->outbuf)));
- }
- else {
- /* For ucs2 passwords clistr_push calls ucs2_align, which causes
- * the space taken by the unicode password to be one byte too
- * long (as we're on an odd byte boundary here). Reduce the
- * count by 1 to cope with this. Fixes smbclient against NetApp
- * servers which can't cope. Fix from
- * bryan.kolodziej@allenlund.com in bug #3840.
- */
- p += clistr_push(cli, p, pass, -1, STR_UNICODE|STR_TERMINATE); /* unicode password */
- SSVAL(cli->outbuf,smb_vwv8,PTR_DIFF(p, smb_buf(cli->outbuf))-1);
+ ssize_t ret;
+ uint8_t wct;
+ uint16_t *vwv;
+
+ status = cli_smb_recv(subreq, state, &in, 3, &wct, &vwv,
+ &num_bytes, &bytes);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
}
- p += clistr_push(cli, p, user, -1, STR_TERMINATE); /* username */
- p += clistr_push(cli, p, workgroup, -1, STR_TERMINATE); /* workgroup */
- p += clistr_push(cli, p, "Unix", -1, STR_TERMINATE);
- p += clistr_push(cli, p, lanman, -1, STR_TERMINATE);
- cli_setup_bcc(cli, p);
+ inbuf = (char *)in;
+ p = bytes;
+
+ cli->vuid = SVAL(inbuf, smb_uid);
+ cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_os,
+ p,
+ bytes+num_bytes-p,
+ &ret);
- if (!cli_send_smb(cli) || !cli_receive_smb(cli)) {
- return cli_nt_error(cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
}
+ p += ret;
- show_msg(cli->inbuf);
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_type,
+ p,
+ bytes+num_bytes-p,
+ &ret);
- if (cli_is_error(cli)) {
- return cli_nt_error(cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
}
+ p += ret;
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_domain,
+ p,
+ bytes+num_bytes-p,
+ &ret);
- cli->vuid = SVAL(cli->inbuf,smb_uid);
- p = smb_buf(cli->inbuf);
- p += clistr_pull(cli->inbuf, cli->server_os, p, sizeof(fstring),
- -1, STR_TERMINATE);
- p += clistr_pull(cli->inbuf, cli->server_type, p, sizeof(fstring),
- -1, STR_TERMINATE);
- p += clistr_pull(cli->inbuf, cli->server_domain, p, sizeof(fstring),
- -1, STR_TERMINATE);
- status = cli_set_username(cli, user);
if (!NT_STATUS_IS_OK(status)) {
- return status;
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
+
+ status = cli_set_username(cli, state->user);
+ if (tevent_req_nterror(req, status)) {
+ return;
}
if (strstr(cli->server_type, "Samba")) {
cli->is_samba = True;
}
+ tevent_req_done(req);
+}
- return NT_STATUS_OK;
+static NTSTATUS cli_session_setup_plain_recv(struct tevent_req *req)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
+
+static NTSTATUS cli_session_setup_plain(struct cli_state *cli,
+ const char *user, const char *pass,
+ const char *workgroup)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct event_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ if (cli_has_async_calls(cli)) {
+ /*
+ * Can't use sync call while an async call is in flight
+ */
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
+ }
+ ev = event_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = cli_session_setup_plain_send(frame, ev, cli, user, pass,
+ workgroup);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = cli_session_setup_plain_recv(req);
+ fail:
+ TALLOC_FREE(frame);
+ return status;
}
/****************************************************************************
@@ -438,18 +810,40 @@ static NTSTATUS cli_session_setup_plaintext(struct cli_state *cli,
@param workgroup The user's domain.
****************************************************************************/
-static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user,
- const char *pass, size_t passlen,
- const char *ntpass, size_t ntpasslen,
- const char *workgroup)
+struct cli_session_setup_nt1_state {
+ struct cli_state *cli;
+ uint16_t vwv[13];
+ DATA_BLOB response;
+ DATA_BLOB session_key;
+ const char *user;
+};
+
+static void cli_session_setup_nt1_done(struct tevent_req *subreq);
+
+static struct tevent_req *cli_session_setup_nt1_send(
+ TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct cli_state *cli, const char *user,
+ const char *pass, size_t passlen,
+ const char *ntpass, size_t ntpasslen,
+ const char *workgroup)
{
- uint32 capabilities = cli_session_setup_capabilities(cli);
+ struct tevent_req *req, *subreq;
+ struct cli_session_setup_nt1_state *state;
DATA_BLOB lm_response = data_blob_null;
DATA_BLOB nt_response = data_blob_null;
DATA_BLOB session_key = data_blob_null;
- NTSTATUS result;
- char *p;
- bool ok;
+ uint16_t *vwv;
+ uint8_t *bytes;
+ char *workgroup_upper;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct cli_session_setup_nt1_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->cli = cli;
+ state->user = user;
+ vwv = state->vwv;
if (passlen == 0) {
/* do nothing - guest login */
@@ -457,20 +851,35 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user,
if (lp_client_ntlmv2_auth()) {
DATA_BLOB server_chal;
DATA_BLOB names_blob;
- server_chal = data_blob(cli->secblob.data, MIN(cli->secblob.length, 8));
- /* note that the 'workgroup' here is a best guess - we don't know
- the server's domain at this point. The 'server name' is also
- dodgy...
- */
- names_blob = NTLMv2_generate_names_blob(NULL, cli->called.name, workgroup);
+ server_chal = data_blob(cli->secblob.data,
+ MIN(cli->secblob.length, 8));
+ if (tevent_req_nomem(server_chal.data, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ /*
+ * note that the 'workgroup' here is a best
+ * guess - we don't know the server's domain
+ * at this point. The 'server name' is also
+ * dodgy...
+ */
+ names_blob = NTLMv2_generate_names_blob(
+ NULL, cli->called.name, workgroup);
+
+ if (tevent_req_nomem(names_blob.data, req)) {
+ return tevent_req_post(req, ev);
+ }
- if (!SMBNTLMv2encrypt(NULL, user, workgroup, pass, &server_chal,
- &names_blob,
- &lm_response, &nt_response, NULL, &session_key)) {
+ if (!SMBNTLMv2encrypt(NULL, user, workgroup, pass,
+ &server_chal, &names_blob,
+ &lm_response, &nt_response,
+ NULL, &session_key)) {
data_blob_free(&names_blob);
data_blob_free(&server_chal);
- return NT_STATUS_ACCESS_DENIED;
+ tevent_req_nterror(
+ req, NT_STATUS_ACCESS_DENIED);
+ return tevent_req_post(req, ev);
}
data_blob_free(&names_blob);
data_blob_free(&server_chal);
@@ -483,23 +892,50 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user,
nt_response = data_blob_null;
#else
nt_response = data_blob(NULL, 24);
- SMBNTencrypt(pass,cli->secblob.data,nt_response.data);
+ if (tevent_req_nomem(nt_response.data, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ SMBNTencrypt(pass, cli->secblob.data,
+ nt_response.data);
#endif
/* non encrypted password supplied. Ignore ntpass. */
if (lp_client_lanman_auth()) {
+
lm_response = data_blob(NULL, 24);
- if (!SMBencrypt(pass,cli->secblob.data, lm_response.data)) {
- /* Oops, the LM response is invalid, just put
- the NT response there instead */
+ if (tevent_req_nomem(lm_response.data, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ if (!SMBencrypt(pass,cli->secblob.data,
+ lm_response.data)) {
+ /*
+ * Oops, the LM response is
+ * invalid, just put the NT
+ * response there instead
+ */
data_blob_free(&lm_response);
- lm_response = data_blob(nt_response.data, nt_response.length);
+ lm_response = data_blob(
+ nt_response.data,
+ nt_response.length);
}
} else {
- /* LM disabled, place NT# in LM field instead */
- lm_response = data_blob(nt_response.data, nt_response.length);
+ /*
+ * LM disabled, place NT# in LM field
+ * instead
+ */
+ lm_response = data_blob(
+ nt_response.data, nt_response.length);
+ }
+
+ if (tevent_req_nomem(lm_response.data, req)) {
+ return tevent_req_post(req, ev);
}
session_key = data_blob(NULL, 16);
+ if (tevent_req_nomem(session_key.data, req)) {
+ return tevent_req_post(req, ev);
+ }
#ifdef LANMAN_ONLY
E_deshash(pass, session_key.data);
memset(&session_key.data[8], '\0', 8);
@@ -514,94 +950,219 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user,
signing because we don't have original key */
lm_response = data_blob(pass, passlen);
+ if (tevent_req_nomem(lm_response.data, req)) {
+ return tevent_req_post(req, ev);
+ }
+
nt_response = data_blob(ntpass, ntpasslen);
+ if (tevent_req_nomem(nt_response.data, req)) {
+ return tevent_req_post(req, ev);
+ }
}
- /* send a session setup command */
- memset(cli->outbuf,'\0',smb_size);
+#ifdef LANMAN_ONLY
+ state->response = data_blob_talloc(
+ state, lm_response.data, lm_response.length);
+#else
+ state->response = data_blob_talloc(
+ state, nt_response.data, nt_response.length);
+#endif
+ if (tevent_req_nomem(state->response.data, req)) {
+ return tevent_req_post(req, ev);
+ }
- cli_set_message(cli->outbuf,13,0,True);
- SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
- cli_setup_packet(cli);
+ if (session_key.data) {
+ state->session_key = data_blob_talloc(
+ state, session_key.data, session_key.length);
+ if (tevent_req_nomem(state->session_key.data, req)) {
+ return tevent_req_post(req, ev);
+ }
+ }
+ data_blob_free(&session_key);
+
+ SCVAL(vwv+0, 0, 0xff);
+ SCVAL(vwv+0, 1, 0);
+ SSVAL(vwv+1, 0, 0);
+ SSVAL(vwv+2, 0, CLI_BUFFER_SIZE);
+ SSVAL(vwv+3, 0, 2);
+ SSVAL(vwv+4, 0, cli->pid);
+ SIVAL(vwv+5, 0, cli->sesskey);
+ SSVAL(vwv+7, 0, lm_response.length);
+ SSVAL(vwv+8, 0, nt_response.length);
+ SSVAL(vwv+9, 0, 0);
+ SSVAL(vwv+10, 0, 0);
+ SIVAL(vwv+11, 0, cli_session_setup_capabilities(cli));
- SCVAL(cli->outbuf,smb_vwv0,0xFF);
- SSVAL(cli->outbuf,smb_vwv2,CLI_BUFFER_SIZE);
- SSVAL(cli->outbuf,smb_vwv3,2);
- SSVAL(cli->outbuf,smb_vwv4,cli->pid);
- SIVAL(cli->outbuf,smb_vwv5,cli->sesskey);
- SSVAL(cli->outbuf,smb_vwv7,lm_response.length);
- SSVAL(cli->outbuf,smb_vwv8,nt_response.length);
- SIVAL(cli->outbuf,smb_vwv11,capabilities);
- p = smb_buf(cli->outbuf);
- if (lm_response.length) {
- memcpy(p,lm_response.data, lm_response.length); p += lm_response.length;
+ bytes = talloc_array(state, uint8_t,
+ lm_response.length + nt_response.length);
+ if (tevent_req_nomem(bytes, req)) {
+ return tevent_req_post(req, ev);
+ }
+ if (lm_response.length != 0) {
+ memcpy(bytes, lm_response.data, lm_response.length);
}
- if (nt_response.length) {
- memcpy(p,nt_response.data, nt_response.length); p += nt_response.length;
+ if (nt_response.length != 0) {
+ memcpy(bytes + lm_response.length,
+ nt_response.data, nt_response.length);
}
- p += clistr_push(cli, p, user, -1, STR_TERMINATE);
+ data_blob_free(&lm_response);
+ data_blob_free(&nt_response);
- /* Upper case here might help some NTLMv2 implementations */
- p += clistr_push(cli, p, workgroup, -1, STR_TERMINATE|STR_UPPER);
- p += clistr_push(cli, p, "Unix", -1, STR_TERMINATE);
- p += clistr_push(cli, p, "Samba", -1, STR_TERMINATE);
- cli_setup_bcc(cli, p);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli),
+ user, strlen(user)+1, NULL);
- if (!cli_send_smb(cli) || !cli_receive_smb(cli)) {
- result = cli_nt_error(cli);
- goto end;
+ /*
+ * Upper case here might help some NTLMv2 implementations
+ */
+ workgroup_upper = talloc_strdup_upper(talloc_tos(), workgroup);
+ if (tevent_req_nomem(workgroup_upper, req)) {
+ return tevent_req_post(req, ev);
}
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli),
+ workgroup_upper, strlen(workgroup_upper)+1,
+ NULL);
+ TALLOC_FREE(workgroup_upper);
- /* show_msg(cli->inbuf); */
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "Unix", 5, NULL);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "Samba", 6, NULL);
+ if (tevent_req_nomem(bytes, req)) {
+ return tevent_req_post(req, ev);
+ }
- if (cli_is_error(cli)) {
- result = cli_nt_error(cli);
- goto end;
+ subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 13, vwv,
+ talloc_get_size(bytes), bytes);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
}
+ tevent_req_set_callback(subreq, cli_session_setup_nt1_done, req);
+ return req;
+}
-#ifdef LANMAN_ONLY
- ok = cli_simple_set_signing(cli, session_key, lm_response);
-#else
- ok = cli_simple_set_signing(cli, session_key, nt_response);
-#endif
- if (ok) {
- if (!cli_check_sign_mac(cli, cli->inbuf, 1)) {
- result = NT_STATUS_ACCESS_DENIED;
- goto end;
- }
+static void cli_session_setup_nt1_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct cli_session_setup_nt1_state *state = tevent_req_data(
+ req, struct cli_session_setup_nt1_state);
+ struct cli_state *cli = state->cli;
+ uint32_t num_bytes;
+ uint8_t *in;
+ char *inbuf;
+ uint8_t *bytes;
+ uint8_t *p;
+ NTSTATUS status;
+ ssize_t ret;
+ uint8_t wct;
+ uint16_t *vwv;
+
+ status = cli_smb_recv(subreq, state, &in, 3, &wct, &vwv,
+ &num_bytes, &bytes);
+ TALLOC_FREE(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
}
- /* use the returned vuid from now on */
- cli->vuid = SVAL(cli->inbuf,smb_uid);
+ inbuf = (char *)in;
+ p = bytes;
- p = smb_buf(cli->inbuf);
- p += clistr_pull(cli->inbuf, cli->server_os, p, sizeof(fstring),
- -1, STR_TERMINATE);
- p += clistr_pull(cli->inbuf, cli->server_type, p, sizeof(fstring),
- -1, STR_TERMINATE);
- p += clistr_pull(cli->inbuf, cli->server_domain, p, sizeof(fstring),
- -1, STR_TERMINATE);
+ cli->vuid = SVAL(inbuf, smb_uid);
+ cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_os,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_type,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
+
+ status = smb_bytes_talloc_string(cli,
+ inbuf,
+ &cli->server_domain,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
if (strstr(cli->server_type, "Samba")) {
cli->is_samba = True;
}
- result = cli_set_username(cli, user);
- if (!NT_STATUS_IS_OK(result)) {
- goto end;
+ status = cli_set_username(cli, state->user);
+ if (tevent_req_nterror(req, status)) {
+ return;
}
-
- if (session_key.data) {
+ if (cli_simple_set_signing(cli, state->session_key, state->response)
+ && !cli_check_sign_mac(cli, (char *)in, 1)) {
+ tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
+ return;
+ }
+ if (state->session_key.data) {
/* Have plaintext orginal */
- cli_set_session_key(cli, session_key);
+ cli_set_session_key(cli, state->session_key);
}
+ tevent_req_done(req);
+}
- result = NT_STATUS_OK;
-end:
- data_blob_free(&lm_response);
- data_blob_free(&nt_response);
- data_blob_free(&session_key);
- return result;
+static NTSTATUS cli_session_setup_nt1_recv(struct tevent_req *req)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
+
+static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user,
+ const char *pass, size_t passlen,
+ const char *ntpass, size_t ntpasslen,
+ const char *workgroup)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct event_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ if (cli_has_async_calls(cli)) {
+ /*
+ * Can't use sync call while an async call is in flight
+ */
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
+ }
+ ev = event_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = cli_session_setup_nt1_send(frame, ev, cli, user, pass, passlen,
+ ntpass, ntpasslen, workgroup);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = cli_session_setup_nt1_recv(req);
+ fail:
+ TALLOC_FREE(frame);
+ return status;
}
/* The following is calculated from :
@@ -729,8 +1290,9 @@ static void cli_sesssetup_blob_done(struct tevent_req *subreq)
uint8_t *p;
uint16_t blob_length;
uint8_t *inbuf;
+ ssize_t ret;
- status = cli_smb_recv(subreq, state, &inbuf, 1, &wct, &vwv,
+ status = cli_smb_recv(subreq, state, &inbuf, 4, &wct, &vwv,
&num_bytes, &bytes);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)
@@ -744,6 +1306,7 @@ static void cli_sesssetup_blob_done(struct tevent_req *subreq)
state->inbuf = (char *)inbuf;
cli->vuid = SVAL(state->inbuf, smb_uid);
+ cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
blob_length = SVAL(vwv+3, 0);
if (blob_length > num_bytes) {
@@ -754,15 +1317,44 @@ static void cli_sesssetup_blob_done(struct tevent_req *subreq)
p = bytes + blob_length;
- p += clistr_pull(state->inbuf, cli->server_os,
- (char *)p, sizeof(fstring),
- bytes+num_bytes-p, STR_TERMINATE);
- p += clistr_pull(state->inbuf, cli->server_type,
- (char *)p, sizeof(fstring),
- bytes+num_bytes-p, STR_TERMINATE);
- p += clistr_pull(state->inbuf, cli->server_domain,
- (char *)p, sizeof(fstring),
- bytes+num_bytes-p, STR_TERMINATE);
+ status = smb_bytes_talloc_string(cli,
+ (char *)inbuf,
+ &cli->server_os,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
+
+ status = smb_bytes_talloc_string(cli,
+ (char *)inbuf,
+ &cli->server_type,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
+
+ status = smb_bytes_talloc_string(cli,
+ (char *)inbuf,
+ &cli->server_domain,
+ p,
+ bytes+num_bytes-p,
+ &ret);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ p += ret;
if (strstr(cli->server_type, "Samba")) {
cli->is_samba = True;
@@ -773,7 +1365,7 @@ static void cli_sesssetup_blob_done(struct tevent_req *subreq)
* More to send
*/
if (!cli_sesssetup_blob_next(state, &subreq)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
tevent_req_set_callback(subreq, cli_sesssetup_blob_done, req);
@@ -833,7 +1425,7 @@ static void cli_session_setup_kerberos_done(struct tevent_req *subreq);
static struct tevent_req *cli_session_setup_kerberos_send(
TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
- const char *principal, const char *workgroup)
+ const char *principal)
{
struct tevent_req *req, *subreq;
struct cli_session_setup_kerberos_state *state;
@@ -921,8 +1513,7 @@ static ADS_STATUS cli_session_setup_kerberos_recv(struct tevent_req *req)
}
static ADS_STATUS cli_session_setup_kerberos(struct cli_state *cli,
- const char *principal,
- const char *workgroup)
+ const char *principal)
{
struct tevent_context *ev;
struct tevent_req *req;
@@ -935,8 +1526,7 @@ static ADS_STATUS cli_session_setup_kerberos(struct cli_state *cli,
if (ev == NULL) {
goto fail;
}
- req = cli_session_setup_kerberos_send(ev, ev, cli, principal,
- workgroup);
+ req = cli_session_setup_kerberos_send(ev, ev, cli, principal);
if (req == NULL) {
goto fail;
}
@@ -1000,7 +1590,7 @@ static struct tevent_req *cli_session_setup_ntlmssp_send(
cli_temp_set_signing(cli);
status = ntlmssp_client_start(state,
- global_myname(),
+ lp_netbios_name(),
lp_workgroup(),
lp_client_ntlmv2_auth(),
&state->ntlmssp_state);
@@ -1063,8 +1653,14 @@ static void cli_session_setup_ntlmssp_done(struct tevent_req *subreq)
if (NT_STATUS_IS_OK(status)) {
if (state->cli->server_domain[0] == '\0') {
- fstrcpy(state->cli->server_domain,
- state->ntlmssp_state->server.netbios_domain);
+ TALLOC_FREE(state->cli->server_domain);
+ state->cli->server_domain = talloc_strdup(state->cli,
+ state->ntlmssp_state->server.netbios_domain);
+ if (state->cli->server_domain == NULL) {
+ TALLOC_FREE(subreq);
+ tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+ return;
+ }
}
cli_set_session_key(
state->cli, state->ntlmssp_state->session_key);
@@ -1179,9 +1775,6 @@ static NTSTATUS cli_session_setup_ntlmssp(struct cli_state *cli,
status = cli_session_setup_ntlmssp_recv(req);
fail:
TALLOC_FREE(ev);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1291,6 +1884,9 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
host = strchr_m(cli->desthost, '.');
if (dest_realm) {
realm = SMB_STRDUP(dest_realm);
+ if (!realm) {
+ return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
+ }
strupper_m(realm);
} else {
if (host) {
@@ -1302,25 +1898,38 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
}
}
- if (realm && *realm) {
- principal = talloc_asprintf(talloc_tos(),
- "cifs/%s@%s",
- cli->desthost,
- realm);
- if (!principal) {
- SAFE_FREE(realm);
+ if (realm == NULL || *realm == '\0') {
+ realm = SMB_STRDUP(lp_realm());
+ if (!realm) {
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
}
- DEBUG(3,("cli_session_setup_spnego: guessed "
- "server principal=%s\n",
- principal ? principal : "<null>"));
+ strupper_m(realm);
+ DEBUG(3,("cli_session_setup_spnego: cannot "
+ "get realm from dest_realm %s, "
+ "desthost %s. Using default "
+ "smb.conf realm %s\n",
+ dest_realm ? dest_realm : "<null>",
+ cli->desthost,
+ realm));
}
+
+ principal = talloc_asprintf(talloc_tos(),
+ "cifs/%s@%s",
+ cli->desthost,
+ realm);
+ if (!principal) {
+ SAFE_FREE(realm);
+ return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
+ }
+ DEBUG(3,("cli_session_setup_spnego: guessed "
+ "server principal=%s\n",
+ principal ? principal : "<null>"));
+
SAFE_FREE(realm);
}
if (principal) {
- rc = cli_session_setup_kerberos(cli, principal,
- dest_realm);
+ rc = cli_session_setup_kerberos(cli, principal);
if (ADS_ERR_OK(rc) || !cli->fallback_after_kerberos) {
TALLOC_FREE(principal);
return rc;
@@ -1361,12 +1970,15 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
const char *workgroup)
{
char *p;
- fstring user2;
+ char *user2;
if (user) {
- fstrcpy(user2, user);
+ user2 = talloc_strdup(talloc_tos(), user);
} else {
- user2[0] ='\0';
+ user2 = talloc_strdup(talloc_tos(), "");
+ }
+ if (user2 == NULL) {
+ return NT_STATUS_NO_MEMORY;
}
if (!workgroup) {
@@ -1378,6 +1990,7 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
(p=strchr_m(user2,*lp_winbind_separator()))) {
*p = 0;
user = p+1;
+ strupper_m(user2);
workgroup = user2;
}
@@ -1420,7 +2033,7 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
connect */
if ((cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL) == 0)
- return cli_session_setup_plaintext(cli, user, "", workgroup);
+ return cli_session_setup_plain(cli, user, "", workgroup);
/* if the server doesn't support encryption then we have to use
plaintext. The second password is ignored */
@@ -1431,7 +2044,7 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
" or 'client ntlmv2 auth = yes'\n"));
return NT_STATUS_ACCESS_DENIED;
}
- return cli_session_setup_plaintext(cli, user, pass, workgroup);
+ return cli_session_setup_plain(cli, user, pass, workgroup);
}
/* if the server supports extended security then use SPNEGO */
@@ -1545,9 +2158,6 @@ NTSTATUS cli_ulogoff(struct cli_state *cli)
status = cli_ulogoff_recv(req);
fail:
TALLOC_FREE(ev);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1572,7 +2182,7 @@ struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
{
struct tevent_req *req, *subreq;
struct cli_tcon_andx_state *state;
- fstring pword;
+ uint8_t p24[24];
uint16_t *vwv;
char *tmp = NULL;
uint8_t *bytes;
@@ -1586,7 +2196,10 @@ struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
state->cli = cli;
vwv = state->vwv;
- fstrcpy(cli->share, share);
+ cli->share = talloc_strdup(cli, share);
+ if (!cli->share) {
+ return NULL;
+ }
/* in user level security don't send a password now */
if (cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL) {
@@ -1611,12 +2224,15 @@ struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
* Non-encrypted passwords - convert to DOS codepage before
* encryption.
*/
+ SMBencrypt(pass, cli->secblob.data, p24);
passlen = 24;
- SMBencrypt(pass, cli->secblob.data, (uchar *)pword);
+ pass = (const char *)p24;
} else {
if((cli->sec_mode & (NEGOTIATE_SECURITY_USER_LEVEL
|NEGOTIATE_SECURITY_CHALLENGE_RESPONSE))
== 0) {
+ char *tmp_pass;
+
if (!lp_client_plaintext_auth() && (*pass)) {
DEBUG(1, ("Server requested plaintext "
"password but "
@@ -1628,16 +2244,21 @@ struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
* Non-encrypted passwords - convert to DOS codepage
* before using.
*/
- passlen = clistr_push(cli, pword, pass, sizeof(pword),
- STR_TERMINATE);
- if (passlen == -1) {
- DEBUG(1, ("clistr_push(pword) failed\n"));
- goto access_denied;
+ tmp_pass = talloc_array(talloc_tos(), char, 128);
+ if (tmp_pass == NULL) {
+ tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+ return tevent_req_post(req, ev);
}
- } else {
- if (passlen) {
- memcpy(pword, pass, passlen);
+ passlen = clistr_push(cli,
+ tmp_pass,
+ pass,
+ talloc_get_size(tmp_pass),
+ STR_TERMINATE);
+ if (passlen == -1) {
+ tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+ return tevent_req_post(req, ev);
}
+ pass = tmp_pass;
}
}
@@ -1647,8 +2268,8 @@ struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
SSVAL(vwv+2, 0, TCONX_FLAG_EXTENDED_RESPONSE);
SSVAL(vwv+3, 0, passlen);
- if (passlen) {
- bytes = (uint8_t *)talloc_memdup(state, pword, passlen);
+ if (passlen && pass) {
+ bytes = (uint8_t *)talloc_memdup(state, pass, passlen);
} else {
bytes = talloc_array(state, uint8_t, 0);
}
@@ -1750,8 +2371,24 @@ static void cli_tcon_andx_done(struct tevent_req *subreq)
inbuf = (char *)in;
- clistr_pull(inbuf, cli->dev, bytes, sizeof(fstring), num_bytes,
- STR_TERMINATE|STR_ASCII);
+ if (num_bytes) {
+ if (clistr_pull_talloc(cli,
+ inbuf,
+ SVAL(inbuf, smb_flg2),
+ &cli->dev,
+ bytes,
+ num_bytes,
+ STR_TERMINATE|STR_ASCII) == -1) {
+ tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+ return;
+ }
+ } else {
+ cli->dev = talloc_strdup(cli, "");
+ if (cli->dev == NULL) {
+ tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+ return;
+ }
+ }
if ((cli->protocol >= PROTOCOL_NT1) && (num_bytes == 3)) {
/* almost certainly win95 - enable bug fixes */
@@ -1814,9 +2451,6 @@ NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share,
status = cli_tcon_andx_recv(req);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1897,9 +2531,6 @@ NTSTATUS cli_tdis(struct cli_state *cli)
status = cli_tdis_recv(req);
fail:
TALLOC_FREE(ev);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -2028,11 +2659,14 @@ static void cli_negprot_done(struct tevent_req *subreq)
}
/* work out if they sent us a workgroup */
if (!(cli->capabilities & CAP_EXTENDED_SECURITY) &&
- smb_buflen(cli->inbuf) > 8) {
- clistr_pull(cli->inbuf, cli->server_domain,
- bytes+8, sizeof(cli->server_domain),
- num_bytes-8,
- STR_UNICODE|STR_NOALIGN);
+ smb_buflen(inbuf) > 8) {
+ ssize_t ret;
+ status = smb_bytes_talloc_string(
+ cli, (char *)inbuf, &cli->server_domain,
+ bytes + 8, num_bytes - 8, &ret);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
}
/*
@@ -2149,306 +2783,141 @@ NTSTATUS cli_negprot(struct cli_state *cli)
status = cli_negprot_recv(req);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
-/****************************************************************************
- Send a session request. See rfc1002.txt 4.3 and 4.3.2.
-****************************************************************************/
-
-bool cli_session_request(struct cli_state *cli,
- struct nmb_name *calling, struct nmb_name *called)
+static NTSTATUS cli_connect_sock(const char *host, int name_type,
+ const struct sockaddr_storage *pss,
+ const char *myname, uint16_t port,
+ int sec_timeout, int *pfd, uint16_t *pport)
{
- char *p;
- int len = 4;
- int namelen = 0;
- char *tmp;
-
- /* 445 doesn't have session request */
- if (cli->port == 445)
- return True;
-
- memcpy(&(cli->calling), calling, sizeof(*calling));
- memcpy(&(cli->called ), called , sizeof(*called ));
-
- /* put in the destination name */
-
- tmp = name_mangle(talloc_tos(), cli->called.name,
- cli->called.name_type);
- if (tmp == NULL) {
- return false;
- }
-
- p = cli->outbuf+len;
- namelen = name_len((unsigned char *)tmp, talloc_get_size(tmp));
- if (namelen > 0) {
- memcpy(p, tmp, namelen);
- len += namelen;
- }
- TALLOC_FREE(tmp);
-
- /* and my name */
-
- tmp = name_mangle(talloc_tos(), cli->calling.name,
- cli->calling.name_type);
- if (tmp == NULL) {
- return false;
- }
-
- p = cli->outbuf+len;
- namelen = name_len((unsigned char *)tmp, talloc_get_size(tmp));
- if (namelen > 0) {
- memcpy(p, tmp, namelen);
- len += namelen;
- }
- TALLOC_FREE(tmp);
-
- /* send a session request (RFC 1002) */
- /* setup the packet length
- * Remove four bytes from the length count, since the length
- * field in the NBT Session Service header counts the number
- * of bytes which follow. The cli_send_smb() function knows
- * about this and accounts for those four bytes.
- * CRH.
- */
- len -= 4;
- _smb_setlen(cli->outbuf,len);
- SCVAL(cli->outbuf,0,0x81);
-
- cli_send_smb(cli);
- DEBUG(5,("Sent session request\n"));
-
- if (!cli_receive_smb(cli))
- return False;
-
- if (CVAL(cli->inbuf,0) == 0x84) {
- /* C. Hoch 9/14/95 Start */
- /* For information, here is the response structure.
- * We do the byte-twiddling to for portability.
- struct RetargetResponse{
- unsigned char type;
- unsigned char flags;
- int16 length;
- int32 ip_addr;
- int16 port;
- };
- */
- uint16_t port = (CVAL(cli->inbuf,8)<<8)+CVAL(cli->inbuf,9);
- struct in_addr dest_ip;
- NTSTATUS status;
-
- /* SESSION RETARGET */
- putip((char *)&dest_ip,cli->inbuf+4);
- in_addr_to_sockaddr_storage(&cli->dest_ss, dest_ip);
-
- status = open_socket_out(&cli->dest_ss, port,
- LONG_CONNECT_TIMEOUT, &cli->fd);
- if (!NT_STATUS_IS_OK(status)) {
- return False;
- }
-
- DEBUG(3,("Retargeted\n"));
-
- set_socket_options(cli->fd, lp_socket_options());
-
- /* Try again */
- {
- static int depth;
- bool ret;
- if (depth > 4) {
- DEBUG(0,("Retarget recursion - failing\n"));
- return False;
- }
- depth++;
- ret = cli_session_request(cli, calling, called);
- depth--;
- return ret;
- }
- } /* C. Hoch 9/14/95 End */
-
- if (CVAL(cli->inbuf,0) != 0x82) {
- /* This is the wrong place to put the error... JRA. */
- cli->rap_error = CVAL(cli->inbuf,4);
- return False;
- }
- return(True);
-}
-
-struct fd_struct {
- int fd;
-};
-
-static void smb_sock_connected(struct tevent_req *req)
-{
- struct fd_struct *pfd = tevent_req_callback_data(
- req, struct fd_struct);
- int fd;
+ TALLOC_CTX *frame = talloc_stackframe();
+ const char *prog;
+ unsigned int i, num_addrs;
+ const char **called_names;
+ const char **calling_names;
+ int *called_types;
NTSTATUS status;
+ int fd;
- status = open_socket_out_defer_recv(req, &fd);
- if (NT_STATUS_IS_OK(status)) {
- pfd->fd = fd;
- }
-}
-
-static NTSTATUS open_smb_socket(const struct sockaddr_storage *pss,
- uint16_t *port, int timeout, int *pfd)
-{
- struct event_context *ev;
- struct tevent_req *r139, *r445;
- struct fd_struct *fd139, *fd445;
- NTSTATUS status = NT_STATUS_NO_MEMORY;
-
- if (*port != 0) {
- return open_socket_out(pss, *port, timeout, pfd);
- }
-
- ev = event_context_init(talloc_tos());
- if (ev == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- fd139 = talloc(ev, struct fd_struct);
- if (fd139 == NULL) {
+ prog = getenv("LIBSMB_PROG");
+ if (prog != NULL) {
+ fd = sock_exec(prog);
+ if (fd == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ port = 0;
goto done;
}
- fd139->fd = -1;
- fd445 = talloc(ev, struct fd_struct);
- if (fd445 == NULL) {
- goto done;
+ if ((pss == NULL) || is_zero_addr(pss)) {
+ struct sockaddr_storage *addrs;
+ status = resolve_name_list(talloc_tos(), host, name_type,
+ &addrs, &num_addrs);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+ pss = addrs;
+ } else {
+ num_addrs = 1;
}
- fd445->fd = -1;
- r445 = open_socket_out_defer_send(ev, ev, timeval_set(0, 0),
- pss, 445, timeout);
- r139 = open_socket_out_defer_send(ev, ev, timeval_set(0, 3000),
- pss, 139, timeout);
- if ((r445 == NULL) || (r139 == NULL)) {
- goto done;
+ called_names = talloc_array(talloc_tos(), const char *, num_addrs);
+ if (called_names == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
}
- tevent_req_set_callback(r445, smb_sock_connected, fd445);
- tevent_req_set_callback(r139, smb_sock_connected, fd139);
-
- while ((fd445->fd == -1) && (fd139->fd == -1)
- && (tevent_req_is_in_progress(r139)
- || tevent_req_is_in_progress(r445))) {
- event_loop_once(ev);
+ called_types = talloc_array(talloc_tos(), int, num_addrs);
+ if (called_types == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
}
-
- if ((fd139->fd != -1) && (fd445->fd != -1)) {
- close(fd139->fd);
- fd139->fd = -1;
+ calling_names = talloc_array(talloc_tos(), const char *, num_addrs);
+ if (calling_names == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
}
-
- if (fd445->fd != -1) {
- *port = 445;
- *pfd = fd445->fd;
- status = NT_STATUS_OK;
- goto done;
+ for (i=0; i<num_addrs; i++) {
+ called_names[i] = host;
+ called_types[i] = name_type;
+ calling_names[i] = myname;
}
- if (fd139->fd != -1) {
- *port = 139;
- *pfd = fd139->fd;
- status = NT_STATUS_OK;
- goto done;
+ status = smbsock_any_connect(pss, called_names, called_types,
+ calling_names, NULL, num_addrs, port,
+ sec_timeout, &fd, NULL, &port);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
}
-
- status = open_socket_out_defer_recv(r445, &fd445->fd);
- done:
- TALLOC_FREE(ev);
+ set_socket_options(fd, lp_socket_options());
+done:
+ *pfd = fd;
+ *pport = port;
+ status = NT_STATUS_OK;
+fail:
+ TALLOC_FREE(frame);
return status;
}
-/****************************************************************************
- Open the client sockets.
-****************************************************************************/
-
-NTSTATUS cli_connect(struct cli_state *cli,
- const char *host,
- struct sockaddr_storage *dest_ss)
-
+NTSTATUS cli_connect_nb(const char *host, struct sockaddr_storage *pss,
+ uint16_t port, int name_type, const char *myname,
+ int signing_state, struct cli_state **pcli)
{
- int name_type = 0x20;
TALLOC_CTX *frame = talloc_stackframe();
- unsigned int num_addrs = 0;
- unsigned int i = 0;
- struct sockaddr_storage *ss_arr = NULL;
- char *p = NULL;
+ struct cli_state *cli;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+ int fd = -1;
+ char *desthost;
+ char *p;
+ socklen_t length;
+ int ret;
- /* reasonable default hostname */
- if (!host) {
- host = STAR_SMBSERVER;
+ desthost = talloc_strdup(talloc_tos(), host);
+ if (desthost == NULL) {
+ goto fail;
}
- fstrcpy(cli->desthost, host);
-
- /* allow hostnames of the form NAME#xx and do a netbios lookup */
- if ((p = strchr(cli->desthost, '#'))) {
+ p = strchr(host, '#');
+ if (p != NULL) {
name_type = strtol(p+1, NULL, 16);
- *p = 0;
- }
-
- if (!dest_ss || is_zero_addr(dest_ss)) {
- NTSTATUS status =resolve_name_list(frame,
- cli->desthost,
- name_type,
- &ss_arr,
- &num_addrs);
- if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(frame);
- return NT_STATUS_BAD_NETWORK_NAME;
- }
- } else {
- num_addrs = 1;
- ss_arr = TALLOC_P(frame, struct sockaddr_storage);
- if (!ss_arr) {
- TALLOC_FREE(frame);
- return NT_STATUS_NO_MEMORY;
+ host = talloc_strndup(talloc_tos(), host, p - host);
+ if (host == NULL) {
+ goto fail;
}
- *ss_arr = *dest_ss;
}
- for (i = 0; i < num_addrs; i++) {
- cli->dest_ss = ss_arr[i];
- if (getenv("LIBSMB_PROG")) {
- cli->fd = sock_exec(getenv("LIBSMB_PROG"));
- } else {
- uint16_t port = cli->port;
- NTSTATUS status;
- status = open_smb_socket(&cli->dest_ss, &port,
- cli->timeout, &cli->fd);
- if (NT_STATUS_IS_OK(status)) {
- cli->port = port;
- }
- }
- if (cli->fd == -1) {
- char addr[INET6_ADDRSTRLEN];
- print_sockaddr(addr, sizeof(addr), &ss_arr[i]);
- DEBUG(2,("Error connecting to %s (%s)\n",
- dest_ss?addr:host,strerror(errno)));
- } else {
- /* Exit from loop on first connection. */
- break;
- }
+ cli = cli_initialise_ex(signing_state);
+ if (cli == NULL) {
+ goto fail;
}
+ cli->desthost = talloc_move(cli, &desthost);
- if (cli->fd == -1) {
- TALLOC_FREE(frame);
- return map_nt_error_from_unix(errno);
+ status = cli_connect_sock(host, name_type, pss, myname, port, 20, &fd,
+ &port);
+ if (!NT_STATUS_IS_OK(status)) {
+ cli_shutdown(cli);
+ goto fail;
}
+ cli->fd = fd;
+ cli->port = port;
- if (dest_ss) {
- *dest_ss = cli->dest_ss;
+ length = sizeof(cli->dest_ss);
+ ret = getpeername(fd, (struct sockaddr *)(void *)&cli->dest_ss,
+ &length);
+ if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
+ cli_shutdown(cli);
+ goto fail;
}
- set_socket_options(cli->fd, lp_socket_options());
+ if (pss != NULL) {
+ *pss = cli->dest_ss;
+ }
+ *pcli = cli;
+ status = NT_STATUS_OK;
+fail:
TALLOC_FREE(frame);
- return NT_STATUS_OK;
+ return status;
}
/**
@@ -2465,59 +2934,16 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli,
int signing_state, int flags)
{
NTSTATUS nt_status;
- struct nmb_name calling;
- struct nmb_name called;
struct cli_state *cli;
- struct sockaddr_storage ss;
-
- if (!my_name)
- my_name = global_myname();
-
- if (!(cli = cli_initialise_ex(signing_state))) {
- return NT_STATUS_NO_MEMORY;
- }
-
- make_nmb_name(&calling, my_name, 0x0);
- make_nmb_name(&called , dest_host, 0x20);
-
- cli_set_port(cli, port);
- cli_set_timeout(cli, 10000); /* 10 seconds. */
- if (dest_ss) {
- ss = *dest_ss;
- } else {
- zero_sockaddr(&ss);
- }
-
-again:
-
- DEBUG(3,("Connecting to host=%s\n", dest_host));
-
- nt_status = cli_connect(cli, dest_host, &ss);
+ nt_status = cli_connect_nb(dest_host, dest_ss, port, 0x20, my_name,
+ signing_state, &cli);
if (!NT_STATUS_IS_OK(nt_status)) {
- char addr[INET6_ADDRSTRLEN];
- print_sockaddr(addr, sizeof(addr), &ss);
- DEBUG(1,("cli_start_connection: failed to connect to %s (%s). Error %s\n",
- nmb_namestr(&called), addr, nt_errstr(nt_status) ));
- cli_shutdown(cli);
+ DEBUG(10, ("cli_connect_nb failed: %s\n",
+ nt_errstr(nt_status)));
return nt_status;
}
- if (!cli_session_request(cli, &calling, &called)) {
- char *p;
- DEBUG(1,("session request to %s failed (%s)\n",
- called.name, cli_errstr(cli)));
- if ((p=strchr(called.name, '.')) && !is_ipaddress(called.name)) {
- *p = 0;
- goto again;
- }
- if (strcmp(called.name, STAR_SMBSERVER)) {
- make_nmb_name(&called , STAR_SMBSERVER, 0x20);
- goto again;
- }
- return NT_STATUS_BAD_NETWORK_NAME;
- }
-
if (flags & CLI_FULL_CONNECTION_DONT_SPNEGO)
cli->use_spnego = False;
else if (flags & CLI_FULL_CONNECTION_USE_KERBEROS)
@@ -2631,71 +3057,6 @@ NTSTATUS cli_full_connection(struct cli_state **output_cli,
}
/****************************************************************************
- Attempt a NetBIOS session request, falling back to *SMBSERVER if needed.
-****************************************************************************/
-
-bool attempt_netbios_session_request(struct cli_state **ppcli, const char *srchost, const char *desthost,
- struct sockaddr_storage *pdest_ss)
-{
- struct nmb_name calling, called;
-
- make_nmb_name(&calling, srchost, 0x0);
-
- /*
- * If the called name is an IP address
- * then use *SMBSERVER immediately.
- */
-
- if(is_ipaddress(desthost)) {
- make_nmb_name(&called, STAR_SMBSERVER, 0x20);
- } else {
- make_nmb_name(&called, desthost, 0x20);
- }
-
- if (!cli_session_request(*ppcli, &calling, &called)) {
- NTSTATUS status;
- struct nmb_name smbservername;
-
- make_nmb_name(&smbservername, STAR_SMBSERVER, 0x20);
-
- /*
- * If the name wasn't *SMBSERVER then
- * try with *SMBSERVER if the first name fails.
- */
-
- if (nmb_name_equal(&called, &smbservername)) {
-
- /*
- * The name used was *SMBSERVER, don't bother with another name.
- */
-
- DEBUG(0,("attempt_netbios_session_request: %s rejected the session for name *SMBSERVER \
-with error %s.\n", desthost, cli_errstr(*ppcli) ));
- return False;
- }
-
- /* Try again... */
- cli_shutdown(*ppcli);
-
- *ppcli = cli_initialise();
- if (!*ppcli) {
- /* Out of memory... */
- return False;
- }
-
- status = cli_connect(*ppcli, desthost, pdest_ss);
- if (!NT_STATUS_IS_OK(status) ||
- !cli_session_request(*ppcli, &calling, &smbservername)) {
- DEBUG(0,("attempt_netbios_session_request: %s rejected the session for \
-name *SMBSERVER with error %s\n", desthost, cli_errstr(*ppcli) ));
- return False;
- }
- }
-
- return True;
-}
-
-/****************************************************************************
Send an old style tcon.
****************************************************************************/
NTSTATUS cli_raw_tcon(struct cli_state *cli,
@@ -2786,7 +3147,7 @@ struct cli_state *get_ipc_connect(char *server,
*/
struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
- struct ip_service *mb_ip,
+ struct sockaddr_storage *mb_ip,
const struct user_auth_info *user_info,
char **pp_workgroup_out)
{
@@ -2797,7 +3158,7 @@ struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
*pp_workgroup_out = NULL;
- print_sockaddr(addr, sizeof(addr), &mb_ip->ss);
+ print_sockaddr(addr, sizeof(addr), mb_ip);
DEBUG(99, ("Looking up name of master browser %s\n",
addr));
@@ -2812,8 +3173,8 @@ struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
* the original wildcard query as the first choice and fall back to
* MSBROWSE if the wildcard query fails.
*/
- if (!name_status_find("*", 0, 0x1d, &mb_ip->ss, name) &&
- !name_status_find(MSBROWSE, 1, 0x1d, &mb_ip->ss, name)) {
+ if (!name_status_find("*", 0, 0x1d, mb_ip, name) &&
+ !name_status_find(MSBROWSE, 1, 0x1d, mb_ip, name)) {
DEBUG(99, ("Could not retrieve name status for %s\n",
addr));
@@ -2844,9 +3205,10 @@ struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
const struct user_auth_info *user_info,
char **pp_workgroup_out)
{
- struct ip_service *ip_list;
+ struct sockaddr_storage *ip_list;
struct cli_state *cli;
int i, count;
+ NTSTATUS status;
*pp_workgroup_out = NULL;
@@ -2854,15 +3216,17 @@ struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
/* Go looking for workgroups by broadcasting on the local network */
- if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list,
- &count))) {
- DEBUG(99, ("No master browsers responded\n"));
+ status = name_resolve_bcast(MSBROWSE, 1, talloc_tos(),
+ &ip_list, &count);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(99, ("No master browsers responded: %s\n",
+ nt_errstr(status)));
return False;
}
for (i = 0; i < count; i++) {
char addr[INET6_ADDRSTRLEN];
- print_sockaddr(addr, sizeof(addr), &ip_list[i].ss);
+ print_sockaddr(addr, sizeof(addr), &ip_list[i]);
DEBUG(99, ("Found master browser %s\n", addr));
cli = get_ipc_connect_master_ip(ctx, &ip_list[i],
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index a0d60482ee6..5c5257fb6f8 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "msdfs.h"
#include "trans2.h"
@@ -87,10 +88,6 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
int name_type)
{
struct cli_state *c = NULL;
- struct nmb_name called, calling;
- const char *called_str;
- const char *server_n;
- struct sockaddr_storage ss;
char *servicename;
char *sharename;
char *newserver, *newshare;
@@ -106,7 +103,6 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
sharename = servicename;
if (*sharename == '\\') {
sharename += 2;
- called_str = sharename;
if (server == NULL) {
server = sharename;
}
@@ -116,36 +112,19 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
}
*sharename = 0;
sharename++;
- } else {
- called_str = server;
}
-
- server_n = server;
-
- zero_sockaddr(&ss);
-
- make_nmb_name(&calling, global_myname(), 0x0);
- make_nmb_name(&called , called_str, name_type);
-
- again:
- zero_sockaddr(&ss);
-
- /* have to open a new connection */
- c = cli_initialise_ex(get_cmdline_auth_info_signing_state(auth_info));
- if (c == NULL) {
- d_printf("Connection to %s failed\n", server_n);
+ if (server == NULL) {
return NULL;
}
- if (port) {
- cli_set_port(c, port);
- }
- status = cli_connect(c, server_n, &ss);
+ status = cli_connect_nb(
+ server, NULL, port, name_type, NULL,
+ get_cmdline_auth_info_signing_state(auth_info), &c);
+
if (!NT_STATUS_IS_OK(status)) {
d_printf("Connection to %s failed (Error %s)\n",
- server_n,
+ server,
nt_errstr(status));
- cli_shutdown(c);
return NULL;
}
@@ -158,23 +137,6 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
get_cmdline_auth_info_fallback_after_kerberos(auth_info);
c->use_ccache = get_cmdline_auth_info_use_ccache(auth_info);
- if (!cli_session_request(c, &calling, &called)) {
- char *p;
- d_printf("session request to %s failed (%s)\n",
- called.name, cli_errstr(c));
- cli_shutdown(c);
- c = NULL;
- if ((p=strchr_m(called.name, '.'))) {
- *p = 0;
- goto again;
- }
- if (strcmp(called.name, "*SMBSERVER")) {
- make_nmb_name(&called , "*SMBSERVER", 0x20);
- goto again;
- }
- return NULL;
- }
-
DEBUG(4,(" session request ok\n"));
status = cli_negprot(c);
diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c
index 92f381e87b4..90f06fd5359 100644
--- a/source3/libsmb/clidgram.c
+++ b/source3/libsmb/clidgram.c
@@ -20,6 +20,8 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "libsmb/clidgram.h"
#include "libsmb/nmblib.h"
#include "messages.h"
@@ -138,7 +140,7 @@ static bool prep_getdc_request(const struct sockaddr_storage *dc_ss,
my_sid = *sid;
}
- my_acct_name = talloc_asprintf(talloc_tos(), "%s$", global_myname());
+ my_acct_name = talloc_asprintf(talloc_tos(), "%s$", lp_netbios_name());
if (my_acct_name == NULL) {
goto fail;
}
@@ -147,7 +149,7 @@ static bool prep_getdc_request(const struct sockaddr_storage *dc_ss,
s = &packet.req.logon;
s->request_count = 0;
- s->computer_name = global_myname();
+ s->computer_name = lp_netbios_name();
s->user_name = my_acct_name;
s->mailslot_name = my_mailslot;
s->acct_control = ACB_WSTRUST;
@@ -168,7 +170,7 @@ static bool prep_getdc_request(const struct sockaddr_storage *dc_ss,
ret = cli_prep_mailslot(false, NBT_MAILSLOT_NTLOGON, 0,
(char *)blob.data, blob.length,
- global_myname(), 0, domain_name, 0x1c,
+ lp_netbios_name(), 0, domain_name, 0x1c,
dc_ss, dgm_id, p);
fail:
TALLOC_FREE(frame);
@@ -225,7 +227,7 @@ static bool parse_getdc_response(
blob = p.smb.body.trans.data;
- r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response);
+ r = talloc_zero(mem_ctx, struct netlogon_samlogon_response);
if (!r) {
return false;
}
@@ -320,7 +322,7 @@ struct tevent_req *nbt_getdc_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
state->my_mailslot = mailslot_name(
- state, ((struct sockaddr_in *)dc_addr)->sin_addr);
+ state, ((const struct sockaddr_in *)dc_addr)->sin_addr);
if (tevent_req_nomem(state->my_mailslot, req)) {
return tevent_req_post(req, ev);
}
diff --git a/source3/libsmb/clidgram.h b/source3/libsmb/clidgram.h
index 01a8a6a4049..a449724a41a 100644
--- a/source3/libsmb/clidgram.h
+++ b/source3/libsmb/clidgram.h
@@ -1,3 +1,27 @@
+/*
+ Unix SMB/CIFS implementation.
+ client dgram calls
+ Copyright (C) Andrew Tridgell 1994-1998
+ Copyright (C) Richard Sharpe 2001
+ Copyright (C) John Terpstra 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 _LIBSMB_CLIDGRAM_H_
+#define _LIBSMB_CLIDGRAM_H_
+
#include "../libcli/netlogon/netlogon.h"
/* The following definitions come from libsmb/clidgram.c */
@@ -21,3 +45,5 @@ NTSTATUS nbt_getdc(struct messaging_context *msg_ctx,
uint32_t *pnt_version,
const char **dc_name,
struct netlogon_samlogon_response **samlogon_response);
+
+#endif /* _LIBSMB_CLIDGRAM_H_ */
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 7eb10c4f1d6..d3b66b67e18 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -19,6 +19,8 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "smb_signing.h"
#include "async_smb.h"
@@ -66,364 +68,6 @@ bool cli_ucs2(struct cli_state *cli)
return ((cli->capabilities & CAP_UNICODE) != 0);
}
-
-/****************************************************************************
- Read an smb from a fd ignoring all keepalive packets.
- The timeout is in milliseconds
-
- This is exactly the same as receive_smb except that it never returns
- a session keepalive packet (just as receive_smb used to do).
- receive_smb was changed to return keepalives as the oplock processing means this call
- should never go into a blocking read.
-****************************************************************************/
-
-static ssize_t client_receive_smb(struct cli_state *cli, size_t maxlen)
-{
- size_t len;
-
- for(;;) {
- NTSTATUS status;
-
- set_smb_read_error(&cli->smb_rw_error, SMB_READ_OK);
-
- status = receive_smb_raw(cli->fd, cli->inbuf, cli->bufsize,
- cli->timeout, maxlen, &len);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(10,("client_receive_smb failed\n"));
- show_msg(cli->inbuf);
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
- set_smb_read_error(&cli->smb_rw_error,
- SMB_READ_EOF);
- return -1;
- }
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- set_smb_read_error(&cli->smb_rw_error,
- SMB_READ_TIMEOUT);
- return -1;
- }
-
- set_smb_read_error(&cli->smb_rw_error, SMB_READ_ERROR);
- return -1;
- }
-
- /*
- * I don't believe len can be < 0 with NT_STATUS_OK
- * returned above, but this check doesn't hurt. JRA.
- */
-
- if ((ssize_t)len < 0) {
- return len;
- }
-
- /* Ignore session keepalive packets. */
- if(CVAL(cli->inbuf,0) != SMBkeepalive) {
- break;
- }
- }
-
- if (cli_encryption_on(cli)) {
- NTSTATUS status = cli_decrypt_message(cli);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("SMB decryption failed on incoming packet! Error %s\n",
- nt_errstr(status)));
- cli->smb_rw_error = SMB_READ_BAD_DECRYPT;
- return -1;
- }
- }
-
- show_msg(cli->inbuf);
- return len;
-}
-
-static bool cli_state_set_seqnum(struct cli_state *cli, uint16_t mid, uint32_t seqnum)
-{
- struct cli_state_seqnum *c;
-
- for (c = cli->seqnum; c; c = c->next) {
- if (c->mid == mid) {
- c->seqnum = seqnum;
- return true;
- }
- }
-
- c = talloc_zero(cli, struct cli_state_seqnum);
- if (!c) {
- return false;
- }
-
- c->mid = mid;
- c->seqnum = seqnum;
- c->persistent = false;
- DLIST_ADD_END(cli->seqnum, c, struct cli_state_seqnum *);
-
- return true;
-}
-
-bool cli_state_seqnum_persistent(struct cli_state *cli,
- uint16_t mid)
-{
- struct cli_state_seqnum *c;
-
- for (c = cli->seqnum; c; c = c->next) {
- if (c->mid == mid) {
- c->persistent = true;
- return true;
- }
- }
-
- return false;
-}
-
-bool cli_state_seqnum_remove(struct cli_state *cli,
- uint16_t mid)
-{
- struct cli_state_seqnum *c;
-
- for (c = cli->seqnum; c; c = c->next) {
- if (c->mid == mid) {
- DLIST_REMOVE(cli->seqnum, c);
- TALLOC_FREE(c);
- return true;
- }
- }
-
- return false;
-}
-
-static uint32_t cli_state_get_seqnum(struct cli_state *cli, uint16_t mid)
-{
- struct cli_state_seqnum *c;
-
- for (c = cli->seqnum; c; c = c->next) {
- if (c->mid == mid) {
- uint32_t seqnum = c->seqnum;
- if (!c->persistent) {
- DLIST_REMOVE(cli->seqnum, c);
- TALLOC_FREE(c);
- }
- return seqnum;
- }
- }
-
- return 0;
-}
-
-/****************************************************************************
- Recv an smb.
-****************************************************************************/
-
-bool cli_receive_smb(struct cli_state *cli)
-{
- ssize_t len;
- uint16_t mid;
- uint32_t seqnum;
-
- /* fd == -1 causes segfaults -- Tom (tom@ninja.nl) */
- if (cli->fd == -1)
- return false;
-
- again:
- len = client_receive_smb(cli, 0);
-
- if (len > 0) {
- /* it might be an oplock break request */
- if (!(CVAL(cli->inbuf, smb_flg) & FLAG_REPLY) &&
- CVAL(cli->inbuf,smb_com) == SMBlockingX &&
- SVAL(cli->inbuf,smb_vwv6) == 0 &&
- SVAL(cli->inbuf,smb_vwv7) == 0) {
- if (cli->oplock_handler) {
- int fnum = SVAL(cli->inbuf,smb_vwv2);
- unsigned char level = CVAL(cli->inbuf,smb_vwv3+1);
- if (!NT_STATUS_IS_OK(cli->oplock_handler(cli, fnum, level))) {
- return false;
- }
- }
- /* try to prevent loops */
- SCVAL(cli->inbuf,smb_com,0xFF);
- goto again;
- }
- }
-
- /* If the server is not responding, note that now */
- if (len < 0) {
- /*
- * only log if the connection should still be open and not when
- * the connection was closed due to a dropped ip message
- */
- if (cli->fd != -1) {
- char addr[INET6_ADDRSTRLEN];
- print_sockaddr(addr, sizeof(addr), &cli->dest_ss);
- DEBUG(0, ("Receiving SMB: Server %s stopped responding\n",
- addr));
- close(cli->fd);
- cli->fd = -1;
- }
- return false;
- }
-
- mid = SVAL(cli->inbuf,smb_mid);
- seqnum = cli_state_get_seqnum(cli, mid);
-
- if (!cli_check_sign_mac(cli, cli->inbuf, seqnum+1)) {
- /*
- * If we get a signature failure in sessionsetup, then
- * the server sometimes just reflects the sent signature
- * back to us. Detect this and allow the upper layer to
- * retrieve the correct Windows error message.
- */
- if (CVAL(cli->outbuf,smb_com) == SMBsesssetupX &&
- (smb_len(cli->inbuf) > (smb_ss_field + 8 - 4)) &&
- (SVAL(cli->inbuf,smb_flg2) & FLAGS2_SMB_SECURITY_SIGNATURES) &&
- memcmp(&cli->outbuf[smb_ss_field],&cli->inbuf[smb_ss_field],8) == 0 &&
- cli_is_error(cli)) {
-
- /*
- * Reflected signature on login error.
- * Set bad sig but don't close fd.
- */
- cli->smb_rw_error = SMB_READ_BAD_SIG;
- return true;
- }
-
- DEBUG(0, ("SMB Signature verification failed on incoming packet!\n"));
- cli->smb_rw_error = SMB_READ_BAD_SIG;
- close(cli->fd);
- cli->fd = -1;
- return false;
- };
- return true;
-}
-
-static ssize_t write_socket(int fd, const char *buf, size_t len)
-{
- ssize_t ret=0;
-
- DEBUG(6,("write_socket(%d,%d)\n",fd,(int)len));
- ret = write_data(fd,buf,len);
-
- DEBUG(6,("write_socket(%d,%d) wrote %d\n",fd,(int)len,(int)ret));
- if(ret <= 0)
- DEBUG(0,("write_socket: Error writing %d bytes to socket %d: ERRNO = %s\n",
- (int)len, fd, strerror(errno) ));
-
- return(ret);
-}
-
-/****************************************************************************
- Send an smb to a fd.
-****************************************************************************/
-
-bool cli_send_smb(struct cli_state *cli)
-{
- size_t len;
- size_t nwritten=0;
- ssize_t ret;
- char *buf_out = cli->outbuf;
- bool enc_on = cli_encryption_on(cli);
- uint32_t seqnum;
-
- /* fd == -1 causes segfaults -- Tom (tom@ninja.nl) */
- if (cli->fd == -1)
- return false;
-
- cli_calculate_sign_mac(cli, cli->outbuf, &seqnum);
-
- if (!cli_state_set_seqnum(cli, cli->mid, seqnum)) {
- DEBUG(0,("Failed to store mid[%u]/seqnum[%u]\n",
- (unsigned int)cli->mid,
- (unsigned int)seqnum));
- return false;
- }
-
- if (enc_on) {
- NTSTATUS status = cli_encrypt_message(cli, cli->outbuf,
- &buf_out);
- if (!NT_STATUS_IS_OK(status)) {
- close(cli->fd);
- cli->fd = -1;
- cli->smb_rw_error = SMB_WRITE_ERROR;
- DEBUG(0,("Error in encrypting client message. Error %s\n",
- nt_errstr(status) ));
- return false;
- }
- }
-
- len = smb_len(buf_out) + 4;
-
- while (nwritten < len) {
- ret = write_socket(cli->fd,buf_out+nwritten,len - nwritten);
- if (ret <= 0) {
- if (enc_on) {
- cli_free_enc_buffer(cli, buf_out);
- }
- close(cli->fd);
- cli->fd = -1;
- cli->smb_rw_error = SMB_WRITE_ERROR;
- DEBUG(0,("Error writing %d bytes to client. %d (%s)\n",
- (int)len,(int)ret, strerror(errno) ));
- return false;
- }
- nwritten += ret;
- }
-
- if (enc_on) {
- cli_free_enc_buffer(cli, buf_out);
- }
-
- /* Increment the mid so we can tell between responses. */
- cli->mid++;
- if (!cli->mid)
- cli->mid++;
- return true;
-}
-
-/****************************************************************************
- Send a "direct" writeX smb to a fd.
-****************************************************************************/
-
-bool cli_send_smb_direct_writeX(struct cli_state *cli,
- const char *p,
- size_t extradata)
-{
- /* First length to send is the offset to the data. */
- size_t len = SVAL(cli->outbuf,smb_vwv11) + 4;
- size_t nwritten=0;
- struct iovec iov[2];
-
- /* fd == -1 causes segfaults -- Tom (tom@ninja.nl) */
- if (cli->fd == -1) {
- return false;
- }
-
- if (client_is_signing_on(cli)) {
- DEBUG(0,("cli_send_smb_large: cannot send signed packet.\n"));
- return false;
- }
-
- iov[0].iov_base = (void *)cli->outbuf;
- iov[0].iov_len = len;
- iov[1].iov_base = CONST_DISCARD(void *, p);
- iov[1].iov_len = extradata;
-
- nwritten = write_data_iov(cli->fd, iov, 2);
- if (nwritten < (len + extradata)) {
- close(cli->fd);
- cli->fd = -1;
- cli->smb_rw_error = SMB_WRITE_ERROR;
- DEBUG(0,("Error writing %d bytes to client. (%s)\n",
- (int)(len+extradata), strerror(errno)));
- return false;
- }
-
- /* Increment the mid so we can tell between responses. */
- cli->mid++;
- if (!cli->mid)
- cli->mid++;
- return true;
-}
-
/****************************************************************************
Setup basics in a outgoing packet.
****************************************************************************/
@@ -460,20 +104,6 @@ void cli_setup_packet_buf(struct cli_state *cli, char *buf)
SSVAL(buf,smb_flg2, flags2);
}
-void cli_setup_packet(struct cli_state *cli)
-{
- cli_setup_packet_buf(cli, cli->outbuf);
-}
-
-/****************************************************************************
- Setup the bcc length of the packet from a pointer to the end of the data.
-****************************************************************************/
-
-void cli_setup_bcc(struct cli_state *cli, void *p)
-{
- set_message_bcc(cli->outbuf, PTR_DIFF(p, smb_buf(cli->outbuf)));
-}
-
/****************************************************************************
Initialize Domain, user or password.
****************************************************************************/
@@ -552,7 +182,7 @@ struct cli_state *cli_initialise_ex(int signing_state)
return NULL;
}
- cli = TALLOC_ZERO_P(NULL, struct cli_state);
+ cli = talloc_zero(NULL, struct cli_state);
if (!cli) {
return NULL;
}
@@ -572,7 +202,6 @@ struct cli_state *cli_initialise_ex(int signing_state)
cli->bufsize = CLI_BUFFER_SIZE+4;
cli->max_xmit = cli->bufsize;
cli->outbuf = (char *)SMB_MALLOC(cli->bufsize+SAFETY_MARGIN);
- cli->seqnum = 0;
cli->inbuf = (char *)SMB_MALLOC(cli->bufsize+SAFETY_MARGIN);
cli->oplock_handler = cli_oplock_ack;
cli->case_sensitive = false;
diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c
index 015afb18aaa..d5ac8937ed6 100644
--- a/source3/libsmb/clierror.c
+++ b/source3/libsmb/clierror.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
/*****************************************************
RAP error codes - a small start but will be extended.
@@ -322,44 +323,6 @@ bool cli_is_dos_error(struct cli_state *cli)
return cli_is_error(cli) && !(flgs2 & FLAGS2_32_BIT_ERROR_CODES);
}
-/* Return the last error always as an NTSTATUS. */
-
-NTSTATUS cli_get_nt_error(struct cli_state *cli)
-{
- if (cli_is_nt_error(cli)) {
- return cli_nt_error(cli);
- } else if (cli_is_dos_error(cli)) {
- uint32 ecode;
- uint8 eclass;
- cli_dos_error(cli, &eclass, &ecode);
- return dos_to_ntstatus(eclass, ecode);
- } else {
- /* Something went wrong, we don't know what. */
- return NT_STATUS_UNSUCCESSFUL;
- }
-}
-
-/* Push an error code into the inbuf to be returned on the next
- * query. */
-
-void cli_set_nt_error(struct cli_state *cli, NTSTATUS status)
-{
- SSVAL(cli->inbuf,smb_flg2, SVAL(cli->inbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES);
- SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(status));
-}
-
-/* Reset an error. */
-
-void cli_reset_error(struct cli_state *cli)
-{
- if (SVAL(cli->inbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES) {
- SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(NT_STATUS_OK));
- } else {
- SCVAL(cli->inbuf,smb_rcls,0);
- SSVAL(cli->inbuf,smb_err,0);
- }
-}
-
bool cli_state_is_connected(struct cli_state *cli)
{
if (cli == NULL) {
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 28f59f0d88c..88cecd505ce 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -20,10 +20,13 @@
#include "includes.h"
#include "system/filesys.h"
+#include "libsmb/libsmb.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
#include "libsmb/clirap.h"
#include "trans2.h"
#include "ntioctl.h"
+#include "libcli/security/secdesc.h"
/***********************************************************
Common function for pushing stings, used by smb_bytes_push_str()
@@ -46,11 +49,13 @@ static uint8_t *internal_bytes_push_str(uint8_t *buf, bool ucs2,
buflen = talloc_get_size(buf);
- if (align_odd && ucs2 && (buflen % 2 == 0)) {
+ if (ucs2 &&
+ ((align_odd && (buflen % 2 == 0)) ||
+ (!align_odd && (buflen % 2 == 1)))) {
/*
* We're pushing into an SMB buffer, align odd
*/
- buf = TALLOC_REALLOC_ARRAY(NULL, buf, uint8_t, buflen + 1);
+ buf = talloc_realloc(NULL, buf, uint8_t, buflen + 1);
if (buf == NULL) {
return NULL;
}
@@ -65,7 +70,7 @@ static uint8_t *internal_bytes_push_str(uint8_t *buf, bool ucs2,
return NULL;
}
- buf = TALLOC_REALLOC_ARRAY(NULL, buf, uint8_t,
+ buf = talloc_realloc(NULL, buf, uint8_t,
buflen + converted_size);
if (buf == NULL) {
TALLOC_FREE(converted);
@@ -106,7 +111,7 @@ uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
}
buflen = talloc_get_size(buf);
- buf = TALLOC_REALLOC_ARRAY(NULL, buf, uint8_t,
+ buf = talloc_realloc(NULL, buf, uint8_t,
buflen + 1 + num_bytes);
if (buf == NULL) {
return NULL;
@@ -159,7 +164,7 @@ struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
SSVAL(&state->setup, 0, TRANSACT2_SETPATHINFO);
/* Setup param array. */
- state->param = TALLOC_ZERO_ARRAY(state, uint8_t, 6);
+ state->param = talloc_zero_array(state, uint8_t, 6);
if (tevent_req_nomem(state->param, req)) {
return tevent_req_post(req, ev);
}
@@ -356,9 +361,6 @@ NTSTATUS cli_posix_symlink(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -416,8 +418,7 @@ static void cli_posix_readlink_done(struct tevent_req *subreq)
status = cli_qpathinfo_recv(subreq, state, &state->data,
&state->num_data);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
/*
@@ -501,9 +502,6 @@ NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -568,107 +566,10 @@ NTSTATUS cli_posix_hardlink(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
/****************************************************************************
- Map standard UNIX permissions onto wire representations.
-****************************************************************************/
-
-uint32_t unix_perms_to_wire(mode_t perms)
-{
- unsigned int ret = 0;
-
- ret |= ((perms & S_IXOTH) ? UNIX_X_OTH : 0);
- ret |= ((perms & S_IWOTH) ? UNIX_W_OTH : 0);
- ret |= ((perms & S_IROTH) ? UNIX_R_OTH : 0);
- ret |= ((perms & S_IXGRP) ? UNIX_X_GRP : 0);
- ret |= ((perms & S_IWGRP) ? UNIX_W_GRP : 0);
- ret |= ((perms & S_IRGRP) ? UNIX_R_GRP : 0);
- ret |= ((perms & S_IXUSR) ? UNIX_X_USR : 0);
- ret |= ((perms & S_IWUSR) ? UNIX_W_USR : 0);
- ret |= ((perms & S_IRUSR) ? UNIX_R_USR : 0);
-#ifdef S_ISVTX
- ret |= ((perms & S_ISVTX) ? UNIX_STICKY : 0);
-#endif
-#ifdef S_ISGID
- ret |= ((perms & S_ISGID) ? UNIX_SET_GID : 0);
-#endif
-#ifdef S_ISUID
- ret |= ((perms & S_ISUID) ? UNIX_SET_UID : 0);
-#endif
- return ret;
-}
-
-/****************************************************************************
- Map wire permissions to standard UNIX.
-****************************************************************************/
-
-mode_t wire_perms_to_unix(uint32_t perms)
-{
- mode_t ret = (mode_t)0;
-
- ret |= ((perms & UNIX_X_OTH) ? S_IXOTH : 0);
- ret |= ((perms & UNIX_W_OTH) ? S_IWOTH : 0);
- ret |= ((perms & UNIX_R_OTH) ? S_IROTH : 0);
- ret |= ((perms & UNIX_X_GRP) ? S_IXGRP : 0);
- ret |= ((perms & UNIX_W_GRP) ? S_IWGRP : 0);
- ret |= ((perms & UNIX_R_GRP) ? S_IRGRP : 0);
- ret |= ((perms & UNIX_X_USR) ? S_IXUSR : 0);
- ret |= ((perms & UNIX_W_USR) ? S_IWUSR : 0);
- ret |= ((perms & UNIX_R_USR) ? S_IRUSR : 0);
-#ifdef S_ISVTX
- ret |= ((perms & UNIX_STICKY) ? S_ISVTX : 0);
-#endif
-#ifdef S_ISGID
- ret |= ((perms & UNIX_SET_GID) ? S_ISGID : 0);
-#endif
-#ifdef S_ISUID
- ret |= ((perms & UNIX_SET_UID) ? S_ISUID : 0);
-#endif
- return ret;
-}
-
-/****************************************************************************
- Return the file type from the wire filetype for UNIX extensions.
-****************************************************************************/
-
-static mode_t unix_filetype_from_wire(uint32_t wire_type)
-{
- switch (wire_type) {
- case UNIX_TYPE_FILE:
- return S_IFREG;
- case UNIX_TYPE_DIR:
- return S_IFDIR;
-#ifdef S_IFLNK
- case UNIX_TYPE_SYMLINK:
- return S_IFLNK;
-#endif
-#ifdef S_IFCHR
- case UNIX_TYPE_CHARDEV:
- return S_IFCHR;
-#endif
-#ifdef S_IFBLK
- case UNIX_TYPE_BLKDEV:
- return S_IFBLK;
-#endif
-#ifdef S_IFIFO
- case UNIX_TYPE_FIFO:
- return S_IFIFO;
-#endif
-#ifdef S_IFSOCK
- case UNIX_TYPE_SOCKET:
- return S_IFSOCK;
-#endif
- default:
- return (mode_t)0;
- }
-}
-
-/****************************************************************************
Do a POSIX getfacl (UNIX extensions).
****************************************************************************/
@@ -711,8 +612,7 @@ static void cli_posix_getfacl_done(struct tevent_req *subreq)
status = cli_qpathinfo_recv(subreq, state, &state->data,
&state->num_data);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -777,9 +677,6 @@ NTSTATUS cli_posix_getfacl(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -825,8 +722,7 @@ static void cli_posix_stat_done(struct tevent_req *subreq)
status = cli_qpathinfo_recv(subreq, state, &state->data,
&state->num_data);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -912,9 +808,6 @@ NTSTATUS cli_posix_stat(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1029,9 +922,6 @@ NTSTATUS cli_posix_chmod(struct cli_state *cli, const char *fname, mode_t mode)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1102,9 +992,6 @@ NTSTATUS cli_posix_chown(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1134,7 +1021,7 @@ struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
return NULL;
}
- SSVAL(state->vwv+0, 0, aSYSTEM | aHIDDEN | aDIR);
+ SSVAL(state->vwv+0, 0, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY);
bytes = talloc_array(state, uint8_t, 1);
if (tevent_req_nomem(bytes, req)) {
@@ -1147,7 +1034,7 @@ struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- bytes = TALLOC_REALLOC_ARRAY(state, bytes, uint8_t,
+ bytes = talloc_realloc(state, bytes, uint8_t,
talloc_get_size(bytes)+1);
if (tevent_req_nomem(bytes, req)) {
return tevent_req_post(req, ev);
@@ -1177,8 +1064,7 @@ static void cli_rename_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -1225,9 +1111,6 @@ NTSTATUS cli_rename(struct cli_state *cli, const char *fname_src, const char *fn
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1259,7 +1142,7 @@ static struct tevent_req *cli_ntrename_internal_send(TALLOC_CTX *mem_ctx,
return NULL;
}
- SSVAL(state->vwv+0, 0 ,aSYSTEM | aHIDDEN | aDIR);
+ SSVAL(state->vwv+0, 0 ,FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY);
SSVAL(state->vwv+1, 0, rename_flag);
bytes = talloc_array(state, uint8_t, 1);
@@ -1273,7 +1156,7 @@ static struct tevent_req *cli_ntrename_internal_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- bytes = TALLOC_REALLOC_ARRAY(state, bytes, uint8_t,
+ bytes = talloc_realloc(state, bytes, uint8_t,
talloc_get_size(bytes)+1);
if (tevent_req_nomem(bytes, req)) {
return tevent_req_post(req, ev);
@@ -1303,8 +1186,7 @@ static void cli_ntrename_internal_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -1370,9 +1252,6 @@ NTSTATUS cli_ntrename(struct cli_state *cli, const char *fname_src, const char *
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1435,9 +1314,6 @@ NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const cha
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1498,8 +1374,7 @@ static void cli_unlink_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -1546,9 +1421,6 @@ NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_a
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1606,8 +1478,7 @@ static void cli_mkdir_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -1654,9 +1525,6 @@ NTSTATUS cli_mkdir(struct cli_state *cli, const char *dname)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1714,8 +1582,7 @@ static void cli_rmdir_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -1762,9 +1629,6 @@ NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1879,9 +1743,6 @@ NTSTATUS cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1976,8 +1837,7 @@ static void cli_ntcreate_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, state, &inbuf, 3, &wct, &vwv,
&num_bytes, &bytes);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
state->fnum = SVAL(vwv+2, 1);
@@ -2044,9 +1904,184 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
status = cli_ntcreate_recv(req, pfid);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
+ return status;
+}
+
+struct cli_nttrans_create_state {
+ uint16_t fnum;
+};
+
+static void cli_nttrans_create_done(struct tevent_req *subreq);
+
+struct tevent_req *cli_nttrans_create_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ uint32_t CreatFlags,
+ uint32_t DesiredAccess,
+ uint32_t FileAttributes,
+ uint32_t ShareAccess,
+ uint32_t CreateDisposition,
+ uint32_t CreateOptions,
+ uint8_t SecurityFlags,
+ struct security_descriptor *secdesc,
+ struct ea_struct *eas,
+ int num_eas)
+{
+ struct tevent_req *req, *subreq;
+ struct cli_nttrans_create_state *state;
+ uint8_t *param;
+ uint8_t *secdesc_buf;
+ size_t secdesc_len;
+ NTSTATUS status;
+ size_t converted_len;
+
+ req = tevent_req_create(mem_ctx,
+ &state, struct cli_nttrans_create_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ if (secdesc != NULL) {
+ status = marshall_sec_desc(talloc_tos(), secdesc,
+ &secdesc_buf, &secdesc_len);
+ if (tevent_req_nterror(req, status)) {
+ DEBUG(10, ("marshall_sec_desc failed: %s\n",
+ nt_errstr(status)));
+ return tevent_req_post(req, ev);
+ }
+ } else {
+ secdesc_buf = NULL;
+ secdesc_len = 0;
+ }
+
+ if (num_eas != 0) {
+ /*
+ * TODO ;-)
+ */
+ tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
+ return tevent_req_post(req, ev);
}
+
+ param = talloc_array(state, uint8_t, 53);
+ if (tevent_req_nomem(param, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ param = trans2_bytes_push_str(param, cli_ucs2(cli),
+ fname, strlen(fname),
+ &converted_len);
+ if (tevent_req_nomem(param, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ SIVAL(param, 0, CreatFlags);
+ SIVAL(param, 4, 0x0); /* RootDirectoryFid */
+ SIVAL(param, 8, DesiredAccess);
+ SIVAL(param, 12, 0x0); /* AllocationSize */
+ SIVAL(param, 16, 0x0); /* AllocationSize */
+ SIVAL(param, 20, FileAttributes);
+ SIVAL(param, 24, ShareAccess);
+ SIVAL(param, 28, CreateDisposition);
+ SIVAL(param, 32, CreateOptions);
+ SIVAL(param, 36, secdesc_len);
+ SIVAL(param, 40, 0); /* EA length*/
+ SIVAL(param, 44, converted_len);
+ SIVAL(param, 48, 0x02); /* ImpersonationLevel */
+ SCVAL(param, 52, SecurityFlags);
+
+ subreq = cli_trans_send(state, ev, cli, SMBnttrans,
+ NULL, -1, /* name, fid */
+ NT_TRANSACT_CREATE, 0,
+ NULL, 0, 0, /* setup */
+ param, talloc_get_size(param), 128, /* param */
+ secdesc_buf, secdesc_len, 0); /* data */
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, cli_nttrans_create_done, req);
+ return req;
+}
+
+static void cli_nttrans_create_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct cli_nttrans_create_state *state = tevent_req_data(
+ req, struct cli_nttrans_create_state);
+ uint8_t *param;
+ uint32_t num_param;
+ NTSTATUS status;
+
+ status = cli_trans_recv(subreq, talloc_tos(), NULL,
+ NULL, 0, NULL, /* rsetup */
+ &param, 69, &num_param,
+ NULL, 0, NULL);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ state->fnum = SVAL(param, 2);
+ TALLOC_FREE(param);
+ tevent_req_done(req);
+}
+
+NTSTATUS cli_nttrans_create_recv(struct tevent_req *req, uint16_t *fnum)
+{
+ struct cli_nttrans_create_state *state = tevent_req_data(
+ req, struct cli_nttrans_create_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+ *fnum = state->fnum;
+ return NT_STATUS_OK;
+}
+
+NTSTATUS cli_nttrans_create(struct cli_state *cli,
+ const char *fname,
+ uint32_t CreatFlags,
+ uint32_t DesiredAccess,
+ uint32_t FileAttributes,
+ uint32_t ShareAccess,
+ uint32_t CreateDisposition,
+ uint32_t CreateOptions,
+ uint8_t SecurityFlags,
+ struct security_descriptor *secdesc,
+ struct ea_struct *eas,
+ int num_eas,
+ uint16_t *pfid)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct event_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ if (cli_has_async_calls(cli)) {
+ /*
+ * Can't use sync call while an async call is in flight
+ */
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
+ }
+ ev = event_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = cli_nttrans_create_send(frame, ev, cli, fname, CreatFlags,
+ DesiredAccess, FileAttributes,
+ ShareAccess, CreateDisposition,
+ CreateOptions, SecurityFlags,
+ secdesc, eas, num_eas);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = cli_nttrans_create_recv(req, pfid);
+ fail:
+ TALLOC_FREE(frame);
return status;
}
@@ -2115,7 +2150,7 @@ struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
SSVAL(state->vwv + 1, 0, 0);
SSVAL(state->vwv + 2, 0, 0); /* no additional info */
SSVAL(state->vwv + 3, 0, accessmode);
- SSVAL(state->vwv + 4, 0, aSYSTEM | aHIDDEN);
+ SSVAL(state->vwv + 4, 0, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
SSVAL(state->vwv + 5, 0, 0);
SIVAL(state->vwv + 6, 0, 0);
SSVAL(state->vwv + 8, 0, openfn);
@@ -2169,8 +2204,7 @@ struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
}
status = cli_smb_req_send(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return tevent_req_post(req, ev);
}
return req;
@@ -2190,8 +2224,7 @@ static void cli_open_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, state, &inbuf, 3, &wct, &vwv, NULL,
NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
state->fnum = SVAL(vwv+2, 0);
@@ -2247,9 +2280,6 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
status = cli_open_recv(req, pfnum);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -2305,8 +2335,7 @@ struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
}
status = cli_smb_req_send(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return tevent_req_post(req, ev);
}
return req;
@@ -2320,8 +2349,7 @@ static void cli_close_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -2367,9 +2395,6 @@ NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum)
status = cli_close_recv(req);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -2485,9 +2510,6 @@ NTSTATUS cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -2547,7 +2569,6 @@ bool cli_lock(struct cli_state *cli, uint16_t fnum,
status = cli_locktype(cli, fnum, offset, len, timeout,
(lock_type == READ_LOCK? 1 : 0));
- cli_set_error(cli, status);
return NT_STATUS_IS_OK(status);
}
@@ -2607,8 +2628,7 @@ static void cli_unlock_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -2659,9 +2679,6 @@ NTSTATUS cli_unlock(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -2712,7 +2729,6 @@ bool cli_lock64(struct cli_state *cli, uint16_t fnum,
cli->timeout = saved_timeout;
- cli_set_error(cli, status);
return NT_STATUS_IS_OK(status);
}
@@ -2772,8 +2788,7 @@ static void cli_unlock64_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -2828,9 +2843,6 @@ NTSTATUS cli_unlock64(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -3002,9 +3014,6 @@ NTSTATUS cli_posix_lock(struct cli_state *cli, uint16_t fnum,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -3069,9 +3078,6 @@ NTSTATUS cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -3131,8 +3137,7 @@ static void cli_getattrE_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, state, &inbuf, 11, &wct, &vwv,
NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -3224,9 +3229,6 @@ NTSTATUS cli_getattrE(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -3295,8 +3297,7 @@ static void cli_getatr_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, state, &inbuf, 4, &wct, &vwv, NULL,
NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -3374,9 +3375,6 @@ NTSTATUS cli_getatr(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -3432,8 +3430,7 @@ static void cli_setattrE_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -3490,9 +3487,6 @@ NTSTATUS cli_setattrE(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -3536,7 +3530,7 @@ struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
if (tevent_req_nomem(bytes, req)) {
return tevent_req_post(req, ev);
}
- bytes = TALLOC_REALLOC_ARRAY(state, bytes, uint8_t,
+ bytes = talloc_realloc(state, bytes, uint8_t,
talloc_get_size(bytes)+1);
if (tevent_req_nomem(bytes, req)) {
return tevent_req_post(req, ev);
@@ -3566,8 +3560,7 @@ static void cli_setatr_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -3617,9 +3610,6 @@ NTSTATUS cli_setatr(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -3677,8 +3667,7 @@ static void cli_chkpath_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -3740,9 +3729,6 @@ NTSTATUS cli_chkpath(struct cli_state *cli, const char *path)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -3794,8 +3780,7 @@ static void cli_dskattr_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, state, &inbuf, 4, &wct, &vwv, NULL,
NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
state->bsize = SVAL(vwv+1, 0)*SVAL(vwv+2,0);
@@ -3855,9 +3840,6 @@ NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -3927,8 +3909,7 @@ static void cli_ctemp_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, state, &inbuf, 1, &wcnt, &vwv,
&num_bytes, &bytes);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -4013,9 +3994,6 @@ NTSTATUS cli_ctemp(struct cli_state *cli,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -4201,7 +4179,7 @@ static bool parse_ea_blob(TALLOC_CTX *ctx, const uint8_t *rdata,
return true;
}
- ea_list = TALLOC_ARRAY(ctx, struct ea_struct, num_eas);
+ ea_list = talloc_array(ctx, struct ea_struct, num_eas);
if (!ea_list) {
return false;
}
@@ -4288,8 +4266,7 @@ static void cli_get_ea_list_path_done(struct tevent_req *subreq)
status = cli_qpathinfo_recv(subreq, state, &state->data,
&state->num_data);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -4343,9 +4320,6 @@ NTSTATUS cli_get_ea_list_path(struct cli_state *cli, const char *path,
status = cli_get_ea_list_path_recv(req, ctx, pnum_eas, pea_list);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -4395,7 +4369,6 @@ static uint32_t open_flags_to_wire(int flags)
#endif
#if defined(O_DIRECTORY)
if (flags & O_DIRECTORY) {
- ret &= ~(SMB_O_RDONLY|SMB_O_RDWR|SMB_O_WRONLY);
ret |= SMB_O_DIRECTORY;
}
#endif
@@ -4425,8 +4398,7 @@ static void cli_posix_open_internal_done(struct tevent_req *subreq)
status = cli_trans_recv(subreq, state, NULL, NULL, 0, NULL,
NULL, 0, NULL, &data, 12, &num_data);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
state->fnum = SVAL(data,2);
@@ -4470,7 +4442,6 @@ static struct tevent_req *cli_posix_open_internal_send(TALLOC_CTX *mem_ctx,
/* Setup data words. */
if (is_dir) {
- wire_flags &= ~(SMB_O_RDONLY|SMB_O_RDWR|SMB_O_WRONLY);
wire_flags |= SMB_O_DIRECTORY;
}
@@ -4575,9 +4546,6 @@ NTSTATUS cli_posix_open(struct cli_state *cli, const char *fname,
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -4636,9 +4604,6 @@ NTSTATUS cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -4744,9 +4709,6 @@ NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -4808,9 +4770,6 @@ NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname)
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -4884,9 +4843,8 @@ static void cli_notify_done(struct tevent_req *subreq)
status = cli_trans_recv(subreq, talloc_tos(), &flags2, NULL, 0, NULL,
&params, 0, &num_params, NULL, 0, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
+ if (tevent_req_nterror(req, status)) {
DEBUG(10, ("cli_trans_recv returned %s\n", nt_errstr(status)));
- tevent_req_nterror(req, status);
return;
}
@@ -5035,8 +4993,7 @@ static void cli_qpathinfo_done(struct tevent_req *subreq)
NULL, 0, NULL,
&state->rdata, state->min_rdata,
&state->num_rdata);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -5095,9 +5052,6 @@ NTSTATUS cli_qpathinfo(TALLOC_CTX *mem_ctx, struct cli_state *cli,
status = cli_qpathinfo_recv(req, mem_ctx, rdata, num_rdata);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -5168,8 +5122,7 @@ static void cli_qfileinfo_done(struct tevent_req *subreq)
NULL, 0, NULL,
&state->rdata, state->min_rdata,
&state->num_rdata);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -5228,9 +5181,6 @@ NTSTATUS cli_qfileinfo(TALLOC_CTX *mem_ctx, struct cli_state *cli,
status = cli_qfileinfo_recv(req, mem_ctx, rdata, num_rdata);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -5271,8 +5221,7 @@ static void cli_flush_done(struct tevent_req *subreq)
status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -5311,9 +5260,6 @@ NTSTATUS cli_flush(TALLOC_CTX *mem_ctx, struct cli_state *cli, uint16_t fnum)
status = cli_flush_recv(req);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -5374,8 +5320,7 @@ static void cli_shadow_copy_data_done(struct tevent_req *subreq)
NULL, 0, NULL, /* param */
&state->data, 12, &state->num_data);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -5460,8 +5405,5 @@ NTSTATUS cli_shadow_copy_data(TALLOC_CTX *mem_ctx, struct cli_state *cli,
status = cli_shadow_copy_data_recv(req, mem_ctx, pnames, pnum_names);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c
index ebd04e6d2b6..78024c8f987 100644
--- a/source3/libsmb/clifsinfo.c
+++ b/source3/libsmb/clifsinfo.c
@@ -19,8 +19,10 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "../libcli/auth/spnego.h"
#include "../libcli/auth/ntlmssp.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
#include "smb_crypt.h"
#include "trans2.h"
@@ -151,9 +153,6 @@ NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
pcaphigh);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -256,9 +255,6 @@ NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
status = cli_set_unix_extensions_capabilities_recv(req);
fail:
TALLOC_FREE(ev);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -355,9 +351,6 @@ NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr)
status = cli_get_fs_attr_info_recv(req, fs_attr);
fail:
TALLOC_FREE(ev);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -599,7 +592,7 @@ NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
return NT_STATUS_NO_MEMORY;
}
status = ntlmssp_client_start(NULL,
- global_myname(),
+ lp_netbios_name(),
lp_workgroup(),
lp_client_ntlmv2_auth(),
&es->s.ntlmssp_state);
@@ -692,7 +685,7 @@ static NTSTATUS make_cli_gss_blob(TALLOC_CTX *ctx,
NTSTATUS status = NT_STATUS_OK;
gss_OID_desc nt_hostbased_service =
- {10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
+ {10, discard_const_p(char, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
memset(&tok_out, '\0', sizeof(tok_out));
diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c
index a872d2df61e..b11aed8c7b2 100644
--- a/source3/libsmb/clikrb5.c
+++ b/source3/libsmb/clikrb5.c
@@ -538,6 +538,7 @@ static krb5_error_code setup_auth_context(krb5_context context,
return retval;
}
+#if defined(TKT_FLG_OK_AS_DELEGATE ) && defined(HAVE_KRB5_FWD_TGT_CREDS) && defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY) && defined(KRB5_AUTH_CONTEXT_USE_SUBKEY) && defined(HAVE_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE)
static krb5_error_code create_gss_checksum(krb5_data *in_data, /* [inout] */
uint32_t gss_flags)
{
@@ -589,6 +590,7 @@ static krb5_error_code create_gss_checksum(krb5_data *in_data, /* [inout] */
in_data->length = base_cksum_size + orig_length;
return 0;
}
+#endif
/*
we can't use krb5_mk_req because w2k wants the service to be in a particular format
@@ -610,7 +612,6 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context,
krb5_data in_data;
bool creds_ready = False;
int i = 0, maxtries = 3;
- uint32_t gss_flags = 0;
ZERO_STRUCT(in_data);
@@ -690,80 +691,84 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context,
}
#if defined(TKT_FLG_OK_AS_DELEGATE ) && defined(HAVE_KRB5_FWD_TGT_CREDS) && defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY) && defined(KRB5_AUTH_CONTEXT_USE_SUBKEY) && defined(HAVE_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE)
- if( credsp->ticket_flags & TKT_FLG_OK_AS_DELEGATE ) {
- /* Fetch a forwarded TGT from the KDC so that we can hand off a 2nd ticket
- as part of the kerberos exchange. */
+ {
+ uint32_t gss_flags = 0;
- DEBUG( 3, ("ads_krb5_mk_req: server marked as OK to delegate to, building forwardable TGT\n") );
+ if( credsp->ticket_flags & TKT_FLG_OK_AS_DELEGATE ) {
+ /* Fetch a forwarded TGT from the KDC so that we can hand off a 2nd ticket
+ as part of the kerberos exchange. */
- retval = krb5_auth_con_setuseruserkey(context,
+ DEBUG( 3, ("ads_krb5_mk_req: server marked as OK to delegate to, building forwardable TGT\n") );
+
+ retval = krb5_auth_con_setuseruserkey(context,
*auth_context,
&credsp->keyblock );
- if (retval) {
- DEBUG(1,("krb5_auth_con_setuseruserkey failed (%s)\n",
- error_message(retval)));
- goto cleanup_creds;
- }
+ if (retval) {
+ DEBUG(1,("krb5_auth_con_setuseruserkey failed (%s)\n",
+ error_message(retval)));
+ goto cleanup_creds;
+ }
- /* Must use a subkey for forwarded tickets. */
- retval = krb5_auth_con_setflags(context,
+ /* Must use a subkey for forwarded tickets. */
+ retval = krb5_auth_con_setflags(context,
*auth_context,
KRB5_AUTH_CONTEXT_USE_SUBKEY);
- if (retval) {
- DEBUG(1,("krb5_auth_con_setflags failed (%s)\n",
- error_message(retval)));
- goto cleanup_creds;
- }
+ if (retval) {
+ DEBUG(1,("krb5_auth_con_setflags failed (%s)\n",
+ error_message(retval)));
+ goto cleanup_creds;
+ }
- retval = krb5_fwd_tgt_creds(context,/* Krb5 context [in] */
+ retval = krb5_fwd_tgt_creds(context,/* Krb5 context [in] */
*auth_context, /* Authentication context [in] */
- CONST_DISCARD(char *, KRB5_TGS_NAME), /* Ticket service name ("krbtgt") [in] */
+ discard_const_p(char, KRB5_TGS_NAME), /* Ticket service name ("krbtgt") [in] */
credsp->client, /* Client principal for the tgt [in] */
credsp->server, /* Server principal for the tgt [in] */
ccache, /* Credential cache to use for storage [in] */
1, /* Turn on for "Forwardable ticket" [in] */
&in_data ); /* Resulting response [out] */
- if (retval) {
- DEBUG( 3, ("krb5_fwd_tgt_creds failed (%s)\n",
- error_message( retval ) ) );
-
- /*
- * This is not fatal. Delete the *auth_context and continue
- * with krb5_mk_req_extended to get a non-forwardable ticket.
- */
-
- if (in_data.data) {
- free( in_data.data );
- in_data.data = NULL;
- in_data.length = 0;
- }
- krb5_auth_con_free(context, *auth_context);
- *auth_context = NULL;
- retval = setup_auth_context(context, auth_context);
if (retval) {
- DEBUG(1,("setup_auth_context failed (%s)\n",
- error_message(retval)));
- goto cleanup_creds;
+ DEBUG( 3, ("krb5_fwd_tgt_creds failed (%s)\n",
+ error_message( retval ) ) );
+
+ /*
+ * This is not fatal. Delete the *auth_context and continue
+ * with krb5_mk_req_extended to get a non-forwardable ticket.
+ */
+
+ if (in_data.data) {
+ free( in_data.data );
+ in_data.data = NULL;
+ in_data.length = 0;
+ }
+ krb5_auth_con_free(context, *auth_context);
+ *auth_context = NULL;
+ retval = setup_auth_context(context, auth_context);
+ if (retval) {
+ DEBUG(1,("setup_auth_context failed (%s)\n",
+ error_message(retval)));
+ goto cleanup_creds;
+ }
+ } else {
+ /* We got a delegated ticket. */
+ gss_flags |= GSS_C_DELEG_FLAG;
}
- } else {
- /* We got a delegated ticket. */
- gss_flags |= GSS_C_DELEG_FLAG;
}
- }
- /* Frees and reallocates in_data into a GSS checksum blob. */
- retval = create_gss_checksum(&in_data, gss_flags);
- if (retval) {
- goto cleanup_data;
- }
+ /* Frees and reallocates in_data into a GSS checksum blob. */
+ retval = create_gss_checksum(&in_data, gss_flags);
+ if (retval) {
+ goto cleanup_data;
+ }
- /* We always want GSS-checksum types. */
- retval = krb5_auth_con_set_req_cksumtype(context, *auth_context, GSSAPI_CHECKSUM );
- if (retval) {
- DEBUG(1,("krb5_auth_con_set_req_cksumtype failed (%s)\n",
- error_message(retval)));
- goto cleanup_data;
+ /* We always want GSS-checksum types. */
+ retval = krb5_auth_con_set_req_cksumtype(context, *auth_context, GSSAPI_CHECKSUM );
+ if (retval) {
+ DEBUG(1,("krb5_auth_con_set_req_cksumtype failed (%s)\n",
+ error_message(retval)));
+ goto cleanup_data;
+ }
}
#endif
@@ -774,7 +779,10 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context,
error_message(retval)));
}
+#if defined(TKT_FLG_OK_AS_DELEGATE ) && defined(HAVE_KRB5_FWD_TGT_CREDS) && defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY) && defined(KRB5_AUTH_CONTEXT_USE_SUBKEY) && defined(HAVE_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE)
cleanup_data:
+#endif
+
if (in_data.data) {
free( in_data.data );
in_data.length = 0;
@@ -919,7 +927,7 @@ done:
{
static krb5_data kdata;
- kdata.data = (char *)krb5_principal_get_comp_string(context, principal, i);
+ kdata.data = discard_const_p(char, krb5_principal_get_comp_string(context, principal, i));
kdata.length = strlen((const char *)kdata.data);
return &kdata;
}
@@ -1131,7 +1139,7 @@ out:
DEBUG(10,("smb_krb5_renew_ticket: using %s as ccache\n", ccache_string));
/* FIXME: we should not fall back to defaults */
- ret = krb5_cc_resolve(context, CONST_DISCARD(char *, ccache_string), &ccache);
+ ret = krb5_cc_resolve(context, discard_const_p(char, ccache_string), &ccache);
if (ret) {
goto done;
}
@@ -1150,7 +1158,7 @@ out:
#ifdef HAVE_KRB5_GET_RENEWED_CREDS /* MIT */
{
- ret = krb5_get_renewed_creds(context, &creds, client, ccache, CONST_DISCARD(char *, service_string));
+ ret = krb5_get_renewed_creds(context, &creds, client, ccache, discard_const_p(char, service_string));
if (ret) {
DEBUG(10,("smb_krb5_renew_ticket: krb5_get_kdc_cred failed: %s\n", error_message(ret)));
goto done;
@@ -1265,7 +1273,7 @@ done:
return ENOMEM;
}
- put_name(buf, global_myname(), ' ', 0x20);
+ put_name(buf, lp_netbios_name(), ' ', 0x20);
#if defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) /* MIT */
{
@@ -1956,11 +1964,11 @@ char *smb_krb5_principal_get_realm(krb5_context context,
krb5_principal principal)
{
#ifdef HAVE_KRB5_PRINCIPAL_GET_REALM /* Heimdal */
- return krb5_principal_get_realm(context, principal);
+ return discard_const_p(char, krb5_principal_get_realm(context, principal));
#elif defined(krb5_princ_realm) /* MIT */
krb5_data *realm;
realm = krb5_princ_realm(context, principal);
- return (char *)realm->data;
+ return discard_const_p(char, realm->data);
#else
return NULL;
#endif
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index 552de002428..9eec97fbeb1 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -18,6 +18,8 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
#include "trans2.h"
@@ -319,7 +321,7 @@ static struct tevent_req *cli_list_old_send(TALLOC_CTX *mem_ctx,
bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), mask,
strlen(mask)+1, NULL);
- bytes = smb_bytes_push_bytes(bytes, 5, (uint8_t *)&zero, 2);
+ bytes = smb_bytes_push_bytes(bytes, 5, (const uint8_t *)&zero, 2);
if (tevent_req_nomem(bytes, req)) {
return tevent_req_post(req, ev);
}
@@ -385,7 +387,7 @@ static void cli_list_old_done(struct tevent_req *subreq)
dirlist_len = talloc_get_size(state->dirlist);
- tmp = TALLOC_REALLOC_ARRAY(
+ tmp = talloc_realloc(
state, state->dirlist, uint8_t,
dirlist_len + received * DIR_STRUCT_SIZE);
if (tevent_req_nomem(tmp, req)) {
@@ -450,7 +452,7 @@ static NTSTATUS cli_list_old_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
num_received = talloc_array_length(state->dirlist) / DIR_STRUCT_SIZE;
- finfo = TALLOC_ARRAY(mem_ctx, struct file_info, num_received);
+ finfo = talloc_array(mem_ctx, struct file_info, num_received);
if (finfo == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -512,9 +514,6 @@ NTSTATUS cli_list_old(struct cli_state *cli, const char *mask,
}
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -574,7 +573,7 @@ static struct tevent_req *cli_list_trans_send(TALLOC_CTX *mem_ctx,
state->setup[0] = TRANSACT2_FINDFIRST;
nlen = 2*(strlen(mask)+1);
- state->param = TALLOC_ARRAY(state, uint8_t, 12+nlen+2);
+ state->param = talloc_array(state, uint8_t, 12+nlen+2);
if (tevent_req_nomem(state->param, req)) {
return tevent_req_post(req, ev);
}
@@ -655,7 +654,7 @@ static void cli_list_trans_done(struct tevent_req *subreq)
old_num_finfo = talloc_array_length(state->finfo);
- tmp = TALLOC_REALLOC_ARRAY(state, state->finfo, struct file_info,
+ tmp = talloc_realloc(state, state->finfo, struct file_info,
old_num_finfo + ff_searchcount);
if (tevent_req_nomem(tmp, req)) {
return;
@@ -712,7 +711,7 @@ static void cli_list_trans_done(struct tevent_req *subreq)
/*
* Shrink state->finfo to the real length we received
*/
- tmp = TALLOC_REALLOC_ARRAY(state, state->finfo, struct file_info,
+ tmp = talloc_realloc(state, state->finfo, struct file_info,
old_num_finfo + i);
if (tevent_req_nomem(tmp, req)) {
return;
@@ -737,7 +736,7 @@ static void cli_list_trans_done(struct tevent_req *subreq)
nlen = 2*(strlen(state->mask) + 1);
- param = TALLOC_REALLOC_ARRAY(state, state->param, uint8_t,
+ param = talloc_realloc(state, state->param, uint8_t,
12 + nlen + last_name_raw.length + 2);
if (tevent_req_nomem(param, req)) {
return;
@@ -841,9 +840,6 @@ NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
}
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -966,8 +962,5 @@ NTSTATUS cli_list(struct cli_state *cli, const char *mask, uint16 attribute,
}
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c
index 2c2921aa0cc..55ffd8d9a59 100644
--- a/source3/libsmb/climessage.c
+++ b/source3/libsmb/climessage.c
@@ -18,7 +18,9 @@
*/
#include "includes.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
+#include "libsmb/libsmb.h"
struct cli_message_start_state {
uint16_t grp;
diff --git a/source3/libsmb/clioplock.c b/source3/libsmb/clioplock.c
index 78e93a4f316..da55f971a80 100644
--- a/source3/libsmb/clioplock.c
+++ b/source3/libsmb/clioplock.c
@@ -18,7 +18,9 @@
*/
#include "includes.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
+#include "libsmb/libsmb.h"
/****************************************************************************
send an ack for an oplock break request
@@ -116,9 +118,6 @@ NTSTATUS cli_oplock_ack(struct cli_state *cli, uint16_t fnum, unsigned char leve
status = cli_oplock_ack_recv(req);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
diff --git a/source3/libsmb/cliprint.c b/source3/libsmb/cliprint.c
index 10d1759de82..06cb02521f6 100644
--- a/source3/libsmb/cliprint.c
+++ b/source3/libsmb/cliprint.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
/*****************************************************************************
@@ -65,16 +66,16 @@ int cli_print_queue(struct cli_state *cli,
p = param;
SSVAL(p,0,76); /* API function number 76 (DosPrintJobEnum) */
p += 2;
- safe_strcpy_base(p,"zWrLeh", param, sizeof(param)); /* parameter description? */
+ strlcpy_base(p,"zWrLeh", param, sizeof(param)); /* parameter description? */
p = skip_string(param,sizeof(param),p);
- safe_strcpy_base(p,"WWzWWDDzz", param, sizeof(param)); /* returned data format */
+ strlcpy_base(p,"WWzWWDDzz", param, sizeof(param)); /* returned data format */
p = skip_string(param,sizeof(param),p);
- safe_strcpy_base(p,cli->share, param, sizeof(param)); /* name of queue */
+ strlcpy_base(p,cli->share, param, sizeof(param)); /* name of queue */
p = skip_string(param,sizeof(param),p);
SSVAL(p,0,2); /* API function level 2, PRJINFO_2 data structure */
SSVAL(p,2,1000); /* size of bytes of returned data buffer */
p += 4;
- safe_strcpy_base(p,"", param,sizeof(param)); /* subformat */
+ strlcpy_base(p,"", param,sizeof(param)); /* subformat */
p = skip_string(param,sizeof(param),p);
DEBUG(4,("doing cli_print_queue for %s\n", cli->share));
@@ -136,9 +137,9 @@ int cli_printjob_del(struct cli_state *cli, int job)
p = param;
SSVAL(p,0,81); /* DosPrintJobDel() */
p += 2;
- safe_strcpy_base(p,"W", param,sizeof(param));
+ strlcpy_base(p,"W", param,sizeof(param));
p = skip_string(param,sizeof(param),p);
- safe_strcpy_base(p,"", param,sizeof(param));
+ strlcpy_base(p,"", param,sizeof(param));
p = skip_string(param,sizeof(param),p);
SSVAL(p,0,job);
p += 2;
diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c
index e5c8c831b73..9136506e48c 100644
--- a/source3/libsmb/cliquota.c
+++ b/source3/libsmb/cliquota.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "../librpc/gen_ndr/ndr_security.h"
#include "fake_file.h"
#include "../libcli/security/security.h"
@@ -88,7 +89,7 @@ static bool parse_user_quota_record(const uint8_t *rdata,
/* the hard quotas 8 bytes (uint64_t)*/
qt.hardlim = BVAL(rdata,32);
- if (!sid_parse((char *)rdata+40,sid_len,&qt.sid)) {
+ if (!sid_parse((const char *)rdata+40,sid_len,&qt.sid)) {
return false;
}
@@ -262,19 +263,19 @@ NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
((curdata)&&(curdata_count>=8)&&(offset>0));
curdata +=offset,curdata_count -= offset) {
ZERO_STRUCT(qt);
- if (!parse_user_quota_record((uint8_t *)curdata, curdata_count,
+ if (!parse_user_quota_record((const uint8_t *)curdata, curdata_count,
&offset, &qt)) {
DEBUG(1,("Failed to parse the quota record\n"));
goto cleanup;
}
- if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) {
+ if ((tmp_list_ent=talloc_zero(mem_ctx,SMB_NTQUOTA_LIST))==NULL) {
DEBUG(0,("TALLOC_ZERO() failed\n"));
talloc_destroy(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
- if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) {
+ if ((tmp_list_ent->quotas=talloc_zero(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) {
DEBUG(0,("TALLOC_ZERO() failed\n"));
talloc_destroy(mem_ctx);
return NT_STATUS_NO_MEMORY;
@@ -318,20 +319,20 @@ NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
((curdata)&&(curdata_count>=8)&&(offset>0));
curdata +=offset,curdata_count -= offset) {
ZERO_STRUCT(qt);
- if (!parse_user_quota_record((uint8_t *)curdata,
+ if (!parse_user_quota_record((const uint8_t *)curdata,
curdata_count, &offset,
&qt)) {
DEBUG(1,("Failed to parse the quota record\n"));
goto cleanup;
}
- if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) {
+ if ((tmp_list_ent=talloc_zero(mem_ctx,SMB_NTQUOTA_LIST))==NULL) {
DEBUG(0,("TALLOC_ZERO() failed\n"));
talloc_destroy(mem_ctx);
goto cleanup;
}
- if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) {
+ if ((tmp_list_ent->quotas=talloc_zero(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) {
DEBUG(0,("TALLOC_ZERO() failed\n"));
talloc_destroy(mem_ctx);
goto cleanup;
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index 8d1be2d66e2..e5ff1abc18b 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -23,7 +23,9 @@
#include "../libcli/auth/libcli_auth.h"
#include "../librpc/gen_ndr/rap.h"
#include "../lib/crypto/arcfour.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "trans2.h"
@@ -687,9 +689,6 @@ NTSTATUS cli_qpathinfo1(struct cli_state *cli,
write_time, size, mode);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -865,9 +864,6 @@ NTSTATUS cli_qpathinfo2(struct cli_state *cli, const char *fname,
write_time, change_time, size, mode, ino);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -979,9 +975,6 @@ NTSTATUS cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
pstreams);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -1005,7 +998,7 @@ static bool parse_streams_blob(TALLOC_CTX *mem_ctx, const uint8_t *rdata,
struct stream_struct *tmp;
uint8_t *tmp_buf;
- tmp = TALLOC_REALLOC_ARRAY(mem_ctx, streams,
+ tmp = talloc_realloc(mem_ctx, streams,
struct stream_struct,
num_streams+1);
@@ -1030,7 +1023,7 @@ static bool parse_streams_blob(TALLOC_CTX *mem_ctx, const uint8_t *rdata,
* convert_string_talloc??
*/
- tmp_buf = TALLOC_ARRAY(streams, uint8_t, nlen+2);
+ tmp_buf = talloc_array(streams, uint8_t, nlen+2);
if (tmp_buf == NULL) {
goto fail;
}
@@ -1086,7 +1079,7 @@ NTSTATUS cli_qfilename(struct cli_state *cli, uint16_t fnum, char *name,
return status;
}
- clistr_pull(cli->inbuf, name, rdata+4, namelen, IVAL(rdata, 0),
+ clistr_pull((const char *)rdata, name, rdata+4, namelen, IVAL(rdata, 0),
STR_UNICODE);
TALLOC_FREE(rdata);
return NT_STATUS_OK;
@@ -1247,9 +1240,6 @@ NTSTATUS cli_qpathinfo_basic(struct cli_state *cli, const char *name,
status = cli_qpathinfo_basic_recv(req, sbuf, attributes);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
diff --git a/source3/libsmb/clirap.h b/source3/libsmb/clirap.h
index 6ea6978c045..26265dec50c 100644
--- a/source3/libsmb/clirap.h
+++ b/source3/libsmb/clirap.h
@@ -25,6 +25,8 @@
#ifndef _LIBSMB_CLIRAP_H
#define _LIBSMB_CLIRAP_H
+struct cli_state;
+
/* The following definitions come from libsmb/clirap.c */
bool cli_api(struct cli_state *cli,
diff --git a/source3/libsmb/clirap2.c b/source3/libsmb/clirap2.c
index 44a9d7c8c49..03b4ca75412 100644
--- a/source3/libsmb/clirap2.c
+++ b/source3/libsmb/clirap2.c
@@ -76,6 +76,7 @@
/*****************************************************/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "../librpc/gen_ndr/rap.h"
#include "../librpc/gen_ndr/svcctl.h"
#include "libsmb/clirap.h"
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index e243f8a0fc4..14b6401051e 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -18,6 +18,8 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
#include "trans2.h"
@@ -26,6 +28,11 @@
****************************************************************************/
static size_t cli_read_max_bufsize(struct cli_state *cli)
{
+ size_t data_offset = smb_size - 4;
+ size_t wct = 12;
+
+ size_t useable_space;
+
if (!client_is_signing_on(cli) && !cli_encryption_on(cli)
&& (cli->server_posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) {
return CLI_SAMBA_MAX_POSIX_LARGE_READX_SIZE;
@@ -35,13 +42,21 @@ static size_t cli_read_max_bufsize(struct cli_state *cli)
? CLI_SAMBA_MAX_LARGE_READX_SIZE
: CLI_WINDOWS_MAX_LARGE_READX_SIZE;
}
- return (cli->max_xmit - (smb_size+32)) & ~1023;
+
+ data_offset += wct * sizeof(uint16_t);
+ data_offset += 1; /* pad */
+
+ useable_space = cli->max_xmit - data_offset;
+
+ return useable_space;
}
/****************************************************************************
Calculate the recommended write buffer size
****************************************************************************/
-static size_t cli_write_max_bufsize(struct cli_state *cli, uint16_t write_mode)
+static size_t cli_write_max_bufsize(struct cli_state *cli,
+ uint16_t write_mode,
+ uint8_t wct)
{
if (write_mode == 0 &&
!client_is_signing_on(cli) &&
@@ -60,13 +75,15 @@ static size_t cli_write_max_bufsize(struct cli_state *cli, uint16_t write_mode)
if (((cli->capabilities & CAP_LARGE_WRITEX) == 0)
|| client_is_signing_on(cli)
|| strequal(cli->dev, "LPT1:")) {
+ size_t data_offset = smb_size - 4;
+ size_t useable_space;
- /*
- * Printer devices are restricted to max_xmit writesize in
- * Vista and XPSP3 as are signing connections.
- */
+ data_offset += wct * sizeof(uint16_t);
+ data_offset += 1; /* pad */
- return (cli->max_xmit - (smb_size+32)) & ~1023;
+ useable_space = cli->max_xmit - data_offset;
+
+ return useable_space;
}
return CLI_WINDOWS_MAX_LARGE_WRITEX_SIZE;
@@ -196,7 +213,7 @@ static void cli_read_andx_done(struct tevent_req *subreq)
return;
}
- state->buf = (uint8_t *)smb_base(inbuf) + SVAL(vwv+6, 0);
+ state->buf = discard_const_p(uint8_t, smb_base(inbuf)) + SVAL(vwv+6, 0);
if (trans_oob(smb_len(inbuf), SVAL(vwv+6, 0), state->received)
|| ((state->received != 0) && (state->buf < bytes))) {
@@ -465,7 +482,7 @@ struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
state->num_reqs = MAX(window_size/state->chunk_size, 1);
state->num_reqs = MIN(state->num_reqs, cli->max_mux);
- state->reqs = TALLOC_ZERO_ARRAY(state, struct cli_pull_subreq,
+ state->reqs = talloc_zero_array(state, struct cli_pull_subreq,
state->num_reqs);
if (state->reqs == NULL) {
goto failed;
@@ -663,9 +680,6 @@ NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
status = cli_pull_recv(req, received);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
@@ -686,171 +700,12 @@ ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
status = cli_pull(cli, fnum, offset, size, size,
cli_read_sink, &buf, &ret);
if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
return -1;
}
return ret;
}
/****************************************************************************
- Issue a single SMBwrite and don't wait for a reply.
-****************************************************************************/
-
-static bool cli_issue_write(struct cli_state *cli,
- uint16_t fnum,
- off_t offset,
- uint16 mode,
- const char *buf,
- size_t size)
-{
- char *p;
- bool large_writex = false;
- /* We can only do direct writes if not signing and not encrypting. */
- bool direct_writes = !client_is_signing_on(cli) && !cli_encryption_on(cli);
-
- if (!direct_writes && size + 1 > cli->bufsize) {
- cli->outbuf = (char *)SMB_REALLOC(cli->outbuf, size + 1024);
- if (!cli->outbuf) {
- return False;
- }
- cli->inbuf = (char *)SMB_REALLOC(cli->inbuf, size + 1024);
- if (cli->inbuf == NULL) {
- SAFE_FREE(cli->outbuf);
- return False;
- }
- cli->bufsize = size + 1024;
- }
-
- memset(cli->outbuf,'\0',smb_size);
- memset(cli->inbuf,'\0',smb_size);
-
- if (cli->capabilities & CAP_LARGE_FILES) {
- large_writex = True;
- }
-
- if (large_writex) {
- cli_set_message(cli->outbuf,14,0,True);
- } else {
- cli_set_message(cli->outbuf,12,0,True);
- }
-
- SCVAL(cli->outbuf,smb_com,SMBwriteX);
- SSVAL(cli->outbuf,smb_tid,cli->cnum);
- cli_setup_packet(cli);
-
- SCVAL(cli->outbuf,smb_vwv0,0xFF);
- SSVAL(cli->outbuf,smb_vwv2,fnum);
-
- SIVAL(cli->outbuf,smb_vwv3,offset);
- SIVAL(cli->outbuf,smb_vwv5,0);
- SSVAL(cli->outbuf,smb_vwv7,mode);
-
- SSVAL(cli->outbuf,smb_vwv8,(mode & 0x0008) ? size : 0);
- /*
- * According to CIFS-TR-1p00, this following field should only
- * be set if CAP_LARGE_WRITEX is set. We should check this
- * locally. However, this check might already have been
- * done by our callers.
- */
- SSVAL(cli->outbuf,smb_vwv9,(size>>16));
- SSVAL(cli->outbuf,smb_vwv10,size);
- /* +1 is pad byte. */
- SSVAL(cli->outbuf,smb_vwv11,
- smb_buf(cli->outbuf) - smb_base(cli->outbuf) + 1);
-
- if (large_writex) {
- SIVAL(cli->outbuf,smb_vwv12,(((uint64_t)offset)>>32) & 0xffffffff);
- }
-
- p = smb_base(cli->outbuf) + SVAL(cli->outbuf,smb_vwv11) -1;
- *p++ = '\0'; /* pad byte. */
- if (!direct_writes) {
- memcpy(p, buf, size);
- }
- if (size > 0x1FFFF) {
- /* This is a POSIX 14 word large write. */
- set_message_bcc(cli->outbuf, 0); /* Set bcc to zero. */
- _smb_setlen_large(cli->outbuf,smb_size + 28 + 1 /* pad */ + size - 4);
- } else {
- cli_setup_bcc(cli, p+size);
- }
-
- show_msg(cli->outbuf);
- if (direct_writes) {
- /* For direct writes we now need to write the data
- * directly out of buf. */
- return cli_send_smb_direct_writeX(cli, buf, size);
- } else {
- return cli_send_smb(cli);
- }
-}
-
-/****************************************************************************
- write to a file
- write_mode: 0x0001 disallow write cacheing
- 0x0002 return bytes remaining
- 0x0004 use raw named pipe protocol
- 0x0008 start of message mode named pipe protocol
-****************************************************************************/
-
-ssize_t cli_write(struct cli_state *cli,
- uint16_t fnum, uint16 write_mode,
- const char *buf, off_t offset, size_t size)
-{
- ssize_t bwritten = 0;
- unsigned int issued = 0;
- unsigned int received = 0;
- int mpx = 1;
- size_t writesize;
- int blocks;
-
- if(cli->max_mux > 1) {
- mpx = cli->max_mux-1;
- } else {
- mpx = 1;
- }
-
- writesize = cli_write_max_bufsize(cli, write_mode);
-
- blocks = (size + (writesize-1)) / writesize;
-
- while (received < blocks) {
-
- while ((issued - received < mpx) && (issued < blocks)) {
- ssize_t bsent = issued * writesize;
- ssize_t size1 = MIN(writesize, size - bsent);
-
- if (!cli_issue_write(cli, fnum, offset + bsent,
- write_mode,
- buf + bsent,
- size1))
- return -1;
- issued++;
- }
-
- if (!cli_receive_smb(cli)) {
- return bwritten;
- }
-
- received++;
-
- if (cli_is_error(cli))
- break;
-
- bwritten += SVAL(cli->inbuf, smb_vwv2);
- if (writesize > 0xFFFF) {
- bwritten += (((int)(SVAL(cli->inbuf, smb_vwv4)))<<16);
- }
- }
-
- while (received < issued && cli_receive_smb(cli)) {
- received++;
- }
-
- return bwritten;
-}
-
-/****************************************************************************
write to a file using a SMBwrite and not bypassing 0 byte writes
****************************************************************************/
@@ -864,7 +719,7 @@ NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
* 3 bytes prefix
*/
- bytes = TALLOC_ARRAY(talloc_tos(), uint8_t, 3);
+ bytes = talloc_array(talloc_tos(), uint8_t, 3);
if (bytes == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -882,7 +737,7 @@ NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
SIVAL(vwv+2, 0, offset);
SSVAL(vwv+4, 0, 0);
- bytes = TALLOC_REALLOC_ARRAY(talloc_tos(), bytes, uint8_t,
+ bytes = talloc_realloc(talloc_tos(), bytes, uint8_t,
size+3);
if (bytes == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -944,7 +799,7 @@ struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
struct cli_write_andx_state *state;
bool bigoffset = ((cli->capabilities & CAP_LARGE_FILES) != 0);
uint8_t wct = bigoffset ? 14 : 12;
- size_t max_write = cli_write_max_bufsize(cli, mode);
+ size_t max_write = cli_write_max_bufsize(cli, mode, wct);
uint16_t *vwv;
req = tevent_req_create(mem_ctx, &state, struct cli_write_andx_state);
@@ -981,7 +836,7 @@ struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
state->pad = 0;
state->iov[0].iov_base = (void *)&state->pad;
state->iov[0].iov_len = 1;
- state->iov[1].iov_base = CONST_DISCARD(void *, buf);
+ state->iov[1].iov_base = discard_const_p(void, buf);
state->iov[1].iov_len = size;
subreq = cli_smb_req_create(state, ev, cli, SMBwriteX, 0, wct, vwv,
@@ -1138,9 +993,54 @@ static void cli_writeall_written(struct tevent_req *subreq)
tevent_req_set_callback(subreq, cli_writeall_written, req);
}
-static NTSTATUS cli_writeall_recv(struct tevent_req *req)
+static NTSTATUS cli_writeall_recv(struct tevent_req *req,
+ size_t *pwritten)
{
- return tevent_req_simple_recv_ntstatus(req);
+ struct cli_writeall_state *state = tevent_req_data(
+ req, struct cli_writeall_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+ if (pwritten != NULL) {
+ *pwritten = state->written;
+ }
+ return NT_STATUS_OK;
+}
+
+NTSTATUS cli_writeall(struct cli_state *cli, uint16_t fnum, uint16_t mode,
+ const uint8_t *buf, off_t offset, size_t size,
+ size_t *pwritten)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct event_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ if (cli_has_async_calls(cli)) {
+ /*
+ * Can't use sync call while an async call is in flight
+ */
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
+ }
+ ev = event_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = cli_writeall_send(frame, ev, cli, fnum, mode, buf, offset, size);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll(req, ev)) {
+ status = map_nt_error_from_unix(errno);
+ goto fail;
+ }
+ status = cli_writeall_recv(req, pwritten);
+ fail:
+ TALLOC_FREE(frame);
+ return status;
}
struct cli_push_write_state {
@@ -1252,7 +1152,7 @@ struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
state->pending = 0;
state->next_offset = start_offset;
- state->chunk_size = cli_write_max_bufsize(cli, mode);
+ state->chunk_size = cli_write_max_bufsize(cli, mode, 14);
if (window_size == 0) {
window_size = cli->max_mux * state->chunk_size;
@@ -1264,7 +1164,7 @@ struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
state->num_reqs = MIN(state->num_reqs, cli->max_mux);
state->num_reqs = MAX(state->num_reqs, 1);
- state->reqs = TALLOC_ZERO_ARRAY(state, struct cli_push_write_state *,
+ state->reqs = talloc_zero_array(state, struct cli_push_write_state *,
state->num_reqs);
if (state->reqs == NULL) {
goto failed;
@@ -1305,7 +1205,7 @@ static void cli_push_written(struct tevent_req *subreq)
state->reqs[idx] = NULL;
state->pending -= 1;
- status = cli_writeall_recv(subreq);
+ status = cli_writeall_recv(subreq, NULL);
TALLOC_FREE(subreq);
TALLOC_FREE(substate);
if (tevent_req_nterror(req, status)) {
@@ -1369,8 +1269,5 @@ NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
status = cli_push_recv(req);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
diff --git a/source3/libsmb/clisecdesc.c b/source3/libsmb/clisecdesc.c
index 5543ce50330..d703b1f7744 100644
--- a/source3/libsmb/clisecdesc.c
+++ b/source3/libsmb/clisecdesc.c
@@ -18,6 +18,8 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
+#include "../libcli/security/secdesc.h"
/****************************************************************************
query the security descriptor for a open file
diff --git a/source3/libsmb/clisigning.c b/source3/libsmb/clisigning.c
index 1752edb023c..ac4db7626f5 100644
--- a/source3/libsmb/clisigning.c
+++ b/source3/libsmb/clisigning.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "smb_signing.h"
bool cli_simple_set_signing(struct cli_state *cli,
diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c
index 944479c2a8f..ff18ef6bcfe 100644
--- a/source3/libsmb/clistr.c
+++ b/source3/libsmb/clistr.c
@@ -19,6 +19,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
size_t clistr_push_fn(struct cli_state *cli,
void *dest,
@@ -74,8 +75,3 @@ size_t clistr_pull_talloc(TALLOC_CTX *ctx,
src_len,
flags);
}
-
-size_t clistr_align_out(struct cli_state *cli, const void *p, int flags)
-{
- return align_string(cli->outbuf, (const char *)p, flags);
-}
diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c
index dab8c10c843..dd8063bf1e3 100644
--- a/source3/libsmb/clitrans.c
+++ b/source3/libsmb/clitrans.c
@@ -18,6 +18,8 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "async_smb.h"
struct trans_recvblob {
@@ -30,7 +32,6 @@ struct cli_trans_state {
struct event_context *ev;
uint8_t cmd;
uint16_t mid;
- uint32_t seqnum;
const char *pipe_name;
uint8_t *pipe_name_conv;
size_t pipe_name_conv_len;
@@ -50,13 +51,29 @@ struct cli_trans_state {
struct trans_recvblob rdata;
uint16_t recv_flags2;
- TALLOC_CTX *secondary_request_ctx;
-
- struct iovec iov[4];
+ struct iovec iov[6];
uint8_t pad[4];
+ uint8_t zero_pad[4];
uint16_t vwv[32];
+
+ struct tevent_req *primary_subreq;
};
+static void cli_trans_cleanup_primary(struct cli_trans_state *state)
+{
+ if (state->primary_subreq) {
+ cli_smb_req_set_mid(state->primary_subreq, 0);
+ cli_smb_req_unset_pending(state->primary_subreq);
+ TALLOC_FREE(state->primary_subreq);
+ }
+}
+
+static int cli_trans_state_destructor(struct cli_trans_state *state)
+{
+ cli_trans_cleanup_primary(state);
+ return 0;
+}
+
static NTSTATUS cli_pull_trans(uint8_t *inbuf,
uint8_t wct, uint16_t *vwv,
uint16_t num_bytes, uint8_t *bytes,
@@ -146,7 +163,7 @@ static NTSTATUS cli_trans_pull_blob(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
blob->total = total;
- blob->data = TALLOC_ARRAY(mem_ctx, uint8_t, total);
+ blob->data = talloc_array(mem_ctx, uint8_t, total);
if (blob->data == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -171,9 +188,12 @@ static void cli_trans_format(struct cli_trans_state *state, uint8_t *pwct,
struct iovec *iov = state->iov;
uint8_t *pad = state->pad;
uint16_t *vwv = state->vwv;
- uint16_t param_offset;
- uint16_t this_param = 0;
- uint16_t this_data = 0;
+ uint32_t param_offset;
+ uint32_t this_param = 0;
+ uint32_t param_pad;
+ uint32_t data_offset;
+ uint32_t this_data = 0;
+ uint32_t data_pad;
uint32_t useable_space;
uint8_t cmd;
@@ -221,7 +241,18 @@ static void cli_trans_format(struct cli_trans_state *state, uint8_t *pwct,
break;
}
- useable_space = state->cli->max_xmit - smb_size - sizeof(uint16_t)*wct;
+ param_offset += wct * sizeof(uint16_t);
+ useable_space = state->cli->max_xmit - param_offset;
+
+ param_pad = param_offset % 4;
+ if (param_pad > 0) {
+ param_pad = MIN(param_pad, useable_space);
+ iov[0].iov_base = (void *)state->zero_pad;
+ iov[0].iov_len = param_pad;
+ iov += 1;
+ param_offset += param_pad;
+ }
+ useable_space = state->cli->max_xmit - param_offset;
if (state->param_sent < state->num_param) {
this_param = MIN(state->num_param - state->param_sent,
@@ -231,27 +262,41 @@ static void cli_trans_format(struct cli_trans_state *state, uint8_t *pwct,
iov += 1;
}
+ data_offset = param_offset + this_param;
+ useable_space = state->cli->max_xmit - data_offset;
+
+ data_pad = data_offset % 4;
+ if (data_pad > 0) {
+ data_pad = MIN(data_pad, useable_space);
+ iov[0].iov_base = (void *)state->zero_pad;
+ iov[0].iov_len = data_pad;
+ iov += 1;
+ data_offset += data_pad;
+ }
+ useable_space = state->cli->max_xmit - data_offset;
+
if (state->data_sent < state->num_data) {
this_data = MIN(state->num_data - state->data_sent,
- useable_space - this_param);
+ useable_space);
iov[0].iov_base = (void *)(state->data + state->data_sent);
iov[0].iov_len = this_data;
iov += 1;
}
- param_offset += wct * sizeof(uint16_t);
-
DEBUG(10, ("num_setup=%u, max_setup=%u, "
"param_total=%u, this_param=%u, max_param=%u, "
"data_total=%u, this_data=%u, max_data=%u, "
- "param_offset=%u, param_disp=%u, data_disp=%u\n",
+ "param_offset=%u, param_pad=%u, param_disp=%u, "
+ "data_offset=%u, data_pad=%u, data_disp=%u\n",
(unsigned)state->num_setup, (unsigned)state->max_setup,
(unsigned)state->num_param, (unsigned)this_param,
(unsigned)state->rparam.max,
(unsigned)state->num_data, (unsigned)this_data,
(unsigned)state->rdata.max,
- (unsigned)param_offset,
- (unsigned)state->param_sent, (unsigned)state->data_sent));
+ (unsigned)param_offset, (unsigned)param_pad,
+ (unsigned)state->param_sent,
+ (unsigned)data_offset, (unsigned)data_pad,
+ (unsigned)state->data_sent));
switch (cmd) {
case SMBtrans:
@@ -268,7 +313,7 @@ static void cli_trans_format(struct cli_trans_state *state, uint8_t *pwct,
SSVAL(vwv + 9, 0, this_param);
SSVAL(vwv +10, 0, param_offset);
SSVAL(vwv +11, 0, this_data);
- SSVAL(vwv +12, 0, param_offset + this_param);
+ SSVAL(vwv +12, 0, data_offset);
SCVAL(vwv +13, 0, state->num_setup);
SCVAL(vwv +13, 1, 0); /* reserved */
memcpy(vwv + 14, state->setup,
@@ -282,40 +327,40 @@ static void cli_trans_format(struct cli_trans_state *state, uint8_t *pwct,
SSVAL(vwv + 3, 0, param_offset);
SSVAL(vwv + 4, 0, state->param_sent);
SSVAL(vwv + 5, 0, this_data);
- SSVAL(vwv + 6, 0, param_offset + this_param);
+ SSVAL(vwv + 6, 0, data_offset);
SSVAL(vwv + 7, 0, state->data_sent);
if (cmd == SMBtranss2) {
SSVAL(vwv + 8, 0, state->fid);
}
break;
case SMBnttrans:
- SCVAL(vwv, 0, state->max_setup);
- SSVAL(vwv, 1, 0); /* reserved */
- SIVAL(vwv, 3, state->num_param);
- SIVAL(vwv, 7, state->num_data);
- SIVAL(vwv, 11, state->rparam.max);
- SIVAL(vwv, 15, state->rdata.max);
- SIVAL(vwv, 19, this_param);
- SIVAL(vwv, 23, param_offset);
- SIVAL(vwv, 27, this_data);
- SIVAL(vwv, 31, param_offset + this_param);
- SCVAL(vwv, 35, state->num_setup);
- SSVAL(vwv, 36, state->function);
+ SCVAL(vwv + 0, 0, state->max_setup);
+ SSVAL(vwv + 0, 1, 0); /* reserved */
+ SIVAL(vwv + 1, 1, state->num_param);
+ SIVAL(vwv + 3, 1, state->num_data);
+ SIVAL(vwv + 5, 1, state->rparam.max);
+ SIVAL(vwv + 7, 1, state->rdata.max);
+ SIVAL(vwv + 9, 1, this_param);
+ SIVAL(vwv +11, 1, param_offset);
+ SIVAL(vwv +13, 1, this_data);
+ SIVAL(vwv +15, 1, data_offset);
+ SCVAL(vwv +17, 1, state->num_setup);
+ SSVAL(vwv +18, 0, state->function);
memcpy(vwv + 19, state->setup,
sizeof(uint16_t) * state->num_setup);
break;
case SMBnttranss:
- SSVAL(vwv, 0, 0); /* reserved */
- SCVAL(vwv, 2, 0); /* reserved */
- SIVAL(vwv, 3, state->num_param);
- SIVAL(vwv, 7, state->num_data);
- SIVAL(vwv, 11, this_param);
- SIVAL(vwv, 15, param_offset);
- SIVAL(vwv, 19, state->param_sent);
- SIVAL(vwv, 23, this_data);
- SIVAL(vwv, 27, param_offset + this_param);
- SIVAL(vwv, 31, state->data_sent);
- SCVAL(vwv, 35, 0); /* reserved */
+ SSVAL(vwv + 0, 0, 0); /* reserved */
+ SCVAL(vwv + 1, 0, 0); /* reserved */
+ SIVAL(vwv + 1, 1, state->num_param);
+ SIVAL(vwv + 3, 1, state->num_data);
+ SIVAL(vwv + 5, 1, this_param);
+ SIVAL(vwv + 7, 1, param_offset);
+ SIVAL(vwv + 9, 1, state->param_sent);
+ SIVAL(vwv +11, 1, this_data);
+ SIVAL(vwv +13, 1, data_offset);
+ SIVAL(vwv +15, 1, state->data_sent);
+ SCVAL(vwv +17, 1, 0); /* reserved */
break;
}
@@ -412,17 +457,30 @@ struct tevent_req *cli_trans_send(
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
- state->mid = cli_smb_req_mid(subreq);
status = cli_smb_req_send(subreq);
if (!NT_STATUS_IS_OK(status)) {
tevent_req_nterror(req, status);
return tevent_req_post(req, state->ev);
}
- cli_state_seqnum_persistent(cli, state->mid);
tevent_req_set_callback(subreq, cli_trans_done, req);
+
+ /*
+ * Now get the MID of the primary request
+ * and mark it as persistent. This means
+ * we will able to send and receive multiple
+ * SMB pdus using this MID in both directions
+ * (including correct SMB signing).
+ */
+ state->mid = cli_smb_req_mid(subreq);
+ cli_smb_req_set_mid(subreq, state->mid);
+ state->primary_subreq = subreq;
+ talloc_set_destructor(state, cli_trans_state_destructor);
+
return req;
}
+static void cli_trans_done2(struct tevent_req *subreq);
+
static void cli_trans_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(
@@ -478,25 +536,25 @@ static void cli_trans_done(struct tevent_req *subreq)
if (!sent_all) {
int iov_count;
-
- TALLOC_FREE(subreq);
+ struct tevent_req *subreq2;
cli_trans_format(state, &wct, &iov_count);
- subreq = cli_smb_req_create(state, state->ev, state->cli,
- state->cmd + 1, 0, wct, state->vwv,
- iov_count, state->iov);
- if (tevent_req_nomem(subreq, req)) {
+ subreq2 = cli_smb_req_create(state, state->ev, state->cli,
+ state->cmd + 1, 0, wct, state->vwv,
+ iov_count, state->iov);
+ if (tevent_req_nomem(subreq2, req)) {
return;
}
- cli_smb_req_set_mid(subreq, state->mid);
+ cli_smb_req_set_mid(subreq2, state->mid);
- status = cli_smb_req_send(subreq);
+ status = cli_smb_req_send(subreq2);
if (!NT_STATUS_IS_OK(status)) {
goto fail;
}
- tevent_req_set_callback(subreq, cli_trans_done, req);
+ tevent_req_set_callback(subreq2, cli_trans_done2, req);
+
return;
}
@@ -521,23 +579,80 @@ static void cli_trans_done(struct tevent_req *subreq)
if ((state->rparam.total == state->rparam.received)
&& (state->rdata.total == state->rdata.received)) {
state->recv_flags2 = SVAL(inbuf, smb_flg2);
- TALLOC_FREE(subreq);
- cli_state_seqnum_remove(state->cli, state->mid);
+ cli_trans_cleanup_primary(state);
tevent_req_done(req);
return;
}
TALLOC_FREE(inbuf);
- if (!cli_smb_req_set_pending(subreq)) {
- status = NT_STATUS_NO_MEMORY;
+ return;
+
+ fail:
+ cli_trans_cleanup_primary(state);
+ tevent_req_nterror(req, status);
+}
+
+static void cli_trans_done2(struct tevent_req *subreq2)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq2, struct tevent_req);
+ struct cli_trans_state *state = tevent_req_data(
+ req, struct cli_trans_state);
+ NTSTATUS status;
+ bool sent_all;
+ uint8_t wct;
+ uint32_t seqnum;
+
+ /*
+ * First backup the seqnum of the secondary request
+ * and attach it to the primary request.
+ */
+ seqnum = cli_smb_req_seqnum(subreq2);
+ cli_smb_req_set_seqnum(state->primary_subreq, seqnum);
+
+ status = cli_smb_recv(subreq2, state, NULL, 0, &wct, NULL,
+ NULL, NULL);
+ TALLOC_FREE(subreq2);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+
+ if (wct != 0) {
+ status = NT_STATUS_INVALID_NETWORK_RESPONSE;
goto fail;
}
+
+ sent_all = ((state->param_sent == state->num_param)
+ && (state->data_sent == state->num_data));
+
+ if (!sent_all) {
+ int iov_count;
+
+ cli_trans_format(state, &wct, &iov_count);
+
+ subreq2 = cli_smb_req_create(state, state->ev, state->cli,
+ state->cmd + 1, 0, wct, state->vwv,
+ iov_count, state->iov);
+ if (tevent_req_nomem(subreq2, req)) {
+ return;
+ }
+ cli_smb_req_set_mid(subreq2, state->mid);
+
+ status = cli_smb_req_send(subreq2);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+ tevent_req_set_callback(subreq2, cli_trans_done2, req);
+ return;
+ }
+
return;
fail:
- cli_state_seqnum_remove(state->cli, state->mid);
- TALLOC_FREE(subreq);
+ cli_trans_cleanup_primary(state);
tevent_req_nterror(req, status);
}
@@ -554,6 +669,8 @@ NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
req, struct cli_trans_state);
NTSTATUS status;
+ cli_trans_cleanup_primary(state);
+
if (tevent_req_is_nterror(req, &status)) {
return status;
}
@@ -644,8 +761,5 @@ NTSTATUS cli_trans(TALLOC_CTX *mem_ctx, struct cli_state *cli,
rdata, min_rdata, num_rdata);
fail:
TALLOC_FREE(frame);
- if (!NT_STATUS_IS_OK(status)) {
- cli_set_error(cli, status);
- }
return status;
}
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index e062818ddae..5df833f40f8 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -32,7 +32,6 @@
struct ip_service_name {
struct sockaddr_storage ss;
- unsigned port;
const char *hostname;
};
@@ -340,7 +339,7 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx,
return NT_STATUS_NOT_FOUND;
}
- info = TALLOC_ZERO_P(mem_ctx, struct netr_DsRGetDCNameInfo);
+ info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo);
if (!info) {
return NT_STATUS_NO_MEMORY;
}
@@ -499,7 +498,7 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
return status;
}
- dclist = TALLOC_ZERO_ARRAY(mem_ctx, struct ip_service_name, count);
+ dclist = talloc_zero_array(mem_ctx, struct ip_service_name, count);
if (!dclist) {
SAFE_FREE(iplist);
return NT_STATUS_NO_MEMORY;
@@ -514,7 +513,6 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
&iplist[i].ss);
r->ss = iplist[i].ss;
- r->port = iplist[i].port;
r->hostname = talloc_strdup(mem_ctx, addr);
if (!r->hostname) {
SAFE_FREE(iplist);
@@ -581,7 +579,7 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
numaddrs += MAX(dcs[i].num_ips,1);
}
- dclist = TALLOC_ZERO_ARRAY(mem_ctx,
+ dclist = talloc_zero_array(mem_ctx,
struct ip_service_name,
numaddrs);
if (!dclist) {
@@ -598,7 +596,6 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
struct ip_service_name *r = &dclist[count];
- r->port = dcs[i].port;
r->hostname = dcs[i].hostname;
/* If we don't have an IP list for a name, lookup it up */
@@ -609,7 +606,7 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
i++;
j = 0;
} else {
- /* use the IP addresses from the SRV sresponse */
+ /* use the IP addresses from the SRV response */
if (j >= dcs[i].num_ips) {
i++;
@@ -623,8 +620,8 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
/* make sure it is a valid IP. I considered checking the
* negative connection cache, but this is the wrong place for
- * it. Maybe only as a hac. After think about it, if all of
- * the IP addresses retuend from DNS are dead, what hope does a
+ * it. Maybe only as a hack. After think about it, if all of
+ * the IP addresses returned from DNS are dead, what hope does a
* netbios name lookup have? The standard reason for falling
* back to netbios lookups is that our DNS server doesn't know
* anything about the DC's -- jerry */
@@ -662,7 +659,7 @@ static NTSTATUS make_domain_controller_info(TALLOC_CTX *mem_ctx,
{
struct netr_DsRGetDCNameInfo *info;
- info = TALLOC_ZERO_P(mem_ctx, struct netr_DsRGetDCNameInfo);
+ info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo);
NT_STATUS_HAVE_NO_MEMORY(info);
if (dc_unc) {
@@ -864,9 +861,10 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx,
for (i=0; i<num_dcs; i++) {
+
DEBUG(10,("LDAP ping to %s\n", dclist[i].hostname));
- if (ads_cldap_netlogon(mem_ctx, dclist[i].hostname,
+ if (ads_cldap_netlogon(mem_ctx, &dclist[i].ss,
domain_name,
nt_version,
&r))
@@ -938,10 +936,8 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
for (i=0; i<num_dcs; i++) {
uint16_t val;
- int dgm_id;
generate_random_buffer((uint8_t *)&val, 2);
- dgm_id = val;
ip_list.ss = dclist[i].ss;
ip_list.port = 0;
@@ -967,7 +963,7 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
{
struct NETLOGON_SAM_LOGON_RESPONSE_NT40 logon1;
- r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response);
+ r = talloc_zero(mem_ctx, struct netlogon_samlogon_response);
NT_STATUS_HAVE_NO_MEMORY(r);
ZERO_STRUCT(logon1);
diff --git a/source3/libsmb/errormap.c b/source3/libsmb/errormap.c
index bc9676bbff6..35b4137ec3a 100644
--- a/source3/libsmb/errormap.c
+++ b/source3/libsmb/errormap.c
@@ -29,600 +29,6 @@
#include <gssapi.h>
#endif
-/* This map was extracted by the ERRMAPEXTRACT smbtorture command.
- The setup was a Samba HEAD (2002-01-03) PDC and an Win2k member
- workstation. The PDC was modified (by using the 'name_to_nt_status'
- authentication module) to convert the username (in hex) into the
- corresponding NTSTATUS error return.
-
- By opening two nbt sessions to the Win2k workstation, one negotiating
- DOS and one negotiating NT errors it was possible to extract the
- error mapping. (Because the server only supplies NT errors, the
- NT4 workstation had to use its own error tables to convert these
- to dos errors).
-
- Some errors show up as 'squashed' because the NT error connection
- got back a different error to the one it sent, so a mapping could
- not be determined (a guess has been made in this case, to map the
- error as squashed). This is done mainly to prevent users from getting
- NT_STATUS_WRONG_PASSWORD and NT_STATUS_NO_SUCH_USER errors (they get
- NT_STATUS_LOGON_FAILURE instead.
-
- -- abartlet (2002-01-03)
-*/
-
-/* NT status -> dos error map */
-static const struct {
- uint8 dos_class;
- uint32 dos_code;
- NTSTATUS ntstatus;
-} ntstatus_to_dos_map[] = {
- {ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL},
- {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED},
- {ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS},
- {ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH},
- {ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION},
- {ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA},
- {ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK},
- {ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC},
- {ERRDOS, 87, NT_STATUS_INVALID_CID},
- {ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER},
- {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE},
- {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE},
- {ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST},
- {ERRDOS, 38, NT_STATUS_END_OF_FILE},
- {ERRDOS, 34, NT_STATUS_WRONG_VOLUME},
- {ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE},
- {ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA},
- {ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR},
-/** Session setup succeeded. This shouldn't happen...*/
-/** Session setup succeeded. This shouldn't happen...*/
-/** NT error on DOS connection! (NT_STATUS_OK) */
-/* { This NT error code was 'sqashed'
- from NT_STATUS_MORE_PROCESSING_REQUIRED to NT_STATUS_OK
- during the session setup }
-*/
-#if 0
- {SUCCESS, 0, NT_STATUS_OK},
-#endif
- {ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY},
- {ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES},
- {ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW},
- {ERRDOS, 87, NT_STATUS_UNABLE_TO_FREE_VM},
- {ERRDOS, 87, NT_STATUS_UNABLE_TO_DELETE_SECTION},
- {ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE},
- {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION},
- {ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE},
- {ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE},
- {ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION},
- {ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED},
-/* { This NT error code was 'sqashed'
- from NT_STATUS_ACCESS_DENIED to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE
- during the session setup }
-*/
- {ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED},
- {ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL},
-/*
- * Not an official error, as only bit 0x80000000, not bits 0xC0000000 are set.
- */
- {ERRDOS, ERRmoredata, STATUS_BUFFER_OVERFLOW},
- {ERRDOS, ERRnofiles, STATUS_NO_MORE_FILES},
- {ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH},
- {ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION},
- {ERRHRD, ERRgeneral, NT_STATUS_UNWIND},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET},
- {ERRDOS, 158, NT_STATUS_NOT_LOCKED},
- {ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR},
- {ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM},
- {ERRDOS, 487, NT_STATUS_NOT_COMMITTED},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES},
- {ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER},
- {ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR},
- {ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID},
- {ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND},
- {ERRDOS, 183, NT_STATUS_OBJECT_NAME_COLLISION},
- {ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE},
- {ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED},
- {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED},
- {ERRDOS, ERRinvalidpath, NT_STATUS_OBJECT_PATH_INVALID},
- {ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND},
- {ERRDOS, ERRinvalidpath, NT_STATUS_OBJECT_PATH_SYNTAX_BAD},
- {ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN},
- {ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR},
- {ERRDOS, 23, NT_STATUS_DATA_ERROR},
- {ERRDOS, 23, NT_STATUS_CRC_ERROR},
- {ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG},
- {ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED},
- {ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE},
- {ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION},
- {ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED},
- {ERRDOS, 87, NT_STATUS_INVALID_PAGE_PROTECTION},
- {ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED},
- {ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
- {ERRDOS, 87, NT_STATUS_PORT_ALREADY_SET},
- {ERRDOS, 87, NT_STATUS_SECTION_NOT_IMAGE},
- {ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED},
- {ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING},
- {ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT},
- {ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP},
- {ERRDOS, 87, NT_STATUS_SECTION_PROTECTION},
- {ERRDOS, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED},
- {ERRDOS, 255, NT_STATUS_EA_TOO_LARGE},
- {ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE},
- {ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR},
- {ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT},
- {ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED},
- {ERRDOS, ERRnoaccess, NT_STATUS_DELETE_PENDING},
- {ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED},
- {ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION},
- {ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN},
- {ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY},
- {ERRDOS, 2215, NT_STATUS_NO_LOGON_SERVERS},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE},
- {ERRDOS, ERRnoaccess, NT_STATUS_PRIVILEGE_NOT_HELD},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME},
- {ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS},
-/* { This NT error code was 'sqashed'
- from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE
- during the session setup }
-*/
- {ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER},
- {ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP},
- {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP},
- {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP},
- {ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN},
-/* { This NT error code was 'sqashed'
- from NT_STATUS_WRONG_PASSWORD to NT_STATUS_LOGON_FAILURE
- during the session setup }
-*/
- {ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD},
- {ERRSRV, ERRbaduid, NT_STATUS_USER_SESSION_DELETED},
- {ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD},
- {ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION},
- {ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE},
- {ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION},
- {ERRSRV, 2241, NT_STATUS_INVALID_LOGON_HOURS},
- {ERRSRV, 2240, NT_STATUS_INVALID_WORKSTATION},
- {ERRSRV, 2242, NT_STATUS_PASSWORD_EXPIRED},
- {ERRSRV, 2239, NT_STATUS_ACCOUNT_DISABLED},
- {ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED},
- {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED},
- {ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR},
- {ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND},
- {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_FORMAT},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL},
- {ERRDOS, 158, NT_STATUS_RANGE_NOT_LOCKED},
- {ERRDOS, 112, NT_STATUS_DISK_FULL},
- {ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED},
- {ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED},
- {ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
- {ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY},
- {ERRDOS, 259, NT_STATUS_AGENTS_EXHAUSTED},
- {ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL},
- {ERRDOS, ERRres, NT_STATUS_SECTION_NOT_EXTENDED},
- {ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA},
- {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND},
- {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND},
- {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND},
- {ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW},
- {ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO},
- {ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW},
- {ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION},
- {ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES},
- {ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID},
- {ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
-/* { This NT error code was 'sqashed'
- from NT_STATUS_INSUFFICIENT_RESOURCES to NT_STATUS_INSUFF_SERVER_RESOURCES
- during the session setup }
-*/
- {ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES},
- {ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND},
- {ERRDOS, 23, NT_STATUS_DEVICE_DATA_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED},
- {ERRDOS, 21, NT_STATUS_DEVICE_POWER_FAILURE},
- {ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE},
- {ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED},
- {ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA},
- {ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED},
- {ERRDOS, 21, NT_STATUS_DEVICE_NOT_READY},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL},
- {ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE},
- {ERRDOS, 87, NT_STATUS_BAD_MASTER_BOOT_RECORD},
- {ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT},
- {ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE},
- {ERRDOS, ERRpipebusy, NT_STATUS_PIPE_NOT_AVAILABLE},
- {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_PIPE_STATE},
- {ERRDOS, ERRpipebusy, NT_STATUS_PIPE_BUSY},
- {ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION},
- {ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED},
- {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING},
- {ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED},
- {ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING},
- {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_READ_MODE},
- {ERRDOS, 121, NT_STATUS_IO_TIMEOUT},
- {ERRDOS, 38, NT_STATUS_FILE_FORCED_CLOSED},
- {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED},
- {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED},
- {ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET},
- {ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY},
- {ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED},
- {ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING},
- {ERRDOS, 52, NT_STATUS_DUPLICATE_NAME},
- {ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH},
- {ERRDOS, 54, NT_STATUS_NETWORK_BUSY},
- {ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST},
- {ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS},
- {ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR},
- {ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE},
- {ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR},
- {ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER},
- {ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL},
- {ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE},
- {ERRDOS, 63, NT_STATUS_PRINT_CANCELLED},
- {ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED},
- {ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED},
- {ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE},
- {ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME},
- {ERRDOS, 68, NT_STATUS_TOO_MANY_NAMES},
- {ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS},
- {ERRDOS, 70, NT_STATUS_SHARING_PAUSED},
- {ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED},
- {ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED},
- {ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT},
- {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT},
- {ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE},
- {ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED},
- {ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT},
- {ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT},
- {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_EMPTY},
- {ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO},
- {ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN},
- {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS},
- {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED},
- {ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED},
- {ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL},
- {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION},
- {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER},
- {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR},
- {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR},
- {ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS},
- {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_1},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_2},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_3},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_4},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_5},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_6},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_7},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_8},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_9},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_10},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_11},
- {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_12},
- {ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED},
- {ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED},
- {ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE},
- {ERRDOS, 203, NT_STATUS(0xc0000100)},
- {ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY},
- {ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR},
- {ERRDOS, ERRbaddirectory, NT_STATUS_NOT_A_DIRECTORY},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE},
- {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION},
- {ERRDOS, 206, NT_STATUS_NAME_TOO_LONG},
- {ERRDOS, 2401, NT_STATUS_FILES_OPEN},
- {ERRDOS, 2404, NT_STATUS_CONNECTION_IN_USE},
- {ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND},
- {ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION},
- {ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE},
- {ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED},
- {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT},
- {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST},
- {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED},
- {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER},
- {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND},
- {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID},
- {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE},
- {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_LDT},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR},
- {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NE_FORMAT},
- {ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE},
- {ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE},
- {ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO},
- {ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES},
- {ERRHRD, ERRgeneral, NT_STATUS_CANCELLED},
- {ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME},
- {ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED},
- {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT},
- {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP},
- {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER},
- {ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP},
- {ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED},
- {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS},
- {ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS},
- {ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE},
- {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED},
- {ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT},
- {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_LE_FORMAT},
- {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NOT_MZ},
- {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_PROTECT},
- {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_WIN_16},
- {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT},
- {ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC},
- {ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED},
- {ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND},
- {ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED},
- {ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED},
- {ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND},
- {ERRDOS, 127, NT_STATUS_ENTRYPOINT_NOT_FOUND},
- {ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT},
- {ERRDOS, 64, NT_STATUS_LOCAL_DISCONNECT},
- {ERRDOS, 64, NT_STATUS_REMOTE_DISCONNECT},
- {ERRDOS, 51, NT_STATUS_REMOTE_RESOURCES},
- {ERRDOS, 59, NT_STATUS_LINK_FAILED},
- {ERRDOS, 59, NT_STATUS_LINK_TIMEOUT},
- {ERRDOS, 59, NT_STATUS_INVALID_CONNECTION},
- {ERRDOS, 59, NT_STATUS_INVALID_ADDRESS},
- {ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED},
- {ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE},
- {ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION},
- {ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE},
- {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE},
- {ERRDOS, ERRunknownlevel, NT_STATUS_INVALID_LEVEL},
- {ERRDOS, 86, NT_STATUS_WRONG_PASSWORD_CORE},
- {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT},
- {ERRDOS, 109, NT_STATUS_PIPE_BROKEN},
- {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT},
- {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR},
- {ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME},
- {ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS},
- {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS},
- {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS},
- {ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS},
- {ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED},
- {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS},
- {ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG},
- {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE},
- {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS},
- {ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED},
- {ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE},
- {ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED},
- {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER},
- {ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY},
- {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER},
- {ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER},
- {ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS},
- {ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED},
- {ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED},
- {ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED},
- {ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY},
- {ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000016e)},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000016f)},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc0000170)},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc0000171)},
- {ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH},
- {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED},
- {ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA},
- {ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA},
- {ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc0000179)},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER},
- {ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE},
- {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS},
- {ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED},
- {ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN},
- {ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE},
- {ERRDOS, 87, NT_STATUS_DEVICE_CONFIGURATION_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR},
- {ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE},
- {ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER},
- {ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL},
- {ERRDOS, 19, NT_STATUS_TOO_LATE},
- {ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET},
-/* { This NT error code was 'sqashed'
- from NT_STATUS_NO_TRUST_SAM_ACCOUNT to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE
- during the session setup }
-*/
- {ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT},
- {ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE},
- {ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE},
- {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT},
- {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START},
- {ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE},
- {ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED},
- {ERRDOS, ERRinvgroup, NT_STATUS_NETLOGON_NOT_STARTED},
- {ERRSRV, 2239, NT_STATUS_ACCOUNT_EXPIRED},
- {ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK},
- {ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT},
- {ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT},
- {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED},
- {ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT},
- {ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT},
- {ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
-/* { This NT error code was 'sqashed'
- from NT_STATUS_DOMAIN_TRUST_INCONSISTENT to NT_STATUS_LOGON_FAILURE
- during the session setup }
-*/
- {ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT},
- {ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY},
- {ERRDOS, 59, NT_STATUS_USER_SESSION_DELETED},
- {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND},
- {ERRDOS, ERRnomem, NT_STATUS_INSUFF_SERVER_RESOURCES},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD},
- {ERRDOS, 68, NT_STATUS_TOO_MANY_ADDRESSES},
- {ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_EXISTS},
- {ERRDOS, 64, NT_STATUS_ADDRESS_CLOSED},
- {ERRDOS, 64, NT_STATUS_CONNECTION_DISCONNECTED},
- {ERRDOS, 64, NT_STATUS_CONNECTION_RESET},
- {ERRDOS, 68, NT_STATUS_TOO_MANY_NODES},
- {ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED},
- {ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT},
- {ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE},
- {ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH},
- {ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED},
- {ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID},
- {ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE},
- {ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION},
- {ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION},
- {ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE},
- {ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED},
- {ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED},
- {ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND},
- {ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR},
- {ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT},
- {ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH},
- {ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT},
- {ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH},
- {ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA},
- {ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID},
- {ERRSRV, 2242, NT_STATUS_PASSWORD_MUST_CHANGE},
- {ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND},
- {ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM},
- {ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE},
- {ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ},
- {ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK},
- {ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID},
- {ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS},
- {ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE},
- {ERRHRD, ERRgeneral, NT_STATUS_RETRY},
- {ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE},
- {ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET},
- {ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND},
- {ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT},
- {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND},
- {ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT},
- {ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE},
- {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED},
- {ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT},
- {ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
- {ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED},
- {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID},
- {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE},
- {ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE},
- {ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE},
- {ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE},
- {ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE},
- {ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED},
- {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER},
- {ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE},
- {ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED},
- {ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET},
- {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT},
- {ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION},
- {ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION},
- {ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000024a)},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000024b)},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000024c)},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000024d)},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000024e)},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000024f)},
- {ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT},
- {ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT},
- {ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST},
- {ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1},
- {ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2},
- {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT},
- {ERRSRV, ERRbadtype, NT_STATUS_PATH_NOT_COVERED},
- {ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE},
- {ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED},
- {ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT},
- {ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT},
- {ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000025d)},
- {ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE},
- {ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE},
- {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH},
- {ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND},
- {ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND},
- {ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED},
- {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LINKS},
- {ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT},
- {ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE},
- {ERRDOS, 21, NT_STATUS(0xc000026e)},
- {ERRDOS, 161, NT_STATUS(0xc0000281)},
- {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028a)},
- {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028b)},
- {ERRHRD, ERRgeneral, NT_STATUS(0xc000028c)},
- {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028d)},
- {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028e)},
- {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028f)},
- {ERRDOS, ERRnoaccess, NT_STATUS(0xc0000290)},
- {ERRDOS, ERRbadfunc, NT_STATUS(0xc000029c)},
-};
-
-
/* dos -> nt status error map */
static const struct {
uint8 dos_class;
@@ -879,555 +285,6 @@ static const struct {
{ERRHRD, 1022, NT_STATUS(0x0000010c)},
};
-/* errmap NTSTATUS->Win32 */
-static const struct {
- NTSTATUS ntstatus;
- WERROR werror;
-} ntstatus_to_werror_map[] = {
- {NT_STATUS(0x103), W_ERROR(0x3e5)},
- {NT_STATUS(0x105), W_ERROR(0xea)},
- {NT_STATUS(0x106), W_ERROR(0x514)},
- {NT_STATUS(0x107), W_ERROR(0x515)},
- {NT_STATUS(0x10c), W_ERROR(0x3fe)},
- {NT_STATUS(0x10d), W_ERROR(0x516)},
- {NT_STATUS(0x121), W_ERROR(0x2009)},
- {NT_STATUS(0xc0000001), W_ERROR(0x1f)},
- {NT_STATUS(0xc0000002), W_ERROR(0x1)},
- {NT_STATUS(0xc0000003), W_ERROR(0x57)},
- {NT_STATUS(0xc0000004), W_ERROR(0x18)},
- {NT_STATUS(0xc0000005), W_ERROR(0x3e6)},
- {NT_STATUS(0xc0000006), W_ERROR(0x3e7)},
- {NT_STATUS(0xc0000007), W_ERROR(0x5ae)},
- {NT_STATUS(0xc0000008), W_ERROR(0x6)},
- {NT_STATUS(0xc0000009), W_ERROR(0x3e9)},
- {NT_STATUS(0xc000000a), W_ERROR(0xc1)},
- {NT_STATUS(0xc000000b), W_ERROR(0x57)},
- {NT_STATUS(0xc000000d), W_ERROR(0x57)},
- {NT_STATUS(0xc000000e), W_ERROR(0x2)},
- {NT_STATUS(0xc000000f), W_ERROR(0x2)},
- {NT_STATUS(0xc0000010), W_ERROR(0x1)},
- {NT_STATUS(0xc0000011), W_ERROR(0x26)},
- {NT_STATUS(0xc0000012), W_ERROR(0x22)},
- {NT_STATUS(0xc0000013), W_ERROR(0x15)},
- {NT_STATUS(0xc0000014), W_ERROR(0x6f9)},
- {NT_STATUS(0xc0000015), W_ERROR(0x1b)},
- {NT_STATUS(0xc0000016), W_ERROR(0xea)},
- {NT_STATUS(0xc0000017), W_ERROR(0x8)},
- {NT_STATUS(0xc0000018), W_ERROR(0x1e7)},
- {NT_STATUS(0xc0000019), W_ERROR(0x1e7)},
- {NT_STATUS(0xc000001a), W_ERROR(0x57)},
- {NT_STATUS(0xc000001b), W_ERROR(0x57)},
- {NT_STATUS(0xc000001c), W_ERROR(0x1)},
- {NT_STATUS(0xc000001d), W_ERROR(0xc000001d)},
- {NT_STATUS(0xc000001e), W_ERROR(0x5)},
- {NT_STATUS(0xc000001f), W_ERROR(0x5)},
- {NT_STATUS(0xc0000020), W_ERROR(0xc1)},
- {NT_STATUS(0xc0000021), W_ERROR(0x5)},
- {NT_STATUS(0xc0000022), W_ERROR(0x5)},
- {NT_STATUS(0xc0000023), W_ERROR(0x7a)},
- {NT_STATUS(0xc0000024), W_ERROR(0x6)},
- {NT_STATUS(0xc0000025), W_ERROR(0xc0000025)},
- {NT_STATUS(0xc0000026), W_ERROR(0xc0000026)},
- {NT_STATUS(0xc000002a), W_ERROR(0x9e)},
- {NT_STATUS(0xc000002b), W_ERROR(0xc000002b)},
- {NT_STATUS(0xc000002c), W_ERROR(0x1e7)},
- {NT_STATUS(0xc000002d), W_ERROR(0x1e7)},
- {NT_STATUS(0xc0000030), W_ERROR(0x57)},
- {NT_STATUS(0xc0000032), W_ERROR(0x571)},
- {NT_STATUS(0xc0000033), W_ERROR(0x7b)},
- {NT_STATUS(0xc0000034), W_ERROR(0x2)},
- {NT_STATUS(0xc0000035), W_ERROR(0xb7)},
- {NT_STATUS(0xc0000037), W_ERROR(0x6)},
- {NT_STATUS(0xc0000039), W_ERROR(0xa1)},
- {NT_STATUS(0xc000003a), W_ERROR(0x3)},
- {NT_STATUS(0xc000003b), W_ERROR(0xa1)},
- {NT_STATUS(0xc000003c), W_ERROR(0x45d)},
- {NT_STATUS(0xc000003d), W_ERROR(0x45d)},
- {NT_STATUS(0xc000003e), W_ERROR(0x17)},
- {NT_STATUS(0xc000003f), W_ERROR(0x17)},
- {NT_STATUS(0xc0000040), W_ERROR(0x8)},
- {NT_STATUS(0xc0000041), W_ERROR(0x5)},
- {NT_STATUS(0xc0000042), W_ERROR(0x6)},
- {NT_STATUS(0xc0000043), W_ERROR(0x20)},
- {NT_STATUS(0xc0000044), W_ERROR(0x718)},
- {NT_STATUS(0xc0000045), W_ERROR(0x57)},
- {NT_STATUS(0xc0000046), W_ERROR(0x120)},
- {NT_STATUS(0xc0000047), W_ERROR(0x12a)},
- {NT_STATUS(0xc0000048), W_ERROR(0x57)},
- {NT_STATUS(0xc0000049), W_ERROR(0x57)},
- {NT_STATUS(0xc000004a), W_ERROR(0x9c)},
- {NT_STATUS(0xc000004b), W_ERROR(0x5)},
- {NT_STATUS(0xc000004c), W_ERROR(0x57)},
- {NT_STATUS(0xc000004d), W_ERROR(0x57)},
- {NT_STATUS(0xc000004e), W_ERROR(0x57)},
- {NT_STATUS(0xc000004f), W_ERROR(0x11a)},
- {NT_STATUS(0xc0000050), W_ERROR(0xff)},
- {NT_STATUS(0xc0000051), W_ERROR(0x570)},
- {NT_STATUS(0xc0000052), W_ERROR(0x570)},
- {NT_STATUS(0xc0000053), W_ERROR(0x570)},
- {NT_STATUS(0xc0000054), W_ERROR(0x21)},
- {NT_STATUS(0xc0000055), W_ERROR(0x21)},
- {NT_STATUS(0xc0000056), W_ERROR(0x5)},
- {NT_STATUS(0xc0000057), W_ERROR(0x32)},
- {NT_STATUS(0xc0000058), W_ERROR(0x519)},
- {NT_STATUS(0xc0000059), W_ERROR(0x51a)},
- {NT_STATUS(0xc000005a), W_ERROR(0x51b)},
- {NT_STATUS(0xc000005b), W_ERROR(0x51c)},
- {NT_STATUS(0xc000005c), W_ERROR(0x51d)},
- {NT_STATUS(0xc000005d), W_ERROR(0x51e)},
- {NT_STATUS(0xc000005e), W_ERROR(0x51f)},
- {NT_STATUS(0xc000005f), W_ERROR(0x520)},
- {NT_STATUS(0xc0000060), W_ERROR(0x521)},
- {NT_STATUS(0xc0000061), W_ERROR(0x522)},
- {NT_STATUS(0xc0000062), W_ERROR(0x523)},
- {NT_STATUS(0xc0000063), W_ERROR(0x524)},
- {NT_STATUS(0xc0000064), W_ERROR(0x525)},
- {NT_STATUS(0xc0000065), W_ERROR(0x526)},
- {NT_STATUS(0xc0000066), W_ERROR(0x527)},
- {NT_STATUS(0xc0000067), W_ERROR(0x528)},
- {NT_STATUS(0xc0000068), W_ERROR(0x529)},
- {NT_STATUS(0xc0000069), W_ERROR(0x52a)},
- {NT_STATUS(0xc000006a), W_ERROR(0x56)},
- {NT_STATUS(0xc000006b), W_ERROR(0x52c)},
- {NT_STATUS(0xc000006c), W_ERROR(0x52d)},
- {NT_STATUS(0xc000006d), W_ERROR(0x52e)},
- {NT_STATUS(0xc000006e), W_ERROR(0x52f)},
- {NT_STATUS(0xc000006f), W_ERROR(0x530)},
- {NT_STATUS(0xc0000070), W_ERROR(0x531)},
- {NT_STATUS(0xc0000071), W_ERROR(0x532)},
- {NT_STATUS(0xc0000072), W_ERROR(0x533)},
- {NT_STATUS(0xc0000073), W_ERROR(0x534)},
- {NT_STATUS(0xc0000074), W_ERROR(0x535)},
- {NT_STATUS(0xc0000075), W_ERROR(0x536)},
- {NT_STATUS(0xc0000076), W_ERROR(0x537)},
- {NT_STATUS(0xc0000077), W_ERROR(0x538)},
- {NT_STATUS(0xc0000078), W_ERROR(0x539)},
- {NT_STATUS(0xc0000079), W_ERROR(0x53a)},
- {NT_STATUS(0xc000007a), W_ERROR(0x7f)},
- {NT_STATUS(0xc000007b), W_ERROR(0xc1)},
- {NT_STATUS(0xc000007c), W_ERROR(0x3f0)},
- {NT_STATUS(0xc000007d), W_ERROR(0x53c)},
- {NT_STATUS(0xc000007e), W_ERROR(0x9e)},
- {NT_STATUS(0xc000007f), W_ERROR(0x70)},
- {NT_STATUS(0xc0000080), W_ERROR(0x53d)},
- {NT_STATUS(0xc0000081), W_ERROR(0x53e)},
- {NT_STATUS(0xc0000082), W_ERROR(0x44)},
- {NT_STATUS(0xc0000083), W_ERROR(0x103)},
- {NT_STATUS(0xc0000084), W_ERROR(0x53f)},
- {NT_STATUS(0xc0000085), W_ERROR(0x103)},
- {NT_STATUS(0xc0000086), W_ERROR(0x9a)},
- {NT_STATUS(0xc0000087), W_ERROR(0xe)},
- {NT_STATUS(0xc0000088), W_ERROR(0x1e7)},
- {NT_STATUS(0xc0000089), W_ERROR(0x714)},
- {NT_STATUS(0xc000008a), W_ERROR(0x715)},
- {NT_STATUS(0xc000008b), W_ERROR(0x716)},
- {NT_STATUS(0xc000008c), W_ERROR(0xc000008c)},
- {NT_STATUS(0xc000008d), W_ERROR(0xc000008d)},
- {NT_STATUS(0xc000008e), W_ERROR(0xc000008e)},
- {NT_STATUS(0xc000008f), W_ERROR(0xc000008f)},
- {NT_STATUS(0xc0000090), W_ERROR(0xc0000090)},
- {NT_STATUS(0xc0000091), W_ERROR(0xc0000091)},
- {NT_STATUS(0xc0000092), W_ERROR(0xc0000092)},
- {NT_STATUS(0xc0000093), W_ERROR(0xc0000093)},
- {NT_STATUS(0xc0000094), W_ERROR(0xc0000094)},
- {NT_STATUS(0xc0000095), W_ERROR(0x216)},
- {NT_STATUS(0xc0000096), W_ERROR(0xc0000096)},
- {NT_STATUS(0xc0000097), W_ERROR(0x8)},
- {NT_STATUS(0xc0000098), W_ERROR(0x3ee)},
- {NT_STATUS(0xc0000099), W_ERROR(0x540)},
- {NT_STATUS(0xc000009a), W_ERROR(0x5aa)},
- {NT_STATUS(0xc000009b), W_ERROR(0x3)},
- {NT_STATUS(0xc000009c), W_ERROR(0x17)},
- {NT_STATUS(0xc000009d), W_ERROR(0x48f)},
- {NT_STATUS(0xc000009e), W_ERROR(0x15)},
- {NT_STATUS(0xc000009f), W_ERROR(0x1e7)},
- {NT_STATUS(0xc00000a0), W_ERROR(0x1e7)},
- {NT_STATUS(0xc00000a1), W_ERROR(0x5ad)},
- {NT_STATUS(0xc00000a2), W_ERROR(0x13)},
- {NT_STATUS(0xc00000a3), W_ERROR(0x15)},
- {NT_STATUS(0xc00000a4), W_ERROR(0x541)},
- {NT_STATUS(0xc00000a5), W_ERROR(0x542)},
- {NT_STATUS(0xc00000a6), W_ERROR(0x543)},
- {NT_STATUS(0xc00000a7), W_ERROR(0x544)},
- {NT_STATUS(0xc00000a8), W_ERROR(0x545)},
- {NT_STATUS(0xc00000a9), W_ERROR(0x57)},
- {NT_STATUS(0xc00000ab), W_ERROR(0xe7)},
- {NT_STATUS(0xc00000ac), W_ERROR(0xe7)},
- {NT_STATUS(0xc00000ad), W_ERROR(0xe6)},
- {NT_STATUS(0xc00000ae), W_ERROR(0xe7)},
- {NT_STATUS(0xc00000af), W_ERROR(0x1)},
- {NT_STATUS(0xc00000b0), W_ERROR(0xe9)},
- {NT_STATUS(0xc00000b1), W_ERROR(0xe8)},
- {NT_STATUS(0xc00000b2), W_ERROR(0x217)},
- {NT_STATUS(0xc00000b3), W_ERROR(0x218)},
- {NT_STATUS(0xc00000b4), W_ERROR(0xe6)},
- {NT_STATUS(0xc00000b5), W_ERROR(0x79)},
- {NT_STATUS(0xc00000b6), W_ERROR(0x26)},
- {NT_STATUS(0xc00000ba), W_ERROR(0x5)},
- {NT_STATUS(0xc00000bb), W_ERROR(0x32)},
- {NT_STATUS(0xc00000bc), W_ERROR(0x33)},
- {NT_STATUS(0xc00000bd), W_ERROR(0x34)},
- {NT_STATUS(0xc00000be), W_ERROR(0x35)},
- {NT_STATUS(0xc00000bf), W_ERROR(0x36)},
- {NT_STATUS(0xc00000c0), W_ERROR(0x37)},
- {NT_STATUS(0xc00000c1), W_ERROR(0x38)},
- {NT_STATUS(0xc00000c2), W_ERROR(0x39)},
- {NT_STATUS(0xc00000c3), W_ERROR(0x3a)},
- {NT_STATUS(0xc00000c4), W_ERROR(0x3b)},
- {NT_STATUS(0xc00000c5), W_ERROR(0x3c)},
- {NT_STATUS(0xc00000c6), W_ERROR(0x3d)},
- {NT_STATUS(0xc00000c7), W_ERROR(0x3e)},
- {NT_STATUS(0xc00000c8), W_ERROR(0x3f)},
- {NT_STATUS(0xc00000c9), W_ERROR(0x40)},
- {NT_STATUS(0xc00000ca), W_ERROR(0x41)},
- {NT_STATUS(0xc00000cb), W_ERROR(0x42)},
- {NT_STATUS(0xc00000cc), W_ERROR(0x43)},
- {NT_STATUS(0xc00000cd), W_ERROR(0x44)},
- {NT_STATUS(0xc00000ce), W_ERROR(0x45)},
- {NT_STATUS(0xc00000cf), W_ERROR(0x46)},
- {NT_STATUS(0xc00000d0), W_ERROR(0x47)},
- {NT_STATUS(0xc00000d1), W_ERROR(0x48)},
- {NT_STATUS(0xc00000d2), W_ERROR(0x58)},
- {NT_STATUS(0xc00000d4), W_ERROR(0x11)},
- {NT_STATUS(0xc00000d5), W_ERROR(0x5)},
- {NT_STATUS(0xc00000d6), W_ERROR(0xf0)},
- {NT_STATUS(0xc00000d7), W_ERROR(0x546)},
- {NT_STATUS(0xc00000d9), W_ERROR(0xe8)},
- {NT_STATUS(0xc00000da), W_ERROR(0x547)},
- {NT_STATUS(0xc00000dc), W_ERROR(0x548)},
- {NT_STATUS(0xc00000dd), W_ERROR(0x549)},
- {NT_STATUS(0xc00000de), W_ERROR(0x54a)},
- {NT_STATUS(0xc00000df), W_ERROR(0x54b)},
- {NT_STATUS(0xc00000e0), W_ERROR(0x54c)},
- {NT_STATUS(0xc00000e1), W_ERROR(0x54d)},
- {NT_STATUS(0xc00000e2), W_ERROR(0x12c)},
- {NT_STATUS(0xc00000e3), W_ERROR(0x12d)},
- {NT_STATUS(0xc00000e4), W_ERROR(0x54e)},
- {NT_STATUS(0xc00000e5), W_ERROR(0x54f)},
- {NT_STATUS(0xc00000e6), W_ERROR(0x550)},
- {NT_STATUS(0xc00000e7), W_ERROR(0x551)},
- {NT_STATUS(0xc00000e8), W_ERROR(0x6f8)},
- {NT_STATUS(0xc00000ed), W_ERROR(0x552)},
- {NT_STATUS(0xc00000ee), W_ERROR(0x553)},
- {NT_STATUS(0xc00000ef), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f0), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f1), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f2), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f3), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f4), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f5), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f6), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f7), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f8), W_ERROR(0x57)},
- {NT_STATUS(0xc00000f9), W_ERROR(0x57)},
- {NT_STATUS(0xc00000fa), W_ERROR(0x57)},
- {NT_STATUS(0xc00000fb), W_ERROR(0x3)},
- {NT_STATUS(0xc00000fd), W_ERROR(0x3e9)},
- {NT_STATUS(0xc00000fe), W_ERROR(0x554)},
- {NT_STATUS(0xc0000100), W_ERROR(0xcb)},
- {NT_STATUS(0xc0000101), W_ERROR(0x91)},
- {NT_STATUS(0xc0000102), W_ERROR(0x570)},
- {NT_STATUS(0xc0000103), W_ERROR(0x10b)},
- {NT_STATUS(0xc0000104), W_ERROR(0x555)},
- {NT_STATUS(0xc0000105), W_ERROR(0x556)},
- {NT_STATUS(0xc0000106), W_ERROR(0xce)},
- {NT_STATUS(0xc0000107), W_ERROR(0x961)},
- {NT_STATUS(0xc0000108), W_ERROR(0x964)},
- {NT_STATUS(0xc000010a), W_ERROR(0x5)},
- {NT_STATUS(0xc000010b), W_ERROR(0x557)},
- {NT_STATUS(0xc000010d), W_ERROR(0x558)},
- {NT_STATUS(0xc000010e), W_ERROR(0x420)},
- {NT_STATUS(0xc0000117), W_ERROR(0x5a4)},
- {NT_STATUS(0xc000011b), W_ERROR(0xc1)},
- {NT_STATUS(0xc000011c), W_ERROR(0x559)},
- {NT_STATUS(0xc000011d), W_ERROR(0x55a)},
- {NT_STATUS(0xc000011e), W_ERROR(0x3ee)},
- {NT_STATUS(0xc000011f), W_ERROR(0x4)},
- {NT_STATUS(0xc0000120), W_ERROR(0x3e3)},
- {NT_STATUS(0xc0000121), W_ERROR(0x5)},
- {NT_STATUS(0xc0000122), W_ERROR(0x4ba)},
- {NT_STATUS(0xc0000123), W_ERROR(0x5)},
- {NT_STATUS(0xc0000124), W_ERROR(0x55b)},
- {NT_STATUS(0xc0000125), W_ERROR(0x55c)},
- {NT_STATUS(0xc0000126), W_ERROR(0x55d)},
- {NT_STATUS(0xc0000127), W_ERROR(0x55e)},
- {NT_STATUS(0xc0000128), W_ERROR(0x6)},
- {NT_STATUS(0xc000012b), W_ERROR(0x55f)},
- {NT_STATUS(0xc000012d), W_ERROR(0x5af)},
- {NT_STATUS(0xc000012e), W_ERROR(0xc1)},
- {NT_STATUS(0xc000012f), W_ERROR(0xc1)},
- {NT_STATUS(0xc0000130), W_ERROR(0xc1)},
- {NT_STATUS(0xc0000131), W_ERROR(0xc1)},
- {NT_STATUS(0xc0000133), W_ERROR(0x576)},
- {NT_STATUS(0xc0000135), W_ERROR(0x7e)},
- {NT_STATUS(0xc0000138), W_ERROR(0xb6)},
- {NT_STATUS(0xc0000139), W_ERROR(0x7f)},
- {NT_STATUS(0xc000013b), W_ERROR(0x40)},
- {NT_STATUS(0xc000013c), W_ERROR(0x40)},
- {NT_STATUS(0xc000013d), W_ERROR(0x33)},
- {NT_STATUS(0xc000013e), W_ERROR(0x3b)},
- {NT_STATUS(0xc000013f), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000140), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000141), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000142), W_ERROR(0x45a)},
- {NT_STATUS(0xc0000148), W_ERROR(0x7c)},
- {NT_STATUS(0xc0000149), W_ERROR(0x56)},
- {NT_STATUS(0xc000014b), W_ERROR(0x6d)},
- {NT_STATUS(0xc000014c), W_ERROR(0x3f1)},
- {NT_STATUS(0xc000014d), W_ERROR(0x3f8)},
- {NT_STATUS(0xc000014f), W_ERROR(0x3ed)},
- {NT_STATUS(0xc0000150), W_ERROR(0x45e)},
- {NT_STATUS(0xc0000151), W_ERROR(0x560)},
- {NT_STATUS(0xc0000152), W_ERROR(0x561)},
- {NT_STATUS(0xc0000153), W_ERROR(0x562)},
- {NT_STATUS(0xc0000154), W_ERROR(0x563)},
- {NT_STATUS(0xc0000155), W_ERROR(0x564)},
- {NT_STATUS(0xc0000156), W_ERROR(0x565)},
- {NT_STATUS(0xc0000157), W_ERROR(0x566)},
- {NT_STATUS(0xc0000158), W_ERROR(0x567)},
- {NT_STATUS(0xc0000159), W_ERROR(0x3ef)},
- {NT_STATUS(0xc000015a), W_ERROR(0x568)},
- {NT_STATUS(0xc000015b), W_ERROR(0x569)},
- {NT_STATUS(0xc000015c), W_ERROR(0x3f9)},
- {NT_STATUS(0xc000015d), W_ERROR(0x56a)},
- {NT_STATUS(0xc000015f), W_ERROR(0x45d)},
- {NT_STATUS(0xc0000162), W_ERROR(0x459)},
- {NT_STATUS(0xc0000165), W_ERROR(0x462)},
- {NT_STATUS(0xc0000166), W_ERROR(0x463)},
- {NT_STATUS(0xc0000167), W_ERROR(0x464)},
- {NT_STATUS(0xc0000168), W_ERROR(0x465)},
- {NT_STATUS(0xc0000169), W_ERROR(0x466)},
- {NT_STATUS(0xc000016a), W_ERROR(0x467)},
- {NT_STATUS(0xc000016b), W_ERROR(0x468)},
- {NT_STATUS(0xc000016c), W_ERROR(0x45f)},
- {NT_STATUS(0xc000016d), W_ERROR(0x45d)},
- {NT_STATUS(0xc0000172), W_ERROR(0x451)},
- {NT_STATUS(0xc0000173), W_ERROR(0x452)},
- {NT_STATUS(0xc0000174), W_ERROR(0x453)},
- {NT_STATUS(0xc0000175), W_ERROR(0x454)},
- {NT_STATUS(0xc0000176), W_ERROR(0x455)},
- {NT_STATUS(0xc0000177), W_ERROR(0x469)},
- {NT_STATUS(0xc0000178), W_ERROR(0x458)},
- {NT_STATUS(0xc000017a), W_ERROR(0x56b)},
- {NT_STATUS(0xc000017b), W_ERROR(0x56c)},
- {NT_STATUS(0xc000017c), W_ERROR(0x3fa)},
- {NT_STATUS(0xc000017d), W_ERROR(0x3fb)},
- {NT_STATUS(0xc000017e), W_ERROR(0x56d)},
- {NT_STATUS(0xc000017f), W_ERROR(0x56e)},
- {NT_STATUS(0xc0000180), W_ERROR(0x3fc)},
- {NT_STATUS(0xc0000181), W_ERROR(0x3fd)},
- {NT_STATUS(0xc0000182), W_ERROR(0x57)},
- {NT_STATUS(0xc0000183), W_ERROR(0x45d)},
- {NT_STATUS(0xc0000184), W_ERROR(0x16)},
- {NT_STATUS(0xc0000185), W_ERROR(0x45d)},
- {NT_STATUS(0xc0000186), W_ERROR(0x45d)},
- {NT_STATUS(0xc0000188), W_ERROR(0x5de)},
- {NT_STATUS(0xc0000189), W_ERROR(0x13)},
- {NT_STATUS(0xc000018a), W_ERROR(0x6fa)},
- {NT_STATUS(0xc000018b), W_ERROR(0x6fb)},
- {NT_STATUS(0xc000018c), W_ERROR(0x6fc)},
- {NT_STATUS(0xc000018d), W_ERROR(0x6fd)},
- {NT_STATUS(0xc000018e), W_ERROR(0x5dc)},
- {NT_STATUS(0xc000018f), W_ERROR(0x5dd)},
- {NT_STATUS(0xc0000190), W_ERROR(0x6fe)},
- {NT_STATUS(0xc0000192), W_ERROR(0x700)},
- {NT_STATUS(0xc0000193), W_ERROR(0x701)},
- {NT_STATUS(0xc0000194), W_ERROR(0x46b)},
- {NT_STATUS(0xc0000195), W_ERROR(0x4c3)},
- {NT_STATUS(0xc0000196), W_ERROR(0x4c4)},
- {NT_STATUS(0xc0000197), W_ERROR(0x5df)},
- {NT_STATUS(0xc0000198), W_ERROR(0x70f)},
- {NT_STATUS(0xc0000199), W_ERROR(0x710)},
- {NT_STATUS(0xc000019a), W_ERROR(0x711)},
- {NT_STATUS(0xc000019b), W_ERROR(0x712)},
- {NT_STATUS(0xc0000202), W_ERROR(0x572)},
- {NT_STATUS(0xc0000203), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000204), W_ERROR(0x717)},
- {NT_STATUS(0xc0000205), W_ERROR(0x46a)},
- {NT_STATUS(0xc0000206), W_ERROR(0x6f8)},
- {NT_STATUS(0xc0000207), W_ERROR(0x4be)},
- {NT_STATUS(0xc0000208), W_ERROR(0x4be)},
- {NT_STATUS(0xc0000209), W_ERROR(0x44)},
- {NT_STATUS(0xc000020a), W_ERROR(0x34)},
- {NT_STATUS(0xc000020b), W_ERROR(0x40)},
- {NT_STATUS(0xc000020c), W_ERROR(0x40)},
- {NT_STATUS(0xc000020d), W_ERROR(0x40)},
- {NT_STATUS(0xc000020e), W_ERROR(0x44)},
- {NT_STATUS(0xc000020f), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000210), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000211), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000212), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000213), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000214), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000215), W_ERROR(0x3b)},
- {NT_STATUS(0xc0000216), W_ERROR(0x32)},
- {NT_STATUS(0xc0000217), W_ERROR(0x32)},
- {NT_STATUS(0xc000021c), W_ERROR(0x17e6)},
- {NT_STATUS(0xc0000220), W_ERROR(0x46c)},
- {NT_STATUS(0xc0000221), W_ERROR(0xc1)},
- {NT_STATUS(0xc0000224), W_ERROR(0x773)},
- {NT_STATUS(0xc0000225), W_ERROR(0x490)},
- {NT_STATUS(0xc000022a), W_ERROR(0xc000022a)},
- {NT_STATUS(0xc000022b), W_ERROR(0xc000022b)},
- {NT_STATUS(0xc000022d), W_ERROR(0x4d5)},
- {NT_STATUS(0xc0000230), W_ERROR(0x492)},
- {NT_STATUS(0xc0000233), W_ERROR(0x774)},
- {NT_STATUS(0xc0000234), W_ERROR(0x775)},
- {NT_STATUS(0xc0000235), W_ERROR(0x6)},
- {NT_STATUS(0xc0000236), W_ERROR(0x4c9)},
- {NT_STATUS(0xc0000237), W_ERROR(0x4ca)},
- {NT_STATUS(0xc0000238), W_ERROR(0x4cb)},
- {NT_STATUS(0xc0000239), W_ERROR(0x4cc)},
- {NT_STATUS(0xc000023a), W_ERROR(0x4cd)},
- {NT_STATUS(0xc000023b), W_ERROR(0x4ce)},
- {NT_STATUS(0xc000023c), W_ERROR(0x4cf)},
- {NT_STATUS(0xc000023d), W_ERROR(0x4d0)},
- {NT_STATUS(0xc000023e), W_ERROR(0x4d1)},
- {NT_STATUS(0xc000023f), W_ERROR(0x4d2)},
- {NT_STATUS(0xc0000240), W_ERROR(0x4d3)},
- {NT_STATUS(0xc0000241), W_ERROR(0x4d4)},
- {NT_STATUS(0xc0000243), W_ERROR(0x4c8)},
- {NT_STATUS(0xc0000246), W_ERROR(0x4d6)},
- {NT_STATUS(0xc0000247), W_ERROR(0x4d7)},
- {NT_STATUS(0xc0000248), W_ERROR(0x4d8)},
- {NT_STATUS(0xc0000249), W_ERROR(0xc1)},
- {NT_STATUS(0xc0000253), W_ERROR(0x54f)},
- {NT_STATUS(0xc0000257), W_ERROR(0x4d0)},
- {NT_STATUS(0xc0000259), W_ERROR(0x573)},
- {NT_STATUS(0xc000025e), W_ERROR(0x422)},
- {NT_STATUS(0xc0000262), W_ERROR(0xb6)},
- {NT_STATUS(0xc0000263), W_ERROR(0x7f)},
- {NT_STATUS(0xc0000264), W_ERROR(0x120)},
- {NT_STATUS(0xc0000265), W_ERROR(0x476)},
- {NT_STATUS(0xc0000267), W_ERROR(0x10fe)},
- {NT_STATUS(0xc000026c), W_ERROR(0x7d1)},
- {NT_STATUS(0xc000026d), W_ERROR(0x4b1)},
- {NT_STATUS(0xc000026e), W_ERROR(0x15)},
- {NT_STATUS(0xc0000272), W_ERROR(0x491)},
- {NT_STATUS(0xc0000275), W_ERROR(0x1126)},
- {NT_STATUS(0xc0000276), W_ERROR(0x1129)},
- {NT_STATUS(0xc0000277), W_ERROR(0x112a)},
- {NT_STATUS(0xc0000278), W_ERROR(0x1128)},
- {NT_STATUS(0xc0000279), W_ERROR(0x780)},
- {NT_STATUS(0xc0000280), W_ERROR(0x781)},
- {NT_STATUS(0xc0000281), W_ERROR(0xa1)},
- {NT_STATUS(0xc0000283), W_ERROR(0x488)},
- {NT_STATUS(0xc0000284), W_ERROR(0x489)},
- {NT_STATUS(0xc0000285), W_ERROR(0x48a)},
- {NT_STATUS(0xc0000286), W_ERROR(0x48b)},
- {NT_STATUS(0xc0000287), W_ERROR(0x48c)},
- {NT_STATUS(0xc000028a), W_ERROR(0x5)},
- {NT_STATUS(0xc000028b), W_ERROR(0x5)},
- {NT_STATUS(0xc000028d), W_ERROR(0x5)},
- {NT_STATUS(0xc000028e), W_ERROR(0x5)},
- {NT_STATUS(0xc000028f), W_ERROR(0x5)},
- {NT_STATUS(0xc0000290), W_ERROR(0x5)},
- {NT_STATUS(0xc0000291), W_ERROR(0x1777)},
- {NT_STATUS(0xc0000292), W_ERROR(0x1778)},
- {NT_STATUS(0xc0000293), W_ERROR(0x1772)},
- {NT_STATUS(0xc0000295), W_ERROR(0x1068)},
- {NT_STATUS(0xc0000296), W_ERROR(0x1069)},
- {NT_STATUS(0xc0000297), W_ERROR(0x106a)},
- {NT_STATUS(0xc0000298), W_ERROR(0x106b)},
- {NT_STATUS(0xc0000299), W_ERROR(0x201a)},
- {NT_STATUS(0xc000029a), W_ERROR(0x201b)},
- {NT_STATUS(0xc000029b), W_ERROR(0x201c)},
- {NT_STATUS(0xc000029c), W_ERROR(0x1)},
- {NT_STATUS(0xc000029d), W_ERROR(0x10ff)},
- {NT_STATUS(0xc000029e), W_ERROR(0x1100)},
- {NT_STATUS(0xc000029f), W_ERROR(0x494)},
- {NT_STATUS(0xc00002a1), W_ERROR(0x200a)},
- {NT_STATUS(0xc00002a2), W_ERROR(0x200b)},
- {NT_STATUS(0xc00002a3), W_ERROR(0x200c)},
- {NT_STATUS(0xc00002a4), W_ERROR(0x200d)},
- {NT_STATUS(0xc00002a5), W_ERROR(0x200e)},
- {NT_STATUS(0xc00002a6), W_ERROR(0x200f)},
- {NT_STATUS(0xc00002a7), W_ERROR(0x2010)},
- {NT_STATUS(0xc00002a8), W_ERROR(0x2011)},
- {NT_STATUS(0xc00002a9), W_ERROR(0x2012)},
- {NT_STATUS(0xc00002aa), W_ERROR(0x2013)},
- {NT_STATUS(0xc00002ab), W_ERROR(0x2014)},
- {NT_STATUS(0xc00002ac), W_ERROR(0x2015)},
- {NT_STATUS(0xc00002ad), W_ERROR(0x2016)},
- {NT_STATUS(0xc00002ae), W_ERROR(0x2017)},
- {NT_STATUS(0xc00002af), W_ERROR(0x2018)},
- {NT_STATUS(0xc00002b0), W_ERROR(0x2019)},
- {NT_STATUS(0xc00002b1), W_ERROR(0x211e)},
- {NT_STATUS(0xc00002b2), W_ERROR(0x1127)},
- {NT_STATUS(0xc00002b6), W_ERROR(0x651)},
- {NT_STATUS(0xc00002b7), W_ERROR(0x49a)},
- {NT_STATUS(0xc00002b8), W_ERROR(0x49b)},
- {NT_STATUS(0xc00002c1), W_ERROR(0x2024)},
- {NT_STATUS(0xc00002c3), W_ERROR(0x575)},
- {NT_STATUS(0xc00002c5), W_ERROR(0x3e6)},
- {NT_STATUS(0xc00002c6), W_ERROR(0x1075)},
- {NT_STATUS(0xc00002c7), W_ERROR(0x1076)},
- {NT_STATUS(0xc00002ca), W_ERROR(0x10e8)},
- {NT_STATUS(0xc00002cb), W_ERROR(0x2138)},
- {NT_STATUS(0xc00002cc), W_ERROR(0x4e3)},
- {NT_STATUS(0xc00002cd), W_ERROR(0x2139)},
- {NT_STATUS(0xc00002cf), W_ERROR(0x49d)},
- {NT_STATUS(0xc00002d0), W_ERROR(0x213a)},
- {NT_STATUS(0xc00002d4), W_ERROR(0x2141)},
- {NT_STATUS(0xc00002d5), W_ERROR(0x2142)},
- {NT_STATUS(0xc00002d6), W_ERROR(0x2143)},
- {NT_STATUS(0xc00002d7), W_ERROR(0x2144)},
- {NT_STATUS(0xc00002d8), W_ERROR(0x2145)},
- {NT_STATUS(0xc00002d9), W_ERROR(0x2146)},
- {NT_STATUS(0xc00002da), W_ERROR(0x2147)},
- {NT_STATUS(0xc00002db), W_ERROR(0x2148)},
- {NT_STATUS(0xc00002dc), W_ERROR(0x2149)},
- {NT_STATUS(0xc00002dd), W_ERROR(0x32)},
- {NT_STATUS(0xc00002df), W_ERROR(0x2151)},
- {NT_STATUS(0xc00002e0), W_ERROR(0x2152)},
- {NT_STATUS(0xc00002e1), W_ERROR(0x2153)},
- {NT_STATUS(0xc00002e2), W_ERROR(0x2154)},
- {NT_STATUS(0xc00002e3), W_ERROR(0x215d)},
- {NT_STATUS(0xc00002e4), W_ERROR(0x2163)},
- {NT_STATUS(0xc00002e5), W_ERROR(0x2164)},
- {NT_STATUS(0xc00002e6), W_ERROR(0x2165)},
- {NT_STATUS(0xc00002e7), W_ERROR(0x216d)},
- {NT_STATUS(0xc00002fe), W_ERROR(0x45b)},
- {NT_STATUS(0xc00002ff), W_ERROR(0x4e7)},
- {NT_STATUS(0xc0000300), W_ERROR(0x4e6)},
- {NT_STATUS(0x80000001), W_ERROR(0x80000001)},
- {NT_STATUS(0x80000002), W_ERROR(0x3e6)},
- {NT_STATUS(0x80000003), W_ERROR(0x80000003)},
- {NT_STATUS(0x80000004), W_ERROR(0x80000004)},
- {NT_STATUS(0x80000005), W_ERROR(0xea)},
- {NT_STATUS(0x80000006), W_ERROR(0x12)},
- {NT_STATUS(0x8000000b), W_ERROR(0x56f)},
- {NT_STATUS(0x8000000d), W_ERROR(0x12b)},
- {NT_STATUS(0x8000000e), W_ERROR(0x1c)},
- {NT_STATUS(0x8000000f), W_ERROR(0x15)},
- {NT_STATUS(0x80000010), W_ERROR(0x15)},
- {NT_STATUS(0x80000011), W_ERROR(0xaa)},
- {NT_STATUS(0x80000012), W_ERROR(0x103)},
- {NT_STATUS(0x80000013), W_ERROR(0xfe)},
- {NT_STATUS(0x80000014), W_ERROR(0xff)},
- {NT_STATUS(0x80000015), W_ERROR(0xff)},
- {NT_STATUS(0x80000016), W_ERROR(0x456)},
- {NT_STATUS(0x8000001a), W_ERROR(0x103)},
- {NT_STATUS(0x8000001b), W_ERROR(0x44d)},
- {NT_STATUS(0x8000001c), W_ERROR(0x456)},
- {NT_STATUS(0x8000001d), W_ERROR(0x457)},
- {NT_STATUS(0x8000001e), W_ERROR(0x44c)},
- {NT_STATUS(0x8000001f), W_ERROR(0x44e)},
- {NT_STATUS(0x80000021), W_ERROR(0x44f)},
- {NT_STATUS(0x80000022), W_ERROR(0x450)},
- {NT_STATUS(0x80000025), W_ERROR(0x962)},
- {NT_STATUS(0x80000288), W_ERROR(0x48d)},
- {NT_STATUS(0x80000289), W_ERROR(0x48e)},
- {NT_STATUS_OK, WERR_OK}};
-
-static const struct {
- WERROR werror;
- NTSTATUS ntstatus;
-} werror_to_ntstatus_map[] = {
- { W_ERROR(0x5), NT_STATUS_ACCESS_DENIED },
- { WERR_OK, NT_STATUS_OK }
-};
-
/*****************************************************************************
convert a dos eclas/ecode to a NT status32 code
*****************************************************************************/
@@ -1444,76 +301,6 @@ NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode)
return NT_STATUS_UNSUCCESSFUL;
}
-
-/*****************************************************************************
-convert a NT status code to a dos class/code
- *****************************************************************************/
-void ntstatus_to_dos(NTSTATUS ntstatus, uint8 *eclass, uint32 *ecode)
-{
- int i;
- if (NT_STATUS_IS_OK(ntstatus)) {
- *eclass = 0;
- *ecode = 0;
- return;
- }
- for (i=0; NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus); i++) {
- if (NT_STATUS_V(ntstatus) ==
- NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus)) {
- *eclass = ntstatus_to_dos_map[i].dos_class;
- *ecode = ntstatus_to_dos_map[i].dos_code;
- return;
- }
- }
- *eclass = ERRHRD;
- *ecode = ERRgeneral;
-}
-
-
-/*****************************************************************************
-convert a WERROR to a NT status32 code
- *****************************************************************************/
-NTSTATUS werror_to_ntstatus(WERROR error)
-{
- int i;
- if (W_ERROR_IS_OK(error)) return NT_STATUS_OK;
-
- for (i=0; !W_ERROR_IS_OK(werror_to_ntstatus_map[i].werror); i++) {
- if (W_ERROR_V(error) ==
- W_ERROR_V(werror_to_ntstatus_map[i].werror)) {
- return werror_to_ntstatus_map[i].ntstatus;
- }
- }
-
- for (i=0; NT_STATUS_V(ntstatus_to_werror_map[i].ntstatus); i++) {
- if (W_ERROR_V(error) ==
- W_ERROR_V(ntstatus_to_werror_map[i].werror)) {
- return ntstatus_to_werror_map[i].ntstatus;
- }
- }
-
- /* just guess ... */
- return NT_STATUS(W_ERROR_V(error) | 0xc0000000);
-}
-
-/*****************************************************************************
-convert a NTSTATUS to a WERROR
- *****************************************************************************/
-WERROR ntstatus_to_werror(NTSTATUS error)
-{
- int i;
- if (NT_STATUS_IS_OK(error)) return WERR_OK;
- for (i=0; NT_STATUS_V(ntstatus_to_werror_map[i].ntstatus); i++) {
- if (NT_STATUS_V(error) ==
- NT_STATUS_V(ntstatus_to_werror_map[i].ntstatus)) {
- return ntstatus_to_werror_map[i].werror;
- }
- }
-
- /* a lame guess */
- return W_ERROR(NT_STATUS_V(error) & 0xffff);
-}
-
-
#if defined(HAVE_GSSAPI)
/*******************************************************************************
Map between gssapi errors and NT status. I made these up :-(. JRA.
diff --git a/source3/libsmb/errormap_wbc.h b/source3/libsmb/errormap_wbc.h
index 2042da4efca..6323deec1dd 100644
--- a/source3/libsmb/errormap_wbc.h
+++ b/source3/libsmb/errormap_wbc.h
@@ -1,3 +1,29 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * error mapping functions
+ * Copyright (C) Andrew Tridgell 2001
+ * Copyright (C) Andrew Bartlett 2001
+ * Copyright (C) Tim Potter 2000
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _LIBSMB_ERRORMAP_WBC_H_
+#define _LIBSMB_ERRORMAP_WBC_H_
+
/* The following definitions come from libsmb/errormap_wbc.c */
NTSTATUS map_nt_error_from_wbcErr(wbcErr wbc_err);
+
+#endif /* _LIBSMB_ERRORMAP_WBC_H_ */
diff --git a/source3/librpc/ndr/util.c b/source3/libsmb/libsmb.h
index 6bbe0549590..061f317e1e5 100644
--- a/source3/librpc/ndr/util.c
+++ b/source3/libsmb/libsmb.h
@@ -1,30 +1,30 @@
-/*
+/*
Unix SMB/CIFS implementation.
- libndr interface
+ Copyright (C) Andrew Tridgell 1992-1998,2001
+ Copyright (C) Jeremy Allison 1998
+ Copyright (C) Remus Koos 2001
+ Copyright (C) Andrew Bartlett 2001
- Copyright (C) Andrew Tridgell 2003
-
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "includes.h"
-#include "../librpc/ndr/libndr.h"
-#include "librpc/ndr/util.h"
+#ifndef _LIBSMB_LIBSMB_H
+#define _LIBSMB_LIBSMB_H
+
+#include "client.h"
+#include "libads/ads_status.h"
+#include "libsmb/proto.h"
-_PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss)
-{
- char addr[INET6_ADDRSTRLEN];
- ndr->print(ndr, "%-25s: %s", name, print_sockaddr(addr, sizeof(addr), ss));
-}
+#endif /* _LIBSMB_LIBSMB_H */
diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c
index f9770d363ca..598fa81376f 100644
--- a/source3/libsmb/libsmb_cache.c
+++ b/source3/libsmb/libsmb_cache.c
@@ -21,6 +21,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmbclient.h"
#include "libsmb_internal.h"
diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
index 9c8429aab47..dbf70e02c8d 100644
--- a/source3/libsmb/libsmb_context.c
+++ b/source3/libsmb/libsmb_context.c
@@ -23,6 +23,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmbclient.h"
#include "libsmb_internal.h"
#include "secrets.h"
@@ -456,11 +457,11 @@ smbc_option_get(SMBCCTX *context,
switch(smbc_getOptionSmbEncryptionLevel(context))
{
case 0:
- return (void *) "none";
+ return discard_const_p(void, "none");
case 1:
- return (void *) "request";
+ return discard_const_p(void, "request");
case 2:
- return (void *) "require";
+ return discard_const_p(void, "require");
}
} else if (strcmp(option_name, "smb_encrypt_on") == 0) {
@@ -598,8 +599,8 @@ smbc_init_context(SMBCCTX *context)
* our hostname etc
*/
char *netbios_name;
- if (global_myname()) {
- netbios_name = SMB_STRDUP(global_myname());
+ if (lp_netbios_name()) {
+ netbios_name = SMB_STRDUP(lp_netbios_name());
} else {
/*
* Hmmm, I want to get hostname as well, but I am too
@@ -749,6 +750,7 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context,
}
set_cmdline_auth_info_username(auth_info, user);
+ set_cmdline_auth_info_domain(auth_info, workgroup);
set_cmdline_auth_info_password(auth_info, password);
set_cmdline_auth_info_use_kerberos(auth_info, use_kerberos);
set_cmdline_auth_info_signing_state(auth_info, signing_state);
@@ -756,7 +758,6 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context,
smbc_getOptionFallbackAfterKerberos(context));
set_cmdline_auth_info_use_ccache(
auth_info, smbc_getOptionUseCCache(context));
- set_global_myworkgroup(workgroup);
TALLOC_FREE(context->internal->auth_info);
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index c0c6e83bb63..ea75dbf2649 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -23,6 +23,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "popt_common.h"
#include "libsmbclient.h"
#include "libsmb_internal.h"
@@ -245,7 +246,7 @@ dir_list_fn(const char *mnt,
{
if (add_dirent((SMBCFILE *)state, finfo->name, "",
- (finfo->mode&aDIR?SMBC_DIR:SMBC_FILE)) < 0) {
+ (finfo->mode&FILE_ATTRIBUTE_DIRECTORY?SMBC_DIR:SMBC_FILE)) < 0) {
SMBCFILE *dir = (SMBCFILE *)state;
return map_nt_error_from_unix(dir->dir_error);
}
@@ -456,9 +457,10 @@ SMBC_opendir_ctx(SMBCCTX *context,
int i;
int count;
int max_lmb_count;
- struct ip_service *ip_list;
- struct ip_service server_addr;
+ struct sockaddr_storage *ip_list;
+ struct sockaddr_storage server_addr;
struct user_auth_info u_info;
+ NTSTATUS status;
if (share[0] != (char)0 || path[0] != (char)0) {
@@ -498,13 +500,14 @@ SMBC_opendir_ctx(SMBCCTX *context,
*/
ip_list = NULL;
- if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list,
- &count)))
+ status = name_resolve_bcast(MSBROWSE, 1, talloc_tos(),
+ &ip_list, &count);
+ if (!NT_STATUS_IS_OK(status))
{
- SAFE_FREE(ip_list);
+ TALLOC_FREE(ip_list);
- if (!find_master_ip(workgroup, &server_addr.ss)) {
+ if (!find_master_ip(workgroup, &server_addr)) {
if (dir) {
SAFE_FREE(dir->fname);
@@ -515,8 +518,9 @@ SMBC_opendir_ctx(SMBCCTX *context,
return NULL;
}
- ip_list = (struct ip_service *)memdup(
- &server_addr, sizeof(server_addr));
+ ip_list = (struct sockaddr_storage *)talloc_memdup(
+ talloc_tos(), &server_addr,
+ sizeof(server_addr));
if (ip_list == NULL) {
if (dir) {
SAFE_FREE(dir->fname);
@@ -534,7 +538,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
char *wg_ptr = NULL;
struct cli_state *cli = NULL;
- print_sockaddr(addr, sizeof(addr), &ip_list[i].ss);
+ print_sockaddr(addr, sizeof(addr), &ip_list[i]);
DEBUG(99, ("Found master browser %d of %d: %s\n",
i+1, MAX(count, max_lmb_count),
addr));
@@ -594,7 +598,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
}
}
- SAFE_FREE(ip_list);
+ TALLOC_FREE(ip_list);
} else {
/*
* Server not an empty string ... Check the rest and see what
@@ -816,7 +820,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
}
status = cli_list(targetcli, targetpath,
- aDIR | aSYSTEM | aHIDDEN,
+ FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
dir_list_fn, (void *)dir);
if (!NT_STATUS_IS_OK(status)) {
if (dir) {
@@ -1345,7 +1349,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
}
status = cli_list(targetcli, lpath,
- aDIR | aSYSTEM | aHIDDEN,
+ FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
rmdir_list_fn,
&smbc_rmdir_dirempty);
@@ -1611,10 +1615,10 @@ SMBC_chmod_ctx(SMBCCTX *context,
mode = 0;
- if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= aRONLY;
- if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= aARCH;
- if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM;
- if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN;
+ if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= FILE_ATTRIBUTE_READONLY;
+ if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= FILE_ATTRIBUTE_ARCHIVE;
+ if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= FILE_ATTRIBUTE_SYSTEM;
+ if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= FILE_ATTRIBUTE_HIDDEN;
if (!NT_STATUS_IS_OK(cli_setatr(targetcli, targetpath, mode, 0))) {
errno = SMBC_errno(context, targetcli);
@@ -1803,7 +1807,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
}
/*d_printf(">>>unlink: resolved path as %s\n", targetpath);*/
- if (!NT_STATUS_IS_OK(cli_unlink(targetcli, targetpath, aSYSTEM | aHIDDEN))) {
+ if (!NT_STATUS_IS_OK(cli_unlink(targetcli, targetpath, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
errno = SMBC_errno(context, targetcli);
@@ -2009,7 +2013,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
int eno = SMBC_errno(ocontext, targetcli1);
if (eno != EEXIST ||
- !NT_STATUS_IS_OK(cli_unlink(targetcli1, targetpath2, aSYSTEM | aHIDDEN)) ||
+ !NT_STATUS_IS_OK(cli_unlink(targetcli1, targetpath2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN)) ||
!NT_STATUS_IS_OK(cli_rename(targetcli1, targetpath1, targetpath2))) {
errno = eno;
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index 58403dfbb36..c822eab7985 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -23,6 +23,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmbclient.h"
#include "libsmb_internal.h"
@@ -318,13 +319,13 @@ SMBC_write_ctx(SMBCCTX *context,
const void *buf,
size_t count)
{
- int ret;
off_t offset;
char *server = NULL, *share = NULL, *user = NULL, *password = NULL;
char *path = NULL;
char *targetpath = NULL;
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
/* First check all pointers before dereferencing them */
@@ -377,18 +378,18 @@ SMBC_write_ctx(SMBCCTX *context,
}
/*d_printf(">>>write: resolved path as %s\n", targetpath);*/
- ret = cli_write(targetcli, file->cli_fd,
- 0, (char *)buf, offset, count);
- if (ret <= 0) {
- errno = SMBC_errno(context, targetcli);
+ status = cli_writeall(targetcli, file->cli_fd,
+ 0, (const uint8_t *)buf, offset, count, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
TALLOC_FREE(frame);
return -1;
}
- file->offset += ret;
+ file->offset += count;
TALLOC_FREE(frame);
- return ret; /* Success, 0 bytes of data ... */
+ return count; /* Success, 0 bytes of data ... */
}
/*
@@ -480,7 +481,7 @@ SMBC_close_ctx(SMBCCTX *context,
bool
SMBC_getatr(SMBCCTX * context,
SMBCSRV *srv,
- char *path,
+ const char *path,
uint16 *mode,
SMB_OFF_T *size,
struct timespec *create_time_ts,
diff --git a/source3/libsmb/libsmb_misc.c b/source3/libsmb/libsmb_misc.c
index a6e96350f54..7808d8e4f0e 100644
--- a/source3/libsmb/libsmb_misc.c
+++ b/source3/libsmb/libsmb_misc.c
@@ -23,6 +23,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmbclient.h"
#include "libsmb_internal.h"
diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c
index 64a956d9ee4..1dcf2dd5167 100644
--- a/source3/libsmb/libsmb_path.c
+++ b/source3/libsmb/libsmb_path.c
@@ -88,7 +88,7 @@ urldecode_talloc(TALLOC_CTX *ctx, char **pp_dest, const char *src)
newlen++;
}
- dest = TALLOC_ARRAY(ctx, char, newlen);
+ dest = talloc_array(ctx, char, newlen);
if (!dest) {
return err_count;
}
diff --git a/source3/libsmb/libsmb_printjob.c b/source3/libsmb/libsmb_printjob.c
index ea0cb37a144..db46ceee9cb 100644
--- a/source3/libsmb/libsmb_printjob.c
+++ b/source3/libsmb/libsmb_printjob.c
@@ -23,6 +23,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmbclient.h"
#include "libsmb_internal.h"
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 961c9cde83e..755ef2d32b0 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -24,6 +24,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmbclient.h"
#include "libsmb_internal.h"
#include "../librpc/gen_ndr/ndr_lsa.h"
@@ -245,20 +246,14 @@ SMBC_server_internal(TALLOC_CTX *ctx,
{
SMBCSRV *srv=NULL;
char *workgroup = NULL;
- struct cli_state *c;
- struct nmb_name called, calling;
+ struct cli_state *c = NULL;
const char *server_n = server;
- struct sockaddr_storage ss;
- int tried_reverse = 0;
- int port_try_first;
- int port_try_next;
int is_ipc = (share != NULL && strcmp(share, "IPC$") == 0);
uint32 fs_attrs = 0;
const char *username_used;
NTSTATUS status;
char *newserver, *newshare;
- zero_sockaddr(&ss);
ZERO_STRUCT(c);
*in_cache = false;
@@ -392,20 +387,32 @@ SMBC_server_internal(TALLOC_CTX *ctx,
return NULL;
}
- make_nmb_name(&calling, smbc_getNetbiosName(context), 0x0);
- make_nmb_name(&called , server, 0x20);
-
DEBUG(4,("SMBC_server: server_n=[%s] server=[%s]\n", server_n, server));
DEBUG(4,(" -> server_n=[%s] server=[%s]\n", server_n, server));
-again:
+ status = NT_STATUS_UNSUCCESSFUL;
- zero_sockaddr(&ss);
+ if (share == NULL || *share == '\0' || is_ipc) {
+ /*
+ * Try 139 first for IPC$
+ */
+ status = cli_connect_nb(server_n, NULL, 139, 0x20,
+ smbc_getNetbiosName(context),
+ Undefined, &c);
+ }
- /* have to open a new connection */
- if ((c = cli_initialise()) == NULL) {
- errno = ENOMEM;
+ if (!NT_STATUS_IS_OK(status)) {
+ /*
+ * No IPC$ or 139 did not work
+ */
+ status = cli_connect_nb(server_n, NULL, 0, 0x20,
+ smbc_getNetbiosName(context),
+ Undefined, &c);
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
return NULL;
}
@@ -423,73 +430,6 @@ again:
c->timeout = smbc_getTimeout(context);
- /*
- * Force use of port 139 for first try if share is $IPC, empty, or
- * null, so browse lists can work
- */
- if (share == NULL || *share == '\0' || is_ipc) {
- port_try_first = 139;
- port_try_next = 445;
- } else {
- port_try_first = 445;
- port_try_next = 139;
- }
-
- c->port = port_try_first;
-
- status = cli_connect(c, server_n, &ss);
- if (!NT_STATUS_IS_OK(status)) {
-
- /* First connection attempt failed. Try alternate port. */
- c->port = port_try_next;
-
- status = cli_connect(c, server_n, &ss);
- if (!NT_STATUS_IS_OK(status)) {
- cli_shutdown(c);
- errno = ETIMEDOUT;
- return NULL;
- }
- }
-
- if (!cli_session_request(c, &calling, &called)) {
- cli_shutdown(c);
- if (strcmp(called.name, "*SMBSERVER")) {
- make_nmb_name(&called , "*SMBSERVER", 0x20);
- goto again;
- } else { /* Try one more time, but ensure we don't loop */
-
- /* Only try this if server is an IP address ... */
-
- if (is_ipaddress(server) && !tried_reverse) {
- fstring remote_name;
- struct sockaddr_storage rem_ss;
-
- if (!interpret_string_addr(&rem_ss, server,
- NI_NUMERICHOST)) {
- DEBUG(4, ("Could not convert IP address "
- "%s to struct sockaddr_storage\n",
- server));
- errno = ETIMEDOUT;
- return NULL;
- }
-
- tried_reverse++; /* Yuck */
-
- if (name_status_find("*", 0, 0,
- &rem_ss, remote_name)) {
- make_nmb_name(&called,
- remote_name,
- 0x20);
- goto again;
- }
- }
- }
- errno = ETIMEDOUT;
- return NULL;
- }
-
- DEBUG(4,(" session request ok\n"));
-
status = cli_negprot(c);
if (!NT_STATUS_IS_OK(status)) {
@@ -646,6 +586,10 @@ done:
workgroup = *pp_workgroup;
}
if(!workgroup) {
+ if (c != NULL) {
+ cli_shutdown(c);
+ }
+ SAFE_FREE(srv);
return NULL;
}
@@ -773,7 +717,7 @@ SMBC_attr_server(TALLOC_CTX *ctx,
zero_sockaddr(&ss);
nt_status = cli_full_connection(&ipc_cli,
- global_myname(), server,
+ lp_netbios_name(), server,
&ss, 0, "IPC$", "?????",
*pp_username,
*pp_workgroup,
diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c
index 9c613508eb4..b579a5f5c1d 100644
--- a/source3/libsmb/libsmb_stat.c
+++ b/source3/libsmb/libsmb_stat.c
@@ -23,6 +23,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmbclient.h"
#include "libsmb_internal.h"
@@ -52,7 +53,7 @@ generate_inode(SMBCCTX *context,
static int
setup_stat(SMBCCTX *context,
struct stat *st,
- char *fname,
+ const char *fname,
SMB_OFF_T size,
int mode)
{
@@ -180,7 +181,7 @@ SMBC_stat_ctx(SMBCCTX *context,
st->st_ino = ino;
- setup_stat(context, st, (char *) fname, size, mode);
+ setup_stat(context, st, fname, size, mode);
st->st_atime = convert_timespec_to_time_t(access_time_ts);
st->st_ctime = convert_timespec_to_time_t(change_time_ts);
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index af2c56ad403..eeff9a90306 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -23,6 +23,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "libsmbclient.h"
#include "libsmb_internal.h"
#include "../librpc/gen_ndr/ndr_lsa.h"
@@ -320,9 +321,9 @@ parse_ace(struct cli_state *ipc_cli,
return false;
}
- if (StrnCaseCmp(tok, "ALLOWED", strlen("ALLOWED")) == 0) {
+ if (strncasecmp_m(tok, "ALLOWED", strlen("ALLOWED")) == 0) {
atype = SEC_ACE_TYPE_ACCESS_ALLOWED;
- } else if (StrnCaseCmp(tok, "DENIED", strlen("DENIED")) == 0) {
+ } else if (strncasecmp_m(tok, "DENIED", strlen("DENIED")) == 0) {
atype = SEC_ACE_TYPE_ACCESS_DENIED;
} else {
TALLOC_FREE(frame);
@@ -435,12 +436,12 @@ sec_desc_parse(TALLOC_CTX *ctx,
while (next_token_talloc(ctx, &p, &tok, "\t,\r\n")) {
- if (StrnCaseCmp(tok,"REVISION:", 9) == 0) {
+ if (strncasecmp_m(tok,"REVISION:", 9) == 0) {
revision = strtol(tok+9, NULL, 16);
continue;
}
- if (StrnCaseCmp(tok,"OWNER:", 6) == 0) {
+ if (strncasecmp_m(tok,"OWNER:", 6) == 0) {
if (owner_sid) {
DEBUG(5,("OWNER specified more than once!\n"));
goto done;
@@ -456,7 +457,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"OWNER+:", 7) == 0) {
+ if (strncasecmp_m(tok,"OWNER+:", 7) == 0) {
if (owner_sid) {
DEBUG(5,("OWNER specified more than once!\n"));
goto done;
@@ -472,7 +473,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"GROUP:", 6) == 0) {
+ if (strncasecmp_m(tok,"GROUP:", 6) == 0) {
if (group_sid) {
DEBUG(5,("GROUP specified more than once!\n"));
goto done;
@@ -488,7 +489,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"GROUP+:", 7) == 0) {
+ if (strncasecmp_m(tok,"GROUP+:", 7) == 0) {
if (group_sid) {
DEBUG(5,("GROUP specified more than once!\n"));
goto done;
@@ -504,7 +505,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"ACL:", 4) == 0) {
+ if (strncasecmp_m(tok,"ACL:", 4) == 0) {
struct security_ace ace;
if (!parse_ace(ipc_cli, pol, &ace, numeric, tok+4)) {
DEBUG(5, ("Failed to parse ACL %s\n", tok));
@@ -517,7 +518,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
continue;
}
- if (StrnCaseCmp(tok,"ACL+:", 5) == 0) {
+ if (strncasecmp_m(tok,"ACL+:", 5) == 0) {
struct security_ace ace;
if (!parse_ace(ipc_cli, pol, &ace, False, tok+5)) {
DEBUG(5, ("Failed to parse ACL %s\n", tok));
@@ -560,14 +561,14 @@ dos_attr_query(SMBCCTX *context,
SMB_INO_T inode = 0;
DOS_ATTR_DESC *ret;
- ret = TALLOC_P(ctx, DOS_ATTR_DESC);
+ ret = talloc(ctx, DOS_ATTR_DESC);
if (!ret) {
errno = ENOMEM;
return NULL;
}
/* Obtain the DOS attributes */
- if (!SMBC_getatr(context, srv, CONST_DISCARD(char *, filename),
+ if (!SMBC_getatr(context, srv, filename,
&mode, &size,
&create_time_ts,
&access_time_ts,
@@ -636,7 +637,7 @@ dos_attr_parse(SMBCCTX *context,
frame = talloc_stackframe();
while (next_token_talloc(frame, &p, &tok, "\t,\r\n")) {
- if (StrnCaseCmp(tok, "MODE:", 5) == 0) {
+ if (strncasecmp_m(tok, "MODE:", 5) == 0) {
long request = strtol(tok+5, NULL, 16);
if (request == 0) {
dad->mode = (request |
@@ -649,32 +650,32 @@ dos_attr_parse(SMBCCTX *context,
continue;
}
- if (StrnCaseCmp(tok, "SIZE:", 5) == 0) {
+ if (strncasecmp_m(tok, "SIZE:", 5) == 0) {
dad->size = (SMB_OFF_T)atof(tok+5);
continue;
}
n = strlen(attr_strings.access_time_attr);
- if (StrnCaseCmp(tok, attr_strings.access_time_attr, n) == 0) {
+ if (strncasecmp_m(tok, attr_strings.access_time_attr, n) == 0) {
dad->access_time = (time_t)strtol(tok+n+1, NULL, 10);
continue;
}
n = strlen(attr_strings.change_time_attr);
- if (StrnCaseCmp(tok, attr_strings.change_time_attr, n) == 0) {
+ if (strncasecmp_m(tok, attr_strings.change_time_attr, n) == 0) {
dad->change_time = (time_t)strtol(tok+n+1, NULL, 10);
continue;
}
n = strlen(attr_strings.write_time_attr);
- if (StrnCaseCmp(tok, attr_strings.write_time_attr, n) == 0) {
+ if (strncasecmp_m(tok, attr_strings.write_time_attr, n) == 0) {
dad->write_time = (time_t)strtol(tok+n+1, NULL, 10);
continue;
}
if (attr_strings.create_time_attr != NULL) {
n = strlen(attr_strings.create_time_attr);
- if (StrnCaseCmp(tok, attr_strings.create_time_attr,
+ if (strncasecmp_m(tok, attr_strings.create_time_attr,
n) == 0) {
dad->create_time = (time_t)strtol(tok+n+1,
NULL, 10);
@@ -682,7 +683,7 @@ dos_attr_parse(SMBCCTX *context,
}
}
- if (StrnCaseCmp(tok, "INODE:", 6) == 0) {
+ if (strncasecmp_m(tok, "INODE:", 6) == 0) {
dad->inode = (SMB_INO_T)atof(tok+6);
continue;
}
@@ -700,8 +701,8 @@ cacl_get(SMBCCTX *context,
SMBCSRV *srv,
struct cli_state *ipc_cli,
struct policy_handle *pol,
- char *filename,
- char *attr_name,
+ const char *filename,
+ const char *attr_name,
char *buf,
int bufsize)
{
@@ -799,12 +800,12 @@ cacl_get(SMBCCTX *context,
*pExclude++ = '\0';
}
- all = (StrnCaseCmp(name, "system.*", 8) == 0);
- all_nt = (StrnCaseCmp(name, "system.nt_sec_desc.*", 20) == 0);
- all_nt_acls = (StrnCaseCmp(name, "system.nt_sec_desc.acl.*", 24) == 0);
- all_dos = (StrnCaseCmp(name, "system.dos_attr.*", 17) == 0);
- some_nt = (StrnCaseCmp(name, "system.nt_sec_desc.", 19) == 0);
- some_dos = (StrnCaseCmp(name, "system.dos_attr.", 16) == 0);
+ all = (strncasecmp_m(name, "system.*", 8) == 0);
+ all_nt = (strncasecmp_m(name, "system.nt_sec_desc.*", 20) == 0);
+ all_nt_acls = (strncasecmp_m(name, "system.nt_sec_desc.acl.*", 24) == 0);
+ all_dos = (strncasecmp_m(name, "system.dos_attr.*", 17) == 0);
+ some_nt = (strncasecmp_m(name, "system.nt_sec_desc.", 19) == 0);
+ some_dos = (strncasecmp_m(name, "system.dos_attr.", 16) == 0);
numeric = (* (name + strlen(name) - 1) != '+');
/* Look for exclusions from "all" requests */
@@ -821,48 +822,48 @@ cacl_get(SMBCCTX *context,
}
/* Which exclusion name is this? */
- if (StrCaseCmp(pExclude,
+ if (strcasecmp_m(pExclude,
"nt_sec_desc.revision") == 0) {
exclude_nt_revision = True;
}
- else if (StrCaseCmp(pExclude,
+ else if (strcasecmp_m(pExclude,
"nt_sec_desc.owner") == 0) {
exclude_nt_owner = True;
}
- else if (StrCaseCmp(pExclude,
+ else if (strcasecmp_m(pExclude,
"nt_sec_desc.group") == 0) {
exclude_nt_group = True;
}
- else if (StrCaseCmp(pExclude,
+ else if (strcasecmp_m(pExclude,
"nt_sec_desc.acl") == 0) {
exclude_nt_acl = True;
}
- else if (StrCaseCmp(pExclude,
+ else if (strcasecmp_m(pExclude,
"dos_attr.mode") == 0) {
exclude_dos_mode = True;
}
- else if (StrCaseCmp(pExclude,
+ else if (strcasecmp_m(pExclude,
"dos_attr.size") == 0) {
exclude_dos_size = True;
}
else if (excl_attr_strings.create_time_attr != NULL &&
- StrCaseCmp(pExclude,
+ strcasecmp_m(pExclude,
excl_attr_strings.change_time_attr) == 0) {
exclude_dos_create_time = True;
}
- else if (StrCaseCmp(pExclude,
+ else if (strcasecmp_m(pExclude,
excl_attr_strings.access_time_attr) == 0) {
exclude_dos_access_time = True;
}
- else if (StrCaseCmp(pExclude,
+ else if (strcasecmp_m(pExclude,
excl_attr_strings.write_time_attr) == 0) {
exclude_dos_write_time = True;
}
- else if (StrCaseCmp(pExclude,
+ else if (strcasecmp_m(pExclude,
excl_attr_strings.change_time_attr) == 0) {
exclude_dos_change_time = True;
}
- else if (StrCaseCmp(pExclude, "dos_attr.inode") == 0) {
+ else if (strcasecmp_m(pExclude, "dos_attr.inode") == 0) {
exclude_dos_inode = True;
}
else {
@@ -932,7 +933,7 @@ cacl_get(SMBCCTX *context,
"REVISION:%d",
sd->revision);
}
- } else if (StrCaseCmp(name, "revision") == 0) {
+ } else if (strcasecmp_m(name, "revision") == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "%d",
sd->revision);
@@ -981,7 +982,7 @@ cacl_get(SMBCCTX *context,
n = snprintf(buf, bufsize,
",OWNER:%s", sidstr);
}
- } else if (StrnCaseCmp(name, "owner", 5) == 0) {
+ } else if (strncasecmp_m(name, "owner", 5) == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "%s", sidstr);
if (!p) {
@@ -1027,7 +1028,7 @@ cacl_get(SMBCCTX *context,
n = snprintf(buf, bufsize,
",GROUP:%s", sidstr);
}
- } else if (StrnCaseCmp(name, "group", 5) == 0) {
+ } else if (strncasecmp_m(name, "group", 5) == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "%s", sidstr);
if (!p) {
@@ -1084,10 +1085,10 @@ cacl_get(SMBCCTX *context,
ace->flags,
ace->access_mask);
}
- } else if ((StrnCaseCmp(name, "acl", 3) == 0 &&
- StrCaseCmp(name+3, sidstr) == 0) ||
- (StrnCaseCmp(name, "acl+", 4) == 0 &&
- StrCaseCmp(name+4, sidstr) == 0)) {
+ } else if ((strncasecmp_m(name, "acl", 3) == 0 &&
+ strcasecmp_m(name+3, sidstr) == 0) ||
+ (strncasecmp_m(name, "acl+", 4) == 0 &&
+ strcasecmp_m(name+4, sidstr) == 0)) {
if (determine_size) {
p = talloc_asprintf(
ctx,
@@ -1192,7 +1193,7 @@ cacl_get(SMBCCTX *context,
: ""),
mode);
}
- } else if (StrCaseCmp(name, "mode") == 0) {
+ } else if (strcasecmp_m(name, "mode") == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "0x%x", mode);
if (!p) {
@@ -1233,7 +1234,7 @@ cacl_get(SMBCCTX *context,
",SIZE:%.0f",
(double)size);
}
- } else if (StrCaseCmp(name, "size") == 0) {
+ } else if (strcasecmp_m(name, "size") == 0) {
if (determine_size) {
p = talloc_asprintf(
ctx,
@@ -1280,7 +1281,7 @@ cacl_get(SMBCCTX *context,
attr_strings.create_time_attr,
(unsigned long) create_time);
}
- } else if (StrCaseCmp(name, attr_strings.create_time_attr) == 0) {
+ } else if (strcasecmp_m(name, attr_strings.create_time_attr) == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "%lu", (unsigned long) create_time);
if (!p) {
@@ -1322,7 +1323,7 @@ cacl_get(SMBCCTX *context,
attr_strings.access_time_attr,
(unsigned long) access_time);
}
- } else if (StrCaseCmp(name, attr_strings.access_time_attr) == 0) {
+ } else if (strcasecmp_m(name, attr_strings.access_time_attr) == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "%lu", (unsigned long) access_time);
if (!p) {
@@ -1364,7 +1365,7 @@ cacl_get(SMBCCTX *context,
attr_strings.write_time_attr,
(unsigned long) write_time);
}
- } else if (StrCaseCmp(name, attr_strings.write_time_attr) == 0) {
+ } else if (strcasecmp_m(name, attr_strings.write_time_attr) == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "%lu", (unsigned long) write_time);
if (!p) {
@@ -1406,7 +1407,7 @@ cacl_get(SMBCCTX *context,
attr_strings.change_time_attr,
(unsigned long) change_time);
}
- } else if (StrCaseCmp(name, attr_strings.change_time_attr) == 0) {
+ } else if (strcasecmp_m(name, attr_strings.change_time_attr) == 0) {
if (determine_size) {
p = talloc_asprintf(ctx, "%lu", (unsigned long) change_time);
if (!p) {
@@ -1447,7 +1448,7 @@ cacl_get(SMBCCTX *context,
",INODE:%.0f",
(double) ino);
}
- } else if (StrCaseCmp(name, "inode") == 0) {
+ } else if (strcasecmp_m(name, "inode") == 0) {
if (determine_size) {
p = talloc_asprintf(
ctx,
@@ -1774,8 +1775,8 @@ SMBC_setxattr_ctx(SMBCCTX *context,
/*
* Are they asking to set the entire set of known attributes?
*/
- if (StrCaseCmp(name, "system.*") == 0 ||
- StrCaseCmp(name, "system.*+") == 0) {
+ if (strcasecmp_m(name, "system.*") == 0 ||
+ strcasecmp_m(name, "system.*+") == 0) {
/* Yup. */
char *namevalue =
talloc_asprintf(talloc_tos(), "%s:%s",
@@ -1834,11 +1835,11 @@ SMBC_setxattr_ctx(SMBCCTX *context,
* Are they asking to set an access control element or to set
* the entire access control list?
*/
- if (StrCaseCmp(name, "system.nt_sec_desc.*") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.*+") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) {
+ if (strcasecmp_m(name, "system.nt_sec_desc.*") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.*+") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.revision") == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl", 22) == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl+", 23) == 0) {
/* Yup. */
char *namevalue =
@@ -1867,8 +1868,8 @@ SMBC_setxattr_ctx(SMBCCTX *context,
/*
* Are they asking to set the owner?
*/
- if (StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0) {
+ if (strcasecmp_m(name, "system.nt_sec_desc.owner") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.owner+") == 0) {
/* Yup. */
char *namevalue =
@@ -1893,8 +1894,8 @@ SMBC_setxattr_ctx(SMBCCTX *context,
/*
* Are they asking to set the group?
*/
- if (StrCaseCmp(name, "system.nt_sec_desc.group") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.group+") == 0) {
+ if (strcasecmp_m(name, "system.nt_sec_desc.group") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.group+") == 0) {
/* Yup. */
char *namevalue =
@@ -1935,13 +1936,13 @@ SMBC_setxattr_ctx(SMBCCTX *context,
/*
* Are they asking to set a DOS attribute?
*/
- if (StrCaseCmp(name, "system.dos_attr.*") == 0 ||
- StrCaseCmp(name, "system.dos_attr.mode") == 0 ||
+ if (strcasecmp_m(name, "system.dos_attr.*") == 0 ||
+ strcasecmp_m(name, "system.dos_attr.mode") == 0 ||
(attr_strings.create_time_attr != NULL &&
- StrCaseCmp(name, attr_strings.create_time_attr) == 0) ||
- StrCaseCmp(name, attr_strings.access_time_attr) == 0 ||
- StrCaseCmp(name, attr_strings.write_time_attr) == 0 ||
- StrCaseCmp(name, attr_strings.change_time_attr) == 0) {
+ strcasecmp_m(name, attr_strings.create_time_attr) == 0) ||
+ strcasecmp_m(name, attr_strings.access_time_attr) == 0 ||
+ strcasecmp_m(name, attr_strings.write_time_attr) == 0 ||
+ strcasecmp_m(name, attr_strings.change_time_attr) == 0) {
/* get a DOS Attribute Descriptor with current attributes */
dad = dos_attr_query(context, talloc_tos(), path, srv);
@@ -2080,39 +2081,39 @@ SMBC_getxattr_ctx(SMBCCTX *context,
}
/* Are they requesting a supported attribute? */
- if (StrCaseCmp(name, "system.*") == 0 ||
- StrnCaseCmp(name, "system.*!", 9) == 0 ||
- StrCaseCmp(name, "system.*+") == 0 ||
- StrnCaseCmp(name, "system.*+!", 10) == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.*") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.*!", 21) == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.*+") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.*+!", 22) == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.group") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.group+") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0 ||
- StrCaseCmp(name, "system.dos_attr.*") == 0 ||
- StrnCaseCmp(name, "system.dos_attr.*!", 18) == 0 ||
- StrCaseCmp(name, "system.dos_attr.mode") == 0 ||
- StrCaseCmp(name, "system.dos_attr.size") == 0 ||
+ if (strcasecmp_m(name, "system.*") == 0 ||
+ strncasecmp_m(name, "system.*!", 9) == 0 ||
+ strcasecmp_m(name, "system.*+") == 0 ||
+ strncasecmp_m(name, "system.*+!", 10) == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.*") == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.*!", 21) == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.*+") == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.*+!", 22) == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.revision") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.owner") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.owner+") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.group") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.group+") == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl", 22) == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl+", 23) == 0 ||
+ strcasecmp_m(name, "system.dos_attr.*") == 0 ||
+ strncasecmp_m(name, "system.dos_attr.*!", 18) == 0 ||
+ strcasecmp_m(name, "system.dos_attr.mode") == 0 ||
+ strcasecmp_m(name, "system.dos_attr.size") == 0 ||
(attr_strings.create_time_attr != NULL &&
- StrCaseCmp(name, attr_strings.create_time_attr) == 0) ||
- StrCaseCmp(name, attr_strings.access_time_attr) == 0 ||
- StrCaseCmp(name, attr_strings.write_time_attr) == 0 ||
- StrCaseCmp(name, attr_strings.change_time_attr) == 0 ||
- StrCaseCmp(name, "system.dos_attr.inode") == 0) {
+ strcasecmp_m(name, attr_strings.create_time_attr) == 0) ||
+ strcasecmp_m(name, attr_strings.access_time_attr) == 0 ||
+ strcasecmp_m(name, attr_strings.write_time_attr) == 0 ||
+ strcasecmp_m(name, attr_strings.change_time_attr) == 0 ||
+ strcasecmp_m(name, "system.dos_attr.inode") == 0) {
/* Yup. */
- char *filename = (char *) name;
+ const char *filename = name;
ret = cacl_get(context, talloc_tos(), srv,
ipc_srv == NULL ? NULL : ipc_srv->cli,
&ipc_srv->pol, path,
filename,
- CONST_DISCARD(char *, value),
+ discard_const_p(char, value),
size);
if (ret < 0 && errno == 0) {
errno = SMBC_errno(context, srv->cli);
@@ -2205,8 +2206,8 @@ SMBC_removexattr_ctx(SMBCCTX *context,
}
/* Are they asking to set the entire ACL? */
- if (StrCaseCmp(name, "system.nt_sec_desc.*") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.*+") == 0) {
+ if (strcasecmp_m(name, "system.nt_sec_desc.*") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.*+") == 0) {
/* Yup. */
ret = cacl_set(context, talloc_tos(), srv->cli,
@@ -2220,18 +2221,18 @@ SMBC_removexattr_ctx(SMBCCTX *context,
* Are they asking to remove one or more spceific security descriptor
* attributes?
*/
- if (StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.group") == 0 ||
- StrCaseCmp(name, "system.nt_sec_desc.group+") == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
- StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) {
+ if (strcasecmp_m(name, "system.nt_sec_desc.revision") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.owner") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.owner+") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.group") == 0 ||
+ strcasecmp_m(name, "system.nt_sec_desc.group+") == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl", 22) == 0 ||
+ strncasecmp_m(name, "system.nt_sec_desc.acl+", 23) == 0) {
/* Yup. */
ret = cacl_set(context, talloc_tos(), srv->cli,
ipc_srv->cli, &ipc_srv->pol, path,
- CONST_DISCARD(char *, name) + 19,
+ discard_const_p(char, name) + 19,
SMBC_XATTR_MODE_REMOVE, 0);
TALLOC_FREE(frame);
return ret;
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index ef7aab6a6aa..dca740d3e6b 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -19,6 +19,7 @@
*/
#include "includes.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "libads/sitename_cache.h"
#include "libads/dns.h"
#include "../libcli/netlogon/netlogon.h"
@@ -196,6 +197,26 @@ char *saf_fetch( const char *domain )
return server;
}
+static void set_socket_addr_v4(struct sockaddr_storage *addr)
+{
+ if (!interpret_string_addr(addr, lp_socket_address(),
+ AI_NUMERICHOST|AI_PASSIVE)) {
+ zero_sockaddr(addr);
+ }
+ if (addr->ss_family != AF_INET) {
+ zero_sockaddr(addr);
+ }
+}
+
+static struct in_addr my_socket_addr_v4(void)
+{
+ struct sockaddr_storage my_addr;
+ struct sockaddr_in *in_addr = (struct sockaddr_in *)((char *)&my_addr);
+
+ set_socket_addr_v4(&my_addr);
+ return in_addr->sin_addr;
+}
+
/****************************************************************************
Generate a random trn_id.
****************************************************************************/
@@ -225,7 +246,7 @@ static struct node_status *parse_node_status(TALLOC_CTX *mem_ctx, char *p,
if (*num_names == 0)
return NULL;
- ret = TALLOC_ARRAY(mem_ctx, struct node_status,*num_names);
+ ret = talloc_array(mem_ctx, struct node_status,*num_names);
if (!ret)
return NULL;
@@ -704,10 +725,7 @@ struct tevent_req *node_status_query_send(TALLOC_CTX *mem_ctx,
in_addr = (struct sockaddr_in *)(void *)&state->addr;
in_addr->sin_port = htons(NMB_PORT);
- if (!interpret_string_addr(&state->my_addr, lp_socket_address(),
- AI_NUMERICHOST|AI_PASSIVE)) {
- zero_sockaddr(&state->my_addr);
- }
+ set_socket_addr_v4(&state->my_addr);
ZERO_STRUCT(p);
nmb->header.name_trn_id = generate_trn_id();
@@ -891,10 +909,7 @@ bool name_status_find(const char *q_name,
return false;
}
- if (!interpret_string_addr(&ss, lp_socket_address(),
- AI_NUMERICHOST|AI_PASSIVE)) {
- zero_sockaddr(&ss);
- }
+ set_socket_addr_v4(&ss);
/* W2K PDC's seem not to respond to '*'#0. JRA */
make_nmb_name(&nname, q_name, q_type);
@@ -962,9 +977,9 @@ static int addr_compare(const struct sockaddr_storage *ss1,
for (i=0;i<num_interfaces;i++) {
const struct sockaddr_storage *pss = iface_n_bcast(i);
- unsigned char *p_ss1 = NULL;
- unsigned char *p_ss2 = NULL;
- unsigned char *p_if = NULL;
+ const unsigned char *p_ss1 = NULL;
+ const unsigned char *p_ss2 = NULL;
+ const unsigned char *p_if = NULL;
size_t len = 0;
int bits1, bits2;
@@ -973,21 +988,21 @@ static int addr_compare(const struct sockaddr_storage *ss1,
continue;
}
if (pss->ss_family == AF_INET) {
- p_if = (unsigned char *)
+ p_if = (const unsigned char *)
&((const struct sockaddr_in *)pss)->sin_addr;
- p_ss1 = (unsigned char *)
+ p_ss1 = (const unsigned char *)
&((const struct sockaddr_in *)ss1)->sin_addr;
- p_ss2 = (unsigned char *)
+ p_ss2 = (const unsigned char *)
&((const struct sockaddr_in *)ss2)->sin_addr;
len = 4;
}
#if defined(HAVE_IPV6)
if (pss->ss_family == AF_INET6) {
- p_if = (unsigned char *)
+ p_if = (const unsigned char *)
&((const struct sockaddr_in6 *)pss)->sin6_addr;
- p_ss1 = (unsigned char *)
+ p_ss1 = (const unsigned char *)
&((const struct sockaddr_in6 *)ss1)->sin6_addr;
- p_ss2 = (unsigned char *)
+ p_ss2 = (const unsigned char *)
&((const struct sockaddr_in6 *)ss2)->sin6_addr;
len = 16;
}
@@ -1002,14 +1017,14 @@ static int addr_compare(const struct sockaddr_storage *ss1,
}
/* Bias towards directly reachable IPs */
- if (iface_local((struct sockaddr *)ss1)) {
+ if (iface_local((const struct sockaddr *)ss1)) {
if (ss1->ss_family == AF_INET) {
max_bits1 += 32;
} else {
max_bits1 += 128;
}
}
- if (iface_local((struct sockaddr *)ss2)) {
+ if (iface_local((const struct sockaddr *)ss2)) {
if (ss2->ss_family == AF_INET) {
max_bits2 += 32;
} else {
@@ -1084,7 +1099,8 @@ static int remove_duplicate_addrs2(struct ip_service *iplist, int count )
}
for ( j=i+1; j<count; j++ ) {
- if (sockaddr_equal((struct sockaddr *)&iplist[i].ss, (struct sockaddr *)&iplist[j].ss) &&
+ if (sockaddr_equal((struct sockaddr *)(void *)&iplist[i].ss,
+ (struct sockaddr *)(void *)&iplist[j].ss) &&
iplist[i].port == iplist[j].port) {
zero_sockaddr(&iplist[j].ss);
}
@@ -1111,7 +1127,7 @@ static int remove_duplicate_addrs2(struct ip_service *iplist, int count )
static bool prioritize_ipv4_list(struct ip_service *iplist, int count)
{
TALLOC_CTX *frame = talloc_stackframe();
- struct ip_service *iplist_new = TALLOC_ARRAY(frame, struct ip_service, count);
+ struct ip_service *iplist_new = talloc_array(frame, struct ip_service, count);
int i, j;
if (iplist_new == NULL) {
@@ -1177,7 +1193,6 @@ struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx,
struct packet_struct p;
struct nmb_packet *nmb = &p.packet.nmb;
struct sockaddr_in *in_addr;
- struct timeval timeout;
req = tevent_req_create(mem_ctx, &state, struct name_query_state);
if (req == NULL) {
@@ -1202,10 +1217,7 @@ struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx,
in_addr = (struct sockaddr_in *)(void *)&state->addr;
in_addr->sin_port = htons(NMB_PORT);
- if (!interpret_string_addr(&state->my_addr, lp_socket_address(),
- AI_NUMERICHOST|AI_PASSIVE)) {
- zero_sockaddr(&state->my_addr);
- }
+ set_socket_addr_v4(&state->my_addr);
ZERO_STRUCT(p);
nmb->header.name_trn_id = generate_trn_id();
@@ -1243,14 +1255,6 @@ struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx,
DEBUG(10, ("nb_trans_send failed\n"));
return tevent_req_post(req, ev);
}
- if (bcast) {
- timeout = timeval_current_ofs(0, 250000);
- } else {
- timeout = timeval_current_ofs(2, 0);
- }
- if (!tevent_req_set_endtime(req, ev, timeout)) {
- return tevent_req_post(req, ev);
- }
tevent_req_set_callback(subreq, name_query_done, req);
return req;
}
@@ -1261,6 +1265,7 @@ static bool name_query_validator(struct packet_struct *p, void *private_data)
private_data, struct name_query_state);
struct nmb_packet *nmb = &p->packet.nmb;
struct sockaddr_storage *tmp_addrs;
+ bool got_unique_netbios_name = false;
int i;
debug_nmb_packet(p);
@@ -1322,7 +1327,7 @@ static bool name_query_validator(struct packet_struct *p, void *private_data)
return false;
}
- tmp_addrs = TALLOC_REALLOC_ARRAY(
+ tmp_addrs = talloc_realloc(
state, state->addrs, struct sockaddr_storage,
state->num_addrs + nmb->answers->rdlength/6);
if (tmp_addrs == NULL) {
@@ -1335,11 +1340,32 @@ static bool name_query_validator(struct packet_struct *p, void *private_data)
"from %s ( ", inet_ntoa(p->ip)));
for (i=0; i<nmb->answers->rdlength/6; i++) {
+ uint16_t flags;
struct in_addr ip;
+ struct sockaddr_storage addr;
+ int j;
+
+ flags = RSVAL(&nmb->answers->rdata[i*6], 0);
+ got_unique_netbios_name |= ((flags & 0x8000) == 0);
+
putip((char *)&ip,&nmb->answers->rdata[2+i*6]);
- in_addr_to_sockaddr_storage(
- &state->addrs[state->num_addrs], ip);
+ in_addr_to_sockaddr_storage(&addr, ip);
+
+ for (j=0; j<state->num_addrs; j++) {
+ if (sockaddr_equal(
+ (struct sockaddr *)(void *)&addr,
+ (struct sockaddr *)(void *)&state->addrs[j])) {
+ break;
+ }
+ }
+ if (j < state->num_addrs) {
+ /* Already got it */
+ continue;
+ }
+
DEBUGADD(2,("%s ",inet_ntoa(ip)));
+
+ state->addrs[state->num_addrs] = addr;
state->num_addrs += 1;
}
DEBUGADD(2,(")\n"));
@@ -1360,10 +1386,10 @@ static bool name_query_validator(struct packet_struct *p, void *private_data)
if (state->bcast) {
/*
- * We have to collect all entries coming in from
- * broadcast queries
+ * We have to collect all entries coming in from broadcast
+ * queries. If we got a unique name, we're done.
*/
- return false;
+ return got_unique_netbios_name;
}
/*
* WINS responses are accepted when they are received
@@ -1407,9 +1433,18 @@ NTSTATUS name_query_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
req, struct name_query_state);
NTSTATUS status;
- if (tevent_req_is_nterror(req, &status)
- && !NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- return status;
+ if (tevent_req_is_nterror(req, &status)) {
+ if (state->bcast &&
+ NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ /*
+ * In the broadcast case we collect replies until the
+ * timeout.
+ */
+ status = NT_STATUS_OK;
+ }
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
}
if (state->num_addrs == 0) {
return NT_STATUS_NOT_FOUND;
@@ -1433,6 +1468,7 @@ NTSTATUS name_query(const char *name, int name_type,
TALLOC_CTX *frame = talloc_stackframe();
struct tevent_context *ev;
struct tevent_req *req;
+ struct timeval timeout;
NTSTATUS status = NT_STATUS_NO_MEMORY;
ev = tevent_context_init(frame);
@@ -1443,6 +1479,14 @@ NTSTATUS name_query(const char *name, int name_type,
if (req == NULL) {
goto fail;
}
+ if (bcast) {
+ timeout = timeval_current_ofs(0, 250000);
+ } else {
+ timeout = timeval_current_ofs(2, 0);
+ }
+ if (!tevent_req_set_endtime(req, ev, timeout)) {
+ goto fail;
+ }
if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}
@@ -1482,113 +1526,507 @@ static bool convert_ss2service(struct ip_service **return_iplist,
return true;
}
+struct name_queries_state {
+ struct tevent_context *ev;
+ const char *name;
+ int name_type;
+ bool bcast;
+ bool recurse;
+ const struct sockaddr_storage *addrs;
+ int num_addrs;
+ int wait_msec;
+ int timeout_msec;
+
+ struct tevent_req **subreqs;
+ int num_received;
+ int num_sent;
+
+ int received_index;
+ struct sockaddr_storage *result_addrs;
+ int num_result_addrs;
+ uint8_t flags;
+};
+
+static void name_queries_done(struct tevent_req *subreq);
+static void name_queries_next(struct tevent_req *subreq);
+
+/*
+ * Send a name query to multiple destinations with a wait time in between
+ */
+
+static struct tevent_req *name_queries_send(
+ TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ const char *name, int name_type,
+ bool bcast, bool recurse,
+ const struct sockaddr_storage *addrs,
+ int num_addrs, int wait_msec, int timeout_msec)
+{
+ struct tevent_req *req, *subreq;
+ struct name_queries_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct name_queries_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->ev = ev;
+ state->name = name;
+ state->name_type = name_type;
+ state->bcast = bcast;
+ state->recurse = recurse;
+ state->addrs = addrs;
+ state->num_addrs = num_addrs;
+ state->wait_msec = wait_msec;
+ state->timeout_msec = timeout_msec;
+
+ state->subreqs = talloc_zero_array(
+ state, struct tevent_req *, num_addrs);
+ if (tevent_req_nomem(state->subreqs, req)) {
+ return tevent_req_post(req, ev);
+ }
+ state->num_sent = 0;
+
+ subreq = name_query_send(
+ state->subreqs, state->ev, name, name_type, bcast, recurse,
+ &state->addrs[state->num_sent]);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ if (!tevent_req_set_endtime(
+ subreq, state->ev,
+ timeval_current_ofs(0, state->timeout_msec * 1000))) {
+ tevent_req_oom(req);
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, name_queries_done, req);
+
+ state->subreqs[state->num_sent] = subreq;
+ state->num_sent += 1;
+
+ if (state->num_sent < state->num_addrs) {
+ subreq = tevent_wakeup_send(
+ state, state->ev,
+ timeval_current_ofs(0, state->wait_msec * 1000));
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, name_queries_next, req);
+ }
+ return req;
+}
+
+static void name_queries_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct name_queries_state *state = tevent_req_data(
+ req, struct name_queries_state);
+ int i;
+ NTSTATUS status;
+
+ status = name_query_recv(subreq, state, &state->result_addrs,
+ &state->num_result_addrs, &state->flags);
+
+ for (i=0; i<state->num_sent; i++) {
+ if (state->subreqs[i] == subreq) {
+ break;
+ }
+ }
+ if (i == state->num_sent) {
+ tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
+ return;
+ }
+ TALLOC_FREE(state->subreqs[i]);
+
+ state->num_received += 1;
+
+ if (!NT_STATUS_IS_OK(status)) {
+
+ if (state->num_received >= state->num_addrs) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ /*
+ * Still outstanding requests, just wait
+ */
+ return;
+ }
+ state->received_index = i;
+ tevent_req_done(req);
+}
+
+static void name_queries_next(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct name_queries_state *state = tevent_req_data(
+ req, struct name_queries_state);
+
+ if (!tevent_wakeup_recv(subreq)) {
+ tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
+ return;
+ }
+
+ subreq = name_query_send(
+ state->subreqs, state->ev,
+ state->name, state->name_type, state->bcast, state->recurse,
+ &state->addrs[state->num_sent]);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, name_queries_done, req);
+ if (!tevent_req_set_endtime(
+ subreq, state->ev,
+ timeval_current_ofs(0, state->timeout_msec * 1000))) {
+ tevent_req_oom(req);
+ return;
+ }
+ state->subreqs[state->num_sent] = subreq;
+ state->num_sent += 1;
+
+ if (state->num_sent < state->num_addrs) {
+ subreq = tevent_wakeup_send(
+ state, state->ev,
+ timeval_current_ofs(0, state->wait_msec * 1000));
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, name_queries_next, req);
+ }
+}
+
+static NTSTATUS name_queries_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **result_addrs,
+ int *num_result_addrs, uint8_t *flags,
+ int *received_index)
+{
+ struct name_queries_state *state = tevent_req_data(
+ req, struct name_queries_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+
+ if (result_addrs != NULL) {
+ *result_addrs = talloc_move(mem_ctx, &state->result_addrs);
+ }
+ if (num_result_addrs != NULL) {
+ *num_result_addrs = state->num_result_addrs;
+ }
+ if (flags != NULL) {
+ *flags = state->flags;
+ }
+ if (received_index != NULL) {
+ *received_index = state->received_index;
+ }
+ return NT_STATUS_OK;
+}
+
/********************************************************
Resolve via "bcast" method.
*********************************************************/
-NTSTATUS name_resolve_bcast(const char *name,
- int name_type,
- struct ip_service **return_iplist,
- int *return_count)
+struct name_resolve_bcast_state {
+ struct sockaddr_storage *addrs;
+ int num_addrs;
+};
+
+static void name_resolve_bcast_done(struct tevent_req *subreq);
+
+struct tevent_req *name_resolve_bcast_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ const char *name,
+ int name_type)
{
- int i;
- int num_interfaces = iface_count();
- struct sockaddr_storage *ss_list;
- struct sockaddr_storage ss;
- NTSTATUS status = NT_STATUS_NOT_FOUND;
+ struct tevent_req *req, *subreq;
+ struct name_resolve_bcast_state *state;
+ struct sockaddr_storage *bcast_addrs;
+ int i, num_addrs, num_bcast_addrs;
- if (lp_disable_netbios()) {
- DEBUG(5,("name_resolve_bcast(%s#%02x): netbios is disabled\n",
- name, name_type));
- return NT_STATUS_INVALID_PARAMETER;
+ req = tevent_req_create(mem_ctx, &state,
+ struct name_resolve_bcast_state);
+ if (req == NULL) {
+ return NULL;
}
- *return_iplist = NULL;
- *return_count = 0;
+ if (lp_disable_netbios()) {
+ DEBUG(5, ("name_resolve_bcast(%s#%02x): netbios is disabled\n",
+ name, name_type));
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ return tevent_req_post(req, ev);
+ }
/*
* "bcast" means do a broadcast lookup on all the local interfaces.
*/
- DEBUG(3,("name_resolve_bcast: Attempting broadcast lookup "
- "for name %s<0x%x>\n", name, name_type));
+ DEBUG(3, ("name_resolve_bcast: Attempting broadcast lookup "
+ "for name %s<0x%x>\n", name, name_type));
- if (!interpret_string_addr(&ss, lp_socket_address(),
- AI_NUMERICHOST|AI_PASSIVE)) {
- zero_sockaddr(&ss);
+ num_addrs = iface_count();
+ bcast_addrs = talloc_array(state, struct sockaddr_storage, num_addrs);
+ if (tevent_req_nomem(bcast_addrs, req)) {
+ return tevent_req_post(req, ev);
}
/*
* Lookup the name on all the interfaces, return on
* the first successful match.
*/
- for( i = num_interfaces-1; i >= 0; i--) {
+ num_bcast_addrs = 0;
+
+ for (i=0; i<num_addrs; i++) {
const struct sockaddr_storage *pss = iface_n_bcast(i);
- /* Done this way to fix compiler error on IRIX 5.x */
- if (!pss) {
+ if (pss->ss_family != AF_INET) {
continue;
}
- status = name_query(name, name_type, true, true, pss,
- talloc_tos(), &ss_list, return_count,
- NULL);
- if (NT_STATUS_IS_OK(status)) {
- goto success;
- }
+ bcast_addrs[num_bcast_addrs] = *pss;
+ num_bcast_addrs += 1;
}
- /* failed - no response */
+ subreq = name_queries_send(state, ev, name, name_type, true, true,
+ bcast_addrs, num_bcast_addrs, 0, 1000);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, name_resolve_bcast_done, req);
+ return req;
+}
- return status;
+static void name_resolve_bcast_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct name_resolve_bcast_state *state = tevent_req_data(
+ req, struct name_resolve_bcast_state);
+ NTSTATUS status;
-success:
+ status = name_queries_recv(subreq, state,
+ &state->addrs, &state->num_addrs,
+ NULL, NULL);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ tevent_req_done(req);
+}
- if (!convert_ss2service(return_iplist, ss_list, *return_count) )
- status = NT_STATUS_NO_MEMORY;
+NTSTATUS name_resolve_bcast_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **addrs,
+ int *num_addrs)
+{
+ struct name_resolve_bcast_state *state = tevent_req_data(
+ req, struct name_resolve_bcast_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+ *addrs = talloc_move(mem_ctx, &state->addrs);
+ *num_addrs = state->num_addrs;
+ return NT_STATUS_OK;
+}
- TALLOC_FREE(ss_list);
+NTSTATUS name_resolve_bcast(const char *name,
+ int name_type,
+ TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **return_iplist,
+ int *return_count)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct event_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ ev = event_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = name_resolve_bcast_send(frame, ev, name, name_type);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = name_resolve_bcast_recv(req, mem_ctx, return_iplist,
+ return_count);
+ fail:
+ TALLOC_FREE(frame);
return status;
}
-/********************************************************
- Resolve via "wins" method.
-*********************************************************/
+struct query_wins_list_state {
+ struct tevent_context *ev;
+ const char *name;
+ uint8_t name_type;
+ struct in_addr *servers;
+ uint32_t num_servers;
+ struct sockaddr_storage server;
+ uint32_t num_sent;
-NTSTATUS resolve_wins(const char *name,
- int name_type,
- struct ip_service **return_iplist,
- int *return_count)
+ struct sockaddr_storage *addrs;
+ int num_addrs;
+ uint8_t flags;
+};
+
+static void query_wins_list_done(struct tevent_req *subreq);
+
+/*
+ * Query a list of (replicating) wins servers in sequence, call them
+ * dead if they don't reply
+ */
+
+static struct tevent_req *query_wins_list_send(
+ TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct in_addr src_ip, const char *name, uint8_t name_type,
+ struct in_addr *servers, int num_servers)
{
- int t, i;
- char **wins_tags;
- struct sockaddr_storage src_ss, *ss_list = NULL;
- struct in_addr src_ip;
+ struct tevent_req *req, *subreq;
+ struct query_wins_list_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct query_wins_list_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->ev = ev;
+ state->name = name;
+ state->name_type = name_type;
+ state->servers = servers;
+ state->num_servers = num_servers;
+
+ if (state->num_servers == 0) {
+ tevent_req_nterror(req, NT_STATUS_NOT_FOUND);
+ return tevent_req_post(req, ev);
+ }
+
+ in_addr_to_sockaddr_storage(
+ &state->server, state->servers[state->num_sent]);
+
+ subreq = name_query_send(state, state->ev,
+ state->name, state->name_type,
+ false, true, &state->server);
+ state->num_sent += 1;
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ if (!tevent_req_set_endtime(subreq, state->ev,
+ timeval_current_ofs(2, 0))) {
+ tevent_req_oom(req);
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, query_wins_list_done, req);
+ return req;
+}
+
+static void query_wins_list_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct query_wins_list_state *state = tevent_req_data(
+ req, struct query_wins_list_state);
NTSTATUS status;
- if (lp_disable_netbios()) {
- DEBUG(5,("resolve_wins(%s#%02x): netbios is disabled\n",
- name, name_type));
- return NT_STATUS_INVALID_PARAMETER;
+ status = name_query_recv(subreq, state,
+ &state->addrs, &state->num_addrs,
+ &state->flags);
+ TALLOC_FREE(subreq);
+ if (NT_STATUS_IS_OK(status)) {
+ tevent_req_done(req);
+ return;
+ }
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ tevent_req_nterror(req, status);
+ return;
}
+ wins_srv_died(state->servers[state->num_sent-1],
+ my_socket_addr_v4());
- *return_iplist = NULL;
- *return_count = 0;
+ if (state->num_sent == state->num_servers) {
+ tevent_req_nterror(req, NT_STATUS_NOT_FOUND);
+ return;
+ }
- DEBUG(3,("resolve_wins: Attempting wins lookup for name %s<0x%x>\n",
- name, name_type));
+ in_addr_to_sockaddr_storage(
+ &state->server, state->servers[state->num_sent]);
- if (wins_srv_count() < 1) {
- DEBUG(3,("resolve_wins: WINS server resolution selected "
- "and no WINS servers listed.\n"));
- return NT_STATUS_INVALID_PARAMETER;
+ subreq = name_query_send(state, state->ev,
+ state->name, state->name_type,
+ false, true, &state->server);
+ state->num_sent += 1;
+ if (tevent_req_nomem(subreq, req)) {
+ return;
}
+ if (!tevent_req_set_endtime(subreq, state->ev,
+ timeval_current_ofs(2, 0))) {
+ tevent_req_oom(req);
+ return;
+ }
+ tevent_req_set_callback(subreq, query_wins_list_done, req);
+}
- /* we try a lookup on each of the WINS tags in turn */
- wins_tags = wins_srv_tags();
+static NTSTATUS query_wins_list_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **addrs,
+ int *num_addrs,
+ uint8_t *flags)
+{
+ struct query_wins_list_state *state = tevent_req_data(
+ req, struct query_wins_list_state);
+ NTSTATUS status;
- if (!wins_tags) {
- /* huh? no tags?? give up in disgust */
- return NT_STATUS_INVALID_PARAMETER;
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+ if (addrs != NULL) {
+ *addrs = talloc_move(mem_ctx, &state->addrs);
+ }
+ if (num_addrs != NULL) {
+ *num_addrs = state->num_addrs;
+ }
+ if (flags != NULL) {
+ *flags = state->flags;
+ }
+ return NT_STATUS_OK;
+}
+
+struct resolve_wins_state {
+ int num_sent;
+ int num_received;
+
+ struct sockaddr_storage *addrs;
+ int num_addrs;
+ uint8_t flags;
+};
+
+static void resolve_wins_done(struct tevent_req *subreq);
+
+struct tevent_req *resolve_wins_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ const char *name,
+ int name_type)
+{
+ struct tevent_req *req, *subreq;
+ struct resolve_wins_state *state;
+ char **wins_tags = NULL;
+ struct sockaddr_storage src_ss;
+ struct in_addr src_ip;
+ int i, num_wins_tags;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct resolve_wins_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ if (wins_srv_count() < 1) {
+ DEBUG(3,("resolve_wins: WINS server resolution selected "
+ "and no WINS servers listed.\n"));
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ goto fail;
}
/* the address we will be sending from */
@@ -1603,80 +2041,164 @@ NTSTATUS resolve_wins(const char *name,
DEBUG(3,("resolve_wins: cannot receive WINS replies "
"on IPv6 address %s\n",
addr));
- wins_srv_tags_free(wins_tags);
- return NT_STATUS_INVALID_PARAMETER;
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ goto fail;
}
- src_ip = ((struct sockaddr_in *)&src_ss)->sin_addr;
+ src_ip = ((const struct sockaddr_in *)(void *)&src_ss)->sin_addr;
- /* in the worst case we will try every wins server with every
- tag! */
- for (t=0; wins_tags && wins_tags[t]; t++) {
- int srv_count = wins_srv_count_tag(wins_tags[t]);
- for (i=0; i<srv_count; i++) {
- struct sockaddr_storage wins_ss;
- struct in_addr wins_ip;
+ wins_tags = wins_srv_tags();
+ if (wins_tags == NULL) {
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ goto fail;
+ }
+
+ num_wins_tags = 0;
+ while (wins_tags[num_wins_tags] != NULL) {
+ num_wins_tags += 1;
+ }
+
+ for (i=0; i<num_wins_tags; i++) {
+ int num_servers, num_alive;
+ struct in_addr *servers, *alive;
+ int j;
+
+ if (!wins_server_tag_ips(wins_tags[i], talloc_tos(),
+ &servers, &num_servers)) {
+ DEBUG(10, ("wins_server_tag_ips failed for tag %s\n",
+ wins_tags[i]));
+ continue;
+ }
+
+ alive = talloc_array(state, struct in_addr, num_servers);
+ if (tevent_req_nomem(alive, req)) {
+ goto fail;
+ }
- wins_ip = wins_srv_ip_tag(wins_tags[t], src_ip);
+ num_alive = 0;
+ for (j=0; j<num_servers; j++) {
+ struct in_addr wins_ip = servers[j];
if (global_in_nmbd && ismyip_v4(wins_ip)) {
/* yikes! we'll loop forever */
continue;
}
-
/* skip any that have been unresponsive lately */
if (wins_srv_is_dead(wins_ip, src_ip)) {
continue;
}
+ DEBUG(3, ("resolve_wins: using WINS server %s "
+ "and tag '%s'\n",
+ inet_ntoa(wins_ip), wins_tags[i]));
+ alive[num_alive] = wins_ip;
+ num_alive += 1;
+ }
+ TALLOC_FREE(servers);
- DEBUG(3,("resolve_wins: using WINS server %s "
- "and tag '%s'\n",
- inet_ntoa(wins_ip), wins_tags[t]));
+ if (num_alive == 0) {
+ continue;
+ }
- in_addr_to_sockaddr_storage(&wins_ss, wins_ip);
- status = name_query(name,
- name_type,
- false,
- true,
- &wins_ss,
- talloc_tos(),
- &ss_list,
- return_count,
- NULL);
+ subreq = query_wins_list_send(
+ state, ev, src_ip, name, name_type,
+ alive, num_alive);
+ if (tevent_req_nomem(subreq, req)) {
+ goto fail;
+ }
+ tevent_req_set_callback(subreq, resolve_wins_done, req);
+ state->num_sent += 1;
+ }
- /* exit loop if we got a list of addresses */
+ if (state->num_sent == 0) {
+ tevent_req_nterror(req, NT_STATUS_NOT_FOUND);
+ goto fail;
+ }
- if (NT_STATUS_IS_OK(status)) {
- goto success;
- }
+ wins_srv_tags_free(wins_tags);
+ return req;
+fail:
+ wins_srv_tags_free(wins_tags);
+ return tevent_req_post(req, ev);
+}
- if (NT_STATUS_EQUAL(status,
- NT_STATUS_IO_TIMEOUT)) {
- /* Timed out waiting for WINS server to
- * respond.
- * Mark it dead. */
- wins_srv_died(wins_ip, src_ip);
- } else {
- /* The name definitely isn't in this
- group of WINS servers.
- goto the next group */
- break;
- }
- }
+static void resolve_wins_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct resolve_wins_state *state = tevent_req_data(
+ req, struct resolve_wins_state);
+ NTSTATUS status;
+
+ status = query_wins_list_recv(subreq, state, &state->addrs,
+ &state->num_addrs, &state->flags);
+ if (NT_STATUS_IS_OK(status)) {
+ tevent_req_done(req);
+ return;
}
- wins_srv_tags_free(wins_tags);
- return NT_STATUS_NO_LOGON_SERVERS;
+ state->num_received += 1;
-success:
+ if (state->num_received < state->num_sent) {
+ /*
+ * Wait for the others
+ */
+ return;
+ }
+ tevent_req_nterror(req, status);
+}
- status = NT_STATUS_OK;
- if (!convert_ss2service(return_iplist, ss_list, *return_count))
- status = NT_STATUS_INVALID_PARAMETER;
+NTSTATUS resolve_wins_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **addrs,
+ int *num_addrs, uint8_t *flags)
+{
+ struct resolve_wins_state *state = tevent_req_data(
+ req, struct resolve_wins_state);
+ NTSTATUS status;
- TALLOC_FREE(ss_list);
- wins_srv_tags_free(wins_tags);
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+ if (addrs != NULL) {
+ *addrs = talloc_move(mem_ctx, &state->addrs);
+ }
+ if (num_addrs != NULL) {
+ *num_addrs = state->num_addrs;
+ }
+ if (flags != NULL) {
+ *flags = state->flags;
+ }
+ return NT_STATUS_OK;
+}
+/********************************************************
+ Resolve via "wins" method.
+*********************************************************/
+
+NTSTATUS resolve_wins(const char *name,
+ int name_type,
+ TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **return_iplist,
+ int *return_count)
+{
+ struct tevent_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ ev = tevent_context_init(talloc_tos());
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = resolve_wins_send(ev, ev, name, name_type);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = resolve_wins_recv(req, mem_ctx, return_iplist, return_count,
+ NULL);
+fail:
+ TALLOC_FREE(ev);
return status;
}
@@ -1744,6 +2266,7 @@ static NTSTATUS resolve_hosts(const char *name, int name_type,
struct addrinfo *res = NULL;
int ret = -1;
int i = 0;
+ const char *dns_hosts_file;
if ( name_type != 0x20 && name_type != 0x0) {
DEBUG(5, ("resolve_hosts: not appropriate "
@@ -1768,6 +2291,32 @@ static NTSTATUS resolve_hosts(const char *name, int name_type,
hints.ai_family = AF_INET;
#endif
+ dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
+ if (dns_hosts_file) {
+ struct sockaddr_storage *ss_list;
+ NTSTATUS status;
+ TALLOC_CTX *ctx = talloc_stackframe();
+ if (!ctx) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = resolve_dns_hosts_file_as_sockaddr(dns_hosts_file, name, false,
+ ctx, &ss_list, return_count);
+ if (NT_STATUS_IS_OK(status)) {
+ if (convert_ss2service(return_iplist,
+ ss_list,
+ *return_count)) {
+ talloc_free(ctx);
+ return NT_STATUS_OK;
+ } else {
+ talloc_free(ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+ talloc_free(ctx);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
ret = getaddrinfo(name,
NULL,
&hints,
@@ -2044,19 +2593,32 @@ NTSTATUS internal_resolve_name(const char *name,
}
} else if(strequal( tok, "wins")) {
/* don't resolve 1D via WINS */
+ struct sockaddr_storage *ss_list;
if (name_type != 0x1D) {
status = resolve_wins(name, name_type,
- return_iplist,
+ talloc_tos(),
+ &ss_list,
return_count);
if (NT_STATUS_IS_OK(status)) {
+ if (!convert_ss2service(return_iplist,
+ ss_list,
+ *return_count)) {
+ status = NT_STATUS_NO_MEMORY;
+ }
goto done;
}
}
} else if(strequal( tok, "bcast")) {
- status = name_resolve_bcast(name, name_type,
- return_iplist,
- return_count);
+ struct sockaddr_storage *ss_list;
+ status = name_resolve_bcast(
+ name, name_type, talloc_tos(),
+ &ss_list, return_count);
if (NT_STATUS_IS_OK(status)) {
+ if (!convert_ss2service(return_iplist,
+ ss_list,
+ *return_count)) {
+ status = NT_STATUS_NO_MEMORY;
+ }
goto done;
}
} else {
@@ -2152,7 +2714,7 @@ bool resolve_name(const char *name,
if (prefer_ipv4) {
for (i=0; i<count; i++) {
if (!is_zero_addr(&ss_list[i].ss) &&
- !is_broadcast_addr((struct sockaddr *)&ss_list[i].ss) &&
+ !is_broadcast_addr((struct sockaddr *)(void *)&ss_list[i].ss) &&
(ss_list[i].ss.ss_family == AF_INET)) {
*return_ss = ss_list[i].ss;
SAFE_FREE(ss_list);
@@ -2165,7 +2727,7 @@ bool resolve_name(const char *name,
/* only return valid addresses for TCP connections */
for (i=0; i<count; i++) {
if (!is_zero_addr(&ss_list[i].ss) &&
- !is_broadcast_addr((struct sockaddr *)&ss_list[i].ss)) {
+ !is_broadcast_addr((struct sockaddr *)(void *)&ss_list[i].ss)) {
*return_ss = ss_list[i].ss;
SAFE_FREE(ss_list);
SAFE_FREE(sitename);
@@ -2203,7 +2765,7 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
*return_ss_arr = NULL;
if (is_ipaddress(name)) {
- *return_ss_arr = TALLOC_P(ctx, struct sockaddr_storage);
+ *return_ss_arr = talloc(ctx, struct sockaddr_storage);
if (!*return_ss_arr) {
return NT_STATUS_NO_MEMORY;
}
@@ -2229,7 +2791,7 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
/* only return valid addresses for TCP connections */
for (i=0, num_entries = 0; i<count; i++) {
if (!is_zero_addr(&ss_list[i].ss) &&
- !is_broadcast_addr((struct sockaddr *)&ss_list[i].ss)) {
+ !is_broadcast_addr((struct sockaddr *)(void *)&ss_list[i].ss)) {
num_entries++;
}
}
@@ -2238,7 +2800,7 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
return NT_STATUS_BAD_NETWORK_NAME;
}
- *return_ss_arr = TALLOC_ARRAY(ctx,
+ *return_ss_arr = talloc_array(ctx,
struct sockaddr_storage,
num_entries);
if (!(*return_ss_arr)) {
@@ -2248,7 +2810,7 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
for (i=0, num_entries = 0; i<count; i++) {
if (!is_zero_addr(&ss_list[i].ss) &&
- !is_broadcast_addr((struct sockaddr *)&ss_list[i].ss)) {
+ !is_broadcast_addr((struct sockaddr *)(void *)&ss_list[i].ss)) {
(*return_ss_arr)[num_entries++] = ss_list[i].ss;
}
}
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index dbf996ee5e7..767ff81476e 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -288,7 +288,7 @@ void put_name(char *dest, const char *name, int pad, unsigned int name_type)
If buf == NULL this is a length calculation.
******************************************************************/
-static int put_nmb_name(char *buf,int offset,struct nmb_name *name)
+static int put_nmb_name(char *buf, size_t buflen, int offset,struct nmb_name *name)
{
int ret,m;
nstring buf1;
@@ -302,6 +302,9 @@ static int put_nmb_name(char *buf,int offset,struct nmb_name *name)
}
if (buf) {
+ if (offset >= buflen) {
+ return 0;
+ }
buf[offset] = 0x20;
}
@@ -309,6 +312,9 @@ static int put_nmb_name(char *buf,int offset,struct nmb_name *name)
for (m=0;m<MAX_NETBIOSNAME_LEN;m++) {
if (buf) {
+ if (offset+2+2*m >= buflen) {
+ return 0;
+ }
buf[offset+1+2*m] = 'A' + ((buf1[m]>>4)&0xF);
buf[offset+2+2*m] = 'A' + (buf1[m]&0xF);
}
@@ -316,20 +322,30 @@ static int put_nmb_name(char *buf,int offset,struct nmb_name *name)
offset += 33;
if (buf) {
+ if (offset >= buflen) {
+ return 0;
+ }
buf[offset] = 0;
}
if (name->scope[0]) {
/* XXXX this scope handling needs testing */
- ret += strlen(name->scope) + 1;
+ size_t scopenamelen = strlen(name->scope) + 1;
+ ret += scopenamelen;
if (buf) {
- safe_strcpy(&buf[offset+1],name->scope,
- sizeof(name->scope));
+ if (offset+1+scopenamelen >= buflen) {
+ return 0;
+ }
+ strlcpy(&buf[offset+1],name->scope,
+ buflen - (offset+1));
p = &buf[offset+1];
while ((p = strchr_m(p,'.'))) {
buf[offset] = PTR_DIFF(p,&buf[offset+1]);
offset += (buf[offset] + 1);
+ if (offset+1 >= buflen) {
+ return 0;
+ }
p = &buf[offset+1];
}
buf[offset] = strlen(&buf[offset+1]);
@@ -404,13 +420,13 @@ static bool parse_alloc_res_rec(char *inbuf,int *offset,int length,
If buf == NULL this is a length calculation.
******************************************************************/
-static int put_res_rec(char *buf,int offset,struct res_rec *recs,int count)
+static int put_res_rec(char *buf, size_t buflen, int offset,struct res_rec *recs,int count)
{
int ret=0;
int i;
for (i=0;i<count;i++) {
- int l = put_nmb_name(buf,offset,&recs[i].rr_name);
+ int l = put_nmb_name(buf,buflen,offset,&recs[i].rr_name);
offset += l;
ret += l;
if (buf) {
@@ -887,8 +903,8 @@ static int build_dgram(char *buf, size_t len, struct dgram_packet *dgram)
if (dgram->header.msg_type == 0x10 ||
dgram->header.msg_type == 0x11 ||
dgram->header.msg_type == 0x12) {
- offset += put_nmb_name((char *)ubuf,offset,&dgram->source_name);
- offset += put_nmb_name((char *)ubuf,offset,&dgram->dest_name);
+ offset += put_nmb_name((char *)ubuf,len,offset,&dgram->source_name);
+ offset += put_nmb_name((char *)ubuf,len,offset,&dgram->dest_name);
}
if (buf) {
@@ -920,7 +936,7 @@ void make_nmb_name( struct nmb_name *n, const char *name, int type)
strupper_m(unix_name);
push_ascii(n->name, unix_name, sizeof(n->name), STR_TERMINATE);
n->name_type = (unsigned int)type & 0xFF;
- push_ascii(n->scope, global_scope(), 64, STR_TERMINATE);
+ push_ascii(n->scope, lp_netbios_scope(), 64, STR_TERMINATE);
}
/*******************************************************************
@@ -979,13 +995,13 @@ static int build_nmb(char *buf, size_t len, struct nmb_packet *nmb)
/* XXXX this doesn't handle a qdcount of > 1 */
if (len) {
/* Length check. */
- int extra = put_nmb_name(NULL,offset,
+ int extra = put_nmb_name(NULL,0,offset,
&nmb->question.question_name);
if (offset + extra > len) {
return 0;
}
}
- offset += put_nmb_name((char *)ubuf,offset,
+ offset += put_nmb_name((char *)ubuf,len,offset,
&nmb->question.question_name);
if (buf) {
RSSVAL(ubuf,offset,nmb->question.question_type);
@@ -997,26 +1013,26 @@ static int build_nmb(char *buf, size_t len, struct nmb_packet *nmb)
if (nmb->header.ancount) {
if (len) {
/* Length check. */
- int extra = put_res_rec(NULL,offset,nmb->answers,
+ int extra = put_res_rec(NULL,0,offset,nmb->answers,
nmb->header.ancount);
if (offset + extra > len) {
return 0;
}
}
- offset += put_res_rec((char *)ubuf,offset,nmb->answers,
+ offset += put_res_rec((char *)ubuf,len,offset,nmb->answers,
nmb->header.ancount);
}
if (nmb->header.nscount) {
if (len) {
/* Length check. */
- int extra = put_res_rec(NULL,offset,nmb->nsrecs,
+ int extra = put_res_rec(NULL,0,offset,nmb->nsrecs,
nmb->header.nscount);
if (offset + extra > len) {
return 0;
}
}
- offset += put_res_rec((char *)ubuf,offset,nmb->nsrecs,
+ offset += put_res_rec((char *)ubuf,len,offset,nmb->nsrecs,
nmb->header.nscount);
}
@@ -1048,13 +1064,13 @@ static int build_nmb(char *buf, size_t len, struct nmb_packet *nmb)
} else if (nmb->header.arcount) {
if (len) {
/* Length check. */
- int extra = put_res_rec(NULL,offset,nmb->additional,
+ int extra = put_res_rec(NULL,0,offset,nmb->additional,
nmb->header.arcount);
if (offset + extra > len) {
return 0;
}
}
- offset += put_res_rec((char *)ubuf,offset,nmb->additional,
+ offset += put_res_rec((char *)ubuf,len,offset,nmb->additional,
nmb->header.arcount);
}
return offset;
@@ -1131,7 +1147,7 @@ bool match_mailslot_name(struct packet_struct *p, const char *mailslot_name)
Return the number of bits that match between two len character buffers
***************************************************************************/
-int matching_len_bits(unsigned char *p1, unsigned char *p2, size_t len)
+int matching_len_bits(const unsigned char *p1, const unsigned char *p2, size_t len)
{
size_t i, j;
int ret = 0;
@@ -1245,7 +1261,7 @@ char *name_mangle(TALLOC_CTX *mem_ctx, const char *In, char name_type)
char *result;
char *p;
- result = talloc_array(mem_ctx, char, 33 + strlen(global_scope()) + 2);
+ result = talloc_array(mem_ctx, char, 33 + strlen(lp_netbios_scope()) + 2);
if (result == NULL) {
return NULL;
}
@@ -1280,8 +1296,8 @@ char *name_mangle(TALLOC_CTX *mem_ctx, const char *In, char name_type)
p[0] = '\0';
/* Add the scope string. */
- for( i = 0, len = 0; *(global_scope()) != '\0'; i++, len++ ) {
- switch( (global_scope())[i] ) {
+ for( i = 0, len = 0; *(lp_netbios_scope()) != '\0'; i++, len++ ) {
+ switch( (lp_netbios_scope())[i] ) {
case '\0':
p[0] = len;
if( len > 0 )
@@ -1293,7 +1309,7 @@ char *name_mangle(TALLOC_CTX *mem_ctx, const char *In, char name_type)
len = -1;
break;
default:
- p[len+1] = (global_scope())[i];
+ p[len+1] = (lp_netbios_scope())[i];
break;
}
}
diff --git a/source3/libsmb/nmblib.h b/source3/libsmb/nmblib.h
index a6666a84c61..d8290dc0765 100644
--- a/source3/libsmb/nmblib.h
+++ b/source3/libsmb/nmblib.h
@@ -1,3 +1,28 @@
+/*
+ Unix SMB/CIFS implementation.
+ handle unexpected packets
+ NBT netbios library routines
+ Copyright (C) Andrew Tridgell 1994-1998, 2000
+ Copyright (C) Jeremy Allison 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 _LIBSMB_NMBLIB_H_
+#define _LIBSMB_NMBLIB_H_
+
/* The following definitions come from libsmb/unexpected.c */
#include "nameserv.h"
@@ -42,8 +67,10 @@ bool nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
int build_packet(char *buf, size_t buflen, struct packet_struct *p);
bool send_packet(struct packet_struct *p);
bool match_mailslot_name(struct packet_struct *p, const char *mailslot_name);
-int matching_len_bits(unsigned char *p1, unsigned char *p2, size_t len);
+int matching_len_bits(const unsigned char *p1, const unsigned char *p2, size_t len);
void sort_query_replies(char *data, int n, struct in_addr ip);
char *name_mangle(TALLOC_CTX *mem_ctx, const char *In, char name_type);
int name_extract(unsigned char *buf,size_t buf_len, unsigned int ofs, fstring name);
int name_len(unsigned char *s1, size_t buf_len);
+
+#endif /* _LIBSMB_NMBLIB_H_ */
diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c
deleted file mode 100644
index 321965878d1..00000000000
--- a/source3/libsmb/nterr.c
+++ /dev/null
@@ -1,802 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * RPC Pipe client / server routines
- * Copyright (C) Luke Kenneth Casson Leighton 1997-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/>.
- */
-
-/* NT error codes. please read nterr.h */
-
-#include "includes.h"
-#include "smb_ldap.h"
-#undef strcasecmp
-
-#if !defined(N_)
-#define N_(string) string
-#endif
-
-typedef struct
-{
- const char *nt_errstr;
- NTSTATUS nt_errcode;
-} nt_err_code_struct;
-
-static const nt_err_code_struct nt_errs[] =
-{
- { "NT_STATUS_OK", NT_STATUS_OK },
- { "STATUS_NO_MORE_FILES", STATUS_NO_MORE_FILES },
- { "STATUS_NO_MORE_EAS", STATUS_NO_MORE_EAS },
- { "STATUS_INVALID_EA_NAME", STATUS_INVALID_EA_NAME },
- { "STATUS_EA_LIST_INCONSISTENT", STATUS_EA_LIST_INCONSISTENT },
- { "STATUS_INVALID_EA_FLAG", STATUS_INVALID_EA_FLAG },
- { "NT_STATUS_UNSUCCESSFUL", NT_STATUS_UNSUCCESSFUL },
- { "NT_STATUS_NOT_IMPLEMENTED", NT_STATUS_NOT_IMPLEMENTED },
- { "NT_STATUS_INVALID_INFO_CLASS", NT_STATUS_INVALID_INFO_CLASS },
- { "NT_STATUS_INFO_LENGTH_MISMATCH", NT_STATUS_INFO_LENGTH_MISMATCH },
- { "NT_STATUS_ACCESS_VIOLATION", NT_STATUS_ACCESS_VIOLATION },
- { "STATUS_BUFFER_OVERFLOW", STATUS_BUFFER_OVERFLOW },
- { "NT_STATUS_IN_PAGE_ERROR", NT_STATUS_IN_PAGE_ERROR },
- { "NT_STATUS_PAGEFILE_QUOTA", NT_STATUS_PAGEFILE_QUOTA },
- { "NT_STATUS_INVALID_HANDLE", NT_STATUS_INVALID_HANDLE },
- { "NT_STATUS_BAD_INITIAL_STACK", NT_STATUS_BAD_INITIAL_STACK },
- { "NT_STATUS_BAD_INITIAL_PC", NT_STATUS_BAD_INITIAL_PC },
- { "NT_STATUS_INVALID_CID", NT_STATUS_INVALID_CID },
- { "NT_STATUS_TIMER_NOT_CANCELED", NT_STATUS_TIMER_NOT_CANCELED },
- { "NT_STATUS_INVALID_PARAMETER", NT_STATUS_INVALID_PARAMETER },
- { "NT_STATUS_NO_SUCH_DEVICE", NT_STATUS_NO_SUCH_DEVICE },
- { "NT_STATUS_NO_SUCH_FILE", NT_STATUS_NO_SUCH_FILE },
- { "NT_STATUS_INVALID_DEVICE_REQUEST", NT_STATUS_INVALID_DEVICE_REQUEST },
- { "NT_STATUS_END_OF_FILE", NT_STATUS_END_OF_FILE },
- { "NT_STATUS_WRONG_VOLUME", NT_STATUS_WRONG_VOLUME },
- { "NT_STATUS_NO_MEDIA_IN_DEVICE", NT_STATUS_NO_MEDIA_IN_DEVICE },
- { "NT_STATUS_UNRECOGNIZED_MEDIA", NT_STATUS_UNRECOGNIZED_MEDIA },
- { "NT_STATUS_NONEXISTENT_SECTOR", NT_STATUS_NONEXISTENT_SECTOR },
- { "NT_STATUS_MORE_PROCESSING_REQUIRED", NT_STATUS_MORE_PROCESSING_REQUIRED },
- { "NT_STATUS_NO_MEMORY", NT_STATUS_NO_MEMORY },
- { "NT_STATUS_CONFLICTING_ADDRESSES", NT_STATUS_CONFLICTING_ADDRESSES },
- { "NT_STATUS_NOT_MAPPED_VIEW", NT_STATUS_NOT_MAPPED_VIEW },
- { "NT_STATUS_UNABLE_TO_FREE_VM", NT_STATUS_UNABLE_TO_FREE_VM },
- { "NT_STATUS_UNABLE_TO_DELETE_SECTION", NT_STATUS_UNABLE_TO_DELETE_SECTION },
- { "NT_STATUS_INVALID_SYSTEM_SERVICE", NT_STATUS_INVALID_SYSTEM_SERVICE },
- { "NT_STATUS_ILLEGAL_INSTRUCTION", NT_STATUS_ILLEGAL_INSTRUCTION },
- { "NT_STATUS_INVALID_LOCK_SEQUENCE", NT_STATUS_INVALID_LOCK_SEQUENCE },
- { "NT_STATUS_INVALID_VIEW_SIZE", NT_STATUS_INVALID_VIEW_SIZE },
- { "NT_STATUS_INVALID_FILE_FOR_SECTION", NT_STATUS_INVALID_FILE_FOR_SECTION },
- { "NT_STATUS_ALREADY_COMMITTED", NT_STATUS_ALREADY_COMMITTED },
- { "NT_STATUS_ACCESS_DENIED", NT_STATUS_ACCESS_DENIED },
- { "NT_STATUS_BUFFER_TOO_SMALL", NT_STATUS_BUFFER_TOO_SMALL },
- { "NT_STATUS_OBJECT_TYPE_MISMATCH", NT_STATUS_OBJECT_TYPE_MISMATCH },
- { "NT_STATUS_NONCONTINUABLE_EXCEPTION", NT_STATUS_NONCONTINUABLE_EXCEPTION },
- { "NT_STATUS_INVALID_DISPOSITION", NT_STATUS_INVALID_DISPOSITION },
- { "NT_STATUS_UNWIND", NT_STATUS_UNWIND },
- { "NT_STATUS_BAD_STACK", NT_STATUS_BAD_STACK },
- { "NT_STATUS_INVALID_UNWIND_TARGET", NT_STATUS_INVALID_UNWIND_TARGET },
- { "NT_STATUS_NOT_LOCKED", NT_STATUS_NOT_LOCKED },
- { "NT_STATUS_PARITY_ERROR", NT_STATUS_PARITY_ERROR },
- { "NT_STATUS_UNABLE_TO_DECOMMIT_VM", NT_STATUS_UNABLE_TO_DECOMMIT_VM },
- { "NT_STATUS_NOT_COMMITTED", NT_STATUS_NOT_COMMITTED },
- { "NT_STATUS_INVALID_PORT_ATTRIBUTES", NT_STATUS_INVALID_PORT_ATTRIBUTES },
- { "NT_STATUS_PORT_MESSAGE_TOO_LONG", NT_STATUS_PORT_MESSAGE_TOO_LONG },
- { "NT_STATUS_INVALID_PARAMETER_MIX", NT_STATUS_INVALID_PARAMETER_MIX },
- { "NT_STATUS_INVALID_QUOTA_LOWER", NT_STATUS_INVALID_QUOTA_LOWER },
- { "NT_STATUS_DISK_CORRUPT_ERROR", NT_STATUS_DISK_CORRUPT_ERROR },
- { "NT_STATUS_OBJECT_NAME_INVALID", NT_STATUS_OBJECT_NAME_INVALID },
- { "NT_STATUS_OBJECT_NAME_NOT_FOUND", NT_STATUS_OBJECT_NAME_NOT_FOUND },
- { "NT_STATUS_OBJECT_NAME_COLLISION", NT_STATUS_OBJECT_NAME_COLLISION },
- { "NT_STATUS_HANDLE_NOT_WAITABLE", NT_STATUS_HANDLE_NOT_WAITABLE },
- { "NT_STATUS_PORT_DISCONNECTED", NT_STATUS_PORT_DISCONNECTED },
- { "NT_STATUS_DEVICE_ALREADY_ATTACHED", NT_STATUS_DEVICE_ALREADY_ATTACHED },
- { "NT_STATUS_OBJECT_PATH_INVALID", NT_STATUS_OBJECT_PATH_INVALID },
- { "NT_STATUS_OBJECT_PATH_NOT_FOUND", NT_STATUS_OBJECT_PATH_NOT_FOUND },
- { "NT_STATUS_OBJECT_PATH_SYNTAX_BAD", NT_STATUS_OBJECT_PATH_SYNTAX_BAD },
- { "NT_STATUS_DATA_OVERRUN", NT_STATUS_DATA_OVERRUN },
- { "NT_STATUS_DATA_LATE_ERROR", NT_STATUS_DATA_LATE_ERROR },
- { "NT_STATUS_DATA_ERROR", NT_STATUS_DATA_ERROR },
- { "NT_STATUS_CRC_ERROR", NT_STATUS_CRC_ERROR },
- { "NT_STATUS_SECTION_TOO_BIG", NT_STATUS_SECTION_TOO_BIG },
- { "NT_STATUS_PORT_CONNECTION_REFUSED", NT_STATUS_PORT_CONNECTION_REFUSED },
- { "NT_STATUS_INVALID_PORT_HANDLE", NT_STATUS_INVALID_PORT_HANDLE },
- { "NT_STATUS_SHARING_VIOLATION", NT_STATUS_SHARING_VIOLATION },
- { "NT_STATUS_QUOTA_EXCEEDED", NT_STATUS_QUOTA_EXCEEDED },
- { "NT_STATUS_INVALID_PAGE_PROTECTION", NT_STATUS_INVALID_PAGE_PROTECTION },
- { "NT_STATUS_MUTANT_NOT_OWNED", NT_STATUS_MUTANT_NOT_OWNED },
- { "NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED", NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED },
- { "NT_STATUS_PORT_ALREADY_SET", NT_STATUS_PORT_ALREADY_SET },
- { "NT_STATUS_SECTION_NOT_IMAGE", NT_STATUS_SECTION_NOT_IMAGE },
- { "NT_STATUS_SUSPEND_COUNT_EXCEEDED", NT_STATUS_SUSPEND_COUNT_EXCEEDED },
- { "NT_STATUS_THREAD_IS_TERMINATING", NT_STATUS_THREAD_IS_TERMINATING },
- { "NT_STATUS_BAD_WORKING_SET_LIMIT", NT_STATUS_BAD_WORKING_SET_LIMIT },
- { "NT_STATUS_INCOMPATIBLE_FILE_MAP", NT_STATUS_INCOMPATIBLE_FILE_MAP },
- { "NT_STATUS_SECTION_PROTECTION", NT_STATUS_SECTION_PROTECTION },
- { "NT_STATUS_EAS_NOT_SUPPORTED", NT_STATUS_EAS_NOT_SUPPORTED },
- { "NT_STATUS_EA_TOO_LARGE", NT_STATUS_EA_TOO_LARGE },
- { "NT_STATUS_NONEXISTENT_EA_ENTRY", NT_STATUS_NONEXISTENT_EA_ENTRY },
- { "NT_STATUS_NO_EAS_ON_FILE", NT_STATUS_NO_EAS_ON_FILE },
- { "NT_STATUS_EA_CORRUPT_ERROR", NT_STATUS_EA_CORRUPT_ERROR },
- { "NT_STATUS_FILE_LOCK_CONFLICT", NT_STATUS_FILE_LOCK_CONFLICT },
- { "NT_STATUS_LOCK_NOT_GRANTED", NT_STATUS_LOCK_NOT_GRANTED },
- { "NT_STATUS_DELETE_PENDING", NT_STATUS_DELETE_PENDING },
- { "NT_STATUS_CTL_FILE_NOT_SUPPORTED", NT_STATUS_CTL_FILE_NOT_SUPPORTED },
- { "NT_STATUS_UNKNOWN_REVISION", NT_STATUS_UNKNOWN_REVISION },
- { "NT_STATUS_REVISION_MISMATCH", NT_STATUS_REVISION_MISMATCH },
- { "NT_STATUS_INVALID_OWNER", NT_STATUS_INVALID_OWNER },
- { "NT_STATUS_INVALID_PRIMARY_GROUP", NT_STATUS_INVALID_PRIMARY_GROUP },
- { "NT_STATUS_NO_IMPERSONATION_TOKEN", NT_STATUS_NO_IMPERSONATION_TOKEN },
- { "NT_STATUS_CANT_DISABLE_MANDATORY", NT_STATUS_CANT_DISABLE_MANDATORY },
- { "NT_STATUS_NO_LOGON_SERVERS", NT_STATUS_NO_LOGON_SERVERS },
- { "NT_STATUS_NO_SUCH_LOGON_SESSION", NT_STATUS_NO_SUCH_LOGON_SESSION },
- { "NT_STATUS_NO_SUCH_PRIVILEGE", NT_STATUS_NO_SUCH_PRIVILEGE },
- { "NT_STATUS_PRIVILEGE_NOT_HELD", NT_STATUS_PRIVILEGE_NOT_HELD },
- { "NT_STATUS_INVALID_ACCOUNT_NAME", NT_STATUS_INVALID_ACCOUNT_NAME },
- { "NT_STATUS_USER_EXISTS", NT_STATUS_USER_EXISTS },
- { "NT_STATUS_NO_SUCH_USER", NT_STATUS_NO_SUCH_USER },
- { "NT_STATUS_GROUP_EXISTS", NT_STATUS_GROUP_EXISTS },
- { "NT_STATUS_NO_SUCH_GROUP", NT_STATUS_NO_SUCH_GROUP },
- { "NT_STATUS_MEMBER_IN_GROUP", NT_STATUS_MEMBER_IN_GROUP },
- { "NT_STATUS_MEMBER_NOT_IN_GROUP", NT_STATUS_MEMBER_NOT_IN_GROUP },
- { "NT_STATUS_LAST_ADMIN", NT_STATUS_LAST_ADMIN },
- { "NT_STATUS_WRONG_PASSWORD", NT_STATUS_WRONG_PASSWORD },
- { "NT_STATUS_ILL_FORMED_PASSWORD", NT_STATUS_ILL_FORMED_PASSWORD },
- { "NT_STATUS_PASSWORD_RESTRICTION", NT_STATUS_PASSWORD_RESTRICTION },
- { "NT_STATUS_LOGON_FAILURE", NT_STATUS_LOGON_FAILURE },
- { "NT_STATUS_ACCOUNT_RESTRICTION", NT_STATUS_ACCOUNT_RESTRICTION },
- { "NT_STATUS_INVALID_LOGON_HOURS", NT_STATUS_INVALID_LOGON_HOURS },
- { "NT_STATUS_INVALID_WORKSTATION", NT_STATUS_INVALID_WORKSTATION },
- { "NT_STATUS_PASSWORD_EXPIRED", NT_STATUS_PASSWORD_EXPIRED },
- { "NT_STATUS_ACCOUNT_DISABLED", NT_STATUS_ACCOUNT_DISABLED },
- { "NT_STATUS_NONE_MAPPED", NT_STATUS_NONE_MAPPED },
- { "NT_STATUS_TOO_MANY_LUIDS_REQUESTED", NT_STATUS_TOO_MANY_LUIDS_REQUESTED },
- { "NT_STATUS_LUIDS_EXHAUSTED", NT_STATUS_LUIDS_EXHAUSTED },
- { "NT_STATUS_INVALID_SUB_AUTHORITY", NT_STATUS_INVALID_SUB_AUTHORITY },
- { "NT_STATUS_INVALID_ACL", NT_STATUS_INVALID_ACL },
- { "NT_STATUS_INVALID_SID", NT_STATUS_INVALID_SID },
- { "NT_STATUS_INVALID_SECURITY_DESCR", NT_STATUS_INVALID_SECURITY_DESCR },
- { "NT_STATUS_PROCEDURE_NOT_FOUND", NT_STATUS_PROCEDURE_NOT_FOUND },
- { "NT_STATUS_INVALID_IMAGE_FORMAT", NT_STATUS_INVALID_IMAGE_FORMAT },
- { "NT_STATUS_NO_TOKEN", NT_STATUS_NO_TOKEN },
- { "NT_STATUS_BAD_INHERITANCE_ACL", NT_STATUS_BAD_INHERITANCE_ACL },
- { "NT_STATUS_RANGE_NOT_LOCKED", NT_STATUS_RANGE_NOT_LOCKED },
- { "NT_STATUS_DISK_FULL", NT_STATUS_DISK_FULL },
- { "NT_STATUS_SERVER_DISABLED", NT_STATUS_SERVER_DISABLED },
- { "NT_STATUS_SERVER_NOT_DISABLED", NT_STATUS_SERVER_NOT_DISABLED },
- { "NT_STATUS_TOO_MANY_GUIDS_REQUESTED", NT_STATUS_TOO_MANY_GUIDS_REQUESTED },
- { "NT_STATUS_GUIDS_EXHAUSTED", NT_STATUS_GUIDS_EXHAUSTED },
- { "NT_STATUS_INVALID_ID_AUTHORITY", NT_STATUS_INVALID_ID_AUTHORITY },
- { "NT_STATUS_AGENTS_EXHAUSTED", NT_STATUS_AGENTS_EXHAUSTED },
- { "NT_STATUS_INVALID_VOLUME_LABEL", NT_STATUS_INVALID_VOLUME_LABEL },
- { "NT_STATUS_SECTION_NOT_EXTENDED", NT_STATUS_SECTION_NOT_EXTENDED },
- { "NT_STATUS_NOT_MAPPED_DATA", NT_STATUS_NOT_MAPPED_DATA },
- { "NT_STATUS_RESOURCE_DATA_NOT_FOUND", NT_STATUS_RESOURCE_DATA_NOT_FOUND },
- { "NT_STATUS_RESOURCE_TYPE_NOT_FOUND", NT_STATUS_RESOURCE_TYPE_NOT_FOUND },
- { "NT_STATUS_RESOURCE_NAME_NOT_FOUND", NT_STATUS_RESOURCE_NAME_NOT_FOUND },
- { "NT_STATUS_ARRAY_BOUNDS_EXCEEDED", NT_STATUS_ARRAY_BOUNDS_EXCEEDED },
- { "NT_STATUS_FLOAT_DENORMAL_OPERAND", NT_STATUS_FLOAT_DENORMAL_OPERAND },
- { "NT_STATUS_FLOAT_DIVIDE_BY_ZERO", NT_STATUS_FLOAT_DIVIDE_BY_ZERO },
- { "NT_STATUS_FLOAT_INEXACT_RESULT", NT_STATUS_FLOAT_INEXACT_RESULT },
- { "NT_STATUS_FLOAT_INVALID_OPERATION", NT_STATUS_FLOAT_INVALID_OPERATION },
- { "NT_STATUS_FLOAT_OVERFLOW", NT_STATUS_FLOAT_OVERFLOW },
- { "NT_STATUS_FLOAT_STACK_CHECK", NT_STATUS_FLOAT_STACK_CHECK },
- { "NT_STATUS_FLOAT_UNDERFLOW", NT_STATUS_FLOAT_UNDERFLOW },
- { "NT_STATUS_INTEGER_DIVIDE_BY_ZERO", NT_STATUS_INTEGER_DIVIDE_BY_ZERO },
- { "NT_STATUS_INTEGER_OVERFLOW", NT_STATUS_INTEGER_OVERFLOW },
- { "NT_STATUS_PRIVILEGED_INSTRUCTION", NT_STATUS_PRIVILEGED_INSTRUCTION },
- { "NT_STATUS_TOO_MANY_PAGING_FILES", NT_STATUS_TOO_MANY_PAGING_FILES },
- { "NT_STATUS_FILE_INVALID", NT_STATUS_FILE_INVALID },
- { "NT_STATUS_ALLOTTED_SPACE_EXCEEDED", NT_STATUS_ALLOTTED_SPACE_EXCEEDED },
- { "NT_STATUS_INSUFFICIENT_RESOURCES", NT_STATUS_INSUFFICIENT_RESOURCES },
- { "NT_STATUS_DFS_EXIT_PATH_FOUND", NT_STATUS_DFS_EXIT_PATH_FOUND },
- { "NT_STATUS_DEVICE_DATA_ERROR", NT_STATUS_DEVICE_DATA_ERROR },
- { "NT_STATUS_DEVICE_NOT_CONNECTED", NT_STATUS_DEVICE_NOT_CONNECTED },
- { "NT_STATUS_DEVICE_POWER_FAILURE", NT_STATUS_DEVICE_POWER_FAILURE },
- { "NT_STATUS_FREE_VM_NOT_AT_BASE", NT_STATUS_FREE_VM_NOT_AT_BASE },
- { "NT_STATUS_MEMORY_NOT_ALLOCATED", NT_STATUS_MEMORY_NOT_ALLOCATED },
- { "NT_STATUS_WORKING_SET_QUOTA", NT_STATUS_WORKING_SET_QUOTA },
- { "NT_STATUS_MEDIA_WRITE_PROTECTED", NT_STATUS_MEDIA_WRITE_PROTECTED },
- { "NT_STATUS_DEVICE_NOT_READY", NT_STATUS_DEVICE_NOT_READY },
- { "NT_STATUS_INVALID_GROUP_ATTRIBUTES", NT_STATUS_INVALID_GROUP_ATTRIBUTES },
- { "NT_STATUS_BAD_IMPERSONATION_LEVEL", NT_STATUS_BAD_IMPERSONATION_LEVEL },
- { "NT_STATUS_CANT_OPEN_ANONYMOUS", NT_STATUS_CANT_OPEN_ANONYMOUS },
- { "NT_STATUS_BAD_VALIDATION_CLASS", NT_STATUS_BAD_VALIDATION_CLASS },
- { "NT_STATUS_BAD_TOKEN_TYPE", NT_STATUS_BAD_TOKEN_TYPE },
- { "NT_STATUS_BAD_MASTER_BOOT_RECORD", NT_STATUS_BAD_MASTER_BOOT_RECORD },
- { "NT_STATUS_INSTRUCTION_MISALIGNMENT", NT_STATUS_INSTRUCTION_MISALIGNMENT },
- { "NT_STATUS_INSTANCE_NOT_AVAILABLE", NT_STATUS_INSTANCE_NOT_AVAILABLE },
- { "NT_STATUS_PIPE_NOT_AVAILABLE", NT_STATUS_PIPE_NOT_AVAILABLE },
- { "NT_STATUS_INVALID_PIPE_STATE", NT_STATUS_INVALID_PIPE_STATE },
- { "NT_STATUS_PIPE_BUSY", NT_STATUS_PIPE_BUSY },
- { "NT_STATUS_ILLEGAL_FUNCTION", NT_STATUS_ILLEGAL_FUNCTION },
- { "NT_STATUS_PIPE_DISCONNECTED", NT_STATUS_PIPE_DISCONNECTED },
- { "NT_STATUS_PIPE_CLOSING", NT_STATUS_PIPE_CLOSING },
- { "NT_STATUS_PIPE_CONNECTED", NT_STATUS_PIPE_CONNECTED },
- { "NT_STATUS_PIPE_LISTENING", NT_STATUS_PIPE_LISTENING },
- { "NT_STATUS_INVALID_READ_MODE", NT_STATUS_INVALID_READ_MODE },
- { "NT_STATUS_IO_TIMEOUT", NT_STATUS_IO_TIMEOUT },
- { "NT_STATUS_FILE_FORCED_CLOSED", NT_STATUS_FILE_FORCED_CLOSED },
- { "NT_STATUS_PROFILING_NOT_STARTED", NT_STATUS_PROFILING_NOT_STARTED },
- { "NT_STATUS_PROFILING_NOT_STOPPED", NT_STATUS_PROFILING_NOT_STOPPED },
- { "NT_STATUS_COULD_NOT_INTERPRET", NT_STATUS_COULD_NOT_INTERPRET },
- { "NT_STATUS_FILE_IS_A_DIRECTORY", NT_STATUS_FILE_IS_A_DIRECTORY },
- { "NT_STATUS_NOT_SUPPORTED", NT_STATUS_NOT_SUPPORTED },
- { "NT_STATUS_REMOTE_NOT_LISTENING", NT_STATUS_REMOTE_NOT_LISTENING },
- { "NT_STATUS_DUPLICATE_NAME", NT_STATUS_DUPLICATE_NAME },
- { "NT_STATUS_BAD_NETWORK_PATH", NT_STATUS_BAD_NETWORK_PATH },
- { "NT_STATUS_NETWORK_BUSY", NT_STATUS_NETWORK_BUSY },
- { "NT_STATUS_DEVICE_DOES_NOT_EXIST", NT_STATUS_DEVICE_DOES_NOT_EXIST },
- { "NT_STATUS_TOO_MANY_COMMANDS", NT_STATUS_TOO_MANY_COMMANDS },
- { "NT_STATUS_ADAPTER_HARDWARE_ERROR", NT_STATUS_ADAPTER_HARDWARE_ERROR },
- { "NT_STATUS_INVALID_NETWORK_RESPONSE", NT_STATUS_INVALID_NETWORK_RESPONSE },
- { "NT_STATUS_UNEXPECTED_NETWORK_ERROR", NT_STATUS_UNEXPECTED_NETWORK_ERROR },
- { "NT_STATUS_BAD_REMOTE_ADAPTER", NT_STATUS_BAD_REMOTE_ADAPTER },
- { "NT_STATUS_PRINT_QUEUE_FULL", NT_STATUS_PRINT_QUEUE_FULL },
- { "NT_STATUS_NO_SPOOL_SPACE", NT_STATUS_NO_SPOOL_SPACE },
- { "NT_STATUS_PRINT_CANCELLED", NT_STATUS_PRINT_CANCELLED },
- { "NT_STATUS_NETWORK_NAME_DELETED", NT_STATUS_NETWORK_NAME_DELETED },
- { "NT_STATUS_NETWORK_ACCESS_DENIED", NT_STATUS_NETWORK_ACCESS_DENIED },
- { "NT_STATUS_BAD_DEVICE_TYPE", NT_STATUS_BAD_DEVICE_TYPE },
- { "NT_STATUS_BAD_NETWORK_NAME", NT_STATUS_BAD_NETWORK_NAME },
- { "NT_STATUS_TOO_MANY_NAMES", NT_STATUS_TOO_MANY_NAMES },
- { "NT_STATUS_TOO_MANY_SESSIONS", NT_STATUS_TOO_MANY_SESSIONS },
- { "NT_STATUS_SHARING_PAUSED", NT_STATUS_SHARING_PAUSED },
- { "NT_STATUS_REQUEST_NOT_ACCEPTED", NT_STATUS_REQUEST_NOT_ACCEPTED },
- { "NT_STATUS_REDIRECTOR_PAUSED", NT_STATUS_REDIRECTOR_PAUSED },
- { "NT_STATUS_NET_WRITE_FAULT", NT_STATUS_NET_WRITE_FAULT },
- { "NT_STATUS_PROFILING_AT_LIMIT", NT_STATUS_PROFILING_AT_LIMIT },
- { "NT_STATUS_NOT_SAME_DEVICE", NT_STATUS_NOT_SAME_DEVICE },
- { "NT_STATUS_FILE_RENAMED", NT_STATUS_FILE_RENAMED },
- { "NT_STATUS_VIRTUAL_CIRCUIT_CLOSED", NT_STATUS_VIRTUAL_CIRCUIT_CLOSED },
- { "NT_STATUS_NO_SECURITY_ON_OBJECT", NT_STATUS_NO_SECURITY_ON_OBJECT },
- { "NT_STATUS_CANT_WAIT", NT_STATUS_CANT_WAIT },
- { "NT_STATUS_PIPE_EMPTY", NT_STATUS_PIPE_EMPTY },
- { "NT_STATUS_CANT_ACCESS_DOMAIN_INFO", NT_STATUS_CANT_ACCESS_DOMAIN_INFO },
- { "NT_STATUS_CANT_TERMINATE_SELF", NT_STATUS_CANT_TERMINATE_SELF },
- { "NT_STATUS_INVALID_SERVER_STATE", NT_STATUS_INVALID_SERVER_STATE },
- { "NT_STATUS_INVALID_DOMAIN_STATE", NT_STATUS_INVALID_DOMAIN_STATE },
- { "NT_STATUS_INVALID_DOMAIN_ROLE", NT_STATUS_INVALID_DOMAIN_ROLE },
- { "NT_STATUS_NO_SUCH_DOMAIN", NT_STATUS_NO_SUCH_DOMAIN },
- { "NT_STATUS_DOMAIN_EXISTS", NT_STATUS_DOMAIN_EXISTS },
- { "NT_STATUS_DOMAIN_LIMIT_EXCEEDED", NT_STATUS_DOMAIN_LIMIT_EXCEEDED },
- { "NT_STATUS_OPLOCK_NOT_GRANTED", NT_STATUS_OPLOCK_NOT_GRANTED },
- { "NT_STATUS_INVALID_OPLOCK_PROTOCOL", NT_STATUS_INVALID_OPLOCK_PROTOCOL },
- { "NT_STATUS_INTERNAL_DB_CORRUPTION", NT_STATUS_INTERNAL_DB_CORRUPTION },
- { "NT_STATUS_INTERNAL_ERROR", NT_STATUS_INTERNAL_ERROR },
- { "NT_STATUS_GENERIC_NOT_MAPPED", NT_STATUS_GENERIC_NOT_MAPPED },
- { "NT_STATUS_BAD_DESCRIPTOR_FORMAT", NT_STATUS_BAD_DESCRIPTOR_FORMAT },
- { "NT_STATUS_INVALID_USER_BUFFER", NT_STATUS_INVALID_USER_BUFFER },
- { "NT_STATUS_UNEXPECTED_IO_ERROR", NT_STATUS_UNEXPECTED_IO_ERROR },
- { "NT_STATUS_UNEXPECTED_MM_CREATE_ERR", NT_STATUS_UNEXPECTED_MM_CREATE_ERR },
- { "NT_STATUS_UNEXPECTED_MM_MAP_ERROR", NT_STATUS_UNEXPECTED_MM_MAP_ERROR },
- { "NT_STATUS_UNEXPECTED_MM_EXTEND_ERR", NT_STATUS_UNEXPECTED_MM_EXTEND_ERR },
- { "NT_STATUS_NOT_LOGON_PROCESS", NT_STATUS_NOT_LOGON_PROCESS },
- { "NT_STATUS_LOGON_SESSION_EXISTS", NT_STATUS_LOGON_SESSION_EXISTS },
- { "NT_STATUS_INVALID_PARAMETER_1", NT_STATUS_INVALID_PARAMETER_1 },
- { "NT_STATUS_INVALID_PARAMETER_2", NT_STATUS_INVALID_PARAMETER_2 },
- { "NT_STATUS_INVALID_PARAMETER_3", NT_STATUS_INVALID_PARAMETER_3 },
- { "NT_STATUS_INVALID_PARAMETER_4", NT_STATUS_INVALID_PARAMETER_4 },
- { "NT_STATUS_INVALID_PARAMETER_5", NT_STATUS_INVALID_PARAMETER_5 },
- { "NT_STATUS_INVALID_PARAMETER_6", NT_STATUS_INVALID_PARAMETER_6 },
- { "NT_STATUS_INVALID_PARAMETER_7", NT_STATUS_INVALID_PARAMETER_7 },
- { "NT_STATUS_INVALID_PARAMETER_8", NT_STATUS_INVALID_PARAMETER_8 },
- { "NT_STATUS_INVALID_PARAMETER_9", NT_STATUS_INVALID_PARAMETER_9 },
- { "NT_STATUS_INVALID_PARAMETER_10", NT_STATUS_INVALID_PARAMETER_10 },
- { "NT_STATUS_INVALID_PARAMETER_11", NT_STATUS_INVALID_PARAMETER_11 },
- { "NT_STATUS_INVALID_PARAMETER_12", NT_STATUS_INVALID_PARAMETER_12 },
- { "NT_STATUS_REDIRECTOR_NOT_STARTED", NT_STATUS_REDIRECTOR_NOT_STARTED },
- { "NT_STATUS_REDIRECTOR_STARTED", NT_STATUS_REDIRECTOR_STARTED },
- { "NT_STATUS_STACK_OVERFLOW", NT_STATUS_STACK_OVERFLOW },
- { "NT_STATUS_NO_SUCH_PACKAGE", NT_STATUS_NO_SUCH_PACKAGE },
- { "NT_STATUS_BAD_FUNCTION_TABLE", NT_STATUS_BAD_FUNCTION_TABLE },
- { "NT_STATUS_DIRECTORY_NOT_EMPTY", NT_STATUS_DIRECTORY_NOT_EMPTY },
- { "NT_STATUS_FILE_CORRUPT_ERROR", NT_STATUS_FILE_CORRUPT_ERROR },
- { "NT_STATUS_NOT_A_DIRECTORY", NT_STATUS_NOT_A_DIRECTORY },
- { "NT_STATUS_BAD_LOGON_SESSION_STATE", NT_STATUS_BAD_LOGON_SESSION_STATE },
- { "NT_STATUS_LOGON_SESSION_COLLISION", NT_STATUS_LOGON_SESSION_COLLISION },
- { "NT_STATUS_NAME_TOO_LONG", NT_STATUS_NAME_TOO_LONG },
- { "NT_STATUS_FILES_OPEN", NT_STATUS_FILES_OPEN },
- { "NT_STATUS_CONNECTION_IN_USE", NT_STATUS_CONNECTION_IN_USE },
- { "NT_STATUS_MESSAGE_NOT_FOUND", NT_STATUS_MESSAGE_NOT_FOUND },
- { "NT_STATUS_PROCESS_IS_TERMINATING", NT_STATUS_PROCESS_IS_TERMINATING },
- { "NT_STATUS_INVALID_LOGON_TYPE", NT_STATUS_INVALID_LOGON_TYPE },
- { "NT_STATUS_NO_GUID_TRANSLATION", NT_STATUS_NO_GUID_TRANSLATION },
- { "NT_STATUS_CANNOT_IMPERSONATE", NT_STATUS_CANNOT_IMPERSONATE },
- { "NT_STATUS_IMAGE_ALREADY_LOADED", NT_STATUS_IMAGE_ALREADY_LOADED },
- { "NT_STATUS_ABIOS_NOT_PRESENT", NT_STATUS_ABIOS_NOT_PRESENT },
- { "NT_STATUS_ABIOS_LID_NOT_EXIST", NT_STATUS_ABIOS_LID_NOT_EXIST },
- { "NT_STATUS_ABIOS_LID_ALREADY_OWNED", NT_STATUS_ABIOS_LID_ALREADY_OWNED },
- { "NT_STATUS_ABIOS_NOT_LID_OWNER", NT_STATUS_ABIOS_NOT_LID_OWNER },
- { "NT_STATUS_ABIOS_INVALID_COMMAND", NT_STATUS_ABIOS_INVALID_COMMAND },
- { "NT_STATUS_ABIOS_INVALID_LID", NT_STATUS_ABIOS_INVALID_LID },
- { "NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE", NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE },
- { "NT_STATUS_ABIOS_INVALID_SELECTOR", NT_STATUS_ABIOS_INVALID_SELECTOR },
- { "NT_STATUS_NO_LDT", NT_STATUS_NO_LDT },
- { "NT_STATUS_INVALID_LDT_SIZE", NT_STATUS_INVALID_LDT_SIZE },
- { "NT_STATUS_INVALID_LDT_OFFSET", NT_STATUS_INVALID_LDT_OFFSET },
- { "NT_STATUS_INVALID_LDT_DESCRIPTOR", NT_STATUS_INVALID_LDT_DESCRIPTOR },
- { "NT_STATUS_INVALID_IMAGE_NE_FORMAT", NT_STATUS_INVALID_IMAGE_NE_FORMAT },
- { "NT_STATUS_RXACT_INVALID_STATE", NT_STATUS_RXACT_INVALID_STATE },
- { "NT_STATUS_RXACT_COMMIT_FAILURE", NT_STATUS_RXACT_COMMIT_FAILURE },
- { "NT_STATUS_MAPPED_FILE_SIZE_ZERO", NT_STATUS_MAPPED_FILE_SIZE_ZERO },
- { "NT_STATUS_TOO_MANY_OPENED_FILES", NT_STATUS_TOO_MANY_OPENED_FILES },
- { "NT_STATUS_CANCELLED", NT_STATUS_CANCELLED },
- { "NT_STATUS_CANNOT_DELETE", NT_STATUS_CANNOT_DELETE },
- { "NT_STATUS_INVALID_COMPUTER_NAME", NT_STATUS_INVALID_COMPUTER_NAME },
- { "NT_STATUS_FILE_DELETED", NT_STATUS_FILE_DELETED },
- { "NT_STATUS_SPECIAL_ACCOUNT", NT_STATUS_SPECIAL_ACCOUNT },
- { "NT_STATUS_SPECIAL_GROUP", NT_STATUS_SPECIAL_GROUP },
- { "NT_STATUS_SPECIAL_USER", NT_STATUS_SPECIAL_USER },
- { "NT_STATUS_MEMBERS_PRIMARY_GROUP", NT_STATUS_MEMBERS_PRIMARY_GROUP },
- { "NT_STATUS_FILE_CLOSED", NT_STATUS_FILE_CLOSED },
- { "NT_STATUS_TOO_MANY_THREADS", NT_STATUS_TOO_MANY_THREADS },
- { "NT_STATUS_THREAD_NOT_IN_PROCESS", NT_STATUS_THREAD_NOT_IN_PROCESS },
- { "NT_STATUS_TOKEN_ALREADY_IN_USE", NT_STATUS_TOKEN_ALREADY_IN_USE },
- { "NT_STATUS_PAGEFILE_QUOTA_EXCEEDED", NT_STATUS_PAGEFILE_QUOTA_EXCEEDED },
- { "NT_STATUS_COMMITMENT_LIMIT", NT_STATUS_COMMITMENT_LIMIT },
- { "NT_STATUS_INVALID_IMAGE_LE_FORMAT", NT_STATUS_INVALID_IMAGE_LE_FORMAT },
- { "NT_STATUS_INVALID_IMAGE_NOT_MZ", NT_STATUS_INVALID_IMAGE_NOT_MZ },
- { "NT_STATUS_INVALID_IMAGE_PROTECT", NT_STATUS_INVALID_IMAGE_PROTECT },
- { "NT_STATUS_INVALID_IMAGE_WIN_16", NT_STATUS_INVALID_IMAGE_WIN_16 },
- { "NT_STATUS_LOGON_SERVER_CONFLICT", NT_STATUS_LOGON_SERVER_CONFLICT },
- { "NT_STATUS_TIME_DIFFERENCE_AT_DC", NT_STATUS_TIME_DIFFERENCE_AT_DC },
- { "NT_STATUS_SYNCHRONIZATION_REQUIRED", NT_STATUS_SYNCHRONIZATION_REQUIRED },
- { "NT_STATUS_DLL_NOT_FOUND", NT_STATUS_DLL_NOT_FOUND },
- { "NT_STATUS_OPEN_FAILED", NT_STATUS_OPEN_FAILED },
- { "NT_STATUS_IO_PRIVILEGE_FAILED", NT_STATUS_IO_PRIVILEGE_FAILED },
- { "NT_STATUS_ORDINAL_NOT_FOUND", NT_STATUS_ORDINAL_NOT_FOUND },
- { "NT_STATUS_ENTRYPOINT_NOT_FOUND", NT_STATUS_ENTRYPOINT_NOT_FOUND },
- { "NT_STATUS_CONTROL_C_EXIT", NT_STATUS_CONTROL_C_EXIT },
- { "NT_STATUS_LOCAL_DISCONNECT", NT_STATUS_LOCAL_DISCONNECT },
- { "NT_STATUS_REMOTE_DISCONNECT", NT_STATUS_REMOTE_DISCONNECT },
- { "NT_STATUS_REMOTE_RESOURCES", NT_STATUS_REMOTE_RESOURCES },
- { "NT_STATUS_LINK_FAILED", NT_STATUS_LINK_FAILED },
- { "NT_STATUS_LINK_TIMEOUT", NT_STATUS_LINK_TIMEOUT },
- { "NT_STATUS_INVALID_CONNECTION", NT_STATUS_INVALID_CONNECTION },
- { "NT_STATUS_INVALID_ADDRESS", NT_STATUS_INVALID_ADDRESS },
- { "NT_STATUS_DLL_INIT_FAILED", NT_STATUS_DLL_INIT_FAILED },
- { "NT_STATUS_MISSING_SYSTEMFILE", NT_STATUS_MISSING_SYSTEMFILE },
- { "NT_STATUS_UNHANDLED_EXCEPTION", NT_STATUS_UNHANDLED_EXCEPTION },
- { "NT_STATUS_APP_INIT_FAILURE", NT_STATUS_APP_INIT_FAILURE },
- { "NT_STATUS_PAGEFILE_CREATE_FAILED", NT_STATUS_PAGEFILE_CREATE_FAILED },
- { "NT_STATUS_NO_PAGEFILE", NT_STATUS_NO_PAGEFILE },
- { "NT_STATUS_INVALID_LEVEL", NT_STATUS_INVALID_LEVEL },
- { "NT_STATUS_WRONG_PASSWORD_CORE", NT_STATUS_WRONG_PASSWORD_CORE },
- { "NT_STATUS_ILLEGAL_FLOAT_CONTEXT", NT_STATUS_ILLEGAL_FLOAT_CONTEXT },
- { "NT_STATUS_PIPE_BROKEN", NT_STATUS_PIPE_BROKEN },
- { "NT_STATUS_REGISTRY_CORRUPT", NT_STATUS_REGISTRY_CORRUPT },
- { "NT_STATUS_REGISTRY_IO_FAILED", NT_STATUS_REGISTRY_IO_FAILED },
- { "NT_STATUS_NO_EVENT_PAIR", NT_STATUS_NO_EVENT_PAIR },
- { "NT_STATUS_UNRECOGNIZED_VOLUME", NT_STATUS_UNRECOGNIZED_VOLUME },
- { "NT_STATUS_SERIAL_NO_DEVICE_INITED", NT_STATUS_SERIAL_NO_DEVICE_INITED },
- { "NT_STATUS_NO_SUCH_ALIAS", NT_STATUS_NO_SUCH_ALIAS },
- { "NT_STATUS_MEMBER_NOT_IN_ALIAS", NT_STATUS_MEMBER_NOT_IN_ALIAS },
- { "NT_STATUS_MEMBER_IN_ALIAS", NT_STATUS_MEMBER_IN_ALIAS },
- { "NT_STATUS_ALIAS_EXISTS", NT_STATUS_ALIAS_EXISTS },
- { "NT_STATUS_LOGON_NOT_GRANTED", NT_STATUS_LOGON_NOT_GRANTED },
- { "NT_STATUS_TOO_MANY_SECRETS", NT_STATUS_TOO_MANY_SECRETS },
- { "NT_STATUS_SECRET_TOO_LONG", NT_STATUS_SECRET_TOO_LONG },
- { "NT_STATUS_INTERNAL_DB_ERROR", NT_STATUS_INTERNAL_DB_ERROR },
- { "NT_STATUS_FULLSCREEN_MODE", NT_STATUS_FULLSCREEN_MODE },
- { "NT_STATUS_TOO_MANY_CONTEXT_IDS", NT_STATUS_TOO_MANY_CONTEXT_IDS },
- { "NT_STATUS_LOGON_TYPE_NOT_GRANTED", NT_STATUS_LOGON_TYPE_NOT_GRANTED },
- { "NT_STATUS_NOT_REGISTRY_FILE", NT_STATUS_NOT_REGISTRY_FILE },
- { "NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED", NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED },
- { "NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR", NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR },
- { "NT_STATUS_FT_MISSING_MEMBER", NT_STATUS_FT_MISSING_MEMBER },
- { "NT_STATUS_ILL_FORMED_SERVICE_ENTRY", NT_STATUS_ILL_FORMED_SERVICE_ENTRY },
- { "NT_STATUS_ILLEGAL_CHARACTER", NT_STATUS_ILLEGAL_CHARACTER },
- { "NT_STATUS_UNMAPPABLE_CHARACTER", NT_STATUS_UNMAPPABLE_CHARACTER },
- { "NT_STATUS_UNDEFINED_CHARACTER", NT_STATUS_UNDEFINED_CHARACTER },
- { "NT_STATUS_FLOPPY_VOLUME", NT_STATUS_FLOPPY_VOLUME },
- { "NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND", NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND },
- { "NT_STATUS_FLOPPY_WRONG_CYLINDER", NT_STATUS_FLOPPY_WRONG_CYLINDER },
- { "NT_STATUS_FLOPPY_UNKNOWN_ERROR", NT_STATUS_FLOPPY_UNKNOWN_ERROR },
- { "NT_STATUS_FLOPPY_BAD_REGISTERS", NT_STATUS_FLOPPY_BAD_REGISTERS },
- { "NT_STATUS_DISK_RECALIBRATE_FAILED", NT_STATUS_DISK_RECALIBRATE_FAILED },
- { "NT_STATUS_DISK_OPERATION_FAILED", NT_STATUS_DISK_OPERATION_FAILED },
- { "NT_STATUS_DISK_RESET_FAILED", NT_STATUS_DISK_RESET_FAILED },
- { "NT_STATUS_SHARED_IRQ_BUSY", NT_STATUS_SHARED_IRQ_BUSY },
- { "NT_STATUS_FT_ORPHANING", NT_STATUS_FT_ORPHANING },
- { "NT_STATUS_PARTITION_FAILURE", NT_STATUS_PARTITION_FAILURE },
- { "NT_STATUS_INVALID_BLOCK_LENGTH", NT_STATUS_INVALID_BLOCK_LENGTH },
- { "NT_STATUS_DEVICE_NOT_PARTITIONED", NT_STATUS_DEVICE_NOT_PARTITIONED },
- { "NT_STATUS_UNABLE_TO_LOCK_MEDIA", NT_STATUS_UNABLE_TO_LOCK_MEDIA },
- { "NT_STATUS_UNABLE_TO_UNLOAD_MEDIA", NT_STATUS_UNABLE_TO_UNLOAD_MEDIA },
- { "NT_STATUS_EOM_OVERFLOW", NT_STATUS_EOM_OVERFLOW },
- { "NT_STATUS_NO_MEDIA", NT_STATUS_NO_MEDIA },
- { "NT_STATUS_NO_SUCH_MEMBER", NT_STATUS_NO_SUCH_MEMBER },
- { "NT_STATUS_INVALID_MEMBER", NT_STATUS_INVALID_MEMBER },
- { "NT_STATUS_KEY_DELETED", NT_STATUS_KEY_DELETED },
- { "NT_STATUS_NO_LOG_SPACE", NT_STATUS_NO_LOG_SPACE },
- { "NT_STATUS_TOO_MANY_SIDS", NT_STATUS_TOO_MANY_SIDS },
- { "NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED", NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED },
- { "NT_STATUS_KEY_HAS_CHILDREN", NT_STATUS_KEY_HAS_CHILDREN },
- { "NT_STATUS_CHILD_MUST_BE_VOLATILE", NT_STATUS_CHILD_MUST_BE_VOLATILE },
- { "NT_STATUS_DEVICE_CONFIGURATION_ERROR", NT_STATUS_DEVICE_CONFIGURATION_ERROR },
- { "NT_STATUS_DRIVER_INTERNAL_ERROR", NT_STATUS_DRIVER_INTERNAL_ERROR },
- { "NT_STATUS_INVALID_DEVICE_STATE", NT_STATUS_INVALID_DEVICE_STATE },
- { "NT_STATUS_IO_DEVICE_ERROR", NT_STATUS_IO_DEVICE_ERROR },
- { "NT_STATUS_DEVICE_PROTOCOL_ERROR", NT_STATUS_DEVICE_PROTOCOL_ERROR },
- { "NT_STATUS_BACKUP_CONTROLLER", NT_STATUS_BACKUP_CONTROLLER },
- { "NT_STATUS_LOG_FILE_FULL", NT_STATUS_LOG_FILE_FULL },
- { "NT_STATUS_TOO_LATE", NT_STATUS_TOO_LATE },
- { "NT_STATUS_NO_TRUST_LSA_SECRET", NT_STATUS_NO_TRUST_LSA_SECRET },
- { "NT_STATUS_NO_TRUST_SAM_ACCOUNT", NT_STATUS_NO_TRUST_SAM_ACCOUNT },
- { "NT_STATUS_TRUSTED_DOMAIN_FAILURE", NT_STATUS_TRUSTED_DOMAIN_FAILURE },
- { "NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE", NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE },
- { "NT_STATUS_EVENTLOG_FILE_CORRUPT", NT_STATUS_EVENTLOG_FILE_CORRUPT },
- { "NT_STATUS_EVENTLOG_CANT_START", NT_STATUS_EVENTLOG_CANT_START },
- { "NT_STATUS_TRUST_FAILURE", NT_STATUS_TRUST_FAILURE },
- { "NT_STATUS_MUTANT_LIMIT_EXCEEDED", NT_STATUS_MUTANT_LIMIT_EXCEEDED },
- { "NT_STATUS_NETLOGON_NOT_STARTED", NT_STATUS_NETLOGON_NOT_STARTED },
- { "NT_STATUS_ACCOUNT_EXPIRED", NT_STATUS_ACCOUNT_EXPIRED },
- { "NT_STATUS_POSSIBLE_DEADLOCK", NT_STATUS_POSSIBLE_DEADLOCK },
- { "NT_STATUS_NETWORK_CREDENTIAL_CONFLICT", NT_STATUS_NETWORK_CREDENTIAL_CONFLICT },
- { "NT_STATUS_REMOTE_SESSION_LIMIT", NT_STATUS_REMOTE_SESSION_LIMIT },
- { "NT_STATUS_EVENTLOG_FILE_CHANGED", NT_STATUS_EVENTLOG_FILE_CHANGED },
- { "NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT", NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT },
- { "NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT", NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT },
- { "NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT", NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT },
- { "NT_STATUS_DOMAIN_TRUST_INCONSISTENT", NT_STATUS_DOMAIN_TRUST_INCONSISTENT },
- { "NT_STATUS_FS_DRIVER_REQUIRED", NT_STATUS_FS_DRIVER_REQUIRED },
- { "NT_STATUS_NO_USER_SESSION_KEY", NT_STATUS_NO_USER_SESSION_KEY },
- { "NT_STATUS_USER_SESSION_DELETED", NT_STATUS_USER_SESSION_DELETED },
- { "NT_STATUS_RESOURCE_LANG_NOT_FOUND", NT_STATUS_RESOURCE_LANG_NOT_FOUND },
- { "NT_STATUS_INSUFF_SERVER_RESOURCES", NT_STATUS_INSUFF_SERVER_RESOURCES },
- { "NT_STATUS_INVALID_BUFFER_SIZE", NT_STATUS_INVALID_BUFFER_SIZE },
- { "NT_STATUS_INVALID_ADDRESS_COMPONENT", NT_STATUS_INVALID_ADDRESS_COMPONENT },
- { "NT_STATUS_INVALID_ADDRESS_WILDCARD", NT_STATUS_INVALID_ADDRESS_WILDCARD },
- { "NT_STATUS_TOO_MANY_ADDRESSES", NT_STATUS_TOO_MANY_ADDRESSES },
- { "NT_STATUS_ADDRESS_ALREADY_EXISTS", NT_STATUS_ADDRESS_ALREADY_EXISTS },
- { "NT_STATUS_ADDRESS_CLOSED", NT_STATUS_ADDRESS_CLOSED },
- { "NT_STATUS_CONNECTION_DISCONNECTED", NT_STATUS_CONNECTION_DISCONNECTED },
- { "NT_STATUS_CONNECTION_RESET", NT_STATUS_CONNECTION_RESET },
- { "NT_STATUS_TOO_MANY_NODES", NT_STATUS_TOO_MANY_NODES },
- { "NT_STATUS_TRANSACTION_ABORTED", NT_STATUS_TRANSACTION_ABORTED },
- { "NT_STATUS_TRANSACTION_TIMED_OUT", NT_STATUS_TRANSACTION_TIMED_OUT },
- { "NT_STATUS_TRANSACTION_NO_RELEASE", NT_STATUS_TRANSACTION_NO_RELEASE },
- { "NT_STATUS_TRANSACTION_NO_MATCH", NT_STATUS_TRANSACTION_NO_MATCH },
- { "NT_STATUS_TRANSACTION_RESPONDED", NT_STATUS_TRANSACTION_RESPONDED },
- { "NT_STATUS_TRANSACTION_INVALID_ID", NT_STATUS_TRANSACTION_INVALID_ID },
- { "NT_STATUS_TRANSACTION_INVALID_TYPE", NT_STATUS_TRANSACTION_INVALID_TYPE },
- { "NT_STATUS_NOT_SERVER_SESSION", NT_STATUS_NOT_SERVER_SESSION },
- { "NT_STATUS_NOT_CLIENT_SESSION", NT_STATUS_NOT_CLIENT_SESSION },
- { "NT_STATUS_CANNOT_LOAD_REGISTRY_FILE", NT_STATUS_CANNOT_LOAD_REGISTRY_FILE },
- { "NT_STATUS_DEBUG_ATTACH_FAILED", NT_STATUS_DEBUG_ATTACH_FAILED },
- { "NT_STATUS_SYSTEM_PROCESS_TERMINATED", NT_STATUS_SYSTEM_PROCESS_TERMINATED },
- { "NT_STATUS_DATA_NOT_ACCEPTED", NT_STATUS_DATA_NOT_ACCEPTED },
- { "NT_STATUS_NO_BROWSER_SERVERS_FOUND", NT_STATUS_NO_BROWSER_SERVERS_FOUND },
- { "NT_STATUS_VDM_HARD_ERROR", NT_STATUS_VDM_HARD_ERROR },
- { "NT_STATUS_DRIVER_CANCEL_TIMEOUT", NT_STATUS_DRIVER_CANCEL_TIMEOUT },
- { "NT_STATUS_REPLY_MESSAGE_MISMATCH", NT_STATUS_REPLY_MESSAGE_MISMATCH },
- { "NT_STATUS_MAPPED_ALIGNMENT", NT_STATUS_MAPPED_ALIGNMENT },
- { "NT_STATUS_IMAGE_CHECKSUM_MISMATCH", NT_STATUS_IMAGE_CHECKSUM_MISMATCH },
- { "NT_STATUS_LOST_WRITEBEHIND_DATA", NT_STATUS_LOST_WRITEBEHIND_DATA },
- { "NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID", NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID },
- { "NT_STATUS_PASSWORD_MUST_CHANGE", NT_STATUS_PASSWORD_MUST_CHANGE },
- { "NT_STATUS_NOT_FOUND", NT_STATUS_NOT_FOUND },
- { "NT_STATUS_NOT_TINY_STREAM", NT_STATUS_NOT_TINY_STREAM },
- { "NT_STATUS_RECOVERY_FAILURE", NT_STATUS_RECOVERY_FAILURE },
- { "NT_STATUS_STACK_OVERFLOW_READ", NT_STATUS_STACK_OVERFLOW_READ },
- { "NT_STATUS_FAIL_CHECK", NT_STATUS_FAIL_CHECK },
- { "NT_STATUS_DUPLICATE_OBJECTID", NT_STATUS_DUPLICATE_OBJECTID },
- { "NT_STATUS_OBJECTID_EXISTS", NT_STATUS_OBJECTID_EXISTS },
- { "NT_STATUS_CONVERT_TO_LARGE", NT_STATUS_CONVERT_TO_LARGE },
- { "NT_STATUS_RETRY", NT_STATUS_RETRY },
- { "NT_STATUS_FOUND_OUT_OF_SCOPE", NT_STATUS_FOUND_OUT_OF_SCOPE },
- { "NT_STATUS_ALLOCATE_BUCKET", NT_STATUS_ALLOCATE_BUCKET },
- { "NT_STATUS_PROPSET_NOT_FOUND", NT_STATUS_PROPSET_NOT_FOUND },
- { "NT_STATUS_MARSHALL_OVERFLOW", NT_STATUS_MARSHALL_OVERFLOW },
- { "NT_STATUS_INVALID_VARIANT", NT_STATUS_INVALID_VARIANT },
- { "NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND", NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND },
- { "NT_STATUS_ACCOUNT_LOCKED_OUT", NT_STATUS_ACCOUNT_LOCKED_OUT },
- { "NT_STATUS_HANDLE_NOT_CLOSABLE", NT_STATUS_HANDLE_NOT_CLOSABLE },
- { "NT_STATUS_CONNECTION_REFUSED", NT_STATUS_CONNECTION_REFUSED },
- { "NT_STATUS_GRACEFUL_DISCONNECT", NT_STATUS_GRACEFUL_DISCONNECT },
- { "NT_STATUS_ADDRESS_ALREADY_ASSOCIATED", NT_STATUS_ADDRESS_ALREADY_ASSOCIATED },
- { "NT_STATUS_ADDRESS_NOT_ASSOCIATED", NT_STATUS_ADDRESS_NOT_ASSOCIATED },
- { "NT_STATUS_CONNECTION_INVALID", NT_STATUS_CONNECTION_INVALID },
- { "NT_STATUS_CONNECTION_ACTIVE", NT_STATUS_CONNECTION_ACTIVE },
- { "NT_STATUS_NETWORK_UNREACHABLE", NT_STATUS_NETWORK_UNREACHABLE },
- { "NT_STATUS_HOST_UNREACHABLE", NT_STATUS_HOST_UNREACHABLE },
- { "NT_STATUS_PROTOCOL_UNREACHABLE", NT_STATUS_PROTOCOL_UNREACHABLE },
- { "NT_STATUS_PORT_UNREACHABLE", NT_STATUS_PORT_UNREACHABLE },
- { "NT_STATUS_REQUEST_ABORTED", NT_STATUS_REQUEST_ABORTED },
- { "NT_STATUS_CONNECTION_ABORTED", NT_STATUS_CONNECTION_ABORTED },
- { "NT_STATUS_BAD_COMPRESSION_BUFFER", NT_STATUS_BAD_COMPRESSION_BUFFER },
- { "NT_STATUS_USER_MAPPED_FILE", NT_STATUS_USER_MAPPED_FILE },
- { "NT_STATUS_AUDIT_FAILED", NT_STATUS_AUDIT_FAILED },
- { "NT_STATUS_TIMER_RESOLUTION_NOT_SET", NT_STATUS_TIMER_RESOLUTION_NOT_SET },
- { "NT_STATUS_CONNECTION_COUNT_LIMIT", NT_STATUS_CONNECTION_COUNT_LIMIT },
- { "NT_STATUS_LOGIN_TIME_RESTRICTION", NT_STATUS_LOGIN_TIME_RESTRICTION },
- { "NT_STATUS_LOGIN_WKSTA_RESTRICTION", NT_STATUS_LOGIN_WKSTA_RESTRICTION },
- { "NT_STATUS_IMAGE_MP_UP_MISMATCH", NT_STATUS_IMAGE_MP_UP_MISMATCH },
- { "NT_STATUS_INSUFFICIENT_LOGON_INFO", NT_STATUS_INSUFFICIENT_LOGON_INFO },
- { "NT_STATUS_BAD_DLL_ENTRYPOINT", NT_STATUS_BAD_DLL_ENTRYPOINT },
- { "NT_STATUS_BAD_SERVICE_ENTRYPOINT", NT_STATUS_BAD_SERVICE_ENTRYPOINT },
- { "NT_STATUS_LPC_REPLY_LOST", NT_STATUS_LPC_REPLY_LOST },
- { "NT_STATUS_IP_ADDRESS_CONFLICT1", NT_STATUS_IP_ADDRESS_CONFLICT1 },
- { "NT_STATUS_IP_ADDRESS_CONFLICT2", NT_STATUS_IP_ADDRESS_CONFLICT2 },
- { "NT_STATUS_REGISTRY_QUOTA_LIMIT", NT_STATUS_REGISTRY_QUOTA_LIMIT },
- { "NT_STATUS_PATH_NOT_COVERED", NT_STATUS_PATH_NOT_COVERED },
- { "NT_STATUS_NO_CALLBACK_ACTIVE", NT_STATUS_NO_CALLBACK_ACTIVE },
- { "NT_STATUS_LICENSE_QUOTA_EXCEEDED", NT_STATUS_LICENSE_QUOTA_EXCEEDED },
- { "NT_STATUS_PWD_TOO_SHORT", NT_STATUS_PWD_TOO_SHORT },
- { "NT_STATUS_PWD_TOO_RECENT", NT_STATUS_PWD_TOO_RECENT },
- { "NT_STATUS_PWD_HISTORY_CONFLICT", NT_STATUS_PWD_HISTORY_CONFLICT },
- { "NT_STATUS_PLUGPLAY_NO_DEVICE", NT_STATUS_PLUGPLAY_NO_DEVICE },
- { "NT_STATUS_UNSUPPORTED_COMPRESSION", NT_STATUS_UNSUPPORTED_COMPRESSION },
- { "NT_STATUS_INVALID_HW_PROFILE", NT_STATUS_INVALID_HW_PROFILE },
- { "NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH", NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH },
- { "NT_STATUS_DRIVER_ORDINAL_NOT_FOUND", NT_STATUS_DRIVER_ORDINAL_NOT_FOUND },
- { "NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND", NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND },
- { "NT_STATUS_RESOURCE_NOT_OWNED", NT_STATUS_RESOURCE_NOT_OWNED },
- { "NT_STATUS_TOO_MANY_LINKS", NT_STATUS_TOO_MANY_LINKS },
- { "NT_STATUS_QUOTA_LIST_INCONSISTENT", NT_STATUS_QUOTA_LIST_INCONSISTENT },
- { "NT_STATUS_FILE_IS_OFFLINE", NT_STATUS_FILE_IS_OFFLINE },
- { "NT_STATUS_DS_NO_MORE_RIDS", NT_STATUS_DS_NO_MORE_RIDS },
- { "NT_STATUS_NOT_A_REPARSE_POINT", NT_STATUS_NOT_A_REPARSE_POINT },
- { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES },
- { "NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED", NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED },
- { "NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX", NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX },
- { "NT_STATUS_RPC_UNKNOWN_IF", NT_STATUS_RPC_UNKNOWN_IF },
- { "NT_STATUS_RPC_CALL_FAILED", NT_STATUS_RPC_CALL_FAILED },
- { "NT_STATUS_RPC_PROTOCOL_ERROR", NT_STATUS_RPC_PROTOCOL_ERROR },
- { "NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE", NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE },
- { "NT_STATUS_RPC_CANNOT_SUPPORT", NT_STATUS_RPC_CANNOT_SUPPORT },
- { "NT_STATUS_RPC_SEC_PKG_ERROR", NT_STATUS_RPC_SEC_PKG_ERROR },
- { "NT_STATUS_RPC_SS_CONTEXT_MISMATCH", NT_STATUS_RPC_SS_CONTEXT_MISMATCH },
- { "NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE", NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE },
- { "NT_STATUS_RPC_BAD_STUB_DATA", NT_STATUS_RPC_BAD_STUB_DATA },
- { "NT_STATUS_RPC_INVALID_PIPE_OBJECT", NT_STATUS_RPC_INVALID_PIPE_OBJECT },
- { "NT_STATUS_RPC_INVALID_PIPE_OPERATION", NT_STATUS_RPC_INVALID_PIPE_OPERATION },
- { "NT_STATUS_RPC_WRONG_PIPE_VERSION", NT_STATUS_RPC_WRONG_PIPE_VERSION },
- { "NT_STATUS_RPC_PIPE_CLOSED", NT_STATUS_RPC_PIPE_CLOSED },
- { "NT_STATUS_RPC_PIPE_DISCIPLINE_ERROR", NT_STATUS_RPC_PIPE_DISCIPLINE_ERROR },
- { "NT_STATUS_RPC_PIPE_EMPTY", NT_STATUS_RPC_PIPE_EMPTY },
- { "NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED", NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED },
- { "NT_STATUS_OBJECTID_NOT_FOUND", NT_STATUS_OBJECTID_NOT_FOUND },
- { "NT_STATUS_DOWNGRADE_DETECTED", NT_STATUS_DOWNGRADE_DETECTED },
- { "NT_STATUS_INVALID_LOCK_RANGE", NT_STATUS_INVALID_LOCK_RANGE },
- { "NT_STATUS_ERROR_DS_OBJ_STRING_NAME_EXISTS", NT_STATUS_ERROR_DS_OBJ_STRING_NAME_EXISTS },
- { "NT_STATUS_ERROR_DS_INCOMPATIBLE_VERSION", NT_STATUS_ERROR_DS_INCOMPATIBLE_VERSION },
- { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES },
- { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED },
- { "STATUS_NOTIFY_CLEANUP", STATUS_NOTIFY_CLEANUP },
- { "STATUS_NOTIFY_ENUM_DIR", STATUS_NOTIFY_ENUM_DIR },
-
- { NULL, NT_STATUS(0) }
-};
-
-/* These need sorting..... */
-
-static const nt_err_code_struct nt_err_desc[] =
-{
- { N_("Success"), NT_STATUS_OK },
- { N_("Undetermined error"), NT_STATUS_UNSUCCESSFUL },
- { N_("Access denied"), NT_STATUS_ACCESS_DENIED },
- { N_("Account locked out"), NT_STATUS_ACCOUNT_LOCKED_OUT },
- { N_("Must change password"), NT_STATUS_PASSWORD_MUST_CHANGE },
- { N_("Password is too short"), NT_STATUS_PWD_TOO_SHORT },
- { N_("Password is too recent"), NT_STATUS_PWD_TOO_RECENT },
- { N_("Password history conflict"), NT_STATUS_PWD_HISTORY_CONFLICT },
- { N_("No logon servers"), NT_STATUS_NO_LOGON_SERVERS },
- { N_("Improperly formed account name"), NT_STATUS_INVALID_ACCOUNT_NAME },
- { N_("User exists"), NT_STATUS_USER_EXISTS },
- { N_("No such user"), NT_STATUS_NO_SUCH_USER },
- { N_("Group exists"), NT_STATUS_GROUP_EXISTS },
- { N_("No such group"), NT_STATUS_NO_SUCH_GROUP },
- { N_("Member not in group"), NT_STATUS_MEMBER_NOT_IN_GROUP },
- { N_("Wrong Password"), NT_STATUS_WRONG_PASSWORD },
- { N_("Ill formed password"), NT_STATUS_ILL_FORMED_PASSWORD },
- { N_("Password restriction"), NT_STATUS_PASSWORD_RESTRICTION },
- { N_("Logon failure"), NT_STATUS_LOGON_FAILURE },
- { N_("Account restriction"), NT_STATUS_ACCOUNT_RESTRICTION },
- { N_("Invalid logon hours"), NT_STATUS_INVALID_LOGON_HOURS },
- { N_("Invalid workstation"), NT_STATUS_INVALID_WORKSTATION },
- { N_("Password expired"), NT_STATUS_PASSWORD_EXPIRED },
- { N_("Account disabled"), NT_STATUS_ACCOUNT_DISABLED },
- { N_("Unexpected information received"), NT_STATUS_INVALID_PARAMETER },
- { N_("Memory allocation error"), NT_STATUS_NO_MEMORY },
- { N_("No domain controllers located"), NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND },
- { N_("Account locked out"), NT_STATUS_ACCOUNT_LOCKED_OUT },
- { N_("Named pipe not available"), NT_STATUS_PIPE_NOT_AVAILABLE },
- { N_("Not implemented"), NT_STATUS_NOT_IMPLEMENTED },
- { N_("Invalid information class"), NT_STATUS_INVALID_INFO_CLASS },
- { N_("Information length mismatch"), NT_STATUS_INFO_LENGTH_MISMATCH },
- { N_("Access violation"), NT_STATUS_ACCESS_VIOLATION },
- { N_("Invalid handle"), NT_STATUS_INVALID_HANDLE },
- { N_("Invalid parameter"), NT_STATUS_INVALID_PARAMETER },
- { N_("No memory"), NT_STATUS_NO_MEMORY },
- { N_("Buffer too small"), NT_STATUS_BUFFER_TOO_SMALL },
- { N_("Revision mismatch"), NT_STATUS_REVISION_MISMATCH },
- { N_("No logon servers"), NT_STATUS_NO_LOGON_SERVERS },
- { N_("No such logon session"), NT_STATUS_NO_SUCH_LOGON_SESSION },
- { N_("No such privilege"), NT_STATUS_NO_SUCH_PRIVILEGE },
- { N_("Procedure not found"), NT_STATUS_PROCEDURE_NOT_FOUND },
- { N_("Server disabled"), NT_STATUS_SERVER_DISABLED },
- { N_("Invalid pipe state"), NT_STATUS_INVALID_PIPE_STATE },
- { N_("Named pipe busy"), NT_STATUS_PIPE_BUSY },
- { N_("Illegal function"), NT_STATUS_ILLEGAL_FUNCTION },
- { N_("Named pipe disconnected"), NT_STATUS_PIPE_DISCONNECTED },
- { N_("Named pipe closing"), NT_STATUS_PIPE_CLOSING },
- { N_("Remote host not listening"), NT_STATUS_REMOTE_NOT_LISTENING },
- { N_("Duplicate name on network"), NT_STATUS_DUPLICATE_NAME },
- { N_("Print queue is full"), NT_STATUS_PRINT_QUEUE_FULL },
- { N_("No print spool space available"), NT_STATUS_NO_SPOOL_SPACE },
- { N_("The network name cannot be found"), NT_STATUS_BAD_NETWORK_NAME },
- { N_("The connection was refused"), NT_STATUS_CONNECTION_REFUSED },
- { N_("Too many names"), NT_STATUS_TOO_MANY_NAMES },
- { N_("Too many sessions"), NT_STATUS_TOO_MANY_SESSIONS },
- { N_("Invalid server state"), NT_STATUS_INVALID_SERVER_STATE },
- { N_("Invalid domain state"), NT_STATUS_INVALID_DOMAIN_STATE },
- { N_("Invalid domain role"), NT_STATUS_INVALID_DOMAIN_ROLE },
- { N_("No such domain"), NT_STATUS_NO_SUCH_DOMAIN },
- { N_("Domain exists"), NT_STATUS_DOMAIN_EXISTS },
- { N_("Domain limit exceeded"), NT_STATUS_DOMAIN_LIMIT_EXCEEDED },
- { N_("Bad logon session state"), NT_STATUS_BAD_LOGON_SESSION_STATE },
- { N_("Logon session collision"), NT_STATUS_LOGON_SESSION_COLLISION },
- { N_("Invalid logon type"), NT_STATUS_INVALID_LOGON_TYPE },
- { N_("Cancelled"), NT_STATUS_CANCELLED },
- { N_("Invalid computer name"), NT_STATUS_INVALID_COMPUTER_NAME },
- { N_("Logon server conflict"), NT_STATUS_LOGON_SERVER_CONFLICT },
- { N_("Time difference at domain controller"), NT_STATUS_TIME_DIFFERENCE_AT_DC },
- { N_("Pipe broken"), NT_STATUS_PIPE_BROKEN },
- { N_("Registry corrupt"), NT_STATUS_REGISTRY_CORRUPT },
- { N_("Too many secrets"), NT_STATUS_TOO_MANY_SECRETS },
- { N_("Too many SIDs"), NT_STATUS_TOO_MANY_SIDS },
- { N_("Lanmanager cross encryption required"), NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED },
- { N_("Log file full"), NT_STATUS_LOG_FILE_FULL },
- { N_("No trusted LSA secret"), NT_STATUS_NO_TRUST_LSA_SECRET },
- { N_("No trusted SAM account"), NT_STATUS_NO_TRUST_SAM_ACCOUNT },
- { N_("Trusted domain failure"), NT_STATUS_TRUSTED_DOMAIN_FAILURE },
- { N_("Trust relationship failure"), NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE },
- { N_("Trust failure"), NT_STATUS_TRUST_FAILURE },
- { N_("Netlogon service not started"), NT_STATUS_NETLOGON_NOT_STARTED },
- { N_("Account expired"), NT_STATUS_ACCOUNT_EXPIRED },
- { N_("Network credential conflict"), NT_STATUS_NETWORK_CREDENTIAL_CONFLICT },
- { N_("Remote session limit"), NT_STATUS_REMOTE_SESSION_LIMIT },
- { N_("No logon interdomain trust account"), NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT },
- { N_("No logon workstation trust account"), NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT },
- { N_("No logon server trust account"), NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT },
- { N_("Domain trust inconsistent"), NT_STATUS_DOMAIN_TRUST_INCONSISTENT },
- { N_("No user session key available"), NT_STATUS_NO_USER_SESSION_KEY },
- { N_("User session deleted"), NT_STATUS_USER_SESSION_DELETED },
- { N_("Insufficient server resources"), NT_STATUS_INSUFF_SERVER_RESOURCES },
- { N_("Insufficient logon information"), NT_STATUS_INSUFFICIENT_LOGON_INFO },
-
- { N_("License quota exceeded"), NT_STATUS_LICENSE_QUOTA_EXCEEDED },
- { N_("No more files"), STATUS_NO_MORE_FILES },
-
- { NULL, NT_STATUS(0) }
-};
-
-/*****************************************************************************
- Returns an NT error message. not amazingly helpful, but better than a number.
- *****************************************************************************/
-
-const char *nt_errstr(NTSTATUS nt_code)
-{
- int idx = 0;
- char *result;
-
-#ifdef HAVE_LDAP
- if (NT_STATUS_IS_LDAP(nt_code)) {
- return ldap_err2string(NT_STATUS_LDAP_CODE(nt_code));
- }
-#endif
-
- if (NT_STATUS_IS_DOS(nt_code)) {
- return smb_dos_err_name(NT_STATUS_DOS_CLASS(nt_code),
- NT_STATUS_DOS_CODE(nt_code));
- }
-
- while (nt_errs[idx].nt_errstr != NULL) {
- if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
- NT_STATUS_V(nt_code)) {
- return nt_errs[idx].nt_errstr;
- }
- idx++;
- }
-
- result = talloc_asprintf(talloc_tos(), "NT code 0x%08x",
- NT_STATUS_V(nt_code));
- SMB_ASSERT(result != NULL);
- return result;
-}
-
-/************************************************************************
- Print friendler version fo NT error code
- ***********************************************************************/
-
-const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
-{
- int idx = 0;
-
- while (nt_err_desc[idx].nt_errstr != NULL) {
- if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) {
- return nt_err_desc[idx].nt_errstr;
- }
- idx++;
- }
-
- /* fall back to NT_STATUS_XXX string */
-
- return nt_errstr(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)
-{
- char *result;
- int idx = 0;
-
- while (nt_errs[idx].nt_errstr != NULL) {
- if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
- NT_STATUS_V(nt_code)) {
- return nt_errs[idx].nt_errstr;
- }
- idx++;
- }
-
- result = talloc_asprintf(talloc_tos(), "NT_STATUS(0x%08x)",
- NT_STATUS_V(nt_code));
- SMB_ASSERT(result);
- return result;
-}
-
-/*****************************************************************************
- Returns the NT_STATUS constant matching the string supplied (as an NTSTATUS)
- *****************************************************************************/
-
-NTSTATUS nt_status_string_to_code(const char *nt_status_str)
-{
- int idx = 0;
-
- while (nt_errs[idx].nt_errstr != NULL) {
- if (strcasecmp(nt_errs[idx].nt_errstr, nt_status_str) == 0) {
- return nt_errs[idx].nt_errcode;
- }
- idx++;
- }
- return NT_STATUS_UNSUCCESSFUL;
-}
-
-/**
- * Squash an NT_STATUS in line with security requirements.
- * In an attempt to avoid giving the whole game away when users
- * are authenticating, NT replaces both NT_STATUS_NO_SUCH_USER and
- * NT_STATUS_WRONG_PASSWORD with NT_STATUS_LOGON_FAILURE in certain situations
- * (session setups in particular).
- *
- * @param nt_status NTSTATUS input for squashing.
- * @return the 'squashed' nt_status
- **/
-
-NTSTATUS nt_status_squash(NTSTATUS nt_status)
-{
- if NT_STATUS_IS_OK(nt_status) {
- return nt_status;
- } else if NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_SUCH_USER) {
- /* Match WinXP and don't give the game away */
- return NT_STATUS_LOGON_FAILURE;
-
- } else if NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD) {
- /* Match WinXP and don't give the game away */
- return NT_STATUS_LOGON_FAILURE;
- } else {
- return nt_status;
- }
-}
diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c
index d000ed59c03..fe2fb663bac 100644
--- a/source3/libsmb/ntlmssp.c
+++ b/source3/libsmb/ntlmssp.c
@@ -117,9 +117,9 @@ NTSTATUS ntlmssp_set_hashes(struct ntlmssp_state *ntlmssp_state,
const uint8_t nt_hash[16])
{
ntlmssp_state->lm_hash = (uint8_t *)
- TALLOC_MEMDUP(ntlmssp_state, lm_hash, 16);
+ talloc_memdup(ntlmssp_state, lm_hash, 16);
ntlmssp_state->nt_hash = (uint8_t *)
- TALLOC_MEMDUP(ntlmssp_state, nt_hash, 16);
+ talloc_memdup(ntlmssp_state, nt_hash, 16);
if (!ntlmssp_state->lm_hash || !ntlmssp_state->nt_hash) {
TALLOC_FREE(ntlmssp_state->lm_hash);
TALLOC_FREE(ntlmssp_state->nt_hash);
diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c
index d37389a4858..bf2103db684 100644
--- a/source3/libsmb/passchange.c
+++ b/source3/libsmb/passchange.c
@@ -2,17 +2,17 @@
Unix SMB/CIFS implementation.
SMB client password change routine
Copyright (C) Andrew Tridgell 1994-1998
-
+
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/>.
*/
@@ -21,6 +21,7 @@
#include "../librpc/gen_ndr/ndr_samr.h"
#include "rpc_client/cli_pipe.h"
#include "rpc_client/cli_samr.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "libsmb/nmblib.h"
@@ -32,10 +33,8 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
const char *old_passwd, const char *new_passwd,
char **err_str)
{
- struct nmb_name calling, called;
struct cli_state *cli = NULL;
struct rpc_pipe_client *pipe_hnd = NULL;
- struct sockaddr_storage ss;
char *user, *domain, *p;
NTSTATUS result;
@@ -56,41 +55,14 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
*err_str = NULL;
- if(!resolve_name( remote_machine, &ss, 0x20, false)) {
- if (asprintf(err_str, "Unable to find an IP address for machine "
- "%s.\n", remote_machine) == -1) {
- *err_str = NULL;
- }
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- cli = cli_initialise();
- if (!cli) {
- return NT_STATUS_NO_MEMORY;
- }
-
- result = cli_connect(cli, remote_machine, &ss);
+ result = cli_connect_nb(remote_machine, NULL, 0, 0x20, NULL,
+ Undefined, &cli);
if (!NT_STATUS_IS_OK(result)) {
if (asprintf(err_str, "Unable to connect to SMB server on "
"machine %s. Error was : %s.\n",
remote_machine, nt_errstr(result))==-1) {
*err_str = NULL;
}
- cli_shutdown(cli);
- return result;
- }
-
- make_nmb_name(&calling, global_myname() , 0x0);
- make_nmb_name(&called , remote_machine, 0x20);
-
- if (!cli_session_request(cli, &calling, &called)) {
- if (asprintf(err_str, "machine %s rejected the session setup. "
- "Error was : %s.\n",
- remote_machine, cli_errstr(cli)) == -1) {
- *err_str = NULL;
- }
- result = cli_nt_error(cli);
- cli_shutdown(cli);
return result;
}
@@ -125,7 +97,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
if (!NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_MUST_CHANGE) &&
!NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_EXPIRED)) {
if (asprintf(err_str, "Could not connect to machine %s: "
- "%s\n", remote_machine, cli_errstr(cli)) == -1) {
+ "%s\n", remote_machine, nt_errstr(result)) == -1) {
*err_str = NULL;
}
cli_shutdown(cli);
@@ -145,7 +117,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
if (!NT_STATUS_IS_OK(result)) {
if (asprintf(err_str, "machine %s rejected the session "
"setup. Error was : %s.\n",
- remote_machine, cli_errstr(cli)) == -1) {
+ remote_machine, nt_errstr(result)) == -1) {
*err_str = NULL;
}
cli_shutdown(cli);
@@ -203,12 +175,12 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
if (lp_client_lanman_auth()) {
/* Use the old RAP method. */
if (!cli_oem_change_password(cli, user_name, new_passwd, old_passwd)) {
+ result = cli_nt_error(cli);
if (asprintf(err_str, "machine %s rejected the "
"password change: Error was : %s.\n",
- remote_machine, cli_errstr(cli)) == -1) {
+ remote_machine, nt_errstr(result)) == -1) {
*err_str = NULL;
}
- result = cli_nt_error(cli);
cli_shutdown(cli);
return result;
}
@@ -294,12 +266,13 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
cli_shutdown(cli);
return NT_STATUS_OK;
}
+
+ result = cli_nt_error(cli);
if (asprintf(err_str, "machine %s rejected the password "
"change: Error was : %s.\n",
- remote_machine, cli_errstr(cli)) == -1) {
+ remote_machine, nt_errstr(result)) == -1) {
*err_str = NULL;
}
- result = cli_nt_error(cli);
cli_shutdown(cli);
return result;
} else {
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
new file mode 100644
index 00000000000..f88a891d585
--- /dev/null
+++ b/source3/libsmb/proto.h
@@ -0,0 +1,854 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) Andrew Bartlett 2001-2003
+ Copyright (C) Andrew Tridgell 1994-1998,2000-2001
+ Copyright (C) Gerald (Jerry) Carter 2004
+ Copyright (C) Jelmer Vernooij 2003
+ Copyright (C) Jeremy Allison 2001-2009,2011
+ Copyright (C) Stefan Metzmacher 2003,2009
+ Copyright (C) Volker Lendecke 2011
+
+ 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 _LIBSMB_PROTO_H_
+#define _LIBSMB_PROTO_H_
+
+#include "ads.h"
+
+/* The following definitions come from libsmb/cliconnect.c */
+
+ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
+ const char *pass, const char *user_domain,
+ const char * dest_realm);
+
+NTSTATUS cli_session_setup(struct cli_state *cli,
+ const char *user,
+ const char *pass, int passlen,
+ const char *ntpass, int ntpasslen,
+ const char *workgroup);
+struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ struct tevent_req **psmbreq);
+struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli);
+NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
+struct tevent_req *cli_ulogoff_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli);
+NTSTATUS cli_ulogoff_recv(struct tevent_req *req);
+NTSTATUS cli_ulogoff(struct cli_state *cli);
+struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *share, const char *dev,
+ const char *pass, int passlen,
+ struct tevent_req **psmbreq);
+struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *share, const char *dev,
+ const char *pass, int passlen);
+NTSTATUS cli_tcon_andx_recv(struct tevent_req *req);
+NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share,
+ const char *dev, const char *pass, int passlen);
+struct tevent_req *cli_tdis_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli);
+NTSTATUS cli_tdis_recv(struct tevent_req *req);
+NTSTATUS cli_tdis(struct cli_state *cli);
+NTSTATUS cli_negprot(struct cli_state *cli);
+struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli);
+NTSTATUS cli_negprot_recv(struct tevent_req *req);
+NTSTATUS cli_connect_nb(const char *host, struct sockaddr_storage *pss,
+ uint16_t port, int name_type, const char *myname,
+ int signing_state, struct cli_state **pcli);
+NTSTATUS cli_start_connection(struct cli_state **output_cli,
+ const char *my_name,
+ const char *dest_host,
+ struct sockaddr_storage *dest_ss, int port,
+ int signing_state, int flags);
+NTSTATUS cli_full_connection(struct cli_state **output_cli,
+ const char *my_name,
+ const char *dest_host,
+ struct sockaddr_storage *dest_ss, int port,
+ const char *service, const char *service_type,
+ const char *user, const char *domain,
+ const char *password, int flags,
+ int signing_state);
+NTSTATUS cli_raw_tcon(struct cli_state *cli,
+ const char *service, const char *pass, const char *dev,
+ uint16 *max_xmit, uint16 *tid);
+struct cli_state *get_ipc_connect(char *server,
+ struct sockaddr_storage *server_ss,
+ const struct user_auth_info *user_info);
+struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
+ struct sockaddr_storage *mb_ip,
+ const struct user_auth_info *user_info,
+ char **pp_workgroup_out);
+struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
+ const struct user_auth_info *user_info,
+ char **pp_workgroup_out);
+
+/* The following definitions come from libsmb/clidfs.c */
+
+NTSTATUS cli_cm_force_encryption(struct cli_state *c,
+ const char *username,
+ const char *password,
+ const char *domain,
+ const char *sharename);
+struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
+ struct cli_state *referring_cli,
+ const char *server,
+ const char *share,
+ const struct user_auth_info *auth_info,
+ bool show_hdr,
+ bool force_encrypt,
+ int max_protocol,
+ int port,
+ int name_type);
+void cli_cm_display(const struct cli_state *c);
+struct client_dfs_referral;
+NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
+ struct cli_state *cli,
+ const char *path,
+ struct client_dfs_referral **refs,
+ size_t *num_refs,
+ size_t *consumed);
+bool cli_resolve_path(TALLOC_CTX *ctx,
+ const char *mountpt,
+ const struct user_auth_info *dfs_auth_info,
+ struct cli_state *rootcli,
+ const char *path,
+ struct cli_state **targetcli,
+ char **pp_targetpath);
+
+bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
+ struct cli_state *cli,
+ const char *sharename,
+ char **pp_newserver,
+ char **pp_newshare,
+ bool force_encrypt,
+ const char *username,
+ const char *password,
+ const char *domain);
+
+/* The following definitions come from libsmb/clientgen.c */
+
+int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
+unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
+void cli_set_port(struct cli_state *cli, int port);
+void cli_setup_packet_buf(struct cli_state *cli, char *buf);
+NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain);
+NTSTATUS cli_set_username(struct cli_state *cli, const char *username);
+NTSTATUS cli_set_password(struct cli_state *cli, const char *password);
+NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password);
+struct cli_state *cli_initialise(void);
+struct cli_state *cli_initialise_ex(int signing_state);
+void cli_nt_pipes_close(struct cli_state *cli);
+void cli_shutdown(struct cli_state *cli);
+void cli_sockopt(struct cli_state *cli, const char *options);
+uint16 cli_setpid(struct cli_state *cli, uint16 pid);
+bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
+struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct cli_state *cli, uint16_t num_echos,
+ DATA_BLOB data);
+NTSTATUS cli_echo_recv(struct tevent_req *req);
+NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
+bool cli_ucs2(struct cli_state *cli);
+bool is_andx_req(uint8_t cmd);
+NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+ uint8_t smb_command, uint8_t additional_flags,
+ uint8_t wct, uint16_t *vwv,
+ uint32_t num_bytes, const uint8_t *bytes,
+ struct tevent_req **result_parent,
+ uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
+ uint32_t *pnum_bytes, uint8_t **pbytes);
+
+/* The following definitions come from libsmb/clierror.c */
+
+const char *cli_errstr(struct cli_state *cli);
+NTSTATUS cli_nt_error(struct cli_state *cli);
+void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode);
+int cli_errno(struct cli_state *cli);
+bool cli_is_error(struct cli_state *cli);
+bool cli_is_nt_error(struct cli_state *cli);
+bool cli_is_dos_error(struct cli_state *cli);
+bool cli_state_is_connected(struct cli_state *cli);
+
+/* The following definitions come from libsmb/clifile.c */
+
+struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli,
+ uint16_t level,
+ const char *path,
+ uint8_t *data,
+ size_t data_len);
+NTSTATUS cli_setpathinfo_recv(struct tevent_req *req);
+NTSTATUS cli_setpathinfo(struct cli_state *cli,
+ uint16_t level,
+ const char *path,
+ uint8_t *data,
+ size_t data_len);
+
+struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *oldname,
+ const char *newname);
+NTSTATUS cli_posix_symlink_recv(struct tevent_req *req);
+NTSTATUS cli_posix_symlink(struct cli_state *cli,
+ const char *oldname,
+ const char *newname);
+struct tevent_req *cli_posix_readlink_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ size_t len);
+NTSTATUS cli_posix_readlink_recv(struct tevent_req *req, struct cli_state *cli,
+ char *retpath, size_t len);
+NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname,
+ char *linkpath, size_t len);
+struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *oldname,
+ const char *newname);
+NTSTATUS cli_posix_hardlink_recv(struct tevent_req *req);
+NTSTATUS cli_posix_hardlink(struct cli_state *cli,
+ const char *oldname,
+ const char *newname);
+uint32_t unix_perms_to_wire(mode_t perms);
+mode_t wire_perms_to_unix(uint32_t perms);
+struct tevent_req *cli_posix_getfacl_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname);
+NTSTATUS cli_posix_getfacl_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ size_t *prb_size,
+ char **retbuf);
+NTSTATUS cli_posix_getfacl(struct cli_state *cli,
+ const char *fname,
+ TALLOC_CTX *mem_ctx,
+ size_t *prb_size,
+ char **retbuf);
+struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname);
+NTSTATUS cli_posix_stat_recv(struct tevent_req *req,
+ SMB_STRUCT_STAT *sbuf);
+NTSTATUS cli_posix_stat(struct cli_state *cli,
+ const char *fname,
+ SMB_STRUCT_STAT *sbuf);
+struct tevent_req *cli_posix_chmod_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ mode_t mode);
+NTSTATUS cli_posix_chmod_recv(struct tevent_req *req);
+NTSTATUS cli_posix_chmod(struct cli_state *cli, const char *fname, mode_t mode);
+struct tevent_req *cli_posix_chown_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ uid_t uid,
+ gid_t gid);
+NTSTATUS cli_posix_chown_recv(struct tevent_req *req);
+NTSTATUS cli_posix_chown(struct cli_state *cli,
+ const char *fname,
+ uid_t uid,
+ gid_t gid);
+struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname_src,
+ const char *fname_dst);
+NTSTATUS cli_rename_recv(struct tevent_req *req);
+NTSTATUS cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
+struct tevent_req *cli_ntrename_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname_src,
+ const char *fname_dst);
+NTSTATUS cli_ntrename_recv(struct tevent_req *req);
+NTSTATUS cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
+
+struct tevent_req *cli_nt_hardlink_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname_src,
+ const char *fname_dst);
+NTSTATUS cli_nt_hardlink_recv(struct tevent_req *req);
+NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
+
+struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ uint16_t mayhave_attrs);
+NTSTATUS cli_unlink_recv(struct tevent_req *req);
+NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
+
+struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *dname);
+NTSTATUS cli_mkdir_recv(struct tevent_req *req);
+NTSTATUS cli_mkdir(struct cli_state *cli, const char *dname);
+struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *dname);
+NTSTATUS cli_rmdir_recv(struct tevent_req *req);
+NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname);
+struct tevent_req *cli_nt_delete_on_close_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ bool flag);
+NTSTATUS cli_nt_delete_on_close_recv(struct tevent_req *req);
+NTSTATUS cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
+struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ uint32_t CreatFlags,
+ uint32_t DesiredAccess,
+ uint32_t FileAttributes,
+ uint32_t ShareAccess,
+ uint32_t CreateDisposition,
+ uint32_t CreateOptions,
+ uint8_t SecurityFlags);
+NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum);
+NTSTATUS cli_ntcreate(struct cli_state *cli,
+ const char *fname,
+ uint32_t CreatFlags,
+ uint32_t DesiredAccess,
+ uint32_t FileAttributes,
+ uint32_t ShareAccess,
+ uint32_t CreateDisposition,
+ uint32_t CreateOptions,
+ uint8_t SecurityFlags,
+ uint16_t *pfid);
+uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
+ size_t str_len, size_t *pconverted_size);
+uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
+ const uint8_t *bytes, size_t num_bytes);
+struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli, const char *fname,
+ int flags, int share_mode,
+ struct tevent_req **psmbreq);
+struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct cli_state *cli, const char *fname,
+ int flags, int share_mode);
+NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *fnum);
+NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
+struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli, uint16_t fnum,
+ struct tevent_req **psubreq);
+struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli, uint16_t fnum);
+NTSTATUS cli_close_recv(struct tevent_req *req);
+NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum);
+struct tevent_req *cli_ftruncate_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ uint64_t size);
+NTSTATUS cli_ftruncate_recv(struct tevent_req *req);
+NTSTATUS cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
+NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
+ uint32_t offset, uint32_t len,
+ int timeout, unsigned char locktype);
+bool cli_lock(struct cli_state *cli, uint16_t fnum,
+ uint32_t offset, uint32_t len, int timeout, enum brl_type lock_type);
+struct tevent_req *cli_unlock_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ uint64_t offset,
+ uint64_t len);
+NTSTATUS cli_unlock_recv(struct tevent_req *req);
+NTSTATUS cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len);
+bool cli_lock64(struct cli_state *cli, uint16_t fnum,
+ uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type);
+struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ uint64_t offset,
+ uint64_t len);
+NTSTATUS cli_unlock64_recv(struct tevent_req *req);
+NTSTATUS cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
+struct tevent_req *cli_posix_lock_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ uint64_t offset,
+ uint64_t len,
+ bool wait_lock,
+ enum brl_type lock_type);
+NTSTATUS cli_posix_lock_recv(struct tevent_req *req);
+NTSTATUS cli_posix_lock(struct cli_state *cli, uint16_t fnum,
+ uint64_t offset, uint64_t len,
+ bool wait_lock, enum brl_type lock_type);
+struct tevent_req *cli_posix_unlock_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ uint64_t offset,
+ uint64_t len);
+NTSTATUS cli_posix_unlock_recv(struct tevent_req *req);
+NTSTATUS cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
+struct tevent_req *cli_getattrE_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum);
+NTSTATUS cli_getattrE_recv(struct tevent_req *req,
+ uint16_t *attr,
+ SMB_OFF_T *size,
+ time_t *change_time,
+ time_t *access_time,
+ time_t *write_time);
+NTSTATUS cli_getattrE(struct cli_state *cli,
+ uint16_t fnum,
+ uint16_t *attr,
+ SMB_OFF_T *size,
+ time_t *change_time,
+ time_t *access_time,
+ time_t *write_time);
+struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ time_t change_time,
+ time_t access_time,
+ time_t write_time);
+NTSTATUS cli_setattrE_recv(struct tevent_req *req);
+NTSTATUS cli_setattrE(struct cli_state *cli,
+ uint16_t fnum,
+ time_t change_time,
+ time_t access_time,
+ time_t write_time);
+struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname);
+NTSTATUS cli_getatr_recv(struct tevent_req *req,
+ uint16_t *attr,
+ SMB_OFF_T *size,
+ time_t *write_time);
+NTSTATUS cli_getatr(struct cli_state *cli,
+ const char *fname,
+ uint16_t *attr,
+ SMB_OFF_T *size,
+ time_t *write_time);
+struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ uint16_t attr,
+ time_t mtime);
+NTSTATUS cli_setatr_recv(struct tevent_req *req);
+NTSTATUS cli_setatr(struct cli_state *cli,
+ const char *fname,
+ uint16_t attr,
+ time_t mtime);
+struct tevent_req *cli_chkpath_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname);
+NTSTATUS cli_chkpath_recv(struct tevent_req *req);
+NTSTATUS cli_chkpath(struct cli_state *cli, const char *path);
+struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli);
+NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
+ int *avail);
+NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
+struct tevent_req *cli_ctemp_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *path);
+NTSTATUS cli_ctemp_recv(struct tevent_req *req,
+ TALLOC_CTX *ctx,
+ uint16_t *pfnum,
+ char **outfile);
+NTSTATUS cli_ctemp(struct cli_state *cli,
+ TALLOC_CTX *ctx,
+ const char *path,
+ uint16_t *pfnum,
+ char **out_path);
+NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob);
+NTSTATUS cli_set_ea_path(struct cli_state *cli, const char *path,
+ const char *ea_name, const char *ea_val,
+ size_t ea_len);
+NTSTATUS cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum,
+ const char *ea_name, const char *ea_val,
+ size_t ea_len);
+struct tevent_req *cli_get_ea_list_path_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli,
+ const char *fname);
+NTSTATUS cli_get_ea_list_path_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ size_t *pnum_eas, struct ea_struct **peas);
+NTSTATUS cli_get_ea_list_path(struct cli_state *cli, const char *path,
+ TALLOC_CTX *ctx,
+ size_t *pnum_eas,
+ struct ea_struct **pea_list);
+struct tevent_req *cli_posix_open_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ int flags,
+ mode_t mode);
+NTSTATUS cli_posix_open_recv(struct tevent_req *req, uint16_t *pfnum);
+NTSTATUS cli_posix_open(struct cli_state *cli, const char *fname,
+ int flags, mode_t mode, uint16_t *fnum);
+struct tevent_req *cli_posix_mkdir_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ mode_t mode);
+NTSTATUS cli_posix_mkdir_recv(struct tevent_req *req);
+NTSTATUS cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode);
+
+struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname);
+NTSTATUS cli_posix_unlink_recv(struct tevent_req *req);
+NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname);
+
+struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname);
+NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname);
+struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli, uint16_t fnum,
+ uint32_t buffer_size,
+ uint32_t completion_filter, bool recursive);
+NTSTATUS cli_notify_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ uint32_t *pnum_changes,
+ struct notify_change **pchanges);
+
+struct tevent_req *cli_nttrans_create_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ uint32_t CreatFlags,
+ uint32_t DesiredAccess,
+ uint32_t FileAttributes,
+ uint32_t ShareAccess,
+ uint32_t CreateDisposition,
+ uint32_t CreateOptions,
+ uint8_t SecurityFlags,
+ struct security_descriptor *secdesc,
+ struct ea_struct *eas,
+ int num_eas);
+NTSTATUS cli_nttrans_create_recv(struct tevent_req *req, uint16_t *fnum);
+NTSTATUS cli_nttrans_create(struct cli_state *cli,
+ const char *fname,
+ uint32_t CreatFlags,
+ uint32_t DesiredAccess,
+ uint32_t FileAttributes,
+ uint32_t ShareAccess,
+ uint32_t CreateDisposition,
+ uint32_t CreateOptions,
+ uint8_t SecurityFlags,
+ struct security_descriptor *secdesc,
+ struct ea_struct *eas,
+ int num_eas,
+ uint16_t *pfid);
+
+/* The following definitions come from libsmb/clifsinfo.c */
+
+struct tevent_req *cli_unix_extensions_version_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli);
+NTSTATUS cli_unix_extensions_version_recv(struct tevent_req *req,
+ uint16_t *pmajor, uint16_t *pminor,
+ uint32_t *pcaplow,
+ uint32_t *pcaphigh);
+NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
+ uint16 *pminor, uint32 *pcaplow,
+ uint32 *pcaphigh);
+struct tevent_req *cli_set_unix_extensions_capabilities_send(
+ TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
+ uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh);
+NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req);
+NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
+ uint16 major, uint16 minor,
+ uint32 caplow, uint32 caphigh);
+struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli);
+NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr);
+NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
+NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name,
+ uint32 *pserial_number, time_t *pdate);
+NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
+ uint64_t *total_allocation_units,
+ uint64_t *caller_allocation_units,
+ uint64_t *actual_allocation_units,
+ uint64_t *sectors_per_allocation_unit,
+ uint64_t *bytes_per_sector);
+NTSTATUS cli_get_posix_fs_info(struct cli_state *cli,
+ uint32 *optimal_transfer_size,
+ uint32 *block_size,
+ uint64_t *total_blocks,
+ uint64_t *blocks_available,
+ uint64_t *user_blocks_available,
+ uint64_t *total_file_nodes,
+ uint64_t *free_file_nodes,
+ uint64_t *fs_identifier);
+NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
+ const char *user,
+ const char *pass,
+ const char *domain);
+NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli);
+NTSTATUS cli_force_encryption(struct cli_state *c,
+ const char *username,
+ const char *password,
+ const char *domain);
+
+/* The following definitions come from libsmb/clilist.c */
+
+NTSTATUS cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
+ NTSTATUS (*fn)(const char *, struct file_info *,
+ const char *, void *), void *state);
+NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
+ uint16_t attribute, int info_level,
+ NTSTATUS (*fn)(const char *mnt, struct file_info *finfo,
+ const char *mask, void *private_data),
+ void *private_data);
+struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli,
+ const char *mask,
+ uint16_t attribute,
+ uint16_t info_level);
+NTSTATUS cli_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ struct file_info **finfo, size_t *num_finfo);
+NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
+ NTSTATUS (*fn)(const char *, struct file_info *, const char *,
+ void *), void *state);
+
+/* The following definitions come from libsmb/climessage.c */
+
+struct tevent_req *cli_message_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli,
+ const char *host, const char *username,
+ const char *message);
+NTSTATUS cli_message_recv(struct tevent_req *req);
+NTSTATUS cli_message(struct cli_state *cli, const char *host,
+ const char *username, const char *message);
+
+/* The following definitions come from libsmb/clioplock.c */
+
+struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum, uint8_t level);
+NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
+NTSTATUS cli_oplock_ack(struct cli_state *cli, uint16_t fnum, unsigned char level);
+void cli_oplock_handler(struct cli_state *cli,
+ NTSTATUS (*handler)(struct cli_state *, uint16_t, unsigned char));
+
+/* The following definitions come from libsmb/cliprint.c */
+
+int cli_print_queue(struct cli_state *cli,
+ void (*fn)(struct print_job_info *));
+int cli_printjob_del(struct cli_state *cli, int job);
+
+/* The following definitions come from libsmb/cliquota.c */
+
+NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum);
+void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
+NTSTATUS cli_get_user_quota(struct cli_state *cli, int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt);
+NTSTATUS cli_set_user_quota(struct cli_state *cli, int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt);
+NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
+ SMB_NTQUOTA_LIST **pqt_list);
+NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt);
+NTSTATUS cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt);
+
+/* The following definitions come from libsmb/clireadwrite.c */
+
+struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli, uint16_t fnum,
+ off_t offset, size_t size,
+ struct tevent_req **psmbreq);
+struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli, uint16_t fnum,
+ off_t offset, size_t size);
+NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
+ uint8_t **rcvbuf);
+struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum, off_t start_offset,
+ SMB_OFF_T size, size_t window_size,
+ NTSTATUS (*sink)(char *buf, size_t n,
+ void *priv),
+ void *priv);
+NTSTATUS cli_pull_recv(struct tevent_req *req, SMB_OFF_T *received);
+NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
+ off_t start_offset, SMB_OFF_T size, size_t window_size,
+ NTSTATUS (*sink)(char *buf, size_t n, void *priv),
+ void *priv, SMB_OFF_T *received);
+ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
+ off_t offset, size_t size);
+NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
+ off_t offset, size_t size1, size_t *ptotal);
+struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli, uint16_t fnum,
+ uint16_t mode, const uint8_t *buf,
+ off_t offset, size_t size,
+ struct tevent_req **reqs_before,
+ int num_reqs_before,
+ struct tevent_req **psmbreq);
+struct tevent_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli, uint16_t fnum,
+ uint16_t mode, const uint8_t *buf,
+ off_t offset, size_t size);
+NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten);
+
+NTSTATUS cli_writeall(struct cli_state *cli, uint16_t fnum, uint16_t mode,
+ const uint8_t *buf, off_t offset, size_t size,
+ size_t *pwritten);
+
+struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum, uint16_t mode,
+ off_t start_offset, size_t window_size,
+ size_t (*source)(uint8_t *buf, size_t n,
+ void *priv),
+ void *priv);
+NTSTATUS cli_push_recv(struct tevent_req *req);
+NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
+ off_t start_offset, size_t window_size,
+ size_t (*source)(uint8_t *buf, size_t n, void *priv),
+ void *priv);
+
+/* The following definitions come from libsmb/clisecdesc.c */
+
+struct security_descriptor *cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
+ TALLOC_CTX *mem_ctx);
+NTSTATUS cli_set_secdesc(struct cli_state *cli, uint16_t fnum,
+ struct security_descriptor *sd);
+
+/* The following definitions come from libsmb/clistr.c */
+
+size_t clistr_push_fn(struct cli_state *cli,
+ void *dest,
+ const char *src,
+ int dest_len,
+ int flags);
+size_t clistr_pull_fn(const char *inbuf,
+ char *dest,
+ const void *src,
+ int dest_len,
+ int src_len,
+ int flags);
+size_t clistr_pull_talloc(TALLOC_CTX *ctx,
+ const char *base,
+ uint16_t flags2,
+ char **pp_dest,
+ const void *src,
+ int src_len,
+ int flags);
+
+/* The following definitions come from libsmb/clitrans.c */
+
+struct tevent_req *cli_trans_send(
+ TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct cli_state *cli, uint8_t cmd,
+ const char *pipe_name, uint16_t fid, uint16_t function, int flags,
+ uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
+ uint8_t *param, uint32_t num_param, uint32_t max_param,
+ uint8_t *data, uint32_t num_data, uint32_t max_data);
+NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ uint16_t *recv_flags2,
+ uint16_t **setup, uint8_t min_setup,
+ uint8_t *num_setup,
+ uint8_t **param, uint32_t min_param,
+ uint32_t *num_param,
+ uint8_t **data, uint32_t min_data,
+ uint32_t *num_data);
+NTSTATUS cli_trans(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+ uint8_t trans_cmd,
+ const char *pipe_name, uint16_t fid, uint16_t function,
+ int flags,
+ uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
+ uint8_t *param, uint32_t num_param, uint32_t max_param,
+ uint8_t *data, uint32_t num_data, uint32_t max_data,
+ uint16_t *recv_flags2,
+ uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
+ uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
+ uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
+
+/* The following definitions come from libsmb/smb_seal.c */
+
+NTSTATUS get_enc_ctx_num(const uint8_t *buf, uint16 *p_enc_ctx_num);
+bool common_encryption_on(struct smb_trans_enc_state *es);
+NTSTATUS common_ntlm_decrypt_buffer(struct ntlmssp_state *ntlmssp_state, char *buf);
+NTSTATUS common_ntlm_encrypt_buffer(struct ntlmssp_state *ntlmssp_state,
+ uint16 enc_ctx_num,
+ char *buf,
+ char **ppbuf_out);
+NTSTATUS common_encrypt_buffer(struct smb_trans_enc_state *es, char *buffer, char **buf_out);
+NTSTATUS common_decrypt_buffer(struct smb_trans_enc_state *es, char *buf);
+void common_free_encryption_state(struct smb_trans_enc_state **pp_es);
+void common_free_enc_buffer(struct smb_trans_enc_state *es, char *buf);
+bool cli_encryption_on(struct cli_state *cli);
+void cli_free_encryption_context(struct cli_state *cli);
+void cli_free_enc_buffer(struct cli_state *cli, char *buf);
+
+/* The following definitions come from libsmb/clisigning.c */
+
+bool cli_simple_set_signing(struct cli_state *cli,
+ const DATA_BLOB user_session_key,
+ const DATA_BLOB response);
+bool cli_temp_set_signing(struct cli_state *cli);
+void cli_calculate_sign_mac(struct cli_state *cli, char *buf, uint32_t *seqnum);
+bool cli_check_sign_mac(struct cli_state *cli, const char *buf, uint32_t seqnum);
+bool client_is_signing_on(struct cli_state *cli);
+bool client_is_signing_allowed(struct cli_state *cli);
+bool client_is_signing_mandatory(struct cli_state *cli);
+void cli_set_signing_negotiated(struct cli_state *cli);
+
+#endif /* _LIBSMB_PROTO_H_ */
diff --git a/source3/libsmb/read_smb.c b/source3/libsmb/read_smb.c
new file mode 100644
index 00000000000..f530633c9f8
--- /dev/null
+++ b/source3/libsmb/read_smb.c
@@ -0,0 +1,134 @@
+/*
+ Unix SMB/CIFS implementation.
+ Infrastructure for async SMB client requests
+ Copyright (C) Volker Lendecke 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "lib/async_req/async_sock.h"
+#include "read_smb.h"
+#include "lib/util/tevent_unix.h"
+
+/*
+ * Read an smb packet asynchronously, discard keepalives
+ */
+
+struct read_smb_state {
+ struct tevent_context *ev;
+ int fd;
+ uint8_t *buf;
+};
+
+static ssize_t read_smb_more(uint8_t *buf, size_t buflen, void *private_data);
+static void read_smb_done(struct tevent_req *subreq);
+
+struct tevent_req *read_smb_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd)
+{
+ struct tevent_req *result, *subreq;
+ struct read_smb_state *state;
+
+ result = tevent_req_create(mem_ctx, &state, struct read_smb_state);
+ if (result == NULL) {
+ return NULL;
+ }
+ state->ev = ev;
+ state->fd = fd;
+
+ subreq = read_packet_send(state, ev, fd, 4, read_smb_more, NULL);
+ if (subreq == NULL) {
+ goto fail;
+ }
+ tevent_req_set_callback(subreq, read_smb_done, result);
+ return result;
+ fail:
+ TALLOC_FREE(result);
+ return NULL;
+}
+
+static ssize_t read_smb_more(uint8_t *buf, size_t buflen, void *private_data)
+{
+ if (buflen > 4) {
+ return 0; /* We've been here, we're done */
+ }
+ return smb_len_large(buf);
+}
+
+static void read_smb_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct read_smb_state *state = tevent_req_data(
+ req, struct read_smb_state);
+ ssize_t len;
+ int err;
+
+ len = read_packet_recv(subreq, state, &state->buf, &err);
+ TALLOC_FREE(subreq);
+ if (len == -1) {
+ tevent_req_error(req, err);
+ return;
+ }
+
+ if (CVAL(state->buf, 0) == SMBkeepalive) {
+ subreq = read_packet_send(state, state->ev, state->fd, 4,
+ read_smb_more, NULL);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, read_smb_done, req);
+ return;
+ }
+ tevent_req_done(req);
+}
+
+ssize_t read_smb_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ uint8_t **pbuf, int *perrno)
+{
+ struct read_smb_state *state = tevent_req_data(
+ req, struct read_smb_state);
+
+ if (tevent_req_is_unix_error(req, perrno)) {
+ return -1;
+ }
+ *pbuf = talloc_move(mem_ctx, &state->buf);
+ return talloc_get_size(*pbuf);
+}
+
+ssize_t read_smb(int fd, TALLOC_CTX *mem_ctx, uint8_t **pbuf, int *perrno)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct event_context *ev;
+ struct tevent_req *req;
+ ssize_t ret = -1;
+
+ ev = event_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = read_smb_send(frame, ev, fd);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll(req, ev)) {
+ goto fail;
+ }
+ ret = read_smb_recv(req, mem_ctx, pbuf, perrno);
+ fail:
+ TALLOC_FREE(frame);
+ return ret;
+}
diff --git a/source3/libsmb/read_smb.h b/source3/libsmb/read_smb.h
new file mode 100644
index 00000000000..b0846c1ec3c
--- /dev/null
+++ b/source3/libsmb/read_smb.h
@@ -0,0 +1,34 @@
+/*
+ Unix SMB/CIFS implementation.
+ Infrastructure for async SMB client requests
+ Copyright (C) Volker Lendecke 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __LIBSMB_READ_SMB_H
+#define __LIBSMB_READ_SMB_H
+
+#include "lib/talloc/talloc.h"
+#include "lib/tevent/tevent.h"
+
+struct tevent_req *read_smb_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd);
+
+ssize_t read_smb_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ uint8_t **pbuf, int *perrno);
+ssize_t read_smb(int fd, TALLOC_CTX *mem_ctx, uint8_t **pbuf, int *perrno);
+
+#endif
diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c
index facdbc7dc19..618a570c4e0 100644
--- a/source3/libsmb/samlogon_cache.c
+++ b/source3/libsmb/samlogon_cache.c
@@ -25,6 +25,7 @@
#include "system/filesys.h"
#include "librpc/gen_ndr/ndr_krb5pac.h"
#include "../libcli/security/security.h"
+#include "util_tdb.h"
#define NETSAMLOGON_TDB "netsamlogon_cache.tdb"
@@ -70,16 +71,9 @@ clear:
}
first_try = false;
- DEBUG(0,("retry after CLEAR_IF_FIRST for '%s'\n", path));
- tdb = tdb_open_log(path, 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
- O_RDWR | O_CREAT, 0600);
- if (tdb) {
- tdb_close(tdb);
- goto again;
- }
- DEBUG(0,("tdb_open_log(%s) with CLEAR_IF_FIRST - failed\n", path));
-
- return false;
+ DEBUG(0,("retry after truncate for '%s'\n", path));
+ truncate(path, 0);
+ goto again;
}
@@ -155,7 +149,7 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3)
/* Prepare data */
- if (!(mem_ctx = TALLOC_P( NULL, int))) {
+ if (!(mem_ctx = talloc( NULL, int))) {
DEBUG(0,("netsamlogon_cache_store: talloc() failed!\n"));
return false;
}
@@ -185,7 +179,7 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3)
data.dsize = blob.length;
data.dptr = blob.data;
- if (tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_REPLACE) != -1) {
+ if (tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_REPLACE) == 0) {
result = true;
}
@@ -223,7 +217,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
return NULL;
}
- info3 = TALLOC_ZERO_P(mem_ctx, struct netr_SamInfo3);
+ info3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
if (!info3) {
goto done;
}
diff --git a/source3/libsmb/smb_seal.c b/source3/libsmb/smb_seal.c
index 0eed15d4a3c..73786ac54a8 100644
--- a/source3/libsmb/smb_seal.c
+++ b/source3/libsmb/smb_seal.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "../libcli/auth/ntlmssp.h"
#include "smb_crypt.h"
+#include "libsmb/libsmb.h"
/******************************************************************************
Pull out the encryption context for this packet. 0 means global context.
@@ -464,46 +465,3 @@ void cli_free_enc_buffer(struct cli_state *cli, char *buf)
*/
common_free_enc_buffer(cli->trans_enc_state, buf);
}
-
-/******************************************************************************
- Decrypt an incoming buffer.
-******************************************************************************/
-
-NTSTATUS cli_decrypt_message(struct cli_state *cli)
-{
- NTSTATUS status;
- uint16 enc_ctx_num;
-
- /* Ignore non-session messages. */
- if(CVAL(cli->inbuf,0)) {
- return NT_STATUS_OK;
- }
-
- status = get_enc_ctx_num((const uint8_t *)cli->inbuf, &enc_ctx_num);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- if (enc_ctx_num != cli->trans_enc_state->enc_ctx_num) {
- return NT_STATUS_INVALID_HANDLE;
- }
-
- return common_decrypt_buffer(cli->trans_enc_state, cli->inbuf);
-}
-
-/******************************************************************************
- Encrypt an outgoing buffer. Return the encrypted pointer in buf_out.
-******************************************************************************/
-
-NTSTATUS cli_encrypt_message(struct cli_state *cli, char *buf, char **buf_out)
-{
- /* Ignore non-session messages. */
- if (CVAL(buf,0)) {
- return NT_STATUS_OK;
- }
-
- /* If we supported multiple encrytion contexts
- * here we'd look up based on tid.
- */
- return common_encrypt_buffer(cli->trans_enc_state, buf, buf_out);
-}
diff --git a/source3/libsmb/smb_share_modes.c b/source3/libsmb/smb_share_modes.c
index 1a6c2123ed6..7c0a6d2a4e6 100644
--- a/source3/libsmb/smb_share_modes.c
+++ b/source3/libsmb/smb_share_modes.c
@@ -27,6 +27,8 @@
#include "includes.h"
#include "system/filesys.h"
#include "smb_share_modes.h"
+#include "tdb_compat.h"
+#include <ccan/hash/hash.h>
/* Database context handle. */
struct smbdb_ctx {
@@ -67,10 +69,12 @@ struct smbdb_ctx *smb_share_mode_db_open(const char *db_path)
memset(smb_db, '\0', sizeof(struct smbdb_ctx));
- smb_db->smb_tdb = tdb_open(db_path,
- 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
- O_RDWR|O_CREAT,
- 0644);
+ /* FIXME: We should *never* open a tdb without logging! */
+ smb_db->smb_tdb = tdb_open_compat(db_path,
+ 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
+ O_RDWR|O_CREAT,
+ 0644,
+ NULL, NULL);
if (!smb_db->smb_tdb) {
free(smb_db);
@@ -120,7 +124,7 @@ int smb_lock_share_mode_entry(struct smbdb_ctx *db_ctx,
{
struct locking_key lk;
return tdb_chainlock(db_ctx->smb_tdb, get_locking_key(&lk, dev, ino,
- extid));
+ extid)) == 0 ? 0 : -1;
}
int smb_unlock_share_mode_entry(struct smbdb_ctx *db_ctx,
@@ -129,8 +133,9 @@ int smb_unlock_share_mode_entry(struct smbdb_ctx *db_ctx,
uint64_t extid)
{
struct locking_key lk;
- return tdb_chainunlock(db_ctx->smb_tdb,
- get_locking_key(&lk, dev, ino, extid));
+ tdb_chainunlock(db_ctx->smb_tdb,
+ get_locking_key(&lk, dev, ino, extid));
+ return 0;
}
/*
@@ -199,8 +204,8 @@ int smb_get_share_mode_entries(struct smbdb_ctx *db_ctx,
*pp_list = NULL;
*p_delete_on_close = 0;
- db_data = tdb_fetch(db_ctx->smb_tdb, get_locking_key(&lk, dev, ino,
- extid));
+ db_data = tdb_fetch_compat(db_ctx->smb_tdb,
+ get_locking_key(&lk, dev, ino, extid));
if (!db_data.dptr) {
return 0;
}
@@ -266,7 +271,6 @@ int smb_get_share_mode_entries(struct smbdb_ctx *db_ctx,
static uint32_t smb_name_hash(const char *sharepath, const char *filename, int *err)
{
- TDB_DATA key;
char *fullpath = NULL;
size_t sharepath_size = strlen(sharepath);
size_t filename_size = strlen(filename);
@@ -282,9 +286,7 @@ static uint32_t smb_name_hash(const char *sharepath, const char *filename, int *
fullpath[sharepath_size] = '/';
memcpy(&fullpath[sharepath_size + 1], filename, filename_size + 1);
- key.dptr = (uint8_t *)fullpath;
- key.dsize = strlen(fullpath) + 1;
- name_hash = tdb_jenkins_hash(&key);
+ name_hash = hash(fullpath, strlen(fullpath) + 1, 0);
free(fullpath);
return name_hash;
}
@@ -316,7 +318,7 @@ int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx,
return -1;
}
- db_data = tdb_fetch(db_ctx->smb_tdb, locking_key);
+ db_data = tdb_fetch_compat(db_ctx->smb_tdb, locking_key);
if (!db_data.dptr) {
/* We must create the entry. */
db_data.dptr = (uint8 *)malloc(
@@ -345,7 +347,7 @@ int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx,
db_data.dsize = sizeof(struct locking_data) + sizeof(struct share_mode_entry) +
strlen(sharepath) + 1 +
strlen(filename) + 1;
- if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_INSERT) == -1) {
+ if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_INSERT) != 0) {
free(db_data.dptr);
return -1;
}
@@ -388,7 +390,7 @@ int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx,
db_data.dptr = new_data_p;
db_data.dsize = new_data_size;
- if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) == -1) {
+ if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) != 0) {
free(db_data.dptr);
return -1;
}
@@ -433,7 +435,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
size_t i, num_share_modes;
const uint8 *remaining_ptr = NULL;
- db_data = tdb_fetch(db_ctx->smb_tdb, locking_key);
+ db_data = tdb_fetch_compat(db_ctx->smb_tdb, locking_key);
if (!db_data.dptr) {
return -1; /* Error - missing entry ! */
}
@@ -451,7 +453,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
}
/* It's ours - just remove the entire record. */
free(db_data.dptr);
- return tdb_delete(db_ctx->smb_tdb, locking_key);
+ return tdb_delete(db_ctx->smb_tdb, locking_key) ? -1 : 0;
}
/* More than one - allocate a new record minus the one we'll delete. */
@@ -490,7 +492,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
/* None left after pruning. Delete record. */
free(db_data.dptr);
free(new_data_p);
- return tdb_delete(db_ctx->smb_tdb, locking_key);
+ return tdb_delete(db_ctx->smb_tdb, locking_key) ? -1 : 0;
}
/* Copy any delete tokens plus the terminating filenames. */
@@ -511,7 +513,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
db_data.dsize = sizeof(struct locking_data) + (num_share_modes * sizeof(struct share_mode_entry)) + remaining_size;
- if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) == -1) {
+ if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) != 0) {
free(db_data.dptr);
return -1;
}
@@ -535,7 +537,7 @@ int smb_change_share_mode_entry(struct smbdb_ctx *db_ctx,
size_t i;
int found_entry = 0;
- db_data = tdb_fetch(db_ctx->smb_tdb, locking_key);
+ db_data = tdb_fetch_compat(db_ctx->smb_tdb, locking_key);
if (!db_data.dptr) {
return -1; /* Error - missing entry ! */
}
@@ -566,7 +568,7 @@ int smb_change_share_mode_entry(struct smbdb_ctx *db_ctx,
}
/* Save modified data. */
- if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) == -1) {
+ if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) != 0) {
free(db_data.dptr);
return -1;
}
diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c
index fd8626f5ad2..3a228b1b9ed 100644
--- a/source3/libsmb/smbsock_connect.c
+++ b/source3/libsmb/smbsock_connect.c
@@ -18,7 +18,8 @@
*/
#include "includes.h"
-#include "../lib/async_req/async_sock.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "client.h"
#include "async_smb.h"
#include "libsmb/nmblib.h"
@@ -215,7 +216,7 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
state->called_type =
(called_type != -1) ? called_type : 0x20;
state->calling_name =
- (calling_name != NULL) ? calling_name : global_myname();
+ (calling_name != NULL) ? calling_name : lp_netbios_name();
state->calling_type =
(calling_type != -1) ? calling_type : 0x00;
@@ -270,6 +271,7 @@ static int smbsock_connect_state_destructor(
{
if (state->sock != -1) {
close(state->sock);
+ state->sock = -1;
}
return 0;
}
@@ -368,7 +370,7 @@ NTSTATUS smbsock_connect_recv(struct tevent_req *req, int *sock,
NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port,
const char *called_name, int called_type,
const char *calling_name, int calling_type,
- int *pfd, uint16_t *ret_port)
+ int *pfd, uint16_t *ret_port, int sec_timeout)
{
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
@@ -385,6 +387,11 @@ NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port,
if (req == NULL) {
goto fail;
}
+ if ((sec_timeout != 0) &&
+ !tevent_req_set_endtime(
+ req, ev, timeval_current_ofs(sec_timeout, 0))) {
+ goto fail;
+ }
if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}
@@ -568,7 +575,7 @@ static void smbsock_any_connect_connected(struct tevent_req *subreq)
}
state->num_received += 1;
- if (state->num_received <= state->num_addrs) {
+ if (state->num_received < state->num_addrs) {
/*
* More addrs pending, wait for the others
*/
@@ -610,6 +617,7 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs,
int *calling_types,
size_t num_addrs,
uint16_t port,
+ int sec_timeout,
int *pfd, size_t *chosen_index,
uint16_t *chosen_port)
{
@@ -629,6 +637,11 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs,
if (req == NULL) {
goto fail;
}
+ if ((sec_timeout != 0) &&
+ !tevent_req_set_endtime(
+ req, ev, timeval_current_ofs(sec_timeout, 0))) {
+ goto fail;
+ }
if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}
diff --git a/source3/libsmb/trusts_util.c b/source3/libsmb/trusts_util.c
index 08377fbfbc6..dc2cf03a044 100644
--- a/source3/libsmb/trusts_util.c
+++ b/source3/libsmb/trusts_util.c
@@ -27,6 +27,7 @@
#include "../librpc/gen_ndr/ndr_netlogon.h"
#include "secrets.h"
#include "passdb.h"
+#include "libsmb/libsmb.h"
/*********************************************************
Change the domain password on the PDC.
@@ -168,7 +169,7 @@ bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain,
/* setup the anonymous connection */
- status = cli_full_connection( &cli, global_myname(), dc_name, &dc_ss, 0, "IPC$", "IPC",
+ status = cli_full_connection( &cli, lp_netbios_name(), dc_name, &dc_ss, 0, "IPC$", "IPC",
"", "", "", 0, Undefined);
if ( !NT_STATUS_IS_OK(status) )
goto done;
@@ -207,20 +208,20 @@ bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain,
*num_domains = dom_list.count;
- *domain_names = TALLOC_ZERO_ARRAY(mem_ctx, char *, *num_domains);
+ *domain_names = talloc_zero_array(mem_ctx, char *, *num_domains);
if (!*domain_names) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
- *sids = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, *num_domains);
+ *sids = talloc_zero_array(mem_ctx, struct dom_sid, *num_domains);
if (!*sids) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
for (i=0; i< *num_domains; i++) {
- (*domain_names)[i] = CONST_DISCARD(char *, dom_list.domains[i].name.string);
+ (*domain_names)[i] = discard_const_p(char, dom_list.domains[i].name.string);
(*sids)[i] = *dom_list.domains[i].sid;
}
@@ -263,7 +264,7 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
/* if this next call fails, then give up. We can't do
password changes on BDC's --jerry */
- if (!NT_STATUS_IS_OK(cli_full_connection(&cli, global_myname(), dc_name,
+ if (!NT_STATUS_IS_OK(cli_full_connection(&cli, lp_netbios_name(), dc_name,
NULL, 0,
"IPC$", "IPC",
"", "",
diff --git a/source3/libsmb/unexpected.c b/source3/libsmb/unexpected.c
index c5ad9ecb595..cf9ed7dbc6d 100644
--- a/source3/libsmb/unexpected.c
+++ b/source3/libsmb/unexpected.c
@@ -19,6 +19,7 @@
*/
#include "includes.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "lib/async_req/async_sock.h"
#include "libsmb/nmblib.h"
@@ -72,7 +73,7 @@ NTSTATUS nb_packet_server_create(TALLOC_CTX *mem_ctx,
struct tevent_fd *fde;
NTSTATUS status;
- result = TALLOC_ZERO_P(mem_ctx, struct nb_packet_server);
+ result = talloc_zero(mem_ctx, struct nb_packet_server);
if (result == NULL) {
status = NT_STATUS_NO_MEMORY;
goto fail;
@@ -139,7 +140,7 @@ static void nb_packet_server_listener(struct tevent_context *ev,
}
DEBUG(6,("accepted socket %d\n", sock));
- client = TALLOC_ZERO_P(server, struct nb_packet_client);
+ client = talloc_zero(server, struct nb_packet_client);
if (client == NULL) {
DEBUG(10, ("talloc failed\n"));
close(sock);
@@ -377,7 +378,7 @@ static void nb_packet_client_send(struct nb_packet_client *client,
return;
}
- state = TALLOC_ZERO_P(client, struct nb_packet_client_state);
+ state = talloc_zero(client, struct nb_packet_client_state);
if (state == NULL) {
DEBUG(10, ("talloc failed\n"));
return;
@@ -484,7 +485,7 @@ struct tevent_req *nb_packet_reader_send(TALLOC_CTX *mem_ctx,
state->query.mailslot_namelen = strlen(mailslot_name);
}
- state->reader = TALLOC_ZERO_P(state, struct nb_packet_reader);
+ state->reader = talloc_zero(state, struct nb_packet_reader);
if (tevent_req_nomem(state->reader, req)) {
return tevent_req_post(req, ev);
}
diff --git a/source3/locale/net/de.po b/source3/locale/net/de.po
index a12fabd9001..2244cd6983b 100644
--- a/source3/locale/net/de.po
+++ b/source3/locale/net/de.po
@@ -415,7 +415,7 @@ msgid " net getdomainsid"
msgstr ""
#: ../../utils/net.c:663
-msgid "Display the maximul RID currently used"
+msgid "Display the maximum RID currently used"
msgstr "Die höchste verwendete RID anzeigen"
#: ../../utils/net.c:664
@@ -924,7 +924,7 @@ msgstr ""
#: ../../utils/net_ads.c:1070
#, c-format
msgid "Join is OK\n"
-msgstr "Beitritt ist OK\n"
+msgstr "Mitgliedschaft ist OK\n"
#: ../../utils/net_ads.c:1081
msgid "Host is not configured as a member server.\n"
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index c325338062d..6eef695f691 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -5,17 +5,17 @@
Copyright (C) Andrew Tridgell 1992-2000
Copyright (C) Jeremy Allison 1992-2000
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -51,8 +51,8 @@ static void print_lock_struct(unsigned int i, struct lock_struct *pls)
i,
(unsigned long long)pls->context.smblctx,
(unsigned int)pls->context.tid,
- procid_str(talloc_tos(), &pls->context.pid) ));
-
+ server_id_str(talloc_tos(), &pls->context.pid) ));
+
DEBUG(10,("start = %.0f, size = %.0f, fnum = %d, %s %s\n",
(double)pls->start,
(double)pls->size,
@@ -180,7 +180,7 @@ static bool brl_conflict1(const struct lock_struct *lck1,
lck2->start >= (lck1->start + lck1->size)) {
return False;
}
-
+
return True;
}
#endif
@@ -1521,7 +1521,7 @@ void brl_close_fnum(struct messaging_context *msg_ctx,
/* Copy the current lock array. */
if (br_lck->num_locks) {
- locks_copy = (struct lock_struct *)TALLOC_MEMDUP(br_lck, locks, br_lck->num_locks * sizeof(struct lock_struct));
+ locks_copy = (struct lock_struct *)talloc_memdup(br_lck, locks, br_lck->num_locks * sizeof(struct lock_struct));
if (!locks_copy) {
smb_panic("brl_close_fnum: talloc failed");
}
@@ -1823,7 +1823,7 @@ static struct byte_range_lock *brl_get_locks_internal(TALLOC_CTX *mem_ctx,
files_struct *fsp, bool read_only)
{
TDB_DATA key, data;
- struct byte_range_lock *br_lck = TALLOC_P(mem_ctx, struct byte_range_lock);
+ struct byte_range_lock *br_lck = talloc(mem_ctx, struct byte_range_lock);
bool do_read_only = read_only;
if (br_lck == NULL) {
@@ -1845,7 +1845,7 @@ static struct byte_range_lock *brl_get_locks_internal(TALLOC_CTX *mem_ctx,
}
if (do_read_only) {
- if (brlock_db->fetch(brlock_db, br_lck, key, &data) == -1) {
+ if (brlock_db->fetch(brlock_db, br_lck, key, &data) != 0) {
DEBUG(3, ("Could not fetch byte range lock record\n"));
TALLOC_FREE(br_lck);
return NULL;
@@ -1881,7 +1881,7 @@ static struct byte_range_lock *brl_get_locks_internal(TALLOC_CTX *mem_ctx,
memcpy(br_lck->lock_data, data.dptr, data.dsize);
}
-
+
if (!fsp->lockdb_clean) {
int orig_num_locks = br_lck->num_locks;
@@ -1993,8 +1993,8 @@ static void brl_revalidate_collect(struct file_id id, struct server_id pid,
static int compare_procids(const void *p1, const void *p2)
{
- const struct server_id *i1 = (struct server_id *)p1;
- const struct server_id *i2 = (struct server_id *)p2;
+ const struct server_id *i1 = (const struct server_id *)p1;
+ const struct server_id *i2 = (const struct server_id *)p2;
if (i1->pid < i2->pid) return -1;
if (i2->pid > i2->pid) return 1;
@@ -2020,7 +2020,7 @@ static void brl_revalidate(struct messaging_context *msg_ctx,
uint32 i;
struct server_id last_pid;
- if (!(state = TALLOC_ZERO_P(NULL, struct brl_revalidate_state))) {
+ if (!(state = talloc_zero(NULL, struct brl_revalidate_state))) {
DEBUG(0, ("talloc failed\n"));
return;
}
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index f5892ddf0d7..81e93a555a1 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -4,17 +4,17 @@
Copyright (C) Andrew Tridgell 1992-2000
Copyright (C) Jeremy Allison 1992-2006
Copyright (C) Volker Lendecke 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/>.
@@ -43,6 +43,7 @@
#include "../libcli/security/security.h"
#include "serverid.h"
#include "messages.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_LOCKING
@@ -309,15 +310,15 @@ NTSTATUS do_unlock(struct messaging_context *msg_ctx,
{
bool ok = False;
struct byte_range_lock *br_lck = NULL;
-
+
if (!fsp->can_lock) {
return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE;
}
-
+
if (!lp_locking(fsp->conn->params)) {
return NT_STATUS_OK;
}
-
+
DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for fnum %d file %s\n",
(double)offset, (double)count, fsp->fnum,
fsp_str_dbg(fsp)));
@@ -334,7 +335,7 @@ NTSTATUS do_unlock(struct messaging_context *msg_ctx,
offset,
count,
lock_flav);
-
+
TALLOC_FREE(br_lck);
if (!ok) {
@@ -364,7 +365,7 @@ NTSTATUS do_lock_cancel(files_struct *fsp,
return fsp->is_directory ?
NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE;
}
-
+
if (!lp_locking(fsp->conn->params)) {
return NT_STATUS_DOS(ERRDOS, ERRcancelviolation);
}
@@ -578,7 +579,7 @@ static int parse_delete_tokens_list(struct share_mode_lock *lck,
p += sizeof(token_len);
- pdtl = TALLOC_ZERO_P(lck, struct delete_token_list);
+ pdtl = talloc_zero(lck, struct delete_token_list);
if (pdtl == NULL) {
DEBUG(0,("parse_delete_tokens_list: talloc failed"));
return -1;
@@ -587,7 +588,7 @@ static int parse_delete_tokens_list(struct share_mode_lock *lck,
memcpy(&pdtl->name_hash, p, sizeof(pdtl->name_hash));
p += sizeof(pdtl->name_hash);
- pdtl->delete_token = TALLOC_ZERO_P(pdtl, struct security_unix_token);
+ pdtl->delete_token = talloc_zero(pdtl, struct security_unix_token);
if (pdtl->delete_token == NULL) {
DEBUG(0,("parse_delete_tokens_list: talloc failed"));
return -1;
@@ -615,7 +616,7 @@ static int parse_delete_tokens_list(struct share_mode_lock *lck,
}
pdtl->delete_token->ngroups = token_len / sizeof(gid_t);
- pdtl->delete_token->groups = TALLOC_ARRAY(pdtl->delete_token, gid_t,
+ pdtl->delete_token->groups = talloc_array(pdtl->delete_token, gid_t,
pdtl->delete_token->ngroups);
if (pdtl->delete_token->groups == NULL) {
DEBUG(0,("parse_delete_tokens_list: talloc failed"));
@@ -671,7 +672,7 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
}
lck->share_modes = NULL;
-
+
if (lck->num_share_modes != 0) {
if (dbuf.dsize < (sizeof(struct locking_data) +
@@ -679,9 +680,9 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
sizeof(struct share_mode_entry)))) {
smb_panic("parse_share_modes: buffer too short");
}
-
+
lck->share_modes = (struct share_mode_entry *)
- TALLOC_MEMDUP(lck,
+ talloc_memdup(lck,
dbuf.dptr+sizeof(struct locking_data),
lck->num_share_modes *
sizeof(struct share_mode_entry));
@@ -781,7 +782,7 @@ static TDB_DATA unparse_share_modes(const struct share_mode_lock *lck)
sp_len + 1 +
bn_len + 1 +
sn_len + 1;
- result.dptr = TALLOC_ARRAY(lck, uint8, result.dsize);
+ result.dptr = talloc_array(lck, uint8, result.dsize);
if (result.dptr == NULL) {
smb_panic("talloc failed");
@@ -838,14 +839,17 @@ static TDB_DATA unparse_share_modes(const struct share_mode_lock *lck)
offset += token_size;
}
- safe_strcpy((char *)result.dptr + offset, lck->servicepath,
- result.dsize - offset - 1);
+ strlcpy((char *)result.dptr + offset,
+ lck->servicepath ? lck->servicepath : "",
+ result.dsize - offset);
offset += sp_len + 1;
- safe_strcpy((char *)result.dptr + offset, lck->base_name,
- result.dsize - offset - 1);
+ strlcpy((char *)result.dptr + offset,
+ lck->base_name ? lck->base_name : "",
+ result.dsize - offset);
offset += bn_len + 1;
- safe_strcpy((char *)result.dptr + offset, lck->stream_name,
- result.dsize - offset - 1);
+ strlcpy((char *)result.dptr + offset,
+ lck->stream_name ? lck->stream_name : "",
+ result.dsize - offset);
if (DEBUGLEVEL >= 10) {
print_share_mode_table(data);
@@ -969,7 +973,7 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
struct file_id tmp;
TDB_DATA key = locking_key(&id, &tmp);
- if (!(lck = TALLOC_P(mem_ctx, struct share_mode_lock))) {
+ if (!(lck = talloc(mem_ctx, struct share_mode_lock))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
@@ -1000,12 +1004,12 @@ struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
TDB_DATA key = locking_key(&id, &tmp);
TDB_DATA data;
- if (!(lck = TALLOC_P(mem_ctx, struct share_mode_lock))) {
+ if (!(lck = talloc(mem_ctx, struct share_mode_lock))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
- if (lock_db->fetch(lock_db, lck, key, &data) == -1) {
+ if (lock_db->fetch(lock_db, lck, key, &data) != 0) {
DEBUG(3, ("Could not fetch share entry\n"));
TALLOC_FREE(lck);
return NULL;
@@ -1078,7 +1082,7 @@ bool rename_share_filename(struct messaging_context *msg_ctx,
sn_len + 1;
/* Set up the name changed message. */
- frm = TALLOC_ARRAY(lck, char, msg_len);
+ frm = talloc_array(lck, char, msg_len);
if (!frm) {
return False;
}
@@ -1087,10 +1091,15 @@ bool rename_share_filename(struct messaging_context *msg_ctx,
DEBUG(10,("rename_share_filename: msg_len = %u\n", (unsigned int)msg_len ));
- safe_strcpy(&frm[24], lck->servicepath, sp_len);
- safe_strcpy(&frm[24 + sp_len + 1], lck->base_name, bn_len);
- safe_strcpy(&frm[24 + sp_len + 1 + bn_len + 1], lck->stream_name,
- sn_len);
+ strlcpy(&frm[24],
+ lck->servicepath ? lck->servicepath : "",
+ sp_len+1);
+ strlcpy(&frm[24 + sp_len + 1],
+ lck->base_name ? lck->base_name : "",
+ bn_len+1);
+ strlcpy(&frm[24 + sp_len + 1 + bn_len + 1],
+ lck->stream_name ? lck->stream_name : "",
+ sn_len+1);
/* Send the messages. */
for (i=0; i<lck->num_share_modes; i++) {
@@ -1424,7 +1433,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode)
* Only allow delete on close for writable files.
*/
- if ((dosmode & aRONLY) &&
+ if ((dosmode & FILE_ATTRIBUTE_READONLY) &&
!lp_delete_readonly(SNUM(fsp->conn))) {
DEBUG(10,("can_set_delete_on_close: file %s delete on close "
"flag set but file attribute is readonly.\n",
@@ -1474,7 +1483,7 @@ static struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct
{
struct security_unix_token *cpy;
- cpy = TALLOC_P(ctx, struct security_unix_token);
+ cpy = talloc(ctx, struct security_unix_token);
if (!cpy) {
return NULL;
}
@@ -1484,11 +1493,12 @@ static struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct
cpy->ngroups = tok->ngroups;
if (tok->ngroups) {
/* Make this a talloc child of cpy. */
- cpy->groups = TALLOC_ARRAY(cpy, gid_t, tok->ngroups);
+ cpy->groups = (gid_t *)talloc_memdup(
+ cpy, tok->groups, tok->ngroups * sizeof(gid_t));
if (!cpy->groups) {
+ TALLOC_FREE(cpy);
return NULL;
}
- memcpy(cpy->groups, tok->groups, tok->ngroups * sizeof(gid_t));
}
return cpy;
}
@@ -1503,7 +1513,7 @@ static bool add_delete_on_close_token(struct share_mode_lock *lck,
{
struct delete_token_list *dtl;
- dtl = TALLOC_ZERO_P(lck, struct delete_token_list);
+ dtl = talloc_zero(lck, struct delete_token_list);
if (dtl == NULL) {
return false;
}
@@ -1573,7 +1583,7 @@ void set_delete_on_close_lck(files_struct *fsp,
bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const struct security_unix_token *tok)
{
struct share_mode_lock *lck;
-
+
DEBUG(10,("set_delete_on_close: %s delete on close flag for "
"fnum = %d, file %s\n",
delete_on_close ? "Adding" : "Removing", fsp->fnum,
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index cea8d2f8a2e..51151df9a43 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -25,6 +25,7 @@
#include "system/filesys.h"
#include "locking/proto.h"
#include "dbwrap.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_LOCKING
@@ -557,7 +558,7 @@ static void add_fd_to_close_entry(files_struct *fsp)
SMB_ASSERT(rec != NULL);
- new_data = TALLOC_ARRAY(
+ new_data = talloc_array(
rec, uint8_t, rec->value.dsize + sizeof(fsp->fh->fd));
SMB_ASSERT(new_data != NULL);
@@ -891,7 +892,7 @@ BECOMES.....
| l_curr| | l_new |
+-------+ +---------+
**********************************************/
- struct lock_list *l_new = TALLOC_P(ctx, struct lock_list);
+ struct lock_list *l_new = talloc(ctx, struct lock_list);
if(l_new == NULL) {
DEBUG(0,("posix_lock_list: talloc fail.\n"));
@@ -999,7 +1000,7 @@ bool set_posix_lock_windows_flavour(files_struct *fsp,
return False;
}
- if ((ll = TALLOC_P(l_ctx, struct lock_list)) == NULL) {
+ if ((ll = talloc(l_ctx, struct lock_list)) == NULL) {
DEBUG(0,("set_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
talloc_destroy(l_ctx);
return False;
@@ -1118,7 +1119,7 @@ bool release_posix_lock_windows_flavour(files_struct *fsp,
return False;
}
- if ((ul = TALLOC_P(ul_ctx, struct lock_list)) == NULL) {
+ if ((ul = talloc(ul_ctx, struct lock_list)) == NULL) {
DEBUG(0,("release_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
talloc_destroy(ul_ctx);
return False;
@@ -1280,7 +1281,7 @@ bool release_posix_lock_posix_flavour(files_struct *fsp,
return False;
}
- if ((ul = TALLOC_P(ul_ctx, struct lock_list)) == NULL) {
+ if ((ul = talloc(ul_ctx, struct lock_list)) == NULL) {
DEBUG(0,("release_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
talloc_destroy(ul_ctx);
return False;
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 6f130961a86..b7c8990b1af 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -1,3 +1,27 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Locking functions
+ *
+ * Copyright (C) Andrew Tridgell 1992-2000
+ * Copyright (C) Jeremy Allison 1992-2006
+ * Copyright (C) Volker Lendecke 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/>.
+ */
+
+#ifndef _LOCKING_PROTO_H_
+#define _LOCKING_PROTO_H_
/* The following definitions come from locking/brlock.c */
@@ -199,3 +223,5 @@ bool release_posix_lock_posix_flavour(files_struct *fsp,
const struct lock_context *lock_ctx,
const struct lock_struct *plocks,
int num_locks);
+
+#endif /* _LOCKING_PROTO_H_ */
diff --git a/source3/m4/aclocal.m4 b/source3/m4/aclocal.m4
index 301445f562d..afd7c7491a1 100644
--- a/source3/m4/aclocal.m4
+++ b/source3/m4/aclocal.m4
@@ -54,7 +54,7 @@ AC_DEFUN(SMB_SUBSYSTEM,
])
-dnl SMB_LIBRARY(name, version, default, reason)
+dnl SMB_LIBRARY(name, soversion, fullversion, default, reason)
dnl
dnl configure build and use of an (internal) shared library
dnl
@@ -74,6 +74,7 @@ LIBUC[_TARGET]=
[UNINSTALL_]LIBUC=
m4_if([$2], [], [LIBUC[_SOVER]=0], [LIBUC[_SOVER]=$2])
+m4_if([$3], [], [LIBUC[_FULLVER]=$LIBUC[_SOVER]], [LIBUC[_FULLVER]=$3])
AC_SUBST(LIBUC[_SHARED_TARGET])
AC_SUBST(LIBUC[_STATIC_TARGET])
@@ -84,15 +85,16 @@ AC_SUBST(LIBUC[_TARGET])
AC_SUBST([INSTALL_]LIBUC)
AC_SUBST([UNINSTALL_]LIBUC)
AC_SUBST(LIBUC[_SOVER])
+AC_SUBST(LIBUC[_FULLVER])
AC_MSG_CHECKING([whether to build the LIBNAME shared library])
-m4_if([$3], [no], [
+m4_if([$4], [no], [
dnl set the default to not build the shared lib
AC_ARG_WITH(LIBNAME,
AS_HELP_STRING([--with-]LIBNAME,
- m4_if([$4], [],
+ m4_if([$5], [],
[Build the LIBNAME shared library (default=no)],
- [Build the LIBNAME shared library (default=no ($4))])),
+ [Build the LIBNAME shared library (default=no ($5))])),
[
case "$withval" in
yes)
diff --git a/source3/m4/samba_version.m4 b/source3/m4/samba_version.m4
index dbea1f3b3a1..8ee0232df81 100644
--- a/source3/m4/samba_version.m4
+++ b/source3/m4/samba_version.m4
@@ -8,7 +8,7 @@ dnl http://www.gnu.org/licenses/
dnl
dnl
-SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
+SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep '#define SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
SAMBA_VERSION_GIT_COMMIT_FULLREV=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_FULLREV' | cut -d ' ' -f3- | cut -d '"' -f2`
diff --git a/source3/modules/CP437.c b/source3/modules/CP437.c
deleted file mode 100644
index 96d14b1f023..00000000000
--- a/source3/modules/CP437.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Conversion table for CP437 charset also known as IBM437
- *
- * Copyright (C) Alexander Bokovoy 2003
- *
- * Conversion tables are generated using GNU libc 2.2.5's
- * localedata/charmaps/IBM437 table and source/script/gen-8bit-gap.sh script
- *
- * 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"
-
-static const uint16 to_ucs2[256] = {
- 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
- 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
- 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
- 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
- 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
- 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
- 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
- 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
- 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
- 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
- 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
- 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
- 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
- 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
- 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
- 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
- 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
- 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
- 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
- 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
- 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
- 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
- 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
- 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
- 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
- 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
- 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
- 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
- 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
- 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
- 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
- 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0,
-};
-
-static const struct charset_gap_table from_idx[] = {
- { 0x0000, 0x007f, 0 },
- { 0x00a0, 0x00c9, -32 },
- { 0x00d1, 0x00ff, -39 },
- { 0x0192, 0x0192, -185 },
- { 0x0393, 0x0398, -697 },
- { 0x03a3, 0x03a9, -707 },
- { 0x03b1, 0x03b5, -714 },
- { 0x03c0, 0x03c6, -724 },
- { 0x207f, 0x207f, -8076 },
- { 0x20a7, 0x20a7, -8115 },
- { 0x2219, 0x221e, -8484 },
- { 0x2229, 0x2229, -8494 },
- { 0x2248, 0x2248, -8524 },
- { 0x2261, 0x2265, -8548 },
- { 0x2310, 0x2310, -8718 },
- { 0x2320, 0x2321, -8733 },
- { 0x2500, 0x2502, -9211 },
- { 0x250c, 0x251c, -9220 },
- { 0x2524, 0x2524, -9227 },
- { 0x252c, 0x252c, -9234 },
- { 0x2534, 0x2534, -9241 },
- { 0x253c, 0x253c, -9248 },
- { 0x2550, 0x256c, -9267 },
- { 0x2580, 0x2593, -9286 },
- { 0x25a0, 0x25a0, -9298 },
- { 0xffff, 0xffff, 0 }
-};
-
-static const unsigned char from_ucs2[] = {
-
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
- 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
- 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
- 0xff, 0xad, 0x9b, 0x9c, 0x00, 0x9d, 0x00, 0x00,
- 0x00, 0x00, 0xa6, 0xae, 0xaa, 0x00, 0x00, 0x00,
- 0xf8, 0xf1, 0xfd, 0x00, 0x00, 0xe6, 0x00, 0xfa,
- 0x00, 0x00, 0xa7, 0xaf, 0xac, 0xab, 0x00, 0xa8,
- 0x00, 0x00, 0x00, 0x00, 0x8e, 0x8f, 0x92, 0x80,
- 0x00, 0x90, 0xa5, 0x00, 0x00, 0x00, 0x00, 0x99,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00,
- 0xe1, 0x85, 0xa0, 0x83, 0x00, 0x84, 0x86, 0x91,
- 0x87, 0x8a, 0x82, 0x88, 0x89, 0x8d, 0xa1, 0x8c,
- 0x8b, 0x00, 0xa4, 0x95, 0xa2, 0x93, 0x00, 0x94,
- 0xf6, 0x00, 0x97, 0xa3, 0x96, 0x81, 0x00, 0x00,
- 0x98, 0x9f, 0xe2, 0x00, 0x00, 0x00, 0x00, 0xe9,
- 0xe4, 0x00, 0x00, 0xe8, 0x00, 0x00, 0xea, 0xe0,
- 0x00, 0x00, 0xeb, 0xee, 0xe3, 0x00, 0x00, 0xe5,
- 0xe7, 0x00, 0xed, 0xfc, 0x9e, 0xf9, 0xfb, 0x00,
- 0x00, 0x00, 0xec, 0xef, 0xf7, 0xf0, 0x00, 0x00,
- 0xf3, 0xf2, 0xa9, 0xf4, 0xf5, 0xc4, 0x00, 0xb3,
- 0xda, 0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00,
- 0xc0, 0x00, 0x00, 0x00, 0xd9, 0x00, 0x00, 0x00,
- 0xc3, 0xb4, 0xc2, 0xc1, 0xc5, 0xcd, 0xba, 0xd5,
- 0xd6, 0xc9, 0xb8, 0xb7, 0xbb, 0xd4, 0xd3, 0xc8,
- 0xbe, 0xbd, 0xbc, 0xc6, 0xc7, 0xcc, 0xb5, 0xb6,
- 0xb9, 0xd1, 0xd2, 0xcb, 0xcf, 0xd0, 0xca, 0xd8,
- 0xd7, 0xce, 0xdf, 0x00, 0x00, 0x00, 0xdc, 0x00,
- 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0xdd, 0x00,
- 0x00, 0x00, 0xde, 0xb0, 0xb1, 0xb2, 0xfe,
-};
-
-SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP(CP437)
diff --git a/source3/modules/CP850.c b/source3/modules/CP850.c
deleted file mode 100644
index 40730c0d8d6..00000000000
--- a/source3/modules/CP850.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Conversion table for CP850 charset also known as IBM850.
- *
- * Copyright (C) Alexander Bokovoy 2003
- *
- * Conversion tables are generated using GNU libc 2.2.5's
- * localedata/charmaps/IBM850 table and source/script/gen-8bit-gap.sh script
- *
- * 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"
-
-static const uint16 to_ucs2[256] = {
- 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
- 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
- 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
- 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
- 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
- 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
- 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
- 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
- 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
- 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
- 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
- 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
- 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
- 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
- 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
- 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
- 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
- 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
- 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
- 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
- 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
- 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
- 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
- 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
- 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
- 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
- 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
- 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
- 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
- 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
- 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
- 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0,
-};
-
-static const struct charset_gap_table from_idx[] = {
- /* start, end, idx */
- { 0x0000, 0x007f, 0 },
- { 0x00a0, 0x00ff, -32 },
- { 0x0131, 0x0131, -81 },
- { 0x0192, 0x0192, -177 },
- { 0x2017, 0x2017, -7989 },
- { 0x2500, 0x2502, -9245 },
- { 0x250c, 0x251c, -9254 },
- { 0x2524, 0x2524, -9261 },
- { 0x252c, 0x252c, -9268 },
- { 0x2534, 0x2534, -9275 },
- { 0x253c, 0x253c, -9282 },
- { 0x2550, 0x256c, -9301 },
- { 0x2580, 0x2588, -9320 },
- { 0x2591, 0x2593, -9328 },
- { 0x25a0, 0x25a0, -9340 },
- { 0xffff, 0xffff, 0 }
-};
-static const unsigned char from_ucs2[] = {
-
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
- 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
- 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
- 0xff, 0xad, 0xbd, 0x9c, 0xcf, 0xbe, 0xdd, 0xf5,
- 0xf9, 0xb8, 0xa6, 0xae, 0xaa, 0xf0, 0xa9, 0xee,
- 0xf8, 0xf1, 0xfd, 0xfc, 0xef, 0xe6, 0xf4, 0xfa,
- 0xf7, 0xfb, 0xa7, 0xaf, 0xac, 0xab, 0xf3, 0xa8,
- 0xb7, 0xb5, 0xb6, 0xc7, 0x8e, 0x8f, 0x92, 0x80,
- 0xd4, 0x90, 0xd2, 0xd3, 0xde, 0xd6, 0xd7, 0xd8,
- 0xd1, 0xa5, 0xe3, 0xe0, 0xe2, 0xe5, 0x99, 0x9e,
- 0x9d, 0xeb, 0xe9, 0xea, 0x9a, 0xed, 0xe8, 0xe1,
- 0x85, 0xa0, 0x83, 0xc6, 0x84, 0x86, 0x91, 0x87,
- 0x8a, 0x82, 0x88, 0x89, 0x8d, 0xa1, 0x8c, 0x8b,
- 0xd0, 0xa4, 0x95, 0xa2, 0x93, 0xe4, 0x94, 0xf6,
- 0x9b, 0x97, 0xa3, 0x96, 0x81, 0xec, 0xe7, 0x98,
- 0xd5, 0x9f, 0xf2, 0xc4, 0x00, 0xb3, 0xda, 0x00,
- 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0xc0, 0x00,
- 0x00, 0x00, 0xd9, 0x00, 0x00, 0x00, 0xc3, 0xb4,
- 0xc2, 0xc1, 0xc5, 0xcd, 0xba, 0x00, 0x00, 0xc9,
- 0x00, 0x00, 0xbb, 0x00, 0x00, 0xc8, 0x00, 0x00,
- 0xbc, 0x00, 0x00, 0xcc, 0x00, 0x00, 0xb9, 0x00,
- 0x00, 0xcb, 0x00, 0x00, 0xca, 0x00, 0x00, 0xce,
- 0xdf, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00,
- 0xdb, 0xb0, 0xb1, 0xb2, 0xfe,
-};
-
-SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP(CP850)
-
diff --git a/source3/modules/charset_macosxfs.c b/source3/modules/charset_macosxfs.c
deleted file mode 100644
index 8c2fdc7776b..00000000000
--- a/source3/modules/charset_macosxfs.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba charset module for Mac OS X/Darwin
- Copyright (C) Benjamin Riefenstahl 2003
-
- 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/>.
-*/
-
-/*
- * modules/charset_macosxfs.c
- *
- * A Samba charset module to use on Mac OS X/Darwin as the filesystem
- * and display encoding.
- *
- * Actually two implementations are provided here. The default
- * implementation is based on the official CFString API. The other is
- * based on internal CFString APIs as defined in the OpenDarwin
- * source.
- */
-
-#include "includes.h"
-
-/*
- * Include OS frameworks. These are only needed in this module.
- */
-#include <CoreFoundation/CFString.h>
-
-/*
- * See if autoconf has found us the internal headers in some form.
- */
-#if HAVE_COREFOUNDATION_CFSTRINGENCODINGCONVERTER_H
-# include <CoreFoundation/CFStringEncodingConverter.h>
-# include <CoreFoundation/CFUnicodePrecomposition.h>
-# define USE_INTERNAL_API 1
-#elif HAVE_CFSTRINGENCODINGCONVERTER_H
-# include <CFStringEncodingConverter.h>
-# include <CFUnicodePrecomposition.h>
-# define USE_INTERNAL_API 1
-#endif
-
-/*
- * Compile time configuration: Do we want debug output?
- */
-/* #define DEBUG_STRINGS 1 */
-
-/*
- * A simple, but efficient memory provider for our buffers.
- */
-static inline void *resize_buffer (void *buffer, size_t *size, size_t newsize)
-{
- if (newsize > *size) {
- *size = newsize + 128;
- buffer = SMB_REALLOC(buffer, *size);
- }
- return buffer;
-}
-
-/*
- * While there is a version of OpenDarwin for intel, the usual case is
- * big-endian PPC. So we need byte swapping to handle the
- * little-endian byte order of the network protocol. We also need an
- * additional dynamic buffer to do this work for incoming data blocks,
- * because we have to consider the original data as constant.
- *
- * We abstract the differences away by providing a simple facade with
- * these functions/macros:
- *
- * le_to_native(dst,src,len)
- * native_to_le(cp,len)
- * set_ucbuffer_with_le(buffer,bufsize,data,size)
- * set_ucbuffer_with_le_copy(buffer,bufsize,data,size,reserve)
- */
-#ifdef WORDS_BIGENDIAN
-
-static inline void swap_bytes (char * dst, const char * src, size_t len)
-{
- const char *srcend = src + len;
- while (src < srcend) {
- dst[0] = src[1];
- dst[1] = src[0];
- dst += 2;
- src += 2;
- }
-}
-static inline void swap_bytes_inplace (char * cp, size_t len)
-{
- char temp;
- char *end = cp + len;
- while (cp < end) {
- temp = cp[1];
- cp[1] = cp[0];
- cp[0] = temp;
- cp += 2;
- }
-}
-
-#define le_to_native(dst,src,len) swap_bytes(dst,src,len)
-#define native_to_le(cp,len) swap_bytes_inplace(cp,len)
-#define set_ucbuffer_with_le(buffer,bufsize,data,size) \
- set_ucbuffer_with_le_copy(buffer,bufsize,data,size,0)
-
-#else /* ! WORDS_BIGENDIAN */
-
-#define le_to_native(dst,src,len) memcpy(dst,src,len)
-#define native_to_le(cp,len) /* nothing */
-#define set_ucbuffer_with_le(buffer,bufsize,data,size) \
- (((void)(bufsize)),(UniChar*)(data))
-
-#endif
-
-static inline UniChar *set_ucbuffer_with_le_copy (
- UniChar *buffer, size_t *bufsize,
- const void *data, size_t size, size_t reserve)
-{
- buffer = resize_buffer(buffer, bufsize, size+reserve);
- le_to_native((char*)buffer,data,size);
- return buffer;
-}
-
-
-/*
- * A simple hexdump function for debugging error conditions.
- */
-#define debug_out(s) DEBUG(0,(s))
-
-#ifdef DEBUG_STRINGS
-
-static void hexdump( const char * label, const char * s, size_t len )
-{
- size_t restlen = len;
- debug_out("<<<<<<<\n");
- debug_out(label);
- debug_out("\n");
- while (restlen > 0) {
- char line[100];
- size_t i, j;
- char * d = line;
-#undef sprintf
- d += sprintf(d, "%04X ", (unsigned)(len-restlen));
- *d++ = ' ';
- for( i = 0; i<restlen && i<8; ++i ) {
- d += sprintf(d, "%02X ", ((unsigned)s[i]) & 0xFF);
- }
- for( j = i; j<8; ++j ) {
- d += sprintf(d, " ");
- }
- *d++ = ' ';
- for( i = 8; i<restlen && i<16; ++i ) {
- d += sprintf(d, "%02X ", ((unsigned)s[i]) & 0xFF);
- }
- for( j = i; j<16; ++j ) {
- d += sprintf(d, " ");
- }
- *d++ = ' ';
- for( i = 0; i<restlen && i<16; ++i ) {
- if(s[i] < ' ' || s[i] >= 0x7F || !isprint(s[i]))
- *d++ = '.';
- else
- *d++ = s[i];
- }
- *d++ = '\n';
- *d = 0;
- restlen -= i;
- s += i;
- debug_out(line);
- }
- debug_out(">>>>>>>\n");
-}
-
-#else /* !DEBUG_STRINGS */
-
-#define hexdump(label,s,len) /* nothing */
-
-#endif
-
-
-#if !USE_INTERNAL_API
-
-/*
- * An implementation based on documented Mac OS X APIs.
- *
- * This does a certain amount of memory management, creating and
- * manipulating CFString objects. We try to minimize the impact by
- * keeping those objects around and re-using them. We also use
- * external backing store for the CFStrings where this is possible and
- * benficial.
- *
- * The Unicode normalizations forms available at this level are
- * generic, not specifically for the file system. So they may not be
- * perfect fits.
- */
-static size_t macosxfs_encoding_pull(
- void *cd, /* Encoder handle */
- char **inbuf, size_t *inbytesleft, /* Script string */
- char **outbuf, size_t *outbytesleft) /* UTF-16-LE string */
-{
- static const int script_code = kCFStringEncodingUTF8;
- static CFMutableStringRef cfstring = NULL;
- size_t outsize;
- CFRange range;
-
- (void) cd; /* UNUSED */
-
- if (0 == *inbytesleft) {
- return 0;
- }
-
- if (NULL == cfstring) {
- /*
- * A version with an external backing store as in the
- * push function should have been more efficient, but
- * testing shows, that it is actually slower (!).
- * Maybe kCFAllocatorDefault gets shortcut evaluation
- * internally, while kCFAllocatorNull doesn't.
- */
- cfstring = CFStringCreateMutable(kCFAllocatorDefault,0);
- }
-
- /*
- * Three methods of appending to a CFString, choose the most
- * efficient.
- */
- if (0 == (*inbuf)[*inbytesleft-1]) {
- CFStringAppendCString(cfstring, *inbuf, script_code);
- } else if (*inbytesleft <= 255) {
- Str255 buffer;
- buffer[0] = *inbytesleft;
- memcpy(buffer+1, *inbuf, buffer[0]);
- CFStringAppendPascalString(cfstring, buffer, script_code);
- } else {
- /*
- * We would like to use a fixed buffer and a loop
- * here, but than we can't garantee that the input is
- * well-formed UTF-8, as we are supposed to do.
- */
- static char *buffer = NULL;
- static size_t buflen = 0;
- buffer = resize_buffer(buffer, &buflen, *inbytesleft+1);
- memcpy(buffer, *inbuf, *inbytesleft);
- buffer[*inbytesleft] = 0;
- CFStringAppendCString(cfstring, *inbuf, script_code);
- }
-
- /*
- * Compose characters, using the non-canonical composition
- * form.
- */
- CFStringNormalize(cfstring, kCFStringNormalizationFormC);
-
- outsize = CFStringGetLength(cfstring);
- range = CFRangeMake(0,outsize);
-
- if (outsize == 0) {
- /*
- * HACK: smbd/mangle_hash2.c:is_legal_name() expects
- * errors here. That function will always pass 2
- * characters. smbd/open.c:check_for_pipe() cuts a
- * patchname to 10 characters blindly. Suppress the
- * debug output in those cases.
- */
- if(2 != *inbytesleft && 10 != *inbytesleft) {
- debug_out("String conversion: "
- "An unknown error occurred\n");
- hexdump("UTF8->UTF16LE (old) input",
- *inbuf, *inbytesleft);
- }
- errno = EILSEQ; /* Not sure, but this is what we have
- * actually seen. */
- return -1;
- }
- if (outsize*2 > *outbytesleft) {
- CFStringDelete(cfstring, range);
- debug_out("String conversion: "
- "Output buffer too small\n");
- hexdump("UTF8->UTF16LE (old) input",
- *inbuf, *inbytesleft);
- errno = E2BIG;
- return -1;
- }
-
- CFStringGetCharacters(cfstring, range, (UniChar*)*outbuf);
- CFStringDelete(cfstring, range);
-
- native_to_le(*outbuf, outsize*2);
-
- /*
- * Add a converted null byte, if the CFString conversions
- * prevented that until now.
- */
- if (0 == (*inbuf)[*inbytesleft-1] &&
- (0 != (*outbuf)[outsize*2-1] || 0 != (*outbuf)[outsize*2-2])) {
-
- if ((outsize*2+2) > *outbytesleft) {
- debug_out("String conversion: "
- "Output buffer too small\n");
- hexdump("UTF8->UTF16LE (old) input",
- *inbuf, *inbytesleft);
- errno = E2BIG;
- return -1;
- }
-
- (*outbuf)[outsize*2] = (*outbuf)[outsize*2+1] = 0;
- outsize += 2;
- }
-
- *inbuf += *inbytesleft;
- *inbytesleft = 0;
- *outbuf += outsize*2;
- *outbytesleft -= outsize*2;
-
- return 0;
-}
-
-static size_t macosxfs_encoding_push(
- void *cd, /* Encoder handle */
- char **inbuf, size_t *inbytesleft, /* UTF-16-LE string */
- char **outbuf, size_t *outbytesleft) /* Script string */
-{
- static const int script_code = kCFStringEncodingUTF8;
- static CFMutableStringRef cfstring = NULL;
- static UniChar *buffer = NULL;
- static size_t buflen = 0;
- CFIndex outsize, cfsize, charsconverted;
-
- (void) cd; /* UNUSED */
-
- if (0 == *inbytesleft) {
- return 0;
- }
-
- /*
- * We need a buffer that can hold 4 times the original data,
- * because that is the theoretical maximum that decomposition
- * can create currently (in Unicode 4.0).
- */
- buffer = set_ucbuffer_with_le_copy(
- buffer, &buflen, *inbuf, *inbytesleft, 3 * *inbytesleft);
-
- if (NULL == cfstring) {
- cfstring = CFStringCreateMutableWithExternalCharactersNoCopy(
- kCFAllocatorDefault,
- buffer, *inbytesleft/2, buflen/2,
- kCFAllocatorNull);
- } else {
- CFStringSetExternalCharactersNoCopy(
- cfstring,
- buffer, *inbytesleft/2, buflen/2);
- }
-
- /*
- * Decompose characters, using the non-canonical decomposition
- * form.
- *
- * NB: This isn't exactly what HFS+ wants (see note on
- * kCFStringEncodingUseHFSPlusCanonical in
- * CFStringEncodingConverter.h), but AFAIK it's the best that
- * the official API can do.
- */
- CFStringNormalize(cfstring, kCFStringNormalizationFormD);
-
- cfsize = CFStringGetLength(cfstring);
- charsconverted = CFStringGetBytes(
- cfstring, CFRangeMake(0,cfsize),
- script_code, 0, False,
- *outbuf, *outbytesleft, &outsize);
-
- if (0 == charsconverted) {
- debug_out("String conversion: "
- "Buffer too small or not convertable\n");
- hexdump("UTF16LE->UTF8 (old) input",
- *inbuf, *inbytesleft);
- errno = EILSEQ; /* Probably more likely. */
- return -1;
- }
-
- /*
- * Add a converted null byte, if the CFString conversions
- * prevented that until now.
- */
- if (0 == (*inbuf)[*inbytesleft-1] && 0 == (*inbuf)[*inbytesleft-2] &&
- (0 != (*outbuf)[outsize-1])) {
-
- if (((size_t)outsize+1) > *outbytesleft) {
- debug_out("String conversion: "
- "Output buffer too small\n");
- hexdump("UTF16LE->UTF8 (old) input",
- *inbuf, *inbytesleft);
- errno = E2BIG;
- return -1;
- }
-
- (*outbuf)[outsize] = 0;
- ++outsize;
- }
-
- *inbuf += *inbytesleft;
- *inbytesleft = 0;
- *outbuf += outsize;
- *outbytesleft -= outsize;
-
- return 0;
-}
-
-#else /* USE_INTERNAL_API */
-
-/*
- * An implementation based on internal code as known from the
- * OpenDarwin CVS.
- *
- * This code doesn't need much memory management because it uses
- * functions that operate on the raw memory directly.
- *
- * The push routine here is faster and more compatible with HFS+ than
- * the other implementation above. The pull routine is only faster
- * for some strings, slightly slower for others. The pull routine
- * looses because it has to iterate over the data twice, once to
- * decode UTF-8 and than to do the character composition required by
- * Windows.
- */
-static size_t macosxfs_encoding_pull(
- void *cd, /* Encoder handle */
- char **inbuf, size_t *inbytesleft, /* Script string */
- char **outbuf, size_t *outbytesleft) /* UTF-16-LE string */
-{
- static const int script_code = kCFStringEncodingUTF8;
- UInt32 srcCharsUsed = 0;
- UInt32 dstCharsUsed = 0;
- UInt32 result;
- uint32_t dstDecomposedUsed = 0;
- uint32_t dstPrecomposedUsed = 0;
-
- (void) cd; /* UNUSED */
-
- if (0 == *inbytesleft) {
- return 0;
- }
-
- result = CFStringEncodingBytesToUnicode(
- script_code, kCFStringEncodingComposeCombinings,
- *inbuf, *inbytesleft, &srcCharsUsed,
- (UniChar*)*outbuf, *outbytesleft, &dstCharsUsed);
-
- switch(result) {
- case kCFStringEncodingConversionSuccess:
- if (*inbytesleft == srcCharsUsed)
- break;
- else
- ; /*fall through*/
- case kCFStringEncodingInsufficientOutputBufferLength:
- debug_out("String conversion: "
- "Output buffer too small\n");
- hexdump("UTF8->UTF16LE (new) input",
- *inbuf, *inbytesleft);
- errno = E2BIG;
- return -1;
- case kCFStringEncodingInvalidInputStream:
- /*
- * HACK: smbd/mangle_hash2.c:is_legal_name() expects
- * errors here. That function will always pass 2
- * characters. smbd/open.c:check_for_pipe() cuts a
- * patchname to 10 characters blindly. Suppress the
- * debug output in those cases.
- */
- if(2 != *inbytesleft && 10 != *inbytesleft) {
- debug_out("String conversion: "
- "Invalid input sequence\n");
- hexdump("UTF8->UTF16LE (new) input",
- *inbuf, *inbytesleft);
- }
- errno = EILSEQ;
- return -1;
- case kCFStringEncodingConverterUnavailable:
- debug_out("String conversion: "
- "Unknown encoding\n");
- hexdump("UTF8->UTF16LE (new) input",
- *inbuf, *inbytesleft);
- errno = EINVAL;
- return -1;
- }
-
- /*
- * It doesn't look like CFStringEncodingBytesToUnicode() can
- * produce precomposed characters (flags=ComposeCombinings
- * doesn't do it), so we need another pass over the data here.
- * We can do this in-place, as the string can only get
- * shorter.
- *
- * (Actually in theory there should be an internal
- * decomposition and reordering before the actual composition
- * step. But we should be able to rely on that we always get
- * fully decomposed strings for input, so this can't create
- * problems in reality.)
- */
- CFUniCharPrecompose(
- (const UTF16Char *)*outbuf, dstCharsUsed, &dstDecomposedUsed,
- (UTF16Char *)*outbuf, dstCharsUsed, &dstPrecomposedUsed);
-
- native_to_le(*outbuf, dstPrecomposedUsed*2);
-
- *inbuf += srcCharsUsed;
- *inbytesleft -= srcCharsUsed;
- *outbuf += dstPrecomposedUsed*2;
- *outbytesleft -= dstPrecomposedUsed*2;
-
- return 0;
-}
-
-static size_t macosxfs_encoding_push(
- void *cd, /* Encoder handle */
- char **inbuf, size_t *inbytesleft, /* UTF-16-LE string */
- char **outbuf, size_t *outbytesleft) /* Script string */
-{
- static const int script_code = kCFStringEncodingUTF8;
- static UniChar *buffer = NULL;
- static size_t buflen = 0;
- UInt32 srcCharsUsed=0, dstCharsUsed=0, result;
-
- (void) cd; /* UNUSED */
-
- if (0 == *inbytesleft) {
- return 0;
- }
-
- buffer = set_ucbuffer_with_le(
- buffer, &buflen, *inbuf, *inbytesleft);
-
- result = CFStringEncodingUnicodeToBytes(
- script_code, kCFStringEncodingUseHFSPlusCanonical,
- buffer, *inbytesleft/2, &srcCharsUsed,
- *outbuf, *outbytesleft, &dstCharsUsed);
-
- switch(result) {
- case kCFStringEncodingConversionSuccess:
- if (*inbytesleft/2 == srcCharsUsed)
- break;
- else
- ; /*fall through*/
- case kCFStringEncodingInsufficientOutputBufferLength:
- debug_out("String conversion: "
- "Output buffer too small\n");
- hexdump("UTF16LE->UTF8 (new) input",
- *inbuf, *inbytesleft);
- errno = E2BIG;
- return -1;
- case kCFStringEncodingInvalidInputStream:
- /*
- * HACK: smbd/open.c:check_for_pipe():is_legal_name()
- * cuts a pathname to 10 characters blindly. Suppress
- * the debug output in those cases.
- */
- if(10 != *inbytesleft) {
- debug_out("String conversion: "
- "Invalid input sequence\n");
- hexdump("UTF16LE->UTF8 (new) input",
- *inbuf, *inbytesleft);
- }
- errno = EILSEQ;
- return -1;
- case kCFStringEncodingConverterUnavailable:
- debug_out("String conversion: "
- "Unknown encoding\n");
- hexdump("UTF16LE->UTF8 (new) input",
- *inbuf, *inbytesleft);
- errno = EINVAL;
- return -1;
- }
-
- *inbuf += srcCharsUsed*2;
- *inbytesleft -= srcCharsUsed*2;
- *outbuf += dstCharsUsed;
- *outbytesleft -= dstCharsUsed;
-
- return 0;
-}
-
-#endif /* USE_INTERNAL_API */
-
-/*
- * For initialization, actually install the encoding as "macosxfs".
- */
-static struct charset_functions macosxfs_encoding_functions = {
- "MACOSXFS", macosxfs_encoding_pull, macosxfs_encoding_push
-};
-
-NTSTATUS charset_macosxfs_init(void)
-{
- if (!smb_register_charset(&macosxfs_encoding_functions)) {
- return NT_STATUS_INTERNAL_ERROR;
- }
- return NT_STATUS_OK;
-}
-
-/* eof */
diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index ef770995483..d2832ba9dc3 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "system/filesys.h"
#include "smbd/smbd.h"
#ifdef HAVE_GPFS
@@ -40,6 +41,7 @@ static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags, struct gpfs_w
static int (*gpfs_get_winattrs_path_fn)(char *pathname, struct gpfs_winattr *attrs);
static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
+static int (*gpfs_lib_init_fn)(int flags);
bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
uint32 share_access)
@@ -189,6 +191,17 @@ int set_gpfs_winattrs(char *pathname,int flags,struct gpfs_winattr *attrs)
return gpfs_set_winattrs_path_fn(pathname,flags, attrs);
}
+void smbd_gpfs_lib_init()
+{
+ if (gpfs_lib_init_fn) {
+ int rc = gpfs_lib_init_fn(0);
+ DEBUG(10, ("gpfs_lib_init() finished with rc %d "
+ "and errno %d\n", rc, errno));
+ } else {
+ DEBUG(10, ("libgpfs lacks gpfs_lib_init\n"));
+ }
+}
+
static bool init_gpfs_function_lib(void *plibhandle_pointer,
const char *libname,
void *pfn_pointer, const char *fn_name)
@@ -251,6 +264,7 @@ void init_gpfs(void)
init_gpfs_function(&gpfs_set_winattrs_path_fn,"gpfs_set_winattrs_path");
init_gpfs_function(&gpfs_get_winattrs_fn,"gpfs_get_winattrs");
init_gpfs_function(&gpfs_ftruncate_fn, "gpfs_ftruncate");
+ init_gpfs_function(&gpfs_lib_init_fn,"gpfs_lib_init");
gpfs_getrealfilename = lp_parm_bool(-1, "gpfs", "getrealfilename",
True);
@@ -311,6 +325,11 @@ int get_gpfs_winattrs(char *pathname,struct gpfs_winattr *attrs)
return -1;
}
+void smbd_gpfs_lib_init()
+{
+ return;
+}
+
void init_gpfs(void)
{
return;
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 14d464451fa..dbfa36e6c2a 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -26,6 +26,7 @@
#include "include/dbwrap.h"
#include "system/filesys.h"
#include "passdb/lookup_sid.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_ACLS
@@ -51,6 +52,57 @@ typedef struct _SMB_ACL4_INT_T
SMB_ACE4_INT_T *last;
} SMB_ACL4_INT_T;
+/************************************************
+ Split the ACE flag mapping between nfs4 and Windows
+ into two separate functions rather than trying to do
+ it inline. Allows us to carefully control what flags
+ are mapped to what in one place.
+************************************************/
+
+static uint32_t map_nfs4_ace_flags_to_windows_ace_flags(uint32_t nfs4_ace_flags)
+{
+ uint32_t win_ace_flags = 0;
+
+ /* The nfs4 flags <= 0xf map perfectly. */
+ win_ace_flags = nfs4_ace_flags & (SEC_ACE_FLAG_OBJECT_INHERIT|
+ SEC_ACE_FLAG_CONTAINER_INHERIT|
+ SEC_ACE_FLAG_NO_PROPAGATE_INHERIT|
+ SEC_ACE_FLAG_INHERIT_ONLY);
+
+ /* flags greater than 0xf have diverged :-(. */
+ /* See the nfs4 ace flag definitions here:
+ http://www.ietf.org/rfc/rfc3530.txt.
+ And the Windows ace flag definitions here:
+ librpc/idl/security.idl. */
+ if (nfs4_ace_flags & SMB_ACE4_INHERITED_ACE) {
+ win_ace_flags |= SEC_ACE_FLAG_INHERITED_ACE;
+ }
+
+ return win_ace_flags;
+}
+
+static uint32_t map_windows_ace_flags_to_nfs4_ace_flags(uint32_t win_ace_flags)
+{
+ uint32_t nfs4_ace_flags = 0;
+
+ /* The windows flags <= 0xf map perfectly. */
+ nfs4_ace_flags = win_ace_flags & (SMB_ACE4_FILE_INHERIT_ACE|
+ SMB_ACE4_DIRECTORY_INHERIT_ACE|
+ SMB_ACE4_NO_PROPAGATE_INHERIT_ACE|
+ SMB_ACE4_INHERIT_ONLY_ACE);
+
+ /* flags greater than 0xf have diverged :-(. */
+ /* See the nfs4 ace flag definitions here:
+ http://www.ietf.org/rfc/rfc3530.txt.
+ And the Windows ace flag definitions here:
+ librpc/idl/security.idl. */
+ if (win_ace_flags & SEC_ACE_FLAG_INHERITED_ACE) {
+ nfs4_ace_flags |= SMB_ACE4_INHERITED_ACE;
+ }
+
+ return nfs4_ace_flags;
+}
+
static SMB_ACL4_INT_T *get_validated_aclint(SMB4ACL_T *theacl)
{
SMB_ACL4_INT_T *aclint = (SMB_ACL4_INT_T *)theacl;
@@ -233,7 +285,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *theacl, /* in */
uint32_t mask;
struct dom_sid sid;
SMB_ACE4PROP_T *ace = &aceint->prop;
- uint32_t mapped_ace_flags;
+ uint32_t win_ace_flags;
DEBUG(10, ("magic: 0x%x, type: %d, iflags: %x, flags: %x, mask: %x, "
"who: %d\n", aceint->magic, ace->aceType, ace->flags,
@@ -270,25 +322,25 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *theacl, /* in */
ace->aceMask |= SMB_ACE4_DELETE_CHILD;
}
- mapped_ace_flags = ace->aceFlags & 0xf;
- if (!is_directory && (mapped_ace_flags & (SMB_ACE4_FILE_INHERIT_ACE|SMB_ACE4_DIRECTORY_INHERIT_ACE))) {
+ win_ace_flags = map_nfs4_ace_flags_to_windows_ace_flags(ace->aceFlags);
+ if (!is_directory && (win_ace_flags & (SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT))) {
/*
* GPFS sets inherits dir_inhert and file_inherit flags
* to files, too, which confuses windows, and seems to
* be wrong anyways. ==> Map these bits away for files.
*/
DEBUG(10, ("removing inherit flags from nfs4 ace\n"));
- mapped_ace_flags &= ~(SMB_ACE4_FILE_INHERIT_ACE|SMB_ACE4_DIRECTORY_INHERIT_ACE);
+ win_ace_flags &= ~(SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT);
}
- DEBUG(10, ("mapped ace flags: 0x%x => 0x%x\n",
- ace->aceFlags, mapped_ace_flags));
+ DEBUG(10, ("Windows mapped ace flags: 0x%x => 0x%x\n",
+ ace->aceFlags, win_ace_flags));
/* Windows clients expect SYNC on acls to
correctly allow rename. See bug #7909. */
mask = ace->aceMask | SMB_ACE4_SYNCHRONIZE;
init_sec_ace(&nt_ace_list[good_aces++], &sid,
ace->aceType, mask,
- mapped_ace_flags);
+ win_ace_flags);
}
*ppnt_ace_list = nt_ace_list;
@@ -397,13 +449,15 @@ static int smbacl4_get_vfs_params(
{
static const struct enum_list enum_smbacl4_modes[] = {
{ e_simple, "simple" },
- { e_special, "special" }
+ { e_special, "special" },
+ { -1 , NULL }
};
static const struct enum_list enum_smbacl4_acedups[] = {
{ e_dontcare, "dontcare" },
{ e_reject, "reject" },
{ e_ignore, "ignore" },
{ e_merge, "merge" },
+ { -1 , NULL }
};
memset(params, 0, sizeof(smbacl4_vfs_params));
@@ -520,7 +574,7 @@ static bool nfs4_map_sid(smbacl4_vfs_params *params, const struct dom_sid *src,
if (mapping_db->fetch(mapping_db, NULL,
string_term_tdb_data(sid_string_tos(src)),
- &data) == -1) {
+ &data) != 0) {
DEBUG(10, ("could not find mapping for SID %s\n",
sid_string_dbg(src)));
return False;
@@ -560,7 +614,7 @@ static bool smbacl4_fill_ace4(
memset(ace_v4, 0, sizeof(SMB_ACE4PROP_T));
ace_v4->aceType = ace_nt->type; /* only ACCESS|DENY supported right now */
- ace_v4->aceFlags = ace_nt->flags & SEC_ACE_FLAG_VALID_INHERIT;
+ ace_v4->aceFlags = map_windows_ace_flags_to_nfs4_ace_flags(ace_nt->flags);
ace_v4->aceMask = ace_nt->access_mask &
(SEC_STD_ALL | SEC_FILE_ALL);
diff --git a/source3/modules/nfs4_acls.h b/source3/modules/nfs4_acls.h
index f4576b0c137..fcab6359154 100644
--- a/source3/modules/nfs4_acls.h
+++ b/source3/modules/nfs4_acls.h
@@ -76,9 +76,10 @@ typedef struct _SMB_ACE4PROP_T {
#define SMB_ACE4_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010
#define SMB_ACE4_FAILED_ACCESS_ACE_FLAG 0x00000020
#define SMB_ACE4_IDENTIFIER_GROUP 0x00000040
+#define SMB_ACE4_INHERITED_ACE 0x00000080
#define SMB_ACE4_ALL_FLAGS ( SMB_ACE4_FILE_INHERIT_ACE | SMB_ACE4_DIRECTORY_INHERIT_ACE \
| SMB_ACE4_NO_PROPAGATE_INHERIT_ACE | SMB_ACE4_INHERIT_ONLY_ACE | SMB_ACE4_SUCCESSFUL_ACCESS_ACE_FLAG \
-| SMB_ACE4_FAILED_ACCESS_ACE_FLAG | SMB_ACE4_IDENTIFIER_GROUP )
+| SMB_ACE4_FAILED_ACCESS_ACE_FLAG | SMB_ACE4_IDENTIFIER_GROUP | SMB_ACE4_INHERITED_ACE)
uint32 aceMask; /* Access rights */
/*The bitmask constants used for the access mask field are as follows: */
diff --git a/source3/modules/onefs_acl.c b/source3/modules/onefs_acl.c
index e986b2a9789..f78d1f0e2e6 100644
--- a/source3/modules/onefs_acl.c
+++ b/source3/modules/onefs_acl.c
@@ -554,7 +554,7 @@ static bool add_sfs_aces(files_struct *fsp, struct ifs_security_descriptor *sd)
/* Use existing samba logic to derive the mode bits. */
file_mode = unix_mode(fsp->conn, 0, fsp->fsp_name, NULL);
- dir_mode = unix_mode(fsp->conn, aDIR, fsp->fsp_name, NULL);
+ dir_mode = unix_mode(fsp->conn, FILE_ATTRIBUTE_DIRECTORY, fsp->fsp_name, NULL);
/* Initialize ACEs. */
new_aces[0] = onefs_init_ace(fsp->conn, file_mode, false, USR);
diff --git a/source3/modules/onefs_cbrl.c b/source3/modules/onefs_cbrl.c
index 5c69bec566c..2f20d04ddb6 100644
--- a/source3/modules/onefs_cbrl.c
+++ b/source3/modules/onefs_cbrl.c
@@ -251,7 +251,7 @@ static void onefs_init_cbrl(void)
DEBUG(10, ("cbrl_event_fd = %d\n", cbrl_event_fd));
/* Register the CBRL event_fd with samba's event system */
- cbrl_fde = event_add_fd(smbd_event_context(),
+ cbrl_fde = event_add_fd(server_event_context(),
NULL,
cbrl_event_fd,
EVENT_FD_READ,
diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c
index 80f799ca6f6..101dc5bc6e2 100644
--- a/source3/modules/onefs_open.c
+++ b/source3/modules/onefs_open.c
@@ -498,9 +498,9 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
unx_mode = (mode_t)(new_dos_attributes & ~FILE_FLAG_POSIX_SEMANTICS);
new_dos_attributes = 0;
} else {
- /* We add aARCH to this as this mode is only used if the file is
+ /* We add FILE_ATTRIBUTE_ARCHIVE to this as this mode is only used if the file is
* created new. */
- unx_mode = unix_mode(conn, new_dos_attributes | aARCH,
+ unx_mode = unix_mode(conn, new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE,
smb_fname, parent_dir);
}
@@ -587,7 +587,7 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
/* Setup dos_attributes to be set by ifs_createfile */
if (lp_store_dos_attributes(SNUM(conn))) {
- createfile_attributes = (new_dos_attributes | aARCH) &
+ createfile_attributes = (new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE) &
~(FILE_ATTRIBUTE_NONINDEXED | FILE_ATTRIBUTE_COMPRESSED);
}
@@ -1310,7 +1310,8 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
new_file_created = True;
}
- set_share_mode(lck, fsp, get_current_uid(conn), 0,
+ set_share_mode(lck, fsp, get_current_uid(conn),
+ req ? req->mid : 0,
fsp->oplock_type);
/* Handle strange delete on close create semantics. */
@@ -1482,7 +1483,7 @@ static NTSTATUS onefs_open_directory(connection_struct *conn,
mode = (mode_t)(file_attributes & ~FILE_FLAG_POSIX_SEMANTICS);
file_attributes = 0;
} else {
- mode = unix_mode(conn, aDIR, smb_dname, parent_dir);
+ mode = unix_mode(conn, FILE_ATTRIBUTE_DIRECTORY, smb_dname, parent_dir);
}
/*
@@ -1666,7 +1667,8 @@ static NTSTATUS onefs_open_directory(connection_struct *conn,
return NT_STATUS_DELETE_PENDING;
}
- set_share_mode(lck, fsp, get_current_uid(conn), 0, NO_OPLOCK);
+ set_share_mode(lck, fsp, get_current_uid(conn),
+ req ? req->mid : 0, NO_OPLOCK);
/*
* For directories the delete on close bit at open time seems
diff --git a/source3/modules/onefs_streams.c b/source3/modules/onefs_streams.c
index 85ab25683f3..78230bcad67 100644
--- a/source3/modules/onefs_streams.c
+++ b/source3/modules/onefs_streams.c
@@ -56,7 +56,7 @@ NTSTATUS onefs_stream_prep_smb_fname(TALLOC_CTX *ctx,
/* Strip off the :$DATA if one exists. */
str_tmp = strrchr_m(stream_name, ':');
if (str_tmp) {
- if (StrCaseCmp(str_tmp, ":$DATA") != 0) {
+ if (strcasecmp_m(str_tmp, ":$DATA") != 0) {
return NT_STATUS_INVALID_PARAMETER;
}
str_tmp[0] = '\0';
@@ -552,7 +552,7 @@ static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
{
struct stream_struct *tmp;
- tmp = TALLOC_REALLOC_ARRAY(mem_ctx, *streams, struct stream_struct,
+ tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
(*num_streams)+1);
if (tmp == NULL) {
return false;
diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c
index 6c57acb13dd..bee7966dfc9 100644
--- a/source3/modules/vfs_acl_common.c
+++ b/source3/modules/vfs_acl_common.c
@@ -144,7 +144,7 @@ static NTSTATUS create_acl_blob(const struct security_descriptor *psd,
xacl.version = 3;
xacl.info.sd_hs3 = &sd_hs3;
- xacl.info.sd_hs3->sd = CONST_DISCARD(struct security_descriptor *, psd);
+ xacl.info.sd_hs3->sd = discard_const_p(struct security_descriptor, psd);
xacl.info.sd_hs3->hash_type = hash_type;
memcpy(&xacl.info.sd_hs3->hash[0], hash, XATTR_SD_HASH_SIZE);
@@ -179,7 +179,7 @@ static void add_directory_inheritable_components(vfs_handle_struct *handle,
mode_t dir_mode;
mode_t file_mode;
mode_t mode;
- struct security_ace *new_ace_list = TALLOC_ZERO_ARRAY(talloc_tos(),
+ struct security_ace *new_ace_list = talloc_zero_array(talloc_tos(),
struct security_ace,
num_aces + 3);
@@ -190,7 +190,7 @@ static void add_directory_inheritable_components(vfs_handle_struct *handle,
/* Fake a quick smb_filename. */
ZERO_STRUCT(smb_fname);
smb_fname.st = *psbuf;
- smb_fname.base_name = CONST_DISCARD(char *, name);
+ smb_fname.base_name = discard_const_p(char, name);
dir_mode = unix_mode(conn,
FILE_ATTRIBUTE_DIRECTORY, &smb_fname, NULL);
@@ -448,10 +448,14 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
struct security_descriptor *psd = NULL;
struct dom_sid *owner_sid = NULL;
struct dom_sid *group_sid = NULL;
+ uint32_t security_info_sent = (SECINFO_OWNER | SECINFO_GROUP | SECINFO_DACL);
bool inherit_owner = lp_inherit_owner(SNUM(handle->conn));
+ bool inheritable_components = sd_has_inheritable_components(parent_desc,
+ is_directory);
size_t size;
- if (!sd_has_inheritable_components(parent_desc, is_directory)) {
+ if (!inheritable_components && !inherit_owner) {
+ /* Nothing to inherit and not setting owner. */
return NT_STATUS_OK;
}
@@ -487,6 +491,17 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
return status;
}
+ /* If inheritable_components == false,
+ se_create_child_secdesc()
+ creates a security desriptor with a NULL dacl
+ entry, but with SEC_DESC_DACL_PRESENT. We need
+ to remove that flag. */
+
+ if (!inheritable_components) {
+ security_info_sent &= ~SECINFO_DACL;
+ psd->type &= ~SEC_DESC_DACL_PRESENT;
+ }
+
if (DEBUGLEVEL >= 10) {
DEBUG(10,("inherit_new_acl: child acl for %s is:\n",
fsp_str_dbg(fsp) ));
@@ -498,9 +513,7 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
become_root();
}
status = SMB_VFS_FSET_NT_ACL(fsp,
- (SECINFO_OWNER |
- SECINFO_GROUP |
- SECINFO_DACL),
+ security_info_sent,
psd);
if (inherit_owner) {
unbecome_root();
@@ -729,7 +742,7 @@ static NTSTATUS fset_nt_acl_common(vfs_handle_struct *handle, files_struct *fsp,
DEBUG(10,("fset_nt_acl_xattr: incoming sd for file %s\n",
fsp_str_dbg(fsp)));
NDR_PRINT_DEBUG(security_descriptor,
- CONST_DISCARD(struct security_descriptor *,orig_psd));
+ discard_const_p(struct security_descriptor, orig_psd));
}
status = get_nt_acl_internal(handle, fsp,
@@ -784,7 +797,7 @@ static NTSTATUS fset_nt_acl_common(vfs_handle_struct *handle, files_struct *fsp,
DEBUG(10,("fset_nt_acl_xattr: storing xattr sd for file %s\n",
fsp_str_dbg(fsp)));
NDR_PRINT_DEBUG(security_descriptor,
- CONST_DISCARD(struct security_descriptor *,psd));
+ discard_const_p(struct security_descriptor, psd));
}
create_acl_blob(psd, &blob, XATTR_SD_HASH_TYPE_SHA256, hash);
store_acl_blob_fsp(handle, fsp, &blob);
@@ -836,7 +849,7 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
}
ZERO_STRUCT(local_fname);
- local_fname.base_name = CONST_DISCARD(char *,final_component);
+ local_fname.base_name = discard_const_p(char, final_component);
/* Must use lstat here. */
ret = SMB_VFS_LSTAT(conn, &local_fname);
diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c
index f2e04152936..0b03896dd90 100644
--- a/source3/modules/vfs_acl_tdb.c
+++ b/source3/modules/vfs_acl_tdb.c
@@ -28,6 +28,7 @@
#include "../lib/crypto/crypto.h"
#include "dbwrap.h"
#include "auth.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_VFS
@@ -176,7 +177,7 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
if (db->fetch(db,
ctx,
make_tdb_data(id_buf, sizeof(id_buf)),
- &data) == -1) {
+ &data) != 0) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c
index 2a83430fa94..70e979b71b0 100644
--- a/source3/modules/vfs_acl_xattr.c
+++ b/source3/modules/vfs_acl_xattr.c
@@ -55,7 +55,7 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
again:
- tmp = TALLOC_REALLOC_ARRAY(ctx, val, uint8_t, size);
+ tmp = talloc_realloc(ctx, val, uint8_t, size);
if (tmp == NULL) {
TALLOC_FREE(val);
return NT_STATUS_NO_MEMORY;
diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c
index 06ce6f5f8d8..2ef6adf953d 100644
--- a/source3/modules/vfs_afsacl.c
+++ b/source3/modules/vfs_afsacl.c
@@ -30,7 +30,7 @@
#include <afs/venus.h>
#include <afs/prs_fs.h>
-#define MAXSIZE 2048
+#define MAXSIZE 2049
extern const struct dom_sid global_sid_World;
extern const struct dom_sid global_sid_Builtin_Administrators;
@@ -89,7 +89,7 @@ static void free_afs_acl(struct afs_acl *acl)
static struct afs_ace *clone_afs_ace(TALLOC_CTX *mem_ctx, struct afs_ace *ace)
{
- struct afs_ace *result = TALLOC_P(mem_ctx, struct afs_ace);
+ struct afs_ace *result = talloc(mem_ctx, struct afs_ace);
if (result == NULL)
return NULL;
@@ -167,7 +167,7 @@ static struct afs_ace *new_afs_ace(TALLOC_CTX *mem_ctx,
}
}
- result = TALLOC_P(mem_ctx, struct afs_ace);
+ result = talloc(mem_ctx, struct afs_ace);
if (result == NULL) {
DEBUG(0, ("Could not talloc AFS ace\n"));
@@ -234,10 +234,10 @@ static bool parse_afs_acl(struct afs_acl *acl, const char *acl_str)
int nplus, nminus;
int aces;
- char str[MAXSIZE+1];
+ char str[MAXSIZE];
char *p = str;
- strncpy(str, acl_str, MAXSIZE);
+ strlcpy(str, acl_str, MAXSIZE);
if (sscanf(p, "%d", &nplus) != 1)
return False;
@@ -313,16 +313,16 @@ static bool unparse_afs_acl(struct afs_acl *acl, char *acl_str)
}
fstr_sprintf(line, "%d\n", positives);
- safe_strcat(acl_str, line, MAXSIZE);
+ strlcat(acl_str, line, MAXSIZE);
fstr_sprintf(line, "%d\n", negatives);
- safe_strcat(acl_str, line, MAXSIZE);
+ strlcat(acl_str, line, MAXSIZE);
ace = acl->acelist;
while (ace != NULL) {
fstr_sprintf(line, "%s\t%d\n", ace->name, ace->rights);
- safe_strcat(acl_str, line, MAXSIZE);
+ strlcat(acl_str, line, MAXSIZE);
ace = ace->next;
}
return True;
@@ -605,7 +605,7 @@ static size_t afs_to_nt_acl_common(struct afs_acl *afs_acl,
gid_to_sid(&group_sid, psbuf->st_ex_gid);
if (afs_acl->num_aces) {
- nt_ace_list = TALLOC_ARRAY(mem_ctx, struct security_ace, afs_acl->num_aces);
+ nt_ace_list = talloc_array(mem_ctx, struct security_ace, afs_acl->num_aces);
if (nt_ace_list == NULL)
return 0;
@@ -897,7 +897,7 @@ static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
{
struct afs_acl old_afs_acl, new_afs_acl;
struct afs_acl dir_acl, file_acl;
- char acl_string[2049];
+ char acl_string[MAXSIZE];
struct afs_iob iob;
int ret = -1;
char *name = NULL;
diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c
index 41b5a89dd29..961efd85de2 100644
--- a/source3/modules/vfs_aio_fork.c
+++ b/source3/modules/vfs_aio_fork.c
@@ -260,7 +260,7 @@ static void aio_child_cleanup(struct event_context *event_ctx,
/*
* Re-schedule the next cleanup round
*/
- list->cleanup_event = event_add_timed(smbd_event_context(), list,
+ list->cleanup_event = event_add_timed(server_event_context(), list,
timeval_add(&now, 30, 0),
aio_child_cleanup, list);
@@ -277,7 +277,7 @@ static struct aio_child_list *init_aio_children(struct vfs_handle_struct *handle
}
if (data == NULL) {
- data = TALLOC_ZERO_P(NULL, struct aio_child_list);
+ data = talloc_zero(NULL, struct aio_child_list);
if (data == NULL) {
return NULL;
}
@@ -290,7 +290,7 @@ static struct aio_child_list *init_aio_children(struct vfs_handle_struct *handle
*/
if (data->cleanup_event == NULL) {
- data->cleanup_event = event_add_timed(smbd_event_context(), data,
+ data->cleanup_event = event_add_timed(server_event_context(), data,
timeval_current_ofs(30, 0),
aio_child_cleanup, data);
if (data->cleanup_event == NULL) {
@@ -481,7 +481,7 @@ static NTSTATUS create_aio_child(struct smbd_server_connection *sconn,
fdpair[0] = fdpair[1] = -1;
- result = TALLOC_ZERO_P(children, struct aio_child);
+ result = talloc_zero(children, struct aio_child);
NT_STATUS_HAVE_NO_MEMORY(result);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fdpair) == -1) {
@@ -519,7 +519,7 @@ static NTSTATUS create_aio_child(struct smbd_server_connection *sconn,
result->sockfd = fdpair[0];
close(fdpair[1]);
- result->sock_event = event_add_fd(smbd_event_context(), result,
+ result->sock_event = event_add_fd(server_event_context(), result,
result->sockfd, EVENT_FD_READ,
handle_aio_completion,
result);
diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c
index 349600fc43f..8213bafa1cb 100644
--- a/source3/modules/vfs_audit.c
+++ b/source3/modules/vfs_audit.c
@@ -40,7 +40,8 @@ static int audit_syslog_facility(vfs_handle_struct *handle)
{ LOG_LOCAL4, "LOCAL4" },
{ LOG_LOCAL5, "LOCAL5" },
{ LOG_LOCAL6, "LOCAL6" },
- { LOG_LOCAL7, "LOCAL7" }
+ { LOG_LOCAL7, "LOCAL7" },
+ { -1, NULL}
};
int facility;
@@ -61,7 +62,8 @@ static int audit_syslog_priority(vfs_handle_struct *handle)
{ LOG_WARNING, "WARNING" },
{ LOG_NOTICE, "NOTICE" },
{ LOG_INFO, "INFO" },
- { LOG_DEBUG, "DEBUG" }
+ { LOG_DEBUG, "DEBUG" },
+ { -1, NULL}
};
int priority;
diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c
index 7aab6c3973b..15bebf6fea0 100644
--- a/source3/modules/vfs_cap.c
+++ b/source3/modules/vfs_cap.c
@@ -75,7 +75,7 @@ static SMB_STRUCT_DIRENT *cap_readdir(vfs_handle_struct *handle,
}
DEBUG(3,("cap: cap_readdir: %s\n", newname));
newnamelen = strlen(newname)+1;
- newdirent = (SMB_STRUCT_DIRENT *)TALLOC_ARRAY(talloc_tos(),
+ newdirent = (SMB_STRUCT_DIRENT *)talloc_array(talloc_tos(),
char,
sizeof(SMB_STRUCT_DIRENT)+
newnamelen);
@@ -663,7 +663,7 @@ static char *capencode(TALLOC_CTX *ctx, const char *from)
}
len++;
- to = TALLOC_ARRAY(ctx, char, len);
+ to = talloc_array(ctx, char, len);
if (!to) {
return NULL;
}
@@ -704,7 +704,7 @@ static char *capdecode(TALLOC_CTX *ctx, const char *from)
}
len++;
- to = TALLOC_ARRAY(ctx, char, len);
+ to = talloc_array(ctx, char, len);
if (!to) {
return NULL;
}
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index cf6e24fca04..2dc7ec75b82 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -84,7 +84,10 @@ static int vfswrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_T
#endif
}
-static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle, struct files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, bool labels)
+static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ struct shadow_copy_data *shadow_copy_data,
+ bool labels)
{
errno = ENOSYS;
return -1; /* Not implemented. */
@@ -745,12 +748,12 @@ static int vfswrap_chdir(vfs_handle_struct *handle, const char *path)
return result;
}
-static char *vfswrap_getwd(vfs_handle_struct *handle, char *path)
+static char *vfswrap_getwd(vfs_handle_struct *handle)
{
char *result;
START_PROFILE(syscall_getwd);
- result = sys_getwd(path);
+ result = sys_getwd();
END_PROFILE(syscall_getwd);
return result;
}
@@ -1512,12 +1515,12 @@ static ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle, const char *p
return sys_listxattr(path, list, size);
}
-ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)
+static ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)
{
return sys_llistxattr(path, list, size);
}
-ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)
+static ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)
{
return sys_flistxattr(fsp->fh->fd, list, size);
}
diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c
index adeab0425d5..ba8441c2dff 100644
--- a/source3/modules/vfs_dirsort.c
+++ b/source3/modules/vfs_dirsort.c
@@ -24,7 +24,7 @@
static int compare_dirent (const SMB_STRUCT_DIRENT *da, const SMB_STRUCT_DIRENT *db)
{
- return StrCaseCmp(da->d_name, db->d_name);
+ return strcasecmp_m(da->d_name, db->d_name);
}
struct dirsort_privates {
diff --git a/source3/modules/vfs_expand_msdfs.c b/source3/modules/vfs_expand_msdfs.c
index f1f82d243ee..eb7c6fed6b5 100644
--- a/source3/modules/vfs_expand_msdfs.c
+++ b/source3/modules/vfs_expand_msdfs.c
@@ -178,7 +178,7 @@ static int expand_msdfs_readlink(struct vfs_handle_struct *handle,
{
TALLOC_CTX *ctx = talloc_tos();
int result;
- char *target = TALLOC_ARRAY(ctx, char, PATH_MAX+1);
+ char *target = talloc_array(ctx, char, PATH_MAX+1);
size_t len;
if (!target) {
diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c
index 34a43c712f8..192b0750ab1 100644
--- a/source3/modules/vfs_extd_audit.c
+++ b/source3/modules/vfs_extd_audit.c
@@ -43,7 +43,8 @@ static int audit_syslog_facility(vfs_handle_struct *handle)
{ LOG_LOCAL4, "LOCAL4" },
{ LOG_LOCAL5, "LOCAL5" },
{ LOG_LOCAL6, "LOCAL6" },
- { LOG_LOCAL7, "LOCAL7" }
+ { LOG_LOCAL7, "LOCAL7" },
+ { -1, NULL}
};
int facility;
@@ -64,7 +65,8 @@ static int audit_syslog_priority(vfs_handle_struct *handle)
{ LOG_WARNING, "WARNING" },
{ LOG_NOTICE, "NOTICE" },
{ LOG_INFO, "INFO" },
- { LOG_DEBUG, "DEBUG" }
+ { LOG_DEBUG, "DEBUG" },
+ { -1, NULL}
};
int priority;
diff --git a/source3/modules/vfs_fileid.c b/source3/modules/vfs_fileid.c
index 4c230a0566d..1168d50cb2e 100644
--- a/source3/modules/vfs_fileid.c
+++ b/source3/modules/vfs_fileid.c
@@ -66,7 +66,7 @@ static void fileid_load_mount_entries(struct fileid_handle_data *data)
m->mnt_fsname += 5;
}
- data->mount_entries = TALLOC_REALLOC_ARRAY(data,
+ data->mount_entries = talloc_realloc(data,
data->mount_entries,
struct fileid_mount_entry,
data->num_mount_entries+1);
@@ -144,7 +144,7 @@ static uint64_t fileid_device_mapping_fsname(struct fileid_handle_data *data,
if (!m) return dev;
if (m->devid == (uint64_t)-1) {
- m->devid = fileid_uint64_hash((uint8_t *)m->mnt_fsname,
+ m->devid = fileid_uint64_hash((const uint8_t *)m->mnt_fsname,
strlen(m->mnt_fsname));
}
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index a723a0ce2d6..e8129f41436 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -355,7 +355,8 @@ static int audit_syslog_facility(vfs_handle_struct *handle)
{ LOG_LOCAL4, "LOCAL4" },
{ LOG_LOCAL5, "LOCAL5" },
{ LOG_LOCAL6, "LOCAL6" },
- { LOG_LOCAL7, "LOCAL7" }
+ { LOG_LOCAL7, "LOCAL7" },
+ { -1, NULL}
};
int facility;
@@ -375,7 +376,8 @@ static int audit_syslog_priority(vfs_handle_struct *handle)
{ LOG_WARNING, "WARNING" },
{ LOG_NOTICE, "NOTICE" },
{ LOG_INFO, "INFO" },
- { LOG_DEBUG, "DEBUG" }
+ { LOG_DEBUG, "DEBUG" },
+ { -1, NULL}
};
int priority;
@@ -609,13 +611,13 @@ static int smb_full_audit_connect(vfs_handle_struct *handle,
return result;
}
- pd = TALLOC_ZERO_P(handle, struct vfs_full_audit_private_data);
+ pd = talloc_zero(handle, struct vfs_full_audit_private_data);
if (!pd) {
SMB_VFS_NEXT_DISCONNECT(handle);
return -1;
}
-#ifndef WITH_SYSLOG
+#ifdef WITH_SYSLOG
openlog("smbd_audit", 0, audit_syslog_facility(handle));
#endif
@@ -695,7 +697,8 @@ static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- SHADOW_COPY_DATA *shadow_copy_data, bool labels)
+ struct shadow_copy_data *shadow_copy_data,
+ bool labels)
{
int result;
@@ -1205,14 +1208,14 @@ static int smb_full_audit_chdir(vfs_handle_struct *handle,
return result;
}
-static char *smb_full_audit_getwd(vfs_handle_struct *handle,
- char *path)
+static char *smb_full_audit_getwd(vfs_handle_struct *handle)
{
char *result;
- result = SMB_VFS_NEXT_GETWD(handle, path);
+ result = SMB_VFS_NEXT_GETWD(handle);
- do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
+ do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s",
+ result == NULL? "" : result);
return result;
}
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index c38d7c2337f..0a684e0d8e5 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -32,6 +32,7 @@
#include <gpfs_gpl.h>
#include "nfs4_acls.h"
#include "vfs_gpfs.h"
+#include "system/filesys.h"
struct gpfs_config_data {
bool sharemodes;
@@ -998,7 +999,7 @@ static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path,
}
- ret = set_gpfs_winattrs(CONST_DISCARD(char *, path),
+ ret = set_gpfs_winattrs(discard_const_p(char, path),
GPFS_WINATTR_SET_ATTRS, &attrs);
if ( ret == -1){
if (errno == ENOSYS) {
@@ -1029,7 +1030,7 @@ static ssize_t gpfs_get_xattr(struct vfs_handle_struct *handle, const char *pat
return SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size);
}
- ret = get_gpfs_winattrs(CONST_DISCARD(char *, path), &attrs);
+ ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
if ( ret == -1){
if (errno == ENOSYS) {
return SMB_VFS_NEXT_GETXATTR(handle, path, name, value,
@@ -1083,11 +1084,12 @@ static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
errno = map_errno_from_nt_status(status);
return -1;
}
- ret = get_gpfs_winattrs(CONST_DISCARD(char *, fname), &attrs);
+ ret = get_gpfs_winattrs(discard_const_p(char, fname), &attrs);
TALLOC_FREE(fname);
if (ret == 0) {
smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
+ smb_fname->st.vfs_private = attrs.winAttrs;
}
return 0;
}
@@ -1130,11 +1132,12 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
errno = map_errno_from_nt_status(status);
return -1;
}
- ret = get_gpfs_winattrs(CONST_DISCARD(char *, path), &attrs);
+ ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
TALLOC_FREE(path);
if (ret == 0) {
smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
+ smb_fname->st.vfs_private = attrs.winAttrs;
}
return 0;
}
@@ -1170,7 +1173,7 @@ static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
attrs.creationTime.tv_sec = ft->create_time.tv_sec;
attrs.creationTime.tv_nsec = ft->create_time.tv_nsec;
- ret = set_gpfs_winattrs(CONST_DISCARD(char *, path),
+ ret = set_gpfs_winattrs(discard_const_p(char, path),
GPFS_WINATTR_SET_CREATION_TIME, &attrs);
if(ret == -1 && errno != ENOSYS){
DEBUG(1,("vfs_gpfs_ntimes: set GPFS ntimes failed %d\n",ret));
@@ -1199,18 +1202,23 @@ static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
struct gpfs_winattr attrs;
char *path = NULL;
NTSTATUS status;
- int ret;
status = get_full_smb_filename(talloc_tos(), fname, &path);
if (!NT_STATUS_IS_OK(status)) {
errno = map_errno_from_nt_status(status);
return -1;
}
- ret = get_gpfs_winattrs(path, &attrs);
- if (ret == -1) {
- TALLOC_FREE(path);
- return false;
+ if (VALID_STAT(*sbuf)) {
+ attrs.winAttrs = sbuf->vfs_private;
+ } else {
+ int ret;
+ ret = get_gpfs_winattrs(path, &attrs);
+
+ if (ret == -1) {
+ TALLOC_FREE(path);
+ return false;
+ }
}
if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) {
DEBUG(10, ("%s is offline\n", path));
@@ -1228,10 +1236,24 @@ static bool vfs_gpfs_aio_force(struct vfs_handle_struct *handle,
return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
}
+static ssize_t vfs_gpfs_sendfile(vfs_handle_struct *handle, int tofd,
+ files_struct *fsp, const DATA_BLOB *hdr,
+ SMB_OFF_T offset, size_t n)
+{
+ if ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0) {
+ errno = ENOSYS;
+ return -1;
+ }
+ return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n);
+}
+
int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service,
const char *user)
{
struct gpfs_config_data *config;
+
+ smbd_gpfs_lib_init();
+
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
@@ -1278,6 +1300,17 @@ static uint32_t vfs_gpfs_capabilities(struct vfs_handle_struct *handle,
return next;
}
+static int vfs_gpfs_open(struct vfs_handle_struct *handle,
+ struct smb_filename *smb_fname, files_struct *fsp,
+ int flags, mode_t mode)
+{
+ if (lp_parm_bool(fsp->conn->params->service, "gpfs", "syncio",
+ false)) {
+ flags |= O_SYNC;
+ }
+ return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
+}
+
static struct vfs_fn_pointers vfs_gpfs_fns = {
.connect_fn = vfs_gpfs_connect,
@@ -1304,6 +1337,8 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
.ntimes = vfs_gpfs_ntimes,
.is_offline = vfs_gpfs_is_offline,
.aio_force = vfs_gpfs_aio_force,
+ .sendfile = vfs_gpfs_sendfile,
+ .open_fn = vfs_gpfs_open,
.ftruncate = vfs_gpfs_ftruncate
};
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index 46cfdfea0ac..4a05841feba 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -1,26 +1,25 @@
/*
Unix SMB/CIFS implementation.
Wrap gpfs calls in vfs functions.
-
+
Copyright (C) Christian Ambach <cambach1@de.ibm.com> 2006
-
+
Major code contributions by Chetan Shringarpure <chetan.sh@in.ibm.com>
and Gomati Mohanan <gomati.mohanan@in.ibm.com>
-
+
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.
-
*/
@@ -36,3 +35,4 @@ int get_gpfs_winattrs(char * pathname,struct gpfs_winattr *attrs);
int set_gpfs_winattrs(char * pathname,int flags,struct gpfs_winattr *attrs);
int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length);
void init_gpfs(void);
+void smbd_gpfs_lib_init();
diff --git a/source3/modules/vfs_gpfs_hsm_notify.c b/source3/modules/vfs_gpfs_hsm_notify.c
new file mode 100644
index 00000000000..fa24db99833
--- /dev/null
+++ b/source3/modules/vfs_gpfs_hsm_notify.c
@@ -0,0 +1,110 @@
+/*
+ Unix SMB/CIFS implementation.
+ Make sure offline->online changes are propagated by notifies
+
+ This module must come before aio_fork in the chain, because
+ aio_fork (correcly!) does not propagate the aio calls further
+
+ Copyright (C) Volker Lendecke 2011
+
+ 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 "smbd/smbd.h"
+#include "librpc/gen_ndr/ndr_xattr.h"
+#include "include/smbprofile.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_VFS
+
+#include <gpfs_gpl.h>
+#include "nfs4_acls.h"
+#include "vfs_gpfs.h"
+
+static ssize_t vfs_gpfs_hsm_notify_pread(vfs_handle_struct *handle, files_struct *fsp,
+ void *data, size_t n, SMB_OFF_T offset)
+{
+ ssize_t ret;
+
+ ret = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
+
+ DEBUG(10, ("vfs_private = %x\n",
+ (unsigned int)fsp->fsp_name->st.vfs_private));
+
+ if ((ret != -1) &&
+ ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
+ fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
+ notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
+ FILE_NOTIFY_CHANGE_ATTRIBUTES,
+ fsp->fsp_name->base_name);
+ }
+
+ return ret;
+}
+
+static ssize_t vfs_gpfs_hsm_notify_pwrite(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ const void *data, size_t n, SMB_OFF_T offset)
+{
+ ssize_t ret;
+
+ ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
+
+ if ((ret != -1) &&
+ ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
+ fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
+ notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
+ FILE_NOTIFY_CHANGE_ATTRIBUTES,
+ fsp->fsp_name->base_name);
+ }
+
+ return ret;
+}
+
+static ssize_t vfs_gpfs_hsm_notify_aio_return(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ SMB_STRUCT_AIOCB *aiocb)
+{
+ ssize_t ret;
+
+ ret = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
+
+ DEBUG(10, ("vfs_gpfs_hsm_notify_aio_return: vfs_private = %x\n",
+ (unsigned int)fsp->fsp_name->st.vfs_private));
+
+ if ((ret != -1) &&
+ ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
+ fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
+ DEBUG(10, ("sending notify\n"));
+ notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
+ FILE_NOTIFY_CHANGE_ATTRIBUTES,
+ fsp->fsp_name->base_name);
+ }
+
+ return ret;
+}
+
+static struct vfs_fn_pointers vfs_gpfs_hsm_notify_fns = {
+ .pread = vfs_gpfs_hsm_notify_pread,
+ .pwrite = vfs_gpfs_hsm_notify_pwrite,
+ .aio_return_fn = vfs_gpfs_hsm_notify_aio_return
+};
+
+NTSTATUS vfs_gpfs_hsm_notify_init(void);
+NTSTATUS vfs_gpfs_hsm_notify_init(void)
+{
+ return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs_hsm_notify",
+ &vfs_gpfs_hsm_notify_fns);
+}
diff --git a/source3/modules/vfs_hpuxacl.c b/source3/modules/vfs_hpuxacl.c
index 2155945b95a..8a574443526 100644
--- a/source3/modules/vfs_hpuxacl.c
+++ b/source3/modules/vfs_hpuxacl.c
@@ -307,7 +307,7 @@ int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle,
}
DEBUG(10, ("resulting acl is valid.\n"));
- ret = acl(CONST_DISCARD(char *, smb_fname->base_name), ACL_SET, count,
+ ret = acl(discard_const_p(char, smb_fname->base_name), ACL_SET, count,
hpux_acl);
if (ret != 0) {
DEBUG(0, ("ERROR calling acl: %s\n", strerror(errno)));
@@ -394,7 +394,7 @@ int hpuxacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
DEBUG(10, ("resulting acl is not valid!\n"));
goto done;
}
- ret = acl(CONST_DISCARD(char *, path), ACL_SET, count, hpux_acl);
+ ret = acl(discard_const_p(char, path), ACL_SET, count, hpux_acl);
if (ret != 0) {
DEBUG(10, ("settinge file acl failed!\n"));
}
@@ -682,7 +682,7 @@ static bool hpux_acl_get_file(const char *name, HPUX_ACL_T *hpux_acl,
* instantiated or malloced each time this function is
* called). Btw: the count parameter does not seem to matter...
*/
- *count = acl(CONST_DISCARD(char *, name), ACL_CNT, 0, &dummy_ace);
+ *count = acl(discard_const_p(char, name), ACL_CNT, 0, &dummy_ace);
if (*count < 0) {
DEBUG(10, ("acl ACL_CNT failed: %s\n", strerror(errno)));
goto done;
@@ -692,7 +692,7 @@ static bool hpux_acl_get_file(const char *name, HPUX_ACL_T *hpux_acl,
DEBUG(10, ("error allocating memory for hpux acl...\n"));
goto done;
}
- *count = acl(CONST_DISCARD(char *, name), ACL_GET, *count, *hpux_acl);
+ *count = acl(discard_const_p(char, name), ACL_GET, *count, *hpux_acl);
if (*count < 0) {
DEBUG(10, ("acl ACL_GET failed: %s\n", strerror(errno)));
goto done;
diff --git a/source3/modules/vfs_notify_fam.c b/source3/modules/vfs_notify_fam.c
index a4e7fd1e2ba..1f76a05fc08 100644
--- a/source3/modules/vfs_notify_fam.c
+++ b/source3/modules/vfs_notify_fam.c
@@ -249,7 +249,7 @@ static NTSTATUS fam_watch(vfs_handle_struct *vfs_handle,
fam_connection_initialized = True;
}
- if (!(watch = TALLOC_P(ctx, struct fam_watch_context))) {
+ if (!(watch = talloc(ctx, struct fam_watch_context))) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c
index 82969e48d6a..3d7f6c1b038 100644
--- a/source3/modules/vfs_preopen.c
+++ b/source3/modules/vfs_preopen.c
@@ -166,7 +166,7 @@ static bool preopen_helper_open_one(int sock_fd, char **pnamebuf,
nread += thistime;
if (nread == talloc_get_size(namebuf)) {
- namebuf = TALLOC_REALLOC_ARRAY(
+ namebuf = talloc_realloc(
NULL, namebuf, char,
talloc_get_size(namebuf) * 2);
if (namebuf == NULL) {
@@ -193,7 +193,7 @@ static bool preopen_helper(int fd, size_t to_read)
char *namebuf;
void *readbuf;
- namebuf = TALLOC_ARRAY(NULL, char, 1024);
+ namebuf = talloc_array(NULL, char, 1024);
if (namebuf == NULL) {
return false;
}
@@ -237,7 +237,7 @@ static NTSTATUS preopen_init_helper(struct preopen_helper *h)
}
close(fdpair[1]);
h->fd = fdpair[0];
- h->fde = event_add_fd(smbd_event_context(), h->state, h->fd,
+ h->fde = event_add_fd(server_event_context(), h->state, h->fd,
EVENT_FD_READ, preopen_helper_readable, h);
if (h->fde == NULL) {
close(h->fd);
@@ -261,7 +261,7 @@ static NTSTATUS preopen_init_helpers(TALLOC_CTX *mem_ctx, size_t to_read,
}
result->num_helpers = num_helpers;
- result->helpers = TALLOC_ARRAY(result, struct preopen_helper,
+ result->helpers = talloc_array(result, struct preopen_helper,
num_helpers);
if (result->helpers == NULL) {
TALLOC_FREE(result);
@@ -322,7 +322,7 @@ static struct preopen_state *preopen_state_get(vfs_handle_struct *handle)
return NULL;
}
- set_namearray(&state->preopen_names, (char *)namelist);
+ set_namearray(&state->preopen_names, namelist);
if (state->preopen_names == NULL) {
TALLOC_FREE(state);
diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c
index 22f61b4b33c..5c4f8706cbf 100644
--- a/source3/modules/vfs_recycle.c
+++ b/source3/modules/vfs_recycle.c
@@ -35,33 +35,9 @@ static int vfs_recycle_debug_level = DBGC_VFS;
#undef DBGC_CLASS
#define DBGC_CLASS vfs_recycle_debug_level
-static int recycle_connect(vfs_handle_struct *handle, const char *service, const char *user);
-static void recycle_disconnect(vfs_handle_struct *handle);
static int recycle_unlink(vfs_handle_struct *handle,
const struct smb_filename *smb_fname);
-static int recycle_connect(vfs_handle_struct *handle, const char *service, const char *user)
-{
- int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
-
- if (ret < 0) {
- return ret;
- }
-
- DEBUG(10,("recycle_connect() connect to service[%s] as user[%s].\n",
- service,user));
-
- return 0;
-}
-
-static void recycle_disconnect(vfs_handle_struct *handle)
-{
- DEBUG(10,("recycle_disconnect() connect to service[%s].\n",
- lp_servicename(SNUM(handle->conn))));
-
- SMB_VFS_NEXT_DISCONNECT(handle);
-}
-
static const char *recycle_repository(vfs_handle_struct *handle)
{
const char *tmp_str = NULL;
@@ -304,13 +280,13 @@ static bool recycle_create_dir(vfs_handle_struct *handle, const char *dname)
*new_dir = '\0';
if (dname[0] == '/') {
/* Absolute path. */
- safe_strcat(new_dir,"/",len);
+ strlcat(new_dir,"/",len+1);
}
/* Create directory tree if neccessary */
for(token = strtok_r(tok_str, "/", &saveptr); token;
token = strtok_r(NULL, "/", &saveptr)) {
- safe_strcat(new_dir, token, len);
+ strlcat(new_dir, token, len+1);
if (recycle_directory_exist(handle, new_dir))
DEBUG(10, ("recycle: dir %s already exists\n", new_dir));
else {
@@ -321,7 +297,7 @@ static bool recycle_create_dir(vfs_handle_struct *handle, const char *dname)
goto done;
}
}
- safe_strcat(new_dir, "/", len);
+ strlcat(new_dir, "/", len+1);
mode = recycle_subdir_mode(handle);
}
@@ -663,8 +639,6 @@ done:
}
static struct vfs_fn_pointers vfs_recycle_fns = {
- .connect_fn = recycle_connect,
- .disconnect = recycle_disconnect,
.unlink = recycle_unlink
};
diff --git a/source3/modules/vfs_scannedonly.c b/source3/modules/vfs_scannedonly.c
index d0eba212d24..6d748c4c238 100644
--- a/source3/modules/vfs_scannedonly.c
+++ b/source3/modules/vfs_scannedonly.c
@@ -75,12 +75,12 @@ struct Tscannedonly {
bool rm_hidden_files_on_rmdir;
bool hide_nonscanned_files;
bool allow_nonscanned_files;
- char *socketname;
- char *scanhost;
- char *scanning_message;
- char *p_scanned; /* prefix for scanned files */
- char *p_virus; /* prefix for virus containing files */
- char *p_failed; /* prefix for failed to scan files */
+ const char *socketname;
+ const char *scanhost;
+ const char *scanning_message;
+ const char *p_scanned; /* prefix for scanned files */
+ const char *p_virus; /* prefix for virus containing files */
+ const char *p_failed; /* prefix for failed to scan files */
char gsendbuffer[SENDBUFFERSIZE + 1];
};
@@ -146,14 +146,15 @@ static char *cachefile_name_f_fullpath(TALLOC_CTX *ctx,
const char *p_scanned)
{
const char *base;
- char *tmp, *cachefile, *shortname;
+ char *tmp, *cachefile;
+ const char *shortname;
tmp = strrchr(fullpath, '/');
if (tmp) {
base = talloc_strndup(ctx, fullpath, (tmp - fullpath) + 1);
shortname = tmp + 1;
} else {
base = "";
- shortname = (char *)fullpath;
+ shortname = (const char *)fullpath;
}
cachefile = cachefile_name(ctx, shortname, base, p_scanned);
DEBUG(SCANNEDONLY_DEBUG,
@@ -164,7 +165,7 @@ static char *cachefile_name_f_fullpath(TALLOC_CTX *ctx,
static char *construct_full_path(TALLOC_CTX *ctx, vfs_handle_struct * handle,
const char *somepath, bool ending_slash)
{
- char *tmp;
+ const char *tmp;
if (!somepath) {
return NULL;
@@ -175,7 +176,7 @@ static char *construct_full_path(TALLOC_CTX *ctx, vfs_handle_struct * handle,
}
return talloc_strdup(ctx,somepath);
}
- tmp=(char *)somepath;
+ tmp = somepath;
if (tmp[0]=='.'&&tmp[1]=='/') {
tmp+=2;
}
@@ -308,14 +309,14 @@ static void flush_sendbuffer(vfs_handle_struct * handle)
static void notify_scanner(vfs_handle_struct * handle, const char *scanfile)
{
- char *tmp;
+ const char *tmp;
int tmplen, gsendlen;
struct Tscannedonly *so = (struct Tscannedonly *)handle->data;
TALLOC_CTX *ctx=talloc_tos();
if (scanfile[0] != '/') {
tmp = construct_full_path(ctx,handle, scanfile, false);
} else {
- tmp = (char *)scanfile;
+ tmp = (const char *)scanfile;
}
tmplen = strlen(tmp);
gsendlen = strlen(so->gsendbuffer);
@@ -515,7 +516,7 @@ static SMB_STRUCT_DIR *scannedonly_opendir(vfs_handle_struct * handle,
return NULL;
}
- sDIR = TALLOC_P(NULL, struct scannedonly_DIR);
+ sDIR = talloc(NULL, struct scannedonly_DIR);
if (fname[0] != '/') {
sDIR->base = construct_full_path(sDIR,handle, fname, true);
} else {
@@ -543,7 +544,7 @@ static SMB_STRUCT_DIR *scannedonly_fdopendir(vfs_handle_struct * handle,
fname = (const char *)fsp->fsp_name->base_name;
- sDIR = TALLOC_P(NULL, struct scannedonly_DIR);
+ sDIR = talloc(NULL, struct scannedonly_DIR);
if (fname[0] != '/') {
sDIR->base = construct_full_path(sDIR,handle, fname, true);
} else {
@@ -631,7 +632,7 @@ static SMB_STRUCT_DIRENT *scannedonly_readdir(vfs_handle_struct *handle,
ctx,"%s %s",result->d_name,
STRUCTSCANO(handle->data)->scanning_message);
namelen = strlen(notify_name);
- newdirent = (SMB_STRUCT_DIRENT *)TALLOC_ARRAY(
+ newdirent = (SMB_STRUCT_DIRENT *)talloc_array(
ctx, char, sizeof(SMB_STRUCT_DIRENT) + namelen + 1);
if (!newdirent) {
return NULL;
@@ -948,15 +949,14 @@ static int scannedonly_connect(struct vfs_handle_struct *handle,
so->domain_socket =
lp_parm_bool(SNUM(handle->conn), "scannedonly",
"domain_socket", True);
- so->socketname =
- (char *)lp_parm_const_string(SNUM(handle->conn),
+ so->socketname = lp_parm_const_string(SNUM(handle->conn),
"scannedonly", "socketname",
"/var/lib/scannedonly/scan");
+
so->portnum =
lp_parm_int(SNUM(handle->conn), "scannedonly", "portnum",
2020);
- so->scanhost =
- (char *)lp_parm_const_string(SNUM(handle->conn),
+ so->scanhost = lp_parm_const_string(SNUM(handle->conn),
"scannedonly", "scanhost",
"localhost");
@@ -972,8 +972,7 @@ static int scannedonly_connect(struct vfs_handle_struct *handle,
so->allow_nonscanned_files =
lp_parm_bool(SNUM(handle->conn), "scannedonly",
"allow_nonscanned_files", False);
- so->scanning_message =
- (char *)lp_parm_const_string(SNUM(handle->conn),
+ so->scanning_message = lp_parm_const_string(SNUM(handle->conn),
"scannedonly",
"scanning_message",
"is being scanned for viruses");
@@ -995,17 +994,17 @@ static int scannedonly_connect(struct vfs_handle_struct *handle,
"recheck_tries_readdir", 20);
so->p_scanned =
- (char *)lp_parm_const_string(SNUM(handle->conn),
+ lp_parm_const_string(SNUM(handle->conn),
"scannedonly",
"pref_scanned",
".scanned:");
so->p_virus =
- (char *)lp_parm_const_string(SNUM(handle->conn),
+ lp_parm_const_string(SNUM(handle->conn),
"scannedonly",
"pref_virus",
".virus:");
so->p_failed =
- (char *)lp_parm_const_string(SNUM(handle->conn),
+ lp_parm_const_string(SNUM(handle->conn),
"scannedonly",
"pref_failed",
".failed:");
diff --git a/source3/modules/vfs_shadow_copy.c b/source3/modules/vfs_shadow_copy.c
index b93f98dedee..1db47d216be 100644
--- a/source3/modules/vfs_shadow_copy.c
+++ b/source3/modules/vfs_shadow_copy.c
@@ -216,7 +216,10 @@ static int shadow_copy_closedir(vfs_handle_struct *handle, SMB_STRUCT_DIR *_dirp
return 0;
}
-static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, bool labels)
+static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle,
+ files_struct *fsp,
+ struct shadow_copy_data *shadow_copy_data,
+ bool labels)
{
SMB_STRUCT_DIR *p = SMB_VFS_NEXT_OPENDIR(handle,fsp->conn->connectpath,NULL,0);
@@ -250,7 +253,7 @@ static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, files_str
continue;
}
- tlabels = (SHADOW_COPY_LABEL *)TALLOC_REALLOC(shadow_copy_data->mem_ctx,
+ tlabels = (SHADOW_COPY_LABEL *)TALLOC_REALLOC(shadow_copy_data,
shadow_copy_data->labels,
(shadow_copy_data->num_volumes+1)*sizeof(SHADOW_COPY_LABEL));
if (tlabels == NULL) {
diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index df3bde72c94..ca33b6d3444 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -1,32 +1,29 @@
-/*
- * implementation of an Shadow Copy module - version 2
+/*
+ * Third attempt at a shadow copy module
*
- * Copyright (C) Andrew Tridgell 2007
- * Copyright (C) Ed Plese 2009
+ * Copyright (C) Andrew Tridgell 2007 (portions taken from shadow_copy2)
+ * Copyright (C) Ed Plese 2009
+ * Copyright (C) Volker Lendecke 2011
+ * Copyright (C) Christian Ambach 2011
*
* 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 "smbd/smbd.h"
-#include "system/filesys.h"
-#include "ntioctl.h"
-
/*
- This is a 2nd implemetation of a shadow copy module for exposing
+ This is a 3rd implemetation of a shadow copy module for exposing
snapshots to windows clients as shadow copies. This version has the
following features:
@@ -96,243 +93,169 @@
The following command would generate a correctly formatted directory name
for use with the default parameters:
date -u +@GMT-%Y.%m.%d-%H.%M.%S
-
*/
-static int vfs_shadow_copy2_debug_level = DBGC_VFS;
-
-#undef DBGC_CLASS
-#define DBGC_CLASS vfs_shadow_copy2_debug_level
+#include "includes.h"
+#include "system/filesys.h"
+#include "include/ntioctl.h"
+#include "smbd/proto.h"
+#include <tdb.h>
+#include "util_tdb.h"
#define GMT_NAME_LEN 24 /* length of a @GMT- name */
-#define SHADOW_COPY2_GMT_FORMAT "@GMT-%Y.%m.%d-%H.%M.%S"
+#define GMT_FORMAT "@GMT-%Y.%m.%d-%H.%M.%S"
-#define SHADOW_COPY2_DEFAULT_SORT NULL
-#define SHADOW_COPY2_DEFAULT_FORMAT "@GMT-%Y.%m.%d-%H.%M.%S"
-#define SHADOW_COPY2_DEFAULT_LOCALTIME false
-
-/*
- make very sure it is one of our special names
- */
-static inline bool shadow_copy2_match_name(const char *name, const char **gmt_start)
+static bool shadow_copy2_find_slashes(TALLOC_CTX *mem_ctx, const char *str,
+ size_t **poffsets,
+ unsigned *pnum_offsets)
{
- unsigned year, month, day, hr, min, sec;
+ unsigned num_offsets;
+ size_t *offsets;
const char *p;
- if (gmt_start) {
- (*gmt_start) = NULL;
- }
- p = strstr_m(name, "@GMT-");
- if (p == NULL) return false;
- if (p > name && p[-1] != '/') return False;
- if (sscanf(p, "@GMT-%04u.%02u.%02u-%02u.%02u.%02u", &year, &month,
- &day, &hr, &min, &sec) != 6) {
- return False;
- }
- if (p[24] != 0 && p[24] != '/') {
- return False;
- }
- if (gmt_start) {
- (*gmt_start) = p;
- }
- return True;
-}
-static char *shadow_copy2_snapshot_to_gmt(TALLOC_CTX *mem_ctx,
- vfs_handle_struct *handle, const char *name)
-{
- struct tm timestamp;
- time_t timestamp_t;
- char gmt[GMT_NAME_LEN + 1];
- const char *fmt;
+ num_offsets = 0;
- fmt = lp_parm_const_string(SNUM(handle->conn), "shadow",
- "format", SHADOW_COPY2_DEFAULT_FORMAT);
+ p = str;
+ while ((p = strchr(p, '/')) != NULL) {
+ num_offsets += 1;
+ p += 1;
+ }
- ZERO_STRUCT(timestamp);
- if (strptime(name, fmt, &timestamp) == NULL) {
- DEBUG(10, ("shadow_copy2_snapshot_to_gmt: no match %s: %s\n",
- fmt, name));
- return NULL;
+ offsets = talloc_array(mem_ctx, size_t, num_offsets);
+ if (offsets == NULL) {
+ return false;
}
- DEBUG(10, ("shadow_copy2_snapshot_to_gmt: match %s: %s\n", fmt, name));
- if (lp_parm_bool(SNUM(handle->conn), "shadow", "localtime",
- SHADOW_COPY2_DEFAULT_LOCALTIME))
- {
- timestamp.tm_isdst = -1;
- timestamp_t = mktime(&timestamp);
- gmtime_r(&timestamp_t, &timestamp);
+ p = str;
+ num_offsets = 0;
+ while ((p = strchr(p, '/')) != NULL) {
+ offsets[num_offsets] = p-str;
+ num_offsets += 1;
+ p += 1;
}
- strftime(gmt, sizeof(gmt), SHADOW_COPY2_GMT_FORMAT, &timestamp);
- return talloc_strdup(mem_ctx, gmt);
+ *poffsets = offsets;
+ *pnum_offsets = num_offsets;
+ return true;
}
-/*
- shadow copy paths can also come into the server in this form:
-
- /foo/bar/@GMT-XXXXX/some/file
-
- This function normalises the filename to be of the form:
-
- @GMT-XXXX/foo/bar/some/file
- */
-static const char *shadow_copy2_normalise_path(TALLOC_CTX *mem_ctx, const char *path, const char *gmt_start)
+static char *shadow_copy2_insert_string(TALLOC_CTX *mem_ctx,
+ struct vfs_handle_struct *handle,
+ time_t snapshot)
{
- char *pcopy;
- char buf[GMT_NAME_LEN];
- size_t prefix_len;
+ struct tm snap_tm;
+ fstring gmt;
+ size_t gmt_len;
- if (path == gmt_start) {
- return path;
+ if (localtime_r(&snapshot, &snap_tm) == 0) {
+ DEBUG(10, ("gmtime_r failed\n"));
+ return NULL;
}
-
- prefix_len = gmt_start - path - 1;
-
- DEBUG(10, ("path=%s, gmt_start=%s, prefix_len=%d\n", path, gmt_start,
- (int)prefix_len));
-
- /*
- * We've got a/b/c/@GMT-YYYY.MM.DD-HH.MM.SS/d/e. convert to
- * @GMT-YYYY.MM.DD-HH.MM.SS/a/b/c/d/e before further
- * processing. As many VFS calls provide a const char *,
- * unfortunately we have to make a copy.
- */
-
- pcopy = talloc_strdup(talloc_tos(), path);
- if (pcopy == NULL) {
+ gmt_len = strftime(gmt, sizeof(gmt),
+ lp_parm_const_string(SNUM(handle->conn), "shadow",
+ "format", GMT_FORMAT),
+ &snap_tm);
+ if (gmt_len == 0) {
+ DEBUG(10, ("strftime failed\n"));
return NULL;
}
-
- gmt_start = pcopy + prefix_len;
-
- /*
- * Copy away "@GMT-YYYY.MM.DD-HH.MM.SS"
- */
- memcpy(buf, gmt_start+1, GMT_NAME_LEN);
-
- /*
- * Make space for it including a trailing /
- */
- memmove(pcopy + GMT_NAME_LEN + 1, pcopy, prefix_len);
-
- /*
- * Move in "@GMT-YYYY.MM.DD-HH.MM.SS/" at the beginning again
- */
- memcpy(pcopy, buf, GMT_NAME_LEN);
- pcopy[GMT_NAME_LEN] = '/';
-
- DEBUG(10, ("shadow_copy2_normalise_path: %s -> %s\n", path, pcopy));
-
- return pcopy;
+ return talloc_asprintf(talloc_tos(), "/%s/%s",
+ lp_parm_const_string(
+ SNUM(handle->conn), "shadow", "snapdir",
+ ".snapshots"),
+ gmt);
}
-/*
- convert a name to the shadow directory
- */
-
-#define _SHADOW2_NEXT(op, args, rtype, eret, extra) do { \
- const char *name = fname; \
- const char *gmt_start; \
- if (shadow_copy2_match_name(fname, &gmt_start)) { \
- char *name2; \
- rtype ret; \
- name2 = convert_shadow2_name(handle, fname, gmt_start); \
- if (name2 == NULL) { \
- errno = EINVAL; \
- return eret; \
- } \
- name = name2; \
- ret = SMB_VFS_NEXT_ ## op args; \
- talloc_free(name2); \
- if (ret != eret) extra; \
- return ret; \
- } else { \
- return SMB_VFS_NEXT_ ## op args; \
- } \
-} while (0)
-
-#define _SHADOW2_NEXT_SMB_FNAME(op, args, rtype, eret, extra) do { \
- const char *gmt_start; \
- if (shadow_copy2_match_name(smb_fname->base_name, &gmt_start)) { \
- char *name2; \
- char *smb_base_name_tmp = NULL; \
- rtype ret; \
- name2 = convert_shadow2_name(handle, smb_fname->base_name, gmt_start); \
- if (name2 == NULL) { \
- errno = EINVAL; \
- return eret; \
- } \
- smb_base_name_tmp = smb_fname->base_name; \
- smb_fname->base_name = name2; \
- ret = SMB_VFS_NEXT_ ## op args; \
- smb_fname->base_name = smb_base_name_tmp; \
- talloc_free(name2); \
- if (ret != eret) extra; \
- return ret; \
- } else { \
- return SMB_VFS_NEXT_ ## op args; \
- } \
-} while (0)
+static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
+ struct vfs_handle_struct *handle,
+ const char *name,
+ time_t *ptimestamp,
+ char **pstripped)
+{
+ struct tm tm;
+ time_t timestamp;
+ const char *p;
+ char *q;
+ char *stripped;
+ size_t rest_len, dst_len;
-/*
- convert a name to the shadow directory: NTSTATUS-specific handling
- */
+ p = strstr_m(name, "@GMT-");
+ if (p == NULL) {
+ goto no_snapshot;
+ }
+ if ((p > name) && (p[-1] != '/')) {
+ goto no_snapshot;
+ }
+ q = strptime(p, GMT_FORMAT, &tm);
+ if (q == NULL) {
+ goto no_snapshot;
+ }
+ tm.tm_isdst = -1;
+ timestamp = mktime(&tm);
+ if (timestamp == (time_t)-1) {
+ goto no_snapshot;
+ }
+ if ((p == name) && (q[0] == '\0')) {
+ if (pstripped != NULL) {
+ stripped = talloc_strdup(mem_ctx, "");
+ if (stripped == NULL) {
+ return false;
+ }
+ *pstripped = stripped;
+ }
+ *ptimestamp = timestamp;
+ return true;
+ }
+ if (q[0] != '/') {
+ goto no_snapshot;
+ }
+ q += 1;
+
+ rest_len = strlen(q);
+ dst_len = (p-name) + rest_len;
+
+ if (lp_parm_bool(SNUM(handle->conn), "shadow", "snapdirseverywhere",
+ false)) {
+ char *insert;
+ bool have_insert;
+ insert = shadow_copy2_insert_string(talloc_tos(), handle,
+ timestamp);
+ if (insert == NULL) {
+ errno = ENOMEM;
+ return false;
+ }
-#define _SHADOW2_NTSTATUS_NEXT(op, args, eret, extra) do { \
- const char *name = fname; \
- const char *gmt_start; \
- if (shadow_copy2_match_name(fname, &gmt_start)) { \
- char *name2; \
- NTSTATUS ret; \
- name2 = convert_shadow2_name(handle, fname, gmt_start); \
- if (name2 == NULL) { \
- errno = EINVAL; \
- return eret; \
- } \
- name = name2; \
- ret = SMB_VFS_NEXT_ ## op args; \
- talloc_free(name2); \
- if (!NT_STATUS_EQUAL(ret, eret)) extra; \
- return ret; \
- } else { \
- return SMB_VFS_NEXT_ ## op args; \
- } \
-} while (0)
-
-#define SHADOW2_NTSTATUS_NEXT(op, args, eret) _SHADOW2_NTSTATUS_NEXT(op, args, eret, )
-
-#define SHADOW2_NEXT(op, args, rtype, eret) _SHADOW2_NEXT(op, args, rtype, eret, )
-
-#define SHADOW2_NEXT_SMB_FNAME(op, args, rtype, eret) _SHADOW2_NEXT_SMB_FNAME(op, args, rtype, eret, )
-
-#define SHADOW2_NEXT2(op, args) do { \
- const char *gmt_start1, *gmt_start2; \
- if (shadow_copy2_match_name(oldname, &gmt_start1) || \
- shadow_copy2_match_name(newname, &gmt_start2)) { \
- errno = EROFS; \
- return -1; \
- } else { \
- return SMB_VFS_NEXT_ ## op args; \
- } \
-} while (0)
-
-#define SHADOW2_NEXT2_SMB_FNAME(op, args) do { \
- const char *gmt_start1, *gmt_start2; \
- if (shadow_copy2_match_name(smb_fname_src->base_name, &gmt_start1) || \
- shadow_copy2_match_name(smb_fname_dst->base_name, &gmt_start2)) { \
- errno = EROFS; \
- return -1; \
- } else { \
- return SMB_VFS_NEXT_ ## op args; \
- } \
-} while (0)
+ have_insert = (strstr(name, insert+1) != NULL);
+ TALLOC_FREE(insert);
+ if (have_insert) {
+ goto no_snapshot;
+ }
+ }
+ if (pstripped != NULL) {
+ stripped = talloc_array(mem_ctx, char, dst_len+1);
+ if (stripped == NULL) {
+ errno = ENOMEM;
+ return false;
+ }
+ if (p > name) {
+ memcpy(stripped, name, p-name);
+ }
+ if (rest_len > 0) {
+ memcpy(stripped + (p-name), q, rest_len);
+ }
+ stripped[dst_len] = '\0';
+ *pstripped = stripped;
+ }
+ *ptimestamp = timestamp;
+ return true;
+no_snapshot:
+ *ptimestamp = 0;
+ return true;
+}
-/*
- find the mount point of a filesystem
- */
-static char *find_mount_point(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle)
+static char *shadow_copy2_find_mount_point(TALLOC_CTX *mem_ctx,
+ vfs_handle_struct *handle)
{
char *path = talloc_strdup(mem_ctx, handle->conn->connectpath);
dev_t dev;
@@ -358,164 +281,152 @@ static char *find_mount_point(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle)
}
}
- return path;
+ return path;
}
-/*
- work out the location of the snapshot for this share
- */
-static const char *shadow_copy2_find_snapdir(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle)
+static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
+ struct vfs_handle_struct *handle,
+ const char *name, time_t timestamp)
{
- const char *snapdir;
- char *mount_point;
- const char *ret;
-
- snapdir = lp_parm_const_string(SNUM(handle->conn), "shadow", "snapdir", NULL);
- if (snapdir == NULL) {
- return NULL;
- }
- /* if its an absolute path, we're done */
- if (*snapdir == '/') {
- return snapdir;
+ struct smb_filename converted_fname;
+ char *result = NULL;
+ size_t *slashes = NULL;
+ unsigned num_slashes;
+ char *path = NULL;
+ size_t pathlen;
+ char *insert = NULL;
+ char *converted = NULL;
+ size_t insertlen;
+ int i, saved_errno;
+ size_t min_offset;
+
+ path = talloc_asprintf(mem_ctx, "%s/%s", handle->conn->connectpath,
+ name);
+ if (path == NULL) {
+ errno = ENOMEM;
+ goto fail;
}
+ pathlen = talloc_get_size(path)-1;
- /* other its relative to the filesystem mount point */
- mount_point = find_mount_point(mem_ctx, handle);
- if (mount_point == NULL) {
- return NULL;
- }
-
- ret = talloc_asprintf(mem_ctx, "%s/%s", mount_point, snapdir);
- talloc_free(mount_point);
- return ret;
-}
-
-/*
- work out the location of the base directory for snapshots of this share
- */
-static const char *shadow_copy2_find_basedir(TALLOC_CTX *mem_ctx, vfs_handle_struct *handle)
-{
- const char *basedir = lp_parm_const_string(SNUM(handle->conn), "shadow", "basedir", NULL);
+ DEBUG(10, ("converting %s\n", path));
- /* other its the filesystem mount point */
- if (basedir == NULL) {
- basedir = find_mount_point(mem_ctx, handle);
+ if (!shadow_copy2_find_slashes(talloc_tos(), path,
+ &slashes, &num_slashes)) {
+ goto fail;
}
-
- return basedir;
-}
-
-/*
- convert a filename from a share relative path, to a path in the
- snapshot directory
- */
-static char *convert_shadow2_name(vfs_handle_struct *handle, const char *fname, const char *gmt_path)
-{
- TALLOC_CTX *tmp_ctx = talloc_new(handle->data);
- const char *snapdir, *relpath, *baseoffset, *basedir;
- size_t baselen;
- char *ret, *prefix;
-
- struct tm timestamp;
- time_t timestamp_t;
- char snapshot[MAXPATHLEN];
- const char *fmt;
-
- fmt = lp_parm_const_string(SNUM(handle->conn), "shadow",
- "format", SHADOW_COPY2_DEFAULT_FORMAT);
-
- snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle);
- if (snapdir == NULL) {
- DEBUG(2,("no snapdir found for share at %s\n", handle->conn->connectpath));
- talloc_free(tmp_ctx);
- return NULL;
+ insert = shadow_copy2_insert_string(talloc_tos(), handle, timestamp);
+ if (insert == NULL) {
+ goto fail;
}
-
- basedir = shadow_copy2_find_basedir(tmp_ctx, handle);
- if (basedir == NULL) {
- DEBUG(2,("no basedir found for share at %s\n", handle->conn->connectpath));
- talloc_free(tmp_ctx);
- return NULL;
+ insertlen = talloc_get_size(insert)-1;
+ converted = talloc_array(mem_ctx, char, pathlen + insertlen + 1);
+ if (converted == NULL) {
+ goto fail;
}
- prefix = talloc_asprintf(tmp_ctx, "%s/@GMT-", snapdir);
- if (strncmp(fname, prefix, (talloc_get_size(prefix)-1)) == 0) {
- /* this looks like as we have already normalized it, leave it untouched*/
- talloc_free(tmp_ctx);
- return talloc_strdup(handle->data, fname);
+ if (path[pathlen-1] != '/') {
+ /*
+ * Append a fake slash to find the snapshot root
+ */
+ size_t *tmp;
+ tmp = talloc_realloc(talloc_tos(), slashes,
+ size_t, num_slashes+1);
+ if (tmp == NULL) {
+ goto fail;
+ }
+ slashes = tmp;
+ slashes[num_slashes] = pathlen;
+ num_slashes += 1;
}
- if (strncmp(fname, "@GMT-", 5) != 0) {
- fname = shadow_copy2_normalise_path(tmp_ctx, fname, gmt_path);
- if (fname == NULL) {
- talloc_free(tmp_ctx);
- return NULL;
+ min_offset = 0;
+
+ if (!lp_parm_bool(SNUM(handle->conn), "shadow", "crossmountpoints",
+ false)) {
+ char *mount_point;
+
+ mount_point = shadow_copy2_find_mount_point(talloc_tos(),
+ handle);
+ if (mount_point == NULL) {
+ goto fail;
}
+ min_offset = strlen(mount_point);
+ TALLOC_FREE(mount_point);
}
- ZERO_STRUCT(timestamp);
- relpath = strptime(fname, SHADOW_COPY2_GMT_FORMAT, &timestamp);
- if (relpath == NULL) {
- talloc_free(tmp_ctx);
- return NULL;
- }
+ memcpy(converted, path, pathlen+1);
+ converted[pathlen+insertlen] = '\0';
- /* relpath is the remaining portion of the path after the @GMT-xxx */
+ ZERO_STRUCT(converted_fname);
+ converted_fname.base_name = converted;
- if (lp_parm_bool(SNUM(handle->conn), "shadow", "localtime",
- SHADOW_COPY2_DEFAULT_LOCALTIME))
- {
- timestamp_t = timegm(&timestamp);
- localtime_r(&timestamp_t, &timestamp);
- }
+ for (i = num_slashes-1; i>=0; i--) {
+ int ret;
+ size_t offset;
- strftime(snapshot, MAXPATHLEN, fmt, &timestamp);
+ offset = slashes[i];
- baselen = strlen(basedir);
- baseoffset = handle->conn->connectpath + baselen;
+ if (offset < min_offset) {
+ errno = ENOENT;
+ goto fail;
+ }
- /* some sanity checks */
- if (strncmp(basedir, handle->conn->connectpath, baselen) != 0 ||
- (handle->conn->connectpath[baselen] != 0 && handle->conn->connectpath[baselen] != '/')) {
- DEBUG(0,("convert_shadow2_name: basedir %s is not a parent of %s\n",
- basedir, handle->conn->connectpath));
- talloc_free(tmp_ctx);
- return NULL;
- }
+ memcpy(converted+offset, insert, insertlen);
- if (*relpath == '/') relpath++;
- if (*baseoffset == '/') baseoffset++;
+ offset += insertlen;
+ memcpy(converted+offset, path + slashes[i],
+ pathlen - slashes[i]);
- ret = talloc_asprintf(handle->data, "%s/%s/%s/%s",
- snapdir,
- snapshot,
- baseoffset,
- relpath);
- DEBUG(6,("convert_shadow2_name: '%s' -> '%s'\n", fname, ret));
- talloc_free(tmp_ctx);
- return ret;
-}
+ ret = SMB_VFS_NEXT_LSTAT(handle, &converted_fname);
+ DEBUG(10, ("Trying %s: %d (%s)\n", converted,
+ ret, ret == 0 ? "ok" : strerror(errno)));
+ if (ret == 0) {
+ /* success */
+ break;
+ }
+ if (errno == ENOTDIR) {
+ /*
+ * This is a valid condition: We appended the
+ * .snaphots/@GMT.. to a file name. Just try
+ * with the upper levels.
+ */
+ continue;
+ }
+ if (errno != ENOENT) {
+ /* Other problem than "not found" */
+ goto fail;
+ }
+ }
-/*
- simple string hash
- */
-static uint32 string_hash(const char *s)
-{
- uint32 n = 0;
- while (*s) {
- n = ((n << 5) + n) ^ (uint32)(*s++);
- }
- return n;
+ if (i >= 0) {
+ /*
+ * Found something
+ */
+ DEBUG(10, ("Found %s\n", converted));
+ result = converted;
+ converted = NULL;
+ } else {
+ errno = ENOENT;
+ }
+fail:
+ saved_errno = errno;
+ TALLOC_FREE(converted);
+ TALLOC_FREE(insert);
+ TALLOC_FREE(slashes);
+ TALLOC_FREE(path);
+ errno = saved_errno;
+ return result;
}
/*
modify a sbuf return to ensure that inodes in the shadow directory
are different from those in the main directory
*/
-static void convert_sbuf(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf)
+static void convert_sbuf(vfs_handle_struct *handle, const char *fname,
+ SMB_STRUCT_STAT *sbuf)
{
- if (lp_parm_bool(SNUM(handle->conn), "shadow", "fixinodes", False)) {
+ if (lp_parm_bool(SNUM(handle->conn), "shadow", "fixinodes", False)) {
/* some snapshot systems, like GPFS, return the name
device:inode for the snapshot files as the current
files. That breaks the 'restore' button in the shadow copy
@@ -526,7 +437,10 @@ static void convert_sbuf(vfs_handle_struct *handle, const char *fname, SMB_STRUC
number collision, but I can't see a better approach
without significant VFS changes
*/
- uint32_t shash = string_hash(fname) & 0xFF000000;
+ uint32_t shash;
+ TDB_DATA data = string_tdb_data(fname);
+
+ shash = tdb_jenkins_hash(&data) & 0xFF000000;
if (shash == 0) {
shash = 1;
}
@@ -534,316 +448,607 @@ static void convert_sbuf(vfs_handle_struct *handle, const char *fname, SMB_STRUC
}
}
+static SMB_STRUCT_DIR *shadow_copy2_opendir(vfs_handle_struct *handle,
+ const char *fname,
+ const char *mask,
+ uint32 attr)
+{
+ time_t timestamp;
+ char *stripped;
+ SMB_STRUCT_DIR *ret;
+ int saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return NULL;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return NULL;
+ }
+ ret = SMB_VFS_NEXT_OPENDIR(handle, conv, mask, attr);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
static int shadow_copy2_rename(vfs_handle_struct *handle,
const struct smb_filename *smb_fname_src,
const struct smb_filename *smb_fname_dst)
{
- if (shadow_copy2_match_name(smb_fname_src->base_name, NULL)) {
+ time_t timestamp_src, timestamp_dst;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ smb_fname_src->base_name,
+ &timestamp_src, NULL)) {
+ return -1;
+ }
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ smb_fname_dst->base_name,
+ &timestamp_dst, NULL)) {
+ return -1;
+ }
+ if (timestamp_src != 0) {
errno = EXDEV;
return -1;
}
- SHADOW2_NEXT2_SMB_FNAME(RENAME,
- (handle, smb_fname_src, smb_fname_dst));
+ if (timestamp_dst != 0) {
+ errno = EROFS;
+ return -1;
+ }
+ return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
}
static int shadow_copy2_symlink(vfs_handle_struct *handle,
const char *oldname, const char *newname)
{
- SHADOW2_NEXT2(SYMLINK, (handle, oldname, newname));
-}
+ time_t timestamp_old, timestamp_new;
-static int shadow_copy2_link(vfs_handle_struct *handle,
- const char *oldname, const char *newname)
-{
- SHADOW2_NEXT2(LINK, (handle, oldname, newname));
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
+ &timestamp_old, NULL)) {
+ return -1;
+ }
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, newname,
+ &timestamp_new, NULL)) {
+ return -1;
+ }
+ if ((timestamp_old != 0) || (timestamp_new != 0)) {
+ errno = EROFS;
+ return -1;
+ }
+ return SMB_VFS_NEXT_SYMLINK(handle, oldname, newname);
}
-static int shadow_copy2_open(vfs_handle_struct *handle,
- struct smb_filename *smb_fname, files_struct *fsp,
- int flags, mode_t mode)
+static int shadow_copy2_link(vfs_handle_struct *handle,
+ const char *oldname, const char *newname)
{
- SHADOW2_NEXT_SMB_FNAME(OPEN,
- (handle, smb_fname, fsp, flags, mode),
- int, -1);
-}
+ time_t timestamp_old, timestamp_new;
-static SMB_STRUCT_DIR *shadow_copy2_opendir(vfs_handle_struct *handle,
- const char *fname, const char *mask, uint32 attr)
-{
- SHADOW2_NEXT(OPENDIR, (handle, name, mask, attr), SMB_STRUCT_DIR *, NULL);
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
+ &timestamp_old, NULL)) {
+ return -1;
+ }
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, newname,
+ &timestamp_new, NULL)) {
+ return -1;
+ }
+ if ((timestamp_old != 0) || (timestamp_new != 0)) {
+ errno = EROFS;
+ return -1;
+ }
+ return SMB_VFS_NEXT_LINK(handle, oldname, newname);
}
static int shadow_copy2_stat(vfs_handle_struct *handle,
struct smb_filename *smb_fname)
{
- _SHADOW2_NEXT_SMB_FNAME(STAT, (handle, smb_fname), int, -1,
- convert_sbuf(handle, smb_fname->base_name,
- &smb_fname->st));
+ time_t timestamp;
+ char *stripped, *tmp;
+ int ret, saved_errno;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ smb_fname->base_name,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_STAT(handle, smb_fname);
+ }
+
+ tmp = smb_fname->base_name;
+ smb_fname->base_name = shadow_copy2_convert(
+ talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+
+ if (smb_fname->base_name == NULL) {
+ smb_fname->base_name = tmp;
+ return -1;
+ }
+
+ ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
+ saved_errno = errno;
+
+ TALLOC_FREE(smb_fname->base_name);
+ smb_fname->base_name = tmp;
+
+ if (ret == 0) {
+ convert_sbuf(handle, smb_fname->base_name, &smb_fname->st);
+ }
+ errno = saved_errno;
+ return ret;
}
static int shadow_copy2_lstat(vfs_handle_struct *handle,
struct smb_filename *smb_fname)
{
- _SHADOW2_NEXT_SMB_FNAME(LSTAT, (handle, smb_fname), int, -1,
- convert_sbuf(handle, smb_fname->base_name,
- &smb_fname->st));
+ time_t timestamp;
+ char *stripped, *tmp;
+ int ret, saved_errno;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ smb_fname->base_name,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
+ }
+
+ tmp = smb_fname->base_name;
+ smb_fname->base_name = shadow_copy2_convert(
+ talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+
+ if (smb_fname->base_name == NULL) {
+ smb_fname->base_name = tmp;
+ return -1;
+ }
+
+ ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
+ saved_errno = errno;
+
+ TALLOC_FREE(smb_fname->base_name);
+ smb_fname->base_name = tmp;
+
+ if (ret == 0) {
+ convert_sbuf(handle, smb_fname->base_name, &smb_fname->st);
+ }
+ errno = saved_errno;
+ return ret;
}
-static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
+static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp,
+ SMB_STRUCT_STAT *sbuf)
{
- int ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
- if (ret == 0 && shadow_copy2_match_name(fsp->fsp_name->base_name, NULL)) {
+ time_t timestamp;
+ int ret;
+
+ ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
+ if (ret == -1) {
+ return ret;
+ }
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ fsp->fsp_name->base_name,
+ &timestamp, NULL)) {
+ return 0;
+ }
+ if (timestamp != 0) {
convert_sbuf(handle, fsp->fsp_name->base_name, sbuf);
}
+ return 0;
+}
+
+static int shadow_copy2_open(vfs_handle_struct *handle,
+ struct smb_filename *smb_fname, files_struct *fsp,
+ int flags, mode_t mode)
+{
+ time_t timestamp;
+ char *stripped, *tmp;
+ int ret, saved_errno;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ smb_fname->base_name,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
+ }
+
+ tmp = smb_fname->base_name;
+ smb_fname->base_name = shadow_copy2_convert(
+ talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+
+ if (smb_fname->base_name == NULL) {
+ smb_fname->base_name = tmp;
+ return -1;
+ }
+
+ ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
+ saved_errno = errno;
+
+ TALLOC_FREE(smb_fname->base_name);
+ smb_fname->base_name = tmp;
+
+ errno = saved_errno;
return ret;
}
static int shadow_copy2_unlink(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname_in)
+ const struct smb_filename *smb_fname)
{
- struct smb_filename *smb_fname = NULL;
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ struct smb_filename *conv;
NTSTATUS status;
- status = copy_smb_filename(talloc_tos(), smb_fname_in, &smb_fname);
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ smb_fname->base_name,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+ }
+ status = copy_smb_filename(talloc_tos(), smb_fname, &conv);
if (!NT_STATUS_IS_OK(status)) {
- errno = map_errno_from_nt_status(status);
+ errno = ENOMEM;
return -1;
}
-
- SHADOW2_NEXT_SMB_FNAME(UNLINK, (handle, smb_fname), int, -1);
+ conv->base_name = shadow_copy2_convert(
+ conv, handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv->base_name == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_UNLINK(handle, conv);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
}
-static int shadow_copy2_chmod(vfs_handle_struct *handle,
- const char *fname, mode_t mode)
+static int shadow_copy2_chmod(vfs_handle_struct *handle, const char *fname,
+ mode_t mode)
{
- SHADOW2_NEXT(CHMOD, (handle, name, mode), int, -1);
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_CHMOD(handle, fname, mode);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_CHMOD(handle, conv, mode);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
}
-static int shadow_copy2_chown(vfs_handle_struct *handle,
- const char *fname, uid_t uid, gid_t gid)
+static int shadow_copy2_chown(vfs_handle_struct *handle, const char *fname,
+ uid_t uid, gid_t gid)
{
- SHADOW2_NEXT(CHOWN, (handle, name, uid, gid), int, -1);
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_CHOWN(handle, fname, uid, gid);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_CHOWN(handle, conv, uid, gid);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
}
static int shadow_copy2_chdir(vfs_handle_struct *handle,
- const char *fname)
+ const char *fname)
{
- SHADOW2_NEXT(CHDIR, (handle, name), int, -1);
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_CHDIR(handle, fname);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_CHDIR(handle, conv);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
}
static int shadow_copy2_ntimes(vfs_handle_struct *handle,
- const struct smb_filename *smb_fname_in,
+ const struct smb_filename *smb_fname,
struct smb_file_time *ft)
{
- struct smb_filename *smb_fname = NULL;
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ struct smb_filename *conv;
NTSTATUS status;
- status = copy_smb_filename(talloc_tos(), smb_fname_in, &smb_fname);
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ smb_fname->base_name,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
+ }
+ status = copy_smb_filename(talloc_tos(), smb_fname, &conv);
if (!NT_STATUS_IS_OK(status)) {
- errno = map_errno_from_nt_status(status);
+ errno = ENOMEM;
return -1;
}
-
- SHADOW2_NEXT_SMB_FNAME(NTIMES, (handle, smb_fname, ft), int, -1);
+ conv->base_name = shadow_copy2_convert(
+ conv, handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv->base_name == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_NTIMES(handle, conv, ft);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
}
static int shadow_copy2_readlink(vfs_handle_struct *handle,
const char *fname, char *buf, size_t bufsiz)
{
- SHADOW2_NEXT(READLINK, (handle, name, buf, bufsiz), int, -1);
-}
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
-static int shadow_copy2_mknod(vfs_handle_struct *handle,
- const char *fname, mode_t mode, SMB_DEV_T dev)
-{
- SHADOW2_NEXT(MKNOD, (handle, name, mode, dev), int, -1);
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_READLINK(handle, fname, buf, bufsiz);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_READLINK(handle, conv, buf, bufsiz);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
}
-static char *shadow_copy2_realpath(vfs_handle_struct *handle,
- const char *fname)
+static int shadow_copy2_mknod(vfs_handle_struct *handle,
+ const char *fname, mode_t mode, SMB_DEV_T dev)
{
- const char *gmt;
-
- if (shadow_copy2_match_name(fname, &gmt)
- && (gmt[GMT_NAME_LEN] == '\0')) {
- char *copy;
-
- copy = talloc_strdup(talloc_tos(), fname);
- if (copy == NULL) {
- errno = ENOMEM;
- return NULL;
- }
-
- copy[gmt - fname] = '.';
- copy[gmt - fname + 1] = '\0';
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
- DEBUG(10, ("calling NEXT_REALPATH with %s\n", copy));
- SHADOW2_NEXT(REALPATH, (handle, name), char *,
- NULL);
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_MKNOD(handle, fname, mode, dev);
}
- SHADOW2_NEXT(REALPATH, (handle, name), char *, NULL);
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_MKNOD(handle, conv, mode, dev);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
}
-static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle,
- const char *fname)
+static char *shadow_copy2_realpath(vfs_handle_struct *handle,
+ const char *fname)
{
- TALLOC_CTX *tmp_ctx;
- const char *snapdir, *baseoffset, *basedir, *gmt_start;
- size_t baselen;
- char *ret;
-
- DEBUG(10, ("shadow_copy2_connectpath called with %s\n", fname));
-
- if (!shadow_copy2_match_name(fname, &gmt_start)) {
- return handle->conn->connectpath;
+ time_t timestamp;
+ char *stripped = NULL;
+ char *tmp = NULL;
+ char *result = NULL;
+ char *inserted = NULL;
+ char *inserted_to, *inserted_end;
+ int saved_errno;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ goto done;
}
-
- /*
- * We have to create a real temporary context because we have
- * to put our result on talloc_tos(). Thus we can't use a
- * talloc_stackframe() here.
- */
- tmp_ctx = talloc_new(talloc_tos());
-
- fname = shadow_copy2_normalise_path(tmp_ctx, fname, gmt_start);
- if (fname == NULL) {
- TALLOC_FREE(tmp_ctx);
- return NULL;
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_REALPATH(handle, fname);
}
- snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle);
- if (snapdir == NULL) {
- DEBUG(2,("no snapdir found for share at %s\n",
- handle->conn->connectpath));
- TALLOC_FREE(tmp_ctx);
- return NULL;
+ tmp = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ if (tmp == NULL) {
+ goto done;
}
- basedir = shadow_copy2_find_basedir(tmp_ctx, handle);
- if (basedir == NULL) {
- DEBUG(2,("no basedir found for share at %s\n",
- handle->conn->connectpath));
- TALLOC_FREE(tmp_ctx);
- return NULL;
+ result = SMB_VFS_NEXT_REALPATH(handle, tmp);
+ if (result == NULL) {
+ goto done;
}
- baselen = strlen(basedir);
- baseoffset = handle->conn->connectpath + baselen;
-
- /* some sanity checks */
- if (strncmp(basedir, handle->conn->connectpath, baselen) != 0 ||
- (handle->conn->connectpath[baselen] != 0
- && handle->conn->connectpath[baselen] != '/')) {
- DEBUG(0,("shadow_copy2_connectpath: basedir %s is not a "
- "parent of %s\n", basedir,
- handle->conn->connectpath));
- TALLOC_FREE(tmp_ctx);
- return NULL;
+ /*
+ * Take away what we've inserted. This removes the @GMT-thingy
+ * completely, but will give a path under the share root.
+ */
+ inserted = shadow_copy2_insert_string(talloc_tos(), handle, timestamp);
+ if (inserted == NULL) {
+ goto done;
}
-
- if (*baseoffset == '/') baseoffset++;
-
- ret = talloc_asprintf(talloc_tos(), "%s/%.*s/%s",
- snapdir,
- GMT_NAME_LEN, fname,
- baseoffset);
- DEBUG(6,("shadow_copy2_connectpath: '%s' -> '%s'\n", fname, ret));
- TALLOC_FREE(tmp_ctx);
- return ret;
+ inserted_to = strstr_m(result, inserted);
+ if (inserted_to == NULL) {
+ DEBUG(2, ("SMB_VFS_NEXT_REALPATH removed %s\n", inserted));
+ goto done;
+ }
+ inserted_end = inserted_to + talloc_get_size(inserted) - 1;
+ memmove(inserted_to, inserted_end, strlen(inserted_end)+1);
+
+done:
+ saved_errno = errno;
+ TALLOC_FREE(inserted);
+ TALLOC_FREE(tmp);
+ TALLOC_FREE(stripped);
+ errno = saved_errno;
+ return result;
}
-static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle,
- const char *fname, uint32 security_info,
- struct security_descriptor **ppdesc)
+static char *have_snapdir(struct vfs_handle_struct *handle,
+ const char *path)
{
- SHADOW2_NTSTATUS_NEXT(GET_NT_ACL, (handle, name, security_info, ppdesc), NT_STATUS_ACCESS_DENIED);
-}
+ struct smb_filename smb_fname;
+ int ret;
+
+ ZERO_STRUCT(smb_fname);
+ smb_fname.base_name = talloc_asprintf(
+ talloc_tos(), "%s/%s", path,
+ lp_parm_const_string(SNUM(handle->conn), "shadow", "snapdir",
+ ".snapshots"));
+ if (smb_fname.base_name == NULL) {
+ return NULL;
+ }
-static int shadow_copy2_mkdir(vfs_handle_struct *handle, const char *fname, mode_t mode)
-{
- SHADOW2_NEXT(MKDIR, (handle, name, mode), int, -1);
+ ret = SMB_VFS_NEXT_STAT(handle, &smb_fname);
+ if ((ret == 0) && (S_ISDIR(smb_fname.st.st_ex_mode))) {
+ return smb_fname.base_name;
+ }
+ TALLOC_FREE(smb_fname.base_name);
+ return NULL;
}
-static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname)
+static char *shadow_copy2_find_snapdir(TALLOC_CTX *mem_ctx,
+ struct vfs_handle_struct *handle,
+ struct smb_filename *smb_fname)
{
- SHADOW2_NEXT(RMDIR, (handle, name), int, -1);
-}
+ char *path, *p;
+ char *snapdir;
-static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
- unsigned int flags)
-{
- SHADOW2_NEXT(CHFLAGS, (handle, name, flags), int, -1);
-}
+ path = talloc_asprintf(mem_ctx, "%s/%s",
+ handle->conn->connectpath,
+ smb_fname->base_name);
+ if (path == NULL) {
+ return NULL;
+ }
-static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
- const char *fname, const char *aname, void *value, size_t size)
-{
- SHADOW2_NEXT(GETXATTR, (handle, name, aname, value, size), ssize_t, -1);
-}
+ snapdir = have_snapdir(handle, path);
+ if (snapdir != NULL) {
+ TALLOC_FREE(path);
+ return snapdir;
+ }
-static ssize_t shadow_copy2_lgetxattr(vfs_handle_struct *handle,
- const char *fname, const char *aname, void *value, size_t size)
-{
- SHADOW2_NEXT(LGETXATTR, (handle, name, aname, value, size), ssize_t, -1);
-}
+ while ((p = strrchr(path, '/')) && (p > path)) {
-static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle, const char *fname,
- char *list, size_t size)
-{
- SHADOW2_NEXT(LISTXATTR, (handle, name, list, size), ssize_t, -1);
-}
+ p[0] = '\0';
-static int shadow_copy2_removexattr(struct vfs_handle_struct *handle, const char *fname,
- const char *aname)
-{
- SHADOW2_NEXT(REMOVEXATTR, (handle, name, aname), int, -1);
+ snapdir = have_snapdir(handle, path);
+ if (snapdir != NULL) {
+ TALLOC_FREE(path);
+ return snapdir;
+ }
+ }
+ TALLOC_FREE(path);
+ return NULL;
}
-static int shadow_copy2_lremovexattr(struct vfs_handle_struct *handle, const char *fname,
- const char *aname)
+static bool shadow_copy2_snapshot_to_gmt(TALLOC_CTX *mem_ctx,
+ vfs_handle_struct *handle,
+ const char *name,
+ char *gmt, size_t gmt_len)
{
- SHADOW2_NEXT(LREMOVEXATTR, (handle, name, aname), int, -1);
-}
+ struct tm timestamp;
+ time_t timestamp_t;
+ const char *fmt;
-static int shadow_copy2_setxattr(struct vfs_handle_struct *handle, const char *fname,
- const char *aname, const void *value, size_t size, int flags)
-{
- SHADOW2_NEXT(SETXATTR, (handle, name, aname, value, size, flags), int, -1);
-}
+ fmt = lp_parm_const_string(SNUM(handle->conn), "shadow",
+ "format", GMT_FORMAT);
-static int shadow_copy2_lsetxattr(struct vfs_handle_struct *handle, const char *fname,
- const char *aname, const void *value, size_t size, int flags)
-{
- SHADOW2_NEXT(LSETXATTR, (handle, name, aname, value, size, flags), int, -1);
-}
+ ZERO_STRUCT(timestamp);
+ if (strptime(name, fmt, &timestamp) == NULL) {
+ DEBUG(10, ("shadow_copy2_snapshot_to_gmt: no match %s: %s\n",
+ fmt, name));
+ return false;
+ }
-static int shadow_copy2_chmod_acl(vfs_handle_struct *handle,
- const char *fname, mode_t mode)
-{
- SHADOW2_NEXT(CHMOD_ACL, (handle, name, mode), int, -1);
+ DEBUG(10, ("shadow_copy2_snapshot_to_gmt: match %s: %s\n", fmt, name));
+
+ if (lp_parm_bool(SNUM(handle->conn), "shadow", "localtime", false)) {
+ timestamp.tm_isdst = -1;
+ timestamp_t = mktime(&timestamp);
+ gmtime_r(&timestamp_t, &timestamp);
+ }
+ strftime(gmt, gmt_len, GMT_FORMAT, &timestamp);
+ return true;
}
static int shadow_copy2_label_cmp_asc(const void *x, const void *y)
{
- return strncmp((char *)x, (char *)y, sizeof(SHADOW_COPY_LABEL));
+ return strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
}
static int shadow_copy2_label_cmp_desc(const void *x, const void *y)
{
- return -strncmp((char *)x, (char *)y, sizeof(SHADOW_COPY_LABEL));
+ return -strncmp((const char *)x, (const char *)y, sizeof(SHADOW_COPY_LABEL));
}
/*
sort the shadow copy data in ascending or descending order
*/
static void shadow_copy2_sort_data(vfs_handle_struct *handle,
- SHADOW_COPY_DATA *shadow_copy2_data)
+ struct shadow_copy_data *shadow_copy2_data)
{
int (*cmpfunc)(const void *, const void *);
const char *sort;
sort = lp_parm_const_string(SNUM(handle->conn), "shadow",
- "sort", SHADOW_COPY2_DEFAULT_SORT);
+ "sort", NULL);
if (sort == NULL) {
return;
}
@@ -867,18 +1072,17 @@ static void shadow_copy2_sort_data(vfs_handle_struct *handle,
return;
}
-static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle,
- files_struct *fsp,
- SHADOW_COPY_DATA *shadow_copy2_data,
- bool labels)
+static int shadow_copy2_get_shadow_copy_data(
+ vfs_handle_struct *handle, files_struct *fsp,
+ struct shadow_copy_data *shadow_copy2_data,
+ bool labels)
{
SMB_STRUCT_DIR *p;
const char *snapdir;
SMB_STRUCT_DIRENT *d;
- TALLOC_CTX *tmp_ctx = talloc_new(handle->data);
- char *snapshot;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
- snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle);
+ snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle, fsp->fsp_name);
if (snapdir == NULL) {
DEBUG(0,("shadow:snapdir not found for %s in get_shadow_copy_data\n",
handle->conn->connectpath));
@@ -901,16 +1105,23 @@ static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle,
shadow_copy2_data->labels = NULL;
while ((d = SMB_VFS_NEXT_READDIR(handle, p, NULL))) {
+ char snapshot[GMT_NAME_LEN+1];
SHADOW_COPY_LABEL *tlabels;
- /* ignore names not of the right form in the snapshot directory */
- snapshot = shadow_copy2_snapshot_to_gmt(tmp_ctx, handle,
- d->d_name);
- DEBUG(6,("shadow_copy2_get_shadow_copy2_data: %s -> %s\n",
- d->d_name, snapshot));
- if (!snapshot) {
+ /*
+ * ignore names not of the right form in the snapshot
+ * directory
+ */
+ if (!shadow_copy2_snapshot_to_gmt(
+ tmp_ctx, handle, d->d_name,
+ snapshot, sizeof(snapshot))) {
+
+ DEBUG(6, ("shadow_copy2_get_shadow_copy_data: "
+ "ignoring %s\n", d->d_name));
continue;
}
+ DEBUG(6,("shadow_copy2_get_shadow_copy_data: %s -> %s\n",
+ d->d_name, snapshot));
if (!labels) {
/* the caller doesn't want the labels */
@@ -918,9 +1129,10 @@ static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle,
continue;
}
- tlabels = talloc_realloc(shadow_copy2_data->mem_ctx,
+ tlabels = talloc_realloc(shadow_copy2_data,
shadow_copy2_data->labels,
- SHADOW_COPY_LABEL, shadow_copy2_data->num_volumes+1);
+ SHADOW_COPY_LABEL,
+ shadow_copy2_data->num_volumes+1);
if (tlabels == NULL) {
DEBUG(0,("shadow_copy2: out of memory\n"));
SMB_VFS_NEXT_CLOSEDIR(handle, p);
@@ -930,7 +1142,6 @@ static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle,
strlcpy(tlabels[shadow_copy2_data->num_volumes], snapshot,
sizeof(*tlabels));
- talloc_free(snapshot);
shadow_copy2_data->num_volumes++;
shadow_copy2_data->labels = tlabels;
@@ -944,59 +1155,455 @@ static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle,
return 0;
}
-static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
- .opendir = shadow_copy2_opendir,
- .mkdir = shadow_copy2_mkdir,
- .rmdir = shadow_copy2_rmdir,
- .chflags = shadow_copy2_chflags,
- .getxattr = shadow_copy2_getxattr,
- .lgetxattr = shadow_copy2_lgetxattr,
- .listxattr = shadow_copy2_listxattr,
- .removexattr = shadow_copy2_removexattr,
- .lremovexattr = shadow_copy2_lremovexattr,
- .setxattr = shadow_copy2_setxattr,
- .lsetxattr = shadow_copy2_lsetxattr,
- .open_fn = shadow_copy2_open,
- .rename = shadow_copy2_rename,
- .stat = shadow_copy2_stat,
- .lstat = shadow_copy2_lstat,
- .fstat = shadow_copy2_fstat,
- .unlink = shadow_copy2_unlink,
- .chmod = shadow_copy2_chmod,
- .chown = shadow_copy2_chown,
- .chdir = shadow_copy2_chdir,
- .ntimes = shadow_copy2_ntimes,
- .symlink = shadow_copy2_symlink,
- .vfs_readlink = shadow_copy2_readlink,
- .link = shadow_copy2_link,
- .mknod = shadow_copy2_mknod,
- .realpath = shadow_copy2_realpath,
- .connectpath = shadow_copy2_connectpath,
- .get_nt_acl = shadow_copy2_get_nt_acl,
- .chmod_acl = shadow_copy2_chmod_acl,
- .get_shadow_copy_data = shadow_copy2_get_shadow_copy2_data,
-};
+static NTSTATUS shadow_copy2_fget_nt_acl(vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ uint32 security_info,
+ struct security_descriptor **ppdesc)
+{
+ time_t timestamp;
+ char *stripped;
+ NTSTATUS status;
+ char *conv;
-NTSTATUS vfs_shadow_copy2_init(void);
-NTSTATUS vfs_shadow_copy2_init(void)
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
+ fsp->fsp_name->base_name,
+ &timestamp, &stripped)) {
+ return map_nt_error_from_unix(errno);
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
+ ppdesc);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return map_nt_error_from_unix(errno);
+ }
+ status = SMB_VFS_NEXT_GET_NT_ACL(handle, conv, security_info, ppdesc);
+ TALLOC_FREE(conv);
+ return status;
+}
+
+static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle,
+ const char *fname,
+ uint32 security_info,
+ struct security_descriptor **ppdesc)
+{
+ time_t timestamp;
+ char *stripped;
+ NTSTATUS status;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return map_nt_error_from_unix(errno);
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_GET_NT_ACL(handle, fname, security_info,
+ ppdesc);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return map_nt_error_from_unix(errno);
+ }
+ status = SMB_VFS_NEXT_GET_NT_ACL(handle, conv, security_info, ppdesc);
+ TALLOC_FREE(conv);
+ return status;
+}
+
+static int shadow_copy2_mkdir(vfs_handle_struct *handle,
+ const char *fname, mode_t mode)
{
- NTSTATUS ret;
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
- ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "shadow_copy2",
- &vfs_shadow_copy2_fns);
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_MKDIR(handle, fname, mode);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_MKDIR(handle, conv, mode);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
- if (!NT_STATUS_IS_OK(ret))
- return ret;
+static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname)
+{
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
- vfs_shadow_copy2_debug_level = debug_add_class("shadow_copy2");
- if (vfs_shadow_copy2_debug_level == -1) {
- vfs_shadow_copy2_debug_level = DBGC_VFS;
- DEBUG(0, ("%s: Couldn't register custom debugging class!\n",
- "vfs_shadow_copy2_init"));
- } else {
- DEBUG(10, ("%s: Debug class number of '%s': %d\n",
- "vfs_shadow_copy2_init","shadow_copy2",vfs_shadow_copy2_debug_level));
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_RMDIR(handle, fname);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_RMDIR(handle, conv);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
+static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
+ unsigned int flags)
+{
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_CHFLAGS(handle, fname, flags);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_CHFLAGS(handle, conv, flags);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
+static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
+ const char *fname, const char *aname,
+ void *value, size_t size)
+{
+ time_t timestamp;
+ char *stripped;
+ ssize_t ret;
+ int saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_GETXATTR(handle, fname, aname, value,
+ size);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
+static ssize_t shadow_copy2_lgetxattr(vfs_handle_struct *handle,
+ const char *fname, const char *aname,
+ void *value, size_t size)
+{
+ time_t timestamp;
+ char *stripped;
+ ssize_t ret;
+ int saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_LGETXATTR(handle, fname, aname, value,
+ size);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_LGETXATTR(handle, conv, aname, value, size);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
+static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle,
+ const char *fname,
+ char *list, size_t size)
+{
+ time_t timestamp;
+ char *stripped;
+ ssize_t ret;
+ int saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_LISTXATTR(handle, fname, list, size);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_LISTXATTR(handle, conv, list, size);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
+static int shadow_copy2_removexattr(vfs_handle_struct *handle,
+ const char *fname, const char *aname)
+{
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_REMOVEXATTR(handle, fname, aname);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
+static int shadow_copy2_lremovexattr(vfs_handle_struct *handle,
+ const char *fname, const char *aname)
+{
+ time_t timestamp;
+ char *stripped;
+ int ret, saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_LREMOVEXATTR(handle, fname, aname);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_LREMOVEXATTR(handle, conv, aname);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
+static int shadow_copy2_setxattr(struct vfs_handle_struct *handle,
+ const char *fname,
+ const char *aname, const void *value,
+ size_t size, int flags)
+{
+ time_t timestamp;
+ char *stripped;
+ ssize_t ret;
+ int saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_SETXATTR(handle, fname, aname, value, size,
+ flags);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_SETXATTR(handle, conv, aname, value, size, flags);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
+static int shadow_copy2_lsetxattr(struct vfs_handle_struct *handle,
+ const char *fname,
+ const char *aname, const void *value,
+ size_t size, int flags)
+{
+ time_t timestamp;
+ char *stripped;
+ ssize_t ret;
+ int saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_LSETXATTR(handle, fname, aname, value,
+ size, flags);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_LSETXATTR(handle, conv, aname, value, size, flags);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+
+static int shadow_copy2_chmod_acl(vfs_handle_struct *handle,
+ const char *fname, mode_t mode)
+{
+ time_t timestamp;
+ char *stripped;
+ ssize_t ret;
+ int saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
+ &timestamp, &stripped)) {
+ return -1;
}
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_CHMOD_ACL(handle, fname, mode);
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_CHMOD_ACL(handle, conv, mode);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
+ return ret;
+}
+static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
+ const char *path,
+ const char *name,
+ TALLOC_CTX *mem_ctx,
+ char **found_name)
+{
+ time_t timestamp;
+ char *stripped;
+ ssize_t ret;
+ int saved_errno;
+ char *conv;
+
+ if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path,
+ &timestamp, &stripped)) {
+ return -1;
+ }
+ if (timestamp == 0) {
+ return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
+ mem_ctx, found_name);
+ }
+ if (stripped[0] == '\0') {
+ *found_name = talloc_strdup(mem_ctx, name);
+ if (*found_name == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ return 0;
+ }
+ conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
+ TALLOC_FREE(stripped);
+ if (conv == NULL) {
+ return -1;
+ }
+ ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, conv, name,
+ mem_ctx, found_name);
+ saved_errno = errno;
+ TALLOC_FREE(conv);
+ errno = saved_errno;
return ret;
}
+
+
+static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
+ .opendir = shadow_copy2_opendir,
+ .rename = shadow_copy2_rename,
+ .link = shadow_copy2_link,
+ .symlink = shadow_copy2_symlink,
+ .stat = shadow_copy2_stat,
+ .lstat = shadow_copy2_lstat,
+ .fstat = shadow_copy2_fstat,
+ .open_fn = shadow_copy2_open,
+ .unlink = shadow_copy2_unlink,
+ .chmod = shadow_copy2_chmod,
+ .chown = shadow_copy2_chown,
+ .chdir = shadow_copy2_chdir,
+ .ntimes = shadow_copy2_ntimes,
+ .vfs_readlink = shadow_copy2_readlink,
+ .mknod = shadow_copy2_mknod,
+ .realpath = shadow_copy2_realpath,
+ .get_nt_acl = shadow_copy2_get_nt_acl,
+ .fget_nt_acl = shadow_copy2_fget_nt_acl,
+ .get_shadow_copy_data = shadow_copy2_get_shadow_copy_data,
+ .mkdir = shadow_copy2_mkdir,
+ .rmdir = shadow_copy2_rmdir,
+ .getxattr = shadow_copy2_getxattr,
+ .lgetxattr = shadow_copy2_lgetxattr,
+ .listxattr = shadow_copy2_listxattr,
+ .removexattr = shadow_copy2_removexattr,
+ .lremovexattr = shadow_copy2_lremovexattr,
+ .setxattr = shadow_copy2_setxattr,
+ .lsetxattr = shadow_copy2_lsetxattr,
+ .chmod_acl = shadow_copy2_chmod_acl,
+ .chflags = shadow_copy2_chflags,
+ .get_real_filename = shadow_copy2_get_real_filename,
+};
+
+NTSTATUS vfs_shadow_copy2_init(void);
+NTSTATUS vfs_shadow_copy2_init(void)
+{
+ return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
+ "shadow_copy2", &vfs_shadow_copy2_fns);
+}
diff --git a/source3/modules/vfs_smb_traffic_analyzer.c b/source3/modules/vfs_smb_traffic_analyzer.c
index e8aa385d69c..ddce7e7dc5e 100644
--- a/source3/modules/vfs_smb_traffic_analyzer.c
+++ b/source3/modules/vfs_smb_traffic_analyzer.c
@@ -174,7 +174,7 @@ static char *smb_traffic_analyzer_encrypt( TALLOC_CTX *ctx,
char *output;
unsigned char crypted[18];
if (akey == NULL) return NULL;
- samba_AES_set_encrypt_key((unsigned char *) akey, 128, &key);
+ samba_AES_set_encrypt_key((const unsigned char *) akey, 128, &key);
s1 = strlen(str) / 16;
s2 = strlen(str) % 16;
for (h = 0; h < s2; h++) *(filler+h)=*(str+(s1*16)+h);
@@ -183,10 +183,10 @@ static char *smb_traffic_analyzer_encrypt( TALLOC_CTX *ctx,
output = talloc_array(ctx, char, (s1*16)+17 );
d=0;
for (h = 0; h < s1; h++) {
- samba_AES_encrypt((unsigned char *) str+(16*h), crypted, &key);
+ samba_AES_encrypt((const unsigned char *) str+(16*h), crypted, &key);
for (d = 0; d<16; d++) output[d+(16*h)]=crypted[d];
}
- samba_AES_encrypt( (unsigned char *) str+(16*h), filler, &key );
+ samba_AES_encrypt( (const unsigned char *) str+(16*h), filler, &key );
for (d = 0;d < 16; d++) output[d+(16*h)]=*(filler+d);
*len = (s1*16)+16;
return output;
@@ -417,6 +417,17 @@ static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle,
*/
char state_flags[9] = "000000\0";
+ /**
+ * The first byte of the state flag string represents
+ * the modules protocol subversion number, defined
+ * in smb_traffic_analyzer.h. smbtatools/smbtad are designed
+ * to handle not yet implemented protocol enhancements
+ * by ignoring them. By recognizing the SMBTA_SUBRELEASE
+ * smbtatools can tell the user to update the client
+ * software.
+ */
+ state_flags[0] = SMBTA_SUBRELEASE;
+
SMB_VFS_HANDLE_GET_DATA(handle, rf_sock, struct refcounted_sock, return);
if (rf_sock == NULL || rf_sock->sock == -1) {
@@ -452,7 +463,7 @@ static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle,
"protocol_version", NULL );
- if ( protocol_version == NULL || strcmp( protocol_version,"V1") == 0) {
+ if (protocol_version != NULL && strcmp(protocol_version,"V1") == 0) {
struct rw_data *s_data = (struct rw_data *) data;
@@ -489,7 +500,10 @@ static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle,
return;
}
- } else if ( strcmp( protocol_version, "V2") == 0) {
+ } else {
+ /**
+ * Protocol 2 is used by default.
+ */
switch( vfs_operation ) {
case vfs_id_open: ;
@@ -557,10 +571,6 @@ static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle,
return;
}
- } else {
- DEBUG(1, ("smb_traffic_analyzer_send_data_socket: "
- "error, unknown protocol given!\n"));
- return;
}
if (!str) {
@@ -656,7 +666,7 @@ static int smb_traffic_analyzer_connect(struct vfs_handle_struct *handle,
rf_sock->ref_count++;
} else {
/* New connection. */
- rf_sock = TALLOC_ZERO_P(NULL, struct refcounted_sock);
+ rf_sock = talloc_zero(NULL, struct refcounted_sock);
if (rf_sock == NULL) {
SMB_VFS_NEXT_DISCONNECT(handle);
errno = ENOMEM;
diff --git a/source3/modules/vfs_smb_traffic_analyzer.h b/source3/modules/vfs_smb_traffic_analyzer.h
index bfc0614132d..817ffd83d12 100644
--- a/source3/modules/vfs_smb_traffic_analyzer.h
+++ b/source3/modules/vfs_smb_traffic_analyzer.h
@@ -77,7 +77,7 @@
*/
/* Protocol subrelease number */
-#define SMBTA_SUBRELEASE 0
+#define SMBTA_SUBRELEASE '0'
/*
* Every data block sends a number of blocks sending common data
diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index 01851cd2f83..3569405da30 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -324,7 +324,7 @@ static NTSTATUS stream_smb_fname(vfs_handle_struct *handle,
stype = strchr_m(smb_fname->stream_name + 1, ':');
if (stype) {
- if (StrCaseCmp(stype, ":$DATA") != 0) {
+ if (strcasecmp_m(stype, ":$DATA") != 0) {
return NT_STATUS_INVALID_PARAMETER;
}
}
@@ -716,7 +716,7 @@ static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
{
struct stream_struct *tmp;
- tmp = TALLOC_REALLOC_ARRAY(mem_ctx, *streams, struct stream_struct,
+ tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
(*num_streams)+1);
if (tmp == NULL) {
return false;
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 34e01b0b5f2..2772c96c4d8 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -52,9 +52,9 @@ static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
SMB_ASSERT(upper_sname != NULL);
MD5Init(&ctx);
- MD5Update(&ctx, (unsigned char *)&(sbuf->st_ex_dev),
+ MD5Update(&ctx, (const unsigned char *)&(sbuf->st_ex_dev),
sizeof(sbuf->st_ex_dev));
- MD5Update(&ctx, (unsigned char *)&(sbuf->st_ex_ino),
+ MD5Update(&ctx, (const unsigned char *)&(sbuf->st_ex_ino),
sizeof(sbuf->st_ex_ino));
MD5Update(&ctx, (unsigned char *)upper_sname,
talloc_get_size(upper_sname)-1);
@@ -614,7 +614,7 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
}
/* Don't rename if the streams are identical. */
- if (StrCaseCmp(smb_fname_src->stream_name,
+ if (strcasecmp_m(smb_fname_src->stream_name,
smb_fname_dst->stream_name) == 0) {
goto done;
}
@@ -731,7 +731,7 @@ static bool add_one_stream(TALLOC_CTX *mem_ctx, unsigned int *num_streams,
{
struct stream_struct *tmp;
- tmp = TALLOC_REALLOC_ARRAY(mem_ctx, *streams, struct stream_struct,
+ tmp = talloc_realloc(mem_ctx, *streams, struct stream_struct,
(*num_streams)+1);
if (tmp == NULL) {
return false;
@@ -880,7 +880,7 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
if ((offset + n) > ea.value.length-1) {
uint8 *tmp;
- tmp = TALLOC_REALLOC_ARRAY(talloc_tos(), ea.value.data, uint8,
+ tmp = talloc_realloc(talloc_tos(), ea.value.data, uint8,
offset + n + 1);
if (tmp == NULL) {
@@ -986,7 +986,7 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
return -1;
}
- tmp = TALLOC_REALLOC_ARRAY(talloc_tos(), ea.value.data, uint8,
+ tmp = talloc_realloc(talloc_tos(), ea.value.data, uint8,
offset + 1);
if (tmp == NULL) {
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index 37fe1c6e35b..25332e4e038 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -144,7 +144,7 @@ static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- SHADOW_COPY_DATA *shadow_copy_data,
+ struct shadow_copy_data *shadow_copy_data,
bool labels)
{
int result;
@@ -564,7 +564,7 @@ static SMB_OFF_T smb_time_audit_lseek(vfs_handle_struct *handle,
files_struct *fsp,
SMB_OFF_T offset, int whence)
{
- ssize_t result;
+ SMB_OFF_T result;
struct timespec ts1,ts2;
double timediff;
@@ -721,7 +721,7 @@ static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct *handle,
files_struct *fsp,
const SMB_STRUCT_STAT *sbuf)
{
- int result;
+ uint64_t result;
struct timespec ts1,ts2;
double timediff;
@@ -869,14 +869,14 @@ static int smb_time_audit_chdir(vfs_handle_struct *handle, const char *path)
return result;
}
-static char *smb_time_audit_getwd(vfs_handle_struct *handle, char *path)
+static char *smb_time_audit_getwd(vfs_handle_struct *handle)
{
char *result;
struct timespec ts1,ts2;
double timediff;
clock_gettime_mono(&ts1);
- result = SMB_VFS_NEXT_GETWD(handle, path);
+ result = SMB_VFS_NEXT_GETWD(handle);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
@@ -2216,7 +2216,7 @@ static ssize_t smb_time_audit_aio_return(struct vfs_handle_struct *handle,
struct files_struct *fsp,
SMB_STRUCT_AIOCB *aiocb)
{
- int result;
+ ssize_t result;
struct timespec ts1,ts2;
double timediff;
diff --git a/source3/modules/vfs_tsmsm.c b/source3/modules/vfs_tsmsm.c
index d53d2918322..e9fd83bfea7 100644
--- a/source3/modules/vfs_tsmsm.c
+++ b/source3/modules/vfs_tsmsm.c
@@ -97,7 +97,7 @@ static int tsmsm_connect(struct vfs_handle_struct *handle,
return ret;
}
- tsmd = TALLOC_ZERO_P(handle, struct tsmsm_struct);
+ tsmd = talloc_zero(handle, struct tsmsm_struct);
if (!tsmd) {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(0,("tsmsm_connect: out of memory!\n"));
diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c
index 5b62565d62f..40ccf06dd95 100644
--- a/source3/modules/vfs_xattr_tdb.c
+++ b/source3/modules/vfs_xattr_tdb.c
@@ -24,6 +24,7 @@
#include "librpc/gen_ndr/ndr_xattr.h"
#include "../librpc/gen_ndr/ndr_netlogon.h"
#include "dbwrap.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_VFS
@@ -40,7 +41,7 @@ static NTSTATUS xattr_tdb_pull_attrs(TALLOC_CTX *mem_ctx,
enum ndr_err_code ndr_err;
struct tdb_xattrs *result;
- if (!(result = TALLOC_ZERO_P(mem_ctx, struct tdb_xattrs))) {
+ if (!(result = talloc_zero(mem_ctx, struct tdb_xattrs))) {
return NT_STATUS_NO_MEMORY;
}
@@ -107,7 +108,7 @@ static NTSTATUS xattr_tdb_load_attrs(TALLOC_CTX *mem_ctx,
if (db_ctx->fetch(db_ctx, mem_ctx,
make_tdb_data(id_buf, sizeof(id_buf)),
- &data) == -1) {
+ &data) != 0) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -298,12 +299,12 @@ static int xattr_tdb_setattr(struct db_context *db_ctx,
return -1;
}
- tmp = TALLOC_REALLOC_ARRAY(
+ tmp = talloc_realloc(
attribs, attribs->eas, struct xattr_EA,
attribs->num_eas+ 1);
if (tmp == NULL) {
- DEBUG(0, ("TALLOC_REALLOC_ARRAY failed\n"));
+ DEBUG(0, ("talloc_realloc failed\n"));
TALLOC_FREE(rec);
errno = ENOMEM;
return -1;
@@ -314,7 +315,7 @@ static int xattr_tdb_setattr(struct db_context *db_ctx,
}
attribs->eas[i].name = name;
- attribs->eas[i].value.data = CONST_DISCARD(uint8 *, value);
+ attribs->eas[i].value.data = discard_const_p(uint8, value);
attribs->eas[i].value.length = size;
status = xattr_tdb_save_attrs(rec, attribs);
diff --git a/source3/modules/weird.c b/source3/modules/weird.c
deleted file mode 100644
index 5db8cdcecd1..00000000000
--- a/source3/modules/weird.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba module with developer tools
- Copyright (C) Andrew Tridgell 2001
- Copyright (C) Jelmer Vernooij 2002
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-static struct {
- char from;
- const char *to;
- int len;
-} weird_table[] = {
- {'q', "^q^", 3},
- {'Q', "^Q^", 3},
- {0, NULL}
-};
-
-static size_t weird_pull(void *cd, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft)
-{
- while (*inbytesleft >= 1 && *outbytesleft >= 2) {
- int i;
- int done = 0;
- for (i=0;weird_table[i].from;i++) {
- if (strncmp((*inbuf),
- weird_table[i].to,
- weird_table[i].len) == 0) {
- if (*inbytesleft < weird_table[i].len) {
- DEBUG(0,("ERROR: truncated weird string\n"));
- /* smb_panic("weird_pull"); */
-
- } else {
- (*outbuf)[0] = weird_table[i].from;
- (*outbuf)[1] = 0;
- (*inbytesleft) -= weird_table[i].len;
- (*outbytesleft) -= 2;
- (*inbuf) += weird_table[i].len;
- (*outbuf) += 2;
- done = 1;
- break;
- }
- }
- }
- if (done) continue;
- (*outbuf)[0] = (*inbuf)[0];
- (*outbuf)[1] = 0;
- (*inbytesleft) -= 1;
- (*outbytesleft) -= 2;
- (*inbuf) += 1;
- (*outbuf) += 2;
- }
-
- if (*inbytesleft > 0) {
- errno = E2BIG;
- return -1;
- }
-
- return 0;
-}
-
-static size_t weird_push(void *cd, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft)
-{
- int ir_count=0;
-
- while (*inbytesleft >= 2 && *outbytesleft >= 1) {
- int i;
- int done=0;
- for (i=0;weird_table[i].from;i++) {
- if ((*inbuf)[0] == weird_table[i].from &&
- (*inbuf)[1] == 0) {
- if (*outbytesleft < weird_table[i].len) {
- DEBUG(0,("No room for weird character\n"));
- /* smb_panic("weird_push"); */
- } else {
- memcpy(*outbuf, weird_table[i].to,
- weird_table[i].len);
- (*inbytesleft) -= 2;
- (*outbytesleft) -= weird_table[i].len;
- (*inbuf) += 2;
- (*outbuf) += weird_table[i].len;
- done = 1;
- break;
- }
- }
- }
- if (done) continue;
-
- (*outbuf)[0] = (*inbuf)[0];
- if ((*inbuf)[1]) ir_count++;
- (*inbytesleft) -= 2;
- (*outbytesleft) -= 1;
- (*inbuf) += 2;
- (*outbuf) += 1;
- }
-
- if (*inbytesleft == 1) {
- errno = EINVAL;
- return -1;
- }
-
- if (*inbytesleft > 1) {
- errno = E2BIG;
- return -1;
- }
-
- return ir_count;
-}
-
-struct charset_functions weird_functions = {"WEIRD", weird_pull, weird_push};
-
-NTSTATUS charset_weird_init(void);
-NTSTATUS charset_weird_init(void)
-{
- if (!smb_register_charset(&weird_functions)) {
- return NT_STATUS_INTERNAL_ERROR;
- }
- return NT_STATUS_OK;
-}
diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
index 201610e8a29..8ccc4cac875 100644
--- a/source3/modules/wscript_build
+++ b/source3/modules/wscript_build
@@ -30,6 +30,7 @@ VFS_CACHEPRIME_SRC = 'vfs_cacheprime.c'
VFS_PREALLOC_SRC = 'vfs_prealloc.c'
VFS_COMMIT_SRC = 'vfs_commit.c'
VFS_GPFS_SRC = 'vfs_gpfs.c gpfs.c'
+VFS_GPFS_HSM_NOTIFY_SRC = 'vfs_gpfs_hsm_notify.c'
VFS_NOTIFY_FAM_SRC = 'vfs_notify_fam.c'
VFS_READAHEAD_SRC = 'vfs_readahead.c'
VFS_TSMSM_SRC = 'vfs_tsmsm.c'
@@ -52,7 +53,8 @@ VFS_TIME_AUDIT_SRC = 'vfs_time_audit.c'
bld.SAMBA3_SUBSYSTEM('NFS4_ACLS',
- source='nfs4_acls.c')
+ source='nfs4_acls.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('VFS_AIXACL_UTIL',
source='vfs_aixacl_util.c',
@@ -66,6 +68,7 @@ bld.SAMBA3_SUBSYSTEM('vfs',
bld.SAMBA3_MODULE('vfs_default',
subsystem='vfs',
source=VFS_DEFAULT_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_default'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_default'))
@@ -73,6 +76,7 @@ bld.SAMBA3_MODULE('vfs_default',
bld.SAMBA3_MODULE('vfs_audit',
subsystem='vfs',
source=VFS_AUDIT_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_audit'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_audit'))
@@ -80,6 +84,7 @@ bld.SAMBA3_MODULE('vfs_audit',
bld.SAMBA3_MODULE('vfs_extd_audit',
subsystem='vfs',
source=VFS_EXTD_AUDIT_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_extd_audit'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_extd_audit'))
@@ -87,6 +92,7 @@ bld.SAMBA3_MODULE('vfs_extd_audit',
bld.SAMBA3_MODULE('vfs_full_audit',
subsystem='vfs',
source=VFS_FULL_AUDIT_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_full_audit'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_full_audit'))
@@ -94,7 +100,7 @@ bld.SAMBA3_MODULE('vfs_full_audit',
bld.SAMBA3_MODULE('vfs_fake_perms',
subsystem='vfs',
source=VFS_FAKE_PERMS_SRC,
- deps='acl attr',
+ deps='acl attr samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_fake_perms'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_fake_perms'))
@@ -102,6 +108,7 @@ bld.SAMBA3_MODULE('vfs_fake_perms',
bld.SAMBA3_MODULE('vfs_recycle',
subsystem='vfs',
source=VFS_RECYCLE_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_recycle'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_recycle'))
@@ -109,6 +116,7 @@ bld.SAMBA3_MODULE('vfs_recycle',
bld.SAMBA3_MODULE('vfs_netatalk',
subsystem='vfs',
source=VFS_NETATALK_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_netatalk'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_netatalk'))
@@ -116,6 +124,7 @@ bld.SAMBA3_MODULE('vfs_netatalk',
bld.SAMBA3_MODULE('vfs_default_quota',
subsystem='vfs',
source=VFS_DEFAULT_QUOTA_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_default_quota'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_default_quota'))
@@ -123,6 +132,7 @@ bld.SAMBA3_MODULE('vfs_default_quota',
bld.SAMBA3_MODULE('vfs_readonly',
subsystem='vfs',
source=VFS_READONLY_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_readonly'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_readonly'))
@@ -130,6 +140,7 @@ bld.SAMBA3_MODULE('vfs_readonly',
bld.SAMBA3_MODULE('vfs_cap',
subsystem='vfs',
source=VFS_CAP_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_cap'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_cap'))
@@ -137,6 +148,7 @@ bld.SAMBA3_MODULE('vfs_cap',
bld.SAMBA3_MODULE('vfs_expand_msdfs',
subsystem='vfs',
source=VFS_EXPAND_MSDFS_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_expand_msdfs'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_expand_msdfs'))
@@ -144,6 +156,7 @@ bld.SAMBA3_MODULE('vfs_expand_msdfs',
bld.SAMBA3_MODULE('vfs_shadow_copy',
subsystem='vfs',
source=VFS_SHADOW_COPY_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_shadow_copy'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_shadow_copy'))
@@ -151,6 +164,7 @@ bld.SAMBA3_MODULE('vfs_shadow_copy',
bld.SAMBA3_MODULE('vfs_shadow_copy2',
subsystem='vfs',
source=VFS_SHADOW_COPY2_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_shadow_copy2'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_shadow_copy2'))
@@ -158,6 +172,7 @@ bld.SAMBA3_MODULE('vfs_shadow_copy2',
bld.SAMBA3_MODULE('vfs_afsacl',
subsystem='vfs',
source=VFS_AFSACL_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_afsacl'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_afsacl'))
@@ -233,6 +248,7 @@ bld.SAMBA3_MODULE('vfs_tru64acl',
bld.SAMBA3_MODULE('vfs_catia',
subsystem='vfs',
source=VFS_CATIA_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_catia'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_catia'))
@@ -240,6 +256,7 @@ bld.SAMBA3_MODULE('vfs_catia',
bld.SAMBA3_MODULE('vfs_streams_xattr',
subsystem='vfs',
source=VFS_STREAMS_XATTR_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_streams_xattr'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_streams_xattr'))
@@ -247,6 +264,7 @@ bld.SAMBA3_MODULE('vfs_streams_xattr',
bld.SAMBA3_MODULE('vfs_streams_depot',
subsystem='vfs',
source=VFS_STREAMS_DEPOT_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_streams_depot'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_streams_depot'))
@@ -254,6 +272,7 @@ bld.SAMBA3_MODULE('vfs_streams_depot',
bld.SAMBA3_MODULE('vfs_cacheprime',
subsystem='vfs',
source=VFS_CACHEPRIME_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_cacheprime'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_cacheprime'))
@@ -261,6 +280,7 @@ bld.SAMBA3_MODULE('vfs_cacheprime',
bld.SAMBA3_MODULE('vfs_prealloc',
subsystem='vfs',
source=VFS_PREALLOC_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_prealloc'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_prealloc'))
@@ -268,6 +288,7 @@ bld.SAMBA3_MODULE('vfs_prealloc',
bld.SAMBA3_MODULE('vfs_commit',
subsystem='vfs',
source=VFS_COMMIT_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_commit'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_commit'))
@@ -280,6 +301,13 @@ bld.SAMBA3_MODULE('vfs_gpfs',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_gpfs'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_gpfs'))
+bld.SAMBA3_MODULE('vfs_gpfs_hsm_notify',
+ subsystem='vfs',
+ source=VFS_GPFS_HSM_NOTIFY_SRC,
+ init_function='',
+ internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_gpfs_hsm_notify'),
+ enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_gpfs_hsm_notify'))
+
bld.SAMBA3_MODULE('vfs_notify_fam',
subsystem='vfs',
source=VFS_NOTIFY_FAM_SRC,
@@ -290,6 +318,7 @@ bld.SAMBA3_MODULE('vfs_notify_fam',
bld.SAMBA3_MODULE('vfs_readahead',
subsystem='vfs',
source=VFS_READAHEAD_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_readahead'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_readahead'))
@@ -297,6 +326,7 @@ bld.SAMBA3_MODULE('vfs_readahead',
bld.SAMBA3_MODULE('vfs_tsmsm',
subsystem='vfs',
source=VFS_TSMSM_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_tsmsm'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_tsmsm'))
@@ -304,6 +334,7 @@ bld.SAMBA3_MODULE('vfs_tsmsm',
bld.SAMBA3_MODULE('vfs_fileid',
subsystem='vfs',
source=VFS_FILEID_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_fileid'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_fileid'))
@@ -311,6 +342,7 @@ bld.SAMBA3_MODULE('vfs_fileid',
bld.SAMBA3_MODULE('vfs_aio_fork',
subsystem='vfs',
source=VFS_AIO_FORK_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_aio_fork'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_aio_fork'))
@@ -318,6 +350,7 @@ bld.SAMBA3_MODULE('vfs_aio_fork',
bld.SAMBA3_MODULE('vfs_preopen',
subsystem='vfs',
source=VFS_PREOPEN_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_preopen'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_preopen'))
@@ -325,6 +358,7 @@ bld.SAMBA3_MODULE('vfs_preopen',
bld.SAMBA3_MODULE('vfs_syncops',
subsystem='vfs',
source=VFS_SYNCOPS_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_syncops'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_syncops'))
@@ -332,6 +366,7 @@ bld.SAMBA3_MODULE('vfs_syncops',
bld.SAMBA3_MODULE('vfs_acl_xattr',
subsystem='vfs',
source=VFS_ACL_XATTR_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_acl_xattr'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_acl_xattr'))
@@ -347,6 +382,7 @@ bld.SAMBA3_MODULE('vfs_acl_tdb',
bld.SAMBA3_MODULE('vfs_smb_traffic_analyzer',
subsystem='vfs',
source=VFS_SMB_TRAFFIC_ANALYZER_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_smb_traffic_analyzer'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_smb_traffic_analyzer'))
@@ -354,6 +390,7 @@ bld.SAMBA3_MODULE('vfs_smb_traffic_analyzer',
bld.SAMBA3_MODULE('vfs_onefs',
subsystem='vfs',
source=VFS_ONEFS_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_onefs'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_onefs'))
@@ -361,6 +398,7 @@ bld.SAMBA3_MODULE('vfs_onefs',
bld.SAMBA3_MODULE('vfs_onefs_shadow_copy',
subsystem='vfs',
source=VFS_ONEFS_SHADOW_COPY_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_onefs_shadow_copy'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_onefs_shadow_copy'))
@@ -368,6 +406,7 @@ bld.SAMBA3_MODULE('vfs_onefs_shadow_copy',
bld.SAMBA3_MODULE('vfs_dirsort',
subsystem='vfs',
source=VFS_DIRSORT_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_dirsort'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_dirsort'))
@@ -375,6 +414,7 @@ bld.SAMBA3_MODULE('vfs_dirsort',
bld.SAMBA3_MODULE('vfs_scannedonly',
subsystem='vfs',
source=VFS_SCANNEDONLY_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_scannedonly'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_scannedonly'))
@@ -382,6 +422,7 @@ bld.SAMBA3_MODULE('vfs_scannedonly',
bld.SAMBA3_MODULE('vfs_crossrename',
subsystem='vfs',
source=VFS_CROSSRENAME_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_crossrename'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_crossrename'))
@@ -389,6 +430,7 @@ bld.SAMBA3_MODULE('vfs_crossrename',
bld.SAMBA3_MODULE('vfs_linux_xfs_sgid',
subsystem='vfs',
source=VFS_LINUX_XFS_SGID_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_linux_xfs_sgid'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_linux_xfs_sgid'))
@@ -396,51 +438,13 @@ bld.SAMBA3_MODULE('vfs_linux_xfs_sgid',
bld.SAMBA3_MODULE('vfs_time_audit',
subsystem='vfs',
source=VFS_TIME_AUDIT_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_time_audit'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_time_audit'))
-CHARSET_WEIRD_SRC = 'weird.c'
-CHARSET_CP850_SRC = 'CP850.c'
-CHARSET_CP437_SRC = 'CP437.c'
-CHARSET_MACOSXFS_SRC = 'charset_macosxfs.c'
-
-
-bld.SAMBA3_SUBSYSTEM('charset',
- source='',
- vars=locals())
-
-bld.SAMBA3_MODULE('charset_weird',
- subsystem='charset',
- source=CHARSET_WEIRD_SRC,
- init_function='',
- internal_module=bld.SAMBA3_IS_STATIC_MODULE('charset_weird'),
- enabled=bld.SAMBA3_IS_ENABLED_MODULE('charset_weird'))
-
-bld.SAMBA3_MODULE('charset_CP850',
- subsystem='charset',
- source=CHARSET_CP850_SRC,
- init_function='',
- internal_module=bld.SAMBA3_IS_STATIC_MODULE('charset_CP850'),
- enabled=bld.SAMBA3_IS_ENABLED_MODULE('charset_CP850'))
-
-bld.SAMBA3_MODULE('charset_CP437',
- subsystem='charset',
- source=CHARSET_CP437_SRC,
- init_function='',
- internal_module=bld.SAMBA3_IS_STATIC_MODULE('charset_CP437'),
- enabled=bld.SAMBA3_IS_ENABLED_MODULE('charset_CP437'))
-
-bld.SAMBA3_MODULE('charset_macosxfs',
- subsystem='charset',
- source=CHARSET_MACOSXFS_SRC,
- init_function='',
- internal_module=bld.SAMBA3_IS_STATIC_MODULE('charset_macosxfs'),
- enabled=bld.SAMBA3_IS_ENABLED_MODULE('charset_macosxfs'))
-
-
PERFCOUNT_ONEFS_SRC = 'perfcount_onefs.c'
PERFCOUNT_TEST_SRC = 'perfcount_test.c'
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index f8108d9d52b..d8a4b17a071 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -240,8 +240,8 @@ static void reload_interfaces(time_t t)
continue;
}
- ip = ((struct sockaddr_in *)(void *)&iface->ip)->sin_addr;
- nmask = ((struct sockaddr_in *)(void *)
+ ip = ((const struct sockaddr_in *)(const void *)&iface->ip)->sin_addr;
+ nmask = ((const struct sockaddr_in *)(const void *)
&iface->netmask)->sin_addr;
/*
@@ -250,7 +250,7 @@ static void reload_interfaces(time_t t)
* ignore it here. JRA.
*/
- if (is_loopback_addr((struct sockaddr *)(void *)&iface->ip)) {
+ if (is_loopback_addr((const struct sockaddr *)(const void *)&iface->ip)) {
DEBUG(2,("reload_interfaces: Ignoring loopback "
"interface %s\n",
print_sockaddr(str, sizeof(str), &iface->ip) ));
diff --git a/source3/nmbd/nmbd.h b/source3/nmbd/nmbd.h
index e100e7d6932..47940e19401 100644
--- a/source3/nmbd/nmbd.h
+++ b/source3/nmbd/nmbd.h
@@ -1,6 +1,31 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * NBT netbios routines and daemon - version 2
+ *
+ * Copyright (C) Guenther Deschner 2011
+ *
+ * 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 _NMBD_NMBD_H_
+#define _NMBD_NMBD_H_
+
#ifndef HAVE_PIPE
#define SYNC_DNS 1
#endif
#include "libsmb/nmblib.h"
#include "nmbd/nmbd_proto.h"
+
+#endif /* _NMBD_NMBD_H_ */
diff --git a/source3/nmbd/nmbd_become_dmb.c b/source3/nmbd/nmbd_become_dmb.c
index 160bcb3c339..276c381f6c8 100644
--- a/source3/nmbd/nmbd_become_dmb.c
+++ b/source3/nmbd/nmbd_become_dmb.c
@@ -51,10 +51,10 @@ workgroup %s on subnet %s\n", failname, subrec->subnet_name));
/* Set the state back to DOMAIN_NONE. */
work->dom_state = DOMAIN_NONE;
- if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
+ if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
DEBUG(0,("become_domain_master_fail: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), work->work_group, subrec->subnet_name));
+ lp_netbios_name(), work->work_group, subrec->subnet_name));
return;
}
@@ -92,10 +92,10 @@ workgroup %s on subnet %s\n", regname, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
+ if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
DEBUG(0,("become_domain_master_stage2: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), regname, subrec->subnet_name));
+ lp_netbios_name(), regname, subrec->subnet_name));
work->dom_state = DOMAIN_NONE;
return;
}
@@ -110,7 +110,7 @@ in workgroup %s on subnet %s\n",
subrec->work_changed = True;
if( DEBUGLVL( 0 ) ) {
- dbgtext( "*****\n\nSamba server %s ", global_myname() );
+ dbgtext( "*****\n\nSamba server %s ", lp_netbios_name() );
dbgtext( "is now a domain master browser for " );
dbgtext( "workgroup %s ", work->work_group );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -126,7 +126,7 @@ in workgroup %s on subnet %s\n",
will stop us syncing with ourself if we are also
a local master browser. */
- make_nmb_name(&nmbname, global_myname(), 0x20);
+ make_nmb_name(&nmbname, lp_netbios_name(), 0x20);
work->dmb_name = nmbname;
diff --git a/source3/nmbd/nmbd_become_lmb.c b/source3/nmbd/nmbd_become_lmb.c
index ffd92cf0d8f..f94efd03711 100644
--- a/source3/nmbd/nmbd_become_lmb.c
+++ b/source3/nmbd/nmbd_become_lmb.c
@@ -85,10 +85,10 @@ subnet %s.\n", workgroup_name, subrec->subnet_name ));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
+ if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
DEBUG(0,("reset_workgroup_state: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), work->work_group, subrec->subnet_name));
+ lp_netbios_name(), work->work_group, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -149,7 +149,7 @@ static void unbecome_local_master_success(struct subnet_record *subrec,
if( DEBUGLVL( 0 ) ) {
dbgtext( "*****\n\n" );
- dbgtext( "Samba name server %s ", global_myname() );
+ dbgtext( "Samba name server %s ", lp_netbios_name() );
dbgtext( "has stopped being a local master browser " );
dbgtext( "for workgroup %s ", relname );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -185,7 +185,7 @@ Removing from namelist anyway.\n", nmb_namestr(fail_name)));
if( DEBUGLVL( 0 ) ) {
dbgtext( "*****\n\n" );
- dbgtext( "Samba name server %s ", global_myname() );
+ dbgtext( "Samba name server %s ", lp_netbios_name() );
dbgtext( "has stopped being a local master browser " );
dbgtext( "for workgroup %s ", failname );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -280,10 +280,10 @@ void unbecome_local_master_browser(struct subnet_record *subrec, struct work_rec
DEBUG(2,("unbecome_local_master_browser: unbecoming local master for workgroup %s \
on subnet %s\n",work->work_group, subrec->subnet_name));
- if(find_server_in_workgroup( work, global_myname()) == NULL) {
+ if(find_server_in_workgroup( work, lp_netbios_name()) == NULL) {
DEBUG(0,("unbecome_local_master_browser: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), work->work_group, subrec->subnet_name));
+ lp_netbios_name(), work->work_group, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -342,10 +342,10 @@ workgroup %s on subnet %s\n", regname, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
+ if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
DEBUG(0,("become_local_master_stage2: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), regname, subrec->subnet_name));
+ lp_netbios_name(), regname, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -363,7 +363,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name));
subrec->work_changed = True;
/* Add this name to the workgroup as local master browser. */
- set_workgroup_local_master_browser_name( work, global_myname());
+ set_workgroup_local_master_browser_name( work, lp_netbios_name());
/* Count the number of servers we have on our list. If it's
less than 10 (just a heuristic) request the servers
@@ -396,7 +396,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name));
if( DEBUGLVL( 0 ) ) {
dbgtext( "*****\n\n" );
- dbgtext( "Samba name server %s ", global_myname() );
+ dbgtext( "Samba name server %s ", lp_netbios_name() );
dbgtext( "is now a local master browser " );
dbgtext( "for workgroup %s ", work->work_group );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
@@ -487,10 +487,10 @@ workgroup %s on subnet %s\n", work_name, subrec->subnet_name));
return;
}
- if(find_server_in_workgroup(work, global_myname()) == NULL) {
+ if(find_server_in_workgroup(work, lp_netbios_name()) == NULL) {
DEBUG(0,("become_local_master_fail1: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), work->work_group, subrec->subnet_name));
+ lp_netbios_name(), work->work_group, subrec->subnet_name));
return;
}
@@ -527,10 +527,10 @@ void become_local_master_browser(struct subnet_record *subrec, struct work_recor
return;
}
- if(find_server_in_workgroup( work, global_myname()) == NULL) {
+ if(find_server_in_workgroup( work, lp_netbios_name()) == NULL) {
DEBUG(0,("become_local_master_browser: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), work->work_group, subrec->subnet_name));
+ lp_netbios_name(), work->work_group, subrec->subnet_name));
return;
}
@@ -554,7 +554,7 @@ in workgroup %s on subnet %s\n",
userdata->copy_fn = NULL;
userdata->free_fn = NULL;
userdata->userdata_len = strlen(work->work_group)+1;
- overmalloc_safe_strcpy(userdata->data, work->work_group, size - sizeof(*userdata) - 1);
+ strlcpy(userdata->data, work->work_group, size - sizeof(*userdata));
/* Register the special browser group name. */
register_name(subrec, MSBROWSE, 0x01, samba_nb_type|NB_GROUP,
diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c
index 3dc89b50261..c6ded584e54 100644
--- a/source3/nmbd/nmbd_browsesync.c
+++ b/source3/nmbd/nmbd_browsesync.c
@@ -119,7 +119,7 @@ static void announce_local_master_browser_to_domain_master_browser( struct work_
SCVAL(p,0,ANN_MasterAnnouncement);
p++;
- unstrcpy(myname, global_myname());
+ unstrcpy(myname, lp_netbios_name());
strupper_m(myname);
myname[15]='\0';
/* The call below does CH_UNIX -> CH_DOS conversion. JRA */
@@ -137,7 +137,7 @@ static void announce_local_master_browser_to_domain_master_browser( struct work_
/* Target name for send_mailslot must be in UNIX charset. */
pull_ascii_nstring(dmb_name, sizeof(dmb_name), work->dmb_name.name);
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname(), 0x0, dmb_name, 0x0,
+ lp_netbios_name(), 0x0, dmb_name, 0x0,
work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT);
}
@@ -330,7 +330,7 @@ static void find_domain_master_name_query_success(struct subnet_record *subrec,
userdata->copy_fn = NULL;
userdata->free_fn = NULL;
userdata->userdata_len = strlen(work->work_group)+1;
- overmalloc_safe_strcpy(userdata->data, work->work_group, size - sizeof(*userdata) - 1);
+ strlcpy(userdata->data, work->work_group, size - sizeof(*userdata));
node_status( subrec, &nmbname, answer_ip,
domain_master_node_status_success,
@@ -435,7 +435,7 @@ static void get_domain_master_name_node_status_success(struct subnet_record *sub
if(!(nb_flags & NB_GROUP) && (name_type == 0x00) &&
server_name[0] == 0) {
/* this is almost certainly the server netbios name */
- unstrcpy(server_name, qname);
+ strlcpy(server_name, qname, sizeof(server_name));
continue;
}
@@ -461,7 +461,9 @@ static void get_domain_master_name_node_status_success(struct subnet_record *sub
return;
/* remember who the master is */
- unstrcpy(work->local_master_browser_name, server_name);
+ strlcpy(work->local_master_browser_name,
+ server_name,
+ sizeof(work->local_master_browser_name));
make_nmb_name(&nmbname, server_name, 0x20);
work->dmb_name = nmbname;
work->dmb_addr = from_ip;
diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c
index 899c273fe08..ac0d8735120 100644
--- a/source3/nmbd/nmbd_elections.c
+++ b/source3/nmbd/nmbd_elections.c
@@ -57,7 +57,7 @@ static void send_election_dgram(struct subnet_record *subrec, const char *workgr
p = skip_string(outbuf,sizeof(outbuf),p);
send_mailslot(False, BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf),
- global_myname(), 0,
+ lp_netbios_name(), 0,
workgroup_name, 0x1e,
subrec->bcast_ip, subrec->myip, DGRAM_PORT);
}
@@ -194,7 +194,7 @@ yet registered on subnet %s\n", nmb_namestr(&nmbname), subrec->subnet_name ));
}
send_election_dgram(subrec, work->work_group, work->ElectionCriterion,
- t - StartupTime, global_myname());
+ t - StartupTime, lp_netbios_name());
if (work->ElectionCount++ >= 4) {
/* Won election (4 packets were sent out uncontested. */
@@ -231,7 +231,7 @@ static bool win_election(struct work_record *work, int version,
version, ELECTION_VERSION,
criterion, mycriterion,
timeup, mytimeup,
- server_name, global_myname()));
+ server_name, lp_netbios_name()));
if (version > ELECTION_VERSION)
return(False);
@@ -248,7 +248,7 @@ static bool win_election(struct work_record *work, int version,
if (timeup < mytimeup)
return(True);
- if (StrCaseCmp(global_myname(), server_name) > 0)
+ if (strcasecmp_m(lp_netbios_name(), server_name) > 0)
return(False);
return(True);
@@ -258,7 +258,7 @@ static bool win_election(struct work_record *work, int version,
Process an incoming election datagram packet.
******************************************************************/
-void process_election(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf)
{
struct dgram_packet *dgram = &p->packet.dgram;
int version = CVAL(buf,0);
diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c
index 6993e183583..582848c1fcf 100644
--- a/source3/nmbd/nmbd_incomingdgrams.c
+++ b/source3/nmbd/nmbd_incomingdgrams.c
@@ -95,7 +95,7 @@ void tell_become_backup(void)
Process an incoming host announcement packet.
*******************************************************************/
-void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf)
{
struct dgram_packet *dgram = &p->packet.dgram;
int ttl = IVAL(buf,1)/1000;
@@ -144,7 +144,7 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
* to be our primary workgroup name.
*/
- if(strequal(work_name, global_myname()))
+ if(strequal(work_name, lp_netbios_name()))
unstrcpy(work_name,lp_workgroup());
/*
@@ -172,7 +172,7 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
/* Update the record. */
servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
update_server_ttl( servrec, ttl);
- fstrcpy(servrec->serv.comment,comment);
+ strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
}
} else {
/*
@@ -195,7 +195,7 @@ done:
Process an incoming WORKGROUP announcement packet.
*******************************************************************/
-void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf)
{
struct dgram_packet *dgram = &p->packet.dgram;
int ttl = IVAL(buf,1)/1000;
@@ -252,7 +252,7 @@ done:
Process an incoming local master browser announcement packet.
*******************************************************************/
-void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf)
{
struct dgram_packet *dgram = &p->packet.dgram;
int ttl = IVAL(buf,1)/1000;
@@ -338,7 +338,7 @@ a local master browser for workgroup %s and we think we are master. Forcing elec
/* Update the record. */
servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
update_server_ttl(servrec, ttl);
- fstrcpy(servrec->serv.comment,comment);
+ strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
}
set_workgroup_local_master_browser_name( work, server_name );
@@ -367,7 +367,7 @@ done:
******************************************************************/
void process_master_browser_announce(struct subnet_record *subrec,
- struct packet_struct *p,char *buf)
+ struct packet_struct *p,const char *buf)
{
unstring local_master_name;
struct work_record *work;
@@ -418,7 +418,7 @@ done:
Process an incoming LanMan host announcement packet.
*******************************************************************/
-void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len)
+void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len)
{
struct dgram_packet *dgram = &p->packet.dgram;
uint32 servertype = IVAL(buf,1);
@@ -431,7 +431,7 @@ void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct
unstring work_name;
unstring source_name;
fstring comment;
- char *s = get_safe_str_ptr(buf,len,buf,9);
+ char *s = get_safe_str_ptr(buf,len,discard_const_p(char, buf),9);
START_PROFILE(lm_host_announce);
if (!s) {
@@ -484,7 +484,7 @@ originate from OS/2 Warp client. Ignoring packet.\n"));
* not needed in the LanMan announce code, but it won't hurt.
*/
- if(strequal(work_name, global_myname()))
+ if(strequal(work_name, lp_netbios_name()))
unstrcpy(work_name,lp_workgroup());
/*
@@ -512,7 +512,7 @@ originate from OS/2 Warp client. Ignoring packet.\n"));
/* Update the record. */
servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
update_server_ttl( servrec, ttl);
- fstrcpy(servrec->serv.comment,comment);
+ strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
}
} else {
/*
@@ -571,7 +571,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
/* We always return at least one name - our own. */
count = 1;
- unstrcpy(myname, global_myname());
+ unstrcpy(myname, lp_netbios_name());
strupper_m(myname);
myname[15]='\0';
push_ascii(p, myname, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE);
@@ -599,7 +599,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
if(count >= (unsigned int)max_number_requested)
break;
- if(strnequal(servrec->serv.name, global_myname(),15))
+ if(strnequal(servrec->serv.name, lp_netbios_name(),15))
continue;
if(!(servrec->serv.type & SV_TYPE_BACKUP_BROWSER))
@@ -625,7 +625,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
send_mailslot(True, BROWSE_MAILSLOT,
outbuf,PTR_DIFF(p,outbuf),
- global_myname(), 0,
+ lp_netbios_name(), 0,
send_to_namestr,0,
sendto_ip, subrec->myip, port);
}
@@ -641,7 +641,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
********************************************************************/
void process_get_backup_list_request(struct subnet_record *subrec,
- struct packet_struct *p,char *buf)
+ struct packet_struct *p,const char *buf)
{
struct dgram_packet *dgram = &p->packet.dgram;
struct work_record *work;
@@ -724,7 +724,7 @@ done:
******************************************************************/
void process_reset_browser(struct subnet_record *subrec,
- struct packet_struct *p,char *buf)
+ struct packet_struct *p,const char *buf)
{
struct dgram_packet *dgram = &p->packet.dgram;
int state = CVAL(buf,0);
@@ -776,7 +776,7 @@ request from %s IP %s state=0x%X\n",
announcement is needed soon.
******************************************************************/
-void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf)
{
struct dgram_packet *dgram = &p->packet.dgram;
struct work_record *work;
@@ -817,7 +817,7 @@ done:
through the "lm announce" parameter in smb.conf)
******************************************************************/
-void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len)
+void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len)
{
struct dgram_packet *dgram = &p->packet.dgram;
unstring workgroup_name;
diff --git a/source3/nmbd/nmbd_incomingrequests.c b/source3/nmbd/nmbd_incomingrequests.c
index d0138ddd4a9..b2545f102fc 100644
--- a/source3/nmbd/nmbd_incomingrequests.c
+++ b/source3/nmbd/nmbd_incomingrequests.c
@@ -290,14 +290,14 @@ static int status_compare(char *n1,char *n2)
;
for (l2=0;l2<15 && n2[l2] && n2[l2] != ' ';l2++)
;
- l3 = strlen(global_myname());
+ l3 = strlen(lp_netbios_name());
- if ((l1==l3) && strncmp(n1,global_myname(),l3) == 0 &&
- (l2!=l3 || strncmp(n2,global_myname(),l3) != 0))
+ if ((l1==l3) && strncmp(n1,lp_netbios_name(),l3) == 0 &&
+ (l2!=l3 || strncmp(n2,lp_netbios_name(),l3) != 0))
return -1;
- if ((l2==l3) && strncmp(n2,global_myname(),l3) == 0 &&
- (l1!=l3 || strncmp(n1,global_myname(),l3) != 0))
+ if ((l2==l3) && strncmp(n2,lp_netbios_name(),l3) == 0 &&
+ (l1!=l3 || strncmp(n1,lp_netbios_name(),l3) != 0))
return 1;
return memcmp(n1,n2,sizeof(name1));
diff --git a/source3/nmbd/nmbd_logonnames.c b/source3/nmbd/nmbd_logonnames.c
index f99092055bb..9a05095bfd0 100644
--- a/source3/nmbd/nmbd_logonnames.c
+++ b/source3/nmbd/nmbd_logonnames.c
@@ -46,10 +46,10 @@ workgroup %s on subnet %s\n", failname, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
+ if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
DEBUG(0,("become_logon_server_fail: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), failname, subrec->subnet_name));
+ lp_netbios_name(), failname, subrec->subnet_name));
work->log_state = LOGON_NONE;
return;
}
@@ -87,10 +87,10 @@ workgroup %s on subnet %s\n", reg_name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
+ if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
DEBUG(0,("become_logon_server_success: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), reg_name, subrec->subnet_name));
+ lp_netbios_name(), reg_name, subrec->subnet_name));
work->log_state = LOGON_NONE;
return;
}
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index 36dacfb6f31..a89f49c8fc9 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -23,6 +23,7 @@
#include "nmbd/nmbd.h"
#include "../lib/util/select.h"
#include "system/select.h"
+#include "libsmb/libsmb.h"
extern int ClientNMB;
extern int ClientDGRAM;
@@ -108,7 +109,7 @@ void set_nb_flags(char *buf, uint16 nb_flags)
Dumps out the browse packet data.
**************************************************************************/
-static void debug_browse_data(char *outbuf, int len)
+static void debug_browse_data(const char *outbuf, int len)
{
int i,j;
@@ -1062,7 +1063,7 @@ static struct subnet_record *find_subnet_for_dgram_browse_packet(struct packet_s
Dispatch a browse frame from port 138 to the correct processing function.
****************************************************************************/
-static void process_browse_packet(struct packet_struct *p, char *buf,int len)
+static void process_browse_packet(struct packet_struct *p, const char *buf,int len)
{
struct dgram_packet *dgram = &p->packet.dgram;
int command = CVAL(buf,0);
@@ -1072,9 +1073,9 @@ static void process_browse_packet(struct packet_struct *p, char *buf,int len)
/* Drop the packet if it's a different NetBIOS scope, or the source is from one of our names. */
pull_ascii(scope, dgram->dest_name.scope, 64, 64, STR_TERMINATE);
- if (!strequal(scope, global_scope())) {
+ if (!strequal(scope, lp_netbios_scope())) {
DEBUG(7,("process_browse_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, global_scope()));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, lp_netbios_scope()));
return;
}
@@ -1149,7 +1150,7 @@ command code %d from %s IP %s to %s\n", subrec->subnet_name, command, nmb_namest
Dispatch a LanMan browse frame from port 138 to the correct processing function.
****************************************************************************/
-static void process_lanman_packet(struct packet_struct *p, char *buf,int len)
+static void process_lanman_packet(struct packet_struct *p, const char *buf,int len)
{
struct dgram_packet *dgram = &p->packet.dgram;
int command = SVAL(buf,0);
@@ -1160,9 +1161,9 @@ static void process_lanman_packet(struct packet_struct *p, char *buf,int len)
/* Drop the packet if it's a different NetBIOS scope, or the source is from one of our names. */
pull_ascii(scope, dgram->dest_name.scope, 64, 64, STR_TERMINATE);
- if (!strequal(scope, global_scope())) {
+ if (!strequal(scope, lp_netbios_scope())) {
DEBUG(7,("process_lanman_packet: Discarding datagram from IP %s. Scope (%s) \
-mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, global_scope()));
+mismatch with our scope (%s).\n", inet_ntoa(p->ip), scope, lp_netbios_scope()));
return;
}
@@ -1216,8 +1217,8 @@ static bool listening(struct packet_struct *p,struct nmb_name *nbname)
static void process_dgram(struct packet_struct *p)
{
- char *buf;
- char *buf2;
+ const char *buf;
+ const char *buf2;
int len;
struct dgram_packet *dgram = &p->packet.dgram;
@@ -1290,28 +1291,28 @@ packet sent to name %s from IP %s\n",
DEBUG(4,("process_dgram: datagram from %s to %s IP %s for %s of type %d len=%d\n",
nmb_namestr(&dgram->source_name),nmb_namestr(&dgram->dest_name),
- inet_ntoa(p->ip), smb_buf(buf),CVAL(buf2,0),len));
+ inet_ntoa(p->ip), smb_buf_const(buf),CVAL(buf2,0),len));
/* Datagram packet received for the browser mailslot */
- if (strequal(smb_buf(buf),BROWSE_MAILSLOT)) {
+ if (strequal(smb_buf_const(buf),BROWSE_MAILSLOT)) {
process_browse_packet(p,buf2,len);
return;
}
/* Datagram packet received for the LAN Manager mailslot */
- if (strequal(smb_buf(buf),LANMAN_MAILSLOT)) {
+ if (strequal(smb_buf_const(buf),LANMAN_MAILSLOT)) {
process_lanman_packet(p,buf2,len);
return;
}
/* Datagram packet received for the domain logon mailslot */
- if (strequal(smb_buf(buf),NET_LOGON_MAILSLOT)) {
+ if (strequal(smb_buf_const(buf),NET_LOGON_MAILSLOT)) {
process_logon_packet(p,buf2,len,NET_LOGON_MAILSLOT);
return;
}
/* Datagram packet received for the NT domain logon mailslot */
- if (strequal(smb_buf(buf),NT_LOGON_MAILSLOT)) {
+ if (strequal(smb_buf_const(buf),NT_LOGON_MAILSLOT)) {
process_logon_packet(p,buf2,len,NT_LOGON_MAILSLOT);
return;
}
@@ -1706,14 +1707,14 @@ static bool create_listen_pollfds(struct pollfd **pfds,
}
}
- fds = TALLOC_ZERO_ARRAY(NULL, struct pollfd, count);
+ fds = talloc_zero_array(NULL, struct pollfd, count);
if (fds == NULL) {
DEBUG(1, ("create_listen_pollfds: malloc fail for fds. "
"size %d\n", count));
return true;
}
- attrs = TALLOC_ARRAY(NULL, struct socket_attributes, count);
+ attrs = talloc_array(NULL, struct socket_attributes, count);
if (fds == NULL) {
DEBUG(1, ("create_listen_pollfds: malloc fail for attrs. "
"size %d\n", count));
@@ -1884,7 +1885,7 @@ bool listen_for_packets(bool run_election)
* create_listen_pollfds.
*/
- fds = TALLOC_REALLOC_ARRAY(NULL, fds, struct pollfd, listen_number);
+ fds = talloc_realloc(NULL, fds, struct pollfd, listen_number);
if (fds == NULL) {
return true;
}
@@ -1893,7 +1894,7 @@ bool listen_for_packets(bool run_election)
#ifndef SYNC_DNS
dns_fd = asyncdns_fd();
if (dns_fd != -1) {
- fds = TALLOC_REALLOC_ARRAY(NULL, fds, struct pollfd, num_sockets+1);
+ fds = talloc_realloc(NULL, fds, struct pollfd, num_sockets+1);
if (fds == NULL) {
return true;
}
@@ -2087,7 +2088,7 @@ bool send_mailslot(bool unique, const char *mailslot,char *buf, size_t len,
SSVAL(ptr,smb_vwv15,1);
SSVAL(ptr,smb_vwv16,2);
p2 = smb_buf(ptr);
- safe_strcpy_base(p2, mailslot, dgram->data, sizeof(dgram->data));
+ strlcpy_base(p2, mailslot, dgram->data, sizeof(dgram->data));
p2 = skip_string(ptr,MAX_DGRAM_SIZE,p2);
if (((p2+len) > dgram->data+sizeof(dgram->data)) || ((p2+len) < p2)) {
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index 79768176647..2adc81d76e1 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -157,7 +157,7 @@ static void nmbd_proxy_logon_done(struct tevent_req *subreq);
static void nmbd_proxy_logon(struct nmbd_proxy_logon_context *ctx,
struct in_addr local_ip,
struct packet_struct *p,
- uint8_t *buf,
+ const uint8_t *buf,
uint32_t len)
{
struct nmbd_proxy_logon_state *state;
@@ -173,7 +173,7 @@ static void nmbd_proxy_logon(struct nmbd_proxy_logon_context *ctx,
fstring source_name;
struct dgram_packet *dgram = &p->packet.dgram;
- state = TALLOC_ZERO_P(ctx, struct nmbd_proxy_logon_state);
+ state = talloc_zero(ctx, struct nmbd_proxy_logon_state);
if (!state) {
DEBUG(0,("failed to allocate nmbd_proxy_logon_state\n"));
return;
@@ -291,7 +291,7 @@ static void nmbd_proxy_logon_done(struct tevent_req *subreq)
send_mailslot(true, state->remote_mailslot,
(char *)response.data, response.length,
- global_myname(), 0x0,
+ lp_netbios_name(), 0x0,
state->remote_name,
state->remote_name_type,
state->p->ip,
@@ -304,7 +304,7 @@ static void nmbd_proxy_logon_done(struct tevent_req *subreq)
Process a domain logon packet
**************************************************************************/
-void process_logon_packet(struct packet_struct *p, char *buf,int len,
+void process_logon_packet(struct packet_struct *p, const char *buf,int len,
const char *mailslot)
{
fstring source_name;
@@ -328,7 +328,7 @@ void process_logon_packet(struct packet_struct *p, char *buf,int len,
inet_ntoa(p->ip) ));
return;
}
- ip = ((struct sockaddr_in *)pss)->sin_addr;
+ ip = ((const struct sockaddr_in *)pss)->sin_addr;
if (!lp_domain_logons()) {
DEBUG(5,("process_logon_packet: Logon packet received from IP %s and domain \
@@ -338,7 +338,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
- pdc_name = talloc_asprintf(talloc_tos(), "\\\\%s", global_myname());
+ pdc_name = talloc_asprintf(talloc_tos(), "\\\\%s", lp_netbios_name());
if (!pdc_name) {
return;
}
@@ -391,7 +391,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
send_mailslot(True, request.req.logon0.mailslot_name,
(char *)blob_out.data,
blob_out.length,
- global_myname(), 0x0,
+ lp_netbios_name(), 0x0,
source_name,
dgram->source_name.name_type,
p->ip, ip, p->port);
@@ -411,7 +411,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
"reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
request.req.pdc.computer_name,
inet_ntoa(p->ip),
- global_myname(),
+ lp_netbios_name(),
lp_workgroup(),
NETLOGON_RESPONSE_FROM_PDC,
request.req.pdc.nt_version,
@@ -419,9 +419,9 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
request.req.pdc.lm20_token));
get_pdc.command = NETLOGON_RESPONSE_FROM_PDC;
- get_pdc.pdc_name = global_myname();
+ get_pdc.pdc_name = lp_netbios_name();
get_pdc._pad = data_blob_null;
- get_pdc.unicode_pdc_name = global_myname();
+ get_pdc.unicode_pdc_name = lp_netbios_name();
get_pdc.domain_name = lp_workgroup();
get_pdc.nt_version = NETLOGON_NT_VERSION_1;
get_pdc.lmnt_token = 0xffff;
@@ -443,7 +443,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
send_mailslot(True, request.req.pdc.mailslot_name,
(char *)blob_out.data,
blob_out.length,
- global_myname(), 0x0,
+ lp_netbios_name(), 0x0,
source_name,
dgram->source_name.name_type,
p->ip, ip, p->port);
@@ -459,7 +459,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
if (global_nmbd_proxy_logon) {
nmbd_proxy_logon(global_nmbd_proxy_logon,
- ip, p, (uint8_t *)buf, len);
+ ip, p, (const uint8_t *)buf, len);
return;
}
@@ -553,7 +553,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
nt5_ex.dns_domain = domain;
nt5_ex.pdc_dns_name = hostname;
nt5_ex.domain_name = lp_workgroup();
- nt5_ex.pdc_name = global_myname();
+ nt5_ex.pdc_name = lp_netbios_name();
nt5_ex.user_name = request.req.logon.user_name;
nt5_ex.server_site = "Default-First-Site-Name";
nt5_ex.client_site = "Default-First-Site-Name";
@@ -604,8 +604,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
source_name, source_addr,
lp_init_logon_delay()));
- when = timeval_current_ofs(0,
- lp_init_logon_delay() * 1000);
+ when = timeval_current_ofs_msec(lp_init_logon_delay());
p->locked = true;
event_add_timed(nmbd_event_context(),
NULL,
@@ -622,7 +621,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
send_mailslot(true, request.req.logon.mailslot_name,
(char *)blob_out.data,
blob_out.length,
- global_myname(), 0x0,
+ lp_netbios_name(), 0x0,
source_name,
dgram->source_name.name_type,
p->ip, ip, p->port);
diff --git a/source3/nmbd/nmbd_proto.h b/source3/nmbd/nmbd_proto.h
index b58ca41e5a0..0258b4a478b 100644
--- a/source3/nmbd/nmbd_proto.h
+++ b/source3/nmbd/nmbd_proto.h
@@ -1,3 +1,28 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * NBT netbios routines and daemon - version 2
+ *
+ * Copyright (C) Andrew Tridgell 1994-1998
+ * Copyright (C) Jeremy Allison 1994-2005
+ * Copyright (C) Luke Kenneth Casson Leighton 1994-1998
+ * Copyright (C) John H Terpstra 1995-1998
+ * Copyright (C) Christopher R. Hertel 1998
+ * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
+ * Copyright (C) Jelmer Vernooij 2002,2003
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
/* The following definitions come from nmbd/asyncdns.c */
@@ -48,7 +73,7 @@ void sync_all_dmbs(time_t t);
void check_master_browser_exists(time_t t);
void run_elections(time_t t);
-void process_election(struct subnet_record *subrec, struct packet_struct *p, char *buf);
+void process_election(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
bool check_elections(void);
void nmbd_message_election(struct messaging_context *msg,
void *private_data,
@@ -59,18 +84,18 @@ void nmbd_message_election(struct messaging_context *msg,
/* The following definitions come from nmbd/nmbd_incomingdgrams.c */
void tell_become_backup(void);
-void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf);
-void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf);
-void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf);
+void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
+void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
+void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
void process_master_browser_announce(struct subnet_record *subrec,
- struct packet_struct *p,char *buf);
-void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len);
+ struct packet_struct *p,const char *buf);
+void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len);
void process_get_backup_list_request(struct subnet_record *subrec,
- struct packet_struct *p,char *buf);
+ struct packet_struct *p,const char *buf);
void process_reset_browser(struct subnet_record *subrec,
- struct packet_struct *p,char *buf);
-void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf);
-void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len);
+ struct packet_struct *p,const char *buf);
+void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf);
+void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len);
/* The following definitions come from nmbd/nmbd_incomingrequests.c */
@@ -250,7 +275,7 @@ bool send_mailslot(bool unique, const char *mailslot,char *buf, size_t len,
bool initialize_nmbd_proxy_logon(void);
-void process_logon_packet(struct packet_struct *p, char *buf,int len,
+void process_logon_packet(struct packet_struct *p, const char *buf,int len,
const char *mailslot);
/* The following definitions come from nmbd/nmbd_responserecordsdb.c */
diff --git a/source3/nmbd/nmbd_sendannounce.c b/source3/nmbd/nmbd_sendannounce.c
index e04e1f6fe3c..39e63d29abb 100644
--- a/source3/nmbd/nmbd_sendannounce.c
+++ b/source3/nmbd/nmbd_sendannounce.c
@@ -50,7 +50,7 @@ void send_browser_reset(int reset_type, const char *to_name, int to_type, struct
p++;
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname(), 0x0, to_name, to_type, to_ip,
+ lp_netbios_name(), 0x0, to_name, to_type, to_ip,
FIRST_SUBNET->myip, DGRAM_PORT);
}
@@ -76,10 +76,10 @@ to subnet %s\n", work->work_group, subrec->subnet_name));
SCVAL(p,0,work->token); /* (local) Unique workgroup token id. */
p++;
- p += push_string_check(p+1, global_myname(), 15, STR_ASCII|STR_UPPER|STR_TERMINATE);
+ p += push_string_check(p+1, lp_netbios_name(), 15, STR_ASCII|STR_UPPER|STR_TERMINATE);
send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname(), 0x0, work->work_group,0x1e, subrec->bcast_ip,
+ lp_netbios_name(), 0x0, work->work_group,0x1e, subrec->bcast_ip,
subrec->myip, DGRAM_PORT);
}
@@ -105,12 +105,12 @@ static void send_announcement(struct subnet_record *subrec, int announce_type,
SCVAL(p,0,updatecount);
SIVAL(p,1,announce_interval*1000); /* Milliseconds - despite the spec. */
- safe_strcpy(upper_server_name, server_name, sizeof(upper_server_name)-1);
+ strlcpy(upper_server_name, server_name ? server_name : "", sizeof(upper_server_name));
strupper_m(upper_server_name);
push_string_check(p+5, upper_server_name, 16, STR_ASCII|STR_TERMINATE);
- SCVAL(p,21,lp_major_announce_version()); /* Major version. */
- SCVAL(p,22,lp_minor_announce_version()); /* Minor version. */
+ SCVAL(p,21,SAMBA_MAJOR_NBT_ANNOUNCE_VERSION); /* Major version. */
+ SCVAL(p,22,SAMBA_MINOR_NBT_ANNOUNCE_VERSION); /* Minor version. */
SIVAL(p,23,server_type & ~SV_TYPE_LOCAL_LIST_ONLY);
/* Browse version: got from NT/AS 4.00 - Value defined in smb.h (JHT). */
@@ -140,8 +140,8 @@ static void send_lm_announcement(struct subnet_record *subrec, int announce_type
SSVAL(p,0,announce_type);
SIVAL(p,2,server_type & ~SV_TYPE_LOCAL_LIST_ONLY);
- SCVAL(p,6,lp_major_announce_version()); /* Major version. */
- SCVAL(p,7,lp_minor_announce_version()); /* Minor version. */
+ SCVAL(p,6,SAMBA_MAJOR_NBT_ANNOUNCE_VERSION); /* Major version. */
+ SCVAL(p,7,SAMBA_MINOR_NBT_ANNOUNCE_VERSION); /* Minor version. */
SSVAL(p,8,announce_interval); /* In seconds - according to spec. */
p += 10;
@@ -164,14 +164,14 @@ static void send_local_master_announcement(struct subnet_record *subrec, struct
uint32 type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n",
- type, global_myname(), subrec->subnet_name, work->work_group));
+ type, lp_netbios_name(), subrec->subnet_name, work->work_group));
send_announcement(subrec, ANN_LocalMasterAnnouncement,
- global_myname(), /* From nbt name. */
+ lp_netbios_name(), /* From nbt name. */
work->work_group, 0x1e, /* To nbt name. */
subrec->bcast_ip, /* To ip. */
work->announce_interval, /* Time until next announce. */
- global_myname(), /* Name to announce. */
+ lp_netbios_name(), /* Name to announce. */
type, /* Type field. */
servrec->serv.comment);
}
@@ -186,13 +186,13 @@ static void send_workgroup_announcement(struct subnet_record *subrec, struct wor
subrec->subnet_name, work->work_group));
send_announcement(subrec, ANN_DomainAnnouncement,
- global_myname(), /* From nbt name. */
+ lp_netbios_name(), /* From nbt name. */
MSBROWSE, 0x1, /* To nbt name. */
subrec->bcast_ip, /* To ip. */
work->announce_interval, /* Time until next announce. */
work->work_group, /* Name to announce. */
SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT, /* workgroup announce flags. */
- global_myname()); /* From name as comment. */
+ lp_netbios_name()); /* From name as comment. */
}
/****************************************************************************
@@ -251,7 +251,7 @@ static void announce_server(struct subnet_record *subrec, struct work_record *wo
/* Only do domain announcements if we are a master and it's
our primary name we're being asked to announce. */
- if (AM_LOCAL_MASTER_BROWSER(work) && strequal(global_myname(),servrec->serv.name)) {
+ if (AM_LOCAL_MASTER_BROWSER(work) && strequal(lp_netbios_name(),servrec->serv.name)) {
send_local_master_announcement(subrec, work, servrec);
send_workgroup_announcement(subrec, work);
} else {
@@ -566,7 +566,7 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
SCVAL(p,0,ANN_MasterAnnouncement);
p++;
- unstrcpy(myname, global_myname());
+ unstrcpy(myname, lp_netbios_name());
strupper_m(myname);
myname[15]='\0';
push_ascii(p, myname, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE);
@@ -579,10 +579,10 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
addr = interpret_addr2(s2);
DEBUG(5,("announce_remote: Doing remote browse sync announce for server %s to IP %s.\n",
- global_myname(), inet_ntoa(addr) ));
+ lp_netbios_name(), inet_ntoa(addr) ));
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
+ lp_netbios_name(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
}
TALLOC_FREE(frame);
}
diff --git a/source3/nmbd/nmbd_subnetdb.c b/source3/nmbd/nmbd_subnetdb.c
index 3a60038dcdc..666679a90b4 100644
--- a/source3/nmbd/nmbd_subnetdb.c
+++ b/source3/nmbd/nmbd_subnetdb.c
@@ -296,7 +296,7 @@ bool create_subnets(void)
* ignore it here. JRA.
*/
- if (is_loopback_addr((struct sockaddr *)&iface->ip)) {
+ if (is_loopback_addr((const struct sockaddr *)&iface->ip)) {
DEBUG(2,("create_subnets: Ignoring loopback interface.\n" ));
continue;
}
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index fc2b25edcae..964975e1a52 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -4,20 +4,19 @@
Copyright (C) Andrew Tridgell 1994-1998
Copyright (C) Luke Kenneth Casson Leighton 1994-1998
Copyright (C) Jeremy Allison 1994-1998
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-
*/
/* this file handles asynchronous browse synchronisation requests. The
@@ -30,6 +29,7 @@
#include "system/filesys.h"
#include "../librpc/gen_ndr/svcctl.h"
#include "nmbd/nmbd.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "smbprofile.h"
@@ -72,7 +72,6 @@ static void sync_child(char *name, int nm_type,
fstring unix_workgroup;
struct cli_state *cli;
uint32 local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
- struct nmb_name called, calling;
struct sockaddr_storage ss;
NTSTATUS status;
@@ -80,25 +79,12 @@ static void sync_child(char *name, int nm_type,
* Patch from Andy Levine andyl@epicrealm.com.
*/
- cli = cli_initialise();
- if (!cli) {
- return;
- }
-
- cli_set_port(cli, 139);
-
in_addr_to_sockaddr_storage(&ss, ip);
- status = cli_connect(cli, name, &ss);
- if (!NT_STATUS_IS_OK(status)) {
- cli_shutdown(cli);
- return;
- }
-
- make_nmb_name(&calling, get_local_machine_name(), 0x0);
- make_nmb_name(&called , name, nm_type);
- if (!cli_session_request(cli, &calling, &called)) {
- cli_shutdown(cli);
+ status = cli_connect_nb(name, &ss, 139, nm_type,
+ get_local_machine_name(), Undefined,
+ &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return;
}
@@ -126,7 +112,7 @@ static void sync_child(char *name, int nm_type,
cli_NetServerEnum(cli, unix_workgroup,
local_type|SV_TYPE_DOMAIN_ENUM,
callback, NULL);
-
+
/* Now fetch a server list. */
if (servers) {
fstrcpy(unix_workgroup, workgroup);
@@ -134,7 +120,7 @@ static void sync_child(char *name, int nm_type,
local?SV_TYPE_LOCAL_LIST_ONLY:SV_TYPE_ALL,
callback, NULL);
}
-
+
cli_shutdown(cli);
}
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index 976b99023eb..50cdc0acf93 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "nmbd/nmbd.h"
+#include "util_tdb.h"
#define WINS_LIST "wins.dat"
#define WINS_VERSION 1
@@ -74,7 +75,7 @@ static void wins_delete_all_1b_in_memory_records(void)
}
/****************************************************************************
- Convert a wins.tdb record to a struct name_record. Add in our global_scope().
+ Convert a wins.tdb record to a struct name_record. Add in our lp_netbios_scope().
*****************************************************************************/
static struct name_record *wins_record_to_name_record(TDB_DATA key, TDB_DATA data)
@@ -127,7 +128,7 @@ static struct name_record *wins_record_to_name_record(TDB_DATA key, TDB_DATA dat
push_ascii_nstring(namerec->name.name, (const char *)key.dptr);
namerec->name.name_type = key.dptr[sizeof(unstring)];
/* Add the scope. */
- push_ascii(namerec->name.scope, global_scope(), 64, STR_TERMINATE);
+ push_ascii(namerec->name.scope, lp_netbios_scope(), 64, STR_TERMINATE);
/* We're using a byte-by-byte compare, so we must be sure that
* unused space doesn't have garbage in it.
@@ -240,7 +241,7 @@ struct name_record *find_name_on_wins_subnet(const struct nmb_name *nmbname, boo
}
key = name_to_key(nmbname);
- data = tdb_fetch(wins_tdb, key);
+ data = tdb_fetch_compat(wins_tdb, key);
if (data.dsize == 0) {
return NULL;
diff --git a/source3/nmbd/nmbd_workgroupdb.c b/source3/nmbd/nmbd_workgroupdb.c
index 5ce10e64d46..43a28aa6699 100644
--- a/source3/nmbd/nmbd_workgroupdb.c
+++ b/source3/nmbd/nmbd_workgroupdb.c
@@ -52,7 +52,7 @@ static void name_to_unstring(unstring unname, const char *name)
if (errno == E2BIG) {
unstring tname;
pull_ascii_nstring(tname, sizeof(tname), nname);
- unstrcpy(unname, tname);
+ strlcpy(unname, tname, sizeof(nname));
DEBUG(0,("name_to_nstring: workgroup name %s is too long. Truncating to %s\n",
name, tname));
} else {
@@ -250,7 +250,7 @@ workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name));
const char *name = my_netbios_names(i);
int stype = lp_default_server_announce() | (lp_local_master() ? SV_TYPE_POTENTIAL_BROWSER : 0 );
- if(!strequal(global_myname(), name))
+ if(!strequal(lp_netbios_name(), name))
stype &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_POTENTIAL_BROWSER|SV_TYPE_DOMAIN_MASTER|SV_TYPE_DOMAIN_MEMBER);
create_server_on_workgroup(work,name,stype|SV_TYPE_LOCAL_LIST_ONLY, PERMANENT_TTL,
diff --git a/source3/pam_smbpass/support.c b/source3/pam_smbpass/support.c
index 79f92a8758d..3dfdff3c028 100644
--- a/source3/pam_smbpass/support.c
+++ b/source3/pam_smbpass/support.c
@@ -150,7 +150,7 @@ int make_remark( pam_handle_t * pamh, unsigned int ctrl
struct pam_response *resp;
pmsg[0] = &msg[0];
- msg[0].msg = CONST_DISCARD(char *, text);
+ msg[0].msg = discard_const_p(char, text);
msg[0].msg_style = type;
resp = NULL;
@@ -550,7 +550,7 @@ int _smb_read_password( pam_handle_t * pamh, unsigned int ctrl,
if (comment != NULL && off(SMB__QUIET, ctrl)) {
pmsg[0] = &msg[0];
msg[0].msg_style = PAM_TEXT_INFO;
- msg[0].msg = CONST_DISCARD(char *, comment);
+ msg[0].msg = discard_const_p(char, comment);
i = 1;
} else {
i = 0;
@@ -558,12 +558,12 @@ int _smb_read_password( pam_handle_t * pamh, unsigned int ctrl,
pmsg[i] = &msg[i];
msg[i].msg_style = PAM_PROMPT_ECHO_OFF;
- msg[i++].msg = CONST_DISCARD(char *, prompt1);
+ msg[i++].msg = discard_const_p(char, prompt1);
if (prompt2 != NULL) {
pmsg[i] = &msg[i];
msg[i].msg_style = PAM_PROMPT_ECHO_OFF;
- msg[i++].msg = CONST_DISCARD(char *, prompt2);
+ msg[i++].msg = discard_const_p(char, prompt2);
expect = 2;
} else
expect = 1;
diff --git a/source3/pam_smbpass/wscript_build b/source3/pam_smbpass/wscript_build
index 0d200c6fd22..200482c7cf4 100644
--- a/source3/pam_smbpass/wscript_build
+++ b/source3/pam_smbpass/wscript_build
@@ -6,8 +6,9 @@ if bld.CONFIG_SET('WITH_PAM_MODULES'):
pam_smb_passwd.c
pam_smb_acct.c
support.c''',
- deps='''tdb talloc pam PAM_ERRORS wbclient cap asn1util param LIB_NONSMBD passdb SMBLDAP
+ deps='''tdb talloc pam PAM_ERRORS wbclient cap asn1util param passdb SMBLDAP
LIBNTLMSSP LIBTSOCKET''',
cflags='-DLOCALEDIR=\"%s/locale\"' % bld.env.DATADIR,
realname='pam_smbpass.so',
+ allow_undefined_symbols=False
)
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 0f76f0925a5..3f622ac1972 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -53,10 +53,10 @@
#include "includes.h"
#include "system/filesys.h"
+#include "util_tdb.h"
#include "printing.h"
#include "lib/smbconf/smbconf.h"
#include "lib/smbconf/smbconf_init.h"
-#include "lib/smbconf/smbconf_reg.h"
#include "ads.h"
#include "../librpc/gen_ndr/svcctl.h"
@@ -130,7 +130,6 @@ struct global {
char *smb_ports;
char *dos_charset;
char *unix_charset;
- char *display_charset;
char *szPrintcapname;
char *szAddPortCommand;
char *szEnumPortsCommand;
@@ -159,6 +158,8 @@ struct global {
char *szPasswordServer;
char *szSocketOptions;
char *szRealm;
+ char *szRealmUpper;
+ char *szDnsDomain;
char *szAfsUsernameMap;
int iAfsTokenLifetime;
char *szLogNtTokenCommand;
@@ -174,7 +175,6 @@ struct global {
char *szSocketAddress;
bool bNmbdBindExplicitBroadcast;
char *szNISHomeMapName;
- char *szAnnounceVersion; /* This is initialised in init_globals */
char *szWorkgroup;
char *szNetbiosName;
char **szNetbiosAliases;
@@ -259,7 +259,6 @@ struct global {
int min_wins_ttl;
int lm_announce;
int lm_interval;
- int announce_as; /* This is initialised in init_globals */
int machine_password_timeout;
int map_to_guest;
int oplock_break_wait_time;
@@ -699,15 +698,14 @@ static int default_server_announce;
/* prototypes for the special type handlers */
static bool handle_include( int snum, const char *pszParmValue, char **ptr);
static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
-static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr);
static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
static bool handle_debug_list( int snum, const char *pszParmValue, char **ptr );
-static bool handle_workgroup( int snum, const char *pszParmValue, char **ptr );
+static bool handle_realm( int snum, const char *pszParmValue, char **ptr );
static bool handle_netbios_aliases( int snum, const char *pszParmValue, char **ptr );
-static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
+static bool handle_dos_charset( int snum, const char *pszParmValue, char **ptr );
static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
@@ -798,21 +796,6 @@ static const struct enum_list enum_ldap_passwd_sync[] = {
{-1, NULL}
};
-/* Types of machine we can announce as. */
-#define ANNOUNCE_AS_NT_SERVER 1
-#define ANNOUNCE_AS_WIN95 2
-#define ANNOUNCE_AS_WFW 3
-#define ANNOUNCE_AS_NT_WORKSTATION 4
-
-static const struct enum_list enum_announce_as[] = {
- {ANNOUNCE_AS_NT_SERVER, "NT"},
- {ANNOUNCE_AS_NT_SERVER, "NT Server"},
- {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
- {ANNOUNCE_AS_WIN95, "win95"},
- {ANNOUNCE_AS_WFW, "WfW"},
- {-1, NULL}
-};
-
static const struct enum_list enum_map_readonly[] = {
{MAP_READONLY_NO, "no"},
{MAP_READONLY_NO, "false"},
@@ -955,7 +938,7 @@ static struct parm_struct parm_table[] = {
.type = P_STRING,
.p_class = P_GLOBAL,
.ptr = &Globals.dos_charset,
- .special = handle_charset,
+ .special = handle_dos_charset,
.enum_list = NULL,
.flags = FLAG_ADVANCED
},
@@ -969,15 +952,6 @@ static struct parm_struct parm_table[] = {
.flags = FLAG_ADVANCED
},
{
- .label = "display charset",
- .type = P_STRING,
- .p_class = P_GLOBAL,
- .ptr = &Globals.display_charset,
- .special = handle_charset,
- .enum_list = NULL,
- .flags = FLAG_ADVANCED
- },
- {
.label = "comment",
.type = P_STRING,
.p_class = P_LOCAL,
@@ -1009,27 +983,25 @@ static struct parm_struct parm_table[] = {
.type = P_USTRING,
.p_class = P_GLOBAL,
.ptr = &Globals.szWorkgroup,
- .special = handle_workgroup,
+ .special = NULL,
.enum_list = NULL,
.flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
},
-#ifdef WITH_ADS
{
.label = "realm",
.type = P_USTRING,
.p_class = P_GLOBAL,
.ptr = &Globals.szRealm,
- .special = NULL,
+ .special = handle_realm,
.enum_list = NULL,
.flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
},
-#endif
{
.label = "netbios name",
.type = P_USTRING,
.p_class = P_GLOBAL,
.ptr = &Globals.szNetbiosName,
- .special = handle_netbios_name,
+ .special = NULL,
.enum_list = NULL,
.flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
},
@@ -1047,7 +1019,7 @@ static struct parm_struct parm_table[] = {
.type = P_USTRING,
.p_class = P_GLOBAL,
.ptr = &Globals.szNetbiosScope,
- .special = handle_netbios_scope,
+ .special = NULL,
.enum_list = NULL,
.flags = FLAG_ADVANCED,
},
@@ -1160,7 +1132,7 @@ static struct parm_struct parm_table[] = {
.ptr = &Globals.bNullPasswords,
.special = NULL,
.enum_list = NULL,
- .flags = FLAG_ADVANCED,
+ .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
},
{
.label = "obey pam restrictions",
@@ -1259,7 +1231,7 @@ static struct parm_struct parm_table[] = {
.ptr = &Globals.bEnablePrivileges,
.special = NULL,
.enum_list = NULL,
- .flags = FLAG_ADVANCED,
+ .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
},
{
@@ -1332,7 +1304,7 @@ static struct parm_struct parm_table[] = {
.ptr = &Globals.pwordlevel,
.special = NULL,
.enum_list = NULL,
- .flags = FLAG_ADVANCED,
+ .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
},
{
.label = "username level",
@@ -1431,7 +1403,7 @@ static struct parm_struct parm_table[] = {
.ptr = &sDefault.szUsername,
.special = NULL,
.enum_list = NULL,
- .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
+ .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
},
{
.label = "user",
@@ -2180,24 +2152,6 @@ static struct parm_struct parm_table[] = {
.flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
},
{
- .label = "announce version",
- .type = P_STRING,
- .p_class = P_GLOBAL,
- .ptr = &Globals.szAnnounceVersion,
- .special = NULL,
- .enum_list = NULL,
- .flags = FLAG_ADVANCED,
- },
- {
- .label = "announce as",
- .type = P_ENUM,
- .p_class = P_GLOBAL,
- .ptr = &Globals.announce_as,
- .special = NULL,
- .enum_list = enum_announce_as,
- .flags = FLAG_ADVANCED,
- },
- {
.label = "map acl inherit",
.type = P_BOOL,
.p_class = P_LOCAL,
@@ -2294,7 +2248,7 @@ static struct parm_struct parm_table[] = {
.ptr = &Globals.bUseSpnego,
.special = NULL,
.enum_list = NULL,
- .flags = FLAG_ADVANCED,
+ .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
},
{
.label = "client signing",
@@ -4139,15 +4093,6 @@ static struct parm_struct parm_table[] = {
.flags = FLAG_ADVANCED,
},
{
- .label = "time offset",
- .type = P_INTEGER,
- .p_class = P_GLOBAL,
- .ptr = &extra_time_offset,
- .special = NULL,
- .enum_list = NULL,
- .flags = FLAG_ADVANCED,
- },
- {
.label = "NIS homedir",
.type = P_BOOL,
.p_class = P_GLOBAL,
@@ -5172,6 +5117,7 @@ static void init_globals(bool reinit_globals)
}
}
+
string_set(&sDefault.fstype, FSTYPE_STRING);
string_set(&sDefault.szPrintjobUsername, "%U");
@@ -5180,6 +5126,9 @@ static void init_globals(bool reinit_globals)
DEBUG(3, ("Initialising global parameters\n"));
+ /* Must manually force to upper case here, as this does not go via the handler */
+ string_set(&Globals.szNetbiosName, myhostname_upper());
+
string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
@@ -5192,14 +5141,6 @@ static void init_globals(bool reinit_globals)
/* using UTF8 by default allows us to support all chars */
string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
-#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
- /* If the system supports nl_langinfo(), try to grab the value
- from the user's locale */
- string_set(&Globals.display_charset, "LOCALE");
-#else
- string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
-#endif
-
/* Use codepage 850 as a default for the dos character set */
string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET);
@@ -5208,11 +5149,7 @@ static void init_globals(bool reinit_globals)
*/
string_set(&Globals.szPasswdChat, DEFAULT_PASSWD_CHAT);
- set_global_myname(myhostname());
- string_set(&Globals.szNetbiosName,global_myname());
-
- set_global_myworkgroup(WORKGROUP);
- string_set(&Globals.szWorkgroup, lp_workgroup());
+ string_set(&Globals.szWorkgroup, WORKGROUP);
string_set(&Globals.szPasswdProgram, "");
string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
@@ -5231,12 +5168,6 @@ static void init_globals(bool reinit_globals)
}
string_set(&Globals.szServerString, s);
SAFE_FREE(s);
- if (asprintf(&s, "%d.%d", DEFAULT_MAJOR_VERSION,
- DEFAULT_MINOR_VERSION) < 0) {
- smb_panic("init_globals: ENOMEM");
- }
- string_set(&Globals.szAnnounceVersion, s);
- SAFE_FREE(s);
#ifdef DEVELOPER
string_set(&Globals.szPanicAction, "/bin/sleep 999999999");
#endif
@@ -5301,7 +5232,6 @@ static void init_globals(bool reinit_globals)
Globals.machine_password_timeout = 60 * 60 * 24 * 7; /* 7 days default. */
Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
Globals.lm_interval = 60;
- Globals.announce_as = ANNOUNCE_AS_NT_SERVER;
#if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
Globals.bNISHomeMap = False;
#ifdef WITH_NISPLUS_HOME
@@ -5533,17 +5463,17 @@ static char *lp_string(const char *s)
*/
#define FN_GLOBAL_STRING(fn_name,ptr) \
- char *fn_name(void) {return(lp_string(*(char **)(ptr) ? *(char **)(ptr) : ""));}
+ char *fn_name(void) {return(lp_string(*(char **)(&Globals.ptr) ? *(char **)(&Globals.ptr) : ""));}
#define FN_GLOBAL_CONST_STRING(fn_name,ptr) \
- const char *fn_name(void) {return(*(const char **)(ptr) ? *(const char **)(ptr) : "");}
+ const char *fn_name(void) {return(*(const char **)(&Globals.ptr) ? *(const char **)(&Globals.ptr) : "");}
#define FN_GLOBAL_LIST(fn_name,ptr) \
- const char **fn_name(void) {return(*(const char ***)(ptr));}
+ const char **fn_name(void) {return(*(const char ***)(&Globals.ptr));}
#define FN_GLOBAL_BOOL(fn_name,ptr) \
- bool fn_name(void) {return(*(bool *)(ptr));}
+ bool fn_name(void) {return(*(bool *)(&Globals.ptr));}
#define FN_GLOBAL_CHAR(fn_name,ptr) \
- char fn_name(void) {return(*(char *)(ptr));}
+ char fn_name(void) {return(*(char *)(&Globals.ptr));}
#define FN_GLOBAL_INTEGER(fn_name,ptr) \
- int fn_name(void) {return(*(int *)(ptr));}
+ int fn_name(void) {return(*(int *)(&Globals.ptr));}
#define FN_LOCAL_STRING(fn_name,val) \
char *fn_name(int i) {return(lp_string((LP_SNUM_OK(i) && ServicePtrs[(i)]->val) ? ServicePtrs[(i)]->val : sDefault.val));}
@@ -5563,78 +5493,80 @@ static char *lp_string(const char *s)
#define FN_LOCAL_CHAR(fn_name,val) \
char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
-FN_GLOBAL_STRING(lp_smb_ports, &Globals.smb_ports)
-FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
-FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
-FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)
-FN_GLOBAL_STRING(lp_logfile, &Globals.szLogFile)
-FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
-FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
-FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
-FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
-FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
-FN_GLOBAL_STRING(lp_addport_cmd, &Globals.szAddPortCommand)
-FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
-FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
-FN_GLOBAL_STRING(lp_deleteprinter_cmd, &Globals.szDeletePrinterCommand)
-FN_GLOBAL_STRING(lp_os2_driver_map, &Globals.szOs2DriverMap)
-FN_GLOBAL_STRING(lp_lockdir, &Globals.szLockDir)
+FN_GLOBAL_CONST_STRING(lp_smb_ports, smb_ports)
+FN_GLOBAL_CONST_STRING(lp_dos_charset, dos_charset)
+FN_GLOBAL_CONST_STRING(lp_unix_charset, unix_charset)
+FN_GLOBAL_STRING(lp_logfile, szLogFile)
+FN_GLOBAL_STRING(lp_configfile, szConfigFile)
+FN_GLOBAL_CONST_STRING(lp_smb_passwd_file, szSMBPasswdFile)
+FN_GLOBAL_CONST_STRING(lp_private_dir, szPrivateDir)
+FN_GLOBAL_STRING(lp_serverstring, szServerString)
+FN_GLOBAL_INTEGER(lp_printcap_cache_time, PrintcapCacheTime)
+FN_GLOBAL_STRING(lp_addport_cmd, szAddPortCommand)
+FN_GLOBAL_STRING(lp_enumports_cmd, szEnumPortsCommand)
+FN_GLOBAL_STRING(lp_addprinter_cmd, szAddPrinterCommand)
+FN_GLOBAL_STRING(lp_deleteprinter_cmd, szDeletePrinterCommand)
+FN_GLOBAL_STRING(lp_os2_driver_map, szOs2DriverMap)
+FN_GLOBAL_CONST_STRING(lp_lockdir, szLockDir)
/* If lp_statedir() and lp_cachedir() are explicitely set during the
* build process or in smb.conf, we use that value. Otherwise they
* default to the value of lp_lockdir(). */
-char *lp_statedir(void) {
+const char *lp_statedir(void) {
if ((strcmp(get_dyn_STATEDIR(), get_dyn_LOCKDIR()) != 0) ||
(strcmp(get_dyn_STATEDIR(), Globals.szStateDir) != 0))
- return(lp_string(*(char **)(&Globals.szStateDir) ?
- *(char **)(&Globals.szStateDir) : ""));
+ return(*(char **)(&Globals.szStateDir) ?
+ *(char **)(&Globals.szStateDir) : "");
else
- return(lp_string(*(char **)(&Globals.szLockDir) ?
- *(char **)(&Globals.szLockDir) : ""));
+ return(*(char **)(&Globals.szLockDir) ?
+ *(char **)(&Globals.szLockDir) : "");
}
-char *lp_cachedir(void) {
+const char *lp_cachedir(void) {
if ((strcmp(get_dyn_CACHEDIR(), get_dyn_LOCKDIR()) != 0) ||
(strcmp(get_dyn_CACHEDIR(), Globals.szCacheDir) != 0))
- return(lp_string(*(char **)(&Globals.szCacheDir) ?
- *(char **)(&Globals.szCacheDir) : ""));
+ return(*(char **)(&Globals.szCacheDir) ?
+ *(char **)(&Globals.szCacheDir) : "");
else
- return(lp_string(*(char **)(&Globals.szLockDir) ?
- *(char **)(&Globals.szLockDir) : ""));
-}
-FN_GLOBAL_STRING(lp_piddir, &Globals.szPidDir)
-FN_GLOBAL_STRING(lp_mangling_method, &Globals.szManglingMethod)
-FN_GLOBAL_INTEGER(lp_mangle_prefix, &Globals.mangle_prefix)
-FN_GLOBAL_STRING(lp_utmpdir, &Globals.szUtmpDir)
-FN_GLOBAL_STRING(lp_wtmpdir, &Globals.szWtmpDir)
-FN_GLOBAL_BOOL(lp_utmp, &Globals.bUtmp)
-FN_GLOBAL_STRING(lp_rootdir, &Globals.szRootdir)
-FN_GLOBAL_STRING(lp_perfcount_module, &Globals.szSMBPerfcountModule)
-FN_GLOBAL_STRING(lp_defaultservice, &Globals.szDefaultService)
-FN_GLOBAL_STRING(lp_msg_command, &Globals.szMsgCommand)
-FN_GLOBAL_STRING(lp_get_quota_command, &Globals.szGetQuota)
-FN_GLOBAL_STRING(lp_set_quota_command, &Globals.szSetQuota)
-FN_GLOBAL_STRING(lp_auto_services, &Globals.szAutoServices)
-FN_GLOBAL_STRING(lp_passwd_program, &Globals.szPasswdProgram)
-FN_GLOBAL_STRING(lp_passwd_chat, &Globals.szPasswdChat)
-FN_GLOBAL_STRING(lp_passwordserver, &Globals.szPasswordServer)
-FN_GLOBAL_STRING(lp_name_resolve_order, &Globals.szNameResolveOrder)
-FN_GLOBAL_STRING(lp_realm, &Globals.szRealm)
-FN_GLOBAL_CONST_STRING(lp_afs_username_map, &Globals.szAfsUsernameMap)
-FN_GLOBAL_INTEGER(lp_afs_token_lifetime, &Globals.iAfsTokenLifetime)
-FN_GLOBAL_STRING(lp_log_nt_token_command, &Globals.szLogNtTokenCommand)
-FN_GLOBAL_STRING(lp_username_map, &Globals.szUsernameMap)
-FN_GLOBAL_CONST_STRING(lp_logon_script, &Globals.szLogonScript)
-FN_GLOBAL_CONST_STRING(lp_logon_path, &Globals.szLogonPath)
-FN_GLOBAL_CONST_STRING(lp_logon_drive, &Globals.szLogonDrive)
-FN_GLOBAL_CONST_STRING(lp_logon_home, &Globals.szLogonHome)
-FN_GLOBAL_STRING(lp_remote_announce, &Globals.szRemoteAnnounce)
-FN_GLOBAL_STRING(lp_remote_browse_sync, &Globals.szRemoteBrowseSync)
-FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, &Globals.bNmbdBindExplicitBroadcast)
-FN_GLOBAL_LIST(lp_wins_server_list, &Globals.szWINSservers)
-FN_GLOBAL_LIST(lp_interfaces, &Globals.szInterfaces)
-FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
-static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
-FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
-/* FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
+ return(*(char **)(&Globals.szLockDir) ?
+ *(char **)(&Globals.szLockDir) : "");
+}
+FN_GLOBAL_CONST_STRING(lp_piddir, szPidDir)
+FN_GLOBAL_STRING(lp_mangling_method, szManglingMethod)
+FN_GLOBAL_INTEGER(lp_mangle_prefix, mangle_prefix)
+FN_GLOBAL_CONST_STRING(lp_utmpdir, szUtmpDir)
+FN_GLOBAL_CONST_STRING(lp_wtmpdir, szWtmpDir)
+FN_GLOBAL_BOOL(lp_utmp, bUtmp)
+FN_GLOBAL_STRING(lp_rootdir, szRootdir)
+FN_GLOBAL_STRING(lp_perfcount_module, szSMBPerfcountModule)
+FN_GLOBAL_STRING(lp_defaultservice, szDefaultService)
+FN_GLOBAL_STRING(lp_msg_command, szMsgCommand)
+FN_GLOBAL_STRING(lp_get_quota_command, szGetQuota)
+FN_GLOBAL_STRING(lp_set_quota_command, szSetQuota)
+FN_GLOBAL_STRING(lp_auto_services, szAutoServices)
+FN_GLOBAL_STRING(lp_passwd_program, szPasswdProgram)
+FN_GLOBAL_STRING(lp_passwd_chat, szPasswdChat)
+FN_GLOBAL_CONST_STRING(lp_passwordserver, szPasswordServer)
+FN_GLOBAL_CONST_STRING(lp_name_resolve_order, szNameResolveOrder)
+FN_GLOBAL_CONST_STRING(lp_workgroup, szWorkgroup)
+FN_GLOBAL_CONST_STRING(lp_netbios_name, szNetbiosName)
+FN_GLOBAL_CONST_STRING(lp_netbios_scope, szNetbiosScope)
+FN_GLOBAL_CONST_STRING(lp_realm, szRealmUpper)
+FN_GLOBAL_CONST_STRING(lp_dnsdomain, szDnsDomain)
+FN_GLOBAL_CONST_STRING(lp_afs_username_map, szAfsUsernameMap)
+FN_GLOBAL_INTEGER(lp_afs_token_lifetime, iAfsTokenLifetime)
+FN_GLOBAL_STRING(lp_log_nt_token_command, szLogNtTokenCommand)
+FN_GLOBAL_STRING(lp_username_map, szUsernameMap)
+FN_GLOBAL_CONST_STRING(lp_logon_script, szLogonScript)
+FN_GLOBAL_CONST_STRING(lp_logon_path, szLogonPath)
+FN_GLOBAL_CONST_STRING(lp_logon_drive, szLogonDrive)
+FN_GLOBAL_CONST_STRING(lp_logon_home, szLogonHome)
+FN_GLOBAL_STRING(lp_remote_announce, szRemoteAnnounce)
+FN_GLOBAL_STRING(lp_remote_browse_sync, szRemoteBrowseSync)
+FN_GLOBAL_BOOL(lp_nmbd_bind_explicit_broadcast, bNmbdBindExplicitBroadcast)
+FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)
+FN_GLOBAL_LIST(lp_interfaces, szInterfaces)
+FN_GLOBAL_STRING(lp_nis_home_map_name, szNISHomeMapName)
+FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)
+/* FN_GLOBAL_STRING(lp_passdb_backend, szPassdbBackend)
* lp_passdb_backend() should be replace by the this macro again after
* some releases.
* */
@@ -5676,46 +5608,46 @@ warn:
out:
return Globals.szPassdbBackend;
}
-FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
-FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
-FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
-FN_GLOBAL_STRING(lp_renameuser_script, &Globals.szRenameUserScript)
-FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
-
-FN_GLOBAL_CONST_STRING(lp_guestaccount, &Globals.szGuestaccount)
-FN_GLOBAL_STRING(lp_addgroup_script, &Globals.szAddGroupScript)
-FN_GLOBAL_STRING(lp_delgroup_script, &Globals.szDelGroupScript)
-FN_GLOBAL_STRING(lp_addusertogroup_script, &Globals.szAddUserToGroupScript)
-FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserFromGroupScript)
-FN_GLOBAL_STRING(lp_setprimarygroup_script, &Globals.szSetPrimaryGroupScript)
-
-FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
-
-FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
-FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
-FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
-FN_GLOBAL_INTEGER(lp_username_map_cache_time, &Globals.iUsernameMapCacheTime)
-
-FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
-
-FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
-FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir)
-FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell)
-FN_GLOBAL_CONST_STRING(lp_winbind_separator, &Globals.szWinbindSeparator)
-FN_GLOBAL_INTEGER(lp_acl_compatibility, &Globals.iAclCompat)
-FN_GLOBAL_BOOL(lp_winbind_enum_users, &Globals.bWinbindEnumUsers)
-FN_GLOBAL_BOOL(lp_winbind_enum_groups, &Globals.bWinbindEnumGroups)
-FN_GLOBAL_BOOL(lp_winbind_use_default_domain, &Globals.bWinbindUseDefaultDomain)
-FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, &Globals.bWinbindTrustedDomainsOnly)
-FN_GLOBAL_BOOL(lp_winbind_nested_groups, &Globals.bWinbindNestedGroups)
-FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups)
-FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets)
-FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon)
-FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames)
-FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
-FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf)
+FN_GLOBAL_LIST(lp_preload_modules, szPreloadModules)
+FN_GLOBAL_STRING(lp_panic_action, szPanicAction)
+FN_GLOBAL_STRING(lp_adduser_script, szAddUserScript)
+FN_GLOBAL_STRING(lp_renameuser_script, szRenameUserScript)
+FN_GLOBAL_STRING(lp_deluser_script, szDelUserScript)
+
+FN_GLOBAL_CONST_STRING(lp_guestaccount, szGuestaccount)
+FN_GLOBAL_STRING(lp_addgroup_script, szAddGroupScript)
+FN_GLOBAL_STRING(lp_delgroup_script, szDelGroupScript)
+FN_GLOBAL_STRING(lp_addusertogroup_script, szAddUserToGroupScript)
+FN_GLOBAL_STRING(lp_deluserfromgroup_script, szDelUserFromGroupScript)
+FN_GLOBAL_STRING(lp_setprimarygroup_script, szSetPrimaryGroupScript)
+
+FN_GLOBAL_STRING(lp_addmachine_script, szAddMachineScript)
+
+FN_GLOBAL_STRING(lp_shutdown_script, szShutdownScript)
+FN_GLOBAL_STRING(lp_abort_shutdown_script, szAbortShutdownScript)
+FN_GLOBAL_STRING(lp_username_map_script, szUsernameMapScript)
+FN_GLOBAL_INTEGER(lp_username_map_cache_time, iUsernameMapCacheTime)
+
+FN_GLOBAL_STRING(lp_check_password_script, szCheckPasswordScript)
+
+FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)
+FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)
+FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)
+FN_GLOBAL_CONST_STRING(lp_winbind_separator, szWinbindSeparator)
+FN_GLOBAL_INTEGER(lp_acl_compatibility, iAclCompat)
+FN_GLOBAL_BOOL(lp_winbind_enum_users, bWinbindEnumUsers)
+FN_GLOBAL_BOOL(lp_winbind_enum_groups, bWinbindEnumGroups)
+FN_GLOBAL_BOOL(lp_winbind_use_default_domain, bWinbindUseDefaultDomain)
+FN_GLOBAL_BOOL(lp_winbind_trusted_domains_only, bWinbindTrustedDomainsOnly)
+FN_GLOBAL_BOOL(lp_winbind_nested_groups, bWinbindNestedGroups)
+FN_GLOBAL_INTEGER(lp_winbind_expand_groups, winbind_expand_groups)
+FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, bWinbindRefreshTickets)
+FN_GLOBAL_BOOL(lp_winbind_offline_logon, bWinbindOfflineLogon)
+FN_GLOBAL_BOOL(lp_winbind_normalize_names, bWinbindNormalizeNames)
+FN_GLOBAL_BOOL(lp_winbind_rpc_only, bWinbindRpcOnly)
+FN_GLOBAL_BOOL(lp_create_krb5_conf, bCreateKrb5Conf)
static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int,
- &Globals.winbindMaxDomainConnections)
+ winbindMaxDomainConnections)
int lp_winbind_max_domain_connections(void)
{
@@ -5728,119 +5660,119 @@ int lp_winbind_max_domain_connections(void)
return MAX(1, lp_winbind_max_domain_connections_int());
}
-FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
-FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
-FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
-FN_GLOBAL_INTEGER(lp_keepalive, &Globals.iKeepalive)
-FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit)
-
-FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix)
-FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn)
-FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl)
-FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads)
-FN_GLOBAL_INTEGER(lp_ldap_deref, &Globals.ldap_deref)
-FN_GLOBAL_INTEGER(lp_ldap_follow_referral, &Globals.ldap_follow_referral)
-FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync)
-FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn)
-FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep)
-FN_GLOBAL_INTEGER(lp_ldap_timeout, &Globals.ldap_timeout)
-FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, &Globals.ldap_connection_timeout)
-FN_GLOBAL_INTEGER(lp_ldap_page_size, &Globals.ldap_page_size)
-FN_GLOBAL_INTEGER(lp_ldap_debug_level, &Globals.ldap_debug_level)
-FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, &Globals.ldap_debug_threshold)
-FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand)
-FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand)
-FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand)
-FN_GLOBAL_STRING(lp_usershare_path, &Globals.szUsersharePath)
-FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, &Globals.szUsersharePrefixAllowList)
-FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, &Globals.szUsersharePrefixDenyList)
-
-FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
-
-FN_GLOBAL_BOOL(lp_registry_shares, &Globals.bRegistryShares)
-FN_GLOBAL_BOOL(lp_usershare_allow_guests, &Globals.bUsershareAllowGuests)
-FN_GLOBAL_BOOL(lp_usershare_owner_only, &Globals.bUsershareOwnerOnly)
-FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
-FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
+FN_GLOBAL_CONST_STRING(lp_idmap_backend, szIdmapBackend)
+FN_GLOBAL_INTEGER(lp_idmap_cache_time, iIdmapCacheTime)
+FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, iIdmapNegativeCacheTime)
+FN_GLOBAL_INTEGER(lp_keepalive, iKeepalive)
+FN_GLOBAL_BOOL(lp_passdb_expand_explicit, bPassdbExpandExplicit)
+
+FN_GLOBAL_STRING(lp_ldap_suffix, szLdapSuffix)
+FN_GLOBAL_STRING(lp_ldap_admin_dn, szLdapAdminDn)
+FN_GLOBAL_INTEGER(lp_ldap_ssl, ldap_ssl)
+FN_GLOBAL_BOOL(lp_ldap_ssl_ads, ldap_ssl_ads)
+FN_GLOBAL_INTEGER(lp_ldap_deref, ldap_deref)
+FN_GLOBAL_INTEGER(lp_ldap_follow_referral, ldap_follow_referral)
+FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, ldap_passwd_sync)
+FN_GLOBAL_BOOL(lp_ldap_delete_dn, ldap_delete_dn)
+FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, ldap_replication_sleep)
+FN_GLOBAL_INTEGER(lp_ldap_timeout, ldap_timeout)
+FN_GLOBAL_INTEGER(lp_ldap_connection_timeout, ldap_connection_timeout)
+FN_GLOBAL_INTEGER(lp_ldap_page_size, ldap_page_size)
+FN_GLOBAL_INTEGER(lp_ldap_debug_level, ldap_debug_level)
+FN_GLOBAL_INTEGER(lp_ldap_debug_threshold, ldap_debug_threshold)
+FN_GLOBAL_STRING(lp_add_share_cmd, szAddShareCommand)
+FN_GLOBAL_STRING(lp_change_share_cmd, szChangeShareCommand)
+FN_GLOBAL_STRING(lp_delete_share_cmd, szDeleteShareCommand)
+FN_GLOBAL_STRING(lp_usershare_path, szUsersharePath)
+FN_GLOBAL_LIST(lp_usershare_prefix_allow_list, szUsersharePrefixAllowList)
+FN_GLOBAL_LIST(lp_usershare_prefix_deny_list, szUsersharePrefixDenyList)
+
+FN_GLOBAL_LIST(lp_eventlog_list, szEventLogs)
+
+FN_GLOBAL_BOOL(lp_registry_shares, bRegistryShares)
+FN_GLOBAL_BOOL(lp_usershare_allow_guests, bUsershareAllowGuests)
+FN_GLOBAL_BOOL(lp_usershare_owner_only, bUsershareOwnerOnly)
+FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)
+FN_GLOBAL_BOOL(lp_reset_on_zero_vc, bResetOnZeroVC)
FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit,
- &Globals.bLogWriteableFilesOnExit)
-FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
-FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
-FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)
-FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
-FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
-FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
-FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
-FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
-FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
-FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
-FN_GLOBAL_BOOL(_lp_readraw, &Globals.bReadRaw)
-FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
-FN_GLOBAL_BOOL(_lp_writeraw, &Globals.bWriteRaw)
-FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
-FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
-FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
-FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
-FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
-FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
-FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
-FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
-FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
-FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
-FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
-FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
-FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
-FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
-FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
-static FN_GLOBAL_BOOL(lp_time_server, &Globals.bTimeServer)
-FN_GLOBAL_BOOL(lp_bind_interfaces_only, &Globals.bBindInterfacesOnly)
-FN_GLOBAL_BOOL(lp_pam_password_change, &Globals.bPamPasswordChange)
-FN_GLOBAL_BOOL(lp_unix_password_sync, &Globals.bUnixPasswdSync)
-FN_GLOBAL_BOOL(lp_passwd_chat_debug, &Globals.bPasswdChatDebug)
-FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, &Globals.iPasswdChatTimeout)
-FN_GLOBAL_BOOL(lp_nt_pipe_support, &Globals.bNTPipeSupport)
-FN_GLOBAL_BOOL(lp_nt_status_support, &Globals.bNTStatusSupport)
-FN_GLOBAL_BOOL(lp_stat_cache, &Globals.bStatCache)
-FN_GLOBAL_INTEGER(lp_max_stat_cache_size, &Globals.iMaxStatCacheSize)
-FN_GLOBAL_BOOL(lp_allow_trusted_domains, &Globals.bAllowTrustedDomains)
-FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, &Globals.bMapUntrustedToDomain)
-FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous)
-FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
-FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth)
-FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth)
-FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth)
-FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth)
-FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
-FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
-FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
-FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
-FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
-FN_GLOBAL_BOOL(lp_use_spnego, &Globals.bUseSpnego)
-FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
-FN_GLOBAL_BOOL(lp_client_use_spnego_principal, &Globals.client_use_spnego_principal)
-FN_GLOBAL_BOOL(lp_send_spnego_principal, &Globals.send_spnego_principal)
-FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
+ bLogWriteableFilesOnExit)
+FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, bMsAddPrinterWizard)
+FN_GLOBAL_BOOL(lp_dns_proxy, bDNSproxy)
+FN_GLOBAL_BOOL(lp_wins_support, bWINSsupport)
+FN_GLOBAL_BOOL(lp_we_are_a_wins_server, bWINSsupport)
+FN_GLOBAL_BOOL(lp_wins_proxy, bWINSproxy)
+FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)
+FN_GLOBAL_BOOL(lp_domain_logons, bDomainLogons)
+FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, szInitLogonDelayedHosts)
+FN_GLOBAL_INTEGER(lp_init_logon_delay, InitLogonDelay)
+FN_GLOBAL_BOOL(lp_load_printers, bLoadPrinters)
+FN_GLOBAL_BOOL(_lp_readraw, bReadRaw)
+FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)
+FN_GLOBAL_BOOL(_lp_writeraw, bWriteRaw)
+FN_GLOBAL_BOOL(lp_null_passwords, bNullPasswords)
+FN_GLOBAL_BOOL(lp_obey_pam_restrictions, bObeyPamRestrictions)
+FN_GLOBAL_BOOL(lp_encrypted_passwords, bEncryptPasswords)
+FN_GLOBAL_INTEGER(lp_client_schannel, clientSchannel)
+FN_GLOBAL_INTEGER(lp_server_schannel, serverSchannel)
+FN_GLOBAL_BOOL(lp_syslog_only, bSyslogOnly)
+FN_GLOBAL_BOOL(lp_timestamp_logs, bTimestampLogs)
+FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, bDebugPrefixTimestamp)
+FN_GLOBAL_BOOL(lp_debug_hires_timestamp, bDebugHiresTimestamp)
+FN_GLOBAL_BOOL(lp_debug_pid, bDebugPid)
+FN_GLOBAL_BOOL(lp_debug_uid, bDebugUid)
+FN_GLOBAL_BOOL(lp_debug_class, bDebugClass)
+FN_GLOBAL_BOOL(lp_enable_core_files, bEnableCoreFiles)
+FN_GLOBAL_BOOL(lp_browse_list, bBrowseList)
+FN_GLOBAL_BOOL(lp_nis_home_map, bNISHomeMap)
+static FN_GLOBAL_BOOL(lp_time_server, bTimeServer)
+FN_GLOBAL_BOOL(lp_bind_interfaces_only, bBindInterfacesOnly)
+FN_GLOBAL_BOOL(lp_pam_password_change, bPamPasswordChange)
+FN_GLOBAL_BOOL(lp_unix_password_sync, bUnixPasswdSync)
+FN_GLOBAL_BOOL(lp_passwd_chat_debug, bPasswdChatDebug)
+FN_GLOBAL_INTEGER(lp_passwd_chat_timeout, iPasswdChatTimeout)
+FN_GLOBAL_BOOL(lp_nt_pipe_support, bNTPipeSupport)
+FN_GLOBAL_BOOL(lp_nt_status_support, bNTStatusSupport)
+FN_GLOBAL_BOOL(lp_stat_cache, bStatCache)
+FN_GLOBAL_INTEGER(lp_max_stat_cache_size, iMaxStatCacheSize)
+FN_GLOBAL_BOOL(lp_allow_trusted_domains, bAllowTrustedDomains)
+FN_GLOBAL_BOOL(lp_map_untrusted_to_domain, bMapUntrustedToDomain)
+FN_GLOBAL_INTEGER(lp_restrict_anonymous, restrict_anonymous)
+FN_GLOBAL_BOOL(lp_lanman_auth, bLanmanAuth)
+FN_GLOBAL_BOOL(lp_ntlm_auth, bNTLMAuth)
+FN_GLOBAL_BOOL(lp_client_plaintext_auth, bClientPlaintextAuth)
+FN_GLOBAL_BOOL(lp_client_lanman_auth, bClientLanManAuth)
+FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, bClientNTLMv2Auth)
+FN_GLOBAL_BOOL(lp_host_msdfs, bHostMSDfs)
+FN_GLOBAL_BOOL(lp_kernel_oplocks, bKernelOplocks)
+FN_GLOBAL_BOOL(lp_enhanced_browsing, enhanced_browsing)
+FN_GLOBAL_BOOL(lp_use_mmap, bUseMmap)
+FN_GLOBAL_BOOL(lp_unix_extensions, bUnixExtensions)
+FN_GLOBAL_BOOL(lp_use_spnego, bUseSpnego)
+FN_GLOBAL_BOOL(lp_client_use_spnego, bClientUseSpnego)
+FN_GLOBAL_BOOL(lp_client_use_spnego_principal, client_use_spnego_principal)
+FN_GLOBAL_BOOL(lp_send_spnego_principal, send_spnego_principal)
+FN_GLOBAL_BOOL(lp_hostname_lookups, bHostnameLookups)
FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify)
-FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile)
-FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod)
-FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations)
-FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges)
-FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport)
-FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
-FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
-FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)
-FN_GLOBAL_INTEGER(lp_min_wins_ttl, &Globals.min_wins_ttl)
-FN_GLOBAL_INTEGER(lp_max_log_size, &Globals.max_log_size)
-FN_GLOBAL_INTEGER(lp_max_open_files, &Globals.max_open_files)
-FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, &Globals.open_files_db_hash_size)
-FN_GLOBAL_INTEGER(lp_maxxmit, &Globals.max_xmit)
-FN_GLOBAL_INTEGER(lp_maxmux, &Globals.max_mux)
-FN_GLOBAL_INTEGER(lp_passwordlevel, &Globals.pwordlevel)
-FN_GLOBAL_INTEGER(lp_usernamelevel, &Globals.unamelevel)
-FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
-FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
-static FN_GLOBAL_INTEGER(_lp_maxprotocol, &Globals.maxprotocol)
+FN_GLOBAL_CONST_STRING(lp_dedicated_keytab_file, szDedicatedKeytabFile)
+FN_GLOBAL_INTEGER(lp_kerberos_method, iKerberosMethod)
+FN_GLOBAL_BOOL(lp_defer_sharing_violations, bDeferSharingViolations)
+FN_GLOBAL_BOOL(lp_enable_privileges, bEnablePrivileges)
+FN_GLOBAL_BOOL(lp_enable_asu_support, bASUSupport)
+FN_GLOBAL_INTEGER(lp_os_level, os_level)
+FN_GLOBAL_INTEGER(lp_max_ttl, max_ttl)
+FN_GLOBAL_INTEGER(lp_max_wins_ttl, max_wins_ttl)
+FN_GLOBAL_INTEGER(lp_min_wins_ttl, min_wins_ttl)
+FN_GLOBAL_INTEGER(lp_max_log_size, max_log_size)
+FN_GLOBAL_INTEGER(lp_max_open_files, max_open_files)
+FN_GLOBAL_INTEGER(lp_open_files_db_hash_size, open_files_db_hash_size)
+FN_GLOBAL_INTEGER(lp_maxxmit, max_xmit)
+FN_GLOBAL_INTEGER(lp_maxmux, max_mux)
+FN_GLOBAL_INTEGER(lp_passwordlevel, pwordlevel)
+FN_GLOBAL_INTEGER(lp_usernamelevel, unamelevel)
+FN_GLOBAL_INTEGER(lp_deadtime, deadtime)
+FN_GLOBAL_BOOL(lp_getwd_cache, getwd_cache)
+static FN_GLOBAL_INTEGER(_lp_maxprotocol, maxprotocol)
int lp_maxprotocol(void)
{
int ret = _lp_maxprotocol();
@@ -5852,28 +5784,27 @@ int lp_maxprotocol(void)
}
return ret;
}
-FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
-FN_GLOBAL_INTEGER(lp_security, &Globals.security)
-FN_GLOBAL_LIST(lp_auth_methods, &Globals.AuthMethods)
-FN_GLOBAL_BOOL(lp_paranoid_server_security, &Globals.paranoid_server_security)
-FN_GLOBAL_INTEGER(lp_maxdisksize, &Globals.maxdisksize)
-FN_GLOBAL_INTEGER(lp_lpqcachetime, &Globals.lpqcachetime)
-FN_GLOBAL_INTEGER(lp_max_smbd_processes, &Globals.iMaxSmbdProcesses)
-FN_GLOBAL_BOOL(_lp_disable_spoolss, &Globals.bDisableSpoolss)
-FN_GLOBAL_INTEGER(lp_syslog, &Globals.syslog)
-static FN_GLOBAL_INTEGER(lp_announce_as, &Globals.announce_as)
-FN_GLOBAL_INTEGER(lp_lm_announce, &Globals.lm_announce)
-FN_GLOBAL_INTEGER(lp_lm_interval, &Globals.lm_interval)
-FN_GLOBAL_INTEGER(lp_machine_password_timeout, &Globals.machine_password_timeout)
-FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
-FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
-FN_GLOBAL_INTEGER(lp_lock_spin_time, &Globals.iLockSpinTime)
-FN_GLOBAL_INTEGER(lp_usershare_max_shares, &Globals.iUsershareMaxShares)
-FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
-FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
-FN_GLOBAL_INTEGER(lp_smb2_max_read, &Globals.ismb2_max_read)
-FN_GLOBAL_INTEGER(lp_smb2_max_write, &Globals.ismb2_max_write)
-FN_GLOBAL_INTEGER(lp_smb2_max_trans, &Globals.ismb2_max_trans)
+FN_GLOBAL_INTEGER(lp_minprotocol, minprotocol)
+FN_GLOBAL_INTEGER(lp_security, security)
+FN_GLOBAL_LIST(lp_auth_methods, AuthMethods)
+FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security)
+FN_GLOBAL_INTEGER(lp_maxdisksize, maxdisksize)
+FN_GLOBAL_INTEGER(lp_lpqcachetime, lpqcachetime)
+FN_GLOBAL_INTEGER(lp_max_smbd_processes, iMaxSmbdProcesses)
+FN_GLOBAL_BOOL(_lp_disable_spoolss, bDisableSpoolss)
+FN_GLOBAL_INTEGER(lp_syslog, syslog)
+FN_GLOBAL_INTEGER(lp_lm_announce, lm_announce)
+FN_GLOBAL_INTEGER(lp_lm_interval, lm_interval)
+FN_GLOBAL_INTEGER(lp_machine_password_timeout, machine_password_timeout)
+FN_GLOBAL_INTEGER(lp_map_to_guest, map_to_guest)
+FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, oplock_break_wait_time)
+FN_GLOBAL_INTEGER(lp_lock_spin_time, iLockSpinTime)
+FN_GLOBAL_INTEGER(lp_usershare_max_shares, iUsershareMaxShares)
+FN_GLOBAL_CONST_STRING(lp_socket_options, szSocketOptions)
+FN_GLOBAL_INTEGER(lp_config_backend, ConfigBackend)
+FN_GLOBAL_INTEGER(lp_smb2_max_read, ismb2_max_read)
+FN_GLOBAL_INTEGER(lp_smb2_max_write, ismb2_max_write)
+FN_GLOBAL_INTEGER(lp_smb2_max_trans, ismb2_max_trans)
int lp_smb2_max_credits(void)
{
if (Globals.ismb2_max_credits == 0) {
@@ -5893,9 +5824,9 @@ FN_LOCAL_STRING(lp_username, szUsername)
FN_LOCAL_LIST(lp_invalid_users, szInvalidUsers)
FN_LOCAL_LIST(lp_valid_users, szValidUsers)
FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
-FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
+FN_GLOBAL_LIST(lp_svcctl_list, szServicesList)
FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
-FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
+FN_GLOBAL_STRING(lp_cups_server, szCupsServer)
int lp_cups_encrypt(void)
{
int result = 0;
@@ -5914,13 +5845,13 @@ int lp_cups_encrypt(void)
#endif
return result;
}
-FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
-FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
-FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
-FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
-FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
-FN_GLOBAL_INTEGER(lp_ctdb_timeout, &Globals.ctdb_timeout)
-FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, &Globals.ctdb_locktime_warn_threshold)
+FN_GLOBAL_STRING(lp_iprint_server, szIPrintServer)
+FN_GLOBAL_INTEGER(lp_cups_connection_timeout, cups_connection_timeout)
+FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, ctdbdSocket)
+FN_GLOBAL_LIST(lp_cluster_addresses, szClusterAddresses)
+FN_GLOBAL_BOOL(lp_clustering, clustering)
+FN_GLOBAL_INTEGER(lp_ctdb_timeout, ctdb_timeout)
+FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, ctdb_locktime_warn_threshold)
FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
FN_LOCAL_STRING(lp_lprmcommand, szLprmcommand)
@@ -5993,8 +5924,8 @@ FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
-FN_GLOBAL_BOOL(lp_async_smb_echo_handler, &Globals.bAsyncSMBEchoHandler)
-FN_GLOBAL_BOOL(lp_multicast_dns_register, &Globals.bMulticastDnsRegister)
+FN_GLOBAL_BOOL(lp_async_smb_echo_handler, bAsyncSMBEchoHandler)
+FN_GLOBAL_BOOL(lp_multicast_dns_register, bMulticastDnsRegister)
FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
@@ -6037,17 +5968,17 @@ FN_LOCAL_INTEGER(lp_map_readonly, iMap_readonly)
FN_LOCAL_INTEGER(lp_directory_name_cache_size, iDirectoryNameCacheSize)
FN_LOCAL_INTEGER(lp_smb_encrypt, ismb_encrypt)
FN_LOCAL_CHAR(lp_magicchar, magic_char)
-FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
-FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
-FN_GLOBAL_INTEGER(lp_winbind_max_clients, &Globals.winbind_max_clients)
-FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
-FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
-FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
-FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
-FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
-FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
-
-FN_GLOBAL_STRING(lp_ncalrpc_dir, &Globals.ncalrpc_dir)
+FN_GLOBAL_INTEGER(lp_winbind_cache_time, winbind_cache_time)
+FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, winbind_reconnect_delay)
+FN_GLOBAL_INTEGER(lp_winbind_max_clients, winbind_max_clients)
+FN_GLOBAL_LIST(lp_winbind_nss_info, szWinbindNssInfo)
+FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, AlgorithmicRidBase)
+FN_GLOBAL_INTEGER(lp_name_cache_timeout, name_cache_timeout)
+FN_GLOBAL_INTEGER(lp_client_signing, client_signing)
+FN_GLOBAL_INTEGER(lp_server_signing, server_signing)
+FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, client_ldap_sasl_wrapping)
+
+FN_GLOBAL_CONST_STRING(lp_ncalrpc_dir, ncalrpc_dir)
/* local prototypes */
@@ -7132,10 +7063,14 @@ static void copy_service(struct service *pserviceDest, struct service *pserviceS
break;
case P_USTRING:
+ {
+ char *upper_string = strupper_talloc(talloc_tos(),
+ *(char **)src_ptr);
string_set((char **)dest_ptr,
- *(char **)src_ptr);
- strupper_m(*(char **)dest_ptr);
+ upper_string);
+ TALLOC_FREE(upper_string);
break;
+ }
case P_LIST:
TALLOC_FREE(*((char ***)dest_ptr));
*((char ***)dest_ptr) = str_list_copy(NULL,
@@ -7208,14 +7143,14 @@ bool service_ok(int iService)
static struct smbconf_ctx *lp_smbconf_ctx(void)
{
- WERROR werr;
+ sbcErr err;
static struct smbconf_ctx *conf_ctx = NULL;
if (conf_ctx == NULL) {
- werr = smbconf_init(NULL, &conf_ctx, "registry:");
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init(NULL, &conf_ctx, "registry:");
+ if (!SBC_ERROR_IS_OK(err)) {
DEBUG(1, ("error initializing registry configuration: "
- "%s\n", win_errstr(werr)));
+ "%s\n", sbcErrorString(err)));
conf_ctx = NULL;
}
}
@@ -7255,7 +7190,7 @@ static bool process_smbconf_service(struct smbconf_service *service)
*/
bool process_registry_service(const char *service_name)
{
- WERROR werr;
+ sbcErr err;
struct smbconf_service *service = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct smbconf_ctx *conf_ctx = lp_smbconf_ctx();
@@ -7276,8 +7211,8 @@ bool process_registry_service(const char *service_name)
goto done;
}
- werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
@@ -7313,7 +7248,7 @@ static bool process_registry_globals(void)
bool process_registry_shares(void)
{
- WERROR werr;
+ sbcErr err;
uint32_t count;
struct smbconf_service **service = NULL;
uint32_t num_shares = 0;
@@ -7325,8 +7260,8 @@ bool process_registry_shares(void)
goto done;
}
- werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
@@ -7499,27 +7434,18 @@ bool lp_file_list_changed(void)
}
-/***************************************************************************
- Run standard_sub_basic on netbios name... needed because global_myname
- is not accessed through any lp_ macro.
- Note: We must *NOT* use string_set() here as ptr points to global_myname.
-***************************************************************************/
-
-static bool handle_netbios_name(int snum, const char *pszParmValue, char **ptr)
+/**
+ * Initialize iconv conversion descriptors.
+ *
+ * This is called the first time it is needed, and also called again
+ * every time the configuration is reloaded, because the charset or
+ * codepage might have changed.
+ **/
+static void init_iconv(void)
{
- bool ret;
- char *netbios_name = talloc_sub_basic(
- talloc_tos(), get_current_username(), current_user_info.domain,
- pszParmValue);
-
- ret = set_global_myname(netbios_name);
- TALLOC_FREE(netbios_name);
- string_set(&Globals.szNetbiosName,global_myname());
-
- DEBUG(4, ("handle_netbios_name: set global_myname to: %s\n",
- global_myname()));
-
- return ret;
+ global_iconv_handle = smb_iconv_handle_reinit(NULL, lp_dos_charset(),
+ lp_unix_charset(),
+ true, global_iconv_handle);
}
static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
@@ -7531,24 +7457,54 @@ static bool handle_charset(int snum, const char *pszParmValue, char **ptr)
return True;
}
-
-
-static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
+static bool handle_dos_charset(int snum, const char *pszParmValue, char **ptr)
{
- bool ret;
+ bool is_utf8 = false;
+ size_t len = strlen(pszParmValue);
- ret = set_global_myworkgroup(pszParmValue);
- string_set(&Globals.szWorkgroup,lp_workgroup());
+ if (len == 4 || len == 5) {
+ /* Don't use StrCaseCmp here as we don't want to
+ initialize iconv. */
+ if ((toupper_ascii(pszParmValue[0]) == 'U') &&
+ (toupper_ascii(pszParmValue[1]) == 'T') &&
+ (toupper_ascii(pszParmValue[2]) == 'F')) {
+ if (len == 4) {
+ if (pszParmValue[3] == '8') {
+ is_utf8 = true;
+ }
+ } else {
+ if (pszParmValue[3] == '-' &&
+ pszParmValue[4] == '8') {
+ is_utf8 = true;
+ }
+ }
+ }
+ }
- return ret;
+ if (strcmp(*ptr, pszParmValue) != 0) {
+ if (is_utf8) {
+ DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
+ "be UTF8, using (default value) %s instead.\n",
+ DEFAULT_DOS_CHARSET));
+ pszParmValue = DEFAULT_DOS_CHARSET;
+ }
+ string_set(ptr, pszParmValue);
+ init_iconv();
+ }
+ return true;
}
-static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
+static bool handle_realm(int snum, const char *pszParmValue, char **ptr)
{
- bool ret;
+ bool ret = true;
+ char *realm = strupper_talloc(talloc_tos(), pszParmValue);
+ char *dnsdomain = strlower_talloc(talloc_tos(), pszParmValue);
- ret = set_global_scope(pszParmValue);
- string_set(&Globals.szNetbiosScope,global_scope());
+ ret &= string_set(&Globals.szRealm, pszParmValue);
+ ret &= string_set(&Globals.szRealmUpper, realm);
+ ret &= string_set(&Globals.szDnsDomain, dnsdomain);
+ TALLOC_FREE(realm);
+ TALLOC_FREE(dnsdomain);
return ret;
}
@@ -7983,10 +7939,13 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
break;
case P_USTRING:
- string_set((char **)parm_ptr, pszParmValue);
- strupper_m(*(char **)parm_ptr);
+ {
+ char *upper_string = strupper_talloc(talloc_tos(),
+ pszParmValue);
+ string_set((char **)parm_ptr, upper_string);
+ TALLOC_FREE(upper_string);
break;
-
+ }
case P_ENUM:
lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr );
break;
@@ -8610,7 +8569,8 @@ static void lp_add_auto_services(char *str)
Auto-load one printer.
***************************************************************************/
-void lp_add_one_printer(const char *name, const char *comment, void *pdata)
+void lp_add_one_printer(const char *name, const char *comment,
+ const char *location, void *pdata)
{
int printers = lp_servicenumber(PRINTERS_NAME);
int i;
@@ -8637,7 +8597,8 @@ bool lp_loaded(void)
Unload unused services.
***************************************************************************/
-void lp_killunused(bool (*snumused) (int))
+void lp_killunused(struct smbd_server_connection *sconn,
+ bool (*snumused) (struct smbd_server_connection *, int))
{
int i;
for (i = 0; i < iNumServices; i++) {
@@ -8650,7 +8611,7 @@ void lp_killunused(bool (*snumused) (int))
continue;
}
- if (!snumused || !snumused(i)) {
+ if (!snumused || !snumused(sconn, i)) {
free_service_byindex(i);
}
}
@@ -8661,7 +8622,7 @@ void lp_killunused(bool (*snumused) (int))
*/
void lp_kill_all_services(void)
{
- lp_killunused(NULL);
+ lp_killunused(NULL, NULL);
}
/***************************************************************************
@@ -9275,7 +9236,7 @@ int load_usershare_service(const char *servicename)
been removed.
***************************************************************************/
-int load_usershare_shares(void)
+int load_usershare_shares(struct smbd_server_connection *sconn)
{
SMB_STRUCT_DIR *dp;
SMB_STRUCT_STAT sbuf;
@@ -9413,7 +9374,7 @@ int load_usershare_shares(void)
not currently in use. */
for (iService = iNumServices - 1; iService >= 0; iService--) {
if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
- if (conn_snum_used(iService)) {
+ if (conn_snum_used(sconn, iService)) {
continue;
}
/* Remove from the share ACL db. */
@@ -9579,6 +9540,17 @@ static bool lp_load_ex(const char *pszFname,
set_default_server_announce_type();
set_allowed_client_auth();
+ if (lp_security() == SEC_SHARE) {
+ DEBUG(1, ("WARNING: The security=share option is deprecated\n"));
+ } else if (lp_security() == SEC_SERVER) {
+ DEBUG(1, ("WARNING: The security=server option is deprecated\n"));
+ }
+
+ if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
+ DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
+ lp_passwordserver()));
+ }
+
bLoaded = True;
/* Now we check bWINSsupport and set szWINSserver to 127.0.0.1 */
@@ -9747,87 +9719,6 @@ bool share_defined(const char *service_name)
return (lp_servicenumber(service_name) != -1);
}
-struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
- const char *sharename)
-{
- struct share_params *result;
- char *sname = NULL;
- int snum;
-
- snum = find_service(mem_ctx, sharename, &sname);
- if (snum < 0 || sname == NULL) {
- return NULL;
- }
-
- if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
- DEBUG(0, ("talloc failed\n"));
- return NULL;
- }
-
- result->service = snum;
- return result;
-}
-
-struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
-{
- struct share_iterator *result;
-
- if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
- DEBUG(0, ("talloc failed\n"));
- return NULL;
- }
-
- result->next_id = 0;
- return result;
-}
-
-struct share_params *next_share(struct share_iterator *list)
-{
- struct share_params *result;
-
- while (!lp_snum_ok(list->next_id) &&
- (list->next_id < lp_numservices())) {
- list->next_id += 1;
- }
-
- if (list->next_id >= lp_numservices()) {
- return NULL;
- }
-
- if (!(result = TALLOC_P(list, struct share_params))) {
- DEBUG(0, ("talloc failed\n"));
- return NULL;
- }
-
- result->service = list->next_id;
- list->next_id += 1;
- return result;
-}
-
-struct share_params *next_printer(struct share_iterator *list)
-{
- struct share_params *result;
-
- while ((result = next_share(list)) != NULL) {
- if (lp_print_ok(result->service)) {
- break;
- }
- }
- return result;
-}
-
-/*
- * This is a hack for a transition period until we transformed all code from
- * service numbers to struct share_params.
- */
-
-struct share_params *snum2params_static(int snum)
-{
- static struct share_params result;
- result.service = snum;
- return &result;
-}
-
/*******************************************************************
A useful volume label function.
********************************************************************/
@@ -9865,22 +9756,8 @@ static void set_default_server_announce_type(void)
default_server_announce |= SV_TYPE_PRINTQ_SERVER;
- switch (lp_announce_as()) {
- case ANNOUNCE_AS_NT_SERVER:
- default_server_announce |= SV_TYPE_SERVER_NT;
- /* fall through... */
- case ANNOUNCE_AS_NT_WORKSTATION:
- default_server_announce |= SV_TYPE_NT;
- break;
- case ANNOUNCE_AS_WIN95:
- default_server_announce |= SV_TYPE_WIN95_PLUS;
- break;
- case ANNOUNCE_AS_WFW:
- default_server_announce |= SV_TYPE_WFW;
- break;
- default:
- break;
- }
+ default_server_announce |= SV_TYPE_SERVER_NT;
+ default_server_announce |= SV_TYPE_NT;
switch (lp_server_role()) {
case ROLE_DOMAIN_MEMBER:
@@ -9973,54 +9850,6 @@ int lp_default_server_announce(void)
return default_server_announce;
}
-/*******************************************************************
- Split the announce version into major and minor numbers.
-********************************************************************/
-
-int lp_major_announce_version(void)
-{
- static bool got_major = False;
- static int major_version = DEFAULT_MAJOR_VERSION;
- char *vers;
- char *p;
-
- if (got_major)
- return major_version;
-
- got_major = True;
- if ((vers = lp_announce_version()) == NULL)
- return major_version;
-
- if ((p = strchr_m(vers, '.')) == 0)
- return major_version;
-
- *p = '\0';
- major_version = atoi(vers);
- return major_version;
-}
-
-int lp_minor_announce_version(void)
-{
- static bool got_minor = False;
- static int minor_version = DEFAULT_MINOR_VERSION;
- char *vers;
- char *p;
-
- if (got_minor)
- return minor_version;
-
- got_minor = True;
- if ((vers = lp_announce_version()) == NULL)
- return minor_version;
-
- if ((p = strchr_m(vers, '.')) == 0)
- return minor_version;
-
- p++;
- minor_version = atoi(p);
- return minor_version;
-}
-
/***********************************************************
Set the global name resolution order (used in smbclient).
************************************************************/
diff --git a/source3/param/loadparm_ctx.c b/source3/param/loadparm_ctx.c
new file mode 100644
index 00000000000..e80f6f18444
--- /dev/null
+++ b/source3/param/loadparm_ctx.c
@@ -0,0 +1,68 @@
+/*
+ Unix SMB/CIFS implementation.
+ Parameter loading functions
+ Copyright (C) Andrew Bartlett 2011
+
+ 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 "../source4/param/s3_param.h"
+
+static const char *get_parametric(const char *type, const char *option)
+{
+ return lp_parm_const_string(-1, type, option, NULL);
+}
+
+/* These are in the order that they appear in the s4 loadparm file.
+ * All of the s4 loadparm functions should be here eventually, once
+ * they are implemented in the s3 loadparm, have the same format (enum
+ * values in particular) and defaults. */
+static const struct loadparm_s3_context s3_fns =
+{
+ .get_parametric = get_parametric,
+
+ .server_role = lp_server_role,
+
+ .winbind_separator = lp_winbind_separator,
+ .template_homedir = lp_template_homedir,
+ .template_shell = lp_template_shell,
+
+ .dos_charset = lp_dos_charset,
+ .unix_charset = lp_unix_charset,
+
+ .realm = lp_realm,
+ .dnsdomain = lp_dnsdomain,
+ .socket_options = lp_socket_options,
+ .workgroup = lp_workgroup,
+
+ .netbios_name = lp_netbios_name,
+ .netbios_scope = lp_netbios_scope,
+
+ .lanman_auth = lp_lanman_auth,
+ .ntlm_auth = lp_ntlm_auth,
+
+ .client_plaintext_auth = lp_client_plaintext_auth,
+ .client_lanman_auth = lp_client_lanman_auth,
+ .client_ntlmv2_auth = lp_client_ntlmv2_auth,
+
+ .private_dir = lp_private_dir,
+ .ncalrpc_dir = lp_ncalrpc_dir,
+ .lockdir = lp_lockdir
+};
+
+const struct loadparm_s3_context *loadparm_s3_context(void)
+{
+ return &s3_fns;
+}
diff --git a/source3/param/service.c b/source3/param/service.c
new file mode 100644
index 00000000000..358b7af2dee
--- /dev/null
+++ b/source3/param/service.c
@@ -0,0 +1,276 @@
+/*
+ Unix SMB/CIFS implementation.
+ service (connection) opening and closing
+ Copyright (C) Andrew Tridgell 1992-1998
+
+ 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/tsocket/tsocket.h"
+#include "smbd/smbd.h"
+#include "smbd/globals.h"
+#include "../librpc/gen_ndr/netlogon.h"
+#include "../libcli/security/security.h"
+#include "printing/pcap.h"
+#include "passdb/lookup_sid.h"
+#include "auth.h"
+
+static int load_registry_service(const char *servicename)
+{
+ if (!lp_registry_shares()) {
+ return -1;
+ }
+
+ if ((servicename == NULL) || (*servicename == '\0')) {
+ return -1;
+ }
+
+ if (strequal(servicename, GLOBAL_NAME)) {
+ return -2;
+ }
+
+ if (!process_registry_service(servicename)) {
+ return -1;
+ }
+
+ return lp_servicenumber(servicename);
+}
+
+void load_registry_shares(void)
+{
+ DEBUG(8, ("load_registry_shares()\n"));
+ if (!lp_registry_shares()) {
+ return;
+ }
+
+ process_registry_shares();
+
+ return;
+}
+
+/****************************************************************************
+ Add a home service. Returns the new service number or -1 if fail.
+****************************************************************************/
+
+int add_home_service(const char *service, const char *username, const char *homedir)
+{
+ int iHomeService;
+
+ if (!service || !homedir || homedir[0] == '\0')
+ return -1;
+
+ if ((iHomeService = lp_servicenumber(HOMES_NAME)) < 0) {
+ if ((iHomeService = load_registry_service(HOMES_NAME)) < 0) {
+ return -1;
+ }
+ }
+
+ /*
+ * If this is a winbindd provided username, remove
+ * the domain component before adding the service.
+ * Log a warning if the "path=" parameter does not
+ * include any macros.
+ */
+
+ {
+ const char *p = strchr(service,*lp_winbind_separator());
+
+ /* We only want the 'user' part of the string */
+ if (p) {
+ service = p + 1;
+ }
+ }
+
+ if (!lp_add_home(service, iHomeService, username, homedir)) {
+ return -1;
+ }
+
+ return lp_servicenumber(service);
+
+}
+
+/**
+ * Find a service entry.
+ *
+ * @param service is modified (to canonical form??)
+ **/
+
+int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out)
+{
+ int iService;
+
+ if (!service_in) {
+ return -1;
+ }
+
+ /* First make a copy. */
+ *p_service_out = talloc_strdup(ctx, service_in);
+ if (!*p_service_out) {
+ return -1;
+ }
+
+ all_string_sub(*p_service_out,"\\","/",0);
+
+ iService = lp_servicenumber(*p_service_out);
+
+ /* now handle the special case of a home directory */
+ if (iService < 0) {
+ char *phome_dir = get_user_home_dir(ctx, *p_service_out);
+
+ if(!phome_dir) {
+ /*
+ * Try mapping the servicename, it may
+ * be a Windows to unix mapped user name.
+ */
+ if(map_username(ctx, *p_service_out, p_service_out)) {
+ if (*p_service_out == NULL) {
+ /* Out of memory. */
+ return -1;
+ }
+ phome_dir = get_user_home_dir(
+ ctx, *p_service_out);
+ }
+ }
+
+ DEBUG(3,("checking for home directory %s gave %s\n",*p_service_out,
+ phome_dir?phome_dir:"(NULL)"));
+
+ iService = add_home_service(*p_service_out,*p_service_out /* 'username' */, phome_dir);
+ }
+
+ /* If we still don't have a service, attempt to add it as a printer. */
+ if (iService < 0) {
+ int iPrinterService;
+
+ if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) < 0) {
+ iPrinterService = load_registry_service(PRINTERS_NAME);
+ }
+ if (iPrinterService >= 0) {
+ DEBUG(3,("checking whether %s is a valid printer name...\n",
+ *p_service_out));
+ if (pcap_printername_ok(*p_service_out)) {
+ DEBUG(3,("%s is a valid printer name\n",
+ *p_service_out));
+ DEBUG(3,("adding %s as a printer service\n",
+ *p_service_out));
+ lp_add_printer(*p_service_out, iPrinterService);
+ iService = lp_servicenumber(*p_service_out);
+ if (iService < 0) {
+ DEBUG(0,("failed to add %s as a printer service!\n",
+ *p_service_out));
+ }
+ } else {
+ DEBUG(3,("%s is not a valid printer name\n",
+ *p_service_out));
+ }
+ }
+ }
+
+ /* Check for default vfs service? Unsure whether to implement this */
+ if (iService < 0) {
+ }
+
+ if (iService < 0) {
+ iService = load_registry_service(*p_service_out);
+ }
+
+ /* Is it a usershare service ? */
+ if (iService < 0 && *lp_usershare_path()) {
+ /* Ensure the name is canonicalized. */
+ strlower_m(*p_service_out);
+ iService = load_usershare_service(*p_service_out);
+ }
+
+ /* just possibly it's a default service? */
+ if (iService < 0) {
+ char *pdefservice = lp_defaultservice();
+ if (pdefservice &&
+ *pdefservice &&
+ !strequal(pdefservice, *p_service_out)
+ && !strstr_m(*p_service_out,"..")) {
+ /*
+ * We need to do a local copy here as lp_defaultservice()
+ * returns one of the rotating lp_string buffers that
+ * could get overwritten by the recursive find_service() call
+ * below. Fix from Josef Hinteregger <joehtg@joehtg.co.at>.
+ */
+ char *defservice = talloc_strdup(ctx, pdefservice);
+
+ if (!defservice) {
+ goto fail;
+ }
+
+ /* Disallow anything except explicit share names. */
+ if (strequal(defservice,HOMES_NAME) ||
+ strequal(defservice, PRINTERS_NAME) ||
+ strequal(defservice, "IPC$")) {
+ TALLOC_FREE(defservice);
+ goto fail;
+ }
+
+ iService = find_service(ctx, defservice, p_service_out);
+ if (!*p_service_out) {
+ TALLOC_FREE(defservice);
+ iService = -1;
+ goto fail;
+ }
+ if (iService >= 0) {
+ all_string_sub(*p_service_out, "_","/",0);
+ iService = lp_add_service(*p_service_out, iService);
+ }
+ TALLOC_FREE(defservice);
+ }
+ }
+
+ if (iService >= 0) {
+ if (!VALID_SNUM(iService)) {
+ DEBUG(0,("Invalid snum %d for %s\n",iService,
+ *p_service_out));
+ iService = -1;
+ }
+ }
+
+ fail:
+
+ if (iService < 0) {
+ DEBUG(3,("find_service() failed to find service %s\n",
+ *p_service_out));
+ }
+
+ return (iService);
+}
+
+
+struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
+ const char *sharename)
+{
+ struct share_params *result;
+ char *sname = NULL;
+ int snum;
+
+ snum = find_service(mem_ctx, sharename, &sname);
+ if (snum < 0 || sname == NULL) {
+ return NULL;
+ }
+
+ if (!(result = talloc(mem_ctx, struct share_params))) {
+ DEBUG(0, ("talloc failed\n"));
+ return NULL;
+ }
+
+ result->service = snum;
+ return result;
+}
diff --git a/source3/passdb/login_cache.c b/source3/passdb/login_cache.c
index 1785a4dacac..a53fe5b24f7 100644
--- a/source3/passdb/login_cache.c
+++ b/source3/passdb/login_cache.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "passdb.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
@@ -58,10 +59,10 @@ bool login_cache_init(void)
bool login_cache_shutdown(void)
{
- /* tdb_close routine returns -1 on error */
+ /* tdb_close routine returns non-zero on error */
if (!cache) return False;
DEBUG(5, ("Closing cache file\n"));
- return tdb_close(cache) != -1;
+ return tdb_close(cache) == 0;
}
/* if we can't read the cache, oh well, no need to return anything */
diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index 5cf391f11c7..8b5330c0974 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -482,8 +482,8 @@ static bool lookup_rids(TALLOC_CTX *mem_ctx, const struct dom_sid *domain_sid,
sid_string_dbg(domain_sid)));
if (num_rids) {
- *names = TALLOC_ZERO_ARRAY(mem_ctx, const char *, num_rids);
- *types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_rids);
+ *names = talloc_zero_array(mem_ctx, const char *, num_rids);
+ *types = talloc_array(mem_ctx, enum lsa_SidType, num_rids);
if ((*names == NULL) || (*types == NULL)) {
return false;
@@ -750,7 +750,7 @@ NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids,
}
if (num_sids) {
- name_infos = TALLOC_ARRAY(mem_ctx, struct lsa_name_info, num_sids);
+ name_infos = talloc_array(mem_ctx, struct lsa_name_info, num_sids);
if (name_infos == NULL) {
result = NT_STATUS_NO_MEMORY;
goto fail;
@@ -759,7 +759,7 @@ NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids,
name_infos = NULL;
}
- dom_infos = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_dom_info,
+ dom_infos = talloc_zero_array(mem_ctx, struct lsa_dom_info,
LSA_REF_DOMAIN_LIST_MULTIPLIER);
if (dom_infos == NULL) {
result = NT_STATUS_NO_MEMORY;
@@ -896,7 +896,7 @@ NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids,
}
if (dom->num_idxs) {
- if (!(rids = TALLOC_ARRAY(tmp_ctx, uint32, dom->num_idxs))) {
+ if (!(rids = talloc_array(tmp_ctx, uint32, dom->num_idxs))) {
result = NT_STATUS_NO_MEMORY;
goto fail;
}
@@ -1404,7 +1404,7 @@ bool sids_to_unix_ids(const struct dom_sid *sids, uint32_t num_sids,
wbcErr err;
bool ret = false;
- wbc_sids = TALLOC_ARRAY(talloc_tos(), struct wbcDomainSid, num_sids);
+ wbc_sids = talloc_array(talloc_tos(), struct wbcDomainSid, num_sids);
if (wbc_sids == NULL) {
return false;
}
@@ -1455,7 +1455,7 @@ bool sids_to_unix_ids(const struct dom_sid *sids, uint32_t num_sids,
if (num_not_cached == 0) {
goto done;
}
- wbc_ids = TALLOC_ARRAY(talloc_tos(), struct wbcUnixId, num_not_cached);
+ wbc_ids = talloc_array(talloc_tos(), struct wbcUnixId, num_not_cached);
if (wbc_ids == NULL) {
goto fail;
}
diff --git a/source3/passdb/machine_account_secrets.c b/source3/passdb/machine_account_secrets.c
index a51a99c9a2f..665e2f89a45 100644
--- a/source3/passdb/machine_account_secrets.c
+++ b/source3/passdb/machine_account_secrets.c
@@ -28,6 +28,7 @@
#include "secrets.h"
#include "dbwrap.h"
#include "../librpc/ndr/libndr.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
@@ -56,6 +57,17 @@ bool secrets_store_domain_sid(const char *domain, const struct dom_sid *sid)
{
bool ret;
+#ifdef _SAMBA_WAF_BUILD_
+ if (strequal(domain, get_global_sam_name()) &&
+ (pdb_capabilities() & PDB_CAP_ADS)) {
+ /* If we have a ADS-capable passdb backend, we
+ * must never make up our own SID, it will
+ * already be in the directory */
+ DEBUG(0, ("Refusing to store a Domain SID, this should be read from the directory not stored here\n"));
+ return false;
+ }
+#endif
+
ret = secrets_store(domain_sid_keystr(domain), sid, sizeof(struct dom_sid ));
/* Force a re-query, in case we modified our domain */
@@ -69,6 +81,24 @@ bool secrets_fetch_domain_sid(const char *domain, struct dom_sid *sid)
struct dom_sid *dyn_sid;
size_t size = 0;
+#ifdef _SAMBA_WAF_BUILD_
+ if (strequal(domain, get_global_sam_name()) &&
+ (pdb_capabilities() & PDB_CAP_ADS)) {
+ struct pdb_domain_info *domain_info;
+ domain_info = pdb_get_domain_info(talloc_tos());
+ if (!domain_info) {
+ /* If we have a ADS-capable passdb backend, we
+ * must never make up our own SID, it will
+ * already be in the directory */
+ DEBUG(0, ("Unable to fetch a Domain SID from the directory!\n"));
+ return false;
+ }
+
+ *sid = domain_info->sid;
+ return true;
+ }
+#endif
+
dyn_sid = (struct dom_sid *)secrets_fetch(domain_sid_keystr(domain), &size);
if (dyn_sid == NULL)
@@ -88,6 +118,17 @@ bool secrets_store_domain_guid(const char *domain, struct GUID *guid)
{
fstring key;
+#ifdef _SAMBA_WAF_BUILD_
+ if (strequal(domain, get_global_sam_name()) &&
+ (pdb_capabilities() & PDB_CAP_ADS)) {
+ /* If we have a ADS-capable passdb backend, we
+ * must never make up our own GUID, it will
+ * already be in the directory */
+ DEBUG(0, ("Refusing to store a Domain GUID, this should be read from the directory not stored here\n"));
+ return false;
+ }
+#endif
+
slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_GUID, domain);
strupper_m(key);
return secrets_store(key, guid, sizeof(struct GUID));
@@ -100,6 +141,24 @@ bool secrets_fetch_domain_guid(const char *domain, struct GUID *guid)
size_t size = 0;
struct GUID new_guid;
+#ifdef _SAMBA_WAF_BUILD_
+ if (strequal(domain, get_global_sam_name()) &&
+ (pdb_capabilities() & PDB_CAP_ADS)) {
+ struct pdb_domain_info *domain_info;
+ domain_info = pdb_get_domain_info(talloc_tos());
+ if (!domain_info) {
+ /* If we have a ADS-capable passdb backend, we
+ * must never make up our own SID, it will
+ * already be in the directory */
+ DEBUG(0, ("Unable to fetch a Domain GUID from the directory!\n"));
+ return false;
+ }
+
+ *guid = domain_info->guid;
+ return true;
+ }
+#endif
+
slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_GUID, domain);
strupper_m(key);
dyn_guid = (struct GUID *)secrets_fetch(key, &size);
diff --git a/source3/passdb/machine_sid.c b/source3/passdb/machine_sid.c
index 8fd51031648..6d4cf237c77 100644
--- a/source3/passdb/machine_sid.c
+++ b/source3/passdb/machine_sid.c
@@ -97,7 +97,7 @@ static struct dom_sid *pdb_generate_sam_sid(void)
}
}
- if (secrets_fetch_domain_sid(global_myname(), sam_sid)) {
+ if (secrets_fetch_domain_sid(lp_netbios_name(), sam_sid)) {
/* We got our sid. If not a pdc/bdc, we're done. */
if ( !IS_DC )
@@ -120,7 +120,7 @@ static struct dom_sid *pdb_generate_sam_sid(void)
/* Domain name sid doesn't match global sam sid. Re-store domain sid as 'local' sid. */
DEBUG(0,("pdb_generate_sam_sid: Mismatched SIDs as a pdc/bdc.\n"));
- if (!secrets_store_domain_sid(global_myname(), &domain_sid)) {
+ if (!secrets_store_domain_sid(lp_netbios_name(), &domain_sid)) {
DEBUG(0,("pdb_generate_sam_sid: Can't re-store domain SID for local sid as PDC/BDC.\n"));
SAFE_FREE(sam_sid);
return NULL;
@@ -139,7 +139,7 @@ static struct dom_sid *pdb_generate_sam_sid(void)
if (read_sid_from_file(fname, sam_sid)) {
/* remember it for future reference and unlink the old MACHINE.SID */
- if (!secrets_store_domain_sid(global_myname(), sam_sid)) {
+ if (!secrets_store_domain_sid(lp_netbios_name(), sam_sid)) {
DEBUG(0,("pdb_generate_sam_sid: Failed to store SID from file.\n"));
SAFE_FREE(fname);
SAFE_FREE(sam_sid);
@@ -166,7 +166,7 @@ static struct dom_sid *pdb_generate_sam_sid(void)
generate one and save it */
generate_random_sid(sam_sid);
- if (!secrets_store_domain_sid(global_myname(), sam_sid)) {
+ if (!secrets_store_domain_sid(lp_netbios_name(), sam_sid)) {
DEBUG(0,("pdb_generate_sam_sid: Failed to store generated machine SID.\n"));
SAFE_FREE(sam_sid);
return NULL;
diff --git a/source3/passdb/machine_sid.h b/source3/passdb/machine_sid.h
index 2da281ac34c..12fde2f3ac6 100644
--- a/source3/passdb/machine_sid.h
+++ b/source3/passdb/machine_sid.h
@@ -1,3 +1,24 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Password and authentication handling
+ * Copyright (C) Jeremy Allison 1996-2002
+ * Copyright (C) Andrew Tridgell 2002
+ * Copyright (C) Gerald (Jerry) Carter 2000
+ * Copyright (C) Stefan (metze) Metzmacher 2002
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
/* The following definitions come from passdb/machine_sid.c */
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 62af5be7eb4..5116396cd1b 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -29,6 +29,7 @@
#include "secrets.h"
#include "../libcli/security/security.h"
#include "../lib/util/util_pw.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
@@ -45,7 +46,7 @@ const char *my_sam_name(void)
{
/* Standalone servers can only use the local netbios name */
if ( lp_server_role() == ROLE_STANDALONE )
- return global_myname();
+ return lp_netbios_name();
/* Default to the DOMAIN name when not specified */
return lp_workgroup();
@@ -73,7 +74,7 @@ struct samu *samu_new( TALLOC_CTX *ctx )
{
struct samu *user;
- if ( !(user = TALLOC_ZERO_P( ctx, struct samu )) ) {
+ if ( !(user = talloc_zero( ctx, struct samu )) ) {
DEBUG(0,("samuser_new: Talloc failed!\n"));
return NULL;
}
@@ -148,7 +149,7 @@ static int count_commas(const char *str)
static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *pwd, bool create)
{
const char *guest_account = lp_guestaccount();
- const char *domain = global_myname();
+ const char *domain = lp_netbios_name();
char *fullname;
uint32_t urid;
@@ -384,9 +385,9 @@ void pdb_sethexpwd(char p[33], const unsigned char *pwd, uint32_t acct_ctrl)
slprintf(&p[i*2], 3, "%02X", pwd[i]);
} else {
if (acct_ctrl & ACB_PWNOTREQ)
- safe_strcpy(p, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX", 32);
+ strlcpy(p, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX", 33);
else
- safe_strcpy(p, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 32);
+ strlcpy(p, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 33);
}
}
@@ -435,7 +436,7 @@ void pdb_sethexhours(char *p, const unsigned char *hours)
slprintf(&p[i*2], 3, "%02X", hours[i]);
}
} else {
- safe_strcpy(p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 43);
+ strlcpy(p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 44);
}
}
@@ -2354,7 +2355,7 @@ bool get_trust_pw_clear(const char *domain, char **ret_pwd,
if (pwd != NULL) {
*ret_pwd = pwd;
if (account_name != NULL) {
- *account_name = global_myname();
+ *account_name = lp_netbios_name();
}
return true;
@@ -2392,7 +2393,7 @@ bool get_trust_pw_hash(const char *domain, uint8_t ret_pwd[16],
channel))
{
if (account_name != NULL) {
- *account_name = global_myname();
+ *account_name = lp_netbios_name();
}
return true;
diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c
index 6c1a2ab23d7..eec82f9c984 100644
--- a/source3/passdb/pdb_get_set.c
+++ b/source3/passdb/pdb_get_set.c
@@ -123,8 +123,7 @@ time_t pdb_get_pass_must_change_time(const struct samu *sampass)
bool pdb_get_pass_can_change(const struct samu *sampass)
{
- if (sampass->pass_can_change_time == get_time_t_max() &&
- sampass->pass_last_set_time != 0)
+ if (sampass->pass_can_change_time == get_time_t_max())
return False;
return True;
}
@@ -512,7 +511,7 @@ bool pdb_set_group_sid(struct samu *sampass, const struct dom_sid *g_sid, enum p
if (!g_sid)
return False;
- if ( !(sampass->group_sid = TALLOC_P( sampass, struct dom_sid )) ) {
+ if ( !(sampass->group_sid = talloc( sampass, struct dom_sid )) ) {
return False;
}
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 36d5aaa01a7..94ed355e2c5 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -25,6 +25,8 @@
#include "passdb.h"
#include "secrets.h"
#include "../librpc/gen_ndr/samr.h"
+#include "../librpc/gen_ndr/drsblobs.h"
+#include "../librpc/gen_ndr/ndr_drsblobs.h"
#include "memcache.h"
#include "nsswitch/winbind_client.h"
#include "../libcli/security/security.h"
@@ -1518,7 +1520,7 @@ static NTSTATUS pdb_default_enum_group_members(struct pdb_methods *methods,
if (num_uids == 0)
return NT_STATUS_OK;
- *pp_member_rids = TALLOC_ZERO_ARRAY(mem_ctx, uint32_t, num_uids);
+ *pp_member_rids = talloc_zero_array(mem_ctx, uint32_t, num_uids);
for (i=0; i<num_uids; i++) {
struct dom_sid sid;
@@ -1570,7 +1572,7 @@ static NTSTATUS pdb_default_enum_group_memberships(struct pdb_methods *methods,
smb_panic("primary group missing");
}
- *pp_sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, *p_num_groups);
+ *pp_sids = talloc_array(mem_ctx, struct dom_sid, *p_num_groups);
if (*pp_sids == NULL) {
TALLOC_FREE(*pp_gids);
@@ -2144,7 +2146,62 @@ static NTSTATUS pdb_default_get_trusted_domain(struct pdb_methods *methods,
const char *domain,
struct pdb_trusted_domain **td)
{
- return NT_STATUS_NOT_IMPLEMENTED;
+ struct trustAuthInOutBlob taiob;
+ struct AuthenticationInformation aia;
+ struct pdb_trusted_domain *tdom;
+ enum ndr_err_code ndr_err;
+ time_t last_set_time;
+ char *pwd;
+ bool ok;
+
+ tdom = talloc(mem_ctx, struct pdb_trusted_domain);
+ if (!tdom) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ tdom->domain_name = talloc_strdup(tdom, domain);
+ tdom->netbios_name = talloc_strdup(tdom, domain);
+ if (!tdom->domain_name || !tdom->netbios_name) {
+ talloc_free(tdom);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ tdom->trust_auth_incoming = data_blob_null;
+
+ ok = pdb_get_trusteddom_pw(domain, &pwd, &tdom->security_identifier,
+ &last_set_time);
+ if (!ok) {
+ talloc_free(tdom);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ ZERO_STRUCT(taiob);
+ ZERO_STRUCT(aia);
+ taiob.count = 1;
+ taiob.current.count = 1;
+ taiob.current.array = &aia;
+ unix_to_nt_time(&aia.LastUpdateTime, last_set_time);
+ aia.AuthType = TRUST_AUTH_TYPE_CLEAR;
+ aia.AuthInfo.clear.password = (uint8_t *) pwd;
+ aia.AuthInfo.clear.size = strlen(pwd);
+ taiob.previous.count = 0;
+ taiob.previous.array = NULL;
+
+ ndr_err = ndr_push_struct_blob(&tdom->trust_auth_outgoing,
+ tdom, &taiob,
+ (ndr_push_flags_fn_t)ndr_push_trustAuthInOutBlob);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(tdom);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ tdom->trust_direction = LSA_TRUST_DIRECTION_OUTBOUND;
+ tdom->trust_type = LSA_TRUST_TYPE_DOWNLEVEL;
+ tdom->trust_attributes = 0;
+ tdom->trust_forest_trust_info = data_blob_null;
+
+ *td = tdom;
+ return NT_STATUS_OK;
}
static NTSTATUS pdb_default_get_trusted_domain_by_sid(struct pdb_methods *methods,
@@ -2155,11 +2212,54 @@ static NTSTATUS pdb_default_get_trusted_domain_by_sid(struct pdb_methods *method
return NT_STATUS_NOT_IMPLEMENTED;
}
+#define IS_NULL_DATA_BLOB(d) ((d).data == NULL && (d).length == 0)
+
static NTSTATUS pdb_default_set_trusted_domain(struct pdb_methods *methods,
const char* domain,
const struct pdb_trusted_domain *td)
{
- return NT_STATUS_NOT_IMPLEMENTED;
+ struct trustAuthInOutBlob taiob;
+ struct AuthenticationInformation *aia;
+ enum ndr_err_code ndr_err;
+ char *pwd;
+ bool ok;
+
+ if (td->trust_attributes != 0 ||
+ td->trust_type != LSA_TRUST_TYPE_DOWNLEVEL ||
+ td->trust_direction != LSA_TRUST_DIRECTION_OUTBOUND ||
+ !IS_NULL_DATA_BLOB(td->trust_auth_incoming) ||
+ !IS_NULL_DATA_BLOB(td->trust_forest_trust_info)) {
+ return NT_STATUS_NOT_IMPLEMENTED;
+ }
+
+ ZERO_STRUCT(taiob);
+ ndr_err = ndr_pull_struct_blob(&td->trust_auth_outgoing, talloc_tos(),
+ &taiob,
+ (ndr_pull_flags_fn_t)ndr_pull_trustAuthInOutBlob);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ aia = (struct AuthenticationInformation *) taiob.current.array;
+
+ if (taiob.count != 1 || taiob.current.count != 1 ||
+ taiob.previous.count != 0 ||
+ aia->AuthType != TRUST_AUTH_TYPE_CLEAR) {
+ return NT_STATUS_NOT_IMPLEMENTED;
+ }
+
+ pwd = talloc_strndup(talloc_tos(), (char *) aia->AuthInfo.clear.password,
+ aia->AuthInfo.clear.size);
+ if (!pwd) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ok = pdb_set_trusteddom_pw(domain, pwd, &td->security_identifier);
+ if (!ok) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ return NT_STATUS_OK;
}
static NTSTATUS pdb_default_del_trusted_domain(struct pdb_methods *methods,
diff --git a/source3/passdb/pdb_ipa.c b/source3/passdb/pdb_ipa.c
index 5f89be7a29f..02f7bb68888 100644
--- a/source3/passdb/pdb_ipa.c
+++ b/source3/passdb/pdb_ipa.c
@@ -636,7 +636,7 @@ static NTSTATUS ipasam_enum_trusted_domains(struct pdb_methods *methods,
}
*num_domains = 0;
- if (!(*domains = TALLOC_ARRAY(mem_ctx, struct pdb_trusted_domain *, 1))) {
+ if (!(*domains = talloc_array(mem_ctx, struct pdb_trusted_domain *, 1))) {
DEBUG(1, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
@@ -684,7 +684,7 @@ static NTSTATUS ipasam_enum_trusteddoms(struct pdb_methods *methods,
return NT_STATUS_OK;
}
- if (!(*domains = TALLOC_ARRAY(mem_ctx, struct trustdom_info *,
+ if (!(*domains = talloc_array(mem_ctx, struct trustdom_info *,
*num_domains))) {
DEBUG(1, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
@@ -693,7 +693,7 @@ static NTSTATUS ipasam_enum_trusteddoms(struct pdb_methods *methods,
for (i = 0; i < *num_domains; i++) {
struct trustdom_info *dom_info;
- dom_info = TALLOC_P(*domains, struct trustdom_info);
+ dom_info = talloc(*domains, struct trustdom_info);
if (dom_info == NULL) {
DEBUG(1, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 7ce5edcefa9..f8da0ff2553 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -208,7 +208,7 @@ static NTSTATUS ldapsam_get_seq_num(struct pdb_methods *my_methods, time_t *seq_
if (mem_ctx == NULL)
return NT_STATUS_NO_MEMORY;
- if ((attrs = TALLOC_ARRAY(mem_ctx, const char *, 2)) == NULL) {
+ if ((attrs = talloc_array(mem_ctx, const char *, 2)) == NULL) {
ntstatus = NT_STATUS_NO_MEMORY;
goto done;
}
@@ -887,7 +887,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
if (pwHistLen > 0){
uint8 *pwhist = NULL;
int i;
- char *history_string = TALLOC_ARRAY(ctx, char,
+ char *history_string = talloc_array(ctx, char,
MAX_PW_HISTORY_LEN*64);
if (!history_string) {
@@ -896,7 +896,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
pwHistLen = MIN(pwHistLen, MAX_PW_HISTORY_LEN);
- pwhist = TALLOC_ARRAY(ctx, uint8,
+ pwhist = talloc_array(ctx, uint8,
pwHistLen * PW_HISTORY_ENTRY_LEN);
if (pwhist == NULL) {
DEBUG(0, ("init_sam_from_ldap: talloc failed!\n"));
@@ -1532,7 +1532,7 @@ static void append_attr(TALLOC_CTX *mem_ctx, const char ***attr_list,
;
}
- (*attr_list) = TALLOC_REALLOC_ARRAY(mem_ctx, (*attr_list),
+ (*attr_list) = talloc_realloc(mem_ctx, (*attr_list),
const char *, i+2);
SMB_ASSERT((*attr_list) != NULL);
(*attr_list)[i] = talloc_strdup((*attr_list), new_attr);
@@ -4340,7 +4340,7 @@ static const char **talloc_attrs(TALLOC_CTX *mem_ctx, ...)
num += 1;
va_end(ap);
- if ((result = TALLOC_ARRAY(mem_ctx, const char *, num+1)) == NULL) {
+ if ((result = talloc_array(mem_ctx, const char *, num+1)) == NULL) {
return NULL;
}
@@ -4564,7 +4564,7 @@ static bool ldapuser2displayentry(struct ldap_search_state *state,
return False;
}
if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **, &result->account_name),
+ discard_const_p(char *, &result->account_name),
vals[0], &converted_size))
{
DEBUG(0,("ldapuser2displayentry: pull_utf8_talloc failed: %s",
@@ -4577,7 +4577,7 @@ static bool ldapuser2displayentry(struct ldap_search_state *state,
if ((vals == NULL) || (vals[0] == NULL))
DEBUG(8, ("\"displayName\" not found\n"));
else if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **, &result->fullname),
+ discard_const_p(char *, &result->fullname),
vals[0], &converted_size))
{
DEBUG(0,("ldapuser2displayentry: pull_utf8_talloc failed: %s",
@@ -4590,7 +4590,7 @@ static bool ldapuser2displayentry(struct ldap_search_state *state,
if ((vals == NULL) || (vals[0] == NULL))
DEBUG(8, ("\"description\" not found\n"));
else if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **, &result->description),
+ discard_const_p(char *, &result->description),
vals[0], &converted_size))
{
DEBUG(0,("ldapuser2displayentry: pull_utf8_talloc failed: %s",
@@ -4724,7 +4724,7 @@ static bool ldapgroup2displayentry(struct ldap_search_state *state,
return False;
}
if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **,
+ discard_const_p(char *,
&result->account_name),
vals[0], &converted_size))
{
@@ -4733,7 +4733,7 @@ static bool ldapgroup2displayentry(struct ldap_search_state *state,
}
}
else if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **,
+ discard_const_p(char *,
&result->account_name),
vals[0], &converted_size))
{
@@ -4747,7 +4747,7 @@ static bool ldapgroup2displayentry(struct ldap_search_state *state,
if ((vals == NULL) || (vals[0] == NULL))
DEBUG(8, ("\"description\" not found\n"));
else if (!pull_utf8_talloc(mem_ctx,
- CONST_DISCARD(char **, &result->description),
+ discard_const_p(char *, &result->description),
vals[0], &converted_size))
{
DEBUG(0,("ldapgroup2displayentry: pull_utf8_talloc failed: %s",
@@ -6356,7 +6356,7 @@ static NTSTATUS ldapsam_enum_trusteddoms(struct pdb_methods *methods,
}
*num_domains = 0;
- if (!(*domains = TALLOC_ARRAY(mem_ctx, struct trustdom_info *, 1))) {
+ if (!(*domains = talloc_array(mem_ctx, struct trustdom_info *, 1))) {
DEBUG(1, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
@@ -6368,7 +6368,7 @@ static NTSTATUS ldapsam_enum_trusteddoms(struct pdb_methods *methods,
char *dom_name, *dom_sid_str;
struct trustdom_info *dom_info;
- dom_info = TALLOC_P(*domains, struct trustdom_info);
+ dom_info = talloc(*domains, struct trustdom_info);
if (dom_info == NULL) {
DEBUG(1, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
@@ -6480,7 +6480,7 @@ static NTSTATUS pdb_init_ldapsam_common(struct pdb_methods **pdb_method, const c
/* TODO: Setup private data and free */
- if ( !(ldap_state = TALLOC_ZERO_P(*pdb_method, struct ldapsam_privates)) ) {
+ if ( !(ldap_state = talloc_zero(*pdb_method, struct ldapsam_privates)) ) {
DEBUG(0, ("pdb_init_ldapsam_common: talloc() failed for ldapsam private_data!\n"));
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/passdb/pdb_samba4.c b/source3/passdb/pdb_samba4.c
new file mode 100644
index 00000000000..5848c23de8e
--- /dev/null
+++ b/source3/passdb/pdb_samba4.c
@@ -0,0 +1,2100 @@
+/*
+ Unix SMB/CIFS implementation.
+ pdb glue module for samba4
+ Copyright (C) Volker Lendecke 2009-2011
+ Copyright (C) Andrew Bartlett 2010
+ Copyright (C) Matthias Dieter Wallnöfer 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This module, is a port of Volker's pdb_ads to ldb and DSDB APIs */
+
+#include "includes.h"
+#include "source3/include/passdb.h"
+#include "source4/dsdb/samdb/samdb.h"
+#include "ldb_errors.h"
+#include "libcli/security/dom_sid.h"
+#include "source4/winbind/idmap.h"
+#include "librpc/gen_ndr/ndr_security.h"
+#include "libds/common/flag_mapping.h"
+#include "source4/lib/events/events.h"
+#include "source4/auth/session.h"
+#include "source4/auth/system_session_proto.h"
+#include "source4/param/param.h"
+
+struct pdb_samba4_state {
+ struct tevent_context *ev;
+ struct ldb_context *ldb;
+ struct idmap_context *idmap_ctx;
+ struct loadparm_context *lp_ctx;
+};
+
+static NTSTATUS pdb_samba4_getsampwsid(struct pdb_methods *m,
+ struct samu *sam_acct,
+ const struct dom_sid *sid);
+static NTSTATUS pdb_samba4_getsamupriv(struct pdb_samba4_state *state,
+ const char *filter,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_message **pmsg);
+static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
+ union unid_t *id, enum lsa_SidType *type);
+
+static bool pdb_samba4_pull_time(struct ldb_message *msg, const char *attr,
+ time_t *ptime)
+{
+ uint64_t tmp;
+ if (! ldb_msg_find_element(msg, attr)) {
+ return false;
+ }
+ tmp = ldb_msg_find_attr_as_uint64(msg, attr, 0);
+ *ptime = uint64s_nt_time_to_unix_abs(&tmp);
+ return true;
+}
+
+static struct pdb_domain_info *pdb_samba4_get_domain_info(
+ struct pdb_methods *m, TALLOC_CTX *mem_ctx)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct pdb_domain_info *info;
+ struct dom_sid *domain_sid;
+ struct ldb_dn *forest_dn, *domain_dn;
+ struct ldb_result *dom_res = NULL;
+ const char *dom_attrs[] = {
+ "objectSid",
+ "objectGUID",
+ "nTMixedDomain",
+ "fSMORoleOwner",
+ NULL
+ };
+ char *p;
+ int ret;
+
+ info = talloc(mem_ctx, struct pdb_domain_info);
+ if (info == NULL) {
+ return NULL;
+ }
+
+ domain_dn = ldb_get_default_basedn(state->ldb);
+
+ ret = ldb_search(state->ldb, info, &dom_res,
+ domain_dn, LDB_SCOPE_BASE, dom_attrs, NULL);
+ if (ret != LDB_SUCCESS) {
+ goto fail;
+ }
+ if (dom_res->count != 1) {
+ goto fail;
+ }
+
+ info->guid = samdb_result_guid(dom_res->msgs[0], "objectGUID");
+
+ domain_sid = samdb_result_dom_sid(state, dom_res->msgs[0], "objectSid");
+ if (!domain_sid) {
+ goto fail;
+ }
+ info->sid = *domain_sid;
+
+ TALLOC_FREE(dom_res);
+
+ info->name = talloc_strdup(info, lpcfg_sam_name(state->lp_ctx));
+ info->dns_domain = ldb_dn_canonical_string(info, domain_dn);
+
+ if (!info->dns_domain) {
+ goto fail;
+ }
+ p = strchr(info->dns_domain, '/');
+ if (p) {
+ *p = '\0';
+ }
+
+ forest_dn = ldb_get_root_basedn(state->ldb);
+ if (!forest_dn) {
+ goto fail;
+ }
+
+ info->dns_forest = ldb_dn_canonical_string(info, forest_dn);
+ if (!info->dns_forest) {
+ goto fail;
+ }
+ p = strchr(info->dns_forest, '/');
+ if (p) {
+ *p = '\0';
+ }
+
+ return info;
+
+fail:
+ TALLOC_FREE(dom_res);
+ TALLOC_FREE(info);
+ return NULL;
+}
+
+static struct ldb_message *pdb_samba4_get_samu_private(
+ struct pdb_methods *m, struct samu *sam)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct ldb_message *msg;
+ char *sidstr, *filter;
+ NTSTATUS status;
+
+ msg = (struct ldb_message *)
+ pdb_get_backend_private_data(sam, m);
+
+ if (msg != NULL) {
+ return talloc_get_type_abort(msg, struct ldb_message);
+ }
+
+ sidstr = dom_sid_string(talloc_tos(), pdb_get_user_sid(sam));
+ if (sidstr == NULL) {
+ return NULL;
+ }
+
+ filter = talloc_asprintf(
+ talloc_tos(), "(&(objectsid=%s)(objectclass=user))", sidstr);
+ TALLOC_FREE(sidstr);
+ if (filter == NULL) {
+ return NULL;
+ }
+
+ status = pdb_samba4_getsamupriv(state, filter, sam, &msg);
+ TALLOC_FREE(filter);
+ if (!NT_STATUS_IS_OK(status)) {
+ return NULL;
+ }
+
+ return msg;
+}
+
+static NTSTATUS pdb_samba4_init_sam_from_priv(struct pdb_methods *m,
+ struct samu *sam,
+ struct ldb_message *msg)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status = NT_STATUS_INTERNAL_DB_CORRUPTION;
+ const char *str;
+ time_t tmp_time;
+ struct dom_sid *sid, group_sid;
+ uint64_t n;
+ const DATA_BLOB *blob;
+
+ str = ldb_msg_find_attr_as_string(msg, "samAccountName", NULL);
+ if (str == NULL) {
+ DEBUG(10, ("no samAccountName\n"));
+ goto fail;
+ }
+ pdb_set_username(sam, str, PDB_SET);
+
+ if (pdb_samba4_pull_time(msg, "lastLogon", &tmp_time)) {
+ pdb_set_logon_time(sam, tmp_time, PDB_SET);
+ }
+ if (pdb_samba4_pull_time(msg, "lastLogoff", &tmp_time)) {
+ pdb_set_logoff_time(sam, tmp_time, PDB_SET);
+ }
+ if (pdb_samba4_pull_time(msg, "pwdLastSet", &tmp_time)) {
+ pdb_set_pass_last_set_time(sam, tmp_time, PDB_SET);
+ }
+ if (pdb_samba4_pull_time(msg, "accountExpires", &tmp_time)) {
+ pdb_set_kickoff_time(sam, tmp_time, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "displayName",
+ NULL);
+ if (str != NULL) {
+ pdb_set_fullname(sam, str, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "homeDirectory",
+ NULL);
+ if (str != NULL) {
+ pdb_set_homedir(sam, str, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "homeDrive", NULL);
+ if (str != NULL) {
+ pdb_set_dir_drive(sam, str, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "scriptPath", NULL);
+ if (str != NULL) {
+ pdb_set_logon_script(sam, str, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "profilePath",
+ NULL);
+ if (str != NULL) {
+ pdb_set_profile_path(sam, str, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "profilePath",
+ NULL);
+ if (str != NULL) {
+ pdb_set_profile_path(sam, str, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "comment",
+ NULL);
+ if (str != NULL) {
+ pdb_set_comment(sam, str, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "description",
+ NULL);
+ if (str != NULL) {
+ pdb_set_acct_desc(sam, str, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "userWorkstations",
+ NULL);
+ if (str != NULL) {
+ pdb_set_workstations(sam, str, PDB_SET);
+ }
+
+ str = ldb_msg_find_attr_as_string(msg, "userParameters",
+ NULL);
+ if (str != NULL) {
+ pdb_set_munged_dial(sam, str, PDB_SET);
+ }
+
+ sid = samdb_result_dom_sid(talloc_tos(), msg, "objectSid");
+ if (!sid) {
+ DEBUG(10, ("Could not pull SID\n"));
+ goto fail;
+ }
+ pdb_set_user_sid(sam, sid, PDB_SET);
+
+ n = ldb_msg_find_attr_as_uint(msg, "userAccountControl", 0);
+ if (n == 0) {
+ DEBUG(10, ("Could not pull userAccountControl\n"));
+ goto fail;
+ }
+ pdb_set_acct_ctrl(sam, ds_uf2acb(n), PDB_SET);
+
+ blob = ldb_msg_find_ldb_val(msg, "unicodePwd");
+ if (blob) {
+ if (blob->length != NT_HASH_LEN) {
+ DEBUG(0, ("Got NT hash of length %d, expected %d\n",
+ (int)blob->length, NT_HASH_LEN));
+ goto fail;
+ }
+ pdb_set_nt_passwd(sam, blob->data, PDB_SET);
+ }
+
+ blob = ldb_msg_find_ldb_val(msg, "dBCSPwd");
+ if (blob) {
+ if (blob->length != LM_HASH_LEN) {
+ DEBUG(0, ("Got LM hash of length %d, expected %d\n",
+ (int)blob->length, LM_HASH_LEN));
+ goto fail;
+ }
+ pdb_set_lanman_passwd(sam, blob->data, PDB_SET);
+ }
+
+ n = ldb_msg_find_attr_as_uint(msg, "primaryGroupID", 0);
+ if (n == 0) {
+ DEBUG(10, ("Could not pull primaryGroupID\n"));
+ goto fail;
+ }
+ sid_compose(&group_sid, samdb_domain_sid(state->ldb), n);
+ pdb_set_group_sid(sam, &group_sid, PDB_SET);
+
+ status = NT_STATUS_OK;
+fail:
+ TALLOC_FREE(frame);
+ return status;
+}
+
+static bool pdb_samba4_add_time(struct ldb_message *msg,
+ const char *attrib, time_t t)
+{
+ uint64_t nt_time;
+
+ unix_to_nt_time(&nt_time, t);
+
+ return ldb_msg_add_fmt(msg, attrib, "%llu", (unsigned long long) nt_time);
+}
+
+/* Like in pdb_ldap(), this will need to be a function pointer when we
+ * start to support 'adds' for migrations from samba3 passdb backends
+ * to samba4 */
+static bool update_required(struct samu *sam, enum pdb_elements element)
+{
+ return (IS_SAM_CHANGED(sam, element));
+}
+
+static bool pdb_samba4_init_samba4_from_sam(struct pdb_samba4_state *state,
+ struct ldb_message *existing,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_message **pmods,
+ struct samu *sam)
+{
+ int ret = LDB_SUCCESS;
+ const char *pw;
+ struct ldb_message *msg;
+
+ /* TODO: All fields :-) */
+
+ msg = ldb_msg_new(mem_ctx);
+ if (!msg) {
+ return false;
+ }
+
+ msg->dn = existing->dn;
+
+ pw = pdb_get_plaintext_passwd(sam);
+ if (update_required(sam, PDB_PLAINTEXT_PW)) {
+ if (pw == NULL) {
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto fail;
+ }
+
+ ret |= ldb_msg_add_string(msg, "clearTextPassword", pw);
+ }
+
+ if (update_required(sam, PDB_FULLNAME)) {
+ ret |= ldb_msg_add_string(msg, "displayName", pdb_get_fullname(sam));
+ }
+
+ if (update_required(sam, PDB_SMBHOME)) {
+ ret |= ldb_msg_add_string(msg, "homeDirectory",
+ pdb_get_homedir(sam));
+ }
+
+ if (update_required(sam, PDB_PROFILE)) {
+ ret |= ldb_msg_add_string(msg, "profilePath",
+ pdb_get_profile_path(sam));
+ }
+
+ if (update_required(sam, PDB_DRIVE)) {
+ ret |= ldb_msg_add_string(msg, "homeDrive",
+ pdb_get_dir_drive(sam));
+ }
+
+ if (update_required(sam, PDB_LOGONSCRIPT)) {
+ ret |= ldb_msg_add_string(msg, "scriptPath",
+ pdb_get_logon_script(sam));
+ }
+
+ if (update_required(sam, PDB_KICKOFFTIME)) {
+ ret |= pdb_samba4_add_time(msg, "accountExpires",
+ pdb_get_kickoff_time(sam));
+ }
+
+ if (update_required(sam, PDB_USERNAME)) {
+ ret |= ldb_msg_add_string(msg, "samAccountName",
+ pdb_get_username(sam));
+ }
+
+ if (update_required(sam, PDB_HOURSLEN) || update_required(sam, PDB_HOURS)) {
+ struct ldb_val hours = data_blob_const(pdb_get_hours(sam), pdb_get_hours_len(sam));
+ ret |= ldb_msg_add_value(msg, "logonHours",
+ &hours, NULL);
+ }
+
+ if (update_required(sam, PDB_ACCTCTRL)) {
+ ret |= ldb_msg_add_fmt(msg, "userAccountControl",
+ "%d", ds_acb2uf(pdb_get_acct_ctrl(sam)));
+ }
+
+ if (update_required(sam, PDB_COMMENT)) {
+ ret |= ldb_msg_add_string(msg, "comment",
+ pdb_get_comment(sam));
+ }
+
+ if (update_required(sam, PDB_ACCTDESC)) {
+ ret |= ldb_msg_add_string(msg, "description",
+ pdb_get_acct_desc(sam));
+ }
+
+ if (update_required(sam, PDB_WORKSTATIONS)) {
+ ret |= ldb_msg_add_string(msg, "userWorkstations",
+ pdb_get_workstations(sam));
+ }
+
+ /* This will need work, it is actually a UTF8 'string' with internal NULLs, to handle TS parameters */
+ if (update_required(sam, PDB_MUNGEDDIAL)) {
+ ret |= ldb_msg_add_string(msg, "userParameters",
+ pdb_get_munged_dial(sam));
+ }
+
+ if (update_required(sam, PDB_COUNTRY_CODE)) {
+ ret |= ldb_msg_add_fmt(msg, "countryCode",
+ "%i", (int)pdb_get_country_code(sam));
+ }
+
+ if (update_required(sam, PDB_CODE_PAGE)) {
+ ret |= ldb_msg_add_fmt(msg, "codePage",
+ "%i", (int)pdb_get_code_page(sam));
+ }
+
+ /* Not yet handled here or not meaningful for modifies on a Samba4 backend:
+ PDB_LOGONTIME,
+ PDB_LOGOFFTIME,
+ PDB_BAD_PASSWORD_TIME,
+ PDB_CANCHANGETIME,
+ PDB_MUSTCHANGETIME,
+ PDB_DOMAIN,
+ PDB_NTUSERNAME,
+ PDB_LOGONDIVS,
+ PDB_USERSID,
+ PDB_GROUPSID,
+ PDB_PASSLASTSET,
+ PDB_FIELDS_PRESENT,
+ PDB_BAD_PASSWORD_COUNT,
+ PDB_LOGON_COUNT,
+ PDB_UNKNOWN6,
+ PDB_LMPASSWD,
+ PDB_NTPASSWD,
+ PDB_PWHISTORY,
+ PDB_BACKEND_PRIVATE_DATA,
+
+ */
+
+ *pmods = msg;
+fail:
+ return ret == LDB_SUCCESS;
+}
+
+static NTSTATUS pdb_samba4_getsamupriv(struct pdb_samba4_state *state,
+ const char *filter,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_message **msg)
+{
+ const char * attrs[] = {
+ "lastLogon", "lastLogoff", "pwdLastSet", "accountExpires",
+ "sAMAccountName", "displayName", "homeDirectory",
+ "homeDrive", "scriptPath", "profilePath", "description",
+ "userWorkstations", "comment", "userParameters", "objectSid",
+ "primaryGroupID", "userAccountControl", "logonHours",
+ "badPwdCount", "logonCount", "countryCode", "codePage",
+ "unicodePwd", "dBCSPwd", NULL };
+
+ int rc = dsdb_search_one(state->ldb, mem_ctx, msg, NULL, LDB_SCOPE_SUBTREE, attrs, 0, "%s", filter);
+ if (rc != LDB_SUCCESS) {
+ DEBUG(10, ("ldap_search failed %s\n",
+ ldb_errstring(state->ldb)));
+ return NT_STATUS_LDAP(rc);
+ }
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_getsampwfilter(struct pdb_methods *m,
+ struct pdb_samba4_state *state,
+ struct samu *sam_acct,
+ const char *exp_fmt, ...) _PRINTF_ATTRIBUTE(4, 5)
+{
+ struct ldb_message *priv;
+ NTSTATUS status;
+ va_list ap;
+ char *expression = NULL;
+ TALLOC_CTX *tmp_ctx = talloc_new(state);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ va_start(ap, exp_fmt);
+ expression = talloc_vasprintf(tmp_ctx, exp_fmt, ap);
+ va_end(ap);
+
+ if (!expression) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = pdb_samba4_getsamupriv(state, expression, sam_acct, &priv);
+ talloc_free(tmp_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(10, ("pdb_samba4_getsamupriv failed: %s\n",
+ nt_errstr(status)));
+ return status;
+ }
+
+ status = pdb_samba4_init_sam_from_priv(m, sam_acct, priv);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(10, ("pdb_samba4_init_sam_from_priv failed: %s\n",
+ nt_errstr(status)));
+ TALLOC_FREE(priv);
+ return status;
+ }
+
+ pdb_set_backend_private_data(sam_acct, priv, NULL, m, PDB_SET);
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_getsampwnam(struct pdb_methods *m,
+ struct samu *sam_acct,
+ const char *username)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+
+ return pdb_samba4_getsampwfilter(m, state, sam_acct,
+ "(&(samaccountname=%s)(objectclass=user))",
+ username);
+}
+
+static NTSTATUS pdb_samba4_getsampwsid(struct pdb_methods *m,
+ struct samu *sam_acct,
+ const struct dom_sid *sid)
+{
+ NTSTATUS status;
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ char *sidstr;
+
+ sidstr = dom_sid_string(talloc_tos(), sid);
+ NT_STATUS_HAVE_NO_MEMORY(sidstr);
+
+ status = pdb_samba4_getsampwfilter(m, state, sam_acct,
+ "(&(objectsid=%s)(objectclass=user))",
+ sidstr);
+ talloc_free(sidstr);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_create_user(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ const char *name, uint32 acct_flags,
+ uint32 *rid)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct dom_sid *sid;
+ struct ldb_dn *dn;
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ /* Internally this uses transactions to ensure all the steps
+ * happen or fail as one */
+ status = dsdb_add_user(state->ldb, tmp_ctx, name, acct_flags, &sid, &dn);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+ sid_peek_rid(sid, rid);
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_delete_user(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ struct samu *sam)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct ldb_dn *dn;
+ int rc;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ dn = ldb_dn_new_fmt(tmp_ctx, state->ldb, "<SID=%s>", dom_sid_string(tmp_ctx, pdb_get_user_sid(sam)));
+ if (!dn || !ldb_dn_validate(dn)) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ rc = ldb_delete(state->ldb, dn);
+
+ if (rc != LDB_SUCCESS) {
+ DEBUG(10, ("ldb_delete for %s failed: %s\n", ldb_dn_get_linearized(dn),
+ ldb_errstring(state->ldb)));
+ talloc_free(tmp_ctx);
+ return NT_STATUS_LDAP(rc);
+ }
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OK;
+}
+
+/* This interface takes a fully populated struct samu and places it in
+ * the database. This is not implemented at this time as we need to
+ * be careful around the creation of arbitary SIDs (ie, we must ensrue
+ * they are not left in a RID pool */
+static NTSTATUS pdb_samba4_add_sam_account(struct pdb_methods *m,
+ struct samu *sampass)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ * Update the Samba4 LDB with the changes from a struct samu.
+ *
+ * This takes care not to update elements that have not been changed
+ * by the caller
+ */
+static NTSTATUS pdb_samba4_update_sam_account(struct pdb_methods *m,
+ struct samu *sam)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct ldb_message *msg = pdb_samba4_get_samu_private(
+ m, sam);
+ struct ldb_message *replace_msg;
+ int rc;
+
+ if (!pdb_samba4_init_samba4_from_sam(state, msg, talloc_tos(),
+ &replace_msg, sam)) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (replace_msg->num_elements == 0) {
+ /* Nothing to do, just return success */
+ return NT_STATUS_OK;
+ }
+
+ rc = dsdb_replace(state->ldb, replace_msg, 0);
+ TALLOC_FREE(replace_msg);
+ if (rc != LDB_SUCCESS) {
+ DEBUG(10, ("dsdb_replace for %s failed: %s\n", ldb_dn_get_linearized(replace_msg->dn),
+ ldb_errstring(state->ldb)));
+ return NT_STATUS_LDAP(rc);
+ }
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_delete_sam_account(struct pdb_methods *m,
+ struct samu *username)
+{
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+ status = pdb_samba4_delete_user(m, tmp_ctx, username);
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_rename_sam_account(struct pdb_methods *m,
+ struct samu *oldname,
+ const char *newname)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/* This is not implemented, as this module is exptected to be used
+ * with auth_samba4, and this is responible for login counters etc
+ *
+ */
+static NTSTATUS pdb_samba4_update_login_attempts(struct pdb_methods *m,
+ struct samu *sam_acct,
+ bool success)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static NTSTATUS pdb_samba4_getgrfilter(struct pdb_methods *m, GROUP_MAP *map,
+ const char *exp_fmt, ...) _PRINTF_ATTRIBUTE(4, 5)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ const char *attrs[] = { "objectSid", "description", "samAccountName",
+ NULL };
+ struct ldb_message *msg;
+ va_list ap;
+ char *expression = NULL;
+ struct dom_sid *sid;
+ const char *str;
+ int rc;
+ union unid_t id;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ va_start(ap, exp_fmt);
+ expression = talloc_vasprintf(tmp_ctx, exp_fmt, ap);
+ va_end(ap);
+
+ if (!expression) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ rc = dsdb_search_one(state->ldb, tmp_ctx, &msg, NULL, LDB_SCOPE_SUBTREE, attrs, 0, "%s", expression);
+ if (rc == LDB_ERR_NO_SUCH_OBJECT) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_SUCH_GROUP;
+ } else if (rc != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ DEBUG(10, ("dsdb_search_one failed %s\n",
+ ldb_errstring(state->ldb)));
+ return NT_STATUS_LDAP(rc);
+ }
+
+ sid = samdb_result_dom_sid(tmp_ctx, msg, "objectSid");
+ if (!sid) {
+ talloc_free(tmp_ctx);
+ DEBUG(10, ("Could not pull SID\n"));
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
+ map->sid = *sid;
+
+ if (!pdb_samba4_sid_to_id(m, sid, &id, &map->sid_name_use)) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_SUCH_GROUP;
+ }
+ if (map->sid_name_use == SID_NAME_USER) {
+ DEBUG(1, (__location__ "Got SID_NAME_USER when searching for a group with %s", expression));
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+ map->gid = id.gid;
+
+ str = ldb_msg_find_attr_as_string(msg, "samAccountName",
+ NULL);
+ if (str == NULL) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+ fstrcpy(map->nt_name, str);
+
+ str = ldb_msg_find_attr_as_string(msg, "description",
+ NULL);
+ if (str != NULL) {
+ fstrcpy(map->comment, str);
+ } else {
+ map->comment[0] = '\0';
+ }
+
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_getgrsid(struct pdb_methods *m, GROUP_MAP *map,
+ struct dom_sid sid)
+{
+ char *filter;
+ NTSTATUS status;
+
+ filter = talloc_asprintf(talloc_tos(),
+ "(&(objectsid=%s)(objectclass=group))",
+ sid_string_talloc(talloc_tos(), &sid));
+ if (filter == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = pdb_samba4_getgrfilter(m, map, filter);
+ TALLOC_FREE(filter);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_getgrgid(struct pdb_methods *m, GROUP_MAP *map,
+ gid_t gid)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ NTSTATUS status;
+ struct id_map id_map;
+ struct id_map *id_maps[2];
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ id_map.xid.id = gid;
+ id_map.xid.type = ID_TYPE_GID;
+ id_maps[0] = &id_map;
+ id_maps[1] = NULL;
+
+ status = idmap_xids_to_sids(state->idmap_ctx, tmp_ctx, id_maps);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ status = pdb_samba4_getgrsid(m, map, *id_map.sid);
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_getgrnam(struct pdb_methods *m, GROUP_MAP *map,
+ const char *name)
+{
+ char *filter;
+ NTSTATUS status;
+
+ filter = talloc_asprintf(talloc_tos(),
+ "(&(samaccountname=%s)(objectclass=group))",
+ name);
+ if (filter == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = pdb_samba4_getgrfilter(m, map, filter);
+ TALLOC_FREE(filter);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_create_dom_group(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx, const char *name,
+ uint32 *rid)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ NTSTATUS status;
+ struct dom_sid *sid;
+ struct ldb_dn *dn;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ status = dsdb_add_domain_group(state->ldb, tmp_ctx, name, &sid, &dn);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+
+ sid_peek_rid(sid, rid);
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_delete_dom_group(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx, uint32 rid)
+{
+ const char *attrs[] = { NULL };
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct dom_sid sid;
+ struct ldb_message *msg;
+ struct ldb_dn *dn;
+ int rc;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ sid_compose(&sid, samdb_domain_sid(state->ldb), rid);
+
+ if (ldb_transaction_start(state->ldb) != LDB_SUCCESS) {
+ DEBUG(0, ("Unable to start transaction in pdb_samba4_delete_dom_group()\n"));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ dn = ldb_dn_new_fmt(tmp_ctx, state->ldb, "<SID=%s>", dom_sid_string(tmp_ctx, &sid));
+ if (!dn || !ldb_dn_validate(dn)) {
+ talloc_free(tmp_ctx);
+ ldb_transaction_cancel(state->ldb);
+ return NT_STATUS_NO_MEMORY;
+ }
+ rc = dsdb_search_one(state->ldb, tmp_ctx, &msg, dn, LDB_SCOPE_BASE, attrs, 0, "objectclass=group");
+ if (rc == LDB_ERR_NO_SUCH_OBJECT) {
+ talloc_free(tmp_ctx);
+ ldb_transaction_cancel(state->ldb);
+ return NT_STATUS_NO_SUCH_GROUP;
+ }
+ rc = ldb_delete(state->ldb, dn);
+ if (rc == LDB_ERR_NO_SUCH_OBJECT) {
+ talloc_free(tmp_ctx);
+ ldb_transaction_cancel(state->ldb);
+ return NT_STATUS_NO_SUCH_GROUP;
+ } else if (rc != LDB_SUCCESS) {
+ DEBUG(10, ("ldb_delete failed %s\n",
+ ldb_errstring(state->ldb)));
+ ldb_transaction_cancel(state->ldb);
+ return NT_STATUS_LDAP(rc);
+ }
+
+ if (ldb_transaction_commit(state->ldb) != LDB_SUCCESS) {
+ DEBUG(0, ("Unable to commit transaction in pdb_samba4_delete_dom_group()\n"));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_add_group_mapping_entry(struct pdb_methods *m,
+ GROUP_MAP *map)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static NTSTATUS pdb_samba4_update_group_mapping_entry(struct pdb_methods *m,
+ GROUP_MAP *map)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static NTSTATUS pdb_samba4_delete_group_mapping_entry(struct pdb_methods *m,
+ struct dom_sid sid)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static NTSTATUS pdb_samba4_enum_group_mapping(struct pdb_methods *m,
+ const struct dom_sid *sid,
+ enum lsa_SidType sid_name_use,
+ GROUP_MAP **pp_rmap,
+ size_t *p_num_entries,
+ bool unix_only)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static NTSTATUS pdb_samba4_enum_group_members(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *group,
+ uint32_t **pmembers,
+ size_t *pnum_members)
+{
+ unsigned int i, num_sids, num_members;
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct dom_sid *members_as_sids;
+ struct dom_sid *dom_sid;
+ uint32_t *members;
+ struct ldb_dn *dn;
+ NTSTATUS status;
+
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ dn = ldb_dn_new_fmt(tmp_ctx, state->ldb, "<SID=%s>", dom_sid_string(tmp_ctx, group));
+ if (!dn || !ldb_dn_validate(dn)) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = dsdb_enum_group_mem(state->ldb, tmp_ctx, dn, &members_as_sids, &num_sids);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+ status = dom_sid_split_rid(tmp_ctx, group, &dom_sid, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+
+ *pmembers = members = talloc_array(mem_ctx, uint32_t, num_sids);
+ NT_STATUS_HAVE_NO_MEMORY_AND_FREE(*pmembers, tmp_ctx);
+ num_members = 0;
+
+ for (i = 0; i < num_sids; i++) {
+ if (!dom_sid_in_domain(dom_sid, &members_as_sids[i])) {
+ continue;
+ }
+ status = dom_sid_split_rid(NULL, &members_as_sids[i],
+ NULL, &members[num_members]);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+ num_members++;
+ }
+ *pnum_members = num_members;
+ return NT_STATUS_OK;
+}
+
+/* Just convert the primary group SID into a group */
+static NTSTATUS fake_enum_group_memberships(struct pdb_samba4_state *state,
+ TALLOC_CTX *mem_ctx,
+ struct samu *user,
+ struct dom_sid **pp_sids,
+ gid_t **pp_gids,
+ uint32_t *p_num_groups)
+{
+ NTSTATUS status;
+ size_t num_groups = 0;
+ struct dom_sid *group_sids;
+ gid_t *gids;
+ TALLOC_CTX *tmp_ctx;
+
+ tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ if (user->group_sid) {
+ struct id_map *id_maps[2];
+ struct id_map id_map;
+
+ num_groups = 1;
+
+ group_sids = talloc_array(tmp_ctx, struct dom_sid, num_groups);
+ if (group_sids == NULL) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ gids = talloc_array(tmp_ctx, gid_t, num_groups);
+ if (gids == NULL) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ group_sids[0] = *user->group_sid;
+
+ ZERO_STRUCT(id_map);
+ id_map.sid = &group_sids[0];
+ id_maps[0] = &id_map;
+ id_maps[1] = NULL;
+
+ status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+ if (id_map.xid.type == ID_TYPE_GID || id_map.xid.type == ID_TYPE_BOTH) {
+ gids[0] = id_map.xid.id;
+ } else {
+ DEBUG(1, (__location__
+ "Group %s, of which %s is a member, could not be converted to a GID\n",
+ dom_sid_string(tmp_ctx, &group_sids[0]),
+ dom_sid_string(tmp_ctx, &user->user_sid)));
+ talloc_free(tmp_ctx);
+ /* We must error out, otherwise a user might
+ * avoid a DENY acl based on a group they
+ * missed out on */
+ return NT_STATUS_NO_SUCH_GROUP;
+ }
+ }
+
+ *pp_sids = talloc_steal(mem_ctx, group_sids);
+ *pp_gids = talloc_steal(mem_ctx, gids);
+ *p_num_groups = num_groups;
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_enum_group_memberships(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ struct samu *user,
+ struct dom_sid **pp_sids,
+ gid_t **pp_gids,
+ uint32_t *p_num_groups)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct ldb_message *msg = pdb_samba4_get_samu_private(
+ m, user);
+ const char *attrs[] = { "tokenGroups", NULL};
+ struct ldb_message *tokengroups_msg;
+ struct ldb_message_element *tokengroups;
+ int i, rc;
+ NTSTATUS status;
+ unsigned int count = 0;
+ size_t num_groups;
+ struct dom_sid *group_sids;
+ gid_t *gids;
+ TALLOC_CTX *tmp_ctx;
+
+ if (msg == NULL) {
+ /* Fake up some things here */
+ return fake_enum_group_memberships(state,
+ mem_ctx,
+ user, pp_sids,
+ pp_gids, p_num_groups);
+ }
+
+ tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ rc = dsdb_search_one(state->ldb, tmp_ctx, &tokengroups_msg, msg->dn, LDB_SCOPE_BASE, attrs, 0, NULL);
+
+ if (rc == LDB_ERR_NO_SUCH_OBJECT) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_SUCH_USER;
+ } else if (rc != LDB_SUCCESS) {
+ DEBUG(10, ("dsdb_search_one failed %s\n",
+ ldb_errstring(state->ldb)));
+ talloc_free(tmp_ctx);
+ return NT_STATUS_LDAP(rc);
+ }
+
+ tokengroups = ldb_msg_find_element(tokengroups_msg, "tokenGroups");
+
+ if (tokengroups) {
+ count = tokengroups->num_values;
+ }
+
+ group_sids = talloc_array(tmp_ctx, struct dom_sid, count);
+ if (group_sids == NULL) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ gids = talloc_array(tmp_ctx, gid_t, count);
+ if (gids == NULL) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ num_groups = 0;
+
+ for (i=0; i<count; i++) {
+ struct id_map *id_maps[2];
+ struct id_map id_map;
+ struct ldb_val *v = &tokengroups->values[i];
+ enum ndr_err_code ndr_err
+ = ndr_pull_struct_blob(v, group_sids, &group_sids[num_groups],
+ (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
+ ZERO_STRUCT(id_map);
+ id_map.sid = &group_sids[num_groups];
+ id_maps[0] = &id_map;
+ id_maps[1] = NULL;
+
+ status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+ if (id_map.xid.type == ID_TYPE_GID || id_map.xid.type == ID_TYPE_BOTH) {
+ gids[num_groups] = id_map.xid.id;
+ } else {
+ DEBUG(1, (__location__
+ "Group %s, of which %s is a member, could not be converted to a GID\n",
+ dom_sid_string(tmp_ctx, &group_sids[num_groups]),
+ ldb_dn_get_linearized(msg->dn)));
+ talloc_free(tmp_ctx);
+ /* We must error out, otherwise a user might
+ * avoid a DENY acl based on a group they
+ * missed out on */
+ return NT_STATUS_NO_SUCH_GROUP;
+ }
+
+ num_groups += 1;
+ if (num_groups == count) {
+ break;
+ }
+ }
+
+ *pp_sids = talloc_steal(mem_ctx, group_sids);
+ *pp_gids = talloc_steal(mem_ctx, gids);
+ *p_num_groups = num_groups;
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_set_unix_primary_group(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ struct samu *user)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static NTSTATUS pdb_samba4_mod_groupmem_by_sid(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *groupsid,
+ const struct dom_sid *membersid,
+ int mod_op)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct ldb_message *msg;
+ int ret;
+ struct ldb_message_element *el;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+ msg = ldb_msg_new(tmp_ctx);
+ NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, tmp_ctx);
+
+ msg->dn = ldb_dn_new_fmt(msg, state->ldb, "<SID=%s>", dom_sid_string(tmp_ctx, groupsid));
+ if (!msg->dn || !ldb_dn_validate(msg->dn)) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ ret = ldb_msg_add_fmt(msg, "member", "<SID=%s>", dom_sid_string(tmp_ctx, membersid));
+ if (ret != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ el = ldb_msg_find_element(msg, "member");
+ el->flags = mod_op;
+
+ /* No need for transactions here, the ldb auto-transaction
+ * code will handle things for the single operation */
+ ret = ldb_modify(state->ldb, msg);
+ talloc_free(tmp_ctx);
+ if (ret != LDB_SUCCESS) {
+ DEBUG(10, ("ldb_modify failed: %s\n",
+ ldb_errstring(state->ldb)));
+ if (ret == LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS) {
+ return NT_STATUS_MEMBER_IN_GROUP;
+ }
+ if (ret == LDB_ERR_NO_SUCH_ATTRIBUTE) {
+ return NT_STATUS_MEMBER_NOT_IN_GROUP;
+ }
+ return NT_STATUS_LDAP(ret);
+ }
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_mod_groupmem(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ uint32 grouprid, uint32 memberrid,
+ int mod_op)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ const struct dom_sid *dom_sid, *groupsid, *membersid;
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ dom_sid = samdb_domain_sid(state->ldb);
+
+ groupsid = dom_sid_add_rid(tmp_ctx, dom_sid, grouprid);
+ NT_STATUS_HAVE_NO_MEMORY_AND_FREE(groupsid, tmp_ctx);
+ membersid = dom_sid_add_rid(tmp_ctx, dom_sid, memberrid);
+ NT_STATUS_HAVE_NO_MEMORY_AND_FREE(membersid, tmp_ctx);
+ status = pdb_samba4_mod_groupmem_by_sid(m, tmp_ctx, groupsid, membersid, mod_op);
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_add_groupmem(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ uint32 group_rid, uint32 member_rid)
+{
+ return pdb_samba4_mod_groupmem(m, mem_ctx, group_rid, member_rid,
+ LDB_FLAG_MOD_ADD);
+}
+
+static NTSTATUS pdb_samba4_del_groupmem(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ uint32 group_rid, uint32 member_rid)
+{
+ return pdb_samba4_mod_groupmem(m, mem_ctx, group_rid, member_rid,
+ LDB_FLAG_MOD_DELETE);
+}
+
+static NTSTATUS pdb_samba4_create_alias(struct pdb_methods *m,
+ const char *name, uint32 *rid)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct dom_sid *sid;
+
+ struct ldb_dn *dn;
+ NTSTATUS status;
+
+ /* Internally this uses transactions to ensure all the steps
+ * happen or fail as one */
+ status = dsdb_add_domain_alias(state->ldb, frame, name, &sid, &dn);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(frame);
+ }
+
+ sid_peek_rid(sid, rid);
+ TALLOC_FREE(frame);
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_delete_alias(struct pdb_methods *m,
+ const struct dom_sid *sid)
+{
+ const char *attrs[] = { NULL };
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct ldb_message *msg;
+ struct ldb_dn *dn;
+ int rc;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ dn = ldb_dn_new_fmt(tmp_ctx, state->ldb, "<SID=%s>", dom_sid_string(tmp_ctx, sid));
+ if (!dn || !ldb_dn_validate(dn)) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (ldb_transaction_start(state->ldb) != LDB_SUCCESS) {
+ DEBUG(0, ("Failed to start transaction in dsdb_add_domain_alias(): %s\n", ldb_errstring(state->ldb)));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ rc = dsdb_search_one(state->ldb, tmp_ctx, &msg, dn, LDB_SCOPE_BASE, attrs, 0, "(objectclass=group)"
+ "(|(grouptype=%d)(grouptype=%d)))",
+ GTYPE_SECURITY_BUILTIN_LOCAL_GROUP,
+ GTYPE_SECURITY_DOMAIN_LOCAL_GROUP);
+ if (rc == LDB_ERR_NO_SUCH_OBJECT) {
+ talloc_free(tmp_ctx);
+ ldb_transaction_cancel(state->ldb);
+ return NT_STATUS_NO_SUCH_ALIAS;
+ }
+ rc = ldb_delete(state->ldb, dn);
+ if (rc == LDB_ERR_NO_SUCH_OBJECT) {
+ talloc_free(tmp_ctx);
+ ldb_transaction_cancel(state->ldb);
+ return NT_STATUS_NO_SUCH_ALIAS;
+ } else if (rc != LDB_SUCCESS) {
+ DEBUG(10, ("ldb_delete failed %s\n",
+ ldb_errstring(state->ldb)));
+ ldb_transaction_cancel(state->ldb);
+ return NT_STATUS_LDAP(rc);
+ }
+
+ if (ldb_transaction_commit(state->ldb) != LDB_SUCCESS) {
+ DEBUG(0, ("Failed to commit transaction in pdb_samba4_delete_alias(): %s\n",
+ ldb_errstring(state->ldb)));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ return NT_STATUS_OK;
+}
+
+#if 0
+static NTSTATUS pdb_samba4_set_aliasinfo(struct pdb_methods *m,
+ const struct dom_sid *sid,
+ struct acct_info *info)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct tldap_context *ld;
+ const char *attrs[3] = { "objectSid", "description",
+ "samAccountName" };
+ struct ldb_message **msg;
+ char *sidstr, *dn;
+ int rc;
+ struct tldap_mod *mods;
+ int num_mods;
+ bool ok;
+
+ ld = pdb_samba4_ld(state);
+ if (ld == NULL) {
+ return NT_STATUS_LDAP(TLDAP_SERVER_DOWN);
+ }
+
+ sidstr = sid_binstring(talloc_tos(), sid);
+ NT_STATUS_HAVE_NO_MEMORY(sidstr);
+
+ rc = pdb_samba4_search_fmt(state, state->domaindn, TLDAP_SCOPE_SUB,
+ attrs, ARRAY_SIZE(attrs), 0, talloc_tos(),
+ &msg, "(&(objectSid=%s)(objectclass=group)"
+ "(|(grouptype=%d)(grouptype=%d)))",
+ sidstr, GTYPE_SECURITY_BUILTIN_LOCAL_GROUP,
+ GTYPE_SECURITY_DOMAIN_LOCAL_GROUP);
+ TALLOC_FREE(sidstr)
+ if (rc != LDB_SUCCESS) {
+ DEBUG(10, ("ldap_search failed %s\n",
+ ldb_errstring(state->ldb)));
+ return NT_STATUS_LDAP(rc);
+ }
+ switch talloc_array_length(msg) {
+ case 0:
+ return NT_STATUS_NO_SUCH_ALIAS;
+ case 1:
+ break;
+ default:
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
+ if (!tldap_entry_dn(msg[0], &dn)) {
+ TALLOC_FREE(msg);
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
+ mods = NULL;
+ num_mods = 0;
+ ok = true;
+
+ ok &= tldap_make_mod_fmt(
+ msg[0], msg, &num_mods, &mods, "description",
+ "%s", info->acct_desc);
+ ok &= tldap_make_mod_fmt(
+ msg[0], msg, &num_mods, &mods, "samAccountName",
+ "%s", info->acct_name);
+ if (!ok) {
+ TALLOC_FREE(msg);
+ return NT_STATUS_NO_MEMORY;
+ }
+ if (num_mods == 0) {
+ /* no change */
+ TALLOC_FREE(msg);
+ return NT_STATUS_OK;
+ }
+
+ rc = tldap_modify(ld, dn, num_mods, mods, NULL, 0, NULL, 0);
+ TALLOC_FREE(msg);
+ if (rc != LDB_SUCCESS) {
+ DEBUG(10, ("ldap_modify failed: %s\n",
+ ldb_errstring(state->ldb)));
+ return NT_STATUS_LDAP(rc);
+ }
+ return NT_STATUS_OK;
+}
+#endif
+static NTSTATUS pdb_samba4_add_aliasmem(struct pdb_methods *m,
+ const struct dom_sid *alias,
+ const struct dom_sid *member)
+{
+ NTSTATUS status;
+ TALLOC_CTX *frame = talloc_stackframe();
+ status = pdb_samba4_mod_groupmem_by_sid(m, frame, alias, member, LDB_FLAG_MOD_ADD);
+ talloc_free(frame);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_del_aliasmem(struct pdb_methods *m,
+ const struct dom_sid *alias,
+ const struct dom_sid *member)
+{
+ NTSTATUS status;
+ TALLOC_CTX *frame = talloc_stackframe();
+ status = pdb_samba4_mod_groupmem_by_sid(m, frame, alias, member, LDB_FLAG_MOD_DELETE);
+ talloc_free(frame);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_enum_aliasmem(struct pdb_methods *m,
+ const struct dom_sid *alias,
+ TALLOC_CTX *mem_ctx,
+ struct dom_sid **pmembers,
+ size_t *pnum_members)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct ldb_dn *dn;
+ unsigned int num_members;
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ dn = ldb_dn_new_fmt(tmp_ctx, state->ldb, "<SID=%s>", dom_sid_string(tmp_ctx, alias));
+ if (!dn || !ldb_dn_validate(dn)) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = dsdb_enum_group_mem(state->ldb, mem_ctx, dn, pmembers, &num_members);
+ *pnum_members = num_members;
+ if (NT_STATUS_IS_OK(status)) {
+ talloc_steal(mem_ctx, pmembers);
+ }
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_enum_alias_memberships(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *domain_sid,
+ const struct dom_sid *members,
+ size_t num_members,
+ uint32_t **palias_rids,
+ size_t *pnum_alias_rids)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ uint32_t *alias_rids = NULL;
+ size_t num_alias_rids = 0;
+ int i;
+ struct dom_sid *groupSIDs = NULL;
+ unsigned int num_groupSIDs = 0;
+ char *filter;
+ NTSTATUS status;
+ const char *sid_string;
+ const char *sid_dn;
+ DATA_BLOB sid_blob;
+
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+ /*
+ * TODO: Get the filter right so that we only get the aliases from
+ * either the SAM or BUILTIN
+ */
+
+ filter = talloc_asprintf(tmp_ctx, "(&(objectClass=group)(groupType:1.2.840.113556.1.4.803:=%u))",
+ GROUP_TYPE_BUILTIN_LOCAL_GROUP);
+ if (filter == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i = 0; i < num_members; i++) {
+ sid_string = dom_sid_string(tmp_ctx, &members[i]);
+ NT_STATUS_HAVE_NO_MEMORY_AND_FREE(sid_string, tmp_ctx);
+
+ sid_dn = talloc_asprintf(tmp_ctx, "<SID=%s>", sid_string);
+ NT_STATUS_HAVE_NO_MEMORY_AND_FREE(sid_dn, tmp_ctx);
+
+ sid_blob = data_blob_string_const(sid_dn);
+
+ status = dsdb_expand_nested_groups(state->ldb, &sid_blob, true, filter,
+ tmp_ctx, &groupSIDs, &num_groupSIDs);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+ }
+
+ alias_rids = talloc_array(mem_ctx, uint32_t, num_groupSIDs);
+ if (alias_rids == NULL) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0; i<num_groupSIDs; i++) {
+ if (sid_peek_check_rid(domain_sid, &groupSIDs[i],
+ &alias_rids[num_alias_rids])) {
+ num_alias_rids++;;
+ }
+ }
+
+ *palias_rids = alias_rids;
+ *pnum_alias_rids = num_alias_rids;
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pdb_samba4_lookup_rids(struct pdb_methods *m,
+ const struct dom_sid *domain_sid,
+ int num_rids,
+ uint32 *rids,
+ const char **names,
+ enum lsa_SidType *lsa_attrs)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ NTSTATUS status;
+
+ TALLOC_CTX *tmp_ctx;
+
+ if (num_rids == 0) {
+ return NT_STATUS_NONE_MAPPED;
+ }
+
+ tmp_ctx = talloc_stackframe();
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ status = dsdb_lookup_rids(state->ldb, tmp_ctx, domain_sid, num_rids, rids, names, lsa_attrs);
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+static NTSTATUS pdb_samba4_lookup_names(struct pdb_methods *m,
+ const struct dom_sid *domain_sid,
+ int num_names,
+ const char **pp_names,
+ uint32 *rids,
+ enum lsa_SidType *attrs)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+static NTSTATUS pdb_samba4_get_account_policy(struct pdb_methods *m,
+ enum pdb_policy_type type,
+ uint32_t *value)
+{
+ return account_policy_get(type, value)
+ ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+}
+
+static NTSTATUS pdb_samba4_set_account_policy(struct pdb_methods *m,
+ enum pdb_policy_type type,
+ uint32_t value)
+{
+ return account_policy_set(type, value)
+ ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+}
+
+static NTSTATUS pdb_samba4_get_seq_num(struct pdb_methods *m,
+ time_t *seq_num_out)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ uint64_t seq_num;
+ int ret = ldb_sequence_number(state->ldb, LDB_SEQ_HIGHEST_SEQ, &seq_num);
+ if (ret == LDB_SUCCESS) {
+ *seq_num_out = seq_num;
+ return NT_STATUS_OK;
+ } else {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+}
+
+struct pdb_samba4_search_state {
+ uint32_t acct_flags;
+ struct samr_displayentry *entries;
+ uint32_t num_entries;
+ ssize_t array_size;
+ uint32_t current;
+};
+
+static bool pdb_samba4_next_entry(struct pdb_search *search,
+ struct samr_displayentry *entry)
+{
+ struct pdb_samba4_search_state *state = talloc_get_type_abort(
+ search->private_data, struct pdb_samba4_search_state);
+
+ if (state->current == state->num_entries) {
+ return false;
+ }
+
+ entry->idx = state->entries[state->current].idx;
+ entry->rid = state->entries[state->current].rid;
+ entry->acct_flags = state->entries[state->current].acct_flags;
+
+ entry->account_name = talloc_strdup(
+ search, state->entries[state->current].account_name);
+ entry->fullname = talloc_strdup(
+ search, state->entries[state->current].fullname);
+ entry->description = talloc_strdup(
+ search, state->entries[state->current].description);
+
+ state->current += 1;
+ return true;
+}
+
+static void pdb_samba4_search_end(struct pdb_search *search)
+{
+ struct pdb_samba4_search_state *state = talloc_get_type_abort(
+ search->private_data, struct pdb_samba4_search_state);
+ talloc_free(state);
+}
+
+static bool pdb_samba4_search_filter(struct pdb_methods *m,
+ struct pdb_search *search,
+ struct pdb_samba4_search_state **pstate,
+ const char *exp_fmt, ...) _PRINTF_ATTRIBUTE(4, 5)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct pdb_samba4_search_state *sstate;
+ const char * attrs[] = { "objectSid", "sAMAccountName", "displayName",
+ "userAccountControl", "description", NULL };
+ struct ldb_result *res;
+ int i, rc, num_users;
+
+ va_list ap;
+ char *expression = NULL;
+
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ if (!tmp_ctx) {
+ return false;
+ }
+
+ va_start(ap, exp_fmt);
+ expression = talloc_vasprintf(tmp_ctx, exp_fmt, ap);
+ va_end(ap);
+
+ if (!expression) {
+ talloc_free(tmp_ctx);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ sstate = talloc_zero(tmp_ctx, struct pdb_samba4_search_state);
+ if (sstate == NULL) {
+ talloc_free(tmp_ctx);
+ return false;
+ }
+
+ rc = dsdb_search(state->ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, attrs, 0, "%s", expression);
+ if (rc != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ DEBUG(10, ("dsdb_search failed: %s\n",
+ ldb_errstring(state->ldb)));
+ return false;
+ }
+
+ num_users = res->count;
+
+ sstate->entries = talloc_array(sstate, struct samr_displayentry,
+ num_users);
+ if (sstate->entries == NULL) {
+ talloc_free(tmp_ctx);
+ DEBUG(10, ("talloc failed\n"));
+ return false;
+ }
+
+ sstate->num_entries = 0;
+
+ for (i=0; i<num_users; i++) {
+ struct samr_displayentry *e;
+ struct dom_sid *sid;
+
+ e = &sstate->entries[sstate->num_entries];
+
+ e->idx = sstate->num_entries;
+ sid = samdb_result_dom_sid(tmp_ctx, res->msgs[i], "objectSid");
+ if (!sid) {
+ talloc_free(tmp_ctx);
+ DEBUG(10, ("Could not pull SID\n"));
+ return false;
+ }
+ sid_peek_rid(sid, &e->rid);
+
+ e->acct_flags = samdb_result_acct_flags(state->ldb, tmp_ctx,
+ res->msgs[i],
+ ldb_get_default_basedn(state->ldb));
+ e->account_name = ldb_msg_find_attr_as_string(
+ res->msgs[i], "samAccountName", NULL);
+ if (e->account_name == NULL) {
+ talloc_free(tmp_ctx);
+ return false;
+ }
+ e->fullname = ldb_msg_find_attr_as_string(
+ res->msgs[i], "displayName", "");
+ e->description = ldb_msg_find_attr_as_string(
+ res->msgs[i], "description", "");
+
+ sstate->num_entries += 1;
+ if (sstate->num_entries >= num_users) {
+ break;
+ }
+ }
+ talloc_steal(sstate->entries, res->msgs);
+ search->private_data = talloc_steal(search, sstate);
+ search->next_entry = pdb_samba4_next_entry;
+ search->search_end = pdb_samba4_search_end;
+ *pstate = sstate;
+ talloc_free(tmp_ctx);
+ return true;
+}
+
+static bool pdb_samba4_search_users(struct pdb_methods *m,
+ struct pdb_search *search,
+ uint32 acct_flags)
+{
+ struct pdb_samba4_search_state *sstate;
+ bool ret;
+
+ ret = pdb_samba4_search_filter(m, search, &sstate, "(objectclass=user)");
+ if (!ret) {
+ return false;
+ }
+ sstate->acct_flags = acct_flags;
+ return true;
+}
+
+static bool pdb_samba4_search_groups(struct pdb_methods *m,
+ struct pdb_search *search)
+{
+ struct pdb_samba4_search_state *sstate;
+ bool ret;
+
+ ret = pdb_samba4_search_filter(m, search, &sstate,
+ "(&(grouptype=%d)(objectclass=group))",
+ GTYPE_SECURITY_GLOBAL_GROUP);
+ if (!ret) {
+ return false;
+ }
+ sstate->acct_flags = 0;
+ return true;
+}
+
+static bool pdb_samba4_search_aliases(struct pdb_methods *m,
+ struct pdb_search *search,
+ const struct dom_sid *sid)
+{
+ struct pdb_samba4_search_state *sstate;
+ bool ret;
+
+ ret = pdb_samba4_search_filter(m, search, &sstate,
+ "(&(grouptype=%d)(objectclass=group))",
+ sid_check_is_builtin(sid)
+ ? GTYPE_SECURITY_BUILTIN_LOCAL_GROUP
+ : GTYPE_SECURITY_DOMAIN_LOCAL_GROUP);
+ if (!ret) {
+ return false;
+ }
+ sstate->acct_flags = 0;
+ return true;
+}
+
+static bool pdb_samba4_uid_to_sid(struct pdb_methods *m, uid_t uid,
+ struct dom_sid *sid)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ NTSTATUS status;
+ struct id_map id_map;
+ struct id_map *id_maps[2];
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ if (!tmp_ctx) {
+ return false;
+ }
+
+ id_map.xid.id = uid;
+ id_map.xid.type = ID_TYPE_UID;
+ id_maps[0] = &id_map;
+ id_maps[1] = NULL;
+
+ status = idmap_xids_to_sids(state->idmap_ctx, tmp_ctx, id_maps);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return false;
+ }
+ *sid = *id_map.sid;
+ talloc_free(tmp_ctx);
+ return true;
+}
+
+static bool pdb_samba4_gid_to_sid(struct pdb_methods *m, gid_t gid,
+ struct dom_sid *sid)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ NTSTATUS status;
+ struct id_map id_map;
+ struct id_map *id_maps[2];
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ if (!tmp_ctx) {
+ return false;
+ }
+
+ id_map.xid.id = gid;
+ id_map.xid.type = ID_TYPE_GID;
+ id_maps[0] = &id_map;
+ id_maps[1] = NULL;
+
+ status = idmap_xids_to_sids(state->idmap_ctx, tmp_ctx, id_maps);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+ *sid = *id_map.sid;
+ talloc_free(tmp_ctx);
+ return true;
+}
+
+static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
+ union unid_t *id, enum lsa_SidType *type)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_samba4_state);
+ struct id_map id_map;
+ struct id_map *id_maps[2];
+ const char *attrs[] = { "objectClass", "groupType", NULL };
+ struct ldb_message *msg;
+ struct ldb_dn *dn;
+ NTSTATUS status;
+ int rc;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ if (!tmp_ctx) {
+ return false;
+ }
+
+ ZERO_STRUCT(id_map);
+
+ dn = ldb_dn_new_fmt(tmp_ctx, state->ldb, "<SID=%s>", dom_sid_string(tmp_ctx, sid));
+ if (!dn || !ldb_dn_validate(dn)) {
+ talloc_free(tmp_ctx);
+ return false;
+ }
+ rc = dsdb_search_one(state->ldb, tmp_ctx, &msg, dn, LDB_SCOPE_BASE, attrs, 0, NULL);
+ if (rc == LDB_ERR_NO_SUCH_OBJECT) {
+ DEBUG(5, (__location__ "SID to Unix ID lookup failed because SID %s could not be found in the samdb\n", dom_sid_string(tmp_ctx, sid)));
+ talloc_free(tmp_ctx);
+ return false;
+ }
+ if (samdb_find_attribute(state->ldb, msg, "objectClass", "group")) {
+ uint32_t grouptype = ldb_msg_find_attr_as_uint(msg, "groupType", 0);
+ switch (grouptype) {
+ case GTYPE_SECURITY_BUILTIN_LOCAL_GROUP:
+ case GTYPE_SECURITY_DOMAIN_LOCAL_GROUP:
+ *type = SID_NAME_ALIAS;
+ break;
+ case GTYPE_SECURITY_GLOBAL_GROUP:
+ *type = SID_NAME_DOM_GRP;
+ break;
+ default:
+ talloc_free(tmp_ctx);
+ DEBUG(10, ("Could not pull groupType\n"));
+ return false;
+ }
+
+ *type = SID_NAME_DOM_GRP;
+
+ ZERO_STRUCT(id_map);
+ id_map.sid = sid;
+ id_maps[0] = &id_map;
+ id_maps[1] = NULL;
+
+ status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
+ talloc_free(tmp_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+ if (id_map.xid.type == ID_TYPE_GID || id_map.xid.type == ID_TYPE_BOTH) {
+ id->gid = id_map.xid.id;
+ return true;
+ }
+ return false;
+ } else if (samdb_find_attribute(state->ldb, msg, "objectClass", "user")) {
+ *type = SID_NAME_USER;
+ ZERO_STRUCT(id_map);
+ id_map.sid = sid;
+ id_maps[0] = &id_map;
+ id_maps[1] = NULL;
+
+ status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
+ talloc_free(tmp_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+ if (id_map.xid.type == ID_TYPE_UID || id_map.xid.type == ID_TYPE_BOTH) {
+ id->uid = id_map.xid.id;
+ return true;
+ }
+ return false;
+ }
+ DEBUG(5, (__location__ "SID to Unix ID lookup failed because SID %s was found, but was not a user or group\n", dom_sid_string(tmp_ctx, sid)));
+ talloc_free(tmp_ctx);
+ return false;
+}
+
+static uint32_t pdb_samba4_capabilities(struct pdb_methods *m)
+{
+ return PDB_CAP_STORE_RIDS | PDB_CAP_ADS;
+}
+
+static bool pdb_samba4_new_rid(struct pdb_methods *m, uint32 *rid)
+{
+ return false;
+}
+
+static bool pdb_samba4_get_trusteddom_pw(struct pdb_methods *m,
+ const char *domain, char** pwd,
+ struct dom_sid *sid,
+ time_t *pass_last_set_time)
+{
+ return false;
+}
+
+static bool pdb_samba4_set_trusteddom_pw(struct pdb_methods *m,
+ const char* domain, const char* pwd,
+ const struct dom_sid *sid)
+{
+ return false;
+}
+
+static bool pdb_samba4_del_trusteddom_pw(struct pdb_methods *m,
+ const char *domain)
+{
+ return false;
+}
+
+static NTSTATUS pdb_samba4_enum_trusteddoms(struct pdb_methods *m,
+ TALLOC_CTX *mem_ctx,
+ uint32 *num_domains,
+ struct trustdom_info ***domains)
+{
+ *num_domains = 0;
+ *domains = NULL;
+ return NT_STATUS_OK;
+}
+
+static void pdb_samba4_init_methods(struct pdb_methods *m)
+{
+ m->name = "samba4";
+ m->get_domain_info = pdb_samba4_get_domain_info;
+ m->getsampwnam = pdb_samba4_getsampwnam;
+ m->getsampwsid = pdb_samba4_getsampwsid;
+ m->create_user = pdb_samba4_create_user;
+ m->delete_user = pdb_samba4_delete_user;
+ m->add_sam_account = pdb_samba4_add_sam_account;
+ m->update_sam_account = pdb_samba4_update_sam_account;
+ m->delete_sam_account = pdb_samba4_delete_sam_account;
+ m->rename_sam_account = pdb_samba4_rename_sam_account;
+ m->update_login_attempts = pdb_samba4_update_login_attempts;
+ m->getgrsid = pdb_samba4_getgrsid;
+ m->getgrgid = pdb_samba4_getgrgid;
+ m->getgrnam = pdb_samba4_getgrnam;
+ m->create_dom_group = pdb_samba4_create_dom_group;
+ m->delete_dom_group = pdb_samba4_delete_dom_group;
+ m->add_group_mapping_entry = pdb_samba4_add_group_mapping_entry;
+ m->update_group_mapping_entry = pdb_samba4_update_group_mapping_entry;
+ m->delete_group_mapping_entry = pdb_samba4_delete_group_mapping_entry;
+ m->enum_group_mapping = pdb_samba4_enum_group_mapping;
+ m->enum_group_members = pdb_samba4_enum_group_members;
+ m->enum_group_memberships = pdb_samba4_enum_group_memberships;
+ m->set_unix_primary_group = pdb_samba4_set_unix_primary_group;
+ m->add_groupmem = pdb_samba4_add_groupmem;
+ m->del_groupmem = pdb_samba4_del_groupmem;
+ m->create_alias = pdb_samba4_create_alias;
+ m->delete_alias = pdb_samba4_delete_alias;
+ m->get_aliasinfo = pdb_default_get_aliasinfo;
+ m->add_aliasmem = pdb_samba4_add_aliasmem;
+ m->del_aliasmem = pdb_samba4_del_aliasmem;
+ m->enum_aliasmem = pdb_samba4_enum_aliasmem;
+ m->enum_alias_memberships = pdb_samba4_enum_alias_memberships;
+ m->lookup_rids = pdb_samba4_lookup_rids;
+ m->lookup_names = pdb_samba4_lookup_names;
+ m->get_account_policy = pdb_samba4_get_account_policy;
+ m->set_account_policy = pdb_samba4_set_account_policy;
+ m->get_seq_num = pdb_samba4_get_seq_num;
+ m->search_users = pdb_samba4_search_users;
+ m->search_groups = pdb_samba4_search_groups;
+ m->search_aliases = pdb_samba4_search_aliases;
+ m->uid_to_sid = pdb_samba4_uid_to_sid;
+ m->gid_to_sid = pdb_samba4_gid_to_sid;
+ m->sid_to_id = pdb_samba4_sid_to_id;
+ m->capabilities = pdb_samba4_capabilities;
+ m->new_rid = pdb_samba4_new_rid;
+ m->get_trusteddom_pw = pdb_samba4_get_trusteddom_pw;
+ m->set_trusteddom_pw = pdb_samba4_set_trusteddom_pw;
+ m->del_trusteddom_pw = pdb_samba4_del_trusteddom_pw;
+ m->enum_trusteddoms = pdb_samba4_enum_trusteddoms;
+}
+
+static void free_private_data(void **vp)
+{
+ struct pdb_samba4_state *state = talloc_get_type_abort(
+ *vp, struct pdb_samba4_state);
+ talloc_unlink(state, state->ldb);
+ return;
+}
+
+static NTSTATUS pdb_init_samba4(struct pdb_methods **pdb_method,
+ const char *location)
+{
+ struct pdb_methods *m;
+ struct pdb_samba4_state *state;
+ NTSTATUS status;
+
+ if ( !NT_STATUS_IS_OK(status = make_pdb_method( &m )) ) {
+ return status;
+ }
+
+ state = talloc_zero(m, struct pdb_samba4_state);
+ if (state == NULL) {
+ goto nomem;
+ }
+ m->private_data = state;
+ m->free_private_data = free_private_data;
+ pdb_samba4_init_methods(m);
+
+ state->ev = s4_event_context_init(state);
+ if (!state->ev) {
+ DEBUG(10, ("s4_event_context_init failed\n"));
+ goto fail;
+ }
+
+ state->lp_ctx = loadparm_init_s3(state, loadparm_s3_context());
+ if (state->lp_ctx == NULL) {
+ DEBUG(10, ("loadparm_init_s3 failed\n"));
+ goto fail;
+ }
+
+ state->ldb = samdb_connect(state,
+ state->ev,
+ state->lp_ctx,
+ system_session(state->lp_ctx), 0);
+
+ if (!state->ldb) {
+ DEBUG(10, ("samdb_connect failed\n"));
+ goto fail;
+ }
+
+ state->idmap_ctx = idmap_init(state, state->ev,
+ state->lp_ctx);
+ if (!state->idmap_ctx) {
+ DEBUG(10, ("samdb_connect failed\n"));
+ goto fail;
+ }
+
+ *pdb_method = m;
+ return NT_STATUS_OK;
+nomem:
+ status = NT_STATUS_NO_MEMORY;
+fail:
+ TALLOC_FREE(m);
+ return status;
+}
+
+NTSTATUS pdb_samba4_init(void);
+NTSTATUS pdb_samba4_init(void)
+{
+ return smb_register_passdb(PASSDB_INTERFACE_VERSION, "samba4",
+ pdb_init_samba4);
+}
diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c
index 43d6eaf6645..2cfacd3a136 100644
--- a/source3/passdb/pdb_smbpasswd.c
+++ b/source3/passdb/pdb_smbpasswd.c
@@ -549,7 +549,7 @@ static struct smb_passwd *getsmbfilepwent(struct smbpasswd_privates *smbpasswd_s
}
if(*p == ':') {
p++;
- if(*p && (StrnCaseCmp((char *)p, "LCT-", 4)==0)) {
+ if(*p && (strncasecmp_m((char *)p, "LCT-", 4)==0)) {
int i;
p += 4;
for(i = 0; i < 8; i++) {
@@ -975,7 +975,7 @@ This is no longer supported.!\n", pwd->smb_name));
p++;
/* We should be pointing at the LCT entry. */
- if((linebuf_len > (PTR_DIFF(p, linebuf) + 13)) && (StrnCaseCmp((char *)p, "LCT-", 4) == 0)) {
+ if((linebuf_len > (PTR_DIFF(p, linebuf) + 13)) && (strncasecmp_m((char *)p, "LCT-", 4) == 0)) {
p += 4;
for(i = 0; i < 8; i++) {
if(p[i] == '\0' || !isxdigit(p[i])) {
@@ -990,7 +990,7 @@ This is no longer supported.!\n", pwd->smb_name));
*/
got_pass_last_set_time = True;
} /* i == 8 */
- } /* *p && StrnCaseCmp() */
+ } /* *p && strncasecmp_m() */
} /* p == ':' */
} /* p == '[' */
@@ -1694,7 +1694,7 @@ static NTSTATUS pdb_init_smbpasswd( struct pdb_methods **pdb_method, const char
/* Setup private data and free function */
- if ( !(privates = TALLOC_ZERO_P( *pdb_method, struct smbpasswd_privates )) ) {
+ if ( !(privates = talloc_zero( *pdb_method, struct smbpasswd_privates )) ) {
DEBUG(0, ("talloc() failed for smbpasswd private_data!\n"));
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 79c0ed196af..28461d0ac3d 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -27,6 +27,7 @@
#include "passdb.h"
#include "dbwrap.h"
#include "../libcli/security/security.h"
+#include "util_tdb.h"
#if 0 /* when made a module use this */
diff --git a/source3/passdb/pdb_wbc_sam.c b/source3/passdb/pdb_wbc_sam.c
index 64529c78961..91adc8108b3 100644
--- a/source3/passdb/pdb_wbc_sam.c
+++ b/source3/passdb/pdb_wbc_sam.c
@@ -112,7 +112,7 @@ static NTSTATUS pdb_wbc_sam_enum_group_memberships(struct pdb_methods *methods,
smb_panic("primary group missing");
}
- *pp_sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, *p_num_groups);
+ *pp_sids = talloc_array(mem_ctx, struct dom_sid, *p_num_groups);
if (*pp_sids == NULL) {
TALLOC_FREE(*pp_gids);
diff --git a/source3/passdb/proto.h b/source3/passdb/proto.h
index a64985c7091..8b95b729597 100644
--- a/source3/passdb/proto.h
+++ b/source3/passdb/proto.h
@@ -1,3 +1,41 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * passdb - password and authentication handling
+ *
+ * Copyright (C) Andrew Tridgell 1992-1998
+ * Copyright (C) Jeremy Allison 1995-2009
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1998
+ * Copyright (C) Jean François Micouleau 1998-2001
+ * Copyright (C) Gerald (Jerry) Carter 2000-2006
+ * Copyright (C) Simo Sorce 2000-2003,2006
+ * Copyright (C) Andrew Bartlett 2001-2002
+ * Copyright (C) Shahms King 2001
+ * Copyright (C) Jelmer Vernooij 2002
+ * Copyright (C) Rafal Szczesniak 2002
+ * Copyright (C) Stefan (metze) Metzmacher 2002-2003
+ * Copyright (C) Guenther Deschner 2004-2005
+ * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2004-2005
+ * Copyright (C) Vince Brimhall 2004-2005
+ * Copyright (C) Volker Lendecke 2006
+ * Copyright (C) Michael Adam 2007
+ * Copyright (C) Dan Sledz 2009
+ *
+ * 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 _PASSDB_PROTO_H_
+#define _PASSDB_PROTO_H_
/* The following definitions come from passdb/account_pol.c */
@@ -300,3 +338,5 @@ NTSTATUS pdb_tdbsam_init(void);
NTSTATUS create_builtin_users(const struct dom_sid *sid);
NTSTATUS create_builtin_administrators(const struct dom_sid *sid);
+
+#endif /* _PASSDB_PROTO_H_ */
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c
index c16d15807bd..c9101ca0506 100644
--- a/source3/passdb/secrets.c
+++ b/source3/passdb/secrets.c
@@ -30,6 +30,7 @@
#include "secrets.h"
#include "dbwrap.h"
#include "../libcli/security/security.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
@@ -419,7 +420,7 @@ static int list_trusted_domain(struct db_record *rec, void *private_data)
return 0;
}
- if (!(dom_info = TALLOC_P(state->domains, struct trustdom_info))) {
+ if (!(dom_info = talloc(state->domains, struct trustdom_info))) {
DEBUG(0, ("talloc failed\n"));
return 0;
}
@@ -458,7 +459,7 @@ NTSTATUS secrets_trusted_domains(TALLOC_CTX *mem_ctx, uint32 *num_domains,
* exists
*/
- if (!(state.domains = TALLOC_ARRAY(
+ if (!(state.domains = talloc_array(
mem_ctx, struct trustdom_info *, 1))) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/passdb/wscript_build b/source3/passdb/wscript_build
index 79b143507f1..90ce2c4c4d2 100644
--- a/source3/passdb/wscript_build
+++ b/source3/passdb/wscript_build
@@ -14,6 +14,7 @@ bld.SAMBA3_SUBSYSTEM('pdb',
bld.SAMBA3_MODULE('pdb_tdbsam',
subsystem='pdb',
source=PDB_TDBSAM_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('pdb_tdbsam'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('pdb_tdbsam'))
@@ -36,6 +37,7 @@ bld.SAMBA3_MODULE('pdb_ads',
bld.SAMBA3_MODULE('pdb_smbpasswd',
subsystem='pdb',
source=PDB_SMBPASSWD_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('pdb_smbpasswd'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('pdb_smbpasswd'))
@@ -43,6 +45,17 @@ bld.SAMBA3_MODULE('pdb_smbpasswd',
bld.SAMBA3_MODULE('pdb_wbc_sam',
subsystem='pdb',
source=PDB_WBC_SAM_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('pdb_wbc_sam'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('pdb_wbc_sam'))
+
+bld.SAMBA3_MODULE('pdb_samba4',
+ subsystem='pdb',
+ source='pdb_samba4.c',
+ init_function='',
+ deps='IDMAP samdb',
+ allow_undefined_symbols=False,
+ internal_module=bld.SAMBA3_IS_STATIC_MODULE('pdb_samba4'),
+ enabled=bld.SAMBA3_IS_ENABLED_MODULE('pdb_samba4'))
+
diff --git a/source3/printing/load.h b/source3/printing/load.h
index df401a43772..4611e9748c2 100644
--- a/source3/printing/load.h
+++ b/source3/printing/load.h
@@ -1,4 +1,28 @@
+/*
+ Unix SMB/CIFS implementation.
+ load printer lists
+ Copyright (C) Andrew Tridgell 1992-2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _PRINTING_LOAD_H_
+#define _PRINTING_LOAD_H_
+
/* The following definitions come from printing/load.c */
void load_printers(struct tevent_context *ev,
struct messaging_context *msg_ctx);
+
+#endif /* _PRINTING_LOAD_H_ */
diff --git a/source3/printing/lpq_parse.c b/source3/printing/lpq_parse.c
index 16b9b09fef3..9104497f9f6 100644
--- a/source3/printing/lpq_parse.c
+++ b/source3/printing/lpq_parse.c
@@ -801,8 +801,9 @@ static bool parse_lpq_plp(char *line,print_queue_struct *buf,bool first)
fstring tmp;
char *p = strrchr_m(tok[6],'/');
if (p) {
+ size_t len = strlen(tok[6])+1;
fstrcpy(tmp,p+1);
- fstrcpy(tok[6],tmp);
+ strlcpy(tok[6],tmp, len);
}
}
diff --git a/source3/printing/notify.c b/source3/printing/notify.c
index 836f7df3d11..b6b7ea045e9 100644
--- a/source3/printing/notify.c
+++ b/source3/printing/notify.c
@@ -25,6 +25,7 @@
#include "nt_printing.h"
#include "printing/notify.h"
#include "messages.h"
+#include "util_tdb.h"
static TALLOC_CTX *send_ctx;
@@ -253,9 +254,9 @@ static bool copy_notify2_msg( SPOOLSS_NOTIFY_MSG *to, SPOOLSS_NOTIFY_MSG *from )
memcpy( to, from, sizeof(SPOOLSS_NOTIFY_MSG) );
if ( from->len ) {
- to->notify.data = (char *)TALLOC_MEMDUP(send_ctx, from->notify.data, from->len );
+ to->notify.data = (char *)talloc_memdup(send_ctx, from->notify.data, from->len );
if ( !to->notify.data ) {
- DEBUG(0,("copy_notify2_msg: TALLOC_MEMDUP() of size [%d] failed!\n", from->len ));
+ DEBUG(0,("copy_notify2_msg: talloc_memdup() of size [%d] failed!\n", from->len ));
return False;
}
}
@@ -304,7 +305,7 @@ static void send_spoolss_notify2_msg(struct tevent_context *ev,
/* Store the message on the pending queue. */
- pnqueue = TALLOC_P(send_ctx, struct notify_queue);
+ pnqueue = talloc(send_ctx, struct notify_queue);
if (!pnqueue) {
DEBUG(0,("send_spoolss_notify2_msg: Out of memory.\n"));
return;
@@ -312,7 +313,7 @@ static void send_spoolss_notify2_msg(struct tevent_context *ev,
/* allocate a new msg structure and copy the fields */
- if ( !(pnqueue->msg = TALLOC_P(send_ctx, SPOOLSS_NOTIFY_MSG)) ) {
+ if ( !(pnqueue->msg = talloc(send_ctx, SPOOLSS_NOTIFY_MSG)) ) {
DEBUG(0,("send_spoolss_notify2_msg: talloc() of size [%lu] failed!\n",
(unsigned long)sizeof(SPOOLSS_NOTIFY_MSG)));
return;
@@ -356,7 +357,7 @@ static void send_notify_field_values(struct tevent_context *ev,
if (!create_send_ctx())
return;
- msg = TALLOC_P(send_ctx, struct spoolss_notify_msg);
+ msg = talloc(send_ctx, struct spoolss_notify_msg);
if (!msg)
return;
@@ -387,7 +388,7 @@ static void send_notify_field_buffer(struct tevent_context *ev,
if (!create_send_ctx())
return;
- msg = TALLOC_P(send_ctx, struct spoolss_notify_msg);
+ msg = talloc(send_ctx, struct spoolss_notify_msg);
if (!msg)
return;
@@ -398,7 +399,7 @@ static void send_notify_field_buffer(struct tevent_context *ev,
msg->field = field;
msg->id = id;
msg->len = len;
- msg->notify.data = CONST_DISCARD(char *,buffer);
+ msg->notify.data = discard_const_p(char, buffer);
send_spoolss_notify2_msg(ev, msg_ctx, msg);
}
@@ -631,7 +632,7 @@ static bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx,
return False;
tdb = pdb->tdb;
- if (tdb_read_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ if (tdb_read_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) != 0) {
DEBUG(0,("print_notify_pid_list: Failed to lock printer %s database\n",
printername));
if (pdb)
@@ -649,7 +650,7 @@ static bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx,
num_pids = data.dsize / 8;
if (num_pids) {
- if ((pid_list = TALLOC_ARRAY(mem_ctx, pid_t, num_pids)) == NULL) {
+ if ((pid_list = talloc_array(mem_ctx, pid_t, num_pids)) == NULL) {
ret = False;
goto done;
}
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index a7539f6478f..45d4191ae76 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -20,12 +20,7 @@
*/
#include "includes.h"
-#include "printing/pcap.h"
#include "printing/nt_printing_tdb.h"
-#include "printing/nt_printing_migrate.h"
-#include "registry.h"
-#include "registry/reg_objects.h"
-#include "../librpc/gen_ndr/ndr_security.h"
#include "../librpc/gen_ndr/ndr_spoolss.h"
#include "rpc_server/spoolss/srv_spoolss_util.h"
#include "nt_printing.h"
@@ -36,7 +31,7 @@
#include "smbd/smbd.h"
#include "auth.h"
#include "messages.h"
-#include "ntdomain.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
/* Map generic permissions to printer object specific permissions */
@@ -152,7 +147,7 @@ const char *get_short_archi(const char *long_archi)
do {
i++;
} while ( (archi_table[i].long_archi!=NULL ) &&
- StrCaseCmp(long_archi, archi_table[i].long_archi) );
+ strcasecmp_m(long_archi, archi_table[i].long_archi) );
if (archi_table[i].long_archi==NULL) {
DEBUGADD(10,("Unknown architecture [%s] !\n", long_archi));
@@ -578,7 +573,7 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
/****************************************************************************
Determine the correct cVersion associated with an architecture and driver
****************************************************************************/
-static uint32 get_correct_cversion(struct pipes_struct *p,
+static uint32 get_correct_cversion(struct auth_serversupplied_info *session_info,
const char *architecture,
const char *driverpath_in,
WERROR *perr)
@@ -621,7 +616,7 @@ static uint32 get_correct_cversion(struct pipes_struct *p,
nt_status = create_conn_struct(talloc_tos(), &conn, printdollar_snum,
lp_pathname(printdollar_snum),
- p->session_info, &oldcwd);
+ session_info, &oldcwd);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("get_correct_cversion: create_conn_struct "
"returned %s\n", nt_errstr(nt_status)));
@@ -636,7 +631,7 @@ static uint32 get_correct_cversion(struct pipes_struct *p,
goto error_free_conn;
}
- if (!become_user_by_session(conn, p->session_info)) {
+ if (!become_user_by_session(conn, session_info)) {
DEBUG(0, ("failed to become user\n"));
*perr = WERR_ACCESS_DENIED;
goto error_free_conn;
@@ -766,7 +761,7 @@ static uint32 get_correct_cversion(struct pipes_struct *p,
} while (0);
static WERROR clean_up_driver_struct_level(TALLOC_CTX *mem_ctx,
- struct pipes_struct *rpc_pipe,
+ struct auth_serversupplied_info *session_info,
const char *architecture,
const char **driver_path,
const char **data_file,
@@ -826,7 +821,7 @@ static WERROR clean_up_driver_struct_level(TALLOC_CTX *mem_ctx,
* NT2K: cversion=3
*/
- *version = get_correct_cversion(rpc_pipe, short_architecture,
+ *version = get_correct_cversion(session_info, short_architecture,
*driver_path, &err);
if (*version == -1) {
return err;
@@ -839,12 +834,12 @@ static WERROR clean_up_driver_struct_level(TALLOC_CTX *mem_ctx,
****************************************************************************/
WERROR clean_up_driver_struct(TALLOC_CTX *mem_ctx,
- struct pipes_struct *rpc_pipe,
+ struct auth_serversupplied_info *session_info,
struct spoolss_AddDriverInfoCtr *r)
{
switch (r->level) {
case 3:
- return clean_up_driver_struct_level(mem_ctx, rpc_pipe,
+ return clean_up_driver_struct_level(mem_ctx, session_info,
r->info.info3->architecture,
&r->info.info3->driver_path,
&r->info.info3->data_file,
@@ -853,7 +848,7 @@ WERROR clean_up_driver_struct(TALLOC_CTX *mem_ctx,
r->info.info3->dependent_files,
&r->info.info3->version);
case 6:
- return clean_up_driver_struct_level(mem_ctx, rpc_pipe,
+ return clean_up_driver_struct_level(mem_ctx, session_info,
r->info.info6->architecture,
&r->info.info6->driver_path,
&r->info.info6->data_file,
@@ -924,7 +919,7 @@ static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx,
}
/* Setup a synthetic smb_filename struct */
- smb_fname_new = TALLOC_ZERO_P(mem_ctx, struct smb_filename);
+ smb_fname_new = talloc_zero(mem_ctx, struct smb_filename);
if (!smb_fname_new) {
ret = WERR_NOMEM;
goto out;
@@ -958,7 +953,7 @@ static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx,
return ret;
}
-WERROR move_driver_to_download_area(struct pipes_struct *p,
+WERROR move_driver_to_download_area(struct auth_serversupplied_info *session_info,
struct spoolss_AddDriverInfoCtr *r)
{
struct spoolss_AddDriverInfo3 *driver;
@@ -1004,7 +999,7 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
nt_status = create_conn_struct(talloc_tos(), &conn, printdollar_snum,
lp_pathname(printdollar_snum),
- p->session_info, &oldcwd);
+ session_info, &oldcwd);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("move_driver_to_download_area: create_conn_struct "
"returned %s\n", nt_errstr(nt_status)));
@@ -1019,7 +1014,7 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
goto err_free_conn;
}
- if (!become_user_by_session(conn, p->session_info)) {
+ if (!become_user_by_session(conn, session_info)) {
DEBUG(0, ("failed to become user\n"));
err = WERR_ACCESS_DENIED;
goto err_free_conn;
diff --git a/source3/printing/nt_printing_ads.c b/source3/printing/nt_printing_ads.c
index ea414716136..6290417260f 100644
--- a/source3/printing/nt_printing_ads.c
+++ b/source3/printing/nt_printing_ads.c
@@ -28,6 +28,7 @@
#include "krb5_env.h"
#include "../libcli/registry/util_reg.h"
#include "auth.h"
+#include "../librpc/ndr/libndr.h"
#ifdef HAVE_ADS
/*****************************************************************
@@ -110,7 +111,7 @@ static WERROR nt_printer_publish_ads(struct messaging_context *msg_ctx,
DEBUG(5, ("publishing printer %s\n", printer));
/* figure out where to publish */
- ads_find_machine_acct(ads, &res, global_myname());
+ ads_find_machine_acct(ads, &res, lp_netbios_name());
/* We use ldap_get_dn here as we need the answer
* in utf8 to call ldap_explode_dn(). JRA. */
@@ -213,7 +214,7 @@ static WERROR nt_printer_unpublish_ads(ADS_STRUCT *ads,
/* remove the printer from the directory */
ads_rc = ads_find_printer_on_server(ads, &res,
- printer, global_myname());
+ printer, lp_netbios_name());
if (ADS_ERR_OK(ads_rc) && res && ads_count_replies(ads, res)) {
prt_dn = ads_get_dn(ads, talloc_tos(), res);
diff --git a/source3/printing/nt_printing_migrate.c b/source3/printing/nt_printing_migrate.c
index 55e49c973b4..ec66dfe8162 100644
--- a/source3/printing/nt_printing_migrate.c
+++ b/source3/printing/nt_printing_migrate.c
@@ -25,10 +25,10 @@
#include "rpc_client/rpc_client.h"
#include "librpc/gen_ndr/ndr_ntprinting.h"
#include "librpc/gen_ndr/ndr_spoolss_c.h"
-#include "rpc_client/cli_spoolss.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "rpc_server/rpc_ncacn_np.h"
#include "auth.h"
+#include "util_tdb.h"
#define FORMS_PREFIX "FORMS/"
#define DRIVERS_PREFIX "DRIVERS/"
@@ -73,7 +73,7 @@ static NTSTATUS migrate_form(TALLOC_CTX *mem_ctx,
DEBUG(2, ("Migrating Form: %s\n", key_name));
- srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
+ srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
if (srv_name_slash == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -164,7 +164,7 @@ static NTSTATUS migrate_driver(TALLOC_CTX *mem_ctx,
DEBUG(2, ("Migrating Printer Driver: %s\n", key_name));
- srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
+ srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
if (srv_name_slash == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -360,13 +360,13 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
/* migrate printerdata */
for (j = 0; j < r.count; j++) {
char *valuename;
- char *keyname;
+ const char *keyname;
if (r.printer_data[j].type == REG_NONE) {
continue;
}
- keyname = CONST_DISCARD(char *, r.printer_data[j].name);
+ keyname = r.printer_data[j].name;
valuename = strchr(keyname, '\\');
if (valuename == NULL) {
continue;
@@ -532,7 +532,7 @@ static NTSTATUS migrate_internal(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client *pipe_hnd)
{
const char *backup_suffix = ".bak";
- TDB_DATA kbuf, newkey, dbuf;
+ TDB_DATA kbuf, dbuf;
TDB_CONTEXT *tdb;
NTSTATUS status;
int rc;
@@ -549,11 +549,11 @@ static NTSTATUS migrate_internal(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_SUCH_FILE;
}
- for (kbuf = tdb_firstkey(tdb);
+ for (kbuf = tdb_firstkey_compat(tdb);
kbuf.dptr;
- newkey = tdb_nextkey(tdb, kbuf), free(kbuf.dptr), kbuf = newkey)
+ kbuf = tdb_nextkey_compat(tdb, kbuf))
{
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_compat(tdb, kbuf);
if (!dbuf.dptr) {
continue;
}
@@ -651,7 +651,7 @@ bool nt_printing_tdb_migrate(struct messaging_context *msg_ctx)
return false;
}
- status = rpc_pipe_open_internal(tmp_ctx,
+ status = rpc_pipe_open_interface(tmp_ctx,
&ndr_table_spoolss.syntax_id,
session_info,
NULL,
diff --git a/source3/printing/nt_printing_tdb.c b/source3/printing/nt_printing_tdb.c
index 98ac46797fc..028dc0b1da9 100644
--- a/source3/printing/nt_printing_tdb.c
+++ b/source3/printing/nt_printing_tdb.c
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/spoolss.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "libcli/security/security.h"
+#include "util_tdb.h"
#define FORMS_PREFIX "FORMS/"
#define DRIVERS_PREFIX "DRIVERS/"
@@ -87,25 +88,25 @@ static TDB_DATA make_printers_secdesc_tdbkey(TALLOC_CTX *ctx,
static bool upgrade_to_version_3(void)
{
- TDB_DATA kbuf, newkey, dbuf;
+ TDB_DATA kbuf, dbuf;
DEBUG(0,("upgrade_to_version_3: upgrading print tdb's to version 3\n"));
- for (kbuf = tdb_firstkey(tdb_drivers); kbuf.dptr;
- newkey = tdb_nextkey(tdb_drivers, kbuf), free(kbuf.dptr), kbuf=newkey) {
+ for (kbuf = tdb_firstkey_compat(tdb_drivers); kbuf.dptr;
+ kbuf = tdb_nextkey_compat(tdb_drivers, kbuf)) {
- dbuf = tdb_fetch(tdb_drivers, kbuf);
+ dbuf = tdb_fetch_compat(tdb_drivers, kbuf);
if (strncmp((const char *)kbuf.dptr, FORMS_PREFIX, strlen(FORMS_PREFIX)) == 0) {
DEBUG(0,("upgrade_to_version_3:moving form\n"));
if (tdb_store(tdb_forms, kbuf, dbuf, TDB_REPLACE) != 0) {
SAFE_FREE(dbuf.dptr);
- DEBUG(0,("upgrade_to_version_3: failed to move form. Error (%s).\n", tdb_errorstr(tdb_forms)));
+ DEBUG(0,("upgrade_to_version_3: failed to move form. Error (%s).\n", tdb_errorstr_compat(tdb_forms)));
return False;
}
if (tdb_delete(tdb_drivers, kbuf) != 0) {
SAFE_FREE(dbuf.dptr);
- DEBUG(0,("upgrade_to_version_3: failed to delete form. Error (%s)\n", tdb_errorstr(tdb_drivers)));
+ DEBUG(0,("upgrade_to_version_3: failed to delete form. Error (%s)\n", tdb_errorstr_compat(tdb_drivers)));
return False;
}
}
@@ -114,12 +115,12 @@ static bool upgrade_to_version_3(void)
DEBUG(0,("upgrade_to_version_3:moving printer\n"));
if (tdb_store(tdb_printers, kbuf, dbuf, TDB_REPLACE) != 0) {
SAFE_FREE(dbuf.dptr);
- DEBUG(0,("upgrade_to_version_3: failed to move printer. Error (%s)\n", tdb_errorstr(tdb_printers)));
+ DEBUG(0,("upgrade_to_version_3: failed to move printer. Error (%s)\n", tdb_errorstr_compat(tdb_printers)));
return False;
}
if (tdb_delete(tdb_drivers, kbuf) != 0) {
SAFE_FREE(dbuf.dptr);
- DEBUG(0,("upgrade_to_version_3: failed to delete printer. Error (%s)\n", tdb_errorstr(tdb_drivers)));
+ DEBUG(0,("upgrade_to_version_3: failed to delete printer. Error (%s)\n", tdb_errorstr_compat(tdb_drivers)));
return False;
}
}
@@ -128,12 +129,12 @@ static bool upgrade_to_version_3(void)
DEBUG(0,("upgrade_to_version_3:moving secdesc\n"));
if (tdb_store(tdb_printers, kbuf, dbuf, TDB_REPLACE) != 0) {
SAFE_FREE(dbuf.dptr);
- DEBUG(0,("upgrade_to_version_3: failed to move secdesc. Error (%s)\n", tdb_errorstr(tdb_printers)));
+ DEBUG(0,("upgrade_to_version_3: failed to move secdesc. Error (%s)\n", tdb_errorstr_compat(tdb_printers)));
return False;
}
if (tdb_delete(tdb_drivers, kbuf) != 0) {
SAFE_FREE(dbuf.dptr);
- DEBUG(0,("upgrade_to_version_3: failed to delete secdesc. Error (%s)\n", tdb_errorstr(tdb_drivers)));
+ DEBUG(0,("upgrade_to_version_3: failed to delete secdesc. Error (%s)\n", tdb_errorstr_compat(tdb_drivers)));
return False;
}
}
@@ -161,7 +162,6 @@ static int sec_desc_upg_fn( TDB_CONTEXT *the_tdb, TDB_DATA key,
struct security_descriptor *sec, *new_sec;
TALLOC_CTX *ctx = state;
int result, i;
- uint32 sd_size;
size_t size_new_sec;
if (!data.dptr || data.dsize == 0) {
@@ -235,9 +235,6 @@ static int sec_desc_upg_fn( TDB_CONTEXT *the_tdb, TDB_DATA key,
/* store it back */
- sd_size = ndr_size_security_descriptor(sd_store->sd, 0)
- + sizeof(struct sec_desc_buf);
-
status = marshall_sec_desc_buf(ctx, sd_store, &data.dptr, &data.dsize);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("sec_desc_upg_fn: Failed to parse new sec_desc for %s\n", key.dptr ));
@@ -248,7 +245,7 @@ static int sec_desc_upg_fn( TDB_CONTEXT *the_tdb, TDB_DATA key,
/* 0 to continue and non-zero to stop traversal */
- return (result == -1);
+ return (result != 0);
}
/*******************************************************************
@@ -269,7 +266,7 @@ static bool upgrade_to_version_4(void)
talloc_destroy( ctx );
- return ( result != -1 );
+ return ( result >= 0 );
}
/*******************************************************************
@@ -337,7 +334,7 @@ static bool upgrade_to_version_5(void)
talloc_destroy( ctx );
- return ( result != -1 );
+ return ( result >= 0 );
}
bool nt_printing_tdb_upgrade(void)
diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c
index 7208f4b7f8c..62db4f5efc1 100644
--- a/source3/printing/pcap.c
+++ b/source3/printing/pcap.c
@@ -43,10 +43,11 @@
struct pcap_cache {
char *name;
char *comment;
+ char *location;
struct pcap_cache *next;
};
-bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment)
+bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment, const char *location)
{
struct pcap_cache *p;
@@ -55,9 +56,11 @@ bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, cons
p->name = SMB_STRDUP(name);
p->comment = (comment && *comment) ? SMB_STRDUP(comment) : NULL;
+ p->location = (location && *location) ? SMB_STRDUP(location) : NULL;
- DEBUG(11,("pcap_cache_add_specific: Adding name %s info %s\n",
- p->name, p->comment ? p->comment : ""));
+ DEBUG(11,("pcap_cache_add_specific: Adding name %s info %s, location: %s\n",
+ p->name, p->comment ? p->comment : "",
+ p->location ? p->location : ""));
p->next = *ppcache;
*ppcache = p;
@@ -74,17 +77,18 @@ void pcap_cache_destroy_specific(struct pcap_cache **pp_cache)
SAFE_FREE(p->name);
SAFE_FREE(p->comment);
+ SAFE_FREE(p->location);
SAFE_FREE(p);
}
*pp_cache = NULL;
}
-bool pcap_cache_add(const char *name, const char *comment)
+bool pcap_cache_add(const char *name, const char *comment, const char *location)
{
NTSTATUS status;
time_t t = time_mono(NULL);
- status = printer_list_set_printer(talloc_tos(), name, comment, t);
+ status = printer_list_set_printer(talloc_tos(), name, comment, location, t);
return NT_STATUS_IS_OK(status);
}
@@ -109,7 +113,7 @@ bool pcap_cache_replace(const struct pcap_cache *pcache)
}
for (p = pcache; p; p = p->next) {
- pcap_cache_add(p->name, p->comment);
+ pcap_cache_add(p->name, p->comment, p->location);
}
status = printer_list_clean_old();
@@ -205,7 +209,7 @@ bool pcap_printername_ok(const char *printername)
{
NTSTATUS status;
- status = printer_list_get_printer(talloc_tos(), printername, NULL, 0);
+ status = printer_list_get_printer(talloc_tos(), printername, NULL, NULL, 0);
return NT_STATUS_IS_OK(status);
}
@@ -214,18 +218,18 @@ run a function on each printer name in the printcap file.
***************************************************************************/
void pcap_printer_fn_specific(const struct pcap_cache *pc,
- void (*fn)(const char *, const char *, void *),
+ void (*fn)(const char *, const char *, const char *, void *),
void *pdata)
{
const struct pcap_cache *p;
for (p = pc; p != NULL; p = p->next)
- fn(p->name, p->comment, pdata);
+ fn(p->name, p->comment, p->location, pdata);
return;
}
-void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *pdata)
+void pcap_printer_fn(void (*fn)(const char *, const char *, const char *, void *), void *pdata)
{
NTSTATUS status;
diff --git a/source3/printing/pcap.h b/source3/printing/pcap.h
index e24142e8b2a..70562137ac8 100644
--- a/source3/printing/pcap.h
+++ b/source3/printing/pcap.h
@@ -2,6 +2,16 @@
Unix SMB/CIFS implementation.
printcap headers
+ Copyright (C) Karl Auer 1993-1998
+
+ Re-working by Martin Kiff, 1994
+
+ Re-written again by Andrew Tridgell
+
+ Modified for SVID support by Norm Jacobs, 1997
+
+ Modified for CUPS support by Michael Sweet, 1999
+
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
@@ -16,17 +26,20 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef _PRINTING_PCAP_H_
+#define _PRINTING_PCAP_H_
+
struct pcap_cache;
/* The following definitions come from printing/pcap.c */
-bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment);
+bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment, const char *location);
void pcap_cache_destroy_specific(struct pcap_cache **ppcache);
-bool pcap_cache_add(const char *name, const char *comment);
+bool pcap_cache_add(const char *name, const char *comment, const char *location);
bool pcap_cache_loaded(void);
bool pcap_cache_replace(const struct pcap_cache *cache);
-void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, void *), void *);
-void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *);
+void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, const char *, void *), void *);
+void pcap_printer_fn(void (*fn)(const char *, const char *, const char *, void *), void *);
void pcap_cache_reload(struct tevent_context *ev,
struct messaging_context *msg_ctx,
@@ -44,10 +57,6 @@ bool cups_cache_reload(struct tevent_context *ev,
struct messaging_context *msg_ctx,
void (*post_cache_fill_fn)(struct tevent_context *,
struct messaging_context *));
-bool cups_pull_comment_location(TALLOC_CTX *mem_ctx,
- const char *printername,
- char **comment,
- char **location);
/* The following definitions come from printing/print_iprint.c */
@@ -59,3 +68,5 @@ bool sysv_cache_reload(void);
/* The following definitions come from printing/print_standard.c */
bool std_pcap_cache_reload(const char *pcap_name);
+
+#endif /* _PRINTING_PCAP_H_ */
diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c
index b7198d36322..23d9a86fe37 100644
--- a/source3/printing/print_aix.c
+++ b/source3/printing/print_aix.c
@@ -86,7 +86,7 @@ bool aix_cache_reload(void)
/* name is found without stanza device */
/* probably a good printer ??? */
iEtat = 0;
- if (!pcap_cache_add(name, NULL)) {
+ if (!pcap_cache_add(name, NULL, NULL)) {
SAFE_FREE(line);
x_fclose(pfile);
TALLOC_FREE(ctx);
@@ -101,7 +101,7 @@ bool aix_cache_reload(void)
} else if (strstr_m(line, "device")) {
/* it's a good virtual printer */
iEtat = 0;
- if (!pcap_cache_add(name, NULL)) {
+ if (!pcap_cache_add(name, NULL, NULL)) {
SAFE_FREE(line);
x_fclose(pfile);
TALLOC_FREE(ctx);
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index da42cb6f85d..b8bbddfebd0 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -163,6 +163,7 @@ static bool process_cups_printers_response(TALLOC_CTX *mem_ctx,
ipp_attribute_t *attr;
char *name;
char *info;
+ char *location = NULL;
struct pcap_printer *printer;
bool ret_ok = false;
@@ -206,6 +207,16 @@ static bool process_cups_printers_response(TALLOC_CTX *mem_ctx,
}
}
+ if (strcmp(attr->name, "printer-location") == 0 &&
+ attr->value_tag == IPP_TAG_TEXT) {
+ if (!pull_utf8_talloc(mem_ctx,
+ &location,
+ attr->values[0].string.text,
+ &size)) {
+ goto err_out;
+ }
+ }
+
attr = attr->next;
}
@@ -229,6 +240,7 @@ static bool process_cups_printers_response(TALLOC_CTX *mem_ctx,
pcap_data->printers = printer;
pcap_data->printers[pcap_data->count].name = name;
pcap_data->printers[pcap_data->count].info = info;
+ pcap_data->printers[pcap_data->count].location = location;
pcap_data->count++;
}
@@ -252,7 +264,8 @@ static bool cups_cache_reload_async(int fd)
static const char *requested[] =/* Requested attributes */
{
"printer-name",
- "printer-info"
+ "printer-info",
+ "printer-location"
};
bool ret = False;
enum ndr_err_code ndr_ret;
@@ -478,7 +491,8 @@ static void cups_async_callback(struct event_context *event_ctx,
for (i = 0; i < pcap_data.count; i++) {
ret_ok = pcap_cache_add_specific(&tmp_pcap_cache,
pcap_data.printers[i].name,
- pcap_data.printers[i].info);
+ pcap_data.printers[i].info,
+ pcap_data.printers[i].location);
if (!ret_ok) {
DEBUG(0, ("failed to add to tmp pcap cache\n"));
goto err_out;
@@ -510,7 +524,7 @@ bool cups_cache_reload(struct tevent_context *ev,
struct cups_async_cb_args *cb_args;
int *p_pipe_fd;
- cb_args = TALLOC_P(NULL, struct cups_async_cb_args);
+ cb_args = talloc(NULL, struct cups_async_cb_args);
if (cb_args == NULL) {
return false;
}
@@ -1573,178 +1587,6 @@ struct printif cups_printif =
cups_job_submit,
};
-bool cups_pull_comment_location(TALLOC_CTX *mem_ctx,
- const char *printername,
- char **comment,
- char **location)
-{
- TALLOC_CTX *frame = talloc_stackframe();
- http_t *http = NULL; /* HTTP connection to server */
- ipp_t *request = NULL, /* IPP Request */
- *response = NULL; /* IPP Response */
- ipp_attribute_t *attr; /* Current attribute */
- cups_lang_t *language = NULL; /* Default language */
- char uri[HTTP_MAX_URI];
- char *server = NULL;
- char *sharename = NULL;
- char *name = NULL;
- static const char *requested[] =/* Requested attributes */
- {
- "printer-name",
- "printer-info",
- "printer-location"
- };
- bool ret = False;
- size_t size;
-
- DEBUG(5, ("pulling %s location\n", printername));
-
- /*
- * Make sure we don't ask for passwords...
- */
-
- cupsSetPasswordCB(cups_passwd_cb);
-
- /*
- * Try to connect to the server...
- */
-
- if ((http = cups_connect(frame)) == NULL) {
- goto out;
- }
-
- request = ippNew();
-
- request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
- request->request.op.request_id = 1;
-
- language = cupsLangDefault();
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
- "attributes-charset", NULL, "utf-8");
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
- "attributes-natural-language", NULL, language->language);
-
- if (lp_cups_server() != NULL && strlen(lp_cups_server()) > 0) {
- if (!push_utf8_talloc(frame, &server, lp_cups_server(), &size)) {
- goto out;
- }
- } else {
- server = talloc_strdup(frame,cupsServer());
- }
- if (server) {
- goto out;
- }
- if (!push_utf8_talloc(frame, &sharename, printername, &size)) {
- goto out;
- }
- slprintf(uri, sizeof(uri) - 1, "ipp://%s/printers/%s",
- server, sharename);
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
- "printer-uri", NULL, uri);
-
- ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requested-attributes",
- (sizeof(requested) / sizeof(requested[0])),
- NULL, requested);
-
- /*
- * Do the request and get back a response...
- */
-
- if ((response = cupsDoRequest(http, request, "/")) == NULL) {
- DEBUG(0,("Unable to get printer attributes - %s\n",
- ippErrorString(cupsLastError())));
- goto out;
- }
-
- for (attr = response->attrs; attr != NULL;) {
- /*
- * Skip leading attributes until we hit a printer...
- */
-
- while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
- attr = attr->next;
-
- if (attr == NULL)
- break;
-
- /*
- * Pull the needed attributes from this printer...
- */
-
- while ( attr && (attr->group_tag == IPP_TAG_PRINTER) ) {
- if (strcmp(attr->name, "printer-name") == 0 &&
- attr->value_tag == IPP_TAG_NAME) {
- if (!pull_utf8_talloc(frame,
- &name,
- attr->values[0].string.text,
- &size)) {
- goto out;
- }
- }
-
- /* Grab the comment if we don't have one */
- if ( (strcmp(attr->name, "printer-info") == 0)
- && (attr->value_tag == IPP_TAG_TEXT))
- {
- if (!pull_utf8_talloc(mem_ctx,
- comment,
- attr->values[0].string.text,
- &size)) {
- goto out;
- }
- DEBUG(5,("cups_pull_comment_location: Using cups comment: %s\n",
- *comment));
- }
-
- /* Grab the location if we don't have one */
- if ( (strcmp(attr->name, "printer-location") == 0)
- && (attr->value_tag == IPP_TAG_TEXT))
- {
- if (!pull_utf8_talloc(mem_ctx,
- location,
- attr->values[0].string.text,
- &size)) {
- goto out;
- }
- DEBUG(5,("cups_pull_comment_location: Using cups location: %s\n",
- *location));
- }
-
- attr = attr->next;
- }
-
- /*
- * We have everything needed...
- */
-
- if (name != NULL)
- break;
- }
-
- ret = True;
-
- out:
- if (response)
- ippDelete(response);
-
- if (request) {
- ippDelete(request);
- }
-
- if (language)
- cupsLangFree(language);
-
- if (http)
- httpClose(http);
-
- TALLOC_FREE(frame);
- return ret;
-}
-
#else
/* this keeps fussy compilers happy */
void print_cups_dummy(void);
diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c
index b925bedaceb..14f4c6dbe79 100644
--- a/source3/printing/print_generic.c
+++ b/source3/printing/print_generic.c
@@ -155,17 +155,17 @@ static int generic_job_submit(int snum, struct printjob *pjob)
/* we print from the directory path to give the best chance of
parsing the lpq output */
- current_directory = TALLOC_ARRAY(ctx,
- char,
- PATH_MAX+1);
- if (!current_directory) {
- return -1;
- }
- wd = sys_getwd(current_directory);
+ wd = sys_getwd();
if (!wd) {
return -1;
}
+ current_directory = talloc_strdup(ctx, wd);
+ SAFE_FREE(wd);
+
+ if (!current_directory) {
+ return -1;
+ }
print_directory = talloc_strdup(ctx, pjob->filename);
if (!print_directory) {
return -1;
@@ -205,7 +205,7 @@ static int generic_job_submit(int snum, struct printjob *pjob)
out:
- if (chdir(wd) == -1) {
+ if (chdir(current_directory) == -1) {
smb_panic("chdir failed in generic_job_submit");
}
TALLOC_FREE(current_directory);
diff --git a/source3/printing/print_iprint.c b/source3/printing/print_iprint.c
index ea375da3b70..1392cba7b8f 100644
--- a/source3/printing/print_iprint.c
+++ b/source3/printing/print_iprint.c
@@ -297,7 +297,7 @@ static int iprint_cache_add_printer(http_t *http,
*/
if (name != NULL && !secure && smb_enabled)
- pcap_cache_add(name, info);
+ pcap_cache_add(name, info, NULL);
}
out:
diff --git a/source3/printing/print_standard.c b/source3/printing/print_standard.c
index a8460935c99..c4f9c5b7ae3 100644
--- a/source3/printing/print_standard.c
+++ b/source3/printing/print_standard.c
@@ -93,6 +93,10 @@ bool std_pcap_cache_reload(const char *pcap_name)
has_punctuation = (strchr_m(p, ' ') ||
strchr_m(p, '\t') ||
+ strchr_m(p, '"') ||
+ strchr_m(p, '\'') ||
+ strchr_m(p, ';') ||
+ strchr_m(p, ',') ||
strchr_m(p, '(') ||
strchr_m(p, ')'));
@@ -101,11 +105,7 @@ bool std_pcap_cache_reload(const char *pcap_name)
continue;
}
- if (strlen(p) <= MAXPRINTERLEN &&
- strlen(p) > strlen(name) && !has_punctuation) {
- if (!*comment) {
- strlcpy(comment, name, sizeof(comment));
- }
+ if (strlen(p) <= MAXPRINTERLEN && *name == '\0' && !has_punctuation) {
strlcpy(name, p, sizeof(name));
continue;
}
@@ -117,10 +117,7 @@ bool std_pcap_cache_reload(const char *pcap_name)
}
}
- comment[60] = 0;
- name[MAXPRINTERLEN] = 0;
-
- if (*name && !pcap_cache_add(name, comment)) {
+ if (*name && !pcap_cache_add(name, comment, NULL)) {
x_fclose(pcap_file);
return false;
}
diff --git a/source3/printing/print_svid.c b/source3/printing/print_svid.c
index 4929be14bc7..222649308ca 100644
--- a/source3/printing/print_svid.c
+++ b/source3/printing/print_svid.c
@@ -111,7 +111,7 @@ bool sysv_cache_reload(void)
*tmp = '\0';
/* add it to the cache */
- if (!pcap_cache_add(name, NULL)) {
+ if (!pcap_cache_add(name, NULL, NULL)) {
TALLOC_FREE(lines);
return False;
}
diff --git a/source3/printing/printer_list.c b/source3/printing/printer_list.c
index 417eea777bb..d28278d069b 100644
--- a/source3/printing/printer_list.c
+++ b/source3/printing/printer_list.c
@@ -20,13 +20,14 @@
#include "includes.h"
#include "system/filesys.h"
#include "dbwrap.h"
+#include "util_tdb.h"
#include "printer_list.h"
#define PL_DB_NAME() lock_path("printer_list.tdb")
#define PL_KEY_PREFIX "PRINTERLIST/PRN/"
#define PL_KEY_FORMAT PL_KEY_PREFIX"%s"
#define PL_TIMESTAMP_KEY "PRINTERLIST/GLOBAL/LAST_REFRESH"
-#define PL_DATA_FORMAT "ddPP"
+#define PL_DATA_FORMAT "ddPPP"
#define PL_TSTAMP_FORMAT "dd"
static struct db_context *get_printer_list_db(void)
@@ -64,6 +65,7 @@ bool printer_list_parent_init(void)
NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
const char *name,
const char **comment,
+ const char **location,
time_t *last_refresh)
{
struct db_context *db;
@@ -72,6 +74,7 @@ NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
uint32_t time_h, time_l;
char *nstr = NULL;
char *cstr = NULL;
+ char *lstr = NULL;
NTSTATUS status;
int ret;
@@ -95,7 +98,7 @@ NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
ret = tdb_unpack(data.dptr, data.dsize,
PL_DATA_FORMAT,
- &time_h, &time_l, &nstr, &cstr);
+ &time_h, &time_l, &nstr, &cstr, &lstr);
if (ret == -1) {
DEBUG(1, ("Failed to un pack printer data"));
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -115,6 +118,15 @@ NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
}
}
+ if (location) {
+ *location = talloc_strdup(mem_ctx, lstr);
+ if (*location == NULL) {
+ DEBUG(1, ("Failed to strdup location!\n"));
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+ }
+
status = NT_STATUS_OK;
done:
@@ -127,6 +139,7 @@ done:
NTSTATUS printer_list_set_printer(TALLOC_CTX *mem_ctx,
const char *name,
const char *comment,
+ const char *location,
time_t last_refresh)
{
struct db_context *db;
@@ -135,6 +148,7 @@ NTSTATUS printer_list_set_printer(TALLOC_CTX *mem_ctx,
uint64_t time_64;
uint32_t time_h, time_l;
const char *str = NULL;
+ const char *str2 = NULL;
NTSTATUS status;
int len;
@@ -155,11 +169,18 @@ NTSTATUS printer_list_set_printer(TALLOC_CTX *mem_ctx,
str = "";
}
+ if (location) {
+ str2 = location;
+ } else {
+ str2 = "";
+ }
+
+
time_64 = last_refresh;
time_l = time_64 & 0xFFFFFFFFL;
time_h = time_64 >> 32;
- len = tdb_pack(NULL, 0, PL_DATA_FORMAT, time_h, time_l, name, str);
+ len = tdb_pack(NULL, 0, PL_DATA_FORMAT, time_h, time_l, name, str, str2);
data.dptr = talloc_array(key, uint8_t, len);
if (!data.dptr) {
@@ -288,6 +309,7 @@ static int printer_list_clean_fn(struct db_record *rec, void *private_data)
time_t refresh;
char *name;
char *comment;
+ char *location;
int ret;
/* skip anything that does not contain PL_DATA_FORMAT data */
@@ -297,7 +319,8 @@ static int printer_list_clean_fn(struct db_record *rec, void *private_data)
}
ret = tdb_unpack(rec->value.dptr, rec->value.dsize,
- PL_DATA_FORMAT, &time_h, &time_l, &name, &comment);
+ PL_DATA_FORMAT, &time_h, &time_l, &name, &comment,
+ &location);
if (ret == -1) {
DEBUG(1, ("Failed to un pack printer data"));
state->status = NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -306,6 +329,7 @@ static int printer_list_clean_fn(struct db_record *rec, void *private_data)
SAFE_FREE(name);
SAFE_FREE(comment);
+ SAFE_FREE(location);
refresh = (time_t)(((uint64_t)time_h << 32) + time_l);
@@ -341,7 +365,7 @@ NTSTATUS printer_list_clean_old(void)
}
struct printer_list_exec_state {
- void (*fn)(const char *, const char *, void *);
+ void (*fn)(const char *, const char *, const char *, void *);
void *private_data;
NTSTATUS status;
};
@@ -353,6 +377,7 @@ static int printer_list_exec_fn(struct db_record *rec, void *private_data)
uint32_t time_h, time_l;
char *name;
char *comment;
+ char *location;
int ret;
/* always skip PL_TIMESTAMP_KEY key */
@@ -361,21 +386,23 @@ static int printer_list_exec_fn(struct db_record *rec, void *private_data)
}
ret = tdb_unpack(rec->value.dptr, rec->value.dsize,
- PL_DATA_FORMAT, &time_h, &time_l, &name, &comment);
+ PL_DATA_FORMAT, &time_h, &time_l, &name, &comment,
+ &location);
if (ret == -1) {
DEBUG(1, ("Failed to un pack printer data"));
state->status = NT_STATUS_INTERNAL_DB_CORRUPTION;
return -1;
}
- state->fn(name, comment, state->private_data);
+ state->fn(name, comment, location, state->private_data);
SAFE_FREE(name);
SAFE_FREE(comment);
+ SAFE_FREE(location);
return 0;
}
-NTSTATUS printer_list_run_fn(void (*fn)(const char *, const char *, void *),
+NTSTATUS printer_list_run_fn(void (*fn)(const char *, const char *, const char *, void *),
void *private_data)
{
struct printer_list_exec_state state;
diff --git a/source3/printing/printer_list.h b/source3/printing/printer_list.h
index fce3e34248c..fb2e007ae6c 100644
--- a/source3/printing/printer_list.h
+++ b/source3/printing/printer_list.h
@@ -32,6 +32,8 @@ bool printer_list_parent_init(void);
*
* @param[out] comment A pointer to store the comment of the printer.
*
+ * @param[out] location A pointer to store the location of the printer.
+ *
* @param[out] last_refresh A pointer to store the last refresh time of the
* printer.
*
@@ -41,6 +43,7 @@ bool printer_list_parent_init(void);
NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
const char *name,
const char **comment,
+ const char **location,
time_t *last_refresh);
/**
@@ -52,6 +55,8 @@ NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
*
* @param[in] comment The comment to store in the db.
*
+ * @param[in] location The location to store in the db.
+ *
* @param[in] last_refresh The last refresh time of the printer to store in
* the db.
*
@@ -61,6 +66,7 @@ NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx,
NTSTATUS printer_list_set_printer(TALLOC_CTX *mem_ctx,
const char *name,
const char *comment,
+ const char *location,
time_t last_refresh);
/**
@@ -94,6 +100,6 @@ NTSTATUS printer_list_mark_reload(void);
*/
NTSTATUS printer_list_clean_old(void);
-NTSTATUS printer_list_run_fn(void (*fn)(const char *, const char *, void *),
+NTSTATUS printer_list_run_fn(void (*fn)(const char *, const char *, const char *, void *),
void *private_data);
#endif /* _PRINTER_LIST_H_ */
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 785e893d3a5..0c070c76682 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -32,6 +32,7 @@
#include "smbd/smbd.h"
#include "auth.h"
#include "messages.h"
+#include "util_tdb.h"
extern struct current_user current_user;
extern userdom_struct current_user_info;
@@ -87,7 +88,7 @@ uint16 pjobid_to_rap(const char* sharename, uint32 jobid)
key.dptr = (uint8 *)&jinfo;
key.dsize = sizeof(jinfo);
- data = tdb_fetch(rap_tdb, key);
+ data = tdb_fetch_compat(rap_tdb, key);
if (data.dptr && data.dsize == sizeof(uint16)) {
rap_jobid = SVAL(data.dptr, 0);
SAFE_FREE(data.dptr);
@@ -124,7 +125,7 @@ bool rap_to_pjobid(uint16 rap_jobid, fstring sharename, uint32 *pjobid)
SSVAL(buf,0,rap_jobid);
key.dptr = buf;
key.dsize = sizeof(rap_jobid);
- data = tdb_fetch(rap_tdb, key);
+ data = tdb_fetch_compat(rap_tdb, key);
if ( data.dptr && data.dsize == sizeof(struct rap_jobid_key) )
{
struct rap_jobid_key *jinfo = (struct rap_jobid_key*)data.dptr;
@@ -162,7 +163,7 @@ void rap_jobid_delete(const char* sharename, uint32 jobid)
key.dptr = (uint8 *)&jinfo;
key.dsize = sizeof(jinfo);
- data = tdb_fetch(rap_tdb, key);
+ data = tdb_fetch_compat(rap_tdb, key);
if (!data.dptr || (data.dsize != sizeof(uint16))) {
DEBUG(10,("rap_jobid_delete: cannot find jobid %u\n",
(unsigned int)jobid ));
@@ -207,7 +208,7 @@ bool print_backend_init(struct messaging_context *msg_ctx)
pdb = get_print_db_byname(lp_const_servicename(snum));
if (!pdb)
continue;
- if (tdb_lock_bystring(pdb->tdb, sversion) == -1) {
+ if (tdb_lock_bystring(pdb->tdb, sversion) != 0) {
DEBUG(0,("print_backend_init: Failed to open printer %s database\n", lp_const_servicename(snum) ));
release_print_db(pdb);
return False;
@@ -440,7 +441,7 @@ static struct printjob *print_job_find(const char *sharename, uint32 jobid)
return NULL;
}
- ret = tdb_fetch(pdb->tdb, print_key(jobid, &tmp));
+ ret = tdb_fetch_compat(pdb->tdb, print_key(jobid, &tmp));
release_print_db(pdb);
if (!ret.dptr) {
@@ -604,12 +605,12 @@ static bool remove_from_jobs_changed(const char* sharename, uint32_t jobid)
key = string_tdb_data("INFO/jobs_changed");
- if (tdb_chainlock_with_timeout(pdb->tdb, key, 5) == -1)
+ if (tdb_chainlock_with_timeout(pdb->tdb, key, 5) != 0)
goto out;
gotlock = True;
- data = tdb_fetch(pdb->tdb, key);
+ data = tdb_fetch_compat(pdb->tdb, key);
if (data.dptr == NULL || data.dsize == 0 || (data.dsize % 4 != 0))
goto out;
@@ -623,7 +624,7 @@ static bool remove_from_jobs_changed(const char* sharename, uint32_t jobid)
if (i < job_count -1 )
memmove(data.dptr + (i*4), data.dptr + (i*4) + 4, (job_count - i - 1)*4 );
data.dsize -= 4;
- if (tdb_store(pdb->tdb, key, data, TDB_REPLACE) == -1)
+ if (tdb_store(pdb->tdb, key, data, TDB_REPLACE) != 0)
goto out;
break;
}
@@ -727,7 +728,7 @@ static bool pjob_store(struct tevent_context *ev,
/* Get old data */
- old_data = tdb_fetch(pdb->tdb, print_key(jobid, &tmp));
+ old_data = tdb_fetch_compat(pdb->tdb, print_key(jobid, &tmp));
/* Doh! Now we have to pack/unpack data since the NT_DEVICEMODE was added */
@@ -1077,7 +1078,7 @@ static pid_t get_updating_pid(const char *sharename)
slprintf(keystr, sizeof(keystr)-1, "UPDATING/%s", sharename);
key = string_tdb_data(keystr);
- data = tdb_fetch(pdb->tdb, key);
+ data = tdb_fetch_compat(pdb->tdb, key);
release_print_db(pdb);
if (!data.dptr || data.dsize != sizeof(pid_t)) {
SAFE_FREE(data.dptr);
@@ -1224,7 +1225,7 @@ static TDB_DATA get_jobs_added_data(struct tdb_print_db *pdb)
ZERO_STRUCT(data);
- data = tdb_fetch(pdb->tdb, string_tdb_data("INFO/jobs_added"));
+ data = tdb_fetch_compat(pdb->tdb, string_tdb_data("INFO/jobs_added"));
if (data.dptr == NULL || data.dsize == 0 || (data.dsize % 4 != 0)) {
SAFE_FREE(data.dptr);
ZERO_STRUCT(data);
@@ -1515,7 +1516,7 @@ static void print_queue_update_with_lock( struct tevent_context *ev,
slprintf(keystr, sizeof(keystr) - 1, "LOCK/%s", sharename);
/* Only wait 10 seconds for this. */
- if (tdb_lock_bystring_with_timeout(pdb->tdb, keystr, 10) == -1) {
+ if (tdb_lock_bystring_with_timeout(pdb->tdb, keystr, 10) != 0) {
DEBUG(0,("print_queue_update_with_lock: Failed to lock printer %s database\n", sharename));
release_print_db(pdb);
return;
@@ -1884,7 +1885,7 @@ bool print_notify_register_pid(int snum)
tdb = pdb->tdb;
}
- if (tdb_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ if (tdb_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) != 0) {
DEBUG(0,("print_notify_register_pid: Failed to lock printer %s\n",
printername));
if (pdb)
@@ -1918,7 +1919,7 @@ bool print_notify_register_pid(int snum)
}
/* Store back the record. */
- if (tdb_store_bystring(tdb, NOTIFY_PID_LIST_KEY, data, TDB_REPLACE) == -1) {
+ if (tdb_store_bystring(tdb, NOTIFY_PID_LIST_KEY, data, TDB_REPLACE) != 0) {
DEBUG(0,("print_notify_register_pid: Failed to update pid \
list for printer %s\n", printername));
goto done;
@@ -1974,7 +1975,7 @@ bool print_notify_deregister_pid(int snum)
tdb = pdb->tdb;
}
- if (tdb_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ if (tdb_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) != 0) {
DEBUG(0,("print_notify_register_pid: Failed to lock \
printer %s database\n", printername));
if (pdb)
@@ -2008,7 +2009,7 @@ printer %s database\n", printername));
SAFE_FREE(data.dptr);
/* Store back the record. */
- if (tdb_store_bystring(tdb, NOTIFY_PID_LIST_KEY, data, TDB_REPLACE) == -1) {
+ if (tdb_store_bystring(tdb, NOTIFY_PID_LIST_KEY, data, TDB_REPLACE) != 0) {
DEBUG(0,("print_notify_register_pid: Failed to update pid \
list for printer %s\n", printername));
goto done;
@@ -2133,12 +2134,12 @@ static bool remove_from_jobs_added(const char* sharename, uint32 jobid)
key = string_tdb_data("INFO/jobs_added");
- if (tdb_chainlock_with_timeout(pdb->tdb, key, 5) == -1)
+ if (tdb_chainlock_with_timeout(pdb->tdb, key, 5) != 0)
goto out;
gotlock = True;
- data = tdb_fetch(pdb->tdb, key);
+ data = tdb_fetch_compat(pdb->tdb, key);
if (data.dptr == NULL || data.dsize == 0 || (data.dsize % 4 != 0))
goto out;
@@ -2152,7 +2153,7 @@ static bool remove_from_jobs_added(const char* sharename, uint32 jobid)
if (i < job_count -1 )
memmove(data.dptr + (i*4), data.dptr + (i*4) + 4, (job_count - i - 1)*4 );
data.dsize -= 4;
- if (tdb_store(pdb->tdb, key, data, TDB_REPLACE) == -1)
+ if (tdb_store(pdb->tdb, key, data, TDB_REPLACE) != 0)
goto out;
break;
}
@@ -2501,7 +2502,7 @@ static int get_queue_status(const char* sharename, print_status_struct *status)
if (status) {
fstr_sprintf(keystr, "STATUS/%s", sharename);
- data = tdb_fetch(pdb->tdb, string_tdb_data(keystr));
+ data = tdb_fetch_compat(pdb->tdb, string_tdb_data(keystr));
if (data.dptr) {
if (data.dsize == sizeof(print_status_struct))
/* this memcpy is ok since the status struct was
@@ -2560,7 +2561,7 @@ static WERROR allocate_print_jobid(struct tdb_print_db *pdb, int snum,
/* Lock the database - only wait 20 seconds. */
ret = tdb_lock_bystring_with_timeout(pdb->tdb,
"INFO/nextjob", 20);
- if (ret == -1) {
+ if (ret != 0) {
DEBUG(0, ("allocate_print_jobid: "
"Failed to lock printing database %s\n",
sharename));
@@ -2588,7 +2589,7 @@ static WERROR allocate_print_jobid(struct tdb_print_db *pdb, int snum,
jobid = NEXT_JOBID(jobid);
ret = tdb_store_int32(pdb->tdb, "INFO/nextjob", jobid);
- if (ret == -1) {
+ if (ret != 0) {
terr = tdb_error(pdb->tdb);
DEBUG(3, ("allocate_print_jobid: "
"Failed to store INFO/nextjob.\n"));
@@ -2621,7 +2622,7 @@ static WERROR allocate_print_jobid(struct tdb_print_db *pdb, int snum,
dum.dptr = NULL;
dum.dsize = 0;
if (tdb_store(pdb->tdb, print_key(jobid, &tmp), dum,
- TDB_INSERT) == -1) {
+ TDB_INSERT) != 0) {
DEBUG(3, ("allocate_print_jobid: "
"jobid (%d) failed to store placeholder.\n",
jobid ));
@@ -3037,18 +3038,18 @@ static bool get_stored_queue_info(struct messaging_context *msg_ctx,
ZERO_STRUCT(cgdata);
/* Get the stored queue data. */
- data = tdb_fetch(pdb->tdb, string_tdb_data("INFO/linear_queue_array"));
+ data = tdb_fetch_compat(pdb->tdb, string_tdb_data("INFO/linear_queue_array"));
if (data.dptr && data.dsize >= sizeof(qcount))
len += tdb_unpack(data.dptr + len, data.dsize - len, "d", &qcount);
/* Get the added jobs list. */
- cgdata = tdb_fetch(pdb->tdb, string_tdb_data("INFO/jobs_added"));
+ cgdata = tdb_fetch_compat(pdb->tdb, string_tdb_data("INFO/jobs_added"));
if (cgdata.dptr != NULL && (cgdata.dsize % 4 == 0))
extra_count = cgdata.dsize/4;
/* Get the changed jobs list. */
- jcdata = tdb_fetch(pdb->tdb, string_tdb_data("INFO/jobs_changed"));
+ jcdata = tdb_fetch_compat(pdb->tdb, string_tdb_data("INFO/jobs_changed"));
if (jcdata.dptr != NULL && (jcdata.dsize % 4 == 0))
changed_count = jcdata.dsize / 4;
@@ -3215,7 +3216,7 @@ int print_queue_status(struct messaging_context *msg_ctx, int snum,
slprintf(keystr, sizeof(keystr)-1, "STATUS/%s", sharename);
key = string_tdb_data(keystr);
- data = tdb_fetch(pdb->tdb, key);
+ data = tdb_fetch_compat(pdb->tdb, key);
if (data.dptr) {
if (data.dsize == sizeof(*status)) {
/* this memcpy is ok since the status struct was
diff --git a/source3/printing/printing_db.c b/source3/printing/printing_db.c
index 70accab9350..e442551b833 100644
--- a/source3/printing/printing_db.c
+++ b/source3/printing/printing_db.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "printing.h"
+#include "util_tdb.h"
static struct tdb_print_db *print_db_head;
@@ -159,7 +160,7 @@ void close_all_print_db(void)
messages. data needs freeing on exit.
****************************************************************************/
-TDB_DATA get_printer_notify_pid_list(TDB_CONTEXT *tdb, const char *printer_name, bool cleanlist)
+TDB_DATA get_printer_notify_pid_list(struct tdb_context *tdb, const char *printer_name, bool cleanlist)
{
TDB_DATA data;
size_t i;
diff --git a/source3/printing/printspoolss.c b/source3/printing/printspoolss.c
index 2f6f19c3da7..3d8b0d8b1bb 100644
--- a/source3/printing/printspoolss.c
+++ b/source3/printing/printspoolss.c
@@ -22,7 +22,6 @@
#include "rpc_client/rpc_client.h"
#include "../librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_server/rpc_ncacn_np.h"
-#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/security/security.h"
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index 340bf0a5f14..896aee0a539 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -19,15 +19,16 @@
#include "includes.h"
#include "serverid.h"
#include "smbd/smbd.h"
-#include "locking/proto.h"
#include "messages.h"
#include "include/printing.h"
#include "printing/nt_printing_migrate.h"
+#include "ntdomain.h"
#include "librpc/gen_ndr/srv_winreg.h"
#include "librpc/gen_ndr/srv_spoolss.h"
#include "rpc_server/rpc_server.h"
#include "rpc_server/rpc_ep_setup.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
#define SPOOLSS_PIPE_NAME "spoolss"
#define DAEMON_NAME "spoolssd"
diff --git a/source3/printing/tests/vlp.c b/source3/printing/tests/vlp.c
index 4bff290e28a..66860e5ada3 100644
--- a/source3/printing/tests/vlp.c
+++ b/source3/printing/tests/vlp.c
@@ -23,6 +23,7 @@
#include "system/passwd.h"
#include "system/filesys.h"
#include "printing.h"
+#include "util_tdb.h"
#ifdef malloc
#undef malloc
@@ -110,10 +111,9 @@ static int next_jobnum(char *printer)
static void set_printer_status(char *printer, int status)
{
fstring keystr;
- int result;
slprintf(keystr, sizeof(keystr) - 1, "STATUS/%s", printer);
- result = tdb_store_int32(tdb, keystr, status);
+ tdb_store_int32(tdb, keystr, status);
}
static int get_printer_status(char *printer)
@@ -392,8 +392,9 @@ int main(int argc, char **argv)
return 1;
}
- if (!(tdb = tdb_open(printdb_path, 0, 0, O_RDWR | O_CREAT,
- 0666))) {
+ /* FIXME: We should *never* open a tdb without logging! */
+ if (!(tdb = tdb_open_compat(printdb_path, 0, 0, O_RDWR | O_CREAT,
+ 0666, NULL, NULL))) {
printf("%s: unable to open %s\n", argv[0], printdb_path);
return 1;
}
diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c
index 935d2441afa..51bd98e9395 100644
--- a/source3/registry/reg_api.c
+++ b/source3/registry/reg_api.c
@@ -142,9 +142,9 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
SMB_ASSERT(strchr(name, '\\') == NULL);
- if (!(regkey = TALLOC_ZERO_P(mem_ctx, struct registry_key)) ||
+ if (!(regkey = talloc_zero(mem_ctx, struct registry_key)) ||
!(regkey->token = dup_nt_token(regkey, token)) ||
- !(regkey->key = TALLOC_ZERO_P(regkey, struct registry_key_handle)))
+ !(regkey->key = talloc_zero(regkey, struct registry_key_handle)))
{
result = WERR_NOMEM;
goto done;
@@ -188,7 +188,7 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
/* Tag this as a Performance Counter Key */
- if( StrnCaseCmp(key->name, KEY_HKPD, strlen(KEY_HKPD)) == 0 )
+ if( strncasecmp_m(key->name, KEY_HKPD, strlen(KEY_HKPD)) == 0 )
key->type = REG_KEY_HKPD;
/* Look up the table of registry I/O operations */
diff --git a/source3/registry/reg_backend_current_version.c b/source3/registry/reg_backend_current_version.c
index ab7bd517b0c..adf304e8c95 100644
--- a/source3/registry/reg_backend_current_version.c
+++ b/source3/registry/reg_backend_current_version.c
@@ -58,8 +58,8 @@ static int current_version_fetch_values(const char *key, struct regval_ctr *valu
regval_ctr_addvalue_sz(values, "SystemRoot", sysroot_string);
- fstr_sprintf(sysversion, "%d.%d", lp_major_announce_version(),
- lp_minor_announce_version());
+ fstr_sprintf(sysversion, "%d.%d", SAMBA_MAJOR_NBT_ANNOUNCE_VERSION,
+ SAMBA_MINOR_NBT_ANNOUNCE_VERSION);
regval_ctr_addvalue_sz(values, "CurrentVersion", sysversion);
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 6024a354c47..812dd0d43cf 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -28,7 +28,9 @@
#include "reg_backend_db.h"
#include "reg_objects.h"
#include "nt_printing.h"
+#include "util_tdb.h"
#include "dbwrap.h"
+#include "../libcli/security/secdesc.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_REGISTRY
@@ -47,6 +49,8 @@ static int regdb_fetch_values_internal(struct db_context *db, const char* key,
static bool regdb_store_values_internal(struct db_context *db, const char *key,
struct regval_ctr *values);
+static NTSTATUS create_sorted_subkeys(const char *key);
+
/* List the deepest path into the registry. All part components will be created.*/
/* If you want to have a part of the path controlled by the tdb and part by
@@ -478,7 +482,7 @@ static WERROR regdb_upgrade_v1_to_v2(void)
talloc_destroy(mem_ctx);
- if (rc == -1) {
+ if (rc < 0) {
return WERR_REG_IO_FAILURE;
}
@@ -831,22 +835,9 @@ static WERROR regdb_store_keys_internal2(struct db_context *db,
W_ERROR_NOT_OK_GOTO_DONE(werr);
/*
- * Delete a sorted subkey cache for regdb_key_exists, will be
- * recreated automatically
+ * recreate the sorted subkey cache for regdb_key_exists()
*/
- keyname = talloc_asprintf(ctx, "%s\\%s", REG_SORTED_SUBKEYS_PREFIX,
- keyname);
- if (keyname == NULL) {
- werr = WERR_NOMEM;
- goto done;
- }
-
- werr = ntstatus_to_werror(dbwrap_delete_bystring(db, keyname));
-
- /* don't treat WERR_NOT_FOUND as an error here */
- if (W_ERROR_EQUAL(werr, WERR_NOT_FOUND)) {
- werr = WERR_OK;
- }
+ werr = ntstatus_to_werror(create_sorted_subkeys(keyname));
done:
TALLOC_FREE(ctx);
@@ -1310,7 +1301,7 @@ done:
static int cmp_keynames(char **p1, char **p2)
{
- return StrCaseCmp(*p1, *p2);
+ return strcasecmp_m(*p1, *p2);
}
struct create_sorted_subkeys_context {
@@ -1407,7 +1398,8 @@ done:
return status;
}
-static bool create_sorted_subkeys(const char *key, const char *sorted_keyname)
+static NTSTATUS create_sorted_subkeys_internal(const char *key,
+ const char *sorted_keyname)
{
NTSTATUS status;
struct create_sorted_subkeys_context sorted_ctx;
@@ -1419,7 +1411,26 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname)
create_sorted_subkeys_action,
&sorted_ctx);
- return NT_STATUS_IS_OK(status);
+ return status;
+}
+
+static NTSTATUS create_sorted_subkeys(const char *key)
+{
+ char *sorted_subkeys_keyname;
+ NTSTATUS status;
+
+ sorted_subkeys_keyname = talloc_asprintf(talloc_tos(), "%s\\%s",
+ REG_SORTED_SUBKEYS_PREFIX,
+ key);
+ if (sorted_subkeys_keyname == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ status = create_sorted_subkeys_internal(key, sorted_subkeys_keyname);
+
+done:
+ return status;
}
struct scan_subkey_state {
@@ -1499,13 +1510,21 @@ static bool scan_parent_subkeys(struct db_context *db, const char *parent,
if (state.scanned) {
result = state.found;
} else {
+ NTSTATUS status;
+
res = db->transaction_start(db);
if (res != 0) {
- DEBUG(0, ("error starting transacion\n"));
+ DEBUG(0, ("error starting transaction\n"));
goto fail;
}
- if (!create_sorted_subkeys(path, key)) {
+ DEBUG(2, (__location__ " WARNING: recreating the sorted "
+ "subkeys cache for key '%s' from scan_parent_subkeys "
+ "this should not happen (too frequently)...\n",
+ path));
+
+ status = create_sorted_subkeys_internal(path, key);
+ if (!NT_STATUS_IS_OK(status)) {
res = db->transaction_cancel(db);
if (res != 0) {
smb_panic("Failed to cancel transaction.");
@@ -1801,7 +1820,7 @@ static bool regdb_store_values_internal(struct db_context *db, const char *key,
goto done;
}
- data.dptr = TALLOC_ARRAY(ctx, uint8, len);
+ data.dptr = talloc_array(ctx, uint8, len);
data.dsize = len;
len = regdb_pack_values(values, data.dptr, data.dsize);
diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c
index 0fab3f7d8be..62487e1e4f4 100644
--- a/source3/registry/reg_objects.c
+++ b/source3/registry/reg_objects.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "registry.h"
#include "reg_objects.h"
+#include "util_tdb.h"
#include "dbwrap.h"
#include "../libcli/registry/util_reg.h"
@@ -61,7 +62,7 @@ struct regsubkey_ctr {
context for internal private data.
There is no longer a regval_ctr_intit() and regval_ctr_destroy()
- pair of functions. Simply TALLOC_ZERO_P() and TALLOC_FREE() the
+ pair of functions. Simply talloc_zero() and TALLOC_FREE() the
object.
**********************************************************************/
@@ -210,7 +211,7 @@ WERROR regsubkey_ctr_addkey( struct regsubkey_ctr *ctr, const char *keyname )
return WERR_OK;
}
- if (!(newkeys = TALLOC_REALLOC_ARRAY(ctr, ctr->subkeys, char *,
+ if (!(newkeys = talloc_realloc(ctr, ctr->subkeys, char *,
ctr->num_subkeys+1))) {
return WERR_NOMEM;
}
@@ -465,7 +466,7 @@ struct regval_blob *regval_compose(TALLOC_CTX *ctx, const char *name,
uint32_t type,
const uint8_t *data_p, size_t size)
{
- struct regval_blob *regval = TALLOC_P(ctx, struct regval_blob);
+ struct regval_blob *regval = talloc(ctx, struct regval_blob);
if (regval == NULL) {
return NULL;
@@ -474,7 +475,7 @@ struct regval_blob *regval_compose(TALLOC_CTX *ctx, const char *name,
fstrcpy(regval->valuename, name);
regval->type = type;
if (size) {
- regval->data_p = (uint8_t *)TALLOC_MEMDUP(regval, data_p, size);
+ regval->data_p = (uint8_t *)talloc_memdup(regval, data_p, size);
if (!regval->data_p) {
TALLOC_FREE(regval);
return NULL;
@@ -504,9 +505,9 @@ int regval_ctr_addvalue(struct regval_ctr *ctr, const char *name, uint32_t type,
/* allocate a slot in the array of pointers */
if ( ctr->num_values == 0 ) {
- ctr->values = TALLOC_P( ctr, struct regval_blob *);
+ ctr->values = talloc( ctr, struct regval_blob *);
} else {
- ctr->values = TALLOC_REALLOC_ARRAY(ctr, ctr->values,
+ ctr->values = talloc_realloc(ctr, ctr->values,
struct regval_blob *,
ctr->num_values+1);
}
diff --git a/source3/registry/reg_parse.c b/source3/registry/reg_parse.c
index 0c596a8f5e0..f1258fca6d1 100644
--- a/source3/registry/reg_parse.c
+++ b/source3/registry/reg_parse.c
@@ -622,7 +622,7 @@ static bool lookslike_utf16(const char* line, size_t len, bool* little_endian)
bool le;
size_t l = MIN(len/2, 64);
- uint16_t* u = (uint16_t*)line;
+ const uint16_t* u = (const uint16_t*)line;
int i;
assert(len >= 2);
diff --git a/source3/registry/reg_parse_internal.c b/source3/registry/reg_parse_internal.c
index dedbe123d86..208844856f0 100644
--- a/source3/registry/reg_parse_internal.c
+++ b/source3/registry/reg_parse_internal.c
@@ -1,4 +1,9 @@
-/* * Samba Unix/Linux SMB client library
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * Registry helper routines
+ *
+ * Copyright (C) Gregor Beck 2010
*
* 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
@@ -308,7 +313,7 @@ int write_bom(FILE* file, const char* charset, charset_t ctype)
DEBUG(0, ("No Byte Order Mark for charset_t: %u\n", (unsigned)ctype));
} else {
for (i=0; BOM[i].name; i++) {
- if (StrCaseCmp(BOM[i].name, charset) == 0) {
+ if (strcasecmp_m(BOM[i].name, charset) == 0) {
return fwrite(BOM[i].seq, 1, BOM[i].len, file);
}
}
diff --git a/source3/registry/reg_parse_internal.h b/source3/registry/reg_parse_internal.h
index ef591617569..14fed89aa95 100644
--- a/source3/registry/reg_parse_internal.h
+++ b/source3/registry/reg_parse_internal.h
@@ -1,4 +1,9 @@
-/* Samba Unix/Linux SMB client library
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * Registry helper routines
+ *
+ * Copyright (C) Gregor Beck 2010
*
* 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
diff --git a/source3/registry/reg_perfcount.c b/source3/registry/reg_perfcount.c
index 4ed3305c158..64e3cbee0f6 100644
--- a/source3/registry/reg_perfcount.c
+++ b/source3/registry/reg_perfcount.c
@@ -25,6 +25,7 @@
#include "registry.h"
#include "reg_perfcount.h"
#include "../libcli/registry/util_reg.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_REGISTRY
@@ -94,7 +95,7 @@ uint32 reg_perfcount_get_base_index(void)
and so on.
So last_counter becomes num_counters*2, and last_help will be last_counter+1 */
kbuf = string_tdb_data(key);
- dbuf = tdb_fetch(names, kbuf);
+ dbuf = tdb_fetch_compat(names, kbuf);
if(dbuf.dptr == NULL)
{
DEBUG(1, ("reg_perfcount_get_base_index: failed to find key \'1\' in [%s].\n", fname));
@@ -161,7 +162,7 @@ static uint32 _reg_perfcount_multi_sz_from_tdb(TDB_CONTEXT *tdb,
memset(temp, 0, sizeof(temp));
snprintf(temp, sizeof(temp), "%d", keyval);
kbuf = string_tdb_data(temp);
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_compat(tdb, kbuf);
if(dbuf.dptr == NULL)
{
/* If a key isn't there, just bypass it -- this really shouldn't
@@ -346,7 +347,7 @@ static uint32 _reg_perfcount_get_numinst(int objInd, TDB_CONTEXT *names)
char buf[PERFCOUNT_MAX_LEN];
_reg_perfcount_make_key(&key, buf, PERFCOUNT_MAX_LEN, objInd, "inst");
- data = tdb_fetch(names, key);
+ data = tdb_fetch_compat(names, key);
if(data.dptr == NULL)
return (uint32)PERF_NO_INSTANCES;
@@ -375,7 +376,7 @@ static bool _reg_perfcount_add_object(struct PERF_DATA_BLOCK *block,
bool success = True;
struct PERF_OBJECT_TYPE *obj;
- block->objects = (struct PERF_OBJECT_TYPE *)TALLOC_REALLOC_ARRAY(mem_ctx,
+ block->objects = (struct PERF_OBJECT_TYPE *)talloc_realloc(mem_ctx,
block->objects,
struct PERF_OBJECT_TYPE,
block->NumObjectTypes+1);
@@ -420,7 +421,7 @@ static bool _reg_perfcount_get_counter_data(TDB_DATA key, TDB_DATA *data)
return False;
}
- *data = tdb_fetch(counters, key);
+ *data = tdb_fetch_compat(counters, key);
tdb_close(counters);
@@ -487,7 +488,7 @@ static bool _reg_perfcount_get_counter_info(struct PERF_DATA_BLOCK *block,
padding = 0;
_reg_perfcount_make_key(&key, buf, PERFCOUNT_MAX_LEN, CounterIndex, "type");
- data = tdb_fetch(names, key);
+ data = tdb_fetch_compat(names, key);
if(data.dptr == NULL)
{
DEBUG(3, ("_reg_perfcount_get_counter_info: No type data for counter [%d].\n", CounterIndex));
@@ -546,7 +547,7 @@ static bool _reg_perfcount_get_counter_info(struct PERF_DATA_BLOCK *block,
SAFE_FREE(data.dptr);
obj->counter_data.ByteLength += dsize + padding;
- obj->counter_data.data = TALLOC_REALLOC_ARRAY(mem_ctx,
+ obj->counter_data.data = talloc_realloc(mem_ctx,
obj->counter_data.data,
uint8,
obj->counter_data.ByteLength - sizeof(uint32));
@@ -634,7 +635,7 @@ static bool _reg_perfcount_add_counter(struct PERF_DATA_BLOCK *block,
parent, num));
return False;
}
- obj->counters = (struct PERF_COUNTER_DEFINITION *)TALLOC_REALLOC_ARRAY(mem_ctx,
+ obj->counters = (struct PERF_COUNTER_DEFINITION *)talloc_realloc(mem_ctx,
obj->counters,
struct PERF_COUNTER_DEFINITION,
obj->NumCounters+1);
@@ -686,7 +687,7 @@ static bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *in
return False;
}
inst->counter_data.ByteLength = data.dsize + sizeof(inst->counter_data.ByteLength);
- inst->counter_data.data = TALLOC_REALLOC_ARRAY(mem_ctx,
+ inst->counter_data.data = talloc_realloc(mem_ctx,
inst->counter_data.data,
uint8,
data.dsize);
@@ -700,7 +701,7 @@ static bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *in
memset(temp, 0, PERFCOUNT_MAX_LEN);
snprintf(temp, PERFCOUNT_MAX_LEN, "i%dname", instId);
_reg_perfcount_make_key(&key, buf, PERFCOUNT_MAX_LEN, obj->ObjectNameTitleIndex, temp);
- data = tdb_fetch(names, key);
+ data = tdb_fetch_compat(names, key);
if(data.dptr == NULL)
{
/* Not actually an error, but possibly unintended? -- just logging FYI */
@@ -718,7 +719,7 @@ static bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *in
SAFE_FREE(data.dptr);
return False;
}
- inst->data = TALLOC_REALLOC_ARRAY(mem_ctx,
+ inst->data = talloc_realloc(mem_ctx,
inst->data,
uint8,
inst->NameLength);
@@ -740,7 +741,7 @@ static bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *in
if((pad = (inst->ByteLength % 8)))
{
pad = 8 - pad;
- inst->data = TALLOC_REALLOC_ARRAY(mem_ctx,
+ inst->data = talloc_realloc(mem_ctx,
inst->data,
uint8,
inst->NameLength + pad);
@@ -762,7 +763,7 @@ static bool _reg_perfcount_add_instance(struct PERF_OBJECT_TYPE *obj,
struct PERF_INSTANCE_DEFINITION *inst;
if(obj->instances == NULL) {
- obj->instances = TALLOC_REALLOC_ARRAY(mem_ctx,
+ obj->instances = talloc_realloc(mem_ctx,
obj->instances,
struct PERF_INSTANCE_DEFINITION,
obj->NumInstances);
@@ -792,7 +793,7 @@ static int _reg_perfcount_assemble_global(struct PERF_DATA_BLOCK *block,
{
j = i*2;
_reg_perfcount_make_key(&key, keybuf, PERFCOUNT_MAX_LEN, j, "rel");
- data = tdb_fetch(names, key);
+ data = tdb_fetch_compat(names, key);
if(data.dptr != NULL)
{
if(_reg_perfcount_isparent(data))
@@ -830,7 +831,7 @@ static bool _reg_perfcount_get_64(uint64_t *retval,
_reg_perfcount_make_key(&key, buf, PERFCOUNT_MAX_LEN, key_part1, key_part2);
- data = tdb_fetch(tdb, key);
+ data = tdb_fetch_compat(tdb, key);
if(data.dptr == NULL)
{
DEBUG(3,("_reg_perfcount_get_64: No data found for key [%s].\n", key.dptr));
@@ -942,9 +943,9 @@ static bool _reg_perfcount_init_data_block(struct PERF_DATA_BLOCK *block,
make_systemtime(&(block->SystemTime), gmtime(&tm));
_reg_perfcount_init_data_block_perf(block, names);
memset(temp, 0, sizeof(temp));
- rpcstr_push((void *)temp, global_myname(), sizeof(temp), STR_TERMINATE);
+ rpcstr_push((void *)temp, lp_netbios_name(), sizeof(temp), STR_TERMINATE);
block->SystemNameLength = (strlen_w(temp) * 2) + 2;
- block->data = TALLOC_ZERO_ARRAY(mem_ctx, uint8, block->SystemNameLength + (8 - (block->SystemNameLength % 8)));
+ block->data = talloc_zero_array(mem_ctx, uint8, block->SystemNameLength + (8 - (block->SystemNameLength % 8)));
if (block->data == NULL) {
return False;
}
@@ -992,7 +993,7 @@ static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block
counter_data = &(instance->counter_data);
counter = &(object[obj].counters[object[obj].NumCounters - 1]);
counter_data->ByteLength = counter->CounterOffset + counter->CounterSize + sizeof(counter_data->ByteLength);
- temp = TALLOC_REALLOC_ARRAY(mem_ctx,
+ temp = talloc_realloc(mem_ctx,
temp,
char,
counter_data->ByteLength- sizeof(counter_data->ByteLength));
@@ -1013,7 +1014,7 @@ static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block
{
pad = 8 - pad;
}
- counter_data->data = TALLOC_REALLOC_ARRAY(mem_ctx,
+ counter_data->data = talloc_realloc(mem_ctx,
counter_data->data,
uint8,
counter_data->ByteLength - sizeof(counter_data->ByteLength) + pad);
@@ -1033,7 +1034,7 @@ static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block
if((pad = (object[obj].counter_data.ByteLength % 8)))
{
pad = 8 - pad;
- object[obj].counter_data.data = TALLOC_REALLOC_ARRAY(mem_ctx,
+ object[obj].counter_data.data = talloc_realloc(mem_ctx,
object[obj].counter_data.data,
uint8,
object[obj].counter_data.ByteLength + pad);
diff --git a/source3/registry/reg_util_internal.c b/source3/registry/reg_util_internal.c
index a1aeaa405cd..b15015b988d 100644
--- a/source3/registry/reg_util_internal.c
+++ b/source3/registry/reg_util_internal.c
@@ -97,12 +97,11 @@ char *normalize_reg_path(TALLOC_CTX *ctx, const char *keyname )
char *nkeyname;
/* skip leading '\' chars */
- p = (char *)keyname;
- while (*p == '\\') {
- p++;
+ while (*keyname == '\\') {
+ keyname++;
}
- nkeyname = talloc_strdup(ctx, p);
+ nkeyname = talloc_strdup(ctx, keyname);
if (nkeyname == NULL) {
return NULL;
}
diff --git a/source3/registry/reg_util_token.c b/source3/registry/reg_util_token.c
index ca0159a6491..d599b3a33dd 100644
--- a/source3/registry/reg_util_token.c
+++ b/source3/registry/reg_util_token.c
@@ -38,7 +38,7 @@ NTSTATUS registry_create_admin_token(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
- token = TALLOC_ZERO_P(mem_ctx, struct security_token);
+ token = talloc_zero(mem_ctx, struct security_token);
if (token == NULL) {
DEBUG(1, ("talloc failed\n"));
status = NT_STATUS_NO_MEMORY;
diff --git a/source3/registry/regfio.c b/source3/registry/regfio.c
index bd5380787c6..6d2beccfef1 100644
--- a/source3/registry/regfio.c
+++ b/source3/registry/regfio.c
@@ -22,6 +22,7 @@
#include "regfio.h"
#include "../librpc/gen_ndr/ndr_security.h"
#include "../libcli/security/security_descriptor.h"
+#include "../libcli/security/secdesc.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_REGISTRY
@@ -497,7 +498,7 @@ static REGF_HBIN* read_hbin_block( REGF_FILE *file, off_t offset )
REGF_HBIN *hbin;
uint32 record_size, curr_off, block_size, header;
- if ( !(hbin = TALLOC_ZERO_P(file->mem_ctx, REGF_HBIN)) )
+ if ( !(hbin = talloc_zero(file->mem_ctx, REGF_HBIN)) )
return NULL;
hbin->file_off = offset;
hbin->free_off = -1;
@@ -1072,7 +1073,7 @@ static bool hbin_prs_key( REGF_FILE *file, REGF_HBIN *hbin, REGF_NK_REC *nk )
}
}
- if ( !(nk->sec_desc = TALLOC_ZERO_P( file->mem_ctx, REGF_SK_REC )) )
+ if ( !(nk->sec_desc = talloc_zero( file->mem_ctx, REGF_SK_REC )) )
return False;
nk->sec_desc->sk_off = nk->sk_off;
if ( !hbin_prs_sk_rec( "sk_rec", sub_hbin, depth, nk->sec_desc ))
@@ -1378,7 +1379,7 @@ REGF_NK_REC* regfio_rootkey( REGF_FILE *file )
if ( !file )
return NULL;
- if ( !(nk = TALLOC_ZERO_P( file->mem_ctx, REGF_NK_REC )) ) {
+ if ( !(nk = talloc_zero( file->mem_ctx, REGF_NK_REC )) ) {
DEBUG(0,("regfio_rootkey: talloc() failed!\n"));
return NULL;
}
@@ -1446,7 +1447,7 @@ REGF_NK_REC* regfio_rootkey( REGF_FILE *file )
return NULL;
nk->subkey_index++;
- if ( !(subkey = TALLOC_ZERO_P( file->mem_ctx, REGF_NK_REC )) )
+ if ( !(subkey = talloc_zero( file->mem_ctx, REGF_NK_REC )) )
return NULL;
if ( !hbin_prs_key( file, hbin, subkey ) )
@@ -1464,7 +1465,7 @@ static REGF_HBIN* regf_hbin_allocate( REGF_FILE *file, uint32 block_size )
REGF_HBIN *hbin;
SMB_STRUCT_STAT sbuf;
- if ( !(hbin = TALLOC_ZERO_P( file->mem_ctx, REGF_HBIN )) )
+ if ( !(hbin = talloc_zero( file->mem_ctx, REGF_HBIN )) )
return NULL;
memcpy( hbin->header, "hbin", sizeof(HBIN_HDR_SIZE) );
@@ -1719,7 +1720,7 @@ static bool create_vk_record(REGF_FILE *file, REGF_VK_REC *vk,
if ( vk->data_size > sizeof(uint32) ) {
uint32 data_size = ( (vk->data_size+sizeof(uint32)) & 0xfffffff8 ) + 8;
- vk->data = (uint8 *)TALLOC_MEMDUP( file->mem_ctx,
+ vk->data = (uint8 *)talloc_memdup( file->mem_ctx,
regval_data_p(value),
vk->data_size );
if (vk->data == NULL) {
@@ -1750,7 +1751,7 @@ static bool create_vk_record(REGF_FILE *file, REGF_VK_REC *vk,
static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
{
- return StrCaseCmp( h1->fullname, h2->fullname );
+ return strcasecmp_m( h1->fullname, h2->fullname );
}
/*******************************************************************
@@ -1764,7 +1765,7 @@ static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
REGF_HBIN *vlist_hbin = NULL;
uint32 size;
- if ( !(nk = TALLOC_ZERO_P( file->mem_ctx, REGF_NK_REC )) )
+ if ( !(nk = talloc_zero( file->mem_ctx, REGF_NK_REC )) )
return NULL;
memcpy( nk->header, "nk", REC_HDR_SIZE );
@@ -1830,7 +1831,7 @@ static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
return NULL;
}
- if ( !(nk->sec_desc = TALLOC_ZERO_P( file->mem_ctx, REGF_SK_REC )) )
+ if ( !(nk->sec_desc = talloc_zero( file->mem_ctx, REGF_SK_REC )) )
return NULL;
/* now we have to store the security descriptor in the list and
@@ -1897,7 +1898,7 @@ static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
nk->subkeys.num_keys = nk->num_subkeys;
if (nk->subkeys.num_keys) {
- if ( !(nk->subkeys.hashes = TALLOC_ZERO_ARRAY( file->mem_ctx, REGF_HASH_REC, nk->subkeys.num_keys )) )
+ if ( !(nk->subkeys.hashes = talloc_zero_array( file->mem_ctx, REGF_HASH_REC, nk->subkeys.num_keys )) )
return NULL;
} else {
nk->subkeys.hashes = NULL;
@@ -1925,7 +1926,7 @@ static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
nk->values_off = prs_offset( &vlist_hbin->ps ) + vlist_hbin->first_hbin_off - HBIN_HDR_SIZE;
if (nk->num_values) {
- if ( !(nk->values = TALLOC_ARRAY( file->mem_ctx, REGF_VK_REC, nk->num_values )) )
+ if ( !(nk->values = talloc_array( file->mem_ctx, REGF_VK_REC, nk->num_values )) )
return NULL;
} else {
nk->values = NULL;
diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index e5995711819..66192bdf54f 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -187,7 +187,7 @@ static NTSTATUS dcerpc_lsa_lookup_sids_noalloc(struct dcerpc_binding_handle *h,
ZERO_STRUCT(lsa_names);
sid_array.num_sids = num_sids;
- sid_array.sids = TALLOC_ARRAY(mem_ctx, struct lsa_SidPtr, num_sids);
+ sid_array.sids = talloc_array(mem_ctx, struct lsa_SidPtr, num_sids);
if (sid_array.sids == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -354,19 +354,19 @@ static NTSTATUS dcerpc_lsa_lookup_sids_generic(struct dcerpc_binding_handle *h,
bool have_unmapped = false;
if (num_sids) {
- if (!(domains = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
+ if (!(domains = talloc_array(mem_ctx, char *, num_sids))) {
DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
status = NT_STATUS_NO_MEMORY;
goto fail;
}
- if (!(names = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
+ if (!(names = talloc_array(mem_ctx, char *, num_sids))) {
DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
status = NT_STATUS_NO_MEMORY;
goto fail;
}
- if (!(types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_sids))) {
+ if (!(types = talloc_array(mem_ctx, enum lsa_SidType, num_sids))) {
DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
status = NT_STATUS_NO_MEMORY;
goto fail;
@@ -589,7 +589,7 @@ static NTSTATUS dcerpc_lsa_lookup_names_generic(struct dcerpc_binding_handle *h,
ZERO_STRUCT(sid_array);
ZERO_STRUCT(sid_array3);
- lsa_names = TALLOC_ARRAY(mem_ctx, struct lsa_String, num_names);
+ lsa_names = talloc_array(mem_ctx, struct lsa_String, num_names);
if (lsa_names == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -639,20 +639,20 @@ static NTSTATUS dcerpc_lsa_lookup_names_generic(struct dcerpc_binding_handle *h,
}
if (num_names) {
- if (!((*sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, num_names)))) {
+ if (!((*sids = talloc_array(mem_ctx, struct dom_sid, num_names)))) {
DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
*presult = NT_STATUS_NO_MEMORY;
goto done;
}
- if (!((*types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_names)))) {
+ if (!((*types = talloc_array(mem_ctx, enum lsa_SidType, num_names)))) {
DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
*presult = NT_STATUS_NO_MEMORY;
goto done;
}
if (dom_names != NULL) {
- *dom_names = TALLOC_ARRAY(mem_ctx, const char *, num_names);
+ *dom_names = talloc_array(mem_ctx, const char *, num_names);
if (*dom_names == NULL) {
DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
*presult = NT_STATUS_NO_MEMORY;
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c
index bd3232d2cde..3c685fd9a7f 100644
--- a/source3/rpc_client/cli_netlogon.c
+++ b/source3/rpc_client/cli_netlogon.c
@@ -177,7 +177,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli,
ZERO_STRUCT(ret_creds);
- logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel);
+ logon = talloc_zero(mem_ctx, union netr_LogonLevel);
if (!logon) {
return NT_STATUS_NO_MEMORY;
}
@@ -185,7 +185,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli,
if (workstation) {
fstr_sprintf( clnt_name_slash, "\\\\%s", workstation );
} else {
- fstr_sprintf( clnt_name_slash, "\\\\%s", global_myname() );
+ fstr_sprintf( clnt_name_slash, "\\\\%s", lp_netbios_name() );
}
/* Initialise input parameters */
@@ -200,7 +200,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli,
struct samr_Password lmpassword;
struct samr_Password ntpassword;
- password_info = TALLOC_ZERO_P(mem_ctx, struct netr_PasswordInfo);
+ password_info = talloc_zero(mem_ctx, struct netr_PasswordInfo);
if (!password_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -240,7 +240,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli,
ZERO_STRUCT(lm);
ZERO_STRUCT(nt);
- network_info = TALLOC_ZERO_P(mem_ctx, struct netr_NetworkInfo);
+ network_info = talloc_zero(mem_ctx, struct netr_NetworkInfo);
if (!network_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -279,7 +279,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli,
status = dcerpc_netr_LogonSamLogon(b, mem_ctx,
cli->srv_name_slash,
- global_myname(),
+ lp_netbios_name(),
&clnt_creds,
&ret_creds,
logon_type,
@@ -388,12 +388,12 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli,
ZERO_STRUCT(lm);
ZERO_STRUCT(nt);
- logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel);
+ logon = talloc_zero(mem_ctx, union netr_LogonLevel);
if (!logon) {
return NT_STATUS_NO_MEMORY;
}
- network_info = TALLOC_ZERO_P(mem_ctx, struct netr_NetworkInfo);
+ network_info = talloc_zero(mem_ctx, struct netr_NetworkInfo);
if (!network_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -441,7 +441,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli,
status = dcerpc_netr_LogonSamLogon(b, mem_ctx,
server_name_slash,
- global_myname(),
+ lp_netbios_name(),
&clnt_creds,
&ret_creds,
NetlogonNetworkInformation,
@@ -505,12 +505,12 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli,
ZERO_STRUCT(lm);
ZERO_STRUCT(nt);
- logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel);
+ logon = talloc_zero(mem_ctx, union netr_LogonLevel);
if (!logon) {
return NT_STATUS_NO_MEMORY;
}
- network_info = TALLOC_ZERO_P(mem_ctx, struct netr_NetworkInfo);
+ network_info = talloc_zero(mem_ctx, struct netr_NetworkInfo);
if (!network_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -556,7 +556,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli,
status = dcerpc_netr_LogonSamLogonEx(b, mem_ctx,
server_name_slash,
- global_myname(),
+ lp_netbios_name(),
NetlogonNetworkInformation,
logon,
validation_level,
@@ -608,7 +608,7 @@ NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli,
result = rpccli_netlogon_setup_creds(cli,
cli->desthost, /* server name */
lp_workgroup(), /* domain */
- global_myname(), /* client name */
+ lp_netbios_name(), /* client name */
account_name, /* machine account name */
orig_trust_passwd_hash,
sec_channel_type,
diff --git a/source3/rpc_client/cli_netlogon.h b/source3/rpc_client/cli_netlogon.h
index 808a4283ce7..ad59d5b2039 100644
--- a/source3/rpc_client/cli_netlogon.h
+++ b/source3/rpc_client/cli_netlogon.h
@@ -1,3 +1,28 @@
+/*
+ Unix SMB/CIFS implementation.
+ NT Domain Authentication SMB / MSRPC client
+ Copyright (C) Andrew Tridgell 1992-2000
+ Copyright (C) Jeremy Allison 1998.
+ Largely re-written by Jeremy Allison (C) 2005.
+ Copyright (C) Guenther Deschner 2008.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _RPC_CLIENT_CLI_NETLOGON_H_
+#define _RPC_CLIENT_CLI_NETLOGON_H_
+
/* The following definitions come from rpc_client/cli_netlogon.c */
NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
@@ -49,3 +74,4 @@ NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli,
const unsigned char new_trust_passwd_hash[16],
enum netr_SchannelType sec_channel_type);
+#endif /* _RPC_CLIENT_CLI_NETLOGON_H_ */
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index d7f990af2c9..0b9470620d9 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -19,12 +19,12 @@
*/
#include "includes.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "librpc/gen_ndr/ndr_epmapper_c.h"
#include "../librpc/gen_ndr/ndr_schannel.h"
#include "../librpc/gen_ndr/ndr_dssetup.h"
#include "../libcli/auth/schannel.h"
#include "../libcli/auth/spnego.h"
-#include "smb_krb5.h"
#include "../libcli/auth/ntlmssp.h"
#include "ntlmssp_wrap.h"
#include "librpc/gen_ndr/ndr_dcerpc.h"
@@ -33,7 +33,7 @@
#include "librpc/crypto/spnego.h"
#include "rpc_dce.h"
#include "cli_pipe.h"
-#include "ntdomain.h"
+#include "client.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_CLI
@@ -469,11 +469,7 @@ static NTSTATUS cli_pipe_validate_current_pdu(TALLOC_CTX *mem_ctx,
pkt->u.fault.status),
rpccli_pipe_txt(talloc_tos(), cli)));
- if (NT_STATUS_IS_OK(NT_STATUS(pkt->u.fault.status))) {
- return NT_STATUS_UNSUCCESSFUL;
- } else {
- return NT_STATUS(pkt->u.fault.status);
- }
+ return dcerpc_fault_to_nt_status(pkt->u.fault.status);
default:
DEBUG(0, (__location__ "Unknown packet type %u received "
@@ -610,7 +606,7 @@ static void cli_api_pipe_write_done(struct tevent_req *subreq)
return;
}
- state->rdata = TALLOC_ARRAY(state, uint8_t, RPC_HEADER_LEN);
+ state->rdata = talloc_array(state, uint8_t, RPC_HEADER_LEN);
if (tevent_req_nomem(state->rdata, req)) {
return;
}
@@ -1091,7 +1087,7 @@ static NTSTATUS create_schannel_auth_rpc_bind_req(struct rpc_pipe_client *cli,
r.Flags = NL_FLAG_OEM_NETBIOS_DOMAIN_NAME |
NL_FLAG_OEM_NETBIOS_COMPUTER_NAME;
r.oem_netbios_domain.a = cli->auth->domain;
- r.oem_netbios_computer.a = global_myname();
+ r.oem_netbios_computer.a = lp_netbios_name();
status = dcerpc_push_schannel_bind(cli, &r, auth_token);
if (!NT_STATUS_IS_OK(status)) {
@@ -2334,7 +2330,7 @@ static NTSTATUS rpccli_ntlmssp_bind_data(TALLOC_CTX *mem_ctx,
}
status = auth_ntlmssp_client_start(NULL,
- global_myname(),
+ lp_netbios_name(),
lp_workgroup(),
lp_client_ntlmv2_auth(),
&ntlmssp_ctx);
@@ -2435,7 +2431,7 @@ static NTSTATUS rpc_pipe_open_tcp_port(TALLOC_CTX *mem_ctx, const char *host,
NTSTATUS status;
int fd;
- result = TALLOC_ZERO_P(mem_ctx, struct rpc_pipe_client);
+ result = talloc_zero(mem_ctx, struct rpc_pipe_client);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -2544,7 +2540,7 @@ static NTSTATUS rpc_pipe_get_tcp_port(const char *host,
/* create tower for asking the epmapper */
- map_binding = TALLOC_ZERO_P(tmp_ctx, struct dcerpc_binding);
+ map_binding = talloc_zero(tmp_ctx, struct dcerpc_binding);
if (map_binding == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -2555,7 +2551,7 @@ static NTSTATUS rpc_pipe_get_tcp_port(const char *host,
map_binding->host = host; /* needed? */
map_binding->endpoint = "0"; /* correct? needed? */
- map_tower = TALLOC_ZERO_P(tmp_ctx, struct epm_twr_t);
+ map_tower = talloc_zero(tmp_ctx, struct epm_twr_t);
if (map_tower == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -2569,14 +2565,14 @@ static NTSTATUS rpc_pipe_get_tcp_port(const char *host,
/* allocate further parameters for the epm_Map call */
- res_towers = TALLOC_ARRAY(tmp_ctx, struct epm_twr_t, max_towers);
+ res_towers = talloc_array(tmp_ctx, struct epm_twr_t, max_towers);
if (res_towers == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
towers.twr = res_towers;
- entry_handle = TALLOC_ZERO_P(tmp_ctx, struct policy_handle);
+ entry_handle = talloc_zero(tmp_ctx, struct policy_handle);
if (entry_handle == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -2586,7 +2582,7 @@ static NTSTATUS rpc_pipe_get_tcp_port(const char *host,
status = dcerpc_epm_Map(epm_handle,
tmp_ctx,
- CONST_DISCARD(struct GUID *,
+ discard_const_p(struct GUID,
&(abstract_syntax->uuid)),
map_tower,
entry_handle,
@@ -2760,7 +2756,7 @@ static NTSTATUS rpc_pipe_open_np(struct cli_state *cli,
return NT_STATUS_INVALID_HANDLE;
}
- result = TALLOC_ZERO_P(NULL, struct rpc_pipe_client);
+ result = talloc_zero(NULL, struct rpc_pipe_client);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/rpc_client/cli_pipe_schannel.c b/source3/rpc_client/cli_pipe_schannel.c
index 0535e930be7..f48c4c7318f 100644
--- a/source3/rpc_client/cli_pipe_schannel.c
+++ b/source3/rpc_client/cli_pipe_schannel.c
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/ndr_dcerpc.h"
#include "librpc/rpc/dcerpc.h"
#include "passdb.h"
+#include "client.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_CLI
@@ -57,7 +58,7 @@ static NTSTATUS get_schannel_session_key_common(struct rpc_pipe_client *netlogon
status = rpccli_netlogon_setup_creds(netlogon_pipe,
cli->desthost, /* server name */
domain, /* domain */
- global_myname(), /* client name */
+ lp_netbios_name(), /* client name */
machine_account, /* machine account name */
machine_pwd,
sec_chan_type,
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 831da85205f..5c8448b29b6 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -26,7 +26,6 @@
#include "rpc_client/rpc_client.h"
#include "../librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_client/cli_spoolss.h"
-#include "ntdomain.h"
/**********************************************************************
convencience wrapper around rpccli_spoolss_OpenPrinterEx
@@ -48,7 +47,7 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
ZERO_STRUCT(devmode_ctr);
level1.size = 28;
- level1.client = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
+ level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
W_ERROR_HAVE_NO_MEMORY(level1.client);
level1.user = cli->auth->user_name;
level1.build = 1381;
@@ -231,7 +230,7 @@ WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli,
level1.major = 2;
level1.minor = 0;
level1.processor = 0;
- level1.client = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
+ level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
W_ERROR_HAVE_NO_MEMORY(level1.client);
level1.user = cli->auth->user_name;
diff --git a/source3/rpc_client/cli_spoolss.h b/source3/rpc_client/cli_spoolss.h
index 285a34fab40..9883874cd68 100644
--- a/source3/rpc_client/cli_spoolss.h
+++ b/source3/rpc_client/cli_spoolss.h
@@ -1,3 +1,30 @@
+/*
+ Unix SMB/CIFS implementation.
+ RPC pipe client
+
+ Copyright (C) Gerald Carter 2001-2005,
+ Copyright (C) Tim Potter 2000-2002,
+ Copyright (C) Andrew Tridgell 1994-2000,
+ Copyright (C) Jean-Francois Micouleau 1999-2000.
+ Copyright (C) Jeremy Allison 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/>.
+*/
+
+#ifndef _RPC_CLIENT_CLI_SPOOLSS_H_
+#define _RPC_CLIENT_CLI_SPOOLSS_H_
+
/* The following definitions come from rpc_client/cli_spoolss.c */
WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
@@ -122,3 +149,5 @@ WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli,
uint32_t offered,
uint32_t *count,
struct spoolss_PrinterEnumValues **info);
+
+#endif /* _RPC_CLIENT_CLI_SPOOLSS_H_ */
diff --git a/source3/rpc_client/cli_winreg.c b/source3/rpc_client/cli_winreg.c
index 2517dbc50ab..e5ebc25ed80 100644
--- a/source3/rpc_client/cli_winreg.c
+++ b/source3/rpc_client/cli_winreg.c
@@ -33,7 +33,7 @@ NTSTATUS dcerpc_winreg_query_dword(TALLOC_CTX *mem_ctx,
WERROR *pwerr)
{
struct winreg_String wvalue;
- enum winreg_Type type;
+ enum winreg_Type type = REG_NONE;
uint32_t value_len = 0;
uint32_t data_size = 0;
WERROR result = WERR_OK;
@@ -69,7 +69,7 @@ NTSTATUS dcerpc_winreg_query_dword(TALLOC_CTX *mem_ctx,
return status;
}
- blob = data_blob_talloc(mem_ctx, NULL, data_size);
+ blob = data_blob_talloc_zero(mem_ctx, data_size);
if (blob.data == NULL) {
*pwerr = WERR_NOMEM;
return status;
@@ -108,13 +108,14 @@ NTSTATUS dcerpc_winreg_query_binary(TALLOC_CTX *mem_ctx,
WERROR *pwerr)
{
struct winreg_String wvalue;
- enum winreg_Type type;
+ enum winreg_Type type = REG_NONE;
WERROR result = WERR_OK;
uint32_t value_len = 0;
uint32_t data_size = 0;
NTSTATUS status;
DATA_BLOB blob;
+ ZERO_STRUCT(wvalue);
wvalue.name = value;
status = dcerpc_winreg_QueryValue(h,
@@ -139,7 +140,7 @@ NTSTATUS dcerpc_winreg_query_binary(TALLOC_CTX *mem_ctx,
return status;
}
- blob = data_blob_talloc(mem_ctx, NULL, data_size);
+ blob = data_blob_talloc_zero(mem_ctx, data_size);
if (blob.data == NULL) {
*pwerr = WERR_NOMEM;
return status;
@@ -179,7 +180,7 @@ NTSTATUS dcerpc_winreg_query_multi_sz(TALLOC_CTX *mem_ctx,
WERROR *pwerr)
{
struct winreg_String wvalue;
- enum winreg_Type type;
+ enum winreg_Type type = REG_NONE;
WERROR result = WERR_OK;
uint32_t value_len = 0;
uint32_t data_size = 0;
@@ -210,7 +211,7 @@ NTSTATUS dcerpc_winreg_query_multi_sz(TALLOC_CTX *mem_ctx,
return status;
}
- blob = data_blob_talloc(mem_ctx, NULL, data_size);
+ blob = data_blob_talloc_zero(mem_ctx, data_size);
if (blob.data == NULL) {
*pwerr = WERR_NOMEM;
return status;
@@ -254,7 +255,7 @@ NTSTATUS dcerpc_winreg_query_sz(TALLOC_CTX *mem_ctx,
WERROR *pwerr)
{
struct winreg_String wvalue;
- enum winreg_Type type;
+ enum winreg_Type type = REG_NONE;
WERROR result = WERR_OK;
uint32_t value_len = 0;
uint32_t data_size = 0;
@@ -285,7 +286,7 @@ NTSTATUS dcerpc_winreg_query_sz(TALLOC_CTX *mem_ctx,
return status;
}
- blob = data_blob_talloc(mem_ctx, NULL, data_size);
+ blob = data_blob_talloc_zero(mem_ctx, data_size);
if (blob.data == NULL) {
*pwerr = WERR_NOMEM;
return status;
@@ -380,13 +381,14 @@ NTSTATUS dcerpc_winreg_set_dword(TALLOC_CTX *mem_ctx,
uint32_t data,
WERROR *pwerr)
{
- struct winreg_String wvalue = { 0, };
+ struct winreg_String wvalue;
DATA_BLOB blob;
WERROR result = WERR_OK;
NTSTATUS status;
+ ZERO_STRUCT(wvalue);
wvalue.name = value;
- blob = data_blob_talloc(mem_ctx, NULL, 4);
+ blob = data_blob_talloc_zero(mem_ctx, 4);
SIVAL(blob.data, 0, data);
status = dcerpc_winreg_SetValue(h,
@@ -615,7 +617,7 @@ NTSTATUS dcerpc_winreg_add_multi_sz(TALLOC_CTX *mem_ctx,
/* count the elements */
for (p = a, i = 0; p && *p; p++, i++);
- p = TALLOC_REALLOC_ARRAY(mem_ctx, a, const char *, i + 2);
+ p = talloc_realloc(mem_ctx, a, const char *, i + 2);
if (p == NULL) {
*pwerr = WERR_NOMEM;
return NT_STATUS_OK;
diff --git a/source3/rpc_client/cli_winreg_int.c b/source3/rpc_client/cli_winreg_int.c
index 8e11ae832d6..1828b419a95 100644
--- a/source3/rpc_client/cli_winreg_int.c
+++ b/source3/rpc_client/cli_winreg_int.c
@@ -21,7 +21,6 @@
#include "includes.h"
#include "include/registry.h"
-#include "utils/net_registry_util.h"
#include "librpc/gen_ndr/ndr_winreg_c.h"
#include "rpc_client/cli_winreg_int.h"
#include "rpc_server/rpc_ncacn_np.h"
diff --git a/source3/rpc_client/cli_winreg_int.h b/source3/rpc_client/cli_winreg_int.h
index f175c17f5c9..6e9d07f95cc 100644
--- a/source3/rpc_client/cli_winreg_int.h
+++ b/source3/rpc_client/cli_winreg_int.h
@@ -23,6 +23,7 @@
#define CLI_WINREG_INT_H
struct auth_serversupplied_info;
+struct dcerpc_binding_handle;
/**
* @brief Connect to the interal winreg server and open the given key.
diff --git a/source3/rpc_client/init_lsa.h b/source3/rpc_client/init_lsa.h
index 670caed2128..e4e5c119636 100644
--- a/source3/rpc_client/init_lsa.h
+++ b/source3/rpc_client/init_lsa.h
@@ -1,3 +1,25 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Guenther Deschner 2008.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _RPC_CLIENT_INIT_LSA_H_
+#define _RPC_CLIENT_INIT_LSA_H_
+
struct lsa_String;
struct lsa_StringLarge;
struct lsa_AsciiString;
@@ -9,3 +31,5 @@ void init_lsa_String(struct lsa_String *name, const char *s);
void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s);
void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s);
void init_lsa_AsciiStringLarge(struct lsa_AsciiStringLarge *name, const char *s);
+
+#endif /* _RPC_CLIENT_INIT_LSA_H_ */
diff --git a/source3/rpc_client/init_netlogon.h b/source3/rpc_client/init_netlogon.h
index d87a9ea493a..826d0c56bb4 100644
--- a/source3/rpc_client/init_netlogon.h
+++ b/source3/rpc_client/init_netlogon.h
@@ -1,5 +1,29 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Guenther Deschner 2008.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _RPC_CLIENT_INIT_NETLOGON_H_
+#define _RPC_CLIENT_INIT_NETLOGON_H_
+
/* The following definitions come from rpc_client/init_netlogon.c */
void init_netr_CryptPassword(const char *pwd,
unsigned char session_key[16],
struct netr_CryptPassword *pwd_buf);
+
+#endif /* _RPC_CLIENT_INIT_NETLOGON_H_ */
diff --git a/source3/rpc_client/init_samr.h b/source3/rpc_client/init_samr.h
index 1ddaef66153..223fa91e3d9 100644
--- a/source3/rpc_client/init_samr.h
+++ b/source3/rpc_client/init_samr.h
@@ -1,3 +1,25 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Guenther Deschner 2008.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _RPC_CLIENT_INIT_SAMR_H_
+#define _RPC_CLIENT_INIT_SAMR_H_
+
/* The following definitions come from rpc_client/init_samr.c */
void init_samr_CryptPasswordEx(const char *pwd,
@@ -7,3 +29,4 @@ void init_samr_CryptPassword(const char *pwd,
DATA_BLOB *session_key,
struct samr_CryptPassword *pwd_buf);
+#endif /* _RPC_CLIENT_INIT_SAMR_H_ */
diff --git a/source3/rpc_client/init_spoolss.h b/source3/rpc_client/init_spoolss.h
index 60ee041ae59..a9374453e11 100644
--- a/source3/rpc_client/init_spoolss.h
+++ b/source3/rpc_client/init_spoolss.h
@@ -1,3 +1,24 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Guenther Deschner 2009.
+ *
+ * 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 _RPC_CLIENT_INIT_SPOOLSS_H_
+#define _RPC_CLIENT_INIT_SPOOLSS_H_
/* The following definitions come from rpc_client/init_spoolss.c */
@@ -14,3 +35,4 @@ WERROR push_spoolss_PrinterData(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
void spoolss_printerinfo2_to_setprinterinfo2(const struct spoolss_PrinterInfo2 *i,
struct spoolss_SetPrinterInfo2 *s);
+#endif /* _RPC_CLIENT_INIT_SPOOLSS_H_ */
diff --git a/source3/rpc_client/rpc_transport_np.c b/source3/rpc_client/rpc_transport_np.c
index 2be01621448..c66d4b80227 100644
--- a/source3/rpc_client/rpc_transport_np.c
+++ b/source3/rpc_client/rpc_transport_np.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "rpc_client/rpc_transport.h"
#include "libsmb/cli_np_tstream.h"
diff --git a/source3/rpc_client/rpc_transport_sock.c b/source3/rpc_client/rpc_transport_sock.c
index 71f979c2af9..a833e4469a3 100644
--- a/source3/rpc_client/rpc_transport_sock.c
+++ b/source3/rpc_client/rpc_transport_sock.c
@@ -18,8 +18,8 @@
*/
#include "includes.h"
+#include "../lib/tsocket/tsocket.h"
#include "rpc_client/rpc_transport.h"
-#include "../lib/async_req/async_sock.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_CLI
diff --git a/source3/rpc_client/rpc_transport_tstream.c b/source3/rpc_client/rpc_transport_tstream.c
index 248b09f0491..488c093d3b7 100644
--- a/source3/rpc_client/rpc_transport_tstream.c
+++ b/source3/rpc_client/rpc_transport_tstream.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "rpc_client/rpc_transport.h"
#include "lib/tsocket/tsocket.h"
#include "libsmb/cli_np_tstream.h"
@@ -201,7 +202,7 @@ static struct tevent_req *rpc_tstream_read_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- endtime = timeval_current_ofs(0, transp->timeout * 1000);
+ endtime = timeval_current_ofs_msec(transp->timeout);
if (!tevent_req_set_endtime(subreq, ev, endtime)) {
goto fail;
}
@@ -285,7 +286,7 @@ static struct tevent_req *rpc_tstream_write_send(TALLOC_CTX *mem_ctx,
goto fail;
}
- endtime = timeval_current_ofs(0, transp->timeout * 1000);
+ endtime = timeval_current_ofs_msec(transp->timeout);
if (!tevent_req_set_endtime(subreq, ev, endtime)) {
goto fail;
}
@@ -373,7 +374,7 @@ static struct tevent_req *rpc_tstream_trans_send(TALLOC_CTX *mem_ctx,
state->req.iov_base = discard_const_p(void *, data);
state->max_rdata_len = max_rdata_len;
- endtime = timeval_current_ofs(0, transp->timeout * 1000);
+ endtime = timeval_current_ofs_msec(transp->timeout);
subreq = tstream_writev_queue_send(state, ev,
transp->stream,
diff --git a/source3/rpc_client/util_netlogon.h b/source3/rpc_client/util_netlogon.h
index 42e4326f7dc..cea9787acb6 100644
--- a/source3/rpc_client/util_netlogon.h
+++ b/source3/rpc_client/util_netlogon.h
@@ -1,5 +1,29 @@
+/*
+ Unix SMB/CIFS implementation.
+ Authentication utility functions
+ Copyright (C) Volker Lendecke 2010
+
+ 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 _RPC_CLIENT_UTIL_NETLOGON_H_
+#define _RPC_CLIENT_UTIL_NETLOGON_H_
+
/* The following definitions come from rpc_client/util_netlogon.c */
NTSTATUS copy_netr_SamBaseInfo(TALLOC_CTX *mem_ctx,
const struct netr_SamBaseInfo *in,
struct netr_SamBaseInfo *out);
+
+#endif /* _RPC_CLIENT_UTIL_NETLOGON_H_ */
diff --git a/source3/rpc_server/dcesrv_gssapi.c b/source3/rpc_server/dcesrv_gssapi.c
index ec024596332..534e8a41896 100644
--- a/source3/rpc_server/dcesrv_gssapi.c
+++ b/source3/rpc_server/dcesrv_gssapi.c
@@ -23,7 +23,9 @@
#include "../librpc/gen_ndr/ndr_krb5pac.h"
#include "librpc/crypto/gse.h"
#include "auth.h"
-
+#ifdef HAVE_KRB5
+#include "libcli/auth/krb5_wrap.h"
+#endif
NTSTATUS gssapi_server_auth_start(TALLOC_CTX *mem_ctx,
bool do_sign,
bool do_seal,
@@ -105,14 +107,9 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
struct auth_serversupplied_info **server_info)
{
TALLOC_CTX *tmp_ctx;
- DATA_BLOB auth_data;
- time_t tgs_authtime;
- NTTIME tgs_authtime_nttime;
- DATA_BLOB pac;
- struct PAC_DATA *pac_data;
- struct PAC_LOGON_NAME *logon_name = NULL;
+ DATA_BLOB pac_blob;
+ struct PAC_DATA *pac_data = NULL;
struct PAC_LOGON_INFO *logon_info = NULL;
- enum ndr_err_code ndr_err;
unsigned int i;
bool is_mapped;
bool is_guest;
@@ -122,14 +119,13 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
char *username;
struct passwd *pw;
NTSTATUS status;
- bool bret;
tmp_ctx = talloc_new(mem_ctx);
if (!tmp_ctx) {
return NT_STATUS_NO_MEMORY;
}
- status = gse_get_authz_data(gse_ctx, tmp_ctx, &auth_data);
+ status = gse_get_pac_blob(gse_ctx, tmp_ctx, &pac_blob);
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
/* TODO: Fetch user by principal name ? */
status = NT_STATUS_ACCESS_DENIED;
@@ -139,37 +135,22 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
goto done;
}
- bret = unwrap_pac(tmp_ctx, &auth_data, &pac);
- if (!bret) {
- DEBUG(1, ("Failed to unwrap PAC\n"));
- status = NT_STATUS_ACCESS_DENIED;
- goto done;
- }
-
- status = gse_get_client_name(gse_ctx, tmp_ctx, &princ_name);
+#ifdef HAVE_KRB5
+ status = kerberos_decode_pac(tmp_ctx,
+ pac_blob,
+ NULL, NULL, NULL, NULL, 0, &pac_data);
+#else
+ status = NT_STATUS_ACCESS_DENIED;
+#endif
+ data_blob_free(&pac_blob);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- status = gse_get_authtime(gse_ctx, &tgs_authtime);
+ status = gse_get_client_name(gse_ctx, tmp_ctx, &princ_name);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- unix_to_nt_time(&tgs_authtime_nttime, tgs_authtime);
-
- pac_data = talloc_zero(tmp_ctx, struct PAC_DATA);
- if (!pac_data) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- ndr_err = ndr_pull_struct_blob(&pac, pac_data, pac_data,
- (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(1, ("Failed to parse the PAC for %s\n", princ_name));
- status = ndr_map_error2ntstatus(ndr_err);
- goto done;
- }
/* get logon name and logon info */
for (i = 0; i < pac_data->num_buffers; i++) {
@@ -182,9 +163,6 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
}
logon_info = data_buf->info->logon_info.info;
break;
- case PAC_TYPE_LOGON_NAME:
- logon_name = &data_buf->info->logon_name;
- break;
default:
break;
}
@@ -194,25 +172,6 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
status = NT_STATUS_NOT_FOUND;
goto done;
}
- if (!logon_name) {
- DEBUG(1, ("Invalid PAC data, missing logon info!\n"));
- status = NT_STATUS_NOT_FOUND;
- goto done;
- }
-
- /* check time */
- if (tgs_authtime_nttime != logon_name->logon_time) {
- DEBUG(1, ("Logon time mismatch between ticket and PAC!\n"
- "PAC Time = %s | Ticket Time = %s\n",
- nt_time_string(tmp_ctx, logon_name->logon_time),
- nt_time_string(tmp_ctx, tgs_authtime_nttime)));
- status = NT_STATUS_ACCESS_DENIED;
- goto done;
- }
-
- /* TODO: Should we check princ_name against account_name in
- * logon_name ? Are they supposed to be identical, or can an
- * account_name be different from the UPN ? */
status = get_user_from_kerberos_info(tmp_ctx, client_id->name,
princ_name, logon_info,
diff --git a/source3/rpc_server/dfs/srv_dfs_nt.c b/source3/rpc_server/dfs/srv_dfs_nt.c
index 45e9d9a6ff3..5b4e423393c 100644
--- a/source3/rpc_server/dfs/srv_dfs_nt.c
+++ b/source3/rpc_server/dfs/srv_dfs_nt.c
@@ -22,11 +22,12 @@
/* This is the implementation of the dfs pipe. */
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_dfs.h"
#include "msdfs.h"
#include "smbd/smbd.h"
+#include "smbd/globals.h"
#include "auth.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_MSDFS
@@ -58,7 +59,7 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
return WERR_ACCESS_DENIED;
}
- jn = TALLOC_ZERO_P(ctx, struct junction_map);
+ jn = talloc_zero(ctx, struct junction_map);
if (!jn) {
return WERR_NOMEM;
}
@@ -87,7 +88,7 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
return WERR_NOMEM;
}
- jn->referral_list = TALLOC_ARRAY(ctx, struct referral, jn->referral_count);
+ jn->referral_list = talloc_array(ctx, struct referral, jn->referral_count);
if(jn->referral_list == NULL) {
DEBUG(0,("init_reply_dfs_add: talloc failed for referral list!\n"));
return WERR_DFS_INTERNAL_ERROR;
@@ -123,7 +124,7 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
return WERR_ACCESS_DENIED;
}
- jn = TALLOC_ZERO_P(ctx, struct junction_map);
+ jn = talloc_zero(ctx, struct junction_map);
if (!jn) {
return WERR_NOMEM;
}
@@ -192,7 +193,7 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
static bool init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,struct dfs_Info1* dfs1)
{
dfs1->path = talloc_asprintf(mem_ctx,
- "\\\\%s\\%s\\%s", global_myname(),
+ "\\\\%s\\%s\\%s", lp_netbios_name(),
j->service_name, j->volume_name);
if (dfs1->path == NULL)
return False;
@@ -204,7 +205,7 @@ static bool init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,st
static bool init_reply_dfs_info_2(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info2* dfs2)
{
dfs2->path = talloc_asprintf(mem_ctx,
- "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name);
+ "\\\\%s\\%s\\%s", lp_netbios_name(), j->service_name, j->volume_name);
if (dfs2->path == NULL)
return False;
dfs2->comment = talloc_strdup(mem_ctx, j->comment);
@@ -218,9 +219,9 @@ static bool init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s
int ii;
if (j->volume_name[0] == '\0')
dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
- global_myname(), j->service_name);
+ lp_netbios_name(), j->service_name);
else
- dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(),
+ dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", lp_netbios_name(),
j->service_name, j->volume_name);
if (dfs3->path == NULL)
@@ -232,7 +233,7 @@ static bool init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s
/* also enumerate the stores */
if (j->referral_count) {
- dfs3->stores = TALLOC_ARRAY(mem_ctx, struct dfs_StorageInfo, j->referral_count);
+ dfs3->stores = talloc_array(mem_ctx, struct dfs_StorageInfo, j->referral_count);
if (!dfs3->stores)
return False;
memset(dfs3->stores, '\0', j->referral_count * sizeof(struct dfs_StorageInfo));
@@ -278,7 +279,8 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
size_t i;
TALLOC_CTX *ctx = talloc_tos();
- jn = enum_msdfs_links(ctx, &num_jn);
+ jn = enum_msdfs_links(msg_ctx_to_sconn(p->msg_ctx),
+ ctx, &num_jn);
if (!jn || num_jn == 0) {
num_jn = 0;
jn = NULL;
@@ -293,7 +295,7 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
switch (r->in.level) {
case 1:
if (num_jn) {
- if ((r->out.info->e.info1->s = TALLOC_ARRAY(ctx, struct dfs_Info1, num_jn)) == NULL) {
+ if ((r->out.info->e.info1->s = talloc_array(ctx, struct dfs_Info1, num_jn)) == NULL) {
return WERR_NOMEM;
}
} else {
@@ -303,7 +305,7 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
break;
case 2:
if (num_jn) {
- if ((r->out.info->e.info2->s = TALLOC_ARRAY(ctx, struct dfs_Info2, num_jn)) == NULL) {
+ if ((r->out.info->e.info2->s = talloc_array(ctx, struct dfs_Info2, num_jn)) == NULL) {
return WERR_NOMEM;
}
} else {
@@ -313,7 +315,7 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
break;
case 3:
if (num_jn) {
- if ((r->out.info->e.info3->s = TALLOC_ARRAY(ctx, struct dfs_Info3, num_jn)) == NULL) {
+ if ((r->out.info->e.info3->s = talloc_array(ctx, struct dfs_Info3, num_jn)) == NULL) {
return WERR_NOMEM;
}
} else {
@@ -352,7 +354,7 @@ WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
TALLOC_CTX *ctx = talloc_tos();
bool ret;
- jn = TALLOC_ZERO_P(ctx, struct junction_map);
+ jn = talloc_zero(ctx, struct junction_map);
if (!jn) {
return WERR_NOMEM;
}
@@ -370,28 +372,28 @@ WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
switch (r->in.level) {
case 1:
- r->out.info->info1 = TALLOC_ZERO_P(ctx,struct dfs_Info1);
+ r->out.info->info1 = talloc_zero(ctx,struct dfs_Info1);
if (!r->out.info->info1) {
return WERR_NOMEM;
}
ret = init_reply_dfs_info_1(ctx, jn, r->out.info->info1);
break;
case 2:
- r->out.info->info2 = TALLOC_ZERO_P(ctx,struct dfs_Info2);
+ r->out.info->info2 = talloc_zero(ctx,struct dfs_Info2);
if (!r->out.info->info2) {
return WERR_NOMEM;
}
ret = init_reply_dfs_info_2(ctx, jn, r->out.info->info2);
break;
case 3:
- r->out.info->info3 = TALLOC_ZERO_P(ctx,struct dfs_Info3);
+ r->out.info->info3 = talloc_zero(ctx,struct dfs_Info3);
if (!r->out.info->info3) {
return WERR_NOMEM;
}
ret = init_reply_dfs_info_3(ctx, jn, r->out.info->info3);
break;
case 100:
- r->out.info->info100 = TALLOC_ZERO_P(ctx,struct dfs_Info100);
+ r->out.info->info100 = talloc_zero(ctx,struct dfs_Info100);
if (!r->out.info->info100) {
return WERR_NOMEM;
}
diff --git a/source3/rpc_server/dssetup/srv_dssetup_nt.c b/source3/rpc_server/dssetup/srv_dssetup_nt.c
index 73617df99f1..1cf4ab80746 100644
--- a/source3/rpc_server/dssetup/srv_dssetup_nt.c
+++ b/source3/rpc_server/dssetup/srv_dssetup_nt.c
@@ -23,9 +23,9 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_dssetup.h"
#include "secrets.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -42,7 +42,7 @@ static WERROR fill_dsrole_dominfo_basic(TALLOC_CTX *ctx,
DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));
- basic = TALLOC_ZERO_P(ctx, struct dssetup_DsRolePrimaryDomInfoBasic);
+ basic = talloc_zero(ctx, struct dssetup_DsRolePrimaryDomInfoBasic);
if (!basic) {
DEBUG(0,("fill_dsrole_dominfo_basic: out of memory\n"));
return WERR_NOMEM;
diff --git a/source3/rpc_server/echo/srv_echo_nt.c b/source3/rpc_server/echo/srv_echo_nt.c
index 7f27984b8bd..7c8ae19b82b 100644
--- a/source3/rpc_server/echo/srv_echo_nt.c
+++ b/source3/rpc_server/echo/srv_echo_nt.c
@@ -22,8 +22,8 @@
/* This is the interface to the rpcecho pipe. */
#include "includes.h"
-#include "../librpc/gen_ndr/srv_echo.h"
#include "ntdomain.h"
+#include "../librpc/gen_ndr/srv_echo.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -48,7 +48,7 @@ void _echo_EchoData(struct pipes_struct *p, struct echo_EchoData *r)
return;
}
- r->out.out_data = TALLOC_ARRAY(p->mem_ctx, uint8, r->in.len);
+ r->out.out_data = talloc_array(p->mem_ctx, uint8, r->in.len);
memcpy( r->out.out_data, r->in.in_data, r->in.len );
return;
}
@@ -76,7 +76,7 @@ void _echo_SourceData(struct pipes_struct *p, struct echo_SourceData *r)
return;
}
- r->out.data = TALLOC_ARRAY(p->mem_ctx, uint8, r->in.len );
+ r->out.data = talloc_array(p->mem_ctx, uint8, r->in.len );
for (i = 0; i < r->in.len; i++ ) {
r->out.data[i] = i & 0xff;
diff --git a/source3/rpc_server/epmapper/srv_epmapper.c b/source3/rpc_server/epmapper/srv_epmapper.c
index d96fd1e929f..70f665dadf6 100644
--- a/source3/rpc_server/epmapper/srv_epmapper.c
+++ b/source3/rpc_server/epmapper/srv_epmapper.c
@@ -20,12 +20,11 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../libcli/security/security.h"
-#include "librpc/gen_ndr/ndr_epmapper.h"
#include "librpc/gen_ndr/srv_epmapper.h"
#include "srv_epmapper.h"
#include "auth.h"
-#include "ntdomain.h"
typedef uint32_t error_status_t;
diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c
index 5e82b276fd2..bb241ff2c1f 100644
--- a/source3/rpc_server/epmd.c
+++ b/source3/rpc_server/epmd.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "serverid.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_epmapper.h"
#include "rpc_server/rpc_server.h"
#include "rpc_server/epmapper/srv_epmapper.h"
@@ -53,7 +54,6 @@ static bool epmd_open_sockets(struct tevent_context *ev_ctx,
port = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
msg_ctx,
- ndr_table_epmapper.syntax_id,
ifss,
135);
if (port == 0) {
@@ -68,7 +68,7 @@ static bool epmd_open_sockets(struct tevent_context *ev_ctx,
if (strequal(sock_addr, "0.0.0.0") ||
strequal(sock_addr, "::")) {
#if HAVE_IPV6
- sock_addr = "::";
+ sock_addr = "::,0.0.0.0";
#else
sock_addr = "0.0.0.0";
#endif
@@ -88,7 +88,6 @@ static bool epmd_open_sockets(struct tevent_context *ev_ctx,
port = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
msg_ctx,
- ndr_table_epmapper.syntax_id,
&ss,
135);
if (port == 0) {
@@ -262,7 +261,6 @@ void start_epmd(struct tevent_context *ev_ctx,
ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
msg_ctx,
- ndr_table_epmapper.syntax_id,
"EPMAPPER",
srv_epmapper_delete_endpoints);
if (!ok) {
diff --git a/source3/rpc_server/eventlog/srv_eventlog_nt.c b/source3/rpc_server/eventlog/srv_eventlog_nt.c
index 2e1c1faa8c5..16a0c974881 100644
--- a/source3/rpc_server/eventlog/srv_eventlog_nt.c
+++ b/source3/rpc_server/eventlog/srv_eventlog_nt.c
@@ -21,16 +21,16 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_eventlog.h"
#include "lib/eventlog/eventlog.h"
-#include "registry.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_winreg_c.h"
#include "rpc_client/cli_winreg_int.h"
#include "rpc_client/cli_winreg.h"
#include "smbd/smbd.h"
#include "auth.h"
-#include "ntdomain.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -212,7 +212,7 @@ static NTSTATUS elog_open( struct pipes_struct * p, const char *logname, struct
if ( !elog_validate_logname( logname ) )
return NT_STATUS_OBJECT_PATH_INVALID;
- if ( !(elog = TALLOC_ZERO_P( NULL, EVENTLOG_INFO )) )
+ if ( !(elog = talloc_zero( NULL, EVENTLOG_INFO )) )
return NT_STATUS_NO_MEMORY;
talloc_set_destructor(elog, eventlog_info_destructor);
diff --git a/source3/rpc_server/initshutdown/srv_initshutdown_nt.c b/source3/rpc_server/initshutdown/srv_initshutdown_nt.c
index 8644d95e7d0..9b16d806096 100644
--- a/source3/rpc_server/initshutdown/srv_initshutdown_nt.c
+++ b/source3/rpc_server/initshutdown/srv_initshutdown_nt.c
@@ -21,9 +21,9 @@
/* Implementation of registry functions. */
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_initshutdown.h"
#include "../librpc/gen_ndr/srv_winreg.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
diff --git a/source3/rpc_server/lsa/srv_lsa_nt.c b/source3/rpc_server/lsa/srv_lsa_nt.c
index 9ea872b0276..c6f45eaad0f 100644
--- a/source3/rpc_server/lsa/srv_lsa_nt.c
+++ b/source3/rpc_server/lsa/srv_lsa_nt.c
@@ -30,6 +30,7 @@
/* This is the implementation of the lsa server code. */
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_lsa.h"
#include "secrets.h"
#include "../librpc/gen_ndr/netlogon.h"
@@ -43,7 +44,6 @@
#include "../librpc/gen_ndr/ndr_security.h"
#include "passdb.h"
#include "auth.h"
-#include "ntdomain.h"
#include "lib/privileges.h"
#include "rpc_server/srv_access_check.h"
@@ -122,7 +122,7 @@ static int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx,
ref->count = num + 1;
ref->max_size = LSA_REF_DOMAIN_LIST_MULTIPLIER;
- ref->domains = TALLOC_REALLOC_ARRAY(mem_ctx, ref->domains,
+ ref->domains = talloc_realloc(mem_ctx, ref->domains,
struct lsa_DomainInfo, ref->count);
if (!ref->domains) {
return -1;
@@ -520,7 +520,7 @@ NTSTATUS _lsa_EnumTrustDom(struct pipes_struct *p,
return nt_status;
}
- entries = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_DomainInfo, count);
+ entries = talloc_zero_array(p->mem_ctx, struct lsa_DomainInfo, count);
if (!entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -628,7 +628,7 @@ NTSTATUS _lsa_QueryInfoPolicy(struct pipes_struct *p,
/* return NT_STATUS_ACCESS_DENIED; */
}
- info = TALLOC_ZERO_P(p->mem_ctx, union lsa_PolicyInformation);
+ info = talloc_zero(p->mem_ctx, union lsa_PolicyInformation);
if (!info) {
return NT_STATUS_NO_MEMORY;
}
@@ -681,7 +681,7 @@ NTSTATUS _lsa_QueryInfoPolicy(struct pipes_struct *p,
info->audit_events.auditing_mode = true;
info->audit_events.count = LSA_AUDIT_NUM_CATEGORIES;
- info->audit_events.settings = TALLOC_ZERO_ARRAY(p->mem_ctx,
+ info->audit_events.settings = talloc_zero_array(p->mem_ctx,
enum lsa_PolicyAuditPolicy,
info->audit_events.count);
if (!info->audit_events.settings) {
@@ -858,8 +858,8 @@ static NTSTATUS _lsa_lookup_sids_internal(struct pipes_struct *p,
return NT_STATUS_OK;
}
- sids = TALLOC_ARRAY(p->mem_ctx, const struct dom_sid *, num_sids);
- ref = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList);
+ sids = talloc_array(p->mem_ctx, const struct dom_sid *, num_sids);
+ ref = talloc_zero(p->mem_ctx, struct lsa_RefDomainList);
if (sids == NULL || ref == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -876,7 +876,7 @@ static NTSTATUS _lsa_lookup_sids_internal(struct pipes_struct *p,
return status;
}
- names = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedName2, num_sids);
+ names = talloc_array(p->mem_ctx, struct lsa_TranslatedName2, num_sids);
if (names == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -998,7 +998,7 @@ NTSTATUS _lsa_LookupSids(struct pipes_struct *p,
}
/* Convert from lsa_TranslatedName2 to lsa_TranslatedName */
- names_out = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedName,
+ names_out = talloc_array(p->mem_ctx, struct lsa_TranslatedName,
num_sids);
if (!names_out) {
return NT_STATUS_NO_MEMORY;
@@ -1168,13 +1168,13 @@ NTSTATUS _lsa_LookupNames(struct pipes_struct *p,
flags = lsa_lookup_level_to_flags(r->in.level);
- domains = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList);
+ domains = talloc_zero(p->mem_ctx, struct lsa_RefDomainList);
if (!domains) {
return NT_STATUS_NO_MEMORY;
}
if (num_entries) {
- rids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TranslatedSid,
+ rids = talloc_zero_array(p->mem_ctx, struct lsa_TranslatedSid,
num_entries);
if (!rids) {
return NT_STATUS_NO_MEMORY;
@@ -1235,7 +1235,7 @@ NTSTATUS _lsa_LookupNames2(struct pipes_struct *p,
struct lsa_TransSidArray *sid_array = NULL;
uint32_t i;
- sid_array = TALLOC_ZERO_P(p->mem_ctx, struct lsa_TransSidArray);
+ sid_array = talloc_zero(p->mem_ctx, struct lsa_TransSidArray);
if (!sid_array) {
return NT_STATUS_NO_MEMORY;
}
@@ -1257,7 +1257,7 @@ NTSTATUS _lsa_LookupNames2(struct pipes_struct *p,
status = _lsa_LookupNames(p, &q);
sid_array2->count = sid_array->count;
- sid_array2->sids = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedSid2, sid_array->count);
+ sid_array2->sids = talloc_array(p->mem_ctx, struct lsa_TranslatedSid2, sid_array->count);
if (!sid_array2->sids) {
return NT_STATUS_NO_MEMORY;
}
@@ -1310,13 +1310,13 @@ NTSTATUS _lsa_LookupNames3(struct pipes_struct *p,
flags = LOOKUP_NAME_ALL;
}
- domains = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList);
+ domains = talloc_zero(p->mem_ctx, struct lsa_RefDomainList);
if (!domains) {
return NT_STATUS_NO_MEMORY;
}
if (num_entries) {
- trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TranslatedSid3,
+ trans_sids = talloc_zero_array(p->mem_ctx, struct lsa_TranslatedSid3,
num_entries);
if (!trans_sids) {
return NT_STATUS_NO_MEMORY;
@@ -2012,7 +2012,7 @@ NTSTATUS _lsa_QueryTrustedDomainInfo(struct pipes_struct *p,
return status;
}
- info = TALLOC_ZERO_P(p->mem_ctx, union lsa_TrustedDomainInfo);
+ info = talloc_zero(p->mem_ctx, union lsa_TrustedDomainInfo);
if (!info) {
return NT_STATUS_NO_MEMORY;
}
@@ -2230,7 +2230,7 @@ NTSTATUS _lsa_EnumPrivs(struct pipes_struct *p,
return NT_STATUS_ACCESS_DENIED;
if (num_privs) {
- entries = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_PrivEntry, num_privs);
+ entries = talloc_zero_array(p->mem_ctx, struct lsa_PrivEntry, num_privs);
if (!entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -2299,7 +2299,7 @@ NTSTATUS _lsa_LookupPrivDisplayName(struct pipes_struct *p,
DEBUG(10,("_lsa_LookupPrivDisplayName: display name = %s\n", description));
- lsa_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_StringLarge);
+ lsa_name = talloc_zero(p->mem_ctx, struct lsa_StringLarge);
if (!lsa_name) {
return NT_STATUS_NO_MEMORY;
}
@@ -2351,7 +2351,7 @@ NTSTATUS _lsa_EnumAccounts(struct pipes_struct *p,
}
if (num_entries - *r->in.resume_handle) {
- sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_SidPtr,
+ sids = talloc_zero_array(p->mem_ctx, struct lsa_SidPtr,
num_entries - *r->in.resume_handle);
if (!sids) {
talloc_free(sid_list);
@@ -2412,14 +2412,14 @@ NTSTATUS _lsa_GetUserName(struct pipes_struct *p,
domname = p->session_info->info3->base.domain.string;
}
- account_name = TALLOC_P(p->mem_ctx, struct lsa_String);
+ account_name = talloc(p->mem_ctx, struct lsa_String);
if (!account_name) {
return NT_STATUS_NO_MEMORY;
}
init_lsa_String(account_name, username);
if (r->out.authority_name) {
- authority_name = TALLOC_P(p->mem_ctx, struct lsa_String);
+ authority_name = talloc(p->mem_ctx, struct lsa_String);
if (!authority_name) {
return NT_STATUS_NO_MEMORY;
}
@@ -2597,7 +2597,7 @@ NTSTATUS _lsa_EnumPrivsAccount(struct pipes_struct *p,
return status;
}
- *r->out.privs = priv_set = TALLOC_ZERO_P(p->mem_ctx, struct lsa_PrivilegeSet);
+ *r->out.privs = priv_set = talloc_zero(p->mem_ctx, struct lsa_PrivilegeSet);
if (!priv_set) {
return NT_STATUS_NO_MEMORY;
}
@@ -2801,7 +2801,7 @@ NTSTATUS _lsa_LookupPrivName(struct pipes_struct *p,
return NT_STATUS_NO_SUCH_PRIVILEGE;
}
- lsa_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_StringLarge);
+ lsa_name = talloc_zero(p->mem_ctx, struct lsa_StringLarge);
if (!lsa_name) {
return NT_STATUS_NO_MEMORY;
}
@@ -3030,7 +3030,7 @@ static NTSTATUS init_lsa_right_set(TALLOC_CTX *mem_ctx,
if (num_priv) {
- r->names = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_StringLarge,
+ r->names = talloc_zero_array(mem_ctx, struct lsa_StringLarge,
num_priv);
if (!r->names) {
return NT_STATUS_NO_MEMORY;
@@ -3323,7 +3323,7 @@ NTSTATUS _lsa_EnumTrustedDomainsEx(struct pipes_struct *p,
return nt_status;
}
- entries = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TrustDomainInfoInfoEx,
+ entries = talloc_zero_array(p->mem_ctx, struct lsa_TrustDomainInfoInfoEx,
count);
if (!entries) {
return NT_STATUS_NO_MEMORY;
@@ -3488,7 +3488,7 @@ static int dns_cmp(const char *s1, size_t l1,
int cret;
if (l1 == l2) {
- if (StrCaseCmp(s1, s2) == 0) {
+ if (strcasecmp_m(s1, s2) == 0) {
return DNS_CMP_MATCH;
}
return DNS_CMP_NO_MATCH;
@@ -3512,7 +3512,7 @@ static int dns_cmp(const char *s1, size_t l1,
return DNS_CMP_NO_MATCH;
}
- if (StrCaseCmp(&p1[t1 - t2], p2) == 0) {
+ if (strcasecmp_m(&p1[t1 - t2], p2) == 0) {
return cret;
}
@@ -3701,7 +3701,7 @@ static NTSTATUS check_ft_info(TALLOC_CTX *mem_ctx,
sid_conflict = true;
}
if (!(trec->flags & LSA_NB_DISABLED_ADMIN) &&
- StrCaseCmp(trec->data.info.netbios_name.string,
+ strcasecmp_m(trec->data.info.netbios_name.string,
nb_name) == 0) {
nb_conflict = true;
}
@@ -3876,7 +3876,7 @@ NTSTATUS _lsa_lsaRSetForestTrustInformation(struct pipes_struct *p,
if (domains[i]->domain_name == NULL) {
return NT_STATUS_INVALID_DOMAIN_STATE;
}
- if (StrCaseCmp(domains[i]->domain_name,
+ if (strcasecmp_m(domains[i]->domain_name,
r->in.trusted_domain_name->string) == 0) {
break;
}
diff --git a/source3/rpc_server/netlogon/srv_netlog_nt.c b/source3/rpc_server/netlogon/srv_netlog_nt.c
index f0535c72953..03897d77a47 100644
--- a/source3/rpc_server/netlogon/srv_netlog_nt.c
+++ b/source3/rpc_server/netlogon/srv_netlog_nt.c
@@ -25,10 +25,9 @@
/* This is the implementation of the netlogon pipe. */
#include "includes.h"
+#include "ntdomain.h"
#include "../libcli/auth/schannel.h"
#include "../librpc/gen_ndr/srv_netlogon.h"
-#include "../librpc/gen_ndr/srv_samr.h"
-#include "../librpc/gen_ndr/srv_lsa.h"
#include "../librpc/gen_ndr/ndr_samr_c.h"
#include "../librpc/gen_ndr/ndr_lsa_c.h"
#include "rpc_client/cli_lsarpc.h"
@@ -45,7 +44,6 @@
#include "passdb.h"
#include "auth.h"
#include "messages.h"
-#include "ntdomain.h"
extern userdom_struct current_user_info;
@@ -348,7 +346,7 @@ WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
switch (r->in.level) {
case 1:
- info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1);
+ info1 = talloc_zero(p->mem_ctx, struct netr_NETLOGON_INFO_1);
W_ERROR_HAVE_NO_MEMORY(info1);
info1->flags = flags;
@@ -357,7 +355,7 @@ WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
r->out.query->info1 = info1;
break;
case 2:
- info2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_2);
+ info2 = talloc_zero(p->mem_ctx, struct netr_NETLOGON_INFO_2);
W_ERROR_HAVE_NO_MEMORY(info2);
info2->flags = flags;
@@ -368,7 +366,7 @@ WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
r->out.query->info2 = info2;
break;
case 3:
- info3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_3);
+ info3 = talloc_zero(p->mem_ctx, struct netr_NETLOGON_INFO_3);
W_ERROR_HAVE_NO_MEMORY(info3);
info3->flags = flags;
@@ -377,7 +375,7 @@ WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
r->out.query->info3 = info3;
break;
case 4:
- info4 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_4);
+ info4 = talloc_zero(p->mem_ctx, struct netr_NETLOGON_INFO_4);
W_ERROR_HAVE_NO_MEMORY(info4);
info4->trusted_dc_name = dc_name;
@@ -524,7 +522,7 @@ static NTSTATUS samr_find_machine_account(TALLOC_CTX *mem_ctx,
uint32_t rid;
status = dcerpc_samr_Connect2(b, mem_ctx,
- global_myname(),
+ lp_netbios_name(),
SAMR_ACCESS_CONNECT_TO_SERVER |
SAMR_ACCESS_ENUM_DOMAINS |
SAMR_ACCESS_LOOKUP_DOMAIN,
@@ -1423,19 +1421,19 @@ static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
switch (r->in.validation_level) {
case 2:
- r->out.validation->sam2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo2);
+ r->out.validation->sam2 = talloc_zero(p->mem_ctx, struct netr_SamInfo2);
if (!r->out.validation->sam2) {
return NT_STATUS_NO_MEMORY;
}
break;
case 3:
- r->out.validation->sam3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo3);
+ r->out.validation->sam3 = talloc_zero(p->mem_ctx, struct netr_SamInfo3);
if (!r->out.validation->sam3) {
return NT_STATUS_NO_MEMORY;
}
break;
case 6:
- r->out.validation->sam6 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo6);
+ r->out.validation->sam6 = talloc_zero(p->mem_ctx, struct netr_SamInfo6);
if (!r->out.validation->sam6) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c b/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c
index af80254a0b2..0a00e000255 100644
--- a/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c
+++ b/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c
@@ -20,10 +20,10 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_ntsvcs.h"
#include "services/svc_winreg_glue.h"
#include "../libcli/registry/util_reg.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
diff --git a/source3/rpc_server/rpc_contexts.c b/source3/rpc_server/rpc_contexts.c
new file mode 100644
index 00000000000..bb5c0eaf6cd
--- /dev/null
+++ b/source3/rpc_server/rpc_contexts.c
@@ -0,0 +1,40 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Almost completely rewritten by (C) Jeremy Allison 2005 - 2010
+ *
+ * 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 "ntdomain.h"
+
+#include "rpc_contexts.h"
+
+struct pipe_rpc_fns *find_pipe_fns_by_context(struct pipe_rpc_fns *list,
+ uint32_t context_id)
+{
+ struct pipe_rpc_fns *fns = NULL;
+
+ if ( !list ) {
+ DEBUG(0,("find_pipe_fns_by_context: ERROR! No context list for pipe!\n"));
+ return NULL;
+ }
+
+ for (fns=list; fns; fns=fns->next ) {
+ if ( fns->context_id == context_id )
+ return fns;
+ }
+ return NULL;
+}
diff --git a/source3/rpc_server/rpc_contexts.h b/source3/rpc_server/rpc_contexts.h
new file mode 100644
index 00000000000..8463414bbb3
--- /dev/null
+++ b/source3/rpc_server/rpc_contexts.h
@@ -0,0 +1,28 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Almost completely rewritten by (C) Jeremy Allison 2005 - 2010
+ *
+ * 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 _RPC_SERVER_RPC_CONTEXTS_H_
+#define _RPC_SERVER_RPC_CONTEXTS_H_
+
+struct pipe_rpc_fns;
+
+struct pipe_rpc_fns *find_pipe_fns_by_context(struct pipe_rpc_fns *list,
+ uint32_t context_id);
+
+#endif /* _RPC_SERVER_RPC_CONTEXTS_H_*/
diff --git a/source3/rpc_server/rpc_ep_setup.c b/source3/rpc_server/rpc_ep_setup.c
index d517bb88516..e5059dae807 100644
--- a/source3/rpc_server/rpc_ep_setup.c
+++ b/source3/rpc_server/rpc_ep_setup.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/ndr_epmapper_c.h"
#include "../librpc/gen_ndr/srv_epmapper.h"
@@ -41,6 +42,8 @@
#include "printing/nt_printing_migrate.h"
#include "rpc_server/eventlog/srv_eventlog_reg.h"
#include "rpc_server/svcctl/srv_svcctl_reg.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
+#include "rpc_server/svcctl/srv_svcctl_nt.h"
#include "librpc/rpc/dcerpc_ep.h"
@@ -76,7 +79,6 @@ static uint16_t _open_sockets(struct tevent_context *ev_ctx,
p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
msg_ctx,
- syntax_id,
ifss,
port);
if (p == 0) {
@@ -92,7 +94,7 @@ static uint16_t _open_sockets(struct tevent_context *ev_ctx,
if (strequal(sock_addr, "0.0.0.0") ||
strequal(sock_addr, "::")) {
#if HAVE_IPV6
- sock_addr = "::";
+ sock_addr = "::,0.0.0.0";
#else
sock_addr = "0.0.0.0";
#endif
@@ -112,7 +114,6 @@ static uint16_t _open_sockets(struct tevent_context *ev_ctx,
p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
msg_ctx,
- syntax_id,
&ss,
port);
if (p == 0) {
@@ -130,7 +131,7 @@ static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const struct ndr_interface_table *iface,
- const char *name,
+ const char *ncalrpc,
uint16_t port,
struct dcerpc_binding_handle **pbh);
@@ -253,7 +254,7 @@ static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const struct ndr_interface_table *iface,
- const char *name,
+ const char *ncalrpc,
uint16_t port,
struct dcerpc_binding_handle **pbh)
{
@@ -263,7 +264,7 @@ static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
status = dcerpc_binding_vector_create(mem_ctx,
iface,
port,
- name,
+ ncalrpc,
&v);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -273,7 +274,7 @@ static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
iface,
v,
&iface->syntax_id.uuid,
- name,
+ iface->name,
pbh);
talloc_free(v);
if (!NT_STATUS_IS_OK(status)) {
@@ -420,14 +421,13 @@ static bool winreg_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -468,14 +468,13 @@ static bool srvsvc_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -517,14 +516,13 @@ static bool lsarpc_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -566,14 +564,13 @@ static bool samr_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -615,14 +612,13 @@ static bool netlogon_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -670,8 +666,8 @@ static bool spoolss_init_cb(void *ptr)
return false;
}
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status =rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -714,8 +710,8 @@ static bool svcctl_init_cb(void *ptr)
/* initialize the control hooks */
init_service_op_table();
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status = rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -749,8 +745,8 @@ static bool ntsvcs_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status = rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -783,8 +779,8 @@ static bool eventlog_init_cb(void *ptr)
return false;
}
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status =rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -811,8 +807,8 @@ static bool initshutdown_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status = rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -840,8 +836,8 @@ static bool rpcecho_init_cb(void *ptr) {
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
port = _open_sockets(ep_ctx->ev_ctx,
@@ -880,14 +876,13 @@ static bool netdfs_init_cb(void *ptr)
"rpc_server",
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -929,14 +924,13 @@ static bool dssetup_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -977,14 +971,13 @@ static bool wkssvc_init_cb(void *ptr)
"rpc_server",
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -1053,7 +1046,7 @@ bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
"rpc_server",
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
epmapper_cb.init = epmapper_init_cb;
epmapper_cb.shutdown = epmapper_shutdown_cb;
epmapper_cb.private_data = ep_ctx;
@@ -1061,7 +1054,7 @@ bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
if (!NT_STATUS_IS_OK(rpc_epmapper_init(&epmapper_cb))) {
return false;
}
- } else if (StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ } else if (strcasecmp_m(rpcsrv_type, "daemon") == 0) {
if (!NT_STATUS_IS_OK(rpc_epmapper_init(NULL))) {
return false;
}
@@ -1107,15 +1100,15 @@ bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
"rpc_server",
"spoolss",
"embedded");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
spoolss_cb.init = spoolss_init_cb;
spoolss_cb.shutdown = spoolss_shutdown_cb;
spoolss_cb.private_data = ep_ctx;
if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
return false;
}
- } else if (StrCaseCmp(rpcsrv_type, "daemon") == 0 ||
- StrCaseCmp(rpcsrv_type, "external") == 0) {
+ } else if (strcasecmp_m(rpcsrv_type, "daemon") == 0 ||
+ strcasecmp_m(rpcsrv_type, "external") == 0) {
if (!NT_STATUS_IS_OK(rpc_spoolss_init(NULL))) {
return false;
}
diff --git a/source3/rpc_server/rpc_ep_setup.h b/source3/rpc_server/rpc_ep_setup.h
index b96de36b16e..57b06abb39f 100644
--- a/source3/rpc_server/rpc_ep_setup.h
+++ b/source3/rpc_server/rpc_ep_setup.h
@@ -22,6 +22,8 @@
#ifndef _SMBD_RPC_CALLBACKS_H
#define _SMBD_RPC_CALLBACKS_H
+struct ndr_interface_table;
+
/**
* @brief Register an endpoint at the endpoint mapper.
*
diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c
index 889e87e9b5a..7fa59b6b117 100644
--- a/source3/rpc_server/rpc_handles.c
+++ b/source3/rpc_server/rpc_handles.c
@@ -24,6 +24,7 @@
#include "../librpc/gen_ndr/ndr_samr.h"
#include "auth.h"
#include "ntdomain.h"
+#include "rpc_server/rpc_ncacn_np.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -83,15 +84,28 @@ bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *synta
for (plist = get_first_internal_pipe();
plist;
plist = get_next_internal_pipe(plist)) {
- if (ndr_syntax_id_equal(syntax, &plist->syntax)) {
- break;
+ struct pipe_rpc_fns *p_ctx;
+ bool stop = false;
+
+ for (p_ctx = plist->contexts;
+ p_ctx != NULL;
+ p_ctx = p_ctx->next) {
+ if (ndr_syntax_id_equal(syntax, &p_ctx->syntax)) {
+ stop = true;
+ break;
+ }
+ if (is_samr_lsa_pipe(&p_ctx->syntax)
+ && is_samr_lsa_pipe(syntax)) {
+ /*
+ * samr and lsa share a handle space (same process
+ * under Windows?)
+ */
+ stop = true;
+ break;
+ }
}
- if (is_samr_lsa_pipe(&plist->syntax)
- && is_samr_lsa_pipe(syntax)) {
- /*
- * samr and lsa share a handle space (same process
- * under Windows?)
- */
+
+ if (stop) {
break;
}
}
@@ -229,7 +243,7 @@ static struct dcesrv_handle *find_policy_by_hnd_internal(struct pipes_struct *p,
for (h = p->pipe_handles->handles; h != NULL; h = h->next) {
if (memcmp(&h->wire_handle, hnd, sizeof(*hnd)) == 0) {
DEBUG(4,("Found policy hnd[%u] ", count));
- dump_data(4, (uint8 *)hnd, sizeof(*hnd));
+ dump_data(4, (const uint8 *)hnd, sizeof(*hnd));
if (data_p) {
*data_p = h->data;
}
@@ -239,7 +253,7 @@ static struct dcesrv_handle *find_policy_by_hnd_internal(struct pipes_struct *p,
}
DEBUG(4,("Policy not found: "));
- dump_data(4, (uint8_t *)hnd, sizeof(*hnd));
+ dump_data(4, (const uint8_t *)hnd, sizeof(*hnd));
p->bad_handle_fault_state = true;
@@ -293,6 +307,10 @@ bool close_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd)
void close_policy_by_pipe(struct pipes_struct *p)
{
+ if (p->pipe_handles == NULL) {
+ return;
+ }
+
p->pipe_handles->pipe_ref_count--;
if (p->pipe_handles->pipe_ref_count == 0) {
@@ -301,9 +319,9 @@ void close_policy_by_pipe(struct pipes_struct *p)
*/
TALLOC_FREE(p->pipe_handles);
- DEBUG(10,("close_policy_by_pipe: deleted handle list for "
- "pipe %s\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ DEBUG(10,("Deleted handle list for RPC connection %s\n",
+ get_pipe_name_from_syntax(talloc_tos(),
+ &p->contexts->syntax)));
}
}
@@ -344,9 +362,10 @@ void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,
void *data;
if (p->pipe_handles->count > MAX_OPEN_POLS) {
- DEBUG(0, ("policy_handle_create: ERROR: too many handles (%d) "
- "on pipe %s.\n", (int)p->pipe_handles->count,
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ DEBUG(0, ("ERROR: Too many handles (%d) for RPC connection %s\n",
+ (int) p->pipe_handles->count,
+ get_pipe_name_from_syntax(talloc_tos(),
+ &p->contexts->syntax)));
*pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
return NULL;
}
diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c
index e89a366f9e9..f14aae540d3 100644
--- a/source3/rpc_server/rpc_ncacn_np.c
+++ b/source3/rpc_server/rpc_ncacn_np.c
@@ -31,12 +31,13 @@
#include "../auth/auth_sam_reply.h"
#include "auth.h"
#include "ntdomain.h"
+#include "../lib/tsocket/tsocket.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "rpc_contexts.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-static int pipes_open;
-
static struct pipes_struct *InternalPipes;
/* TODO
@@ -102,11 +103,11 @@ int close_internal_rpc_pipe_hnd(struct pipes_struct *p)
TALLOC_FREE(p->auth.auth_ctx);
- free_pipe_rpc_context_internal( p->contexts );
-
/* Free the handles database. */
close_policy_by_pipe(p);
+ free_pipe_rpc_context_internal( p->contexts );
+
DLIST_REMOVE(InternalPipes, p);
ZERO_STRUCTP(p);
@@ -125,11 +126,12 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx)
{
struct pipes_struct *p;
+ struct pipe_rpc_fns *context_fns;
DEBUG(4,("Create pipe requested %s\n",
get_pipe_name_from_syntax(talloc_tos(), syntax)));
- p = TALLOC_ZERO_P(mem_ctx, struct pipes_struct);
+ p = talloc_zero(mem_ctx, struct pipes_struct);
if (!p) {
DEBUG(0,("ERROR! no memory for pipes_struct!\n"));
@@ -167,11 +169,25 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
p->endian = RPC_LITTLE_ENDIAN;
- p->syntax = *syntax;
p->transport = NCALRPC;
- DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n",
- get_pipe_name_from_syntax(talloc_tos(), syntax), pipes_open));
+ context_fns = SMB_MALLOC_P(struct pipe_rpc_fns);
+ if (context_fns == NULL) {
+ DEBUG(0,("malloc() failed!\n"));
+ return False;
+ }
+
+ context_fns->next = context_fns->prev = NULL;
+ context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(syntax);
+ context_fns->cmds = rpc_srv_get_pipe_cmds(syntax);
+ context_fns->context_id = 0;
+ context_fns->syntax = *syntax;
+
+ /* add to the list of open contexts */
+ DLIST_ADD(p->contexts, context_fns);
+
+ DEBUG(4,("Created internal pipe %s\n",
+ get_pipe_name_from_syntax(talloc_tos(), syntax)));
talloc_set_destructor(p, close_internal_rpc_pipe_hnd);
@@ -184,8 +200,9 @@ static NTSTATUS rpcint_dispatch(struct pipes_struct *p,
const DATA_BLOB *in_data,
DATA_BLOB *out_data)
{
- uint32_t num_cmds = rpc_srv_get_pipe_num_cmds(&p->syntax);
- const struct api_struct *cmds = rpc_srv_get_pipe_cmds(&p->syntax);
+ struct pipe_rpc_fns *fns = find_pipe_fns_by_context(p->contexts, 0);
+ uint32_t num_cmds = fns->n_cmds;
+ const struct api_struct *cmds = fns->cmds;
uint32_t i;
bool ok;
@@ -517,7 +534,8 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
* @brief Create a new RPC client context which uses a local transport.
*
* This creates a local transport. It is a shortcut to directly call the server
- * functions and avoid marschalling.
+ * functions and avoid marshalling.
+ * NOTE: this function should be used only by rpc_pipe_open_interface()
*
* @param[in] mem_ctx The memory context to use.
*
@@ -534,19 +552,8 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
*
* @return NT_STATUS_OK on success, a corresponding NT status if an
* error occured.
- *
- * @code
- * struct rpc_pipe_client *winreg_pipe;
- * NTSTATUS status;
- *
- * status = rpc_pipe_open_internal(tmp_ctx,
- * &ndr_table_winreg.syntax_id,
- * p->session_info,
- * client_id,
- * &winreg_pipe);
- * @endcode
*/
-NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
const struct ndr_syntax_id *abstract_syntax,
const struct auth_serversupplied_info *serversupplied_info,
struct client_address *client_id,
@@ -556,7 +563,7 @@ NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client *result;
NTSTATUS status;
- result = TALLOC_ZERO_P(mem_ctx, struct rpc_pipe_client);
+ result = talloc_zero(mem_ctx, struct rpc_pipe_client);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -831,17 +838,36 @@ done:
}
/**
- * @brief Create a new RPC client context which uses a local dispatch function.
+ * @brief Create a new RPC client context which uses a local dispatch function
+ * or a remote transport, depending on rpc_server configuration for the
+ * specific service.
+ *
+ * @param[in] mem_ctx The memory context to use.
+ *
+ * @param[in] abstract_syntax Normally the syntax_id of the autogenerated
+ * ndr_table_<name>.
+ *
+ * @param[in] serversupplied_info The server supplied authentication function.
*
- * @param mem_ctx The memory context on which thje pipe will ultimately
- * be allocated
- * @param name The pipe name to connect to.
- * @param session_info Credentials to use for the connection.
- * @param pipe [in|out] Checks if a pipe is connected, and connects it
- * if not
+ * @param[in] client_id The client address information.
*
- * @return NT_STATUS_OK on success, a corresponding NT status if
- * an error occured.
+ * @param[in] msg_ctx The messaging context to use.
+ *
+ * @param[out] presult A pointer to store the connected rpc client pipe.
+ *
+ * @return NT_STATUS_OK on success, a corresponding NT status if an
+ * error occured.
+ *
+ * @code
+ * struct rpc_pipe_client *winreg_pipe;
+ * NTSTATUS status;
+ *
+ * status = rpc_pipe_open_interface(tmp_ctx,
+ * &ndr_table_winreg.syntax_id,
+ * p->session_info,
+ * client_id,
+ * &winreg_pipe);
+ * @endcode
*/
NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
@@ -884,7 +910,7 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
"rpc_server", pipe_name,
"embedded");
- if (StrCaseCmp(server_type, "embedded") == 0) {
+ if (strcasecmp_m(server_type, "embedded") == 0) {
status = rpc_pipe_open_internal(tmp_ctx,
syntax, session_info,
client_id, msg_ctx,
@@ -892,8 +918,8 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- } else if (StrCaseCmp(server_type, "daemon") == 0 ||
- StrCaseCmp(server_type, "external") == 0) {
+ } else if (strcasecmp_m(server_type, "daemon") == 0 ||
+ strcasecmp_m(server_type, "external") == 0) {
/* It would be nice to just use rpc_pipe_open_ncalrpc() but
* for now we need to use the special proxy setup to connect
* to spoolssd. */
diff --git a/source3/rpc_server/rpc_ncacn_np.h b/source3/rpc_server/rpc_ncacn_np.h
index 7c8619b46db..3d9a170cdc9 100644
--- a/source3/rpc_server/rpc_ncacn_np.h
+++ b/source3/rpc_server/rpc_ncacn_np.h
@@ -20,6 +20,10 @@
#ifndef _RPC_NCACN_NP_H_
#define _RPC_NCACN_NP_H_
+struct dcerpc_binding_handle;
+struct ndr_interface_table;
+struct tsocket_address;
+
struct np_proxy_state {
uint16_t file_type;
uint16_t device_state;
@@ -45,12 +49,6 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
struct dcerpc_binding_handle **binding_handle);
-NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
- const struct ndr_syntax_id *abstract_syntax,
- const struct auth_serversupplied_info *serversupplied_info,
- struct client_address *client_id,
- struct messaging_context *msg_ctx,
- struct rpc_pipe_client **presult);
NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
const struct ndr_syntax_id *syntax,
const struct auth_serversupplied_info *session_info,
@@ -58,4 +56,9 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
struct rpc_pipe_client **cli_pipe);
+struct pipes_struct *get_first_internal_pipe(void);
+struct pipes_struct *get_next_internal_pipe(struct pipes_struct *p);
+bool check_open_pipes(void);
+int close_internal_rpc_pipe_hnd(struct pipes_struct *p);
+
#endif /* _RPC_NCACN_NP_H_ */
diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c
index c7c77f03757..44c1b104c0b 100644
--- a/source3/rpc_server/rpc_server.c
+++ b/source3/rpc_server/rpc_server.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "rpc_server/rpc_server.h"
#include "rpc_dce.h"
#include "librpc/gen_ndr/netlogon.h"
@@ -26,7 +27,9 @@
#include "libcli/named_pipe_auth/npa_tstream.h"
#include "../auth/auth_sam_reply.h"
#include "auth.h"
-#include "ntdomain.h"
+#include "rpc_server/rpc_ncacn_np.h"
+#include "rpc_server/srv_pipe_hnd.h"
+#include "rpc_server/srv_pipe.h"
#define SERVER_TCP_LOW_PORT 1024
#define SERVER_TCP_HIGH_PORT 1300
@@ -76,7 +79,6 @@ static NTSTATUS auth_anonymous_session_info(TALLOC_CTX *mem_ctx,
* sent from the client */
static int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
const char *pipe_name,
- const struct ndr_syntax_id id,
enum dcerpc_transport_t transport,
bool ncalrpc_as_system,
const char *client_address,
@@ -90,14 +92,13 @@ static int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
struct pipes_struct *p;
struct auth_serversupplied_info *server_info;
NTSTATUS status;
- bool ok;
p = talloc_zero(mem_ctx, struct pipes_struct);
if (!p) {
*perrno = ENOMEM;
return -1;
}
- p->syntax = id;
+
p->transport = transport;
p->ncalrpc_as_system = ncalrpc_as_system;
@@ -108,15 +109,6 @@ static int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
return -1;
}
- ok = init_pipe_handles(p, &id);
- if (!ok) {
- DEBUG(1, ("Failed to init handles\n"));
- TALLOC_FREE(p);
- *perrno = EINVAL;
- return -1;
- }
-
-
data_blob_free(&p->in_data.data);
data_blob_free(&p->in_data.pdu);
@@ -258,6 +250,17 @@ bool setup_named_pipe_socket(const char *pipe_name,
}
state->fd = -1;
+ /*
+ * As lp_ncalrpc_dir() should have 0755, but
+ * lp_ncalrpc_dir()/np should have 0700, we need to
+ * create lp_ncalrpc_dir() first.
+ */
+ if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) {
+ DEBUG(0, ("Failed to create pipe directory %s - %s\n",
+ lp_ncalrpc_dir(), strerror(errno)));
+ goto out;
+ }
+
np_dir = talloc_asprintf(state, "%s/np", lp_ncalrpc_dir());
if (!np_dir) {
DEBUG(0, ("Out of memory\n"));
@@ -340,7 +343,6 @@ static void named_pipe_listener(struct tevent_context *ev,
struct named_pipe_client {
const char *pipe_name;
- struct ndr_syntax_id pipe_id;
struct tevent_context *ev;
struct messaging_context *msg_ctx;
@@ -369,20 +371,11 @@ static void named_pipe_accept_done(struct tevent_req *subreq);
static void named_pipe_accept_function(const char *pipe_name, int fd)
{
- struct ndr_syntax_id syntax;
struct named_pipe_client *npc;
struct tstream_context *plain;
struct tevent_req *subreq;
- bool ok;
int ret;
- ok = is_known_pipename(pipe_name, &syntax);
- if (!ok) {
- DEBUG(1, ("Unknown pipe [%s]\n", pipe_name));
- close(fd);
- return;
- }
-
npc = talloc_zero(NULL, struct named_pipe_client);
if (!npc) {
DEBUG(0, ("Out of memory!\n"));
@@ -390,7 +383,6 @@ static void named_pipe_accept_function(const char *pipe_name, int fd)
return;
}
npc->pipe_name = pipe_name;
- npc->pipe_id = syntax;
npc->ev = server_event_context();
npc->msg_ctx = server_messaging_context();
@@ -470,7 +462,7 @@ static void named_pipe_accept_done(struct tevent_req *subreq)
}
ret = make_server_pipes_struct(npc,
- npc->pipe_name, npc->pipe_id, NCACN_NP,
+ npc->pipe_name, NCACN_NP,
false, cli_addr, NULL, npc->session_info,
&npc->p, &error);
if (ret != 0) {
@@ -679,7 +671,6 @@ fail:
static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
enum dcerpc_transport_t transport,
const char *name,
uint16_t port,
@@ -699,7 +690,6 @@ static void dcerpc_ncacn_tcpip_listener(struct tevent_context *ev,
uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
const struct sockaddr_storage *ifss,
uint16_t port)
{
@@ -713,7 +703,6 @@ uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
return 0;
}
- state->syntax_id = syntax_id;
state->fd = -1;
state->ep.port = port;
state->disconnect_fn = NULL;
@@ -839,7 +828,6 @@ static void dcerpc_ncacn_tcpip_listener(struct tevent_context *ev,
dcerpc_ncacn_accept(state->ev_ctx,
state->msg_ctx,
- state->syntax_id,
NCACN_IP_TCP,
NULL,
state->ep.port,
@@ -860,7 +848,6 @@ static void dcerpc_ncalrpc_listener(struct tevent_context *ev,
bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
const char *name,
dcerpc_ncacn_disconnect_fn fn)
{
@@ -873,7 +860,6 @@ bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
return false;
}
- state->syntax_id = syntax_id;
state->fd = -1;
state->disconnect_fn = fn;
@@ -888,13 +874,13 @@ bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
return false;
}
- if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0700)) {
+ if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) {
DEBUG(0, ("Failed to create pipe directory %s - %s\n",
lp_ncalrpc_dir(), strerror(errno)));
goto out;
}
- state->fd = create_pipe_sock(lp_ncalrpc_dir(), name, 0700);
+ state->fd = create_pipe_sock(lp_ncalrpc_dir(), name, 0755);
if (state->fd == -1) {
DEBUG(0, ("Failed to create pipe socket! [%s/%s]\n",
lp_ncalrpc_dir(), name));
@@ -969,15 +955,13 @@ static void dcerpc_ncalrpc_listener(struct tevent_context *ev,
dcerpc_ncacn_accept(state->ev_ctx,
state->msg_ctx,
- state->syntax_id, NCALRPC,
+ NCALRPC,
state->ep.name, 0,
cli_addr, NULL, sd,
state->disconnect_fn);
}
struct dcerpc_ncacn_conn {
- struct ndr_syntax_id syntax_id;
-
enum dcerpc_transport_t transport;
union {
@@ -1011,7 +995,6 @@ static void dcerpc_ncacn_packet_done(struct tevent_req *subreq);
static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
enum dcerpc_transport_t transport,
const char *name,
uint16_t port,
@@ -1040,7 +1023,6 @@ static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
}
ncacn_conn->transport = transport;
- ncacn_conn->syntax_id = syntax_id;
ncacn_conn->ev_ctx = ev_ctx;
ncacn_conn->msg_ctx = msg_ctx;
ncacn_conn->sock = s;
@@ -1171,7 +1153,6 @@ static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
rc = make_server_pipes_struct(ncacn_conn,
pipe_name,
- ncacn_conn->syntax_id,
ncacn_conn->transport,
system_user,
cli_str,
diff --git a/source3/rpc_server/rpc_server.h b/source3/rpc_server/rpc_server.h
index 3791589bb64..aafc96238a5 100644
--- a/source3/rpc_server/rpc_server.h
+++ b/source3/rpc_server/rpc_server.h
@@ -20,6 +20,8 @@
#ifndef _RPC_SERVER_H_
#define _RPC_SERVER_H_
+struct pipes_struct;
+
typedef bool (*dcerpc_ncacn_disconnect_fn)(struct pipes_struct *p);
void set_incoming_fault(struct pipes_struct *p);
@@ -29,13 +31,11 @@ bool setup_named_pipe_socket(const char *pipe_name,
uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
const struct sockaddr_storage *ifss,
uint16_t port);
bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
const char *name,
dcerpc_ncacn_disconnect_fn fn);
diff --git a/source3/rpc_server/samr/srv_samr_nt.c b/source3/rpc_server/samr/srv_samr_nt.c
index 99dd3f4d585..a253f307ac6 100644
--- a/source3/rpc_server/samr/srv_samr_nt.c
+++ b/source3/rpc_server/samr/srv_samr_nt.c
@@ -33,8 +33,8 @@
#include "includes.h"
#include "system/passwd.h"
-#include "smbd/globals.h"
#include "../libcli/auth/libcli_auth.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_samr.h"
#include "rpc_server/samr/srv_samr_util.h"
#include "../lib/crypto/arcfour.h"
@@ -43,7 +43,6 @@
#include "../libcli/security/security.h"
#include "passdb.h"
#include "auth.h"
-#include "ntdomain.h"
#include "rpc_server/srv_access_check.h"
#undef DBGC_CLASS
@@ -785,7 +784,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- sam = TALLOC_ZERO_ARRAY(ctx, struct samr_SamEntry, num_entries);
+ sam = talloc_zero_array(ctx, struct samr_SamEntry, num_entries);
if (sam == NULL) {
DEBUG(0, ("make_user_sam_entry_list: TALLOC_ZERO failed!\n"));
return NT_STATUS_NO_MEMORY;
@@ -843,7 +842,7 @@ NTSTATUS _samr_EnumDomainUsers(struct pipes_struct *p,
return status;
}
- samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray);
+ samr_array = talloc_zero(p->mem_ctx, struct samr_SamArray);
if (!samr_array) {
return NT_STATUS_NO_MEMORY;
}
@@ -939,7 +938,7 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx,
return;
}
- sam = TALLOC_ZERO_ARRAY(ctx, struct samr_SamEntry, num_sam_entries);
+ sam = talloc_zero_array(ctx, struct samr_SamEntry, num_sam_entries);
if (sam == NULL) {
return;
}
@@ -978,7 +977,7 @@ NTSTATUS _samr_EnumDomainGroups(struct pipes_struct *p,
DEBUG(5,("_samr_EnumDomainGroups: %d\n", __LINE__));
- samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray);
+ samr_array = talloc_zero(p->mem_ctx, struct samr_SamArray);
if (!samr_array) {
return NT_STATUS_NO_MEMORY;
}
@@ -1056,7 +1055,7 @@ NTSTATUS _samr_EnumDomainAliases(struct pipes_struct *p,
DEBUG(5,("_samr_EnumDomainAliases: sid %s\n",
sid_string_dbg(&dinfo->sid)));
- samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray);
+ samr_array = talloc_zero(p->mem_ctx, struct samr_SamArray);
if (!samr_array) {
return NT_STATUS_NO_MEMORY;
}
@@ -1121,7 +1120,7 @@ static NTSTATUS init_samr_dispinfo_1(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryGeneral, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryGeneral, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1165,7 +1164,7 @@ static NTSTATUS init_samr_dispinfo_2(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryFull, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryFull, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1206,7 +1205,7 @@ static NTSTATUS init_samr_dispinfo_3(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryFullGroup, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryFullGroup, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1247,7 +1246,7 @@ static NTSTATUS init_samr_dispinfo_4(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryAscii, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryAscii, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1283,7 +1282,7 @@ static NTSTATUS init_samr_dispinfo_5(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryAscii, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryAscii, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1579,7 +1578,7 @@ NTSTATUS _samr_QueryAliasInfo(struct pipes_struct *p,
return status;
}
- alias_info = TALLOC_ZERO_P(p->mem_ctx, union samr_AliasInfo);
+ alias_info = talloc_zero(p->mem_ctx, union samr_AliasInfo);
if (!alias_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -1985,12 +1984,12 @@ NTSTATUS _samr_ChangePasswordUser3(struct pipes_struct *p,
time_t u_expire, u_min_age;
uint32 account_policy_temp;
- dominfo = TALLOC_ZERO_P(p->mem_ctx, struct samr_DomInfo1);
+ dominfo = talloc_zero(p->mem_ctx, struct samr_DomInfo1);
if (!dominfo) {
return NT_STATUS_NO_MEMORY;
}
- reject = TALLOC_ZERO_P(p->mem_ctx,
+ reject = talloc_zero(p->mem_ctx,
struct userPwdChangeFailureInformation);
if (!reject) {
return NT_STATUS_NO_MEMORY;
@@ -2051,7 +2050,7 @@ static bool make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names,
*lsa_name_array_p = NULL;
if (num_names != 0) {
- lsa_name_array = TALLOC_ZERO_ARRAY(ctx, struct lsa_String, num_names);
+ lsa_name_array = talloc_zero_array(ctx, struct lsa_String, num_names);
if (!lsa_name_array) {
return false;
}
@@ -2101,9 +2100,9 @@ NTSTATUS _samr_LookupRids(struct pipes_struct *p,
}
if (num_rids) {
- names = TALLOC_ZERO_ARRAY(p->mem_ctx, const char *, num_rids);
- attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, enum lsa_SidType, num_rids);
- wire_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids);
+ names = talloc_zero_array(p->mem_ctx, const char *, num_rids);
+ attrs = talloc_zero_array(p->mem_ctx, enum lsa_SidType, num_rids);
+ wire_attrs = talloc_zero_array(p->mem_ctx, uint32, num_rids);
if ((names == NULL) || (attrs == NULL) || (wire_attrs==NULL))
return NT_STATUS_NO_MEMORY;
@@ -2289,12 +2288,12 @@ static NTSTATUS init_samr_parameters_string(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
- r = TALLOC_ZERO_P(mem_ctx, struct lsa_BinaryString);
+ r = talloc_zero(mem_ctx, struct lsa_BinaryString);
if (!r) {
return NT_STATUS_NO_MEMORY;
}
- r->array = TALLOC_ZERO_ARRAY(mem_ctx, uint16_t, blob->length/2);
+ r->array = talloc_zero_array(mem_ctx, uint16_t, blob->length/2);
if (!r->array) {
return NT_STATUS_NO_MEMORY;
}
@@ -2988,7 +2987,7 @@ NTSTATUS _samr_QueryUserInfo(struct pipes_struct *p,
DEBUG(5,("_samr_QueryUserInfo: sid:%s\n",
sid_string_dbg(&uinfo->sid)));
- user_info = TALLOC_ZERO_P(p->mem_ctx, union samr_UserInfo);
+ user_info = talloc_zero(p->mem_ctx, union samr_UserInfo);
if (!user_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -3150,7 +3149,7 @@ NTSTATUS _samr_GetGroupsForUser(struct pipes_struct *p,
return result;
}
- rids = TALLOC_ZERO_P(p->mem_ctx, struct samr_RidWithAttributeArray);
+ rids = talloc_zero(p->mem_ctx, struct samr_RidWithAttributeArray);
if (!rids) {
return NT_STATUS_NO_MEMORY;
}
@@ -3324,7 +3323,7 @@ static NTSTATUS query_dom_info_2(TALLOC_CTX *mem_ctx,
r->oem_information.string = lp_serverstring();
r->domain_name.string = lp_workgroup();
- r->primary.string = global_myname();
+ r->primary.string = lp_netbios_name();
r->sequence_num = seq_num;
r->domain_server_state = DOMAIN_SERVER_ENABLED;
r->role = (enum samr_Role) samr_get_server_role();
@@ -3391,7 +3390,7 @@ static NTSTATUS query_dom_info_6(TALLOC_CTX *mem_ctx,
/* NT returns its own name when a PDC. win2k and later
* only the name of the PDC if itself is a BDC (samba4
* idl) */
- r->primary.string = global_myname();
+ r->primary.string = lp_netbios_name();
return NT_STATUS_OK;
}
@@ -3599,7 +3598,7 @@ NTSTATUS _samr_QueryDomainInfo(struct pipes_struct *p,
return status;
}
- dom_info = TALLOC_ZERO_P(p->mem_ctx, union samr_DomainInfo);
+ dom_info = talloc_zero(p->mem_ctx, union samr_DomainInfo);
if (!dom_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -4055,7 +4054,7 @@ NTSTATUS _samr_LookupDomain(struct pipes_struct *p,
return NT_STATUS_INVALID_PARAMETER;
}
- sid = TALLOC_ZERO_P(p->mem_ctx, struct dom_sid2);
+ sid = talloc_zero(p->mem_ctx, struct dom_sid2);
if (!sid) {
return NT_STATUS_NO_MEMORY;
}
@@ -4096,12 +4095,12 @@ NTSTATUS _samr_EnumDomains(struct pipes_struct *p,
return status;
}
- sam = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray);
+ sam = talloc_zero(p->mem_ctx, struct samr_SamArray);
if (!sam) {
return NT_STATUS_NO_MEMORY;
}
- entry_array = TALLOC_ZERO_ARRAY(p->mem_ctx,
+ entry_array = talloc_zero_array(p->mem_ctx,
struct samr_SamEntry,
num_entries);
if (!entry_array) {
@@ -5299,7 +5298,7 @@ NTSTATUS _samr_GetAliasMembership(struct pipes_struct *p,
return NT_STATUS_OBJECT_TYPE_MISMATCH;
if (r->in.sids->num_sids) {
- members = TALLOC_ARRAY(p->mem_ctx, struct dom_sid, r->in.sids->num_sids);
+ members = talloc_array(p->mem_ctx, struct dom_sid, r->in.sids->num_sids);
if (members == NULL)
return NT_STATUS_NO_MEMORY;
@@ -5370,7 +5369,7 @@ NTSTATUS _samr_GetMembersInAlias(struct pipes_struct *p,
}
if (num_sids) {
- sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_SidPtr, num_sids);
+ sids = talloc_zero_array(p->mem_ctx, struct lsa_SidPtr, num_sids);
if (sids == NULL) {
TALLOC_FREE(pdb_sids);
return NT_STATUS_NO_MEMORY;
@@ -5416,7 +5415,7 @@ NTSTATUS _samr_QueryGroupMember(struct pipes_struct *p,
return status;
}
- rids = TALLOC_ZERO_P(p->mem_ctx, struct samr_RidAttrArray);
+ rids = talloc_zero(p->mem_ctx, struct samr_RidAttrArray);
if (!rids) {
return NT_STATUS_NO_MEMORY;
}
@@ -5440,7 +5439,7 @@ NTSTATUS _samr_QueryGroupMember(struct pipes_struct *p,
return status;
if (num_members) {
- attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_members);
+ attr=talloc_zero_array(p->mem_ctx, uint32, num_members);
if (attr == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -5955,7 +5954,7 @@ NTSTATUS _samr_QueryGroupInfo(struct pipes_struct *p,
group_name = talloc_strdup(r, map.nt_name);
group_description = talloc_strdup(r, map.comment);
- info = TALLOC_ZERO_P(p->mem_ctx, union samr_GroupInfo);
+ info = talloc_zero(p->mem_ctx, union samr_GroupInfo);
if (!info) {
return NT_STATUS_NO_MEMORY;
}
@@ -6133,7 +6132,7 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
/* make sure the name doesn't already exist as a user
or local group */
- fstr_sprintf( group_name, "%s\\%s", global_myname(), info.acct_name );
+ fstr_sprintf( group_name, "%s\\%s", lp_netbios_name(), info.acct_name );
status = can_create( p->mem_ctx, group_name );
if ( !NT_STATUS_IS_OK( status ) )
return status;
diff --git a/source3/rpc_server/samr/srv_samr_util.c b/source3/rpc_server/samr/srv_samr_util.c
index 29123321f86..d052846b2e5 100644
--- a/source3/rpc_server/samr/srv_samr_util.c
+++ b/source3/rpc_server/samr/srv_samr_util.c
@@ -612,7 +612,16 @@ void copy_id21_to_sam_passwd(const char *log_prefix,
DEBUG(10,("%s SAMR_FIELD_EXPIRED_FLAG: %02X\n", l,
from->password_expired));
if (from->password_expired != 0) {
- pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
+ /* Only allow the set_time to zero (which means
+ "User Must Change Password on Next Login"
+ if the user object allows password change. */
+ if (pdb_get_pass_can_change(to)) {
+ pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
+ } else {
+ DEBUG(10,("%s Disallowing set of 'User Must "
+ "Change Password on Next Login' as "
+ "user object disallows this.\n", l));
+ }
} else {
/* A subtlety here: some windows commands will
clear the expired flag even though it's not
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 312f50965b7..8216388905f 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -28,6 +28,7 @@
up, all the errors returned are DOS errors, not NT status codes. */
#include "includes.h"
+#include "ntdomain.h"
#include "nt_printing.h"
#include "srv_spoolss_util.h"
#include "../librpc/gen_ndr/srv_spoolss.h"
@@ -46,9 +47,13 @@
#include "serverid.h"
#include "../libcli/registry/util_reg.h"
#include "smbd/smbd.h"
+#include "smbd/globals.h"
#include "auth.h"
#include "messages.h"
-#include "ntdomain.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
+#include "util_tdb.h"
+#include "libsmb/libsmb.h"
+#include "printing/printer_list.h"
/* macros stolen from s4 spoolss server */
#define SPOOLSS_BUFFER_UNION(fn,info,level) \
@@ -574,7 +579,7 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename,
(unsigned long)strlen(handlename)));
- aprinter = CONST_DISCARD(char *, handlename);
+ aprinter = discard_const_p(char, handlename);
if ( *handlename == '\\' ) {
servername = canon_servername(handlename);
if ( (aprinter = strchr_m( servername, '\\' )) != NULL ) {
@@ -726,7 +731,7 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s\n", aprinter, sname));
- fstrcpy(Printer->sharename, sname);
+ strlcpy(Printer->sharename, sname, sizeof(Printer->sharename));
return WERR_OK;
}
@@ -1089,7 +1094,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS
if ( i == ctr->num_groups ) {
ctr->num_groups++;
- if ( !(groups = TALLOC_REALLOC_ARRAY( ctr->ctx, ctr->msg_groups, SPOOLSS_NOTIFY_MSG_GROUP, ctr->num_groups)) ) {
+ if ( !(groups = talloc_realloc( ctr->ctx, ctr->msg_groups, SPOOLSS_NOTIFY_MSG_GROUP, ctr->num_groups)) ) {
DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed!\n"));
return 0;
}
@@ -1107,7 +1112,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS
msg_grp->num_msgs++;
- if ( !(msg_list = TALLOC_REALLOC_ARRAY( ctr->ctx, msg_grp->msgs, SPOOLSS_NOTIFY_MSG, msg_grp->num_msgs )) ) {
+ if ( !(msg_list = talloc_realloc( ctr->ctx, msg_grp->msgs, SPOOLSS_NOTIFY_MSG, msg_grp->num_msgs )) ) {
DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed for new message [%d]!\n", msg_grp->num_msgs));
return 0;
}
@@ -1120,7 +1125,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS
if ( msg->len != 0 )
msg_grp->msgs[new_slot].notify.data = (char *)
- TALLOC_MEMDUP( ctr->ctx, msg->notify.data, msg->len );
+ talloc_memdup( ctr->ctx, msg->notify.data, msg->len );
return ctr->num_groups;
}
@@ -1500,7 +1505,7 @@ static bool srv_spoolss_drv_upgrade_printer(const char *drivername,
messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx),
MSG_PRINTER_DRVUPGRADE,
- (uint8_t *)drivername, len+1);
+ (const uint8_t *)drivername, len+1);
return true;
}
@@ -2335,32 +2340,32 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
{
DEBUG(8,("getprinterdata_printer_server:%s\n", value));
- if (!StrCaseCmp(value, "W3SvcInstalled")) {
+ if (!strcasecmp_m(value, "W3SvcInstalled")) {
*type = REG_DWORD;
data->value = 0x00;
return WERR_OK;
}
- if (!StrCaseCmp(value, "BeepEnabled")) {
+ if (!strcasecmp_m(value, "BeepEnabled")) {
*type = REG_DWORD;
data->value = 0x00;
return WERR_OK;
}
- if (!StrCaseCmp(value, "EventLog")) {
+ if (!strcasecmp_m(value, "EventLog")) {
*type = REG_DWORD;
/* formally was 0x1b */
data->value = 0x00;
return WERR_OK;
}
- if (!StrCaseCmp(value, "NetPopup")) {
+ if (!strcasecmp_m(value, "NetPopup")) {
*type = REG_DWORD;
data->value = 0x00;
return WERR_OK;
}
- if (!StrCaseCmp(value, "MajorVersion")) {
+ if (!strcasecmp_m(value, "MajorVersion")) {
*type = REG_DWORD;
/* Windows NT 4.0 seems to not allow uploading of drivers
@@ -2377,7 +2382,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- if (!StrCaseCmp(value, "MinorVersion")) {
+ if (!strcasecmp_m(value, "MinorVersion")) {
*type = REG_DWORD;
data->value = 0x00;
return WERR_OK;
@@ -2390,7 +2395,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
* uint32_t build = [2195|2600]
* extra unicode string = e.g. "Service Pack 3"
*/
- if (!StrCaseCmp(value, "OSVersion")) {
+ if (!strcasecmp_m(value, "OSVersion")) {
DATA_BLOB blob;
enum ndr_err_code ndr_err;
struct spoolss_OSVersion os;
@@ -2413,7 +2418,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
}
- if (!StrCaseCmp(value, "DefaultSpoolDirectory")) {
+ if (!strcasecmp_m(value, "DefaultSpoolDirectory")) {
*type = REG_SZ;
data->string = talloc_strdup(mem_ctx, "C:\\PRINTERS");
@@ -2422,7 +2427,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- if (!StrCaseCmp(value, "Architecture")) {
+ if (!strcasecmp_m(value, "Architecture")) {
*type = REG_SZ;
data->string = talloc_strdup(mem_ctx,
lp_parm_const_string(GLOBAL_SECTION_SNUM, "spoolss", "architecture", SPOOLSS_ARCHITECTURE_NT_X86));
@@ -2431,7 +2436,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- if (!StrCaseCmp(value, "DsPresent")) {
+ if (!strcasecmp_m(value, "DsPresent")) {
*type = REG_DWORD;
/* only show the publish check box if we are a
@@ -2445,7 +2450,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- if (!StrCaseCmp(value, "DNSMachineName")) {
+ if (!strcasecmp_m(value, "DNSMachineName")) {
const char *hostname = get_mydnsfullname();
if (!hostname) {
@@ -2518,7 +2523,7 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
}
/* setup the connection */
- ret = cli_full_connection( &the_cli, global_myname(), remote_machine,
+ ret = cli_full_connection( &the_cli, lp_netbios_name(), remote_machine,
&rm_addr, 0, "IPC$", "IPC",
"", /* username */
"", /* domain */
@@ -2876,7 +2881,21 @@ static void spoolss_notify_location(struct messaging_context *msg_ctx,
struct spoolss_PrinterInfo2 *pinfo2,
TALLOC_CTX *mem_ctx)
{
- SETUP_SPOOLSS_NOTIFY_DATA_STRING(data, pinfo2->location);
+ const char *loc = pinfo2->location;
+ NTSTATUS status;
+
+ status = printer_list_get_printer(mem_ctx,
+ pinfo2->sharename,
+ NULL,
+ &loc,
+ NULL);
+ if (NT_STATUS_IS_OK(status)) {
+ if (loc == NULL) {
+ loc = pinfo2->location;
+ }
+ }
+
+ SETUP_SPOOLSS_NOTIFY_DATA_STRING(data, loc);
}
/*******************************************************************
@@ -3404,7 +3423,6 @@ static bool construct_notify_printer_info(struct messaging_context *msg_ctx,
uint16_t field;
struct spoolss_Notify *current_data;
- print_queue_struct *queue=NULL;
type = option_type->type;
@@ -3420,7 +3438,7 @@ static bool construct_notify_printer_info(struct messaging_context *msg_ctx,
if (!search_notify(type, field, &j) )
continue;
- info->notifies = TALLOC_REALLOC_ARRAY(info, info->notifies,
+ info->notifies = talloc_realloc(info, info->notifies,
struct spoolss_Notify,
info->count + 1);
if (info->notifies == NULL) {
@@ -3438,7 +3456,7 @@ static bool construct_notify_printer_info(struct messaging_context *msg_ctx,
pinfo2->printername));
notify_info_data_table[j].fn(msg_ctx, snum, current_data,
- queue, pinfo2, mem_ctx);
+ NULL, pinfo2, mem_ctx);
info->count++;
}
@@ -3480,7 +3498,7 @@ static bool construct_notify_jobs_info(struct messaging_context *msg_ctx,
if (!search_notify(type, field, &j) )
continue;
- info->notifies = TALLOC_REALLOC_ARRAY(info, info->notifies,
+ info->notifies = talloc_realloc(info, info->notifies,
struct spoolss_Notify,
info->count + 1);
if (info->notifies == NULL) {
@@ -4009,8 +4027,24 @@ static WERROR construct_printer_info2(TALLOC_CTX *mem_ctx,
}
W_ERROR_HAVE_NO_MEMORY(r->comment);
- r->location = talloc_strdup(mem_ctx, info2->location);
+ r->location = talloc_strdup(mem_ctx, info2->location);
+ if (info2->location[0] == '\0') {
+ const char *loc = NULL;
+ NTSTATUS nt_status;
+
+ nt_status = printer_list_get_printer(mem_ctx,
+ info2->sharename,
+ NULL,
+ &loc,
+ NULL);
+ if (NT_STATUS_IS_OK(nt_status)) {
+ if (loc != NULL) {
+ r->location = talloc_strdup(mem_ctx, loc);
+ }
+ }
+ }
W_ERROR_HAVE_NO_MEMORY(r->location);
+
r->sepfile = talloc_strdup(mem_ctx, info2->sepfile);
W_ERROR_HAVE_NO_MEMORY(r->sepfile);
r->printprocessor = talloc_strdup(mem_ctx, info2->printprocessor);
@@ -4145,10 +4179,9 @@ static WERROR construct_printer_info6(TALLOC_CTX *mem_ctx,
struct spoolss_PrinterInfo6 *r,
int snum)
{
- int count;
print_status_struct status;
- count = print_queue_length(msg_ctx, snum, &status);
+ print_queue_length(msg_ctx, snum, &status);
r->status = nt_printq_status(status.status);
@@ -4274,7 +4307,7 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
goto out;
}
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
union spoolss_PrinterInfo,
count + 1);
if (!info) {
@@ -5314,7 +5347,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
*count_p = 0;
if (strlen(driver->driver_path)) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -5329,7 +5362,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
}
if (strlen(driver->config_file)) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -5344,7 +5377,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
}
if (strlen(driver->data_file)) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -5359,7 +5392,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
}
if (strlen(driver->help_file)) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -5374,7 +5407,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
}
for (i=0; driver->dependent_files[i] && driver->dependent_files[i][0] != '\0'; i++) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -6004,7 +6037,7 @@ static bool check_printer_ok(TALLOC_CTX *mem_ctx,
info2->location));
/* we force some elements to "correct" values */
- info2->servername = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
+ info2->servername = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
if (info2->servername == NULL) {
return false;
}
@@ -6016,7 +6049,7 @@ static bool check_printer_ok(TALLOC_CTX *mem_ctx,
/* check to see if we allow printername != sharename */
if (lp_force_printername(snum)) {
info2->printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
- global_myname(), info2->sharename);
+ lp_netbios_name(), info2->sharename);
} else {
/* make sure printername is in \\server\printername format */
fstrcpy(printername, info2->printername);
@@ -6027,7 +6060,7 @@ static bool check_printer_ok(TALLOC_CTX *mem_ctx,
}
info2->printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
- global_myname(), p);
+ lp_netbios_name(), p);
}
if (info2->printername == NULL) {
return false;
@@ -6413,7 +6446,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
buffer.length);
}
- push_reg_sz(mem_ctx, &buffer, global_myname());
+ push_reg_sz(mem_ctx, &buffer, lp_netbios_name());
winreg_set_printer_dataex(mem_ctx,
session_info,
msg_ctx,
@@ -6428,7 +6461,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
if (dnsdomname != NULL && dnsdomname[0] != '\0') {
longname = talloc_strdup(mem_ctx, dnsdomname);
} else {
- longname = talloc_strdup(mem_ctx, global_myname());
+ longname = talloc_strdup(mem_ctx, lp_netbios_name());
}
if (longname == NULL) {
result = WERR_NOMEM;
@@ -6447,7 +6480,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
buffer.length);
uncname = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
- global_myname(), printer->sharename);
+ lp_netbios_name(), printer->sharename);
push_reg_sz(mem_ctx, &buffer, uncname);
winreg_set_printer_dataex(mem_ctx,
session_info,
@@ -6891,7 +6924,7 @@ static WERROR enumjobs_level1(TALLOC_CTX *mem_ctx,
int i;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_JobInfo, num_queues);
+ info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues);
W_ERROR_HAVE_NO_MEMORY(info);
*count = num_queues;
@@ -6935,7 +6968,7 @@ static WERROR enumjobs_level2(TALLOC_CTX *mem_ctx,
int i;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_JobInfo, num_queues);
+ info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues);
W_ERROR_HAVE_NO_MEMORY(info);
*count = num_queues;
@@ -6990,7 +7023,7 @@ static WERROR enumjobs_level3(TALLOC_CTX *mem_ctx,
int i;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_JobInfo, num_queues);
+ info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues);
W_ERROR_HAVE_NO_MEMORY(info);
*count = num_queues;
@@ -7259,7 +7292,7 @@ static WERROR enumprinterdrivers_level_by_architecture(TALLOC_CTX *mem_ctx,
num_drivers, architecture, version));
if (num_drivers != 0) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
union spoolss_DriverInfo,
count + num_drivers);
if (!info) {
@@ -7599,7 +7632,7 @@ static WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines)
/* if no hook then just fill in the default port */
if ( !*cmd ) {
- if (!(qlines = TALLOC_ARRAY( NULL, char*, 2 ))) {
+ if (!(qlines = talloc_array( NULL, char*, 2 ))) {
return WERR_NOMEM;
}
if (!(qlines[0] = talloc_strdup(qlines, SAMBA_PRINTER_PORT_NAME ))) {
@@ -7660,7 +7693,7 @@ static WERROR enumports_level_1(TALLOC_CTX *mem_ctx,
}
if (numlines) {
- info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines);
+ info = talloc_array(mem_ctx, union spoolss_PortInfo, numlines);
if (!info) {
DEBUG(10,("Returning WERR_NOMEM\n"));
result = WERR_NOMEM;
@@ -7712,7 +7745,7 @@ static WERROR enumports_level_2(TALLOC_CTX *mem_ctx,
}
if (numlines) {
- info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines);
+ info = talloc_array(mem_ctx, union spoolss_PortInfo, numlines);
if (!info) {
DEBUG(10,("Returning WERR_NOMEM\n"));
result = WERR_NOMEM;
@@ -8011,12 +8044,12 @@ WERROR _spoolss_AddPrinterDriverEx(struct pipes_struct *p,
}
DEBUG(5,("Cleaning driver's information\n"));
- err = clean_up_driver_struct(p->mem_ctx, p, r->in.info_ctr);
+ err = clean_up_driver_struct(p->mem_ctx, p->session_info, r->in.info_ctr);
if (!W_ERROR_IS_OK(err))
goto done;
DEBUG(5,("Moving driver to final destination\n"));
- err = move_driver_to_download_area(p, r->in.info_ctr);
+ err = move_driver_to_download_area(p->session_info, r->in.info_ctr);
if (!W_ERROR_IS_OK(err)) {
goto done;
}
@@ -8639,7 +8672,7 @@ static WERROR enumprintprocessors_level_1(TALLOC_CTX *mem_ctx,
union spoolss_PrintProcessorInfo *info;
WERROR result;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_PrintProcessorInfo, 1);
+ info = talloc_array(mem_ctx, union spoolss_PrintProcessorInfo, 1);
W_ERROR_HAVE_NO_MEMORY(info);
*count = 1;
@@ -8741,7 +8774,7 @@ static WERROR enumprintprocdatatypes_level_1(TALLOC_CTX *mem_ctx,
WERROR result;
union spoolss_PrintProcDataTypesInfo *info;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_PrintProcDataTypesInfo, 1);
+ info = talloc_array(mem_ctx, union spoolss_PrintProcDataTypesInfo, 1);
W_ERROR_HAVE_NO_MEMORY(info);
*count = 1;
@@ -8798,6 +8831,10 @@ WERROR _spoolss_EnumPrintProcDataTypes(struct pipes_struct *p,
return WERR_UNKNOWN_LEVEL;
}
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
*r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(p->mem_ctx,
spoolss_EnumPrintProcDataTypes,
*r->out.info, r->in.level,
@@ -8853,7 +8890,7 @@ static WERROR enumprintmonitors_level_1(TALLOC_CTX *mem_ctx,
union spoolss_MonitorInfo *info;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_MonitorInfo, 2);
+ info = talloc_array(mem_ctx, union spoolss_MonitorInfo, 2);
W_ERROR_HAVE_NO_MEMORY(info);
*count = 2;
@@ -8893,7 +8930,7 @@ static WERROR enumprintmonitors_level_2(TALLOC_CTX *mem_ctx,
union spoolss_MonitorInfo *info;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_MonitorInfo, 2);
+ info = talloc_array(mem_ctx, union spoolss_MonitorInfo, 2);
W_ERROR_HAVE_NO_MEMORY(info);
*count = 2;
@@ -9154,9 +9191,9 @@ WERROR _spoolss_GetPrinterDataEx(struct pipes_struct *p,
int snum = 0;
WERROR result = WERR_OK;
DATA_BLOB blob;
- enum winreg_Type val_type;
- uint8_t *val_data;
- uint32_t val_size;
+ enum winreg_Type val_type = REG_NONE;
+ uint8_t *val_data = NULL;
+ uint32_t val_size = 0;
DEBUG(4,("_spoolss_GetPrinterDataEx\n"));
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.h b/source3/rpc_server/spoolss/srv_spoolss_nt.h
new file mode 100644
index 00000000000..d6d141a5e8f
--- /dev/null
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.h
@@ -0,0 +1,40 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-2000,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
+ * Copyright (C) Jean François Micouleau 1998-2000,
+ * Copyright (C) Jeremy Allison 2001-2002,
+ * Copyright (C) Gerald Carter 2000-2004,
+ * Copyright (C) Tim Potter 2001-2002.
+ * Copyright (C) Guenther Deschner 2009-2010.
+ * Copyright (C) Andreas Schneider 2010.
+ *
+ * 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 _RPC_SERVER_SPOOLSS_SRV_SPOOLSS_NT_H_
+#define _RPC_SERVER_SPOOLSS_SRV_SPOOLSS_NT_H_
+
+/* The following definitions come from rpc_server/srv_spoolss_nt.c */
+void srv_spoolss_cleanup(void);
+
+void do_drv_upgrade_printer(struct messaging_context *msg,
+ void *private_data,
+ uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data);
+void update_monitored_printq_cache(struct messaging_context *msg_ctx);
+
+#endif /* _RPC_SERVER_SPOOLSS_SRV_SPOOLSS_NT_H_ */
diff --git a/source3/rpc_server/spoolss/srv_spoolss_util.c b/source3/rpc_server/spoolss/srv_spoolss_util.c
index 9e9e253dd71..5201571a372 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_util.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_util.c
@@ -23,7 +23,6 @@
#include "nt_printing.h"
#include "srv_spoolss_util.h"
#include "../librpc/gen_ndr/ndr_spoolss.h"
-#include "../librpc/gen_ndr/srv_winreg.h"
#include "../librpc/gen_ndr/ndr_winreg_c.h"
#include "../librpc/gen_ndr/ndr_security.h"
#include "secrets.h"
@@ -450,7 +449,7 @@ static WERROR winreg_printer_enumvalues(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- enum_values = TALLOC_ARRAY(tmp_ctx, struct spoolss_PrinterEnumValues, num_values);
+ enum_values = talloc_array(tmp_ctx, struct spoolss_PrinterEnumValues, num_values);
if (enum_values == NULL) {
result = WERR_NOMEM;
goto error;
@@ -472,7 +471,7 @@ static WERROR winreg_printer_enumvalues(TALLOC_CTX *mem_ctx,
data_size = max_valbufsize;
data = NULL;
if (data_size) {
- data = (uint8_t *) TALLOC(tmp_ctx, data_size);
+ data = (uint8_t *) talloc_zero_size(tmp_ctx, data_size);
}
length = 0;
@@ -1048,7 +1047,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
winreg_handle,
&key_hnd,
SPOOL_REG_SHORTSERVERNAME,
- global_myname(),
+ lp_netbios_name(),
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
@@ -1063,9 +1062,9 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
*/
dnssuffix = get_mydnsdomname(tmp_ctx);
if (dnssuffix != NULL && dnssuffix[0] != '\0') {
- longname = talloc_asprintf(tmp_ctx, "%s.%s", global_myname(), dnssuffix);
+ longname = talloc_asprintf(tmp_ctx, "%s.%s", lp_netbios_name(), dnssuffix);
} else {
- longname = talloc_strdup(tmp_ctx, global_myname());
+ longname = talloc_strdup(tmp_ctx, lp_netbios_name());
}
if (longname == NULL) {
result = WERR_NOMEM;
@@ -2316,9 +2315,9 @@ WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
struct dcerpc_binding_handle *winreg_handle = NULL;
struct policy_handle hive_hnd, key_hnd;
struct winreg_String wvalue;
- enum winreg_Type type_in;
+ enum winreg_Type type_in = REG_NONE;
char *path;
- uint8_t *data_in;
+ uint8_t *data_in = NULL;
uint32_t data_in_size = 0;
uint32_t value_len = 0;
WERROR result = WERR_OK;
@@ -3085,7 +3084,7 @@ WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
goto done;
}
- info = TALLOC_ARRAY(tmp_ctx, union spoolss_FormInfo, num_builtin + num_values);
+ info = talloc_array(tmp_ctx, union spoolss_FormInfo, num_builtin + num_values);
if (info == NULL) {
result = WERR_NOMEM;
goto done;
@@ -3338,8 +3337,8 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
struct dcerpc_binding_handle *winreg_handle = NULL;
struct policy_handle hive_hnd, key_hnd;
struct winreg_String wvalue;
- enum winreg_Type type_in;
- uint8_t *data_in;
+ enum winreg_Type type_in = REG_NONE;
+ uint8_t *data_in = NULL;
uint32_t data_in_size = 0;
uint32_t value_len = 0;
uint32_t num_builtin = ARRAY_SIZE(builtin_forms1);
diff --git a/source3/rpc_server/srv_access_check.h b/source3/rpc_server/srv_access_check.h
index 27a09bd0074..72ce539568e 100644
--- a/source3/rpc_server/srv_access_check.h
+++ b/source3/rpc_server/srv_access_check.h
@@ -1,3 +1,35 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997,
+ * Copyright (C) Marc Jacobsen 1999,
+ * Copyright (C) Jeremy Allison 2001-2008,
+ * Copyright (C) Jean François Micouleau 1998-2001,
+ * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002,
+ * Copyright (C) Gerald (Jerry) Carter 2003-2004,
+ * Copyright (C) Simo Sorce 2003.
+ * Copyright (C) Volker Lendecke 2005.
+ * Copyright (C) Guenther Deschner 2008.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _RPC_SERVER_SRV_ACCESS_CHECK_H_
+#define _RPC_SERVER_SRV_ACCESS_CHECK_H_
+
/* The following definitions come from rpc_server/srv_access_check.c */
NTSTATUS access_check_object( struct security_descriptor *psd, struct security_token *token,
@@ -8,3 +40,5 @@ NTSTATUS access_check_object( struct security_descriptor *psd, struct security_t
void map_max_allowed_access(const struct security_token *nt_token,
const struct security_unix_token *unix_token,
uint32_t *pacc_requested);
+
+#endif /* _RPC_SERVER_SRV_ACCESS_CHECK_H_ */
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index 27a7aaeaf47..fc08d56b1e9 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -41,6 +41,8 @@
#include "smbd/smbd.h"
#include "auth.h"
#include "ntdomain.h"
+#include "rpc_server/srv_pipe.h"
+#include "rpc_server/rpc_contexts.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -330,23 +332,30 @@ bool setup_fault_pdu(struct pipes_struct *p, NTSTATUS fault_status)
static bool check_bind_req(struct pipes_struct *p,
struct ndr_syntax_id* abstract,
struct ndr_syntax_id* transfer,
- uint32 context_id)
+ uint32_t context_id)
{
struct pipe_rpc_fns *context_fns;
+ bool ok;
DEBUG(3,("check_bind_req for %s\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ get_pipe_name_from_syntax(talloc_tos(), abstract)));
/* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */
if (rpc_srv_pipe_exists_by_id(abstract) &&
ndr_syntax_id_equal(transfer, &ndr_transfer_syntax)) {
- DEBUG(3, ("check_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n",
- rpc_srv_get_pipe_cli_name(abstract),
- rpc_srv_get_pipe_srv_name(abstract)));
+ DEBUG(3, ("check_bind_req: %s -> %s rpc service\n",
+ rpc_srv_get_pipe_cli_name(abstract),
+ rpc_srv_get_pipe_srv_name(abstract)));
} else {
return false;
}
+ ok = init_pipe_handles(p, abstract);
+ if (!ok) {
+ DEBUG(1, ("Failed to init pipe handles!\n"));
+ return false;
+ }
+
context_fns = SMB_MALLOC_P(struct pipe_rpc_fns);
if (context_fns == NULL) {
DEBUG(0,("check_bind_req: malloc() failed!\n"));
@@ -357,6 +366,7 @@ static bool check_bind_req(struct pipes_struct *p,
context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(abstract);
context_fns->cmds = rpc_srv_get_pipe_cmds(abstract);
context_fns->context_id = context_id;
+ context_fns->syntax = *abstract;
/* add to the list of open contexts */
@@ -615,14 +625,12 @@ static bool pipe_ntlmssp_verify_final(TALLOC_CTX *mem_ctx,
struct auth_ntlmssp_state *ntlmssp_ctx,
enum dcerpc_AuthLevel auth_level,
struct client_address *client_id,
- struct ndr_syntax_id *syntax,
struct auth_serversupplied_info **session_info)
{
NTSTATUS status;
bool ret;
- DEBUG(5, (__location__ ": pipe %s checking user details\n",
- get_pipe_name_from_syntax(talloc_tos(), syntax)));
+ DEBUG(5, (__location__ ": checking user details\n"));
/* Finally - if the pipe negotiated integrity (sign) or privacy (seal)
ensure the underlying NTLMSSP flags are also set. If not we should
@@ -635,8 +643,7 @@ static bool pipe_ntlmssp_verify_final(TALLOC_CTX *mem_ctx,
DCERPC_AUTH_LEVEL_PRIVACY));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, (__location__ ": Client failed to negotatie proper "
- "security for pipe %s\n",
- get_pipe_name_from_syntax(talloc_tos(), syntax)));
+ "security for rpc connection\n"));
return false;
}
@@ -767,7 +774,7 @@ static NTSTATUS pipe_auth_verify_final(struct pipes_struct *p)
struct auth_ntlmssp_state);
if (!pipe_ntlmssp_verify_final(p, ntlmssp_ctx,
p->auth.auth_level,
- p->client_id, &p->syntax,
+ p->client_id,
&p->session_info)) {
return NT_STATUS_ACCESS_DENIED;
}
@@ -813,7 +820,6 @@ static NTSTATUS pipe_auth_verify_final(struct pipes_struct *p)
if (!pipe_ntlmssp_verify_final(p, ntlmssp_ctx,
p->auth.auth_level,
p->client_id,
- &p->syntax,
&p->session_info)) {
return NT_STATUS_ACCESS_DENIED;
}
@@ -854,9 +860,7 @@ static bool api_pipe_bind_req(struct pipes_struct *p,
/* No rebinds on a bound pipe - use alter context. */
if (p->pipe_bound) {
- DEBUG(2,("api_pipe_bind_req: rejecting bind request on bound "
- "pipe %s.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ DEBUG(2,("Rejecting bind request on bound rpc connection\n"));
return setup_bind_nak(p, pkt);
}
@@ -871,38 +875,35 @@ static bool api_pipe_bind_req(struct pipes_struct *p,
*/
id = pkt->u.bind.ctx_list[0].abstract_syntax;
if (rpc_srv_pipe_exists_by_id(&id)) {
- DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n",
- rpc_srv_get_pipe_cli_name(&id),
- rpc_srv_get_pipe_srv_name(&id)));
+ DEBUG(3, ("api_pipe_bind_req: %s -> %s rpc service\n",
+ rpc_srv_get_pipe_cli_name(&id),
+ rpc_srv_get_pipe_srv_name(&id)));
} else {
status = smb_probe_module(
"rpc", get_pipe_name_from_syntax(
talloc_tos(),
- &pkt->u.bind.ctx_list[0].abstract_syntax));
+ &id));
if (NT_STATUS_IS_ERR(status)) {
- DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n",
- get_pipe_name_from_syntax(
- talloc_tos(),
- &pkt->u.bind.ctx_list[0].abstract_syntax)));
+ DEBUG(3,("api_pipe_bind_req: Unknown rpc service name "
+ "%s in bind request.\n",
+ get_pipe_name_from_syntax(talloc_tos(), &id)));
return setup_bind_nak(p, pkt);
}
if (rpc_srv_get_pipe_interface_by_cli_name(
get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax),
+ &id),
&id)) {
- DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n",
- rpc_srv_get_pipe_cli_name(&id),
- rpc_srv_get_pipe_srv_name(&id)));
+ DEBUG(3, ("api_pipe_bind_req: %s -> %s rpc service\n",
+ rpc_srv_get_pipe_cli_name(&id),
+ rpc_srv_get_pipe_srv_name(&id)));
} else {
DEBUG(0, ("module %s doesn't provide functions for "
"pipe %s!\n",
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax),
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ get_pipe_name_from_syntax(talloc_tos(), &id),
+ get_pipe_name_from_syntax(talloc_tos(), &id)));
return setup_bind_nak(p, pkt);
}
}
@@ -1507,28 +1508,9 @@ static bool api_pipe_alter_context(struct pipes_struct *p,
return setup_bind_nak(p, pkt);
}
-/****************************************************************************
- Find the set of RPC functions associated with this context_id
-****************************************************************************/
-
-static PIPE_RPC_FNS* find_pipe_fns_by_context( PIPE_RPC_FNS *list, uint32 context_id )
-{
- PIPE_RPC_FNS *fns = NULL;
-
- if ( !list ) {
- DEBUG(0,("find_pipe_fns_by_context: ERROR! No context list for pipe!\n"));
- return NULL;
- }
-
- for (fns=list; fns; fns=fns->next ) {
- if ( fns->context_id == context_id )
- return fns;
- }
- return NULL;
-}
-
static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt,
- const struct api_struct *api_rpc_cmds, int n_cmds);
+ const struct api_struct *api_rpc_cmds, int n_cmds,
+ const struct ndr_syntax_id *syntax);
/****************************************************************************
Find the correct RPC function to call for this request.
@@ -1547,16 +1529,13 @@ static bool api_pipe_request(struct pipes_struct *p,
((p->auth.auth_type == DCERPC_AUTH_TYPE_NTLMSSP) ||
(p->auth.auth_type == DCERPC_AUTH_TYPE_KRB5) ||
(p->auth.auth_type == DCERPC_AUTH_TYPE_SPNEGO))) {
- if(!become_authenticated_pipe_user(p)) {
+ if(!become_authenticated_pipe_user(p->session_info)) {
data_blob_free(&p->out_data.rdata);
return False;
}
changed_user = True;
}
- DEBUG(5, ("Requested \\PIPE\\%s\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
-
/* get the set of RPC functions for this context */
pipe_fns = find_pipe_fns_by_context(p->contexts,
@@ -1564,15 +1543,19 @@ static bool api_pipe_request(struct pipes_struct *p,
if ( pipe_fns ) {
TALLOC_CTX *frame = talloc_stackframe();
- ret = api_rpcTNP(p, pkt, pipe_fns->cmds, pipe_fns->n_cmds);
+
+ DEBUG(5, ("Requested %s rpc service\n",
+ get_pipe_name_from_syntax(talloc_tos(), &pipe_fns->syntax)));
+
+ ret = api_rpcTNP(p, pkt, pipe_fns->cmds, pipe_fns->n_cmds,
+ &pipe_fns->syntax);
+
TALLOC_FREE(frame);
}
else {
DEBUG(0, ("No rpc function table associated with context "
- "[%d] on pipe [%s]\n",
- pkt->u.request.context_id,
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ "[%d]\n",
+ pkt->u.request.context_id));
}
if (changed_user) {
@@ -1587,20 +1570,21 @@ static bool api_pipe_request(struct pipes_struct *p,
********************************************************************/
static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt,
- const struct api_struct *api_rpc_cmds, int n_cmds)
+ const struct api_struct *api_rpc_cmds, int n_cmds,
+ const struct ndr_syntax_id *syntax)
{
int fn_num;
uint32_t offset1;
/* interpret the command */
DEBUG(4,("api_rpcTNP: %s op 0x%x - ",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), syntax),
pkt->u.request.opnum));
if (DEBUGLEVEL >= 50) {
fstring name;
slprintf(name, sizeof(name)-1, "in_%s",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax));
+ get_pipe_name_from_syntax(talloc_tos(), syntax));
dump_pdu_region(name, pkt->u.request.opnum,
&p->in_data.data, 0,
p->in_data.data.length);
@@ -1633,7 +1617,7 @@ static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt,
/* do the actual command */
if(!api_rpc_cmds[fn_num].fn(p)) {
DEBUG(0,("api_rpcTNP: %s: %s failed.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), syntax),
api_rpc_cmds[fn_num].name));
data_blob_free(&p->out_data.rdata);
return False;
@@ -1656,14 +1640,14 @@ static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt,
if (DEBUGLEVEL >= 50) {
fstring name;
slprintf(name, sizeof(name)-1, "out_%s",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax));
+ get_pipe_name_from_syntax(talloc_tos(), syntax));
dump_pdu_region(name, pkt->u.request.opnum,
&p->out_data.rdata, offset1,
p->out_data.rdata.length);
}
DEBUG(5,("api_rpcTNP: called %s successfully\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ get_pipe_name_from_syntax(talloc_tos(), syntax)));
/* Check for buffer underflow in rpc parsing */
if ((DEBUGLEVEL >= 10) &&
@@ -1706,8 +1690,8 @@ void set_incoming_fault(struct pipes_struct *p)
p->in_data.pdu_needed_len = 0;
p->in_data.pdu.length = 0;
p->fault_state = True;
- DEBUG(10, ("set_incoming_fault: Setting fault state on pipe %s\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+
+ DEBUG(10, ("Setting fault state\n"));
}
static NTSTATUS dcesrv_auth_request(struct pipe_auth_data *auth,
@@ -1841,8 +1825,7 @@ void process_complete_pdu(struct pipes_struct *p)
bool reply = False;
if(p->fault_state) {
- DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ DEBUG(10,("RPC connection in fault state.\n"));
goto done;
}
@@ -1874,7 +1857,7 @@ void process_complete_pdu(struct pipes_struct *p)
/* Store the call_id */
p->call_id = pkt->call_id;
- DEBUG(10, ("Processing packet type %d\n", (int)pkt->ptype));
+ DEBUG(10, ("Processing packet type %u\n", (unsigned int)pkt->ptype));
switch (pkt->ptype) {
case DCERPC_PKT_REQUEST:
@@ -1882,19 +1865,12 @@ void process_complete_pdu(struct pipes_struct *p)
break;
case DCERPC_PKT_PING: /* CL request - ignore... */
- DEBUG(0, ("process_complete_pdu: Error. "
- "Connectionless packet type %d received on "
- "pipe %s.\n", (int)pkt->ptype,
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - Connectionless packet type %u received\n",
+ (unsigned int)pkt->ptype));
break;
case DCERPC_PKT_RESPONSE: /* No responses here. */
- DEBUG(0, ("process_complete_pdu: Error. "
- "DCERPC_PKT_RESPONSE received from client "
- "on pipe %s.\n",
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - DCERPC_PKT_RESPONSE received from client"));
break;
case DCERPC_PKT_FAULT:
@@ -1907,11 +1883,8 @@ void process_complete_pdu(struct pipes_struct *p)
case DCERPC_PKT_CL_CANCEL:
case DCERPC_PKT_FACK:
case DCERPC_PKT_CANCEL_ACK:
- DEBUG(0, ("process_complete_pdu: Error. "
- "Connectionless packet type %u received on "
- "pipe %s.\n", (unsigned int)pkt->ptype,
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - Connectionless packet type %u received\n",
+ (unsigned int)pkt->ptype));
break;
case DCERPC_PKT_BIND:
@@ -1925,12 +1898,9 @@ void process_complete_pdu(struct pipes_struct *p)
case DCERPC_PKT_BIND_ACK:
case DCERPC_PKT_BIND_NAK:
- DEBUG(0, ("process_complete_pdu: Error. "
- "DCERPC_PKT_BINDACK/DCERPC_PKT_BINDNACK "
- "packet type %u received on pipe %s.\n",
- (unsigned int)pkt->ptype,
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - DCERPC_PKT_BINDACK/DCERPC_PKT_BINDNACK "
+ "packet type %u received.\n",
+ (unsigned int)pkt->ptype));
break;
@@ -1944,11 +1914,8 @@ void process_complete_pdu(struct pipes_struct *p)
break;
case DCERPC_PKT_ALTER_RESP:
- DEBUG(0, ("process_complete_pdu: Error. "
- "DCERPC_PKT_ALTER_RESP on pipe %s: "
- "Should only be server -> client.\n",
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - DCERPC_PKT_ALTER_RESP received: "
+ "Should only be server -> client.\n"));
break;
case DCERPC_PKT_AUTH3:
@@ -1961,11 +1928,8 @@ void process_complete_pdu(struct pipes_struct *p)
break;
case DCERPC_PKT_SHUTDOWN:
- DEBUG(0, ("process_complete_pdu: Error. "
- "DCERPC_PKT_SHUTDOWN on pipe %s: "
- "Should only be server -> client.\n",
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - DCERPC_PKT_SHUTDOWN received: "
+ "Should only be server -> client.\n"));
break;
case DCERPC_PKT_CO_CANCEL:
@@ -2010,9 +1974,7 @@ void process_complete_pdu(struct pipes_struct *p)
done:
if (!reply) {
- DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on "
- "pipe %s\n", get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(3,("DCE/RPC fault sent!"));
set_incoming_fault(p);
setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR));
TALLOC_FREE(pkt);
diff --git a/source3/rpc_server/srv_pipe.h b/source3/rpc_server/srv_pipe.h
new file mode 100644
index 00000000000..453cca18d91
--- /dev/null
+++ b/source3/rpc_server/srv_pipe.h
@@ -0,0 +1,33 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Almost completely rewritten by (C) Jeremy Allison 2005 - 2010
+ *
+ * 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 _RPC_SERVER_SRV_PIPE_H_
+#define _RPC_SERVER_SRV_PIPE_H_
+
+struct ncacn_packet;
+struct pipes_struct;
+
+/* The following definitions come from rpc_server/srv_pipe.c */
+
+bool create_next_pdu(struct pipes_struct *p);
+bool api_pipe_bind_auth3(struct pipes_struct *p, struct ncacn_packet *pkt);
+bool setup_fault_pdu(struct pipes_struct *p, NTSTATUS status);
+bool is_known_pipename(const char *cli_filename, struct ndr_syntax_id *syntax);
+
+#endif /* _RPC_SERVER_SRV_PIPE_H_ */
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index 52525987269..501bb1efc77 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -20,15 +20,15 @@
*/
#include "includes.h"
-#include "../librpc/gen_ndr/srv_spoolss.h"
-#include "librpc/gen_ndr/ndr_named_pipe_auth.h"
-#include "../libcli/named_pipe_auth/npa_tstream.h"
#include "rpc_server.h"
-#include "smbd/globals.h"
#include "fake_file.h"
#include "rpc_dce.h"
-#include "rpc_server/rpc_ncacn_np.h"
#include "ntdomain.h"
+#include "rpc_server/rpc_ncacn_np.h"
+#include "rpc_server/srv_pipe_hnd.h"
+#include "rpc_server/srv_pipe.h"
+#include "../lib/tsocket/tsocket.h"
+#include "../lib/util/tevent_ntstatus.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -37,7 +37,7 @@
Ensures we have at least RPC_HEADER_LEN amount of data in the incoming buffer.
****************************************************************************/
-static ssize_t fill_rpc_header(struct pipes_struct *p, char *data, size_t data_to_copy)
+static ssize_t fill_rpc_header(struct pipes_struct *p, const char *data, size_t data_to_copy)
{
size_t len_needed_to_complete_hdr =
MIN(data_to_copy, RPC_HEADER_LEN - p->in_data.pdu.length);
@@ -126,7 +126,7 @@ static void free_pipe_context(struct pipes_struct *p)
Accepts incoming data on an rpc pipe. Processes the data in pdu sized units.
****************************************************************************/
-ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n)
+ssize_t process_incoming_data(struct pipes_struct *p, const char *data, size_t n)
{
size_t data_to_copy = MIN(n, RPC_MAX_PDU_FRAG_LEN
- p->in_data.pdu.length);
@@ -231,7 +231,7 @@ ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n)
Accepts incoming data on an internal rpc pipe.
****************************************************************************/
-static ssize_t write_to_internal_pipe(struct pipes_struct *p, char *data, size_t n)
+static ssize_t write_to_internal_pipe(struct pipes_struct *p, const char *data, size_t n)
{
size_t data_left = n;
@@ -280,7 +280,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
}
DEBUG(6,(" name: %s len: %u\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax),
(unsigned int)n));
/*
@@ -298,7 +298,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
DEBUG(5,("read_from_pipe: too large read (%u) requested on "
"pipe %s. We can only service %d sized reads.\n",
(unsigned int)n,
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax),
RPC_MAX_PDU_FRAG_LEN ));
n = RPC_MAX_PDU_FRAG_LEN;
}
@@ -319,7 +319,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
DEBUG(10,("read_from_pipe: %s: current_pdu_len = %u, "
"current_pdu_sent = %u returning %d bytes.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax),
(unsigned int)p->out_data.frag.length,
(unsigned int)p->out_data.current_pdu_sent,
(int)data_returned));
@@ -340,7 +340,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
DEBUG(10,("read_from_pipe: %s: fault_state = %d : data_sent_length "
"= %u, p->out_data.rdata.length = %u.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax),
(int)p->fault_state,
(unsigned int)p->out_data.data_sent_length,
(unsigned int)p->out_data.rdata.length));
@@ -362,7 +362,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
if(!create_next_pdu(p)) {
DEBUG(0,("read_from_pipe: %s: create_next_pdu failed.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax)));
return -1;
}
@@ -433,7 +433,7 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server", name,
"embedded");
- if (StrCaseCmp(rpcsrv_type, "embedded") != 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") != 0) {
external = true;
}
@@ -535,7 +535,7 @@ struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct pipes_struct *p = talloc_get_type_abort(
handle->private_data, struct pipes_struct);
- state->nwritten = write_to_internal_pipe(p, (char *)data, len);
+ state->nwritten = write_to_internal_pipe(p, (const char *)data, len);
status = (state->nwritten >= 0)
? NT_STATUS_OK : NT_STATUS_UNEXPECTED_IO_ERROR;
@@ -549,7 +549,7 @@ struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
state->ev = ev;
state->p = p;
- state->iov.iov_base = CONST_DISCARD(void *, data);
+ state->iov.iov_base = discard_const_p(void, data);
state->iov.iov_len = len;
subreq = tstream_writev_queue_send(state, ev,
diff --git a/source3/rpc_server/srv_pipe_hnd.h b/source3/rpc_server/srv_pipe_hnd.h
new file mode 100644
index 00000000000..680add469b0
--- /dev/null
+++ b/source3/rpc_server/srv_pipe_hnd.h
@@ -0,0 +1,51 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1998,
+ * Largely re-written : 2005
+ * Copyright (C) Jeremy Allison 1998 - 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/>.
+ */
+
+#ifndef _RPC_SERVER_SRV_PIPE_HND_H_
+#define _RPC_SERVER_SRV_PIPE_HND_H_
+
+struct tsocket_address;
+struct pipes_struct;
+
+/* The following definitions come from rpc_server/srv_pipe_hnd.c */
+
+bool fsp_is_np(struct files_struct *fsp);
+NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
+ const struct tsocket_address *local_address,
+ const struct tsocket_address *remote_address,
+ struct client_address *client_id,
+ struct auth_serversupplied_info *session_info,
+ struct messaging_context *msg_ctx,
+ struct fake_file_handle **phandle);
+bool np_read_in_progress(struct fake_file_handle *handle);
+struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct fake_file_handle *handle,
+ const uint8_t *data, size_t len);
+NTSTATUS np_write_recv(struct tevent_req *req, ssize_t *pnwritten);
+struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct fake_file_handle *handle,
+ uint8_t *data, size_t len);
+NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
+ bool *is_data_outstanding);
+
+ssize_t process_incoming_data(struct pipes_struct *p, const char *data, size_t n);
+
+#endif /* _RPC_SERVER_SRV_PIPE_HND_H_ */
diff --git a/source3/rpc_server/srv_pipe_register.c b/source3/rpc_server/srv_pipe_register.c
index a6d654277ed..c3500c97be6 100644
--- a/source3/rpc_server/srv_pipe_register.c
+++ b/source3/rpc_server/srv_pipe_register.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "librpc/rpc/dcerpc.h"
#include "srv_pipe_internal.h"
+#include "rpc_server/srv_pipe_register.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -197,7 +198,7 @@ NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv,
rpc_entry = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(rpc_lookup, struct rpc_table, rpc_lookup_size);
if (NULL == rpc_entry) {
rpc_lookup_size--;
- DEBUG(0, ("rpc_pipe_register_commands: memory allocation failed\n"));
+ DEBUG(0, ("rpc_srv_register: memory allocation failed\n"));
return NT_STATUS_NO_MEMORY;
} else {
rpc_lookup = rpc_entry;
diff --git a/source3/rpc_server/srv_pipe_register.h b/source3/rpc_server/srv_pipe_register.h
new file mode 100644
index 00000000000..b1b454e0bd5
--- /dev/null
+++ b/source3/rpc_server/srv_pipe_register.h
@@ -0,0 +1,39 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Almost completely rewritten by (C) Jeremy Allison 2005 - 2010
+ *
+ * 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 _RPC_SERVER_SRV_PIPE_REGISTER_H_
+#define _RPC_SERVER_SRV_PIPE_REGISTER_H_
+
+struct rpc_srv_callbacks {
+ bool (*init)(void *private_data);
+ bool (*shutdown)(void *private_data);
+ void *private_data;
+};
+
+/* The following definitions come from rpc_server/srv_rpc_register.c */
+
+NTSTATUS rpc_srv_register(int version, const char *clnt,
+ const char *srv,
+ const struct ndr_interface_table *iface,
+ const struct api_struct *cmds, int size,
+ const struct rpc_srv_callbacks *rpc_srv_cb);
+
+NTSTATUS rpc_srv_unregister(const struct ndr_interface_table *iface);
+
+#endif /* _RPC_SERVER_SRV_PIPE_REGISTER_H_ */
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index e51fee89c61..752b8576676 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -25,6 +25,7 @@
#include "includes.h"
#include "system/passwd.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_srvsvc.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_security.h"
@@ -32,9 +33,9 @@
#include "session.h"
#include "../lib/util/util_pw.h"
#include "smbd/smbd.h"
+#include "smbd/globals.h"
#include "auth.h"
#include "messages.h"
-#include "ntdomain.h"
extern const struct generic_mapping file_generic_mapping;
@@ -100,7 +101,7 @@ static int pipe_enum_fn( struct db_record *rec, void *p)
return 1;
}
- f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array,
+ f = talloc_realloc(fenum->ctx, fenum->ctr3->array,
struct srvsvc_NetFileInfo3, i+1);
if ( !f ) {
DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
@@ -135,7 +136,7 @@ static WERROR net_enum_pipes(TALLOC_CTX *ctx,
fenum.username = username;
fenum.ctr3 = *ctr3;
- if (connections_traverse(pipe_enum_fn, &fenum) == -1) {
+ if (connections_traverse(pipe_enum_fn, &fenum) < 0) {
DEBUG(0,("net_enum_pipes: traverse of connections.tdb "
"failed\n"));
return WERR_NOMEM;
@@ -178,7 +179,7 @@ static void enum_file_fn( const struct share_mode_entry *e,
return;
}
- f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array,
+ f = talloc_realloc(fenum->ctx, fenum->ctr3->array,
struct srvsvc_NetFileInfo3, i+1);
if ( !f ) {
DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
@@ -568,12 +569,12 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
/* Ensure all the usershares are loaded. */
become_root();
- load_usershare_shares();
+ load_usershare_shares(msg_ctx_to_sconn(p->msg_ctx));
load_registry_shares();
num_services = lp_numservices();
unbecome_root();
- allowed = TALLOC_ZERO_ARRAY(ctx, bool, num_services);
+ allowed = talloc_zero_array(ctx, bool, num_services);
W_ERROR_HAVE_NO_MEMORY(allowed);
/* Count the number of entries. */
@@ -599,11 +600,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
alloc_entries = num_entries - resume_handle;
switch (info_ctr->level) {
case 0:
- ctr.ctr0 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr0);
+ ctr.ctr0 = talloc_zero(ctx, struct srvsvc_NetShareCtr0);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr0);
ctr.ctr0->count = alloc_entries;
- ctr.ctr0->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo0, alloc_entries);
+ ctr.ctr0->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo0, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr0->array);
for (snum = 0; snum < num_services; snum++) {
@@ -616,11 +617,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1:
- ctr.ctr1 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1);
+ ctr.ctr1 = talloc_zero(ctx, struct srvsvc_NetShareCtr1);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1);
ctr.ctr1->count = alloc_entries;
- ctr.ctr1->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1, alloc_entries);
+ ctr.ctr1->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1->array);
for (snum = 0; snum < num_services; snum++) {
@@ -633,11 +634,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 2:
- ctr.ctr2 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr2);
+ ctr.ctr2 = talloc_zero(ctx, struct srvsvc_NetShareCtr2);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr2);
ctr.ctr2->count = alloc_entries;
- ctr.ctr2->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo2, alloc_entries);
+ ctr.ctr2->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo2, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr2->array);
for (snum = 0; snum < num_services; snum++) {
@@ -650,11 +651,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 501:
- ctr.ctr501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr501);
+ ctr.ctr501 = talloc_zero(ctx, struct srvsvc_NetShareCtr501);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr501);
ctr.ctr501->count = alloc_entries;
- ctr.ctr501->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo501, alloc_entries);
+ ctr.ctr501->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo501, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr501->array);
for (snum = 0; snum < num_services; snum++) {
@@ -667,11 +668,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 502:
- ctr.ctr502 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr502);
+ ctr.ctr502 = talloc_zero(ctx, struct srvsvc_NetShareCtr502);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr502);
ctr.ctr502->count = alloc_entries;
- ctr.ctr502->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo502, alloc_entries);
+ ctr.ctr502->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo502, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr502->array);
for (snum = 0; snum < num_services; snum++) {
@@ -684,11 +685,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1004:
- ctr.ctr1004 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1004);
+ ctr.ctr1004 = talloc_zero(ctx, struct srvsvc_NetShareCtr1004);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004);
ctr.ctr1004->count = alloc_entries;
- ctr.ctr1004->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1004, alloc_entries);
+ ctr.ctr1004->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1004, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004->array);
for (snum = 0; snum < num_services; snum++) {
@@ -701,11 +702,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1005:
- ctr.ctr1005 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1005);
+ ctr.ctr1005 = talloc_zero(ctx, struct srvsvc_NetShareCtr1005);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005);
ctr.ctr1005->count = alloc_entries;
- ctr.ctr1005->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1005, alloc_entries);
+ ctr.ctr1005->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1005, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005->array);
for (snum = 0; snum < num_services; snum++) {
@@ -718,11 +719,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1006:
- ctr.ctr1006 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1006);
+ ctr.ctr1006 = talloc_zero(ctx, struct srvsvc_NetShareCtr1006);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006);
ctr.ctr1006->count = alloc_entries;
- ctr.ctr1006->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1006, alloc_entries);
+ ctr.ctr1006->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1006, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006->array);
for (snum = 0; snum < num_services; snum++) {
@@ -735,11 +736,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1007:
- ctr.ctr1007 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1007);
+ ctr.ctr1007 = talloc_zero(ctx, struct srvsvc_NetShareCtr1007);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007);
ctr.ctr1007->count = alloc_entries;
- ctr.ctr1007->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1007, alloc_entries);
+ ctr.ctr1007->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1007, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007->array);
for (snum = 0; snum < num_services; snum++) {
@@ -752,11 +753,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1501:
- ctr.ctr1501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1501);
+ ctr.ctr1501 = talloc_zero(ctx, struct srvsvc_NetShareCtr1501);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501);
ctr.ctr1501->count = alloc_entries;
- ctr.ctr1501->array = TALLOC_ZERO_ARRAY(ctx, struct sec_desc_buf, alloc_entries);
+ ctr.ctr1501->array = talloc_zero_array(ctx, struct sec_desc_buf, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501->array);
for (snum = 0; snum < num_services; snum++) {
@@ -815,7 +816,7 @@ static WERROR init_srv_sess_info_0(struct pipes_struct *p,
for (; resume_handle < *total_entries; resume_handle++) {
- ctr0->array = TALLOC_REALLOC_ARRAY(p->mem_ctx,
+ ctr0->array = talloc_realloc(p->mem_ctx,
ctr0->array,
struct srvsvc_NetSessInfo0,
num_entries+1);
@@ -913,7 +914,7 @@ static WERROR init_srv_sess_info_1(struct pipes_struct *p,
num_files = net_count_files(pw->pw_uid, session_list[resume_handle].pid);
guest = strequal( session_list[resume_handle].username, lp_guestaccount() );
- ctr1->array = TALLOC_REALLOC_ARRAY(p->mem_ctx,
+ ctr1->array = talloc_realloc(p->mem_ctx,
ctr1->array,
struct srvsvc_NetSessInfo1,
num_entries+1);
@@ -968,7 +969,7 @@ static WERROR init_srv_conn_info_0(struct srvsvc_NetConnCtr0 *ctr0,
for (; resume_handle < *total_entries; resume_handle++) {
- ctr0->array = TALLOC_REALLOC_ARRAY(talloc_tos(),
+ ctr0->array = talloc_realloc(talloc_tos(),
ctr0->array,
struct srvsvc_NetConnInfo0,
num_entries+1);
@@ -1022,7 +1023,7 @@ static WERROR init_srv_conn_info_1(struct srvsvc_NetConnCtr1 *ctr1,
for (; resume_handle < *total_entries; resume_handle++) {
- ctr1->array = TALLOC_REALLOC_ARRAY(talloc_tos(),
+ ctr1->array = talloc_realloc(talloc_tos(),
ctr1->array,
struct srvsvc_NetConnInfo1,
num_entries+1);
@@ -1138,15 +1139,15 @@ WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p,
case 102: {
struct srvsvc_NetSrvInfo102 *info102;
- info102 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo102);
+ info102 = talloc(p->mem_ctx, struct srvsvc_NetSrvInfo102);
if (!info102) {
return WERR_NOMEM;
}
info102->platform_id = PLATFORM_ID_NT;
- info102->server_name = global_myname();
- info102->version_major = lp_major_announce_version();
- info102->version_minor = lp_minor_announce_version();
+ info102->server_name = lp_netbios_name();
+ info102->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info102->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info102->server_type = lp_default_server_announce();
info102->comment = string_truncate(lp_serverstring(),
MAX_SERVER_STRING_LENGTH);
@@ -1164,15 +1165,15 @@ WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p,
case 101: {
struct srvsvc_NetSrvInfo101 *info101;
- info101 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo101);
+ info101 = talloc(p->mem_ctx, struct srvsvc_NetSrvInfo101);
if (!info101) {
return WERR_NOMEM;
}
info101->platform_id = PLATFORM_ID_NT;
- info101->server_name = global_myname();
- info101->version_major = lp_major_announce_version();
- info101->version_minor = lp_minor_announce_version();
+ info101->server_name = lp_netbios_name();
+ info101->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info101->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info101->server_type = lp_default_server_announce();
info101->comment = string_truncate(lp_serverstring(),
MAX_SERVER_STRING_LENGTH);
@@ -1183,13 +1184,13 @@ WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p,
case 100: {
struct srvsvc_NetSrvInfo100 *info100;
- info100 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo100);
+ info100 = talloc(p->mem_ctx, struct srvsvc_NetSrvInfo100);
if (!info100) {
return WERR_NOMEM;
}
info100->platform_id = PLATFORM_ID_NT;
- info100->server_name = global_myname();
+ info100->server_name = lp_netbios_name();
r->out.info->info100 = info100;
@@ -1453,47 +1454,47 @@ WERROR _srvsvc_NetShareGetInfo(struct pipes_struct *p,
switch (r->in.level) {
case 0:
- info->info0 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo0);
+ info->info0 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo0);
W_ERROR_HAVE_NO_MEMORY(info->info0);
init_srv_share_info_0(p, info->info0, snum);
break;
case 1:
- info->info1 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1);
+ info->info1 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1);
W_ERROR_HAVE_NO_MEMORY(info->info1);
init_srv_share_info_1(p, info->info1, snum);
break;
case 2:
- info->info2 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo2);
+ info->info2 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo2);
W_ERROR_HAVE_NO_MEMORY(info->info2);
init_srv_share_info_2(p, info->info2, snum);
break;
case 501:
- info->info501 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo501);
+ info->info501 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo501);
W_ERROR_HAVE_NO_MEMORY(info->info501);
init_srv_share_info_501(p, info->info501, snum);
break;
case 502:
- info->info502 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo502);
+ info->info502 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo502);
W_ERROR_HAVE_NO_MEMORY(info->info502);
init_srv_share_info_502(p, info->info502, snum);
break;
case 1004:
- info->info1004 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1004);
+ info->info1004 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1004);
W_ERROR_HAVE_NO_MEMORY(info->info1004);
init_srv_share_info_1004(p, info->info1004, snum);
break;
case 1005:
- info->info1005 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1005);
+ info->info1005 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1005);
W_ERROR_HAVE_NO_MEMORY(info->info1005);
init_srv_share_info_1005(p, info->info1005, snum);
break;
case 1006:
- info->info1006 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1006);
+ info->info1006 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1006);
W_ERROR_HAVE_NO_MEMORY(info->info1006);
init_srv_share_info_1006(p, info->info1006, snum);
break;
case 1007:
- info->info1007 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1007);
+ info->info1007 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1007);
W_ERROR_HAVE_NO_MEMORY(info->info1007);
init_srv_share_info_1007(p, info->info1007, snum);
break;
@@ -1513,40 +1514,6 @@ WERROR _srvsvc_NetShareGetInfo(struct pipes_struct *p,
}
/*******************************************************************
- Check a given DOS pathname is valid for a share.
-********************************************************************/
-
-char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname)
-{
- char *ptr = NULL;
-
- if (!dos_pathname) {
- return NULL;
- }
-
- ptr = talloc_strdup(ctx, dos_pathname);
- if (!ptr) {
- return NULL;
- }
- /* Convert any '\' paths to '/' */
- unix_format(ptr);
- ptr = unix_clean_name(ctx, ptr);
- if (!ptr) {
- return NULL;
- }
-
- /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */
- if (strlen(ptr) > 2 && ptr[1] == ':' && ptr[0] != '/')
- ptr += 2;
-
- /* Only absolute paths allowed. */
- if (*ptr != '/')
- return NULL;
-
- return ptr;
-}
-
-/*******************************************************************
_srvsvc_NetShareSetInfo. Modify share details.
********************************************************************/
@@ -2095,7 +2062,7 @@ WERROR _srvsvc_NetRemoteTOD(struct pipes_struct *p,
DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__));
- if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetRemoteTODInfo)) )
+ if ( !(tod = talloc_zero(p->mem_ctx, struct srvsvc_NetRemoteTODInfo)) )
return WERR_NOMEM;
*r->out.info = tod;
@@ -2222,7 +2189,7 @@ WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p,
sd_size = ndr_size_security_descriptor(psd, 0);
- sd_buf = TALLOC_ZERO_P(p->mem_ctx, struct sec_desc_buf);
+ sd_buf = talloc_zero(p->mem_ctx, struct sec_desc_buf);
if (!sd_buf) {
werr = WERR_NOMEM;
goto error_exit;
@@ -2471,7 +2438,7 @@ WERROR _srvsvc_NetDiskEnum(struct pipes_struct *p,
*r->out.totalentries = init_server_disk_enum(&resume);
- r->out.info->disks = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetDiskInfo0,
+ r->out.info->disks = talloc_zero_array(ctx, struct srvsvc_NetDiskInfo0,
MAX_SERVER_DISK_ENTRIES);
W_ERROR_HAVE_NO_MEMORY(r->out.info->disks);
diff --git a/source3/rpc_server/svcctl/srv_svcctl_nt.c b/source3/rpc_server/svcctl/srv_svcctl_nt.c
index a4eb282de7c..f515906339f 100644
--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
+++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
@@ -23,13 +23,14 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_svcctl.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_security.h"
#include "services/services.h"
#include "services/svc_winreg_glue.h"
#include "auth.h"
-#include "ntdomain.h"
+#include "rpc_server/svcctl/srv_svcctl_nt.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -70,7 +71,7 @@ bool init_service_op_table( void )
int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_length( service_list );
int i;
- if ( !(svcctl_ops = TALLOC_ARRAY( NULL, struct service_control_op, num_services+1)) ) {
+ if ( !(svcctl_ops = talloc_array( NULL, struct service_control_op, num_services+1)) ) {
DEBUG(0,("init_service_op_table: talloc() failed!\n"));
return False;
}
@@ -208,7 +209,7 @@ static WERROR create_open_service_handle(struct pipes_struct *p,
WERROR result = WERR_OK;
struct service_control_op *s_op;
- if ( !(info = TALLOC_ZERO_P( NULL, SERVICE_INFO )) )
+ if ( !(info = talloc_zero( NULL, SERVICE_INFO )) )
return WERR_NOMEM;
/* the Service Manager has a NULL name */
@@ -420,7 +421,7 @@ static int enumerate_status(TALLOC_CTX *ctx,
while ( svcctl_ops[num_services].name )
num_services++;
- if ( !(st = TALLOC_ARRAY( ctx, struct ENUM_SERVICE_STATUSW, num_services )) ) {
+ if ( !(st = talloc_array( ctx, struct ENUM_SERVICE_STATUSW, num_services )) ) {
DEBUG(0,("enumerate_status: talloc() failed!\n"));
return -1;
}
@@ -667,17 +668,18 @@ WERROR _svcctl_QueryServiceStatusEx(struct pipes_struct *p,
/********************************************************************
********************************************************************/
-static WERROR fill_svc_config(TALLOC_CTX *ctx,
+static WERROR fill_svc_config(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
struct auth_serversupplied_info *session_info,
const char *name,
struct QUERY_SERVICE_CONFIG *config)
{
- TALLOC_CTX *mem_ctx = talloc_stackframe();
const char *result = NULL;
/* now fill in the individual values */
+ ZERO_STRUCTP(config);
+
config->displayname = svcctl_lookup_dispname(mem_ctx,
msg_ctx,
session_info,
@@ -719,9 +721,6 @@ static WERROR fill_svc_config(TALLOC_CTX *ctx,
else
config->start_type = SVCCTL_DEMAND_START;
-
- talloc_free(mem_ctx);
-
return WERR_OK;
}
@@ -776,7 +775,8 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
struct svcctl_QueryServiceConfig2W *r)
{
SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle );
- uint32 buffer_size;
+ uint32_t buffer_size;
+ DATA_BLOB blob = data_blob_null;
/* perform access checks */
@@ -796,7 +796,6 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
struct SERVICE_DESCRIPTION desc_buf;
const char *description;
enum ndr_err_code ndr_err;
- DATA_BLOB blob;
description = svcctl_lookup_description(p->mem_ctx,
p->msg_ctx,
@@ -811,9 +810,6 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
return WERR_INVALID_PARAM;
}
- buffer_size = ndr_size_SERVICE_DESCRIPTION(&desc_buf, 0);
- r->out.buffer = blob.data;
-
break;
}
break;
@@ -821,7 +817,6 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
{
struct SERVICE_FAILURE_ACTIONS actions;
enum ndr_err_code ndr_err;
- DATA_BLOB blob;
/* nothing to say...just service the request */
@@ -833,9 +828,6 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
return WERR_INVALID_PARAM;
}
- buffer_size = ndr_size_SERVICE_FAILURE_ACTIONS(&actions, 0);
- r->out.buffer = blob.data;
-
break;
}
break;
@@ -844,12 +836,15 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
return WERR_UNKNOWN_LEVEL;
}
+ buffer_size = blob.length;
buffer_size += buffer_size % 4;
*r->out.needed = (buffer_size > r->in.offered) ? buffer_size : r->in.offered;
if (buffer_size > r->in.offered)
return WERR_INSUFFICIENT_BUFFER;
+ memcpy(r->out.buffer, blob.data, blob.length);
+
return WERR_OK;
}
@@ -941,7 +936,7 @@ WERROR _svcctl_QueryServiceObjectSecurity(struct pipes_struct *p,
}
*r->out.needed = len;
- r->out.buffer = buffer;
+ memcpy(r->out.buffer, buffer, len);
return WERR_OK;
}
diff --git a/source3/rpc_server/svcctl/srv_svcctl_nt.h b/source3/rpc_server/svcctl/srv_svcctl_nt.h
new file mode 100644
index 00000000000..dd049272882
--- /dev/null
+++ b/source3/rpc_server/svcctl/srv_svcctl_nt.h
@@ -0,0 +1,33 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ *
+ * Copyright (C) Marcin Krzysztof Porwit 2005.
+ *
+ * Largely Rewritten (Again) by:
+ * Copyright (C) Gerald (Jerry) Carter 2005.
+ * Copyright (C) Guenther Deschner 2008,2009.
+ *
+ * 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 _RPC_SERVER_SVCCTL_SRV_SVCCTL_NT_H_
+#define _RPC_SERVER_SVCCTL_SRV_SVCCTL_NT_H_
+
+/* The following definitions come from rpc_server/srv_svcctl_nt.c */
+
+bool init_service_op_table( void );
+bool shutdown_service_op_table(void);
+
+#endif /* _RPC_SERVER_SVCCTL_SRV_SVCCTL_NT_H_ */
diff --git a/source3/rpc_server/winreg/srv_winreg_nt.c b/source3/rpc_server/winreg/srv_winreg_nt.c
index fedb665a30b..6fee5b6acd9 100644
--- a/source3/rpc_server/winreg/srv_winreg_nt.c
+++ b/source3/rpc_server/winreg/srv_winreg_nt.c
@@ -21,6 +21,7 @@
/* Implementation of registry functions. */
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_winreg.h"
#include "registry.h"
#include "registry/reg_api.h"
@@ -28,8 +29,8 @@
#include "registry/reg_perfcount.h"
#include "rpc_misc.h"
#include "auth.h"
-#include "ntdomain.h"
#include "lib/privileges.h"
+#include "libcli/security/secdesc.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -541,7 +542,7 @@ WERROR _winreg_InitiateSystemShutdownEx(struct pipes_struct *p,
if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->string )) == NULL ) {
return WERR_NOMEM;
}
- chkmsg = TALLOC_ARRAY(p->mem_ctx, char, strlen(msg)+1);
+ chkmsg = talloc_array(p->mem_ctx, char, strlen(msg)+1);
if (!chkmsg) {
return WERR_NOMEM;
}
diff --git a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
index d44414f7767..49c71b8d6eb 100644
--- a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
+++ b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
@@ -23,6 +23,7 @@
/* This is the implementation of the wks interface. */
#include "includes.h"
+#include "ntdomain.h"
#include "librpc/gen_ndr/libnet_join.h"
#include "libnet/libnet_join.h"
#include "../libcli/auth/libcli_auth.h"
@@ -31,7 +32,6 @@
#include "session.h"
#include "smbd/smbd.h"
#include "auth.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -196,7 +196,7 @@ static struct dom_usr *get_domain_userlist(TALLOC_CTX *mem_ctx)
DEBUG(10, ("talloc_asprintf failed\n"));
continue;
}
- if (strcmp(machine_name, global_myname()) == 0) {
+ if (strcmp(machine_name, lp_netbios_name()) == 0) {
p = session_list[i].username;
nm = strstr(p, sep);
if (nm) {
@@ -260,11 +260,11 @@ static struct wkssvc_NetWkstaInfo100 *create_wks_info_100(TALLOC_CTX *mem_ctx)
}
info100->platform_id = PLATFORM_ID_NT; /* unknown */
- info100->version_major = lp_major_announce_version();
- info100->version_minor = lp_minor_announce_version();
+ info100->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info100->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info100->server_name = talloc_asprintf_strupper_m(
- info100, "%s", global_myname());
+ info100, "%s", lp_netbios_name());
info100->domain_name = talloc_asprintf_strupper_m(
info100, "%s", lp_workgroup());
@@ -289,11 +289,11 @@ static struct wkssvc_NetWkstaInfo101 *create_wks_info_101(TALLOC_CTX *mem_ctx)
}
info101->platform_id = PLATFORM_ID_NT; /* unknown */
- info101->version_major = lp_major_announce_version();
- info101->version_minor = lp_minor_announce_version();
+ info101->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info101->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info101->server_name = talloc_asprintf_strupper_m(
- info101, "%s", global_myname());
+ info101, "%s", lp_netbios_name());
info101->domain_name = talloc_asprintf_strupper_m(
info101, "%s", lp_workgroup());
info101->lan_root = "";
@@ -320,11 +320,11 @@ static struct wkssvc_NetWkstaInfo102 *create_wks_info_102(TALLOC_CTX *mem_ctx)
}
info102->platform_id = PLATFORM_ID_NT; /* unknown */
- info102->version_major = lp_major_announce_version();
- info102->version_minor = lp_minor_announce_version();
+ info102->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info102->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info102->server_name = talloc_asprintf_strupper_m(
- info102, "%s", global_myname());
+ info102, "%s", lp_netbios_name());
info102->domain_name = talloc_asprintf_strupper_m(
info102, "%s", lp_workgroup());
info102->lan_root = "";
@@ -528,7 +528,7 @@ static struct wkssvc_NetWkstaEnumUsersCtr1 *create_enum_users1(
/* For a local user the domain name and logon server are
* both returned as the local machine's NetBIOS name */
ctr1->user1[i].logon_domain = ctr1->user1[i].logon_server =
- talloc_asprintf_strupper_m(ctr1->user1, "%s", global_myname());
+ talloc_asprintf_strupper_m(ctr1->user1, "%s", lp_netbios_name());
ctr1->user1[i].other_domains = NULL; /* Maybe in future? */
}
diff --git a/source3/rpc_server/wscript_build b/source3/rpc_server/wscript_build
index 346d770385e..5d21d5e3408 100644
--- a/source3/rpc_server/wscript_build
+++ b/source3/rpc_server/wscript_build
@@ -26,26 +26,32 @@ bld.SAMBA3_SUBSYSTEM('rpc',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_NCACN_NP',
- source='rpc_ncacn_np.c rpc_handles.c',
- deps='auth_sam_reply')
+ source='rpc_ncacn_np.c rpc_handles.c rpc_contexts.c',
+ deps='auth_sam_reply RPC_PIPE_REGISTER AUTH_COMMON npa_tstream')
bld.SAMBA3_SUBSYSTEM('RPC_SERVICE',
- source='rpc_server.c')
+ source='rpc_server.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('RPC_CRYPTO',
- source='dcesrv_ntlmssp.c dcesrv_gssapi.c dcesrv_spnego.c')
+ source='dcesrv_ntlmssp.c dcesrv_gssapi.c dcesrv_spnego.c',
+ deps = 'KRB5_PAC')
bld.SAMBA3_SUBSYSTEM('RPC_PIPE_REGISTER',
- source='srv_pipe_register.c')
+ source='srv_pipe_register.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('RPC_SERVER_REGISTER',
- source='rpc_ep_setup.c ../librpc/rpc/dcerpc_ep.c')
+ source='rpc_ep_setup.c ../librpc/rpc/dcerpc_ep.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('EPMD',
- source='epmd.c')
+ source='epmd.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('SRV_ACCESS_CHECK',
- source='srv_access_check.c')
+ source='srv_access_check.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('RPC_SAMR',
source=RPC_SAMR_SRC,
@@ -64,10 +70,12 @@ bld.SAMBA3_SUBSYSTEM('RPC_WINREG',
bld.SAMBA3_SUBSYSTEM('RPC_INITSHUTDOWN',
source=RPC_INITSHUTDOWN_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_DSSETUP',
source=RPC_DSSETUP_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_WKSSVC',
@@ -82,23 +90,27 @@ bld.SAMBA3_SUBSYSTEM('RPC_SVCCTL',
bld.SAMBA3_SUBSYSTEM('RPC_NTSVCS',
source=RPC_NTSVCS_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_NETLOGON',
source=RPC_NETLOGON_SRC,
+ deps='RPC_NCACN_NP',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_NETDFS',
source=RPC_NETDFS_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_SRVSVC',
source=RPC_SRVSVC_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_SPOOLSS',
source=RPC_SPOOLSS_SRC,
- deps='cups PRINTING PRINTBACKEND LIBCLI_WINREG',
+ deps='cups PRINTING PRINTBACKEND LIBCLI_WINREG RPC_NCACN_NP',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_EVENTLOG',
@@ -108,10 +120,12 @@ bld.SAMBA3_SUBSYSTEM('RPC_EVENTLOG',
bld.SAMBA3_SUBSYSTEM('RPC_RPCECHO',
source=RPC_RPCECHO_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_EPMAPPER',
source=RPC_EPMAPPER_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_SERVER',
diff --git a/source3/rpcclient/cmd_drsuapi.c b/source3/rpcclient/cmd_drsuapi.c
index 3f1ecab7503..292fa8838b2 100644
--- a/source3/rpcclient/cmd_drsuapi.c
+++ b/source3/rpcclient/cmd_drsuapi.c
@@ -40,7 +40,7 @@ static WERROR cracknames(struct rpc_pipe_client *cli,
struct drsuapi_DsNameString *names;
struct dcerpc_binding_handle *b = cli->binding_handle;
- names = TALLOC_ZERO_ARRAY(mem_ctx, struct drsuapi_DsNameString, argc);
+ names = talloc_zero_array(mem_ctx, struct drsuapi_DsNameString, argc);
W_ERROR_HAVE_NO_MEMORY(names);
for (i=0; i<argc; i++) {
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 4b065d0dd2d..3382eb1a5c7 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -400,7 +400,7 @@ static NTSTATUS cmd_lsa_lookup_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem
/* Convert arguments to sids */
- sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, argc - 1);
+ sids = talloc_array(mem_ctx, struct dom_sid, argc - 1);
if (!sids) {
printf("could not allocate memory for %d sids\n", argc - 1);
@@ -978,7 +978,7 @@ static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli,
goto done;
rights.count = argc-2;
- rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
rights.count);
if (!rights.names) {
return NT_STATUS_NO_MEMORY;
@@ -1036,7 +1036,7 @@ static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli,
goto done;
rights.count = argc-2;
- rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
rights.count);
if (!rights.names) {
return NT_STATUS_NO_MEMORY;
@@ -1494,7 +1494,7 @@ static NTSTATUS cmd_lsa_add_priv(struct rpc_pipe_client *cli,
}
privs.count++;
- set = TALLOC_REALLOC_ARRAY(mem_ctx, set,
+ set = talloc_realloc(mem_ctx, set,
struct lsa_LUIDAttribute,
privs.count);
if (!set) {
@@ -1592,7 +1592,7 @@ static NTSTATUS cmd_lsa_del_priv(struct rpc_pipe_client *cli,
}
privs.count++;
- set = TALLOC_REALLOC_ARRAY(mem_ctx, set,
+ set = talloc_realloc(mem_ctx, set,
struct lsa_LUIDAttribute,
privs.count);
if (!set) {
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index 63057ac3689..ad43452bf11 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -583,7 +583,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli,
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
NTSTATUS status;
const char *logon_server = cli->desthost;
- const char *computername = global_myname();
+ const char *computername = lp_netbios_name();
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN;
@@ -654,7 +654,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
NTSTATUS status;
uint32_t tmp;
const char *logon_server = cli->desthost;
- const char *computername = global_myname();
+ const char *computername = lp_netbios_name();
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN;
@@ -1121,8 +1121,8 @@ static NTSTATUS cmd_netlogon_database_redo(struct rpc_pipe_client *cli,
status = rpccli_netlogon_setup_creds(cli,
server_name, /* server name */
lp_workgroup(), /* domain */
- global_myname(), /* client name */
- global_myname(), /* machine account name */
+ lp_netbios_name(), /* client name */
+ lp_netbios_name(), /* machine account name */
trust_passwd_hash,
sec_channel_type,
&neg_flags);
@@ -1141,7 +1141,7 @@ static NTSTATUS cmd_netlogon_database_redo(struct rpc_pipe_client *cli,
status = dcerpc_netr_DatabaseRedo(b, mem_ctx,
server_name,
- global_myname(),
+ lp_netbios_name(),
&clnt_creds,
&srv_cred,
e,
@@ -1187,7 +1187,7 @@ static NTSTATUS cmd_netlogon_capabilities(struct rpc_pipe_client *cli,
status = dcerpc_netr_LogonGetCapabilities(b, mem_ctx,
cli->desthost,
- global_myname(),
+ lp_netbios_name(),
&credential,
&return_authenticator,
level,
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 727c9d14560..24bd55abf32 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -284,18 +284,18 @@ static NTSTATUS get_domain_handle(struct rpc_pipe_client *cli,
struct dcerpc_binding_handle *b = cli->binding_handle;
NTSTATUS status = NT_STATUS_INVALID_PARAMETER, result;
- if (StrCaseCmp(sam, "domain") == 0) {
+ if (strcasecmp_m(sam, "domain") == 0) {
status = dcerpc_samr_OpenDomain(b, mem_ctx,
connect_pol,
access_mask,
_domain_sid,
domain_pol,
&result);
- } else if (StrCaseCmp(sam, "builtin") == 0) {
+ } else if (strcasecmp_m(sam, "builtin") == 0) {
status = dcerpc_samr_OpenDomain(b, mem_ctx,
connect_pol,
access_mask,
- CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ discard_const_p(struct dom_sid2, &global_sid_Builtin),
domain_pol,
&result);
}
@@ -728,7 +728,7 @@ static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
}
if (num_sids) {
- sid_array.sids = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_SidPtr, num_sids);
+ sid_array.sids = talloc_zero_array(mem_ctx, struct lsa_SidPtr, num_sids);
if (sid_array.sids == NULL)
return NT_STATUS_NO_MEMORY;
} else {
@@ -2087,7 +2087,7 @@ static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli,
num_names = argc - 2;
- if ((names = TALLOC_ARRAY(mem_ctx, struct lsa_String, num_names)) == NULL) {
+ if ((names = talloc_array(mem_ctx, struct lsa_String, num_names)) == NULL) {
dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
status = NT_STATUS_NO_MEMORY;
@@ -2167,7 +2167,7 @@ static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
num_rids = argc - 2;
- if ((rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids)) == NULL) {
+ if ((rids = talloc_array(mem_ctx, uint32, num_rids)) == NULL) {
dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
status = NT_STATUS_NO_MEMORY;
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 712b23724ec..0e12201f927 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -27,12 +27,12 @@
#include "../librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_client/cli_spoolss.h"
#include "rpc_client/init_spoolss.h"
-#include "registry.h"
#include "registry/reg_objects.h"
#include "nt_printing.h"
#include "../libcli/security/display_sec.h"
#include "../libcli/security/security_descriptor.h"
#include "../libcli/registry/util_reg.h"
+#include "libsmb/libsmb.h"
#define RPCCLIENT_PRINTERNAME(_printername, _cli, _arg) \
{ \
@@ -83,7 +83,7 @@ static const char *cmd_spoolss_get_short_archi(const char *long_archi)
do {
i++;
} while ( (archi_table[i].long_archi!=NULL ) &&
- StrCaseCmp(long_archi, archi_table[i].long_archi) );
+ strcasecmp_m(long_archi, archi_table[i].long_archi) );
if (archi_table[i].long_archi==NULL) {
DEBUGADD(10,("Unknown architecture [%s] !\n", long_archi));
@@ -1616,7 +1616,7 @@ static char *get_driver_3_param(TALLOC_CTX *mem_ctx, char *str,
parameter because two consecutive delimiters
will not return an empty string. See man strtok(3)
for details */
- if (ptr && (StrCaseCmp(ptr, "NULL") == 0)) {
+ if (ptr && (strcasecmp_m(ptr, "NULL") == 0)) {
ptr = NULL;
}
@@ -3263,7 +3263,7 @@ static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli,
}
option.types[1].fields[0].field = JOB_NOTIFY_FIELD_PRINTER_NAME;
- clientname = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
+ clientname = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
if (!clientname) {
result = WERR_NOMEM;
goto done;
@@ -3429,7 +3429,7 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli,
/* first get the connection to the remote server */
- nt_status = cli_full_connection(&cli_server2, global_myname(), argv[2],
+ nt_status = cli_full_connection(&cli_server2, lp_netbios_name(), argv[2],
NULL, 0,
"IPC$", "IPC",
get_cmdline_auth_info_username(rpcclient_auth_info),
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index cebe2a9c6ae..542862606b2 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -30,7 +30,7 @@
#include "../libcli/smbreadline/smbreadline.h"
#include "../libcli/security/security.h"
#include "passdb.h"
-#include "ntdomain.h"
+#include "libsmb/libsmb.h"
enum pipe_auth_type_spnego {
PIPE_AUTH_TYPE_SPNEGO_NONE = 0,
@@ -240,7 +240,7 @@ static NTSTATUS cmd_listcommands(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ct
{
tmp_set = tmp->cmd_set;
- if (!StrCaseCmp(argv[1], tmp_set->name))
+ if (!strcasecmp_m(argv[1], tmp_set->name))
{
printf("Available commands on the %s pipe:\n\n", tmp_set->name);
@@ -775,7 +775,7 @@ static NTSTATUS do_cmd(struct cli_state *cli,
ntresult = rpccli_netlogon_setup_creds(cmd_entry->rpc_pipe,
cli->desthost, /* server name */
get_cmdline_auth_info_domain(auth_info), /* domain */
- global_myname(), /* client name */
+ lp_netbios_name(), /* client name */
machine_account, /* machine account name */
trust_password,
sec_channel_type,
@@ -892,7 +892,6 @@ out_free:
struct sockaddr_storage server_ss;
NTSTATUS nt_status;
static int opt_port = 0;
- fstring new_workgroup;
int result = 0;
TALLOC_CTX *frame = talloc_stackframe();
uint32_t flags = 0;
@@ -975,22 +974,11 @@ out_free:
goto done;
}
- /* save the workgroup...
-
- FIXME!! do we need to do this for other options as well
- (or maybe a generic way to keep lp_load() from overwriting
- everything)? */
-
- fstrcpy( new_workgroup, lp_workgroup() );
-
/* Load smb.conf file */
if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True))
fprintf(stderr, "Can't load %s\n", get_dyn_CONFIGFILE());
- if ( strlen(new_workgroup) != 0 )
- set_global_myworkgroup( new_workgroup );
-
/*
* Get password
* from stdin if necessary
@@ -1091,7 +1079,7 @@ out_free:
}
- nt_status = cli_full_connection(&cli, global_myname(), binding->host,
+ nt_status = cli_full_connection(&cli, lp_netbios_name(), binding->host,
opt_ipaddr ? &server_ss : NULL, opt_port,
"IPC$", "IPC",
get_cmdline_auth_info_username(rpcclient_auth_info),
diff --git a/source3/script/mkbuildoptions-waf.awk b/source3/script/mkbuildoptions-waf.awk
index ddb3f6527a9..2d7063a79e6 100644
--- a/source3/script/mkbuildoptions-waf.awk
+++ b/source3/script/mkbuildoptions-waf.awk
@@ -21,7 +21,7 @@ BEGIN {
print "";
print "#include \"includes.h\"";
print "#include \"build_env.h\"";
- print "#include \"dynconfig.h\"";
+ print "#include \"dynconfig/dynconfig.h\"";
print "";
print "static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);";
print "void build_options(bool screen);";
diff --git a/source3/script/mkbuildoptions.awk b/source3/script/mkbuildoptions.awk
index 1955a80b46c..0b1b2ef3ab8 100644
--- a/source3/script/mkbuildoptions.awk
+++ b/source3/script/mkbuildoptions.awk
@@ -21,7 +21,7 @@ BEGIN {
print "";
print "#include \"includes.h\"";
print "#include \"build_env.h\"";
- print "#include \"dynconfig.h\"";
+ print "#include \"dynconfig/dynconfig.h\"";
print "";
print "static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);";
print "void build_options(bool screen);";
@@ -235,7 +235,7 @@ function output(ARRAY, ELEMENTS, TITLE) {
END {
##################################################
# add code to show various options
- print "/* Output various other options (as gleaned from include/config.h.in) */";
+ print "/* Output various other options (as gleaned from include/autoconf/config.h.in) */";
output(sys_ary, sys_i, "System Headers");
output(headers_ary, headers_i, "Headers");
output(utmp_ary, utmp_i, "UTMP Options");
diff --git a/source3/script/tests/test_net_registry_roundtrip.sh b/source3/script/tests/test_net_registry_roundtrip.sh
index f35a7524281..33114ccd4c0 100755
--- a/source3/script/tests/test_net_registry_roundtrip.sh
+++ b/source3/script/tests/test_net_registry_roundtrip.sh
@@ -7,7 +7,7 @@
if [ $# -lt 3 ]; then
cat <<EOF
-Usage: test_net_registry_roundtrip.sh SCRIPTDIR SERVERCONFFILE CONFIGURATION
+Usage: test_net_registry_roundtrip.sh SCRIPTDIR SERVERCONFFILE PREFIX CONFIGURATION
EOF
exit 1;
fi
@@ -144,7 +144,7 @@ conf_roundtrip()
rm -r $DIR
}
-CONF_FILES=${CONF_FILES:-$(find $SRCDIR/source3 -name '*.conf' | grep -v examples/logon | xargs grep -l "\[global\]")}
+CONF_FILES=$SERVERCONFFILE
# remove old logs:
for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do
diff --git a/source3/script/tests/test_pthreadpool.sh b/source3/script/tests/test_pthreadpool.sh
new file mode 100755
index 00000000000..b1c7c6da11c
--- /dev/null
+++ b/source3/script/tests/test_pthreadpool.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+if [ ! -x $BINDIR/pthreadpooltest ] ; then
+ # Some machines don't have /bin/true, simulate it
+ cat >$BINDIR/pthreadpooltest <<EOF
+#!/bin/sh
+exit 0
+EOF
+ chmod +x $BINDIR/pthreadpooltest
+fi
+
+failed=0
+
+testit "pthreadpool" $VALGRIND $BINDIR/pthreadpooltest ||
+ failed=`expr $failed + 1`
+
+testok $0 $failed
diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh
index 0395f3e12c6..8937c97bbef 100755
--- a/source3/script/tests/test_smbclient_s3.sh
+++ b/source3/script/tests/test_smbclient_s3.sh
@@ -4,22 +4,23 @@
if [ $# -lt 7 ]; then
cat <<EOF
-Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD USERID LOCAL_PATH PREFIX SMBCLIENT
+Usage: test_smbclient_s3.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD USERID LOCAL_PATH PREFIX SMBCLIENT
EOF
exit 1;
fi
SERVER="$1"
SERVER_IP="$2"
-USERNAME="$3"
-PASSWORD="$4"
-USERID="$5"
-LOCAL_PATH="$6"
-PREFIX="$7"
-SMBCLIENT="$8"
+DOMAIN="$3"
+USERNAME="$4"
+PASSWORD="$5"
+USERID="$6"
+LOCAL_PATH="$7"
+PREFIX="$8"
+SMBCLIENT="$9"
SMBCLIENT="$VALGRIND ${SMBCLIENT}"
WBINFO="$VALGRIND ${WBINFO:-$BINDIR/wbinfo}"
-shift 8
+shift 9
ADDARGS="$*"
incdir=`dirname $0`/../../../testprogs/blackbox
@@ -218,6 +219,7 @@ EOF
if [ $ret != 0 ] ; then
echo "$out"
echo "failed writing into read-only directory with error $ret"
+
false
return
fi
@@ -235,6 +237,49 @@ EOF
fi
}
+
+# Test sending a message
+test_message()
+{
+ tmpfile=$PREFIX/message_in.$$
+
+ cat > $tmpfile <<EOF
+Test message from pid $$
+EOF
+
+ cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD -M $SERVER -p 139 $ADDARGS -n msgtest < $tmpfile 2>&1'
+ eval echo "$cmd"
+ out=`eval $cmd`
+ ret=$?
+
+ if [ $ret != 0 ] ; then
+ echo "$out"
+ echo "failed sending message to $SERVER with error $ret"
+ false
+ rm -f $tmpfile
+ return
+ fi
+
+ cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmpguest -p 139 $ADDARGS -c "get message.msgtest $PREFIX/message_out.$$" 2>&1'
+ eval echo "$cmd"
+ out=`eval $cmd`
+ ret=$?
+
+ if [ $ret != 0 ] ; then
+ echo "$out"
+ echo "failed getting sent message from $SERVER with error $ret"
+ false
+ return
+ fi
+
+ if [ cmp $PREFIX/message_out.$$ $tmpfile != 0 ] ; then
+ echo "failed comparison of message from $SERVER"
+ false
+ return
+ fi
+ true
+}
+
# Test reading an owner-only file (logon as guest) fails.
test_owner_only_file()
{
@@ -389,6 +434,43 @@ test_ccache_access()
$WBINFO --logoff
}
+# Test authenticating using the winbind ccache
+test_auth_file()
+{
+ tmpfile=$PREFIX/smbclient.in.$$
+ cat > $tmpfile <<EOF
+username=${USERNAME}
+password=${PASSWORD}
+domain=${DOMAIN}
+EOF
+ $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile \
+ -c quit 2>&1
+ ret=$?
+ rm $tmpfile
+
+ if [ $ret != 0 ] ; then
+ echo "smbclient failed to use auth file"
+ false
+ return
+ fi
+
+ cat > $tmpfile <<EOF
+username=${USERNAME}
+password=xxxx
+domain=${DOMAIN}
+EOF
+ $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile\
+ -c quit 2>&1
+ ret=$?
+ rm $tmpfile
+
+ if [ $ret -eq 0 ] ; then
+ echo "smbclient succeeded with wrong auth file credentials"
+ false
+ return
+ fi
+}
+
LOGDIR_PREFIX=test_smbclient_s3
# possibly remove old logdirs:
@@ -444,6 +526,14 @@ testit "ccache access works for smbclient" \
test_ccache_access || \
failed=`expr $failed + 1`
+testit "sending a message to the remote server" \
+ test_message || \
+ failed=`expr $failed + 1`
+
+testit "using an authentication file" \
+ test_auth_file || \
+ failed=`expr $failed + 1`
+
testit "rm -rf $LOGDIR" \
rm -rf $LOGDIR || \
failed=`expr $failed + 1`
diff --git a/source3/selftest/knownfail b/source3/selftest/knownfail
index 95f01f64dcf..4f746c8d706 100644
--- a/source3/selftest/knownfail
+++ b/source3/selftest/knownfail
@@ -1,14 +1,16 @@
-samba3.blackbox.failure # this is designed to fail, for testing our test infrastructure
+^samba3.blackbox.failure # this is designed to fail, for testing our test infrastructure
.*printer.*print_test_extended # fails on some hosts due to timing issues ?
.*printer.*print_test # fails on some hosts due to timing issues ?
-samba3.posix_s3.rap.printing # fails sometimes on sn-devel
-samba3.posix_s3.rpc.spoolss.*printserver.enum_printers_old # fails on some hosts due to timing issues ?
-samba3.posix_s3.rpc.spoolss.printer.*addprinterex.print_test # another intermittent failure
-samba3.posix_s3.smb2.lock.*.rw-exclusive # another intermittent failure
+^samba3.posix_s3.rap.printing # fails sometimes on sn-devel
+^samba3.posix_s3.rpc.spoolss.*printserver.enum_printers_old # fails on some hosts due to timing issues ?
+^samba3.posix_s3.rpc.spoolss.printer.*addprinterex.print_test # another intermittent failure
+^samba3.posix_s3.smb2.lock.*.rw-exclusive # another intermittent failure
.*driver.add_driver_timestamps # we only can store dates, not timestamps
-samba3.raw.mux.* #This test is flaky on the async lock time
-samba3.smbtorture_s3.*OPLOCK4 # fails sometimes on sn-devel
-samba3.posix_s3.nbt.dgram.*netlogon2
-samba3.*rap.sam.*.useradd # Not provided by Samba 3
-samba3.*rap.sam.*.userdelete # Not provided by Samba 3
-samba3.*rap.basic.*.netsessiongetinfo # Not provided by Samba 3
+^samba3.raw.mux.* #This test is flaky on the async lock time
+^samba3.smbtorture_s3.*OPLOCK4 # fails sometimes on sn-devel
+^samba3.posix_s3.nbt.dgram.*netlogon2
+^samba3.*rap.sam.*.useradd # Not provided by Samba 3
+^samba3.*rap.sam.*.userdelete # Not provided by Samba 3
+^samba3.*rap.basic.*.netsessiongetinfo # Not provided by Samba 3
+^samba3.posix_s3.libsmbclient .opendir # This requires a workgroup called 'WORKGROUP' and for netbios browse lists to have been registered
+
diff --git a/source3/selftest/ktest-secrets.tdb2 b/source3/selftest/ktest-secrets.tdb2
new file mode 100644
index 00000000000..2af58b140f1
--- /dev/null
+++ b/source3/selftest/ktest-secrets.tdb2
Binary files differ
diff --git a/source3/selftest/quick b/source3/selftest/quick
new file mode 100644
index 00000000000..bb3b066b498
--- /dev/null
+++ b/source3/selftest/quick
@@ -0,0 +1 @@
+#none
diff --git a/source3/selftest/skip b/source3/selftest/skip
index 02166a14578..4366ae68726 100644
--- a/source3/selftest/skip
+++ b/source3/selftest/skip
@@ -1,23 +1,23 @@
-samba3.smbtorture_s3.*.randomipc
-samba3.smbtorture_s3.*.negnowait
-samba3.smbtorture_s3.*.nbench
-samba3.smbtorture_s3.*.errmapextract
-samba3.smbtorture_s3.*.trans2scan
-samba3.smbtorture_s3.*.nttransscan
-samba3.smbtorture_s3.*.deny1
-samba3.smbtorture_s3.*.deny2
-samba3.smbtorture_s3.*.openattr
-samba3.smbtorture_s3.*.casetable
-samba3.smbtorture_s3.*.eatest
-samba3.smbtorture_s3.*.mangle
-samba3.smbtorture_s3.*.utable
-samba3.smbtorture_s3.*.pipe_number
-samba3.smbtorture_s3.*.CHAIN1
-samba3.*base.charset
-samba3.*raw.acls
-samba3.*raw.composite
-samba3.*raw.context
-samba3.*raw.ioctl
-samba3.*raw.qfileinfo
-samba3.*raw.qfsinfo
-samba3.*raw.sfileinfo.base
+^samba3.smbtorture_s3.*.randomipc
+^samba3.smbtorture_s3.*.negnowait
+^samba3.smbtorture_s3.*.nbench
+^samba3.smbtorture_s3.*.errmapextract
+^samba3.smbtorture_s3.*.trans2scan
+^samba3.smbtorture_s3.*.nttransscan
+^samba3.smbtorture_s3.*.deny1
+^samba3.smbtorture_s3.*.deny2
+^samba3.smbtorture_s3.*.openattr
+^samba3.smbtorture_s3.*.casetable
+^samba3.smbtorture_s3.*.eatest
+^samba3.smbtorture_s3.*.mangle
+^samba3.smbtorture_s3.*.utable
+^samba3.smbtorture_s3.*.pipe_number
+^samba3.smbtorture_s3.*.CHAIN1
+^samba3.*base.charset
+^samba3.*raw.acls
+^samba3.*raw.composite
+^samba3.*raw.context
+^samba3.*raw.ioctl
+^samba3.*raw.qfileinfo
+^samba3.*raw.qfsinfo
+^samba3.*raw.sfileinfo.base
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index f05e00537d9..2a3002189c0 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -53,13 +53,14 @@ plantestsuite("samba3.local_s3", "s3dc:local", [os.path.join(samba3srcdir, "scri
tests=[ "FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7", "LOCK9",
"UNLINK", "BROWSE", "ATTR", "TRANS2", "TORTURE",
- "OPLOCK1", "OPLOCK2", "OPLOCK3", "OPLOCK4", "STREAMERROR",
+ "OPLOCK1", "OPLOCK2", "OPLOCK4", "STREAMERROR",
"DIR", "DIR1", "DIR-CREATETIME", "TCON", "TCONDEV", "RW1", "RW2", "RW3", "RW-SIGNING",
"OPEN", "XCOPY", "RENAME", "DELETE", "DELETE-LN", "PROPERTIES", "W2K",
"TCON2", "IOCTL", "CHKPATH", "FDSESS", "LOCAL-SUBSTITUTE", "CHAIN1",
"GETADDRINFO", "POSIX", "UID-REGRESSION-TEST", "SHORTNAME-TEST",
"LOCAL-BASE64", "LOCAL-GENCACHE", "POSIX-APPEND",
"CASE-INSENSITIVE-CREATE",
+ "BAD-NBT-SESSION",
"LOCAL-string_to_sid", "LOCAL-CONVERT-STRING" ]
for t in tests:
@@ -112,20 +113,20 @@ for env in ["secshare", "secserver"]:
# plain
for env in ["s3dc"]:
- plantestsuite("samba3.blackbox.smbclient_s3.plain (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DC_USERNAME', '$DC_PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration])
+ plantestsuite("samba3.blackbox.smbclient_s3.plain (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration])
for env in ["member"]:
- plantestsuite("samba3.blackbox.smbclient_s3.plain (%s) member creds" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$SERVER\\\\$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration])
+ plantestsuite("samba3.blackbox.smbclient_s3.plain (%s) member creds" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$SERVER', '$SERVER\\\\$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration])
for env in ["s3dc"]:
- plantestsuite("samba3.blackbox.smbclient_s3.sign (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DC_USERNAME', '$DC_PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration, "--signing=required"])
+ plantestsuite("samba3.blackbox.smbclient_s3.sign (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration, "--signing=required"])
for env in ["member"]:
- plantestsuite("samba3.blackbox.smbclient_s3.sign (%s) member creds" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$SERVER\\\\$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration, "--signing=required"])
+ plantestsuite("samba3.blackbox.smbclient_s3.sign (%s) member creds" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$SERVER', '$SERVER\\\\$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration, "--signing=required"])
# encrypted
for env in ["s3dc"]:
- plantestsuite("samba3.blackbox.smbclient_s3.crypt (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration, "-e"])
+ plantestsuite("samba3.blackbox.smbclient_s3.crypt (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_s3.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', binpath('smbclient3'), configuration, "-e"])
#TODO encrypted against member, with member creds, and with DC creds
plantestsuite("samba3.blackbox.net.misc", "s3dc:local", [os.path.join(samba3srcdir, "script/tests/test_net_misc.sh"),
@@ -140,6 +141,9 @@ plantestsuite("samba3.blackbox.net.local.registry.roundtrip", "s3dc:local", [os.
plantestsuite("samba3.blackbox.testparm", "s3dc:local", [os.path.join(samba3srcdir, "script/tests/test_testparm_s3.sh"),
"$LOCAL_PATH"])
+plantestsuite(
+ "samba3.pthreadpool", "s3dc",
+ [os.path.join(samba3srcdir, "script/tests/test_pthreadpool.sh")])
#smbtorture4 tests
@@ -157,7 +161,9 @@ raw = ["raw.acls", "raw.chkpath", "raw.close", "raw.composite", "raw.context", "
"raw.sfileinfo.base", "raw.sfileinfo.bug", "raw.streams", "raw.unlink", "raw.write",
"raw.samba3hide", "raw.samba3badpath", "raw.sfileinfo.rename",
"raw.samba3caseinsensitive", "raw.samba3posixtimedlock",
- "raw.samba3rootdirfid", "raw.sfileinfo.end-of-file"]
+ "raw.samba3rootdirfid", "raw.sfileinfo.end-of-file",
+ "raw.bench-oplock", "raw.bench-lock", "raw.bench-open", "raw.bench-tcon",
+ "raw.samba3checkfsp", "raw.samba3closeerr", "raw.samba3oplocklogoff"]
smb2 = ["smb2.lock", "smb2.read", "smb2.compound", "smb2.connect", "smb2.scan", "smb2.scanfind",
"smb2.bench-oplock"]
@@ -186,7 +192,9 @@ unix = ["unix.info2", "unix.whoami"]
nbt = ["nbt.dgram" ]
-tests= base + raw + smb2 + rpc + unix + local + winbind + rap + nbt
+libsmbclient = ["libsmbclient"]
+
+tests= base + raw + smb2 + rpc + unix + local + winbind + rap + nbt + libsmbclient
sub = subprocess.Popen("%s --version 2> /dev/null" % smb4torture, stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
sub.communicate("")
@@ -195,17 +203,17 @@ if sub.returncode == 0:
for t in tests:
if t == "base.delaywrite":
plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD --maximum-runtime=900')
- if t == "rap.sam":
+ elif t == "rap.sam":
plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD --option=doscharset=ISO-8859-1')
elif t == "unix.whoami":
plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmpguest -U$USERNAME%$PASSWORD')
elif t == "raw.samba3posixtimedlock":
plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmpguest -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/s3dc/share')
+ elif t == "raw.chkpath":
+ plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmpcase -U$USERNAME%$PASSWORD')
else:
plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
- if t == "raw.chkpath":
- plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmpcase -U$USERNAME%$PASSWORD')
test = 'rpc.lsa.lookupsids'
auth_options = ["", "ntlm", "spnego" ]
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 682d042806a..db2926b4a4f 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
+#include "../lib/util/tevent_ntstatus.h"
#if defined(WITH_AIO)
@@ -80,8 +81,8 @@ static bool initialize_async_io_handler(void)
}
tried_signal_setup = true;
- aio_signal_event = tevent_add_signal(smbd_event_context(),
- smbd_event_context(),
+ aio_signal_event = tevent_add_signal(server_event_context(),
+ server_event_context(),
RT_SIGNAL_AIO, SA_SIGINFO,
smbd_aio_signal_handler,
NULL);
@@ -115,7 +116,7 @@ static struct aio_extra *create_aio_extra(TALLOC_CTX *mem_ctx,
files_struct *fsp,
size_t buflen)
{
- struct aio_extra *aio_ex = TALLOC_ZERO_P(mem_ctx, struct aio_extra);
+ struct aio_extra *aio_ex = talloc_zero(mem_ctx, struct aio_extra);
if (!aio_ex) {
return NULL;
@@ -250,7 +251,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
struct smb_request *smbreq,
- files_struct *fsp, char *data,
+ files_struct *fsp, const char *data,
SMB_OFF_T startpos,
size_t numtowrite)
{
@@ -328,7 +329,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
/* Now set up the aio record for the write call. */
a->aio_fildes = fsp->fh->fd;
- a->aio_buf = data;
+ a->aio_buf = discard_const_p(char, data);
a->aio_nbytes = numtowrite;
a->aio_offset = startpos;
a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
@@ -1029,7 +1030,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
struct smb_request *smbreq,
- files_struct *fsp, char *data,
+ files_struct *fsp, const char *data,
SMB_OFF_T startpos,
size_t numtowrite)
{
diff --git a/source3/smbd/avahi_register.c b/source3/smbd/avahi_register.c
index 05bd6038f46..368168d41dc 100644
--- a/source3/smbd/avahi_register.c
+++ b/source3/smbd/avahi_register.c
@@ -88,7 +88,7 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status,
}
if (avahi_entry_group_add_service(
state->entry_group, AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC, 0, global_myname(),
+ AVAHI_PROTO_UNSPEC, 0, lp_netbios_name(),
"_smb._tcp", NULL, NULL, state->port, NULL) < 0) {
error = avahi_client_errno(c);
DEBUG(10, ("avahi_entry_group_add_service failed: "
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index c208234bdcf..d9c1fb2d3b3 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -139,7 +139,7 @@ static bool recalc_brl_timeout(struct smbd_server_connection *sconn)
(int)from_now.tv_sec, (int)from_now.tv_usec));
}
- sconn->smb1.locks.brl_timeout = event_add_timed(smbd_event_context(),
+ sconn->smb1.locks.brl_timeout = event_add_timed(server_event_context(),
NULL, next_timeout,
brl_timeout_fn, sconn);
if (sconn->smb1.locks.brl_timeout == NULL) {
@@ -208,8 +208,7 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
blr->expire_time.tv_sec = 0;
blr->expire_time.tv_usec = 0; /* Never expire. */
} else {
- blr->expire_time = timeval_current_ofs(lock_timeout/1000,
- (lock_timeout % 1000) * 1000);
+ blr->expire_time = timeval_current_ofs_msec(lock_timeout);
}
blr->lock_num = lock_num;
blr->smblctx = smblctx;
@@ -337,7 +336,7 @@ static void reply_lockingX_error(struct blocking_lock_record *blr, NTSTATUS stat
uint8_t *data;
int i;
- data = (uint8_t *)blr->req->buf
+ data = discard_const_p(uint8_t, blr->req->buf)
+ ((large_file_format ? 20 : 10)*num_ulocks);
/*
@@ -429,7 +428,7 @@ static bool process_lockingX(struct blocking_lock_record *blr)
uint8_t *data;
NTSTATUS status = NT_STATUS_OK;
- data = (uint8_t *)blr->req->buf
+ data = discard_const_p(uint8_t, blr->req->buf)
+ ((large_file_format ? 20 : 10)*num_ulocks);
/*
@@ -575,9 +574,9 @@ static bool blocking_lock_record_process(struct blocking_lock_record *blr)
Called when a file is closed.
*****************************************************************************/
-void cancel_pending_lock_requests_by_fid(files_struct *fsp,
- struct byte_range_lock *br_lck,
- enum file_close_type close_type)
+void smbd_cancel_pending_lock_requests_by_fid(files_struct *fsp,
+ struct byte_range_lock *br_lck,
+ enum file_close_type close_type)
{
struct smbd_server_connection *sconn = fsp->conn->sconn;
struct blocking_lock_record *blr, *blr_cancelled, *next = NULL;
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index aeed4e3c9d7..52cfc111fbe 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -283,7 +283,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
/* Ensure any pending write time updates are done. */
if (fsp->update_write_time_event) {
- update_write_time_handler(smbd_event_context(),
+ update_write_time_handler(server_event_context(),
fsp->update_write_time_event,
timeval_current(),
(void *)fsp);
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index 16a0ee053e9..a3f66b36be7 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -53,10 +53,9 @@ int conn_num_open(struct smbd_server_connection *sconn)
Check if a snum is in use.
****************************************************************************/
-bool conn_snum_used(int snum)
+bool conn_snum_used(struct smbd_server_connection *sconn,
+ int snum)
{
- struct smbd_server_connection *sconn = smbd_server_conn;
-
if (sconn->using_smb2) {
/* SMB2 */
struct smbd_smb2_session *sess;
@@ -134,8 +133,8 @@ connection_struct *conn_new(struct smbd_server_connection *sconn)
if (sconn->using_smb2) {
/* SMB2 */
- if (!(conn=TALLOC_ZERO_P(NULL, connection_struct)) ||
- !(conn->params = TALLOC_P(conn, struct share_params))) {
+ if (!(conn=talloc_zero(NULL, connection_struct)) ||
+ !(conn->params = talloc(conn, struct share_params))) {
DEBUG(0,("TALLOC_ZERO() failed!\n"));
TALLOC_FREE(conn);
return NULL;
@@ -189,8 +188,8 @@ find_again:
return NULL;
}
- if (!(conn=TALLOC_ZERO_P(NULL, connection_struct)) ||
- !(conn->params = TALLOC_P(conn, struct share_params))) {
+ if (!(conn=talloc_zero(NULL, connection_struct)) ||
+ !(conn->params = talloc(conn, struct share_params))) {
DEBUG(0,("TALLOC_ZERO() failed!\n"));
TALLOC_FREE(conn);
return NULL;
@@ -212,142 +211,52 @@ find_again:
}
/****************************************************************************
- Close all conn structures.
- Return true if any were closed.
-****************************************************************************/
-
-bool conn_close_all(struct smbd_server_connection *sconn)
-{
- bool ret = false;
- if (sconn->using_smb2) {
- /* SMB2 */
- struct smbd_smb2_session *sess;
- for (sess = sconn->smb2.sessions.list; sess; sess = sess->next) {
- struct smbd_smb2_tcon *tcon, *tc_next;
-
- for (tcon = sess->tcons.list; tcon; tcon = tc_next) {
- tc_next = tcon->next;
- TALLOC_FREE(tcon);
- ret = true;
- }
- }
- } else {
- /* SMB1 */
- connection_struct *conn, *next;
-
- for (conn=sconn->smb1.tcons.Connections;conn;conn=next) {
- next=conn->next;
- set_current_service(conn, 0, True);
- close_cnum(conn, conn->vuid);
- ret = true;
- }
- }
- return ret;
-}
-
-/****************************************************************************
- Update last used timestamps.
-****************************************************************************/
-
-static void conn_lastused_update(struct smbd_server_connection *sconn,time_t t)
-{
- if (sconn->using_smb2) {
- /* SMB2 */
- struct smbd_smb2_session *sess;
- for (sess = sconn->smb2.sessions.list; sess; sess = sess->next) {
- struct smbd_smb2_tcon *ptcon;
-
- for (ptcon = sess->tcons.list; ptcon; ptcon = ptcon->next) {
- connection_struct *conn = ptcon->compat_conn;
- /* Update if connection wasn't idle. */
- if (conn && conn->lastused != conn->lastused_count) {
- conn->lastused = t;
- conn->lastused_count = t;
- }
- }
- }
- } else {
- /* SMB1 */
- connection_struct *conn;
- for (conn=sconn->smb1.tcons.Connections;conn;conn=conn->next) {
- /* Update if connection wasn't idle. */
- if (conn->lastused != conn->lastused_count) {
- conn->lastused = t;
- conn->lastused_count = t;
- }
- }
- }
-}
-
-/****************************************************************************
- Idle inactive connections.
+ Clear a vuid out of the connection's vuid cache
****************************************************************************/
-bool conn_idle_all(struct smbd_server_connection *sconn, time_t t)
+static void conn_clear_vuid_cache(connection_struct *conn, uint16_t vuid)
{
- int deadtime = lp_deadtime()*60;
-
- conn_lastused_update(sconn, t);
-
- if (deadtime <= 0) {
- deadtime = DEFAULT_SMBD_TIMEOUT;
- }
-
- if (sconn->using_smb2) {
- /* SMB2 */
- struct smbd_smb2_session *sess;
- for (sess = sconn->smb2.sessions.list; sess; sess = sess->next) {
- struct smbd_smb2_tcon *ptcon;
-
- for (ptcon = sess->tcons.list; ptcon; ptcon = ptcon->next) {
- time_t age;
- connection_struct *conn = ptcon->compat_conn;
-
- if (conn == NULL) {
- continue;
- }
-
- age = t - conn->lastused;
- /* close dirptrs on connections that are idle */
- if (age > DPTR_IDLE_TIMEOUT) {
- dptr_idlecnum(conn);
- }
-
- if (conn->num_files_open > 0 || age < deadtime) {
- return false;
- }
- }
- }
- } else {
- /* SMB1 */
- connection_struct *conn;
- for (conn=sconn->smb1.tcons.Connections;conn;conn=conn->next) {
- time_t age = t - conn->lastused;
-
- /* close dirptrs on connections that are idle */
- if (age > DPTR_IDLE_TIMEOUT) {
- dptr_idlecnum(conn);
- }
+ int i;
- if (conn->num_files_open > 0 || age < deadtime) {
- return false;
+ for (i=0; i<VUID_CACHE_SIZE; i++) {
+ struct vuid_cache_entry *ent;
+
+ ent = &conn->vuid_cache.array[i];
+
+ if (ent->vuid == vuid) {
+ ent->vuid = UID_FIELD_INVALID;
+ /*
+ * We need to keep conn->session_info around
+ * if it's equal to ent->session_info as a SMBulogoff
+ * is often followed by a SMBtdis (with an invalid
+ * vuid). The debug code (or regular code in
+ * vfs_full_audit) wants to refer to the
+ * conn->session_info pointer to print debug
+ * statements. Theoretically this is a bug,
+ * as once the vuid is gone the session_info
+ * on the conn struct isn't valid any more,
+ * but there's enough code that assumes
+ * conn->session_info is never null that
+ * it's easier to hold onto the old pointer
+ * until we get a new sessionsetupX.
+ * As everything is hung off the
+ * conn pointer as a talloc context we're not
+ * leaking memory here. See bug #6315. JRA.
+ */
+ if (conn->session_info == ent->session_info) {
+ ent->session_info = NULL;
+ } else {
+ TALLOC_FREE(ent->session_info);
}
+ ent->read_only = False;
}
}
-
- /*
- * Check all pipes for any open handles. We cannot
- * idle with a handle open.
- */
- if (check_open_pipes()) {
- return false;
- }
-
- return true;
}
/****************************************************************************
Clear a vuid out of the validity cache, and as the 'owner' of a connection.
+
+ Called from invalidate_vuid()
****************************************************************************/
void conn_clear_vuid_caches(struct smbd_server_connection *sconn,uint16_t vuid)
@@ -451,64 +360,3 @@ void conn_free(connection_struct *conn)
conn_free_internal(conn);
}
-
-/****************************************************************************
- Receive a smbcontrol message to forcibly unmount a share.
- The message contains just a share name and all instances of that
- share are unmounted.
- The special sharename '*' forces unmount of all shares.
-****************************************************************************/
-
-void msg_force_tdis(struct messaging_context *msg,
- void *private_data,
- uint32_t msg_type,
- struct server_id server_id,
- DATA_BLOB *data)
-{
- struct smbd_server_connection *sconn;
- connection_struct *conn, *next;
- fstring sharename;
-
- sconn = msg_ctx_to_sconn(msg);
- if (sconn == NULL) {
- DEBUG(1, ("could not find sconn\n"));
- return;
- }
-
- fstrcpy(sharename, (const char *)data->data);
-
- if (strcmp(sharename, "*") == 0) {
- DEBUG(1,("Forcing close of all shares\n"));
- conn_close_all(sconn);
- return;
- }
-
- if (sconn->using_smb2) {
- /* SMB2 */
- struct smbd_smb2_session *sess;
- for (sess = sconn->smb2.sessions.list; sess; sess = sess->next) {
- struct smbd_smb2_tcon *tcon, *tc_next;
-
- for (tcon = sess->tcons.list; tcon; tcon = tc_next) {
- tc_next = tcon->next;
- if (tcon->compat_conn &&
- strequal(lp_servicename(SNUM(tcon->compat_conn)),
- sharename)) {
- DEBUG(1,("Forcing close of share %s cnum=%d\n",
- sharename, tcon->compat_conn->cnum));
- TALLOC_FREE(tcon);
- }
- }
- }
- } else {
- /* SMB1 */
- for (conn=sconn->smb1.tcons.Connections;conn;conn=next) {
- next=conn->next;
- if (strequal(lp_servicename(SNUM(conn)), sharename)) {
- DEBUG(1,("Forcing close of share %s cnum=%d\n",
- sharename, conn->cnum));
- close_cnum(conn, (uint16)-1);
- }
- }
- }
-}
diff --git a/source3/smbd/conn_idle.c b/source3/smbd/conn_idle.c
new file mode 100644
index 00000000000..46f5b7b111c
--- /dev/null
+++ b/source3/smbd/conn_idle.c
@@ -0,0 +1,207 @@
+/*
+ Unix SMB/CIFS implementation.
+ Manage connections_struct structures
+ Copyright (C) Andrew Tridgell 1998
+ Copyright (C) Alexander Bokovoy 2002
+ Copyright (C) Jeremy Allison 2010
+
+ 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 "smbd/smbd.h"
+#include "smbd/globals.h"
+#include "rpc_server/rpc_ncacn_np.h"
+
+/****************************************************************************
+ Update last used timestamps.
+****************************************************************************/
+
+static void conn_lastused_update(struct smbd_server_connection *sconn,time_t t)
+{
+ if (sconn->using_smb2) {
+ /* SMB2 */
+ struct smbd_smb2_session *sess;
+ for (sess = sconn->smb2.sessions.list; sess; sess = sess->next) {
+ struct smbd_smb2_tcon *ptcon;
+
+ for (ptcon = sess->tcons.list; ptcon; ptcon = ptcon->next) {
+ connection_struct *conn = ptcon->compat_conn;
+ /* Update if connection wasn't idle. */
+ if (conn && conn->lastused != conn->lastused_count) {
+ conn->lastused = t;
+ conn->lastused_count = t;
+ }
+ }
+ }
+ } else {
+ /* SMB1 */
+ connection_struct *conn;
+ for (conn=sconn->smb1.tcons.Connections;conn;conn=conn->next) {
+ /* Update if connection wasn't idle. */
+ if (conn->lastused != conn->lastused_count) {
+ conn->lastused = t;
+ conn->lastused_count = t;
+ }
+ }
+ }
+}
+
+/****************************************************************************
+ Idle inactive connections.
+****************************************************************************/
+
+bool conn_idle_all(struct smbd_server_connection *sconn, time_t t)
+{
+ int deadtime = lp_deadtime()*60;
+
+ conn_lastused_update(sconn, t);
+
+ if (deadtime <= 0) {
+ deadtime = DEFAULT_SMBD_TIMEOUT;
+ }
+
+ if (sconn->using_smb2) {
+ /* SMB2 */
+ struct smbd_smb2_session *sess;
+ for (sess = sconn->smb2.sessions.list; sess; sess = sess->next) {
+ struct smbd_smb2_tcon *ptcon;
+
+ for (ptcon = sess->tcons.list; ptcon; ptcon = ptcon->next) {
+ time_t age;
+ connection_struct *conn = ptcon->compat_conn;
+
+ if (conn == NULL) {
+ continue;
+ }
+
+ age = t - conn->lastused;
+ /* close dirptrs on connections that are idle */
+ if (age > DPTR_IDLE_TIMEOUT) {
+ dptr_idlecnum(conn);
+ }
+
+ if (conn->num_files_open > 0 || age < deadtime) {
+ return false;
+ }
+ }
+ }
+ } else {
+ /* SMB1 */
+ connection_struct *conn;
+ for (conn=sconn->smb1.tcons.Connections;conn;conn=conn->next) {
+ time_t age = t - conn->lastused;
+
+ /* close dirptrs on connections that are idle */
+ if (age > DPTR_IDLE_TIMEOUT) {
+ dptr_idlecnum(conn);
+ }
+
+ if (conn->num_files_open > 0 || age < deadtime) {
+ return false;
+ }
+ }
+ }
+
+ /*
+ * Check all pipes for any open handles. We cannot
+ * idle with a handle open.
+ */
+ if (check_open_pipes()) {
+ return false;
+ }
+
+ return true;
+}
+
+/****************************************************************************
+ Close all conn structures.
+ Return true if any were closed.
+****************************************************************************/
+
+bool conn_close_all(struct smbd_server_connection *sconn)
+{
+ bool ret = false;
+ if (sconn->using_smb2) {
+ /* SMB2 */
+ struct smbd_smb2_session *sess;
+ for (sess = sconn->smb2.sessions.list; sess; sess = sess->next) {
+ struct smbd_smb2_tcon *tcon, *tc_next;
+
+ for (tcon = sess->tcons.list; tcon; tcon = tc_next) {
+ tc_next = tcon->next;
+ TALLOC_FREE(tcon);
+ ret = true;
+ }
+ }
+ } else {
+ /* SMB1 */
+ connection_struct *conn, *next;
+
+ for (conn=sconn->smb1.tcons.Connections;conn;conn=next) {
+ next=conn->next;
+ set_current_service(conn, 0, True);
+ close_cnum(conn, conn->vuid);
+ ret = true;
+ }
+ }
+ return ret;
+}
+
+
+/****************************************************************************
+ Forcibly unmount a share.
+ All instances of the parameter 'sharename' share are unmounted.
+ The special sharename '*' forces unmount of all shares.
+****************************************************************************/
+
+void conn_force_tdis(struct smbd_server_connection *sconn, const char *sharename)
+{
+ connection_struct *conn, *next;
+
+ if (strcmp(sharename, "*") == 0) {
+ DEBUG(1,("Forcing close of all shares\n"));
+ conn_close_all(sconn);
+ return;
+ }
+
+ if (sconn->using_smb2) {
+ /* SMB2 */
+ struct smbd_smb2_session *sess;
+ for (sess = sconn->smb2.sessions.list; sess; sess = sess->next) {
+ struct smbd_smb2_tcon *tcon, *tc_next;
+
+ for (tcon = sess->tcons.list; tcon; tcon = tc_next) {
+ tc_next = tcon->next;
+ if (tcon->compat_conn &&
+ strequal(lp_servicename(SNUM(tcon->compat_conn)),
+ sharename)) {
+ DEBUG(1,("Forcing close of share %s cnum=%d\n",
+ sharename, tcon->compat_conn->cnum));
+ TALLOC_FREE(tcon);
+ }
+ }
+ }
+ } else {
+ /* SMB1 */
+ for (conn=sconn->smb1.tcons.Connections;conn;conn=next) {
+ next=conn->next;
+ if (strequal(lp_servicename(SNUM(conn)), sharename)) {
+ DEBUG(1,("Forcing close of share %s cnum=%d\n",
+ sharename, conn->cnum));
+ close_cnum(conn, (uint16)-1);
+ }
+ }
+ }
+}
diff --git a/source3/smbd/conn_msg.c b/source3/smbd/conn_msg.c
new file mode 100644
index 00000000000..b0c968a6807
--- /dev/null
+++ b/source3/smbd/conn_msg.c
@@ -0,0 +1,49 @@
+/*
+ Unix SMB/CIFS implementation.
+ Manage connections_struct structures
+ Copyright (C) Andrew Tridgell 1998
+ Copyright (C) Alexander Bokovoy 2002
+ Copyright (C) Jeremy Allison 2010
+
+ 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 "smbd/smbd.h"
+#include "smbd/globals.h"
+
+/****************************************************************************
+ Receive a smbcontrol message to forcibly unmount a share.
+ The message contains just a share name and all instances of that
+ share are unmounted.
+ The special sharename '*' forces unmount of all shares.
+****************************************************************************/
+
+void msg_force_tdis(struct messaging_context *msg,
+ void *private_data,
+ uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data)
+{
+ struct smbd_server_connection *sconn;
+ const char *sharename = (const char *)data->data;
+
+ sconn = msg_ctx_to_sconn(msg);
+ if (sconn == NULL) {
+ DEBUG(1, ("could not find sconn\n"));
+ return;
+ }
+
+ conn_force_tdis(sconn, sharename);
+}
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index 8560a5d211b..7ed9518756b 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -101,6 +101,7 @@ static int count_fn(struct db_record *rec,
int count_current_connections( const char *sharename, bool clear )
{
struct count_stat cs;
+ int ret;
cs.curr_connections = 0;
cs.name = sharename;
@@ -111,10 +112,18 @@ int count_current_connections( const char *sharename, bool clear )
* as it leads to deadlock.
*/
- if (connections_forall(count_fn, &cs) == -1) {
+ /*
+ * become_root() because we might have to open connections.tdb
+ * via ctdb, which is not possible without root.
+ */
+ become_root();
+ ret = connections_forall(count_fn, &cs);
+ unbecome_root();
+
+ if (ret < 0) {
DEBUG(0,("count_current_connections: traverse of "
"connections.tdb failed\n"));
- return False;
+ return 0;
}
return cs.curr_connections;
diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c
index 63c287cd417..03541880e15 100644
--- a/source3/smbd/dfree.c
+++ b/source3/smbd/dfree.c
@@ -207,7 +207,7 @@ uint64_t get_dfree_info(connection_struct *conn,
/* No cached info or time to refresh. */
if (!dfc) {
- dfc = TALLOC_P(conn, struct dfree_cached_info);
+ dfc = talloc(conn, struct dfree_cached_info);
if (!dfc) {
return dfree_ret;
}
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 5fc87a608fd..fda7c34c578 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -92,7 +92,7 @@ bool make_dir_struct(TALLOC_CTX *ctx,
return False;
}
- if ((mode & aDIR) != 0) {
+ if ((mode & FILE_ATTRIBUTE_DIRECTORY) != 0) {
size = 0;
}
@@ -872,15 +872,15 @@ bool dir_check_ftype(connection_struct *conn, uint32 mode, uint32 dirtype)
uint32 mask;
/* Check the "may have" search bits. */
- if (((mode & ~dirtype) & (aHIDDEN | aSYSTEM | aDIR)) != 0)
+ if (((mode & ~dirtype) & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY)) != 0)
return False;
/* Check the "must have" bits, which are the may have bits shifted eight */
/* If must have bit is set, the file/dir can not be returned in search unless the matching
file attribute is set */
- mask = ((dirtype >> 8) & (aDIR|aARCH|aRONLY|aHIDDEN|aSYSTEM)); /* & 0x37 */
+ mask = ((dirtype >> 8) & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM)); /* & 0x37 */
if(mask) {
- if((mask & (mode & (aDIR|aARCH|aRONLY|aHIDDEN|aSYSTEM))) == mask) /* check if matching attribute present */
+ if((mask & (mode & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))) == mask) /* check if matching attribute present */
return True;
else
return False;
@@ -1342,7 +1342,7 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn,
const char *mask,
uint32 attr)
{
- struct smb_Dir *dirp = TALLOC_ZERO_P(mem_ctx, struct smb_Dir);
+ struct smb_Dir *dirp = talloc_zero(mem_ctx, struct smb_Dir);
struct smbd_server_connection *sconn = conn->sconn;
if (!dirp) {
@@ -1386,7 +1386,7 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct *conn,
const char *mask,
uint32 attr)
{
- struct smb_Dir *dirp = TALLOC_ZERO_P(mem_ctx, struct smb_Dir);
+ struct smb_Dir *dirp = talloc_zero(mem_ctx, struct smb_Dir);
struct smbd_server_connection *sconn = conn->sconn;
if (!dirp) {
@@ -1559,7 +1559,7 @@ void DirCacheAdd(struct smb_Dir *dirp, const char *name, long offset)
}
if (dirp->name_cache == NULL) {
- dirp->name_cache = TALLOC_ZERO_ARRAY(
+ dirp->name_cache = talloc_zero_array(
dirp, struct name_cache_entry, dirp->name_cache_size);
if (dirp->name_cache == NULL) {
@@ -1625,8 +1625,8 @@ bool SearchDir(struct smb_Dir *dirp, const char *name, long *poffset)
Is this directory empty ?
*****************************************************************/
-NTSTATUS can_delete_directory(struct connection_struct *conn,
- const char *dirname)
+NTSTATUS smbd_can_delete_directory(struct connection_struct *conn,
+ const char *dirname)
{
NTSTATUS status = NT_STATUS_OK;
long dirpos = 0;
diff --git a/source3/smbd/dmapi.c b/source3/smbd/dmapi.c
index 2869b6d781c..8e80a588c5f 100644
--- a/source3/smbd/dmapi.c
+++ b/source3/smbd/dmapi.c
@@ -96,7 +96,7 @@ static int dmapi_init_session(struct smbd_dmapi_context *ctx)
do {
dm_sessid_t *new_sessions;
nsessions *= 2;
- new_sessions = TALLOC_REALLOC_ARRAY(tmp_ctx, sessions,
+ new_sessions = talloc_realloc(tmp_ctx, sessions,
dm_sessid_t, nsessions);
if (new_sessions == NULL) {
talloc_free(tmp_ctx);
@@ -289,7 +289,7 @@ uint32 dmapi_file_flags(const char * const path)
become_root();
#endif
- err = dm_path_to_handle(CONST_DISCARD(char *, path),
+ err = dm_path_to_handle(discard_const_p(char, path),
&dm_handle, &dm_handle_len);
if (err < 0) {
DEBUG(DMAPI_TRACE, ("dm_path_to_handle(%s): %s\n",
@@ -308,7 +308,7 @@ uint32 dmapi_file_flags(const char * const path)
set_effective_capability(DMAPI_ACCESS_CAPABILITY);
- err = dm_path_to_handle(CONST_DISCARD(char *, path),
+ err = dm_path_to_handle(discard_const_p(char, path),
&dm_handle, &dm_handle_len);
if (err < 0) {
DEBUG(DMAPI_TRACE,
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index a9b6dfef78e..823d44d0aaf 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -41,7 +41,7 @@ static int set_link_read_only_flag(const SMB_STRUCT_STAT *const sbuf)
#ifdef S_ISLNK
#if LINKS_READ_ONLY
if (S_ISLNK(sbuf->st_mode) && S_ISDIR(sbuf->st_mode))
- return aRONLY;
+ return FILE_ATTRIBUTE_READONLY;
#endif
#endif
return 0;
@@ -173,36 +173,36 @@ static uint32 dos_mode_from_sbuf(connection_struct *conn,
if (ro_opts == MAP_READONLY_YES) {
/* Original Samba method - map inverse of user "w" bit. */
if ((smb_fname->st.st_ex_mode & S_IWUSR) == 0) {
- result |= aRONLY;
+ result |= FILE_ATTRIBUTE_READONLY;
}
} else if (ro_opts == MAP_READONLY_PERMISSIONS) {
/* Check actual permissions for read-only. */
if (!can_write_to_file(conn, smb_fname)) {
- result |= aRONLY;
+ result |= FILE_ATTRIBUTE_READONLY;
}
} /* Else never set the readonly bit. */
if (MAP_ARCHIVE(conn) && ((smb_fname->st.st_ex_mode & S_IXUSR) != 0))
- result |= aARCH;
+ result |= FILE_ATTRIBUTE_ARCHIVE;
if (MAP_SYSTEM(conn) && ((smb_fname->st.st_ex_mode & S_IXGRP) != 0))
- result |= aSYSTEM;
+ result |= FILE_ATTRIBUTE_SYSTEM;
if (MAP_HIDDEN(conn) && ((smb_fname->st.st_ex_mode & S_IXOTH) != 0))
- result |= aHIDDEN;
+ result |= FILE_ATTRIBUTE_HIDDEN;
if (S_ISDIR(smb_fname->st.st_ex_mode))
- result = aDIR | (result & aRONLY);
+ result = FILE_ATTRIBUTE_DIRECTORY | (result & FILE_ATTRIBUTE_READONLY);
result |= set_link_read_only_flag(&smb_fname->st);
DEBUG(8,("dos_mode_from_sbuf returning "));
- if (result & aHIDDEN) DEBUG(8, ("h"));
- if (result & aRONLY ) DEBUG(8, ("r"));
- if (result & aSYSTEM) DEBUG(8, ("s"));
- if (result & aDIR ) DEBUG(8, ("d"));
- if (result & aARCH ) DEBUG(8, ("a"));
+ if (result & FILE_ATTRIBUTE_HIDDEN) DEBUG(8, ("h"));
+ if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
+ if (result & FILE_ATTRIBUTE_SYSTEM) DEBUG(8, ("s"));
+ if (result & FILE_ATTRIBUTE_DIRECTORY ) DEBUG(8, ("d"));
+ if (result & FILE_ATTRIBUTE_ARCHIVE ) DEBUG(8, ("a"));
DEBUG(8,("\n"));
return result;
@@ -318,18 +318,18 @@ static bool get_ea_dos_attribute(connection_struct *conn,
}
if (S_ISDIR(smb_fname->st.st_ex_mode)) {
- dosattr |= aDIR;
+ dosattr |= FILE_ATTRIBUTE_DIRECTORY;
}
/* FILE_ATTRIBUTE_SPARSE is valid on get but not on set. */
*pattr = (uint32)(dosattr & (SAMBA_ATTRIBUTES_MASK|FILE_ATTRIBUTE_SPARSE));
DEBUG(8,("get_ea_dos_attribute returning (0x%x)", dosattr));
- if (dosattr & aHIDDEN) DEBUG(8, ("h"));
- if (dosattr & aRONLY ) DEBUG(8, ("r"));
- if (dosattr & aSYSTEM) DEBUG(8, ("s"));
- if (dosattr & aDIR ) DEBUG(8, ("d"));
- if (dosattr & aARCH ) DEBUG(8, ("a"));
+ if (dosattr & FILE_ATTRIBUTE_HIDDEN) DEBUG(8, ("h"));
+ if (dosattr & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
+ if (dosattr & FILE_ATTRIBUTE_SYSTEM) DEBUG(8, ("s"));
+ if (dosattr & FILE_ATTRIBUTE_DIRECTORY ) DEBUG(8, ("d"));
+ if (dosattr & FILE_ATTRIBUTE_ARCHIVE ) DEBUG(8, ("a"));
DEBUG(8,("\n"));
@@ -465,7 +465,7 @@ uint32 dos_mode_msdfs(connection_struct *conn,
/* Only . and .. are not hidden. */
if (p[0] == '.' && !((p[1] == '\0') ||
(p[1] == '.' && p[2] == '\0'))) {
- result |= aHIDDEN;
+ result |= FILE_ATTRIBUTE_HIDDEN;
}
}
@@ -473,9 +473,9 @@ uint32 dos_mode_msdfs(connection_struct *conn,
/* Optimization : Only call is_hidden_path if it's not already
hidden. */
- if (!(result & aHIDDEN) &&
+ if (!(result & FILE_ATTRIBUTE_HIDDEN) &&
IS_HIDDEN_PATH(conn, smb_fname->base_name)) {
- result |= aHIDDEN;
+ result |= FILE_ATTRIBUTE_HIDDEN;
}
if (result == 0) {
@@ -486,11 +486,11 @@ uint32 dos_mode_msdfs(connection_struct *conn,
DEBUG(8,("dos_mode_msdfs returning "));
- if (result & aHIDDEN) DEBUG(8, ("h"));
- if (result & aRONLY ) DEBUG(8, ("r"));
- if (result & aSYSTEM) DEBUG(8, ("s"));
- if (result & aDIR ) DEBUG(8, ("d"));
- if (result & aARCH ) DEBUG(8, ("a"));
+ if (result & FILE_ATTRIBUTE_HIDDEN) DEBUG(8, ("h"));
+ if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
+ if (result & FILE_ATTRIBUTE_SYSTEM) DEBUG(8, ("s"));
+ if (result & FILE_ATTRIBUTE_DIRECTORY ) DEBUG(8, ("d"));
+ if (result & FILE_ATTRIBUTE_ARCHIVE ) DEBUG(8, ("a"));
if (result & FILE_ATTRIBUTE_SPARSE ) DEBUG(8, ("[sparse]"));
DEBUG(8,("\n"));
@@ -507,13 +507,13 @@ int dos_attributes_to_stat_dos_flags(uint32_t dosmode)
{
uint32_t dos_stat_flags = 0;
- if (dosmode & aARCH)
+ if (dosmode & FILE_ATTRIBUTE_ARCHIVE)
dos_stat_flags |= UF_DOS_ARCHIVE;
- if (dosmode & aHIDDEN)
+ if (dosmode & FILE_ATTRIBUTE_HIDDEN)
dos_stat_flags |= UF_DOS_HIDDEN;
- if (dosmode & aRONLY)
+ if (dosmode & FILE_ATTRIBUTE_READONLY)
dos_stat_flags |= UF_DOS_RO;
- if (dosmode & aSYSTEM)
+ if (dosmode & FILE_ATTRIBUTE_SYSTEM)
dos_stat_flags |= UF_DOS_SYSTEM;
if (dosmode & FILE_ATTRIBUTE_NONINDEXED)
dos_stat_flags |= UF_DOS_NOINDEX;
@@ -540,19 +540,19 @@ static bool get_stat_dos_flags(connection_struct *conn,
smb_fname_str_dbg(smb_fname)));
if (smb_fname->st.st_ex_flags & UF_DOS_ARCHIVE)
- *dosmode |= aARCH;
+ *dosmode |= FILE_ATTRIBUTE_ARCHIVE;
if (smb_fname->st.st_ex_flags & UF_DOS_HIDDEN)
- *dosmode |= aHIDDEN;
+ *dosmode |= FILE_ATTRIBUTE_HIDDEN;
if (smb_fname->st.st_ex_flags & UF_DOS_RO)
- *dosmode |= aRONLY;
+ *dosmode |= FILE_ATTRIBUTE_READONLY;
if (smb_fname->st.st_ex_flags & UF_DOS_SYSTEM)
- *dosmode |= aSYSTEM;
+ *dosmode |= FILE_ATTRIBUTE_SYSTEM;
if (smb_fname->st.st_ex_flags & UF_DOS_NOINDEX)
*dosmode |= FILE_ATTRIBUTE_NONINDEXED;
if (smb_fname->st.st_ex_flags & FILE_ATTRIBUTE_SPARSE)
*dosmode |= FILE_ATTRIBUTE_SPARSE;
if (S_ISDIR(smb_fname->st.st_ex_mode))
- *dosmode |= aDIR;
+ *dosmode |= FILE_ATTRIBUTE_DIRECTORY;
*dosmode |= set_link_read_only_flag(&smb_fname->st);
@@ -637,7 +637,7 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
/* Only . and .. are not hidden. */
if (p[0] == '.' && !((p[1] == '\0') ||
(p[1] == '.' && p[2] == '\0'))) {
- result |= aHIDDEN;
+ result |= FILE_ATTRIBUTE_HIDDEN;
}
}
@@ -658,9 +658,9 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
/* Optimization : Only call is_hidden_path if it's not already
hidden. */
- if (!(result & aHIDDEN) &&
+ if (!(result & FILE_ATTRIBUTE_HIDDEN) &&
IS_HIDDEN_PATH(conn, smb_fname->base_name)) {
- result |= aHIDDEN;
+ result |= FILE_ATTRIBUTE_HIDDEN;
}
if (result == 0) {
@@ -671,11 +671,11 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
DEBUG(8,("dos_mode returning "));
- if (result & aHIDDEN) DEBUG(8, ("h"));
- if (result & aRONLY ) DEBUG(8, ("r"));
- if (result & aSYSTEM) DEBUG(8, ("s"));
- if (result & aDIR ) DEBUG(8, ("d"));
- if (result & aARCH ) DEBUG(8, ("a"));
+ if (result & FILE_ATTRIBUTE_HIDDEN) DEBUG(8, ("h"));
+ if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
+ if (result & FILE_ATTRIBUTE_SYSTEM) DEBUG(8, ("s"));
+ if (result & FILE_ATTRIBUTE_DIRECTORY ) DEBUG(8, ("d"));
+ if (result & FILE_ATTRIBUTE_ARCHIVE ) DEBUG(8, ("a"));
if (result & FILE_ATTRIBUTE_SPARSE ) DEBUG(8, ("[sparse]"));
DEBUG(8,("\n"));
@@ -712,9 +712,9 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
&smb_fname->st.st_ex_mode);
if (S_ISDIR(smb_fname->st.st_ex_mode))
- dosmode |= aDIR;
+ dosmode |= FILE_ATTRIBUTE_DIRECTORY;
else
- dosmode &= ~aDIR;
+ dosmode &= ~FILE_ATTRIBUTE_DIRECTORY;
new_create_timespec = smb_fname->st.st_ex_btime;
diff --git a/source3/smbd/error.c b/source3/smbd/error.c
index 6655a6fb082..2fb4241968d 100644
--- a/source3/smbd/error.c
+++ b/source3/smbd/error.c
@@ -21,9 +21,6 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
-/* From lib/error.c */
-extern struct unix_error_map unix_dos_nt_errmap[];
-
bool use_nt_status(void)
{
return lp_nt_status_support() && (global_client_caps & CAP_STATUS32);
@@ -80,11 +77,10 @@ void error_packet_set(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatu
smb_fn_name(CVAL(outbuf,smb_com)),
nt_errstr(ntstatus)));
} else {
- /* We're returning a DOS error only. */
- if (NT_STATUS_IS_DOS(ntstatus)) {
- eclass = NT_STATUS_DOS_CLASS(ntstatus);
- ecode = NT_STATUS_DOS_CODE(ntstatus);
- } else if (eclass == 0 && NT_STATUS_V(ntstatus)) {
+ /* We're returning a DOS error only,
+ * nt_status_to_dos() pulls DOS error codes out of the
+ * NTSTATUS */
+ if (NT_STATUS_IS_DOS(ntstatus) || (eclass == 0 && NT_STATUS_V(ntstatus))) {
ntstatus_to_dos(ntstatus, &eclass, &ecode);
}
diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c
index 960dcb703a5..74855649ea2 100644
--- a/source3/smbd/file_access.c
+++ b/source3/smbd/file_access.c
@@ -92,6 +92,11 @@ bool can_delete_file_in_directory(connection_struct *conn,
return False;
}
+ if (!lp_acl_check_permissions(SNUM(conn))) {
+ /* This option means don't check. */
+ return true;
+ }
+
/* Get the parent directory permission mask and owners. */
if (!parent_dirname(ctx, smb_fname->base_name, &dname, NULL)) {
return False;
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 16d8853b54c..3b317f9a863 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -240,8 +240,8 @@ void trigger_write_time_update(struct files_struct *fsp)
/* trigger the update 2 seconds later */
fsp->update_write_time_event =
- event_add_timed(smbd_event_context(), NULL,
- timeval_current_ofs(0, delay),
+ event_add_timed(server_event_context(), NULL,
+ timeval_current_ofs_usec(delay),
update_write_time_handler, fsp);
}
@@ -322,7 +322,7 @@ ssize_t write_file(struct smb_request *req,
int dosmode = dos_mode(fsp->conn, fsp->fsp_name);
if (!IS_DOS_ARCHIVE(dosmode)) {
file_set_dosmode(fsp->conn, fsp->fsp_name,
- dosmode | aARCH, NULL, false);
+ dosmode | FILE_ATTRIBUTE_ARCHIVE, NULL, false);
}
}
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 08bc79dfd22..ec8d1139faa 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -163,11 +163,11 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx,
* last compnent to shorten the tree walk. */
/*
- * Safe to use CONST_DISCARD
+ * Safe to use discard_const_p
* here as last_component points
* into our smb_fname->base_name.
*/
- *pp_start = CONST_DISCARD(char *,last_component);
+ *pp_start = discard_const_p(char, last_component);
/* Update dirpath. */
TALLOC_FREE(*pp_dirpath);
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index b9063ccbb89..b8a25c1d5b6 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -21,6 +21,8 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "libcli/security/security.h"
+#include "util_tdb.h"
+#include <ccan/hash/hash.h>
#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < real_max_open_files))
@@ -598,7 +600,6 @@ NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *from,
NTSTATUS file_name_hash(connection_struct *conn,
const char *name, uint32_t *p_name_hash)
{
- TDB_DATA key;
char *fullpath = NULL;
/* Set the hash of the full pathname. */
@@ -609,8 +610,7 @@ NTSTATUS file_name_hash(connection_struct *conn,
if (!fullpath) {
return NT_STATUS_NO_MEMORY;
}
- key = string_term_tdb_data(fullpath);
- *p_name_hash = tdb_jenkins_hash(&key);
+ *p_name_hash = hash(fullpath, strlen(fullpath) + 1, 0);
DEBUG(10,("file_name_hash: %s hash 0x%x\n",
fullpath,
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index 63c1f5dcb5d..2736fa69d0b 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -20,8 +20,10 @@
#include "includes.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
+#include "lib/smbd_shim.h"
#include "memcache.h"
#include "messages.h"
+#include "tdb_compat.h"
#if defined(WITH_AIO)
struct aio_extra *aio_list_head = NULL;
@@ -144,14 +146,29 @@ struct memcache *smbd_memcache(void)
return smbd_memcache_ctx;
}
+static const struct smbd_shim smbd_shim_fns =
+{
+ .cancel_pending_lock_requests_by_fid = smbd_cancel_pending_lock_requests_by_fid,
+ .send_stat_cache_delete_message = smbd_send_stat_cache_delete_message,
+ .can_delete_directory = smbd_can_delete_directory,
+ .change_to_root_user = smbd_change_to_root_user,
+
+ .contend_level2_oplocks_begin = smbd_contend_level2_oplocks_begin,
+ .contend_level2_oplocks_end = smbd_contend_level2_oplocks_end,
+
+ .become_root = smbd_become_root,
+ .unbecome_root = smbd_unbecome_root
+};
void smbd_init_globals(void)
{
+ set_smbd_shim(&smbd_shim_fns);
+
ZERO_STRUCT(conn_ctx_stack);
ZERO_STRUCT(sec_ctx_stack);
- smbd_server_conn = talloc_zero(smbd_event_context(), struct smbd_server_connection);
+ smbd_server_conn = talloc_zero(server_event_context(), struct smbd_server_connection);
if (!smbd_server_conn) {
exit_server("failed to create smbd_server_connection");
}
@@ -159,3 +176,32 @@ void smbd_init_globals(void)
smbd_server_conn->smb1.echo_handler.trusted_fd = -1;
smbd_server_conn->smb1.echo_handler.socket_lock_fd = -1;
}
+
+void smbd_set_server_fd(int fd)
+{
+ struct smbd_server_connection *sconn = smbd_server_conn;
+ char addr[INET6_ADDRSTRLEN];
+ const char *name;
+
+ sconn->sock = fd;
+
+ /*
+ * Initialize sconn->client_id: If we can't find the client's
+ * name, default to its address.
+ */
+
+ client_addr(fd, sconn->client_id.addr, sizeof(sconn->client_id.addr));
+
+ name = client_name(sconn->sock);
+ if (strcmp(name, "UNKNOWN") != 0) {
+ name = talloc_strdup(sconn, name);
+ } else {
+ name = NULL;
+ }
+ sconn->client_id.name =
+ (name != NULL) ? name : sconn->client_id.addr;
+
+ sub_set_socket_ids(sconn->client_id.addr, sconn->client_id.name,
+ client_socket_addr(sconn->sock, addr,
+ sizeof(addr)));
+}
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 01be31a57f9..97d75fd4137 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -47,7 +47,8 @@ struct fsp_singleton_cache {
extern const struct mangle_fns *mangle_fns;
extern unsigned char *chartest;
-extern TDB_CONTEXT *tdb_mangled_cache;
+struct tdb_context;
+extern struct tdb_context *tdb_mangled_cache;
/*
this determines how many characters are used from the original filename
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index 4f2fea52658..669e28e715c 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -28,6 +28,7 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "smbprofile.h"
+#include "rpc_server/srv_pipe_hnd.h"
#define NERR_notsupported 50
@@ -267,7 +268,7 @@ static void api_dcerpc_cmd(connection_struct *conn, struct smb_request *req,
state->num_data = length;
state->max_read = max_read;
- subreq = np_write_send(state, smbd_event_context(), state->handle,
+ subreq = np_write_send(state, server_event_context(), state->handle,
state->data, length);
if (subreq == NULL) {
TALLOC_FREE(state);
@@ -297,14 +298,14 @@ static void api_dcerpc_cmd_write_done(struct tevent_req *subreq)
goto send;
}
- state->data = TALLOC_REALLOC_ARRAY(state, state->data, uint8_t,
+ state->data = talloc_realloc(state, state->data, uint8_t,
state->max_read);
if (state->data == NULL) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
goto send;
}
- subreq = np_read_send(req->conn, smbd_event_context(),
+ subreq = np_read_send(req->conn, server_event_context(),
state->handle, state->data, state->max_read);
if (subreq == NULL) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
@@ -644,7 +645,7 @@ void reply_trans(struct smb_request *req)
return;
}
- if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {
+ if ((state = talloc(conn, struct trans_state)) == NULL) {
DEBUG(0, ("talloc failed\n"));
reply_nterror(req, NT_STATUS_NO_MEMORY);
END_PROFILE(SMBtrans);
@@ -741,7 +742,7 @@ void reply_trans(struct smb_request *req)
goto bad_param;
}
- if((state->setup = TALLOC_ARRAY(
+ if((state->setup = talloc_array(
state, uint16, state->setup_count)) == NULL) {
DEBUG(0,("reply_trans: setup malloc fail for %u "
"bytes !\n", (unsigned int)
@@ -807,7 +808,7 @@ void reply_transs(struct smb_request *req)
START_PROFILE(SMBtranss);
- show_msg((char *)req->inbuf);
+ show_msg((const char *)req->inbuf);
if (req->wct < 8) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 13297c02221..dac91b2a40b 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -34,17 +34,15 @@
#include "rpc_client/cli_spoolss.h"
#include "rpc_client/init_spoolss.h"
#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
-#include "../librpc/gen_ndr/srv_samr.h"
-#include "../librpc/gen_ndr/srv_srvsvc.h"
#include "../librpc/gen_ndr/rap.h"
#include "../lib/util/binsearch.h"
#include "../libcli/auth/libcli_auth.h"
#include "rpc_client/init_lsa.h"
-#include "rpc_server/rpc_ncacn_np.h"
#include "../libcli/security/security.h"
#include "printing.h"
#include "passdb/machine_sid.h"
#include "auth.h"
+#include "rpc_server/rpc_ncacn_np.h"
#ifdef CHECK_TYPES
#undef CHECK_TYPES
@@ -614,9 +612,9 @@ static void fill_printq_info_52(struct spoolss_DriverInfo3 *driver,
{
int i;
fstring location;
- trim_string((char *)driver->driver_path, "\\print$\\WIN40\\0\\", 0);
- trim_string((char *)driver->data_file, "\\print$\\WIN40\\0\\", 0);
- trim_string((char *)driver->help_file, "\\print$\\WIN40\\0\\", 0);
+ trim_string(discard_const_p(char, driver->driver_path), "\\print$\\WIN40\\0\\", 0);
+ trim_string(discard_const_p(char, driver->data_file), "\\print$\\WIN40\\0\\", 0);
+ trim_string(discard_const_p(char, driver->help_file), "\\print$\\WIN40\\0\\", 0);
PACKI(desc, "W", 0x0400); /* don't know */
PACKS(desc, "z", driver->driver_name); /* long printer name */
@@ -643,7 +641,7 @@ static void fill_printq_info_52(struct spoolss_DriverInfo3 *driver,
for ( i=0; i<count && driver->dependent_files && *driver->dependent_files[i]; i++)
{
- trim_string((char *)driver->dependent_files[i], "\\print$\\WIN40\\0\\", 0);
+ trim_string(discard_const_p(char, driver->dependent_files[i]), "\\print$\\WIN40\\0\\", 0);
PACKS(desc,"z",driver->dependent_files[i]); /* driver files to copy */
DEBUG(3,("Dependent File: %s:\n", driver->dependent_files[i]));
}
@@ -1429,7 +1427,7 @@ static int fill_srv_info(struct srv_info_struct *service,
static int srv_comp(struct srv_info_struct *s1,struct srv_info_struct *s2)
{
- return StrCaseCmp(s1->name,s2->name);
+ return strcasecmp_m(s1->name,s2->name);
}
/****************************************************************************
@@ -1598,7 +1596,7 @@ static int srv_name_match(const char *n1, const char *n2)
* the server will return a list of servers that exist on
* the network greater than or equal to the FirstNameToReturn.
*/
- int ret = StrCaseCmp(n1, n2);
+ int ret = strcasecmp_m(n1, n2);
if (ret <= 0) {
return 0;
@@ -1710,7 +1708,7 @@ static bool api_RNetServerEnum3(struct smbd_server_connection *sconn,
*/
for (;first > 0;) {
int ret;
- ret = StrCaseCmp(first_name,
+ ret = strcasecmp_m(first_name,
servers[first-1].name);
if (ret > 0) {
break;
@@ -2094,7 +2092,7 @@ static bool api_RNetShareEnum(struct smbd_server_connection *sconn,
/* Ensure all the usershares are loaded. */
become_root();
load_registry_shares();
- count = load_usershare_shares();
+ count = load_usershare_shares(sconn);
unbecome_root();
data_len = fixed_len = string_len = 0;
@@ -2256,7 +2254,7 @@ static bool api_RNetShareAdd(struct smbd_server_connection *sconn,
return false;
}
- status = rpc_pipe_open_internal(mem_ctx, &ndr_table_srvsvc.syntax_id,
+ status = rpc_pipe_open_interface(mem_ctx, &ndr_table_srvsvc.syntax_id,
conn->session_info,
&conn->sconn->client_id,
conn->sconn->msg_ctx,
@@ -2367,7 +2365,7 @@ static bool api_RNetGroupEnum(struct smbd_server_connection *sconn,
return False;
}
- status = rpc_pipe_open_internal(
+ status = rpc_pipe_open_interface(
talloc_tos(), &ndr_table_samr.syntax_id,
conn->session_info, &conn->sconn->client_id,
conn->sconn->msg_ctx, &samr_pipe);
@@ -2379,7 +2377,7 @@ static bool api_RNetGroupEnum(struct smbd_server_connection *sconn,
b = samr_pipe->binding_handle;
- status = dcerpc_samr_Connect2(b, talloc_tos(), global_myname(),
+ status = dcerpc_samr_Connect2(b, talloc_tos(), lp_netbios_name(),
SAMR_ACCESS_LOOKUP_DOMAIN, &samr_handle,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -2573,7 +2571,7 @@ static bool api_NetUserGetGroups(struct smbd_server_connection *sconn,
p = *rdata;
endp = *rdata + *rdata_len;
- status = rpc_pipe_open_internal(
+ status = rpc_pipe_open_interface(
talloc_tos(), &ndr_table_samr.syntax_id,
conn->session_info, &conn->sconn->client_id,
conn->sconn->msg_ctx, &samr_pipe);
@@ -2585,7 +2583,7 @@ static bool api_NetUserGetGroups(struct smbd_server_connection *sconn,
b = samr_pipe->binding_handle;
- status = dcerpc_samr_Connect2(b, talloc_tos(), global_myname(),
+ status = dcerpc_samr_Connect2(b, talloc_tos(), lp_netbios_name(),
SAMR_ACCESS_LOOKUP_DOMAIN, &samr_handle,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -2765,7 +2763,7 @@ static bool api_RNetUserEnum(struct smbd_server_connection *sconn,
p = *rdata;
endp = *rdata + *rdata_len;
- status = rpc_pipe_open_internal(
+ status = rpc_pipe_open_interface(
talloc_tos(), &ndr_table_samr.syntax_id,
conn->session_info, &conn->sconn->client_id,
conn->sconn->msg_ctx, &samr_pipe);
@@ -2777,7 +2775,7 @@ static bool api_RNetUserEnum(struct smbd_server_connection *sconn,
b = samr_pipe->binding_handle;
- status = dcerpc_samr_Connect2(b, talloc_tos(), global_myname(),
+ status = dcerpc_samr_Connect2(b, talloc_tos(), lp_netbios_name(),
SAMR_ACCESS_LOOKUP_DOMAIN, &samr_handle,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -3031,7 +3029,7 @@ static bool api_SetUserPassword(struct smbd_server_connection *sconn,
ZERO_STRUCT(domain_handle);
ZERO_STRUCT(user_handle);
- status = rpc_pipe_open_internal(mem_ctx, &ndr_table_samr.syntax_id,
+ status = rpc_pipe_open_interface(mem_ctx, &ndr_table_samr.syntax_id,
conn->session_info,
&conn->sconn->client_id,
conn->sconn->msg_ctx,
@@ -3046,7 +3044,7 @@ static bool api_SetUserPassword(struct smbd_server_connection *sconn,
b = cli->binding_handle;
status = dcerpc_samr_Connect2(b, mem_ctx,
- global_myname(),
+ lp_netbios_name(),
SAMR_ACCESS_CONNECT_TO_SERVER |
SAMR_ACCESS_ENUM_DOMAINS |
SAMR_ACCESS_LOOKUP_DOMAIN,
@@ -3282,7 +3280,7 @@ static bool api_SamOEMChangePassword(struct smbd_server_connection *sconn,
memcpy(password.data, data, 516);
memcpy(hash.hash, data+516, 16);
- status = rpc_pipe_open_internal(mem_ctx, &ndr_table_samr.syntax_id,
+ status = rpc_pipe_open_interface(mem_ctx, &ndr_table_samr.syntax_id,
conn->session_info,
&conn->sconn->client_id,
conn->sconn->msg_ctx,
@@ -3296,7 +3294,7 @@ static bool api_SamOEMChangePassword(struct smbd_server_connection *sconn,
b = cli->binding_handle;
- init_lsa_AsciiString(&server, global_myname());
+ init_lsa_AsciiString(&server, lp_netbios_name());
init_lsa_AsciiString(&account, user);
status = dcerpc_samr_OemChangePasswordUser2(b, mem_ctx,
@@ -3866,7 +3864,7 @@ static bool api_RNetServerGetInfo(struct smbd_server_connection *sconn,
p = *rdata;
p2 = p + struct_len;
- status = rpc_pipe_open_internal(mem_ctx, &ndr_table_srvsvc.syntax_id,
+ status = rpc_pipe_open_interface(mem_ctx, &ndr_table_srvsvc.syntax_id,
conn->session_info,
&conn->sconn->client_id,
conn->sconn->msg_ctx,
@@ -4029,8 +4027,8 @@ static bool api_NetWkstaGetInfo(struct smbd_server_connection *sconn,
}
p += 4;
- SCVAL(p,0,lp_major_announce_version()); /* system version - e.g 4 in 4.1 */
- SCVAL(p,1,lp_minor_announce_version()); /* system version - e.g .1 in 4.1 */
+ SCVAL(p,0,SAMBA_MAJOR_NBT_ANNOUNCE_VERSION); /* system version - e.g 4 in 4.1 */
+ SCVAL(p,1,SAMBA_MINOR_NBT_ANNOUNCE_VERSION); /* system version - e.g .1 in 4.1 */
p += 2;
SIVAL(p,0,PTR_DIFF(p2,*rdata));
@@ -4293,7 +4291,7 @@ static bool api_RNetUserGetInfo(struct smbd_server_connection *sconn,
ZERO_STRUCT(domain_handle);
ZERO_STRUCT(user_handle);
- status = rpc_pipe_open_internal(mem_ctx, &ndr_table_samr.syntax_id,
+ status = rpc_pipe_open_interface(mem_ctx, &ndr_table_samr.syntax_id,
conn->session_info,
&conn->sconn->client_id,
conn->sconn->msg_ctx,
@@ -4308,7 +4306,7 @@ static bool api_RNetUserGetInfo(struct smbd_server_connection *sconn,
b = cli->binding_handle;
status = dcerpc_samr_Connect2(b, mem_ctx,
- global_myname(),
+ lp_netbios_name(),
SAMR_ACCESS_CONNECT_TO_SERVER |
SAMR_ACCESS_ENUM_DOMAINS |
SAMR_ACCESS_LOOKUP_DOMAIN,
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index d98b350a37e..c196a13ed02 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -25,6 +25,7 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "mangle.h"
+#include "util_tdb.h"
/* -------------------------------------------------------------------------- **
* Other stuff...
@@ -86,7 +87,7 @@ static void init_valid_table(void)
return;
}
- valid_table = (uint8 *)map_file(data_path("valid.dat"), 0x10000);
+ valid_table = (uint8 *)map_file(data_path(talloc_tos(), "valid.dat"), 0x10000);
if (!valid_table) {
smb_panic("Could not load valid.dat file required for mangle method=hash");
return;
@@ -473,7 +474,7 @@ static void cache_mangled_name( const char mangled_name[13],
return;
/* Init the string lengths. */
- safe_strcpy(mangled_name_key, mangled_name, sizeof(mangled_name_key)-1);
+ strlcpy(mangled_name_key, mangled_name, sizeof(mangled_name_key));
/* See if the extensions are unmangled. If so, store the entry
* without the extension, thus creating a "group" reverse map.
@@ -638,7 +639,7 @@ static bool to_8_3(char magic_char, const char *in, char out[13], int default_ca
if( p ) {
if( p == s )
- safe_strcpy( extension, "___", 3 );
+ strlcpy( extension, "___", 4);
else {
*p++ = 0;
while( *p && extlen < 3 ) {
@@ -670,7 +671,7 @@ static bool to_8_3(char magic_char, const char *in, char out[13], int default_ca
if( *extension ) {
out[baselen+3] = '.';
- safe_strcpy(&out[baselen+4], extension, 3);
+ strlcpy(&out[baselen+4], extension, 4);
}
SAFE_FREE(s);
@@ -738,7 +739,7 @@ static bool hash_name_to_8_3(const char *in,
if (NT_STATUS_IS_OK(is_valid_name(in_ucs2, False, False)) &&
NT_STATUS_IS_OK(is_8_3_w(in_ucs2, False))) {
TALLOC_FREE(in_ucs2);
- safe_strcpy(out, in, 12);
+ strlcpy(out, in, 13);
return True;
}
@@ -772,8 +773,13 @@ const struct mangle_fns *mangle_hash_init(void)
mangle_reset();
/* Create the in-memory tdb using our custom hash function. */
+#ifndef BUILD_TDB2
tdb_mangled_cache = tdb_open_ex("mangled_cache", 1031, TDB_INTERNAL,
(O_RDWR|O_CREAT), 0644, NULL, fast_string_hash);
+#else
+ /* FIXME: We should *never* open a tdb without logging! */
+ tdb_mangled_cache = tdb_open("mangled_cache", TDB_INTERNAL, 0, 0, NULL);
+#endif
return &mangle_hash_fns;
}
diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c
index a39bb895c28..4de80cbe31b 100644
--- a/source3/smbd/mangle_hash2.c
+++ b/source3/smbd/mangle_hash2.c
@@ -705,7 +705,7 @@ static bool hash2_name_to_8_3(const char *name,
/* if the name is already a valid 8.3 name then we don't need to
* change anything */
if (is_legal_name(name) && is_8_3(name, False, False, p)) {
- safe_strcpy(new_name, name, 12);
+ strlcpy(new_name, name, 13);
return True;
}
}
diff --git a/source3/smbd/message.c b/source3/smbd/message.c
index 34997a13dc5..63b08e12620 100644
--- a/source3/smbd/message.c
+++ b/source3/smbd/message.c
@@ -202,7 +202,7 @@ void reply_sendstrt(struct smb_request *req)
TALLOC_FREE(smbd_msg_state);
- smbd_msg_state = TALLOC_ZERO_P(NULL, struct msg_state);
+ smbd_msg_state = talloc_zero(NULL, struct msg_state);
if (smbd_msg_state == NULL) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
@@ -259,7 +259,7 @@ void reply_sendtxt(struct smb_request *req)
len = MIN(SVAL(msg, 0), smbreq_bufrem(req, msg+2));
- tmp = TALLOC_REALLOC_ARRAY(smbd_msg_state, smbd_msg_state->msg,
+ tmp = talloc_realloc(smbd_msg_state, smbd_msg_state->msg,
char, old_len + len);
if (tmp == NULL) {
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index ab67ac8596d..47c2b1ee786 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -231,7 +231,7 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
char *oldcwd;
const char *vfs_user;
- conn = TALLOC_ZERO_P(ctx, connection_struct);
+ conn = talloc_zero(ctx, connection_struct);
if (conn == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -252,7 +252,7 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
/* needed for smbd_vfs_init() */
- if (!(conn->params = TALLOC_ZERO_P(conn, struct share_params))) {
+ if (!(conn->params = talloc_zero(conn, struct share_params))) {
DEBUG(0, ("TALLOC failed\n"));
TALLOC_FREE(conn);
return NT_STATUS_NO_MEMORY;
@@ -364,7 +364,7 @@ static bool parse_msdfs_symlink(TALLOC_CTX *ctx,
return False;
}
- alt_path = TALLOC_ARRAY(ctx, char *, MAX_REFERRAL_COUNT);
+ alt_path = talloc_array(ctx, char *, MAX_REFERRAL_COUNT);
if (!alt_path) {
return False;
}
@@ -378,7 +378,7 @@ static bool parse_msdfs_symlink(TALLOC_CTX *ctx,
DEBUG(10,("parse_msdfs_symlink: count=%d\n", count));
if (count) {
- reflist = *preflist = TALLOC_ZERO_ARRAY(ctx,
+ reflist = *preflist = talloc_zero_array(ctx,
struct referral, count);
if(reflist == NULL) {
TALLOC_FREE(alt_path);
@@ -443,7 +443,7 @@ static bool is_msdfs_link_internal(TALLOC_CTX *ctx,
if (pp_link_target) {
bufsize = 1024;
- link_target = TALLOC_ARRAY(ctx, char, bufsize);
+ link_target = talloc_array(ctx, char, bufsize);
if (!link_target) {
return False;
}
@@ -692,7 +692,7 @@ static NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
bool *ppath_contains_wcard)
{
NTSTATUS status;
- struct dfs_path *pdp = TALLOC_P(ctx, struct dfs_path);
+ struct dfs_path *pdp = talloc(ctx, struct dfs_path);
if (!pdp) {
return NT_STATUS_NO_MEMORY;
@@ -794,7 +794,7 @@ static NTSTATUS self_ref(TALLOC_CTX *ctx,
*self_referralp = True;
jucn->referral_count = 1;
- if((ref = TALLOC_ZERO_P(ctx, struct referral)) == NULL) {
+ if((ref = talloc_zero(ctx, struct referral)) == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -825,7 +825,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
int snum;
NTSTATUS status = NT_STATUS_NOT_FOUND;
bool dummy;
- struct dfs_path *pdp = TALLOC_P(ctx, struct dfs_path);
+ struct dfs_path *pdp = talloc(ctx, struct dfs_path);
char *oldpath;
if (!pdp) {
@@ -899,7 +899,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
*/
jucn->referral_count = 1;
- if ((ref = TALLOC_ZERO_P(ctx, struct referral)) == NULL) {
+ if ((ref = talloc_zero(ctx, struct referral)) == NULL) {
TALLOC_FREE(pdp);
return NT_STATUS_NO_MEMORY;
}
@@ -1233,7 +1233,7 @@ int setup_dfs_referral(connection_struct *orig_conn,
pathnamep++;
}
- junction = TALLOC_ZERO_P(ctx, struct junction_map);
+ junction = talloc_zero(ctx, struct junction_map);
if (!junction) {
*pstatus = NT_STATUS_NO_MEMORY;
talloc_destroy(ctx);
@@ -1318,7 +1318,7 @@ bool create_junction(TALLOC_CTX *ctx,
{
int snum;
bool dummy;
- struct dfs_path *pdp = TALLOC_P(ctx,struct dfs_path);
+ struct dfs_path *pdp = talloc(ctx,struct dfs_path);
NTSTATUS status;
if (!pdp) {
@@ -1630,7 +1630,7 @@ static int form_junctions(TALLOC_CTX *ctx,
jucn[cnt].comment = "";
jucn[cnt].referral_count = 1;
- ref = jucn[cnt].referral_list = TALLOC_ZERO_P(ctx, struct referral);
+ ref = jucn[cnt].referral_list = talloc_zero(ctx, struct referral);
if (jucn[cnt].referral_list == NULL) {
goto out;
}
@@ -1709,7 +1709,8 @@ out:
return cnt;
}
-struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn)
+struct junction_map *enum_msdfs_links(struct smbd_server_connection *sconn,
+ TALLOC_CTX *ctx, size_t *p_num_jn)
{
struct junction_map *jn = NULL;
int i=0;
@@ -1724,7 +1725,7 @@ struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn)
/* Ensure all the usershares are loaded. */
become_root();
load_registry_shares();
- sharecount = load_usershare_shares();
+ sharecount = load_usershare_shares(sconn);
unbecome_root();
for(i=0;i < sharecount;i++) {
@@ -1735,7 +1736,7 @@ struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn)
if (jn_count == 0) {
return NULL;
}
- jn = TALLOC_ARRAY(ctx, struct junction_map, jn_count);
+ jn = talloc_array(ctx, struct junction_map, jn_count);
if (!jn) {
return NULL;
}
@@ -1786,7 +1787,7 @@ NTSTATUS resolve_dfspath_wcard(TALLOC_CTX *ctx,
* Once srvstr_get_path() uses talloc it'll
* be a talloced ptr anyway.
*/
- *pp_name_out = CONST_DISCARD(char *,name_in);
+ *pp_name_out = discard_const_p(char, name_in);
}
return status;
}
diff --git a/source3/smbd/msg_idmap.c b/source3/smbd/msg_idmap.c
index b1ee60ff7f7..2a00f1bbb91 100644
--- a/source3/smbd/msg_idmap.c
+++ b/source3/smbd/msg_idmap.c
@@ -27,10 +27,8 @@
#include "includes.h"
#include "smbd/smbd.h"
-#include "memcache.h"
#include "globals.h"
#include "../libcli/security/dom_sid.h"
-#include "../librpc/gen_ndr/ndr_security.h"
#include "idmap_cache.h"
#include "passdb/lookup_sid.h"
#include "auth.h"
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index 6877ccc861f..a6d7cc0ab3e 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -224,7 +224,7 @@ DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbd_server_connection *sconn)
} else {
fstring myname;
char *host_princ_s = NULL;
- name_to_fqdn(myname, global_myname());
+ name_to_fqdn(myname, lp_netbios_name());
strlower_m(myname);
if (asprintf(&host_princ_s, "cifs/%s@%s", myname, lp_realm())
== -1) {
@@ -234,6 +234,10 @@ DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbd_server_connection *sconn)
SAFE_FREE(host_princ_s);
}
+ if (blob.length == 0 || blob.data == NULL) {
+ return data_blob_null;
+ }
+
blob_out = data_blob_talloc(ctx, NULL, 16 + blob.length);
if (blob_out.data == NULL) {
data_blob_free(&blob);
@@ -242,10 +246,10 @@ DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbd_server_connection *sconn)
memset(blob_out.data, '\0', 16);
- checked_strlcpy(unix_name, global_myname(), sizeof(unix_name));
+ checked_strlcpy(unix_name, lp_netbios_name(), sizeof(unix_name));
strlower_m(unix_name);
push_ascii_nstring(dos_name, unix_name);
- safe_strcpy((char *)blob_out.data, dos_name, 16);
+ strlcpy((char *)blob_out.data, dos_name, 17);
#ifdef DEVELOPER
/* Fix valgrind 'uninitialized bytes' issue. */
@@ -569,7 +573,7 @@ void reply_negprot(struct smb_request *req)
char **tmp;
- tmp = TALLOC_REALLOC_ARRAY(talloc_tos(), cliprotos, char *,
+ tmp = talloc_realloc(talloc_tos(), cliprotos, char *,
num_cliprotos+1);
if (tmp == NULL) {
DEBUG(0, ("talloc failed\n"));
@@ -712,6 +716,11 @@ void reply_negprot(struct smb_request *req)
}
TALLOC_FREE(cliprotos);
+
+ if (lp_async_smb_echo_handler() && !fork_echo_handler(sconn)) {
+ exit_server("Failed to fork echo handler");
+ }
+
END_PROFILE(SMBnegprot);
return;
}
diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c
index 24385c94a0d..8160d5ac638 100644
--- a/source3/smbd/notify.c
+++ b/source3/smbd/notify.c
@@ -183,7 +183,7 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
SMB_ASSERT(fsp->notify == NULL);
- if (!(fsp->notify = TALLOC_ZERO_P(NULL, struct notify_change_buf))) {
+ if (!(fsp->notify = talloc_zero(NULL, struct notify_change_buf))) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
@@ -424,7 +424,7 @@ static void notify_fsp(files_struct *fsp, uint32 action, const char *name)
return;
}
- if (!(changes = TALLOC_REALLOC_ARRAY(
+ if (!(changes = talloc_realloc(
fsp->notify, fsp->notify->changes,
struct notify_change, fsp->notify->num_changes+1))) {
DEBUG(0, ("talloc_realloc failed\n"));
@@ -520,7 +520,7 @@ struct sys_notify_context *sys_notify_context_create(connection_struct *conn,
{
struct sys_notify_context *ctx;
- if (!(ctx = TALLOC_P(mem_ctx, struct sys_notify_context))) {
+ if (!(ctx = talloc(mem_ctx, struct sys_notify_context))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c
index a8eaf793921..a0193a44679 100644
--- a/source3/smbd/notify_internal.c
+++ b/source3/smbd/notify_internal.c
@@ -29,6 +29,8 @@
#include "dbwrap.h"
#include "smbd/smbd.h"
#include "messages.h"
+#include "lib/util/tdb_wrap.h"
+#include "util_tdb.h"
struct notify_context {
struct db_context *db_recursive;
@@ -196,7 +198,7 @@ static NTSTATUS notify_load(struct notify_context *notify, struct db_record *rec
notify->seqnum = seqnum;
talloc_free(notify->array);
- notify->array = TALLOC_ZERO_P(notify, struct notify_array);
+ notify->array = talloc_zero(notify, struct notify_array);
NT_STATUS_HAVE_NO_MEMORY(notify->array);
if (!rec) {
@@ -529,7 +531,7 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0,
depth = count_chars(e.path, '/');
- listel = TALLOC_ZERO_P(notify, struct notify_list);
+ listel = talloc_zero(notify, struct notify_list);
if (listel == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -597,7 +599,7 @@ NTSTATUS notify_remove_onelevel(struct notify_context *notify,
rec = notify->db_onelevel->fetch_locked(
notify->db_onelevel, array,
- make_tdb_data((uint8_t *)fid, sizeof(*fid)));
+ make_tdb_data((const uint8_t *)fid, sizeof(*fid)));
if (rec == NULL) {
DEBUG(10, ("notify_remove_onelevel: fetch_locked for %s failed"
"\n", file_id_string_tos(fid)));
@@ -841,7 +843,7 @@ void notify_onelevel(struct notify_context *notify, uint32_t action,
if (notify->db_onelevel->fetch(
notify->db_onelevel, array,
make_tdb_data((uint8_t *)&fid, sizeof(fid)),
- &dbuf) == -1) {
+ &dbuf) != 0) {
TALLOC_FREE(array);
return;
}
diff --git a/source3/smbd/ntquotas.c b/source3/smbd/ntquotas.c
index d0056756ac0..1f4fc2d0a21 100644
--- a/source3/smbd/ntquotas.c
+++ b/source3/smbd/ntquotas.c
@@ -22,6 +22,7 @@
#include "../lib/util/util_pw.h"
#include "system/passwd.h"
#include "passdb/lookup_sid.h"
+#include "libsmb/libsmb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_QUOTA
@@ -200,14 +201,14 @@ int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list)
DEBUG(15,("quota entry for id[%s] path[%s]\n",
sid_string_dbg(&sid), fsp->conn->connectpath));
- if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) {
+ if ((tmp_list_ent=talloc_zero(mem_ctx,SMB_NTQUOTA_LIST))==NULL) {
DEBUG(0,("TALLOC_ZERO() failed\n"));
*qt_list = NULL;
talloc_destroy(mem_ctx);
return (-1);
}
- if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) {
+ if ((tmp_list_ent->quotas=talloc_zero(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) {
DEBUG(0,("TALLOC_ZERO() failed\n"));
*qt_list = NULL;
talloc_destroy(mem_ctx);
@@ -240,7 +241,7 @@ void *init_quota_handle(TALLOC_CTX *mem_ctx)
if (!mem_ctx)
return False;
- qt_handle = TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_HANDLE);
+ qt_handle = talloc_zero(mem_ctx,SMB_NTQUOTA_HANDLE);
if (qt_handle==NULL) {
DEBUG(0,("TALLOC_ZERO() failed\n"));
return NULL;
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 71f20ac77e0..5fdb07d769a 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -29,6 +29,7 @@
#include "auth.h"
#include "ntioctl.h"
#include "smbprofile.h"
+#include "libsmb/libsmb.h"
extern const struct generic_mapping file_generic_mapping;
@@ -1363,7 +1364,7 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
/* Ensure attributes match. */
fattr = dos_mode(conn, smb_fname_src);
- if ((fattr & ~attrs) & (aHIDDEN | aSYSTEM)) {
+ if ((fattr & ~attrs) & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
status = NT_STATUS_NO_SUCH_FILE;
goto out;
}
@@ -1450,7 +1451,7 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
status = close_file(NULL, fsp2, NORMAL_CLOSE);
- /* Grrr. We have to do this as open_file_ntcreate adds aARCH when it
+ /* Grrr. We have to do this as open_file_ntcreate adds FILE_ATTRIBUTE_ARCHIVE when it
creates the file. This isn't the correct thing to do in the copy
case. JRA */
if (!parent_dirname(talloc_tos(), smb_fname_dst->base_name, &parent,
@@ -2213,8 +2214,7 @@ static void call_nt_transact_ioctl(connection_struct *conn,
* Allocate the correct amount and return the pointer to let
* it be deallocated when we return.
*/
- SHADOW_COPY_DATA *shadow_data = NULL;
- TALLOC_CTX *shadow_mem_ctx = NULL;
+ struct shadow_copy_data *shadow_data = NULL;
bool labels = False;
uint32 labels_data_count = 0;
uint32 i;
@@ -2235,28 +2235,19 @@ static void call_nt_transact_ioctl(connection_struct *conn,
labels = True;
}
- shadow_mem_ctx = talloc_init("SHADOW_COPY_DATA");
- if (shadow_mem_ctx == NULL) {
- DEBUG(0,("talloc_init(SHADOW_COPY_DATA) failed!\n"));
- reply_nterror(req, NT_STATUS_NO_MEMORY);
- return;
- }
-
- shadow_data = TALLOC_ZERO_P(shadow_mem_ctx,SHADOW_COPY_DATA);
+ shadow_data = talloc_zero(talloc_tos(),
+ struct shadow_copy_data);
if (shadow_data == NULL) {
DEBUG(0,("TALLOC_ZERO() failed!\n"));
- talloc_destroy(shadow_mem_ctx);
reply_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
- shadow_data->mem_ctx = shadow_mem_ctx;
-
/*
* Call the VFS routine to actually do the work.
*/
if (SMB_VFS_GET_SHADOW_COPY_DATA(fsp, shadow_data, labels)!=0) {
- talloc_destroy(shadow_data->mem_ctx);
+ TALLOC_FREE(shadow_data);
if (errno == ENOSYS) {
DEBUG(5,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\n",
conn->connectpath));
@@ -2281,14 +2272,14 @@ static void call_nt_transact_ioctl(connection_struct *conn,
if (max_data_count<data_count) {
DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) too small (%u) bytes needed!\n",
max_data_count,data_count));
- talloc_destroy(shadow_data->mem_ctx);
+ TALLOC_FREE(shadow_data);
reply_nterror(req, NT_STATUS_BUFFER_TOO_SMALL);
return;
}
pdata = nttrans_realloc(ppdata, data_count);
if (pdata == NULL) {
- talloc_destroy(shadow_data->mem_ctx);
+ TALLOC_FREE(shadow_data);
reply_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
@@ -2321,7 +2312,7 @@ static void call_nt_transact_ioctl(connection_struct *conn,
}
}
- talloc_destroy(shadow_data->mem_ctx);
+ TALLOC_FREE(shadow_data);
send_nt_replies(conn, req, NT_STATUS_OK, NULL, 0,
pdata, data_count);
@@ -2861,7 +2852,7 @@ static void handle_nttrans(connection_struct *conn,
{
if (get_Protocol() >= PROTOCOL_NT1) {
req->flags2 |= 0x40; /* IS_LONG_NAME */
- SSVAL(req->inbuf,smb_flg2,req->flags2);
+ SSVAL(discard_const_p(uint8_t, req->inbuf),smb_flg2,req->flags2);
}
@@ -3029,7 +3020,7 @@ void reply_nttrans(struct smb_request *req)
return;
}
- if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {
+ if ((state = talloc(conn, struct trans_state)) == NULL) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
END_PROFILE(SMBnttrans);
return;
@@ -3203,7 +3194,7 @@ void reply_nttranss(struct smb_request *req)
START_PROFILE(SMBnttranss);
- show_msg((char *)req->inbuf);
+ show_msg((const char *)req->inbuf);
if (req->wct < 18) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 14e6bf9b4e6..86a5924f16e 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -77,6 +77,16 @@ NTSTATUS smbd_check_open_rights(struct connection_struct *conn,
NTSTATUS status;
struct security_descriptor *sd = NULL;
+ if ((access_mask & DELETE_ACCESS) && !lp_acl_check_permissions(SNUM(conn))) {
+ *access_granted = access_mask;
+
+ DEBUG(10,("smbd_check_open_rights: not checking ACL "
+ "on DELETE_ACCESS on file %s. Granting 0x%x\n",
+ smb_fname_str_dbg(smb_fname),
+ (unsigned int)*access_granted ));
+ return NT_STATUS_OK;
+ }
+
status = SMB_VFS_GET_NT_ACL(conn, smb_fname->base_name,
(SECINFO_OWNER |
SECINFO_GROUP |
@@ -241,6 +251,8 @@ void change_file_owner_to_parent(connection_struct *conn,
DEBUG(10,("change_file_owner_to_parent: changed new file %s to "
"parent directory uid %u.\n", fsp_str_dbg(fsp),
(unsigned int)smb_fname_parent->st.st_ex_uid));
+ /* Ensure the uid entry is updated. */
+ fsp->fsp_name->st.st_ex_uid = smb_fname_parent->st.st_ex_uid;
}
TALLOC_FREE(smb_fname_parent);
@@ -316,10 +328,9 @@ NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
/* Ensure we're pointing at the same place. */
if (smb_fname_cwd->st.st_ex_dev != psbuf->st_ex_dev ||
- smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino ||
- smb_fname_cwd->st.st_ex_mode != psbuf->st_ex_mode ) {
+ smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino) {
DEBUG(0,("change_dir_owner_to_parent: "
- "device/inode/mode on directory %s changed. "
+ "device/inode on directory %s changed. "
"Refusing to chown !\n", fname ));
status = NT_STATUS_ACCESS_DENIED;
goto chdir;
@@ -350,6 +361,8 @@ NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
DEBUG(10,("change_dir_owner_to_parent: changed ownership of new "
"directory %s to parent directory uid %u.\n",
fname, (unsigned int)smb_fname_parent->st.st_ex_uid ));
+ /* Ensure the uid entry is updated. */
+ psbuf->st_ex_uid = smb_fname_parent->st.st_ex_uid;
}
chdir:
@@ -378,6 +391,7 @@ static NTSTATUS open_file(files_struct *fsp,
int accmode = (flags & O_ACCMODE);
int local_flags = flags;
bool file_existed = VALID_STAT(fsp->fsp_name->st);
+ bool file_created = false;
fsp->fh->fd = -1;
errno = EPERM;
@@ -477,23 +491,7 @@ static NTSTATUS open_file(files_struct *fsp,
}
if ((local_flags & O_CREAT) && !file_existed) {
-
- /* Inherit the ACL if required */
- if (lp_inherit_perms(SNUM(conn))) {
- inherit_access_posix_acl(conn, parent_dir,
- smb_fname->base_name,
- unx_mode);
- }
-
- /* Change the owner if required. */
- if (lp_inherit_owner(SNUM(conn))) {
- change_file_owner_to_parent(conn, parent_dir,
- fsp);
- }
-
- notify_fname(conn, NOTIFY_ACTION_ADDED,
- FILE_NOTIFY_CHANGE_FILE_NAME,
- smb_fname->base_name);
+ file_created = true;
}
} else {
@@ -603,6 +601,47 @@ static NTSTATUS open_file(files_struct *fsp,
fd_close(fsp);
return status;
}
+
+ if (file_created) {
+ bool need_re_stat = false;
+ /* Do all inheritance work after we've
+ done a successful stat call and filled
+ in the stat struct in fsp->fsp_name. */
+
+ /* Inherit the ACL if required */
+ if (lp_inherit_perms(SNUM(conn))) {
+ inherit_access_posix_acl(conn, parent_dir,
+ smb_fname->base_name,
+ unx_mode);
+ need_re_stat = true;
+ }
+
+ /* Change the owner if required. */
+ if (lp_inherit_owner(SNUM(conn))) {
+ change_file_owner_to_parent(conn, parent_dir,
+ fsp);
+ need_re_stat = true;
+ }
+
+ if (need_re_stat) {
+ if (fsp->fh->fd == -1) {
+ ret = SMB_VFS_STAT(conn, smb_fname);
+ } else {
+ ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
+ /* If we have an fd, this stat should succeed. */
+ if (ret == -1) {
+ DEBUG(0,("Error doing fstat on open file %s "
+ "(%s)\n",
+ smb_fname_str_dbg(smb_fname),
+ strerror(errno) ));
+ }
+ }
+ }
+
+ notify_fname(conn, NOTIFY_ACTION_ADDED,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ smb_fname->base_name);
+ }
}
/*
@@ -949,7 +988,9 @@ static NTSTATUS send_break_message(files_struct *fsp,
* Do internal consistency checks on the share mode for a file.
*/
-static void find_oplock_types(struct share_mode_lock *lck,
+static void find_oplock_types(files_struct *fsp,
+ int oplock_request,
+ struct share_mode_lock *lck,
struct share_mode_entry **pp_batch,
struct share_mode_entry **pp_ex_or_batch,
bool *got_level2,
@@ -962,11 +1003,27 @@ static void find_oplock_types(struct share_mode_lock *lck,
*got_level2 = false;
*got_no_oplock = false;
+ /* Ignore stat or internal opens, as is done in
+ delay_for_batch_oplocks() and
+ delay_for_exclusive_oplocks().
+ */
+ if ((oplock_request & INTERNAL_OPEN_ONLY) || is_stat_open(fsp->access_mask)) {
+ return;
+ }
+
for (i=0; i<lck->num_share_modes; i++) {
if (!is_valid_share_mode_entry(&lck->share_modes[i])) {
continue;
}
+ if (lck->share_modes[i].op_type == NO_OPLOCK &&
+ is_stat_open(lck->share_modes[i].access_mask)) {
+ /* We ignore stat opens in the table - they
+ always have NO_OPLOCK and never get or
+ cause breaks. JRA. */
+ continue;
+ }
+
if (BATCH_OPLOCK_TYPE(lck->share_modes[i].op_type)) {
/* batch - can only be one. */
if (*pp_ex_or_batch || *pp_batch || *got_level2 || *got_no_oplock) {
@@ -1037,18 +1094,8 @@ static bool delay_for_exclusive_oplocks(files_struct *fsp,
return false;
}
-static bool file_has_brlocks(files_struct *fsp)
-{
- struct byte_range_lock *br_lck;
-
- br_lck = brl_get_locks_readonly(fsp);
- if (!br_lck)
- return false;
-
- return br_lck->num_locks > 0 ? true : false;
-}
-
static void grant_fsp_oplock_type(files_struct *fsp,
+ const struct byte_range_lock *br_lck,
int oplock_request,
bool got_level2_oplock,
bool got_a_none_oplock)
@@ -1066,7 +1113,7 @@ static void grant_fsp_oplock_type(files_struct *fsp,
DEBUG(10,("grant_fsp_oplock_type: oplock type 0x%x on file %s\n",
fsp->oplock_type, fsp_str_dbg(fsp)));
return;
- } else if (lp_locking(fsp->conn->params) && file_has_brlocks(fsp)) {
+ } else if (br_lck && br_lck->num_locks > 0) {
DEBUG(10,("grant_fsp_oplock_type: file %s has byte range locks\n",
fsp_str_dbg(fsp)));
fsp->oplock_type = NO_OPLOCK;
@@ -1544,6 +1591,55 @@ void remove_deferred_open_entry(struct file_id id, uint64_t mid,
}
}
+/****************************************************************
+ Ensure we get the brlock lock followed by the share mode lock
+ in the correct order to prevent deadlocks if other smbd's are
+ using the brlock database on this file simultaneously with this open
+ (that code also gets the locks in brlock -> share mode lock order).
+****************************************************************/
+
+static bool acquire_ordered_locks(TALLOC_CTX *mem_ctx,
+ files_struct *fsp,
+ const struct file_id id,
+ const char *connectpath,
+ const struct smb_filename *smb_fname,
+ const struct timespec *p_old_write_time,
+ struct share_mode_lock **p_lck,
+ struct byte_range_lock **p_br_lck)
+{
+ /* Ordering - we must get the br_lck for this
+ file before the share mode. */
+ if (lp_locking(fsp->conn->params)) {
+ *p_br_lck = brl_get_locks_readonly(fsp);
+ if (*p_br_lck == NULL) {
+ DEBUG(0, ("Could not get br_lock\n"));
+ return false;
+ }
+ /* Note - we don't need to free the returned
+ br_lck explicitly as it was allocated on talloc_tos()
+ and so will be autofreed (and release the lock)
+ once the frame context disappears.
+
+ If it was set to fsp->brlock_rec then it was
+ talloc_move'd to hang off the fsp pointer and
+ in this case is guarenteed to not be holding the
+ lock on the brlock database. */
+ }
+
+ *p_lck = get_share_mode_lock(mem_ctx,
+ id,
+ connectpath,
+ smb_fname,
+ p_old_write_time);
+
+ if (*p_lck == NULL) {
+ DEBUG(0, ("Could not get share mode lock\n"));
+ TALLOC_FREE(*p_br_lck);
+ return false;
+ }
+ return true;
+}
+
/****************************************************************************
Open a file with a share mode. Passed in an already created files_struct *.
****************************************************************************/
@@ -1622,9 +1718,9 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
unx_mode = (mode_t)(new_dos_attributes & ~FILE_FLAG_POSIX_SEMANTICS);
new_dos_attributes = 0;
} else {
- /* We add aARCH to this as this mode is only used if the file is
+ /* We add FILE_ATTRIBUTE_ARCHIVE to this as this mode is only used if the file is
* created new. */
- unx_mode = unix_mode(conn, new_dos_attributes | aARCH,
+ unx_mode = unix_mode(conn, new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE,
smb_fname, parent_dir);
}
@@ -1888,6 +1984,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
}
if (file_existed) {
+ struct byte_range_lock *br_lck = NULL;
struct share_mode_entry *batch_entry = NULL;
struct share_mode_entry *exclusive_entry = NULL;
bool got_level2_oplock = false;
@@ -1896,17 +1993,21 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
struct timespec old_write_time = smb_fname->st.st_ex_mtime;
id = vfs_file_id_from_sbuf(conn, &smb_fname->st);
- lck = get_share_mode_lock(talloc_tos(), id,
- conn->connectpath,
- smb_fname, &old_write_time);
-
- if (lck == NULL) {
- DEBUG(0, ("Could not get share mode lock\n"));
+ if (!acquire_ordered_locks(talloc_tos(),
+ fsp,
+ id,
+ conn->connectpath,
+ smb_fname,
+ &old_write_time,
+ &lck,
+ &br_lck)) {
return NT_STATUS_SHARING_VIOLATION;
}
/* Get the types we need to examine. */
- find_oplock_types(lck,
+ find_oplock_types(fsp,
+ oplock_request,
+ lck,
&batch_entry,
&exclusive_entry,
&got_level2_oplock,
@@ -1953,6 +2054,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
}
grant_fsp_oplock_type(fsp,
+ br_lck,
oplock_request,
got_level2_oplock,
got_a_none_oplock);
@@ -2109,13 +2211,12 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
open_access_mask);
if (!NT_STATUS_IS_OK(fsp_open)) {
- if (lck != NULL) {
- TALLOC_FREE(lck);
- }
+ TALLOC_FREE(lck);
return fsp_open;
}
if (!file_existed) {
+ struct byte_range_lock *br_lck = NULL;
struct share_mode_entry *batch_entry = NULL;
struct share_mode_entry *exclusive_entry = NULL;
bool got_level2_oplock = false;
@@ -2138,20 +2239,21 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
id = fsp->file_id;
- lck = get_share_mode_lock(talloc_tos(), id,
- conn->connectpath,
- smb_fname, &old_write_time);
-
- if (lck == NULL) {
- DEBUG(0, ("open_file_ntcreate: Could not get share "
- "mode lock for %s\n",
- smb_fname_str_dbg(smb_fname)));
- fd_close(fsp);
+ if (!acquire_ordered_locks(talloc_tos(),
+ fsp,
+ id,
+ conn->connectpath,
+ smb_fname,
+ &old_write_time,
+ &lck,
+ &br_lck)) {
return NT_STATUS_SHARING_VIOLATION;
}
/* Get the types we need to examine. */
- find_oplock_types(lck,
+ find_oplock_types(fsp,
+ oplock_request,
+ lck,
&batch_entry,
&exclusive_entry,
&got_level2_oplock,
@@ -2194,8 +2296,6 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
if (!NT_STATUS_IS_OK(status)) {
struct deferred_open_record state;
- fd_close(fsp);
-
state.delayed_for_oplocks = False;
state.id = id;
@@ -2211,10 +2311,12 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
req, &state);
}
TALLOC_FREE(lck);
+ fd_close(fsp);
return status;
}
grant_fsp_oplock_type(fsp,
+ br_lck,
oplock_request,
got_level2_oplock,
got_a_none_oplock);
@@ -2335,7 +2437,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
new_file_created = True;
}
- set_share_mode(lck, fsp, get_current_uid(conn), 0,
+ set_share_mode(lck, fsp, get_current_uid(conn),
+ req ? req->mid : 0,
fsp->oplock_type);
/* Handle strange delete on close create semantics. */
@@ -2361,7 +2464,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
lp_store_dos_attributes(SNUM(conn))) {
if (!posix_open) {
if (file_set_dosmode(conn, smb_fname,
- new_dos_attributes | aARCH,
+ new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE,
parent_dir, true) == 0) {
unx_mode = smb_fname->st.st_ex_mode;
}
@@ -2475,6 +2578,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
char *parent_dir;
NTSTATUS status;
bool posix_open = false;
+ bool need_re_stat = false;
if(!CAN_WRITE(conn)) {
DEBUG(5,("mkdir_internal: failing create on read-only share "
@@ -2496,7 +2600,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
posix_open = true;
mode = (mode_t)(file_attributes & ~FILE_FLAG_POSIX_SEMANTICS);
} else {
- mode = unix_mode(conn, aDIR, smb_dname, parent_dir);
+ mode = unix_mode(conn, FILE_ATTRIBUTE_DIRECTORY, smb_dname, parent_dir);
}
if (SMB_VFS_MKDIR(conn, smb_dname->base_name, mode) != 0) {
@@ -2521,7 +2625,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
if (lp_store_dos_attributes(SNUM(conn))) {
if (!posix_open) {
file_set_dosmode(conn, smb_dname,
- file_attributes | aDIR,
+ file_attributes | FILE_ATTRIBUTE_DIRECTORY,
parent_dir, true);
}
}
@@ -2529,6 +2633,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
if (lp_inherit_perms(SNUM(conn))) {
inherit_access_posix_acl(conn, parent_dir,
smb_dname->base_name, mode);
+ need_re_stat = true;
}
if (!posix_open) {
@@ -2543,6 +2648,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
SMB_VFS_CHMOD(conn, smb_dname->base_name,
(smb_dname->st.st_ex_mode |
(mode & ~smb_dname->st.st_ex_mode)));
+ need_re_stat = true;
}
}
@@ -2551,6 +2657,15 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
change_dir_owner_to_parent(conn, parent_dir,
smb_dname->base_name,
&smb_dname->st);
+ need_re_stat = true;
+ }
+
+ if (need_re_stat) {
+ if (SMB_VFS_LSTAT(conn, smb_dname) == -1) {
+ DEBUG(2, ("Could not stat directory '%s' just created: %s\n",
+ smb_fname_str_dbg(smb_dname), strerror(errno)));
+ return map_nt_error_from_unix(errno);
+ }
}
notify_fname(conn, NOTIFY_ACTION_ADDED, FILE_NOTIFY_CHANGE_DIR_NAME,
@@ -2828,7 +2943,8 @@ static NTSTATUS open_directory(connection_struct *conn,
return status;
}
- set_share_mode(lck, fsp, get_current_uid(conn), 0, NO_OPLOCK);
+ set_share_mode(lck, fsp, get_current_uid(conn),
+ req ? req->mid : 0, NO_OPLOCK);
/* For directories the delete on close bit at open time seems
always to be honored on close... See test 19 in Samba4 BASE-DELETE. */
@@ -3018,7 +3134,7 @@ NTSTATUS open_streams_for_delete(connection_struct *conn,
return NT_STATUS_OK;
}
- streams = TALLOC_ARRAY(talloc_tos(), files_struct *, num_streams);
+ streams = talloc_array(talloc_tos(), files_struct *, num_streams);
if (streams == NULL) {
DEBUG(0, ("talloc failed\n"));
status = NT_STATUS_NO_MEMORY;
@@ -3172,8 +3288,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
/* Setting FILE_SHARE_DELETE is the hint. */
- if (lp_acl_check_permissions(SNUM(conn))
- && (create_disposition != FILE_CREATE)
+ if ((create_disposition != FILE_CREATE)
&& (access_mask & DELETE_ACCESS)
&& (!(can_delete_file_in_directory(conn, smb_fname) ||
can_access_file_acl(conn, smb_fname, DELETE_ACCESS)))) {
@@ -3531,7 +3646,7 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
* Copy in the base directory name.
*/
- parent_fname = TALLOC_ARRAY(talloc_tos(), char,
+ parent_fname = talloc_array(talloc_tos(), char,
dir_name_len+2);
if (parent_fname == NULL) {
status = NT_STATUS_NO_MEMORY;
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 087d6ef045a..284b0321aa8 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -224,7 +224,7 @@ bool should_notify_deferred_opens()
static char *new_break_message_smb1(TALLOC_CTX *mem_ctx,
files_struct *fsp, int cmd)
{
- char *result = TALLOC_ARRAY(mem_ctx, char, smb_size + 8*2 + 0);
+ char *result = talloc_array(mem_ctx, char, smb_size + 8*2 + 0);
if (result == NULL) {
DEBUG(0, ("talloc failed\n"));
@@ -353,7 +353,7 @@ static void add_oplock_timeout_handler(files_struct *fsp)
}
fsp->oplock_timeout =
- event_add_timed(smbd_event_context(), fsp,
+ event_add_timed(server_event_context(), fsp,
timeval_current_ofs(OPLOCK_BREAK_TIMEOUT, 0),
oplock_timeout_handler, fsp);
@@ -459,7 +459,7 @@ void process_oplock_async_level2_break_message(struct messaging_context *msg_ctx
message_to_share_mode_entry(&msg, (char *)data->data);
DEBUG(10, ("Got oplock async level 2 break message from pid %s: "
- "%s/%lu\n", procid_str(talloc_tos(), &src),
+ "%s/%lu\n", server_id_str(talloc_tos(), &src),
file_id_string_tos(&msg.id), msg.share_file_id));
fsp = initial_break_processing(sconn, msg.id, msg.share_file_id);
@@ -510,7 +510,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
message_to_share_mode_entry(&msg, (char *)data->data);
DEBUG(10, ("Got oplock break message from pid %s: %s/%lu\n",
- procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
+ server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
msg.share_file_id));
fsp = initial_break_processing(sconn, msg.id, msg.share_file_id);
@@ -617,7 +617,7 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
file_id = (unsigned long)IVAL(data->data, 24);
DEBUG(10, ("Got kernel oplock break message from pid %s: %s/%u\n",
- procid_str(talloc_tos(), &src), file_id_string_tos(&id),
+ server_id_str(talloc_tos(), &src), file_id_string_tos(&id),
(unsigned int)file_id));
fsp = initial_break_processing(sconn, id, file_id);
@@ -704,7 +704,7 @@ static void process_oplock_break_response(struct messaging_context *msg_ctx,
message_to_share_mode_entry(&msg, (char *)data->data);
DEBUG(10, ("Got oplock break response from pid %s: %s/%lu mid %llu\n",
- procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
+ server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
msg.share_file_id, (unsigned long long)msg.op_mid));
schedule_deferred_open_message_smb(msg.op_mid);
@@ -732,7 +732,7 @@ static void process_open_retry_message(struct messaging_context *msg_ctx,
message_to_share_mode_entry(&msg, (char *)data->data);
DEBUG(10, ("Got open retry msg from pid %s: %s mid %llu\n",
- procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
+ server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
(unsigned long long)msg.op_mid));
schedule_deferred_open_message_smb(msg.op_mid);
@@ -849,7 +849,7 @@ static void contend_level2_oplocks_begin_default(files_struct *fsp,
TALLOC_FREE(lck);
}
-void contend_level2_oplocks_begin(files_struct *fsp,
+void smbd_contend_level2_oplocks_begin(files_struct *fsp,
enum level2_contention_type type)
{
if (koplocks && koplocks->ops->contend_level2_oplocks_begin) {
@@ -860,7 +860,7 @@ void contend_level2_oplocks_begin(files_struct *fsp,
contend_level2_oplocks_begin_default(fsp, type);
}
-void contend_level2_oplocks_end(files_struct *fsp,
+void smbd_contend_level2_oplocks_end(files_struct *fsp,
enum level2_contention_type type)
{
/* Only kernel oplocks implement this so far */
diff --git a/source3/smbd/oplock_irix.c b/source3/smbd/oplock_irix.c
index 207952d040c..ef737efd223 100644
--- a/source3/smbd/oplock_irix.c
+++ b/source3/smbd/oplock_irix.c
@@ -332,7 +332,7 @@ struct kernel_oplocks *irix_init_kernel_oplocks(TALLOC_CTX *mem_ctx)
ctx->read_fd = pfd[0];
ctx->write_fd = pfd[1];
- ctx->read_fde = event_add_fd(smbd_event_context(),
+ ctx->read_fde = event_add_fd(server_event_context(),
ctx,
ctx->read_fd,
EVENT_FD_READ,
diff --git a/source3/smbd/oplock_linux.c b/source3/smbd/oplock_linux.c
index 4f243e2e9ff..19f4d6e06d8 100644
--- a/source3/smbd/oplock_linux.c
+++ b/source3/smbd/oplock_linux.c
@@ -210,7 +210,7 @@ struct kernel_oplocks *linux_init_kernel_oplocks(TALLOC_CTX *mem_ctx)
ctx->ops = &linux_koplocks;
- se = tevent_add_signal(smbd_event_context(),
+ se = tevent_add_signal(server_event_context(),
ctx,
RT_SIGNAL_LEASE, SA_SIGINFO,
linux_oplock_signal_handler,
diff --git a/source3/smbd/oplock_onefs.c b/source3/smbd/oplock_onefs.c
index dbf465ca63a..4717b1faf7d 100644
--- a/source3/smbd/oplock_onefs.c
+++ b/source3/smbd/oplock_onefs.c
@@ -709,7 +709,7 @@ struct kernel_oplocks *onefs_init_kernel_oplocks(TALLOC_CTX *mem_ctx)
DEBUG(10, ("oplock event_fd = %d\n", ctx->onefs_event_fd));
/* Register the oplock event_fd with samba's event system */
- ctx->read_fde = event_add_fd(smbd_event_context(),
+ ctx->read_fde = event_add_fd(server_event_context(),
ctx,
ctx->onefs_event_fd,
EVENT_FD_READ,
diff --git a/source3/smbd/password.c b/source3/smbd/password.c
index 720b1bf4c20..69b37596c5d 100644
--- a/source3/smbd/password.c
+++ b/source3/smbd/password.c
@@ -549,7 +549,7 @@ static char *validate_group(struct smbd_server_connection *sconn,
DEBUG(10,("validate_group: = gr_mem = "
"%s\n", gptr->gr_mem[i]));
- safe_strcpy(member, gptr->gr_mem[i],
+ strlcpy(member, gptr->gr_mem[i],
list_len - (member-member_list));
member += member_len;
}
@@ -644,7 +644,7 @@ bool authorise_login(struct smbd_server_connection *sconn,
get_session_workgroup(sconn),
user2,password)) {
ok = True;
- fstrcpy(user,user2);
+ strlcpy(user,user2,sizeof(fstring));
DEBUG(3,("authorise_login: ACCEPTED: session "
"list username (%s) and given "
"password ok\n", user));
@@ -695,7 +695,7 @@ bool authorise_login(struct smbd_server_connection *sconn,
get_session_workgroup(sconn),
user2,password)) {
ok = True;
- fstrcpy(user,user2);
+ strlcpy(user,user2,sizeof(fstring));
DEBUG(3,("authorise_login: ACCEPTED: "
"user list username and "
"given password ok (%s)\n",
@@ -714,7 +714,7 @@ bool authorise_login(struct smbd_server_connection *sconn,
fstrcpy(guestname,lp_guestaccount());
guest_pw = Get_Pwnam_alloc(talloc_tos(), guestname);
if (guest_pw != NULL) {
- fstrcpy(user,guestname);
+ strlcpy(user,guestname,sizeof(fstring));
ok = True;
DEBUG(3,("authorise_login: ACCEPTED: guest account "
"and guest ok (%s)\n", user));
diff --git a/source3/smbd/perfcount.c b/source3/smbd/perfcount.c
index 3bc83b98d5f..15618937582 100644
--- a/source3/smbd/perfcount.c
+++ b/source3/smbd/perfcount.c
@@ -85,7 +85,7 @@ NTSTATUS smb_register_perfcounter(int interface_version, const char *name,
entry = SMB_XMALLOC_P(struct smb_perfcount_module);
entry->name = smb_xstrdup(name);
- entry->handlers = (struct smb_perfcount_handlers*) handlers;
+ entry->handlers = discard_const_p(struct smb_perfcount_handlers, handlers);
DLIST_ADD(modules, entry);
DEBUG(3, ("Successfully added perfcounter module '%s'\n", name));
diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c
index 89d6c8dfca1..2de48adcbcf 100644
--- a/source3/smbd/pipes.c
+++ b/source3/smbd/pipes.c
@@ -29,6 +29,7 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "libcli/security/security.h"
+#include "rpc_server/srv_pipe_hnd.h"
#define PIPE "\\PIPE\\"
#define PIPELEN strlen(PIPE)
@@ -202,7 +203,7 @@ void reply_pipe_write(struct smb_request *req)
DEBUG(6, ("reply_pipe_write: %x name: %s len: %d\n", (int)fsp->fnum,
fsp_str_dbg(fsp), (int)state->numtowrite));
- subreq = np_write_send(state, smbd_event_context(),
+ subreq = np_write_send(state, server_event_context(),
fsp->fake_file_handle, data, state->numtowrite);
if (subreq == NULL) {
TALLOC_FREE(state);
@@ -269,7 +270,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
{
files_struct *fsp = file_fsp(req, SVAL(req->vwv+2, 0));
int smb_doff = SVAL(req->vwv+11, 0);
- uint8_t *data;
+ const uint8_t *data;
struct pipe_write_andx_state *state;
struct tevent_req *subreq;
@@ -298,7 +299,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
DEBUG(6, ("reply_pipe_write_and_X: %x name: %s len: %d\n",
(int)fsp->fnum, fsp_str_dbg(fsp), (int)state->numtowrite));
- data = (uint8_t *)smb_base(req->inbuf) + smb_doff;
+ data = (const uint8_t *)smb_base(req->inbuf) + smb_doff;
if (state->pipe_start_message_raw) {
/*
@@ -318,7 +319,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
state->numtowrite -= 2;
}
- subreq = np_write_send(state, smbd_event_context(),
+ subreq = np_write_send(state, server_event_context(),
fsp->fake_file_handle, data, state->numtowrite);
if (subreq == NULL) {
TALLOC_FREE(state);
@@ -425,7 +426,7 @@ void reply_pipe_read_and_X(struct smb_request *req)
state->outbuf = req->outbuf;
req->outbuf = NULL;
- subreq = np_read_send(state, smbd_event_context(),
+ subreq = np_read_send(state, server_event_context(),
fsp->fake_file_handle, data,
state->smb_maxcnt);
if (subreq == NULL) {
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index 9252ee639fd..da25a52b8db 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -3687,7 +3687,7 @@ NTSTATUS append_parent_acl(files_struct *fsp,
num_aces += parent_sd->dacl->num_aces;
- if((new_ace = TALLOC_ZERO_ARRAY(mem_ctx, struct security_ace,
+ if((new_ace = talloc_zero_array(mem_ctx, struct security_ace,
num_aces)) == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -4744,13 +4744,13 @@ struct security_descriptor *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fna
struct fd_handle fh;
NTSTATUS status;
- conn = TALLOC_ZERO_P(ctx, connection_struct);
+ conn = talloc_zero(ctx, connection_struct);
if (conn == NULL) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
- if (!(conn->params = TALLOC_P(conn, struct share_params))) {
+ if (!(conn->params = talloc(conn, struct share_params))) {
DEBUG(0,("get_nt_acl_no_snum: talloc() failed!\n"));
TALLOC_FREE(conn);
return NULL;
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 248b3e403d0..f3f532fbaec 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -19,6 +19,7 @@
*/
#include "includes.h"
+#include "../lib/tsocket/tsocket.h"
#include "system/filesys.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
@@ -32,6 +33,8 @@
#include "auth.h"
#include "messages.h"
#include "smbprofile.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
+#include "libsmb/libsmb.h"
extern bool global_machine_password_needs_changing;
@@ -318,7 +321,7 @@ static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
/* Copy the header we've written. */
- *buffer = (char *)TALLOC_MEMDUP(mem_ctx,
+ *buffer = (char *)talloc_memdup(mem_ctx,
writeX_header,
sizeof(writeX_header));
@@ -343,7 +346,7 @@ static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
* talloc and return.
*/
- *buffer = TALLOC_ARRAY(mem_ctx, char, len+4);
+ *buffer = talloc_array(mem_ctx, char, len+4);
if (*buffer == NULL) {
DEBUG(0, ("Could not allocate inbuf of length %d\n",
@@ -412,7 +415,7 @@ static NTSTATUS receive_smb_raw_talloc(TALLOC_CTX *mem_ctx,
* The +4 here can't wrap, we've checked the length above already.
*/
- *buffer = TALLOC_ARRAY(mem_ctx, char, len+4);
+ *buffer = talloc_array(mem_ctx, char, len+4);
if (*buffer == NULL) {
DEBUG(0, ("Could not allocate inbuf of length %d\n",
@@ -501,9 +504,9 @@ static bool init_smb_request(struct smb_request *req,
req->vuid = SVAL(inbuf, smb_uid);
req->tid = SVAL(inbuf, smb_tid);
req->wct = CVAL(inbuf, smb_wct);
- req->vwv = (uint16_t *)(inbuf+smb_vwv);
+ req->vwv = discard_const_p(uint16_t, (inbuf+smb_vwv));
req->buflen = smb_buflen(inbuf);
- req->buf = (const uint8_t *)smb_buf(inbuf);
+ req->buf = (const uint8_t *)smb_buf_const(inbuf);
req->unread_bytes = unread_bytes;
req->encrypted = encrypted;
req->sconn = sconn;
@@ -522,7 +525,7 @@ static bool init_smb_request(struct smb_request *req,
return false;
}
/* Ensure bcc is correct. */
- if (((uint8 *)smb_buf(inbuf)) + req->buflen > inbuf + req_size) {
+ if (((const uint8_t *)smb_buf_const(inbuf)) + req->buflen > inbuf + req_size) {
DEBUG(0,("init_smb_request: invalid bcc number %u "
"(wct = %u, size %u)\n",
(unsigned int)req->buflen,
@@ -591,7 +594,7 @@ static bool push_queued_message(struct smb_request *req,
int msg_len = smb_len(req->inbuf) + 4;
struct pending_message_list *msg;
- msg = TALLOC_ZERO_P(NULL, struct pending_message_list);
+ msg = talloc_zero(NULL, struct pending_message_list);
if(msg == NULL) {
DEBUG(0,("push_message: malloc fail (1)\n"));
@@ -621,7 +624,7 @@ static bool push_queued_message(struct smb_request *req,
}
}
- msg->te = event_add_timed(smbd_event_context(),
+ msg->te = event_add_timed(server_event_context(),
msg,
end_time,
smbd_deferred_open_timer,
@@ -705,7 +708,7 @@ void schedule_deferred_open_message_smb(uint64_t mid)
"scheduling mid %llu\n",
(unsigned long long)mid ));
- te = event_add_timed(smbd_event_context(),
+ te = event_add_timed(server_event_context(),
pml,
timeval_zero(),
smbd_deferred_open_timer,
@@ -888,7 +891,7 @@ struct idle_event *event_add_idle(struct event_context *event_ctx,
struct idle_event *result;
struct timeval now = timeval_current();
- result = TALLOC_P(mem_ctx, struct idle_event);
+ result = talloc(mem_ctx, struct idle_event);
if (result == NULL) {
DEBUG(0, ("talloc failed\n"));
return NULL;
@@ -931,8 +934,8 @@ void smbd_setup_sig_term_handler(void)
{
struct tevent_signal *se;
- se = tevent_add_signal(smbd_event_context(),
- smbd_event_context(),
+ se = tevent_add_signal(server_event_context(),
+ server_event_context(),
SIGTERM, 0,
smbd_sig_term_handler,
NULL);
@@ -984,11 +987,11 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *
* select for longer than it would take to wait for them.
*/
- event_add_to_poll_args(smbd_event_context(), conn,
+ event_add_to_poll_args(server_event_context(), conn,
&conn->pfds, &num_pfds, &timeout);
/* Process a signal and timed events now... */
- if (run_events_poll(smbd_event_context(), 0, NULL, 0)) {
+ if (run_events_poll(server_event_context(), 0, NULL, 0)) {
return NT_STATUS_RETRY;
}
@@ -1003,11 +1006,14 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *
errno = sav;
}
- if (ret == -1 && errno != EINTR) {
+ if (ret == -1) {
+ if (errno == EINTR) {
+ return NT_STATUS_RETRY;
+ }
return map_nt_error_from_unix(errno);
}
- retry = run_events_poll(smbd_event_context(), ret, conn->pfds,
+ retry = run_events_poll(server_event_context(), ret, conn->pfds,
num_pfds);
if (retry) {
return NT_STATUS_RETRY;
@@ -1345,12 +1351,12 @@ static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
char *msg;
if (asprintf(&msg, "num_bytes too large: %u",
(unsigned)num_bytes) == -1) {
- msg = CONST_DISCARD(char *, "num_bytes too large");
+ msg = discard_const_p(char, "num_bytes too large");
}
smb_panic(msg);
}
- *outbuf = TALLOC_ARRAY(mem_ctx, char,
+ *outbuf = talloc_array(mem_ctx, char,
smb_size + num_words*2 + num_bytes);
if (*outbuf == NULL) {
return false;
@@ -1372,7 +1378,7 @@ static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes)
{
char *outbuf;
- if (!create_outbuf(req, req, (char *)req->inbuf, &outbuf, num_words,
+ if (!create_outbuf(req, req, (const char *)req->inbuf, &outbuf, num_words,
num_bytes)) {
smb_panic("could not allocate output buffer\n");
}
@@ -1444,7 +1450,7 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
if (smb_messages[type].fn == NULL) {
DEBUG(0,("Unknown message type %d!\n",type));
- smb_dump("Unknown", 1, (char *)req->inbuf, size);
+ smb_dump("Unknown", 1, (const char *)req->inbuf, size);
reply_unknown_new(req, type);
return NULL;
}
@@ -1459,10 +1465,10 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
DEBUG(3,("switch message %s (pid %d) conn 0x%lx\n", smb_fn_name(type),
(int)sys_getpid(), (unsigned long)conn));
- smb_dump(smb_fn_name(type), 1, (char *)req->inbuf, size);
+ smb_dump(smb_fn_name(type), 1, (const char *)req->inbuf, size);
/* Ensure this value is replaced in the incoming packet. */
- SSVAL(req->inbuf,smb_uid,session_tag);
+ SSVAL(discard_const_p(uint8_t, req->inbuf),smb_uid,session_tag);
/*
* Ensure the correct username is in current_user_info. This is a
@@ -1748,7 +1754,7 @@ static void construct_reply_common(struct smb_request *req, const char *inbuf,
void construct_reply_common_req(struct smb_request *req, char *outbuf)
{
- construct_reply_common(req, (char *)req->inbuf, outbuf);
+ construct_reply_common(req, (const char *)req->inbuf, outbuf);
}
/*
@@ -1888,7 +1894,7 @@ static bool smb_splice_chain(uint8_t **poutbuf, uint8_t smb_command,
return false;
}
- outbuf = TALLOC_REALLOC_ARRAY(NULL, *poutbuf, uint8_t, new_size);
+ outbuf = talloc_realloc(NULL, *poutbuf, uint8_t, new_size);
if (outbuf == NULL) {
DEBUG(0, ("talloc failed\n"));
return false;
@@ -1902,7 +1908,7 @@ static bool smb_splice_chain(uint8_t **poutbuf, uint8_t smb_command,
if (!find_andx_cmd_ofs(outbuf, &andx_cmd_ofs)) {
DEBUG(1, ("invalid command chain\n"));
- *poutbuf = TALLOC_REALLOC_ARRAY(
+ *poutbuf = talloc_realloc(
NULL, *poutbuf, uint8_t, old_size);
return false;
}
@@ -1971,9 +1977,9 @@ void chain_reply(struct smb_request *req)
uint32_t chain_offset; /* uint32_t to avoid overflow */
uint8_t wct;
- uint16_t *vwv;
+ const uint16_t *vwv;
uint16_t buflen;
- uint8_t *buf;
+ const uint8_t *buf;
if (IVAL(req->outbuf, smb_rcls) != 0) {
fixup_chain_error_packet(req);
@@ -1990,7 +1996,7 @@ void chain_reply(struct smb_request *req)
if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) {
if (req->chain_outbuf == NULL) {
- req->chain_outbuf = TALLOC_REALLOC_ARRAY(
+ req->chain_outbuf = talloc_realloc(
req, req->outbuf, uint8_t,
smb_len(req->outbuf) + 4);
if (req->chain_outbuf == NULL) {
@@ -2022,7 +2028,7 @@ void chain_reply(struct smb_request *req)
* over-allocated (reply_pipe_read_and_X used to be such an
* example).
*/
- req->chain_outbuf = TALLOC_REALLOC_ARRAY(
+ req->chain_outbuf = talloc_realloc(
req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4);
if (req->chain_outbuf == NULL) {
smb_panic("talloc failed");
@@ -2122,7 +2128,7 @@ void chain_reply(struct smb_request *req)
if (length_needed > smblen) {
goto error;
}
- vwv = (uint16_t *)(smb_base(req->inbuf) + chain_offset + 1);
+ vwv = (const uint16_t *)(smb_base(req->inbuf) + chain_offset + 1);
/*
* Now grab the new byte buffer....
@@ -2138,11 +2144,11 @@ void chain_reply(struct smb_request *req)
if (length_needed > smblen) {
goto error;
}
- buf = (uint8_t *)(vwv+wct+1);
+ buf = (const uint8_t *)(vwv+wct+1);
req->cmd = chain_cmd;
req->wct = wct;
- req->vwv = vwv;
+ req->vwv = discard_const_p(uint16_t, vwv);
req->buflen = buflen;
req->buf = buf;
@@ -2240,13 +2246,14 @@ static bool fd_is_readable(int fd)
}
-static void smbd_server_connection_write_handler(struct smbd_server_connection *conn)
+static void smbd_server_connection_write_handler(
+ struct smbd_server_connection *sconn)
{
/* TODO: make write nonblocking */
}
static void smbd_server_connection_read_handler(
- struct smbd_server_connection *conn, int fd)
+ struct smbd_server_connection *sconn, int fd)
{
uint8_t *inbuf = NULL;
size_t inbuf_len = 0;
@@ -2256,29 +2263,29 @@ static void smbd_server_connection_read_handler(
NTSTATUS status;
uint32_t seqnum;
- bool from_client = (conn->sock == fd);
+ bool from_client = (sconn->sock == fd);
if (from_client) {
- smbd_lock_socket(conn);
+ smbd_lock_socket(sconn);
if (lp_async_smb_echo_handler() && !fd_is_readable(fd)) {
DEBUG(10,("the echo listener was faster\n"));
- smbd_unlock_socket(conn);
+ smbd_unlock_socket(sconn);
return;
}
/* TODO: make this completely nonblocking */
- status = receive_smb_talloc(mem_ctx, conn, fd,
+ status = receive_smb_talloc(mem_ctx, sconn, fd,
(char **)(void *)&inbuf,
0, /* timeout */
&unread_bytes,
&encrypted,
&inbuf_len, &seqnum,
false /* trusted channel */);
- smbd_unlock_socket(conn);
+ smbd_unlock_socket(sconn);
} else {
/* TODO: make this completely nonblocking */
- status = receive_smb_talloc(mem_ctx, conn, fd,
+ status = receive_smb_talloc(mem_ctx, sconn, fd,
(char **)(void *)&inbuf,
0, /* timeout */
&unread_bytes,
@@ -2298,7 +2305,7 @@ static void smbd_server_connection_read_handler(
}
process:
- process_smb(conn, inbuf, inbuf_len, unread_bytes,
+ process_smb(sconn, inbuf, inbuf_len, unread_bytes,
seqnum, encrypted, NULL);
}
@@ -2339,6 +2346,7 @@ static void smbd_server_echo_handler(struct event_context *ev,
}
}
+#ifdef CLUSTER_SUPPORT
/****************************************************************************
received when we should release a specific IP
****************************************************************************/
@@ -2351,6 +2359,9 @@ static void release_ip(const char *ip, void *priv)
p = addr + 7;
}
+ DEBUG(10, ("Got release IP message for %s, "
+ "our address is %s\n", ip, p));
+
if ((strcmp(p, ip) == 0) || ((p != addr) && strcmp(addr, ip) == 0)) {
/* we can't afford to do a clean exit - that involves
database writes, which would potentially mean we
@@ -2365,16 +2376,6 @@ static void release_ip(const char *ip, void *priv)
}
}
-static void msg_release_ip(struct messaging_context *msg_ctx, void *private_data,
- uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
-{
- struct smbd_server_connection *sconn = talloc_get_type_abort(
- private_data, struct smbd_server_connection);
-
- release_ip((char *)data->data, sconn->client_id.addr);
-}
-
-#ifdef CLUSTER_SUPPORT
static int client_get_tcp_info(int sock, struct sockaddr_storage *server,
struct sockaddr_storage *client)
{
@@ -2608,7 +2609,7 @@ static bool smbd_echo_reply(uint8_t *inbuf, size_t inbuf_len,
return false;
}
- if (!create_outbuf(talloc_tos(), &req, (char *)req.inbuf, &outbuf,
+ if (!create_outbuf(talloc_tos(), &req, (const char *)req.inbuf, &outbuf,
1, req.buflen)) {
DEBUG(10, ("create_outbuf failed\n"));
return false;
@@ -2788,7 +2789,7 @@ static void smbd_echo_loop(struct smbd_server_connection *sconn,
/*
* Handle SMBecho requests in a forked child process
*/
-static bool fork_echo_handler(struct smbd_server_connection *sconn)
+bool fork_echo_handler(struct smbd_server_connection *sconn)
{
int listener_pipe[2];
int res;
@@ -2813,7 +2814,7 @@ static bool fork_echo_handler(struct smbd_server_connection *sconn)
set_blocking(listener_pipe[1], false);
status = reinit_after_fork(sconn->msg_ctx,
- smbd_event_context(),
+ server_event_context(),
procid_self(), false);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("reinit_after_fork failed: %s\n",
@@ -2833,7 +2834,7 @@ static bool fork_echo_handler(struct smbd_server_connection *sconn)
* Without smb signing this is the same as the normal smbd
* listener. This needs to change once signing comes in.
*/
- sconn->smb1.echo_handler.trusted_fde = event_add_fd(smbd_event_context(),
+ sconn->smb1.echo_handler.trusted_fde = event_add_fd(server_event_context(),
sconn,
sconn->smb1.echo_handler.trusted_fd,
EVENT_FD_READ,
@@ -2902,8 +2903,7 @@ void smbd_process(struct smbd_server_connection *sconn)
const char *remaddr = NULL;
int ret;
- if (lp_maxprotocol() == PROTOCOL_SMB2 &&
- !lp_async_smb_echo_handler()) {
+ if (lp_maxprotocol() == PROTOCOL_SMB2) {
/*
* We're not making the decision here,
* we're just allowing the client
@@ -3024,10 +3024,6 @@ void smbd_process(struct smbd_server_connection *sconn)
exit_server("Failed to init smb_signing");
}
- if (lp_async_smb_echo_handler() && !fork_echo_handler(sconn)) {
- exit_server("Failed to fork echo handler");
- }
-
/* Setup oplocks */
if (!init_oplocks(sconn->msg_ctx))
exit_server("Failed to init oplocks");
@@ -3035,8 +3031,6 @@ void smbd_process(struct smbd_server_connection *sconn)
/* register our message handlers */
messaging_register(sconn->msg_ctx, NULL,
MSG_SMB_FORCE_TDIS, msg_force_tdis);
- messaging_register(sconn->msg_ctx, sconn,
- MSG_SMB_RELEASE_IP, msg_release_ip);
messaging_register(sconn->msg_ctx, NULL,
MSG_SMB_CLOSE_FILE, msg_close_file);
@@ -3050,7 +3044,7 @@ void smbd_process(struct smbd_server_connection *sconn)
MSG_DEBUG, debug_message);
if ((lp_keepalive() != 0)
- && !(event_add_idle(smbd_event_context(), NULL,
+ && !(event_add_idle(server_event_context(), NULL,
timeval_set(lp_keepalive(), 0),
"keepalive", keepalive_fn,
NULL))) {
@@ -3058,14 +3052,14 @@ void smbd_process(struct smbd_server_connection *sconn)
exit(1);
}
- if (!(event_add_idle(smbd_event_context(), NULL,
+ if (!(event_add_idle(server_event_context(), NULL,
timeval_set(IDLE_CLOSED_TIMEOUT, 0),
"deadtime", deadtime_fn, sconn))) {
DEBUG(0, ("Could not add deadtime event\n"));
exit(1);
}
- if (!(event_add_idle(smbd_event_context(), NULL,
+ if (!(event_add_idle(server_event_context(), NULL,
timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
"housekeeping", housekeeping_fn, sconn))) {
DEBUG(0, ("Could not add housekeeping event\n"));
@@ -3122,7 +3116,7 @@ void smbd_process(struct smbd_server_connection *sconn)
exit_server("init_dptrs() failed");
}
- sconn->smb1.fde = event_add_fd(smbd_event_context(),
+ sconn->smb1.fde = event_add_fd(server_event_context(),
sconn,
sconn->sock,
EVENT_FD_READ,
@@ -3157,7 +3151,7 @@ void smbd_process(struct smbd_server_connection *sconn)
bool req_is_in_chain(struct smb_request *req)
{
- if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) {
+ if (req->vwv != (const uint16_t *)(req->inbuf+smb_vwv)) {
/*
* We're right now handling a subsequent request, so we must
* be in a chain
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 36eea5e16ee..adeaf688996 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -1,3 +1,50 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Main SMB server routines
+ *
+ * Copyright (C) Andrew Tridgell 1992-2002,2006
+ * Copyright (C) Jeremy Allison 1992-2010
+ * Copyright (C) Volker Lendecke 1993-2009
+ * Copyright (C) John H Terpstra 1995-1998
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1998
+ * Copyright (C) Paul Ashton 1997-1998
+ * Copyright (C) Tim Potter 1999-2000
+ * Copyright (C) T.D.Lee@durham.ac.uk 1999
+ * Copyright (C) Ying Chen 2000
+ * Copyright (C) Shirish Kalele 2000
+ * Copyright (C) Andrew Bartlett 2001-2003
+ * Copyright (C) Alexander Bokovoy 2002,2005
+ * Copyright (C) Simo Sorce 2001-2002,2009
+ * Copyright (C) Andreas Gruenbacher 2002
+ * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
+ * Copyright (C) Martin Pool 2002
+ * Copyright (C) Luke Howard 2003
+ * Copyright (C) Stefan (metze) Metzmacher 2003,2009
+ * Copyright (C) Steve French 2005
+ * Copyright (C) Gerald (Jerry) Carter 2006
+ * Copyright (C) James Peach 2006-2007
+ * Copyright (C) Jelmer Vernooij 2002-2003
+ * Copyright (C) Michael Adam 2007
+ * Copyright (C) Rishi Srivatsavai 2007
+ * Copyright (C) Tim Prouty 2009
+ * Copyright (C) Gregor Beck 2011
+ *
+ * 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 _SMBD_PROTO_H_
+#define _SMBD_PROTO_H_
/* The following definitions come from smbd/signing.c */
@@ -23,7 +70,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
size_t smb_maxcnt);
NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
struct smb_request *req,
- files_struct *fsp, char *data,
+ files_struct *fsp, const char *data,
SMB_OFF_T startpos,
size_t numtowrite);
NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
@@ -63,6 +110,9 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
uint64_t offset,
uint64_t count,
uint64_t blocking_smblctx);
+void smbd_cancel_pending_lock_requests_by_fid(files_struct *fsp,
+ struct byte_range_lock *br_lck,
+ enum file_close_type close_type);
void cancel_pending_lock_requests_by_fid(files_struct *fsp,
struct byte_range_lock *br_lck,
enum file_close_type close_type);
@@ -94,7 +144,7 @@ NTSTATUS delete_all_streams(connection_struct *conn, const char *fname);
void conn_init(struct smbd_server_connection *sconn);
int conn_num_open(struct smbd_server_connection *sconn);
-bool conn_snum_used(int snum);
+bool conn_snum_used(struct smbd_server_connection *sconn, int snum);
connection_struct *conn_find(struct smbd_server_connection *sconn,
unsigned cnum);
connection_struct *conn_new(struct smbd_server_connection *sconn);
@@ -102,6 +152,7 @@ bool conn_close_all(struct smbd_server_connection *sconn);
bool conn_idle_all(struct smbd_server_connection *sconn, time_t t);
void conn_clear_vuid_caches(struct smbd_server_connection *sconn, uint16 vuid);
void conn_free(connection_struct *conn);
+void conn_force_tdis(struct smbd_server_connection *sconn, const char *sharename);
void msg_force_tdis(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
@@ -188,6 +239,8 @@ void DirCacheAdd(struct smb_Dir *dirp, const char *name, long offset);
bool SearchDir(struct smb_Dir *dirp, const char *name, long *poffset);
NTSTATUS can_delete_directory(struct connection_struct *conn,
const char *dirname);
+NTSTATUS smbd_can_delete_directory(struct connection_struct *conn,
+ const char *dirname);
/* The following definitions come from smbd/dmapi.c */
@@ -407,7 +460,8 @@ bool create_junction(TALLOC_CTX *ctx,
struct junction_map *jucn);
bool create_msdfs_link(const struct junction_map *jucn);
bool remove_msdfs_link(const struct junction_map *jucn);
-struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn);
+struct junction_map *enum_msdfs_links(struct smbd_server_connection *sconn,
+ TALLOC_CTX *ctx, size_t *p_num_jn);
NTSTATUS resolve_dfspath(TALLOC_CTX *ctx,
connection_struct *conn,
bool dfs_pathnames,
@@ -621,6 +675,10 @@ void contend_level2_oplocks_begin(files_struct *fsp,
enum level2_contention_type type);
void contend_level2_oplocks_end(files_struct *fsp,
enum level2_contention_type type);
+void smbd_contend_level2_oplocks_begin(files_struct *fsp,
+ enum level2_contention_type type);
+void smbd_contend_level2_oplocks_end(files_struct *fsp,
+ enum level2_contention_type type);
void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e);
void message_to_share_mode_entry(struct share_mode_entry *e, char *msg);
bool init_oplocks(struct messaging_context *msg_ctx);
@@ -750,6 +808,7 @@ size_t req_wct_ofs(struct smb_request *req);
void chain_reply(struct smb_request *req);
bool req_is_in_chain(struct smb_request *req);
void smbd_process(struct smbd_server_connection *sconn);
+bool fork_echo_handler(struct smbd_server_connection *sconn);
/* The following definitions come from smbd/quotas.c */
@@ -996,10 +1055,18 @@ bool stat_cache_lookup(connection_struct *conn,
char **pp_dirpath,
char **pp_start,
SMB_STRUCT_STAT *pst);
+void smbd_send_stat_cache_delete_message(struct messaging_context *msg_ctx,
+ const char *name);
void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
const char *name);
void stat_cache_delete(const char *name);
-unsigned int fast_string_hash(TDB_DATA *key);
+#if BUILD_TDB2
+struct tdb_data;
+unsigned int fast_string_hash(struct tdb_data *key);
+#else
+struct TDB_DATA;
+unsigned int fast_string_hash(struct TDB_DATA *key);
+#endif
bool reset_stat_cache( void );
/* The following definitions come from smbd/statvfs.c */
@@ -1046,15 +1113,17 @@ void reply_transs2(struct smb_request *req);
/* The following definitions come from smbd/uid.c */
bool change_to_guest(void);
-void conn_clear_vuid_cache(connection_struct *conn, uint16_t vuid);
bool change_to_user(connection_struct *conn, uint16 vuid);
bool change_to_user_by_session(connection_struct *conn,
const struct auth_serversupplied_info *session_info);
bool change_to_root_user(void);
-bool become_authenticated_pipe_user(struct pipes_struct *p);
+bool smbd_change_to_root_user(void);
+bool become_authenticated_pipe_user(struct auth_serversupplied_info *session_info);
bool unbecome_authenticated_pipe_user(void);
void become_root(void);
void unbecome_root(void);
+void smbd_become_root(void);
+void smbd_unbecome_root(void);
bool become_user(connection_struct *conn, uint16 vuid);
bool become_user_by_session(connection_struct *conn,
const struct auth_serversupplied_info *session_info);
@@ -1130,3 +1199,5 @@ void *avahi_start_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
/* The following definitions come from smbd/msg_idmap.c */
void msg_idmap_register_msgs(struct messaging_context *ctx);
+
+#endif /* _SMBD_PROTO_H_ */
diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c
index c9f85b6ad09..41516621f0f 100644
--- a/source3/smbd/quotas.c
+++ b/source3/smbd/quotas.c
@@ -26,6 +26,7 @@
#include "includes.h"
#include "smbd/smbd.h"
+#include "system/filesys.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_QUOTA
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 01d4332b7e7..a804884ef7b 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -314,7 +314,7 @@ size_t srvstr_get_path_req_wcard(TALLOC_CTX *mem_ctx, struct smb_request *req,
char **pp_dest, const char *src, int flags,
NTSTATUS *err, bool *contains_wcard)
{
- return srvstr_get_path_wcard(mem_ctx, (char *)req->inbuf, req->flags2,
+ return srvstr_get_path_wcard(mem_ctx, (const char *)req->inbuf, req->flags2,
pp_dest, src, smbreq_bufrem(req, src),
flags, err, contains_wcard);
}
@@ -491,6 +491,13 @@ static bool netbios_session_retarget(struct smbd_server_connection *sconn,
return ret;
}
+static void reply_called_name_not_present(char *outbuf)
+{
+ smb_setlen(outbuf, 1);
+ SCVAL(outbuf, 0, 0x83);
+ SCVAL(outbuf, 4, 0x82);
+}
+
/****************************************************************************
Reply to a (netbios-level) special message.
****************************************************************************/
@@ -531,11 +538,13 @@ void reply_special(struct smbd_server_connection *sconn, char *inbuf, size_t inb
name_len1 = name_len((unsigned char *)(inbuf+4),inbuf_size - 4);
if (name_len1 <= 0 || name_len1 > inbuf_size - 4) {
DEBUG(0,("Invalid name length in session request\n"));
+ reply_called_name_not_present(outbuf);
break;
}
name_len2 = name_len((unsigned char *)(inbuf+4+name_len1),inbuf_size - 4 - name_len1);
if (name_len2 <= 0 || name_len2 > inbuf_size - 4 - name_len1) {
DEBUG(0,("Invalid name length in session request\n"));
+ reply_called_name_not_present(outbuf);
break;
}
@@ -546,6 +555,7 @@ void reply_special(struct smbd_server_connection *sconn, char *inbuf, size_t inb
if (name_type1 == -1 || name_type2 == -1) {
DEBUG(0,("Invalid name type in session request\n"));
+ reply_called_name_not_present(outbuf);
break;
}
@@ -575,7 +585,7 @@ void reply_special(struct smbd_server_connection *sconn, char *inbuf, size_t inb
if (name_type2 == 'R') {
/* We are being asked for a pathworks session ---
no thanks! */
- SCVAL(outbuf, 0,0x83);
+ reply_called_name_not_present(outbuf);
break;
}
@@ -614,6 +624,10 @@ void reply_special(struct smbd_server_connection *sconn, char *inbuf, size_t inb
msg_type, msg_flags));
srv_send_smb(sconn, outbuf, false, 0, false, NULL);
+
+ if (CVAL(outbuf, 0) != 0x82) {
+ exit_server_cleanly("invalid netbios session");
+ }
return;
}
@@ -873,7 +887,7 @@ void reply_tcon_and_X(struct smb_request *req)
service));
/* set the incoming and outgoing tid to the just created one */
- SSVAL(req->inbuf,smb_tid,conn->cnum);
+ SSVAL(discard_const_p(uint8_t, req->inbuf),smb_tid,conn->cnum);
SSVAL(req->outbuf,smb_tid,conn->cnum);
END_PROFILE(SMBtconX);
@@ -958,7 +972,7 @@ void reply_ioctl(struct smb_request *req)
SSVAL(p, 0, 0);
}
srvstr_push((char *)req->outbuf, req->flags2, p+2,
- global_myname(), 15,
+ lp_netbios_name(), 15,
STR_TERMINATE|STR_ASCII);
if (conn) {
srvstr_push((char *)req->outbuf, req->flags2,
@@ -1108,9 +1122,9 @@ void reply_getatr(struct smb_request *req)
/* dos smetimes asks for a stat of "" - it returns a "hidden directory"
under WfWg - weird! */
if (*fname == '\0') {
- mode = aHIDDEN | aDIR;
+ mode = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
if (!CAN_WRITE(conn)) {
- mode |= aRONLY;
+ mode |= FILE_ATTRIBUTE_READONLY;
}
size = 0;
mtime = 0;
@@ -1156,7 +1170,7 @@ void reply_getatr(struct smb_request *req)
}
mtime = convert_timespec_to_time_t(smb_fname->st.st_ex_mtime);
- if (mode & aDIR) {
+ if (mode & FILE_ATTRIBUTE_DIRECTORY) {
size = 0;
}
}
@@ -1257,9 +1271,9 @@ void reply_setatr(struct smb_request *req)
if (mode != FILE_ATTRIBUTE_NORMAL) {
if (VALID_STAT_OF_DIR(smb_fname->st))
- mode |= aDIR;
+ mode |= FILE_ATTRIBUTE_DIRECTORY;
else
- mode &= ~aDIR;
+ mode &= ~FILE_ATTRIBUTE_DIRECTORY;
if (file_set_dosmode(conn, smb_fname, mode, NULL,
false) != 0) {
@@ -1428,7 +1442,7 @@ void reply_search(struct smb_request *req)
status_len = SVAL(p, 0);
p += 2;
- /* dirtype &= ~aDIR; */
+ /* dirtype &= ~FILE_ATTRIBUTE_DIRECTORY; */
if (status_len == 0) {
nt_status = filename_convert(ctx, conn,
@@ -1520,11 +1534,11 @@ void reply_search(struct smb_request *req)
/* Initialize per SMBsearch/SMBffirst/SMBfunique operation data */
dptr_init_search_op(dirptr);
- if ((dirtype&0x1F) == aVOLID) {
+ if ((dirtype&0x1F) == FILE_ATTRIBUTE_VOLUME) {
char buf[DIR_STRUCT_SIZE];
memcpy(buf,status,21);
if (!make_dir_struct(ctx,buf,"???????????",volume_label(SNUM(conn)),
- 0,aVOLID,0,!allow_long_path_components)) {
+ 0,FILE_ATTRIBUTE_VOLUME,0,!allow_long_path_components)) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
goto out;
}
@@ -1820,7 +1834,7 @@ void reply_open(struct smb_request *req)
mtime = convert_timespec_to_time_t(smb_fname->st.st_ex_mtime);
- if (fattr & aDIR) {
+ if (fattr & FILE_ATTRIBUTE_DIRECTORY) {
DEBUG(3,("attempt to open a directory %s\n",
fsp_str_dbg(fsp)));
close_file(req, fsp, ERROR_CLOSE);
@@ -2004,7 +2018,7 @@ void reply_open_and_X(struct smb_request *req)
fattr = dos_mode(conn, fsp->fsp_name);
mtime = convert_timespec_to_time_t(fsp->fsp_name->st.st_ex_mtime);
- if (fattr & aDIR) {
+ if (fattr & FILE_ATTRIBUTE_DIRECTORY) {
close_file(req, fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_ACCESS_DENIED);
goto out;
@@ -2160,7 +2174,7 @@ void reply_mknew(struct smb_request *req)
goto out;
}
- if (fattr & aVOLID) {
+ if (fattr & FILE_ATTRIBUTE_VOLUME) {
DEBUG(0,("Attempt to create file (%s) with volid set - "
"please report this\n",
smb_fname_str_dbg(smb_fname)));
@@ -2381,15 +2395,18 @@ void reply_ctemp(struct smb_request *req)
static NTSTATUS can_rename(connection_struct *conn, files_struct *fsp,
uint16 dirtype)
{
- uint32 fmode;
-
if (!CAN_WRITE(conn)) {
return NT_STATUS_MEDIA_WRITE_PROTECTED;
}
- fmode = dos_mode(conn, fsp->fsp_name);
- if ((fmode & ~dirtype) & (aHIDDEN | aSYSTEM)) {
- return NT_STATUS_NO_SUCH_FILE;
+ if ((dirtype & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) !=
+ (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
+ /* Only bother to read the DOS attribute if we might deny the
+ rename on the grounds of attribute missmatch. */
+ uint32_t fmode = dos_mode(conn, fsp->fsp_name);
+ if ((fmode & ~dirtype) & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) {
+ return NT_STATUS_NO_SUCH_FILE;
+ }
}
if (S_ISDIR(fsp->fsp_name->st.st_ex_mode)) {
@@ -2449,16 +2466,16 @@ static NTSTATUS do_unlink(connection_struct *conn,
fattr = dos_mode(conn, smb_fname);
if (dirtype & FILE_ATTRIBUTE_NORMAL) {
- dirtype = aDIR|aARCH|aRONLY;
+ dirtype = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY;
}
- dirtype &= (aDIR|aARCH|aRONLY|aHIDDEN|aSYSTEM);
+ dirtype &= (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
if (!dirtype) {
return NT_STATUS_NO_SUCH_FILE;
}
if (!dir_check_ftype(conn, fattr, dirtype)) {
- if (fattr & aDIR) {
+ if (fattr & FILE_ATTRIBUTE_DIRECTORY) {
return NT_STATUS_FILE_IS_A_DIRECTORY;
}
return NT_STATUS_NO_SUCH_FILE;
@@ -2489,13 +2506,13 @@ static NTSTATUS do_unlink(connection_struct *conn,
}
/* Can't delete a directory. */
- if (fattr & aDIR) {
+ if (fattr & FILE_ATTRIBUTE_DIRECTORY) {
return NT_STATUS_FILE_IS_A_DIRECTORY;
}
#endif
#if 0 /* JRATEST */
- else if (dirtype & aDIR) /* Asked for a directory and it isn't. */
+ else if (dirtype & FILE_ATTRIBUTE_DIRECTORY) /* Asked for a directory and it isn't. */
return NT_STATUS_OBJECT_NAME_INVALID;
#endif /* JRATEST */
@@ -2632,7 +2649,7 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req,
const char *dname = NULL;
char *talloced = NULL;
- if ((dirtype & SAMBA_ATTRIBUTES_MASK) == aDIR) {
+ if ((dirtype & SAMBA_ATTRIBUTES_MASK) == FILE_ATTRIBUTE_DIRECTORY) {
status = NT_STATUS_OBJECT_NAME_INVALID;
goto out;
}
@@ -3077,9 +3094,9 @@ static void send_file_readbraw(connection_struct *conn,
normal_readbraw:
- outbuf = TALLOC_ARRAY(NULL, char, nread+4);
+ outbuf = talloc_array(NULL, char, nread+4);
if (!outbuf) {
- DEBUG(0,("send_file_readbraw: TALLOC_ARRAY failed for size %u.\n",
+ DEBUG(0,("send_file_readbraw: talloc_array failed for size %u.\n",
(unsigned)(nread+4)));
reply_readbraw_error(sconn);
return;
@@ -3213,7 +3230,7 @@ void reply_readbraw(struct smb_request *req)
"(%x << 32) used and we don't support "
"64 bit offsets.\n",
(unsigned int)IVAL(req->vwv+8, 0) ));
- reply_readbraw_error();
+ reply_readbraw_error(sconn);
END_PROFILE(SMBreadbraw);
return;
}
@@ -3896,7 +3913,7 @@ void reply_writebraw(struct smb_request *req)
size_t numtowrite=0;
size_t tcount;
SMB_OFF_T startpos;
- char *data=NULL;
+ const char *data=NULL;
bool write_through;
files_struct *fsp;
struct lock_struct lock;
@@ -3909,7 +3926,7 @@ void reply_writebraw(struct smb_request *req)
* type of SMBwritec, not SMBwriteBraw, as this tells the client
* we're finished.
*/
- SCVAL(req->inbuf,smb_com,SMBwritec);
+ SCVAL(discard_const_p(uint8_t, req->inbuf),smb_com,SMBwritec);
if (srv_is_signing_active(req->sconn)) {
END_PROFILE(SMBwritebraw);
@@ -3955,8 +3972,8 @@ void reply_writebraw(struct smb_request *req)
on whether we are using the core+ or lanman1.0 protocol */
if(get_Protocol() <= PROTOCOL_COREPLUS) {
- numtowrite = SVAL(smb_buf(req->inbuf),-2);
- data = smb_buf(req->inbuf);
+ numtowrite = SVAL(smb_buf_const(req->inbuf),-2);
+ data = smb_buf_const(req->inbuf);
} else {
numtowrite = SVAL(req->vwv+10, 0);
data = smb_base(req->inbuf) + SVAL(req->vwv+11, 0);
@@ -4001,7 +4018,7 @@ void reply_writebraw(struct smb_request *req)
total_written = nwritten;
/* Allocate a buffer of 64k + length. */
- buf = TALLOC_ARRAY(NULL, char, 65540);
+ buf = talloc_array(NULL, char, 65540);
if (!buf) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
error_to_writebrawerr(req);
@@ -4474,7 +4491,7 @@ void reply_write_and_X(struct smb_request *req)
ssize_t nwritten;
unsigned int smb_doff;
unsigned int smblen;
- char *data;
+ const char *data;
NTSTATUS status;
int saved_errno = 0;
@@ -5815,7 +5832,7 @@ static void rename_open_files(connection_struct *conn,
files_struct *fsp;
bool did_rename = False;
NTSTATUS status;
- uint32_t new_name_hash;
+ uint32_t new_name_hash = 0;
for(fsp = file_find_di_first(conn->sconn, lck->id); fsp;
fsp = file_find_di_next(fsp)) {
@@ -6405,7 +6422,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
/* Quick check for "." and ".." */
if (ISDOT(dname) || ISDOTDOT(dname)) {
- if (attrs & aDIR) {
+ if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
sysdir_entry = True;
} else {
TALLOC_FREE(talloced);
@@ -7971,7 +7988,7 @@ void reply_getattrE(struct smb_request *req)
srv_put_dos_date2((char *)req->outbuf, smb_vwv4,
convert_timespec_to_time_t(fsp->fsp_name->st.st_ex_mtime));
- if (mode & aDIR) {
+ if (mode & FILE_ATTRIBUTE_DIRECTORY) {
SIVAL(req->outbuf, smb_vwv6, 0);
SIVAL(req->outbuf, smb_vwv8, 0);
} else {
diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c
index b3dd84264a8..26185062a6f 100644
--- a/source3/smbd/seal.c
+++ b/source3/smbd/seal.c
@@ -26,6 +26,7 @@
#include "smb_crypt.h"
#include "../lib/util/asn1.h"
#include "auth.h"
+#include "libsmb/libsmb.h"
/******************************************************************************
Server side encryption.
@@ -133,7 +134,7 @@ static NTSTATUS get_srv_gss_creds(const char *service,
NTSTATUS status = NT_STATUS_OK;
gss_OID_desc nt_hostbased_service =
- {10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
+ {10, discard_const_p(char, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
if (asprintf(&host_princ_s, "%s@%s", service, name) == -1) {
return NT_STATUS_NO_MEMORY;
@@ -195,7 +196,7 @@ static NTSTATUS make_auth_gss(struct smb_srv_trans_enc_ctx *ec)
gss_cred_id_t srv_cred;
fstring fqdn;
- name_to_fqdn(fqdn, global_myname());
+ name_to_fqdn(fqdn, lp_netbios_name());
strlower_m(fqdn);
status = get_srv_gss_creds("cifs", fqdn, GSS_C_ACCEPT, &srv_cred);
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index d3c6c1884f0..5aa3ddbdc9a 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -26,7 +26,6 @@
#include "popt_common.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
-#include "registry.h"
#include "registry/reg_init_full.h"
#include "libcli/auth/schannel.h"
#include "secrets.h"
@@ -52,40 +51,6 @@ extern void start_spoolssd(struct event_context *ev_ctx,
extern int dcelogin_atmost_once;
#endif /* WITH_DFS */
-static void smbd_set_server_fd(int fd)
-{
- struct smbd_server_connection *sconn = smbd_server_conn;
- char addr[INET6_ADDRSTRLEN];
- const char *name;
-
- sconn->sock = fd;
-
- /*
- * Initialize sconn->client_id: If we can't find the client's
- * name, default to its address.
- */
-
- client_addr(fd, sconn->client_id.addr, sizeof(sconn->client_id.addr));
-
- name = client_name(sconn->sock);
- if (strcmp(name, "UNKNOWN") != 0) {
- name = talloc_strdup(sconn, name);
- } else {
- name = NULL;
- }
- sconn->client_id.name =
- (name != NULL) ? name : sconn->client_id.addr;
-
- sub_set_socket_ids(sconn->client_id.addr, sconn->client_id.name,
- client_socket_addr(sconn->sock, addr,
- sizeof(addr)));
-}
-
-struct event_context *smbd_event_context(void)
-{
- return server_event_context();
-}
-
/*******************************************************************
What to do when smb.conf is updated.
********************************************************************/
@@ -288,7 +253,7 @@ static void remove_child_pid(pid_t pid, bool unclean_shutdown)
if (!cleanup_te) {
/* call the cleanup timer, but not too often */
int cleanup_time = lp_parm_int(-1, "smbd", "cleanuptime", 20);
- cleanup_te = event_add_timed(smbd_event_context(), NULL,
+ cleanup_te = event_add_timed(server_event_context(), NULL,
timeval_current_ofs(cleanup_time, 0),
cleanup_timeout_fn,
&cleanup_te);
@@ -366,8 +331,8 @@ static void smbd_setup_sig_chld_handler(void)
{
struct tevent_signal *se;
- se = tevent_add_signal(smbd_event_context(),
- smbd_event_context(),
+ se = tevent_add_signal(server_event_context(),
+ server_event_context(),
SIGCHLD, 0,
smbd_sig_chld_handler,
NULL);
@@ -469,7 +434,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
s = NULL;
status = reinit_after_fork(smbd_messaging_context(),
- smbd_event_context(), procid_self(),
+ server_event_context(), procid_self(),
true);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,
@@ -582,7 +547,7 @@ static bool smbd_open_one_socket(struct smbd_parent_context *parent,
return false;
}
- s->fde = tevent_add_fd(smbd_event_context(),
+ s->fde = tevent_add_fd(server_event_context(),
s,
s->fd, TEVENT_FD_READ,
smbd_accept_connection,
@@ -632,7 +597,7 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
{
int num_interfaces = iface_count();
int i;
- char *ports;
+ const char *ports;
unsigned dns_port = 0;
#ifdef HAVE_ATEXIT
@@ -763,7 +728,7 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
return false;
}
- if (!(event_add_idle(smbd_event_context(), NULL,
+ if (!(event_add_idle(server_event_context(), NULL,
timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
"parent_housekeeping", smbd_parent_housekeeping,
NULL))) {
@@ -801,14 +766,14 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
if (lp_multicast_dns_register() && (dns_port != 0)) {
#ifdef WITH_DNSSD_SUPPORT
- smbd_setup_mdns_registration(smbd_event_context(),
+ smbd_setup_mdns_registration(server_event_context(),
parent, dns_port);
#endif
#ifdef WITH_AVAHI_SUPPORT
void *avahi_conn;
avahi_conn = avahi_start_register(
- smbd_event_context(), smbd_event_context(), dns_port);
+ server_event_context(), server_event_context(), dns_port);
if (avahi_conn == NULL) {
DEBUG(10, ("avahi_start_register failed\n"));
}
@@ -827,7 +792,7 @@ static void smbd_parent_loop(struct smbd_parent_context *parent)
int ret;
TALLOC_CTX *frame = talloc_stackframe();
- ret = tevent_loop_once(smbd_event_context());
+ ret = tevent_loop_once(server_event_context());
if (ret != 0) {
exit_server_cleanly("tevent_loop_once() error");
}
@@ -917,7 +882,7 @@ extern void build_options(bool screen);
load_case_tables();
/* Initialize the event context, it will panic on error */
- smbd_event_context();
+ server_event_context();
smbd_init_globals();
@@ -1063,7 +1028,7 @@ extern void build_options(bool screen);
* Reloading of the printers will not work here as we don't have a
* server info and rpc services set up. It will be called later.
*/
- if (!reload_services(smbd_messaging_context(), -1, False)) {
+ if (!reload_services(NULL, -1, False)) {
exit(1);
}
@@ -1124,7 +1089,7 @@ extern void build_options(bool screen);
pidfile_create("smbd");
status = reinit_after_fork(smbd_messaging_context(),
- smbd_event_context(),
+ server_event_context(),
procid_self(), false);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n"));
@@ -1134,7 +1099,7 @@ extern void build_options(bool screen);
smbd_server_conn->msg_ctx = smbd_messaging_context();
smbd_setup_sig_term_handler();
- smbd_setup_sig_hup_handler(smbd_event_context(),
+ smbd_setup_sig_hup_handler(server_event_context(),
smbd_server_conn->msg_ctx);
/* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
@@ -1148,7 +1113,7 @@ extern void build_options(bool screen);
/* Initialise the password backed before the global_sam_sid
to ensure that we fetch from ldap before we make a domain sid up */
- if(!initialize_password_db(False, smbd_event_context()))
+ if(!initialize_password_db(False, server_event_context()))
exit(1);
if (!secrets_init()) {
@@ -1178,15 +1143,15 @@ extern void build_options(bool screen);
if (!locking_init())
exit(1);
- if (!messaging_tdb_parent_init(smbd_event_context())) {
+ if (!messaging_tdb_parent_init(server_event_context())) {
exit(1);
}
- if (!notify_internal_parent_init(smbd_event_context())) {
+ if (!notify_internal_parent_init(server_event_context())) {
exit(1);
}
- if (!serverid_parent_init(smbd_event_context())) {
+ if (!serverid_parent_init(server_event_context())) {
exit(1);
}
@@ -1232,13 +1197,13 @@ extern void build_options(bool screen);
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server", "epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "daemon") == 0) {
- start_epmd(smbd_event_context(),
+ if (strcasecmp_m(rpcsrv_type, "daemon") == 0) {
+ start_epmd(server_event_context(),
smbd_server_conn->msg_ctx);
}
}
- if (!dcesrv_ep_setup(smbd_event_context(), smbd_server_conn->msg_ctx)) {
+ if (!dcesrv_ep_setup(server_event_context(), smbd_server_conn->msg_ctx)) {
exit(1);
}
@@ -1253,7 +1218,7 @@ extern void build_options(bool screen);
if (is_daemon && !interactive
&& lp_parm_bool(-1, "smbd", "backgroundqueue", true)) {
- start_background_queue(smbd_event_context(),
+ start_background_queue(server_event_context(),
smbd_messaging_context());
}
@@ -1265,8 +1230,8 @@ extern void build_options(bool screen);
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server", "spoolss",
"embedded");
- if (StrCaseCmp(rpcsrv_type, "daemon") == 0) {
- start_spoolssd(smbd_event_context(),
+ if (strcasecmp_m(rpcsrv_type, "daemon") == 0) {
+ start_spoolssd(server_event_context(),
smbd_messaging_context());
}
}
@@ -1296,7 +1261,7 @@ extern void build_options(bool screen);
return(0);
}
- parent = talloc_zero(smbd_event_context(), struct smbd_parent_context);
+ parent = talloc_zero(server_event_context(), struct smbd_parent_context);
if (!parent) {
exit_server("talloc(struct smbd_parent_context) failed");
}
diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c
index 554affc9849..c7a318d891f 100644
--- a/source3/smbd/server_exit.c
+++ b/source3/smbd/server_exit.c
@@ -25,7 +25,7 @@
#include "includes.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
-
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_dfs.h"
#include "../librpc/gen_ndr/srv_dssetup.h"
#include "../librpc/gen_ndr/srv_echo.h"
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c
index 82b0cb03e95..fef66dac6a5 100644
--- a/source3/smbd/server_reload.c
+++ b/source3/smbd/server_reload.c
@@ -113,7 +113,11 @@ bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
if (test && !lp_file_list_changed())
return(True);
- lp_killunused(conn_snum_used);
+ if (msg_ctx) {
+ lp_killunused(msg_ctx_to_sconn(msg_ctx), conn_snum_used);
+ } else {
+ lp_killunused(NULL, NULL);
+ }
ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index b29713d21d2..0857645d1c6 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "system/filesys.h"
+#include "../lib/tsocket/tsocket.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../librpc/gen_ndr/netlogon.h"
@@ -221,232 +222,6 @@ bool set_current_service(connection_struct *conn, uint16 flags, bool do_chdir)
return(True);
}
-static int load_registry_service(const char *servicename)
-{
- if (!lp_registry_shares()) {
- return -1;
- }
-
- if ((servicename == NULL) || (*servicename == '\0')) {
- return -1;
- }
-
- if (strequal(servicename, GLOBAL_NAME)) {
- return -2;
- }
-
- if (!process_registry_service(servicename)) {
- return -1;
- }
-
- return lp_servicenumber(servicename);
-}
-
-void load_registry_shares(void)
-{
- DEBUG(8, ("load_registry_shares()\n"));
- if (!lp_registry_shares()) {
- return;
- }
-
- process_registry_shares();
-
- return;
-}
-
-/****************************************************************************
- Add a home service. Returns the new service number or -1 if fail.
-****************************************************************************/
-
-int add_home_service(const char *service, const char *username, const char *homedir)
-{
- int iHomeService;
-
- if (!service || !homedir || homedir[0] == '\0')
- return -1;
-
- if ((iHomeService = lp_servicenumber(HOMES_NAME)) < 0) {
- if ((iHomeService = load_registry_service(HOMES_NAME)) < 0) {
- return -1;
- }
- }
-
- /*
- * If this is a winbindd provided username, remove
- * the domain component before adding the service.
- * Log a warning if the "path=" parameter does not
- * include any macros.
- */
-
- {
- const char *p = strchr(service,*lp_winbind_separator());
-
- /* We only want the 'user' part of the string */
- if (p) {
- service = p + 1;
- }
- }
-
- if (!lp_add_home(service, iHomeService, username, homedir)) {
- return -1;
- }
-
- return lp_servicenumber(service);
-
-}
-
-/**
- * Find a service entry.
- *
- * @param service is modified (to canonical form??)
- **/
-
-int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out)
-{
- int iService;
-
- if (!service_in) {
- return -1;
- }
-
- /* First make a copy. */
- *p_service_out = talloc_strdup(ctx, service_in);
- if (!*p_service_out) {
- return -1;
- }
-
- all_string_sub(*p_service_out,"\\","/",0);
-
- iService = lp_servicenumber(*p_service_out);
-
- /* now handle the special case of a home directory */
- if (iService < 0) {
- char *phome_dir = get_user_home_dir(ctx, *p_service_out);
-
- if(!phome_dir) {
- /*
- * Try mapping the servicename, it may
- * be a Windows to unix mapped user name.
- */
- if(map_username(ctx, *p_service_out, p_service_out)) {
- if (*p_service_out == NULL) {
- /* Out of memory. */
- return -1;
- }
- phome_dir = get_user_home_dir(
- ctx, *p_service_out);
- }
- }
-
- DEBUG(3,("checking for home directory %s gave %s\n",*p_service_out,
- phome_dir?phome_dir:"(NULL)"));
-
- iService = add_home_service(*p_service_out,*p_service_out /* 'username' */, phome_dir);
- }
-
- /* If we still don't have a service, attempt to add it as a printer. */
- if (iService < 0) {
- int iPrinterService;
-
- if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) < 0) {
- iPrinterService = load_registry_service(PRINTERS_NAME);
- }
- if (iPrinterService >= 0) {
- DEBUG(3,("checking whether %s is a valid printer name...\n",
- *p_service_out));
- if (pcap_printername_ok(*p_service_out)) {
- DEBUG(3,("%s is a valid printer name\n",
- *p_service_out));
- DEBUG(3,("adding %s as a printer service\n",
- *p_service_out));
- lp_add_printer(*p_service_out, iPrinterService);
- iService = lp_servicenumber(*p_service_out);
- if (iService < 0) {
- DEBUG(0,("failed to add %s as a printer service!\n",
- *p_service_out));
- }
- } else {
- DEBUG(3,("%s is not a valid printer name\n",
- *p_service_out));
- }
- }
- }
-
- /* Check for default vfs service? Unsure whether to implement this */
- if (iService < 0) {
- }
-
- if (iService < 0) {
- iService = load_registry_service(*p_service_out);
- }
-
- /* Is it a usershare service ? */
- if (iService < 0 && *lp_usershare_path()) {
- /* Ensure the name is canonicalized. */
- strlower_m(*p_service_out);
- iService = load_usershare_service(*p_service_out);
- }
-
- /* just possibly it's a default service? */
- if (iService < 0) {
- char *pdefservice = lp_defaultservice();
- if (pdefservice &&
- *pdefservice &&
- !strequal(pdefservice, *p_service_out)
- && !strstr_m(*p_service_out,"..")) {
- /*
- * We need to do a local copy here as lp_defaultservice()
- * returns one of the rotating lp_string buffers that
- * could get overwritten by the recursive find_service() call
- * below. Fix from Josef Hinteregger <joehtg@joehtg.co.at>.
- */
- char *defservice = talloc_strdup(ctx, pdefservice);
-
- if (!defservice) {
- goto fail;
- }
-
- /* Disallow anything except explicit share names. */
- if (strequal(defservice,HOMES_NAME) ||
- strequal(defservice, PRINTERS_NAME) ||
- strequal(defservice, "IPC$")) {
- TALLOC_FREE(defservice);
- goto fail;
- }
-
- iService = find_service(ctx, defservice, p_service_out);
- if (!*p_service_out) {
- TALLOC_FREE(defservice);
- iService = -1;
- goto fail;
- }
- if (iService >= 0) {
- all_string_sub(*p_service_out, "_","/",0);
- iService = lp_add_service(*p_service_out, iService);
- }
- TALLOC_FREE(defservice);
- }
- }
-
- if (iService >= 0) {
- if (!VALID_SNUM(iService)) {
- DEBUG(0,("Invalid snum %d for %s\n",iService,
- *p_service_out));
- iService = -1;
- }
- }
-
- fail:
-
- if (iService < 0) {
- DEBUG(3,("find_service() failed to find service %s\n",
- *p_service_out));
- }
-
- return (iService);
-}
-
-
/****************************************************************************
do some basic sainity checks on the share.
This function modifies dev, ecode.
@@ -930,7 +705,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
conn->notify_ctx = notify_init(conn,
sconn_server_id(sconn),
sconn->msg_ctx,
- smbd_event_context(),
+ server_event_context(),
conn);
}
diff --git a/source3/smbd/session.c b/source3/smbd/session.c
index f3a678b2055..48afb5389f9 100644
--- a/source3/smbd/session.c
+++ b/source3/smbd/session.c
@@ -231,7 +231,7 @@ static int gather_sessioninfo(const char *key, struct sessionid *session,
{
struct session_list *sesslist = (struct session_list *)private_data;
- sesslist->sessions = TALLOC_REALLOC_ARRAY(
+ sesslist->sessions = talloc_realloc(
sesslist->mem_ctx, sesslist->sessions, struct sessionid,
sesslist->count+1);
@@ -264,7 +264,7 @@ int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list)
sesslist.sessions = NULL;
ret = sessionid_traverse_read(gather_sessioninfo, (void *) &sesslist);
- if (ret == -1) {
+ if (ret < 0) {
DEBUG(3, ("Session traverse failed\n"));
SAFE_FREE(sesslist.sessions);
*session_list = NULL;
diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index 3cf6758e296..dda4ef296e4 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/smbd/sesssetup.c
@@ -23,6 +23,7 @@
*/
#include "includes.h"
+#include "../lib/tsocket/tsocket.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/auth/spnego.h"
@@ -193,7 +194,7 @@ static bool make_krb5_skew_error(DATA_BLOB *pblob_out)
return False;
}
/* Create server principal. */
- asprintf(&host_princ_s, "%s$@%s", global_myname(), lp_realm());
+ asprintf(&host_princ_s, "%s$@%s", lp_netbios_name(), lp_realm());
if (!host_princ_s) {
goto out;
}
@@ -929,13 +930,28 @@ static NTSTATUS check_spnego_blob_complete(struct smbd_server_connection *sconn,
}
asn1_load(data, *pblob);
- asn1_start_tag(data, pblob->data[0]);
- if (data->has_error || data->nesting == NULL) {
+ if (asn1_start_tag(data, pblob->data[0])) {
+ /* asn1_start_tag checks if the given
+ length of the blob is enough to complete
+ the tag. If it returns true we know
+ there is nothing to do - the blob is
+ complete. */
asn1_free(data);
- /* Let caller catch. */
return NT_STATUS_OK;
}
+ if (data->nesting == NULL) {
+ /* Incorrect tag, allocation failed,
+ or reading the tag length failed.
+ Let the caller catch. */
+ asn1_free(data);
+ return NT_STATUS_OK;
+ }
+
+ /* Here we know asn1_start_tag() has set data->has_error to true.
+ asn1_tag_remaining() will have failed due to the given blob
+ being too short. We need to work out how short. */
+
/* Integer wrap paranoia.... */
if (data->nesting->taglen + data->nesting->start < data->nesting->taglen ||
@@ -964,6 +980,13 @@ static NTSTATUS check_spnego_blob_complete(struct smbd_server_connection *sconn,
if (needed_len <= pblob->length) {
/* Nothing to do - blob is complete. */
+ /* THIS SHOULD NOT HAPPEN - asn1_start_tag()
+ above should have caught this !!! */
+ DEBUG(0,("check_spnego_blob_complete: logic "
+ "error (needed_len = %u, "
+ "pblob->length = %u).\n",
+ (unsigned int)needed_len,
+ (unsigned int)pblob->length ));
return NT_STATUS_OK;
}
@@ -1042,7 +1065,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req)
file_save("negotiate.dat", blob1.data, blob1.length);
#endif
- p2 = (char *)req->buf + blob1.length;
+ p2 = (const char *)req->buf + blob1.length;
p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2,
STR_TERMINATE);
@@ -1200,7 +1223,7 @@ static int shutdown_other_smbds(const struct connections_key *key,
struct shutdown_state *state = (struct shutdown_state *)private_data;
DEBUG(10, ("shutdown_other_smbds: %s, %s\n",
- procid_str(talloc_tos(), &crec->pid), crec->addr));
+ server_id_str(talloc_tos(), &crec->pid), crec->addr));
if (!process_exists(crec->pid)) {
DEBUG(10, ("process does not exist\n"));
@@ -1684,7 +1707,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
data_blob_free(&lm_resp);
SSVAL(req->outbuf,smb_uid,sess_vuid);
- SSVAL(req->inbuf,smb_uid,sess_vuid);
+ SSVAL(discard_const_p(char, req->inbuf),smb_uid,sess_vuid);
req->vuid = sess_vuid;
if (!sconn->smb1.sessions.done_sesssetup) {
diff --git a/source3/smbd/signing.c b/source3/smbd/signing.c
index bea24098839..25b3c40d7d2 100644
--- a/source3/smbd/signing.c
+++ b/source3/smbd/signing.c
@@ -176,7 +176,7 @@ bool srv_init_signing(struct smbd_server_connection *conn)
struct smbd_shm_signing *s;
/* setup the signing state in shared memory */
- s = talloc_zero(smbd_event_context(), struct smbd_shm_signing);
+ s = talloc_zero(server_event_context(), struct smbd_shm_signing);
if (s == NULL) {
return false;
}
@@ -198,7 +198,7 @@ bool srv_init_signing(struct smbd_server_connection *conn)
return true;
}
- conn->smb1.signing_state = smb_signing_init(smbd_event_context(),
+ conn->smb1.signing_state = smb_signing_init(server_event_context(),
allowed, mandatory);
if (!conn->smb1.signing_state) {
return false;
diff --git a/source3/smbd/smb2_break.c b/source3/smbd/smb2_break.c
index 925384c3bfe..5d5ab4139d9 100644
--- a/source3/smbd/smb2_break.c
+++ b/source3/smbd/smb2_break.c
@@ -23,6 +23,7 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
+#include "../lib/util/tevent_ntstatus.h"
static struct tevent_req *smbd_smb2_oplock_break_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index 6e292468f9e..73b8ade5bd3 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -25,6 +25,7 @@
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
#include "../librpc/gen_ndr/ndr_security.h"
+#include "../lib/util/tevent_ntstatus.h"
int map_smb2_oplock_levels_to_samba(uint8_t in_oplock_level)
{
diff --git a/source3/smbd/smb2_find.c b/source3/smbd/smb2_find.c
index 3ac573c2137..9fc8f1fef26 100644
--- a/source3/smbd/smb2_find.c
+++ b/source3/smbd/smb2_find.c
@@ -23,6 +23,7 @@
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
#include "trans2.h"
+#include "../lib/util/tevent_ntstatus.h"
static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -228,7 +229,7 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx,
int last_entry_off = 0;
int off = 0;
uint32_t num = 0;
- uint32_t dirtype = aHIDDEN | aSYSTEM | aDIR;
+ uint32_t dirtype = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY;
bool dont_descend = false;
bool ask_sharemode = true;
diff --git a/source3/smbd/smb2_flush.c b/source3/smbd/smb2_flush.c
index 93955929077..c3f5a301290 100644
--- a/source3/smbd/smb2_flush.c
+++ b/source3/smbd/smb2_flush.c
@@ -22,6 +22,7 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
+#include "../lib/util/tevent_ntstatus.h"
static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
diff --git a/source3/smbd/smb2_getinfo.c b/source3/smbd/smb2_getinfo.c
index 1d6b862d6ae..3c8c690342e 100644
--- a/source3/smbd/smb2_getinfo.c
+++ b/source3/smbd/smb2_getinfo.c
@@ -24,6 +24,7 @@
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
#include "trans2.h"
+#include "../lib/util/tevent_ntstatus.h"
static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
diff --git a/source3/smbd/smb2_ioctl.c b/source3/smbd/smb2_ioctl.c
index 6ee9318212e..bce02b0a3a8 100644
--- a/source3/smbd/smb2_ioctl.c
+++ b/source3/smbd/smb2_ioctl.c
@@ -22,6 +22,9 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "rpc_server/srv_pipe_hnd.h"
+#include "include/ntioctl.h"
static struct tevent_req *smbd_smb2_ioctl_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -242,8 +245,9 @@ static struct tevent_req *smbd_smb2_ioctl_send(TALLOC_CTX *mem_ctx,
state->in_max_output = in_max_output;
state->out_output = data_blob_null;
- DEBUG(10,("smbd_smb2_ioctl: file_id[0x%016llX]\n",
- (unsigned long long)in_file_id_volatile));
+ DEBUG(10, ("smbd_smb2_ioctl: ctl_code[0x%08x] file_id[0x%016llX]\n",
+ (unsigned)in_ctl_code,
+ (unsigned long long)in_file_id_volatile));
smbreq = smbd_smb2_fake_smb_request(smb2req);
if (tevent_req_nomem(smbreq, req)) {
@@ -375,6 +379,131 @@ static struct tevent_req *smbd_smb2_ioctl_send(TALLOC_CTX *mem_ctx,
req);
return req;
+ case 0x00144064: /* FSCTL_SRV_ENUMERATE_SNAPSHOTS */
+ {
+ /*
+ * This is called to retrieve the number of Shadow Copies (a.k.a. snapshots)
+ * and return their volume names. If max_data_count is 16, then it is just
+ * asking for the number of volumes and length of the combined names.
+ *
+ * pdata is the data allocated by our caller, but that uses
+ * total_data_count (which is 0 in our case) rather than max_data_count.
+ * Allocate the correct amount and return the pointer to let
+ * it be deallocated when we return.
+ */
+ struct shadow_copy_data *shadow_data = NULL;
+ bool labels = False;
+ uint32_t labels_data_count = 0;
+ uint32_t data_count;
+ uint32_t i;
+ char *pdata;
+ NTSTATUS status;
+
+ if (fsp == NULL) {
+ tevent_req_nterror(req, NT_STATUS_FILE_CLOSED);
+ return tevent_req_post(req, ev);
+ }
+
+ if (in_max_output < 16) {
+ DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: "
+ "in_max_output(%u) < 16 is invalid!\n",
+ in_max_output));
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ return tevent_req_post(req, ev);
+ }
+
+ if (in_max_output > 16) {
+ labels = True;
+ }
+
+ shadow_data = talloc_zero(talloc_tos(),
+ struct shadow_copy_data);
+ if (tevent_req_nomem(shadow_data, req)) {
+ DEBUG(0,("TALLOC_ZERO() failed!\n"));
+ return tevent_req_post(req, ev);
+ }
+
+ /*
+ * Call the VFS routine to actually do the work.
+ */
+ if (SMB_VFS_GET_SHADOW_COPY_DATA(fsp, shadow_data, labels)
+ != 0) {
+ if (errno == ENOSYS) {
+ DEBUG(5, ("FSCTL_GET_SHADOW_COPY_DATA: "
+ "connectpath %s, not supported.\n",
+ smbreq->conn->connectpath));
+ status = NT_STATUS_NOT_SUPPORTED;
+ } else {
+ DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: "
+ "connectpath %s, failed.\n",
+ smbreq->conn->connectpath));
+ status = map_nt_error_from_unix(errno);
+ }
+ TALLOC_FREE(shadow_data);
+ tevent_req_nterror(req, status);
+ return tevent_req_post(req, ev);
+ }
+
+ labels_data_count =
+ (shadow_data->num_volumes*2*sizeof(SHADOW_COPY_LABEL))
+ + 2;
+
+ if (labels) {
+ data_count = 12+labels_data_count+4;
+ } else {
+ data_count = 16;
+ }
+
+ if (labels && (in_max_output < data_count)) {
+ DEBUG(0, ("FSCTL_GET_SHADOW_COPY_DATA: "
+ "in_max_output(%u) too small (%u) bytes "
+ "needed!\n", in_max_output, data_count));
+ TALLOC_FREE(shadow_data);
+ tevent_req_nterror(req, NT_STATUS_BUFFER_TOO_SMALL);
+ return tevent_req_post(req, ev);
+ }
+
+ state->out_output = data_blob_talloc(state, NULL, data_count);
+ if (tevent_req_nomem(state->out_output.data, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ pdata = (char *)state->out_output.data;
+
+ /* num_volumes 4 bytes */
+ SIVAL(pdata, 0, shadow_data->num_volumes);
+
+ if (labels) {
+ /* num_labels 4 bytes */
+ SIVAL(pdata, 4, shadow_data->num_volumes);
+ }
+
+ /* needed_data_count 4 bytes */
+ SIVAL(pdata, 8, labels_data_count+4);
+
+ pdata += 12;
+
+ DEBUG(10,("FSCTL_GET_SHADOW_COPY_DATA: %u volumes for "
+ "path[%s].\n",
+ shadow_data->num_volumes, fsp_str_dbg(fsp)));
+ if (labels && shadow_data->labels) {
+ for (i=0; i<shadow_data->num_volumes; i++) {
+ srvstr_push(pdata, smbreq->flags2,
+ pdata, shadow_data->labels[i],
+ 2*sizeof(SHADOW_COPY_LABEL),
+ STR_UNICODE|STR_TERMINATE);
+ pdata += 2*sizeof(SHADOW_COPY_LABEL);
+ DEBUGADD(10, ("Label[%u]: '%s'\n", i,
+ shadow_data->labels[i]));
+ }
+ }
+
+ TALLOC_FREE(shadow_data);
+
+ tevent_req_done(req);
+ return tevent_req_post(req, ev);
+ }
+
default:
if (IS_IPC(smbreq->conn)) {
tevent_req_nterror(req, NT_STATUS_FS_DRIVER_REQUIRED);
diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c
index dcf1e0c6a53..5d615e1bed5 100644
--- a/source3/smbd/smb2_lock.c
+++ b/source3/smbd/smb2_lock.c
@@ -23,6 +23,7 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "messages.h"
struct smbd_smb2_lock_element {
@@ -567,7 +568,7 @@ static bool recalc_smb2_brl_timeout(struct smbd_server_connection *sconn)
}
sconn->smb2.locks.brl_timeout = event_add_timed(
- smbd_event_context(),
+ server_event_context(),
NULL,
next_timeout,
brl_timeout_fn,
@@ -627,9 +628,7 @@ bool push_blocking_lock_request_smb2( struct byte_range_lock *br_lck,
blr->expire_time.tv_sec = 0;
blr->expire_time.tv_usec = 0; /* Never expire. */
} else {
- blr->expire_time = timeval_current_ofs(
- lock_timeout/1000,
- (lock_timeout % 1000) * 1000);
+ blr->expire_time = timeval_current_ofs_msec(lock_timeout);
}
blr->lock_num = lock_num;
diff --git a/source3/smbd/smb2_negprot.c b/source3/smbd/smb2_negprot.c
index 1e02c88d3dc..f639503ad4c 100644
--- a/source3/smbd/smb2_negprot.c
+++ b/source3/smbd/smb2_negprot.c
@@ -78,7 +78,7 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
uint16_t dialect = 0;
uint32_t capabilities;
-/* TODO: drop the connection with INVALI_PARAMETER */
+/* TODO: drop the connection with INVALID_PARAMETER */
if (req->in.vector[i+1].iov_len != (expected_body_size & 0xFFFFFFFE)) {
return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
@@ -177,5 +177,7 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
outdyn = security_buffer;
+ req->sconn->using_smb2 = true;
+
return smbd_smb2_request_done(req, outbody, &outdyn);
}
diff --git a/source3/smbd/smb2_notify.c b/source3/smbd/smb2_notify.c
index d52b2878eca..9e377ceda42 100644
--- a/source3/smbd/smb2_notify.c
+++ b/source3/smbd/smb2_notify.c
@@ -23,6 +23,7 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
+#include "../lib/util/tevent_ntstatus.h"
struct smbd_smb2_notify_state {
struct smbd_smb2_request *smb2req;
diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c
index bffda890106..6e686ef2738 100644
--- a/source3/smbd/smb2_read.c
+++ b/source3/smbd/smb2_read.c
@@ -24,6 +24,8 @@
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
#include "libcli/security/security.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "rpc_server/srv_pipe_hnd.h"
static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -306,7 +308,7 @@ static NTSTATUS schedule_smb2_sendfile_read(struct smbd_smb2_request *smb2req,
/* Make a copy of state attached to the smb2req. Attach
the destructor here as this will trigger the sendfile
call when the request is destroyed. */
- state_copy = TALLOC_P(smb2req, struct smbd_smb2_read_state);
+ state_copy = talloc(smb2req, struct smbd_smb2_read_state);
if (!state_copy) {
return NT_STATUS_NO_MEMORY;
}
@@ -442,7 +444,7 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- subreq = np_read_send(state, smbd_event_context(),
+ subreq = np_read_send(state, server_event_context(),
fsp->fake_file_handle,
state->out_data.data,
state->out_data.length);
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index 0004e7ca8ca..65bb5b9eb0a 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -24,6 +24,7 @@
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
#include "../lib/tsocket/tsocket.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "smbprofile.h"
#define OUTVEC_ALLOC_SIZE (SMB2_HDR_BODY + 9)
@@ -94,7 +95,7 @@ static NTSTATUS smbd_initialize_smb2(struct smbd_server_connection *sconn)
TALLOC_FREE(sconn->smb1.fde);
- sconn->smb2.event_ctx = smbd_event_context();
+ sconn->smb2.event_ctx = server_event_context();
sconn->smb2.recv_queue = tevent_queue_create(sconn, "smb2 recv queue");
if (sconn->smb2.recv_queue == NULL) {
@@ -268,15 +269,15 @@ static NTSTATUS smbd_smb2_request_create(struct smbd_server_connection *sconn,
memcpy(req->in.nbt_hdr, inbuf, 4);
ofs = 0;
- req->in.vector[0].iov_base = (void *)req->in.nbt_hdr;
+ req->in.vector[0].iov_base = discard_const_p(void, req->in.nbt_hdr);
req->in.vector[0].iov_len = 4;
ofs += req->in.vector[0].iov_len;
- req->in.vector[1].iov_base = (void *)(inbuf + ofs);
+ req->in.vector[1].iov_base = discard_const_p(void, (inbuf + ofs));
req->in.vector[1].iov_len = SMB2_HDR_BODY;
ofs += req->in.vector[1].iov_len;
- req->in.vector[2].iov_base = (void *)(inbuf + ofs);
+ req->in.vector[2].iov_base = discard_const_p(void, (inbuf + ofs));
req->in.vector[2].iov_len = SVAL(inbuf, ofs) & 0xFFFE;
ofs += req->in.vector[2].iov_len;
@@ -284,7 +285,7 @@ static NTSTATUS smbd_smb2_request_create(struct smbd_server_connection *sconn,
return NT_STATUS_INVALID_PARAMETER;
}
- req->in.vector[3].iov_base = (void *)(inbuf + ofs);
+ req->in.vector[3].iov_base = discard_const_p(void, (inbuf + ofs));
req->in.vector[3].iov_len = size - ofs;
ofs += req->in.vector[3].iov_len;
@@ -607,7 +608,7 @@ static bool dup_smb2_vec3(TALLOC_CTX *ctx,
srcvec[1].iov_base ==
((uint8_t *)srcvec[0].iov_base) +
SMB2_HDR_BODY) {
- outvec[1].iov_base = ((uint8_t *)outvec[1].iov_base) +
+ outvec[1].iov_base = ((uint8_t *)outvec[0].iov_base) +
SMB2_HDR_BODY;
outvec[1].iov_len = 8;
} else {
@@ -2017,9 +2018,11 @@ static int smbd_smb2_request_next_vector(struct tstream_context *stream,
invalid = true;
}
- if ((body_size % 2) != 0) {
- body_size -= 1;
- }
+ /*
+ * Mask out the lowest bit, the "dynamic" part
+ * of body_size.
+ */
+ body_size &= ~1;
if (body_size > (full_size - SMB2_HDR_BODY)) {
/*
diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c
index d727ee98b02..c33d1c61be9 100644
--- a/source3/smbd/smb2_sesssetup.c
+++ b/source3/smbd/smb2_sesssetup.c
@@ -844,7 +844,7 @@ NTSTATUS smbd_smb2_request_check_session(struct smbd_smb2_request *req)
if (chained_fixup) {
/* Fix up our own outhdr. */
outhdr = (const uint8_t *)req->out.vector[i].iov_base;
- SBVAL(outhdr, SMB2_HDR_SESSION_ID, in_session_id);
+ SBVAL(discard_const_p(uint8_t, outhdr), SMB2_HDR_SESSION_ID, in_session_id);
}
return NT_STATUS_OK;
}
diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c
index 39b7aee76b5..e1149408d19 100644
--- a/source3/smbd/smb2_setinfo.c
+++ b/source3/smbd/smb2_setinfo.c
@@ -24,6 +24,7 @@
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
#include "trans2.h"
+#include "../lib/util/tevent_ntstatus.h"
static struct tevent_req *smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
diff --git a/source3/smbd/smb2_tcon.c b/source3/smbd/smb2_tcon.c
index bdd18d5d07e..1b4aa79070a 100644
--- a/source3/smbd/smb2_tcon.c
+++ b/source3/smbd/smb2_tcon.c
@@ -331,7 +331,7 @@ NTSTATUS smbd_smb2_request_check_tcon(struct smbd_smb2_request *req)
if (chained_fixup) {
/* Fix up our own outhdr. */
outhdr = (const uint8_t *)req->out.vector[i].iov_base;
- SIVAL(outhdr, SMB2_HDR_TID, in_tid);
+ SIVAL(discard_const_p(uint8_t, outhdr), SMB2_HDR_TID, in_tid);
}
return NT_STATUS_OK;
diff --git a/source3/smbd/smb2_write.c b/source3/smbd/smb2_write.c
index 413fe0c7d17..057abcc8f7f 100644
--- a/source3/smbd/smb2_write.c
+++ b/source3/smbd/smb2_write.c
@@ -22,6 +22,8 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "rpc_server/srv_pipe_hnd.h"
static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -281,7 +283,7 @@ static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- subreq = np_write_send(state, smbd_event_context(),
+ subreq = np_write_send(state, server_event_context(),
fsp->fake_file_handle,
in_data.data,
in_data.length);
diff --git a/source3/smbd/srvstr.c b/source3/smbd/srvstr.c
index 050de599a57..c069dd4a5ec 100644
--- a/source3/smbd/srvstr.c
+++ b/source3/smbd/srvstr.c
@@ -56,7 +56,7 @@ ssize_t message_push_string(uint8 **outbuf, const char *str, int flags)
*/
grow_size = (strlen(str) + 2) * 4;
- if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, *outbuf, uint8,
+ if (!(tmp = talloc_realloc(NULL, *outbuf, uint8,
buf_size + grow_size))) {
DEBUG(0, ("talloc failed\n"));
return -1;
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index 5c74b928550..963b7c4bc13 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -25,6 +25,7 @@
#include "smbd/smbd.h"
#include "messages.h"
#include "smbprofile.h"
+#include "tdb_compat.h"
/****************************************************************************
Stat cache code used in unix_convert.
@@ -339,8 +340,8 @@ bool stat_cache_lookup(connection_struct *conn,
Tell all smbd's to delete an entry.
**************************************************************************/
-void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
- const char *name)
+void smbd_send_stat_cache_delete_message(struct messaging_context *msg_ctx,
+ const char *name)
{
#ifdef DEVELOPER
message_send_all(msg_ctx,
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 507ae9ba93a..b853722eae0 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -35,6 +35,7 @@
#include "trans2.h"
#include "auth.h"
#include "smbprofile.h"
+#include "rpc_server/srv_pipe_hnd.h"
#define DIR_ENTRY_SAFETY_MARGIN 4096
@@ -106,7 +107,7 @@ static bool samba_private_attr_name(const char *unix_ea_name)
if (strequal( prohibited_ea_names[i], unix_ea_name))
return true;
}
- if (StrnCaseCmp(unix_ea_name, SAMBA_XATTR_DOSSTREAM_PREFIX,
+ if (strncasecmp_m(unix_ea_name, SAMBA_XATTR_DOSSTREAM_PREFIX,
strlen(SAMBA_XATTR_DOSSTREAM_PREFIX)) == 0) {
return true;
}
@@ -128,7 +129,7 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
again:
- val = TALLOC_REALLOC_ARRAY(mem_ctx, val, char, attr_size);
+ val = talloc_realloc(mem_ctx, val, char, attr_size);
if (!val) {
return NT_STATUS_NO_MEMORY;
}
@@ -191,7 +192,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
* TALLOC the result early to get the talloc hierarchy right.
*/
- names = TALLOC_ARRAY(mem_ctx, char *, 1);
+ names = talloc_array(mem_ctx, char *, 1);
if (names == NULL) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
@@ -199,7 +200,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
while (ea_namelist_size <= 65536) {
- ea_namelist = TALLOC_REALLOC_ARRAY(
+ ea_namelist = talloc_realloc(
names, ea_namelist, char, ea_namelist_size);
if (ea_namelist == NULL) {
DEBUG(0, ("talloc failed\n"));
@@ -258,7 +259,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
num_names += 1;
}
- tmp = TALLOC_REALLOC_ARRAY(mem_ctx, names, char *, num_names);
+ tmp = talloc_realloc(mem_ctx, names, char *, num_names);
if (tmp == NULL) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(names);
@@ -315,7 +316,7 @@ static struct ea_list *get_ea_list_from_file(TALLOC_CTX *mem_ctx, connection_str
|| samba_private_attr_name(names[i]))
continue;
- listp = TALLOC_P(mem_ctx, struct ea_list);
+ listp = talloc(mem_ctx, struct ea_list);
if (listp == NULL) {
return NULL;
}
@@ -387,7 +388,7 @@ static unsigned int fill_ea_buffer(TALLOC_CTX *mem_ctx, char *pdata, unsigned in
SCVAL(p,0,ea_list->ea.flags);
SCVAL(p,1,dos_namelen);
SSVAL(p,2,ea_list->ea.value.length);
- fstrcpy(p+4, dos_ea_name);
+ strlcpy(p+4, dos_ea_name, dos_namelen+1);
memcpy( p + 4 + dos_namelen + 1, ea_list->ea.value.data, ea_list->ea.value.length);
total_data_size -= 4 + dos_namelen + 1 + ea_list->ea.value.length;
@@ -451,7 +452,7 @@ static NTSTATUS fill_ea_chained_buffer(TALLOC_CTX *mem_ctx,
SCVAL(p, 0x04, ea_list->ea.flags);
SCVAL(p, 0x05, dos_namelen);
SSVAL(p, 0x06, ea_list->ea.value.length);
- fstrcpy((char *)(p+0x08), dos_ea_name);
+ strlcpy((char *)(p+0x08), dos_ea_name, dos_namelen+1);
memcpy(p + 0x08 + dos_namelen + 1, ea_list->ea.value.data, ea_list->ea.value.length);
total_data_size -= this_size;
@@ -490,7 +491,7 @@ static void canonicalize_ea_name(connection_struct *conn, files_struct *fsp, con
if (strequal(&unix_ea_name[5], ea_list->ea.name)) {
DEBUG(10,("canonicalize_ea_name: %s -> %s\n",
&unix_ea_name[5], ea_list->ea.name));
- safe_strcpy(&unix_ea_name[5], ea_list->ea.name, sizeof(fstring)-6);
+ strlcpy(&unix_ea_name[5], ea_list->ea.name, sizeof(fstring)-5);
break;
}
}
@@ -589,7 +590,7 @@ static struct ea_list *read_ea_name_list(TALLOC_CTX *ctx, const char *pdata, siz
size_t converted_size, offset = 0;
while (offset + 2 < data_size) {
- struct ea_list *eal = TALLOC_ZERO_P(ctx, struct ea_list);
+ struct ea_list *eal = talloc_zero(ctx, struct ea_list);
unsigned int namelen = CVAL(pdata,offset);
offset++; /* Go past the namelen byte. */
@@ -627,7 +628,7 @@ static struct ea_list *read_ea_name_list(TALLOC_CTX *ctx, const char *pdata, siz
struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t data_size, size_t *pbytes_used)
{
- struct ea_list *eal = TALLOC_ZERO_P(ctx, struct ea_list);
+ struct ea_list *eal = talloc_zero(ctx, struct ea_list);
uint16 val_len;
unsigned int namelen;
size_t converted_size;
@@ -1148,7 +1149,7 @@ static void call_trans2open(connection_struct *conn,
fattr = dos_mode(conn, smb_fname);
mtime = convert_timespec_to_time_t(smb_fname->st.st_ex_mtime);
inode = smb_fname->st.st_ex_ino;
- if (fattr & aDIR) {
+ if (fattr & FILE_ATTRIBUTE_DIRECTORY) {
close_file(req, fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_ACCESS_DENIED);
goto out;
@@ -1218,7 +1219,7 @@ static bool exact_match(bool has_wild,
if (case_sensitive) {
return strcmp(str,mask)==0;
} else {
- return StrCaseCmp(str,mask) == 0;
+ return strcasecmp_m(str,mask) == 0;
}
}
@@ -1524,7 +1525,7 @@ static bool smbd_marshall_dir_entry(TALLOC_CTX *ctx,
ZERO_STRUCT(create_date_ts);
ZERO_STRUCT(cdate_ts);
- if (!(mode & aDIR)) {
+ if (!(mode & FILE_ATTRIBUTE_DIRECTORY)) {
file_size = get_file_size_stat(&smb_fname->st);
}
allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, NULL, &smb_fname->st);
@@ -3733,36 +3734,10 @@ cap_low = 0x%x, cap_high = 0x%x\n",
/* unknown_1 24 NULL bytes in pdata*/
/* the soft quotas 8 bytes (uint64_t)*/
- quotas.softlim = (uint64_t)IVAL(pdata,24);
-#ifdef LARGE_SMB_OFF_T
- quotas.softlim |= (((uint64_t)IVAL(pdata,28)) << 32);
-#else /* LARGE_SMB_OFF_T */
- if ((IVAL(pdata,28) != 0)&&
- ((quotas.softlim != 0xFFFFFFFF)||
- (IVAL(pdata,28)!=0xFFFFFFFF))) {
- /* more than 32 bits? */
- reply_nterror(
- req,
- NT_STATUS_INVALID_PARAMETER);
- return;
- }
-#endif /* LARGE_SMB_OFF_T */
+ quotas.softlim = BVAL(pdata,24);
/* the hard quotas 8 bytes (uint64_t)*/
- quotas.hardlim = (uint64_t)IVAL(pdata,32);
-#ifdef LARGE_SMB_OFF_T
- quotas.hardlim |= (((uint64_t)IVAL(pdata,36)) << 32);
-#else /* LARGE_SMB_OFF_T */
- if ((IVAL(pdata,36) != 0)&&
- ((quotas.hardlim != 0xFFFFFFFF)||
- (IVAL(pdata,36)!=0xFFFFFFFF))) {
- /* more than 32 bits? */
- reply_nterror(
- req,
- NT_STATUS_INVALID_PARAMETER);
- return;
- }
-#endif /* LARGE_SMB_OFF_T */
+ quotas.hardlim = BVAL(pdata,32);
/* quota_flags 2 bytes **/
quotas.qflags = SVAL(pdata,40);
@@ -4253,7 +4228,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
mode = dos_mode(conn, smb_fname);
nlink = psbuf->st_ex_nlink;
- if (nlink && (mode&aDIR)) {
+ if (nlink && (mode&FILE_ATTRIBUTE_DIRECTORY)) {
nlink = 1;
}
@@ -4334,7 +4309,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
}
}
- if (!(mode & aDIR)) {
+ if (!(mode & FILE_ATTRIBUTE_DIRECTORY)) {
file_size = get_file_size_stat(psbuf);
}
@@ -4504,7 +4479,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
SOFF_T(pdata,8,file_size);
SIVAL(pdata,16,nlink);
SCVAL(pdata,20,delete_pending?1:0);
- SCVAL(pdata,21,(mode&aDIR)?1:0);
+ SCVAL(pdata,21,(mode&FILE_ATTRIBUTE_DIRECTORY)?1:0);
SSVAL(pdata,22,0); /* Padding. */
break;
@@ -4587,7 +4562,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
SOFF_T(pdata,8,file_size);
SIVAL(pdata,16,nlink);
SCVAL(pdata,20,delete_pending);
- SCVAL(pdata,21,(mode&aDIR)?1:0);
+ SCVAL(pdata,21,(mode&FILE_ATTRIBUTE_DIRECTORY)?1:0);
SSVAL(pdata,22,0);
pdata += 24;
SIVAL(pdata,0,ea_size);
@@ -4618,7 +4593,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
SBVAL(pdata, 0x30, file_size);
SIVAL(pdata, 0x38, nlink);
SCVAL(pdata, 0x3C, delete_pending);
- SCVAL(pdata, 0x3D, (mode&aDIR)?1:0);
+ SCVAL(pdata, 0x3D, (mode&FILE_ATTRIBUTE_DIRECTORY)?1:0);
SSVAL(pdata, 0x3E, 0); /* padding */
SBVAL(pdata, 0x40, file_index);
SIVAL(pdata, 0x48, ea_size);
@@ -4793,7 +4768,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
case SMB_QUERY_FILE_UNIX_LINK:
{
int len;
- char *buffer = TALLOC_ARRAY(mem_ctx, char, PATH_MAX+1);
+ char *buffer = talloc_array(mem_ctx, char, PATH_MAX+1);
if (!buffer) {
return NT_STATUS_NO_MEMORY;
@@ -5326,7 +5301,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
}
/* Copy the lock range data. */
- lock_data = (char *)TALLOC_MEMDUP(
+ lock_data = (char *)talloc_memdup(
req, pdata, total_data);
if (!lock_data) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
@@ -5580,9 +5555,9 @@ static NTSTATUS smb_set_file_dosmode(connection_struct *conn,
if (dosmode) {
if (S_ISDIR(smb_fname_base->st.st_ex_mode)) {
- dosmode |= aDIR;
+ dosmode |= FILE_ATTRIBUTE_DIRECTORY;
} else {
- dosmode &= ~aDIR;
+ dosmode &= ~FILE_ATTRIBUTE_DIRECTORY;
}
}
@@ -6075,8 +6050,9 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
"SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n",
fsp->fnum, fsp_str_dbg(fsp),
smb_fname_str_dbg(smb_fname_dst)));
- status = rename_internals_fsp(conn, fsp, smb_fname_dst, 0,
- overwrite);
+ status = rename_internals_fsp(conn, fsp, smb_fname_dst,
+ (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM),
+ overwrite);
out:
TALLOC_FREE(smb_fname_dst);
@@ -7251,6 +7227,9 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
Open/Create a file with POSIX semantics.
****************************************************************************/
+#define SMB_O_RDONLY_MAPPING (FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA)
+#define SMB_O_WRONLY_MAPPING (FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES|FILE_WRITE_EA)
+
static NTSTATUS smb_posix_open(connection_struct *conn,
struct smb_request *req,
char **ppdata,
@@ -7266,7 +7245,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
uint32 mod_unixmode = 0;
uint32 create_disp = 0;
uint32 access_mask = 0;
- uint32 create_options = 0;
+ uint32 create_options = FILE_NON_DIRECTORY_FILE;
NTSTATUS status = NT_STATUS_OK;
mode_t unixmode = (mode_t)0;
files_struct *fsp = NULL;
@@ -7296,13 +7275,14 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
switch (wire_open_mode & SMB_ACCMODE) {
case SMB_O_RDONLY:
- access_mask = FILE_READ_DATA;
+ access_mask = SMB_O_RDONLY_MAPPING;
break;
case SMB_O_WRONLY:
- access_mask = FILE_WRITE_DATA;
+ access_mask = SMB_O_WRONLY_MAPPING;
break;
case SMB_O_RDWR:
- access_mask = FILE_READ_DATA|FILE_WRITE_DATA;
+ access_mask = (SMB_O_RDONLY_MAPPING|
+ SMB_O_WRONLY_MAPPING);
break;
default:
DEBUG(5,("smb_posix_open: invalid open mode 0x%x\n",
@@ -7312,18 +7292,55 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
wire_open_mode &= ~SMB_ACCMODE;
- if((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) == (SMB_O_CREAT | SMB_O_EXCL)) {
- create_disp = FILE_CREATE;
- } else if((wire_open_mode & (SMB_O_CREAT | SMB_O_TRUNC)) == (SMB_O_CREAT | SMB_O_TRUNC)) {
- create_disp = FILE_OVERWRITE_IF;
- } else if((wire_open_mode & SMB_O_CREAT) == SMB_O_CREAT) {
- create_disp = FILE_OPEN_IF;
- } else if ((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL | SMB_O_TRUNC)) == 0) {
- create_disp = FILE_OPEN;
- } else {
- DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n",
- (unsigned int)wire_open_mode ));
- return NT_STATUS_INVALID_PARAMETER;
+ /* First take care of O_CREAT|O_EXCL interactions. */
+ switch (wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) {
+ case (SMB_O_CREAT | SMB_O_EXCL):
+ /* File exists fail. File not exist create. */
+ create_disp = FILE_CREATE;
+ break;
+ case SMB_O_CREAT:
+ /* File exists open. File not exist create. */
+ create_disp = FILE_OPEN_IF;
+ break;
+ case 0:
+ /* File exists open. File not exist fail. */
+ create_disp = FILE_OPEN;
+ break;
+ case SMB_O_EXCL:
+ /* O_EXCL on its own without O_CREAT is undefined. */
+ default:
+ DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n",
+ (unsigned int)wire_open_mode ));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ /* Next factor in the effects of O_TRUNC. */
+ wire_open_mode &= ~(SMB_O_CREAT | SMB_O_EXCL);
+
+ if (wire_open_mode & SMB_O_TRUNC) {
+ switch (create_disp) {
+ case FILE_CREATE:
+ /* (SMB_O_CREAT | SMB_O_EXCL | O_TRUNC) */
+ /* Leave create_disp alone as
+ (O_CREAT|O_EXCL|O_TRUNC) == (O_CREAT|O_EXCL)
+ */
+ /* File exists fail. File not exist create. */
+ break;
+ case FILE_OPEN_IF:
+ /* SMB_O_CREAT | SMB_O_TRUNC */
+ /* File exists overwrite. File not exist create. */
+ create_disp = FILE_OVERWRITE_IF;
+ break;
+ case FILE_OPEN:
+ /* SMB_O_TRUNC */
+ /* File exists overwrite. File not exist fail. */
+ create_disp = FILE_OVERWRITE;
+ break;
+ default:
+ /* Cannot get here. */
+ smb_panic("smb_posix_open: logic error");
+ return NT_STATUS_INVALID_PARAMETER;
+ }
}
raw_unixmode = IVAL(pdata,8);
@@ -7350,6 +7367,15 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
mod_unixmode |= FILE_FLAG_NO_BUFFERING;
}
+ if ((wire_open_mode & SMB_O_DIRECTORY) ||
+ VALID_STAT_OF_DIR(smb_fname->st)) {
+ if (access_mask != SMB_O_RDONLY_MAPPING) {
+ return NT_STATUS_FILE_IS_A_DIRECTORY;
+ }
+ create_options &= ~FILE_NON_DIRECTORY_FILE;
+ create_options |= FILE_DIRECTORY_FILE;
+ }
+
DEBUG(10,("smb_posix_open: file %s, smb_posix_flags = %u, mode 0%o\n",
smb_fname_str_dbg(smb_fname),
(unsigned int)wire_open_mode,
@@ -7364,7 +7390,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
(FILE_SHARE_READ | FILE_SHARE_WRITE | /* share_access */
FILE_SHARE_DELETE),
create_disp, /* create_disposition*/
- FILE_NON_DIRECTORY_FILE, /* create_options */
+ create_options, /* create_options */
mod_unixmode, /* file_attributes */
oplock_request, /* oplock_request */
0, /* allocation_size */
@@ -8302,7 +8328,7 @@ static void call_trans2getdfsreferral(connection_struct *conn,
return;
}
- SSVAL(req->inbuf, smb_flg2,
+ SSVAL((discard_const_p(uint8_t, req->inbuf)), smb_flg2,
SVAL(req->inbuf,smb_flg2) | FLAGS2_DFS_PATHNAMES);
send_trans2_replies(conn, req,0,0,*ppdata,reply_size, max_data_bytes);
@@ -8351,7 +8377,7 @@ static void call_trans2ioctl(connection_struct *conn,
SSVAL(pdata, 0, 0);
}
srvstr_push(pdata, req->flags2, pdata + 2,
- global_myname(), 15,
+ lp_netbios_name(), 15,
STR_ASCII|STR_TERMINATE); /* Our NetBIOS name */
srvstr_push(pdata, req->flags2, pdata+18,
lp_servicename(SNUM(conn)), 13,
@@ -8433,7 +8459,7 @@ static void handle_trans2(connection_struct *conn, struct smb_request *req,
{
if (get_Protocol() >= PROTOCOL_NT1) {
req->flags2 |= 0x40; /* IS_LONG_NAME */
- SSVAL(req->inbuf,smb_flg2,req->flags2);
+ SSVAL((discard_const_p(uint8_t, req->inbuf)),smb_flg2,req->flags2);
}
if (conn->encrypt_level == Required && !req->encrypted) {
@@ -8646,7 +8672,7 @@ void reply_trans2(struct smb_request *req)
}
}
- if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {
+ if ((state = talloc(conn, struct trans_state)) == NULL) {
DEBUG(0, ("talloc failed\n"));
reply_nterror(req, NT_STATUS_NO_MEMORY);
END_PROFILE(SMBtrans2);
@@ -8792,7 +8818,7 @@ void reply_transs2(struct smb_request *req)
START_PROFILE(SMBtranss2);
- show_msg((char *)req->inbuf);
+ show_msg((const char *)req->inbuf);
if (req->wct < 8) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c
index b554b36054b..285b158a191 100644
--- a/source3/smbd/uid.c
+++ b/source3/smbd/uid.c
@@ -25,7 +25,6 @@
#include "libcli/security/security.h"
#include "passdb/lookup_sid.h"
#include "auth.h"
-#include "ntdomain.h"
/* what user is current? */
extern struct current_user current_user;
@@ -183,50 +182,6 @@ static bool check_user_ok(connection_struct *conn,
}
/****************************************************************************
- Clear a vuid out of the connection's vuid cache
- This is only called on SMBulogoff.
-****************************************************************************/
-
-void conn_clear_vuid_cache(connection_struct *conn, uint16_t vuid)
-{
- int i;
-
- for (i=0; i<VUID_CACHE_SIZE; i++) {
- struct vuid_cache_entry *ent;
-
- ent = &conn->vuid_cache.array[i];
-
- if (ent->vuid == vuid) {
- ent->vuid = UID_FIELD_INVALID;
- /*
- * We need to keep conn->session_info around
- * if it's equal to ent->session_info as a SMBulogoff
- * is often followed by a SMBtdis (with an invalid
- * vuid). The debug code (or regular code in
- * vfs_full_audit) wants to refer to the
- * conn->session_info pointer to print debug
- * statements. Theoretically this is a bug,
- * as once the vuid is gone the session_info
- * on the conn struct isn't valid any more,
- * but there's enough code that assumes
- * conn->session_info is never null that
- * it's easier to hold onto the old pointer
- * until we get a new sessionsetupX.
- * As everything is hung off the
- * conn pointer as a talloc context we're not
- * leaking memory here. See bug #6315. JRA.
- */
- if (conn->session_info == ent->session_info) {
- ent->session_info = NULL;
- } else {
- TALLOC_FREE(ent->session_info);
- }
- ent->read_only = False;
- }
- }
-}
-
-/****************************************************************************
Become the user of a connection number without changing the security context
stack, but modify the current_user entries.
****************************************************************************/
@@ -390,7 +345,7 @@ bool change_to_user_by_session(connection_struct *conn,
but modify the current_user entries.
****************************************************************************/
-bool change_to_root_user(void)
+bool smbd_change_to_root_user(void)
{
set_root_sec_ctx();
@@ -409,14 +364,14 @@ bool change_to_root_user(void)
user. Doesn't modify current_user.
****************************************************************************/
-bool become_authenticated_pipe_user(struct pipes_struct *p)
+bool become_authenticated_pipe_user(struct auth_serversupplied_info *session_info)
{
if (!push_sec_ctx())
return False;
- set_sec_ctx(p->session_info->utok.uid, p->session_info->utok.gid,
- p->session_info->utok.ngroups, p->session_info->utok.groups,
- p->session_info->security_token);
+ set_sec_ctx(session_info->utok.uid, session_info->utok.gid,
+ session_info->utok.ngroups, session_info->utok.groups,
+ session_info->security_token);
return True;
}
@@ -486,7 +441,7 @@ static void pop_conn_ctx(void)
restores the connection context.
****************************************************************************/
-void become_root(void)
+void smbd_become_root(void)
{
/*
* no good way to handle push_sec_ctx() failing without changing
@@ -501,7 +456,7 @@ void become_root(void)
/* Unbecome the root user */
-void unbecome_root(void)
+void smbd_unbecome_root(void)
{
pop_sec_ctx();
pop_conn_ctx();
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 3b482e7f0cd..7be38672678 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -183,7 +183,7 @@ bool vfs_init_custom(connection_struct *conn, const char *vfs_object)
DEBUGADD(5,("Successfully loaded vfs module [%s] with the new modules system\n", vfs_object));
- handle = TALLOC_ZERO_P(conn, vfs_handle_struct);
+ handle = talloc_zero(conn, vfs_handle_struct);
if (!handle) {
DEBUG(0,("TALLOC_ZERO() failed!\n"));
goto fail;
@@ -795,7 +795,7 @@ int vfs_ChDir(connection_struct *conn, const char *path)
char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
{
- char s[PATH_MAX+1];
+ char *current_dir = NULL;
char *result = NULL;
DATA_BLOB cache_value;
struct file_id key;
@@ -803,8 +803,6 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
struct smb_filename *smb_fname_full = NULL;
NTSTATUS status;
- *s = 0;
-
if (!lp_getwd_cache()) {
goto nocache;
}
@@ -866,7 +864,8 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
* systems, or the not quite so bad getwd.
*/
- if (!SMB_VFS_GETWD(conn,s)) {
+ current_dir = SMB_VFS_GETWD(conn);
+ if (current_dir == NULL) {
DEBUG(0, ("vfs_GetWd: SMB_VFS_GETWD call failed: %s\n",
strerror(errno)));
goto out;
@@ -877,10 +876,11 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
memcache_add(smbd_memcache(), GETWD_CACHE,
data_blob_const(&key, sizeof(key)),
- data_blob_const(s, strlen(s)+1));
+ data_blob_const(current_dir,
+ strlen(current_dir)+1));
}
- result = talloc_strdup(ctx, s);
+ result = talloc_strdup(ctx, current_dir);
if (result == NULL) {
errno = ENOMEM;
}
@@ -888,6 +888,7 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
out:
TALLOC_FREE(smb_fname_dot);
TALLOC_FREE(smb_fname_full);
+ SAFE_FREE(current_dir);
return result;
}
@@ -899,6 +900,8 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
{
char *resolved_name = NULL;
+ bool allow_symlinks = true;
+ bool allow_widelinks = false;
DEBUG(3,("check_reduced_name [%s] [%s]\n", fname, conn->connectpath));
@@ -973,9 +976,13 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
return NT_STATUS_OBJECT_NAME_INVALID;
}
- /* Check for widelinks allowed. */
- if (!lp_widelinks(SNUM(conn))) {
+ allow_widelinks = lp_widelinks(SNUM(conn));
+ allow_symlinks = lp_symlinks(SNUM(conn));
+
+ /* Common widelinks and symlinks checks. */
+ if (!allow_widelinks || !allow_symlinks) {
const char *conn_rootdir;
+ size_t rootdir_len;
conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname);
if (conn_rootdir == NULL) {
@@ -985,8 +992,9 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
return NT_STATUS_ACCESS_DENIED;
}
+ rootdir_len = strlen(conn_rootdir);
if (strncmp(conn_rootdir, resolved_name,
- strlen(conn_rootdir)) != 0) {
+ rootdir_len) != 0) {
DEBUG(2, ("check_reduced_name: Bad access "
"attempt: %s is a symlink outside the "
"share path\n", fname));
@@ -995,35 +1003,38 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
SAFE_FREE(resolved_name);
return NT_STATUS_ACCESS_DENIED;
}
- }
- /* Check if we are allowing users to follow symlinks */
- /* Patch from David Clerc <David.Clerc@cui.unige.ch>
- University of Geneva */
+ /* Extra checks if all symlinks are disallowed. */
+ if (!allow_symlinks) {
+ /* fname can't have changed in resolved_path. */
+ const char *p = &resolved_name[rootdir_len];
-#ifdef S_ISLNK
- if (!lp_symlinks(SNUM(conn))) {
- struct smb_filename *smb_fname = NULL;
- NTSTATUS status;
+ /* *p can be '\0' if fname was "." */
+ if (*p == '\0' && ISDOT(fname)) {
+ goto out;
+ }
- status = create_synthetic_smb_fname(talloc_tos(), fname, NULL,
- NULL, &smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
- SAFE_FREE(resolved_name);
- return status;
+ if (*p != '/') {
+ DEBUG(2, ("check_reduced_name: logic error (%c) "
+ "in resolved_name: %s\n",
+ *p,
+ fname));
+ SAFE_FREE(resolved_name);
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+ p++;
+ if (strcmp(fname, p)!=0) {
+ DEBUG(2, ("check_reduced_name: Bad access "
+ "attempt: %s is a symlink\n",
+ fname));
+ SAFE_FREE(resolved_name);
+ return NT_STATUS_ACCESS_DENIED;
+ }
}
+ }
- if ( (SMB_VFS_LSTAT(conn, smb_fname) != -1) &&
- (S_ISLNK(smb_fname->st.st_ex_mode)) ) {
- SAFE_FREE(resolved_name);
- DEBUG(3,("check_reduced_name: denied: file path name "
- "%s is a symlink\n",resolved_name));
- TALLOC_FREE(smb_fname);
- return NT_STATUS_ACCESS_DENIED;
- }
- TALLOC_FREE(smb_fname);
- }
-#endif
+ out:
DEBUG(3,("check_reduced_name: %s reduced to %s\n", fname,
resolved_name));
@@ -1164,7 +1175,7 @@ int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- SHADOW_COPY_DATA *shadow_copy_data,
+ struct shadow_copy_data *shadow_copy_data,
bool labels)
{
VFS_FIND(get_shadow_copy_data);
@@ -1496,7 +1507,7 @@ NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid)
}
ZERO_STRUCT(local_fname);
- local_fname.base_name = CONST_DISCARD(char *,final_component);
+ local_fname.base_name = discard_const_p(char, final_component);
/* Must use lstat here. */
ret = SMB_VFS_LSTAT(fsp->conn, &local_fname);
@@ -1543,10 +1554,10 @@ int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path)
return handle->fns->chdir(handle, path);
}
-char *smb_vfs_call_getwd(struct vfs_handle_struct *handle, char *buf)
+char *smb_vfs_call_getwd(struct vfs_handle_struct *handle)
{
VFS_FIND(getwd);
- return handle->fns->getwd(handle, buf);
+ return handle->fns->getwd(handle);
}
int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
diff --git a/source3/stf/info3cache.py b/source3/stf/info3cache.py
deleted file mode 100755
index 96d5a1d4596..00000000000
--- a/source3/stf/info3cache.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/python
-#
-# Upon a winbindd authentication, test that an info3 record is cached in
-# netsamlogon_cache.tdb and cache records are removed from winbindd_cache.tdb
-#
-
-import comfychair, stf
-from samba import tdb, winbind
-
-#
-# We want to implement the following test on a win2k native mode domain.
-#
-# 1. trash netsamlogon_cache.tdb
-# 2. wbinfo -r DOMAIN\Administrator [FAIL]
-# 3. wbinfo --auth-crap DOMAIN\Administrator%password [PASS]
-# 4. wbinfo -r DOMAIN\Administrator [PASS]
-#
-# Also for step 3 we want to try 'wbinfo --auth-smbd' and
-# 'wbinfo --auth-plaintext'
-#
-
-#
-# TODO: To implement this test we need to be able to
-#
-# - pass username%password combination for an invidivual winbindd request
-# (so we can get the administrator SID so we can clear the info3 cache)
-#
-# - start/restart winbindd (to trash the winbind cache)
-#
-# - from samba import dynconfig (to find location of info3 cache)
-#
-# - be able to modify the winbindd cache (to set/reset individual winbind
-# cache entries)
-#
-# - have --auth-crap present in HEAD
-#
-
-class WinbindAuthCrap(comfychair.TestCase):
- def runtest(self):
- raise comfychair.NotRunError, "not implemented"
-
-class WinbindAuthSmbd(comfychair.TestCase):
- def runtest(self):
- # Grr - winbindd in HEAD doesn't contain the auth_smbd function
- raise comfychair.NotRunError, "no auth_smbd in HEAD"
-
-class WinbindAuthPlaintext(comfychair.TestCase):
- def runtest(self):
- raise comfychair.NotRunError, "not implemented"
-
-tests = [WinbindAuthCrap, WinbindAuthSmbd, WinbindAuthPlaintext]
-
-if __name__ == "__main__":
- comfychair.main(tests)
diff --git a/source3/stf/sambalib.py b/source3/stf/sambalib.py
deleted file mode 100644
index 552280ed292..00000000000
--- a/source3/stf/sambalib.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /usr/bin/python
-
-# Comfychair test cases for Samba string functions.
-
-# Copyright (C) 2003 by Martin Pool <mbp@samba.org>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-
-"""Tests for Samba library functions."""
-
-import sys, re, comfychair
-from unicodenames import *
-
-class snprintf_Test(comfychair.TestCase):
- def runtest(self):
- # Everything is built in to the test
- out, err = self.runcmd('t_snprintf')
-
-# Define the tests exported by this module
-tests = [snprintf_Test]
-
-# Handle execution of this file as a main program
-if __name__ == '__main__':
- comfychair.main(tests)
-
-# Local variables:
-# coding: utf-8
-# End:
diff --git a/source3/stf/strings.py b/source3/stf/strings.py
deleted file mode 100755
index 4e00021525f..00000000000
--- a/source3/stf/strings.py
+++ /dev/null
@@ -1,149 +0,0 @@
-#! /usr/bin/python
-
-# Comfychair test cases for Samba string functions.
-
-# Copyright (C) 2003 by Martin Pool <mbp@samba.org>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-
-# XXX: All this code assumes that the Unix character set is UTF-8,
-# which is the most common setting. I guess it would be better to
-# force it to that value while running the tests. I'm not sure of the
-# best way to do that yet.
-#
-# Note that this is NOT the case in C code until the loadparm table is
-# intialized -- the default seems to be ASCII, which rather lets Samba
-# off the hook. :-) The best way seems to be to put this in the test
-# harnesses:
-#
-# lp_load("/dev/null", True, False, False);
-#
-# -- mbp
-
-import sys, re, comfychair
-from unicodenames import *
-
-def signum(a):
- if a < 0:
- return -1
- elif a > 0:
- return +1
- else:
- return 0
-
-
-class PushUCS2_Tests(comfychair.TestCase):
- """Conversion to/from UCS2"""
- def runtest(self):
- OE = LATIN_CAPITAL_LETTER_O_WITH_DIARESIS
- oe = LATIN_CAPITAL_LETTER_O_WITH_DIARESIS
- cases = ['hello',
- 'hello world',
- 'g' + OE + OE + 'gomobile',
- 'g' + OE + oe + 'gomobile',
- u'foo\u0100',
- KATAKANA_LETTER_A * 20,
- ]
- for u8str in cases:
- out, err = self.runcmd("t_push_ucs2 \"%s\"" % u8str.encode('utf-8'))
- self.assert_equal(out, "0\n")
-
-
-class StrCaseCmp(comfychair.TestCase):
- """String comparisons in simple ASCII"""
- def run_strcmp(self, a, b, expect):
- out, err = self.runcmd('t_strcmp \"%s\" \"%s\"' % (a.encode('utf-8'), b.encode('utf-8')))
- if signum(int(out)) != expect:
- self.fail("comparison failed:\n"
- " a=%s\n"
- " b=%s\n"
- " expected=%s\n"
- " result=%s\n" % (`a`, `b`, `expect`, `out`))
-
- def runtest(self):
- # A, B, strcasecmp(A, B)
- cases = [('hello', 'hello', 0),
- ('hello', 'goodbye', +1),
- ('goodbye', 'hello', -1),
- ('hell', 'hello', -1),
- ('', '', 0),
- ('a', '', +1),
- ('', 'a', -1),
- ('a', 'A', 0),
- ('aa', 'aA', 0),
- ('Aa', 'aa', 0),
- ('longstring ' * 100, 'longstring ' * 100, 0),
- ('longstring ' * 100, 'longstring ' * 100 + 'a', -1),
- ('longstring ' * 100 + 'a', 'longstring ' * 100, +1),
- (KATAKANA_LETTER_A, KATAKANA_LETTER_A, 0),
- (KATAKANA_LETTER_A, 'a', 1),
- ]
- for a, b, expect in cases:
- self.run_strcmp(a, b, expect)
-
-class strstr_m(comfychair.TestCase):
- """String comparisons in simple ASCII"""
- def run_strstr(self, a, b, expect):
- out, err = self.runcmd('t_strstr \"%s\" \"%s\"' % (a.encode('utf-8'), b.encode('utf-8')))
- if (out != (expect + '\n').encode('utf-8')):
- self.fail("comparison failed:\n"
- " a=%s\n"
- " b=%s\n"
- " expected=%s\n"
- " result=%s\n" % (`a`, `b`, `expect+'\n'`, `out`))
-
- def runtest(self):
- # A, B, strstr_m(A, B)
- cases = [('hello', 'hello', 'hello'),
- ('hello', 'goodbye', '(null)'),
- ('goodbye', 'hello', '(null)'),
- ('hell', 'hello', '(null)'),
- ('hello', 'hell', 'hello'),
- ('', '', ''),
- ('a', '', 'a'),
- ('', 'a', '(null)'),
- ('a', 'A', '(null)'),
- ('aa', 'aA', '(null)'),
- ('Aa', 'aa', '(null)'),
- ('%v foo', '%v', '%v foo'),
- ('foo %v foo', '%v', '%v foo'),
- ('foo %v', '%v', '%v'),
- ('longstring ' * 100, 'longstring ' * 99, 'longstring ' * 100),
- ('longstring ' * 99, 'longstring ' * 100, '(null)'),
- ('longstring a' * 99, 'longstring ' * 100 + 'a', '(null)'),
- ('longstring ' * 100 + 'a', 'longstring ' * 100, 'longstring ' * 100 + 'a'),
- (KATAKANA_LETTER_A, KATAKANA_LETTER_A + 'bcd', '(null)'),
- (KATAKANA_LETTER_A + 'bcde', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcde'),
- ('d'+KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcd'),
- ('d'+KATAKANA_LETTER_A + 'bd', KATAKANA_LETTER_A + 'bcd', '(null)'),
-
- ('e'+KATAKANA_LETTER_A + 'bcdf', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcdf'),
- (KATAKANA_LETTER_A, KATAKANA_LETTER_A + 'bcd', '(null)'),
- (KATAKANA_LETTER_A*3, 'a', '(null)'),
- ]
- for a, b, expect in cases:
- self.run_strstr(a, b, expect)
-
-# Define the tests exported by this module
-tests = [StrCaseCmp,
- strstr_m,
- PushUCS2_Tests]
-
-# Handle execution of this file as a main program
-if __name__ == '__main__':
- comfychair.main(tests)
-
-# Local variables:
-# coding: utf-8
-# End:
diff --git a/source3/stf/unicodenames.py b/source3/stf/unicodenames.py
deleted file mode 100644
index 34d0a192383..00000000000
--- a/source3/stf/unicodenames.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#! /usr/bin/python
-
-# Copyright (C) 2003 by Martin Pool <mbp@samba.org>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-
-
-"""
-Defines symbolic names for a few UNICODE characters, to make test
-source code more readable on machines that don't have all the
-necessary fonts.
-
-You can do "import *" on this file safely.
-"""
-
-LATIN_CAPITAL_LETTER_N_WITH_TILDE = u'\u004e'
-LATIN_CAPITAL_LETTER_O_WITH_DIARESIS = u'\u00d6'
-LATIN_SMALL_LETTER_O_WITH_DIARESIS = u'\u00f6'
-
-KATAKANA_LETTER_A = u'\u30a2'
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 2c3a4160024..9527a34af4d 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -57,7 +57,7 @@ static NTSTATUS cmd_populate(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg
}
c = argv[1][0];
size = atoi(argv[2]);
- vfs->data = TALLOC_ARRAY(mem_ctx, char, size);
+ vfs->data = talloc_array(mem_ctx, char, size);
if (vfs->data == NULL) {
printf("populate: error=-1 (not enough memory)");
return NT_STATUS_UNSUCCESSFUL;
@@ -435,7 +435,7 @@ static NTSTATUS cmd_read(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
/* do some error checking on these */
fd = atoi(argv[1]);
size = atoi(argv[2]);
- vfs->data = TALLOC_ARRAY(mem_ctx, char, size);
+ vfs->data = talloc_array(mem_ctx, char, size);
if (vfs->data == NULL) {
printf("read: error=-1 (not enough memory)");
return NT_STATUS_UNSUCCESSFUL;
@@ -889,13 +889,14 @@ static NTSTATUS cmd_fchown(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
static NTSTATUS cmd_getwd(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
- char buf[PATH_MAX];
- if (SMB_VFS_GETWD(vfs->conn, buf) == NULL) {
+ char *buf = SMB_VFS_GETWD(vfs->conn);
+ if (buf == NULL) {
printf("getwd: error=%d (%s)\n", errno, strerror(errno));
return NT_STATUS_UNSUCCESSFUL;
}
printf("getwd: %s\n", buf);
+ SAFE_FREE(buf);
return NT_STATUS_OK;
}
diff --git a/source3/torture/denytest.c b/source3/torture/denytest.c
index 1f60734fa7a..be01e829dc9 100644
--- a/source3/torture/denytest.c
+++ b/source3/torture/denytest.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "torture/proto.h"
+#include "libsmb/libsmb.h"
extern bool torture_showall;
@@ -1421,9 +1422,10 @@ bool torture_denytest1(int dummy)
printf("starting denytest1\n");
for (i=0;i<2;i++) {
- cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1);
- cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
+ cli_writeall(cli1, fnum1, 0, (const uint8_t *)fnames[i], 0,
+ strlen(fnames[i]), NULL);
cli_close(cli1, fnum1);
}
@@ -1452,7 +1454,9 @@ bool torture_denytest1(int dummy)
if (cli_read(cli1, fnum2, (char *)&x, 0, 1) == 1) {
res += A_R;
}
- if (cli_write(cli1, fnum2, 0, (char *)&x, 0, 1) == 1) {
+ if (NT_STATUS_IS_OK(cli_writeall(cli1, fnum2, 0,
+ (uint8_t *)&x, 0, 1,
+ NULL))) {
res += A_W;
}
}
@@ -1481,7 +1485,7 @@ bool torture_denytest1(int dummy)
}
for (i=0;i<2;i++) {
- cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
}
if (!torture_close_connection(cli1)) {
@@ -1512,9 +1516,10 @@ bool torture_denytest2(int dummy)
printf("starting denytest2\n");
for (i=0;i<2;i++) {
- cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1);
- cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
+ cli_writeall(cli1, fnum1, 0, (const uint8_t *)fnames[i], 0,
+ strlen(fnames[i]), NULL);
cli_close(cli1, fnum1);
}
@@ -1541,7 +1546,9 @@ bool torture_denytest2(int dummy)
if (cli_read(cli2, fnum2, (char *)&x, 0, 1) == 1) {
res += A_R;
}
- if (cli_write(cli2, fnum2, 0, (char *)&x, 0, 1) == 1) {
+ if (NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0,
+ (uint8_t *)&x, 0, 1,
+ NULL))) {
res += A_W;
}
}
@@ -1570,7 +1577,7 @@ bool torture_denytest2(int dummy)
}
for (i=0;i<2;i++) {
- cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
}
if (!torture_close_connection(cli1)) {
diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
index d52a8de4605..d27eb5fa548 100644
--- a/source3/torture/locktest.c
+++ b/source3/torture/locktest.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "system/filesys.h"
#include "locking/proto.h"
#include "libsmb/nmblib.h"
@@ -163,10 +164,8 @@ return a connection to a server
static struct cli_state *connect_one(char *share, int snum)
{
struct cli_state *c;
- struct nmb_name called, calling;
char *server_n;
fstring server;
- struct sockaddr_storage ss;
fstring myname;
static int count;
NTSTATUS status;
@@ -179,42 +178,20 @@ static struct cli_state *connect_one(char *share, int snum)
server_n = server;
- zero_sockaddr(&ss);
-
slprintf(myname,sizeof(myname), "lock-%lu-%u", (unsigned long)getpid(), count++);
- make_nmb_name(&calling, myname, 0x0);
- make_nmb_name(&called , server, 0x20);
-
- again:
- zero_sockaddr(&ss);
-
/* have to open a new connection */
- if (!(c=cli_initialise())) {
- DEBUG(0,("Connection to %s failed\n", server_n));
- return NULL;
- }
- status = cli_connect(c, server_n, &ss);
+ status = cli_connect_nb(server_n, NULL, 0, 0x20, myname, Undefined,
+ &c);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("Connection to %s failed. Error %s\n", server_n, nt_errstr(status) ));
+ DEBUG(0, ("Connection to %s failed. Error %s\n", server_n,
+ nt_errstr(status)));
return NULL;
}
c->use_kerberos = use_kerberos;
- if (!cli_session_request(c, &calling, &called)) {
- DEBUG(0,("session request to %s failed\n", called.name));
- cli_shutdown(c);
- if (strcmp(called.name, "*SMBSERVER")) {
- make_nmb_name(&called , "*SMBSERVER", 0x20);
- goto again;
- }
- return NULL;
- }
-
- DEBUG(4,(" session request ok\n"));
-
status = cli_negprot(c);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("protocol negotiation failed: %s\n",
@@ -232,8 +209,8 @@ static struct cli_state *connect_one(char *share, int snum)
}
if (got_pass == 1) {
- fstrcpy(password[1], password[0]);
- fstrcpy(username[1], username[0]);
+ strlcpy(password[1], password[0],sizeof(password[1]));
+ strlcpy(username[1], username[0],sizeof(username[1]));
}
status = cli_session_setup(c, username[snum],
@@ -400,7 +377,7 @@ static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
}
}
for (server=0;server<NSERVERS;server++) {
- cli_unlink(cli[server][0], FILENAME, aSYSTEM | aHIDDEN);
+ cli_unlink(cli[server][0], FILENAME, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
}
}
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index 55dc1d52b78..aba6d2ff134 100644
--- a/source3/torture/locktest2.c
+++ b/source3/torture/locktest2.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "system/filesys.h"
#include "locking/proto.h"
@@ -325,7 +326,7 @@ static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
}
}
for (server=0;server<NSERVERS;server++) {
- cli_unlink(cli[server][0], FILENAME, aSYSTEM | aHIDDEN);
+ cli_unlink(cli[server][0], FILENAME, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
}
}
diff --git a/source3/torture/mangle_test.c b/source3/torture/mangle_test.c
index dd684671409..4fc91dc4b3a 100644
--- a/source3/torture/mangle_test.c
+++ b/source3/torture/mangle_test.c
@@ -20,7 +20,9 @@
#include "includes.h"
#include "system/filesys.h"
#include "torture/proto.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
+#include "util_tdb.h"
extern int torture_numops;
@@ -40,46 +42,53 @@ static bool test_one(struct cli_state *cli, const char *name)
total++;
- if (!NT_STATUS_IS_OK(cli_open(cli, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
- printf("open of %s failed (%s)\n", name, cli_errstr(cli));
+ status = cli_open(cli, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", name, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
- printf("close of %s failed (%s)\n", name, cli_errstr(cli));
+ status = cli_close(cli, fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close of %s failed (%s)\n", name, nt_errstr(status));
return False;
}
/* get the short name */
status = cli_qpathinfo_alt_name(cli, name, shortname);
if (!NT_STATUS_IS_OK(status)) {
- printf("query altname of %s failed (%s)\n", name, cli_errstr(cli));
+ printf("query altname of %s failed (%s)\n", name, nt_errstr(status));
return False;
}
fstr_sprintf(name2, "\\mangle_test\\%s", shortname);
- if (!NT_STATUS_IS_OK(cli_unlink(cli, name2, aSYSTEM | aHIDDEN))) {
+ status = cli_unlink(cli, name2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
printf("unlink of %s (%s) failed (%s)\n",
- name2, name, cli_errstr(cli));
+ name2, name, nt_errstr(status));
return False;
}
/* recreate by short name */
- if (!NT_STATUS_IS_OK(cli_open(cli, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
- printf("open2 of %s failed (%s)\n", name2, cli_errstr(cli));
+ status = cli_open(cli, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open2 of %s failed (%s)\n", name2, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
- printf("close of %s failed (%s)\n", name, cli_errstr(cli));
+
+ status = cli_close(cli, fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close of %s failed (%s)\n", name, nt_errstr(status));
return False;
}
/* and unlink by long name */
- if (!NT_STATUS_IS_OK(cli_unlink(cli, name, aSYSTEM | aHIDDEN))) {
+ status = cli_unlink(cli, name, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
printf("unlink2 of %s (%s) failed (%s)\n",
- name, name2, cli_errstr(cli));
+ name, name2, nt_errstr(status));
failures++;
- cli_unlink(cli, name2, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, name2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
return True;
}
@@ -98,7 +107,7 @@ static bool test_one(struct cli_state *cli, const char *name)
} else {
TDB_DATA namedata;
/* store it for later */
- namedata.dptr = CONST_DISCARD(uint8 *, name);
+ namedata.dptr = discard_const_p(uint8, name);
namedata.dsize = strlen(name)+1;
tdb_store_bystring(tdb, shortname, namedata, TDB_REPLACE);
}
@@ -172,13 +181,13 @@ bool torture_mangle(int dummy)
}
/* we will use an internal tdb to store the names we have used */
- tdb = tdb_open(NULL, 100000, TDB_INTERNAL, 0, 0);
+ tdb = tdb_open_compat(NULL, 100000, TDB_INTERNAL, 0, 0, NULL, NULL);
if (!tdb) {
printf("ERROR: Failed to open tdb\n");
return False;
}
- cli_unlink(cli, "\\mangle_test\\*", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\mangle_test\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, "\\mangle_test");
if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\mangle_test"))) {
@@ -202,7 +211,7 @@ bool torture_mangle(int dummy)
}
}
- cli_unlink(cli, "\\mangle_test\\*", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\mangle_test\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!NT_STATUS_IS_OK(cli_rmdir(cli, "\\mangle_test"))) {
printf("ERROR: Failed to remove directory\n");
return False;
diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c
index c8f346435af..9bb34dfe459 100644
--- a/source3/torture/masktest.c
+++ b/source3/torture/masktest.c
@@ -2,17 +2,17 @@
Unix SMB/CIFS implementation.
mask_match tester
Copyright (C) Andrew Tridgell 1999
-
+
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/>.
*/
@@ -20,6 +20,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "trans2.h"
+#include "libsmb/libsmb.h"
#include "libsmb/nmblib.h"
static fstring password;
@@ -166,10 +167,8 @@ return a connection to a server
static struct cli_state *connect_one(char *share)
{
struct cli_state *c;
- struct nmb_name called, calling;
char *server_n;
char *server;
- struct sockaddr_storage ss;
NTSTATUS status;
server = share+2;
@@ -180,40 +179,16 @@ static struct cli_state *connect_one(char *share)
server_n = server;
- zero_sockaddr(&ss);
-
- make_nmb_name(&calling, "masktest", 0x0);
- make_nmb_name(&called , server, 0x20);
-
- again:
- zero_sockaddr(&ss);
-
- /* have to open a new connection */
- if (!(c=cli_initialise())) {
- DEBUG(0,("Connection to %s failed\n", server_n));
- return NULL;
- }
-
- status = cli_connect(c, server_n, &ss);
+ status = cli_connect_nb(server, NULL, 0, 0x20, "masktest", Undefined,
+ &c);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("Connection to %s failed. Error %s\n", server_n, nt_errstr(status) ));
+ DEBUG(0,("Connection to %s failed. Error %s\n", server_n,
+ nt_errstr(status)));
return NULL;
}
c->protocol = max_protocol;
- if (!cli_session_request(c, &calling, &called)) {
- DEBUG(0,("session request to %s failed\n", called.name));
- cli_shutdown(c);
- if (strcmp(called.name, "*SMBSERVER")) {
- make_nmb_name(&called , "*SMBSERVER", 0x20);
- goto again;
- }
- return NULL;
- }
-
- DEBUG(4,(" session request ok\n"));
-
status = cli_negprot(c);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("protocol negotiation failed: %s\n",
@@ -313,11 +288,11 @@ static void get_real_name(struct cli_state *cli,
*pp_long_name = NULL;
/* nasty hack to force level 260 listings - tridge */
if (max_protocol <= PROTOCOL_LANMAN1) {
- cli_list_trans(cli, "\\masktest\\*.*", aHIDDEN | aDIR,
+ cli_list_trans(cli, "\\masktest\\*.*", FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
SMB_FIND_FILE_BOTH_DIRECTORY_INFO, listfn,
&state);
} else {
- cli_list_trans(cli, "\\masktest\\*", aHIDDEN | aDIR,
+ cli_list_trans(cli, "\\masktest\\*", FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
SMB_FIND_FILE_BOTH_DIRECTORY_INFO,
listfn, &state);
}
@@ -359,7 +334,7 @@ static void testpair(struct cli_state *cli, const char *mask, const char *file)
return;
}
fstrcpy(res1, "---");
- cli_list(cli, mask, aHIDDEN | aDIR, listfn, NULL);
+ cli_list(cli, mask, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY, listfn, NULL);
res2 = reg_test(cli, mask, long_name, short_name);
@@ -371,7 +346,7 @@ static void testpair(struct cli_state *cli, const char *mask, const char *file)
if (die_on_error) exit(1);
}
- cli_unlink(cli, file, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, file, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (count % 100 == 0) DEBUG(0,("%d\n", count));
SAFE_FREE(long_name);
@@ -388,7 +363,7 @@ static void test_mask(int argc, char *argv[],
cli_mkdir(cli, "\\masktest");
- cli_unlink(cli, "\\masktest\\*", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\masktest\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (argc >= 2) {
while (argc >= 2) {
@@ -411,8 +386,8 @@ static void test_mask(int argc, char *argv[],
while (1) {
l1 = 1 + random() % 20;
l2 = 1 + random() % 20;
- mask = TALLOC_ARRAY(ctx, char, strlen("\\masktest\\")+1+22);
- file = TALLOC_ARRAY(ctx, char, strlen("\\masktest\\")+1+22);
+ mask = talloc_array(ctx, char, strlen("\\masktest\\")+1+22);
+ file = talloc_array(ctx, char, strlen("\\masktest\\")+1+22);
if (!mask || !file) {
goto finished;
}
diff --git a/source3/torture/msgtest.c b/source3/torture/msgtest.c
index 607d4c3bb1c..c7fa3153d8a 100644
--- a/source3/torture/msgtest.c
+++ b/source3/torture/msgtest.c
@@ -85,7 +85,7 @@ static void pong_message(struct messaging_context *msg_ctx,
/* Now test that the duplicate filtering code works. */
pong_count = 0;
- safe_strcpy(buf, "1234567890", sizeof(buf)-1);
+ strlcpy(buf, "1234567890", sizeof(buf));
for (i=0;i<n;i++) {
messaging_send(msg_ctx, messaging_server_id(msg_ctx), MSG_PING,
diff --git a/source3/torture/nbench.c b/source3/torture/nbench.c
index 182f6f7cd91..d2fddf00945 100644
--- a/source3/torture/nbench.c
+++ b/source3/torture/nbench.c
@@ -19,7 +19,9 @@
#include "includes.h"
#include "torture/proto.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
+#include "../lib/util/tevent_ntstatus.h"
static long long int ival(const char *str)
{
@@ -94,7 +96,7 @@ static struct nbench_cmd_struct *nbench_parse(TALLOC_CTX *mem_ctx,
char *cmd;
char *status;
- result = TALLOC_P(mem_ctx, struct nbench_cmd_struct);
+ result = talloc(mem_ctx, struct nbench_cmd_struct);
if (result == NULL) {
return NULL;
}
diff --git a/source3/torture/nbio.c b/source3/torture/nbio.c
index 664943b681b..0da6bc084e2 100644
--- a/source3/torture/nbio.c
+++ b/source3/torture/nbio.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "torture/proto.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#define MAX_FILES 1000
@@ -134,10 +135,13 @@ void nb_setup(struct cli_state *cli)
void nb_unlink(const char *fname)
{
- if (!NT_STATUS_IS_OK(cli_unlink(c, fname, aSYSTEM | aHIDDEN))) {
+ NTSTATUS status;
+
+ status = cli_unlink(c, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
#if NBDEBUG
printf("(%d) unlink %s failed (%s)\n",
- line_count, fname, cli_errstr(c));
+ line_count, fname, nt_errstr(status));
#endif
}
}
@@ -165,7 +169,7 @@ void nb_createx(const char *fname,
create_options, 0, &fd);
if (!NT_STATUS_IS_OK(status) && handle != -1) {
printf("ERROR: cli_ntcreate failed for %s - %s\n",
- fname, cli_errstr(c));
+ fname, nt_errstr(status));
exit(1);
}
if (NT_STATUS_IS_OK(status) && handle == -1) {
@@ -189,13 +193,17 @@ void nb_createx(const char *fname,
void nb_writex(int handle, int offset, int size, int ret_size)
{
int i;
+ NTSTATUS status;
if (buf[0] == 0) memset(buf, 1, sizeof(buf));
i = find_handle(handle);
- if (cli_write(c, ftable[i].fd, 0, buf, offset, size) != ret_size) {
- printf("(%d) ERROR: write failed on handle %d, fd %d \
-errno %d (%s)\n", line_count, handle, ftable[i].fd, errno, strerror(errno));
+ status = cli_writeall(c, ftable[i].fd, 0, (uint8_t *)buf, offset, size,
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("(%d) ERROR: write failed on handle %d, fd %d "
+ "error %s\n", line_count, handle, ftable[i].fd,
+ nt_errstr(status));
exit(1);
}
@@ -228,18 +236,24 @@ void nb_close(int handle)
void nb_rmdir(const char *fname)
{
- if (!NT_STATUS_IS_OK(cli_rmdir(c, fname))) {
+ NTSTATUS status;
+
+ status = cli_rmdir(c, fname);
+ if (!NT_STATUS_IS_OK(status)) {
printf("ERROR: rmdir %s failed (%s)\n",
- fname, cli_errstr(c));
+ fname, nt_errstr(status));
exit(1);
}
}
void nb_rename(const char *oldname, const char *newname)
{
- if (!NT_STATUS_IS_OK(cli_rename(c, oldname, newname))) {
+ NTSTATUS status;
+
+ status = cli_rename(c, oldname, newname);
+ if (!NT_STATUS_IS_OK(status)) {
printf("ERROR: rename %s %s failed (%s)\n",
- oldname, newname, cli_errstr(c));
+ oldname, newname, nt_errstr(status));
exit(1);
}
}
@@ -301,13 +315,13 @@ static NTSTATUS delete_fn(const char *mnt, struct file_info *finfo,
printf("asprintf failed\n");
return NT_STATUS_NO_MEMORY;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
char *s2;
if (asprintf(&s2, "%s\\*", s) == -1) {
printf("asprintf failed\n");
return NT_STATUS_NO_MEMORY;
}
- status = cli_list(c, s2, aDIR, delete_fn, NULL);
+ status = cli_list(c, s2, FILE_ATTRIBUTE_DIRECTORY, delete_fn, NULL);
if (!NT_STATUS_IS_OK(status)) {
free(n);
free(s2);
@@ -332,7 +346,7 @@ void nb_deltree(const char *dname)
}
total_deleted = 0;
- cli_list(c, mask, aDIR, delete_fn, NULL);
+ cli_list(c, mask, FILE_ATTRIBUTE_DIRECTORY, delete_fn, NULL);
free(mask);
cli_rmdir(c, dname);
diff --git a/source3/torture/pdbtest.c b/source3/torture/pdbtest.c
index 7ab20c76926..33419db2753 100644
--- a/source3/torture/pdbtest.c
+++ b/source3/torture/pdbtest.c
@@ -24,6 +24,14 @@
#include "popt_common.h"
#include "passdb.h"
+#include "../librpc/gen_ndr/drsblobs.h"
+#include "../librpc/gen_ndr/ndr_drsblobs.h"
+#include "../libcli/security/dom_sid.h"
+
+#define TRUST_DOM "trustdom"
+#define TRUST_PWD "trustpwd1232"
+#define TRUST_SID "S-1-5-21-1111111111-2222222222-3333333333"
+
static bool samu_correct(struct samu *s1, struct samu *s2)
{
bool ret = True;
@@ -366,6 +374,81 @@ int main(int argc, char **argv)
get_friendly_nt_error_msg(rv));
}
+ /* test trustdom calls */
+ struct pdb_trusted_domain *td;
+ struct pdb_trusted_domain *new_td;
+ struct trustAuthInOutBlob taiob;
+ struct AuthenticationInformation aia;
+ enum ndr_err_code ndr_err;
+
+ td = talloc_zero(ctx ,struct pdb_trusted_domain);
+ if (!td) {
+ fprintf(stderr, "talloc failed\n");
+ exit(1);
+ }
+
+ td->domain_name = talloc_strdup(td, TRUST_DOM);
+ td->netbios_name = talloc_strdup(td, TRUST_DOM);
+ if (!td->domain_name || !td->netbios_name) {
+ fprintf(stderr, "talloc failed\n");
+ exit(1);
+ }
+
+ td->trust_auth_incoming = data_blob_null;
+
+ ZERO_STRUCT(taiob);
+ ZERO_STRUCT(aia);
+ taiob.count = 1;
+ taiob.current.count = 1;
+ taiob.current.array = &aia;
+ unix_to_nt_time(&aia.LastUpdateTime, time(NULL));
+ aia.AuthType = TRUST_AUTH_TYPE_CLEAR;
+ aia.AuthInfo.clear.password = (uint8_t *) talloc_strdup(ctx, TRUST_PWD);
+ aia.AuthInfo.clear.size = strlen(TRUST_PWD);
+
+ taiob.previous.count = 0;
+ taiob.previous.array = NULL;
+
+ ndr_err = ndr_push_struct_blob(&td->trust_auth_outgoing,
+ td, &taiob,
+ (ndr_push_flags_fn_t) ndr_push_trustAuthInOutBlob);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ fprintf(stderr, "ndr_push_struct_blob failed.\n");
+ exit(1);
+ }
+
+ td->trust_direction = LSA_TRUST_DIRECTION_OUTBOUND;
+ td->trust_type = LSA_TRUST_TYPE_DOWNLEVEL;
+ td->trust_attributes = 0;
+ td->trust_forest_trust_info = data_blob_null;
+
+ rv = pdb->set_trusted_domain(pdb, TRUST_DOM, td);
+ if (!NT_STATUS_IS_OK(rv)) {
+ fprintf(stderr, "Error in set_trusted_domain %s\n",
+ get_friendly_nt_error_msg(rv));
+ error = True;
+ }
+
+ rv = pdb->get_trusted_domain(pdb, ctx, TRUST_DOM, &new_td);
+ if (!NT_STATUS_IS_OK(rv)) {
+ fprintf(stderr, "Error in set_trusted_domain %s\n",
+ get_friendly_nt_error_msg(rv));
+ error = True;
+ }
+
+ if (!strequal(td->domain_name, new_td->domain_name) ||
+ !strequal(td->netbios_name, new_td->netbios_name) ||
+ !sid_equal(&td->security_identifier, &new_td->security_identifier) ||
+ td->trust_direction != new_td->trust_direction ||
+ td->trust_type != new_td->trust_type ||
+ td->trust_attributes != new_td->trust_attributes ||
+ td->trust_auth_incoming.length != new_td->trust_auth_incoming.length ||
+ td->trust_forest_trust_info.length != new_td->trust_forest_trust_info.length ||
+ data_blob_cmp(&td->trust_auth_outgoing, &new_td->trust_auth_outgoing) != 0) {
+ fprintf(stderr, "Old and new trusdet domain data do not match\n");
+ error = True;
+ }
+
TALLOC_FREE(ctx);
if (error) {
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index a45aa153c43..6a47a18cd7c 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -23,6 +23,8 @@
#ifndef __TORTURE_H__
#define __TORTURE_H__
+struct cli_state;
+
/* The following definitions come from torture/denytest.c */
bool torture_denytest1(int dummy);
@@ -87,5 +89,7 @@ bool run_nbench2(int dummy);
bool run_async_echo(int dummy);
bool run_smb_any_connect(int dummy);
bool run_addrchange(int dummy);
+bool run_notify_online(int dummy);
+bool run_nttrans_create(int dummy);
#endif /* __TORTURE_H__ */
diff --git a/source3/torture/scanner.c b/source3/torture/scanner.c
index c7d3ebc2913..1ca4ca45956 100644
--- a/source3/torture/scanner.c
+++ b/source3/torture/scanner.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "torture/proto.h"
+#include "libsmb/libsmb.h"
#define VERBOSE 0
#define OP_MIN 0
@@ -172,7 +173,7 @@ static bool scan_trans2(struct cli_state *cli, int op, int level,
status = try_trans2_len(cli, "newfile", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_unlink(cli, "\\newfile.dat", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\newfile.dat", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, "\\newfile.dat");
if (NT_STATUS_IS_OK(status)) return True;
@@ -379,7 +380,7 @@ static bool scan_nttrans(struct cli_state *cli, int op, int level,
status = try_nttrans_len(cli, "newfile", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_unlink(cli, "\\newfile.dat", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\newfile.dat", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, "\\newfile.dat");
if (NT_STATUS_IS_OK(status)) return True;
diff --git a/source3/torture/t_strcmp.c b/source3/torture/t_strcmp.c
index 318423b8be0..5be26cdc79f 100644
--- a/source3/torture/t_strcmp.c
+++ b/source3/torture/t_strcmp.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2003 by Martin Pool
*
- * Test harness for StrCaseCmp
+ * Test harness for strcasecmp_m
*/
#include "includes.h"
@@ -16,7 +16,7 @@ int main(int argc, char *argv[])
if (argc < 3) {
fprintf(stderr, "usage: %s STRING1 STRING2 [ITERS]\n"
- "Compares two strings, prints the results of StrCaseCmp\n",
+ "Compares two strings, prints the results of strcasecmp_m\n",
argv[0]);
return 2;
}
@@ -24,7 +24,7 @@ int main(int argc, char *argv[])
iters = atoi(argv[3]);
for (i = 0; i < iters; i++)
- ret = StrCaseCmp(argv[1], argv[2]);
+ ret = strcasecmp_m(argv[1], argv[2]);
printf("%d\n", ret);
diff --git a/source3/torture/test_async_echo.c b/source3/torture/test_async_echo.c
index e443d4f8a7d..d097f49ca5e 100644
--- a/source3/torture/test_async_echo.c
+++ b/source3/torture/test_async_echo.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "torture/proto.h"
+#include "libsmb/libsmb.h"
#include "rpc_client/cli_pipe.h"
#include "librpc/gen_ndr/ndr_echo_c.h"
diff --git a/source3/torture/test_case_insensitive.c b/source3/torture/test_case_insensitive.c
index df9d1498618..26b3d65d7ec 100644
--- a/source3/torture/test_case_insensitive.c
+++ b/source3/torture/test_case_insensitive.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "torture/proto.h"
#include "system/filesys.h"
+#include "libsmb/libsmb.h"
/*
* Regression test file creates on case insensitive file systems (e.g. OS/X)
diff --git a/source3/torture/test_notify_online.c b/source3/torture/test_notify_online.c
new file mode 100644
index 00000000000..b9ebc00b54b
--- /dev/null
+++ b/source3/torture/test_notify_online.c
@@ -0,0 +1,294 @@
+/*
+ Unix SMB/CIFS implementation.
+ Make sure that for offline files pread and pwrite trigger a notify
+ Copyright (C) Volker Lendecke 2011
+
+ 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/proto.h"
+#include "libcli/security/security.h"
+#include "lib/util/tevent_ntstatus.h"
+#include "libsmb/libsmb.h"
+
+extern char *test_filename;
+
+struct notify_online_state {
+ struct tevent_context *ev;
+ struct cli_state *cli;
+ uint16_t dnum;
+ const char *fname;
+ uint16_t fnum;
+ bool got_notify;
+};
+
+static void notify_online_opened_dir(struct tevent_req *subreq);
+static void notify_online_notify_callback(struct tevent_req *subreq);
+static void notify_online_opened_file(struct tevent_req *subreq);
+static void notify_online_sent_read(struct tevent_req *subreq);
+static void notify_online_sent_closefile(struct tevent_req *subreq);
+static void notify_online_waited(struct tevent_req *subreq);
+static void notify_online_sent_closedir(struct tevent_req *subreq);
+
+static struct tevent_req *notify_online_send(
+ TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct cli_state *cli, const char *dname, const char *fname)
+{
+ struct tevent_req *req, *subreq;
+ struct notify_online_state *state;
+
+ req = tevent_req_create(mem_ctx, &state, struct notify_online_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->ev = ev;
+ state->cli = cli;
+ state->fname = fname;
+
+ subreq = cli_ntcreate_send(
+ state, ev, cli, dname, EXTENDED_RESPONSE_REQUIRED,
+ SEC_FILE_READ_DATA, 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ FILE_OPEN, 0, 0);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, notify_online_opened_dir, req);
+ return req;
+}
+
+static void notify_online_opened_dir(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct notify_online_state *state = tevent_req_data(
+ req, struct notify_online_state);
+ NTSTATUS status;
+
+ status = cli_ntcreate_recv(subreq, &state->dnum);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ subreq = cli_notify_send(state, state->ev, state->cli, state->dnum,
+ 128, FILE_NOTIFY_CHANGE_ATTRIBUTES, false);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, notify_online_notify_callback, req);
+
+ subreq = cli_ntcreate_send(
+ state, state->ev, state->cli, state->fname, 0,
+ GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OPEN, FILE_NON_DIRECTORY_FILE, 0);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, notify_online_opened_file, req);
+}
+
+static void notify_online_notify_callback(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct notify_online_state *state = tevent_req_data(
+ req, struct notify_online_state);
+ NTSTATUS status;
+ uint32_t num_changes;
+ struct notify_change *changes;
+
+ status = cli_notify_recv(subreq, state, &num_changes, &changes);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ if ((num_changes == 1)
+ && (changes[0].action == NOTIFY_ACTION_MODIFIED)
+ && (strcmp(changes[0].name, state->fname) == 0)) {
+ state->got_notify = true;
+ }
+ tevent_req_done(req);
+}
+
+static void notify_online_opened_file(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct notify_online_state *state = tevent_req_data(
+ req, struct notify_online_state);
+ NTSTATUS status;
+
+ status = cli_ntcreate_recv(subreq, &state->fnum);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ subreq = cli_read_andx_send(
+ state, state->ev, state->cli, state->fnum, 0, 1);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, notify_online_sent_read, req);
+}
+
+static void notify_online_sent_read(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct notify_online_state *state = tevent_req_data(
+ req, struct notify_online_state);
+ NTSTATUS status;
+ ssize_t received;
+ uint8_t *buf;
+
+ status = cli_read_andx_recv(subreq, &received, &buf);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ subreq = cli_close_send(
+ state, state->ev, state->cli, state->fnum);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, notify_online_sent_closefile, req);
+}
+
+static void notify_online_sent_closefile(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct notify_online_state *state = tevent_req_data(
+ req, struct notify_online_state);
+ NTSTATUS status;
+
+ status = cli_close_recv(subreq);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ subreq = tevent_wakeup_send(
+ state, state->ev, timeval_current_ofs(10, 0));
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, notify_online_waited, req);
+}
+
+static void notify_online_waited(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct notify_online_state *state = tevent_req_data(
+ req, struct notify_online_state);
+
+ tevent_wakeup_recv(subreq);
+ TALLOC_FREE(subreq);
+ subreq = cli_close_send(
+ state, state->ev, state->cli, state->dnum);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, notify_online_sent_closedir, req);
+}
+
+static void notify_online_sent_closedir(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ NTSTATUS status;
+
+ status = cli_close_recv(subreq);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+}
+
+static NTSTATUS notify_online_recv(struct tevent_req *req, bool *got_notify)
+{
+ struct notify_online_state *state = tevent_req_data(
+ req, struct notify_online_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+ *got_notify = state->got_notify;
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS notify_online(struct cli_state *cli,
+ const char *dirname, const char *filename,
+ bool *got_notify)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct event_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ ev = event_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = notify_online_send(frame, ev, cli, dirname, filename);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = notify_online_recv(req, got_notify);
+ fail:
+ TALLOC_FREE(frame);
+ return status;
+}
+
+bool run_notify_online(int dummy)
+{
+ struct cli_state *cli;
+ NTSTATUS status;
+ char *p;
+ const char *dir;
+ const char *file;
+ bool got_notify = false;
+
+ printf("Starting NOTIFY_ONLINE\n");
+
+ if (test_filename == NULL) {
+ fprintf(stderr, "<-f filename> missing\n");
+ return false;
+ }
+
+ if (!torture_open_connection(&cli, 0)) {
+ return false;
+ }
+
+ p = strrchr(test_filename, '/');
+ if (p != NULL) {
+ dir = SMB_STRNDUP(test_filename, p-test_filename);
+ file = SMB_STRDUP(p+1);
+ } else {
+ dir = "";
+ file = test_filename;
+ }
+
+ status = notify_online(cli, dir, file, &got_notify);
+ d_printf("notify_online returned %s (%d)\n", nt_errstr(status),
+ (int)got_notify);
+ torture_close_connection(cli);
+ return NT_STATUS_IS_OK(status) && got_notify;
+}
diff --git a/source3/torture/test_nttrans_create.c b/source3/torture/test_nttrans_create.c
new file mode 100644
index 00000000000..9869f020e9b
--- /dev/null
+++ b/source3/torture/test_nttrans_create.c
@@ -0,0 +1,108 @@
+/*
+ Unix SMB/CIFS implementation.
+ Basic test for share secdescs vs nttrans_create
+ Copyright (C) Volker Lendecke 2011
+
+ 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/proto.h"
+#include "libsmb/libsmb.h"
+#include "libcli/security/dom_sid.h"
+#include "libcli/security/secdesc.h"
+#include "libcli/security/security.h"
+
+bool run_nttrans_create(int dummy)
+{
+ struct cli_state *cli = NULL;
+ NTSTATUS status, status2;
+ bool ret = false;
+ struct security_ace ace;
+ struct security_acl acl;
+ struct security_descriptor *sd;
+ const char *fname = "transtest";
+ uint16_t fnum, fnum2;
+ struct dom_sid owner;
+
+ printf("Starting NTTRANS_CREATE\n");
+
+ if (!torture_open_connection(&cli, 0)) {
+ printf("torture_open_connection failed\n");
+ goto fail;
+ }
+
+ ZERO_STRUCT(ace);
+ ace.type = SEC_ACE_TYPE_ACCESS_ALLOWED;
+ ace.access_mask = SEC_RIGHTS_FILE_ALL & ~SEC_STD_WRITE_DAC;
+ sid_copy(&ace.trustee, &global_sid_World);
+
+ acl.revision = SECURITY_ACL_REVISION_NT4;
+ acl.size = 0;
+ acl.num_aces = 1;
+ acl.aces = &ace;
+
+ dom_sid_parse("S-1-22-1-1000", &owner);
+
+ sd = make_sec_desc(talloc_tos(),
+ SECURITY_DESCRIPTOR_REVISION_1,
+ SEC_DESC_SELF_RELATIVE|
+ SEC_DESC_DACL_PRESENT|SEC_DESC_OWNER_DEFAULTED|
+ SEC_DESC_GROUP_DEFAULTED,
+ NULL, NULL, NULL, &acl, NULL);
+ if (sd == NULL) {
+ d_fprintf(stderr, "make_sec_desc failed\n");
+ goto fail;
+ }
+
+ status = cli_nttrans_create(
+ cli, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS|
+ READ_CONTROL_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE| FILE_SHARE_DELETE,
+ FILE_CREATE, 0, 0, sd, NULL, 0, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "cli_nttrans_create returned %s\n",
+ nt_errstr(status));
+ goto fail;
+ }
+
+ cli_query_secdesc(cli, fnum, talloc_tos());
+
+ status2 = cli_ntcreate(cli, fname, 0, WRITE_DAC_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|
+ FILE_SHARE_DELETE,
+ FILE_OPEN, 0, 0, &fnum2);
+
+ status = cli_nt_delete_on_close(cli, fnum, true);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "cli_nt_delete_on_close returned %s\n",
+ nt_errstr(status));
+ goto fail;
+ }
+
+ if (!NT_STATUS_EQUAL(status2, NT_STATUS_ACCESS_DENIED)) {
+ d_fprintf(stderr, "cli_ntcreate returned %s\n",
+ nt_errstr(status));
+ goto fail;
+ }
+
+ ret = true;
+fail:
+ if (cli != NULL) {
+ torture_close_connection(cli);
+ }
+ return ret;
+}
diff --git a/source3/torture/test_posix_append.c b/source3/torture/test_posix_append.c
index 6c8317e5aad..2f562633e50 100644
--- a/source3/torture/test_posix_append.c
+++ b/source3/torture/test_posix_append.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "torture/proto.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
/*
* Make sure that GENERIC_WRITE does not trigger append. See
@@ -32,9 +33,8 @@ bool run_posix_append(int dummy)
const char *fname = "append";
NTSTATUS status;
uint16_t fnum;
- ssize_t written;
SMB_OFF_T size;
- char c = '\0';
+ uint8_t c = '\0';
bool ret = false;
printf("Starting POSIX_APPEND\n");
@@ -69,14 +69,14 @@ bool run_posix_append(int dummy)
* with a file of 2 byte length.
*/
- written = cli_write(cli, fnum, 0, &c, 0, sizeof(c));
- if (written != sizeof(c)) {
- printf("cli_write failed\n");
+ status = cli_writeall(cli, fnum, 0, &c, 0, sizeof(c), NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_write failed: %s\n", nt_errstr(status));
goto fail;
}
- written = cli_write(cli, fnum, 0, &c, 0, sizeof(c));
- if (written != sizeof(c)) {
- printf("cli_write failed\n");
+ status = cli_writeall(cli, fnum, 0, &c, 0, sizeof(c), NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_write failed: %s\n", nt_errstr(status));
goto fail;
}
diff --git a/source3/torture/test_smbsock_any_connect.c b/source3/torture/test_smbsock_any_connect.c
index 28a99815e77..a964e0fd831 100644
--- a/source3/torture/test_smbsock_any_connect.c
+++ b/source3/torture/test_smbsock_any_connect.c
@@ -35,7 +35,7 @@ bool run_smb_any_connect(int dummy)
interpret_string_addr(&addrs[4], "192.168.99.9", 0);
status = smbsock_any_connect(addrs, NULL, NULL, NULL, NULL,
- ARRAY_SIZE(addrs), 0,
+ ARRAY_SIZE(addrs), 0, 0,
&fd, &chosen_index, &port);
d_printf("smbsock_any_connect returned %s (fd %d)\n",
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 6319d6194d7..faa4326489a 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -31,9 +31,13 @@
#include "dbwrap.h"
#include "talloc_dict.h"
#include "async_smb.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "trans2.h"
#include "libsmb/nmblib.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "util_tdb.h"
+#include "libsmb/read_smb.h"
extern char *optarg;
extern int optind;
@@ -57,6 +61,7 @@ static bool use_multishare_conn = False;
static bool do_encrypt;
static const char *local_path = NULL;
static int signing_state = Undefined;
+char *test_filename;
bool torture_showall = False;
@@ -173,24 +178,11 @@ static bool force_cli_encryption(struct cli_state *c,
static struct cli_state *open_nbt_connection(void)
{
- struct nmb_name called, calling;
- struct sockaddr_storage ss;
struct cli_state *c;
NTSTATUS status;
- make_nmb_name(&calling, myname, 0x0);
- make_nmb_name(&called , host, 0x20);
-
- zero_sockaddr(&ss);
-
- if (!(c = cli_initialise_ex(signing_state))) {
- printf("Failed initialize cli_struct to connect with %s\n", host);
- return NULL;
- }
-
- c->port = port_to_use;
-
- status = cli_connect(c, host, &ss);
+ status = cli_connect_nb(host, NULL, port_to_use, 0x20, myname,
+ signing_state, &c);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
return NULL;
@@ -202,27 +194,6 @@ static struct cli_state *open_nbt_connection(void)
if (use_oplocks) c->use_oplocks = True;
if (use_level_II_oplocks) c->use_level_II_oplocks = True;
- if (!cli_session_request(c, &calling, &called)) {
- /*
- * Well, that failed, try *SMBSERVER ...
- * However, we must reconnect as well ...
- */
- status = cli_connect(c, host, &ss);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
- return NULL;
- }
-
- make_nmb_name(&called, "*SMBSERVER", 0x20);
- if (!cli_session_request(c, &calling, &called)) {
- printf("%s rejected the session\n",host);
- printf("We tried with a called name of %s & %s\n",
- host, "*SMBSERVER");
- cli_shutdown(c);
- return NULL;
- }
- }
-
return c;
}
@@ -230,115 +201,94 @@ static struct cli_state *open_nbt_connection(void)
Send a corrupt session request. See rfc1002.txt 4.3 and 4.3.2.
****************************************************************************/
-static bool cli_bad_session_request(struct cli_state *cli,
+static bool cli_bad_session_request(int fd,
struct nmb_name *calling, struct nmb_name *called)
{
- char *p;
- int len = 4;
- int namelen = 0;
- char *tmp;
+ TALLOC_CTX *frame;
+ uint8_t len_buf[4];
+ struct iovec iov[3];
+ ssize_t len;
+ uint8_t *inbuf;
+ int err;
+ bool ret = false;
+ uint8_t message_type;
+ uint8_t error;
- memcpy(&(cli->calling), calling, sizeof(*calling));
- memcpy(&(cli->called ), called , sizeof(*called ));
+ frame = talloc_stackframe();
- /* put in the destination name */
+ iov[0].iov_base = len_buf;
+ iov[0].iov_len = sizeof(len_buf);
- tmp = name_mangle(talloc_tos(), cli->called.name,
- cli->called.name_type);
- if (tmp == NULL) {
- return false;
- }
+ /* put in the destination name */
- p = cli->outbuf+len;
- namelen = name_len((unsigned char *)tmp, talloc_get_size(tmp));
- if (namelen > 0) {
- memcpy(p, tmp, namelen);
- len += namelen;
- }
- TALLOC_FREE(tmp);
-
- /* Deliberately corrupt the name len (first byte) */
- *p = 100;
+ iov[1].iov_base = name_mangle(talloc_tos(), called->name,
+ called->name_type);
+ if (iov[1].iov_base == NULL) {
+ goto fail;
+ }
+ iov[1].iov_len = name_len((unsigned char *)iov[1].iov_base,
+ talloc_get_size(iov[1].iov_base));
- /* and my name */
+ /* and my name */
- tmp = name_mangle(talloc_tos(), cli->calling.name,
- cli->calling.name_type);
- if (tmp == NULL) {
- return false;
- }
+ iov[2].iov_base = name_mangle(talloc_tos(), calling->name,
+ calling->name_type);
+ if (iov[2].iov_base == NULL) {
+ goto fail;
+ }
+ iov[2].iov_len = name_len((unsigned char *)iov[2].iov_base,
+ talloc_get_size(iov[2].iov_base));
- p = cli->outbuf+len;
- namelen = name_len((unsigned char *)tmp, talloc_get_size(tmp));
- if (namelen > 0) {
- memcpy(p, tmp, namelen);
- len += namelen;
- }
- TALLOC_FREE(tmp);
/* Deliberately corrupt the name len (first byte) */
- *p = 100;
+ *((uint8_t *)iov[2].iov_base) = 100;
- /* send a session request (RFC 1002) */
- /* setup the packet length
+ /* send a session request (RFC 1002) */
+ /* setup the packet length
* Remove four bytes from the length count, since the length
* field in the NBT Session Service header counts the number
* of bytes which follow. The cli_send_smb() function knows
* about this and accounts for those four bytes.
* CRH.
*/
- len -= 4;
- _smb_setlen(cli->outbuf,len);
- SCVAL(cli->outbuf,0,0x81);
-
- cli_send_smb(cli);
- DEBUG(5,("Sent session request\n"));
-
- if (!cli_receive_smb(cli))
- return False;
-
- if (CVAL(cli->inbuf,0) != 0x82) {
- /* This is the wrong place to put the error... JRA. */
- cli->rap_error = CVAL(cli->inbuf,4);
- return False;
- }
- return(True);
-}
-
-static struct cli_state *open_bad_nbt_connection(void)
-{
- struct nmb_name called, calling;
- struct sockaddr_storage ss;
- struct cli_state *c;
- NTSTATUS status;
-
- make_nmb_name(&calling, myname, 0x0);
- make_nmb_name(&called , host, 0x20);
- zero_sockaddr(&ss);
+ _smb_setlen(len_buf, iov[1].iov_len + iov[2].iov_len);
+ SCVAL(len_buf,0,0x81);
- if (!(c = cli_initialise_ex(signing_state))) {
- printf("Failed initialize cli_struct to connect with %s\n", host);
- return NULL;
+ len = write_data_iov(fd, iov, 3);
+ if (len == -1) {
+ goto fail;
}
-
- c->port = 139;
-
- status = cli_connect(c, host, &ss);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
- return NULL;
+ len = read_smb(fd, talloc_tos(), &inbuf, &err);
+ if (len == -1) {
+ errno = err;
+ goto fail;
}
- c->timeout = 4000; /* set a short timeout (4 seconds) */
+ message_type = CVAL(inbuf, 0);
+ if (message_type != 0x83) {
+ d_fprintf(stderr, "Expected msg type 0x83, got 0x%2.2x\n",
+ message_type);
+ goto fail;
+ }
- if (!cli_bad_session_request(c, &calling, &called)) {
- printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
- return NULL;
- }
+ if (smb_len(inbuf) != 1) {
+ d_fprintf(stderr, "Expected smb_len 1, got %d\n",
+ (int)smb_len(inbuf));
+ goto fail;
+ }
- return c;
-}
+ error = CVAL(inbuf, 4);
+ if (error != 0x82) {
+ d_fprintf(stderr, "Expected error 0x82, got %d\n",
+ (int)error);
+ goto fail;
+ }
+ ret = true;
+fail:
+ TALLOC_FREE(frame);
+ return ret;
+}
/* Insert a NULL at the first separator of the given path and return a pointer
* to the remainder of the string.
@@ -572,12 +522,14 @@ static bool rw_torture(struct cli_state *c)
status = cli_open(c, lockfname, O_RDWR, DENY_NONE, &fnum2);
}
if (!NT_STATUS_IS_OK(status)) {
- printf("open of %s failed (%s)\n", lockfname, cli_errstr(c));
+ printf("open of %s failed (%s)\n",
+ lockfname, nt_errstr(status));
return False;
}
for (i=0;i<torture_numops;i++) {
unsigned n = (unsigned)sys_random()%10;
+
if (i % 10 == 0) {
printf("%d\r", i); fflush(stdout);
}
@@ -587,22 +539,28 @@ static bool rw_torture(struct cli_state *c)
return False;
}
- if (!NT_STATUS_IS_OK(cli_open(c, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL, &fnum))) {
- printf("open failed (%s)\n", cli_errstr(c));
+ status = cli_open(c, fname, O_RDWR | O_CREAT | O_TRUNC,
+ DENY_ALL, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open failed (%s)\n", nt_errstr(status));
correct = False;
break;
}
- if (cli_write(c, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) {
- printf("write failed (%s)\n", cli_errstr(c));
+ status = cli_writeall(c, fnum, 0, (uint8_t *)&pid, 0,
+ sizeof(pid), NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("write failed (%s)\n", nt_errstr(status));
correct = False;
}
for (j=0;j<50;j++) {
- if (cli_write(c, fnum, 0, (char *)buf,
- sizeof(pid)+(j*sizeof(buf)),
- sizeof(buf)) != sizeof(buf)) {
- printf("write failed (%s)\n", cli_errstr(c));
+ status = cli_writeall(c, fnum, 0, (uint8_t *)buf,
+ sizeof(pid)+(j*sizeof(buf)),
+ sizeof(buf), NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("write failed (%s)\n",
+ nt_errstr(status));
correct = False;
}
}
@@ -619,24 +577,27 @@ static bool rw_torture(struct cli_state *c)
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_close(c, fnum))) {
- printf("close failed (%s)\n", cli_errstr(c));
+ status = cli_close(c, fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close failed (%s)\n", nt_errstr(status));
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_unlink(c, fname, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s)\n", cli_errstr(c));
+ status = cli_unlink(c, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s)\n", nt_errstr(status));
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_unlock(c, fnum2, n*sizeof(int), sizeof(int)))) {
- printf("unlock failed (%s)\n", cli_errstr(c));
+ status = cli_unlock(c, fnum2, n*sizeof(int), sizeof(int));
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlock failed (%s)\n", nt_errstr(status));
correct = False;
}
}
cli_close(c, fnum2);
- cli_unlink(c, lockfname, aSYSTEM | aHIDDEN);
+ cli_unlink(c, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
printf("%d\n", i);
@@ -681,14 +642,15 @@ static bool rw_torture3(struct cli_state *c, char *lockfname)
if (procnum == 0)
{
- if (!NT_STATUS_IS_OK(cli_unlink(c, lockfname, aSYSTEM | aHIDDEN))) {
+ if (!NT_STATUS_IS_OK(cli_unlink(c, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
printf("unlink failed (%s) (normal, this file should not exist)\n", cli_errstr(c));
}
- if (!NT_STATUS_IS_OK(cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL,
- DENY_NONE, &fnum))) {
+ status = cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ DENY_NONE, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
printf("first open read/write of %s failed (%s)\n",
- lockfname, cli_errstr(c));
+ lockfname, nt_errstr(status));
return False;
}
}
@@ -705,7 +667,7 @@ static bool rw_torture3(struct cli_state *c, char *lockfname)
}
if (!NT_STATUS_IS_OK(status)) {
printf("second open read-only of %s failed (%s)\n",
- lockfname, cli_errstr(c));
+ lockfname, nt_errstr(status));
return False;
}
}
@@ -728,8 +690,11 @@ static bool rw_torture3(struct cli_state *c, char *lockfname)
sent = sizeof(buf) - count;
}
- if (cli_write(c, fnum, 0, buf+count, count, (size_t)sent) != sent) {
- printf("write failed (%s)\n", cli_errstr(c));
+ status = cli_writeall(c, fnum, 0, (uint8_t *)buf+count,
+ count, (size_t)sent, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("write failed (%s)\n",
+ nt_errstr(status));
correct = False;
}
}
@@ -759,8 +724,9 @@ static bool rw_torture3(struct cli_state *c, char *lockfname)
}
- if (!NT_STATUS_IS_OK(cli_close(c, fnum))) {
- printf("close failed (%s)\n", cli_errstr(c));
+ status = cli_close(c, fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close failed (%s)\n", nt_errstr(status));
correct = False;
}
@@ -777,26 +743,30 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2)
char buf_rd[131072];
bool correct = True;
ssize_t bytes_read;
+ NTSTATUS status;
- if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s) (normal, this file should not exist)\n", cli_errstr(c1));
+ status = cli_unlink(c1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s) (normal, this file should not exist)\n", nt_errstr(status));
}
- if (!NT_STATUS_IS_OK(cli_open(c1, lockfname, O_RDWR | O_CREAT | O_EXCL,
- DENY_NONE, &fnum1))) {
+ status = cli_open(c1, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
printf("first open read/write of %s failed (%s)\n",
- lockfname, cli_errstr(c1));
+ lockfname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_open(c2, lockfname, O_RDONLY,
- DENY_NONE, &fnum2))) {
+
+ status = cli_open(c2, lockfname, O_RDONLY, DENY_NONE, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
printf("second open read-only of %s failed (%s)\n",
- lockfname, cli_errstr(c2));
+ lockfname, nt_errstr(status));
cli_close(c1, fnum1);
return False;
}
- for (i=0;i<torture_numops;i++)
+ for (i = 0; i < torture_numops; i++)
{
size_t buf_size = ((unsigned)sys_random()%(sizeof(buf)-1))+ 1;
if (i % 10 == 0) {
@@ -805,8 +775,10 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2)
generate_random_buffer((unsigned char *)buf, buf_size);
- if (cli_write(c1, fnum1, 0, buf, 0, buf_size) != buf_size) {
- printf("write failed (%s)\n", cli_errstr(c1));
+ status = cli_writeall(c1, fnum1, 0, (uint8_t *)buf, 0,
+ buf_size, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("write failed (%s)\n", nt_errstr(status));
correct = False;
break;
}
@@ -827,17 +799,21 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2)
}
}
- if (!NT_STATUS_IS_OK(cli_close(c2, fnum2))) {
- printf("close failed (%s)\n", cli_errstr(c2));
+ status = cli_close(c2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close failed (%s)\n", nt_errstr(status));
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_close(c1, fnum1))) {
- printf("close failed (%s)\n", cli_errstr(c1));
+
+ status = cli_close(c1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close failed (%s)\n", nt_errstr(status));
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s)\n", cli_errstr(c1));
+ status = cli_unlink(c1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s)\n", nt_errstr(status));
correct = False;
}
@@ -903,6 +879,7 @@ static bool run_readwritelarge_internal(int max_xmit_k)
SMB_OFF_T fsize;
char buf[126*1024];
bool correct = True;
+ NTSTATUS status;
if (!torture_open_connection(&cli1, 0)) {
return False;
@@ -922,19 +899,21 @@ static bool run_readwritelarge_internal(int max_xmit_k)
printf("starting readwritelarge_internal\n");
- cli_unlink(cli1, lockfname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_open(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE, &fnum1))) {
- printf("open read/write of %s failed (%s)\n", lockfname, cli_errstr(cli1));
+ status = cli_open(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open read/write of %s failed (%s)\n", lockfname, nt_errstr(status));
return False;
}
- cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf));
+ cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), NULL);
- if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
- cli1, fnum1, NULL, &fsize, NULL, NULL,
- NULL, NULL, NULL))) {
- printf("qfileinfo failed (%s)\n", cli_errstr(cli1));
+ status = cli_qfileinfo_basic(cli1, fnum1, NULL, &fsize, NULL, NULL,
+ NULL, NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("qfileinfo failed (%s)\n", nt_errstr(status));
correct = False;
}
@@ -947,18 +926,22 @@ static bool run_readwritelarge_internal(int max_xmit_k)
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close failed (%s)\n", nt_errstr(status));
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_unlink(cli1, lockfname, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s)\n", cli_errstr(cli1));
+ status = cli_unlink(cli1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s)\n", nt_errstr(status));
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_open(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE, &fnum1))) {
- printf("open read/write of %s failed (%s)\n", lockfname, cli_errstr(cli1));
+ status = cli_open(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open read/write of %s failed (%s)\n", lockfname, nt_errstr(status));
return False;
}
@@ -966,10 +949,10 @@ static bool run_readwritelarge_internal(int max_xmit_k)
cli_smbwrite(cli1, fnum1, buf, 0, sizeof(buf), NULL);
- if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
- cli1, fnum1, NULL, &fsize, NULL, NULL,
- NULL, NULL, NULL))) {
- printf("qfileinfo failed (%s)\n", cli_errstr(cli1));
+ status = cli_qfileinfo_basic(cli1, fnum1, NULL, &fsize, NULL, NULL,
+ NULL, NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("qfileinfo failed (%s)\n", nt_errstr(status));
correct = False;
}
@@ -997,8 +980,9 @@ static bool run_readwritelarge_internal(int max_xmit_k)
printf("readwritelarge test 3 (truncate test) succeeded (size = %x)\n", fsize);
#endif
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close failed (%s)\n", nt_errstr(status));
correct = False;
}
@@ -1160,6 +1144,7 @@ static bool run_locktest1(int dummy)
uint16_t fnum1, fnum2, fnum3;
time_t t1, t2;
unsigned lock_timeout;
+ NTSTATUS status;
if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) {
return False;
@@ -1169,18 +1154,24 @@ static bool run_locktest1(int dummy)
printf("starting locktest1\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+ &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum2))) {
- printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli1));
+
+ status = cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum3))) {
- printf("open3 of %s failed (%s)\n", fname, cli_errstr(cli2));
+
+ status = cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum3);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open3 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -1218,8 +1209,9 @@ static bool run_locktest1(int dummy)
printf("server slept for %u seconds for a %u second timeout\n",
(unsigned int)(t2-t1), lock_timeout);
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum2))) {
- printf("close1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close1 failed (%s)\n", nt_errstr(status));
return False;
}
@@ -1231,18 +1223,21 @@ static bool run_locktest1(int dummy)
NT_STATUS_FILE_LOCK_CONFLICT)) return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close2 failed (%s)\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum3))) {
- printf("close3 failed (%s)\n", cli_errstr(cli2));
+ status = cli_close(cli2, fnum3);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close3 failed (%s)\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s)\n", cli_errstr(cli1));
+ status = cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s)\n", nt_errstr(status));
return False;
}
@@ -1283,18 +1278,20 @@ static bool run_tcon_test(int dummy)
printf("starting tcontest\n");
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
cnum1 = cli->cnum;
vuid1 = cli->vuid;
- if (cli_write(cli, fnum1, 0, buf, 130, 4) != 4) {
- printf("initial write failed (%s)", cli_errstr(cli));
+ status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("initial write failed (%s)", nt_errstr(status));
return False;
}
@@ -1314,40 +1311,47 @@ static bool run_tcon_test(int dummy)
/* try a write with the wrong tid */
cli->cnum = cnum2;
- if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) {
+ status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
+ if (NT_STATUS_IS_OK(status)) {
printf("* server allows write with wrong TID\n");
ret = False;
} else {
- printf("server fails write with wrong TID : %s\n", cli_errstr(cli));
+ printf("server fails write with wrong TID : %s\n",
+ nt_errstr(status));
}
/* try a write with an invalid tid */
cli->cnum = cnum3;
- if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) {
+ status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
+ if (NT_STATUS_IS_OK(status)) {
printf("* server allows write with invalid TID\n");
ret = False;
} else {
- printf("server fails write with invalid TID : %s\n", cli_errstr(cli));
+ printf("server fails write with invalid TID : %s\n",
+ nt_errstr(status));
}
/* try a write with an invalid vuid */
cli->vuid = vuid2;
cli->cnum = cnum1;
- if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) {
+ status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
+ if (NT_STATUS_IS_OK(status)) {
printf("* server allows write with invalid VUID\n");
ret = False;
} else {
- printf("server fails write with invalid VUID : %s\n", cli_errstr(cli));
+ printf("server fails write with invalid VUID : %s\n",
+ nt_errstr(status));
}
cli->cnum = cnum1;
cli->vuid = vuid1;
- if (!NT_STATUS_IS_OK(cli_close(cli, fnum1))) {
- printf("close failed (%s)\n", cli_errstr(cli));
+ status = cli_close(cli, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close failed (%s)\n", nt_errstr(status));
return False;
}
@@ -1534,6 +1538,7 @@ static bool run_locktest2(int dummy)
const char *fname = "\\lockt2.lck";
uint16_t fnum1, fnum2, fnum3;
bool correct = True;
+ NTSTATUS status;
if (!torture_open_connection(&cli, 0)) {
return False;
@@ -1543,24 +1548,27 @@ static bool run_locktest2(int dummy)
printf("starting locktest2\n");
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_setpid(cli, 1);
- if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum2))) {
- printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli));
+ status = cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
cli_setpid(cli, 2);
- if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum3))) {
- printf("open3 of %s failed (%s)\n", fname, cli_errstr(cli));
+ status = cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum3);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open3 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -1631,18 +1639,21 @@ static bool run_locktest2(int dummy)
cli_setpid(cli, 1);
- if (!NT_STATUS_IS_OK(cli_close(cli, fnum1))) {
- printf("close1 failed (%s)\n", cli_errstr(cli));
+ status = cli_close(cli, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close1 failed (%s)\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli, fnum2))) {
- printf("close2 failed (%s)\n", cli_errstr(cli));
+ status = cli_close(cli, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close2 failed (%s)\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli, fnum3))) {
- printf("close3 failed (%s)\n", cli_errstr(cli));
+ status = cli_close(cli, fnum3);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close3 failed (%s)\n", nt_errstr(status));
return False;
}
@@ -1669,6 +1680,7 @@ static bool run_locktest3(int dummy)
int i;
uint32 offset;
bool correct = True;
+ NTSTATUS status;
#define NEXT_OFFSET offset += (~(uint32)0) / torture_numops
@@ -1680,14 +1692,18 @@ static bool run_locktest3(int dummy)
printf("starting locktest3\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+ &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2))) {
- printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+
+ status = cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -1735,33 +1751,38 @@ static bool run_locktest3(int dummy)
for (offset=i=0;i<torture_numops;i++) {
NEXT_OFFSET;
- if (!NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, offset-1, 1))) {
+ status = cli_unlock(cli1, fnum1, offset-1, 1);
+ if (!NT_STATUS_IS_OK(status)) {
printf("unlock1 %d failed (%s)\n",
i,
- cli_errstr(cli1));
+ nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_unlock(cli2, fnum2, offset-2, 1))) {
+ status = cli_unlock(cli2, fnum2, offset-2, 1);
+ if (!NT_STATUS_IS_OK(status)) {
printf("unlock2 %d failed (%s)\n",
i,
- cli_errstr(cli1));
+ nt_errstr(status));
return False;
}
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close1 failed (%s)\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
- printf("close2 failed (%s)\n", cli_errstr(cli2));
+ status = cli_close(cli2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close2 failed (%s)\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s)\n", cli_errstr(cli1));
+ status = cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s)\n", nt_errstr(status));
return False;
}
@@ -1793,6 +1814,7 @@ static bool run_locktest4(int dummy)
bool ret;
char buf[1000];
bool correct = True;
+ NTSTATUS status;
if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) {
return False;
@@ -1803,15 +1825,17 @@ static bool run_locktest4(int dummy)
printf("starting locktest4\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
memset(buf, 0, sizeof(buf));
- if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
- printf("Failed to create file\n");
+ status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf),
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to create file: %s\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -1883,8 +1907,12 @@ static bool run_locktest4(int dummy)
EXPECTED(ret, False);
printf("this server %s strict write locking\n", ret?"doesn't do":"does");
- ret = cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK) &&
- (cli_write(cli2, fnum2, 0, buf, 130, 4) == 4);
+ ret = cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK);
+ if (ret) {
+ status = cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, 130, 4,
+ NULL);
+ ret = NT_STATUS_IS_OK(status);
+ }
EXPECTED(ret, False);
printf("this server %s strict read locking\n", ret?"doesn't do":"does");
@@ -1901,21 +1929,24 @@ static bool run_locktest4(int dummy)
cli_lock(cli1, fnum1, 150, 4, 0, READ_LOCK) &&
NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4)) &&
(cli_read(cli2, fnum2, buf, 150, 4) == 4) &&
- !(cli_write(cli2, fnum2, 0, buf, 150, 4) == 4) &&
+ !(NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf,
+ 150, 4, NULL))) &&
NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4));
EXPECTED(ret, True);
printf("this server %s do recursive lock overlays\n", ret?"does":"doesn't");
ret = cli_lock(cli1, fnum1, 160, 4, 0, READ_LOCK) &&
NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 160, 4)) &&
- (cli_write(cli2, fnum2, 0, buf, 160, 4) == 4) &&
+ NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf,
+ 160, 4, NULL)) &&
(cli_read(cli2, fnum2, buf, 160, 4) == 4);
EXPECTED(ret, True);
printf("the same process %s remove a read lock using write locking\n", ret?"can":"cannot");
ret = cli_lock(cli1, fnum1, 170, 4, 0, WRITE_LOCK) &&
NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 170, 4)) &&
- (cli_write(cli2, fnum2, 0, buf, 170, 4) == 4) &&
+ NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf,
+ 170, 4, NULL)) &&
(cli_read(cli2, fnum2, buf, 170, 4) == 4);
EXPECTED(ret, True);
printf("the same process %s remove a write lock using read locking\n", ret?"can":"cannot");
@@ -1923,7 +1954,8 @@ static bool run_locktest4(int dummy)
ret = cli_lock(cli1, fnum1, 190, 4, 0, WRITE_LOCK) &&
cli_lock(cli1, fnum1, 190, 4, 0, READ_LOCK) &&
NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 190, 4)) &&
- !(cli_write(cli2, fnum2, 0, buf, 190, 4) == 4) &&
+ !NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf,
+ 190, 4, NULL)) &&
(cli_read(cli2, fnum2, buf, 190, 4) == 4);
EXPECTED(ret, True);
printf("the same process %s remove the first lock first\n", ret?"does":"doesn't");
@@ -1945,7 +1977,7 @@ static bool run_locktest4(int dummy)
fail:
cli_close(cli1, fnum1);
cli_close(cli2, fnum2);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
torture_close_connection(cli1);
torture_close_connection(cli2);
@@ -1964,6 +1996,7 @@ static bool run_locktest5(int dummy)
bool ret;
char buf[1000];
bool correct = True;
+ NTSTATUS status;
if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) {
return False;
@@ -1974,7 +2007,7 @@ static bool run_locktest5(int dummy)
printf("starting locktest5\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
@@ -1982,8 +2015,10 @@ static bool run_locktest5(int dummy)
memset(buf, 0, sizeof(buf));
- if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
- printf("Failed to create file\n");
+ status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf),
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to create file: %s\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -2064,7 +2099,7 @@ static bool run_locktest5(int dummy)
fail:
cli_close(cli1, fnum1);
cli_close(cli2, fnum2);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!torture_close_connection(cli1)) {
correct = False;
}
@@ -2099,7 +2134,7 @@ static bool run_locktest6(int dummy)
for (i=0;i<1;i++) {
printf("Testing %s\n", fname[i]);
- cli_unlink(cli, fname[i], aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_open(cli, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
status = cli_locktype(cli, fnum, 0, 8, 0, LOCKING_ANDX_CHANGE_LOCKTYPE);
@@ -2111,7 +2146,7 @@ static bool run_locktest6(int dummy)
cli_close(cli, fnum);
printf("CANCEL_LOCK gave %s\n", nt_errstr(status));
- cli_unlink(cli, fname[i], aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
}
torture_close_connection(cli);
@@ -2127,6 +2162,7 @@ static bool run_locktest7(int dummy)
uint16_t fnum1;
char buf[200];
bool correct = False;
+ NTSTATUS status;
if (!torture_open_connection(&cli1, 0)) {
return False;
@@ -2136,14 +2172,16 @@ static bool run_locktest7(int dummy)
printf("starting locktest7\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
memset(buf, 0, sizeof(buf));
- if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
- printf("Failed to create file\n");
+ status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf),
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to create file: %s\n", nt_errstr(status));
goto fail;
}
@@ -2163,9 +2201,11 @@ static bool run_locktest7(int dummy)
printf("pid1 successfully read the range 130:4\n");
}
- if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
- if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("pid1 unable to write to the range 130:4, error was "
+ "%s\n", nt_errstr(status));
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
@@ -2182,9 +2222,11 @@ static bool run_locktest7(int dummy)
printf("pid2 successfully read the range 130:4\n");
}
- if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
- if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("pid2 unable to write to the range 130:4, error was "
+ "%s\n", nt_errstr(status));
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
@@ -2210,8 +2252,10 @@ static bool run_locktest7(int dummy)
printf("pid1 successfully read the range 130:4\n");
}
- if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
+ status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("pid1 unable to write to the range 130:4, error was "
+ "%s\n", nt_errstr(status));
goto fail;
} else {
printf("pid1 successfully wrote to the range 130:4\n");
@@ -2230,9 +2274,11 @@ static bool run_locktest7(int dummy)
goto fail;
}
- if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
- if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("pid2 unable to write to the range 130:4, error was "
+ "%s\n", nt_errstr(status));
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
@@ -2246,7 +2292,7 @@ static bool run_locktest7(int dummy)
fail:
cli_close(cli1, fnum1);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
torture_close_connection(cli1);
printf("finished locktest7\n");
@@ -2278,12 +2324,12 @@ static bool run_locktest8(int dummy)
printf("starting locktest8\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_WRITE,
&fnum1);
if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr, "cli_open returned %s\n", cli_errstr(cli1));
+ d_fprintf(stderr, "cli_open returned %s\n", nt_errstr(status));
return false;
}
@@ -2292,7 +2338,7 @@ static bool run_locktest8(int dummy)
status = cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum2);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "cli_open second time returned %s\n",
- cli_errstr(cli1));
+ nt_errstr(status));
goto fail;
}
@@ -2304,14 +2350,14 @@ static bool run_locktest8(int dummy)
status = cli_close(cli1, fnum1);
if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr, "cli_close(fnum1) %s\n", cli_errstr(cli1));
+ d_fprintf(stderr, "cli_close(fnum1) %s\n", nt_errstr(status));
goto fail;
}
status = cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "cli_open third time returned %s\n",
- cli_errstr(cli1));
+ nt_errstr(status));
goto fail;
}
@@ -2320,7 +2366,7 @@ static bool run_locktest8(int dummy)
fail:
cli_close(cli1, fnum1);
cli_close(cli1, fnum2);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
torture_close_connection(cli1);
printf("finished locktest8\n");
@@ -2473,7 +2519,7 @@ static bool run_locktest9(int dummy)
status = cli_open(cli1, fname, O_RDWR, DENY_NONE,
&fnum);
if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr, "cli_open returned %s\n", cli_errstr(cli1));
+ d_fprintf(stderr, "cli_open returned %s\n", nt_errstr(status));
return false;
}
@@ -2514,7 +2560,7 @@ static bool run_locktest9(int dummy)
status = cli_close(cli1, fnum);
if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr, "cli_close(fnum1) %s\n", cli_errstr(cli1));
+ d_fprintf(stderr, "cli_close(fnum1) %s\n", nt_errstr(status));
goto fail;
}
@@ -2540,6 +2586,7 @@ static bool run_fdpasstest(int dummy)
const char *fname = "\\fdpass.tst";
uint16_t fnum1;
char buf[1024];
+ NTSTATUS status;
if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) {
return False;
@@ -2549,15 +2596,19 @@ static bool run_fdpasstest(int dummy)
printf("starting fdpasstest\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+ &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (cli_write(cli1, fnum1, 0, "hello world\n", 0, 13) != 13) {
- printf("write failed (%s)\n", cli_errstr(cli1));
+ status = cli_writeall(cli1, fnum1, 0, (const uint8_t *)"hello world\n", 0,
+ 13, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("write failed (%s)\n", nt_errstr(status));
return False;
}
@@ -2572,7 +2623,7 @@ static bool run_fdpasstest(int dummy)
}
cli_close(cli1, fnum1);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
torture_close_connection(cli1);
torture_close_connection(cli2);
@@ -2594,6 +2645,7 @@ static bool run_fdsesstest(int dummy)
uint16_t fnum2;
char buf[1024];
bool ret = True;
+ NTSTATUS status;
if (!torture_open_connection(&cli, 0))
return False;
@@ -2610,16 +2662,19 @@ static bool run_fdsesstest(int dummy)
printf("starting fdsesstest\n");
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli, fname1, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (cli_write(cli, fnum1, 0, "hello world\n", 0, 13) != 13) {
- printf("write failed (%s)\n", cli_errstr(cli));
+ status = cli_writeall(cli, fnum1, 0, (const uint8_t *)"hello world\n", 0, 13,
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("write failed (%s)\n", nt_errstr(status));
return False;
}
@@ -2635,7 +2690,7 @@ static bool run_fdsesstest(int dummy)
if (NT_STATUS_IS_OK(cli_open(cli, fname1, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum2))) {
printf("create with different vuid, same cnum succeeded.\n");
cli_close(cli, fnum2);
- cli_unlink(cli, fname1, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
} else {
printf("create with different vuid, same cnum failed.\n");
printf("This will cause problems with service clients.\n");
@@ -2655,7 +2710,7 @@ static bool run_fdsesstest(int dummy)
cli->cnum = saved_cnum;
cli_close(cli, fnum1);
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
torture_close_connection(cli);
@@ -2674,6 +2729,7 @@ static bool run_unlinktest(int dummy)
const char *fname = "\\unlink.tst";
uint16_t fnum;
bool correct = True;
+ NTSTATUS status;
if (!torture_open_connection(&cli, 0)) {
return False;
@@ -2683,16 +2739,17 @@ static bool run_unlinktest(int dummy)
printf("starting unlink test\n");
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_setpid(cli, 1);
- if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | aHIDDEN))) {
+ if (NT_STATUS_IS_OK(cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
printf("error: server allowed unlink on an open file\n");
correct = False;
} else {
@@ -2701,7 +2758,7 @@ static bool run_unlinktest(int dummy)
}
cli_close(cli, fnum);
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!torture_close_connection(cli)) {
correct = False;
@@ -2719,12 +2776,12 @@ test how many open files this server supports on the one socket
static bool run_maxfidtest(int dummy)
{
struct cli_state *cli;
- const char *ftemplate = "\\maxfid.%d.%d";
fstring fname;
uint16_t fnums[0x11000];
int i;
int retries=4;
bool correct = True;
+ NTSTATUS status;
cli = current_cli;
@@ -2736,11 +2793,12 @@ static bool run_maxfidtest(int dummy)
cli_sockopt(cli, sockops);
for (i=0; i<0x11000; i++) {
- slprintf(fname,sizeof(fname)-1,ftemplate, i,(int)getpid());
- if (!NT_STATUS_IS_OK(cli_open(cli, fname,
- O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnums[i]))) {
+ slprintf(fname,sizeof(fname)-1,"\\maxfid.%d.%d", i,(int)getpid());
+ status = cli_open(cli, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE,
+ &fnums[i]);
+ if (!NT_STATUS_IS_OK(status)) {
printf("open of %s failed (%s)\n",
- fname, cli_errstr(cli));
+ fname, nt_errstr(status));
printf("maximum fnum is %d\n", i);
break;
}
@@ -2751,11 +2809,13 @@ static bool run_maxfidtest(int dummy)
printf("cleaning up\n");
for (;i>=0;i--) {
- slprintf(fname,sizeof(fname)-1,ftemplate, i,(int)getpid());
+ slprintf(fname,sizeof(fname)-1,"\\maxfid.%d.%d", i,(int)getpid());
cli_close(cli, fnums[i]);
- if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | aHIDDEN))) {
+
+ status = cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
printf("unlink of %s failed (%s)\n",
- fname, cli_errstr(cli));
+ fname, nt_errstr(status));
correct = False;
}
printf("%6d\r", i);
@@ -2827,15 +2887,37 @@ static bool run_negprot_nowait(int dummy)
/* send smb negprot commands, not reading the response */
static bool run_bad_nbt_session(int dummy)
{
- static struct cli_state *cli;
+ struct nmb_name called, calling;
+ struct sockaddr_storage ss;
+ NTSTATUS status;
+ int fd;
+ bool ret;
printf("starting bad nbt session test\n");
- if (!(cli = open_bad_nbt_connection())) {
- return False;
+ make_nmb_name(&calling, myname, 0x0);
+ make_nmb_name(&called , host, 0x20);
+
+ if (!resolve_name(host, &ss, 0x20, true)) {
+ d_fprintf(stderr, "Could not resolve name %s\n", host);
+ return false;
+ }
+
+ status = open_socket_out(&ss, 139, 10000, &fd);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "open_socket_out failed: %s\n",
+ nt_errstr(status));
+ return false;
+ }
+
+ ret = cli_bad_session_request(fd, &calling, &called);
+ close(fd);
+ if (!ret) {
+ d_fprintf(stderr, "open_socket_out failed: %s\n",
+ nt_errstr(status));
+ return false;
}
- cli_shutdown(cli);
printf("finished bad nbt session test\n");
return true;
}
@@ -2942,6 +3024,7 @@ static bool run_attrtest(int dummy)
time_t t, t2;
const char *fname = "\\attrib123456789.tst";
bool correct = True;
+ NTSTATUS status;
printf("starting attrib test\n");
@@ -2949,12 +3032,14 @@ static bool run_attrtest(int dummy)
return False;
}
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_open(cli, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
cli_close(cli, fnum);
- if (!NT_STATUS_IS_OK(cli_getatr(cli, fname, NULL, NULL, &t))) {
- printf("getatr failed (%s)\n", cli_errstr(cli));
+
+ status = cli_getatr(cli, fname, NULL, NULL, &t);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("getatr failed (%s)\n", nt_errstr(status));
correct = False;
}
@@ -2967,13 +3052,15 @@ static bool run_attrtest(int dummy)
t2 = t-60*60*24; /* 1 day ago */
- if (!NT_STATUS_IS_OK(cli_setatr(cli, fname, 0, t2))) {
- printf("setatr failed (%s)\n", cli_errstr(cli));
+ status = cli_setatr(cli, fname, 0, t2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("setatr failed (%s)\n", nt_errstr(status));
correct = True;
}
- if (!NT_STATUS_IS_OK(cli_getatr(cli, fname, NULL, NULL, &t))) {
- printf("getatr failed (%s)\n", cli_errstr(cli));
+ status = cli_getatr(cli, fname, NULL, NULL, &t);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("getatr failed (%s)\n", nt_errstr(status));
correct = True;
}
@@ -2984,7 +3071,7 @@ static bool run_attrtest(int dummy)
correct = True;
}
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!torture_close_connection(cli)) {
correct = False;
@@ -3027,19 +3114,18 @@ static bool run_trans2test(int dummy)
correct = false;
}
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
- cli_open(cli, fname,
- O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
- if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
- cli, fnum, NULL, &size, &c_time_ts,
- &a_time_ts, &w_time_ts,
- &m_time_ts, NULL))) {
- printf("ERROR: qfileinfo failed (%s)\n", cli_errstr(cli));
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
+ status = cli_qfileinfo_basic(cli, fnum, NULL, &size, &c_time_ts,
+ &a_time_ts, &w_time_ts, &m_time_ts, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ERROR: qfileinfo failed (%s)\n", nt_errstr(status));
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_qfilename(cli, fnum, pname, sizeof(pname)))) {
- printf("ERROR: qfilename failed (%s)\n", cli_errstr(cli));
+ status = cli_qfilename(cli, fnum, pname, sizeof(pname));
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ERROR: qfilename failed (%s)\n", nt_errstr(status));
correct = False;
}
@@ -3053,10 +3139,11 @@ static bool run_trans2test(int dummy)
sleep(2);
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
- if (!NT_STATUS_IS_OK(cli_open(cli, fname,
- O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ status = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE,
+ &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
cli_close(cli, fnum);
@@ -3085,7 +3172,7 @@ static bool run_trans2test(int dummy)
}
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_open(cli, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
cli_close(cli, fnum);
@@ -3102,13 +3189,14 @@ static bool run_trans2test(int dummy)
}
}
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
/* check if the server updates the directory modification time
when creating a new file */
- if (!NT_STATUS_IS_OK(cli_mkdir(cli, dname))) {
- printf("ERROR: mkdir failed (%s)\n", cli_errstr(cli));
+ status = cli_mkdir(cli, dname);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ERROR: mkdir failed (%s)\n", nt_errstr(status));
correct = False;
}
sleep(3);
@@ -3121,7 +3209,7 @@ static bool run_trans2test(int dummy)
cli_open(cli, fname2,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
- cli_write(cli, fnum, 0, (char *)&fnum, 0, sizeof(fnum));
+ cli_writeall(cli, fnum, 0, (uint8_t *)&fnum, 0, sizeof(fnum), NULL);
cli_close(cli, fnum);
status = cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts,
&w_time_ts, &m_time2_ts, &size, NULL, NULL);
@@ -3135,7 +3223,7 @@ static bool run_trans2test(int dummy)
correct = False;
}
}
- cli_unlink(cli, fname2, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, dname);
if (!torture_close_connection(cli)) {
@@ -3213,6 +3301,7 @@ static bool run_oplock1(int dummy)
const char *fname = "\\lockt1.lck";
uint16_t fnum1;
bool correct = True;
+ NTSTATUS status;
printf("starting oplock test 1\n");
@@ -3220,29 +3309,33 @@ static bool run_oplock1(int dummy)
return False;
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_sockopt(cli1, sockops);
cli1->use_oplocks = True;
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+ &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
cli1->use_oplocks = False;
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close2 failed (%s)\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s)\n", cli_errstr(cli1));
+ status = cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s)\n", nt_errstr(status));
return False;
}
@@ -3264,6 +3357,7 @@ static bool run_oplock2(int dummy)
char buf[4];
bool correct = True;
volatile bool *shared_correct;
+ NTSTATUS status;
shared_correct = (volatile bool *)shm_setup(sizeof(bool));
*shared_correct = True;
@@ -3291,13 +3385,15 @@ static bool run_oplock2(int dummy)
cli2->use_oplocks = True;
cli2->use_level_II_oplocks = True;
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_sockopt(cli1, sockops);
cli_sockopt(cli2, sockops);
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+ &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -3307,16 +3403,18 @@ static bool run_oplock2(int dummy)
if (fork() == 0) {
/* Child code */
- if (!NT_STATUS_IS_OK(cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2))) {
- printf("second open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("second open of %s failed (%s)\n", fname, nt_errstr(status));
*shared_correct = False;
exit(0);
}
sleep(2);
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close2 failed (%s)\n", nt_errstr(status));
*shared_correct = False;
}
@@ -3356,22 +3454,17 @@ static bool run_oplock2(int dummy)
cli_read(cli1, fnum1, buf, 0, 4);
-#if 0
- if (cli_write(cli1, fnum1, 0, buf, 0, 4) != 4) {
- printf("write on fnum1 failed (%s)\n", cli_errstr(cli1));
- correct = False;
- }
-#endif
-
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close1 failed (%s)\n", nt_errstr(status));
correct = False;
}
sleep(4);
- if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s)\n", cli_errstr(cli1));
+ status = cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s)\n", nt_errstr(status));
correct = False;
}
@@ -3388,78 +3481,21 @@ static bool run_oplock2(int dummy)
return correct;
}
-/* handler for oplock 3 tests */
-static NTSTATUS oplock3_handler(struct cli_state *cli, uint16_t fnum, unsigned char level)
-{
- printf("got oplock break fnum=%d level=%d\n",
- fnum, level);
- return cli_oplock_ack(cli, fnum, level);
-}
-
-static bool run_oplock3(int dummy)
-{
+struct oplock4_state {
+ struct tevent_context *ev;
struct cli_state *cli;
- const char *fname = "\\oplockt3.dat";
- uint16_t fnum;
- char buf[4] = "abcd";
- bool correct = True;
- volatile bool *shared_correct;
-
- shared_correct = (volatile bool *)shm_setup(sizeof(bool));
- *shared_correct = True;
-
- printf("starting oplock test 3\n");
-
- if (fork() == 0) {
- /* Child code */
- use_oplocks = True;
- use_level_II_oplocks = True;
- if (!torture_open_connection(&cli, 0)) {
- *shared_correct = False;
- exit(0);
- }
- sleep(2);
- /* try to trigger a oplock break in parent */
- cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum);
- cli_write(cli, fnum, 0, buf, 0, 4);
- exit(0);
- }
-
- /* parent code */
- use_oplocks = True;
- use_level_II_oplocks = True;
- if (!torture_open_connection(&cli, 1)) { /* other is forked */
- return False;
- }
- cli_oplock_handler(cli, oplock3_handler);
- cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum);
- cli_write(cli, fnum, 0, buf, 0, 4);
- cli_close(cli, fnum);
- cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum);
- cli->timeout = 20000;
- cli_receive_smb(cli);
- printf("finished oplock test 3\n");
-
- return (correct && *shared_correct);
-
-/* What are we looking for here? What's sucess and what's FAILURE? */
-}
+ bool *got_break;
+ uint16_t *fnum2;
+};
-/* handler for oplock 4 tests */
-bool *oplock4_shared_correct;
-
-static NTSTATUS oplock4_handler(struct cli_state *cli, uint16_t fnum, unsigned char level)
-{
- printf("got oplock break fnum=%d level=%d\n",
- fnum, level);
- *oplock4_shared_correct = true;
- cli_oplock_ack(cli, fnum, level);
- return NT_STATUS_UNSUCCESSFUL; /* Cause cli_receive_smb to return. */
-}
+static void oplock4_got_break(struct tevent_req *req);
+static void oplock4_got_open(struct tevent_req *req);
static bool run_oplock4(int dummy)
{
+ struct tevent_context *ev;
struct cli_state *cli1, *cli2;
+ struct tevent_req *oplock_req, *open_req;
const char *fname = "\\lockt4.lck";
const char *fname_ln = "\\lockt4_ln.lck";
uint16_t fnum1, fnum2;
@@ -3467,8 +3503,9 @@ static bool run_oplock4(int dummy)
NTSTATUS status;
bool correct = true;
- oplock4_shared_correct = (bool *)shm_setup(sizeof(bool));
- *oplock4_shared_correct = false;
+ bool got_break;
+
+ struct oplock4_state *state;
printf("starting oplock test 4\n");
@@ -3484,32 +3521,37 @@ static bool run_oplock4(int dummy)
return false;
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli1, fname_ln, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli1, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_sockopt(cli1, sockops);
cli_sockopt(cli2, sockops);
/* Create the file. */
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+ &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return false;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close1 failed (%s)\n", nt_errstr(status));
return false;
}
/* Now create a hardlink. */
- if (!NT_STATUS_IS_OK(cli_nt_hardlink(cli1, fname, fname_ln))) {
- printf("nt hardlink failed (%s)\n", cli_errstr(cli1));
+ status = cli_nt_hardlink(cli1, fname, fname_ln);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("nt hardlink failed (%s)\n", nt_errstr(status));
return false;
}
/* Prove that opening hardlinks cause deny modes to conflict. */
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return false;
}
@@ -3526,8 +3568,9 @@ static bool run_oplock4(int dummy)
return false;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close1 failed (%s)\n", nt_errstr(status));
return false;
}
@@ -3537,44 +3580,78 @@ static bool run_oplock4(int dummy)
cli2->use_oplocks = true;
cli2->use_level_II_oplocks = true;
- cli_oplock_handler(cli1, oplock4_handler);
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return false;
}
- if (fork() == 0) {
- /* Child code */
- if (!NT_STATUS_IS_OK(cli_open(cli2, fname_ln, O_RDWR, DENY_NONE, &fnum2))) {
- printf("open of %s failed (%s)\n", fname_ln, cli_errstr(cli1));
- *oplock4_shared_correct = false;
- exit(0);
- }
+ ev = tevent_context_init(talloc_tos());
+ if (ev == NULL) {
+ printf("tevent_req_create failed\n");
+ return false;
+ }
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
- *oplock4_shared_correct = false;
- }
+ state = talloc(ev, struct oplock4_state);
+ if (state == NULL) {
+ printf("talloc failed\n");
+ return false;
+ }
+ state->ev = ev;
+ state->cli = cli1;
+ state->got_break = &got_break;
+ state->fnum2 = &fnum2;
+
+ oplock_req = cli_smb_oplock_break_waiter_send(
+ talloc_tos(), ev, cli1);
+ if (oplock_req == NULL) {
+ printf("cli_smb_oplock_break_waiter_send failed\n");
+ return false;
+ }
+ tevent_req_set_callback(oplock_req, oplock4_got_break, state);
- exit(0);
+ open_req = cli_open_send(
+ talloc_tos(), ev, cli2, fname_ln, O_RDWR, DENY_NONE);
+ if (oplock_req == NULL) {
+ printf("cli_open_send failed\n");
+ return false;
}
+ tevent_req_set_callback(open_req, oplock4_got_open, state);
- sleep(2);
+ got_break = false;
+ fnum2 = 0xffff;
- /* Process the oplock break. */
- cli_receive_smb(cli1);
+ while (!got_break || fnum2 == 0xffff) {
+ int ret;
+ ret = tevent_loop_once(ev);
+ if (ret == -1) {
+ printf("tevent_loop_once failed: %s\n",
+ strerror(errno));
+ return false;
+ }
+ }
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close2 failed (%s)\n", nt_errstr(status));
+ correct = false;
+ }
+
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close1 failed (%s)\n", nt_errstr(status));
correct = false;
}
- if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s)\n", cli_errstr(cli1));
+ status = cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s)\n", nt_errstr(status));
correct = false;
}
- if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname_ln, aSYSTEM | aHIDDEN))) {
- printf("unlink failed (%s)\n", cli_errstr(cli1));
+
+ status = cli_unlink(cli1, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink failed (%s)\n", nt_errstr(status));
correct = false;
}
@@ -3582,7 +3659,7 @@ static bool run_oplock4(int dummy)
correct = false;
}
- if (!*oplock4_shared_correct) {
+ if (!got_break) {
correct = false;
}
@@ -3591,6 +3668,43 @@ static bool run_oplock4(int dummy)
return correct;
}
+static void oplock4_got_break(struct tevent_req *req)
+{
+ struct oplock4_state *state = tevent_req_callback_data(
+ req, struct oplock4_state);
+ uint16_t fnum;
+ uint8_t level;
+ NTSTATUS status;
+
+ status = cli_smb_oplock_break_waiter_recv(req, &fnum, &level);
+ TALLOC_FREE(req);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_smb_oplock_break_waiter_recv returned %s\n",
+ nt_errstr(status));
+ return;
+ }
+ *state->got_break = true;
+
+ req = cli_oplock_ack_send(state, state->ev, state->cli, fnum,
+ NO_OPLOCK);
+ if (req == NULL) {
+ printf("cli_oplock_ack_send failed\n");
+ return;
+ }
+}
+
+static void oplock4_got_open(struct tevent_req *req)
+{
+ struct oplock4_state *state = tevent_req_callback_data(
+ req, struct oplock4_state);
+ NTSTATUS status;
+
+ status = cli_open_recv(req, state->fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_open_recv returned %s\n", nt_errstr(status));
+ *state->fnum2 = 0xffff;
+ }
+}
/*
Test delete on close semantics.
@@ -3603,6 +3717,7 @@ static bool run_deletetest(int dummy)
uint16_t fnum1 = (uint16_t)-1;
uint16_t fnum2 = (uint16_t)-1;
bool correct = True;
+ NTSTATUS status;
printf("starting delete test\n");
@@ -3615,18 +3730,20 @@ static bool run_deletetest(int dummy)
/* Test 1 - this should delete the file on close. */
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS, FILE_ATTRIBUTE_NORMAL,
- 0, FILE_OVERWRITE_IF,
- FILE_DELETE_ON_CLOSE, 0, &fnum1))) {
- printf("[1] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
+ FILE_DELETE_ON_CLOSE, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[1] open of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[1] close failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[1] close failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -3642,46 +3759,53 @@ static bool run_deletetest(int dummy)
/* Test 2 - this should delete the file on close. */
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS,
- FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("[2] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[2] open of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_nt_delete_on_close(cli1, fnum1, true))) {
- printf("[2] setting delete_on_close failed (%s)\n", cli_errstr(cli1));
+ status = cli_nt_delete_on_close(cli1, fnum1, true);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[2] setting delete_on_close failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[2] close failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[2] close failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
printf("[2] open of %s succeeded should have been deleted on close !\n", fname);
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[2] close failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[2] close failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
} else
printf("second delete on close test succeeded.\n");
/* Test 3 - ... */
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("[3] open - 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[3] open - 1 of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
@@ -3697,28 +3821,33 @@ static bool run_deletetest(int dummy)
}
/* This should succeed. */
-
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN, 0, 0, &fnum2))) {
- printf("[3] open - 2 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OPEN, 0, 0, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[3] open - 2 of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_nt_delete_on_close(cli1, fnum1, true))) {
- printf("[3] setting delete_on_close failed (%s)\n", cli_errstr(cli1));
+ status = cli_nt_delete_on_close(cli1, fnum1, true);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[3] setting delete_on_close failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[3] close 1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[3] close 1 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum2))) {
- printf("[3] close 2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[3] close 2 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -3727,10 +3856,11 @@ static bool run_deletetest(int dummy)
if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
printf("[3] open of %s succeeded should have been deleted on close !\n", fname);
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[3] close failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[3] close failed (%s)\n", nt_errstr(status));
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
correct = False;
goto fail;
} else
@@ -3738,31 +3868,40 @@ static bool run_deletetest(int dummy)
/* Test 4 ... */
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
- FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("[4] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0,
+ FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[4] open of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
/* This should succeed. */
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
- FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN, 0, 0, &fnum2))) {
- printf("[4] open - 2 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OPEN, 0, 0, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[4] open - 2 of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum2))) {
- printf("[4] close - 1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[4] close - 1 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_nt_delete_on_close(cli1, fnum1, true))) {
- printf("[4] setting delete_on_close failed (%s)\n", cli_errstr(cli1));
+ status = cli_nt_delete_on_close(cli1, fnum1, true);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[4] setting delete_on_close failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -3777,18 +3916,20 @@ static bool run_deletetest(int dummy)
} else
printf("fourth delete on close test succeeded.\n");
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[4] close - 2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[4] close - 2 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
/* Test 5 ... */
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum1))) {
- printf("[5] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[5] open of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
@@ -3801,8 +3942,9 @@ static bool run_deletetest(int dummy)
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[5] close - 2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[5] close - 2 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -3811,12 +3953,15 @@ static bool run_deletetest(int dummy)
/* Test 6 ... */
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA,
- FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("[6] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[6] open of %s failed (%s)\n", fname,
+ nt_errstr(status));
correct = False;
goto fail;
}
@@ -3829,8 +3974,9 @@ static bool run_deletetest(int dummy)
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[6] close - 2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[6] close - 2 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -3839,11 +3985,14 @@ static bool run_deletetest(int dummy)
/* Test 7 ... */
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
- FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("[7] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0,
+ FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
+ 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[7] open of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
@@ -3860,22 +4009,24 @@ static bool run_deletetest(int dummy)
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[7] close - 2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[7] close - 2 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
/* This next open should succeed - we reset the flag. */
-
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
- printf("[5] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[5] open of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[7] close - 2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[7] close - 2 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -3884,7 +4035,7 @@ static bool run_deletetest(int dummy)
/* Test 7 ... */
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!torture_open_connection(&cli2, 1)) {
printf("[8] failed to open second connection.\n");
@@ -3894,18 +4045,24 @@ static bool run_deletetest(int dummy)
cli_sockopt(cli1, sockops);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
- FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("[8] open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0,
+ FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[8] open 1 of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
- FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN, 0, 0, &fnum2))) {
- printf("[8] open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_ntcreate(cli2, fname, 0,
+ FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OPEN, 0, 0, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[8] open 2 of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
@@ -3916,20 +4073,23 @@ static bool run_deletetest(int dummy)
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[8] close - 1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[8] close - 1 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
- printf("[8] close - 2 failed (%s)\n", cli_errstr(cli2));
+ status = cli_close(cli2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[8] close - 2 failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
/* This should fail.. */
- if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
+ status = cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1);
+ if (NT_STATUS_IS_OK(status)) {
printf("[8] open of %s succeeded should have been deleted on close !\n", fname);
goto fail;
correct = False;
@@ -3946,16 +4106,21 @@ static bool run_deletetest(int dummy)
printf("ninth delete on close test succeeded.\n");
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
- FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE, FILE_OVERWRITE_IF, FILE_DELETE_ON_CLOSE, 0, &fnum1))) {
- printf("[10] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0,
+ FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, FILE_DELETE_ON_CLOSE,
+ 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[10] open of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
/* This should delete the file. */
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[10] close failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[10] close failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -3969,21 +4134,24 @@ static bool run_deletetest(int dummy)
printf("tenth delete on close test succeeded.\n");
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
/* What error do we get when attempting to open a read-only file with
delete access ? */
/* Create a readonly file. */
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA,
- FILE_ATTRIBUTE_READONLY, FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("[11] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA,
+ FILE_ATTRIBUTE_READONLY, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[11] open of %s failed (%s)\n", fname, nt_errstr(status));
correct = False;
goto fail;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("[11] close failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("[11] close failed (%s)\n", nt_errstr(status));
correct = False;
goto fail;
}
@@ -4017,7 +4185,7 @@ static bool run_deletetest(int dummy)
if (fnum1 != (uint16_t)-1) cli_close(cli1, fnum1);
if (fnum2 != (uint16_t)-1) cli_close(cli1, fnum2);
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (cli1 && !torture_close_connection(cli1)) {
correct = False;
@@ -4045,25 +4213,28 @@ static bool run_deletetest_ln(int dummy)
return false;
}
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli, fname_ln, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_sockopt(cli, sockops);
/* Create the file. */
- if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return false;
}
- if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
- printf("close1 failed (%s)\n", cli_errstr(cli));
+ status = cli_close(cli, fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close1 failed (%s)\n", nt_errstr(status));
return false;
}
/* Now create a hardlink. */
- if (!NT_STATUS_IS_OK(cli_nt_hardlink(cli, fname, fname_ln))) {
- printf("nt hardlink failed (%s)\n", cli_errstr(cli));
+ status = cli_nt_hardlink(cli, fname, fname_ln);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("nt hardlink failed (%s)\n", nt_errstr(status));
return false;
}
@@ -4127,8 +4298,8 @@ static bool run_deletetest_ln(int dummy)
correct = False;
}
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli, fname_ln, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!torture_close_connection(cli)) {
correct = false;
@@ -4196,6 +4367,7 @@ static bool run_xcopy(int dummy)
const char *fname = "\\test.txt";
bool correct = True;
uint16_t fnum1, fnum2;
+ NTSTATUS status;
printf("starting xcopy test\n");
@@ -4203,19 +4375,19 @@ static bool run_xcopy(int dummy)
return False;
}
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0,
- FIRST_DESIRED_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF,
- 0x4044, 0, &fnum1))) {
- printf("First open failed - %s\n", cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, FIRST_DESIRED_ACCESS,
+ FILE_ATTRIBUTE_ARCHIVE, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0x4044, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("First open failed - %s\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0,
- SECOND_DESIRED_ACCESS, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN,
- 0x200000, 0, &fnum2))) {
- printf("second open failed - %s\n", cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, SECOND_DESIRED_ACCESS, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OPEN, 0x200000, 0, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("second open failed - %s\n", nt_errstr(status));
return False;
}
@@ -4245,28 +4417,33 @@ static bool run_rename(int dummy)
return False;
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("First open failed - %s\n", cli_errstr(cli1));
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+
+ status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("First open failed - %s\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_rename(cli1, fname, fname1))) {
- printf("First rename failed (SHARE_READ) (this is correct) - %s\n", cli_errstr(cli1));
+ status = cli_rename(cli1, fname, fname1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("First rename failed (SHARE_READ) (this is correct) - %s\n", nt_errstr(status));
} else {
printf("First rename succeeded (SHARE_READ) - this should have failed !\n");
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close - 1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close - 1 failed (%s)\n", nt_errstr(status));
return False;
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
#if 0
FILE_SHARE_DELETE|FILE_SHARE_NONE,
@@ -4275,28 +4452,32 @@ static bool run_rename(int dummy)
#endif
FILE_OVERWRITE_IF, 0, 0, &fnum1);
if (!NT_STATUS_IS_OK(status)) {
- printf("Second open failed - %s\n", cli_errstr(cli1));
+ printf("Second open failed - %s\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_rename(cli1, fname, fname1))) {
- printf("Second rename failed (SHARE_DELETE | SHARE_READ) - this should have succeeded - %s\n", cli_errstr(cli1));
+ status = cli_rename(cli1, fname, fname1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Second rename failed (SHARE_DELETE | SHARE_READ) - this should have succeeded - %s\n", nt_errstr(status));
correct = False;
} else {
printf("Second rename succeeded (SHARE_DELETE | SHARE_READ)\n");
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close - 2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close - 2 failed (%s)\n", nt_errstr(status));
return False;
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, READ_CONTROL_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("Third open failed - %s\n", cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, READ_CONTROL_ACCESS,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Third open failed - %s\n", nt_errstr(status));
return False;
}
@@ -4322,58 +4503,68 @@ static bool run_rename(int dummy)
}
#endif
- if (!NT_STATUS_IS_OK(cli_rename(cli1, fname, fname1))) {
- printf("Third rename failed (SHARE_NONE) - this should have succeeded - %s\n", cli_errstr(cli1));
+ status = cli_rename(cli1, fname, fname1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Third rename failed (SHARE_NONE) - this should have succeeded - %s\n", nt_errstr(status));
correct = False;
} else {
printf("Third rename succeeded (SHARE_NONE)\n");
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close - 3 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close - 3 failed (%s)\n", nt_errstr(status));
return False;
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
/*----*/
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("Fourth open failed - %s\n", cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Fourth open failed - %s\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_rename(cli1, fname, fname1))) {
- printf("Fourth rename failed (SHARE_READ | SHARE_WRITE) (this is correct) - %s\n", cli_errstr(cli1));
+ status = cli_rename(cli1, fname, fname1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Fourth rename failed (SHARE_READ | SHARE_WRITE) (this is correct) - %s\n", nt_errstr(status));
} else {
printf("Fourth rename succeeded (SHARE_READ | SHARE_WRITE) - this should have failed !\n");
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close - 4 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close - 4 failed (%s)\n", nt_errstr(status));
return False;
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
/*--*/
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("Fifth open failed - %s\n", cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Fifth open failed - %s\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_rename(cli1, fname, fname1))) {
- printf("Fifth rename failed (SHARE_READ | SHARE_WRITE | SHARE_DELETE) - this should have succeeded - %s ! \n",
- cli_errstr(cli1));
+ status = cli_rename(cli1, fname, fname1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Fifth rename failed (SHARE_READ | SHARE_WRITE | SHARE_DELETE) - this should have succeeded - %s ! \n", nt_errstr(status));
correct = False;
} else {
- printf("Fifth rename succeeded (SHARE_READ | SHARE_WRITE | SHARE_DELETE) (this is correct) - %s\n", cli_errstr(cli1));
+ printf("Fifth rename succeeded (SHARE_READ | SHARE_WRITE | SHARE_DELETE) (this is correct) - %s\n", nt_errstr(status));
}
/*
@@ -4391,16 +4582,17 @@ static bool run_rename(int dummy)
} */
/*--*/
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close - 5 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close - 5 failed (%s)\n", nt_errstr(status));
return False;
}
/* Check that the renamed file has FILE_ATTRIBUTE_ARCHIVE. */
- if (!NT_STATUS_IS_OK(cli_getatr(cli1, fname1, &attr, NULL, NULL))) {
+ status = cli_getatr(cli1, fname1, &attr, NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
printf("getatr on file %s failed - %s ! \n",
- fname1,
- cli_errstr(cli1));
+ fname1, nt_errstr(status));
correct = False;
} else {
if (attr != FILE_ATTRIBUTE_ARCHIVE) {
@@ -4415,8 +4607,8 @@ static bool run_rename(int dummy)
}
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
- cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!torture_close_connection(cli1)) {
correct = False;
@@ -4431,6 +4623,7 @@ static bool run_pipe_number(int dummy)
const char *pipe_name = "\\SPOOLSS";
uint16_t fnum;
int num_pipes = 0;
+ NTSTATUS status;
printf("starting pipenumber test\n");
if (!torture_open_connection(&cli1, 0)) {
@@ -4439,9 +4632,12 @@ static bool run_pipe_number(int dummy)
cli_sockopt(cli1, sockops);
while(1) {
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, pipe_name, 0, FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN_IF, 0, 0, &fnum))) {
- printf("Open of pipe %s failed with error (%s)\n", pipe_name, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, pipe_name, 0, FILE_READ_DATA,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_OPEN_IF, 0, 0, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Open of pipe %s failed with error (%s)\n", pipe_name, nt_errstr(status));
break;
}
num_pipes++;
@@ -4475,27 +4671,31 @@ static bool run_opentest(int dummy)
}
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_sockopt(cli1, sockops);
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close2 failed (%s)\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, aRONLY, 0))) {
- printf("cli_setatr failed (%s)\n", cli_errstr(cli1));
+ status = cli_setatr(cli1, fname, FILE_ATTRIBUTE_READONLY, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_setatr failed (%s)\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -4515,8 +4715,9 @@ static bool run_opentest(int dummy)
cli_setatr(cli1, fname, 0, 0);
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -4528,19 +4729,20 @@ static bool run_opentest(int dummy)
printf("correct error code ERRDOS/ERRbadshare returned\n");
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close2 failed (%s)\n", nt_errstr(status));
return False;
}
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
printf("finished open test 2\n");
/* Test truncate open disposition on file opened for read. */
-
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
- printf("(3) open (1) of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("(3) open (1) of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -4548,19 +4750,22 @@ static bool run_opentest(int dummy)
memset(buf, '\0', 20);
- if (cli_write(cli1, fnum1, 0, buf, 0, 20) != 20) {
- printf("write failed (%s)\n", cli_errstr(cli1));
+ status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, 20, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("write failed (%s)\n", nt_errstr(status));
correct = False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("(3) close1 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("(3) close1 failed (%s)\n", nt_errstr(status));
return False;
}
/* Ensure size == 20. */
- if (!NT_STATUS_IS_OK(cli_getatr(cli1, fname, NULL, &fsize, NULL))) {
- printf("(3) getatr failed (%s)\n", cli_errstr(cli1));
+ status = cli_getatr(cli1, fname, NULL, &fsize, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("(3) getatr failed (%s)\n", nt_errstr(status));
return False;
}
@@ -4570,20 +4775,22 @@ static bool run_opentest(int dummy)
}
/* Now test if we can truncate a file opened for readonly. */
-
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY|O_TRUNC, DENY_NONE, &fnum1))) {
- printf("(3) open (2) of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDONLY|O_TRUNC, DENY_NONE, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("(3) open (2) of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close2 failed (%s)\n", nt_errstr(status));
return False;
}
/* Ensure size == 0. */
- if (!NT_STATUS_IS_OK(cli_getatr(cli1, fname, NULL, &fsize, NULL))) {
- printf("(3) getatr failed (%s)\n", cli_errstr(cli1));
+ status = cli_getatr(cli1, fname, NULL, &fsize, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("(3) getatr failed (%s)\n", nt_errstr(status));
return False;
}
@@ -4593,19 +4800,24 @@ static bool run_opentest(int dummy)
}
printf("finished open test 3\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
printf("Do ctemp tests\n");
- if (!NT_STATUS_IS_OK(cli_ctemp(cli1, talloc_tos(), "\\", &fnum1, &tmp_path))) {
- printf("ctemp failed (%s)\n", cli_errstr(cli1));
+ status = cli_ctemp(cli1, talloc_tos(), "\\", &fnum1, &tmp_path);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ctemp failed (%s)\n", nt_errstr(status));
return False;
}
+
printf("ctemp gave path %s\n", tmp_path);
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close of temp failed (%s)\n", cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close of temp failed (%s)\n", nt_errstr(status));
}
- if (!NT_STATUS_IS_OK(cli_unlink(cli1, tmp_path, aSYSTEM | aHIDDEN))) {
- printf("unlink of temp failed (%s)\n", cli_errstr(cli1));
+
+ status = cli_unlink(cli1, tmp_path, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("unlink of temp failed (%s)\n", nt_errstr(status));
}
/* Test the non-io opens... */
@@ -4615,137 +4827,174 @@ static bool run_opentest(int dummy)
}
cli_setatr(cli2, fname, 0, 0);
- cli_unlink(cli2, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli2, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_sockopt(cli2, sockops);
printf("TEST #1 testing 2 non-io opens (no delete)\n");
-
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("TEST #1 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #1 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) {
- printf("TEST #1 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OPEN_IF, 0, 0, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #1 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("TEST #1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #1 close 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
- printf("TEST #1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+
+ status = cli_close(cli2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #1 close 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
printf("non-io open test #1 passed.\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
printf("TEST #2 testing 2 non-io opens (first with delete)\n");
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("TEST #2 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0,
+ DELETE_ACCESS|FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #2 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) {
- printf("TEST #2 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OPEN_IF, 0, 0, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #2 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("TEST #2 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #2 close 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
- printf("TEST #2 close 2 of %s failed (%s)\n", fname, cli_errstr(cli1));
+
+ status = cli_close(cli2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #2 close 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
printf("non-io open test #2 passed.\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
printf("TEST #3 testing 2 non-io opens (second with delete)\n");
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("TEST #3 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #3 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) {
- printf("TEST #3 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_ntcreate(cli2, fname, 0,
+ DELETE_ACCESS|FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OPEN_IF, 0, 0, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #3 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("TEST #3 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #3 close 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
- printf("TEST #3 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+
+ status = cli_close(cli2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #3 close 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
printf("non-io open test #3 passed.\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
printf("TEST #4 testing 2 non-io opens (both with delete)\n");
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("TEST #4 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0,
+ DELETE_ACCESS|FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #4 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) {
- printf("TEST #4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_ntcreate(cli2, fname, 0,
+ DELETE_ACCESS|FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OPEN_IF, 0, 0, &fnum2);
+ if (NT_STATUS_IS_OK(status)) {
+ printf("TEST #4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, nt_errstr(status));
return False;
}
- printf("TEST #4 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");
+ printf("TEST #4 open 2 of %s gave %s (correct error should be %s)\n", fname, nt_errstr(status), "sharing violation");
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("TEST #4 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #4 close 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
printf("non-io open test #4 passed.\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
printf("TEST #5 testing 2 non-io opens (both with delete - both with file share delete)\n");
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("TEST #5 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0,
+ DELETE_ACCESS|FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_DELETE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #5 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_DELETE, FILE_OPEN_IF, 0, 0, &fnum2))) {
- printf("TEST #5 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_ntcreate(cli2, fname, 0,
+ DELETE_ACCESS|FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_DELETE,
+ FILE_OPEN_IF, 0, 0, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #5 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("TEST #5 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #5 close 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
- printf("TEST #5 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_close(cli2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #5 close 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -4753,27 +5002,33 @@ static bool run_opentest(int dummy)
printf("TEST #6 testing 1 non-io open, one io open\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("TEST #6 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, FILE_READ_DATA,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #6 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ, FILE_OPEN_IF, 0, 0, &fnum2))) {
- printf("TEST #6 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ,
+ FILE_OPEN_IF, 0, 0, &fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #6 open 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("TEST #6 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #6 close 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
- printf("TEST #6 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_close(cli2, fnum2);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #6 close 2 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -4781,30 +5036,37 @@ static bool run_opentest(int dummy)
printf("TEST #7 testing 1 non-io open, one io open with delete\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("TEST #7 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_ntcreate(cli1, fname, 0, FILE_READ_DATA,
+ FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #7 open 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
- if (NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
- FILE_SHARE_READ|FILE_SHARE_DELETE, FILE_OPEN_IF, 0, 0, &fnum2))) {
- printf("TEST #7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));
+ status = cli_ntcreate(cli2, fname, 0,
+ DELETE_ACCESS|FILE_READ_ATTRIBUTES,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ|FILE_SHARE_DELETE,
+ FILE_OPEN_IF, 0, 0, &fnum2);
+ if (NT_STATUS_IS_OK(status)) {
+ printf("TEST #7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, nt_errstr(status));
return False;
}
- printf("TEST #7 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");
+ printf("TEST #7 open 2 of %s gave %s (correct error should be %s)\n", fname, nt_errstr(status), "sharing violation");
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("TEST #7 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #7 close 1 of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
printf("non-io open test #7 passed.\n");
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
printf("TEST #8 testing open without WRITE_ATTRIBUTES, updating close write time.\n");
status = cli_ntcreate(cli1, fname, 0, FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL,
@@ -4817,8 +5079,10 @@ static bool run_opentest(int dummy)
}
/* Write to ensure we have to update the file time. */
- if (cli_write(cli1, fnum1, 0, "TEST DATA\n", 0, 10) != 10) {
- printf("TEST #8 cli_write failed: %s\n", cli_errstr(cli1));
+ status = cli_writeall(cli1, fnum1, 0, (const uint8_t *)"TEST DATA\n", 0, 10,
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("TEST #8 cli_write failed: %s\n", nt_errstr(status));
correct = false;
goto out;
}
@@ -4911,11 +5175,79 @@ static bool run_simple_posix_open_test(int dummy)
cli_posix_unlink(cli1, sname);
/* Create a directory. */
- if (!NT_STATUS_IS_OK(cli_posix_mkdir(cli1, dname, 0777))) {
- printf("POSIX mkdir of %s failed (%s)\n", dname, cli_errstr(cli1));
+ status = cli_posix_mkdir(cli1, dname, 0777);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX mkdir of %s failed (%s)\n", dname, nt_errstr(status));
+ goto out;
+ }
+
+ status = cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL,
+ 0600, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX create of %s failed (%s)\n", fname, nt_errstr(status));
goto out;
}
+ /* Test ftruncate - set file size. */
+ status = cli_ftruncate(cli1, fnum1, 1000);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ftruncate failed (%s)\n", nt_errstr(status));
+ goto out;
+ }
+
+ /* Ensure st_size == 1000 */
+ status = cli_posix_stat(cli1, fname, &sbuf);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("stat failed (%s)\n", nt_errstr(status));
+ goto out;
+ }
+
+ if (sbuf.st_ex_size != 1000) {
+ printf("ftruncate - stat size (%u) != 1000\n", (unsigned int)sbuf.st_ex_size);
+ goto out;
+ }
+
+ /* Test ftruncate - set file size back to zero. */
+ status = cli_ftruncate(cli1, fnum1, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ftruncate failed (%s)\n", nt_errstr(status));
+ goto out;
+ }
+
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close failed (%s)\n", nt_errstr(status));
+ goto out;
+ }
+
+ /* Now open the file again for read only. */
+ status = cli_posix_open(cli1, fname, O_RDONLY, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX open of %s failed (%s)\n", fname, nt_errstr(status));
+ goto out;
+ }
+
+ /* Now unlink while open. */
+ status = cli_posix_unlink(cli1, fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX unlink of %s failed (%s)\n", fname, nt_errstr(status));
+ goto out;
+ }
+
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close(2) failed (%s)\n", nt_errstr(status));
+ goto out;
+ }
+
+ /* Ensure the file has gone. */
+ status = cli_posix_open(cli1, fname, O_RDONLY, 0, &fnum1);
+ if (NT_STATUS_IS_OK(status)) {
+ printf("POSIX open of %s succeeded, should have been deleted.\n", fname);
+ goto out;
+ }
+
+ /* Create again to test open with O_TRUNC. */
if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, 0600, &fnum1))) {
printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1));
goto out;
@@ -4938,42 +5270,48 @@ static bool run_simple_posix_open_test(int dummy)
goto out;
}
- /* Test ftruncate - set file size back to zero. */
- if (!NT_STATUS_IS_OK(cli_ftruncate(cli1, fnum1, 0))) {
- printf("ftruncate failed (%s)\n", cli_errstr(cli1));
+ if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
+ printf("close(2) failed (%s)\n", cli_errstr(cli1));
goto out;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close failed (%s)\n", cli_errstr(cli1));
+ /* Re-open with O_TRUNC. */
+ if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_WRONLY|O_TRUNC, 0600, &fnum1))) {
+ printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1));
goto out;
}
- /* Now open the file again for read only. */
- if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_RDONLY, 0, &fnum1))) {
- printf("POSIX open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ /* Ensure st_size == 0 */
+ if (!NT_STATUS_IS_OK(cli_posix_stat(cli1, fname, &sbuf))) {
+ printf("stat failed (%s)\n", cli_errstr(cli1));
goto out;
}
- /* Now unlink while open. */
- if (!NT_STATUS_IS_OK(cli_posix_unlink(cli1, fname))) {
- printf("POSIX unlink of %s failed (%s)\n", fname, cli_errstr(cli1));
+ if (sbuf.st_ex_size != 0) {
+ printf("O_TRUNC - stat size (%u) != 0\n", (unsigned int)sbuf.st_ex_size);
goto out;
}
if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close(2) failed (%s)\n", cli_errstr(cli1));
+ printf("close failed (%s)\n", cli_errstr(cli1));
goto out;
}
- /* Ensure the file has gone. */
- if (NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_RDONLY, 0, &fnum1))) {
- printf("POSIX open of %s succeeded, should have been deleted.\n", fname);
+ if (!NT_STATUS_IS_OK(cli_posix_unlink(cli1, fname))) {
+ printf("POSIX unlink of %s failed (%s)\n", fname, cli_errstr(cli1));
+ goto out;
+ }
+
+ if (!NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) {
+ printf("POSIX open directory O_RDONLY of %s failed (%s)\n",
+ dname, cli_errstr(cli1));
goto out;
}
- /* What happens when we try and POSIX open a directory ? */
- if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) {
+ cli_close(cli1, fnum1);
+
+ /* What happens when we try and POSIX open a directory for write ? */
+ if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDWR, 0, &fnum1))) {
printf("POSIX open of directory %s succeeded, should have failed.\n", fname);
goto out;
} else {
@@ -4984,34 +5322,41 @@ static bool run_simple_posix_open_test(int dummy)
}
/* Create the file. */
- if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, 0600, &fnum1))) {
- printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1));
+ status = cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL,
+ 0600, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX create of %s failed (%s)\n", fname, nt_errstr(status));
goto out;
}
/* Write some data into it. */
- if (cli_write(cli1, fnum1, 0, "TEST DATA\n", 0, 10) != 10) {
- printf("cli_write failed: %s\n", cli_errstr(cli1));
+ status = cli_writeall(cli1, fnum1, 0, (const uint8_t *)"TEST DATA\n", 0, 10,
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_write failed: %s\n", nt_errstr(status));
goto out;
}
cli_close(cli1, fnum1);
/* Now create a hardlink. */
- if (!NT_STATUS_IS_OK(cli_posix_hardlink(cli1, fname, hname))) {
- printf("POSIX hardlink of %s failed (%s)\n", hname, cli_errstr(cli1));
+ status = cli_posix_hardlink(cli1, fname, hname);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX hardlink of %s failed (%s)\n", hname, nt_errstr(status));
goto out;
}
/* Now create a symlink. */
- if (!NT_STATUS_IS_OK(cli_posix_symlink(cli1, fname, sname))) {
- printf("POSIX symlink of %s failed (%s)\n", sname, cli_errstr(cli1));
+ status = cli_posix_symlink(cli1, fname, sname);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX symlink of %s failed (%s)\n", sname, nt_errstr(status));
goto out;
}
/* Open the hardlink for read. */
- if (!NT_STATUS_IS_OK(cli_posix_open(cli1, hname, O_RDONLY, 0, &fnum1))) {
- printf("POSIX open of %s failed (%s)\n", hname, cli_errstr(cli1));
+ status = cli_posix_open(cli1, hname, O_RDONLY, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX open of %s failed (%s)\n", hname, nt_errstr(status));
goto out;
}
@@ -5026,14 +5371,16 @@ static bool run_simple_posix_open_test(int dummy)
}
/* Do a POSIX lock/unlock. */
- if (!NT_STATUS_IS_OK(cli_posix_lock(cli1, fnum1, 0, 100, true, READ_LOCK))) {
- printf("POSIX lock failed %s\n", cli_errstr(cli1));
+ status = cli_posix_lock(cli1, fnum1, 0, 100, true, READ_LOCK);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX lock failed %s\n", nt_errstr(status));
goto out;
}
/* Punch a hole in the locked area. */
- if (!NT_STATUS_IS_OK(cli_posix_unlock(cli1, fnum1, 10, 80))) {
- printf("POSIX unlock failed %s\n", cli_errstr(cli1));
+ status = cli_posix_unlock(cli1, fnum1, 10, 80);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX unlock failed %s\n", nt_errstr(status));
goto out;
}
@@ -5041,7 +5388,8 @@ static bool run_simple_posix_open_test(int dummy)
/* Open the symlink for read - this should fail. A POSIX
client should not be doing opens on a symlink. */
- if (NT_STATUS_IS_OK(cli_posix_open(cli1, sname, O_RDONLY, 0, &fnum1))) {
+ status = cli_posix_open(cli1, sname, O_RDONLY, 0, &fnum1);
+ if (NT_STATUS_IS_OK(status)) {
printf("POSIX open of %s succeeded (should have failed)\n", sname);
goto out;
} else {
@@ -5050,13 +5398,14 @@ static bool run_simple_posix_open_test(int dummy)
printf("POSIX open of %s should have failed "
"with NT_STATUS_OBJECT_PATH_NOT_FOUND, "
"failed with %s instead.\n",
- sname, cli_errstr(cli1));
+ sname, nt_errstr(status));
goto out;
}
}
- if (!NT_STATUS_IS_OK(cli_posix_readlink(cli1, sname, namebuf, sizeof(namebuf)))) {
- printf("POSIX readlink on %s failed (%s)\n", sname, cli_errstr(cli1));
+ status = cli_posix_readlink(cli1, sname, namebuf, sizeof(namebuf));
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX readlink on %s failed (%s)\n", sname, nt_errstr(status));
goto out;
}
@@ -5066,8 +5415,9 @@ static bool run_simple_posix_open_test(int dummy)
goto out;
}
- if (!NT_STATUS_IS_OK(cli_posix_rmdir(cli1, dname))) {
- printf("POSIX rmdir failed (%s)\n", cli_errstr(cli1));
+ status = cli_posix_rmdir(cli1, dname);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("POSIX rmdir failed (%s)\n", nt_errstr(status));
goto out;
}
@@ -5162,6 +5512,7 @@ static bool run_openattrtest(int dummy)
bool correct = True;
uint16 attr;
unsigned int i, j, k, l;
+ NTSTATUS status;
printf("starting open attr test\n");
@@ -5173,34 +5524,43 @@ static bool run_openattrtest(int dummy)
for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32); i++) {
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_WRITE_DATA, open_attrs_table[i],
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
- printf("open %d (1) of %s failed (%s)\n", i, fname, cli_errstr(cli1));
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+
+ status = cli_ntcreate(cli1, fname, 0, FILE_WRITE_DATA,
+ open_attrs_table[i], FILE_SHARE_NONE,
+ FILE_OVERWRITE_IF, 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open %d (1) of %s failed (%s)\n", i, fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close %d (1) of %s failed (%s)\n", i, fname, cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close %d (1) of %s failed (%s)\n", i, fname, nt_errstr(status));
return False;
}
for (j = 0; j < sizeof(open_attrs_table)/sizeof(uint32); j++) {
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA, open_attrs_table[j],
- FILE_SHARE_NONE, FILE_OVERWRITE, 0, 0, &fnum1))) {
+ status = cli_ntcreate(cli1, fname, 0,
+ FILE_READ_DATA|FILE_WRITE_DATA,
+ open_attrs_table[j],
+ FILE_SHARE_NONE, FILE_OVERWRITE,
+ 0, 0, &fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
for (l = 0; l < sizeof(attr_results)/sizeof(struct trunc_open_results); l++) {
if (attr_results[l].num == k) {
printf("[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(0x%x:%s)\n",
k, open_attrs_table[i],
open_attrs_table[j],
- fname, NT_STATUS_V(cli_nt_error(cli1)), cli_errstr(cli1));
+ fname, NT_STATUS_V(status), nt_errstr(status));
correct = False;
}
}
- if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_ACCESS_DENIED)) {
+
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
printf("[%d] trunc open 0x%x -> 0x%x failed with wrong error code %s\n",
k, open_attrs_table[i], open_attrs_table[j],
- cli_errstr(cli1));
+ nt_errstr(status));
correct = False;
}
#if 0
@@ -5210,13 +5570,15 @@ static bool run_openattrtest(int dummy)
continue;
}
- if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
- printf("close %d (2) of %s failed (%s)\n", j, fname, cli_errstr(cli1));
+ status = cli_close(cli1, fnum1);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close %d (2) of %s failed (%s)\n", j, fname, nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_getatr(cli1, fname, &attr, NULL, NULL))) {
- printf("getatr(2) failed (%s)\n", cli_errstr(cli1));
+ status = cli_getatr(cli1, fname, &attr, NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("getatr(2) failed (%s)\n", nt_errstr(status));
return False;
}
@@ -5245,7 +5607,7 @@ static bool run_openattrtest(int dummy)
}
cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
printf("open attr test %s.\n", correct ? "passed" : "failed");
@@ -5316,7 +5678,7 @@ static bool run_dirtest(int dummy)
for (i=0;i<torture_numops;i++) {
fstring fname;
slprintf(fname, sizeof(fname), "\\%x", (int)random());
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
}
if (!torture_close_connection(cli)) {
@@ -5338,11 +5700,11 @@ static NTSTATUS del_fn(const char *mnt, struct file_info *finfo, const char *mas
if (strcmp(finfo->name, ".") == 0 || strcmp(finfo->name, "..") == 0)
return NT_STATUS_OK;
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
if (!NT_STATUS_IS_OK(cli_rmdir(pcli, fname)))
printf("del_fn: failed to rmdir %s\n,", fname );
} else {
- if (!NT_STATUS_IS_OK(cli_unlink(pcli, fname, aSYSTEM | aHIDDEN)))
+ if (!NT_STATUS_IS_OK(cli_unlink(pcli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN)))
printf("del_fn: failed to unlink %s\n,", fname );
}
return NT_STATUS_OK;
@@ -5367,10 +5729,11 @@ bool torture_ioctl_test(int dummy)
printf("starting ioctl test\n");
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
- if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open of %s failed (%s)\n", fname, nt_errstr(status));
return False;
}
@@ -5411,6 +5774,7 @@ bool torture_chkpath_test(int dummy)
static struct cli_state *cli;
uint16_t fnum;
bool ret;
+ NTSTATUS status;
if (!torture_open_connection(&cli, 0)) {
return False;
@@ -5420,36 +5784,43 @@ bool torture_chkpath_test(int dummy)
/* cleanup from an old run */
cli_rmdir(cli, "\\chkpath.dir\\dir2");
- cli_unlink(cli, "\\chkpath.dir\\*", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\chkpath.dir\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, "\\chkpath.dir");
- if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\chkpath.dir"))) {
- printf("mkdir1 failed : %s\n", cli_errstr(cli));
+ status = cli_mkdir(cli, "\\chkpath.dir");
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("mkdir1 failed : %s\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\chkpath.dir\\dir2"))) {
- printf("mkdir2 failed : %s\n", cli_errstr(cli));
+ status = cli_mkdir(cli, "\\chkpath.dir\\dir2");
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("mkdir2 failed : %s\n", nt_errstr(status));
return False;
}
- if (!NT_STATUS_IS_OK(cli_open(cli, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
- printf("open1 failed (%s)\n", cli_errstr(cli));
+ status = cli_open(cli, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL,
+ DENY_NONE, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open1 failed (%s)\n", nt_errstr(status));
return False;
}
cli_close(cli, fnum);
- if (!NT_STATUS_IS_OK(cli_chkpath(cli, "\\chkpath.dir"))) {
- printf("chkpath1 failed: %s\n", cli_errstr(cli));
+ status = cli_chkpath(cli, "\\chkpath.dir");
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("chkpath1 failed: %s\n", nt_errstr(status));
ret = False;
}
- if (!NT_STATUS_IS_OK(cli_chkpath(cli, "\\chkpath.dir\\dir2"))) {
- printf("chkpath2 failed: %s\n", cli_errstr(cli));
+ status = cli_chkpath(cli, "\\chkpath.dir\\dir2");
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("chkpath2 failed: %s\n", nt_errstr(status));
ret = False;
}
- if (!NT_STATUS_IS_OK(cli_chkpath(cli, "\\chkpath.dir\\foo.txt"))) {
+ status = cli_chkpath(cli, "\\chkpath.dir\\foo.txt");
+ if (!NT_STATUS_IS_OK(status)) {
ret = check_error(__LINE__, cli, ERRDOS, ERRbadpath,
NT_STATUS_NOT_A_DIRECTORY);
} else {
@@ -5474,7 +5845,7 @@ bool torture_chkpath_test(int dummy)
}
cli_rmdir(cli, "\\chkpath.dir\\dir2");
- cli_unlink(cli, "\\chkpath.dir\\*", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\chkpath.dir\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, "\\chkpath.dir");
if (!torture_close_connection(cli)) {
@@ -5503,12 +5874,14 @@ static bool run_eatest(int dummy)
return False;
}
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli, fname, 0,
- FIRST_DESIRED_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
- FILE_SHARE_NONE, FILE_OVERWRITE_IF,
- 0x4044, 0, &fnum))) {
- printf("open failed - %s\n", cli_errstr(cli));
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+
+ status = cli_ntcreate(cli, fname, 0,
+ FIRST_DESIRED_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
+ FILE_SHARE_NONE, FILE_OVERWRITE_IF,
+ 0x4044, 0, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open failed - %s\n", nt_errstr(status));
talloc_destroy(mem_ctx);
return False;
}
@@ -5631,7 +6004,7 @@ static bool run_dirtest1(int dummy)
cli_sockopt(cli, sockops);
cli_list(cli, "\\LISTDIR\\*", 0, del_fn, cli);
- cli_list(cli, "\\LISTDIR\\*", aDIR, del_fn, cli);
+ cli_list(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli);
cli_rmdir(cli, "\\LISTDIR");
cli_mkdir(cli, "\\LISTDIR");
@@ -5657,7 +6030,7 @@ static bool run_dirtest1(int dummy)
/* Now ensure that doing an old list sees both files and directories. */
num_seen = 0;
- cli_list_old(cli, "\\LISTDIR\\*", aDIR, list_fn, &num_seen);
+ cli_list_old(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, list_fn, &num_seen);
printf("num_seen = %d\n", num_seen );
/* We should see 100 files + 1000 directories + . and .. */
if (num_seen != 2002)
@@ -5667,20 +6040,20 @@ static bool run_dirtest1(int dummy)
* relevent entries.
*/
num_seen = 0;
- cli_list_old(cli, "\\LISTDIR\\*", (aDIR<<8)|aDIR, list_fn, &num_seen);
+ cli_list_old(cli, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, &num_seen);
printf("num_seen = %d\n", num_seen );
if (num_seen != 1002)
correct = False;
num_seen = 0;
- cli_list_old(cli, "\\LISTDIR\\*", (aARCH<<8)|aDIR, list_fn, &num_seen);
+ cli_list_old(cli, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, &num_seen);
printf("num_seen = %d\n", num_seen );
if (num_seen != 1000)
correct = False;
/* Delete everything. */
cli_list(cli, "\\LISTDIR\\*", 0, del_fn, cli);
- cli_list(cli, "\\LISTDIR\\*", aDIR, del_fn, cli);
+ cli_list(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli);
cli_rmdir(cli, "\\LISTDIR");
#if 0
@@ -5730,9 +6103,9 @@ static bool run_error_map_extract(int dummy) {
return False;
}
- if (!NT_STATUS_IS_OK(cli_session_setup(c_nt, "", "", 0, "", 0,
- workgroup))) {
- printf("%s rejected the NT-error initial session setup (%s)\n",host, cli_errstr(c_nt));
+ status = cli_session_setup(c_nt, "", "", 0, "", 0, workgroup);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("%s rejected the NT-error initial session setup (%s)\n",host, nt_errstr(status));
return False;
}
@@ -5753,19 +6126,21 @@ static bool run_error_map_extract(int dummy) {
return False;
}
- if (!NT_STATUS_IS_OK(cli_session_setup(c_dos, "", "", 0, "", 0,
- workgroup))) {
- printf("%s rejected the DOS-error initial session setup (%s)\n",host, cli_errstr(c_dos));
+ status = cli_session_setup(c_dos, "", "", 0, "", 0, workgroup);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("%s rejected the DOS-error initial session setup (%s)\n",
+ host, nt_errstr(status));
return False;
}
for (error=(0xc0000000 | 0x1); error < (0xc0000000| 0xFFF); error++) {
fstr_sprintf(user, "%X", error);
- if (NT_STATUS_IS_OK(cli_session_setup(c_nt, user,
- password, strlen(password),
- password, strlen(password),
- workgroup))) {
+ status = cli_session_setup(c_nt, user,
+ password, strlen(password),
+ password, strlen(password),
+ workgroup);
+ if (NT_STATUS_IS_OK(status)) {
printf("/** Session setup succeeded. This shouldn't happen...*/\n");
}
@@ -5799,14 +6174,14 @@ static bool run_error_map_extract(int dummy) {
if (NT_STATUS_V(nt_status) != error) {
printf("/*\t{ This NT error code was 'sqashed'\n\t from %s to %s \n\t during the session setup }\n*/\n",
- get_nt_error_c_code(NT_STATUS(error)),
- get_nt_error_c_code(nt_status));
+ get_nt_error_c_code(talloc_tos(), NT_STATUS(error)),
+ get_nt_error_c_code(talloc_tos(), nt_status));
}
printf("\t{%s,\t%s,\t%s},\n",
smb_dos_err_class(errclass),
smb_dos_err_name(errclass, errnum),
- get_nt_error_c_code(NT_STATUS(error)));
+ get_nt_error_c_code(talloc_tos(), NT_STATUS(error)));
}
return True;
}
@@ -5823,11 +6198,11 @@ static bool run_sesssetup_bench(int dummy)
return false;
}
- if (!NT_STATUS_IS_OK(cli_ntcreate(
- c, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
- FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
- FILE_DELETE_ON_CLOSE, 0, &fnum))) {
- d_printf("open %s failed: %s\n", fname, cli_errstr(c));
+ status = cli_ntcreate(c, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
+ FILE_DELETE_ON_CLOSE, 0, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("open %s failed: %s\n", fname, nt_errstr(status));
return false;
}
@@ -5936,7 +6311,7 @@ static bool run_chain1(int dummy)
reqs[1] = cli_write_andx_create(talloc_tos(), evt, cli1, 0, 0,
- (uint8_t *)str, 0, strlen(str)+1,
+ (const uint8_t *)str, 0, strlen(str)+1,
smbreqs, 1, &smbreqs[1]);
if (reqs[1] == NULL) return false;
tevent_req_set_callback(reqs[1], chain1_write_completion, NULL);
@@ -5983,7 +6358,7 @@ static bool run_chain2(int dummy)
NTSTATUS status;
printf("starting chain2 test\n");
- status = cli_start_connection(&cli1, global_myname(), host, NULL,
+ status = cli_start_connection(&cli1, lp_netbios_name(), host, NULL,
port_to_use, Undefined, 0);
if (!NT_STATUS_IS_OK(status)) {
return False;
@@ -6435,10 +6810,11 @@ static bool run_mangle1(int dummy)
cli_sockopt(cli, sockops);
- if (!NT_STATUS_IS_OK(cli_ntcreate(
- cli, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
- FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF, 0, 0, &fnum))) {
- d_printf("open %s failed: %s\n", fname, cli_errstr(cli));
+ status = cli_ntcreate(cli, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS,
+ FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
+ 0, 0, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("open %s failed: %s\n", fname, nt_errstr(status));
return false;
}
cli_close(cli, fnum);
@@ -6451,9 +6827,10 @@ static bool run_mangle1(int dummy)
}
d_printf("alt_name: %s\n", alt_name);
- if (!NT_STATUS_IS_OK(cli_open(cli, alt_name, O_RDONLY, DENY_NONE, &fnum))) {
+ status = cli_open(cli, alt_name, O_RDONLY, DENY_NONE, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("cli_open(%s) failed: %s\n", alt_name,
- cli_errstr(cli));
+ nt_errstr(status));
return false;
}
cli_close(cli, fnum);
@@ -6494,14 +6871,16 @@ static bool run_windows_write(int dummy)
struct timeval start_time;
double seconds;
double kbytes;
+ NTSTATUS status;
printf("starting windows_write test\n");
if (!torture_open_connection(&cli1, 0)) {
return False;
}
- if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
- printf("open failed (%s)\n", cli_errstr(cli1));
+ status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("open failed (%s)\n", nt_errstr(status));
return False;
}
@@ -6510,14 +6889,14 @@ static bool run_windows_write(int dummy)
start_time = timeval_current();
for (i=0; i<torture_numops; i++) {
- char c = 0;
+ uint8_t c = 0;
off_t start = i * torture_blocksize;
- NTSTATUS status;
size_t to_pull = torture_blocksize - 1;
- if (cli_write(cli1, fnum, 0, &c,
- start + torture_blocksize - 1, 1) != 1) {
- printf("cli_write failed: %s\n", cli_errstr(cli1));
+ status = cli_writeall(cli1, fnum, 0, &c,
+ start + torture_blocksize - 1, 1, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_write failed: %s\n", nt_errstr(status));
goto fail;
}
@@ -6539,7 +6918,7 @@ static bool run_windows_write(int dummy)
ret = true;
fail:
cli_close(cli1, fnum);
- cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
torture_close_connection(cli1);
return ret;
}
@@ -6666,13 +7045,13 @@ static NTSTATUS shortname_del_fn(const char *mnt, struct file_info *finfo,
if (strcmp(finfo->name, ".") == 0 || strcmp(finfo->name, "..") == 0)
return NT_STATUS_OK;
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
status = cli_rmdir(pcli, fname);
if (!NT_STATUS_IS_OK(status)) {
printf("del_fn: failed to rmdir %s\n,", fname );
}
} else {
- status = cli_unlink(pcli, fname, aSYSTEM | aHIDDEN);
+ status = cli_unlink(pcli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!NT_STATUS_IS_OK(status)) {
printf("del_fn: failed to unlink %s\n,", fname );
}
@@ -6721,6 +7100,7 @@ static bool run_shortname_test(int dummy)
int i;
struct sn_state s;
char fname[20];
+ NTSTATUS status;
printf("starting shortname test\n");
@@ -6731,12 +7111,13 @@ static bool run_shortname_test(int dummy)
cli_sockopt(cli, sockops);
cli_list(cli, "\\shortname\\*", 0, shortname_del_fn, cli);
- cli_list(cli, "\\shortname\\*", aDIR, shortname_del_fn, cli);
+ cli_list(cli, "\\shortname\\*", FILE_ATTRIBUTE_DIRECTORY, shortname_del_fn, cli);
cli_rmdir(cli, "\\shortname");
- if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\shortname"))) {
+ status = cli_mkdir(cli, "\\shortname");
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) cli_mkdir of \\shortname failed: %s\n",
- __location__, cli_errstr(cli));
+ __location__, nt_errstr(status));
correct = false;
goto out;
}
@@ -6747,7 +7128,6 @@ static bool run_shortname_test(int dummy)
s.val = false;
for (i = 32; i < 128; i++) {
- NTSTATUS status;
uint16_t fnum = (uint16_t)-1;
s.i = i;
@@ -6761,7 +7141,7 @@ static bool run_shortname_test(int dummy)
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OVERWRITE_IF, 0, 0, &fnum);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) cli_nt_create of %s failed: %s\n",
- __location__, fname, cli_errstr(cli));
+ __location__, fname, nt_errstr(status));
correct = false;
goto out;
}
@@ -6776,9 +7156,11 @@ static bool run_shortname_test(int dummy)
correct = false;
goto out;
}
- if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | aHIDDEN))) {
+
+ status = cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) failed to delete %s: %s\n",
- __location__, fname, cli_errstr(cli));
+ __location__, fname, nt_errstr(status));
correct = false;
goto out;
}
@@ -6792,7 +7174,7 @@ static bool run_shortname_test(int dummy)
out:
cli_list(cli, "\\shortname\\*", 0, shortname_del_fn, cli);
- cli_list(cli, "\\shortname\\*", aDIR, shortname_del_fn, cli);
+ cli_list(cli, "\\shortname\\*", FILE_ATTRIBUTE_DIRECTORY, shortname_del_fn, cli);
cli_rmdir(cli, "\\shortname");
torture_close_connection(cli);
return correct;
@@ -6921,7 +7303,7 @@ static bool run_dir_createtime(int dummy)
return false;
}
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, dname);
status = cli_mkdir(cli, dname);
@@ -6965,7 +7347,7 @@ static bool run_dir_createtime(int dummy)
out:
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, dname);
if (!torture_close_connection(cli)) {
ret = false;
@@ -6990,7 +7372,7 @@ static bool run_streamerror(int dummy)
return false;
}
- cli_unlink(cli, "\\testdir\\*", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\testdir\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, dname);
status = cli_mkdir(cli, dname);
@@ -7573,7 +7955,7 @@ static NTSTATUS split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,
stype = "$DATA";
}
else {
- if (StrCaseCmp(stype, ":$DATA") != 0) {
+ if (strcasecmp_m(stype, ":$DATA") != 0) {
/*
* If there is an explicit stream type, so far we only
* allow $DATA. Is there anything else allowed? -- vl
@@ -7822,7 +8204,7 @@ static bool run_local_wbclient(int dummy)
goto fail;
}
- wb_ctx = TALLOC_ARRAY(ev, struct wb_context *, nprocs);
+ wb_ctx = talloc_array(ev, struct wb_context *, nprocs);
if (wb_ctx == NULL) {
goto fail;
}
@@ -7900,7 +8282,7 @@ static bool run_getaddrinfo_send(int dummy)
goto fail;
}
tevent_req_set_callback(reqs[i], getaddrinfo_finished,
- (void *)names[i]);
+ discard_const_p(void, names[i]));
}
for (i=0; i<ARRAY_SIZE(reqs); i++) {
@@ -7966,7 +8348,7 @@ static bool run_local_dbtrans(int dummy)
}
res = db->transaction_start(db);
- if (res == -1) {
+ if (res != 0) {
printf(__location__ "transaction_start failed\n");
return false;
}
@@ -7993,7 +8375,7 @@ static bool run_local_dbtrans(int dummy)
TALLOC_FREE(rec);
res = db->transaction_commit(db);
- if (res == -1) {
+ if (res != 0) {
printf(__location__ "transaction_commit failed\n");
return false;
}
@@ -8003,7 +8385,7 @@ static bool run_local_dbtrans(int dummy)
int i;
res = db->transaction_start(db);
- if (res == -1) {
+ if (res != 0) {
printf(__location__ "transaction_start failed\n");
break;
}
@@ -8033,7 +8415,7 @@ static bool run_local_dbtrans(int dummy)
printf("val2=%d\r", val2);
res = db->transaction_commit(db);
- if (res == -1) {
+ if (res != 0) {
printf(__location__ "transaction_commit failed\n");
break;
}
@@ -8208,7 +8590,6 @@ static struct {
{"NBENCH2", run_nbench2, 0},
{"OPLOCK1", run_oplock1, 0},
{"OPLOCK2", run_oplock2, 0},
- {"OPLOCK3", run_oplock3, 0},
{"OPLOCK4", run_oplock4, 0},
{"DIR", run_dirtest, 0},
{"DIR1", run_dirtest1, 0},
@@ -8255,6 +8636,7 @@ static struct {
{ "CHAIN1", run_chain1, 0},
{ "CHAIN2", run_chain2, 0},
{ "WINDOWS-WRITE", run_windows_write, 0},
+ { "NTTRANS-CREATE", run_nttrans_create, 0},
{ "CLI_ECHO", run_cli_echo, 0},
{ "GETADDRINFO", run_getaddrinfo_send, 0},
{ "TLDAP", run_tldap },
@@ -8262,6 +8644,7 @@ static struct {
{ "NOTIFY-BENCH", run_notify_bench },
{ "BAD-NBT-SESSION", run_bad_nbt_session },
{ "SMB-ANY-CONNECT", run_smb_any_connect },
+ { "NOTIFY-ONLINE", run_notify_online },
{ "LOCAL-SUBSTITUTE", run_local_substitute, 0},
{ "LOCAL-GENCACHE", run_local_gencache, 0},
{ "LOCAL-TALLOC-DICT", run_local_talloc_dict, 0},
@@ -8355,6 +8738,7 @@ static void usage(void)
printf("\t-p port\n");
printf("\t-s seed\n");
printf("\t-b unclist_filename specify multiple shares for multiple connections\n");
+ printf("\t-f filename filename to test\n");
printf("\n\n");
printf("tests are:");
@@ -8432,7 +8816,8 @@ static void usage(void)
fstrcpy(workgroup, lp_workgroup());
- while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ll:d:Aec:ks:b:B:")) != EOF) {
+ while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ll:d:Aec:ks:b:B:f:"))
+ != EOF) {
switch (opt) {
case 'p':
port_to_use = atoi(optarg);
@@ -8501,6 +8886,9 @@ static void usage(void)
case 'B':
torture_blocksize = atoi(optarg);
break;
+ case 'f':
+ test_filename = SMB_STRDUP(optarg);
+ break;
default:
printf("Unknown option %c (%d)\n", (char)opt, opt);
usage();
diff --git a/source3/torture/utable.c b/source3/torture/utable.c
index e7ee00a8a36..4c6605d9210 100644
--- a/source3/torture/utable.c
+++ b/source3/torture/utable.c
@@ -21,6 +21,7 @@
#include "system/filesys.h"
#include "torture/proto.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
bool torture_utable(int dummy)
@@ -42,7 +43,7 @@ bool torture_utable(int dummy)
memset(valid, 0, sizeof(valid));
cli_mkdir(cli, "\\utable");
- cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\utable\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
for (c=1; c < 0x10000; c++) {
size_t size = 0;
@@ -77,7 +78,7 @@ bool torture_utable(int dummy)
}
cli_close(cli, fnum);
- cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+ cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (c % 100 == 0) {
printf("%d (%d/%d)\r", c, chars_allowed, alt_allowed);
@@ -144,7 +145,7 @@ bool torture_casetable(int dummy)
memset(equiv, 0, sizeof(equiv));
- cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\utable\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, "\\utable");
if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\utable"))) {
printf("Failed to create utable directory!\n");
@@ -198,11 +199,12 @@ bool torture_casetable(int dummy)
fflush(stdout);
}
- cli_write(cli, fnum, 0, (char *)&c, size, sizeof(c));
+ cli_writeall(cli, fnum, 0, (uint8_t *)&c, size, sizeof(c),
+ NULL);
cli_close(cli, fnum);
}
- cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);
+ cli_unlink(cli, "\\utable\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
cli_rmdir(cli, "\\utable");
return True;
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index 584f6e30ef3..490dd2bd529 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -414,16 +414,6 @@ void exit_server_cleanly(const char *const reason)
int last_message = -1;
-struct event_context *smbd_event_context(void)
-{
- static struct event_context *ctx;
-
- if (!ctx && !(ctx = event_context_init(NULL))) {
- smb_panic("Could not init smbd event context\n");
- }
- return ctx;
-}
-
/* Main function */
int main(int argc, char *argv[])
@@ -479,8 +469,8 @@ int main(int argc, char *argv[])
/* some basic initialization stuff */
sec_init();
- vfs.conn = TALLOC_ZERO_P(NULL, connection_struct);
- vfs.conn->params = TALLOC_P(vfs.conn, struct share_params);
+ vfs.conn = talloc_zero(NULL, connection_struct);
+ vfs.conn->params = talloc(vfs.conn, struct share_params);
for (i=0; i < 1024; i++)
vfs.files[i] = NULL;
diff --git a/source3/torture/wbc_async.c b/source3/torture/wbc_async.c
index 182474c2167..9252b58bc98 100644
--- a/source3/torture/wbc_async.c
+++ b/source3/torture/wbc_async.c
@@ -551,7 +551,7 @@ struct tevent_req *wb_trans_send(TALLOC_CTX *mem_ctx,
if (!tevent_queue_add(wb_ctx->queue, ev, req, wb_trans_trigger,
NULL)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return tevent_req_post(req, ev);
}
return req;
diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c
index 9ddd9c7df84..d170604a1bf 100644
--- a/source3/utils/eventlogadm.c
+++ b/source3/utils/eventlogadm.c
@@ -171,14 +171,14 @@ static bool eventlog_add_source( const char *eventlog, const char *sourcename,
if ( !already_in ) {
/* make a new list with an additional entry; copy values, add another */
- wp = TALLOC_ARRAY(ctx, const char *, numsources + 2 );
+ wp = talloc_array(ctx, const char *, numsources + 2 );
if ( !wp ) {
d_printf("talloc() failed \n");
return False;
}
memcpy( wp, wrklist, sizeof( char * ) * numsources );
- *( wp + numsources ) = ( char * ) sourcename;
+ *( wp + numsources ) = (const char * ) sourcename;
*( wp + numsources + 1 ) = NULL;
if (!push_reg_multi_sz(ctx, &blob, wp)) {
return false;
@@ -365,15 +365,12 @@ static int DoDumpCommand(int argc, char **argv, bool debugflag, char *exename)
{
ELOG_TDB *etdb;
TALLOC_CTX *mem_ctx = talloc_tos();
- const char *tdb_filename;
uint32_t count = 1;
if (argc > 2) {
return -1;
}
- tdb_filename = argv[0];
-
if (argc > 1) {
count = atoi(argv[1]);
}
@@ -475,16 +472,16 @@ int main( int argc, char *argv[] )
/* note that the separate command types should call usage if they need to... */
while ( 1 ) {
- if ( !StrCaseCmp( opname, "addsource" ) ) {
+ if ( !strcasecmp_m( opname, "addsource" ) ) {
rc = DoAddSourceCommand( argc, argv, opt_debug,
exename );
break;
}
- if ( !StrCaseCmp( opname, "write" ) ) {
+ if ( !strcasecmp_m( opname, "write" ) ) {
rc = DoWriteCommand( argc, argv, opt_debug, exename );
break;
}
- if ( !StrCaseCmp( opname, "dump" ) ) {
+ if ( !strcasecmp_m( opname, "dump" ) ) {
rc = DoDumpCommand( argc, argv, opt_debug, exename );
break;
}
diff --git a/source3/utils/net.c b/source3/utils/net.c
index c53b2859b09..95b937444ec 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -243,7 +243,7 @@ static int net_getlocalsid(struct net_context *c, int argc, const char **argv)
name = argv[0];
}
else {
- name = global_myname();
+ name = lp_netbios_name();
}
if(!initialize_password_db(false, NULL)) {
@@ -286,7 +286,7 @@ static int net_setlocalsid(struct net_context *c, int argc, const char **argv)
return 1;
}
- if (!secrets_store_domain_sid(global_myname(), &sid)) {
+ if (!secrets_store_domain_sid(lp_netbios_name(), &sid)) {
DEBUG(0,("Can't store domain SID as a pdc/bdc.\n"));
return 1;
}
@@ -346,13 +346,13 @@ static int net_getdomainsid(struct net_context *c, int argc, const char **argv)
/* Generate one, if it doesn't exist */
get_global_sam_sid();
- if (!secrets_fetch_domain_sid(global_myname(), &domain_sid)) {
+ if (!secrets_fetch_domain_sid(lp_netbios_name(), &domain_sid)) {
d_fprintf(stderr, _("Could not fetch local SID\n"));
return 1;
}
sid_to_fstring(sid_str, &domain_sid);
d_printf(_("SID for local machine %s is: %s\n"),
- global_myname(), sid_str);
+ lp_netbios_name(), sid_str);
if (!secrets_fetch_domain_sid(c->opt_workgroup, &domain_sid)) {
d_fprintf(stderr, _("Could not fetch domain SID\n"));
@@ -880,6 +880,16 @@ static struct functable net_func[] = {
lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
+#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
+ /* Bind our gettext results to 'unix charset'
+
+ This ensures that the translations and any embedded strings are in the
+ same charset. It won't be the one from the user's locale (we no
+ longer auto-detect that), but it will be self-consistent.
+ */
+ bind_textdomain_codeset(MODULE_NAME, lp_unix_charset());
+#endif
+
argv_new = (const char **)poptGetArgs(pc);
argc_new = argc;
@@ -895,7 +905,7 @@ static struct functable net_func[] = {
}
if (c->opt_requester_name) {
- set_global_myname(c->opt_requester_name);
+ lp_set_cmdline("netbios name", c->opt_requester_name);
}
if (!c->opt_user_name && getenv("LOGNAME")) {
diff --git a/source3/utils/net.h b/source3/utils/net.h
index ac43068c12f..1d1559f12d2 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -22,6 +22,8 @@
* include
*/
+struct cli_state;
+
#include "../librpc/gen_ndr/lsa.h"
#include "intl.h"
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 4b4b0a80318..bb78ecbf12e 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -36,6 +36,7 @@
#include "secrets.h"
#include "krb5_env.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
#ifdef HAVE_ADS
@@ -60,7 +61,8 @@ static int net_ads_cldap_netlogon(struct net_context *c, ADS_STRUCT *ads)
struct NETLOGON_SAM_LOGON_RESPONSE_EX reply;
print_sockaddr(addr, sizeof(addr), &ads->ldap.ss);
- if ( !ads_cldap_netlogon_5(talloc_tos(), addr, ads->server.realm, &reply ) ) {
+
+ if ( !ads_cldap_netlogon_5(talloc_tos(), &ads->ldap.ss, ads->server.realm, &reply ) ) {
d_fprintf(stderr, _("CLDAP query failed!\n"));
return -1;
}
@@ -154,7 +156,7 @@ static int net_ads_lookup(struct net_context *c, int argc, const char **argv)
}
if (!ads->config.realm) {
- ads->config.realm = CONST_DISCARD(char *, c->opt_target_workgroup);
+ ads->config.realm = discard_const_p(char, c->opt_target_workgroup);
ads->ldap.port = 389;
}
@@ -383,7 +385,6 @@ int net_ads_check(struct net_context *c)
static int net_ads_workgroup(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
- char addr[INET6_ADDRSTRLEN];
struct NETLOGON_SAM_LOGON_RESPONSE_EX reply;
if (c->display_usage) {
@@ -401,12 +402,11 @@ static int net_ads_workgroup(struct net_context *c, int argc, const char **argv)
}
if (!ads->config.realm) {
- ads->config.realm = CONST_DISCARD(char *, c->opt_target_workgroup);
+ ads->config.realm = discard_const_p(char, c->opt_target_workgroup);
ads->ldap.port = 389;
}
- print_sockaddr(addr, sizeof(addr), &ads->ldap.ss);
- if ( !ads_cldap_netlogon_5(talloc_tos(), addr, ads->server.realm, &reply ) ) {
+ if ( !ads_cldap_netlogon_5(talloc_tos(), &ads->ldap.ss, ads->server.realm, &reply ) ) {
d_fprintf(stderr, _("CLDAP query failed!\n"));
ads_destroy(&ads);
return -1;
@@ -441,10 +441,10 @@ static bool usergrp_display(ADS_STRUCT *ads, char *field, void **values, void *d
}
if (!values) /* must be new field, indicate string field */
return true;
- if (StrCaseCmp(field, "sAMAccountName") == 0) {
+ if (strcasecmp_m(field, "sAMAccountName") == 0) {
disp_fields[0] = SMB_STRDUP((char *) values[0]);
}
- if (StrCaseCmp(field, "description") == 0)
+ if (strcasecmp_m(field, "description") == 0)
disp_fields[1] = SMB_STRDUP((char *) values[0]);
return true;
}
@@ -915,7 +915,7 @@ static int net_ads_status(struct net_context *c, int argc, const char **argv)
return -1;
}
- rc = ads_find_machine_acct(ads, &res, global_myname());
+ rc = ads_find_machine_acct(ads, &res, lp_netbios_name());
if (!ADS_ERR_OK(rc)) {
d_fprintf(stderr, _("ads_find_machine_acct: %s\n"), ads_errstr(rc));
ads_destroy(&ads);
@@ -923,7 +923,7 @@ static int net_ads_status(struct net_context *c, int argc, const char **argv)
}
if (ads_count_replies(ads, res) == 0) {
- d_fprintf(stderr, _("No machine account for '%s' found\n"), global_myname());
+ d_fprintf(stderr, _("No machine account for '%s' found\n"), lp_netbios_name());
ads_destroy(&ads);
return -1;
}
@@ -1100,10 +1100,10 @@ static WERROR check_ads_config( void )
return WERR_INVALID_DOMAIN_ROLE;
}
- if (strlen(global_myname()) > 15) {
+ if (strlen(lp_netbios_name()) > 15) {
d_printf(_("Our netbios name can be at most 15 chars long, "
- "\"%s\" is %u chars long\n"), global_myname(),
- (unsigned int)strlen(global_myname()));
+ "\"%s\" is %u chars long\n"), lp_netbios_name(),
+ (unsigned int)strlen(lp_netbios_name()));
return WERR_INVALID_COMPUTERNAME;
}
@@ -1244,7 +1244,7 @@ static NTSTATUS net_update_dns_ext(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads,
if (hostname) {
fstrcpy(machine_name, hostname);
} else {
- name_to_fqdn( machine_name, global_myname() );
+ name_to_fqdn( machine_name, lp_netbios_name() );
}
strlower_m( machine_name );
@@ -1349,25 +1349,25 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
/* process additional command line args */
for ( i=0; i<argc; i++ ) {
- if ( !StrnCaseCmp(argv[i], "createupn", strlen("createupn")) ) {
+ if ( !strncasecmp_m(argv[i], "createupn", strlen("createupn")) ) {
createupn = true;
machineupn = get_string_param(argv[i]);
}
- else if ( !StrnCaseCmp(argv[i], "createcomputer", strlen("createcomputer")) ) {
+ else if ( !strncasecmp_m(argv[i], "createcomputer", strlen("createcomputer")) ) {
if ( (create_in_ou = get_string_param(argv[i])) == NULL ) {
d_fprintf(stderr, _("Please supply a valid OU path.\n"));
werr = WERR_INVALID_PARAM;
goto fail;
}
}
- else if ( !StrnCaseCmp(argv[i], "osName", strlen("osName")) ) {
+ else if ( !strncasecmp_m(argv[i], "osName", strlen("osName")) ) {
if ( (os_name = get_string_param(argv[i])) == NULL ) {
d_fprintf(stderr, _("Please supply a operating system name.\n"));
werr = WERR_INVALID_PARAM;
goto fail;
}
}
- else if ( !StrnCaseCmp(argv[i], "osVer", strlen("osVer")) ) {
+ else if ( !strncasecmp_m(argv[i], "osVer", strlen("osVer")) ) {
if ( (os_version = get_string_param(argv[i])) == NULL ) {
d_fprintf(stderr, _("Please supply a valid operating system version.\n"));
werr = WERR_INVALID_PARAM;
@@ -1468,7 +1468,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
/* kinit with the machine password */
use_in_memory_ccache();
- if (asprintf( &ads_dns->auth.user_name, "%s$", global_myname()) == -1) {
+ if (asprintf( &ads_dns->auth.user_name, "%s$", lp_netbios_name()) == -1) {
goto fail;
}
ads_dns->auth.password = secrets_fetch_machine_password(
@@ -1756,7 +1756,7 @@ static int net_ads_printer_info(struct net_context *c, int argc, const char **ar
if (argc > 1) {
servername = argv[1];
} else {
- servername = global_myname();
+ servername = lp_netbios_name();
}
rc = ads_find_printer_on_server(ads, &res, printername, servername);
@@ -1819,14 +1819,14 @@ static int net_ads_printer_publish(struct net_context *c, int argc, const char *
if (argc == 2) {
servername = argv[1];
} else {
- servername = global_myname();
+ servername = lp_netbios_name();
}
/* Get printer data from SPOOLSS */
resolve_name(servername, &server_ss, 0x20, false);
- nt_status = cli_full_connection(&cli, global_myname(), servername,
+ nt_status = cli_full_connection(&cli, lp_netbios_name(), servername,
&server_ss, 0,
"IPC$", "IPC",
c->opt_user_name, c->opt_workgroup,
@@ -1942,7 +1942,7 @@ static int net_ads_printer_remove(struct net_context *c, int argc, const char **
if (argc > 1) {
servername = argv[1];
} else {
- servername = global_myname();
+ servername = lp_netbios_name();
}
rc = ads_find_printer_on_server(ads, &res, argv[0], servername);
@@ -2023,8 +2023,8 @@ static int net_ads_password(struct net_context *c, int argc, const char **argv)
ADS_STRUCT *ads;
const char *auth_principal = c->opt_user_name;
const char *auth_password = c->opt_password;
- char *realm = NULL;
- char *new_password = NULL;
+ const char *realm = NULL;
+ const char *new_password = NULL;
char *chr, *prompt;
const char *user;
ADS_STATUS ret;
@@ -2083,7 +2083,7 @@ static int net_ads_password(struct net_context *c, int argc, const char **argv)
}
if (argv[1]) {
- new_password = (char *)argv[1];
+ new_password = (const char *)argv[1];
} else {
if (asprintf(&prompt, _("Enter new password for %s:"), user) == -1) {
return -1;
@@ -2135,7 +2135,7 @@ int net_ads_changetrustpw(struct net_context *c, int argc, const char **argv)
return -1;
}
- fstrcpy(my_name, global_myname());
+ fstrcpy(my_name, lp_netbios_name());
strlower_m(my_name);
if (asprintf(&host_principal, "%s$@%s", my_name, ads->config.realm) == -1) {
ads_destroy(&ads);
diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c
index 88aff4e16ec..afcb7a1874f 100644
--- a/source3/utils/net_cache.c
+++ b/source3/utils/net_cache.c
@@ -244,7 +244,7 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv)
if (gencache_get_data_blob(keystr, &value, &timeout, NULL)) {
print_cache_entry(keystr, value, timeout, NULL);
- SAFE_FREE(value.data);
+ data_blob_free(&value);
return 0;
}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index fd00c008dd6..93811598140 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -174,12 +174,12 @@ static int net_conf_delincludes_usage(struct net_context *c, int argc,
/**
* This functions process a service previously loaded with libsmbconf.
*/
-static WERROR import_process_service(struct net_context *c,
+static sbcErr import_process_service(struct net_context *c,
struct smbconf_ctx *conf_ctx,
struct smbconf_service *service)
{
uint32_t idx;
- WERROR werr = WERR_OK;
+ sbcErr err = SBC_ERR_OK;
uint32_t num_includes = 0;
char **includes = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -200,54 +200,58 @@ static WERROR import_process_service(struct net_context *c,
}
if (smbconf_share_exists(conf_ctx, service->name)) {
- werr = smbconf_delete_share(conf_ctx, service->name);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_delete_share(conf_ctx, service->name);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
}
- werr = smbconf_create_share(conf_ctx, service->name);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_create_share(conf_ctx, service->name);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
for (idx = 0; idx < service->num_params; idx ++) {
if (strequal(service->param_names[idx], "include")) {
- includes = TALLOC_REALLOC_ARRAY(mem_ctx,
+ includes = talloc_realloc(mem_ctx,
includes,
char *,
num_includes+1);
if (includes == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
includes[num_includes] = talloc_strdup(includes,
service->param_values[idx]);
if (includes[num_includes] == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
num_includes++;
} else {
- werr = smbconf_set_parameter(conf_ctx,
+ err = smbconf_set_parameter(conf_ctx,
service->name,
service->param_names[idx],
service->param_values[idx]);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr,
_("Error in section [%s], parameter \"%s\": %s\n"),
service->name, service->param_names[idx],
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
}
}
- werr = smbconf_set_includes(conf_ctx, service->name, num_includes,
- (const char **)includes);
+ err = smbconf_set_includes(conf_ctx, service->name, num_includes,
+ (const char **)includes);
+ if (!SBC_ERROR_IS_OK(err)) {
+ goto done;
+ }
+ err = SBC_ERR_OK;
done:
TALLOC_FREE(mem_ctx);
- return werr;
+ return err;
}
@@ -260,7 +264,7 @@ done:
static int net_conf_list(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
- WERROR werr = WERR_OK;
+ sbcErr err;
int ret = -1;
TALLOC_CTX *mem_ctx;
uint32_t num_shares;
@@ -274,10 +278,10 @@ static int net_conf_list(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
- werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &shares);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &shares);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error getting config: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -315,7 +319,7 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
char *conf_source = NULL;
TALLOC_CTX *mem_ctx;
struct smbconf_ctx *txt_ctx;
- WERROR werr;
+ sbcErr err;
if (c->display_usage)
return net_conf_import_usage(c, argc, argv);
@@ -347,10 +351,10 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
- werr = smbconf_init(mem_ctx, &txt_ctx, conf_source);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init(mem_ctx, &txt_ctx, conf_source);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error loading file '%s': %s\n"), filename,
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -362,37 +366,36 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
if (servicename != NULL) {
struct smbconf_service *service = NULL;
- werr = smbconf_get_share(txt_ctx, mem_ctx,
- servicename,
- &service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share(txt_ctx, mem_ctx,
+ servicename,
+ &service);
+ if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error starting transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
- werr = import_process_service(c, conf_ctx, service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = import_process_service(c, conf_ctx, service);
+ if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
} else {
struct smbconf_service **services = NULL;
uint32_t num_shares, sidx;
- werr = smbconf_get_config(txt_ctx, mem_ctx,
+ err = smbconf_get_config(txt_ctx, mem_ctx,
&num_shares,
&services);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
if (!c->opt_testmode) {
- werr = smbconf_drop(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(smbconf_drop(conf_ctx))) {
goto cancel;
}
}
@@ -405,17 +408,17 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
* imported shares, the MAX_TALLOC_SIZE of 256 MB
* was exceeded.
*/
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error starting transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
for (sidx = 0; sidx < num_shares; sidx++) {
- werr = import_process_service(c, conf_ctx,
- services[sidx]);
- if (!W_ERROR_IS_OK(werr)) {
+ err = import_process_service(c, conf_ctx,
+ services[sidx]);
+ if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
@@ -423,26 +426,26 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
continue;
}
- werr = smbconf_transaction_commit(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_commit(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error committing transaction: "
"%s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error starting transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
}
}
- werr = smbconf_transaction_commit(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_commit(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error committing transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
} else {
ret = 0;
}
@@ -450,10 +453,10 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
cancel:
- werr = smbconf_transaction_cancel(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_cancel(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error cancelling transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
}
done:
@@ -465,7 +468,7 @@ static int net_conf_listshares(struct net_context *c,
struct smbconf_ctx *conf_ctx, int argc,
const char **argv)
{
- WERROR werr = WERR_OK;
+ sbcErr err;
int ret = -1;
uint32_t count, num_shares = 0;
char **share_names = NULL;
@@ -478,9 +481,9 @@ static int net_conf_listshares(struct net_context *c,
goto done;
}
- werr = smbconf_get_share_names(conf_ctx, mem_ctx, &num_shares,
- &share_names);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share_names(conf_ctx, mem_ctx, &num_shares,
+ &share_names);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
@@ -500,17 +503,17 @@ static int net_conf_drop(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
- WERROR werr;
+ sbcErr err;
if (argc != 0 || c->display_usage) {
net_conf_drop_usage(c, argc, argv);
goto done;
}
- werr = smbconf_drop(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_drop(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error deleting configuration: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -525,7 +528,7 @@ static int net_conf_showshare(struct net_context *c,
const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
const char *sharename = NULL;
TALLOC_CTX *mem_ctx;
uint32_t count;
@@ -544,10 +547,10 @@ static int net_conf_showshare(struct net_context *c,
goto done;
}
- werr = smbconf_get_share(conf_ctx, mem_ctx, sharename, &service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share(conf_ctx, mem_ctx, sharename, &service);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error getting share parameters: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -576,13 +579,12 @@ static int net_conf_addshare(struct net_context *c,
const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
char *sharename = NULL;
const char *path = NULL;
const char *comment = NULL;
const char *guest_ok = "no";
const char *writeable = "no";
- SMB_STRUCT_STAT sbuf;
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (c->display_usage) {
@@ -682,30 +684,14 @@ static int net_conf_addshare(struct net_context *c,
goto done;
}
- if (sys_stat(path, &sbuf, false) != 0) {
- d_fprintf(stderr,
- _("ERROR: cannot stat path '%s' to ensure "
- "this is a directory.\n"
- "Error was '%s'.\n"),
- path, strerror(errno));
- goto done;
- }
-
- if (!S_ISDIR(sbuf.st_ex_mode)) {
- d_fprintf(stderr,
- _("ERROR: path '%s' is not a directory.\n"),
- path);
- goto done;
- }
-
/*
* start a transaction
*/
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf("error starting transaction: %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -713,10 +699,10 @@ static int net_conf_addshare(struct net_context *c,
* create the share
*/
- werr = smbconf_create_share(conf_ctx, sharename);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_create_share(conf_ctx, sharename);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error creating share %s: %s\n"),
- sharename, win_errstr(werr));
+ sharename, sbcErrorString(err));
goto cancel;
}
@@ -724,35 +710,35 @@ static int net_conf_addshare(struct net_context *c,
* fill the share with parameters
*/
- werr = smbconf_set_parameter(conf_ctx, sharename, "path", path);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "path", path);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "path", win_errstr(werr));
+ "path", sbcErrorString(err));
goto cancel;
}
if (comment != NULL) {
- werr = smbconf_set_parameter(conf_ctx, sharename, "comment",
- comment);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "comment",
+ comment);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "comment", win_errstr(werr));
+ "comment", sbcErrorString(err));
goto cancel;
}
}
- werr = smbconf_set_parameter(conf_ctx, sharename, "guest ok", guest_ok);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "guest ok", guest_ok);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "'guest ok'", win_errstr(werr));
+ "'guest ok'", sbcErrorString(err));
goto cancel;
}
- werr = smbconf_set_parameter(conf_ctx, sharename, "writeable",
- writeable);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "writeable",
+ writeable);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "writeable", win_errstr(werr));
+ "writeable", sbcErrorString(err));
goto cancel;
}
@@ -760,10 +746,10 @@ static int net_conf_addshare(struct net_context *c,
* commit the whole thing
*/
- werr = smbconf_transaction_commit(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_commit(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf("error committing transaction: %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
} else {
ret = 0;
}
@@ -771,10 +757,10 @@ static int net_conf_addshare(struct net_context *c,
goto done;
cancel:
- werr = smbconf_transaction_cancel(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_cancel(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf("error cancelling transaction: %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
}
done:
@@ -788,7 +774,7 @@ static int net_conf_delshare(struct net_context *c,
{
int ret = -1;
const char *sharename = NULL;
- WERROR werr = WERR_OK;
+ sbcErr err;
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 1 || c->display_usage) {
@@ -801,10 +787,10 @@ static int net_conf_delshare(struct net_context *c,
goto done;
}
- werr = smbconf_delete_share(conf_ctx, sharename);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_delete_share(conf_ctx, sharename);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error deleting share %s: %s\n"),
- sharename, win_errstr(werr));
+ sharename, sbcErrorString(err));
goto done;
}
@@ -818,7 +804,7 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
char *service = NULL;
char *param = NULL;
const char *value_str = NULL;
@@ -846,34 +832,33 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
}
value_str = argv[2];
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error starting transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
if (!smbconf_share_exists(conf_ctx, service)) {
- werr = smbconf_create_share(conf_ctx, service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_create_share(conf_ctx, service);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error creating share '%s': %s\n"),
- service, win_errstr(werr));
+ service, sbcErrorString(err));
goto cancel;
}
}
- werr = smbconf_set_parameter(conf_ctx, service, param, value_str);
-
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, service, param, value_str);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting value '%s': %s\n"),
- param, win_errstr(werr));
+ param, sbcErrorString(err));
goto cancel;
}
- werr = smbconf_transaction_commit(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_commit(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error committing transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
} else {
ret = 0;
}
@@ -881,10 +866,10 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
cancel:
- werr = smbconf_transaction_cancel(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_cancel(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error cancelling transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
}
done:
@@ -896,7 +881,7 @@ static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
char *service = NULL;
char *param = NULL;
char *valstr = NULL;
@@ -925,21 +910,20 @@ static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
- werr = smbconf_get_parameter(conf_ctx, mem_ctx, service, param, &valstr);
-
- if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
+ err = smbconf_get_parameter(conf_ctx, mem_ctx, service, param, &valstr);
+ if (SBC_ERROR_EQUAL(err, SBC_ERR_NO_SUCH_SERVICE)) {
d_fprintf(stderr,
_("Error: given service '%s' does not exist.\n"),
service);
goto done;
- } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
+ } else if (SBC_ERROR_EQUAL(err, SBC_ERR_INVALID_PARAM)) {
d_fprintf(stderr,
_("Error: given parameter '%s' is not set.\n"),
param);
goto done;
- } else if (!W_ERROR_IS_OK(werr)) {
+ } else if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error getting value '%s': %s.\n"),
- param, win_errstr(werr));
+ param, sbcErrorString(err));
goto done;
}
@@ -955,7 +939,7 @@ static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
char *service = NULL;
char *param = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -981,21 +965,20 @@ static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
- werr = smbconf_delete_parameter(conf_ctx, service, param);
-
- if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
+ err = smbconf_delete_parameter(conf_ctx, service, param);
+ if (SBC_ERROR_EQUAL(err, SBC_ERR_NO_SUCH_SERVICE)) {
d_fprintf(stderr,
_("Error: given service '%s' does not exist.\n"),
service);
goto done;
- } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
+ } else if (SBC_ERROR_EQUAL(err, SBC_ERR_INVALID_PARAM)) {
d_fprintf(stderr,
_("Error: given parameter '%s' is not set.\n"),
param);
goto done;
- } else if (!W_ERROR_IS_OK(werr)) {
+ } else if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error deleting value '%s': %s.\n"),
- param, win_errstr(werr));
+ param, sbcErrorString(err));
goto done;
}
@@ -1010,7 +993,7 @@ static int net_conf_getincludes(struct net_context *c,
struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
uint32_t num_includes;
uint32_t count;
char *service;
@@ -1029,10 +1012,10 @@ static int net_conf_getincludes(struct net_context *c,
goto done;
}
- werr = smbconf_get_includes(conf_ctx, mem_ctx, service,
+ err = smbconf_get_includes(conf_ctx, mem_ctx, service,
&num_includes, &includes);
- if (!W_ERROR_IS_OK(werr)) {
- d_printf(_("error getting includes: %s\n"), win_errstr(werr));
+ if (!SBC_ERROR_IS_OK(err)) {
+ d_printf(_("error getting includes: %s\n"), sbcErrorString(err));
goto done;
}
@@ -1051,7 +1034,7 @@ static int net_conf_setincludes(struct net_context *c,
struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
char *service;
uint32_t num_includes;
const char **includes;
@@ -1076,9 +1059,9 @@ static int net_conf_setincludes(struct net_context *c,
includes = argv + 1;
}
- werr = smbconf_set_includes(conf_ctx, service, num_includes, includes);
- if (!W_ERROR_IS_OK(werr)) {
- d_printf(_("error setting includes: %s\n"), win_errstr(werr));
+ err = smbconf_set_includes(conf_ctx, service, num_includes, includes);
+ if (!SBC_ERROR_IS_OK(err)) {
+ d_printf(_("error setting includes: %s\n"), sbcErrorString(err));
goto done;
}
@@ -1093,7 +1076,7 @@ static int net_conf_delincludes(struct net_context *c,
struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
char *service;
int ret = -1;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -1109,9 +1092,9 @@ static int net_conf_delincludes(struct net_context *c,
goto done;
}
- werr = smbconf_delete_includes(conf_ctx, service);
- if (!W_ERROR_IS_OK(werr)) {
- d_printf(_("error deleting includes: %s\n"), win_errstr(werr));
+ err = smbconf_delete_includes(conf_ctx, service);
+ if (!SBC_ERROR_IS_OK(err)) {
+ d_printf(_("error deleting includes: %s\n"), sbcErrorString(err));
goto done;
}
@@ -1140,14 +1123,13 @@ static int net_conf_wrap_function(struct net_context *c,
int, const char **),
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct smbconf_ctx *conf_ctx;
int ret = -1;
- werr = smbconf_init(mem_ctx, &conf_ctx, "registry:");
-
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init(mem_ctx, &conf_ctx, "registry:");
+ if (!SBC_ERROR_IS_OK(err)) {
return -1;
}
@@ -1184,7 +1166,7 @@ static int net_conf_run_function(struct net_context *c, int argc,
if (argc != 0) {
for (i=0; table[i].funcname; i++) {
- if (StrCaseCmp(argv[0], table[i].funcname) == 0)
+ if (strcasecmp_m(argv[0], table[i].funcname) == 0)
return net_conf_wrap_function(c, table[i].fn,
argc-1,
argv+1);
diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c
index 4378d01fe7b..2b67b7b2fe0 100644
--- a/source3/utils/net_dom.c
+++ b/source3/utils/net_dom.c
@@ -23,6 +23,7 @@
#include "../librpc/gen_ndr/ndr_winreg.h"
#include "lib/netapi/netapi.h"
#include "lib/netapi/netapi_net.h"
+#include "libsmb/libsmb.h"
int net_dom_usage(struct net_context *c, int argc, const char **argv)
{
diff --git a/source3/utils/net_file.c b/source3/utils/net_file.c
index 27f2d24096d..71a7e05fe77 100644
--- a/source3/utils/net_file.c
+++ b/source3/utils/net_file.c
@@ -44,7 +44,7 @@ int net_file(struct net_context *c, int argc, const char **argv)
if (argc < 1)
return net_file_usage(c, argc, argv);
- if (StrCaseCmp(argv[0], "HELP") == 0) {
+ if (strcasecmp_m(argv[0], "HELP") == 0) {
net_file_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_g_lock.c b/source3/utils/net_g_lock.c
index 6ed5d1776a6..f8a7a8b6202 100644
--- a/source3/utils/net_g_lock.c
+++ b/source3/utils/net_g_lock.c
@@ -113,7 +113,7 @@ static int net_g_lock_dump_fn(struct server_id pid, enum g_lock_type lock_type,
{
char *pidstr;
- pidstr = procid_str(talloc_tos(), &pid);
+ pidstr = server_id_str(talloc_tos(), &pid);
d_printf("%s: %s (%s)\n", pidstr,
(lock_type & 1) ? "WRITE" : "READ",
(lock_type & G_LOCK_PENDING) ? "pending" : "holder");
@@ -175,7 +175,7 @@ done:
TALLOC_FREE(g_ctx);
TALLOC_FREE(msg);
TALLOC_FREE(ev);
- return ret;
+ return ret < 0 ? -1 : ret;
}
int net_g_lock(struct net_context *c, int argc, const char **argv)
diff --git a/source3/utils/net_group.c b/source3/utils/net_group.c
index 7114f1feeaa..505856a0080 100644
--- a/source3/utils/net_group.c
+++ b/source3/utils/net_group.c
@@ -55,7 +55,7 @@ int net_group(struct net_context *c, int argc, const char **argv)
if (argc < 1)
return net_group_usage(c, argc, argv);
- if (StrCaseCmp(argv[0], "HELP") == 0) {
+ if (strcasecmp_m(argv[0], "HELP") == 0) {
net_group_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c
index 818905e122f..09f4bfd33a5 100644
--- a/source3/utils/net_groupmap.c
+++ b/source3/utils/net_groupmap.c
@@ -35,7 +35,7 @@ static bool get_sid_from_input(struct dom_sid *sid, char *input)
{
GROUP_MAP map;
- if (StrnCaseCmp( input, "S-", 2)) {
+ if (strncasecmp_m( input, "S-", 2)) {
/* Perhaps its the NT group name? */
if (!pdb_getgrnam(&map, input)) {
printf(_("NT Group %s doesn't exist in mapping DB\n"),
@@ -100,17 +100,17 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
/* get the options */
for ( i=0; i<argc; i++ ) {
- if ( !StrCaseCmp(argv[i], "verbose")) {
+ if ( !strcasecmp_m(argv[i], "verbose")) {
long_list = true;
}
- else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+ else if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
d_fprintf(stderr, _("must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+ else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
fstrcpy( sid_string, get_string_param( argv[i] ) );
if ( !sid_string[0] ) {
d_fprintf(stderr, _("must supply a SID\n"));
@@ -130,7 +130,7 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
GROUP_MAP map;
if ( sid_string[0] )
- fstrcpy( ntgroup, sid_string);
+ strlcpy(ntgroup, sid_string, sizeof(ntgroup));
if (!get_sid_from_input(&sid, ntgroup)) {
return -1;
@@ -201,7 +201,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
/* get the options */
for ( i=0; i<argc; i++ ) {
- if ( !StrnCaseCmp(argv[i], "rid", strlen("rid")) ) {
+ if ( !strncasecmp_m(argv[i], "rid", strlen("rid")) ) {
rid = get_int_param(argv[i]);
if ( rid < DOMAIN_RID_ADMINS ) {
d_fprintf(stderr,
@@ -210,28 +210,28 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
+ else if ( !strncasecmp_m(argv[i], "unixgroup", strlen("unixgroup")) ) {
fstrcpy( unixgrp, get_string_param( argv[i] ) );
if ( !unixgrp[0] ) {
d_fprintf(stderr,_( "must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+ else if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
d_fprintf(stderr, _("must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+ else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
fstrcpy( string_sid, get_string_param( argv[i] ) );
if ( !string_sid[0] ) {
d_fprintf(stderr, _("must supply a SID\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
+ else if ( !strncasecmp_m(argv[i], "comment", strlen("comment")) ) {
fstrcpy( ntcomment, get_string_param( argv[i] ) );
if ( !ntcomment[0] ) {
d_fprintf(stderr,
@@ -239,7 +239,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) ) {
+ else if ( !strncasecmp_m(argv[i], "type", strlen("type")) ) {
fstrcpy( type, get_string_param( argv[i] ) );
switch ( type[0] ) {
case 'b':
@@ -324,7 +324,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
}
if (!ntgroup[0] )
- fstrcpy( ntgroup, unixgrp );
+ strlcpy(ntgroup, unixgrp, sizeof(ntgroup));
if (!NT_STATUS_IS_OK(add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment))) {
d_fprintf(stderr, _("adding entry for group %s failed!\n"), ntgroup);
@@ -361,21 +361,21 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
/* get the options */
for ( i=0; i<argc; i++ ) {
- if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+ if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
d_fprintf(stderr, _("must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+ else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
fstrcpy( sid_string, get_string_param( argv[i] ) );
if ( !sid_string[0] ) {
d_fprintf(stderr, _("must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
+ else if ( !strncasecmp_m(argv[i], "comment", strlen("comment")) ) {
fstrcpy( ntcomment, get_string_param( argv[i] ) );
if ( !ntcomment[0] ) {
d_fprintf(stderr,
@@ -383,7 +383,7 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
+ else if ( !strncasecmp_m(argv[i], "unixgroup", strlen("unixgroup")) ) {
fstrcpy( unixgrp, get_string_param( argv[i] ) );
if ( !unixgrp[0] ) {
d_fprintf(stderr,
@@ -391,7 +391,7 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) ) {
+ else if ( !strncasecmp_m(argv[i], "type", strlen("type")) ) {
fstrcpy( type, get_string_param( argv[i] ) );
switch ( type[0] ) {
case 'd':
@@ -457,10 +457,10 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
/* Change comment if new one */
if ( ntcomment[0] )
- fstrcpy( map.comment, ntcomment );
+ strlcpy(map.comment, ntcomment, sizeof(map.comment));
if ( ntgroup[0] )
- fstrcpy( map.nt_name, ntgroup );
+ strlcpy(map.nt_name, ntgroup, sizeof(map.nt_name));
if ( unixgrp[0] ) {
gid = nametogid( unixgrp );
@@ -500,14 +500,14 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg
/* get the options */
for ( i=0; i<argc; i++ ) {
- if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+ if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
d_fprintf(stderr, _("must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+ else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
fstrcpy( sid_string, get_string_param( argv[i] ) );
if ( !sid_string[0] ) {
d_fprintf(stderr, _("must supply a SID\n"));
@@ -528,7 +528,7 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg
/* give preference to the SID if we have that */
if ( sid_string[0] )
- fstrcpy( ntgroup, sid_string );
+ strlcpy(ntgroup, sid_string, sizeof(ntgroup));
if ( !get_sid_from_input(&sid, ntgroup) ) {
d_fprintf(stderr, _("Unable to resolve group %s to a SID\n"),
diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c
index 4e326ba9020..4aba1c57037 100644
--- a/source3/utils/net_help.c
+++ b/source3/utils/net_help.c
@@ -60,7 +60,7 @@ int net_help(struct net_context *c, int argc, const char **argv)
return net_usage(c, argc, argv);
}
- if (StrCaseCmp(argv[0], "help") == 0) {
+ if (strcasecmp_m(argv[0], "help") == 0) {
return net_help_usage(c, argc, argv);
}
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index e059a6432c0..383035e906c 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -25,6 +25,7 @@
#include "dbwrap.h"
#include "../libcli/security/security.h"
#include "net_idmap_check.h"
+#include "util_tdb.h"
#define ALLOC_CHECK(mem) do { \
if (!mem) { \
diff --git a/source3/utils/net_idmap_check.c b/source3/utils/net_idmap_check.c
index 88725e18a61..3adc060a7c6 100644
--- a/source3/utils/net_idmap_check.c
+++ b/source3/utils/net_idmap_check.c
@@ -32,6 +32,7 @@
#include "cbuf.h"
#include "srprs.h"
#include <termios.h>
+#include "util_tdb.h"
static int traverse_commit(struct db_record *diff_rec, void* data);
static int traverse_check(struct db_record *rec, void* data);
@@ -345,7 +346,7 @@ fetch_record(struct check_ctx* ctx, TALLOC_CTX* mem_ctx, TDB_DATA key)
{
TDB_DATA tmp;
- if (ctx->diff->fetch(ctx->diff, mem_ctx, key, &tmp) == -1) {
+ if (ctx->diff->fetch(ctx->diff, mem_ctx, key, &tmp) != 0) {
DEBUG(0, ("Out of memory!\n"));
return tdb_null;
}
@@ -356,7 +357,7 @@ fetch_record(struct check_ctx* ctx, TALLOC_CTX* mem_ctx, TDB_DATA key)
return ret;
}
- if (ctx->db->fetch(ctx->db, mem_ctx, key, &tmp) == -1) {
+ if (ctx->db->fetch(ctx->db, mem_ctx, key, &tmp) != 0) {
DEBUG(0, ("Out of memory!\n"));
return tdb_null;
}
diff --git a/source3/utils/net_join.c b/source3/utils/net_join.c
index 9e9ef2af065..1493dff74d7 100644
--- a/source3/utils/net_join.c
+++ b/source3/utils/net_join.c
@@ -34,7 +34,7 @@ int net_join_usage(struct net_context *c, int argc, const char **argv)
int net_join(struct net_context *c, int argc, const char **argv)
{
- if ((argc > 0) && (StrCaseCmp(argv[0], "HELP") == 0)) {
+ if ((argc > 0) && (strcasecmp_m(argv[0], "HELP") == 0)) {
net_join_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c
index 06aedbd4730..febf481e552 100644
--- a/source3/utils/net_lookup.c
+++ b/source3/utils/net_lookup.c
@@ -290,10 +290,10 @@ static int net_lookup_kdc(struct net_context *c, int argc, const char **argv)
}
if (argc>0) {
- realm.data = CONST_DISCARD(char *, argv[0]);
+ realm.data = discard_const_p(char, argv[0]);
realm.length = strlen(argv[0]);
} else if (lp_realm() && *lp_realm()) {
- realm.data = lp_realm();
+ realm.data = discard_const_p(char, lp_realm());
realm.length = strlen((const char *)realm.data);
} else {
rc = krb5_get_host_realm(ctx, NULL, &realms);
@@ -457,7 +457,7 @@ int net_lookup(struct net_context *c, int argc, const char **argv)
return net_lookup_usage(c, argc, argv);
}
for (i=0; table[i].funcname; i++) {
- if (StrCaseCmp(argv[0], table[i].funcname) == 0)
+ if (strcasecmp_m(argv[0], table[i].funcname) == 0)
return table[i].fn(c, argc-1, argv+1);
}
diff --git a/source3/utils/net_printing.c b/source3/utils/net_printing.c
index 11c87bb5b4f..2f8caad8fda 100644
--- a/source3/utils/net_printing.c
+++ b/source3/utils/net_printing.c
@@ -28,6 +28,7 @@
#include "rpc_client/cli_spoolss.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_security.h"
+#include "util_tdb.h"
#define FORMS_PREFIX "FORMS/"
#define DRIVERS_PREFIX "DRIVERS/"
@@ -161,7 +162,7 @@ static int net_printing_dump(struct net_context *c, int argc,
int ret = -1;
TALLOC_CTX *ctx = talloc_stackframe();
TDB_CONTEXT *tdb;
- TDB_DATA kbuf, newkey, dbuf;
+ TDB_DATA kbuf, dbuf;
if (argc < 1 || c->display_usage) {
d_fprintf(stderr, "%s\nnet printing dump <file.tdb>\n",
@@ -175,11 +176,11 @@ static int net_printing_dump(struct net_context *c, int argc,
goto done;
}
- for (kbuf = tdb_firstkey(tdb);
+ for (kbuf = tdb_firstkey_compat(tdb);
kbuf.dptr;
- newkey = tdb_nextkey(tdb, kbuf), free(kbuf.dptr), kbuf=newkey)
+ kbuf = tdb_nextkey_compat(tdb, kbuf))
{
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_compat(tdb, kbuf);
if (!dbuf.dptr) {
continue;
}
@@ -512,7 +513,7 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
continue;
}
- keyname = CONST_DISCARD(char *, r.printer_data[j].name);
+ keyname = discard_const_p(char, r.printer_data[j].name);
valuename = strchr(keyname, '\\');
if (valuename == NULL) {
continue;
@@ -636,7 +637,7 @@ static NTSTATUS printing_migrate_internal(struct net_context *c,
{
TALLOC_CTX *tmp_ctx;
TDB_CONTEXT *tdb;
- TDB_DATA kbuf, newkey, dbuf;
+ TDB_DATA kbuf, dbuf;
NTSTATUS status;
tmp_ctx = talloc_new(mem_ctx);
@@ -651,11 +652,11 @@ static NTSTATUS printing_migrate_internal(struct net_context *c,
goto done;
}
- for (kbuf = tdb_firstkey(tdb);
+ for (kbuf = tdb_firstkey_compat(tdb);
kbuf.dptr;
- newkey = tdb_nextkey(tdb, kbuf), free(kbuf.dptr), kbuf = newkey)
+ kbuf = tdb_nextkey_compat(tdb, kbuf))
{
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_compat(tdb, kbuf);
if (!dbuf.dptr) {
continue;
}
diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h
index ba3860a88d8..ad20f6e0743 100644
--- a/source3/utils/net_proto.h
+++ b/source3/utils/net_proto.h
@@ -23,6 +23,7 @@
#ifndef _NET_PROTO_H_
#define _NET_PROTO_H_
+#include "libads/ads_status.h"
/* The following definitions come from utils/net.c */
diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c
index afda2227406..36f6d331970 100644
--- a/source3/utils/net_rap.c
+++ b/source3/utils/net_rap.c
@@ -26,6 +26,7 @@
#include "../librpc/gen_ndr/rap.h"
#include "../librpc/gen_ndr/svcctl.h"
#include "utils/net.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
/* The following messages were for error checking that is not properly
@@ -824,7 +825,7 @@ static int rap_user_add(struct net_context *c, int argc, const char **argv)
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
- safe_strcpy((char *)userinfo.user_name, argv[0], sizeof(userinfo.user_name)-1);
+ strlcpy((char *)userinfo.user_name, argv[0], sizeof(userinfo.user_name));
if (c->opt_flags == 0)
c->opt_flags = 0x21;
@@ -969,7 +970,7 @@ static int rap_group_add(struct net_context *c, int argc, const char **argv)
return -1;
/* BB check for length 21 or smaller explicitly ? BB */
- safe_strcpy((char *)grinfo.group_name, argv[0], sizeof(grinfo.group_name)-1);
+ strlcpy((char *)grinfo.group_name, argv[0], sizeof(grinfo.group_name));
grinfo.reserved1 = '\0';
grinfo.comment = smb_xstrdup(c->opt_comment ? c->opt_comment : "");
diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c
index 19405e2c085..086c4e7ccc3 100644
--- a/source3/utils/net_registry.c
+++ b/source3/utils/net_registry.c
@@ -122,23 +122,88 @@ done:
return werr;
}
+static WERROR registry_enumkey(struct registry_key* parent, const char* keyname, bool recursive)
+{
+ WERROR werr;
+ TALLOC_CTX *ctx = talloc_stackframe();
+ char* subkey_name;
+ NTTIME modtime;
+ uint32_t count;
+ char* valname = NULL;
+ struct registry_value *valvalue = NULL;
+ struct registry_key* key = NULL;
+
+ werr = reg_openkey(ctx, parent, keyname, REG_KEY_READ, &key);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
+ if (recursive) {
+ printf("[%s]\n\n", key->key->name);
+ } else {
+ for (count = 0;
+ werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime),
+ W_ERROR_IS_OK(werr);
+ count++)
+ {
+ print_registry_key(subkey_name, &modtime);
+ }
+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ goto done;
+ }
+ }
+
+ for (count = 0;
+ werr = reg_enumvalue(ctx, key, count, &valname, &valvalue),
+ W_ERROR_IS_OK(werr);
+ count++)
+ {
+ print_registry_value_with_name(valname, valvalue);
+ }
+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ goto done;
+ }
+
+ if (!recursive) {
+ werr = WERR_OK;
+ goto done;
+ }
+
+ for (count = 0;
+ werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime),
+ W_ERROR_IS_OK(werr);
+ count++)
+ {
+ werr = registry_enumkey(key, subkey_name, recursive);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+ }
+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ goto done;
+ }
+
+ werr = WERR_OK;
+
+done:
+ TALLOC_FREE(ctx);
+ return werr;
+}
+
+
+
/*
*
* the main "net registry" function implementations
*
*/
-
static int net_registry_enumerate(struct net_context *c, int argc,
const char **argv)
{
WERROR werr;
struct registry_key *key = NULL;
+ char* name = NULL;
TALLOC_CTX *ctx = talloc_stackframe();
- char *subkey_name;
- NTTIME modtime;
- uint32_t count;
- char *valname = NULL;
- struct registry_value *valvalue = NULL;
int ret = -1;
if (argc != 1 || c->display_usage) {
@@ -151,40 +216,56 @@ static int net_registry_enumerate(struct net_context *c, int argc,
goto done;
}
- werr = open_key(ctx, argv[0], REG_KEY_READ, &key);
+ werr = open_hive(ctx, argv[0], REG_KEY_READ, &key, &name);
if (!W_ERROR_IS_OK(werr)) {
d_fprintf(stderr, _("open_key failed: %s\n"), win_errstr(werr));
goto done;
}
- for (count = 0;
- werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime),
- W_ERROR_IS_OK(werr);
- count++)
- {
- print_registry_key(subkey_name, &modtime);
+ werr = registry_enumkey(key, name, c->opt_reboot);
+ if (W_ERROR_IS_OK(werr)) {
+ ret = 0;
}
- if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+done:
+ TALLOC_FREE(ctx);
+ return ret;
+}
+
+static int net_registry_enumerate_recursive(struct net_context *c, int argc,
+ const char **argv)
+{
+ WERROR werr;
+ struct registry_key *key = NULL;
+ char* name = NULL;
+ TALLOC_CTX *ctx = talloc_stackframe();
+ int ret = -1;
+
+ if (argc != 1 || c->display_usage) {
+ d_printf("%s\n%s",
+ _("Usage:"),
+ _("net registry enumerate <path>\n"));
+ d_printf("%s\n%s",
+ _("Example:"),
+ _("net registry enumerate 'HKLM\\Software\\Samba'\n"));
goto done;
}
- for (count = 0;
- werr = reg_enumvalue(ctx, key, count, &valname, &valvalue),
- W_ERROR_IS_OK(werr);
- count++)
- {
- print_registry_value_with_name(valname, valvalue);
- }
- if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ werr = open_hive(ctx, argv[0], REG_KEY_READ, &key, &name);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_fprintf(stderr, _("open_key failed: %s\n"), win_errstr(werr));
goto done;
}
- ret = 0;
+ werr = registry_enumkey(key, name, true);
+ if (W_ERROR_IS_OK(werr)) {
+ ret = 0;
+ }
done:
TALLOC_FREE(ctx);
return ret;
}
+
static int net_registry_createkey(struct net_context *c, int argc,
const char **argv)
{
@@ -958,9 +1039,11 @@ static int net_registry_import(struct net_context *c, int argc,
.createkey = (reg_import_callback_createkey_t)&import_create_key,
.deletekey = (reg_import_callback_deletekey_t)&import_delete_key,
.deleteval = (reg_import_callback_deleteval_t)&import_delete_val,
- .setval.registry_value = (reg_import_callback_setval_registry_value_t)
- &import_create_val,
- .setval_type = REGISTRY_VALUE,
+ .setval = {
+ .registry_value = (reg_import_callback_setval_registry_value_t)
+ &import_create_val,
+ },
+ .setval_type = REGISTRY_VALUE,
.data = &import_ctx
};
@@ -1019,7 +1102,6 @@ static int registry_export(TALLOC_CTX *ctx, /*const*/ struct registry_key* key,
struct registry_value *valvalue = NULL;
char *valname = NULL;
- struct registry_key* subkey = NULL;
char *subkey_name = NULL;
NTTIME modtime = 0;
@@ -1045,6 +1127,8 @@ static int registry_export(TALLOC_CTX *ctx, /*const*/ struct registry_key* key,
W_ERROR_IS_OK(werr);
count++)
{
+ struct registry_key* subkey = NULL;
+
werr = reg_openkey(ctx, key, subkey_name, REG_KEY_READ,
&subkey);
if (!W_ERROR_IS_OK(werr)) {
@@ -1054,6 +1138,7 @@ static int registry_export(TALLOC_CTX *ctx, /*const*/ struct registry_key* key,
}
registry_export(ctx, subkey, f);
+ TALLOC_FREE(subkey);
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
d_fprintf(stderr, _("reg_enumkey failed: %s\n"),
@@ -1174,6 +1259,14 @@ int net_registry(struct net_context *c, int argc, const char **argv)
" Enumerate registry keys and values")
},
{
+ "enumerate_recursive",
+ net_registry_enumerate_recursive,
+ NET_TRANSPORT_LOCAL,
+ N_("Enumerate registry keys and values"),
+ N_("net registry enumerate_recursive\n"
+ " Enumerate registry keys and values")
+ },
+ {
"createkey",
net_registry_createkey,
NET_TRANSPORT_LOCAL,
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 4003b88d51c..2ecf1aaa5a4 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -39,6 +39,7 @@
#include "lib/netapi/netapi_net.h"
#include "rpc_client/init_lsa.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "nsswitch/libwbclient/wbclient.h"
#include "passdb.h"
@@ -365,7 +366,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c,
sec_channel_type = get_sec_channel_type(NULL);
}
- fstrcpy(trust_passwd, global_myname());
+ fstrcpy(trust_passwd, lp_netbios_name());
strlower_m(trust_passwd);
/*
@@ -378,7 +379,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c,
E_md4hash(trust_passwd, orig_trust_passwd_hash);
result = trust_pw_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup,
- global_myname(),
+ lp_netbios_name(),
orig_trust_passwd_hash,
sec_channel_type);
@@ -480,10 +481,10 @@ int net_rpc_join(struct net_context *c, int argc, const char **argv)
return -1;
}
- if (strlen(global_myname()) > 15) {
+ if (strlen(lp_netbios_name()) > 15) {
d_printf(_("Our netbios name can be at most 15 chars long, "
"\"%s\" is %u chars long\n"),
- global_myname(), (unsigned int)strlen(global_myname()));
+ lp_netbios_name(), (unsigned int)strlen(lp_netbios_name()));
return -1;
}
@@ -549,7 +550,7 @@ NTSTATUS rpc_info_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -1622,7 +1623,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -1976,7 +1977,7 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli,
TALLOC_FREE(pipe_hnd);
}
- if (!NT_STATUS_IS_OK(status) && (StrnCaseCmp(name, "S-", 2) == 0)) {
+ if (!NT_STATUS_IS_OK(status) && (strncasecmp_m(name, "S-", 2) == 0)) {
/* Try as S-1-5-whatever */
@@ -2584,7 +2585,7 @@ static NTSTATUS rpc_group_list_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -2710,7 +2711,7 @@ static NTSTATUS rpc_group_list_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ discard_const_p(struct dom_sid2, &global_sid_Builtin),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -2956,7 +2957,7 @@ static NTSTATUS rpc_list_alias_members(struct net_context *c,
return result;
}
- alias_sids = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, num_members);
+ alias_sids = talloc_zero_array(mem_ctx, struct dom_sid, num_members);
if (!alias_sids) {
d_fprintf(stderr, _("Out of memory\n"));
TALLOC_FREE(lsa_pipe);
@@ -3032,7 +3033,7 @@ static NTSTATUS rpc_group_members_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -3430,7 +3431,7 @@ static WERROR get_share_info(struct net_context *c,
{
struct srvsvc_NetShareCtr1 *ctr1;
- ctr1 = TALLOC_ZERO_P(mem_ctx, struct srvsvc_NetShareCtr1);
+ ctr1 = talloc_zero(mem_ctx, struct srvsvc_NetShareCtr1);
W_ERROR_HAVE_NO_MEMORY(ctr1);
ctr1->count = 1;
@@ -3444,7 +3445,7 @@ static WERROR get_share_info(struct net_context *c,
{
struct srvsvc_NetShareCtr2 *ctr2;
- ctr2 = TALLOC_ZERO_P(mem_ctx, struct srvsvc_NetShareCtr2);
+ ctr2 = talloc_zero(mem_ctx, struct srvsvc_NetShareCtr2);
W_ERROR_HAVE_NO_MEMORY(ctr2);
ctr2->count = 1;
@@ -3458,7 +3459,7 @@ static WERROR get_share_info(struct net_context *c,
{
struct srvsvc_NetShareCtr502 *ctr502;
- ctr502 = TALLOC_ZERO_P(mem_ctx, struct srvsvc_NetShareCtr502);
+ ctr502 = talloc_zero(mem_ctx, struct srvsvc_NetShareCtr502);
W_ERROR_HAVE_NO_MEMORY(ctr502);
ctr502->count = 1;
@@ -3730,7 +3731,7 @@ static NTSTATUS copy_fn(const char *mnt, struct file_info *f,
DEBUG(3,("got mask: %s, name: %s\n", mask, f->name));
/* DIRECTORY */
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
DEBUG(3,("got dir: %s\n", f->name));
@@ -3763,8 +3764,8 @@ static NTSTATUS copy_fn(const char *mnt, struct file_info *f,
}
/* search below that directory */
- fstrcpy(new_mask, dir);
- fstrcat(new_mask, "\\*");
+ strlcpy(new_mask, dir, sizeof(new_mask));
+ strlcat(new_mask, "\\*", sizeof(new_mask));
old_dir = local_state->cwd;
local_state->cwd = dir;
@@ -3968,7 +3969,7 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c,
cp_clistate.cli_share_src = NULL;
cp_clistate.cli_share_dst = NULL;
cp_clistate.cwd = NULL;
- cp_clistate.attribute = aSYSTEM | aHIDDEN | aDIR;
+ cp_clistate.attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
cp_clistate.c = c;
/* open share source */
@@ -4318,7 +4319,7 @@ static NTSTATUS rpc_fetch_domain_aliases(struct rpc_pipe_client *pipe_hnd,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -4802,7 +4803,7 @@ static bool get_user_tokens_from_file(FILE *f,
token = &((*tokens)[*num_tokens-1]);
- fstrcpy(token->name, line);
+ strlcpy(token->name, line, sizeof(token->name));
token->token.num_sids = 0;
token->token.sids = NULL;
continue;
@@ -5803,7 +5804,7 @@ static NTSTATUS rpc_trustdom_add_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -5977,7 +5978,7 @@ static NTSTATUS rpc_trustdom_del_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -6500,7 +6501,6 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
struct rpc_pipe_client *pipe_hnd = NULL;
NTSTATUS nt_status, result;
const char *domain_name = NULL;
- struct dom_sid *queried_dom_sid;
struct policy_handle connect_hnd;
union lsa_PolicyInformation *info = NULL;
@@ -6531,11 +6531,11 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
* or to remote one given in command line
*/
- if (StrCaseCmp(c->opt_workgroup, lp_workgroup())) {
+ if (strcasecmp_m(c->opt_workgroup, lp_workgroup())) {
domain_name = c->opt_workgroup;
c->opt_target_workgroup = c->opt_workgroup;
} else {
- fstrcpy(pdc_name, global_myname());
+ fstrcpy(pdc_name, lp_netbios_name());
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
c->opt_target_workgroup = domain_name;
};
@@ -6593,8 +6593,6 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
return -1;
}
- queried_dom_sid = info->account_domain.sid;
-
/*
* Keep calling LsaEnumTrustdom over opened pipe until
* the end of enumeration is reached
@@ -6711,11 +6709,11 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
* or to remote one given in command line
*/
- if (StrCaseCmp(c->opt_workgroup, lp_workgroup())) {
+ if (strcasecmp_m(c->opt_workgroup, lp_workgroup())) {
domain_name = c->opt_workgroup;
c->opt_target_workgroup = c->opt_workgroup;
} else {
- fstrcpy(pdc_name, global_myname());
+ fstrcpy(pdc_name, lp_netbios_name());
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
c->opt_target_workgroup = domain_name;
};
@@ -6937,7 +6935,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
for (i = 0; i < num_domains; i++) {
- char *str = CONST_DISCARD(char *, trusts->entries[i].name.string);
+ char *str = discard_const_p(char, trusts->entries[i].name.string);
found_domain = true;
@@ -7090,16 +7088,11 @@ bool net_rpc_check(struct net_context *c, unsigned flags)
if (!net_find_server(c, NULL, flags, &server_ss, &server_name))
return false;
- if ((cli = cli_initialise()) == NULL) {
+ status = cli_connect_nb(server_name, &server_ss, 0, 0x20,
+ lp_netbios_name(), Undefined, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
-
- status = cli_connect(cli, server_name, &server_ss);
- if (!NT_STATUS_IS_OK(status))
- goto done;
- if (!attempt_netbios_session_request(&cli, global_myname(),
- server_name, &server_ss))
- goto done;
status = cli_negprot(cli);
if (!NT_STATUS_IS_OK(status))
goto done;
diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c
index 1ca213d155b..d228f928047 100644
--- a/source3/utils/net_rpc_join.c
+++ b/source3/utils/net_rpc_join.c
@@ -30,6 +30,7 @@
#include "rpc_client/cli_netlogon.h"
#include "secrets.h"
#include "rpc_client/init_lsa.h"
+#include "libsmb/libsmb.h"
/* Macro for checking RPC error codes to make things more readable */
@@ -306,7 +307,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
"could not open domain");
/* Create domain user */
- if ((acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname())) == NULL) {
+ if ((acct_name = talloc_asprintf(mem_ctx, "%s$", lp_netbios_name())) == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
@@ -442,8 +443,8 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
status = rpccli_netlogon_setup_creds(pipe_hnd,
cli->desthost, /* server name */
domain, /* domain */
- global_myname(), /* client name */
- global_myname(), /* machine account name */
+ lp_netbios_name(), /* client name */
+ lp_netbios_name(), /* machine account name */
md4_trust_password,
sec_channel_type,
&neg_flags);
@@ -457,7 +458,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
d_fprintf(stderr, _("Please make sure that no computer "
"account\nnamed like this machine "
"(%s) exists in the domain\n"),
- global_myname());
+ lp_netbios_name());
}
goto done;
@@ -486,7 +487,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
"computer account\nnamed "
"like this machine (%s) "
"exists in the domain\n"),
- global_myname());
+ lp_netbios_name());
}
goto done;
@@ -498,7 +499,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
/* Now store the secret in the secrets database */
- strupper_m(CONST_DISCARD(char *, domain));
+ strupper_m(discard_const_p(char, domain));
if (!secrets_store_domain_sid(domain, domain_sid)) {
DEBUG(0, ("error storing domain sid for %s\n", domain));
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index 7a225871744..272e0c9dfa1 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -27,7 +27,7 @@
#include "registry/reg_objects.h"
#include "../libcli/security/security.h"
#include "../libcli/registry/util_reg.h"
-#include "ntdomain.h"
+#include "libsmb/libsmb.h"
/* support itanium as well */
static const struct print_architecture_table_node archi_table[]= {
@@ -70,7 +70,7 @@ static void display_print_driver3(struct spoolss_DriverInfo3 *r)
printf(_("\tConfigfile: [%s]\n\n"), r->config_file);
printf(_("\tHelpfile: [%s]\n\n"), r->help_file);
- for (i=0; r->dependent_files[i] != NULL; i++) {
+ for (i=0; r->dependent_files && r->dependent_files[i] != NULL; i++) {
printf(_("\tDependentfiles: [%s]\n"), r->dependent_files[i]);
}
@@ -158,14 +158,13 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
bool copy_acls, bool copy_attrs,
bool copy_timestamps, bool is_file)
{
- NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS nt_status;
uint16_t fnum_src = 0;
uint16_t fnum_dst = 0;
struct security_descriptor *sd = NULL;
uint16_t attr;
time_t f_atime, f_ctime, f_mtime;
-
if (!copy_timestamps && !copy_acls && !copy_attrs)
return NT_STATUS_OK;
@@ -174,17 +173,17 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
DEBUGADD(3,("opening %s %s on originating server\n",
is_file?"file":"dir", src_name));
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_src, src_name, 0, READ_CONTROL_ACCESS, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_src))) {
+ nt_status = cli_ntcreate(cli_share_src, src_name, 0,
+ READ_CONTROL_ACCESS, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
+ 0x0, 0x0, &fnum_src);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUGADD(0,("cannot open %s %s on originating server %s\n",
- is_file?"file":"dir", src_name, cli_errstr(cli_share_src)));
- nt_status = cli_nt_error(cli_share_src);
+ is_file?"file":"dir", src_name, nt_errstr(nt_status)));
goto out;
}
-
if (copy_acls) {
-
/* get the security descriptor */
sd = cli_query_secdesc(cli_share_src, fnum_src, mem_ctx);
if (!sd) {
@@ -198,81 +197,74 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
display_sec_desc(sd);
}
-
if (copy_attrs || copy_timestamps) {
/* get file attributes */
- if (!NT_STATUS_IS_OK(cli_getattrE(cli_share_src, fnum_src, &attr, NULL,
- &f_ctime, &f_atime, &f_mtime))) {
+ nt_status = cli_getattrE(cli_share_src, fnum_src, &attr, NULL,
+ &f_ctime, &f_atime, &f_mtime);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("failed to get file-attrs: %s\n",
- cli_errstr(cli_share_src)));
- nt_status = cli_nt_error(cli_share_src);
+ nt_errstr(nt_status)));
goto out;
}
}
-
/* open the file/dir on the destination server */
-
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_dst, dst_name, 0, WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_dst))) {
+ nt_status = cli_ntcreate(cli_share_dst, dst_name, 0,
+ WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
+ 0x0, 0x0, &fnum_dst);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("failed to open %s on the destination server: %s: %s\n",
- is_file?"file":"dir", dst_name, cli_errstr(cli_share_dst)));
- nt_status = cli_nt_error(cli_share_dst);
+ is_file?"file":"dir", dst_name, nt_errstr(nt_status)));
goto out;
}
if (copy_timestamps) {
-
/* set timestamps */
- if (!NT_STATUS_IS_OK(cli_setattrE(cli_share_dst, fnum_dst, f_ctime, f_atime, f_mtime))) {
+ nt_status = cli_setattrE(cli_share_dst, fnum_dst, f_ctime, f_atime, f_mtime);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("failed to set file-attrs (timestamps): %s\n",
- cli_errstr(cli_share_dst)));
- nt_status = cli_nt_error(cli_share_dst);
+ nt_errstr(nt_status)));
goto out;
}
}
if (copy_acls) {
- NTSTATUS status;
-
/* set acls */
- status = cli_set_secdesc(cli_share_dst, fnum_dst, sd);
- if (!NT_STATUS_IS_OK(status)) {
+ nt_status = cli_set_secdesc(cli_share_dst, fnum_dst, sd);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("could not set secdesc on %s: %s\n",
- dst_name, nt_errstr(status)));
- nt_status = status;
+ dst_name, nt_errstr(nt_status)));
goto out;
}
}
if (copy_attrs) {
-
/* set attrs */
- if (!NT_STATUS_IS_OK(cli_setatr(cli_share_dst, dst_name, attr, 0))) {
+ nt_status = cli_setatr(cli_share_dst, dst_name, attr, 0);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("failed to set file-attrs: %s\n",
- cli_errstr(cli_share_dst)));
- nt_status = cli_nt_error(cli_share_dst);
+ nt_errstr(nt_status)));
goto out;
}
}
/* closing files */
-
- if (!NT_STATUS_IS_OK(cli_close(cli_share_src, fnum_src))) {
+ nt_status = cli_close(cli_share_src, fnum_src);
+ if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr,
_("could not close %s on originating server: %s\n"),
- is_file?"file":"dir", cli_errstr(cli_share_src));
- nt_status = cli_nt_error(cli_share_src);
+ is_file?"file":"dir", nt_errstr(nt_status));
goto out;
}
- if (!NT_STATUS_IS_OK(cli_close(cli_share_dst, fnum_dst))) {
+ nt_status = cli_close(cli_share_dst, fnum_dst);
+ if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr,
_("could not close %s on destination server: %s\n"),
- is_file?"file":"dir", cli_errstr(cli_share_dst));
- nt_status = cli_nt_error(cli_share_dst);
+ is_file?"file":"dir", nt_errstr(nt_status));
goto out;
}
@@ -343,7 +335,7 @@ NTSTATUS net_copy_file(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUGADD(0,("cannot open %s %s on originating server %s\n",
is_file ? "file":"dir",
- src_name, cli_errstr(cli_share_src)));
+ src_name, nt_errstr(nt_status)));
goto out;
}
@@ -357,7 +349,7 @@ NTSTATUS net_copy_file(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUGADD(1,("cannot create file %s on destination server: %s\n",
- dst_name, cli_errstr(cli_share_dst)));
+ dst_name, nt_errstr(nt_status)));
goto out;
}
@@ -387,20 +379,19 @@ NTSTATUS net_copy_file(struct net_context *c,
while (is_file) {
/* copying file */
- int n, ret;
+ int n;
n = cli_read(cli_share_src, fnum_src, data, nread,
read_size);
if (n <= 0)
break;
- ret = cli_write(cli_share_dst, fnum_dst, 0, data,
- nread, n);
+ nt_status = cli_writeall(cli_share_dst, fnum_dst, 0,
+ (uint8_t *)data, nread, n, NULL);
- if (n != ret) {
+ if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr, _("Error writing file: %s\n"),
- cli_errstr(cli_share_dst));
- nt_status = cli_nt_error(cli_share_dst);
+ nt_errstr(nt_status));
goto out;
}
@@ -414,36 +405,41 @@ NTSTATUS net_copy_file(struct net_context *c,
DEBUGADD(3,("creating dir %s on the destination server\n",
dst_name));
- if (!NT_STATUS_IS_OK(cli_mkdir(cli_share_dst, dst_name))) {
+ nt_status = cli_mkdir(cli_share_dst, dst_name);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("cannot create directory %s: %s\n",
- dst_name, cli_errstr(cli_share_dst)));
+ dst_name, nt_errstr(nt_status)));
nt_status = NT_STATUS_NO_SUCH_FILE;
}
- if (!NT_STATUS_IS_OK(cli_chkpath(cli_share_dst, dst_name))) {
+
+ nt_status = cli_chkpath(cli_share_dst, dst_name);
+ if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr,
_("cannot check for directory %s: %s\n"),
- dst_name, cli_errstr(cli_share_dst));
+ dst_name, nt_errstr(nt_status));
goto out;
}
}
/* closing files */
- if (!NT_STATUS_IS_OK(cli_close(cli_share_src, fnum_src))) {
+ nt_status = cli_close(cli_share_src, fnum_src);
+ if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr,
_("could not close file on originating server: %s\n"),
- cli_errstr(cli_share_src));
- nt_status = cli_nt_error(cli_share_src);
+ nt_errstr(nt_status));
goto out;
}
- if (is_file && !NT_STATUS_IS_OK(cli_close(cli_share_dst, fnum_dst))) {
- d_fprintf(stderr,
+ if (is_file) {
+ nt_status = cli_close(cli_share_dst, fnum_dst);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ d_fprintf(stderr,
_("could not close file on destination server: %s\n"),
- cli_errstr(cli_share_dst));
- nt_status = cli_nt_error(cli_share_dst);
- goto out;
+ nt_errstr(nt_status));
+ goto out;
+ }
}
/* possibly we have to copy some file-attributes / acls / sd */
@@ -563,15 +559,16 @@ static NTSTATUS check_arch_dir(struct cli_state *cli_share, const char *short_ar
DEBUG(10,("creating print-driver dir for architecture: %s\n",
short_archi));
- if (!NT_STATUS_IS_OK(cli_mkdir(cli_share, dir))) {
+ nt_status = cli_mkdir(cli_share, dir);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(1,("cannot create directory %s: %s\n",
- dir, cli_errstr(cli_share)));
- nt_status = NT_STATUS_NO_SUCH_FILE;
+ dir, nt_errstr(nt_status)));
}
- if (!NT_STATUS_IS_OK(cli_chkpath(cli_share, dir))) {
+ nt_status = cli_chkpath(cli_share, dir);
+ if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr, _("cannot check %s: %s\n"),
- dir, cli_errstr(cli_share));
+ dir, nt_errstr(nt_status));
goto out;
}
@@ -2547,7 +2544,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
if (strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME)) {
- push_reg_sz(mem_ctx, &blob, global_myname());
+ push_reg_sz(mem_ctx, &blob, lp_netbios_name());
}
value = regval_compose(talloc_tos(),
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 31f4e3ec5fd..9195bd477da 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -31,6 +31,7 @@
#include <assert.h>
#include "../libcli/security/display_sec.h"
#include "../libcli/registry/util_reg.h"
+#include "client.h"
/*******************************************************************
@@ -210,9 +211,9 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- if ((!(names = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_subkeys))) ||
- (!(classes = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_subkeys))) ||
- (!(modtimes = TALLOC_ZERO_ARRAY(mem_ctx, NTTIME *,
+ if ((!(names = talloc_zero_array(mem_ctx, char *, num_subkeys))) ||
+ (!(classes = talloc_zero_array(mem_ctx, char *, num_subkeys))) ||
+ (!(modtimes = talloc_zero_array(mem_ctx, NTTIME *,
num_subkeys)))) {
status = NT_STATUS_NO_MEMORY;
goto error;
@@ -332,8 +333,8 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- if ((!(names = TALLOC_ARRAY(mem_ctx, char *, num_values))) ||
- (!(values = TALLOC_ARRAY(mem_ctx, struct registry_value *,
+ if ((!(names = talloc_array(mem_ctx, char *, num_values))) ||
+ (!(values = talloc_array(mem_ctx, struct registry_value *,
num_values)))) {
status = NT_STATUS_NO_MEMORY;
goto error;
@@ -455,8 +456,8 @@ static NTSTATUS registry_enumvalues2(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- if ((!(names = TALLOC_ARRAY(mem_ctx, char *, num_values))) ||
- (!(values = TALLOC_ARRAY(mem_ctx, struct regval_blob *,
+ if ((!(names = talloc_array(mem_ctx, char *, num_values))) ||
+ (!(values = talloc_array(mem_ctx, struct regval_blob *,
num_values)))) {
status = NT_STATUS_NO_MEMORY;
goto error;
@@ -1450,7 +1451,7 @@ static NTSTATUS rpc_registry_getsd_internal(struct net_context *c,
return status;
}
- sd = TALLOC_ZERO_P(mem_ctx, struct KeySecurityData);
+ sd = talloc_zero(mem_ctx, struct KeySecurityData);
if (!sd) {
status = NT_STATUS_NO_MEMORY;
goto out;
@@ -1958,7 +1959,9 @@ static NTSTATUS rpc_registry_import_internal(struct net_context *c,
.createkey = (reg_import_callback_createkey_t)&import_create_key,
.deletekey = (reg_import_callback_deletekey_t)&import_delete_key,
.deleteval = (reg_import_callback_deleteval_t)&import_delete_val,
- .setval.blob = (reg_import_callback_setval_blob_t)&import_create_val,
+ .setval = {
+ .blob = (reg_import_callback_setval_blob_t)&import_create_val,
+ },
.setval_type = BLOB,
.data = &import_ctx
};
diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c
index a2847749b70..737bfb0e868 100644
--- a/source3/utils/net_rpc_rights.c
+++ b/source3/utils/net_rpc_rights.c
@@ -190,7 +190,7 @@ static NTSTATUS check_privilege_for_user(struct rpc_pipe_client *pipe_hnd,
}
for (i = 0; i < rights.count; i++) {
- if (StrCaseCmp(rights.names[i].string, right) == 0) {
+ if (strcasecmp_m(rights.names[i].string, right) == 0) {
return NT_STATUS_OK;
}
}
@@ -506,7 +506,7 @@ static NTSTATUS rpc_rights_grant_internal(struct net_context *c,
return status;
rights.count = argc-1;
- rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
rights.count);
if (!rights.names) {
return NT_STATUS_NO_MEMORY;
@@ -579,7 +579,7 @@ static NTSTATUS rpc_rights_revoke_internal(struct net_context *c,
return status;
rights.count = argc-1;
- rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
rights.count);
if (!rights.names) {
return NT_STATUS_NO_MEMORY;
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index 861f429559f..04aefbb13f2 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -51,50 +51,50 @@ static void parse_samsync_partial_replication_objects(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(o);
- if (!StrnCaseCmp(argv[i], "user_rid=", strlen("user_rid="))) {
+ if (!strncasecmp_m(argv[i], "user_rid=", strlen("user_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_USER;
o.database_id = SAM_DATABASE_DOMAIN;
}
- if (!StrnCaseCmp(argv[i], "group_rid=", strlen("group_rid="))) {
+ if (!strncasecmp_m(argv[i], "group_rid=", strlen("group_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_GROUP;
o.database_id = SAM_DATABASE_DOMAIN;
}
- if (!StrnCaseCmp(argv[i], "group_member_rid=", strlen("group_member_rid="))) {
+ if (!strncasecmp_m(argv[i], "group_member_rid=", strlen("group_member_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_GROUP_MEMBER;
o.database_id = SAM_DATABASE_DOMAIN;
}
- if (!StrnCaseCmp(argv[i], "alias_rid=", strlen("alias_rid="))) {
+ if (!strncasecmp_m(argv[i], "alias_rid=", strlen("alias_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_ALIAS;
o.database_id = SAM_DATABASE_BUILTIN;
}
- if (!StrnCaseCmp(argv[i], "alias_member_rid=", strlen("alias_member_rid="))) {
+ if (!strncasecmp_m(argv[i], "alias_member_rid=", strlen("alias_member_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_ALIAS_MEMBER;
o.database_id = SAM_DATABASE_BUILTIN;
}
- if (!StrnCaseCmp(argv[i], "account_sid=", strlen("account_sid="))) {
+ if (!strncasecmp_m(argv[i], "account_sid=", strlen("account_sid="))) {
const char *sid_str = get_string_param(argv[i]);
string_to_sid(&o.object_identifier.sid, sid_str);
o.object_type = NETR_DELTA_ACCOUNT;
o.database_id = SAM_DATABASE_PRIVS;
}
- if (!StrnCaseCmp(argv[i], "policy_sid=", strlen("policy_sid="))) {
+ if (!strncasecmp_m(argv[i], "policy_sid=", strlen("policy_sid="))) {
const char *sid_str = get_string_param(argv[i]);
string_to_sid(&o.object_identifier.sid, sid_str);
o.object_type = NETR_DELTA_POLICY;
o.database_id = SAM_DATABASE_PRIVS;
}
- if (!StrnCaseCmp(argv[i], "trustdom_sid=", strlen("trustdom_sid="))) {
+ if (!strncasecmp_m(argv[i], "trustdom_sid=", strlen("trustdom_sid="))) {
const char *sid_str = get_string_param(argv[i]);
string_to_sid(&o.object_identifier.sid, sid_str);
o.object_type = NETR_DELTA_TRUSTED_DOMAIN;
o.database_id = SAM_DATABASE_PRIVS;
}
- if (!StrnCaseCmp(argv[i], "secret_name=", strlen("secret_name="))) {
+ if (!strncasecmp_m(argv[i], "secret_name=", strlen("secret_name="))) {
o.object_identifier.name = get_string_param(argv[i]);
o.object_type = NETR_DELTA_SECRET;
o.database_id = SAM_DATABASE_PRIVS;
diff --git a/source3/utils/net_rpc_shell.c b/source3/utils/net_rpc_shell.c
index 1985bf8b0b6..42dfc48d4a4 100644
--- a/source3/utils/net_rpc_shell.c
+++ b/source3/utils/net_rpc_shell.c
@@ -26,6 +26,7 @@
#include "lib/netapi/netapi.h"
#include "lib/netapi/netapi_net.h"
#include "../libcli/smbreadline/smbreadline.h"
+#include "libsmb/libsmb.h"
static NTSTATUS rpc_sh_info(struct net_context *c,
TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
@@ -153,7 +154,7 @@ static bool net_sh_process(struct net_context *c,
return true;
}
- new_ctx = TALLOC_P(ctx, struct rpc_sh_ctx);
+ new_ctx = talloc(ctx, struct rpc_sh_ctx);
if (new_ctx == NULL) {
d_fprintf(stderr, _("talloc failed\n"));
return false;
@@ -233,7 +234,7 @@ int net_rpc_shell(struct net_context *c, int argc, const char **argv)
libnetapi_set_use_kerberos(c->netapi_ctx);
}
- ctx = TALLOC_P(NULL, struct rpc_sh_ctx);
+ ctx = talloc(NULL, struct rpc_sh_ctx);
if (ctx == NULL) {
d_fprintf(stderr, _("talloc failed\n"));
return -1;
diff --git a/source3/utils/net_rpc_trust.c b/source3/utils/net_rpc_trust.c
index da0a7cca67d..318c06ffe99 100644
--- a/source3/utils/net_rpc_trust.c
+++ b/source3/utils/net_rpc_trust.c
@@ -25,6 +25,7 @@
#include "../librpc/gen_ndr/ndr_lsa_c.h"
#include "../lib/crypto/crypto.h"
#include "../libcli/security/dom_sid.h"
+#include "libsmb/libsmb.h"
#define ARG_OTHERSERVER "otherserver="
@@ -418,19 +419,22 @@ static int rpc_trust_common(struct net_context *net_ctx, int argc,
struct other_dom_data *other_dom_data;
struct net_context *other_net_ctx = NULL;
struct dom_data dom_data[2];
+ void (*usage)(void);
+
+ switch (op) {
+ case TRUST_CREATE:
+ usage = print_trust_usage;
+ break;
+ case TRUST_DELETE:
+ usage = print_trust_delete_usage;
+ break;
+ default:
+ DEBUG(0, ("Unsupported trust operation.\n"));
+ return -1;
+ }
if (net_ctx->display_usage) {
- switch (op) {
- case TRUST_CREATE:
- print_trust_usage();
- break;
- case TRUST_DELETE:
- print_trust_delete_usage();
- break;
- default:
- DEBUG(0, ("Unsupported trust operation.\n"));
- return -1;
- }
+ usage();
return 0;
}
@@ -443,7 +447,7 @@ static int rpc_trust_common(struct net_context *net_ctx, int argc,
ret = parse_trust_args(mem_ctx, argc, argv, &other_dom_data, &trust_pw);
if (ret != 0) {
if (ret == EINVAL) {
- print_trust_usage();
+ usage();
} else {
DEBUG(0, ("Failed to parse arguments.\n"));
}
@@ -470,7 +474,7 @@ static int rpc_trust_common(struct net_context *net_ctx, int argc,
(dom_data[1].domain_name == NULL ||
dom_data[1].dns_domain_name == NULL))) {
DEBUG(0, ("Missing required argument.\n"));
- print_trust_usage();
+ usage();
goto done;
}
}
diff --git a/source3/utils/net_serverid.c b/source3/utils/net_serverid.c
index 08a1a7f298b..4159eead7a7 100644
--- a/source3/utils/net_serverid.c
+++ b/source3/utils/net_serverid.c
@@ -26,7 +26,7 @@
static int net_serverid_list_fn(const struct server_id *id,
uint32_t msg_flags, void *priv)
{
- char *str = procid_str(talloc_tos(), id);
+ char *str = server_id_str(talloc_tos(), id);
d_printf("%s %llu 0x%x\n", str, (unsigned long long)id->unique_id,
(unsigned int)msg_flags);
TALLOC_FREE(str);
@@ -37,7 +37,7 @@ static int net_serverid_list(struct net_context *c, int argc,
const char **argv)
{
d_printf("pid unique_id msg_flags\n");
- return serverid_traverse_read(net_serverid_list_fn, NULL) ? 0 : -1;
+ return serverid_traverse_read(net_serverid_list_fn, NULL) > 0 ? 0 : -1;
}
static int net_serverid_wipe_fn(struct db_record *rec,
@@ -51,7 +51,7 @@ static int net_serverid_wipe_fn(struct db_record *rec,
}
status = rec->delete_rec(rec);
if (!NT_STATUS_IS_OK(status)) {
- char *str = procid_str(talloc_tos(), id);
+ char *str = server_id_str(talloc_tos(), id);
DEBUG(1, ("Could not delete serverid.tdb record %s: %s\n",
str, nt_errstr(status)));
TALLOC_FREE(str);
@@ -62,7 +62,7 @@ static int net_serverid_wipe_fn(struct db_record *rec,
static int net_serverid_wipe(struct net_context *c, int argc,
const char **argv)
{
- return serverid_traverse(net_serverid_wipe_fn, NULL) ? 0 : -1;
+ return serverid_traverse(net_serverid_wipe_fn, NULL) > 0 ? 0 : -1;
}
static int net_serverid_wipedbs_conn(
@@ -75,13 +75,13 @@ static int net_serverid_wipedbs_conn(
NTSTATUS status;
DEBUG(10, ("Deleting connections.tdb record for pid %s\n",
- procid_str(talloc_tos(), &key->pid)));
+ server_id_str(talloc_tos(), &key->pid)));
status = rec->delete_rec(rec);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Could not delete connections.tdb record "
"for pid %s: %s\n",
- procid_str(talloc_tos(), &key->pid),
+ server_id_str(talloc_tos(), &key->pid),
nt_errstr(status)));
}
}
@@ -97,13 +97,13 @@ static int net_serverid_wipedbs_sessionid(struct db_record *rec,
NTSTATUS status;
DEBUG(10, ("Deleting sessionid.tdb record for pid %s\n",
- procid_str(talloc_tos(), &session->pid)));
+ server_id_str(talloc_tos(), &session->pid)));
status = rec->delete_rec(rec);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Could not delete session.tdb record "
"for pid %s: %s\n",
- procid_str(talloc_tos(), &session->pid),
+ server_id_str(talloc_tos(), &session->pid),
nt_errstr(status)));
}
}
diff --git a/source3/utils/net_share.c b/source3/utils/net_share.c
index 156b27b572a..6eca9d64ceb 100644
--- a/source3/utils/net_share.c
+++ b/source3/utils/net_share.c
@@ -62,7 +62,7 @@ int net_share_usage(struct net_context *c, int argc, const char **argv)
int net_share(struct net_context *c, int argc, const char **argv)
{
- if (argc > 0 && StrCaseCmp(argv[0], "HELP") == 0) {
+ if (argc > 0 && strcasecmp_m(argv[0], "HELP") == 0) {
net_share_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index fdb46dbba50..9b6293ed499 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -19,40 +19,25 @@
#include "includes.h"
#include "utils/net.h"
#include "libsmb/nmblib.h"
+#include "libsmb/libsmb.h"
/*
return the time on a server. This does not require any authentication
*/
static time_t cli_servertime(const char *host, struct sockaddr_storage *pss, int *zone)
{
- struct nmb_name calling, called;
time_t ret = 0;
struct cli_state *cli = NULL;
NTSTATUS status;
- cli = cli_initialise();
- if (!cli) {
- goto done;
- }
-
- status = cli_connect(cli, host, pss);
+ status = cli_connect_nb(host, pss, 0, 0x20, lp_netbios_name(),
+ Undefined, &cli);
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, _("Can't contact server %s. Error %s\n"),
host, nt_errstr(status));
goto done;
}
- make_nmb_name(&calling, global_myname(), 0x0);
- if (host) {
- make_nmb_name(&called, host, 0x20);
- } else {
- make_nmb_name(&called, "*SMBSERVER", 0x20);
- }
-
- if (!cli_session_request(cli, &calling, &called)) {
- fprintf(stderr, _("Session request failed\n"));
- goto done;
- }
status = cli_negprot(cli);
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, _("Protocol negotiation failed: %s\n"),
diff --git a/source3/utils/net_user.c b/source3/utils/net_user.c
index 2cf00170de4..9fb6f80f929 100644
--- a/source3/utils/net_user.c
+++ b/source3/utils/net_user.c
@@ -50,7 +50,7 @@ int net_user(struct net_context *c, int argc, const char **argv)
if (argc < 1)
return net_user_usage(c, argc, argv);
- if (StrCaseCmp(argv[0], "HELP") == 0) {
+ if (strcasecmp_m(argv[0], "HELP") == 0) {
net_user_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c
index 06ed4533d55..295f9ce4d9b 100644
--- a/source3/utils/net_usershare.c
+++ b/source3/utils/net_usershare.c
@@ -278,7 +278,7 @@ static int get_share_list(TALLOC_CTX *ctx, const char *wcard, bool only_ours)
}
/* (Finally) - add to list. */
- fl = TALLOC_P(ctx, struct file_list);
+ fl = talloc(ctx, struct file_list);
if (!fl) {
sys_closedir(dp);
return -1;
diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c
index ffcda14e7fd..0b8bd839d1b 100644
--- a/source3/utils/net_util.c
+++ b/source3/utils/net_util.c
@@ -27,6 +27,7 @@
#include "../librpc/gen_ndr/ndr_dssetup_c.h"
#include "secrets.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
NTSTATUS net_rpc_lookup_name(struct net_context *c,
TALLOC_CTX *mem_ctx, struct cli_state *cli,
@@ -359,7 +360,7 @@ int net_use_krb_machine_account(struct net_context *c)
c->opt_password = secrets_fetch_machine_password(
c->opt_target_workgroup, NULL, NULL);
- if (asprintf(&user_name, "%s$@%s", global_myname(), lp_realm()) == -1) {
+ if (asprintf(&user_name, "%s$@%s", lp_netbios_name(), lp_realm()) == -1) {
return -1;
}
c->opt_user_name = user_name;
@@ -381,7 +382,7 @@ int net_use_machine_account(struct net_context *c)
c->opt_password = secrets_fetch_machine_password(
c->opt_target_workgroup, NULL, NULL);
- if (asprintf(&user_name, "%s$", global_myname()) == -1) {
+ if (asprintf(&user_name, "%s$", lp_netbios_name()) == -1) {
return -1;
}
c->opt_user_name = user_name;
@@ -585,7 +586,7 @@ int net_run_function(struct net_context *c, int argc, const char **argv,
if (argc != 0) {
for (i=0; table[i].funcname != NULL; i++) {
- if (StrCaseCmp(argv[0], table[i].funcname) == 0)
+ if (strcasecmp_m(argv[0], table[i].funcname) == 0)
return table[i].fn(c, argc-1, argv+1);
}
}
diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c
index b160ee55863..5d81d43634e 100644
--- a/source3/utils/netlookup.c
+++ b/source3/utils/netlookup.c
@@ -24,6 +24,7 @@
#include "rpc_client/cli_pipe.h"
#include "../librpc/gen_ndr/ndr_lsa.h"
#include "rpc_client/cli_lsarpc.h"
+#include "libsmb/libsmb.h"
/********************************************************
Connection cachine struct. Goes away when ctx destroyed.
@@ -77,7 +78,7 @@ static struct con_struct *create_cs(struct net_context *c,
return cs;
}
- cs = TALLOC_P(ctx, struct con_struct);
+ cs = talloc(ctx, struct con_struct);
if (!cs) {
*perr = NT_STATUS_NO_MEMORY;
return NULL;
@@ -97,7 +98,7 @@ static struct con_struct *create_cs(struct net_context *c,
}
#endif
- nt_status = cli_full_connection(&cs->cli, global_myname(), global_myname(),
+ nt_status = cli_full_connection(&cs->cli, lp_netbios_name(), lp_netbios_name(),
&loopback_ss, 0,
"IPC$", "IPC",
#if 0
diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c
index f8545401e6a..73db278e364 100644
--- a/source3/utils/nmblookup.c
+++ b/source3/utils/nmblookup.c
@@ -168,27 +168,9 @@ static bool query_one(const char *lookup, unsigned int lookup_type)
&bcast_addr, talloc_tos(),
&ip_list, &count, &flags);
} else {
- const struct in_addr *bcast;
- for (j=iface_count() - 1;
- !ip_list && j >= 0;
- j--) {
- char addr[INET6_ADDRSTRLEN];
- struct sockaddr_storage bcast_ss;
-
- bcast = iface_n_bcast_v4(j);
- if (!bcast) {
- continue;
- }
- in_addr_to_sockaddr_storage(&bcast_ss, *bcast);
- print_sockaddr(addr, sizeof(addr), &bcast_ss);
- d_printf("querying %s on %s\n",
- lookup, addr);
- status = name_query(lookup,lookup_type,
- use_bcast,
- use_bcast?True:recursion_desired,
- &bcast_ss, talloc_tos(),
- &ip_list, &count, &flags);
- }
+ status = name_resolve_bcast(
+ lookup, lookup_type,
+ talloc_tos(), &ip_list, &count);
}
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index 73f41a7fe66..ba11ec73685 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -217,7 +217,7 @@ const char *get_winbind_netbios_name(void)
if (winbindd_request_response(WINBINDD_NETBIOS_NAME, NULL, &response) !=
NSS_STATUS_SUCCESS) {
DEBUG(0, ("could not obtain winbind netbios name!\n"));
- return global_myname();
+ return lp_netbios_name();
}
fstrcpy(winbind_netbios_name, response.data.netbios_name);
@@ -313,13 +313,13 @@ int get_pam_winbind_config()
opt_pam_winbind_conf = PAM_WINBIND_CONFIG_FILE;
}
- d = iniparser_load(CONST_DISCARD(char *, opt_pam_winbind_conf));
+ d = iniparser_load(discard_const_p(char, opt_pam_winbind_conf));
if (!d) {
return 0;
}
- if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:krb5_auth"), false)) {
+ if (iniparser_getboolean(d, discard_const_p(char, "global:krb5_auth"), false)) {
ctrl |= WINBIND_KRB5_AUTH;
}
@@ -657,7 +657,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
}
status = ntlmssp_client_start(NULL,
- global_myname(),
+ lp_netbios_name(),
lp_workgroup(),
lp_client_ntlmv2_auth(),
client_ntlmssp_state);
@@ -711,7 +711,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_server(struct ntlmssp_state **ntlmssp_st
bool is_standalone = false;
if (opt_password) {
- netbios_name = global_myname();
+ netbios_name = lp_netbios_name();
netbios_domain = lp_workgroup();
} else {
netbios_name = get_winbind_netbios_name();
@@ -1182,7 +1182,7 @@ static void offer_gss_spnego_mechs(void) {
ZERO_STRUCT(spnego);
- myname_lower = talloc_strdup(ctx, global_myname());
+ myname_lower = talloc_strdup(ctx, lp_netbios_name());
if (!myname_lower) {
return;
}
@@ -1722,7 +1722,7 @@ static void manage_client_ntlmssp_targ(struct spnego_data spnego)
spnego.type = SPNEGO_NEG_TOKEN_TARG;
spnego.negTokenTarg.negResult = SPNEGO_ACCEPT_INCOMPLETE;
- spnego.negTokenTarg.supportedMech = (char *)OID_NTLMSSP;
+ spnego.negTokenTarg.supportedMech = (const char *)OID_NTLMSSP;
spnego.negTokenTarg.responseToken = request;
spnego.negTokenTarg.mechListMIC = null_blob;
@@ -2063,7 +2063,7 @@ static void manage_ntlm_server_1_request(struct ntlm_auth_state *state,
if (!NT_STATUS_IS_OK(
contact_winbind_auth_crap(username,
domain,
- global_myname(),
+ lp_netbios_name(),
&challenge,
&lm_response,
&nt_response,
@@ -2680,7 +2680,7 @@ enum {
break;
case OPT_REQUIRE_MEMBERSHIP:
- if (StrnCaseCmp("S-", require_membership_of, 2) == 0) {
+ if (strncasecmp_m("S-", require_membership_of, 2) == 0) {
require_membership_of_sid = require_membership_of;
}
break;
diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c
index 1d7c6c12943..ab52e4727a2 100644
--- a/source3/utils/sharesec.c
+++ b/source3/utils/sharesec.c
@@ -312,7 +312,7 @@ static struct security_descriptor* parse_acl_string(TALLOC_CTX *mem_ctx, const c
pacl = szACL;
num_ace = count_chars( pacl, ',' ) + 1;
- if ( !(ace = TALLOC_ZERO_ARRAY( mem_ctx, struct security_ace, num_ace )) )
+ if ( !(ace = talloc_zero_array( mem_ctx, struct security_ace, num_ace )) )
return NULL;
for ( i=0; i<num_ace; i++ ) {
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index 45b4163c960..d226c84b9a7 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -27,6 +27,7 @@
#include "../librpc/gen_ndr/ndr_lsa.h"
#include "rpc_client/cli_lsarpc.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "passdb/machine_sid.h"
@@ -359,7 +360,12 @@ static bool parse_ace_flags(const char *str, unsigned int *pflags)
return false;
}
- if (*p != '|' && *p != '\0') {
+ switch (*p) {
+ case '|':
+ p++;
+ case '\0':
+ continue;
+ default:
return false;
}
}
@@ -1044,7 +1050,7 @@ static int inherit(struct cli_state *cli, const char *filename,
/* Add inherited flag to all aces */
ace->flags=ace->flags|
SEC_ACE_FLAG_INHERITED_ACE;
- if ((oldattr & aDIR) == aDIR) {
+ if ((oldattr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
if ((ace->flags & SEC_ACE_FLAG_CONTAINER_INHERIT) ==
SEC_ACE_FLAG_CONTAINER_INHERIT) {
add_ace(&old->dacl, ace);
@@ -1144,7 +1150,7 @@ static struct cli_state *connect_one(struct user_auth_info *auth_info,
set_cmdline_auth_info_getpass(auth_info);
- nt_status = cli_full_connection(&c, global_myname(), server,
+ nt_status = cli_full_connection(&c, lp_netbios_name(), server,
&ss, 0,
share, "?????",
get_cmdline_auth_info_username(auth_info),
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index ea1b6815887..5520dcf608a 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -31,6 +31,7 @@
#include "printing/notify.h"
#include "libsmb/nmblib.h"
#include "messages.h"
+#include "util_tdb.h"
#if HAVE_LIBUNWIND_H
#include <libunwind.h>
@@ -63,7 +64,7 @@ static bool send_message(struct messaging_context *msg_ctx,
if (procid_to_pid(&pid) != 0)
return NT_STATUS_IS_OK(
messaging_send_buf(msg_ctx, pid, msg_type,
- (uint8 *)buf, len));
+ (const uint8 *)buf, len));
ret = message_send_all(msg_ctx, msg_type, buf, len, &n_sent);
DEBUG(10,("smbcontrol/send_message: broadcast message to "
@@ -118,7 +119,7 @@ static void print_pid_string_cb(struct messaging_context *msg,
{
char *pidstr;
- pidstr = procid_str(talloc_tos(), &pid);
+ pidstr = server_id_str(talloc_tos(), &pid);
printf("PID %s: %.*s", pidstr, (int)data->length,
(const char *)data->data);
TALLOC_FREE(pidstr);
@@ -432,7 +433,7 @@ static void pong_cb(struct messaging_context *msg,
struct server_id pid,
DATA_BLOB *data)
{
- char *src_string = procid_str(NULL, &pid);
+ char *src_string = server_id_str(NULL, &pid);
printf("PONG from pid %s\n", src_string);
TALLOC_FREE(src_string);
num_replies++;
@@ -748,7 +749,7 @@ static bool do_printnotify(struct messaging_context *msg_ctx,
notify_printer_byname(messaging_event_context(msg_ctx),
msg_ctx, argv[2], attribute,
- CONST_DISCARD(char *, argv[4]));
+ discard_const_p(char, argv[4]));
goto send;
}
@@ -1142,7 +1143,7 @@ static void winbind_validate_cache_cb(struct messaging_context *msg,
struct server_id pid,
DATA_BLOB *data)
{
- char *src_string = procid_str(NULL, &pid);
+ char *src_string = server_id_str(NULL, &pid);
printf("Winbindd cache is %svalid. (answer from pid %s)\n",
(*(data->data) == 0 ? "" : "NOT "), src_string);
TALLOC_FREE(src_string);
@@ -1201,7 +1202,7 @@ static void my_make_nmb_name( struct nmb_name *n, const char *name, int type)
strupper_m(unix_name);
push_ascii(n->name, unix_name, sizeof(n->name), STR_TERMINATE);
n->name_type = (unsigned int)type & 0xFF;
- push_ascii(n->scope, global_scope(), 64, STR_TERMINATE);
+ push_ascii(n->scope, lp_netbios_scope(), 64, STR_TERMINATE);
}
static bool do_nodestatus(struct messaging_context *msg_ctx,
diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c
index 0efa60608b0..9858e0a3a87 100644
--- a/source3/utils/smbcquotas.c
+++ b/source3/utils/smbcquotas.c
@@ -28,6 +28,7 @@
#include "rpc_client/cli_lsarpc.h"
#include "fake_file.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
static char *server;
@@ -522,7 +523,7 @@ static struct cli_state *connect_one(const char *share)
set_cmdline_auth_info_getpass(smbcquotas_auth_info);
- nt_status = cli_full_connection(&c, global_myname(), server,
+ nt_status = cli_full_connection(&c, lp_netbios_name(), server,
&ss, 0,
share, "?????",
get_cmdline_auth_info_username(smbcquotas_auth_info),
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index fc65b3b570f..d60a13fd69b 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -17,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "includes.h"
+#include "system/filesys.h"
#include "popt_common.h"
#include "libsmbclient.h"
@@ -669,7 +670,7 @@ int main(int argc, const char **argv)
if (smb_encrypt) {
SMBCCTX *smb_ctx = smbc_set_context(NULL);
smbc_option_set(smb_ctx,
- CONST_DISCARD(char *, "smb_encrypt_level"),
+ discard_const_p(char, "smb_encrypt_level"),
"require");
}
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index ada057c2479..eeab4ef7de0 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -107,6 +107,7 @@ static int process_options(int argc, char **argv, int local_flags)
break;
case 'c':
configfile = optarg;
+ set_dyn_CONFIGFILE(optarg);
break;
case 'a':
local_flags |= LOCAL_ADD_USER;
@@ -378,7 +379,7 @@ static int process_root(int local_flags)
*/
slprintf(buf, sizeof(buf)-1, "%s$", user_name);
- fstrcpy(user_name, buf);
+ strlcpy(user_name, buf, sizeof(user_name));
} else if (local_flags & LOCAL_INTERDOM_ACCOUNT) {
static fstring buf;
@@ -395,7 +396,7 @@ static int process_root(int local_flags)
/* prepare uppercased and '$' terminated username */
slprintf(buf, sizeof(buf) - 1, "%s$", user_name);
- fstrcpy(user_name, buf);
+ strlcpy(user_name, buf, sizeof(user_name));
} else {
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index 3f7fc976986..41f4103e5a1 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -23,6 +23,7 @@
#include "popt_common.h"
#include "rpc_client/cli_pipe.h"
#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
static int use_bcast;
diff --git a/source3/utils/status.c b/source3/utils/status.c
index cf625fb73fa..4d37f7e66e5 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -474,7 +474,7 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
if (result == 0) {
d_printf("No locked files\n");
- } else if (result == -1) {
+ } else if (result < 0) {
d_printf("locked file list truncated\n");
}
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index 978ada26c65..721034dedff 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -39,7 +39,7 @@
Check if a directory exists.
********************************************************************/
-static bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st)
+static bool directory_exist_stat(const char *dname,SMB_STRUCT_STAT *st)
{
SMB_STRUCT_STAT st2;
bool ret;
@@ -77,7 +77,7 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
ret = 1;
}
- if (strequal(lp_workgroup(), global_myname())) {
+ if (strequal(lp_workgroup(), lp_netbios_name())) {
fprintf(stderr, "WARNING: 'workgroup' and 'netbios name' " \
"must differ.\n");
ret = 1;
@@ -128,20 +128,35 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
* Password server sanity checks.
*/
- if((lp_security() == SEC_SERVER || lp_security() >= SEC_DOMAIN) && !lp_passwordserver()) {
+ if((lp_security() == SEC_SERVER || lp_security() >= SEC_DOMAIN) && !*lp_passwordserver()) {
const char *sec_setting;
if(lp_security() == SEC_SERVER)
sec_setting = "server";
else if(lp_security() == SEC_DOMAIN)
sec_setting = "domain";
+ else if(lp_security() == SEC_ADS)
+ sec_setting = "ads";
else
sec_setting = "";
- fprintf(stderr, "ERROR: The setting 'security=%s' requires the 'password server' parameter be set \
-to a valid password server.\n", sec_setting );
+ fprintf(stderr, "ERROR: The setting 'security=%s' requires the 'password server' parameter be set\n"
+ "to the default value * or a valid password server.\n", sec_setting );
ret = 1;
}
+ if((lp_security() >= SEC_DOMAIN) && (strcmp(lp_passwordserver(), "*") != 0)) {
+ const char *sec_setting;
+ if(lp_security() == SEC_DOMAIN)
+ sec_setting = "domain";
+ else if(lp_security() == SEC_ADS)
+ sec_setting = "ads";
+ else
+ sec_setting = "";
+
+ fprintf(stderr, "WARNING: The setting 'security=%s' should NOT be combined with the 'password server' parameter.\n"
+ "(by default Samba will discover the correct DC to contact automatically).\n", sec_setting );
+ }
+
/*
* Password chat sanity checks.
*/
@@ -246,6 +261,11 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_
fprintf(stderr,"WARNING: Maximum value for 'os level' is 255!\n");
}
+ if (strequal(lp_dos_charset(), "UTF8") || strequal(lp_dos_charset(), "UTF-8")) {
+ fprintf(stderr, "ERROR: 'dos charset' must not be UTF8\n");
+ ret = 1;
+ }
+
return ret;
}
diff --git a/source3/web/cgi.c b/source3/web/cgi.c
index fa2304016ec..cc31eef97e5 100644
--- a/source3/web/cgi.c
+++ b/source3/web/cgi.c
@@ -118,7 +118,7 @@ void cgi_load_variables(void)
#ifdef DEBUG_COMMENTS
char dummy[100]="";
print_title(dummy);
- d_printf("<!== Start dump in cgi_load_variables() %s ==>\n",__FILE__);
+ printf("<!== Start dump in cgi_load_variables() %s ==>\n",__FILE__);
#endif
if (!content_length) {
@@ -275,7 +275,7 @@ static void cgi_setup_error(const char *err, const char *header, const char *inf
}
}
- d_printf("HTTP/1.0 %s\r\n%sConnection: close\r\nContent-Type: text/html\r\n\r\n<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><H1>%s</H1>%s<p></BODY></HTML>\r\n\r\n", err, header, err, err, info);
+ printf("HTTP/1.0 %s\r\n%sConnection: close\r\nContent-Type: text/html\r\n\r\n<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><H1>%s</H1>%s<p></BODY></HTML>\r\n\r\n", err, header, err, err, info);
fclose(stdin);
fclose(stdout);
exit(0);
diff --git a/source3/web/diagnose.c b/source3/web/diagnose.c
index cf93991f94c..abb4d79b9a7 100644
--- a/source3/web/diagnose.c
+++ b/source3/web/diagnose.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "web/swat_proto.h"
#include "lib/winbind_util.h"
+#include "libsmb/libsmb.h"
#ifdef WITH_WINBIND
@@ -69,15 +70,11 @@ bool smbd_running(void)
loopback_ip.s_addr = htonl(INADDR_LOOPBACK);
in_addr_to_sockaddr_storage(&ss, loopback_ip);
- if ((cli = cli_initialise()) == NULL)
- return False;
-
- status = cli_connect(cli, global_myname(), &ss);
+ status = cli_connect_nb("localhost", &ss, 0, 0x20, lp_netbios_name(),
+ Undefined, &cli);
if (!NT_STATUS_IS_OK(status)) {
- cli_shutdown(cli);
- return False;
+ return false;
}
-
cli_shutdown(cli);
return True;
}
diff --git a/source3/web/startstop.c b/source3/web/startstop.c
index 81350e62f5c..e23acf89313 100644
--- a/source3/web/startstop.c
+++ b/source3/web/startstop.c
@@ -19,7 +19,7 @@
#include "includes.h"
#include "web/swat_proto.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
/** Startup smbd from web interface. */
diff --git a/source3/web/swat.c b/source3/web/swat.c
index f06bf5ed26c..277b25c4268 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -83,7 +83,7 @@ static char *fix_backslash(const char *str)
return newstring;
}
-static const char *fix_quotes(TALLOC_CTX *ctx, const char *str)
+static const char *fix_quotes(TALLOC_CTX *ctx, char *str)
{
char *newstring = NULL;
char *p = NULL;
@@ -101,7 +101,7 @@ static const char *fix_quotes(TALLOC_CTX *ctx, const char *str)
}
++p;
}
- newstring = TALLOC_ARRAY(ctx, char, newstring_len);
+ newstring = talloc_array(ctx, char, newstring_len);
if (!newstring) {
return "";
}
diff --git a/source3/winbindd/idmap.c b/source3/winbindd/idmap.c
index 2eb655f7800..6ae10115b78 100644
--- a/source3/winbindd/idmap.c
+++ b/source3/winbindd/idmap.c
@@ -401,7 +401,7 @@ struct idmap_domain *idmap_find_domain(const char *domname)
/*
* talloc context for all idmap domains
*/
- idmap_domains = TALLOC_ARRAY(NULL, struct idmap_domain *, 1);
+ idmap_domains = talloc_array(NULL, struct idmap_domain *, 1);
}
if (idmap_domains == NULL) {
diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index cf15f038ca0..65b518074b5 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -216,7 +216,7 @@ static NTSTATUS idmap_ad_initialize(struct idmap_domain *dom)
char *config_option;
const char *schema_mode = NULL;
- ctx = TALLOC_ZERO_P(dom, struct idmap_ad_context);
+ ctx = talloc_zero(dom, struct idmap_ad_context);
if (ctx == NULL) {
DEBUG(0, ("Out of memory!\n"));
return NT_STATUS_NO_MEMORY;
@@ -736,7 +736,7 @@ static NTSTATUS nss_ad_generic_init(struct nss_domain_entry *e,
if (e->state != NULL) {
dom = talloc_get_type(e->state, struct idmap_domain);
} else {
- dom = TALLOC_ZERO_P(e, struct idmap_domain);
+ dom = talloc_zero(e, struct idmap_domain);
if (dom == NULL) {
DEBUG(0, ("Out of memory!\n"));
return NT_STATUS_NO_MEMORY;
@@ -756,7 +756,7 @@ static NTSTATUS nss_ad_generic_init(struct nss_domain_entry *e,
ctx = talloc_get_type(dom->private_data,
struct idmap_ad_context);
} else {
- ctx = TALLOC_ZERO_P(dom, struct idmap_ad_context);
+ ctx = talloc_zero(dom, struct idmap_ad_context);
if (ctx == NULL) {
DEBUG(0, ("Out of memory!\n"));
return NT_STATUS_NO_MEMORY;
diff --git a/source3/winbindd/idmap_adex/cell_util.c b/source3/winbindd/idmap_adex/cell_util.c
index c82407c0f48..194544086be 100644
--- a/source3/winbindd/idmap_adex/cell_util.c
+++ b/source3/winbindd/idmap_adex/cell_util.c
@@ -38,7 +38,7 @@
for (i = 0; i < num_lines; i++) {
/* make sure to avoid substring matches like uid
and uidNumber */
- if ((StrnCaseCmp(list[i], substr, cmplen) == 0) &&
+ if ((strncasecmp_m(list[i], substr, cmplen) == 0) &&
(list[i][cmplen] == '=')) {
/* Don't return an empty string */
if (list[i][cmplen + 1] != '\0')
@@ -110,7 +110,7 @@ static NTSTATUS cell_lookup_forest(struct likewise_cell *c)
return NT_STATUS_INVALID_PARAMETER;
}
- if ((gc = TALLOC_ZERO_P(NULL, struct gc_info)) == NULL) {
+ if ((gc = talloc_zero(NULL, struct gc_info)) == NULL) {
nt_status = NT_STATUS_NO_MEMORY;
BAIL_ON_NTSTATUS_ERROR(nt_status);
}
@@ -230,7 +230,7 @@ done:
while (next_token_talloc(frame, &tmp_dn, &buffer, ",")) {
/* skip everything up the where DC=... begins */
- if (StrnCaseCmp(buffer, "DC=", 3) != 0)
+ if (strncasecmp_m(buffer, "DC=", 3) != 0)
continue;
if (!domain) {
diff --git a/source3/winbindd/idmap_adex/domain_util.c b/source3/winbindd/idmap_adex/domain_util.c
index c3731064469..99dc0cca658 100644
--- a/source3/winbindd/idmap_adex/domain_util.c
+++ b/source3/winbindd/idmap_adex/domain_util.c
@@ -71,7 +71,7 @@ static NTSTATUS dc_add_domain(const char *domain)
return NT_STATUS_OK;
}
- dc = TALLOC_ZERO_P(NULL, struct dc_info);
+ dc = talloc_zero(NULL, struct dc_info);
BAIL_ON_PTR_ERROR(dc, nt_status);
dc->dns_name = talloc_strdup(dc, domain);
@@ -281,7 +281,7 @@ static struct dc_info *dc_find_domain(const char *dns_domain)
*cell = dc->domain_cell;
done:
- talloc_destroy(CONST_DISCARD(char*, base));
+ talloc_destroy(discard_const_p(char, base));
talloc_destroy(frame);
return nt_status;
diff --git a/source3/winbindd/idmap_adex/gc_util.c b/source3/winbindd/idmap_adex/gc_util.c
index 77b318cb2d7..461a2e679b7 100644
--- a/source3/winbindd/idmap_adex/gc_util.c
+++ b/source3/winbindd/idmap_adex/gc_util.c
@@ -107,6 +107,7 @@ done:
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct NETLOGON_SAM_LOGON_RESPONSE_EX cldap_reply;
TALLOC_CTX *frame = talloc_stackframe();
+ struct sockaddr_storage ss;
if (!gc || !domain) {
return NT_STATUS_INVALID_PARAMETER;
@@ -126,8 +127,17 @@ done:
nt_status = ads_ntstatus(ads_status);
BAIL_ON_NTSTATUS_ERROR(nt_status);
+ if (!resolve_name(ads->config.ldap_server_name, &ss, 0x20, true)) {
+ DEBUG(5,("gc_find_forest_root: unable to resolve name %s\n",
+ ads->config.ldap_server_name));
+ nt_status = NT_STATUS_IO_TIMEOUT;
+ /* This matches the old code which did the resolve in
+ * ads_cldap_netlogon_5 */
+ BAIL_ON_NTSTATUS_ERROR(nt_status);
+ }
+
if (!ads_cldap_netlogon_5(frame,
- ads->config.ldap_server_name,
+ &ss,
ads->config.realm,
&cldap_reply))
{
@@ -181,7 +191,7 @@ static NTSTATUS gc_add_forest(const char *domain)
return NT_STATUS_OK;
}
- if ((gc = TALLOC_ZERO_P(NULL, struct gc_info)) == NULL) {
+ if ((gc = talloc_zero(NULL, struct gc_info)) == NULL) {
nt_status = NT_STATUS_NO_MEMORY;
BAIL_ON_NTSTATUS_ERROR(nt_status);
}
@@ -771,17 +781,17 @@ done:
#endif
if (count == 0) {
- ads_tmp = TALLOC_ARRAY(NULL, ADS_STRUCT*, 1);
+ ads_tmp = talloc_array(NULL, ADS_STRUCT*, 1);
BAIL_ON_PTR_ERROR(ads_tmp, nt_status);
- msg_tmp = TALLOC_ARRAY(NULL, LDAPMessage*, 1);
+ msg_tmp = talloc_array(NULL, LDAPMessage*, 1);
BAIL_ON_PTR_ERROR(msg_tmp, nt_status);
} else {
- ads_tmp = TALLOC_REALLOC_ARRAY(*ads_list, *ads_list, ADS_STRUCT*,
+ ads_tmp = talloc_realloc(*ads_list, *ads_list, ADS_STRUCT*,
count+1);
BAIL_ON_PTR_ERROR(ads_tmp, nt_status);
- msg_tmp = TALLOC_REALLOC_ARRAY(*msg_list, *msg_list, LDAPMessage*,
+ msg_tmp = talloc_realloc(*msg_list, *msg_list, LDAPMessage*,
count+1);
BAIL_ON_PTR_ERROR(msg_tmp, nt_status);
}
diff --git a/source3/winbindd/idmap_adex/likewise_cell.c b/source3/winbindd/idmap_adex/likewise_cell.c
index 0914132b933..0e544e90f76 100644
--- a/source3/winbindd/idmap_adex/likewise_cell.c
+++ b/source3/winbindd/idmap_adex/likewise_cell.c
@@ -85,7 +85,7 @@ static struct likewise_cell *_lw_cell_list = NULL;
/* Each cell struct is a TALLOC_CTX* */
- c = TALLOC_ZERO_P(NULL, struct likewise_cell);
+ c = talloc_zero(NULL, struct likewise_cell);
if (!c) {
DEBUG(0,("cell_new: memory allocation failure!\n"));
return NULL;
diff --git a/source3/winbindd/idmap_adex/provider_unified.c b/source3/winbindd/idmap_adex/provider_unified.c
index b61666fa502..9e271a0db9e 100644
--- a/source3/winbindd/idmap_adex/provider_unified.c
+++ b/source3/winbindd/idmap_adex/provider_unified.c
@@ -237,7 +237,7 @@ static NTSTATUS search_cell(struct likewise_cell *c,
done:
PRINT_NTSTATUS_ERROR(nt_status, "search_cell", 4);
- talloc_destroy(CONST_DISCARD(char*, base));
+ talloc_destroy(discard_const_p(char, base));
talloc_destroy(frame);
return nt_status;
@@ -310,7 +310,7 @@ static bool check_forest_scope(const char *dn)
}
q++;
- if (StrnCaseCmp(q, "dc=", 3) != 0) {
+ if (strncasecmp_m(q, "dc=", 3) != 0) {
nt_status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
BAIL_ON_NTSTATUS_ERROR(nt_status);
}
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index 5e3dacf6240..cddbff2d478 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -28,6 +28,7 @@
#include "dbwrap.h"
#include "idmap.h"
#include "../libcli/security/dom_sid.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_IDMAP
@@ -376,7 +377,7 @@ static struct autorid_global_config *idmap_autorid_loadconfig(TALLOC_CTX * ctx)
return NULL;
}
- cfg = TALLOC_ZERO_P(ctx, struct autorid_global_config);
+ cfg = talloc_zero(ctx, struct autorid_global_config);
if (!cfg) {
return NULL;
}
@@ -435,7 +436,14 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
NTSTATUS status;
uint32_t hwm;
- config = TALLOC_ZERO_P(dom, struct autorid_global_config);
+ if (!strequal(dom->name, "*")) {
+ DEBUG(0, ("idmap_autorid_initialize: Error: autorid configured "
+ "for domain '%s'. But autorid can only be used for "
+ "the default idmap configuration.\n", dom->name));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ config = talloc_zero(dom, struct autorid_global_config);
if (!config) {
DEBUG(0, ("Out of memory!\n"));
return NT_STATUS_NO_MEMORY;
@@ -447,7 +455,7 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
}
config->minvalue = dom->low_id;
- config->rangesize = lp_parm_int(-1, "autorid", "rangesize", 100000);
+ config->rangesize = lp_parm_int(-1, "idmap config *", "rangesize", 100000);
if (config->rangesize < 2000) {
DEBUG(1, ("autorid rangesize must be at least 2000\n"));
@@ -522,14 +530,12 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
dom->private_data = config;
- if (!NT_STATUS_IS_OK(status)) {
- goto error;
- }
+ goto done;
- return NT_STATUS_OK;
-
- error:
+error:
talloc_free(config);
+
+done:
talloc_free(storedconfig);
return status;
diff --git a/source3/winbindd/idmap_hash/idmap_hash.c b/source3/winbindd/idmap_hash/idmap_hash.c
index 474387918e4..a6e883c4746 100644
--- a/source3/winbindd/idmap_hash/idmap_hash.c
+++ b/source3/winbindd/idmap_hash/idmap_hash.c
@@ -127,7 +127,7 @@ static NTSTATUS be_init(struct idmap_domain *dom)
/* Create the hash table of domain SIDs */
- hashed_domains = TALLOC_ZERO_ARRAY(dom, struct sid_hash_table, 4096);
+ hashed_domains = talloc_zero_array(dom, struct sid_hash_table, 4096);
BAIL_ON_PTR_NT_ERROR(hashed_domains, nt_status);
/* create the hash table of domain SIDs */
diff --git a/source3/winbindd/idmap_hash/mapfile.c b/source3/winbindd/idmap_hash/mapfile.c
index 28280590934..075f0f25cc4 100644
--- a/source3/winbindd/idmap_hash/mapfile.c
+++ b/source3/winbindd/idmap_hash/mapfile.c
@@ -87,8 +87,8 @@ static bool mapfile_read_line(fstring key, fstring value)
*p = '\0';
p++;
- fstrcpy(key, buffer);
- fstrcpy(value, p);
+ strlcpy(key, buffer, sizeof(fstring));
+ strlcpy(value, p, sizeof(fstring));
/* Eat whitespace */
diff --git a/source3/winbindd/idmap_ldap.c b/source3/winbindd/idmap_ldap.c
index 7195912fc38..10d9d2e8b63 100644
--- a/source3/winbindd/idmap_ldap.c
+++ b/source3/winbindd/idmap_ldap.c
@@ -232,8 +232,8 @@ done:
Allocate a new uid or gid
********************************/
-static NTSTATUS idmap_ldap_allocate_id(struct idmap_domain *dom,
- struct unixid *xid)
+static NTSTATUS idmap_ldap_allocate_id_internal(struct idmap_domain *dom,
+ struct unixid *xid)
{
TALLOC_CTX *mem_ctx;
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
@@ -391,21 +391,21 @@ done:
* For now this is for the default idmap domain only.
* Should be extended later on.
*/
-static NTSTATUS idmap_ldap_get_new_id(struct idmap_domain *dom,
- struct unixid *id)
+static NTSTATUS idmap_ldap_allocate_id(struct idmap_domain *dom,
+ struct unixid *id)
{
NTSTATUS ret;
if (!strequal(dom->name, "*")) {
- DEBUG(3, ("idmap_ldap_get_new_id: "
+ DEBUG(3, ("idmap_ldap_allocate_id: "
"Refusing allocation of a new unixid for domain'%s'. "
- "Currently only supported for the default "
+ "This is only supported for the default "
"domain \"*\".\n",
dom->name));
return NT_STATUS_NOT_IMPLEMENTED;
}
- ret = idmap_ldap_allocate_id(dom, id);
+ ret = idmap_ldap_allocate_id_internal(dom, id);
return ret;
}
@@ -443,7 +443,7 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom)
return NT_STATUS_FILE_IS_OFFLINE;
}
- ctx = TALLOC_ZERO_P(dom, struct idmap_ldap_context);
+ ctx = talloc_zero(dom, struct idmap_ldap_context);
if ( ! ctx) {
DEBUG(0, ("Out of memory!\n"));
return NT_STATUS_NO_MEMORY;
@@ -484,7 +484,7 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom)
ctx->rw_ops = talloc_zero(ctx, struct idmap_rw_ops);
CHECK_ALLOC_DONE(ctx->rw_ops);
- ctx->rw_ops->get_new_id = idmap_ldap_get_new_id;
+ ctx->rw_ops->get_new_id = idmap_ldap_allocate_id_internal;
ctx->rw_ops->set_mapping = idmap_ldap_set_mapping;
ret = smbldap_init(ctx, winbind_event_context(), ctx->url,
@@ -1144,7 +1144,7 @@ static struct idmap_methods idmap_ldap_methods = {
.init = idmap_ldap_db_init,
.unixids_to_sids = idmap_ldap_unixids_to_sids,
.sids_to_unixids = idmap_ldap_sids_to_unixids,
- .allocate_id = idmap_ldap_get_new_id,
+ .allocate_id = idmap_ldap_allocate_id,
};
NTSTATUS idmap_ldap_init(void);
diff --git a/source3/winbindd/idmap_proto.h b/source3/winbindd/idmap_proto.h
index fa7f7120246..4fa9ed1a268 100644
--- a/source3/winbindd/idmap_proto.h
+++ b/source3/winbindd/idmap_proto.h
@@ -1,3 +1,30 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * ID Mapping
+ *
+ * Copyright (C) Tim Potter 2000
+ * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
+ * Copyright (C) Simo Sorce 2003-2007
+ * Copyright (C) Jeremy Allison 2006
+ * Copyright (C) Michael Adam 2009-2010
+ *
+ * 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 _WINBINDD_IDMAP_PROTO_H_
+#define _WINBINDD_IDMAP_PROTO_H_
+
/* The following definitions come from winbindd/idmap.c */
bool idmap_is_offline(void);
@@ -31,3 +58,5 @@ NTSTATUS idmap_gid_to_sid(const char *domname, struct dom_sid *sid, gid_t gid);
NTSTATUS idmap_sid_to_uid(const char *dom_name, struct dom_sid *sid, uid_t *uid);
NTSTATUS idmap_sid_to_gid(const char *domname, struct dom_sid *sid, gid_t *gid);
bool idmap_unix_id_is_in_range(uint32_t id, struct idmap_domain *dom);
+
+#endif /* _WINBINDD_IDMAP_PROTO_H_ */
diff --git a/source3/winbindd/idmap_rid.c b/source3/winbindd/idmap_rid.c
index 8bb63fd534a..edc5e167740 100644
--- a/source3/winbindd/idmap_rid.c
+++ b/source3/winbindd/idmap_rid.c
@@ -41,7 +41,7 @@ static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom)
struct idmap_rid_context *ctx;
char *config_option = NULL;
- ctx = TALLOC_ZERO_P(dom, struct idmap_rid_context);
+ ctx = talloc_zero(dom, struct idmap_rid_context);
if (ctx == NULL) {
DEBUG(0, ("Out of memory!\n"));
return NT_STATUS_NO_MEMORY;
diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c
index 19e7f0e1d5f..d99d2f0e4e9 100644
--- a/source3/winbindd/idmap_tdb.c
+++ b/source3/winbindd/idmap_tdb.c
@@ -30,6 +30,7 @@
#include "idmap_rw.h"
#include "dbwrap.h"
#include "../libcli/security/security.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_IDMAP
@@ -145,9 +146,23 @@ static bool idmap_tdb_upgrade(struct idmap_domain *dom, struct db_context *db)
bool bigendianheader;
struct convert_fn_state s;
- DEBUG(0, ("Upgrading winbindd_idmap.tdb from an old version\n"));
-
+#if BUILD_TDB2
+ /* If we are bigendian, tdb is bigendian if NOT converted. */
+ union {
+ uint16 large;
+ unsigned char small[2];
+ } u;
+ u.large = 0x0102;
+ if (u.small[0] == 0x01)
+ bigendianheader = !(db->get_flags(db) & TDB_CONVERT);
+ else {
+ assert(u.small[0] == 0x02);
+ bigendianheader = (db->get_flags(db) & TDB_CONVERT);
+ }
+#else
bigendianheader = (db->get_flags(db) & TDB_BIGENDIAN) ? True : False;
+#endif
+ DEBUG(0, ("Upgrading winbindd_idmap.tdb from an old version\n"));
vers = dbwrap_fetch_int32(db, "IDMAP_VERSION");
diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c
index 1a5a51a5b44..2a152444595 100644
--- a/source3/winbindd/idmap_tdb2.c
+++ b/source3/winbindd/idmap_tdb2.c
@@ -38,6 +38,7 @@
#include "idmap_rw.h"
#include "dbwrap.h"
#include "../libcli/security/dom_sid.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_IDMAP
diff --git a/source3/winbindd/nss_info.c b/source3/winbindd/nss_info.c
index 77ac421d551..a3f95c64935 100644
--- a/source3/winbindd/nss_info.c
+++ b/source3/winbindd/nss_info.c
@@ -118,7 +118,7 @@ static NTSTATUS nss_domain_list_add_domain(const char *domain,
{
struct nss_domain_entry *nss_domain;
- nss_domain = TALLOC_ZERO_P(nss_domain_list, struct nss_domain_entry);
+ nss_domain = talloc_zero(nss_domain_list, struct nss_domain_entry);
if (!nss_domain) {
DEBUG(0, ("nss_domain_list_add_domain: talloc() failure!\n"));
return NT_STATUS_NO_MEMORY;
diff --git a/source3/winbindd/wb_fill_pwent.c b/source3/winbindd/wb_fill_pwent.c
index 23057384c2b..a716245ce85 100644
--- a/source3/winbindd/wb_fill_pwent.c
+++ b/source3/winbindd/wb_fill_pwent.c
@@ -72,8 +72,7 @@ static void wb_fill_pwent_sid2uid_done(struct tevent_req *subreq)
status = wb_sid2uid_recv(subreq, &state->pw->pw_uid);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -98,8 +97,7 @@ static void wb_fill_pwent_sid2gid_done(struct tevent_req *subreq)
status = wb_sid2gid_recv(subreq, &state->pw->pw_gid);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -131,7 +129,9 @@ static void wb_fill_pwent_sid2gid_done(struct tevent_req *subreq)
true);
}
- fstrcpy(state->pw->pw_name, output_username);
+ strlcpy(state->pw->pw_name,
+ output_username,
+ sizeof(state->pw->pw_name));
fstrcpy(state->pw->pw_gecos, state->info->full_name);
/* Home directory and shell */
@@ -194,7 +194,7 @@ static bool fillup_pw_field(const char *lp_template,
if (!templ)
return False;
- safe_strcpy(out, templ, sizeof(fstring) - 1);
+ strlcpy(out, templ, sizeof(fstring));
TALLOC_FREE(templ);
return True;
diff --git a/source3/winbindd/wb_getgrsid.c b/source3/winbindd/wb_getgrsid.c
index e55c1b0021b..7d7e56a5ca2 100644
--- a/source3/winbindd/wb_getgrsid.c
+++ b/source3/winbindd/wb_getgrsid.c
@@ -83,8 +83,7 @@ static void wb_getgrsid_lookupsid_done(struct tevent_req *subreq)
status = wb_lookupsid_recv(subreq, state, &state->type,
&state->domname, &state->name);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -115,8 +114,7 @@ static void wb_getgrsid_sid2gid_done(struct tevent_req *subreq)
status = wb_sid2gid_recv(subreq, &state->gid);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
subreq = wb_group_members_send(state, state->ev, &state->sid,
@@ -137,8 +135,7 @@ static void wb_getgrsid_got_members(struct tevent_req *subreq)
status = wb_group_members_recv(subreq, state, &state->members);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/wb_getpwsid.c b/source3/winbindd/wb_getpwsid.c
index 24ce7dc3f4f..3c942f0857c 100644
--- a/source3/winbindd/wb_getpwsid.c
+++ b/source3/winbindd/wb_getpwsid.c
@@ -74,8 +74,7 @@ static void wb_getpwsid_queryuser_done(struct tevent_req *subreq)
status = wb_queryuser_recv(subreq, state, &state->userinfo);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -118,8 +117,7 @@ static void wb_getpwsid_lookupsid_done(struct tevent_req *subreq)
status = wb_lookupsid_recv(subreq, state->userinfo, &type, &domain,
&state->userinfo->acct_name);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
subreq = wb_fill_pwent_send(state, state->ev, state->userinfo,
@@ -137,8 +135,7 @@ static void wb_getpwsid_done(struct tevent_req *subreq)
NTSTATUS status;
status = wb_fill_pwent_recv(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/wb_gettoken.c b/source3/winbindd/wb_gettoken.c
index 5c2af4abd64..aaaffa0bf20 100644
--- a/source3/winbindd/wb_gettoken.c
+++ b/source3/winbindd/wb_gettoken.c
@@ -90,8 +90,7 @@ static void wb_gettoken_gotgroups(struct tevent_req *subreq)
status = wb_lookupusergroups_recv(subreq, state, &state->num_sids,
&state->sids);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -135,8 +134,7 @@ static void wb_gettoken_gotlocalgroups(struct tevent_req *subreq)
status = wb_lookupuseraliases_recv(subreq, state, &num_rids, &rids);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
domain = find_domain_from_sid_noinit(get_global_sam_sid());
@@ -181,8 +179,7 @@ static void wb_gettoken_gotbuiltins(struct tevent_req *subreq)
status = wb_lookupuseraliases_recv(subreq, state, &num_rids, &rids);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
if (!wb_add_rids_to_sids(state, &state->num_sids, &state->sids,
diff --git a/source3/winbindd/wb_group_members.c b/source3/winbindd/wb_group_members.c
index c9603e73f8b..e6efcabfad4 100644
--- a/source3/winbindd/wb_group_members.c
+++ b/source3/winbindd/wb_group_members.c
@@ -155,8 +155,7 @@ static struct tevent_req *wb_groups_members_send(TALLOC_CTX *mem_ctx,
state->all_members = NULL;
status = wb_groups_members_next_subreq(state, state, &subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return tevent_req_post(req, ev);
}
if (subreq == NULL) {
@@ -210,8 +209,7 @@ static void wb_groups_members_done(struct tevent_req *subreq)
* and just continue if an error occured.
*/
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -235,8 +233,7 @@ static void wb_groups_members_done(struct tevent_req *subreq)
TALLOC_FREE(members);
status = wb_groups_members_next_subreq(state, state, &subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
if (subreq == NULL) {
@@ -313,8 +310,7 @@ struct tevent_req *wb_group_members_send(TALLOC_CTX *mem_ctx,
state->groups->type = type;
status = wb_group_members_next_subreq(state, state, &subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return tevent_req_post(req, ev);
}
if (subreq == NULL) {
@@ -361,8 +357,7 @@ static void wb_group_members_done(struct tevent_req *subreq)
status = wb_groups_members_recv(subreq, state, &num_members, &members);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -440,8 +435,7 @@ static void wb_group_members_done(struct tevent_req *subreq)
}
status = wb_group_members_next_subreq(state, state, &subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
if (subreq == NULL) {
diff --git a/source3/winbindd/wb_lookupname.c b/source3/winbindd/wb_lookupname.c
index a9b4dfa586d..2ebaba03d3f 100644
--- a/source3/winbindd/wb_lookupname.c
+++ b/source3/winbindd/wb_lookupname.c
@@ -91,8 +91,7 @@ static void wb_lookupname_done(struct tevent_req *subreq)
status = dcerpc_wbint_LookupName_recv(subreq, state, &result);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
if (NT_STATUS_IS_OK(result)) {
diff --git a/source3/winbindd/wb_lookupsid.c b/source3/winbindd/wb_lookupsid.c
index 2e1b21a8d88..2ab3917ceb7 100644
--- a/source3/winbindd/wb_lookupsid.c
+++ b/source3/winbindd/wb_lookupsid.c
@@ -76,8 +76,7 @@ static void wb_lookupsid_done(struct tevent_req *subreq)
status = dcerpc_wbint_LookupSid_recv(subreq, state, &result);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
if (NT_STATUS_IS_OK(result)) {
diff --git a/source3/winbindd/wb_lookupsids.c b/source3/winbindd/wb_lookupsids.c
index 05601ad192b..03b2ca9029b 100644
--- a/source3/winbindd/wb_lookupsids.c
+++ b/source3/winbindd/wb_lookupsids.c
@@ -128,26 +128,26 @@ struct tevent_req *wb_lookupsids_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- state->single_sids = TALLOC_ARRAY(state, uint32_t, num_sids);
+ state->single_sids = talloc_array(state, uint32_t, num_sids);
if (tevent_req_nomem(state->single_sids, req)) {
return tevent_req_post(req, ev);
}
- state->res_domains = TALLOC_ZERO_P(state, struct lsa_RefDomainList);
+ state->res_domains = talloc_zero(state, struct lsa_RefDomainList);
if (tevent_req_nomem(state->res_domains, req)) {
return tevent_req_post(req, ev);
}
- state->res_domains->domains = TALLOC_ARRAY(
+ state->res_domains->domains = talloc_array(
state->res_domains, struct lsa_DomainInfo, num_sids);
if (tevent_req_nomem(state->res_domains->domains, req)) {
return tevent_req_post(req, ev);
}
- state->res_names = TALLOC_ZERO_P(state, struct lsa_TransNameArray);
+ state->res_names = talloc_zero(state, struct lsa_TransNameArray);
if (tevent_req_nomem(state->res_names, req)) {
return tevent_req_post(req, ev);
}
- state->res_names->names = TALLOC_ARRAY(
+ state->res_names->names = talloc_array(
state->res_names, struct lsa_TranslatedName, num_sids);
if (tevent_req_nomem(state->res_names->names, req)) {
return tevent_req_post(req, ev);
@@ -187,7 +187,7 @@ static bool wb_lookupsids_next(struct tevent_req *req,
if (sid_check_is_domain(&d->sid)) {
state->rids.num_rids = d->sids.num_sids;
- state->rids.rids = TALLOC_ARRAY(state, uint32_t,
+ state->rids.rids = talloc_array(state, uint32_t,
state->rids.num_rids);
if (tevent_req_nomem(state->rids.rids, req)) {
return false;
@@ -325,7 +325,7 @@ static struct wb_lookupsids_domain *wb_lookupsids_get_domain(
return NULL;
}
- domains = TALLOC_REALLOC_ARRAY(
+ domains = talloc_realloc(
mem_ctx, domains, struct wb_lookupsids_domain, num_domains+1);
if (domains == NULL) {
return NULL;
@@ -337,13 +337,13 @@ static struct wb_lookupsids_domain *wb_lookupsids_get_domain(
sid_split_rid(&domain->sid, NULL);
domain->domain = wb_domain;
- domain->sids.sids = TALLOC_ARRAY(domains, struct lsa_SidPtr, num_sids);
+ domain->sids.sids = talloc_array(domains, struct lsa_SidPtr, num_sids);
if (domains->sids.sids == NULL) {
goto fail;
}
domain->sids.num_sids = 0;
- domain->sid_indexes = TALLOC_ARRAY(domains, uint32_t, num_sids);
+ domain->sid_indexes = talloc_array(domains, uint32_t, num_sids);
if (domain->sid_indexes == NULL) {
TALLOC_FREE(domain->sids.sids);
goto fail;
@@ -354,7 +354,7 @@ fail:
/*
* Realloc to the state it was in before
*/
- *pdomains = TALLOC_REALLOC_ARRAY(
+ *pdomains = talloc_realloc(
mem_ctx, domains, struct wb_lookupsids_domain, num_domains);
return NULL;
}
@@ -428,6 +428,7 @@ static void wb_lookupsids_done(struct tevent_req *subreq)
req, struct wb_lookupsids_state);
struct wb_lookupsids_domain *d;
uint32_t i;
+ bool fallback = false;
NTSTATUS status, result;
@@ -437,13 +438,31 @@ static void wb_lookupsids_done(struct tevent_req *subreq)
return;
}
+ d = &state->domains[state->domains_done];
+
+ if (NT_STATUS_IS_ERR(result)) {
+ fallback = true;
+ } else if (state->tmp_names.count != d->sids.num_sids) {
+ fallback = true;
+ }
+
+ if (fallback) {
+ for (i=0; i < d->sids.num_sids; i++) {
+ uint32_t res_sid_index = d->sid_indexes[i];
+
+ state->single_sids[state->num_single_sids] =
+ res_sid_index;
+ state->num_single_sids += 1;
+ }
+ state->domains_done += 1;
+ wb_lookupsids_next(req, state);
+ return;
+ }
+
/*
- * Ignore "result" here. We depend on the individual states in
- * the translated names.
+ * Look at the individual states in the translated names.
*/
- d = &state->domains[state->domains_done];
-
for (i=0; i<state->tmp_names.count; i++) {
uint32_t res_sid_index = d->sid_indexes[i];
@@ -462,7 +481,7 @@ static void wb_lookupsids_done(struct tevent_req *subreq)
&state->tmp_domains, &state->tmp_names.names[i],
state->res_domains, state->res_names,
res_sid_index)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
}
@@ -525,7 +544,7 @@ static void wb_lookupsids_single_done(struct tevent_req *subreq)
&src_domains, &src_name,
state->res_domains, state->res_names,
res_sid_index)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
state->single_sids_done += 1;
@@ -544,6 +563,7 @@ static void wb_lookupsids_lookuprids_done(struct tevent_req *subreq)
NTSTATUS status, result;
struct wb_lookupsids_domain *d;
uint32_t i;
+ bool fallback = false;
status = dcerpc_wbint_LookupRids_recv(subreq, state, &result);
TALLOC_FREE(subreq);
@@ -552,6 +572,30 @@ static void wb_lookupsids_lookuprids_done(struct tevent_req *subreq)
}
d = &state->domains[state->domains_done];
+
+ if (NT_STATUS_IS_ERR(result)) {
+ fallback = true;
+ } else if (state->rid_names.num_principals != d->sids.num_sids) {
+ fallback = true;
+ }
+
+ if (fallback) {
+ for (i=0; i < d->sids.num_sids; i++) {
+ uint32_t res_sid_index = d->sid_indexes[i];
+
+ state->single_sids[state->num_single_sids] =
+ res_sid_index;
+ state->num_single_sids += 1;
+ }
+ state->domains_done += 1;
+ wb_lookupsids_next(req, state);
+ return;
+ }
+
+ /*
+ * Look at the individual states in the translated names.
+ */
+
sid_copy(&src_domain_sid, get_global_sam_sid());
src_domain.name.string = get_global_sam_name();
src_domain.sid = &src_domain_sid;
@@ -575,7 +619,7 @@ static void wb_lookupsids_lookuprids_done(struct tevent_req *subreq)
&src_domains, &src_name,
state->res_domains, state->res_names,
res_sid_index)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
}
@@ -595,6 +639,24 @@ NTSTATUS wb_lookupsids_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
if (tevent_req_is_nterror(req, &status)) {
return status;
}
+
+ /*
+ * The returned names need to match the given sids,
+ * if not we have a bug in the code!
+ *
+ */
+ SMB_ASSERT(state->res_names->count == state->num_sids);
+
+ /*
+ * Not strictly needed, but it might make debugging in the callers
+ * easier in future, if the talloc_array_length() returns the
+ * expected result...
+ */
+ state->res_domains->domains = talloc_realloc(state->res_domains,
+ state->res_domains->domains,
+ struct lsa_DomainInfo,
+ state->res_domains->count);
+
*domains = talloc_move(mem_ctx, &state->res_domains);
*names = talloc_move(mem_ctx, &state->res_names);
return NT_STATUS_OK;
diff --git a/source3/winbindd/wb_lookupuseraliases.c b/source3/winbindd/wb_lookupuseraliases.c
index f6fe855a856..5e7eb1c33c2 100644
--- a/source3/winbindd/wb_lookupuseraliases.c
+++ b/source3/winbindd/wb_lookupuseraliases.c
@@ -44,7 +44,7 @@ struct tevent_req *wb_lookupuseraliases_send(TALLOC_CTX *mem_ctx,
return NULL;
}
state->sids.num_sids = num_sids;
- state->sids.sids = CONST_DISCARD(struct dom_sid *, sids);
+ state->sids.sids = discard_const_p(struct dom_sid, sids);
subreq = dcerpc_wbint_LookupUserAliases_send(
state, ev, dom_child_handle(domain), &state->sids, &state->rids);
diff --git a/source3/winbindd/wb_next_grent.c b/source3/winbindd/wb_next_grent.c
index c7af6416c49..2b3799ab93e 100644
--- a/source3/winbindd/wb_next_grent.c
+++ b/source3/winbindd/wb_next_grent.c
@@ -101,12 +101,11 @@ static void wb_next_grent_fetch_done(struct tevent_req *subreq)
status = dcerpc_wbint_QueryGroupList_recv(subreq, state, &result);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
+ if (tevent_req_nterror(req, status)) {
/* Ignore errors here, just log it */
DEBUG(10, ("query_user_list for domain %s returned %s\n",
state->gstate->domain->name,
nt_errstr(status)));
- tevent_req_nterror(req, status);
return;
}
if (!NT_STATUS_IS_OK(result)) {
@@ -169,8 +168,7 @@ static void wb_next_grent_getgrsid_done(struct tevent_req *subreq)
status = wb_getgrsid_recv(subreq, talloc_tos(), &domname, &name,
&state->gr->gr_gid, &state->members);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
if (!fill_grent(talloc_tos(), state->gr, domname, name,
diff --git a/source3/winbindd/wb_next_pwent.c b/source3/winbindd/wb_next_pwent.c
index 4595fbc6533..da4754cc9fc 100644
--- a/source3/winbindd/wb_next_pwent.c
+++ b/source3/winbindd/wb_next_pwent.c
@@ -148,8 +148,7 @@ static void wb_next_pwent_fill_done(struct tevent_req *subreq)
status = wb_fill_pwent_recv(subreq);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
state->gstate->next_user += 1;
diff --git a/source3/winbindd/wb_sid2gid.c b/source3/winbindd/wb_sid2gid.c
index 6c102a205c5..cb95191e7e3 100644
--- a/source3/winbindd/wb_sid2gid.c
+++ b/source3/winbindd/wb_sid2gid.c
@@ -94,8 +94,7 @@ static void wb_sid2gid_lookup_done(struct tevent_req *subreq)
status = wb_lookupsid_recv(subreq, talloc_tos(), &type, &domname,
&name);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
diff --git a/source3/winbindd/wb_sid2uid.c b/source3/winbindd/wb_sid2uid.c
index 5dd4b82eef3..a2e0f9712f9 100644
--- a/source3/winbindd/wb_sid2uid.c
+++ b/source3/winbindd/wb_sid2uid.c
@@ -93,8 +93,7 @@ static void wb_sid2uid_lookup_done(struct tevent_req *subreq)
status = wb_lookupsid_recv(subreq, talloc_tos(), &type, &domname,
&name);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index c5a124a628f..469d64e41d5 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -27,6 +27,7 @@
#include "winbindd.h"
#include "nsswitch/winbind_client.h"
#include "nsswitch/wb_reqtrans.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_lsa.h"
#include "../librpc/gen_ndr/srv_samr.h"
#include "secrets.h"
@@ -378,6 +379,7 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
{
uint8 ret;
pid_t child_pid;
+ NTSTATUS status;
DEBUG(10, ("winbindd_msg_validate_cache: got validate-cache "
"message.\n"));
@@ -404,7 +406,10 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
/* child */
- if (!winbindd_reinit_after_fork(NULL)) {
+ status = winbindd_reinit_after_fork(NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("winbindd_reinit_after_fork failed: %s\n",
+ nt_errstr(status)));
_exit(0);
}
@@ -445,11 +450,6 @@ static struct winbindd_dispatch_table {
{ WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" },
{ WINBINDD_CCACHE_SAVE, winbindd_ccache_save, "CCACHE_SAVE" },
- /* WINS functions */
-
- { WINBINDD_WINS_BYNAME, winbindd_wins_byname, "WINS_BYNAME" },
- { WINBINDD_WINS_BYIP, winbindd_wins_byip, "WINS_BYIP" },
-
/* End of list */
{ WINBINDD_NUM_CMDS, NULL, "NONE" }
@@ -540,6 +540,10 @@ static struct winbindd_async_dispatch_table async_nonpriv_table[] = {
{ WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP, "PAM_CHNG_PSWD_AUTH_CRAP",
winbindd_pam_chng_pswd_auth_crap_send,
winbindd_pam_chng_pswd_auth_crap_recv },
+ { WINBINDD_WINS_BYIP, "WINS_BYIP",
+ winbindd_wins_byip_send, winbindd_wins_byip_recv },
+ { WINBINDD_WINS_BYNAME, "WINS_BYNAME",
+ winbindd_wins_byname_send, winbindd_wins_byname_recv },
{ 0, NULL, NULL, NULL }
};
@@ -779,7 +783,7 @@ static void new_connection(int listen_sock, bool privileged)
/* Create new connection structure */
- if ((state = TALLOC_ZERO_P(NULL, struct winbindd_cli_state)) == NULL) {
+ if ((state = talloc_zero(NULL, struct winbindd_cli_state)) == NULL) {
close(sock);
return;
}
@@ -940,12 +944,12 @@ static void winbindd_listen_fde_handler(struct tevent_context *ev,
const char *get_winbind_pipe_dir(void)
{
- return lp_parm_const_string(-1, "winbindd", "socket dir", WINBINDD_SOCKET_DIR);
+ return lp_parm_const_string(-1, "winbindd", "socket dir", get_dyn_WINBINDD_SOCKET_DIR());
}
char *get_winbind_priv_pipe_dir(void)
{
- return lock_path(WINBINDD_PRIV_SOCKET_SUBDIR);
+ return state_path(WINBINDD_PRIV_SOCKET_SUBDIR);
}
static bool winbindd_setup_listeners(void)
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h
index 4f0f624d5be..3f1c7f558e2 100644
--- a/source3/winbindd/winbindd.h
+++ b/source3/winbindd/winbindd.h
@@ -30,6 +30,8 @@
#include "talloc_dict.h"
#include "smb_ldap.h"
+#include "../lib/util/tevent_ntstatus.h"
+
#ifdef HAVE_LIBNSCD
#include <libnscd.h>
#endif
diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c
index dde8e3f53d2..610db7a62b6 100644
--- a/source3/winbindd/winbindd_ads.c
+++ b/source3/winbindd/winbindd_ads.c
@@ -199,7 +199,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
goto done;
}
- (*pinfo) = TALLOC_ZERO_ARRAY(mem_ctx, struct wbint_userinfo, count);
+ (*pinfo) = talloc_zero_array(mem_ctx, struct wbint_userinfo, count);
if (!*pinfo) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -351,7 +351,7 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
goto done;
}
- (*info) = TALLOC_ZERO_ARRAY(mem_ctx, struct wb_acct_info, count);
+ (*info) = talloc_zero_array(mem_ctx, struct wb_acct_info, count);
if (!*info) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -489,7 +489,7 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
/* try netsamlogon cache first */
- if ( (user = netsamlogon_cache_get( mem_ctx, sid )) != NULL )
+ if (winbindd_use_cache() && (user = netsamlogon_cache_get( mem_ctx, sid )) != NULL )
{
DEBUG(5,("query_user: Cache lookup succeeded for %s\n",
sid_string_dbg(sid)));
@@ -769,7 +769,7 @@ static NTSTATUS lookup_usergroups_memberof(struct winbindd_domain *domain,
goto done;
}
- group_sids = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, num_strings + 1);
+ group_sids = talloc_zero_array(mem_ctx, struct dom_sid, num_strings + 1);
if (!group_sids) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -1085,10 +1085,10 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
* cache. Only the rest is passed to the lsa_lookup_sids call. */
if (num_members) {
- (*sid_mem) = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, num_members);
- (*names) = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_members);
- (*name_types) = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_members);
- (sid_mem_nocache) = TALLOC_ZERO_ARRAY(tmp_ctx, struct dom_sid, num_members);
+ (*sid_mem) = talloc_zero_array(mem_ctx, struct dom_sid, num_members);
+ (*names) = talloc_zero_array(mem_ctx, char *, num_members);
+ (*name_types) = talloc_zero_array(mem_ctx, uint32, num_members);
+ (sid_mem_nocache) = talloc_zero_array(tmp_ctx, struct dom_sid, num_members);
if ((members == NULL) || (*sid_mem == NULL) ||
(*names == NULL) || (*name_types == NULL) ||
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index 68a86257da2..58a8e710f6f 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -33,6 +33,7 @@
#include "nss_info.h"
#include "../libcli/security/security.h"
#include "passdb/machine_sid.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
@@ -308,7 +309,7 @@ static char *centry_string(struct cache_entry *centry, TALLOC_CTX *mem_ctx)
smb_panic_fn("centry_string");
}
- ret = TALLOC_ARRAY(mem_ctx, char, len+1);
+ ret = talloc_array(mem_ctx, char, len+1);
if (!ret) {
smb_panic_fn("centry_string out of memory\n");
}
@@ -338,7 +339,7 @@ static char *centry_hash16(struct cache_entry *centry, TALLOC_CTX *mem_ctx)
return NULL;
}
- ret = TALLOC_ARRAY(mem_ctx, char, 16);
+ ret = talloc_array(mem_ctx, char, 16);
if (!ret) {
smb_panic_fn("centry_hash out of memory\n");
}
@@ -483,9 +484,9 @@ bool wcache_store_seqnum(const char *domain_name, uint32_t seqnum,
ret = tdb_store_bystring(wcache->tdb, key_str,
make_tdb_data(buf, sizeof(buf)), TDB_REPLACE);
TALLOC_FREE(key_str);
- if (ret == -1) {
+ if (ret != 0) {
DEBUG(10, ("tdb_store_bystring failed: %s\n",
- tdb_errorstr(wcache->tdb)));
+ tdb_errorstr_compat(wcache->tdb)));
TALLOC_FREE(key_str);
return false;
}
@@ -637,7 +638,7 @@ static struct cache_entry *wcache_fetch_raw(char *kstr)
TDB_DATA key;
key = string_tdb_data(kstr);
- data = tdb_fetch(wcache->tdb, key);
+ data = tdb_fetch_compat(wcache->tdb, key);
if (!data.dptr) {
/* a cache miss */
return NULL;
@@ -1270,7 +1271,7 @@ NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const struct
fstr_sprintf(key_str, "CRED/%s", sid_to_fstring(tmp, sid));
- data = tdb_fetch(cache->tdb, string_tdb_data(key_str));
+ data = tdb_fetch_compat(cache->tdb, string_tdb_data(key_str));
if (!data.dptr) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
@@ -1295,6 +1296,10 @@ NTSTATUS wcache_get_creds(struct winbindd_domain *domain,
uint32 rid;
fstring tmp;
+ if (!winbindd_use_cache()) {
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
if (!cache->tdb) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
@@ -1431,7 +1436,7 @@ do_fetch_cache:
if (*num_entries == 0)
goto do_cached;
- (*info) = TALLOC_ARRAY(mem_ctx, struct wbint_userinfo, *num_entries);
+ (*info) = talloc_array(mem_ctx, struct wbint_userinfo, *num_entries);
if (! (*info)) {
smb_panic_fn("query_user_list out of memory");
}
@@ -1583,7 +1588,7 @@ do_fetch_cache:
if (*num_entries == 0)
goto do_cached;
- (*info) = TALLOC_ARRAY(mem_ctx, struct wb_acct_info, *num_entries);
+ (*info) = talloc_array(mem_ctx, struct wb_acct_info, *num_entries);
if (! (*info)) {
smb_panic_fn("enum_dom_groups out of memory");
}
@@ -1678,7 +1683,7 @@ do_fetch_cache:
if (*num_entries == 0)
goto do_cached;
- (*info) = TALLOC_ARRAY(mem_ctx, struct wb_acct_info, *num_entries);
+ (*info) = talloc_array(mem_ctx, struct wb_acct_info, *num_entries);
if (! (*info)) {
smb_panic_fn("enum_dom_groups out of memory");
}
@@ -1856,8 +1861,8 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
/* Only save the reverse mapping if this was not a UPN */
if (!strchr(name, '@')) {
- strupper_m(CONST_DISCARD(char *,domain_name));
- strlower_m(CONST_DISCARD(char *,name));
+ strupper_m(discard_const_p(char, domain_name));
+ strlower_m(discard_const_p(char, name));
wcache_save_sid_to_name(domain, status, sid, domain_name, name, *type);
}
}
@@ -2001,8 +2006,8 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain,
return NT_STATUS_OK;
}
- *names = TALLOC_ARRAY(mem_ctx, char *, num_rids);
- *types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_rids);
+ *names = talloc_array(mem_ctx, char *, num_rids);
+ *types = talloc_array(mem_ctx, enum lsa_SidType, num_rids);
if ((*names == NULL) || (*types == NULL)) {
result = NT_STATUS_NO_MEMORY;
@@ -2769,7 +2774,7 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
}
do_fetch_cache:
- trusts->array = TALLOC_ZERO_ARRAY(mem_ctx, struct netr_DomainTrust, num_domains);
+ trusts->array = talloc_zero_array(mem_ctx, struct netr_DomainTrust, num_domains);
if (!trusts->array) {
TALLOC_FREE(dom_list);
return NT_STATUS_NO_MEMORY;
@@ -3160,7 +3165,7 @@ bool initialize_winbindd_cache(void)
/* Write the version. */
if (!tdb_store_uint32(wcache->tdb, WINBINDD_CACHE_VERSION_KEYSTR, WINBINDD_CACHE_VERSION)) {
DEBUG(0,("initialize_winbindd_cache: version number store failed %s\n",
- tdb_errorstr(wcache->tdb) ));
+ tdb_errorstr_compat(wcache->tdb) ));
return false;
}
}
@@ -3378,7 +3383,7 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const
ret = tdb_traverse(cache->tdb, traverse_fn_get_credlist, NULL);
if (ret == 0) {
return NT_STATUS_OK;
- } else if ((ret == -1) || (wcache_cred_list == NULL)) {
+ } else if ((ret < 0) || (wcache_cred_list == NULL)) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
@@ -3389,7 +3394,7 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const
TDB_DATA data;
time_t t;
- data = tdb_fetch(cache->tdb, string_tdb_data(cred->name));
+ data = tdb_fetch_compat(cache->tdb, string_tdb_data(cred->name));
if (!data.dptr) {
DEBUG(10,("wcache_remove_oldest_cached_creds: entry for [%s] not found\n",
cred->name));
@@ -4198,10 +4203,10 @@ static bool add_wbdomain_to_tdc_array( struct winbindd_domain *new_dom,
if ( !set_only ) {
if ( !*domains ) {
- list = TALLOC_ARRAY( NULL, struct winbindd_tdc_domain, 1 );
+ list = talloc_array( NULL, struct winbindd_tdc_domain, 1 );
idx = 0;
} else {
- list = TALLOC_REALLOC_ARRAY( *domains, *domains,
+ list = talloc_realloc( *domains, *domains,
struct winbindd_tdc_domain,
(*num_domains)+1);
idx = *num_domains;
@@ -4341,7 +4346,7 @@ static size_t unpack_tdc_domains( unsigned char *buf, int buflen,
return 0;
}
- list = TALLOC_ARRAY( NULL, struct winbindd_tdc_domain, num_domains );
+ list = talloc_array( NULL, struct winbindd_tdc_domain, num_domains );
if ( !list ) {
DEBUG(0,("unpack_tdc_domains: Failed to talloc() domain list!\n"));
return 0;
@@ -4415,7 +4420,7 @@ static bool wcache_tdc_store_list( struct winbindd_tdc_domain *domains, size_t n
SAFE_FREE( data.dptr );
SAFE_FREE( key.dptr );
- return ( ret != -1 );
+ return ( ret == 0 );
}
/*********************************************************************
@@ -4432,7 +4437,7 @@ bool wcache_tdc_fetch_list( struct winbindd_tdc_domain **domains, size_t *num_do
if ( !key.dptr )
return false;
- data = tdb_fetch( wcache->tdb, key );
+ data = tdb_fetch_compat( wcache->tdb, key );
SAFE_FREE( key.dptr );
@@ -4522,7 +4527,7 @@ struct winbindd_tdc_domain * wcache_tdc_fetch_domain( TALLOC_CTX *ctx, const cha
DEBUG(10,("wcache_tdc_fetch_domain: Found domain %s\n",
name));
- d = TALLOC_P( ctx, struct winbindd_tdc_domain );
+ d = talloc( ctx, struct winbindd_tdc_domain );
if ( !d )
break;
@@ -4572,7 +4577,7 @@ struct winbindd_tdc_domain*
dom_list[i].domain_name,
sid_string_dbg(sid)));
- d = TALLOC_P(ctx, struct winbindd_tdc_domain);
+ d = talloc(ctx, struct winbindd_tdc_domain);
if (!d)
break;
@@ -4777,7 +4782,7 @@ bool wcache_fetch_ndr(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
if (!wcache_ndr_key(talloc_tos(), domain->name, opnum, req, &key)) {
return false;
}
- data = tdb_fetch(wcache->tdb, key);
+ data = tdb_fetch_compat(wcache->tdb, key);
TALLOC_FREE(key.dptr);
if (data.dptr == NULL) {
diff --git a/source3/winbindd/winbindd_ccache_access.c b/source3/winbindd/winbindd_ccache_access.c
index 6a265ccaf07..0b52ae2eb9a 100644
--- a/source3/winbindd/winbindd_ccache_access.c
+++ b/source3/winbindd/winbindd_ccache_access.c
@@ -55,7 +55,7 @@ static NTSTATUS do_ntlm_auth_with_hashes(const char *username,
DATA_BLOB dummy_msg, reply;
status = ntlmssp_client_start(NULL,
- global_myname(),
+ lp_netbios_name(),
lp_workgroup(),
lp_client_ntlmv2_auth(),
&ntlmssp_state);
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 1473d337218..86d6662e5a5 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -69,13 +69,13 @@
#include "rpc_client/cli_lsarpc.h"
#include "../librpc/gen_ndr/ndr_dssetup_c.h"
#include "libads/sitename_cache.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clidgram.h"
#include "ads.h"
#include "secrets.h"
#include "../libcli/security/security.h"
#include "passdb.h"
#include "messages.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
@@ -189,6 +189,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
TALLOC_CTX *mem_ctx = NULL;
pid_t parent_pid = sys_getpid();
char *lfile = NULL;
+ NTSTATUS status;
if (domain->dc_probe_pid != (pid_t)-1) {
/*
@@ -233,7 +234,10 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
}
}
- if (!winbindd_reinit_after_fork(lfile)) {
+ status = winbindd_reinit_after_fork(NULL, lfile);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("winbindd_reinit_after_fork failed: %s\n",
+ nt_errstr(status)));
messaging_send_buf(winbind_messaging_context(),
pid_to_procid(parent_pid),
MSG_WINBIND_FAILED_TO_GO_ONLINE,
@@ -816,7 +820,12 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain,
(*cli)->timeout = 10000; /* 10 seconds */
(*cli)->fd = sockfd;
- fstrcpy((*cli)->desthost, controller);
+ (*cli)->desthost = talloc_strdup((*cli), controller);
+ if ((*cli)->desthost == NULL) {
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
(*cli)->use_kerberos = True;
peeraddr_len = sizeof(peeraddr);
@@ -876,7 +885,7 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain,
(*cli)->use_kerberos = True;
DEBUG(5, ("connecting to %s from %s with kerberos principal "
- "[%s] and realm [%s]\n", controller, global_myname(),
+ "[%s] and realm [%s]\n", controller, lp_netbios_name(),
machine_krb5_principal, domain->alt_name));
winbindd_set_locator_kdc_envs(domain);
@@ -907,7 +916,7 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain,
(*cli)->use_kerberos = False;
DEBUG(5, ("connecting to %s from %s with username "
- "[%s]\\[%s]\n", controller, global_myname(),
+ "[%s]\\[%s]\n", controller, lp_netbios_name(),
lp_workgroup(), machine_account));
ads_status = cli_session_setup_spnego(*cli,
@@ -943,7 +952,7 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain,
/* Only try authenticated if we have a username */
DEBUG(5, ("connecting to %s from %s with username "
- "[%s]\\[%s]\n", controller, global_myname(),
+ "[%s]\\[%s]\n", controller, lp_netbios_name(),
ipc_domain, ipc_username));
if (NT_STATUS_IS_OK(cli_session_setup(
@@ -1073,7 +1082,7 @@ static bool add_one_dc_unique(TALLOC_CTX *mem_ctx, const char *domain_name,
(struct sockaddr *)(void *)pss))
return False;
- *dcs = TALLOC_REALLOC_ARRAY(mem_ctx, *dcs, struct dc_name_ip, (*num)+1);
+ *dcs = talloc_realloc(mem_ctx, *dcs, struct dc_name_ip, (*num)+1);
if (*dcs == NULL)
return False;
@@ -1088,7 +1097,7 @@ static bool add_sockaddr_to_array(TALLOC_CTX *mem_ctx,
struct sockaddr_storage *pss, uint16 port,
struct sockaddr_storage **addrs, int *num)
{
- *addrs = TALLOC_REALLOC_ARRAY(mem_ctx, *addrs, struct sockaddr_storage, (*num)+1);
+ *addrs = talloc_realloc(mem_ctx, *addrs, struct sockaddr_storage, (*num)+1);
if (*addrs == NULL) {
*num = 0;
@@ -1375,7 +1384,7 @@ static bool find_new_dc(TALLOC_CTX *mem_ctx,
return False;
status = smbsock_any_connect(addrs, dcnames, NULL, NULL, NULL,
- num_addrs, 0, fd, &fd_index, NULL);
+ num_addrs, 0, 10, fd, &fd_index, NULL);
if (!NT_STATUS_IS_OK(status)) {
for (i=0; i<num_dcs; i++) {
char ab[INET6_ADDRSTRLEN];
@@ -1541,7 +1550,7 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
return NT_STATUS_UNSUCCESSFUL;
}
if (dcip_to_name(mem_ctx, domain, &ss, saf_name )) {
- fstrcpy( domain->dcname, saf_name );
+ strlcpy(domain->dcname, saf_name, sizeof(domain->dcname));
} else {
winbind_add_failed_connection_entry(
domain, saf_servername,
@@ -1571,7 +1580,7 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
status = smbsock_connect(&domain->dcaddr, 0,
NULL, -1, NULL, -1,
- &fd, NULL);
+ &fd, NULL, 10);
if (!NT_STATUS_IS_OK(status)) {
fd = -1;
}
@@ -1699,6 +1708,7 @@ void invalidate_cm_connection(struct winbindd_cm_conn *conn)
void close_conns_after_fork(void)
{
struct winbindd_domain *domain;
+ struct winbindd_cli_state *cli_state;
for (domain = domain_list(); domain; domain = domain->next) {
struct cli_state *cli = domain->conn.cli;
@@ -1715,6 +1725,15 @@ void close_conns_after_fork(void)
invalidate_cm_connection(&domain->conn);
}
+
+ for (cli_state = winbindd_client_list();
+ cli_state != NULL;
+ cli_state = cli_state->next) {
+ if (cli_state->sock >= 0) {
+ close(cli_state->sock);
+ cli_state->sock = -1;
+ }
+ }
}
static bool connection_ok(struct winbindd_domain *domain)
@@ -1985,7 +2004,7 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain )
* no_dssetup mode here as well to get domain->initialized
* set - gd */
- if (NT_STATUS_V(status) == DCERPC_FAULT_OP_RNG_ERROR) {
+ if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE)) {
goto no_dssetup;
}
@@ -2608,7 +2627,7 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
netlogon_pipe,
domain->dcname, /* server name. */
domain->name, /* domain name */
- global_myname(), /* client name */
+ lp_netbios_name(), /* client name */
account_name, /* machine account */
mach_pwd, /* machine password */
sec_chan_type, /* from get_trust_pw */
diff --git a/source3/winbindd/winbindd_cred_cache.c b/source3/winbindd/winbindd_cred_cache.c
index ab8934bfd4a..5e79a96ca76 100644
--- a/source3/winbindd/winbindd_cred_cache.c
+++ b/source3/winbindd/winbindd_cred_cache.c
@@ -596,7 +596,7 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
return NT_STATUS_OK;
}
- entry = TALLOC_P(NULL, struct WINBINDD_CCACHE_ENTRY);
+ entry = talloc(NULL, struct WINBINDD_CCACHE_ENTRY);
if (!entry) {
return NT_STATUS_NO_MEMORY;
}
@@ -908,7 +908,7 @@ static NTSTATUS winbindd_add_memory_creds_internal(const char *username,
return winbindd_replace_memory_creds_internal(memcredp, pass);
}
- memcredp = TALLOC_ZERO_P(NULL, struct WINBINDD_MEMORY_CREDS);
+ memcredp = talloc_zero(NULL, struct WINBINDD_MEMORY_CREDS);
if (!memcredp) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/winbindd/winbindd_creds.c b/source3/winbindd/winbindd_creds.c
index 6bbd0ffd9d1..a160f7a6b5b 100644
--- a/source3/winbindd/winbindd_creds.c
+++ b/source3/winbindd/winbindd_creds.c
@@ -38,6 +38,10 @@ NTSTATUS winbindd_get_creds(struct winbindd_domain *domain,
struct netr_SamInfo3 *info;
NTSTATUS status;
+ if (!winbindd_use_cache()) {
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
status = wcache_get_creds(domain, mem_ctx, sid, cached_nt_pass, cred_salt);
if (!NT_STATUS_IS_OK(status)) {
return status;
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 0a1534cae1a..5bf90b12223 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -35,7 +35,7 @@
#include "../libcli/security/security.h"
#include "system/select.h"
#include "messages.h"
-#include "ntdomain.h"
+#include "../lib/util/tevent_unix.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
@@ -127,7 +127,7 @@ struct tevent_req *wb_child_request_send(TALLOC_CTX *mem_ctx,
if (!tevent_queue_add(child->queue, ev, req,
wb_child_request_trigger, NULL)) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return tevent_req_post(req, ev);
}
return req;
@@ -510,6 +510,11 @@ void winbind_child_died(pid_t pid)
DLIST_REMOVE(winbindd_children, child);
child->pid = 0;
+
+ if (child->sock != -1) {
+ close(child->sock);
+ child->sock = -1;
+ }
}
/* Ensure any negative cache entries with the netbios or realm names are removed. */
@@ -741,7 +746,7 @@ void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
}
messaging_send_buf(msg_ctx, *sender, MSG_WINBIND_ONLINESTATUS,
- (uint8 *)message, strlen(message) + 1);
+ (const uint8 *)message, strlen(message) + 1);
talloc_destroy(mem_ctx);
}
@@ -818,7 +823,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
messaging_send_buf(msg_ctx, *sender,
MSG_WINBIND_DUMP_DOMAIN_LIST,
- (uint8_t *)message, strlen(message) + 1);
+ (const uint8_t *)message, strlen(message) + 1);
talloc_destroy(mem_ctx);
@@ -1166,7 +1171,8 @@ static void child_msg_dump_event_list(struct messaging_context *msg,
dump_event_list(winbind_event_context());
}
-bool winbindd_reinit_after_fork(const char *logfilename)
+NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
+ const char *logfilename)
{
struct winbindd_domain *domain;
struct winbindd_child *cl;
@@ -1179,7 +1185,7 @@ bool winbindd_reinit_after_fork(const char *logfilename)
true);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n"));
- return false;
+ return status;
}
close_conns_after_fork();
@@ -1190,10 +1196,10 @@ bool winbindd_reinit_after_fork(const char *logfilename)
}
if (!winbindd_setup_sig_term_handler(false))
- return false;
+ return NT_STATUS_NO_MEMORY;
if (!winbindd_setup_sig_hup_handler(override_logfile ? NULL :
logfilename))
- return false;
+ return NT_STATUS_NO_MEMORY;
/* Stop zombies in children */
CatchChild();
@@ -1241,6 +1247,14 @@ bool winbindd_reinit_after_fork(const char *logfilename)
* go through the parent.
*/
cl->pid = (pid_t)0;
+
+ /*
+ * Close service sockets to all other children
+ */
+ if ((cl != myself) && (cl->sock != -1)) {
+ close(cl->sock);
+ cl->sock = -1;
+ }
}
/*
* This is a little tricky, children must not
@@ -1261,7 +1275,7 @@ bool winbindd_reinit_after_fork(const char *logfilename)
cl = idmap_child();
cl->pid = (pid_t)0;
- return true;
+ return NT_STATUS_OK;
}
/*
@@ -1281,6 +1295,8 @@ static bool fork_domain_child(struct winbindd_child *child)
struct winbindd_request request;
struct winbindd_response response;
struct winbindd_domain *primary_domain = NULL;
+ NTSTATUS status;
+ ssize_t nwritten;
if (child->domain) {
DEBUG(10, ("fork_domain_child called for domain '%s'\n",
@@ -1309,7 +1325,25 @@ static bool fork_domain_child(struct winbindd_child *child)
if (child->pid != 0) {
/* Parent */
+ ssize_t nread;
+
close(fdpair[0]);
+
+ nread = read(fdpair[1], &status, sizeof(status));
+ if (nread != sizeof(status)) {
+ DEBUG(1, ("fork_domain_child: Could not read child status: "
+ "nread=%d, error=%s\n", (int)nread,
+ strerror(errno)));
+ close(fdpair[1]);
+ return false;
+ }
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("fork_domain_child: Child status is %s\n",
+ nt_errstr(status)));
+ close(fdpair[1]);
+ return false;
+ }
+
child->next = child->prev = NULL;
DLIST_ADD(winbindd_children, child);
child->sock = fdpair[1];
@@ -1324,7 +1358,18 @@ static bool fork_domain_child(struct winbindd_child *child)
state.sock = fdpair[0];
close(fdpair[1]);
- if (!winbindd_reinit_after_fork(child->logfilename)) {
+ status = winbindd_reinit_after_fork(child, child->logfilename);
+
+ nwritten = write(state.sock, &status, sizeof(status));
+ if (nwritten != sizeof(status)) {
+ DEBUG(1, ("fork_domain_child: Could not write status: "
+ "nwritten=%d, error=%s\n", (int)nwritten,
+ strerror(errno)));
+ _exit(0);
+ }
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("winbindd_reinit_after_fork failed: %s\n",
+ nt_errstr(status)));
_exit(0);
}
@@ -1424,7 +1469,6 @@ static bool fork_domain_child(struct winbindd_child *child)
TALLOC_CTX *frame = talloc_stackframe();
struct iovec iov[2];
int iov_count;
- NTSTATUS status;
if (run_events_poll(winbind_event_context(), 0, NULL, 0)) {
TALLOC_FREE(frame);
@@ -1439,7 +1483,7 @@ static bool fork_domain_child(struct winbindd_child *child)
child->domain->startup = False;
}
- pfds = TALLOC_ZERO_P(talloc_tos(), struct pollfd);
+ pfds = talloc_zero(talloc_tos(), struct pollfd);
if (pfds == NULL) {
DEBUG(1, ("talloc failed\n"));
_exit(1);
diff --git a/source3/winbindd/winbindd_dual_ndr.c b/source3/winbindd/winbindd_dual_ndr.c
index 003d3cded7a..f5f143f6126 100644
--- a/source3/winbindd/winbindd_dual_ndr.c
+++ b/source3/winbindd/winbindd_dual_ndr.c
@@ -29,8 +29,8 @@
#include "includes.h"
#include "winbindd/winbindd.h"
#include "winbindd/winbindd_proto.h"
-#include "librpc/gen_ndr/srv_wbint.h"
#include "ntdomain.h"
+#include "librpc/gen_ndr/srv_wbint.h"
struct wbint_bh_state {
struct winbindd_domain *domain;
@@ -144,7 +144,7 @@ static void wbint_bh_raw_call_done(struct tevent_req *subreq)
state->response->extra_data.data,
state->response->length - sizeof(struct winbindd_response));
if (state->response->extra_data.data && !state->out_data.data) {
- tevent_req_nomem(NULL, req);
+ tevent_req_oom(req);
return;
}
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index 230edae9080..c2510bc84d9 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -24,11 +24,11 @@
#include "winbindd/winbindd.h"
#include "winbindd/winbindd_proto.h"
#include "rpc_client/cli_pipe.h"
+#include "ntdomain.h"
#include "librpc/gen_ndr/srv_wbint.h"
#include "../librpc/gen_ndr/ndr_netlogon_c.h"
#include "idmap.h"
#include "../libcli/security/security.h"
-#include "ntdomain.h"
void _wbint_Ping(struct pipes_struct *p, struct wbint_Ping *r)
{
@@ -148,22 +148,22 @@ NTSTATUS _wbint_Sids2UnixIDs(struct pipes_struct *p,
}
}
- ids = TALLOC_REALLOC_ARRAY(talloc_tos(), ids,
+ ids = talloc_realloc(talloc_tos(), ids,
struct id_map, num_ids);
if (ids == NULL) {
goto nomem;
}
- id_ptrs = TALLOC_REALLOC_ARRAY(talloc_tos(), id_ptrs,
+ id_ptrs = talloc_realloc(talloc_tos(), id_ptrs,
struct id_map *, num_ids+1);
if (id_ptrs == NULL) {
goto nomem;
}
- id_idx = TALLOC_REALLOC_ARRAY(talloc_tos(), id_idx,
+ id_idx = talloc_realloc(talloc_tos(), id_idx,
uint32_t, num_ids);
if (id_idx == NULL) {
goto nomem;
}
- sids = TALLOC_REALLOC_ARRAY(talloc_tos(), sids,
+ sids = talloc_realloc(talloc_tos(), sids,
struct dom_sid, num_ids);
if (sids == NULL) {
goto nomem;
diff --git a/source3/winbindd/winbindd_getdcname.c b/source3/winbindd/winbindd_getdcname.c
index 1c5f69e50d7..cbf7f22eb88 100644
--- a/source3/winbindd/winbindd_getdcname.c
+++ b/source3/winbindd/winbindd_getdcname.c
@@ -65,8 +65,7 @@ static void winbindd_getdcname_done(struct tevent_req *subreq)
status = wb_dsgetdcname_recv(subreq, state, &state->dcinfo);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_getgrgid.c b/source3/winbindd/winbindd_getgrgid.c
index 80db3090607..5edecffcb2b 100644
--- a/source3/winbindd/winbindd_getgrgid.c
+++ b/source3/winbindd/winbindd_getgrgid.c
@@ -68,8 +68,7 @@ static void winbindd_getgrgid_gid2sid_done(struct tevent_req *subreq)
status = wb_gid2sid_recv(subreq, &state->sid);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -92,8 +91,7 @@ static void winbindd_getgrgid_done(struct tevent_req *subreq)
status = wb_getgrsid_recv(subreq, state, &state->domname, &state->name,
&state->gid, &state->members);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_getgrnam.c b/source3/winbindd/winbindd_getgrnam.c
index 3ca1aa61115..9460ff44ad1 100644
--- a/source3/winbindd/winbindd_getgrnam.c
+++ b/source3/winbindd/winbindd_getgrnam.c
@@ -97,8 +97,7 @@ static void winbindd_getgrnam_lookupsid_done(struct tevent_req *subreq)
status = wb_lookupname_recv(subreq, &state->sid, &type);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -127,8 +126,7 @@ static void winbindd_getgrnam_done(struct tevent_req *subreq)
status = wb_getgrsid_recv(subreq, state, &state->domname, &state->name,
&state->gid, &state->members);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_getgroups.c b/source3/winbindd/winbindd_getgroups.c
index c9b0f195ce5..a42986f15f5 100644
--- a/source3/winbindd/winbindd_getgroups.c
+++ b/source3/winbindd/winbindd_getgroups.c
@@ -96,8 +96,7 @@ static void winbindd_getgroups_lookupname_done(struct tevent_req *subreq)
status = wb_lookupname_recv(subreq, &state->sid, &state->type);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -119,8 +118,7 @@ static void winbindd_getgroups_gettoken_done(struct tevent_req *subreq)
status = wb_gettoken_recv(subreq, state, &state->num_sids,
&state->sids);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
diff --git a/source3/winbindd/winbindd_getpwent.c b/source3/winbindd/winbindd_getpwent.c
index ef905b48bb2..3c035eac8a6 100644
--- a/source3/winbindd/winbindd_getpwent.c
+++ b/source3/winbindd/winbindd_getpwent.c
@@ -97,8 +97,7 @@ static void winbindd_getpwent_done(struct tevent_req *subreq)
tevent_req_done(req);
return;
}
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
state->num_users += 1;
diff --git a/source3/winbindd/winbindd_getpwnam.c b/source3/winbindd/winbindd_getpwnam.c
index bc771b2e41b..f2c93362ca8 100644
--- a/source3/winbindd/winbindd_getpwnam.c
+++ b/source3/winbindd/winbindd_getpwnam.c
@@ -100,8 +100,7 @@ static void winbindd_getpwnam_lookupname_done(struct tevent_req *subreq)
status = wb_lookupname_recv(subreq, &state->sid, &state->type);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -120,8 +119,7 @@ static void winbindd_getpwnam_done(struct tevent_req *subreq)
status = wb_getpwsid_recv(subreq);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_getpwsid.c b/source3/winbindd/winbindd_getpwsid.c
index efea3fd2b36..52481700756 100644
--- a/source3/winbindd/winbindd_getpwsid.c
+++ b/source3/winbindd/winbindd_getpwsid.c
@@ -70,8 +70,7 @@ static void winbindd_getpwsid_done(struct tevent_req *subreq)
status = wb_getpwsid_recv(subreq);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_getpwuid.c b/source3/winbindd/winbindd_getpwuid.c
index d47c0852143..30f3a04efdd 100644
--- a/source3/winbindd/winbindd_getpwuid.c
+++ b/source3/winbindd/winbindd_getpwuid.c
@@ -65,8 +65,7 @@ static void winbindd_getpwuid_uid2sid_done(struct tevent_req *subreq)
status = wb_uid2sid_recv(subreq, &state->sid);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
@@ -85,8 +84,7 @@ static void winbindd_getpwuid_done(struct tevent_req *subreq)
status = wb_getpwsid_recv(subreq);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_getsidaliases.c b/source3/winbindd/winbindd_getsidaliases.c
index f01dac9c4ce..e40a51dbd6d 100644
--- a/source3/winbindd/winbindd_getsidaliases.c
+++ b/source3/winbindd/winbindd_getsidaliases.c
@@ -112,8 +112,7 @@ static void winbindd_getsidaliases_done(struct tevent_req *subreq)
status = wb_lookupuseraliases_recv(subreq, state, &state->num_aliases,
&state->aliases);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_getuserdomgroups.c b/source3/winbindd/winbindd_getuserdomgroups.c
index 9fdff4fc66f..55094bb99a2 100644
--- a/source3/winbindd/winbindd_getuserdomgroups.c
+++ b/source3/winbindd/winbindd_getuserdomgroups.c
@@ -83,8 +83,7 @@ static void winbindd_getuserdomgroups_done(struct tevent_req *subreq)
status = wb_lookupusergroups_recv(subreq, state, &state->num_sids,
&state->sids);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_getusersids.c b/source3/winbindd/winbindd_getusersids.c
index 157c2ab644b..6b5510ad5a5 100644
--- a/source3/winbindd/winbindd_getusersids.c
+++ b/source3/winbindd/winbindd_getusersids.c
@@ -74,8 +74,7 @@ static void winbindd_getusersids_done(struct tevent_req *subreq)
status = wb_gettoken_recv(subreq, state, &state->num_sids,
&state->sids);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_gid_to_sid.c b/source3/winbindd/winbindd_gid_to_sid.c
index f8494d2df23..4a378d3d26c 100644
--- a/source3/winbindd/winbindd_gid_to_sid.c
+++ b/source3/winbindd/winbindd_gid_to_sid.c
@@ -63,8 +63,7 @@ static void winbindd_gid_to_sid_done(struct tevent_req *subreq)
status = wb_gid2sid_recv(subreq, &state->sid);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_group.c b/source3/winbindd/winbindd_group.c
index a985fa254fe..1e4ad5fa8ac 100644
--- a/source3/winbindd/winbindd_group.c
+++ b/source3/winbindd/winbindd_group.c
@@ -60,8 +60,8 @@ bool fill_grent(TALLOC_CTX *mem_ctx, struct winbindd_gr *gr,
/* Group name and password */
- safe_strcpy(gr->gr_name, full_group_name, sizeof(gr->gr_name) - 1);
- safe_strcpy(gr->gr_passwd, "x", sizeof(gr->gr_passwd) - 1);
+ strlcpy(gr->gr_name, full_group_name, sizeof(gr->gr_name));
+ strlcpy(gr->gr_passwd, "x", sizeof(gr->gr_passwd));
return True;
}
diff --git a/source3/winbindd/winbindd_lookupname.c b/source3/winbindd/winbindd_lookupname.c
index c1d0bf04c1b..1be29fd85c8 100644
--- a/source3/winbindd/winbindd_lookupname.c
+++ b/source3/winbindd/winbindd_lookupname.c
@@ -86,8 +86,7 @@ static void winbindd_lookupname_done(struct tevent_req *subreq)
status = wb_lookupname_recv(subreq, &state->sid, &state->type);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_lookupsids.c b/source3/winbindd/winbindd_lookupsids.c
index aeaf21dfb53..4a1b83fd34a 100644
--- a/source3/winbindd/winbindd_lookupsids.c
+++ b/source3/winbindd/winbindd_lookupsids.c
@@ -80,8 +80,7 @@ static void winbindd_lookupsids_done(struct tevent_req *subreq)
status = wb_lookupsids_recv(subreq, state, &state->domains,
&state->names);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index 7d2516770bc..3fb14368209 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -404,7 +404,7 @@ void winbindd_netbios_name(struct winbindd_cli_state *state)
DEBUG(3, ("[%5lu]: request netbios name\n",
(unsigned long)state->pid));
- fstrcpy(state->response->data.netbios_name, global_myname());
+ fstrcpy(state->response->data.netbios_name, lp_netbios_name());
request_ok(state);
}
diff --git a/source3/winbindd/winbindd_msrpc.c b/source3/winbindd/winbindd_msrpc.c
index 8986598daa0..9ef0d87f5ad 100644
--- a/source3/winbindd/winbindd_msrpc.c
+++ b/source3/winbindd/winbindd_msrpc.c
@@ -342,7 +342,7 @@ static NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain,
DEBUG(3, ("msrpc_rids_to_names: domain %s\n", domain->name ));
if (num_rids) {
- sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, num_rids);
+ sids = talloc_array(mem_ctx, struct dom_sid, num_rids);
if (sids == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -400,7 +400,7 @@ static NTSTATUS msrpc_query_user(struct winbindd_domain *domain,
{
struct rpc_pipe_client *samr_pipe;
struct policy_handle dom_pol;
- struct netr_SamInfo3 *user;
+ struct netr_SamInfo3 *user = NULL;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
@@ -418,7 +418,9 @@ static NTSTATUS msrpc_query_user(struct winbindd_domain *domain,
}
/* try netsamlogon cache first */
- user = netsamlogon_cache_get(tmp_ctx, user_sid);
+ if (winbindd_use_cache()) {
+ user = netsamlogon_cache_get(tmp_ctx, user_sid);
+ }
if (user != NULL) {
DEBUG(5,("msrpc_query_user: Cache lookup succeeded for %s\n",
sid_string_dbg(user_sid)));
@@ -699,9 +701,9 @@ static NTSTATUS msrpc_lookup_groupmem(struct winbindd_domain *domain,
#define MAX_LOOKUP_RIDS 900
- *names = TALLOC_ZERO_ARRAY(mem_ctx, char *, *num_names);
- *name_types = TALLOC_ZERO_ARRAY(mem_ctx, uint32, *num_names);
- *sid_mem = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, *num_names);
+ *names = talloc_zero_array(mem_ctx, char *, *num_names);
+ *name_types = talloc_zero_array(mem_ctx, uint32, *num_names);
+ *sid_mem = talloc_zero_array(mem_ctx, struct dom_sid, *num_names);
for (j=0;j<(*num_names);j++)
sid_compose(&(*sid_mem)[j], &domain->sid, rid_mem[j]);
@@ -762,7 +764,7 @@ static NTSTATUS msrpc_lookup_groupmem(struct winbindd_domain *domain,
#include <ldap.h>
-static int get_ldap_seq(const char *server, int port, uint32 *seq)
+static int get_ldap_seq(const char *server, struct sockaddr_storage *ss, int port, uint32 *seq)
{
int ret = -1;
struct timeval to;
@@ -778,7 +780,7 @@ static int get_ldap_seq(const char *server, int port, uint32 *seq)
* search timeout doesn't seem to apply to doing an open as well. JRA.
*/
- ldp = ldap_open_with_timeout(server, port, lp_ldap_timeout());
+ ldp = ldap_open_with_timeout(server, ss, port, lp_ldap_timeout());
if (ldp == NULL)
return -1;
@@ -787,7 +789,7 @@ static int get_ldap_seq(const char *server, int port, uint32 *seq)
to.tv_usec = 0;
if (ldap_search_st(ldp, "", LDAP_SCOPE_BASE, "(objectclass=*)",
- CONST_DISCARD(char **, attrs), 0, &to, &res))
+ discard_const_p(char *, attrs), 0, &to, &res))
goto done;
if (ldap_count_entries(ldp, res) != 1)
@@ -822,7 +824,7 @@ static int get_ldap_sequence_number(struct winbindd_domain *domain, uint32 *seq)
char addr[INET6_ADDRSTRLEN];
print_sockaddr(addr, sizeof(addr), &domain->dcaddr);
- if ((ret = get_ldap_seq(addr, LDAP_PORT, seq)) == 0) {
+ if ((ret = get_ldap_seq(addr, &domain->dcaddr, LDAP_PORT, seq)) == 0) {
DEBUG(3, ("get_ldap_sequence_number: Retrieved sequence "
"number for Domain (%s) from DC (%s)\n",
domain->name, addr));
@@ -1057,14 +1059,15 @@ static NTSTATUS msrpc_password_policy(struct winbindd_domain *domain,
return status;
}
-typedef NTSTATUS (*lookup_sids_fn_t)(struct rpc_pipe_client *cli,
+typedef NTSTATUS (*lookup_sids_fn_t)(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
int num_sids,
const struct dom_sid *sids,
char ***pdomains,
char ***pnames,
- enum lsa_SidType **ptypes);
+ enum lsa_SidType **ptypes,
+ NTSTATUS *result);
NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
struct winbindd_domain *domain,
@@ -1075,15 +1078,17 @@ NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
enum lsa_SidType **types)
{
NTSTATUS status;
+ NTSTATUS result;
struct rpc_pipe_client *cli = NULL;
+ struct dcerpc_binding_handle *b = NULL;
struct policy_handle lsa_policy;
unsigned int orig_timeout;
- lookup_sids_fn_t lookup_sids_fn = rpccli_lsa_lookup_sids;
+ lookup_sids_fn_t lookup_sids_fn = dcerpc_lsa_lookup_sids;
if (domain->can_do_ncacn_ip_tcp) {
status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
if (NT_STATUS_IS_OK(status)) {
- lookup_sids_fn = rpccli_lsa_lookup_sids3;
+ lookup_sids_fn = dcerpc_lsa_lookup_sids3;
goto lookup;
}
domain->can_do_ncacn_ip_tcp = false;
@@ -1095,27 +1100,30 @@ NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
}
lookup:
+ b = cli->binding_handle;
+
/*
* This call can take a long time
* allow the server to time out.
* 35 seconds should do it.
*/
- orig_timeout = rpccli_set_timeout(cli, 35000);
+ orig_timeout = dcerpc_binding_handle_set_timeout(b, 35000);
- status = lookup_sids_fn(cli,
+ status = lookup_sids_fn(b,
mem_ctx,
&lsa_policy,
num_sids,
sids,
domains,
names,
- types);
+ types,
+ &result);
/* And restore our original timeout. */
- rpccli_set_timeout(cli, orig_timeout);
+ dcerpc_binding_handle_set_timeout(b, orig_timeout);
- if (NT_STATUS_V(status) == DCERPC_FAULT_ACCESS_DENIED ||
- NT_STATUS_V(status) == DCERPC_FAULT_SEC_PKG_ERROR) {
+ if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
+ NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR)) {
/*
* This can happen if the schannel key is not
* valid anymore, we need to invalidate the
@@ -1130,18 +1138,23 @@ NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
return status;
}
- return status;
+ if (!NT_STATUS_IS_OK(result)) {
+ return result;
+ }
+
+ return NT_STATUS_OK;
}
-typedef NTSTATUS (*lookup_names_fn_t)(struct rpc_pipe_client *cli,
+typedef NTSTATUS (*lookup_names_fn_t)(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
- int num_names,
+ uint32_t num_names,
const char **names,
const char ***dom_names,
- int level,
+ enum lsa_LookupNamesLevel level,
struct dom_sid **sids,
- enum lsa_SidType **types);
+ enum lsa_SidType **types,
+ NTSTATUS *result);
NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
struct winbindd_domain *domain,
@@ -1152,15 +1165,17 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
enum lsa_SidType **types)
{
NTSTATUS status;
+ NTSTATUS result;
struct rpc_pipe_client *cli = NULL;
+ struct dcerpc_binding_handle *b = NULL;
struct policy_handle lsa_policy;
unsigned int orig_timeout = 0;
- lookup_names_fn_t lookup_names_fn = rpccli_lsa_lookup_names;
+ lookup_names_fn_t lookup_names_fn = dcerpc_lsa_lookup_names;
if (domain->can_do_ncacn_ip_tcp) {
status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
if (NT_STATUS_IS_OK(status)) {
- lookup_names_fn = rpccli_lsa_lookup_names4;
+ lookup_names_fn = dcerpc_lsa_lookup_names4;
goto lookup;
}
domain->can_do_ncacn_ip_tcp = false;
@@ -1172,15 +1187,16 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
}
lookup:
+ b = cli->binding_handle;
/*
* This call can take a long time
* allow the server to time out.
* 35 seconds should do it.
*/
- orig_timeout = rpccli_set_timeout(cli, 35000);
+ orig_timeout = dcerpc_binding_handle_set_timeout(b, 35000);
- status = lookup_names_fn(cli,
+ status = lookup_names_fn(b,
mem_ctx,
&lsa_policy,
num_names,
@@ -1188,13 +1204,14 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
domains,
1,
sids,
- types);
+ types,
+ &result);
/* And restore our original timeout. */
- rpccli_set_timeout(cli, orig_timeout);
+ dcerpc_binding_handle_set_timeout(b, orig_timeout);
- if (NT_STATUS_V(status) == DCERPC_FAULT_ACCESS_DENIED ||
- NT_STATUS_V(status) == DCERPC_FAULT_SEC_PKG_ERROR) {
+ if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
+ NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR)) {
/*
* This can happen if the schannel key is not
* valid anymore, we need to invalidate the
@@ -1209,7 +1226,11 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
return status;
}
- return status;
+ if (!NT_STATUS_IS_OK(result)) {
+ return result;
+ }
+
+ return NT_STATUS_OK;
}
/* the rpc backend methods are exposed via this structure */
diff --git a/source3/winbindd/winbindd_ndr.c b/source3/winbindd/winbindd_ndr.c
index 2f26d8d9810..b1fd6d715f5 100644
--- a/source3/winbindd/winbindd_ndr.c
+++ b/source3/winbindd/winbindd_ndr.c
@@ -21,7 +21,7 @@
#include "winbindd.h"
#include "../librpc/gen_ndr/ndr_netlogon.h"
#include "../librpc/gen_ndr/ndr_security.h"
-#include "librpc/ndr/util.h"
+#include "../librpc/ndr/libndr.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c
index 76e06d3735a..910e42971a7 100644
--- a/source3/winbindd/winbindd_pam.c
+++ b/source3/winbindd/winbindd_pam.c
@@ -37,7 +37,6 @@
#include "../librpc/gen_ndr/krb5pac.h"
#include "passdb/machine_sid.h"
#include "auth.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
@@ -386,9 +385,9 @@ static void fill_in_password_policy(struct winbindd_response *r,
r->data.auth.policy.password_properties =
p->password_properties;
r->data.auth.policy.expire =
- nt_time_to_unix_abs((NTTIME *)&(p->max_password_age));
+ nt_time_to_unix_abs((const NTTIME *)&(p->max_password_age));
r->data.auth.policy.min_passwordage =
- nt_time_to_unix_abs((NTTIME *)&(p->min_password_age));
+ nt_time_to_unix_abs((const NTTIME *)&(p->min_password_age));
}
static NTSTATUS fillup_password_policy(struct winbindd_domain *domain,
@@ -994,7 +993,10 @@ static NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain,
}
- /* User does *NOT* know the correct password, modify info3 accordingly */
+ /* User does *NOT* know the correct password, modify info3 accordingly, but only if online */
+ if (domain->online == false) {
+ goto failed;
+ }
/* failure of this is not critical */
result = get_max_bad_attempts_from_lockout_policy(domain, state->mem_ctx, &max_allowed_bad_attempts);
@@ -1116,7 +1118,7 @@ static NTSTATUS winbindd_dual_auth_passdb(TALLOC_CTX *mem_ctx,
NTSTATUS status;
status = make_user_info(&user_info, user, user, domain, domain,
- global_myname(), lm_resp, nt_resp, NULL, NULL,
+ lp_netbios_name(), lm_resp, nt_resp, NULL, NULL,
NULL, AUTH_PASSWORD_RESPONSE);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("make_user_info failed: %s\n", nt_errstr(status)));
@@ -1248,7 +1250,7 @@ static NTSTATUS winbind_samlogon_retry_loop(struct winbindd_domain *domain,
info3);
}
- if ((NT_STATUS_V(result) == DCERPC_FAULT_OP_RNG_ERROR)
+ if (NT_STATUS_EQUAL(result, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE)
&& domain->can_do_samlogon_ex) {
DEBUG(3, ("Got a DC that can not do NetSamLogonEx, "
"retrying with NetSamLogon\n"));
@@ -1346,7 +1348,7 @@ static NTSTATUS winbindd_dual_pam_auth_samlogon(TALLOC_CTX *mem_ctx,
'workstation' passed to the actual SamLogon call.
*/
names_blob = NTLMv2_generate_names_blob(
- mem_ctx, global_myname(), lp_workgroup());
+ mem_ctx, lp_netbios_name(), lp_workgroup());
if (!SMBNTLMv2encrypt(mem_ctx, name_user, name_domain,
pass,
@@ -1384,7 +1386,7 @@ static NTSTATUS winbindd_dual_pam_auth_samlogon(TALLOC_CTX *mem_ctx,
domain->dcname,
name_user,
name_domain,
- global_myname(),
+ lp_netbios_name(),
chal,
lm_resp,
nt_resp,
@@ -1515,8 +1517,8 @@ enum winbindd_result winbindd_dual_pam_auth(struct winbindd_domain *domain,
fstr_sprintf( domain_user, "%s%c%s", name_domain,
*lp_winbind_separator(),
name_user );
- safe_strcpy( state->request->data.auth.user, domain_user,
- sizeof(state->request->data.auth.user)-1 );
+ strlcpy( state->request->data.auth.user, domain_user,
+ sizeof(state->request->data.auth.user));
}
if (!domain->online) {
@@ -1938,10 +1940,10 @@ enum winbindd_result winbindd_dual_pam_chauthtok(struct winbindd_domain *contact
* short to comply with the samr_ChangePasswordUser3 idl - gd */
/* only fallback when the chgpasswd_user3 call is not supported */
- if ((NT_STATUS_EQUAL(result, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR))) ||
- (NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED)) ||
- (NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL)) ||
- (NT_STATUS_EQUAL(result, NT_STATUS_NOT_IMPLEMENTED))) {
+ if (NT_STATUS_EQUAL(result, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE) ||
+ NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED) ||
+ NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL) ||
+ NT_STATUS_EQUAL(result, NT_STATUS_NOT_IMPLEMENTED)) {
DEBUG(10,("Password change with chgpasswd_user3 failed with: %s, retrying chgpasswd_user2\n",
nt_errstr(result)));
@@ -2136,7 +2138,7 @@ enum winbindd_result winbindd_dual_pam_chng_pswd_auth_crap(struct winbindd_domai
}
if (!*domain && lp_winbind_use_default_domain()) {
- fstrcpy(domain,(char *)lp_workgroup());
+ fstrcpy(domain,lp_workgroup());
}
if(!*user) {
diff --git a/source3/winbindd/winbindd_pam_auth_crap.c b/source3/winbindd/winbindd_pam_auth_crap.c
index 186e510aa3e..2fb5111510c 100644
--- a/source3/winbindd/winbindd_pam_auth_crap.c
+++ b/source3/winbindd/winbindd_pam_auth_crap.c
@@ -74,7 +74,7 @@ struct tevent_req *winbindd_pam_auth_crap_send(
}
if (request->data.auth_crap.workstation[0] == '\0') {
- fstrcpy(request->data.auth_crap.workstation, global_myname());
+ fstrcpy(request->data.auth_crap.workstation, lp_netbios_name());
}
subreq = wb_domain_request_send(state, winbind_event_context(), domain,
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 5b48a99a8fb..ce66964ace4 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -291,7 +291,8 @@ void winbind_msg_ip_dropped_parent(struct messaging_context *msg_ctx,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data);
-bool winbindd_reinit_after_fork(const char *logfilename);
+NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
+ const char *logfilename);
struct winbindd_domain *wb_child_domain(void);
/* The following definitions come from winbindd/winbindd_group.c */
@@ -391,7 +392,6 @@ struct winbindd_domain *find_lookup_domain_from_name(const char *domain_name);
bool parse_domain_user(const char *domuser, fstring domain, fstring user);
bool parse_domain_user_talloc(TALLOC_CTX *mem_ctx, const char *domuser,
char **domain, char **user);
-void parse_add_domuser(void *buf, char *domuser, int *len);
bool canonicalize_username(fstring username_inout, fstring domain, fstring user);
void fill_domain_username(fstring name, const char *domain, const char *user, bool can_assume);
char *fill_domain_username_talloc(TALLOC_CTX *ctx,
@@ -436,7 +436,6 @@ bool parse_sidlist(TALLOC_CTX *mem_ctx, const char *sidstr,
/* The following definitions come from winbindd/winbindd_wins.c */
-void winbindd_wins_byip(struct winbindd_cli_state *state);
void winbindd_wins_byname(struct winbindd_cli_state *state);
struct tevent_req *wb_ping_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
@@ -861,6 +860,18 @@ struct tevent_req *winbindd_sids_to_xids_send(TALLOC_CTX *mem_ctx,
struct winbindd_request *request);
NTSTATUS winbindd_sids_to_xids_recv(struct tevent_req *req,
struct winbindd_response *response);
+struct tevent_req *winbindd_wins_byip_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request);
+NTSTATUS winbindd_wins_byip_recv(struct tevent_req *req,
+ struct winbindd_response *presp);
+struct tevent_req *winbindd_wins_byname_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request);
+NTSTATUS winbindd_wins_byname_recv(struct tevent_req *req,
+ struct winbindd_response *presp);
/* The following definitions come from winbindd/winbindd_samr.c */
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
index 82599e78782..e9114873242 100644
--- a/source3/winbindd/winbindd_rpc.c
+++ b/source3/winbindd/winbindd_rpc.c
@@ -26,12 +26,9 @@
#include "includes.h"
#include "winbindd.h"
#include "winbindd_rpc.h"
-
#include "rpc_client/rpc_client.h"
#include "librpc/gen_ndr/ndr_samr_c.h"
-#include "librpc/gen_ndr/srv_samr.h"
#include "librpc/gen_ndr/ndr_lsa_c.h"
-#include "librpc/gen_ndr/srv_lsa.h"
#include "rpc_client/cli_samr.h"
#include "rpc_client/cli_lsarpc.h"
#include "../libcli/security/security.h"
@@ -92,7 +89,7 @@ NTSTATUS rpc_query_user_list(TALLOC_CTX *mem_ctx,
num_info += num_dom_users;
- info = TALLOC_REALLOC_ARRAY(mem_ctx,
+ info = talloc_realloc(mem_ctx,
info,
struct wbint_userinfo,
num_info);
@@ -184,7 +181,7 @@ NTSTATUS rpc_enum_dom_groups(TALLOC_CTX *mem_ctx,
}
}
- info = TALLOC_REALLOC_ARRAY(mem_ctx,
+ info = talloc_realloc(mem_ctx,
info,
struct wb_acct_info,
num_info + count);
@@ -244,7 +241,7 @@ NTSTATUS rpc_enum_local_groups(TALLOC_CTX *mem_ctx,
}
}
- info = TALLOC_REALLOC_ARRAY(mem_ctx,
+ info = talloc_realloc(mem_ctx,
info,
struct wb_acct_info,
num_info + count);
@@ -407,7 +404,7 @@ NTSTATUS rpc_rids_to_names(TALLOC_CTX *mem_ctx,
NTSTATUS status;
if (num_rids > 0) {
- sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, num_rids);
+ sids = talloc_array(mem_ctx, struct dom_sid, num_rids);
if (sids == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -597,7 +594,7 @@ NTSTATUS rpc_lookup_usergroups(TALLOC_CTX *mem_ctx,
return result;
}
- user_grpsids = TALLOC_ARRAY(mem_ctx, struct dom_sid, num_groups);
+ user_grpsids = talloc_array(mem_ctx, struct dom_sid, num_groups);
if (user_grpsids == NULL) {
status = NT_STATUS_NO_MEMORY;
return status;
@@ -647,7 +644,7 @@ NTSTATUS rpc_lookup_useraliases(TALLOC_CTX *mem_ctx,
num_queries, num_query_sids));
if (num_query_sids) {
- sid_array.sids = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_SidPtr, num_query_sids);
+ sid_array.sids = talloc_zero_array(mem_ctx, struct lsa_SidPtr, num_query_sids);
if (sid_array.sids == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -842,9 +839,9 @@ NTSTATUS rpc_lookup_groupmem(TALLOC_CTX *mem_ctx,
* Step #2: Convert list of rids into list of usernames.
*/
if (num_names > 0) {
- names = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_names);
- name_types = TALLOC_ZERO_ARRAY(mem_ctx, uint32_t, num_names);
- sid_mem = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, num_names);
+ names = talloc_zero_array(mem_ctx, char *, num_names);
+ name_types = talloc_zero_array(mem_ctx, uint32_t, num_names);
+ sid_mem = talloc_zero_array(mem_ctx, struct dom_sid, num_names);
if (names == NULL || name_types == NULL || sid_mem == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -1069,7 +1066,7 @@ static NTSTATUS rpc_try_lookup_sids3(TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_ERR(result)) {
return result;
}
- names = TALLOC_ZERO_P(mem_ctx, struct lsa_TransNameArray);
+ names = talloc_zero(mem_ctx, struct lsa_TransNameArray);
if (names == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -1114,7 +1111,7 @@ NTSTATUS rpc_lookup_sids(TALLOC_CTX *mem_ctx,
return status;
}
- names = TALLOC_ZERO_P(mem_ctx, struct lsa_TransNameArray);
+ names = talloc_zero(mem_ctx, struct lsa_TransNameArray);
if (names == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c
index f24a14391b6..3b9377f7299 100644
--- a/source3/winbindd/winbindd_samr.c
+++ b/source3/winbindd/winbindd_samr.c
@@ -26,14 +26,11 @@
#include "includes.h"
#include "winbindd.h"
#include "winbindd_rpc.h"
-
#include "rpc_client/rpc_client.h"
#include "../librpc/gen_ndr/ndr_samr_c.h"
#include "rpc_client/cli_samr.h"
-#include "../librpc/gen_ndr/srv_samr.h"
#include "../librpc/gen_ndr/ndr_lsa_c.h"
#include "rpc_client/cli_lsarpc.h"
-#include "../librpc/gen_ndr/srv_lsa.h"
#include "rpc_server/rpc_ncacn_np.h"
#include "../libcli/security/security.h"
#include "passdb/machine_sid.h"
diff --git a/source3/winbindd/winbindd_show_sequence.c b/source3/winbindd/winbindd_show_sequence.c
index 447706685e7..8e53781e5af 100644
--- a/source3/winbindd/winbindd_show_sequence.c
+++ b/source3/winbindd/winbindd_show_sequence.c
@@ -97,8 +97,7 @@ static void winbindd_show_sequence_done_one(struct tevent_req *subreq)
status = wb_seqnum_recv(subreq, &state->seqnum);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
@@ -116,8 +115,7 @@ static void winbindd_show_sequence_done_all(struct tevent_req *subreq)
&state->domains, &state->stati,
&state->seqnums);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_sid_to_gid.c b/source3/winbindd/winbindd_sid_to_gid.c
index b0b0e6e211e..df44ed8d6b6 100644
--- a/source3/winbindd/winbindd_sid_to_gid.c
+++ b/source3/winbindd/winbindd_sid_to_gid.c
@@ -72,8 +72,7 @@ static void winbindd_sid_to_gid_done(struct tevent_req *subreq)
status = wb_sid2gid_recv(subreq, &state->gid);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_sid_to_uid.c b/source3/winbindd/winbindd_sid_to_uid.c
index bf2824f9d8d..9ce564f02e8 100644
--- a/source3/winbindd/winbindd_sid_to_uid.c
+++ b/source3/winbindd/winbindd_sid_to_uid.c
@@ -72,8 +72,7 @@ static void winbindd_sid_to_uid_done(struct tevent_req *subreq)
status = wb_sid2uid_recv(subreq, &state->uid);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_sids_to_xids.c b/source3/winbindd/winbindd_sids_to_xids.c
index 52d473b58f8..d08064fbf38 100644
--- a/source3/winbindd/winbindd_sids_to_xids.c
+++ b/source3/winbindd/winbindd_sids_to_xids.c
@@ -80,12 +80,12 @@ struct tevent_req *winbindd_sids_to_xids_send(TALLOC_CTX *mem_ctx,
DEBUG(10, ("num_sids: %d\n", (int)state->num_sids));
- state->cached = TALLOC_ZERO_ARRAY(state, struct id_map,
+ state->cached = talloc_zero_array(state, struct id_map,
state->num_sids);
if (tevent_req_nomem(state->cached, req)) {
return tevent_req_post(req, ev);
}
- state->non_cached = TALLOC_ARRAY(state, struct dom_sid,
+ state->non_cached = talloc_array(state, struct dom_sid,
state->num_sids);
if (tevent_req_nomem(state->non_cached, req)) {
return tevent_req_post(req, ev);
@@ -171,13 +171,12 @@ static void winbindd_sids_to_xids_lookupsids_done(struct tevent_req *subreq)
status = wb_lookupsids_recv(subreq, state, &state->domains,
&state->names);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
state->ids.num_ids = state->num_non_cached;
- state->ids.ids = TALLOC_ARRAY(state, struct wbint_TransID,
+ state->ids.ids = talloc_array(state, struct wbint_TransID,
state->num_non_cached);
if (tevent_req_nomem(state->ids.ids, req)) {
return;
@@ -202,7 +201,7 @@ static void winbindd_sids_to_xids_lookupsids_done(struct tevent_req *subreq)
break;
};
t->domain_index = n->sid_index;
- sid_peek_rid(&state->sids[i], &t->rid);
+ sid_peek_rid(&state->non_cached[i], &t->rid);
t->unix_id = (uint64_t)-1;
}
@@ -269,6 +268,9 @@ NTSTATUS winbindd_sids_to_xids_recv(struct tevent_req *req,
}
} else {
unix_id = state->ids.ids[num_non_cached].unix_id;
+ if (unix_id == -1) {
+ found = false;
+ }
switch(state->ids.ids[num_non_cached].type) {
case WBC_ID_TYPE_UID:
type = 'U';
diff --git a/source3/winbindd/winbindd_uid_to_sid.c b/source3/winbindd/winbindd_uid_to_sid.c
index 467a1af96a3..653a96f72ae 100644
--- a/source3/winbindd/winbindd_uid_to_sid.c
+++ b/source3/winbindd/winbindd_uid_to_sid.c
@@ -63,8 +63,7 @@ static void winbindd_uid_to_sid_done(struct tevent_req *subreq)
status = wb_uid2sid_recv(subreq, &state->sid);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
+ if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c
index 9fbc778e048..7dff138fc13 100644
--- a/source3/winbindd/winbindd_util.c
+++ b/source3/winbindd/winbindd_util.c
@@ -261,7 +261,7 @@ static void add_trusted_domains( struct winbindd_domain *domain )
struct trustdom_state *state;
struct tevent_req *req;
- state = TALLOC_ZERO_P(NULL, struct trustdom_state);
+ state = talloc_zero(NULL, struct trustdom_state);
if (state == NULL) {
DEBUG(0, ("talloc failed\n"));
return;
@@ -894,31 +894,6 @@ bool parse_domain_user_talloc(TALLOC_CTX *mem_ctx, const char *domuser,
return ((*domain != NULL) && (*user != NULL));
}
-/* add a domain user name to a buffer */
-void parse_add_domuser(void *buf, char *domuser, int *len)
-{
- fstring domain;
- char *p, *user;
-
- user = domuser;
- p = strchr(domuser, *lp_winbind_separator());
-
- if (p) {
-
- fstrcpy(domain, domuser);
- domain[PTR_DIFF(p, domuser)] = 0;
- p++;
-
- if (assume_domain(domain)) {
-
- user = p;
- *len -= (PTR_DIFF(p, domuser));
- }
- }
-
- safe_strcpy((char *)buf, user, *len);
-}
-
/* Ensure an incoming username from NSS is fully qualified. Replace the
incoming fstring with DOMAIN <separator> user. Returns the same
values as parse_domain_user() but also replaces the incoming username.
diff --git a/source3/winbindd/winbindd_wins.c b/source3/winbindd/winbindd_wins.c
deleted file mode 100644
index e1beb1d80bf..00000000000
--- a/source3/winbindd/winbindd_wins.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Winbind daemon - WINS related functions
-
- Copyright (C) Andrew Tridgell 1999
- Copyright (C) Herb Lewis 2002
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "winbindd.h"
-#include "libsmb/nmblib.h"
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_WINBIND
-
-static struct node_status *lookup_byaddr_backend(TALLOC_CTX *mem_ctx,
- const char *addr, int *count)
-{
- struct sockaddr_storage ss;
- struct nmb_name nname;
- struct node_status *result;
- NTSTATUS status;
-
- make_nmb_name(&nname, "*", 0);
- if (!interpret_string_addr(&ss, addr, AI_NUMERICHOST)) {
- return NULL;
- }
- status = node_status_query(mem_ctx, &nname, &ss,
- &result, count, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- return NULL;
- }
- return result;
-}
-
-static struct sockaddr_storage *lookup_byname_backend(TALLOC_CTX *mem_ctx,
- const char *name,
- int *count)
-{
- struct ip_service *ret = NULL;
- struct sockaddr_storage *return_ss = NULL;
- int j, i;
- NTSTATUS status;
-
- *count = 0;
-
- /* always try with wins first */
- if (NT_STATUS_IS_OK(resolve_wins(name,0x20,&ret,count))) {
- if ( *count == 0 )
- return NULL;
- return_ss = TALLOC_ARRAY(mem_ctx, struct sockaddr_storage,
- *count);
- if (return_ss == NULL ) {
- free( ret );
- return NULL;
- }
-
- /* copy the IP addresses */
- for ( i=0; i<(*count); i++ )
- return_ss[i] = ret[i].ss;
-
- free( ret );
- return return_ss;
- }
-
- /* uggh, we have to broadcast to each interface in turn */
- for (j=iface_count() - 1;
- j >= 0;
- j--) {
- const struct sockaddr_storage *bcast_ss = iface_n_bcast(j);
- if (!bcast_ss) {
- continue;
- }
- status = name_query(name, 0x20, True, True,bcast_ss,
- mem_ctx, &return_ss, count, NULL);
- if (NT_STATUS_IS_OK(status)) {
- break;
- }
- }
-
- return return_ss;
-}
-
-/* Get hostname from IP */
-
-void winbindd_wins_byip(struct winbindd_cli_state *state)
-{
- fstring response;
- int i, count, maxlen, size;
- struct node_status *status;
-
- /* Ensure null termination */
- state->request->data.winsreq[sizeof(state->request->data.winsreq)-1]='\0';
-
- DEBUG(3, ("[%5lu]: wins_byip %s\n", (unsigned long)state->pid,
- state->request->data.winsreq));
-
- *response = '\0';
- maxlen = sizeof(response) - 1;
-
- if ((status = lookup_byaddr_backend(
- state->mem_ctx, state->request->data.winsreq, &count))) {
- size = strlen(state->request->data.winsreq);
- if (size > maxlen) {
- TALLOC_FREE(status);
- request_error(state);
- return;
- }
- fstrcat(response,state->request->data.winsreq);
- fstrcat(response,"\t");
- for (i = 0; i < count; i++) {
- /* ignore group names */
- if (status[i].flags & 0x80) continue;
- if (status[i].type == 0x20) {
- size = sizeof(status[i].name) + strlen(response);
- if (size > maxlen) {
- TALLOC_FREE(status);
- request_error(state);
- return;
- }
- fstrcat(response, status[i].name);
- fstrcat(response, " ");
- }
- }
- /* make last character a newline */
- response[strlen(response)-1] = '\n';
- TALLOC_FREE(status);
- }
- fstrcpy(state->response->data.winsresp,response);
- request_ok(state);
-}
-
-/* Get IP from hostname */
-
-void winbindd_wins_byname(struct winbindd_cli_state *state)
-{
- struct sockaddr_storage *ip_list = NULL;
- int i, count, maxlen, size;
- fstring response;
- char addr[INET6_ADDRSTRLEN];
-
- /* Ensure null termination */
- state->request->data.winsreq[sizeof(state->request->data.winsreq)-1]='\0';
-
- DEBUG(3, ("[%5lu]: wins_byname %s\n", (unsigned long)state->pid,
- state->request->data.winsreq));
-
- *response = '\0';
- maxlen = sizeof(response) - 1;
-
- ip_list = lookup_byname_backend(
- state->mem_ctx, state->request->data.winsreq, &count);
- if (ip_list != NULL){
- for (i = count; i ; i--) {
- print_sockaddr(addr, sizeof(addr), &ip_list[i-1]);
- size = strlen(addr);
- if (size > maxlen) {
- TALLOC_FREE(ip_list);
- request_error(state);
- return;
- }
- if (i != 0) {
- /* Clear out the newline character */
- /* But only if there is something in there,
- otherwise we clobber something in the stack */
- if (strlen(response)) {
- response[strlen(response)-1] = ' ';
- }
- }
- fstrcat(response,addr);
- fstrcat(response,"\t");
- }
- size = strlen(state->request->data.winsreq) + strlen(response);
- if (size > maxlen) {
- TALLOC_FREE(ip_list);
- request_error(state);
- return;
- }
- fstrcat(response,state->request->data.winsreq);
- fstrcat(response,"\n");
- TALLOC_FREE(ip_list);
- } else {
- request_error(state);
- return;
- }
-
- fstrcpy(state->response->data.winsresp,response);
-
- request_ok(state);
-}
diff --git a/source3/winbindd/winbindd_wins_byip.c b/source3/winbindd/winbindd_wins_byip.c
new file mode 100644
index 00000000000..4ae1b82ac23
--- /dev/null
+++ b/source3/winbindd/winbindd_wins_byip.c
@@ -0,0 +1,135 @@
+/*
+ Unix SMB/CIFS implementation.
+ async implementation of WINBINDD_WINS_BYIP
+ Copyright (C) Volker Lendecke 2011
+
+ 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 "winbindd.h"
+#include "librpc/gen_ndr/ndr_wbint_c.h"
+#include "libsmb/nmblib.h"
+
+struct winbindd_wins_byip_state {
+ struct nmb_name star;
+ struct sockaddr_storage addr;
+ fstring response;
+};
+
+static void winbindd_wins_byip_done(struct tevent_req *subreq);
+
+struct tevent_req *winbindd_wins_byip_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request)
+{
+ struct tevent_req *req, *subreq;
+ struct winbindd_wins_byip_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct winbindd_wins_byip_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ /* Ensure null termination */
+ request->data.winsreq[sizeof(request->data.winsreq)-1]='\0';
+
+ fstr_sprintf(state->response, "%s\t", request->data.winsreq);
+
+ DEBUG(3, ("[%5lu]: wins_byip %s\n", (unsigned long)cli->pid,
+ request->data.winsreq));
+
+ make_nmb_name(&state->star, "*", 0);
+
+ if (!interpret_string_addr(&state->addr, request->data.winsreq,
+ AI_NUMERICHOST)) {
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ return tevent_req_post(req, ev);
+ }
+
+ subreq = node_status_query_send(state, ev, &state->star,
+ &state->addr);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, winbindd_wins_byip_done, req);
+ return req;
+}
+
+static void winbindd_wins_byip_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct winbindd_wins_byip_state *state = tevent_req_data(
+ req, struct winbindd_wins_byip_state);
+ struct node_status *names;
+ int i, num_names;
+ NTSTATUS status;
+
+ status = node_status_query_recv(subreq, talloc_tos(), &names,
+ &num_names, NULL);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+
+ for (i=0; i<num_names; i++) {
+ size_t size;
+ /*
+ * ignore group names
+ */
+ if (names[i].flags & 0x80) {
+ continue;
+ }
+ /*
+ * Only report 0x20
+ */
+ if (names[i].type != 0x20) {
+ continue;
+ }
+
+ DEBUG(10, ("got name %s\n", names[i].name));
+
+ size = strlen(names[i].name + strlen(state->response));
+ if (size > sizeof(state->response) - 1) {
+ DEBUG(10, ("To much data\n"));
+ tevent_req_nterror(req, STATUS_BUFFER_OVERFLOW);
+ return;
+ }
+ fstrcat(state->response, names[i].name);
+ fstrcat(state->response, " ");
+ }
+ state->response[strlen(state->response)-1] = '\n';
+
+ DEBUG(10, ("response: %s", state->response));
+
+ TALLOC_FREE(names);
+ tevent_req_done(req);
+}
+
+NTSTATUS winbindd_wins_byip_recv(struct tevent_req *req,
+ struct winbindd_response *presp)
+{
+ struct winbindd_wins_byip_state *state = tevent_req_data(
+ req, struct winbindd_wins_byip_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+ fstrcpy(presp->data.winsresp, state->response);
+ return NT_STATUS_OK;
+}
diff --git a/source3/winbindd/winbindd_wins_byname.c b/source3/winbindd/winbindd_wins_byname.c
new file mode 100644
index 00000000000..ad642d479d0
--- /dev/null
+++ b/source3/winbindd/winbindd_wins_byname.c
@@ -0,0 +1,149 @@
+/*
+ Unix SMB/CIFS implementation.
+ async implementation of WINBINDD_WINS_BYNAME
+ Copyright (C) Volker Lendecke 2011
+
+ 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 "winbindd.h"
+#include "librpc/gen_ndr/ndr_wbint_c.h"
+#include "libsmb/nmblib.h"
+#include "lib/util/string_wrappers.h"
+
+struct winbindd_wins_byname_state {
+ struct tevent_context *ev;
+ struct winbindd_request *request;
+ struct sockaddr_storage *addrs;
+ int num_addrs;
+};
+
+static void winbindd_wins_byname_wins_done(struct tevent_req *subreq);
+static void winbindd_wins_byname_bcast_done(struct tevent_req *subreq);
+
+struct tevent_req *winbindd_wins_byname_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request)
+{
+ struct tevent_req *req, *subreq;
+ struct winbindd_wins_byname_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct winbindd_wins_byname_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->ev = ev;
+ state->request = request;
+
+ /* Ensure null termination */
+ request->data.winsreq[sizeof(request->data.winsreq)-1]='\0';
+
+ DEBUG(3, ("[%5lu]: wins_byname %s\n", (unsigned long)cli->pid,
+ request->data.winsreq));
+
+ subreq = resolve_wins_send(state, ev, state->request->data.winsreq,
+ 0x20);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, winbindd_wins_byname_wins_done, req);
+ return req;
+}
+
+static void winbindd_wins_byname_wins_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct winbindd_wins_byname_state *state = tevent_req_data(
+ req, struct winbindd_wins_byname_state);
+ NTSTATUS status;
+
+ status = resolve_wins_recv(subreq, talloc_tos(), &state->addrs,
+ &state->num_addrs, NULL);
+ TALLOC_FREE(subreq);
+ if (NT_STATUS_IS_OK(status)) {
+ tevent_req_done(req);
+ return;
+ }
+ subreq = name_resolve_bcast_send(state, state->ev,
+ state->request->data.winsreq, 0x20);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, winbindd_wins_byname_bcast_done, req);
+}
+
+static void winbindd_wins_byname_bcast_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct winbindd_wins_byname_state *state = tevent_req_data(
+ req, struct winbindd_wins_byname_state);
+ NTSTATUS status;
+
+ status = name_resolve_bcast_recv(subreq, talloc_tos(), &state->addrs,
+ &state->num_addrs);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ tevent_req_done(req);
+}
+
+NTSTATUS winbindd_wins_byname_recv(struct tevent_req *req,
+ struct winbindd_response *presp)
+{
+ struct winbindd_wins_byname_state *state = tevent_req_data(
+ req, struct winbindd_wins_byname_state);
+ char *response;
+ NTSTATUS status;
+ int i;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+
+ response = talloc_strdup(talloc_tos(), "");
+ if (response == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0; i<state->num_addrs; i++) {
+ char addr[INET6_ADDRSTRLEN];
+ print_sockaddr(addr, sizeof(addr), &state->addrs[i]);
+
+ response = talloc_asprintf_append_buffer(
+ response, "%s\t", addr);
+ if (response == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ response = talloc_asprintf_append_buffer(
+ response, "%s\n", state->request->data.winsreq);
+ if (response == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (talloc_get_size(response) > sizeof(presp->data.winsresp)) {
+ TALLOC_FREE(response);
+ return NT_STATUS_MARSHALL_OVERFLOW;
+ }
+ fstrcpy(presp->data.winsresp, response);
+ TALLOC_FREE(response);
+ return NT_STATUS_OK;
+}
diff --git a/source3/winbindd/wscript_build b/source3/winbindd/wscript_build
index dbae11697e5..6754f354108 100644
--- a/source3/winbindd/wscript_build
+++ b/source3/winbindd/wscript_build
@@ -24,6 +24,7 @@ IDMAP_SRC = 'idmap.c idmap_util.c ${IDMAP_RW_SRC}'
bld.SAMBA3_SUBSYSTEM('idmap',
source=IDMAP_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('IDMAP_ADEX',
@@ -33,6 +34,7 @@ bld.SAMBA3_SUBSYSTEM('IDMAP_ADEX',
bld.SAMBA3_SUBSYSTEM('IDMAP_HASH',
source=IDMAP_HASH_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('IDMAP_AD',
@@ -58,6 +60,7 @@ bld.SAMBA3_MODULE('idmap_rid',
bld.SAMBA3_MODULE('idmap_passdb',
subsystem='idmap',
source=IDMAP_PASSDB_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('idmap_passdb'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('idmap_passdb'))
@@ -72,6 +75,7 @@ bld.SAMBA3_MODULE('idmap_ldap',
bld.SAMBA3_MODULE('idmap_nss',
subsystem='idmap',
source=IDMAP_NSS_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('idmap_nss'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('idmap_nss'))
@@ -79,6 +83,7 @@ bld.SAMBA3_MODULE('idmap_nss',
bld.SAMBA3_MODULE('idmap_tdb',
subsystem='idmap',
source=IDMAP_TDB_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('idmap_tdb'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('idmap_tdb'))
@@ -86,6 +91,7 @@ bld.SAMBA3_MODULE('idmap_tdb',
bld.SAMBA3_MODULE('idmap_tdb2',
subsystem='idmap',
source=IDMAP_TDB2_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('idmap_tdb2'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('idmap_tdb2'))
@@ -109,6 +115,7 @@ bld.SAMBA3_MODULE('idmap_adex',
bld.SAMBA3_MODULE('idmap_autorid',
subsystem='idmap',
source=IDMAP_AUTORID_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('idmap_autorid'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('idmap_autorid'))
@@ -119,11 +126,13 @@ NSS_INFO_SRC = 'nss_info.c'
bld.SAMBA3_SUBSYSTEM('nss_info',
source=NSS_INFO_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_MODULE('nss_info_template',
subsystem='nss_info',
source=NSS_INFO_TEMPLATE_SRC,
+ deps='samba-util',
init_function='',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('nss_info_template'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('nss_info_template'))
diff --git a/source3/wscript b/source3/wscript
index 49f11f2e5b2..d88faa21044 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -25,7 +25,7 @@ def set_options(opt):
opt.RECURSE('../lib/nss_wrapper')
opt.RECURSE('../lib/socket_wrapper')
opt.RECURSE('../lib/tevent')
- opt.RECURSE('../lib/tdb')
+ opt.RECURSE('../lib/tdb_compat')
opt.add_option('--with-static-modules',
help=("Comma-separated list of names of modules to statically link in"),
@@ -59,7 +59,7 @@ def set_options(opt):
opt.SAMBA3_ADD_OPTION('syslog')
opt.SAMBA3_ADD_OPTION('automount')
opt.SAMBA3_ADD_OPTION('aio-support')
- opt.SAMBA3_ADD_OPTION('profiling-data')
+ opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
opt.SAMBA3_ADD_OPTION('cluster-support')
@@ -78,6 +78,7 @@ def configure(conf):
if not conf.env.toplevel_build:
version = samba_version.load_version(env=conf.env)
conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
+ conf.DEFINE('_SAMBA_WAF_BUILD_', version.MAJOR)
conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
@@ -91,7 +92,8 @@ def configure(conf):
if not conf.env.toplevel_build:
conf.RECURSE('../lib/replace')
conf.RECURSE('build')
- conf.RECURSE('../lib/tdb')
+ conf.RECURSE('../lib/ccan')
+ conf.RECURSE('../lib/tdb_compat')
conf.RECURSE('../lib/talloc')
conf.RECURSE('../lib/tevent')
conf.RECURSE('../lib/popt')
@@ -101,9 +103,9 @@ def configure(conf):
conf.RECURSE('../libcli/smbreadline')
conf.RECURSE('../lib/util')
- conf.ADD_EXTRA_INCLUDES('''#source3 #source3/include #lib/replace''')
+ conf.ADD_EXTRA_INCLUDES('''#source3 #source3/include #lib/replace #lib''')
if not conf.env.USING_SYSTEM_TDB:
- conf.ADD_EXTRA_INCLUDES('#lib/tdb/include')
+ conf.ADD_EXTRA_INCLUDES('#lib/tdb_compat')
if not conf.env.USING_SYSTEM_TEVENT:
conf.ADD_EXTRA_INCLUDES('#lib/tevent')
if not conf.env.USING_SYSTEM_TALLOC:
@@ -129,14 +131,14 @@ def configure(conf):
conf.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
conf.CHECK_FUNCS('fdopendir fdopendir64')
conf.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
- conf.CHECK_FUNCS('syslog vsyslog timegm setlocale nl_langinfo')
+ conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
conf.CHECK_FUNCS_IN('nanosleep', 'rt')
conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
conf.CHECK_FUNCS('shmget')
conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
- conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain')
+ conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain bind_textdomain_codeset')
#FIXME: for some reason this one still fails
conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
@@ -287,7 +289,7 @@ inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
__lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
-nl_langinfo _open __open open64 _open64 __open64 _opendir __opendir
+_open __open open64 _open64 __open64 _opendir __opendir
opendir64 pathconf poll posix_fallocate posix_fallocate64
posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
pwrite _pwrite __pwrite pwrite64 _pwrite64
@@ -574,7 +576,7 @@ msg.msg_acctrightslen = sizeof(fd);
# Check for LDAP
if Options.options.with_ldap:
- conf.CHECK_HEADERS('ldap.h lber.h')
+ conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
@@ -584,7 +586,7 @@ msg.msg_acctrightslen = sizeof(fd);
conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
- conf.CHECK_FUNCS_IN('ldap_init ldap_initialize ldap_set_rebind_proc', 'ldap')
+ conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
# Check if ldap_set_rebind_proc() takes three arguments
@@ -619,7 +621,7 @@ msg.msg_acctrightslen = sizeof(fd);
conf.check_cfg(path="krb5-config", args="--cflags --libs",
package="gssapi", uselib_store="krb5")
conf.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib='krb5')
- conf.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h', lib='krb5')
+ conf.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h gssapi/gssapi_krb5.h com_err.h', lib='krb5')
if conf.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
conf.env['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
@@ -632,7 +634,7 @@ msg.msg_acctrightslen = sizeof(fd);
if conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi') or \
conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi_krb5'):
have_gssapi=True
- conf.CHECK_FUNCS_IN('gss_wrap_iov gss_krb5_import_cred', 'gssapi gssapi_krb5 krb5')
+ conf.CHECK_FUNCS_IN('gss_wrap_iov gss_krb5_import_cred gss_get_name_attribute gss_mech_krb5 gss_oid_equal gss_inquire_sec_context_by_oid', 'gssapi gssapi_krb5 krb5')
conf.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
conf.CHECK_FUNCS('''
krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
@@ -1419,6 +1421,16 @@ main() {
conf.DEFINE('AIX_SENDFILE_API', '1')
conf.DEFINE('WITH_SENDFILE', '1')
+ # Check for getcwd allowing a NULL arg.
+ conf.CHECK_CODE('''
+#include <unistd.h>
+main() {
+ char *s = getcwd(NULL,0);
+ exit(s != NULL ? 0 : 1);
+}''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
+ msg="getcwd takes a NULL argument")
+
+
conf.CHECK_CODE('''enum TDB_ERROR err = TDB_ERR_NESTING''',
'HAVE_TDB_ERR_NESTING',
headers='tdb.h',
@@ -1637,6 +1649,47 @@ main() {
if Options.options.with_profiling_data:
conf.DEFINE('WITH_PROFILE', 1);
+ PTHREAD_CFLAGS='error'
+ PTHREAD_LDFLAGS='error'
+
+ if PTHREAD_LDFLAGS == 'error':
+ if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
+ PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
+ PTHREAD_LDFLAGS='-lpthread'
+ if PTHREAD_LDFLAGS == 'error':
+ if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
+ PTHREAD_CFLAGS='-D_THREAD_SAFE'
+ PTHREAD_LDFLAGS='-lpthreads'
+ if PTHREAD_LDFLAGS == 'error':
+ if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
+ PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread'
+ PTHREAD_LDFLAGS='-pthread'
+ if PTHREAD_LDFLAGS == 'error':
+ if conf.CHECK_FUNC('pthread_attr_init'):
+ PTHREAD_CFLAGS='-D_REENTRANT'
+ PTHREAD_LDFLAGS='-lpthread'
+ # especially for HP-UX, where the CHECK_FUNC macro fails to test for
+ # pthread_attr_init. On pthread_mutex_lock it works there...
+ if PTHREAD_LDFLAGS == 'error':
+ if conf.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
+ PTHREAD_CFLAGS='-D_REENTRANT'
+ PTHREAD_LDFLAGS='-lpthread'
+
+ if PTHREAD_CFLAGS != 'error' and PTHREAD_LDFLAGS != 'error':
+ conf.ADD_CFLAGS(PTHREAD_CFLAGS)
+ conf.ADD_LDFLAGS(PTHREAD_LDFLAGS)
+ conf.CHECK_HEADERS('pthread.h')
+ conf.DEFINE('HAVE_PTHREAD', '1')
+
+ if Options.options.with_pthreadpool:
+ if conf.CONFIG_SET('HAVE_PTHREAD'):
+ conf.DEFINE('WITH_PTHREADPOOL', '1')
+ else:
+ Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
+ conf.undefine('WITH_PTHREADPOOL')
+
+ if conf.CHECK_HEADERS('gpfs_gpl.h'):
+ conf.DEFINE('HAVE_GPFS', '1')
default_static_modules=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
auth_sam auth_unix auth_winbind auth_wbc auth_server
@@ -1657,6 +1710,9 @@ main() {
default_static_modules.extend(TO_LIST('pdb_ads auth_netlogond'))
default_shared_modules.extend(TO_LIST('charset_weird perfcount_test'))
+ if conf.env.toplevel_build:
+ default_static_modules.extend(TO_LIST('pdb_samba4 auth_samba4'))
+
if Options.options.with_acl_support and conf.CONFIG_SET('HAVE_POSIX_ACLS'):
default_static_modules.extend(TO_LIST('vfs_posixacl'))
@@ -1678,6 +1734,9 @@ main() {
if conf.CONFIG_SET('DARWINOS'):
default_shared_modules.extend(TO_LIST('charset_macosxfs'))
+ if conf.CONFIG_SET('HAVE_GPFS'):
+ default_shared_modules.extend(TO_LIST('vfs_gpfs vfs_gpfs_hsm_notify'))
+
explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
diff --git a/source3/wscript_build b/source3/wscript_build
index 7a01a7a366f..624fcc8a732 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -16,8 +16,7 @@ bld.env.public_headers_allow_broken = True
TDB_LIB_SRC = '''
lib/dbwrap.c lib/dbwrap_tdb.c
lib/dbwrap_ctdb.c
- lib/g_lock.c
- lib/dbwrap_rbt.c'''
+ lib/g_lock.c'''
TDB_VALIDATE_SRC = '''lib/tdb_validate.c'''
@@ -39,8 +38,6 @@ COMPRESSION_SRC = '../lib/compression/mszip.c'
DRSUAPI_SRC = '''${COMPRESSION_SRC}'''
-LIBNDR_SRC = '''librpc/ndr/util.c'''
-
LIBCLI_SPOOLSS_SRC = '''rpc_client/cli_spoolss.c
rpc_client/init_spoolss.c'''
@@ -57,12 +54,9 @@ LIBCLI_WINREG_SRC = '''rpc_client/cli_winreg.c
# that requires knowledge of security contexts
REG_PARSE_PRS_SRC = '''registry/reg_parse_prs.c'''
-PTHREADPOOL_SRC = ''
-
LIB_SRC = '''
lib/messages.c lib/messages_local.c
- lib/messages_ctdbd.c lib/packet.c lib/ctdbd_conn.c
- lib/interfaces.c lib/memcache.c
+ lib/messages_ctdbd.c lib/ctdb_packet.c lib/ctdbd_conn.c
lib/talloc_dict.c
lib/util_sconn.c
lib/serverid.c
@@ -75,36 +69,31 @@ LIB_SRC = '''
lib/system.c lib/sendfile.c lib/recvfile.c lib/time.c
lib/username.c
lib/access.c lib/smbrun.c
- lib/bitmap.c lib/dprintf.c
lib/wins_srv.c
lib/util_sid.c
lib/util_file.c
- lib/util.c lib/util_cmdline.c lib/util_names.c
- lib/util_sock.c lib/sock_exec.c lib/util_sec.c
- lib/substitute.c lib/dbwrap_util.c
+ lib/util.c
+ lib/util_sock.c lib/sock_exec.c
+ lib/substitute.c lib/substitute_generic.c
lib/ms_fnmatch.c
lib/tallocmsg.c lib/dmallocmsg.c
libsmb/clisigning.c libsmb/smb_signing.c
intl/lang_tdb.c
- lib/conn_tdb.c lib/adt_tree.c lib/gencache.c
+ lib/conn_tdb.c lib/gencache.c
lib/sessionid_tdb.c
lib/module.c lib/events.c
lib/server_contexts.c
lib/ldap_escape.c
- lib/secdesc.c ${PTHREADPOOL_SRC}
lib/fncall.c
libads/krb5_errs.c lib/system_smbd.c lib/audit.c
lib/file_id.c lib/idmap_cache.c'''
-LIB_DUMMY_SRC = '''lib/dummysmbd.c lib/dummyroot.c'''
-LIB_NONSMBD_SRC = '''${LIB_DUMMY_SRC}'''
-
POPT_LIB_SRC = '''lib/popt_common.c'''
PARAM_UTIL_SRC = '''param/util.c'''
PARAM_WITHOUT_REG_SRC = '''param/loadparm.c param/loadparm_server_role.c
- lib/sharesec.c lib/ldap_debug_handler.c'''
+ lib/sharesec.c lib/ldap_debug_handler.c lib/util_names.c'''
KRBCLIENT_SRC = '''libads/kerberos.c libads/ads_status.c libsmb/clikrb5.c'''
@@ -146,7 +135,7 @@ LIBSMB_SRC = '''libsmb/clientgen.c libsmb/cliconnect.c libsmb/clifile.c
libsmb/clitrans.c libsmb/clisecdesc.c libsmb/clidgram.c
libsmb/clistr.c libsmb/cliquota.c libsmb/clifsinfo.c libsmb/clidfs.c
libsmb/clioplock.c libsmb/clirap2.c
- libsmb/smb_seal.c libsmb/async_smb.c
+ libsmb/smb_seal.c libsmb/async_smb.c libsmb/read_smb.c
libsmb/cli_np_tstream.c
libsmb/smbsock_connect.c'''
@@ -261,7 +250,8 @@ WINBINDD_SRC1 = '''winbindd/winbindd.c
winbindd/winbindd_pam.c
winbindd/winbindd_misc.c
winbindd/winbindd_cm.c
- winbindd/winbindd_wins.c
+ winbindd/winbindd_wins_byip.c
+ winbindd/winbindd_wins_byname.c
winbindd/winbindd_msrpc.c
winbindd/winbindd_rpc.c
winbindd/winbindd_reconnect.c
@@ -345,13 +335,14 @@ WINBINDD_SRC = '''${WINBINDD_SRC1}
MANGLE_SRC = '''smbd/mangle.c smbd/mangle_hash.c smbd/mangle_hash2.c'''
-SMBD_SRC_MAIN = '''smbd/server.c smbd/server_exit.c smbd/msg_idmap.c'''
+SMBD_SRC_MAIN = '''smbd/server.c smbd/msg_idmap.c'''
BUILDOPT_SRC = '''smbd/build_options.c'''
SMBD_SRC_SRV = '''smbd/server_reload.c smbd/files.c smbd/connection.c
smbd/utmp.c smbd/session.c
- smbd/dfree.c smbd/dir.c smbd/password.c smbd/conn.c
+ smbd/dfree.c smbd/dir.c smbd/password.c smbd/conn_msg.c
+ smbd/conn_idle.c
smbd/share_access.c smbd/fileio.c
smbd/ipc.c smbd/lanman.c smbd/negprot.c
smbd/message.c smbd/nttrans.c smbd/pipes.c
@@ -390,6 +381,7 @@ SMBD_SRC_SRV = '''smbd/server_reload.c smbd/files.c smbd/connection.c
smbd/smb2_getinfo.c
smbd/smb2_setinfo.c
smbd/smb2_break.c
+ smbd/server_exit.c
${MANGLE_SRC}'''
SMBD_SRC_BASE = '''${SMBD_SRC_SRV}
@@ -567,7 +559,9 @@ SMBTORTURE_SRC1 = '''torture/torture.c torture/nbio.c torture/scanner.c torture/
torture/test_async_echo.c
torture/test_addrchange.c
torture/test_posix_append.c
+ torture/test_nttrans_create.c
torture/test_case_insensitive.c
+ torture/test_notify_online.c
torture/test_smbsock_any_connect.c'''
SMBTORTURE_SRC = '''${SMBTORTURE_SRC1}
@@ -642,13 +636,6 @@ t = bld.SAMBA_GENERATOR('build_env.h',
t.env.SRCDIR = bld.path.abspath()
t.env.BUILDDIR = bld.path.abspath()
-if not bld.env.toplevel_build:
- bld.SAMBA_GENERATOR('smbtorture4',
- source='',
- target='',
- rule='cd ../; make -f Makefile-smbtorture4 bin/smbtorture4',
- always=True)
-
bld.SETUP_BUILD_GROUPS()
if not bld.env.toplevel_build:
@@ -664,45 +651,48 @@ if not bld.env.toplevel_build:
bld.SAMBA3_LIBRARY('netapi',
source=LIBNETAPI_SRC,
- public_deps='''talloc tdb cap wbclient LIB_NONSMBD LIBSMB KRBCLIENT
- passdb SMBLDAP PARAM_WITHOUT_REG samba-util
+ public_deps='''talloc tdb_compat cap wbclient smbd_shim LIBSMB KRBCLIENT
+ passdb SMBLDAP param samba-util
LIBMSRPC_GEN msrpc3 ads LIBNET DCUTIL NDR_LIBNETAPI
- RPC_CLIENT_SCHANNEL LIB_SMBCONF REG_SMBCONF TOKEN_UTIL
+ RPC_CLIENT_SCHANNEL smbconf REG_SMBCONF TOKEN_UTIL
LIBCLI_SAMR LIBCLI_LSA3 LIBRPCCLI_NETLOGON
RPC_NDR_SRVSVC RPC_NDR_WKSSVC RPC_NDR_INITSHUTDOWN
- INIT_NETLOGON INIT_SAMR''',
+ INIT_NETLOGON INIT_SAMR POPT_SAMBA3''',
public_headers='../source3/lib/netapi/netapi.h',
vnum='0',
vars=locals())
bld.SAMBA3_LIBRARY('libsmb/smbclient',
source=LIBSMBCLIENT_SRC,
- public_deps='''talloc tdb wbclient cap param LIB_NONSMBD LIBSMB KRBCLIENT passdb SMBLDAP
- LIBMSRPC_GEN msrpc3 LIBCLI_LSA3 RPC_NDR_SRVSVC''',
+ public_deps='''talloc tdb_compat wbclient cap param smbd_shim LIBSMB KRBCLIENT passdb SMBLDAP
+ LIBMSRPC_GEN msrpc3 LIBCLI_LSA3 RPC_NDR_SRVSVC POPT_SAMBA3''',
public_headers='include/libsmbclient.h',
vnum='0',
vars=locals())
bld.SAMBA3_LIBRARY('smbsharemodes',
source=LIBSMBSHAREMODES_SRC,
- public_deps='''talloc tdb''',
+ public_deps='''talloc tdb_compat''',
+ deps='''ccan''',
public_headers='include/smb_share_modes.h',
vnum='0',
vars=locals())
bld.SAMBA3_LIBRARY('nss_wins',
source=WINBIND_WINS_NSS_SRC,
- deps='''winbind-client param LIBSMB LIB_NONSMBD LIBTSOCKET KRBCLIENT
+ deps='''winbind-client param LIBSMB smbd_shim LIBTSOCKET KRBCLIENT
cap wbclient''',
realname='libnss_wins.so.2',
vnum='2')
-bld.SAMBA3_SUBSYSTEM('msrpc3',
- source='${LIBMSRPC_SRC}',
- deps='''ndr ndr-util NDR_SECURITY NDR_DCERPC NDR_SCHANNEL
- RPC_NDR_EPMAPPER COMMON_SCHANNEL LIBCLI_AUTH
- LIBTSOCKET krb5 rpccommon''',
- vars=locals())
+bld.SAMBA3_LIBRARY('msrpc3',
+ source='${LIBMSRPC_SRC}',
+ deps='''ndr ndr-standard
+ RPC_NDR_EPMAPPER NTLMSSP_COMMON COMMON_SCHANNEL LIBCLI_AUTH
+ LIBTSOCKET KRB5_WRAP rpccommon
+ LIBSMB''',
+ vars=locals(),
+ private_library=True)
bld.SAMBA3_SUBSYSTEM('LIBMSRPC_GEN',
source='',
@@ -711,7 +701,7 @@ bld.SAMBA3_SUBSYSTEM('LIBMSRPC_GEN',
bld.SAMBA3_SUBSYSTEM('LIBGPO',
source='${LIBGPO_SRC}',
- deps='gpext',
+ deps='gpext talloc',
vars=locals())
bld.SAMBA3_SUBSYSTEM('AVAHI',
@@ -720,7 +710,8 @@ bld.SAMBA3_SUBSYSTEM('AVAHI',
enabled=bld.env.with_avahi)
bld.SAMBA3_SUBSYSTEM('GROUPDB',
- source=GROUPDB_SRC)
+ source=GROUPDB_SRC,
+ deps='tdb_compat')
bld.SAMBA3_SUBSYSTEM('TLDAP',
source=TLDAP_SRC,
@@ -728,39 +719,50 @@ bld.SAMBA3_SUBSYSTEM('TLDAP',
bld.SAMBA3_LIBRARY('passdb',
source=PASSDB_SRC,
- deps='SECRETS3 SMBLDAP GROUPDB pdb wbclient LIBCLI_AUTH',
+ deps='SECRETS3 SMBLDAP GROUPDB pdb wbclient LIBCLI_AUTH flag_mapping',
private_library=True,
vars=locals())
bld.SAMBA3_SUBSYSTEM('PARAM_UTIL',
- source=PARAM_UTIL_SRC)
+ source=PARAM_UTIL_SRC,
+ deps='samba-util')
-bld.SAMBA3_SUBSYSTEM('PARAM_WITHOUT_REG',
- source=PARAM_WITHOUT_REG_SRC,
- deps='''PARAM_UTIL''',
- vars=locals())
+if bld.env.toplevel_build:
+ bld.SAMBA3_SUBSYSTEM('LOADPARM_CTX',
+ source='param/loadparm_ctx.c',
+ deps='''s3_param_h param''',
+ vars=locals())
-bld.SAMBA3_LIBRARY('param',
- source='',
- deps='PARAM_WITHOUT_REG samba-util LIB_SMBCONF',
- private_library=True,
- vars=locals())
+bld.SAMBA3_SUBSYSTEM('param',
+ source=PARAM_WITHOUT_REG_SRC,
+ deps='samba-util PARAM_UTIL smbd_conn ldap lber LOADPARM_CTX samba3core smbconf''')
+
+bld.SAMBA3_SUBSYSTEM('param_service',
+ source='param/service.c',
+ deps = 'USER_UTIL param USER_UTIL PRINTING')
bld.SAMBA3_SUBSYSTEM('REGFIO',
source=REGFIO_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('REG_API_REGF',
source=REG_API_REGF_SRC,
+ deps='samba-util',
vars=locals())
-bld.SAMBA3_SUBSYSTEM('REG_BASE',
- source=REG_BASE_SRC,
- vars=locals())
+bld.SAMBA3_LIBRARY('smbregistry',
+ source=REG_BASE_SRC,
+ deps='''smbd_shim tdb-wrap3 NDR_SECURITY UTIL_TDB talloc
+ replace util_reg samba-util security
+ errors3 adt_tree dbwrap_util util_str util_sec util_malloc''',
+ vars=locals(),
+ allow_undefined_symbols=True,
+ private_library=True)
bld.SAMBA3_SUBSYSTEM('REG_SMBCONF',
source=REG_SMBCONF_SRC,
- deps='REG_BASE',
+ deps='smbregistry',
vars=locals())
bld.SAMBA3_SUBSYSTEM('REG_FULL',
@@ -768,30 +770,34 @@ bld.SAMBA3_SUBSYSTEM('REG_FULL',
deps='REG_SMBCONF',
vars=locals())
-bld.SAMBA3_SUBSYSTEM('POPT_SAMBA3',
- source=POPT_LIB_SRC,
- deps='popt',
- vars=locals())
+bld.SAMBA3_LIBRARY('POPT_SAMBA3',
+ source=POPT_LIB_SRC,
+ deps='popt samba-util UTIL_CMDLINE',
+ vars=locals(),
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('UTIL_CMDLINE',
+ source='lib/util_cmdline.c',
+ deps='SECRETS3',
+ private_library=True)
bld.SAMBA3_SUBSYSTEM('KRBCLIENT',
source=KRBCLIENT_SRC,
- public_deps='KRB5_WRAP krb5 k5crypto com_err gssapi gssapi_krb5',
+ public_deps='KRB5_WRAP k5crypto',
vars=locals())
-bld.SAMBA3_LIBRARY('samba3core',
+bld.SAMBA3_SUBSYSTEM('samba3core',
source=LIB_SRC,
- deps='LIBCRYPTO ndr ndr-util security NDR_SECURITY charset NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 CHARSET3 UTIL_TDB UTIL_PW SAMBA_VERSION krb5 flag_mapping util_reg',
- private_library=True,
+ deps='LIBCRYPTO ndr security NDR_SECURITY samba-util NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 UTIL_TDB UTIL_PW SAMBA_VERSION KRB5_WRAP flag_mapping util_reg PTHREADPOOL interfaces cap string_init param util_str CHARSET3 namearray dbwrap_util util_sec util_malloc memcache ccan errors3',
vars=locals())
-bld.SAMBA3_SUBSYSTEM('LIB_NONSMBD',
- source=LIB_NONSMBD_SRC,
- deps='samba3core',
- vars=locals())
+bld.SAMBA3_LIBRARY('smbd_shim',
+ source='''lib/smbd_shim.c''',
+ private_library=True)
bld.SAMBA3_SUBSYSTEM('LIBSMB_ERR',
source='',
- deps='errors3 SECRETS3 ldap lber MSRPC_PARSE LIBCLI_AUTH rpccommon',
+ deps='errors3 passdb ldap lber MSRPC_PARSE LIBCLI_AUTH rpccommon',
vars=locals())
bld.SAMBA3_SUBSYSTEM('LIBNTLMSSP',
@@ -799,10 +805,11 @@ bld.SAMBA3_SUBSYSTEM('LIBNTLMSSP',
deps='LIBSMB_ERR NDR_NTLMSSP NTLMSSP_COMMON',
vars=locals())
-bld.SAMBA3_SUBSYSTEM('LIBSMB',
- source=LIBSMB_SRC,
- deps='LIBNTLMSSP CLDAP LIBNMB LIBNBT LIBDRSUAPI SPNEGO_PARSE LIBTSOCKET KRBCLIENT',
- vars=locals())
+bld.SAMBA3_LIBRARY('LIBSMB',
+ source=LIBSMB_SRC,
+ deps='LIBNTLMSSP CLDAP LIBNMB LIBNBT LIBDRSUAPI SPNEGO_PARSE LIBTSOCKET KRBCLIENT LIBCLI_SMB_COMMON UTIL_CMDLINE',
+ vars=locals(),
+ private_library=True)
bld.SAMBA3_SUBSYSTEM('LIBDRSUAPI',
source=DRSUAPI_SRC,
@@ -815,9 +822,9 @@ bld.SAMBA3_SUBSYSTEM('CLDAP',
vars=locals())
bld.SAMBA3_SUBSYSTEM('SECRETS3',
- source=SECRETS_SRC,
- deps='NDR_SECRETS',
- vars=locals())
+ source=SECRETS_SRC,
+ deps='NDR_SECRETS param samba3core passdb',
+ vars=locals())
bld.SAMBA3_SUBSYSTEM('SMBLDAP',
source=SMBLDAP_SRC,
@@ -827,59 +834,72 @@ bld.SAMBA3_SUBSYSTEM('SMBLDAP',
bld.SAMBA3_LIBRARY('ads',
source=LIBADS_SRC,
- deps='cli-ldap-common krb5 gssapi gssapi_krb5 ldap lber',
+ deps='cli-ldap-common KRB5_WRAP ldap lber KRBCLIENT param LIBNTLMSSP LIBNMB LIBSMB DCUTIL',
private_library=True,
vars=locals())
bld.SAMBA3_SUBSYSTEM('LIBADS_SERVER',
source=LIBADS_SERVER_SRC,
- deps='ndr-krb5pac krb5 KRB5_WRAP',
+ deps='ndr-krb5pac KRB5_WRAP',
vars=locals())
bld.SAMBA3_SUBSYSTEM('LIBADS_PRINTER',
source=LIBADS_PRINTER_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('LIBAFS',
source=AFS_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('LIBAFS_SETTOKEN',
source=AFS_SETTOKEN_SRC,
+ deps='samba-util',
vars=locals())
-bld.SAMBA3_SUBSYSTEM('LIB_SMBCONF',
- source=LIB_SMBCONF_SRC,
- deps='LIBSMBCONF REG_BASE REG_SMBCONF',
- vars=locals())
+bld.SAMBA3_LIBRARY('smbconf',
+ source=LIB_SMBCONF_SRC,
+ deps='''LIBSMBCONF smbregistry REG_SMBCONF talloc param
+ util_reg samba-util errors3 CHARSET SAMBA_VERSION''',
+ public_headers='../lib/smbconf/smbconf.h',
+ vnum='0')
+
+bld.SAMBA3_LIBRARY('smbd_conn',
+ source='smbd/conn.c',
+ deps='string_init bitmap namearray',
+ private_library=True)
bld.SAMBA3_LIBRARY('smbd_base',
source=SMBD_SRC_BASE,
- deps='''tdb tevent dl krb5 ldap gssapi gssapi_krb5
+ deps='''tdb_compat tevent dl krb5 ldap gssapi gssapi_krb5
samba-util wbclient crypt nsl cups cap z passdb
- PARAM_WITHOUT_REG samba3core LIBSMB POPT_SAMBA3 KRBCLIENT AVAHI
+ param samba3core LIBSMB POPT_SAMBA3 KRBCLIENT AVAHI
LIBMSRPC_GEN msrpc3 ads LIBADS_SERVER LIBADS_PRINTER
vfs vfs_default vfs_posixacl auth rpc LOCKING LIBAFS LIBAFS_SETTOKEN PROFILE
- PRINTING PRINTBACKEND NDR_XATTR NDR_NOTIFY3 REGFIO
- LIB_SMBCONF REG_FULL FNAME_UTIL
+ PRINTING PRINTBACKEND NDR_XATTR NDR_NOTIFY REGFIO
+ smbconf REG_FULL FNAME_UTIL
LIBCLI_SAMR LIBCLI_LSA3 LIBRPCCLI_NETLOGON LIBCLI_SPOOLSS
RPC_NDR_SRVSVC npa_tstream INIT_NETLOGON INIT_SAMR
- LIBCLI_SMB_COMMON RPC_SERVER
+ LIBCLI_SMB_COMMON RPC_SERVER smbd_conn param_service
+ smbd_shim
''',
private_library=True,
vars=locals())
bld.SAMBA3_SUBSYSTEM('LOCKING',
source='${LOCKING_SRC}',
- deps='''tdb talloc''',
+ deps='''tdb_compat talloc''',
vars=locals())
bld.SAMBA3_SUBSYSTEM('PROFILE',
source='${PROFILE_SRC}',
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('PRINTBASE',
source=PRINTBASE_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('PRINTBACKEND',
@@ -894,15 +914,17 @@ bld.SAMBA3_SUBSYSTEM('PRINTING',
bld.SAMBA3_SUBSYSTEM('PASSWD_UTIL',
source=PASSWD_UTIL_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('FNAME_UTIL',
source=FNAME_UTIL_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('LIBNET',
source=LIBNET_SRC,
- deps='NDR_LIBNET_JOIN krb5',
+ deps='NDR_LIBNET_JOIN KRB5_WRAP',
vars=locals())
bld.SAMBA3_SUBSYSTEM('LIBNET_DSSYNC',
@@ -932,6 +954,7 @@ bld.SAMBA3_SUBSYSTEM('LIBNBT',
bld.SAMBA3_SUBSYSTEM('SERVICES',
source=SERVICES_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('PLAINTEXT_AUTH',
@@ -946,42 +969,91 @@ bld.SAMBA3_SUBSYSTEM('PASSCHANGE',
bld.SAMBA3_SUBSYSTEM('SAMBA_VERSION',
source=VERSION_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('SLCACHE',
source=SLCACHE_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('DCUTIL',
source=DCUTIL_SRC,
- vars=locals())
-
-bld.SAMBA3_SUBSYSTEM('ndr-util',
- source=LIBNDR_SRC,
+ deps='ads LIBRPCCLI_NETLOGON msrpc3 LIBCLI_LSA3 INIT_NETLOGON',
vars=locals())
bld.SAMBA3_SUBSYSTEM('tdb-wrap3',
source='lib/util_tdb.c',
+ deps='tdb-wrap',
vars=locals())
-bld.SAMBA3_SUBSYSTEM('CHARSET3',
- source='''lib/util_str.c lib/charcnv.c ../lib/util/charset/convert_string.c lib/fstring.c''',
- public_deps='ICONV_WRAPPER CODEPOINTS',
- deps='samba-util')
+bld.SAMBA3_LIBRARY('dbwrap_util',
+ source='lib/dbwrap_util.c lib/dbwrap_rbt.c',
+ deps='samba-util UTIL_TDB errors',
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('util_malloc',
+ source='''lib/util_malloc.c''',
+ deps='samba-util',
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('string_init',
+ source='''lib/string_init.c''',
+ deps='samba-util',
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('util_str',
+ source='''lib/util_str.c''',
+ deps='samba-util CHARSET',
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('util_sec',
+ source='''lib/util_sec.c''',
+ deps='samba-util',
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('bitmap',
+ source='lib/bitmap.c',
+ deps='samba-util',
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('namearray',
+ source='lib/namearray.c',
+ deps='samba-util',
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('adt_tree',
+ source='lib/adt_tree.c',
+ deps='samba-util',
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('memcache',
+ source='lib/memcache.c',
+ deps='samba-util util_malloc',
+ private_library=True)
+
+bld.SAMBA3_LIBRARY('CHARSET3',
+ source='''lib/charcnv.c lib/fstring.c''',
+ public_deps='ICONV_WRAPPER CHARSET',
+ deps='samba-util util_str',
+ private_library=True)
bld.SAMBA3_SUBSYSTEM('ldb3',
- source='lib/ldb_compat.c')
+ source='lib/ldb_compat.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('errors3',
- source='../libcli/util/doserr.c libsmb/nterr.c libsmb/errormap.c libsmb/smberr.c lib/errmap_unix.c')
+ source='libsmb/errormap.c libsmb/smberr.c lib/errmap_unix.c',
+ deps='errors')
bld.SAMBA3_SUBSYSTEM('LIBCLI_SAMR',
source=LIBCLI_SAMR_SRC,
deps='RPC_NDR_SAMR')
-bld.SAMBA3_SUBSYSTEM('LIBCLI_LSA3',
- source=LIBCLI_LSA_SRC,
- deps='RPC_NDR_LSA INIT_LSA')
+bld.SAMBA3_LIBRARY('LIBCLI_LSA3',
+ source=LIBCLI_LSA_SRC,
+ deps='RPC_NDR_LSA INIT_LSA',
+ private_library=True)
bld.SAMBA3_SUBSYSTEM('LIBRPCCLI_NETLOGON',
source=LIBRPCCLI_NETLOGON_SRC,
@@ -993,20 +1065,24 @@ bld.SAMBA3_SUBSYSTEM('LIBCLI_SPOOLSS',
bld.SAMBA3_SUBSYSTEM('LIBCLI_WINREG',
source=LIBCLI_WINREG_SRC,
- deps='RPC_NDR_WINREG')
+ deps='RPC_NDR_WINREG RPC_NCACN_NP')
bld.SAMBA3_SUBSYSTEM('RPC_CLIENT_SCHANNEL',
- source=RPC_CLIENT_SCHANNEL_SRC,
- vars=locals())
+ source=RPC_CLIENT_SCHANNEL_SRC,
+ deps='samba-util',
+ vars=locals())
bld.SAMBA3_SUBSYSTEM('INIT_LSA',
- source='rpc_client/init_lsa.c')
+ source='rpc_client/init_lsa.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('INIT_NETLOGON',
- source='rpc_client/init_netlogon.c')
+ source='rpc_client/init_netlogon.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('INIT_SAMR',
- source='rpc_client/init_samr.c')
+ source='rpc_client/init_samr.c',
+ deps='samba-util')
########################## BINARIES #################################
@@ -1018,16 +1094,16 @@ bld.SAMBA3_BINARY('smbd/smbd',
bld.SAMBA3_BINARY('nmbd/nmbd',
source=NMBD_SRC,
- deps='''talloc tdb tevent z cap wbclient dl
- passdb param ldap LIB_NONSMBD LIBSMB
+ deps='''talloc tdb_compat tevent z cap wbclient dl
+ passdb param ldap smbd_shim LIBSMB
POPT_SAMBA3 KRBCLIENT NDR_SAMR NDR_LSA PROFILE''',
install_path='${SBINDIR}',
vars=locals())
bld.SAMBA3_BINARY('winbindd/winbindd',
source=WINBINDD_SRC,
- deps='''talloc tdb tevent cap dl z
- wbclient passdb ldap param LIB_NONSMBD LIBSMB
+ deps='''talloc tdb_compat tevent cap dl z
+ wbclient passdb ldap param smbd_shim LIBSMB
POPT_SAMBA3 KRBCLIENT LIBMSRPC_GEN msrpc3 ads LIBADS_SERVER
SRV_NDR_WBINT RPC_NDR_WBINT NDR_WBINT LIBAFS
LIBAFS_SETTOKEN PROFILE SLCACHE DCUTIL idmap nss_info
@@ -1044,7 +1120,7 @@ bld.SAMBA3_BINARY('winbindd/winbindd',
bld.SAMBA3_BINARY('web/swat',
source=SWAT_SRC,
deps='''talloc tevent cap samba3core LIBSMB wbclient param
- LIB_NONSMBD passdb POPT_SAMBA3 KRBCLIENT cups
+ smbd_shim passdb POPT_SAMBA3 KRBCLIENT cups
LIBMSRPC_GEN msrpc3 LOCKING PLAINTEXT_AUTH PRINTBASE PRINTING FNAME_UTIL
LIBCLI_SAMR INIT_LSA PASSCHANGE''',
enabled=bld.env.build_swat,
@@ -1053,8 +1129,8 @@ bld.SAMBA3_BINARY('web/swat',
bld.SAMBA3_BINARY('rpcclient/rpcclient',
source=RPCCLIENT_SRC,
- deps='''talloc tdb cap POPT_SAMBA3 passdb LIBSMB LIB_NONSMBD
- PARAM_WITHOUT_REG wbclient param KRBCLIENT LIBMSRPC_GEN msrpc3
+ deps='''talloc tdb_compat cap POPT_SAMBA3 passdb LIBSMB smbd_shim
+ param wbclient param KRBCLIENT LIBMSRPC_GEN msrpc3
ads SMBREADLINE DCUTIL RPC_NDR_WINREG RPC_NDR_ECHO
RPC_CLIENT_SCHANNEL
LIBCLI_SAMR LIBCLI_LSA3 LIBRPCCLI_NETLOGON LIBCLI_SPOOLSS
@@ -1066,15 +1142,16 @@ bld.SAMBA3_BINARY('rpcclient/rpcclient',
bld.SAMBA3_BINARY('client/smbclient' + bld.env.suffix3,
source=CLIENT_SRC,
- deps='''talloc tdb cap POPT_SAMBA3 passdb LIBSMB LIB_NONSMBD
- PARAM_WITHOUT_REG wbclient param KRBCLIENT LIBMSRPC_GEN
- msrpc3 SMBREADLINE libsmb/smbclient RPC_NDR_SRVSVC INIT_LSA''',
+ deps='''talloc tdb_compat cap POPT_SAMBA3 passdb LIBSMB smbd_shim
+ param wbclient param KRBCLIENT LIBMSRPC_GEN
+ msrpc3 SMBREADLINE libsmb/smbclient RPC_NDR_SRVSVC INIT_LSA
+ LIBCLI_SMB_COMMON''',
vars=locals())
bld.SAMBA3_BINARY('net',
source=NET_SRC,
- deps='''talloc tdb netapi addns cap intl POPT_SAMBA3 passdb LIBSMB LIB_NONSMBD
- PARAM_WITHOUT_REG wbclient param KRBCLIENT LIBMSRPC_GEN msrpc3 LIBGPO ads LIBADS_SERVER LIBADS_PRINTER
+ deps='''talloc tdb_compat netapi addns cap intl POPT_SAMBA3 passdb LIBSMB smbd_shim
+ param wbclient param KRBCLIENT LIBMSRPC_GEN msrpc3 LIBGPO ads LIBADS_SERVER LIBADS_PRINTER
LIBAFS LIBAFS_SETTOKEN SMBREADLINE PASSWD_UTIL LIBNET
LIBNET_DSSYNC LIBNET_SAMSYNC LIBEVENTLOG DCUTIL
REGFIO NDR_NTPRINTING RPC_NDR_WINREG
@@ -1087,79 +1164,79 @@ bld.SAMBA3_BINARY('net',
bld.SAMBA3_BINARY('profiles',
source=PROFILES_SRC,
- deps='''talloc tdb cap tevent POPT_SAMBA3 param samba3core LIBSMB_ERR LIB_NONSMBD REGFIO''',
+ deps='''talloc tdb_compat cap tevent POPT_SAMBA3 param samba3core LIBSMB_ERR smbd_shim REGFIO''',
vars=locals())
bld.SAMBA3_BINARY('smbspool',
source=CUPS_SRC,
- deps='''talloc tdb tevent cap wbclient POPT_SAMBA3 param LIBSMB LIB_NONSMBD samba3core
+ deps='''talloc tdb_compat tevent cap wbclient POPT_SAMBA3 param LIBSMB smbd_shim samba3core
KRBCLIENT asn1util LIBTSOCKET NDR_SAMR NDR_LSA''',
vars=locals())
bld.SAMBA3_BINARY('testparm',
source=TESTPARM_SRC,
deps='''talloc tevent ldap cap
- wbclient asn1util LIBTSOCKET passdb param LIB_NONSMBD
+ wbclient asn1util LIBTSOCKET passdb param smbd_shim
LIBSMB_ERR POPT_SAMBA3''',
vars=locals())
bld.SAMBA3_BINARY('smbta-util',
source=SMBTA_UTIL_SRC,
- deps='''talloc tdb tevent cap param POPT_SAMBA3 LIB_NONSMBD
+ deps='''talloc tdb_compat tevent cap param POPT_SAMBA3 smbd_shim
LIBSMB_ERR''',
vars=locals())
bld.SAMBA3_BINARY('smbstatus',
source=STATUS_SRC,
- deps='''talloc tdb tevent cap param POPT_SAMBA3 LIB_NONSMBD
+ deps='''talloc tdb_compat tevent cap param POPT_SAMBA3 smbd_shim
LIBSMB_ERR LOCKING PROFILE FNAME_UTIL''',
vars=locals())
bld.SAMBA3_BINARY('smbcontrol',
source=SMBCONTROL_SRC,
- deps='''talloc tdb tevent cap param LIB_NONSMBD LIBSMB_ERR POPT_SAMBA3 PRINTBASE''',
+ deps='''talloc tdb_compat tevent cap param smbd_shim LIBSMB_ERR POPT_SAMBA3 PRINTBASE''',
vars=locals())
bld.SAMBA3_BINARY('smbtree',
source=SMBTREE_SRC,
- deps='''talloc tdb tevent cap wbclient param LIB_NONSMBD
+ deps='''talloc tdb_compat tevent cap wbclient param smbd_shim
LIBSMB LIBSMB_ERR POPT_SAMBA3 KRBCLIENT passdb SMBLDAP LIBMSRPC_GEN msrpc3 PROFILE
RPC_NDR_SRVSVC''',
vars=locals())
bld.SAMBA3_BINARY('smbpasswd',
source=SMBPASSWD_SRC,
- deps='''talloc tdb tevent cap wbclient param LIB_NONSMBD
+ deps='''talloc tdb_compat tevent cap wbclient param smbd_shim
LIBSMB LIBSMB_ERR POPT_SAMBA3 KRBCLIENT passdb SMBLDAP LIBMSRPC_GEN msrpc3 PASSWD_UTIL
LIBCLI_SAMR INIT_LSA PASSCHANGE''',
vars=locals())
bld.SAMBA3_BINARY('pdbedit',
source=PDBEDIT_SRC,
- deps='''talloc tdb tevent cap wbclient param LIB_NONSMBD
+ deps='''talloc tdb_compat tevent cap wbclient param smbd_shim
LIBNTLMSSP LIBSMB_ERR POPT_SAMBA3 passdb SMBLDAP
PASSWD_UTIL cli-ldap-common''',
vars=locals())
bld.SAMBA3_BINARY('smbget',
source=SMBGET_SRC,
- deps='''talloc tdb libsmb/smbclient POPT_SAMBA3''',
+ deps='''talloc tdb_compat libsmb/smbclient POPT_SAMBA3''',
vars=locals())
bld.SAMBA3_BINARY('nmblookup' + bld.env.suffix3,
source=NMBLOOKUP_SRC,
- deps='''talloc tdb tevent cap param LIB_NONSMBD POPT_SAMBA3 LIBSMB_ERR LIBNMB''',
+ deps='''talloc tdb_compat tevent cap param smbd_shim POPT_SAMBA3 LIBSMB_ERR LIBNMB''',
vars=locals())
bld.SAMBA3_BINARY('smbtorture' + bld.env.suffix3,
source=SMBTORTURE_SRC,
- deps='''talloc tdb tevent cap wbclient param LIBSMB KRBCLIENT TLDAP
- LIB_NONSMBD POPT_SAMBA3 asn1util LIBTSOCKET NDR_LSA msrpc3 LIBMSRPC_GEN RPC_NDR_ECHO WB_REQTRANS''',
+ deps='''talloc tdb_compat tevent cap wbclient param LIBSMB KRBCLIENT TLDAP
+ smbd_shim POPT_SAMBA3 asn1util LIBTSOCKET NDR_LSA msrpc3 LIBMSRPC_GEN RPC_NDR_ECHO WB_REQTRANS''',
vars=locals())
bld.SAMBA3_BINARY('smbconftort',
source=SMBCONFTORT_SRC,
- deps='''talloc tdb tevent cap wbclient param LIB_NONSMBD LIBSMB_ERR POPT_SAMBA3''',
+ deps='''talloc tdb_compat tevent cap wbclient param smbd_shim LIBSMB_ERR POPT_SAMBA3''',
vars=locals())
bld.SAMBA3_BINARY('replacetort',
@@ -1169,25 +1246,25 @@ bld.SAMBA3_BINARY('replacetort',
bld.SAMBA3_BINARY('masktest' + bld.env.suffix3,
source=MASKTEST_SRC,
- deps='''talloc tdb cap wbclient param LIB_NONSMBD LIBSMB KRBCLIENT
+ deps='''talloc tdb_compat cap wbclient param smbd_shim LIBSMB KRBCLIENT
asn1util LIBTSOCKET NDR_SAMR NDR_LSA''',
vars=locals())
bld.SAMBA3_BINARY('msgtest',
source=MSGTEST_SRC,
- deps='''talloc tdb tevent cap param LIBSMB_ERR LIB_NONSMBD''',
+ deps='''talloc tdb_compat tevent cap param LIBSMB_ERR smbd_shim''',
vars=locals())
bld.SAMBA3_BINARY('smbcacls',
source=SMBCACLS_SRC,
- deps='''talloc tdb cap wbclient param LIBSMB KRBCLIENT
- LIB_NONSMBD passdb POPT_SAMBA3 SMBLDAP LIBMSRPC_GEN
+ deps='''talloc tdb_compat cap wbclient param LIBSMB KRBCLIENT
+ smbd_shim passdb POPT_SAMBA3 SMBLDAP LIBMSRPC_GEN
msrpc3 LIBCLI_LSA3''',
vars=locals())
bld.SAMBA3_BINARY('smbcquotas',
source=SMBCQUOTAS_SRC,
- deps='''talloc tdb cap wbclient param LIB_NONSMBD LIBSMB KRBCLIENT
+ deps='''talloc tdb_compat cap wbclient param smbd_shim LIBSMB KRBCLIENT
POPT_SAMBA3 passdb SMBLDAP LIBMSRPC_GEN msrpc3
LIBCLI_LSA3''',
vars=locals())
@@ -1195,23 +1272,23 @@ bld.SAMBA3_BINARY('smbcquotas',
bld.SAMBA3_BINARY('eventlogadm',
source=EVTLOGADM_SRC,
deps='''talloc tevent cap POPT_SAMBA3 samba3core param
- LIB_NONSMBD LIBSMB_ERR passdb wbclient LIBEVENTLOG''',
+ smbd_shim LIBSMB_ERR passdb wbclient LIBEVENTLOG''',
vars=locals())
bld.SAMBA3_BINARY('sharesec',
source=SHARESEC_SRC,
- deps='''talloc tdb tevent cap wbclient param LIB_NONSMBD LIBSMB_ERR POPT_SAMBA3''',
+ deps='''talloc tdb_compat tevent cap wbclient param smbd_shim LIBSMB_ERR POPT_SAMBA3''',
vars=locals())
bld.SAMBA3_BINARY('locktest' + bld.env.suffix3,
source=LOCKTEST_SRC,
- deps='''talloc tdb tevent cap wbclient param KRBCLIENT LIBSMB LIB_NONSMBD
+ deps='''talloc tdb_compat tevent cap wbclient param KRBCLIENT LIBSMB smbd_shim
asn1util LIBTSOCKET NDR_SAMR NDR_LSA LOCKING FNAME_UTIL''',
vars=locals())
bld.SAMBA3_BINARY('pdbtest',
source=PDBTEST_SRC,
- deps='''talloc tdb cap wbclient param LIBSMB KRBCLIENT LIB_NONSMBD passdb
+ deps='''talloc tdb_compat cap wbclient param LIBSMB KRBCLIENT smbd_shim passdb
SMBLDAP POPT_SAMBA3 NDR_SAMR NDR_LSA''',
vars=locals())
@@ -1222,7 +1299,7 @@ bld.SAMBA3_BINARY('vfstest',
bld.SAMBA3_BINARY('smbiconv',
source=SMBICONV_SRC,
- deps='''talloc tdb tevent cap param LIB_NONSMBD POPT_SAMBA3 LIBSMB_ERR''',
+ deps='''talloc tdb_compat tevent cap param smbd_shim POPT_SAMBA3 LIBSMB_ERR''',
vars=locals())
bld.SAMBA3_BINARY('log2pcap',
@@ -1232,7 +1309,7 @@ bld.SAMBA3_BINARY('log2pcap',
bld.SAMBA3_BINARY('locktest2',
source=LOCKTEST2_SRC,
- deps='''talloc tdb tevent cap wbclient param KRBCLIENT LIBSMB LIB_NONSMBD
+ deps='''talloc tdb_compat tevent cap wbclient param KRBCLIENT LIBSMB smbd_shim
asn1util LIBTSOCKET NDR_SAMR NDR_LSA LOCKING FNAME_UTIL''',
vars=locals())
@@ -1243,25 +1320,25 @@ bld.SAMBA3_BINARY('debug2html',
bld.SAMBA3_BINARY('smbfilter',
source=SMBFILTER_SRC,
- deps='''talloc tevent cap wbclient param LIBSMB LIB_NONSMBD KRBCLIENT asn1util LIBTSOCKET
+ deps='''talloc tevent cap wbclient param LIBSMB smbd_shim KRBCLIENT asn1util LIBTSOCKET
NDR_SAMR NDR_LSA''',
vars=locals())
bld.SAMBA3_BINARY('versiontest',
source='lib/version_test.c',
- deps='SAMBA_VERSION',
+ deps='SAMBA_VERSION samba3core param',
vars=locals())
bld.SAMBA3_BINARY('wbinfo' + bld.env.suffix3,
source=WBINFO_SRC,
deps='''talloc wbclient tevent cap
- asn1util LIBTSOCKET passdb ldap param LIB_NONSMBD
+ asn1util LIBTSOCKET passdb ldap param smbd_shim
LIBNTLMSSP POPT_SAMBA3 LIBAFS_SETTOKEN''',
vars=locals())
bld.SAMBA3_BINARY('ntlm_auth' + bld.env.suffix3,
source=NTLM_AUTH_SRC,
- deps='''tdb talloc cap krb5 k5crypto com_err wbclient param LIB_NONSMBD
+ deps='''tdb_compat talloc cap KRB5_WRAP k5crypto wbclient param smbd_shim
samba3core LIBNTLMSSP POPT_SAMBA3 asn1util LIBTSOCKET
passdb SMBLDAP winbind-client LIBINIPARSER LIBADS_SERVER
NDR_SAMR NDR_LSA NDR_NETLOGON cli-ldap-common LIBNMB SLCACHE SPNEGO_PARSE KRBCLIENT''',
@@ -1273,35 +1350,35 @@ bld.SAMBA3_BINARY('timelimit',
bld.SAMBA3_BINARY('rpc_open_tcp',
source=RPC_OPEN_TCP_SRC,
- deps='''talloc tdb tevent cap wbclient KRBCLIENT param samba3core LIBSMB LIB_NONSMBD
+ deps='''talloc tdb_compat tevent cap wbclient KRBCLIENT param samba3core LIBSMB smbd_shim
LIBSMB_ERR asn1util LIBTSOCKET LIBMSRPC_GEN msrpc3''',
vars=locals())
bld.SAMBA3_BINARY('test_lp_load',
source=TEST_LP_LOAD_SRC,
- deps='''talloc tdb tevent cap wbclient param LIB_NONSMBD POPT_SAMBA3 LIBNTLMSSP''',
+ deps='''talloc tdb_compat tevent cap wbclient param smbd_shim POPT_SAMBA3 LIBNTLMSSP''',
vars=locals())
bld.SAMBA3_BINARY('dbwrap_tool',
source=DBWRAP_TOOL_SRC,
- deps='''talloc tdb tevent cap param LIB_NONSMBD LIBSMB_ERR''',
+ deps='''talloc tdb_compat tevent cap param smbd_shim LIBSMB_ERR''',
vars=locals())
bld.SAMBA3_BINARY('dbwrap_torture',
source=DBWRAP_TORTURE_SRC,
- deps='''talloc tdb tevent cap param LIB_NONSMBD LIBSMB_ERR
+ deps='''talloc tdb_compat tevent cap param smbd_shim LIBSMB_ERR
POPT_SAMBA3''',
vars=locals())
bld.SAMBA3_BINARY('split_tokens',
source=SPLIT_TOKENS_SRC,
- deps='''talloc tdb tevent cap wbclient param LIB_NONSMBD POPT_SAMBA3
+ deps='''talloc tdb_compat tevent cap wbclient param smbd_shim POPT_SAMBA3
LIBNTLMSSP''',
vars=locals())
bld.SAMBA3_BINARY('vlp',
source=VLP_SRC,
- deps='''talloc tdb PARAM_UTIL UTIL_TDB''',
+ deps='''talloc tdb_compat PARAM_UTIL UTIL_TDB samba3core param''',
vars=locals())
swat_dir = os.path.join(bld.curdir, '../swat')
@@ -1314,32 +1391,20 @@ bld.INSTALL_FILES('${SWATDIR}', swat_files, base_name='../swat')
if not bld.env.toplevel_build:
bld.SAMBA3_SUBSYSTEM('POPT_SAMBA', source='', deps='POPT_SAMBA3')
- bld.SAMBA3_SUBSYSTEM('tdb-wrap', source='', deps='tdb-wrap3')
- bld.SAMBA3_SUBSYSTEM('errors', source='', deps='errors3')
- bld.SAMBA3_SUBSYSTEM('samba-util', source='', deps='DYNCONFIG')
- bld.SAMBA3_SUBSYSTEM('CHARSET', source='', deps='CHARSET3')
bld.SAMBA3_SUBSYSTEM('ldb', source='', deps='ldb3')
bld.SAMBA3_SUBSYSTEM('dcerpc', '', deps='UTIL_TEVENT')
bld.SAMBA3_SUBSYSTEM('cli-ldap', '', deps='UTIL_TEVENT')
-else:
-
- # point the s3 rules at in-tree heimdal
- bld.SAMBA3_SUBSYSTEM('gssapi_krb5',
- source='',
- deps='gssapi krb5')
- bld.SAMBA3_SUBSYSTEM('k5crypto',
- source='',
- deps='krb5')
-
-
-
+ bld.SAMBA3_SUBSYSTEM('LOADPARM_CTX', '')
########################## INCLUDES #################################
bld.RECURSE('../lib/util/charset')
bld.RECURSE('../auth')
+bld.RECURSE('../auth/kerberos')
bld.RECURSE('../lib/addns')
bld.RECURSE('../lib/async_req')
+bld.RECURSE('../lib/ccan')
+bld.RECURSE('../lib/socket')
bld.RECURSE('../libcli/auth')
bld.RECURSE('../libcli/drsuapi')
bld.RECURSE('../libcli/ldap')
@@ -1349,6 +1414,7 @@ bld.RECURSE('../libcli/netlogon')
bld.RECURSE('../libcli/samsync')
bld.RECURSE('../libcli/security')
bld.RECURSE('../libcli/smb')
+bld.RECURSE('../libcli/util')
bld.RECURSE('../libcli/smbreadline')
bld.RECURSE('../libcli/nbt')
bld.RECURSE('../libcli/registry')
@@ -1361,7 +1427,7 @@ bld.RECURSE('../lib/smbconf')
bld.RECURSE('../lib/socket_wrapper')
bld.RECURSE('../lib/uid_wrapper')
bld.RECURSE('../lib/talloc')
-bld.RECURSE('../lib/tdb')
+bld.RECURSE('../lib/tdb_compat')
bld.RECURSE('../lib/util')
bld.RECURSE('../lib/tevent')
bld.RECURSE('../lib/tsocket')
@@ -1371,6 +1437,7 @@ bld.RECURSE('../nsswitch')
bld.RECURSE('../nsswitch/libwbclient')
bld.RECURSE('auth')
bld.RECURSE('libgpo/gpext')
+bld.RECURSE('lib/pthreadpool')
bld.RECURSE('librpc')
bld.RECURSE('librpc/idl')
bld.RECURSE('modules')