summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Wright <amw@Sun.COM>2010-05-27 15:26:41 -0700
committerAlan Wright <amw@Sun.COM>2010-05-27 15:26:41 -0700
commit148c5f43199ca0b43fc8e3b643aab11cd66ea327 (patch)
tree60f84788d354f1cb0dfccfa111a87171e5d9a5f5
parent9cd928fe5e3ea4e05f64cfb380beb54b2623e7dc (diff)
downloadillumos-gate-148c5f43199ca0b43fc8e3b643aab11cd66ea327.tar.gz
6935899 Add AD connectivity diagnostics
PSARC 2010/120 SMB/CIFS Statistics 6893904 The statistics of the CIFS server must be improved 6947373 only calculate pathname for query fileinfo levels which require it PSARC 2010/097 idmap: default unresolvable SID mapping to true 6864900 Enable unresolvable SID mapping by default 6923504 Need detailed tracing for idmap mapping requests 6928157 Need detailed tracing for idmap discovery operations 6949333 Panic in smb_pre_open_print_file 6795069 Commonize error codes between CIFS client and server 6941787 Spurious message "DC discovery failed" upon refresh 6941349 Update shortname support to remove name83 format 6941382 smbsrv should use smb_node_getpath functions instead of vnodetopath 6939494 smb_authenticate() doesn't check for smb_user_login() return 6944226 Need to keep the list of shares in smbsrv 6942697 open file lock count is incorrect on MMC 6941227 On addition of SMB local group, add corresponding POSIX group 6948109 Add ability to manage shares in ZFS group via Windows MMC 6948143 Add ability to set additional properties on Autohome shares 6903260 two "ID type" enumerations 6946940 smb_sid_tostr/fromstr input arguments should be const 6949088 CIFS continuously refresh when one of the interfaces won't properly initialize 6946075 Filebench IO errors when signing property enabled on Solaris CIFS Server 6951169 idmap reports "no such file or directory" when looking up krb5.conf, even when not a domain member 6813063 degraded operation message should occur only when appropriate 6644872 idmapd is too whiny in workgroup mode 6813268 idmapd bangs on DNS server when in workgroup mode 6883800 Trusted domain members won't map to a UID when the trust is one-way 6891704 Cross-forest trust discovery may not work in multi-domain forest 6933937 idmapd doesn't map out trusted domains properly when joined to a domain that isn't the forest root. 6923908 smbadm join CLI doesn't always report Kerberos change password failure 6926930 smbsrv libraries should use krb5_get_error_messsage() 6943528 Unable to update Windows 2008 dynamic dns record with cifs hostname > 15 characters. 6953259 Can't map remote-forest users when IDMU is enabled 6953688 Should allow only one standalone DFS namespace in a cluster system 6952292 smb_find_ads_server() deferences string one too many times 6950070 Share is not getting correct access based on host access control list 6950820 Host-based access control list does not work properly with ipv6_enable=true --HG-- rename : usr/src/lib/libidmap/common/idmap_priv.h => usr/src/cmd/idmap/idmap/namemaps.h rename : usr/src/lib/smbsrv/libsmb/common/smb_nicmon.c => usr/src/cmd/smbsrv/smbd/smbd_nicmon.c rename : usr/src/lib/smbsrv/libmlsvc/common/eventlog_syslog.c => usr/src/lib/smbsrv/libmlsvc/common/eventlog_log.c rename : usr/src/common/smbsrv/smb_status_xlat.c => usr/src/lib/smbsrv/libsmb/common/smb_status_tbl.c rename : usr/src/uts/common/smbsrv/doserror.h => usr/src/uts/common/smb/doserror.h rename : usr/src/uts/common/smbsrv/lmerr.h => usr/src/uts/common/smb/lmerr.h rename : usr/src/uts/common/smbsrv/nterror.h => usr/src/uts/common/smb/nterror.h rename : usr/src/uts/common/smbsrv/ntstatus.h => usr/src/uts/common/smb/ntstatus.h
-rw-r--r--exception_lists/packaging1
-rw-r--r--exception_lists/packaging.cpiotranslate11
-rw-r--r--usr/src/cmd/idmap/idmap/idmap.c31
-rw-r--r--usr/src/cmd/idmap/idmapd/Makefile15
-rw-r--r--usr/src/cmd/idmap/idmapd/adutils.c73
-rw-r--r--usr/src/cmd/idmap/idmapd/adutils.h28
-rw-r--r--usr/src/cmd/idmap/idmapd/dbutils.c589
-rw-r--r--usr/src/cmd/idmap/idmapd/idmap.xml19
-rw-r--r--usr/src/cmd/idmap/idmapd/idmap_config.c769
-rw-r--r--usr/src/cmd/idmap/idmapd/idmap_config.h7
-rw-r--r--usr/src/cmd/idmap/idmapd/idmap_lsa.c237
-rw-r--r--usr/src/cmd/idmap/idmapd/idmap_lsa.h53
-rw-r--r--usr/src/cmd/idmap/idmapd/idmapd.c206
-rw-r--r--usr/src/cmd/idmap/idmapd/idmapd.h103
-rw-r--r--usr/src/cmd/idmap/idmapd/init.c38
-rw-r--r--usr/src/cmd/idmap/idmapd/nldaputils.c29
-rw-r--r--usr/src/cmd/idmap/idmapd/server.c165
-rw-r--r--usr/src/cmd/idmap/idmapd/wksids.c7
-rw-r--r--usr/src/cmd/mdb/common/modules/smbsrv/smbsrv.c386
-rw-r--r--usr/src/cmd/smbsrv/dtrace/cifs.d76
-rw-r--r--usr/src/cmd/smbsrv/dtrace/msrpc.d8
-rw-r--r--[-rwxr-xr-x]usr/src/cmd/smbsrv/dtrace/stype.d64
-rw-r--r--usr/src/cmd/smbsrv/smbadm/smbadm.c19
-rw-r--r--usr/src/cmd/smbsrv/smbd/Makefile6
-rw-r--r--usr/src/cmd/smbsrv/smbd/server.xml5
-rw-r--r--usr/src/cmd/smbsrv/smbd/smbd.h10
-rw-r--r--usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c59
-rw-r--r--usr/src/cmd/smbsrv/smbd/smbd_join.c5
-rw-r--r--usr/src/cmd/smbsrv/smbd/smbd_main.c25
-rw-r--r--usr/src/cmd/smbsrv/smbd/smbd_nicmon.c323
-rw-r--r--usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c181
-rw-r--r--usr/src/cmd/smbsrv/smbd/smbd_vss.c5
-rw-r--r--usr/src/cmd/smbsrv/smbstat/Makefile7
-rw-r--r--usr/src/cmd/smbsrv/smbstat/smbstat.c1298
-rw-r--r--usr/src/common/smbsrv/smb_match.c62
-rw-r--r--usr/src/common/smbsrv/smb_sid.c13
-rw-r--r--usr/src/common/smbsrv/smb_status_xlat.c597
-rw-r--r--usr/src/common/smbsrv/smb_xdr.c68
-rw-r--r--usr/src/lib/libadutils/common/addisc.c280
-rw-r--r--usr/src/lib/libadutils/common/addisc.h3
-rw-r--r--usr/src/lib/libadutils/common/adutils.c12
-rw-r--r--usr/src/lib/libadutils/common/adutils_impl.h8
-rw-r--r--usr/src/lib/libadutils/common/libadutils.h16
-rw-r--r--usr/src/lib/libadutils/common/mapfile-vers1
-rw-r--r--usr/src/lib/libidmap/Makefile.com2
-rw-r--r--usr/src/lib/libidmap/common/idmap_api.c293
-rw-r--r--usr/src/lib/libidmap/common/idmap_priv.h23
-rw-r--r--usr/src/lib/libidmap/common/mapfile-vers27
-rw-r--r--usr/src/lib/libshare/Makefile.com8
-rw-r--r--usr/src/lib/libshare/common/libshare.c49
-rw-r--r--usr/src/lib/libshare/common/libshare.h5
-rw-r--r--usr/src/lib/libshare/common/libshare_zfs.c138
-rw-r--r--usr/src/lib/libshare/common/libsharecore.c10
-rw-r--r--usr/src/lib/libshare/common/mapfile-vers4
-rw-r--r--usr/src/lib/libshare/smb/libshare_smb.c36
-rw-r--r--usr/src/lib/libshare/smb/smb_share_doorclnt.c4
-rw-r--r--usr/src/lib/libsmbfs/smb/netshareenum.c5
-rw-r--r--usr/src/lib/libsmbfs/smb/ssnsetup.c9
-rw-r--r--usr/src/lib/smbsrv/libmlrpc/common/ndr_ops.c5
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/Makefile.com6
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/dfs.c43
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/dssetup_svc.c5
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/eventlog_log.c (renamed from usr/src/lib/smbsrv/libmlsvc/common/eventlog_syslog.c)35
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/eventlog_svc.c6
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/libmlsvc.h7
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/lsalib.c13
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/lsar_clnt.c20
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/lsar_svc.c12
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/mlsvc_client.c22
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/mlsvc_domain.c5
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/mlsvc_netr.c6
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/msgsvc_svc.c5
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/netdfs.c23
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/netr_auth.c5
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/netr_logon.c5
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/samlib.c6
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/samr_clnt.c5
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/samr_svc.c11
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/smb_autohome.c18
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/smb_quota.c7
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/smb_share.c272
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c5
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/srvsvc_clnt.c5
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/srvsvc_sd.c8
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/srvsvc_svc.c54
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/svcctl_scm.c9
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/svcctl_svc.c9
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/winreg_svc.c65
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/wkssvc_svc.c6
-rw-r--r--usr/src/lib/smbsrv/libsmb/Makefile14
-rw-r--r--usr/src/lib/smbsrv/libsmb/Makefile.com6
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/libsmb.h54
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/mapfile-vers14
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_cfg.c45
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_door_encdec.c35
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_doorclnt.c40
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_info.c4
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_kmod.c47
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_lgrp.c229
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_nicmon.c254
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_sd.c5
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_status_gen.awk61
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_status_tbl.c81
-rw-r--r--usr/src/lib/smbsrv/libsmb/common/smb_util.c271
-rw-r--r--usr/src/lib/smbsrv/libsmbns/common/smbns_ads.c155
-rw-r--r--usr/src/lib/smbsrv/libsmbns/common/smbns_dyndns.c16
-rw-r--r--usr/src/lib/smbsrv/libsmbns/common/smbns_krb.c38
-rw-r--r--usr/src/lib/smbsrv/libsmbns/common/smbns_krb.h80
-rw-r--r--usr/src/lib/smbsrv/libsmbns/common/smbns_ksetpwd.c509
-rw-r--r--usr/src/lib/smbsrv/libsmbrdr/common/smbrdr.h8
-rw-r--r--usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_lib.c57
-rw-r--r--usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_logon.c61
-rw-r--r--usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netbios.c7
-rw-r--r--usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netuse.c47
-rw-r--r--usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_read_andx.c19
-rw-r--r--usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_rpcpipe.c44
-rw-r--r--usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_session.c63
-rw-r--r--usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_transact.c19
-rw-r--r--usr/src/uts/Makefile4
-rw-r--r--usr/src/uts/common/Makefile.files4
-rw-r--r--usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.c10
-rw-r--r--usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.h4
-rw-r--r--usr/src/uts/common/fs/smbclnt/netsmb/smb_subr.h5
-rw-r--r--usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c425
-rw-r--r--usr/src/uts/common/fs/smbclnt/smbfs/smbfs_xattr.c5
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_alloc.c15
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_common_open.c17
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_common_transact.c31
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_delete.c43
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_dispatch.c855
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_find.c111
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_fsops.c50
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_init.c32
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_kshare.c1197
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_kutil.c574
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_lock.c25
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_locking_andx.c12
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_mangle_name.c517
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_negotiate.c315
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_node.c2
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_nt_transact_notify_change.c19
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_nt_transact_quota.c8
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_nt_transact_security.c5
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_odir.c62
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_ofile.c16
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_opipe.c5
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_oplock.c8
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_pathname.c9
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_print.c15
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_query_fileinfo.c176
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_server.c550
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_session.c48
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_session_setup_andx.c488
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_signing.c56
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_tree.c481
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_tree_connect.c64
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_unlock_byte_range.c6
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_user.c131
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_vfs.c156
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_vss.c150
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_write.c6
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_write_raw.c4
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_xlate.c248
-rw-r--r--usr/src/uts/common/idmap/Makefile5
-rw-r--r--usr/src/uts/common/netsmb/smb.h695
-rw-r--r--usr/src/uts/common/rpcsvc/idmap_prot.x131
-rw-r--r--usr/src/uts/common/smb/Makefile51
-rw-r--r--usr/src/uts/common/smb/doserror.h149
-rw-r--r--usr/src/uts/common/smb/lmerr.h (renamed from usr/src/uts/common/smbsrv/lmerr.h)197
-rw-r--r--usr/src/uts/common/smb/nterror.h1644
-rw-r--r--usr/src/uts/common/smb/ntstatus.h1054
-rw-r--r--usr/src/uts/common/smbsrv/Makefile8
-rw-r--r--usr/src/uts/common/smbsrv/doserror.h141
-rw-r--r--usr/src/uts/common/smbsrv/nterror.h942
-rw-r--r--usr/src/uts/common/smbsrv/ntstatus.h707
-rw-r--r--usr/src/uts/common/smbsrv/smb.h12
-rw-r--r--usr/src/uts/common/smbsrv/smb_door.h40
-rw-r--r--usr/src/uts/common/smbsrv/smb_ioctl.h9
-rw-r--r--usr/src/uts/common/smbsrv/smb_kproto.h116
-rw-r--r--usr/src/uts/common/smbsrv/smb_kstat.h51
-rw-r--r--usr/src/uts/common/smbsrv/smb_ktypes.h386
-rw-r--r--usr/src/uts/common/smbsrv/smb_share.h109
-rw-r--r--usr/src/uts/common/smbsrv/smb_sid.h7
-rw-r--r--usr/src/uts/common/smbsrv/smb_xdr.h25
-rw-r--r--usr/src/uts/common/smbsrv/smbinfo.h11
-rw-r--r--usr/src/uts/common/smbsrv/string.h8
186 files changed, 13723 insertions, 9256 deletions
diff --git a/exception_lists/packaging b/exception_lists/packaging
index c980d49281..876a5be0e3 100644
--- a/exception_lists/packaging
+++ b/exception_lists/packaging
@@ -768,6 +768,7 @@ usr/include/sys/srn.h
#
# Private/Internal header files of smbsrv. Do not ship.
#
+usr/include/smb
usr/include/smbsrv
#
# Private/Internal dtrace scripts of smbsrv. Do not ship.
diff --git a/exception_lists/packaging.cpiotranslate b/exception_lists/packaging.cpiotranslate
index 6750c31102..5d34323261 100644
--- a/exception_lists/packaging.cpiotranslate
+++ b/exception_lists/packaging.cpiotranslate
@@ -20,8 +20,7 @@
#
#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
#
#
@@ -294,17 +293,19 @@ usr/include/inet/nca/ncalogd.h
usr/include/inet/nca/ncandd.h
usr/include/netsmb/smbfs_acl.h
usr/include/netsmb/smbfs_api.h
+usr/include/smb/doserror.h
+usr/include/smb/lmerr.h
+usr/include/smb/nterror.h
+usr/include/smb/ntstatus.h
usr/include/smbsrv/alloc.h
usr/include/smbsrv/cp_unicode.h
usr/include/smbsrv/cp_usascii.h
-usr/include/smbsrv/doserror.h
usr/include/smbsrv/hash_table.h
usr/include/smbsrv/libmlrpc.h
usr/include/smbsrv/libmlsvc.h
usr/include/smbsrv/libsmb.h
usr/include/smbsrv/libsmbns.h
usr/include/smbsrv/libsmbrdr.h
-usr/include/smbsrv/lmerr.h
usr/include/smbsrv/mac_cifs.h
usr/include/smbsrv/mailslot.h
usr/include/smbsrv/mbuf.h
@@ -329,10 +330,8 @@ usr/include/smbsrv/netbios.h
usr/include/smbsrv/netrauth.h
usr/include/smbsrv/nmpipes.h
usr/include/smbsrv/ntaccess.h
-usr/include/smbsrv/nterror.h
usr/include/smbsrv/ntifs.h
usr/include/smbsrv/ntlocale.h
-usr/include/smbsrv/ntstatus.h
usr/include/smbsrv/smb_door.h
usr/include/smbsrv/smb_dfs.h
usr/include/smbsrv/smb_fsops.h
diff --git a/usr/src/cmd/idmap/idmap/idmap.c b/usr/src/cmd/idmap/idmap/idmap.c
index 57c6b3bfe5..1c05e3d76a 100644
--- a/usr/src/cmd/idmap/idmap/idmap.c
+++ b/usr/src/cmd/idmap/idmap/idmap.c
@@ -117,6 +117,7 @@ id_code_t identity2code[] = {
#define n_FLAG 'n'
#define c_FLAG 'c'
#define v_FLAG 'v'
+#define V_FLAG 'V'
#define j_FLAG 'j'
@@ -256,7 +257,7 @@ static int do_get_namemap(flag_t *f, int argc, char **argv, cmd_pos_t *pos);
static cmd_ops_t commands[] = {
{
"show",
- "c(create)v(verbose)",
+ "c(create)v(verbose)V(trace)",
do_show_mapping
},
{
@@ -1462,9 +1463,6 @@ print_how(idmap_how *how)
}
-
-
-
static
void
print_info(idmap_info *info)
@@ -1489,6 +1487,11 @@ print_info(idmap_info *info)
}
print_how(&info->how);
}
+
+ if (info->trace != NULL) {
+ (void) printf(gettext("Trace:\n"));
+ idmap_trace_print(stdout, "\t", info->trace);
+ }
}
@@ -1571,6 +1574,11 @@ print_error_info(idmap_info *info)
CHECK_NULL(how->idmap_how_u.idmu.value));
break;
}
+
+ if (info->trace != NULL) {
+ (void) printf(gettext("Trace:\n"));
+ idmap_trace_print(stderr, "\t", info->trace);
+ }
}
@@ -1627,7 +1635,7 @@ do_dump(flag_t *f, int argc, char **argv, cmd_pos_t *pos)
if (stat >= 0) {
(void) print_mapping(ph, nm);
- (void) print_how(&info.how);
+ print_how(&info.how);
idmap_info_free(&info);
}
name_mapping_fini(nm);
@@ -2952,8 +2960,13 @@ do_show_mapping(flag_t *f, int argc, char **argv, cmd_pos_t *pos)
return (-1);
}
- flag = f[c_FLAG] != NULL ? 0 : IDMAP_REQ_FLG_NO_NEW_ID_ALLOC;
- flag |= f[v_FLAG] == NULL ? 0 : IDMAP_REQ_FLG_MAPPING_INFO;
+ flag = 0;
+ if (f[c_FLAG] == NULL)
+ flag |= IDMAP_REQ_FLG_NO_NEW_ID_ALLOC;
+ if (f[v_FLAG] != NULL)
+ flag |= IDMAP_REQ_FLG_MAPPING_INFO;
+ if (f[V_FLAG] != NULL)
+ flag |= IDMAP_REQ_FLG_TRACE;
if (init_command())
return (-1);
@@ -3182,8 +3195,9 @@ errormsg:
print_error(pos, gettext("Error:\t%s\n"),
idmap_stat2string(handle, map_stat));
print_error_info(&info);
- } else
+ } else {
print_info(&info);
+ }
idmap_info_free(&info);
cleanup:
@@ -3546,7 +3560,6 @@ static
void
idmap_cli_logger(int pri, const char *format, ...)
{
- NOTE(ARGUNUSED(pri))
va_list args;
if (pri == LOG_DEBUG)
diff --git a/usr/src/cmd/idmap/idmapd/Makefile b/usr/src/cmd/idmap/idmapd/Makefile
index 04bee240ae..e940895ede 100644
--- a/usr/src/cmd/idmap/idmapd/Makefile
+++ b/usr/src/cmd/idmap/idmapd/Makefile
@@ -19,8 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
PROG = idmapd
@@ -35,6 +34,7 @@ SERVEROBJS = \
idmap_config.o \
idmapd.o \
init.o \
+ idmap_lsa.o \
nldaputils.o \
rpc_svc.o \
server.o \
@@ -71,7 +71,8 @@ $(ROOTMANIFEST) := FILEMODE= 444
INCS += -I. -I../../../lib/libidmap/common\
-I../../../lib/libsldap/common\
- -I../../../lib/libadutils/common
+ -I../../../lib/libadutils/common \
+ -I../../../lib/smbsrv/libsmb/common
$(OBJS) := CPPFLAGS += $(INCS) -D_REENTRANT
$(POFILE) := CPPFLAGS += $(INCS)
@@ -86,12 +87,16 @@ LDLIBS += -lsecdb \
-lldap \
-luuid \
-ladutils \
- -lumem
+ -lumem \
+ -lnvpair \
+ -L $(ROOT)/usr/lib/smbsrv \
+ -lsmb
rpc_svc.o := CFLAGS += $(RPC_MSGOUT_OPT)
$(PROG) := MAPFILES = $(MAPFILE.INT) $(MAPFILE.NGB)
-$(PROG) := LDFLAGS += $(MAPFILES:%=-M%)
+$(PROG) := LDFLAGS += $(MAPFILES:%=-M%) \
+ -R /usr/lib/smbsrv
DIRMODE = 0755
FILEMODE = 0555
diff --git a/usr/src/cmd/idmap/idmapd/adutils.c b/usr/src/cmd/idmap/idmapd/adutils.c
index cbc447e0c9..254ccc214d 100644
--- a/usr/src/cmd/idmap/idmapd/adutils.c
+++ b/usr/src/cmd/idmap/idmapd/adutils.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -78,13 +77,13 @@ typedef struct idmap_q {
*/
char *ecanonname; /* expected canon name */
char *edomain; /* expected domain name */
- int eunixtype; /* expected unix type */
+ idmap_id_type esidtype; /* expected SID type */
/* results */
char **canonname; /* actual canon name */
char **domain; /* name of domain of object */
char **sid; /* stringified SID */
rid_t *rid; /* RID */
- int *sid_type; /* user or group SID? */
+ idmap_id_type *sid_type; /* user or group SID? */
char **unixname; /* unixname for name mapping */
char **dn; /* DN of entry */
char **attr; /* Attr for name mapping */
@@ -352,7 +351,7 @@ idmap_bv_objclass2sidtype(BerValue **bvalues, int *sid_type)
{
BerValue **cbval;
- *sid_type = _IDMAP_T_OTHER;
+ *sid_type = IDMAP_SID;
if (bvalues == NULL)
return (0);
@@ -363,14 +362,14 @@ idmap_bv_objclass2sidtype(BerValue **bvalues, int *sid_type)
*/
for (cbval = bvalues; *cbval != NULL; cbval++) {
if (BVAL_CASEEQ(cbval, "group")) {
- *sid_type = _IDMAP_T_GROUP;
+ *sid_type = IDMAP_GSID;
break;
} else if (BVAL_CASEEQ(cbval, "user")) {
- *sid_type = _IDMAP_T_USER;
+ *sid_type = IDMAP_USID;
break;
}
/*
- * "else if (*sid_type = _IDMAP_T_USER)" then this is a
+ * "else if (*sid_type = IDMAP_USID)" then this is a
* new sub-class of user -- what to do with it??
*/
}
@@ -426,9 +425,9 @@ idmap_extract_object(idmap_query_state_t *state, idmap_q_t *q,
if (state->directory_based_mapping == DIRECTORY_MAPPING_IDMU &&
q->pid != NULL) {
- if (sid_type == _IDMAP_T_USER)
+ if (sid_type == IDMAP_USID)
attr = UIDNUMBER;
- else if (sid_type == _IDMAP_T_GROUP)
+ else if (sid_type == IDMAP_GSID)
attr = GIDNUMBER;
if (attr != NULL) {
bvalues = ldap_get_values_len(ld, res, attr);
@@ -451,24 +450,20 @@ idmap_extract_object(idmap_query_state_t *state, idmap_q_t *q,
* AD attribute name that will have the unixname, and retrieve
* its value.
*/
- int unix_type;
+ idmap_id_type esidtype;
/*
- * Determine the target UNIX type.
+ * Determine the target type.
*
* If the caller specified one, use that. Otherwise, give the
* same type that as we found for the Windows user.
*/
- unix_type = q->eunixtype;
- if (unix_type == _IDMAP_T_UNDEF) {
- if (sid_type == _IDMAP_T_USER)
- unix_type = _IDMAP_T_USER;
- else if (sid_type == _IDMAP_T_GROUP)
- unix_type = _IDMAP_T_GROUP;
- }
+ esidtype = q->esidtype;
+ if (esidtype == IDMAP_SID)
+ esidtype = sid_type;
- if (unix_type == _IDMAP_T_USER)
+ if (esidtype == IDMAP_USID)
attr = state->ad_unixuser_attr;
- else if (unix_type == _IDMAP_T_GROUP)
+ else if (esidtype == IDMAP_GSID)
attr = state->ad_unixgroup_attr;
if (attr != NULL) {
@@ -591,10 +586,10 @@ idmap_lookup_batch_end(idmap_query_state_t **state)
static
idmap_retcode
idmap_batch_add1(idmap_query_state_t *state, const char *filter,
- char *ecanonname, char *edomain, int eunixtype,
+ char *ecanonname, char *edomain, idmap_id_type esidtype,
char **dn, char **attr, char **value,
char **canonname, char **dname,
- char **sid, rid_t *rid, int *sid_type, char **unixname,
+ char **sid, rid_t *rid, idmap_id_type *sid_type, char **unixname,
posix_id_t *pid,
idmap_retcode *rc)
{
@@ -614,7 +609,7 @@ idmap_batch_add1(idmap_query_state_t *state, const char *filter,
*/
q->ecanonname = ecanonname;
q->edomain = edomain;
- q->eunixtype = eunixtype;
+ q->esidtype = esidtype;
/* Remember where to put the results */
q->canonname = canonname;
@@ -637,18 +632,18 @@ idmap_batch_add1(idmap_query_state_t *state, const char *filter,
if (unixname != NULL) {
/* Add unixuser/unixgroup attribute names to the attrs list */
- if (eunixtype != _IDMAP_T_GROUP &&
+ if (esidtype != IDMAP_GSID &&
state->ad_unixuser_attr != NULL)
attrs[i++] = (char *)state->ad_unixuser_attr;
- if (eunixtype != _IDMAP_T_USER &&
+ if (esidtype != IDMAP_USID &&
state->ad_unixgroup_attr != NULL)
attrs[i++] = (char *)state->ad_unixgroup_attr;
}
if (pid != NULL) {
- if (eunixtype != _IDMAP_T_GROUP)
+ if (esidtype != IDMAP_GSID)
attrs[i++] = UIDNUMBER;
- if (eunixtype != _IDMAP_T_USER)
+ if (esidtype != IDMAP_USID)
attrs[i++] = GIDNUMBER;
}
@@ -667,7 +662,7 @@ idmap_batch_add1(idmap_query_state_t *state, const char *filter,
*/
*rc = IDMAP_ERR_RETRIABLE_NET_ERR;
if (sid_type != NULL)
- *sid_type = _IDMAP_T_OTHER;
+ *sid_type = IDMAP_SID;
if (sid != NULL)
*sid = NULL;
if (dname != NULL)
@@ -698,10 +693,10 @@ idmap_batch_add1(idmap_query_state_t *state, const char *filter,
idmap_retcode
idmap_name2sid_batch_add1(idmap_query_state_t *state,
- const char *name, const char *dname, int eunixtype,
+ const char *name, const char *dname, idmap_id_type esidtype,
char **dn, char **attr, char **value,
char **canonname, char **sid, rid_t *rid,
- int *sid_type, char **unixname,
+ idmap_id_type *sid_type, char **unixname,
posix_id_t *pid, idmap_retcode *rc)
{
idmap_retcode retcode;
@@ -761,7 +756,7 @@ idmap_name2sid_batch_add1(idmap_query_state_t *state,
}
retcode = idmap_batch_add1(state, filter, ecanonname, edomain,
- eunixtype, dn, attr, value, canonname, NULL, sid, rid, sid_type,
+ esidtype, dn, attr, value, canonname, NULL, sid, rid, sid_type,
unixname, pid, rc);
free(filter);
@@ -771,9 +766,9 @@ idmap_name2sid_batch_add1(idmap_query_state_t *state,
idmap_retcode
idmap_sid2name_batch_add1(idmap_query_state_t *state,
- const char *sid, const rid_t *rid, int eunixtype,
+ const char *sid, const rid_t *rid, idmap_id_type esidtype,
char **dn, char **attr, char **value,
- char **name, char **dname, int *sid_type,
+ char **name, char **dname, idmap_id_type *sid_type,
char **unixname, posix_id_t *pid, idmap_retcode *rc)
{
idmap_retcode retcode;
@@ -801,7 +796,7 @@ idmap_sid2name_batch_add1(idmap_query_state_t *state,
if (filter == NULL)
return (IDMAP_ERR_MEMORY);
- retcode = idmap_batch_add1(state, filter, NULL, NULL, eunixtype,
+ retcode = idmap_batch_add1(state, filter, NULL, NULL, esidtype,
dn, attr, value, name, dname, NULL, NULL, sid_type, unixname,
pid, rc);
@@ -815,7 +810,7 @@ idmap_unixname2sid_batch_add1(idmap_query_state_t *state,
const char *unixname, int is_user, int is_wuser,
char **dn, char **attr, char **value,
char **sid, rid_t *rid, char **name,
- char **dname, int *sid_type, idmap_retcode *rc)
+ char **dname, idmap_id_type *sid_type, idmap_retcode *rc)
{
idmap_retcode retcode;
char *filter, *s_unixname;
@@ -841,7 +836,7 @@ idmap_unixname2sid_batch_add1(idmap_query_state_t *state,
}
retcode = idmap_batch_add1(state, filter, NULL, NULL,
- _IDMAP_T_UNDEF, dn, NULL, NULL, name, dname, sid, rid, sid_type,
+ IDMAP_POSIXID, dn, NULL, NULL, name, dname, sid, rid, sid_type,
NULL, NULL, rc);
if (retcode == IDMAP_SUCCESS && attr != NULL) {
@@ -864,7 +859,7 @@ idmap_pid2sid_batch_add1(idmap_query_state_t *state,
posix_id_t pid, int is_user,
char **dn, char **attr, char **value,
char **sid, rid_t *rid, char **name,
- char **dname, int *sid_type, idmap_retcode *rc)
+ char **dname, idmap_id_type *sid_type, idmap_retcode *rc)
{
idmap_retcode retcode;
char *filter;
@@ -882,7 +877,7 @@ idmap_pid2sid_batch_add1(idmap_query_state_t *state,
return (IDMAP_ERR_MEMORY);
retcode = idmap_batch_add1(state, filter, NULL, NULL,
- _IDMAP_T_UNDEF, dn, NULL, NULL, name, dname, sid, rid, sid_type,
+ IDMAP_POSIXID, dn, NULL, NULL, name, dname, sid, rid, sid_type,
NULL, NULL, rc);
if (retcode == IDMAP_SUCCESS && attr != NULL) {
diff --git a/usr/src/cmd/idmap/idmapd/adutils.h b/usr/src/cmd/idmap/idmapd/adutils.h
index 88807f01d8..b5d45b4a4d 100644
--- a/usr/src/cmd/idmap/idmapd/adutils.h
+++ b/usr/src/cmd/idmap/idmapd/adutils.h
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _ADUTILS_H
@@ -56,16 +55,6 @@ extern "C" {
* idmapd interfaces stolen? from other idmapd code?
*/
-/*
- * Eventually these should be an enum here, but instead we share a
- * namespace with other things in idmapd.
- */
-#define _IDMAP_T_OTHER 0
-#define _IDMAP_T_UNDEF -1
-#define _IDMAP_T_USER -1004
-#define _IDMAP_T_GROUP -1005
-#define _IDMAP_T_DOMAIN -1006
-
typedef uint32_t rid_t;
typedef uid_t posix_id_t;
@@ -118,9 +107,10 @@ void idmap_lookup_release_batch(idmap_query_state_t **state);
* The caller must free() *sid.
*/
idmap_retcode idmap_name2sid_batch_add1(idmap_query_state_t *state,
- const char *name, const char *dname, int eunixtype,
+ const char *name, const char *dname, idmap_id_type esidtype,
char **dn, char **attr, char **value, char **canonname,
- char **sid, rid_t *rid, int *sid_type, char **unixname,
+ char **sid, rid_t *rid, idmap_id_type *sid_type,
+ char **unixname,
posix_id_t *pid, idmap_retcode *rc);
/*
* Add a SID->name lookup
@@ -137,9 +127,9 @@ idmap_retcode idmap_name2sid_batch_add1(idmap_query_state_t *state,
* The caller must free() *name and *dname (if present).
*/
idmap_retcode idmap_sid2name_batch_add1(idmap_query_state_t *state,
- const char *sid, const rid_t *rid, int eunixtype,
+ const char *sid, const rid_t *rid, idmap_id_type esidtype,
char **dn, char **attr, char **value, char **name,
- char **dname, int *sid_type, char **unixname,
+ char **dname, idmap_id_type *sid_type, char **unixname,
posix_id_t *pid, idmap_retcode *rc);
/*
@@ -148,7 +138,8 @@ idmap_retcode idmap_sid2name_batch_add1(idmap_query_state_t *state,
idmap_retcode idmap_unixname2sid_batch_add1(idmap_query_state_t *state,
const char *unixname, int is_user, int is_wuser,
char **dn, char **attr, char **value, char **sid, rid_t *rid,
- char **name, char **dname, int *sid_type, idmap_retcode *rc);
+ char **name, char **dname, idmap_id_type *sid_type,
+ idmap_retcode *rc);
/*
* Add a PID->SID lookup
@@ -156,7 +147,8 @@ idmap_retcode idmap_unixname2sid_batch_add1(idmap_query_state_t *state,
idmap_retcode idmap_pid2sid_batch_add1(idmap_query_state_t *state,
posix_id_t pid, int is_user,
char **dn, char **attr, char **value, char **sid, rid_t *rid,
- char **name, char **dname, int *sid_type, idmap_retcode *rc);
+ char **name, char **dname, idmap_id_type *sid_type,
+ idmap_retcode *rc);
/*
* Set unixname attribute names for the batch for AD-based name mapping
diff --git a/usr/src/cmd/idmap/idmapd/dbutils.c b/usr/src/cmd/idmap/idmapd/dbutils.c
index 3043c507db..d697ab154a 100644
--- a/usr/src/cmd/idmap/idmapd/dbutils.c
+++ b/usr/src/cmd/idmap/idmapd/dbutils.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -42,6 +41,7 @@
#include <assert.h>
#include <sys/u8_textprep.h>
#include <alloca.h>
+#include <note.h>
#include "idmapd.h"
#include "adutils.h"
@@ -49,6 +49,7 @@
#include "idmap_priv.h"
#include "schema.h"
#include "nldaputils.h"
+#include "idmap_lsa.h"
#include "miscutils.h"
@@ -56,7 +57,7 @@ static idmap_retcode sql_compile_n_step_once(sqlite *, char *,
sqlite_vm **, int *, int, const char ***);
static idmap_retcode lookup_localsid2pid(idmap_mapping *, idmap_id_res *);
static idmap_retcode lookup_cache_name2sid(sqlite *, const char *,
- const char *, char **, char **, idmap_rid_t *, int *);
+ const char *, char **, char **, idmap_rid_t *, idmap_id_type *);
#define NELEM(a) (sizeof (a) / sizeof ((a)[0]))
@@ -129,10 +130,13 @@ idmap_tsd_destroy(void *key)
}
}
-int
+void
idmap_init_tsd_key(void)
{
- return (pthread_key_create(&idmap_tsd_key, idmap_tsd_destroy));
+ int rc;
+
+ rc = pthread_key_create(&idmap_tsd_key, idmap_tsd_destroy);
+ assert(rc == 0);
}
@@ -1412,7 +1416,7 @@ lookup_wksids_name2sid(
char **canondomain,
char **sidprefix,
idmap_rid_t *rid,
- int *type)
+ idmap_id_type *type)
{
const wksids_table_t *wksid;
@@ -1463,7 +1467,7 @@ lookup_wksids_name2sid(
if (type != NULL)
*type = (wksid->is_wuser) ?
- _IDMAP_T_USER : _IDMAP_T_GROUP;
+ IDMAP_USID : IDMAP_GSID;
return (IDMAP_SUCCESS);
@@ -1702,10 +1706,36 @@ out:
return (retcode);
}
+/*
+ * Previous versions used two enumerations for representing types.
+ * One of those has largely been eliminated, but was used in the
+ * name cache table and so during an upgrade might still be visible.
+ * In addition, the test suite prepopulates the cache with these values.
+ *
+ * This function translates those old values into the new values.
+ *
+ * This code deliberately does not use symbolic values for the legacy
+ * values. This is the *only* place where they should be used.
+ */
+static
+idmap_id_type
+xlate_legacy_type(int type)
+{
+ switch (type) {
+ case -1004: /* _IDMAP_T_USER */
+ return (IDMAP_USID);
+ case -1005: /* _IDMAP_T_GROUP */
+ return (IDMAP_GSID);
+ default:
+ return (type);
+ }
+ NOTE(NOTREACHED)
+}
+
static
idmap_retcode
lookup_cache_sid2name(sqlite *cache, const char *sidprefix, idmap_rid_t rid,
- char **canonname, char **canondomain, int *type)
+ char **canonname, char **canondomain, idmap_id_type *type)
{
char *end;
char *sql = NULL;
@@ -1745,7 +1775,7 @@ lookup_cache_sid2name(sqlite *cache, const char *sidprefix, idmap_rid_t rid,
retcode = IDMAP_ERR_CACHE;
goto out;
}
- *type = strtol(values[2], &end, 10);
+ *type = xlate_legacy_type(strtol(values[2], &end, 10));
}
if (canonname != NULL && values[0] != NULL) {
@@ -1785,15 +1815,17 @@ static
idmap_retcode
lookup_name_cache(sqlite *cache, idmap_mapping *req, idmap_id_res *res)
{
- int type = -1;
+ idmap_id_type type = -1;
idmap_retcode retcode;
char *sidprefix = NULL;
idmap_rid_t rid;
char *name = NULL, *domain = NULL;
/* Done if we've both sid and winname */
- if (req->id1.idmap_id_u.sid.prefix != NULL && req->id1name != NULL)
+ if (req->id1.idmap_id_u.sid.prefix != NULL && req->id1name != NULL) {
+ /* Don't bother TRACE()ing, too boring */
return (IDMAP_SUCCESS);
+ }
if (req->id1.idmap_id_u.sid.prefix != NULL) {
/* Lookup sid to winname */
@@ -1807,18 +1839,18 @@ lookup_name_cache(sqlite *cache, idmap_mapping *req, idmap_id_res *res)
}
if (retcode != IDMAP_SUCCESS) {
+ if (retcode == IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res, "Not found in name cache");
+ } else {
+ TRACE(req, res, "Name cache lookup error=%d", retcode);
+ }
free(name);
free(domain);
free(sidprefix);
return (retcode);
}
- if (res->id.idtype == IDMAP_POSIXID) {
- res->id.idtype = (type == _IDMAP_T_USER) ?
- IDMAP_UID : IDMAP_GID;
- }
- req->id1.idtype = (type == _IDMAP_T_USER) ?
- IDMAP_USID : IDMAP_GSID;
+ req->id1.idtype = type;
req->direction |= _IDMAP_F_DONT_UPDATE_NAMECACHE;
@@ -1839,6 +1871,8 @@ lookup_name_cache(sqlite *cache, idmap_mapping *req, idmap_id_res *res)
req->id1.idmap_id_u.sid.prefix = sidprefix;
req->id1.idmap_id_u.sid.rid = rid;
}
+
+ TRACE(req, res, "Found in name cache");
return (retcode);
}
@@ -1852,7 +1886,7 @@ ad_lookup_batch_int(lookup_state_t *state, idmap_mapping_batch *batch,
idmap_retcode retcode;
int i, num_queued, is_wuser, is_user;
int next_request;
- int retries = 0, eunixtype;
+ int retries = 0, esidtype;
char **unixname;
idmap_mapping *req;
idmap_id_res *res;
@@ -1928,23 +1962,23 @@ retry:
if (res->retcode != IDMAP_ERR_RETRIABLE_NET_ERR)
continue;
- if (IS_REQUEST_SID(*req, 1)) {
+ if (IS_ID_SID(req->id1)) {
/* win2unix request: */
posix_id_t *pid = NULL;
unixname = dn = attr = value = NULL;
- eunixtype = _IDMAP_T_UNDEF;
+ esidtype = IDMAP_SID;
if (state->directory_based_mapping ==
DIRECTORY_MAPPING_NAME &&
req->id2name == NULL) {
if (res->id.idtype == IDMAP_UID &&
AD_OR_MIXED(state->nm_siduid)) {
- eunixtype = _IDMAP_T_USER;
+ esidtype = IDMAP_USID;
unixname = &req->id2name;
} else if (res->id.idtype == IDMAP_GID &&
AD_OR_MIXED(state->nm_sidgid)) {
- eunixtype = _IDMAP_T_GROUP;
+ esidtype = IDMAP_GSID;
unixname = &req->id2name;
} else if (AD_OR_MIXED(state->nm_siduid) ||
AD_OR_MIXED(state->nm_sidgid)) {
@@ -1957,7 +1991,7 @@ retry:
* mapping only if AD or MIXED
* mode is enabled.
*/
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
res->info.src = IDMAP_MAP_SRC_NEW;
how->map_type = IDMAP_MAP_TYPE_DS_AD;
dn = &how->idmap_how_u.ad.dn;
@@ -1975,7 +2009,7 @@ retry:
/*
* Get how info for IDMU based mapping.
*/
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
res->info.src = IDMAP_MAP_SRC_NEW;
how->map_type = IDMAP_MAP_TYPE_IDMU;
dn = &how->idmap_how_u.idmu.dn;
@@ -1987,13 +2021,13 @@ retry:
/* Lookup AD by SID */
retcode = idmap_sid2name_batch_add1(
qs, req->id1.idmap_id_u.sid.prefix,
- &req->id1.idmap_id_u.sid.rid, eunixtype,
+ &req->id1.idmap_id_u.sid.rid, esidtype,
dn, attr, value,
(req->id1name == NULL) ?
&req->id1name : NULL,
(req->id1domain == NULL) ?
&req->id1domain : NULL,
- (int *)&req->id2.idtype, unixname,
+ &req->id2.idtype, unixname,
pid,
&res->retcode);
if (retcode == IDMAP_SUCCESS)
@@ -2003,19 +2037,19 @@ retry:
assert(req->id1name != NULL);
retcode = idmap_name2sid_batch_add1(
qs, req->id1name, req->id1domain,
- eunixtype,
+ esidtype,
dn, attr, value,
&req->id1name,
&req->id1.idmap_id_u.sid.prefix,
&req->id1.idmap_id_u.sid.rid,
- (int *)&req->id2.idtype, unixname,
+ &req->id2.idtype, unixname,
pid,
&res->retcode);
if (retcode == IDMAP_SUCCESS)
num_queued++;
}
- } else if (IS_REQUEST_UID(*req) || IS_REQUEST_GID(*req)) {
+ } else if (IS_ID_UID(req->id1) || IS_ID_GID(req->id1)) {
/* unix2win request: */
@@ -2038,10 +2072,10 @@ retry:
retcode = idmap_sid2name_batch_add1(
qs, res->id.idmap_id_u.sid.prefix,
&res->id.idmap_id_u.sid.rid,
- _IDMAP_T_UNDEF,
+ IDMAP_POSIXID,
NULL, NULL, NULL,
&req->id2name,
- &req->id2domain, (int *)&req->id2.idtype,
+ &req->id2domain, &req->id2.idtype,
NULL, NULL, &res->retcode);
if (retcode == IDMAP_SUCCESS)
num_queued++;
@@ -2055,11 +2089,11 @@ retry:
*/
retcode = idmap_name2sid_batch_add1(
qs, req->id2name, req->id2domain,
- _IDMAP_T_UNDEF,
+ IDMAP_POSIXID,
NULL, NULL, NULL, NULL,
&res->id.idmap_id_u.sid.prefix,
&res->id.idmap_id_u.sid.rid,
- (int *)&req->id2.idtype, NULL,
+ &req->id2.idtype, NULL,
NULL,
&res->retcode);
if (retcode == IDMAP_SUCCESS)
@@ -2069,7 +2103,7 @@ retry:
(how_local & DOMAIN_IS_LOCAL)) {
assert(req->id1.idmap_id_u.uid !=
IDMAP_SENTINEL_PID);
- is_user = IS_REQUEST_UID(*req);
+ is_user = IS_ID_UID(req->id1);
if (res->id.idtype == IDMAP_USID)
is_wuser = 1;
else if (res->id.idtype == IDMAP_GSID)
@@ -2081,7 +2115,7 @@ retry:
if (is_user != is_wuser)
continue;
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
res->info.src = IDMAP_MAP_SRC_NEW;
how->map_type = IDMAP_MAP_TYPE_IDMU;
retcode = idmap_pid2sid_batch_add1(
@@ -2092,7 +2126,7 @@ retry:
&res->id.idmap_id_u.sid.prefix,
&res->id.idmap_id_u.sid.rid,
&req->id2name, &req->id2domain,
- (int *)&req->id2.idtype, &res->retcode);
+ &req->id2.idtype, &res->retcode);
if (retcode == IDMAP_SUCCESS)
num_queued++;
} else if (req->id1name != NULL) {
@@ -2100,7 +2134,7 @@ retry:
* No SID and no winname but we've unixname.
* Lookup AD by unixname to get SID.
*/
- is_user = (IS_REQUEST_UID(*req)) ? 1 : 0;
+ is_user = (IS_ID_UID(req->id1)) ? 1 : 0;
if (res->id.idtype == IDMAP_USID)
is_wuser = 1;
else if (res->id.idtype == IDMAP_GSID)
@@ -2108,7 +2142,7 @@ retry:
else
is_wuser = is_user;
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
res->info.src = IDMAP_MAP_SRC_NEW;
how->map_type = IDMAP_MAP_TYPE_DS_AD;
retcode = idmap_unixname2sid_batch_add1(
@@ -2119,7 +2153,7 @@ retry:
&res->id.idmap_id_u.sid.prefix,
&res->id.idmap_id_u.sid.rid,
&req->id2name, &req->id2domain,
- (int *)&req->id2.idtype, &res->retcode);
+ &req->id2.idtype, &res->retcode);
if (retcode == IDMAP_SUCCESS)
num_queued++;
}
@@ -2175,7 +2209,7 @@ out:
* and update the idtype in request.
*/
for (i = 0; i < batch->idmap_mapping_batch_len; i++) {
- int type;
+ idmap_id_type type;
uid_t posix_id;
req = &batch->idmap_mapping_batch_val[i];
@@ -2218,15 +2252,15 @@ out:
if (res->retcode == IDMAP_ERR_NOTFOUND) {
/* Nothing found - remove the preset info */
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
}
- if (IS_REQUEST_SID(*req, 1)) {
+ if (IS_ID_SID(req->id1)) {
if (res->retcode != IDMAP_SUCCESS)
continue;
/* Evaluate result type */
switch (type) {
- case _IDMAP_T_USER:
+ case IDMAP_USID:
if (res->id.idtype == IDMAP_POSIXID)
res->id.idtype = IDMAP_UID;
/*
@@ -2245,7 +2279,7 @@ out:
req->id1.idtype = IDMAP_USID;
break;
- case _IDMAP_T_GROUP:
+ case IDMAP_GSID:
if (res->id.idtype == IDMAP_POSIXID)
res->id.idtype = IDMAP_GID;
/*
@@ -2276,7 +2310,7 @@ out:
req->direction |= _IDMAP_F_LOOKUP_NLDAP;
state->nldap_nqueries++;
}
- } else if (IS_REQUEST_UID(*req) || IS_REQUEST_GID(*req)) {
+ } else if (IS_ID_UID(req->id1) || IS_ID_GID(req->id1)) {
if (res->retcode != IDMAP_SUCCESS) {
if ((!(IDMAP_FATAL_ERROR(res->retcode))) &&
res->id.idmap_id_u.sid.prefix == NULL &&
@@ -2295,14 +2329,10 @@ out:
}
/* Evaluate result type */
switch (type) {
- case _IDMAP_T_USER:
+ case IDMAP_USID:
+ case IDMAP_GSID:
if (res->id.idtype == IDMAP_SID)
- res->id.idtype = IDMAP_USID;
- break;
-
- case _IDMAP_T_GROUP:
- if (res->id.idtype == IDMAP_SID)
- res->id.idtype = IDMAP_GSID;
+ res->id.idtype = type;
break;
default:
@@ -2519,19 +2549,33 @@ sid2pid_first_pass(lookup_state_t *state, idmap_mapping *req,
/* Lookup well-known SIDs table */
retcode = lookup_wksids_sid2pid(req, res, &wksid);
- /*
- * Note that IDMAP_SUCCESS means that we found a hardwired mapping.
- * If we found a well-known identity but no mapping, wksid==true and
- * retcode==IDMAP_ERR_NOTFOUND.
- */
- if (retcode != IDMAP_ERR_NOTFOUND)
+ if (retcode == IDMAP_SUCCESS) {
+ /* Found a well-known account with a hardwired mapping */
+ TRACE(req, res, "Hardwired mapping");
+ goto out;
+ } else if (retcode != IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res,
+ "Well-known account lookup failed, code %d", retcode);
goto out;
+ }
+
+ if (wksid) {
+ /* Found a well-known account, but no mapping */
+ TRACE(req, res, "Well-known account");
+ } else {
+ TRACE(req, res, "Not a well-known account");
- if (!wksid) {
/* Check if this is a localsid */
retcode = lookup_localsid2pid(req, res);
- if (retcode != IDMAP_ERR_NOTFOUND)
+ if (retcode == IDMAP_SUCCESS) {
+ TRACE(req, res, "Local SID");
+ goto out;
+ } else if (retcode != IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res,
+ "Local SID lookup error=%d", retcode);
goto out;
+ }
+ TRACE(req, res, "Not a local SID");
if (ALLOW_WK_OR_LOCAL_SIDS_ONLY(req)) {
retcode = IDMAP_ERR_NONE_GENERATED;
@@ -2557,12 +2601,19 @@ sid2pid_first_pass(lookup_state_t *state, idmap_mapping *req,
retcode = IDMAP_ERR_MEMORY;
goto out;
}
+ TRACE(req, res, "Added default domain");
}
/* Lookup cache */
retcode = lookup_cache_sid2pid(state->cache, req, res);
- if (retcode != IDMAP_ERR_NOTFOUND)
+ if (retcode == IDMAP_SUCCESS) {
+ TRACE(req, res, "Found in mapping cache");
goto out;
+ } else if (retcode != IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res, "Mapping cache lookup error=%d", retcode);
+ goto out;
+ }
+ TRACE(req, res, "Not found in mapping cache");
if (DO_NOT_ALLOC_NEW_ID_MAPPING(req) || AVOID_NAMESERVICE(req)) {
retcode = IDMAP_ERR_NONE_GENERATED;
@@ -2579,9 +2630,64 @@ sid2pid_first_pass(lookup_state_t *state, idmap_mapping *req,
* batched for AD lookup.
*/
retcode = lookup_name_cache(state->cache, req, res);
- if (retcode != IDMAP_SUCCESS && retcode != IDMAP_ERR_NOTFOUND)
+ if (retcode == IDMAP_SUCCESS) {
+ if (res->id.idtype == IDMAP_POSIXID) {
+ if (req->id1.idtype == IDMAP_USID)
+ res->id.idtype = IDMAP_UID;
+ else
+ res->id.idtype = IDMAP_GID;
+ }
+ } else if (retcode != IDMAP_ERR_NOTFOUND)
goto out;
+ if (_idmapdstate.cfg->pgcfg.use_lsa &&
+ _idmapdstate.cfg->pgcfg.domain_name != NULL) {
+ /*
+ * If we don't have both name and SID, try looking up the
+ * entry with LSA.
+ */
+ if (req->id1.idmap_id_u.sid.prefix != NULL &&
+ req->id1name == NULL) {
+
+ retcode = lookup_lsa_by_sid(
+ req->id1.idmap_id_u.sid.prefix,
+ req->id1.idmap_id_u.sid.rid,
+ &req->id1name, &req->id1domain, &req->id1.idtype);
+ if (retcode == IDMAP_SUCCESS) {
+ TRACE(req, res, "Found with LSA");
+ } else if (retcode == IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res, "Not found with LSA");
+ } else {
+ TRACE(req, res, "LSA error %d", retcode);
+ goto out;
+ }
+
+ } else if (req->id1name != NULL &&
+ req->id1.idmap_id_u.sid.prefix == NULL) {
+ char *canonname;
+ char *canondomain;
+
+ retcode = lookup_lsa_by_name(
+ req->id1name, req->id1domain,
+ &req->id1.idmap_id_u.sid.prefix,
+ &req->id1.idmap_id_u.sid.rid,
+ &canonname, &canondomain,
+ &req->id1.idtype);
+ if (retcode == IDMAP_SUCCESS) {
+ free(req->id1name);
+ req->id1name = canonname;
+ free(req->id1domain);
+ req->id1domain = canondomain;
+ TRACE(req, res, "Found with LSA");
+ } else if (retcode == IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res, "Not found with LSA");
+ } else {
+ TRACE(req, res, "LSA error %d", retcode);
+ goto out;
+ }
+ }
+ }
+
/*
* Set the flag to indicate that we are not done yet so that
* subsequent passes considers this request for name-based
@@ -2652,7 +2758,7 @@ generate_localsid(idmap_mapping *req, idmap_id_res *res, int is_user,
RDLOCK_CONFIG();
/*
* machine_sid is never NULL because if it is we won't be here.
- * No need to assert because stdrup(NULL) will core anyways.
+ * No need to assert because strdup(NULL) will core anyways.
*/
res->id.idmap_id_u.sid.prefix =
strdup(_idmapdstate.cfg->pgcfg.machine_sid);
@@ -2956,6 +3062,12 @@ name_based_mapping_sid2pid(lookup_state_t *state,
retcode = IDMAP_ERR_INTERNAL;
goto out;
}
+
+ TRACE(req, res, "Matching rule: %s@%s -> %s",
+ values[2] == NULL ? "(null)" : values[2],
+ values[3] == NULL ? "(null)" : values[3],
+ values[0] == NULL ? "(null)" : values[0]);
+
if (values[0] == NULL) {
retcode = IDMAP_ERR_INTERNAL;
goto out;
@@ -2969,6 +3081,7 @@ name_based_mapping_sid2pid(lookup_state_t *state,
direction = IDMAP_DIRECTION_W2U;
if (EMPTY_NAME(values[0])) {
+ TRACE(req, res, "Mapping inhibited");
idmap_namerule_set(rule, values[3], values[2],
values[0], is_user, is_wuser,
strtol(values[4], &end, 10),
@@ -2987,11 +3100,18 @@ name_based_mapping_sid2pid(lookup_state_t *state,
retcode = ns_lookup_byname(unixname, lower_unixname,
&res->id);
- if (retcode == IDMAP_ERR_NOTFOUND) {
- if (values[0][0] == '*')
+ if (retcode == IDMAP_SUCCESS) {
+ break;
+ } else if (retcode == IDMAP_ERR_NOTFOUND) {
+ if (values[0][0] == '*') {
+ TRACE(req, res,
+ "%s not found, continuing",
+ unixname);
/* Case 4 */
continue;
- else {
+ } else {
+ TRACE(req, res,
+ "%s not found, error", unixname);
/* Case 3 */
idmap_namerule_set(rule, values[3],
values[2], values[0], is_user,
@@ -3000,6 +3120,9 @@ name_based_mapping_sid2pid(lookup_state_t *state,
direction);
retcode = IDMAP_ERR_NOMAPPING;
}
+ } else {
+ TRACE(req, res, "Looking up %s error=%d",
+ unixname, retcode);
}
goto out;
} else if (r == SQLITE_DONE) {
@@ -3016,29 +3139,36 @@ name_based_mapping_sid2pid(lookup_state_t *state,
}
}
-out:
- if (sql != NULL)
- sqlite_freemem(sql);
- if (retcode == IDMAP_SUCCESS) {
- if (values[1] != NULL)
- res->direction =
- (strtol(values[1], &end, 10) == 0)?
- IDMAP_DIRECTION_W2U:IDMAP_DIRECTION_BI;
- else
- res->direction = IDMAP_DIRECTION_W2U;
+ /* Found */
- req->id2name = strdup(unixname);
- if (req->id2name == NULL) {
- retcode = IDMAP_ERR_MEMORY;
- }
+ if (values[1] != NULL)
+ res->direction =
+ (strtol(values[1], &end, 10) == 0)?
+ IDMAP_DIRECTION_W2U:IDMAP_DIRECTION_BI;
+ else
+ res->direction = IDMAP_DIRECTION_W2U;
+
+ req->id2name = strdup(unixname);
+ if (req->id2name == NULL) {
+ retcode = IDMAP_ERR_MEMORY;
+ goto out;
}
+ TRACE(req, res, "UNIX name found");
- if (retcode == IDMAP_SUCCESS) {
- idmap_namerule_set(rule, values[3], values[2],
- values[0], is_user, is_wuser, strtol(values[4], &end, 10),
- res->direction);
+ idmap_namerule_set(rule, values[3], values[2],
+ values[0], is_user, is_wuser, strtol(values[4], &end, 10),
+ res->direction);
+
+out:
+ if (retcode != IDMAP_SUCCESS &&
+ retcode != IDMAP_ERR_NOTFOUND &&
+ retcode != IDMAP_ERR_NOMAPPING) {
+ TRACE(req, res, "Rule processing error, code=%d", retcode);
}
+ if (sql != NULL)
+ sqlite_freemem(sql);
+
if (retcode != IDMAP_ERR_NOTFOUND) {
res->info.how.map_type = IDMAP_MAP_TYPE_RULE_BASED;
res->info.src = IDMAP_MAP_SRC_NEW;
@@ -3224,6 +3354,7 @@ sid2pid_second_pass(lookup_state_t *state,
idmap_mapping *req, idmap_id_res *res)
{
idmap_retcode retcode;
+ idmap_retcode retcode2;
/* Check if second pass is needed */
if (ARE_WE_DONE(req->direction))
@@ -3242,8 +3373,14 @@ sid2pid_second_pass(lookup_state_t *state,
*/
if (req->id1.idtype == IDMAP_SID)
req->id1.idtype = IDMAP_USID;
- if (res->id.idtype == IDMAP_POSIXID)
+ if (res->id.idtype == IDMAP_POSIXID) {
res->id.idtype = IDMAP_UID;
+ TRACE(req, res, "Assume unresolvable SID is user");
+ } else if (res->id.idtype == IDMAP_UID) {
+ TRACE(req, res, "Must map unresolvable SID to user");
+ } else if (res->id.idtype == IDMAP_GID) {
+ TRACE(req, res, "Must map unresolvable SID to group");
+ }
goto do_eph;
}
if (retcode != IDMAP_SUCCESS)
@@ -3265,8 +3402,15 @@ sid2pid_second_pass(lookup_state_t *state,
* have a UID or GID that isn't in the
* name service.
*/
- (void) ns_lookup_bypid(res->id.idmap_id_u.uid,
+ retcode2 = ns_lookup_bypid(res->id.idmap_id_u.uid,
res->id.idtype == IDMAP_UID, &req->id2name);
+ if (IDMAP_ERROR(retcode2)) {
+ TRACE(req, res,
+ "Getting UNIX name, error=%d (ignored)",
+ retcode2);
+ } else {
+ TRACE(req, res, "Found UNIX name");
+ }
}
goto out;
}
@@ -3332,42 +3476,65 @@ sid2pid_second_pass(lookup_state_t *state,
res->id.idtype == IDMAP_GID) ||
(req->id1.idtype == IDMAP_GSID &&
res->id.idtype == IDMAP_UID))) {
+ TRACE(req, res, "Ignoring UNIX name found in AD");
free(req->id2name);
req->id2name = NULL;
res->id.idmap_id_u.uid = IDMAP_SENTINEL_PID;
/* fallback */
} else {
- if (res->id.idmap_id_u.uid == IDMAP_SENTINEL_PID)
+ if (res->id.idmap_id_u.uid == IDMAP_SENTINEL_PID) {
retcode = ns_lookup_byname(req->id2name,
NULL, &res->id);
- /*
- * If ns_lookup_byname() fails that means the
- * unixname (req->id2name), which was obtained
- * from the AD object by directory-based mapping,
- * is not a valid Unix user/group and therefore
- * we return the error to the client instead of
- * doing rule-based mapping or ephemeral mapping.
- * This way the client can detect the issue.
- */
+ if (retcode != IDMAP_SUCCESS) {
+ /*
+ * If ns_lookup_byname() fails that
+ * means the unixname (req->id2name),
+ * which was obtained from the AD
+ * object by directory-based mapping,
+ * is not a valid Unix user/group and
+ * therefore we return the error to the
+ * client instead of doing rule-based
+ * mapping or ephemeral mapping. This
+ * way the client can detect the issue.
+ */
+ TRACE(req, res,
+ "UNIX lookup error=%d", retcode);
+ goto out;
+ }
+ TRACE(req, res, "UNIX lookup");
+ }
goto out;
}
}
/* Free any mapping info from Directory based mapping */
if (res->info.how.map_type != IDMAP_MAP_TYPE_UNKNOWN)
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
/*
* If we don't have unixname then evaluate local name-based
* mapping rules.
*/
retcode = name_based_mapping_sid2pid(state, req, res);
- if (retcode != IDMAP_ERR_NOTFOUND)
+ if (retcode == IDMAP_SUCCESS) {
+ TRACE(req, res, "Rule-based mapping");
goto out;
+ } else if (retcode != IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res, "Rule-based mapping error=%d", retcode);
+ goto out;
+ }
+ TRACE(req, res, "No matching rule");
do_eph:
/* If not found, do ephemeral mapping */
retcode = dynamic_ephemeral_mapping(state, req, res);
+ if (retcode == IDMAP_SUCCESS) {
+ TRACE(req, res, "Ephemeral mapping");
+ goto out;
+ } else if (retcode != IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res, "Ephemeral mapping error=%d", retcode);
+ goto out;
+ }
out:
res->retcode = idmap_stat4prot(retcode);
@@ -3386,6 +3553,7 @@ update_cache_pid2sid(lookup_state_t *state,
{
char *sql = NULL;
idmap_retcode retcode;
+ idmap_retcode retcode2;
char *map_dn = NULL;
char *map_attr = NULL;
char *map_value = NULL;
@@ -3420,8 +3588,12 @@ update_cache_pid2sid(lookup_state_t *state,
* If we can't find it... c'est la vie.
*/
if (req->id1name == NULL) {
- (void) ns_lookup_bypid(req->id1.idmap_id_u.uid,
+ retcode2 = ns_lookup_bypid(req->id1.idmap_id_u.uid,
req->id1.idtype == IDMAP_UID, &req->id1name);
+ if (retcode2 == IDMAP_SUCCESS)
+ TRACE(req, res, "Found UNIX name");
+ else
+ TRACE(req, res, "Getting UNIX name error=%d", retcode2);
}
assert(res->info.how.map_type != IDMAP_MAP_TYPE_UNKNOWN);
@@ -3458,7 +3630,7 @@ update_cache_pid2sid(lookup_state_t *state,
break;
default:
- /* Dont cache other mapping types */
+ /* Don't cache other mapping types */
assert(FALSE);
}
@@ -3508,7 +3680,7 @@ update_cache_pid2sid(lookup_state_t *state,
"VALUES(%Q, %u, %Q, %Q, %d, strftime('%%s','now') + 3600); ",
res->id.idmap_id_u.sid.prefix, res->id.idmap_id_u.sid.rid,
req->id2name, req->id2domain,
- (res->id.idtype == IDMAP_USID) ? _IDMAP_T_USER : _IDMAP_T_GROUP);
+ res->id.idtype);
if (sql == NULL) {
retcode = IDMAP_ERR_INTERNAL;
@@ -3519,8 +3691,6 @@ update_cache_pid2sid(lookup_state_t *state,
retcode = sql_exec_no_cb(state->cache, IDMAP_CACHENAME, sql);
out:
- if (!(req->flag & IDMAP_REQ_FLG_MAPPING_INFO))
- idmap_info_free(&res->info);
if (sql != NULL)
sqlite_freemem(sql);
return (retcode);
@@ -3612,7 +3782,7 @@ update_cache_sid2pid(lookup_state_t *state,
break;
default:
- /* Dont cache other mapping types */
+ /* Don't cache other mapping types */
assert(FALSE);
}
@@ -3659,7 +3829,7 @@ update_cache_sid2pid(lookup_state_t *state,
"VALUES(%Q, %u, %Q, %Q, %d, strftime('%%s','now') + 3600); ",
req->id1.idmap_id_u.sid.prefix, req->id1.idmap_id_u.sid.rid,
req->id1name, req->id1domain,
- (req->id1.idtype == IDMAP_USID) ? _IDMAP_T_USER : _IDMAP_T_GROUP);
+ req->id1.idtype);
if (sql == NULL) {
retcode = IDMAP_ERR_INTERNAL;
@@ -3670,9 +3840,6 @@ update_cache_sid2pid(lookup_state_t *state,
retcode = sql_exec_no_cb(state->cache, IDMAP_CACHENAME, sql);
out:
- if (!(req->flag & IDMAP_REQ_FLG_MAPPING_INFO))
- idmap_info_free(&res->info);
-
if (sql != NULL)
sqlite_freemem(sql);
return (retcode);
@@ -3889,8 +4056,14 @@ out:
*/
static
idmap_retcode
-lookup_cache_name2sid(sqlite *cache, const char *name, const char *domain,
- char **canonname, char **sidprefix, idmap_rid_t *rid, int *type)
+lookup_cache_name2sid(
+ sqlite *cache,
+ const char *name,
+ const char *domain,
+ char **canonname,
+ char **sidprefix,
+ idmap_rid_t *rid,
+ idmap_id_type *type)
{
char *end, *lower_name;
char *sql;
@@ -3939,7 +4112,7 @@ lookup_cache_name2sid(sqlite *cache, const char *name, const char *domain,
retcode = IDMAP_ERR_CACHE;
goto out;
}
- *type = strtol(values[2], &end, 10);
+ *type = xlate_legacy_type(strtol(values[2], &end, 10));
}
if (values[0] == NULL || values[1] == NULL) {
@@ -3985,9 +4158,9 @@ out:
static
idmap_retcode
ad_lookup_by_winname(lookup_state_t *state,
- const char *name, const char *domain, int eunixtype,
+ const char *name, const char *domain, int esidtype,
char **dn, char **attr, char **value, char **canonname,
- char **sidprefix, idmap_rid_t *rid, int *wintype,
+ char **sidprefix, idmap_rid_t *rid, idmap_id_type *wintype,
char **unixname)
{
int retries;
@@ -4034,7 +4207,7 @@ retry:
}
retcode = idmap_name2sid_batch_add1(qs, name, domain,
- eunixtype, dn, attr, value, canonname, sidprefix,
+ esidtype, dn, attr, value, canonname, sidprefix,
rid, wintype, unixname, NULL, &rc);
if (retcode == IDMAP_ERR_DOMAIN_NOTFOUND) {
idmap_lookup_release_batch(&qs);
@@ -4092,15 +4265,15 @@ lookup_name2sid(
sqlite *cache,
const char *name,
const char *domain,
- int *is_wuser,
+ int want_wuser,
char **canonname,
char **canondomain,
char **sidprefix,
idmap_rid_t *rid,
+ idmap_id_type *type,
idmap_mapping *req,
int local_only)
{
- int type;
idmap_retcode retcode;
*sidprefix = NULL;
@@ -4111,7 +4284,7 @@ lookup_name2sid(
/* Lookup well-known SIDs table */
retcode = lookup_wksids_name2sid(name, domain, canonname, canondomain,
- sidprefix, rid, &type);
+ sidprefix, rid, type);
if (retcode == IDMAP_SUCCESS) {
req->direction |= _IDMAP_F_DONT_UPDATE_NAMECACHE;
goto out;
@@ -4121,7 +4294,7 @@ lookup_name2sid(
/* Lookup cache */
retcode = lookup_cache_name2sid(cache, name, domain, canonname,
- sidprefix, rid, &type);
+ sidprefix, rid, type);
if (retcode == IDMAP_SUCCESS) {
req->direction |= _IDMAP_F_DONT_UPDATE_NAMECACHE;
goto out;
@@ -4138,28 +4311,39 @@ lookup_name2sid(
if (local_only)
return (retcode);
+ if (_idmapdstate.cfg->pgcfg.use_lsa &&
+ _idmapdstate.cfg->pgcfg.domain_name != NULL &&
+ name != NULL && *sidprefix == NULL) {
+ retcode = lookup_lsa_by_name(name, domain,
+ sidprefix, rid,
+ canonname, canondomain,
+ type);
+ if (retcode == IDMAP_SUCCESS)
+ goto out;
+ else if (retcode != IDMAP_ERR_NOTFOUND)
+ return (retcode);
+ }
+
/* Lookup AD */
- retcode = ad_lookup_by_winname(NULL, name, domain, _IDMAP_T_UNDEF,
- NULL, NULL, NULL, canonname, sidprefix, rid, &type, NULL);
+ retcode = ad_lookup_by_winname(NULL, name, domain, IDMAP_POSIXID,
+ NULL, NULL, NULL, canonname, sidprefix, rid, type, NULL);
if (retcode != IDMAP_SUCCESS)
return (retcode);
out:
/*
* Entry found (cache or Windows lookup)
- * is_wuser is both input as well as output parameter
*/
- if (*is_wuser == 1 && type != _IDMAP_T_USER)
+ if (want_wuser == 1 && *type != IDMAP_USID)
retcode = IDMAP_ERR_NOTUSER;
- else if (*is_wuser == 0 && type != _IDMAP_T_GROUP)
+ else if (want_wuser == 0 && *type != IDMAP_GSID)
retcode = IDMAP_ERR_NOTGROUP;
- else if (*is_wuser == -1) {
- /* Caller wants to know if its user or group */
- if (type == _IDMAP_T_USER)
- *is_wuser = 1;
- else if (type == _IDMAP_T_GROUP)
- *is_wuser = 0;
- else
+ else if (want_wuser == -1) {
+ /*
+ * Caller wants to know if its user or group
+ * Verify that it's one or the other.
+ */
+ if (*type != IDMAP_USID && *type != IDMAP_GSID)
retcode = IDMAP_ERR_SID;
}
@@ -4204,7 +4388,7 @@ name_based_mapping_pid2sid(lookup_state_t *state, const char *unixname,
const char **values;
sqlite_vm *vm = NULL;
int ncol, r;
- int is_wuser;
+ int want_wuser;
const char *me = "name_based_mapping_pid2sid";
int non_wild_match = FALSE;
idmap_namerule *rule = &res->info.how.idmap_how_u.rule;
@@ -4243,6 +4427,12 @@ name_based_mapping_pid2sid(lookup_state_t *state, const char *unixname,
retcode = IDMAP_ERR_INTERNAL;
goto out;
}
+
+ TRACE(req, res, "Matching rule: %s -> %s@%s",
+ values[4] == NULL ? "(null)" : values[4],
+ values[0] == NULL ? "(null)" : values[0],
+ values[1] == NULL ? "(null)" : values[1]);
+
if (values[0] == NULL) {
/* values [1] and [2] can be null */
retcode = IDMAP_ERR_INTERNAL;
@@ -4262,6 +4452,7 @@ name_based_mapping_pid2sid(lookup_state_t *state, const char *unixname,
strtol(values[3], &end, 10),
strtol(values[5], &end, 10),
direction);
+ TRACE(req, res, "Mapping inhibited");
retcode = IDMAP_ERR_NOMAPPING;
goto out;
}
@@ -4290,28 +4481,44 @@ name_based_mapping_pid2sid(lookup_state_t *state, const char *unixname,
}
winname = values[0];
}
- is_wuser = res->id.idtype == IDMAP_USID ? 1
+ want_wuser = res->id.idtype == IDMAP_USID ? 1
: res->id.idtype == IDMAP_GSID ? 0
: -1;
if (values[1] != NULL)
windomain = values[1];
- else if (state->defdom != NULL)
+ else if (state->defdom != NULL) {
windomain = state->defdom;
- else {
+ TRACE(req, res,
+ "Added default domain %s to rule",
+ windomain);
+ } else {
idmapdlog(LOG_ERR, "%s: no domain", me);
+ TRACE(req, res,
+ "No domain in rule, and no default domain");
retcode = IDMAP_ERR_DOMAIN_NOTFOUND;
goto out;
}
retcode = lookup_name2sid(state->cache,
winname, windomain,
- &is_wuser, &canonname, &canondomain,
+ want_wuser, &canonname, &canondomain,
&res->id.idmap_id_u.sid.prefix,
- &res->id.idmap_id_u.sid.rid, req, 0);
+ &res->id.idmap_id_u.sid.rid,
+ &res->id.idtype, req, 0);
- if (retcode == IDMAP_ERR_NOTFOUND) {
+ if (retcode == IDMAP_SUCCESS) {
+ break;
+ } else if (retcode == IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res,
+ "%s@%s not found, continuing",
+ winname, windomain);
continue;
+ } else {
+ TRACE(req, res,
+ "Looking up %s@%s error=%d",
+ winname, windomain, retcode);
}
+
goto out;
} else if (r == SQLITE_DONE) {
@@ -4336,29 +4543,25 @@ name_based_mapping_pid2sid(lookup_state_t *state, const char *unixname,
}
}
-out:
- if (sql != NULL)
- sqlite_freemem(sql);
- if (retcode == IDMAP_SUCCESS) {
- res->id.idtype = is_wuser ? IDMAP_USID : IDMAP_GSID;
+ if (values[2] != NULL)
+ res->direction =
+ (strtol(values[2], &end, 10) == 0)?
+ IDMAP_DIRECTION_U2W:IDMAP_DIRECTION_BI;
+ else
+ res->direction = IDMAP_DIRECTION_U2W;
- if (values[2] != NULL)
- res->direction =
- (strtol(values[2], &end, 10) == 0)?
- IDMAP_DIRECTION_U2W:IDMAP_DIRECTION_BI;
- else
- res->direction = IDMAP_DIRECTION_U2W;
+ req->id2name = canonname;
+ req->id2domain = canondomain;
- req->id2name = canonname;
- req->id2domain = canondomain;
- }
+ idmap_namerule_set(rule, values[1], values[0], values[4],
+ is_user, strtol(values[3], &end, 10),
+ strtol(values[5], &end, 10),
+ rule->direction);
+ TRACE(req, res, "Windows name found");
- if (retcode == IDMAP_SUCCESS) {
- idmap_namerule_set(rule, values[1], values[0], values[4],
- is_user, strtol(values[3], &end, 10),
- strtol(values[5], &end, 10),
- rule->direction);
- }
+out:
+ if (sql != NULL)
+ sqlite_freemem(sql);
if (retcode != IDMAP_ERR_NOTFOUND) {
res->info.how.map_type = IDMAP_MAP_TYPE_RULE_BASED;
@@ -4432,6 +4635,7 @@ pid2sid_first_pass(lookup_state_t *state, idmap_mapping *req,
idmap_id_res *res, int is_user)
{
idmap_retcode retcode;
+ idmap_retcode retcode2;
bool_t gen_localsid_on_err = FALSE;
/* Initialize result */
@@ -4451,26 +4655,42 @@ pid2sid_first_pass(lookup_state_t *state, idmap_mapping *req,
goto out;
}
- if (ns_lookup_byname(req->id1name, NULL, &req->id1)
- != IDMAP_SUCCESS) {
+ retcode = ns_lookup_byname(req->id1name, NULL, &req->id1);
+ if (retcode != IDMAP_SUCCESS) {
+ TRACE(req, res, "Getting UNIX ID error=%d", retcode);
retcode = IDMAP_ERR_NOMAPPING;
goto out;
}
+ TRACE(req, res, "Found UNIX ID");
}
/* Lookup in well-known SIDs table */
retcode = lookup_wksids_pid2sid(req, res, is_user);
- if (retcode != IDMAP_ERR_NOTFOUND)
+ if (retcode == IDMAP_SUCCESS) {
+ TRACE(req, res, "Hardwired mapping");
+ goto out;
+ } else if (retcode != IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res,
+ "Well-known account lookup error=%d", retcode);
goto out;
+ }
/* Lookup in cache */
retcode = lookup_cache_pid2sid(state->cache, req, res, is_user);
- if (retcode != IDMAP_ERR_NOTFOUND)
+ if (retcode == IDMAP_SUCCESS) {
+ TRACE(req, res, "Found in mapping cache");
+ goto out;
+ } else if (retcode != IDMAP_ERR_NOTFOUND) {
+ TRACE(req, res,
+ "Mapping cache lookup error=%d", retcode);
goto out;
+ }
+ TRACE(req, res, "Not found in mapping cache");
/* Ephemeral ids cannot be allocated during pid2sid */
if (IDMAP_ID_IS_EPHEMERAL(req->id1.idmap_id_u.uid)) {
retcode = IDMAP_ERR_NOMAPPING;
+ TRACE(req, res, "Shouldn't have an ephemeral ID here");
goto out;
}
@@ -4500,9 +4720,12 @@ pid2sid_first_pass(lookup_state_t *state, idmap_mapping *req,
retcode = ns_lookup_bypid(req->id1.idmap_id_u.uid,
is_user, &req->id1name);
if (retcode != IDMAP_SUCCESS) {
+ TRACE(req, res,
+ "Getting UNIX name error=%d", retcode);
gen_localsid_on_err = TRUE;
goto out;
}
+ TRACE(req, res, "Found UNIX name");
}
req->direction |= _IDMAP_F_LOOKUP_AD;
state->ad_nqueries++;
@@ -4526,9 +4749,16 @@ pid2sid_first_pass(lookup_state_t *state, idmap_mapping *req,
out:
res->retcode = idmap_stat4prot(retcode);
- if (ARE_WE_DONE(req->direction) && res->retcode != IDMAP_SUCCESS)
- if (gen_localsid_on_err == TRUE)
- (void) generate_localsid(req, res, is_user, TRUE);
+ if (ARE_WE_DONE(req->direction) && res->retcode != IDMAP_SUCCESS) {
+ if (gen_localsid_on_err == TRUE) {
+ retcode2 = generate_localsid(req, res, is_user, TRUE);
+ if (retcode2 == IDMAP_SUCCESS)
+ TRACE(req, res, "Generate local SID");
+ else
+ TRACE(req, res,
+ "Generate local SID error=%d", retcode2);
+ }
+ }
return (retcode);
}
@@ -4538,6 +4768,7 @@ pid2sid_second_pass(lookup_state_t *state, idmap_mapping *req,
{
bool_t gen_localsid_on_err = TRUE;
idmap_retcode retcode = IDMAP_SUCCESS;
+ idmap_retcode retcode2;
/* Check if second pass is needed */
if (ARE_WE_DONE(req->direction))
@@ -4561,6 +4792,7 @@ pid2sid_second_pass(lookup_state_t *state, idmap_mapping *req,
if (req->id2name != NULL) {
/* Return notfound if we've winname but no SID. */
if (res->id.idmap_id_u.sid.prefix == NULL) {
+ TRACE(req, res, "Windows name but no SID");
retcode = IDMAP_ERR_NOTFOUND;
goto out;
}
@@ -4583,21 +4815,28 @@ pid2sid_second_pass(lookup_state_t *state, idmap_mapping *req,
/* Free any mapping info from Directory based mapping */
if (res->info.how.map_type != IDMAP_MAP_TYPE_UNKNOWN)
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
if (req->id1name == NULL) {
/* Get unixname from name service */
retcode = ns_lookup_bypid(req->id1.idmap_id_u.uid, is_user,
&req->id1name);
- if (retcode != IDMAP_SUCCESS)
+ if (retcode != IDMAP_SUCCESS) {
+ TRACE(req, res,
+ "Getting UNIX name error=%d", retcode);
goto out;
+ }
+ TRACE(req, res, "Found UNIX name");
} else if (req->id1.idmap_id_u.uid == IDMAP_SENTINEL_PID) {
/* Get pid from name service */
retcode = ns_lookup_byname(req->id1name, NULL, &req->id1);
if (retcode != IDMAP_SUCCESS) {
+ TRACE(req, res,
+ "Getting UNIX ID error=%d", retcode);
gen_localsid_on_err = FALSE;
goto out;
}
+ TRACE(req, res, "Found UNIX ID");
}
/* Use unixname to evaluate local name-based mapping rules */
@@ -4605,6 +4844,12 @@ pid2sid_second_pass(lookup_state_t *state, idmap_mapping *req,
req, res);
if (retcode == IDMAP_ERR_NOTFOUND) {
retcode = generate_localsid(req, res, is_user, FALSE);
+ if (retcode == IDMAP_SUCCESS) {
+ TRACE(req, res, "Generated local SID");
+ } else {
+ TRACE(req, res,
+ "Generating local SID error=%d", retcode);
+ }
gen_localsid_on_err = FALSE;
}
@@ -4616,10 +4861,16 @@ out:
req->id2name = NULL;
free(req->id2domain);
req->id2domain = NULL;
- if (gen_localsid_on_err == TRUE)
- (void) generate_localsid(req, res, is_user, TRUE);
- else
+ if (gen_localsid_on_err == TRUE) {
+ retcode2 = generate_localsid(req, res, is_user, TRUE);
+ if (retcode2 == IDMAP_SUCCESS)
+ TRACE(req, res, "Generate local SID");
+ else
+ TRACE(req, res,
+ "Generate local SID error=%d", retcode2);
+ } else {
res->id.idtype = is_user ? IDMAP_USID : IDMAP_GSID;
+ }
}
if (!ARE_WE_DONE(req->direction))
state->pid2sid_done = FALSE;
diff --git a/usr/src/cmd/idmap/idmapd/idmap.xml b/usr/src/cmd/idmap/idmapd/idmap.xml
index b7400cc811..87933b5507 100644
--- a/usr/src/cmd/idmap/idmapd/idmap.xml
+++ b/usr/src/cmd/idmap/idmapd/idmap.xml
@@ -1,8 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
- Copyright 2007 Sun Microsystems, Inc. All rights reserved.
- Use is subject to license terms.
+ Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
CDDL HEADER START
@@ -23,8 +22,6 @@
CDDL HEADER END
- ident "%Z%%M% %I% %E% SMI"
-
NOTE: This service manifest is not editable; its contents will
be overwritten by package or patch operations, including
operating system upgrade. Make customizations in a different
@@ -101,6 +98,20 @@
value='solaris.smf.value.idmap' />
</property_group>
+ <property_group name='debug' type='application' >
+ <stability value='Unstable' />
+ <propval name='all' type='integer' value='0' />
+ <propval name='config' type='integer' value='0' />
+ <propval name='mapping' type='integer' value='0' />
+ <propval name='discovery' type='integer' value='0' />
+ <propval name='dns' type='integer' value='0' />
+ <propval name='ldap' type='integer' value='0' />
+ <propval
+ name='value_authorization'
+ type='astring'
+ value='solaris.smf.value.idmap' />
+ </property_group>
+
<stability value='Unstable' />
<template>
diff --git a/usr/src/cmd/idmap/idmapd/idmap_config.c b/usr/src/cmd/idmap/idmapd/idmap_config.c
index c25f6da2fc..cf5848aa0f 100644
--- a/usr/src/cmd/idmap/idmapd/idmap_config.c
+++ b/usr/src/cmd/idmap/idmapd/idmap_config.c
@@ -40,12 +40,13 @@
#include <port.h>
#include <net/route.h>
#include <sys/u8_textprep.h>
+#include <note.h>
#include "addisc.h"
#define MACHINE_SID_LEN (9 + 3 * 11)
#define FMRI_BASE "svc:/system/idmap"
#define CONFIG_PG "config"
-#define GENERAL_PG "general"
+#define DEBUG_PG "debug"
#define RECONFIGURE 1
#define POKE_AUTO_DISCOVERY 2
@@ -57,7 +58,6 @@ enum event_type {
EVENT_REFRESH, /* SMF refresh */
};
-/*LINTLIBRARY*/
static pthread_t update_thread_handle = 0;
@@ -72,6 +72,13 @@ struct enum_lookup_map directory_mapping_map[] = {
{ 0, NULL },
};
+struct enum_lookup_map trust_dir_map[] = {
+ { 1, "they trust us" },
+ { 2, "we trust them" },
+ { 3, "we trust each other" },
+ { 0, NULL },
+};
+
static int
generate_machine_sid(char **machine_sid)
{
@@ -125,7 +132,6 @@ prop_exists(idmap_cfg_handles_t *handles, const char *name, boolean_t *exists)
{
scf_property_t *scf_prop;
- scf_value_t *value;
*exists = B_FALSE;
@@ -135,6 +141,77 @@ prop_exists(idmap_cfg_handles_t *handles, const char *name, boolean_t *exists)
scf_strerror(scf_error()));
return (-1);
}
+
+ if (scf_pg_get_property(handles->config_pg, name, scf_prop) == 0)
+ *exists = B_TRUE;
+
+ scf_property_destroy(scf_prop);
+
+ return (0);
+}
+
+static int
+get_debug(idmap_cfg_handles_t *handles, const char *name)
+{
+ int64_t i64 = 0;
+
+ scf_property_t *scf_prop;
+ scf_value_t *value;
+
+ scf_prop = scf_property_create(handles->main);
+ if (scf_prop == NULL) {
+ idmapdlog(LOG_ERR, "scf_property_create() failed: %s",
+ scf_strerror(scf_error()));
+ abort();
+ }
+ value = scf_value_create(handles->main);
+ if (value == NULL) {
+ idmapdlog(LOG_ERR, "scf_value_create() failed: %s",
+ scf_strerror(scf_error()));
+ abort();
+ }
+
+ if (scf_pg_get_property(handles->debug_pg, name, scf_prop) < 0) {
+ /* this is OK: the property is just undefined */
+ goto destruction;
+ }
+
+
+ if (scf_property_get_value(scf_prop, value) < 0) {
+ /* It is still OK when a property doesn't have any value */
+ goto destruction;
+ }
+
+ if (scf_value_get_integer(value, &i64) != 0) {
+ idmapdlog(LOG_ERR, "Can not retrieve %s/%s: %s",
+ DEBUG_PG, name, scf_strerror(scf_error()));
+ abort();
+ }
+
+destruction:
+ scf_value_destroy(value);
+ scf_property_destroy(scf_prop);
+
+ return ((int)i64);
+}
+
+static int
+get_val_bool(idmap_cfg_handles_t *handles, const char *name,
+ boolean_t *val, boolean_t default_val)
+{
+ int rc = 0;
+
+ scf_property_t *scf_prop;
+ scf_value_t *value;
+
+ *val = default_val;
+
+ scf_prop = scf_property_create(handles->main);
+ if (scf_prop == NULL) {
+ idmapdlog(LOG_ERR, "scf_property_create() failed: %s",
+ scf_strerror(scf_error()));
+ return (-1);
+ }
value = scf_value_create(handles->main);
if (value == NULL) {
idmapdlog(LOG_ERR, "scf_value_create() failed: %s",
@@ -143,16 +220,28 @@ prop_exists(idmap_cfg_handles_t *handles, const char *name, boolean_t *exists)
return (-1);
}
- if (scf_pg_get_property(handles->config_pg, name, scf_prop) == 0)
- *exists = B_TRUE;
+ /* It is OK if the property is undefined */
+ if (scf_pg_get_property(handles->config_pg, name, scf_prop) < 0)
+ goto destruction;
+
+
+ /* It is still OK when a property doesn't have any value */
+ if (scf_property_get_value(scf_prop, value) < 0)
+ goto destruction;
+
+ uint8_t b;
+ rc = scf_value_get_boolean(value, &b);
+ if (rc == 0)
+ *val = (boolean_t)b;
+
+destruction:
scf_value_destroy(value);
scf_property_destroy(scf_prop);
- return (0);
+ return (rc);
}
-/* Check if in the case of failure the original value of *val is preserved */
static int
get_val_int(idmap_cfg_handles_t *handles, const char *name,
void *val, scf_type_t type)
@@ -161,12 +250,8 @@ get_val_int(idmap_cfg_handles_t *handles, const char *name,
scf_property_t *scf_prop;
scf_value_t *value;
- uint8_t b;
switch (type) {
- case SCF_TYPE_BOOLEAN:
- *(boolean_t *)val = B_FALSE;
- break;
case SCF_TYPE_COUNT:
*(uint64_t *)val = 0;
break;
@@ -203,10 +288,6 @@ get_val_int(idmap_cfg_handles_t *handles, const char *name,
goto destruction;
switch (type) {
- case SCF_TYPE_BOOLEAN:
- rc = scf_value_get_boolean(value, &b);
- *(boolean_t *)val = b;
- break;
case SCF_TYPE_COUNT:
rc = scf_value_get_count(value, val);
break;
@@ -426,7 +507,10 @@ destruction:
static int
-del_val(idmap_cfg_handles_t *handles, const char *name)
+del_val(
+ idmap_cfg_handles_t *handles,
+ scf_propertygroup_t *pg,
+ const char *name)
{
int rc = -1;
int ret;
@@ -447,13 +531,13 @@ del_val(idmap_cfg_handles_t *handles, const char *name)
}
do {
- if (scf_pg_update(handles->config_pg) == -1) {
+ if (scf_pg_update(pg) == -1) {
idmapdlog(LOG_ERR,
"scf_pg_update(%s) failed: %s",
name, scf_strerror(scf_error()));
goto destruction;
}
- if (scf_transaction_start(tx, handles->config_pg) != 0) {
+ if (scf_transaction_start(tx, pg) != 0) {
idmapdlog(LOG_ERR,
"scf_transaction_start(%s) failed: %s",
name, scf_strerror(scf_error()));
@@ -496,18 +580,19 @@ destruction:
static int
-set_val_astring(idmap_cfg_handles_t *handles, const char *name, const char *val)
+set_val(
+ idmap_cfg_handles_t *handles,
+ scf_propertygroup_t *pg,
+ const char *name,
+ scf_value_t *value)
{
int rc = -1;
- int ret = -2;
int i;
- scf_property_t *scf_prop = NULL;
- scf_value_t *value = NULL;
+ scf_property_t *prop = NULL;
scf_transaction_t *tx = NULL;
scf_transaction_entry_t *ent = NULL;
- if ((scf_prop = scf_property_create(handles->main)) == NULL ||
- (value = scf_value_create(handles->main)) == NULL ||
+ if ((prop = scf_property_create(handles->main)) == NULL ||
(tx = scf_transaction_create(handles->main)) == NULL ||
(ent = scf_entry_create(handles->main)) == NULL) {
idmapdlog(LOG_ERR, "Unable to set property %s",
@@ -515,26 +600,45 @@ set_val_astring(idmap_cfg_handles_t *handles, const char *name, const char *val)
goto destruction;
}
- for (i = 0; i < MAX_TRIES && (ret == -2 || ret == 0); i++) {
- if (scf_transaction_start(tx, handles->config_pg) == -1) {
+ for (i = 0; i < MAX_TRIES; i++) {
+ int ret;
+
+ if (scf_pg_update(pg) == -1) {
idmapdlog(LOG_ERR,
- "scf_transaction_start(%s) failed: %s",
- name, scf_strerror(scf_error()));
+ "scf_pg_update() failed: %s",
+ scf_strerror(scf_error()));
goto destruction;
}
- if (scf_transaction_property_new(tx, ent, name,
- SCF_TYPE_ASTRING) < 0) {
+ if (scf_transaction_start(tx, pg) == -1) {
idmapdlog(LOG_ERR,
- "scf_transaction_property_new() failed: %s",
- scf_strerror(scf_error()));
+ "scf_transaction_start(%s) failed: %s",
+ name, scf_strerror(scf_error()));
goto destruction;
}
- if (scf_value_set_astring(value, val) == -1) {
+ ret = scf_pg_get_property(pg, name, prop);
+ if (ret == SCF_SUCCESS) {
+ if (scf_transaction_property_change_type(tx, ent, name,
+ scf_value_type(value)) < 0) {
+ idmapdlog(LOG_ERR,
+ "scf_transaction_property_change_type(%s)"
+ " failed: %s",
+ name, scf_strerror(scf_error()));
+ goto destruction;
+ }
+ } else if (scf_error() == SCF_ERROR_NOT_FOUND) {
+ if (scf_transaction_property_new(tx, ent, name,
+ scf_value_type(value)) < 0) {
+ idmapdlog(LOG_ERR,
+ "scf_transaction_property_new() failed: %s",
+ scf_strerror(scf_error()));
+ goto destruction;
+ }
+ } else {
idmapdlog(LOG_ERR,
- "scf_value_set_astring() failed: %s",
- scf_strerror(scf_error()));
+ "scf_pg_get_property(%s) failed: %s",
+ name, scf_strerror(scf_error()));
goto destruction;
}
@@ -545,41 +649,90 @@ set_val_astring(idmap_cfg_handles_t *handles, const char *name, const char *val)
goto destruction;
}
- if ((ret = scf_transaction_commit(tx)) == 1)
- break;
-
- if (ret == 0 && i < MAX_TRIES - 1) {
+ ret = scf_transaction_commit(tx);
+ if (ret == 0) {
/*
* Property group set in scf_transaction_start()
* is not the most recent. Update pg, reset tx and
* retry tx.
*/
idmapdlog(LOG_WARNING,
- "scf_transaction_commit(%s) failed - Retry: %s",
+ "scf_transaction_commit(%s) failed: %s",
name, scf_strerror(scf_error()));
- if (scf_pg_update(handles->config_pg) == -1) {
- idmapdlog(LOG_ERR,
- "scf_pg_update() failed: %s",
- scf_strerror(scf_error()));
- goto destruction;
- }
scf_transaction_reset(tx);
+ continue;
+ }
+ if (ret != 1) {
+ idmapdlog(LOG_ERR,
+ "scf_transaction_commit(%s) failed: %s",
+ name, scf_strerror(scf_error()));
+ goto destruction;
}
+ /* Success! */
+ rc = 0;
+ break;
}
+destruction:
+ scf_entry_destroy(ent);
+ scf_transaction_destroy(tx);
+ scf_property_destroy(prop);
+ return (rc);
+}
- if (ret == 1)
- rc = 0;
- else if (ret != -2)
- idmapdlog(LOG_ERR,
- "scf_transaction_commit(%s) failed: %s",
+static int
+set_val_integer(
+ idmap_cfg_handles_t *handles,
+ scf_propertygroup_t *pg,
+ const char *name,
+ int64_t val)
+{
+ scf_value_t *value = NULL;
+ int rc;
+
+ if ((value = scf_value_create(handles->main)) == NULL) {
+ idmapdlog(LOG_ERR, "Unable to set property %s",
name, scf_strerror(scf_error()));
+ return (-1);
+ }
+
+ scf_value_set_integer(value, val);
+
+ rc = set_val(handles, pg, name, value);
-destruction:
scf_value_destroy(value);
- scf_entry_destroy(ent);
- scf_transaction_destroy(tx);
- scf_property_destroy(scf_prop);
+
+ return (rc);
+}
+
+
+static int
+set_val_astring(
+ idmap_cfg_handles_t *handles,
+ scf_propertygroup_t *pg,
+ const char *name,
+ const char *val)
+{
+ scf_value_t *value = NULL;
+ int rc = -1;
+
+ if ((value = scf_value_create(handles->main)) == NULL) {
+ idmapdlog(LOG_ERR, "Unable to set property %s",
+ name, scf_strerror(scf_error()));
+ goto out;
+ }
+
+ if (scf_value_set_astring(value, val) == -1) {
+ idmapdlog(LOG_ERR,
+ "scf_value_set_astring() failed: %s",
+ scf_strerror(scf_error()));
+ goto out;
+ }
+
+ rc = set_val(handles, pg, name, value);
+
+out:
+ scf_value_destroy(value);
return (rc);
}
@@ -595,12 +748,15 @@ update_bool(boolean_t *value, boolean_t *new, char *name)
if (*value == *new)
return (0);
- idmapdlog(LOG_INFO, "change %s=%s", name, *new ? "true" : "false");
+ if (DBG(CONFIG, 1)) {
+ idmapdlog(LOG_INFO, "change %s=%s", name,
+ *new ? "true" : "false");
+ }
+
*value = *new;
return (1);
}
-
/*
* This function updates a string value.
* If nothing has changed it returns 0 else 1
@@ -608,21 +764,29 @@ update_bool(boolean_t *value, boolean_t *new, char *name)
static int
update_string(char **value, char **new, char *name)
{
- if (*new == NULL)
- return (0);
+ int changed;
+
+ if (*new == NULL && *value != NULL)
+ changed = 1;
+ else if (*new != NULL && *value == NULL)
+ changed = 1;
+ else if (*new != NULL && *value != NULL && strcmp(*new, *value) != 0)
+ changed = 1;
+ else
+ changed = 0;
- if (*value != NULL && strcmp(*new, *value) == 0) {
- free(*new);
- *new = NULL;
- return (0);
- }
+ /*
+ * Note that even if unchanged we can't just return; we must free one
+ * of the values.
+ */
- idmapdlog(LOG_INFO, "change %s=%s", name, CHECK_NULL(*new));
- if (*value != NULL)
- free(*value);
+ if (DBG(CONFIG, 1) && changed)
+ idmapdlog(LOG_INFO, "change %s=%s", name, CHECK_NULL(*new));
+
+ free(*value);
*value = *new;
*new = NULL;
- return (1);
+ return (changed);
}
static int
@@ -631,7 +795,10 @@ update_enum(int *value, int *new, char *name, struct enum_lookup_map *map)
if (*value == *new)
return (0);
- idmapdlog(LOG_INFO, "change %s=%s", name, enum_lookup(*new, map));
+ if (DBG(CONFIG, 1)) {
+ idmapdlog(LOG_INFO, "change %s=%s", name,
+ enum_lookup(*new, map));
+ }
*value = *new;
@@ -666,14 +833,18 @@ update_dirs(idmap_ad_disc_ds_t **value, idmap_ad_disc_ds_t **new, char *name)
if (*value == NULL) {
/* We're unsetting this DS property */
- idmapdlog(LOG_INFO, "change %s=<none>", name);
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_INFO, "change %s=<none>", name);
return (1);
}
- /* List all the new DSs */
- for (i = 0; (*value)[i].host[0] != '\0'; i++)
- idmapdlog(LOG_INFO, "change %s=%s port=%d", name,
- (*value)[i].host, (*value)[i].port);
+ if (DBG(CONFIG, 1)) {
+ /* List all the new DSs */
+ for (i = 0; (*value)[i].host[0] != '\0'; i++) {
+ idmapdlog(LOG_INFO, "change %s=%s port=%d", name,
+ (*value)[i].host, (*value)[i].port);
+ }
+ }
return (1);
}
@@ -706,15 +877,19 @@ update_trusted_domains(ad_disc_trusteddomains_t **value,
if (*value == NULL) {
/* We're unsetting this DS property */
- idmapdlog(LOG_INFO, "change %s=<none>", name);
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_INFO, "change %s=<none>", name);
return (1);
}
- /* List all the new domains */
- for (i = 0; (*value)[i].domain[0] != '\0'; i++)
- idmapdlog(LOG_INFO, "change %s=%s direction=%s", name,
- (*value)[i].domain,
- (*value)[i].direction == 3 ? "bi-directional" : "inbound");
+ if (DBG(CONFIG, 1)) {
+ /* List all the new domains */
+ for (i = 0; (*value)[i].domain[0] != '\0'; i++) {
+ idmapdlog(LOG_INFO, "change %s=%s direction=%s", name,
+ (*value)[i].domain,
+ enum_lookup((*value)[i].direction, trust_dir_map));
+ }
+ }
return (1);
}
@@ -748,14 +923,18 @@ update_domains_in_forest(ad_disc_domainsinforest_t **value,
if (*value == NULL) {
/* We're unsetting this DS property */
- idmapdlog(LOG_INFO, "change %s=<none>", name);
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_INFO, "change %s=<none>", name);
return (1);
}
- /* List all the new domains */
- for (i = 0; (*value)[i].domain[0] != '\0'; i++)
- idmapdlog(LOG_INFO, "change %s=%s", name,
- (*value)[i].domain);
+ if (DBG(CONFIG, 1)) {
+ /* List all the new domains */
+ for (i = 0; (*value)[i].domain[0] != '\0'; i++) {
+ idmapdlog(LOG_INFO, "change %s=%s", name,
+ (*value)[i].domain);
+ }
+ }
return (1);
}
@@ -865,26 +1044,36 @@ not_equal:
if (*value == NULL) {
/* We're unsetting this DS property */
- idmapdlog(LOG_INFO, "change %s=<none>", name);
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_INFO, "change %s=<none>", name);
return (1);
}
- /* List all the trusted forests */
- for (i = 0; i < *num_value; i++) {
- for (j = 0; (*value)[i].domains_in_forest[j].domain[0] != '\0';
- j++) {
- /* List trusted Domains in the forest. */
- if ((*value)[i].domains_in_forest[j].trusted)
- idmapdlog(LOG_INFO, "change %s=%s domain=%s",
- name, (*value)[i].forest_name,
- (*value)[i].domains_in_forest[j].domain);
+ if (DBG(CONFIG, 1)) {
+ /* List all the trusted forests */
+ for (i = 0; i < *num_value; i++) {
+ idmap_trustedforest_t *f = &(*value)[i];
+ for (j = 0;
+ f->domains_in_forest[j].domain[0] != '\0';
+ j++) {
+ /* List trusted Domains in the forest. */
+ if (f->domains_in_forest[j].trusted)
+ idmapdlog(LOG_INFO,
+ "change %s=%s domain=%s",
+ name, f->forest_name,
+ f->domains_in_forest[j].domain);
+ }
+ /* List the hosts */
+ for (j = 0;
+ f->global_catalog[j].host[0] != '\0';
+ j++) {
+ idmapdlog(LOG_INFO,
+ "change %s=%s host=%s port=%d",
+ name, f->forest_name,
+ f->global_catalog[j].host,
+ f->global_catalog[j].port);
+ }
}
- /* List the hosts */
- for (j = 0; (*value)[i].global_catalog[j].host[0] != '\0'; j++)
- idmapdlog(LOG_INFO, "change %s=%s host=%s port=%d",
- name, (*value)[i].forest_name,
- (*value)[i].global_catalog[j].host,
- (*value)[i].global_catalog[j].port);
}
return (1);
}
@@ -950,7 +1139,7 @@ wait_for_event(struct timespec *timeoutp)
{
port_event_t pe;
- memset(&pe, 0, sizeof (pe));
+ (void) memset(&pe, 0, sizeof (pe));
if (port_get(idmapd_ev_port, &pe, timeoutp) != 0) {
switch (errno) {
case EINTR:
@@ -1004,12 +1193,16 @@ wait_for_event(struct timespec *timeoutp)
* timeout if need be.
*/
if (pfroute_event_is_interesting(rt_sock)) {
- idmapdlog(LOG_DEBUG,
- "Interesting routing event");
+ if (DBG(CONFIG, 1)) {
+ idmapdlog(LOG_DEBUG,
+ "Interesting routing event");
+ }
return (EVENT_ROUTING);
} else {
- idmapdlog(LOG_DEBUG,
- "Boring routing event");
+ if (DBG(CONFIG, 2)) {
+ idmapdlog(LOG_DEBUG,
+ "Boring routing event");
+ }
return (EVENT_NOTHING);
}
}
@@ -1023,6 +1216,7 @@ wait_for_event(struct timespec *timeoutp)
void *
idmap_cfg_update_thread(void *arg)
{
+ NOTE(ARGUNUSED(arg))
const ad_disc_t ad_ctx = _idmapdstate.cfg->handles.ad_ctx;
@@ -1062,10 +1256,12 @@ idmap_cfg_update_thread(void *arg)
switch (wait_for_event(timeoutp)) {
case EVENT_NOTHING:
- idmapdlog(LOG_DEBUG, "Boring event.");
+ if (DBG(CONFIG, 2))
+ idmapdlog(LOG_DEBUG, "Boring event.");
continue;
case EVENT_REFRESH:
- idmapdlog(LOG_INFO, "SMF refresh");
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_INFO, "SMF refresh");
/*
* Blow away the ccache, we might have
* re-joined the domain or joined a new one
@@ -1073,11 +1269,14 @@ idmap_cfg_update_thread(void *arg)
(void) unlink(IDMAP_CACHEDIR "/ccache");
break;
case EVENT_DEGRADE:
- idmapdlog(LOG_DEBUG,
- "Service degraded");
+ if (DBG(CONFIG, 1)) {
+ idmapdlog(LOG_DEBUG,
+ "Service degraded");
+ }
break;
case EVENT_TIMEOUT:
- idmapdlog(LOG_DEBUG, "TTL expired");
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_DEBUG, "TTL expired");
break;
case EVENT_ROUTING:
/* Already logged to DEBUG */
@@ -1157,29 +1356,40 @@ valid_ldap_attr(const char *attr) {
}
static
-int
-check_smf_debug_mode(idmap_cfg_handles_t *handles)
+void
+idmapd_set_debug(
+ idmap_cfg_handles_t *handles,
+ enum idmapd_debug item,
+ const char *name)
{
- boolean_t new_debug_mode;
- int rc;
+ int val;
- rc = prop_exists(handles, "debug", &new_debug_mode);
- if (rc != 0)
- return (rc);
+ if (item < 0 || item > IDMAPD_DEBUG_MAX)
+ return;
- if (_idmapdstate.debug_mode != new_debug_mode) {
- if (!_idmapdstate.debug_mode) {
- _idmapdstate.debug_mode = new_debug_mode;
- idmap_log_stderr(LOG_DEBUG);
- idmapdlog(LOG_DEBUG, "debug mode enabled");
- } else {
- idmapdlog(LOG_DEBUG, "debug mode disabled");
- idmap_log_stderr(-1);
- _idmapdstate.debug_mode = new_debug_mode;
- }
- }
+ val = get_debug(handles, name);
- return (0);
+ if (val != _idmapdstate.debug[item])
+ idmapdlog(LOG_DEBUG, "%s/%s = %d", DEBUG_PG, name, val);
+
+ _idmapdstate.debug[item] = val;
+}
+
+static
+void
+check_smf_debug_mode(idmap_cfg_handles_t *handles)
+{
+ idmapd_set_debug(handles, IDMAPD_DEBUG_ALL, "all");
+ idmapd_set_debug(handles, IDMAPD_DEBUG_CONFIG, "config");
+ idmapd_set_debug(handles, IDMAPD_DEBUG_MAPPING, "mapping");
+ idmapd_set_debug(handles, IDMAPD_DEBUG_DISC, "discovery");
+ idmapd_set_debug(handles, IDMAPD_DEBUG_DNS, "dns");
+ idmapd_set_debug(handles, IDMAPD_DEBUG_LDAP, "ldap");
+
+ adutils_set_debug(AD_DEBUG_ALL, _idmapdstate.debug[IDMAPD_DEBUG_ALL]);
+ adutils_set_debug(AD_DEBUG_DISC, _idmapdstate.debug[IDMAPD_DEBUG_DISC]);
+ adutils_set_debug(AD_DEBUG_DNS, _idmapdstate.debug[IDMAPD_DEBUG_DNS]);
+ adutils_set_debug(AD_DEBUG_LDAP, _idmapdstate.debug[IDMAPD_DEBUG_LDAP]);
}
/*
@@ -1206,18 +1416,26 @@ idmap_cfg_load_smf(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg,
return (-2);
}
- if (scf_pg_update(handles->general_pg) < 0) {
+ if (scf_pg_update(handles->debug_pg) < 0) {
idmapdlog(LOG_ERR, "scf_pg_update() failed: %s",
scf_strerror(scf_error()));
return (-2);
}
- rc = check_smf_debug_mode(handles);
+ check_smf_debug_mode(handles);
+
+ rc = get_val_bool(handles, "unresolvable_sid_mapping",
+ &pgcfg->eph_map_unres_sids, B_TRUE);
if (rc != 0)
(*errors)++;
- rc = get_val_int(handles, "unresolvable_sid_mapping",
- &pgcfg->eph_map_unres_sids, SCF_TYPE_BOOLEAN);
+ rc = get_val_bool(handles, "use_lsa",
+ &pgcfg->use_lsa, B_TRUE);
+ if (rc != 0)
+ (*errors)++;
+
+ rc = get_val_bool(handles, "disable_cross_forest_trusts",
+ &pgcfg->disable_cross_forest_trusts, B_TRUE);
if (rc != 0)
(*errors)++;
@@ -1249,6 +1467,11 @@ idmap_cfg_load_smf(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg,
if (rc != 0)
(*errors)++;
else {
+ if (pgcfg->domain_name != NULL &&
+ pgcfg->domain_name[0] == '\0') {
+ free(pgcfg->domain_name);
+ pgcfg->domain_name = NULL;
+ }
(void) ad_disc_set_DomainName(handles->ad_ctx,
pgcfg->domain_name);
pgcfg->domain_name_auto_disc = B_FALSE;
@@ -1276,8 +1499,8 @@ idmap_cfg_load_smf(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg,
/* If machine_sid not configured, generate one */
if (generate_machine_sid(&pgcfg->machine_sid) < 0)
return (-2);
- rc = set_val_astring(handles, "machine_sid",
- pgcfg->machine_sid);
+ rc = set_val_astring(handles, handles->config_pg,
+ "machine_sid", pgcfg->machine_sid);
if (rc != 0)
(*errors)++;
}
@@ -1368,19 +1591,19 @@ idmap_cfg_load_smf(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg,
}
+static
+void
+log_if_unable(const void *val, const char *what)
+{
+ if (val == NULL) {
+ idmapdlog(LOG_DEBUG, "unable to discover %s", what);
+ }
+}
-/*
- * This is the half of idmap_cfg_load() that auto-discovers values of
- * discoverable properties that weren't already set via SMF properties.
- *
- * idmap_cfg_discover() is called *after* idmap_cfg_load_smf(), so it
- * needs to be careful not to overwrite any properties set in SMF.
- */
static
void
-idmap_cfg_discover(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg)
+discover_trusted_domains(idmap_pg_config_t *pgcfg, ad_disc_t ad_ctx)
{
- ad_disc_t ad_ctx = handles->ad_ctx;
ad_disc_t trusted_ctx;
int i, j, k, l;
char *forestname;
@@ -1391,39 +1614,6 @@ idmap_cfg_discover(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg)
idmap_trustedforest_t *trustedforests;
ad_disc_domainsinforest_t *domainsinforest;
- idmapdlog(LOG_DEBUG, "Running discovery.");
-
- ad_disc_refresh(ad_ctx);
-
- if (pgcfg->default_domain == NULL)
- pgcfg->default_domain = ad_disc_get_DomainName(ad_ctx,
- NULL);
-
- if (pgcfg->domain_name == NULL)
- pgcfg->domain_name = ad_disc_get_DomainName(ad_ctx,
- &pgcfg->domain_name_auto_disc);
-
- if (pgcfg->domain_controller == NULL)
- pgcfg->domain_controller =
- ad_disc_get_DomainController(ad_ctx, AD_DISC_PREFER_SITE,
- &pgcfg->domain_controller_auto_disc);
-
- if (pgcfg->forest_name == NULL)
- pgcfg->forest_name = ad_disc_get_ForestName(ad_ctx,
- &pgcfg->forest_name_auto_disc);
-
- if (pgcfg->site_name == NULL)
- pgcfg->site_name = ad_disc_get_SiteName(ad_ctx,
- &pgcfg->site_name_auto_disc);
-
- if (pgcfg->global_catalog == NULL)
- pgcfg->global_catalog =
- ad_disc_get_GlobalCatalog(ad_ctx, AD_DISC_PREFER_SITE,
- &pgcfg->global_catalog_auto_disc);
-
- pgcfg->domains_in_forest =
- ad_disc_get_DomainsInForest(ad_ctx, NULL);
-
pgcfg->trusted_domains =
ad_disc_get_TrustedDomains(ad_ctx, NULL);
@@ -1444,14 +1634,17 @@ idmap_cfg_discover(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg)
for (i = 0; pgcfg->trusted_domains[i].domain[0] != '\0'; i++) {
trusteddomain = pgcfg->trusted_domains[i].domain;
trusted_ctx = ad_disc_init();
- ad_disc_set_DomainName(trusted_ctx,
+ (void) ad_disc_set_DomainName(trusted_ctx,
trusteddomain);
forestname =
ad_disc_get_ForestName(trusted_ctx, NULL);
if (forestname == NULL) {
- idmapdlog(LOG_DEBUG, "unable to discover "
- "Forest Name for the trusted domain %s",
- trusteddomain);
+ if (DBG(CONFIG, 1)) {
+ idmapdlog(LOG_DEBUG,
+ "unable to discover Forest Name"
+ " for the trusted domain %s",
+ trusteddomain);
+ }
ad_disc_fini(trusted_ctx);
continue;
}
@@ -1501,10 +1694,12 @@ idmap_cfg_discover(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg)
ad_disc_get_GlobalCatalog(trusted_ctx,
AD_DISC_PREFER_SITE, NULL);
if (globalcatalog == NULL) {
- idmapdlog(LOG_DEBUG,
- "unable to discover Global "
- "Catalog for the trusted domain %s",
- trusteddomain);
+ if (DBG(CONFIG, 1)) {
+ idmapdlog(LOG_DEBUG,
+ "unable to discover Global Catalog"
+ " for the trusted domain %s",
+ trusteddomain);
+ }
free(forestname);
ad_disc_fini(trusted_ctx);
continue;
@@ -1513,10 +1708,12 @@ idmap_cfg_discover(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg)
ad_disc_get_DomainsInForest(trusted_ctx,
NULL);
if (domainsinforest == NULL) {
- idmapdlog(LOG_DEBUG,
- "unable to discover Domains in the Forest "
- "for the trusted domain %s",
- trusteddomain);
+ if (DBG(CONFIG, 1)) {
+ idmapdlog(LOG_DEBUG,
+ "unable to discover Domains in the"
+ " Forest for the trusted domain %s",
+ trusteddomain);
+ }
free(globalcatalog);
free(forestname);
ad_disc_fini(trusted_ctx);
@@ -1545,25 +1742,75 @@ idmap_cfg_discover(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg)
free(trustedforests);
}
}
+}
- if (pgcfg->domain_name == NULL)
- idmapdlog(LOG_DEBUG, "unable to discover Domain Name");
- if (pgcfg->domain_controller == NULL)
- idmapdlog(LOG_DEBUG, "unable to discover Domain Controller");
- if (pgcfg->forest_name == NULL)
- idmapdlog(LOG_DEBUG, "unable to discover Forest Name");
- if (pgcfg->site_name == NULL)
- idmapdlog(LOG_DEBUG, "unable to discover Site Name");
- if (pgcfg->global_catalog == NULL)
- idmapdlog(LOG_DEBUG, "unable to discover Global Catalog");
- if (pgcfg->domains_in_forest == NULL)
- idmapdlog(LOG_DEBUG,
- "unable to discover Domains in the Forest");
- if (pgcfg->trusted_domains == NULL)
- idmapdlog(LOG_DEBUG, "unable to discover Trusted Domains");
+/*
+ * This is the half of idmap_cfg_load() that auto-discovers values of
+ * discoverable properties that weren't already set via SMF properties.
+ *
+ * idmap_cfg_discover() is called *after* idmap_cfg_load_smf(), so it
+ * needs to be careful not to overwrite any properties set in SMF.
+ */
+static
+void
+idmap_cfg_discover(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg)
+{
+ ad_disc_t ad_ctx = handles->ad_ctx;
+
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_DEBUG, "Running discovery.");
+
+ ad_disc_refresh(ad_ctx);
+
+ if (pgcfg->domain_name == NULL) {
+ idmapdlog(LOG_DEBUG, "No domain name specified.");
+ } else {
+ if (pgcfg->domain_controller == NULL)
+ pgcfg->domain_controller =
+ ad_disc_get_DomainController(ad_ctx,
+ AD_DISC_PREFER_SITE,
+ &pgcfg->domain_controller_auto_disc);
+
+ if (pgcfg->forest_name == NULL)
+ pgcfg->forest_name = ad_disc_get_ForestName(ad_ctx,
+ &pgcfg->forest_name_auto_disc);
+
+ if (pgcfg->site_name == NULL)
+ pgcfg->site_name = ad_disc_get_SiteName(ad_ctx,
+ &pgcfg->site_name_auto_disc);
+
+ if (pgcfg->global_catalog == NULL)
+ pgcfg->global_catalog =
+ ad_disc_get_GlobalCatalog(ad_ctx,
+ AD_DISC_PREFER_SITE,
+ &pgcfg->global_catalog_auto_disc);
+
+ pgcfg->domains_in_forest =
+ ad_disc_get_DomainsInForest(ad_ctx, NULL);
+
+ if (!pgcfg->disable_cross_forest_trusts)
+ discover_trusted_domains(pgcfg, ad_ctx);
+
+ if (DBG(CONFIG, 1)) {
+ log_if_unable(pgcfg->domain_name, "Domain Name");
+ log_if_unable(pgcfg->domain_controller,
+ "Domain Controller");
+ log_if_unable(pgcfg->forest_name, "Forest Name");
+ log_if_unable(pgcfg->site_name, "Site Name");
+ log_if_unable(pgcfg->global_catalog, "Global Catalog");
+ log_if_unable(pgcfg->domains_in_forest,
+ "Domains in the Forest");
+ if (!pgcfg->disable_cross_forest_trusts) {
+ log_if_unable(pgcfg->trusted_domains,
+ "Trusted Domains");
+ }
+ }
+ }
ad_disc_done(ad_ctx);
- idmapdlog(LOG_DEBUG, "Discovery done.");
+
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_DEBUG, "Discovery done.");
}
@@ -1574,18 +1821,16 @@ idmap_cfg_discover(idmap_cfg_handles_t *handles, idmap_pg_config_t *pgcfg)
* reads from SMF, but you still have to refresh the service after
* changing the config pg in order for the changes to take effect.
*
- * There are two flags:
+ * There is one flag:
*
* - CFG_DISCOVER
- * - CFG_LOG
*
* If CFG_DISCOVER is set then idmap_cfg_load() calls
* idmap_cfg_discover() to discover, via DNS and LDAP lookups, property
* values that weren't set in SMF.
*
- * If CFG_LOG is set then idmap_cfg_load() will log (to LOG_NOTICE)
- * whether the configuration changed. This should be used only from the
- * refresh method.
+ * idmap_cfg_load() will log (to LOG_NOTICE) whether the configuration
+ * changed.
*
* Return values: 0 -> success, -1 -> failure, -2 -> hard failures
* reading from SMF.
@@ -1599,10 +1844,13 @@ idmap_cfg_load(idmap_cfg_t *cfg, int flags)
int ad_reload_required = 0;
idmap_pg_config_t new_pgcfg, *live_pgcfg;
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_DEBUG, "Loading configuration.");
+
live_pgcfg = &cfg->pgcfg;
(void) memset(&new_pgcfg, 0, sizeof (new_pgcfg));
- pthread_mutex_lock(&cfg->handles.mutex);
+ (void) pthread_mutex_lock(&cfg->handles.mutex);
if ((rc = idmap_cfg_load_smf(&cfg->handles, &new_pgcfg, &errors)) < -1)
goto err;
@@ -1612,8 +1860,10 @@ idmap_cfg_load(idmap_cfg_t *cfg, int flags)
WRLOCK_CONFIG();
if (live_pgcfg->list_size_limit != new_pgcfg.list_size_limit) {
- idmapdlog(LOG_INFO, "change list_size=%d",
- new_pgcfg.list_size_limit);
+ if (DBG(CONFIG, 1)) {
+ idmapdlog(LOG_INFO, "change list_size=%d",
+ new_pgcfg.list_size_limit);
+ }
live_pgcfg->list_size_limit = new_pgcfg.list_size_limit;
}
@@ -1624,6 +1874,13 @@ idmap_cfg_load(idmap_cfg_t *cfg, int flags)
changed += update_bool(&live_pgcfg->eph_map_unres_sids,
&new_pgcfg.eph_map_unres_sids, "unresolvable_sid_mapping");
+ changed += update_bool(&live_pgcfg->use_lsa,
+ &new_pgcfg.use_lsa, "use_lsa");
+
+ changed += update_bool(&live_pgcfg->disable_cross_forest_trusts,
+ &new_pgcfg.disable_cross_forest_trusts,
+ "disable_cross_forest_trusts");
+
changed += update_enum(&live_pgcfg->directory_based_mapping,
&new_pgcfg.directory_based_mapping, "directory_based_mapping",
directory_mapping_map);
@@ -1695,20 +1952,17 @@ idmap_cfg_load(idmap_cfg_t *cfg, int flags)
idmap_cfg_unload(&new_pgcfg);
- if (flags & CFG_LOG) {
- /*
- * If the config changes as a result of a refresh of the
- * service, then logging about it can provide useful
- * feedback to the sysadmin.
- */
- idmapdlog(LOG_NOTICE, "Configuration %schanged",
- changed ? "" : "un");
+ if (DBG(CONFIG, 1)) {
+ if (changed)
+ idmapdlog(LOG_NOTICE, "Configuration changed");
+ else
+ idmapdlog(LOG_NOTICE, "Configuration unchanged");
}
UNLOCK_CONFIG();
err:
- pthread_mutex_unlock(&cfg->handles.mutex);
+ (void) pthread_mutex_unlock(&cfg->handles.mutex);
if (rc < -1)
return (rc);
@@ -1749,7 +2003,7 @@ idmap_cfg_init()
if (!(handles->service = scf_service_create(handles->main)) ||
!(handles->instance = scf_instance_create(handles->main)) ||
!(handles->config_pg = scf_pg_create(handles->main)) ||
- !(handles->general_pg = scf_pg_create(handles->main))) {
+ !(handles->debug_pg = scf_pg_create(handles->main))) {
idmapdlog(LOG_ERR, "scf handle creation failed: %s",
scf_strerror(scf_error()));
goto error;
@@ -1769,14 +2023,13 @@ idmap_cfg_init()
}
if (scf_service_get_pg(handles->service,
- GENERAL_PG, handles->general_pg) < 0) {
- idmapdlog(LOG_ERR, "scf_service_get_pg() failed: %s",
- scf_strerror(scf_error()));
+ DEBUG_PG, handles->debug_pg) < 0) {
+ idmapdlog(LOG_ERR, "Property group \"%s\": %s",
+ DEBUG_PG, scf_strerror(scf_error()));
goto error;
}
- if (check_smf_debug_mode(handles) != 0)
- goto error;
+ check_smf_debug_mode(handles);
/* Initialize AD Auto Discovery context */
handles->ad_ctx = ad_disc_init();
@@ -1852,7 +2105,8 @@ idmap_cfg_fini(idmap_cfg_t *cfg)
(void) pthread_mutex_destroy(&handles->mutex);
scf_pg_destroy(handles->config_pg);
- scf_pg_destroy(handles->general_pg);
+ if (handles->debug_pg != NULL)
+ scf_pg_destroy(handles->debug_pg);
scf_instance_destroy(handles->instance);
scf_service_destroy(handles->service);
scf_handle_destroy(handles->main);
@@ -1879,6 +2133,47 @@ idmap_cfg_hup_handler(int sig)
}
/*
+ * Upgrade the debug flags.
+ *
+ * We're replacing a single debug flag with a fine-grained mechanism that
+ * is also capable of considerably more verbosity. We'll take a stab at
+ * producing roughly the same level of output.
+ */
+static
+int
+upgrade_debug(idmap_cfg_handles_t *handles)
+{
+ boolean_t debug_present;
+ const char DEBUG_PROP[] = "debug";
+ int rc;
+
+ rc = prop_exists(handles, DEBUG_PROP, &debug_present);
+
+ if (rc != 0)
+ return (rc);
+
+ if (!debug_present)
+ return (0);
+
+ idmapdlog(LOG_INFO,
+ "Upgrading old %s/%s setting to %s/* settings.",
+ CONFIG_PG, DEBUG_PROP, DEBUG_PG);
+
+ rc = set_val_integer(handles, handles->debug_pg, "config", 1);
+ if (rc != 0)
+ return (rc);
+ rc = set_val_integer(handles, handles->debug_pg, "discovery", 1);
+ if (rc != 0)
+ return (rc);
+
+ rc = del_val(handles, handles->config_pg, DEBUG_PROP);
+ if (rc != 0)
+ return (rc);
+
+ return (0);
+}
+
+/*
* Upgrade the DS mapping flags.
*
* If the old ds_name_mapping_enabled flag is present, then
@@ -1908,8 +2203,8 @@ upgrade_directory_mapping(idmap_cfg_handles_t *handles)
return (0);
boolean_t legacy_ds_name_mapping_enabled;
- rc = get_val_int(handles, DS_NAME_MAPPING_ENABLED,
- &legacy_ds_name_mapping_enabled, SCF_TYPE_BOOLEAN);
+ rc = get_val_bool(handles, DS_NAME_MAPPING_ENABLED,
+ &legacy_ds_name_mapping_enabled, B_FALSE);
if (rc != 0)
return (rc);
@@ -1935,8 +2230,8 @@ upgrade_directory_mapping(idmap_cfg_handles_t *handles)
"to %s=%s.",
DS_NAME_MAPPING_ENABLED, legacy_bool_string,
DIRECTORY_BASED_MAPPING, legacy_mode);
- rc = set_val_astring(handles, DIRECTORY_BASED_MAPPING,
- legacy_mode);
+ rc = set_val_astring(handles, handles->config_pg,
+ DIRECTORY_BASED_MAPPING, legacy_mode);
if (rc != 0)
return (rc);
} else {
@@ -1962,7 +2257,7 @@ upgrade_directory_mapping(idmap_cfg_handles_t *handles)
free(directory_based_mapping);
}
- rc = del_val(handles, DS_NAME_MAPPING_ENABLED);
+ rc = del_val(handles, handles->config_pg, DS_NAME_MAPPING_ENABLED);
if (rc != 0)
return (rc);
@@ -1982,5 +2277,9 @@ idmap_cfg_upgrade(idmap_cfg_t *cfg)
if (rc != 0)
return (rc);
+ rc = upgrade_debug(&cfg->handles);
+ if (rc != 0)
+ return (rc);
+
return (0);
}
diff --git a/usr/src/cmd/idmap/idmapd/idmap_config.h b/usr/src/cmd/idmap/idmapd/idmap_config.h
index bdee366906..eb1c7ffb69 100644
--- a/usr/src/cmd/idmap/idmapd/idmap_config.h
+++ b/usr/src/cmd/idmap/idmapd/idmap_config.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _IDMAP_CONFIG_H
@@ -57,7 +56,7 @@ typedef struct idmap_cfg_handles {
scf_instance_t *instance;
scf_service_t *service;
scf_propertygroup_t *config_pg;
- scf_propertygroup_t *general_pg;
+ scf_propertygroup_t *debug_pg;
ad_disc_t ad_ctx;
} idmap_cfg_handles_t;
@@ -106,6 +105,8 @@ typedef struct idmap_pg_config {
char *nldap_winname_attr;
int directory_based_mapping; /* enum */
boolean_t eph_map_unres_sids;
+ boolean_t use_lsa;
+ boolean_t disable_cross_forest_trusts;
} idmap_pg_config_t;
typedef struct idmap_cfg {
diff --git a/usr/src/cmd/idmap/idmapd/idmap_lsa.c b/usr/src/cmd/idmap/idmapd/idmap_lsa.c
new file mode 100644
index 0000000000..256e8494d8
--- /dev/null
+++ b/usr/src/cmd/idmap/idmapd/idmap_lsa.c
@@ -0,0 +1,237 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * LSA lookups
+ */
+
+#include <stdio.h>
+#include <note.h>
+#include <assert.h>
+
+#include "idmapd.h"
+#include "libsmb.h"
+
+idmap_retcode
+idmap_lsa_xlate_sid_type(const lsa_account_t *acct, idmap_id_type *ret_type)
+{
+ switch (acct->a_sidtype) {
+ case SidTypeUser:
+ case SidTypeComputer:
+ case SidTypeDomain:
+ case SidTypeDeletedAccount:
+ case SidTypeUnknown:
+ case SidTypeLabel:
+ *ret_type = IDMAP_USID;
+ return (IDMAP_SUCCESS);
+ case SidTypeGroup:
+ case SidTypeAlias:
+ case SidTypeWellKnownGroup:
+ *ret_type = IDMAP_GSID;
+ return (IDMAP_SUCCESS);
+ case SidTypeNull:
+ case SidTypeInvalid:
+ default:
+ idmapdlog(LOG_WARNING,
+ "LSA lookup: bad type %d for %s@%s",
+ acct->a_sidtype, acct->a_name, acct->a_domain);
+ return (IDMAP_ERR_OTHER);
+ }
+ NOTE(NOTREACHED)
+}
+
+/* Given SID, look up name and type */
+idmap_retcode
+lookup_lsa_by_sid(
+ const char *sidprefix,
+ uint32_t rid,
+ char **ret_name,
+ char **ret_domain,
+ idmap_id_type *ret_type)
+{
+ lsa_account_t acct;
+ char sid[SMB_SID_STRSZ + 1];
+ idmap_retcode ret;
+ int rc;
+
+ (void) memset(&acct, 0, sizeof (acct));
+ *ret_name = NULL;
+ *ret_domain = NULL;
+
+ (void) snprintf(sid, sizeof (sid), "%s-%u", sidprefix, rid);
+
+ rc = smb_lookup_sid(sid, &acct);
+ if (rc != 0) {
+ idmapdlog(LOG_ERR, "Error: smb_lookup_sid failed.");
+ idmapdlog(LOG_ERR,
+ "Check SMB service (svc:/network/smb/server).");
+ idmapdlog(LOG_ERR,
+ "Check connectivity to Active Directory.");
+
+ ret = IDMAP_ERR_OTHER;
+ goto out;
+ }
+ if (acct.a_status == NT_STATUS_NONE_MAPPED) {
+ ret = IDMAP_ERR_NOTFOUND;
+ goto out;
+ }
+ if (acct.a_status != NT_STATUS_SUCCESS) {
+ idmapdlog(LOG_WARNING,
+ "Warning: smb_lookup_sid(%s) failed (0x%x)",
+ sid, acct.a_status);
+ /* Fail soft */
+ ret = IDMAP_ERR_NOTFOUND;
+ goto out;
+ }
+
+ ret = idmap_lsa_xlate_sid_type(&acct, ret_type);
+ if (ret != IDMAP_SUCCESS)
+ goto out;
+
+ *ret_name = strdup(acct.a_name);
+ if (*ret_name == NULL) {
+ ret = IDMAP_ERR_MEMORY;
+ goto out;
+ }
+
+ *ret_domain = strdup(acct.a_domain);
+ if (*ret_domain == NULL) {
+ ret = IDMAP_ERR_MEMORY;
+ goto out;
+ }
+
+ ret = IDMAP_SUCCESS;
+
+out:
+ if (ret != IDMAP_SUCCESS) {
+ free(*ret_name);
+ *ret_name = NULL;
+ free(*ret_domain);
+ *ret_domain = NULL;
+ }
+ return (ret);
+}
+
+/* Given name and optional domain, look up SID, type, and canonical name */
+idmap_retcode
+lookup_lsa_by_name(
+ const char *name,
+ const char *domain,
+ char **ret_sidprefix,
+ uint32_t *ret_rid,
+ char **ret_name,
+ char **ret_domain,
+ idmap_id_type *ret_type)
+{
+ lsa_account_t acct;
+ char *namedom = NULL;
+ idmap_retcode ret;
+ int rc;
+
+ (void) memset(&acct, 0, sizeof (acct));
+ *ret_sidprefix = NULL;
+ if (ret_name != NULL)
+ *ret_name = NULL;
+ if (ret_domain != NULL)
+ *ret_domain = NULL;
+
+ if (domain != NULL)
+ (void) asprintf(&namedom, "%s@%s", name, domain);
+ else
+ namedom = strdup(name);
+ if (namedom == NULL) {
+ ret = IDMAP_ERR_MEMORY;
+ goto out;
+ }
+
+ rc = smb_lookup_name(namedom, SidTypeUnknown, &acct);
+ if (rc != 0) {
+ idmapdlog(LOG_ERR, "Error: smb_lookup_name failed.");
+ idmapdlog(LOG_ERR,
+ "Check SMB service (svc:/network/smb/server).");
+ idmapdlog(LOG_ERR,
+ "Check connectivity to Active Directory.");
+ ret = IDMAP_ERR_OTHER;
+ goto out;
+ }
+ if (acct.a_status == NT_STATUS_NONE_MAPPED) {
+ ret = IDMAP_ERR_NOTFOUND;
+ goto out;
+ }
+ if (acct.a_status != NT_STATUS_SUCCESS) {
+ idmapdlog(LOG_WARNING,
+ "Warning: smb_lookup_name(%s) failed (0x%x)",
+ namedom, acct.a_status);
+ /* Fail soft */
+ ret = IDMAP_ERR_NOTFOUND;
+ goto out;
+ }
+
+ rc = smb_sid_splitstr(acct.a_sid, ret_rid);
+ assert(rc == 0);
+ *ret_sidprefix = strdup(acct.a_sid);
+ if (*ret_sidprefix == NULL) {
+ ret = IDMAP_ERR_MEMORY;
+ goto out;
+ }
+
+ ret = idmap_lsa_xlate_sid_type(&acct, ret_type);
+ if (ret != IDMAP_SUCCESS)
+ goto out;
+
+ if (ret_name != NULL) {
+ *ret_name = strdup(acct.a_name);
+ if (*ret_name == NULL) {
+ ret = IDMAP_ERR_MEMORY;
+ goto out;
+ }
+ }
+
+ if (ret_domain != NULL) {
+ *ret_domain = strdup(acct.a_domain);
+ if (*ret_domain == NULL) {
+ ret = IDMAP_ERR_MEMORY;
+ goto out;
+ }
+ }
+
+ ret = IDMAP_SUCCESS;
+
+out:
+ free(namedom);
+ if (ret != IDMAP_SUCCESS) {
+ if (ret_name != NULL) {
+ free(*ret_name);
+ *ret_name = NULL;
+ }
+ if (ret_domain != NULL) {
+ free(*ret_domain);
+ *ret_domain = NULL;
+ }
+ free(*ret_sidprefix);
+ *ret_sidprefix = NULL;
+ }
+ return (ret);
+}
diff --git a/usr/src/cmd/idmap/idmapd/idmap_lsa.h b/usr/src/cmd/idmap/idmapd/idmap_lsa.h
new file mode 100644
index 0000000000..5dae07a6ab
--- /dev/null
+++ b/usr/src/cmd/idmap/idmapd/idmap_lsa.h
@@ -0,0 +1,53 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef IDMAP_LSA_H
+#define IDMAP_LSA_H
+
+/*
+ * LSA lookups
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rpcsvc/idmap_prot.h>
+
+/* Given SID, look up name and type */
+idmap_retcode
+lookup_lsa_by_sid(const char *sidprefix, uint32_t rid, char **ret_name,
+ char **ret_domain, idmap_id_type *ret_type);
+
+/* Given name and optional domain, look up SID, type, and canonical name */
+idmap_retcode lookup_lsa_by_name(const char *name, const char *domain,
+ char **ret_sidprefix, uint32_t *ret_rid, char **ret_name,
+ char **ret_domain, idmap_id_type *ret_type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDMAP_LSA_H */
diff --git a/usr/src/cmd/idmap/idmapd/idmapd.c b/usr/src/cmd/idmap/idmapd/idmapd.c
index 5ea3292acd..828bfc6545 100644
--- a/usr/src/cmd/idmap/idmapd/idmapd.c
+++ b/usr/src/cmd/idmap/idmapd/idmapd.c
@@ -53,6 +53,9 @@
#include <sys/sid.h>
#include <sys/idmap.h>
#include <pthread.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <note.h>
static void term_handler(int);
static void init_idmapd();
@@ -63,31 +66,13 @@ idmapd_state_t _idmapdstate;
SVCXPRT *xprt = NULL;
static int dfd = -1; /* our door server fildes, for unregistration */
-static int degraded = 0; /* whether the FMRI has been marked degraded */
+static boolean_t degraded = B_FALSE;
static uint32_t num_threads = 0;
static pthread_key_t create_threads_key;
static uint32_t max_threads = 40;
-
-/*
- * The following structure determines where the log messages from idmapdlog()
- * go to. It can be stderr (idmapd -d) and/or the real idmapdlog (idmapd).
- *
- * logstate.max_pri is integer cutoff necessary to silence low-priority
- * messages to stderr. idmapdlog has its own means so there a boolean
- * logstate.write_idmapdlog is enough.
- *
- * logstate.degraded is a mode used by idmapd in its degraded state.
- */
-
-static struct {
- boolean_t write_syslog;
- int max_pri; /* Max priority written to stderr */
- boolean_t degraded;
-} logstate = {B_FALSE, LOG_DEBUG, B_FALSE};
-
/*
* Server door thread start routine.
*
@@ -193,16 +178,8 @@ term_handler(int sig)
static void
usr1_handler(int sig)
{
- boolean_t saved_debug_mode = _idmapdstate.debug_mode;
-
- _idmapdstate.debug_mode = B_TRUE;
- idmap_log_stderr(LOG_DEBUG);
-
+ NOTE(ARGUNUSED(sig))
print_idmapdstate();
-
- _idmapdstate.debug_mode = saved_debug_mode;
- idmap_log_stderr(_idmapdstate.daemon_mode ? -1 : LOG_DEBUG);
-
}
static int pipe_fd = -1;
@@ -274,7 +251,6 @@ main(int argc, char **argv)
struct rlimit rl;
_idmapdstate.daemon_mode = TRUE;
- _idmapdstate.debug_mode = FALSE;
while ((c = getopt(argc, argv, "d")) != -1) {
switch (c) {
case 'd':
@@ -293,8 +269,6 @@ main(int argc, char **argv)
idmap_set_logger(idmapdlog);
adutils_set_logger(idmapdlog);
- idmap_log_syslog(B_TRUE);
- idmap_log_stderr(_idmapdstate.daemon_mode ? -1 : LOG_DEBUG);
if (is_system_labeled() && getzoneid() != GLOBAL_ZONEID) {
idmapdlog(LOG_ERR,
@@ -373,7 +347,7 @@ init_idmapd()
* one.
*/
(void) unlink(IDMAP_CACHEDIR "/ccache");
- putenv("KRB5CCNAME=" IDMAP_CACHEDIR "/ccache");
+ (void) putenv("KRB5CCNAME=" IDMAP_CACHEDIR "/ccache");
if (sysinfo(SI_HOSTNAME, _idmapdstate.hostname,
sizeof (_idmapdstate.hostname)) == -1) {
@@ -433,7 +407,8 @@ init_idmapd()
_idmapdstate.limit_gid = _idmapdstate.next_gid + 8192;
}
- print_idmapdstate();
+ if (DBG(CONFIG, 1))
+ print_idmapdstate();
return;
@@ -445,7 +420,7 @@ errout:
static void
fini_idmapd()
{
- __idmap_unreg(dfd);
+ (void) __idmap_unreg(dfd);
fini_mapping_system();
if (xprt != NULL)
svc_destroy(xprt);
@@ -492,13 +467,10 @@ degrade_svc(int poke_discovery, const char *reason)
if (degraded)
return;
- idmapdlog(LOG_ERR, "Degraded operation (%s). If you are running an "
- "SMB server in workgroup mode, or if you're not running an SMB "
- "server, then you can ignore this message", reason);
+ idmapdlog(LOG_ERR, "Degraded operation (%s).", reason);
membar_producer();
- degraded = 1;
- idmap_log_degraded(B_TRUE);
+ degraded = B_TRUE;
if ((fmri = get_fmri()) != NULL)
(void) smf_degrade_instance(fmri, 0);
@@ -524,8 +496,7 @@ restore_svc(void)
(void) smf_restore_instance(fmri);
membar_producer();
- degraded = 0;
- idmap_log_degraded(B_FALSE);
+ degraded = B_FALSE;
idmapdlog(LOG_NOTICE, "Normal operation restored");
}
@@ -536,41 +507,152 @@ void
idmapdlog(int pri, const char *format, ...) {
va_list args;
- if (pri <= logstate.max_pri) {
- va_start(args, format);
- (void) vfprintf(stderr, format, args);
- (void) fprintf(stderr, "\n");
- va_end(args);
- }
+ va_start(args, format);
+ (void) vfprintf(stderr, format, args);
+ (void) fprintf(stderr, "\n");
+ va_end(args);
/*
* We don't want to fill up the logs with useless messages when
* we're degraded, but we still want to log.
*/
- if (logstate.degraded)
+ if (degraded)
pri = LOG_DEBUG;
- if (logstate.write_syslog) {
- va_start(args, format);
- vsyslog(pri, format, args);
- va_end(args);
- }
+ va_start(args, format);
+ vsyslog(pri, format, args);
+ va_end(args);
}
-void
-idmap_log_stderr(int pri)
+static void
+trace_str(nvlist_t *entry, char *n1, char *n2, char *str)
{
- logstate.max_pri = pri;
+ char name[IDMAP_TRACE_NAME_MAX+1]; /* Max used is only about 11 */
+
+ (void) strlcpy(name, n1, sizeof (name));
+ if (n2 != NULL)
+ (void) strlcat(name, n2, sizeof (name));
+
+ (void) nvlist_add_string(entry, name, str);
}
-void
-idmap_log_syslog(boolean_t what)
+static void
+trace_int(nvlist_t *entry, char *n1, char *n2, int64_t i)
{
- logstate.write_syslog = what;
+ char name[IDMAP_TRACE_NAME_MAX+1]; /* Max used is only about 11 */
+
+ (void) strlcpy(name, n1, sizeof (name));
+ if (n2 != NULL)
+ (void) strlcat(name, n2, sizeof (name));
+
+ (void) nvlist_add_int64(entry, name, i);
}
-void
-idmap_log_degraded(boolean_t what)
+static void
+trace_sid(nvlist_t *entry, char *n1, char *n2, idmap_sid *sid)
+{
+ char *str;
+
+ (void) asprintf(&str, "%s-%u", sid->prefix, sid->rid);
+ if (str == NULL)
+ return;
+
+ trace_str(entry, n1, n2, str);
+ free(str);
+}
+
+static void
+trace_id(nvlist_t *entry, char *fromto, idmap_id *id, char *name, char *domain)
+{
+ trace_int(entry, fromto, IDMAP_TRACE_TYPE, (int64_t)id->idtype);
+ if (IS_ID_SID(*id)) {
+ if (name != NULL) {
+ char *str;
+
+ (void) asprintf(&str, "%s%s%s", name,
+ domain == NULL ? "" : "@",
+ domain == NULL ? "" : domain);
+ if (str != NULL) {
+ trace_str(entry, fromto, IDMAP_TRACE_NAME, str);
+ free(str);
+ }
+ }
+ if (id->idmap_id_u.sid.prefix != NULL) {
+ trace_sid(entry, fromto, IDMAP_TRACE_SID,
+ &id->idmap_id_u.sid);
+ }
+ } else if (IS_ID_POSIX(*id)) {
+ if (name != NULL)
+ trace_str(entry, fromto, IDMAP_TRACE_NAME, name);
+ if (id->idmap_id_u.uid != IDMAP_SENTINEL_PID) {
+ trace_int(entry, fromto, IDMAP_TRACE_UNIXID,
+ (int64_t)id->idmap_id_u.uid);
+ }
+ }
+}
+
+/*
+ * Record a trace event. TRACE() has already decided whether or not
+ * tracing is required; what we do here is collect the data and send it
+ * to its destination - to the trace log in the response, if
+ * IDMAP_REQ_FLG_TRACE is set, and to the SMF service log, if debug/mapping
+ * is greater than zero.
+ */
+int
+trace(idmap_mapping *req, idmap_id_res *res, char *fmt, ...)
{
- logstate.degraded = what;
+ va_list va;
+ char *buf;
+ int err;
+ nvlist_t *entry;
+
+ assert(req != NULL);
+ assert(res != NULL);
+
+ err = nvlist_alloc(&entry, NV_UNIQUE_NAME, 0);
+ if (err != 0) {
+ (void) fprintf(stderr, "trace nvlist_alloc(entry): %s\n",
+ strerror(err));
+ return (0);
+ }
+
+ trace_id(entry, "from", &req->id1, req->id1name, req->id1domain);
+ trace_id(entry, "to", &res->id, req->id2name, req->id2domain);
+
+ if (IDMAP_ERROR(res->retcode)) {
+ trace_int(entry, IDMAP_TRACE_ERROR, NULL,
+ (int64_t)res->retcode);
+ }
+
+ va_start(va, fmt);
+ (void) vasprintf(&buf, fmt, va);
+ va_end(va);
+ if (buf != NULL) {
+ trace_str(entry, IDMAP_TRACE_MESSAGE, NULL, buf);
+ free(buf);
+ }
+
+ if (DBG(MAPPING, 1))
+ idmap_trace_print_1(stderr, "", entry);
+
+ if (req->flag & IDMAP_REQ_FLG_TRACE) {
+ /* Lazily allocate the trace list */
+ if (res->info.trace == NULL) {
+ err = nvlist_alloc(&res->info.trace, 0, 0);
+ if (err != 0) {
+ res->info.trace = NULL; /* just in case */
+ (void) fprintf(stderr,
+ "trace nvlist_alloc(trace): %s\n",
+ strerror(err));
+ nvlist_free(entry);
+ return (0);
+ }
+ }
+ (void) nvlist_add_nvlist(res->info.trace, "", entry);
+ /* Note that entry is copied, so we must still free our copy */
+ }
+
+ nvlist_free(entry);
+
+ return (0);
}
diff --git a/usr/src/cmd/idmap/idmapd/idmapd.h b/usr/src/cmd/idmap/idmapd/idmapd.h
index fe62e0468b..4e59ee49ae 100644
--- a/usr/src/cmd/idmap/idmapd/idmapd.h
+++ b/usr/src/cmd/idmap/idmapd/idmapd.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _IDMAPD_H
@@ -59,13 +58,41 @@ typedef enum idmap_namemap_mode {
} idmap_namemap_mode_t;
/*
+ * Debugging output.
+ *
+ * There are some number of areas - configuration, mapping, discovery, et
+ * cetera - and for each area there is a verbosity level controlled through
+ * an SMF property. The default is zero, and "debug/all" provides a master
+ * control allowing you to turn on all debugging output with one setting.
+ *
+ * A typical debugging output sequence would look like
+ *
+ * if (DBG(CONFIG, 2)) {
+ * idmapdlog(LOG_DEBUG,
+ * "some message about config at verbosity 2");
+ * }
+ */
+enum idmapd_debug {
+ IDMAPD_DEBUG_ALL = 0,
+ IDMAPD_DEBUG_CONFIG = 1,
+ IDMAPD_DEBUG_MAPPING = 2,
+ IDMAPD_DEBUG_DISC = 3,
+ IDMAPD_DEBUG_DNS = 4,
+ IDMAPD_DEBUG_LDAP = 5,
+ IDMAPD_DEBUG_MAX = 5
+};
+
+#define DBG(type, lev) \
+ (_idmapdstate.debug[IDMAPD_DEBUG_##type] >= (lev) || \
+ _idmapdstate.debug[IDMAPD_DEBUG_ALL] >= (lev))
+
+/*
* Global state of idmapd daemon.
*/
typedef struct idmapd_state {
rwlock_t rwlk_cfg; /* config lock */
idmap_cfg_t *cfg; /* config */
bool_t daemon_mode;
- bool_t debug_mode;
char hostname[MAX_NAME_LEN]; /* my hostname */
uid_t next_uid;
gid_t next_gid;
@@ -76,6 +103,7 @@ typedef struct idmapd_state {
adutils_ad_t **gcs;
int num_dcs;
adutils_ad_t **dcs;
+ int debug[IDMAPD_DEBUG_MAX+1];
} idmapd_state_t;
extern idmapd_state_t _idmapdstate;
@@ -207,30 +235,24 @@ typedef struct wksids_table {
#define IDMAP_DBNAME IDMAP_DBDIR "/idmap.db"
#define IDMAP_CACHENAME IDMAP_CACHEDIR "/idmap.db"
-#define IS_BATCH_SID(batch, i) \
- (batch.idmap_mapping_batch_val[i].id1.idtype == IDMAP_SID || \
- batch.idmap_mapping_batch_val[i].id1.idtype == IDMAP_USID || \
- batch.idmap_mapping_batch_val[i].id1.idtype == IDMAP_GSID)
-
-#define IS_BATCH_UID(batch, i) \
- (batch.idmap_mapping_batch_val[i].id1.idtype == IDMAP_UID)
-
-#define IS_BATCH_GID(batch, i) \
- (batch.idmap_mapping_batch_val[i].id1.idtype == IDMAP_GID)
+#define IS_ID_NONE(id) \
+ ((id).idtype == IDMAP_NONE)
#define IS_ID_SID(id) \
((id).idtype == IDMAP_SID || \
(id).idtype == IDMAP_USID || \
(id).idtype == IDMAP_GSID) \
-#define IS_REQUEST_SID(req, n) IS_ID_SID((req).id##n)
-
+#define IS_ID_UID(id) \
+ ((id).idtype == IDMAP_UID)
-#define IS_REQUEST_UID(request) \
- ((request).id1.idtype == IDMAP_UID)
+#define IS_ID_GID(id) \
+ ((id).idtype == IDMAP_GID)
-#define IS_REQUEST_GID(request) \
- ((request).id1.idtype == IDMAP_GID)
+#define IS_ID_POSIX(id) \
+ ((id).idtype == IDMAP_UID || \
+ (id).idtype == IDMAP_GID || \
+ (id).idtype == IDMAP_POSIXID) \
/*
* Local RID ranges
@@ -240,6 +262,32 @@ typedef struct wksids_table {
#define LOCALRID_GID_MIN (((uint32_t)INT32_MAX) + 1)
#define LOCALRID_GID_MAX UINT32_MAX
+/*
+ * Tracing.
+ *
+ * The tracing mechanism is intended to help the administrator understand
+ * why their mapping configuration is doing what it is. Each interesting
+ * decision point during the mapping process calls TRACE() with the current
+ * request and response and a printf-style message. The message, plus
+ * data from the request and the response, is logged to the service log
+ * (if debug/mapping is greater than zero) or reported to the caller
+ * (if IDMAP_REQ_FLG_TRACE was set in the request. The primary consumer
+ * is the "-V" option to "idmap show".
+ *
+ * TRACING(req) says whether tracing is appropriate for the request, and
+ * is used to determine and record whether any request in a batch requested
+ * tracing, to control whether later code loops over the batch to do tracing
+ * for any of the requests.
+ *
+ * TRACE(req, res, fmt, ...) generates a trace entry if appropriate.
+ */
+#define TRACING(req) \
+ (DBG(MAPPING, 1) || \
+ ((req)->flag & IDMAP_REQ_FLG_TRACE) != 0)
+#define TRACE(req, res, ...) \
+ ((void)(TRACING(req) && trace(req, res, __VA_ARGS__)))
+extern int trace(idmap_mapping *req, idmap_id_res *res, char *fmt, ...);
+
typedef idmap_retcode (*update_list_res_cb)(void *, const char **, uint64_t);
typedef int (*list_svc_cb)(void *, int, char **, char **);
@@ -251,7 +299,7 @@ extern void print_idmapdstate();
extern int create_directory(const char *, uid_t, gid_t);
extern int load_config();
extern void reload_ad();
-extern int idmap_init_tsd_key(void);
+extern void idmap_init_tsd_key(void);
extern void degrade_svc(int, const char *);
extern void restore_svc(void);
@@ -294,22 +342,19 @@ extern void cleanup_lookup_state(lookup_state_t *);
extern idmap_retcode ad_lookup_batch(lookup_state_t *,
idmap_mapping_batch *, idmap_ids_res *);
extern idmap_retcode lookup_name2sid(sqlite *, const char *, const char *,
- int *, char **, char **, char **,
- idmap_rid_t *, idmap_mapping *, int);
+ int, char **, char **, char **,
+ idmap_rid_t *, idmap_id_type *,
+ idmap_mapping *, int);
extern idmap_retcode lookup_wksids_name2sid(const char *, const char *,
char **, char **, char **, idmap_rid_t *,
- int *);
+ idmap_id_type *);
extern idmap_retcode idmap_cache_flush(idmap_flush_op);
-extern void idmap_log_stderr(int);
-extern void idmap_log_syslog(boolean_t);
-extern void idmap_log_degraded(boolean_t);
-
extern const wksids_table_t *find_wksid_by_pid(posix_id_t pid, int is_user);
extern const wksids_table_t *find_wksid_by_sid(const char *sid, int rid,
- int type);
+ idmap_id_type type);
extern const wksids_table_t *find_wksid_by_name(const char *name,
- const char *domain, int type);
+ const char *domain, idmap_id_type type);
extern const wksids_table_t *find_wk_by_sid(char *sid);
#ifdef __cplusplus
diff --git a/usr/src/cmd/idmap/idmapd/init.c b/usr/src/cmd/idmap/idmapd/init.c
index c661ede558..43c18b6293 100644
--- a/usr/src/cmd/idmap/idmapd/init.c
+++ b/usr/src/cmd/idmap/idmapd/init.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -100,7 +99,8 @@ load_config()
return (rc);
}
- idmapdlog(LOG_DEBUG, "Initial configuration loaded");
+ if (DBG(CONFIG, 1))
+ idmapdlog(LOG_DEBUG, "Initial configuration loaded");
return (0);
}
@@ -111,14 +111,21 @@ reload_gcs()
{
int i, j;
adutils_ad_t **new_gcs;
- adutils_ad_t **old_gcs;
+ adutils_ad_t **old_gcs = _idmapdstate.gcs;
int new_num_gcs;
- int old_num_gcs;
+ int old_num_gcs = _idmapdstate.num_gcs;
idmap_pg_config_t *pgcfg = &_idmapdstate.cfg->pgcfg;
idmap_trustedforest_t *trustfor = pgcfg->trusted_forests;
int num_trustfor = pgcfg->num_trusted_forests;
ad_disc_domainsinforest_t *domain_in_forest;
+ if (pgcfg->domain_name == NULL) {
+ /* No domain name specified - workgroup mode. */
+ new_gcs = NULL;
+ new_num_gcs = 0;
+ goto out;
+ }
+
if (pgcfg->global_catalog == NULL ||
pgcfg->global_catalog[0].host[0] == '\0') {
/*
@@ -132,9 +139,6 @@ reload_gcs()
return;
}
- old_gcs = _idmapdstate.gcs;
- old_num_gcs = _idmapdstate.num_gcs;
-
new_num_gcs = 1 + num_trustfor;
new_gcs = calloc(new_num_gcs, sizeof (adutils_ad_t *));
if (new_gcs == NULL) {
@@ -220,7 +224,6 @@ out:
_idmapdstate.gcs = new_gcs;
_idmapdstate.num_gcs = new_num_gcs;
-
if (old_gcs != NULL) {
for (i = 0; i < old_num_gcs; i++)
adutils_ad_free(&old_gcs[i]);
@@ -240,11 +243,18 @@ reload_dcs(void)
{
int i;
adutils_ad_t **new_dcs;
- adutils_ad_t **old_dcs;
+ adutils_ad_t **old_dcs = _idmapdstate.dcs;
int new_num_dcs;
- int old_num_dcs;
+ int old_num_dcs = _idmapdstate.num_dcs;
idmap_pg_config_t *pgcfg = &_idmapdstate.cfg->pgcfg;
+ if (pgcfg->domain_name == NULL) {
+ /* No domain name specified - workgroup mode. */
+ new_dcs = NULL;
+ new_num_dcs = 0;
+ goto out;
+ }
+
if (pgcfg->domain_controller == NULL ||
pgcfg->domain_controller[0].host[0] == '\0') {
/*
@@ -258,9 +268,6 @@ reload_dcs(void)
return;
}
- old_dcs = _idmapdstate.dcs;
- old_num_dcs = _idmapdstate.num_dcs;
-
new_num_dcs = 1;
new_dcs = calloc(new_num_dcs, sizeof (adutils_ad_t *));
if (new_dcs == NULL)
@@ -295,6 +302,7 @@ reload_dcs(void)
}
}
+out:
_idmapdstate.dcs = new_dcs;
_idmapdstate.num_dcs = new_num_dcs;
@@ -325,7 +333,7 @@ reload_ad(void)
}
void
-print_idmapdstate()
+print_idmapdstate(void)
{
int i, j;
idmap_pg_config_t *pgcfg;
diff --git a/usr/src/cmd/idmap/idmapd/nldaputils.c b/usr/src/cmd/idmap/idmapd/nldaputils.c
index e14d47e2bb..2895789bd3 100644
--- a/usr/src/cmd/idmap/idmapd/nldaputils.c
+++ b/usr/src/cmd/idmap/idmapd/nldaputils.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -721,7 +720,7 @@ nldap_lookup_batch(lookup_state_t *state, idmap_mapping_batch *batch,
idmap_ids_res *result)
{
idmap_retcode retcode, rc1;
- int i, add, is_wuser;
+ int i, add;
idmap_mapping *req;
idmap_id_res *res;
idmap_nldap_query_state_t *qs = NULL;
@@ -751,7 +750,7 @@ nldap_lookup_batch(lookup_state_t *state, idmap_mapping_batch *batch,
if (!(req->direction & _IDMAP_F_LOOKUP_NLDAP))
continue;
- if (IS_REQUEST_SID(*req, 1)) {
+ if (IS_ID_SID(req->id1)) {
/* win2unix request: */
@@ -779,7 +778,7 @@ nldap_lookup_batch(lookup_state_t *state, idmap_mapping_batch *batch,
/* Lookup nldap by winname to get pid and unixname */
add = 1;
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
res->info.src = IDMAP_MAP_SRC_NEW;
how = &res->info.how;
how->map_type = IDMAP_MAP_TYPE_DS_NLDAP;
@@ -792,7 +791,7 @@ nldap_lookup_batch(lookup_state_t *state, idmap_mapping_batch *batch,
&req->id2name, &res->id.idmap_id_u.uid,
&res->retcode);
- } else if (IS_REQUEST_UID(*req) || IS_REQUEST_GID(*req)) {
+ } else if (IS_ID_UID(req->id1) || IS_ID_GID(req->id1)) {
/* unix2win request: */
@@ -807,7 +806,7 @@ nldap_lookup_batch(lookup_state_t *state, idmap_mapping_batch *batch,
req->id2domain = NULL;
/* Set how info */
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
res->info.src = IDMAP_MAP_SRC_NEW;
how = &res->info.how;
how->map_type = IDMAP_MAP_TYPE_DS_NLDAP;
@@ -887,18 +886,16 @@ out:
if (res->retcode == IDMAP_SUCCESS &&
req->id2name != NULL &&
res->id.idmap_id_u.sid.prefix == NULL &&
- (IS_REQUEST_UID(*req) || IS_REQUEST_GID(*req))) {
+ (IS_ID_UID(req->id1) || IS_ID_GID(req->id1))) {
- is_wuser = -1;
rc1 = lookup_name2sid(state->cache,
- req->id2name, req->id2domain, &is_wuser,
+ req->id2name, req->id2domain, -1,
NULL, NULL,
&res->id.idmap_id_u.sid.prefix,
- &res->id.idmap_id_u.sid.rid, req, 1);
- if (rc1 == IDMAP_SUCCESS)
- res->id.idtype =
- is_wuser ? IDMAP_USID : IDMAP_GSID;
- else if (rc1 == IDMAP_ERR_NOTFOUND) {
+ &res->id.idmap_id_u.sid.rid,
+ &res->id.idtype,
+ req, 1);
+ if (rc1 == IDMAP_ERR_NOTFOUND) {
req->direction |= _IDMAP_F_LOOKUP_AD;
state->ad_nqueries++;
} else
@@ -913,7 +910,7 @@ out:
if (res->retcode != IDMAP_SUCCESS &&
res->retcode != IDMAP_ERR_NS_LDAP_BAD_WINNAME &&
!(IDMAP_FATAL_ERROR(res->retcode))) {
- idmap_info_free(&res->info);
+ idmap_how_clear(&res->info.how);
res->retcode = IDMAP_SUCCESS;
}
}
diff --git a/usr/src/cmd/idmap/idmapd/server.c b/usr/src/cmd/idmap/idmapd/server.c
index db5e93c876..94a7cea12a 100644
--- a/usr/src/cmd/idmap/idmapd/server.c
+++ b/usr/src/cmd/idmap/idmapd/server.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -123,10 +122,10 @@ validate_mapped_id_by_name_req(idmap_mapping *req)
{
int e;
- if (IS_REQUEST_UID(*req) || IS_REQUEST_GID(*req))
+ if (IS_ID_UID(req->id1) || IS_ID_GID(req->id1))
return (IDMAP_SUCCESS);
- if (IS_REQUEST_SID(*req, 1)) {
+ if (IS_ID_SID(req->id1)) {
if (!EMPTY_STRING(req->id1name) &&
u8_validate(req->id1name, strlen(req->id1name),
NULL, U8_VALIDATE_ENTIRE, &e) < 0)
@@ -186,6 +185,9 @@ idmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
lookup_state_t state;
idmap_retcode retcode;
uint_t i;
+ idmap_mapping *req;
+ idmap_id_res *res;
+ boolean_t any_tracing;
/* Init */
(void) memset(result, 0, sizeof (*result));
@@ -241,28 +243,34 @@ idmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
/* Init our 'done' flags */
state.sid2pid_done = state.pid2sid_done = TRUE;
+ any_tracing = B_FALSE;
+
/* First stage */
for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
+ req = &batch.idmap_mapping_batch_val[i];
+ res = &result->ids.ids_val[i];
+ if (TRACING(req))
+ any_tracing = B_TRUE;
state.curpos = i;
- (void) sanitize_mapping_request(
- &batch.idmap_mapping_batch_val[i]);
- if (IS_BATCH_SID(batch, i)) {
+ (void) sanitize_mapping_request(req);
+ TRACE(req, res, "Start mapping");
+ if (IS_ID_SID(req->id1)) {
retcode = sid2pid_first_pass(
&state,
- &batch.idmap_mapping_batch_val[i],
- &result->ids.ids_val[i]);
- } else if (IS_BATCH_UID(batch, i)) {
+ req,
+ res);
+ } else if (IS_ID_UID(req->id1)) {
retcode = pid2sid_first_pass(
&state,
- &batch.idmap_mapping_batch_val[i],
- &result->ids.ids_val[i], 1);
- } else if (IS_BATCH_GID(batch, i)) {
+ req,
+ res, 1);
+ } else if (IS_ID_GID(req->id1)) {
retcode = pid2sid_first_pass(
&state,
- &batch.idmap_mapping_batch_val[i],
- &result->ids.ids_val[i], 0);
+ req,
+ res, 0);
} else {
- result->ids.ids_val[i].retcode = IDMAP_ERR_IDTYPE;
+ res->retcode = IDMAP_ERR_IDTYPE;
continue;
}
if (IDMAP_FATAL_ERROR(retcode)) {
@@ -288,9 +296,23 @@ idmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
if (state.nldap_nqueries) {
retcode = nldap_lookup_batch(&state, &batch, result);
if (IDMAP_FATAL_ERROR(retcode)) {
+ TRACE(req, res, "Native LDAP lookup error=%d", retcode);
result->retcode = retcode;
goto out;
}
+ if (any_tracing) {
+ for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
+ res = &result->ids.ids_val[i];
+ req = &batch.idmap_mapping_batch_val[i];
+ if (IDMAP_ERROR(res->retcode)) {
+ TRACE(req, res,
+ "Native LDAP lookup error=%d",
+ res->retcode);
+ } else {
+ TRACE(req, res, "Native LDAP lookup");
+ }
+ }
+ }
}
/*
@@ -310,9 +332,45 @@ idmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
if (state.ad_nqueries) {
retcode = ad_lookup_batch(&state, &batch, result);
if (IDMAP_FATAL_ERROR(retcode)) {
+ TRACE(req, res, "AD lookup error=%d", retcode);
result->retcode = retcode;
goto out;
}
+ for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
+ res = &result->ids.ids_val[i];
+ req = &batch.idmap_mapping_batch_val[i];
+ if (res->retcode == IDMAP_ERR_DOMAIN_NOTFOUND &&
+ req->id1.idmap_id_u.sid.prefix != NULL &&
+ req->id1name != NULL) {
+ /*
+ * If AD lookup failed Domain Not Found but
+ * we have a winname and SID, it means that
+ * - LSA succeeded
+ * - it's a request a cross-forest trust
+ * and
+ * - we were looking for directory-based
+ * mapping information.
+ * In that case, we're OK, just go on.
+ *
+ * If this seems more convoluted than it
+ * should be, it is - really, we probably
+ * shouldn't even be attempting AD lookups
+ * in this situation, but that's a more
+ * intricate cleanup that will have to wait
+ * for later.
+ */
+ res->retcode = IDMAP_SUCCESS;
+ TRACE(req, res,
+ "AD lookup - domain not found (ignored)");
+ continue;
+ }
+ if (res->retcode == IDMAP_SUCCESS)
+ TRACE(req, res, "Found in AD");
+ else if (res->retcode == IDMAP_ERR_NOTFOUND)
+ TRACE(req, res, "Not found in AD");
+ else
+ TRACE(req, res, "AD lookup error");
+ }
}
/*
@@ -324,9 +382,17 @@ idmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
if (state.nldap_nqueries) {
retcode = nldap_lookup_batch(&state, &batch, result);
if (IDMAP_FATAL_ERROR(retcode)) {
+ TRACE(req, res, "Native LDAP lookup error=%d", retcode);
result->retcode = retcode;
goto out;
}
+ if (any_tracing) {
+ for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
+ res = &result->ids.ids_val[i];
+ req = &batch.idmap_mapping_batch_val[i];
+ TRACE(req, res, "Native LDAP lookup");
+ }
+ }
}
/* Reset 'done' flags */
@@ -334,22 +400,24 @@ idmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
/* Second stage */
for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
+ req = &batch.idmap_mapping_batch_val[i];
+ res = &result->ids.ids_val[i];
state.curpos = i;
- if (IS_BATCH_SID(batch, i)) {
+ if (IS_ID_SID(req->id1)) {
retcode = sid2pid_second_pass(
&state,
- &batch.idmap_mapping_batch_val[i],
- &result->ids.ids_val[i]);
- } else if (IS_BATCH_UID(batch, i)) {
+ req,
+ res);
+ } else if (IS_ID_UID(req->id1)) {
retcode = pid2sid_second_pass(
&state,
- &batch.idmap_mapping_batch_val[i],
- &result->ids.ids_val[i], 1);
- } else if (IS_BATCH_GID(batch, i)) {
+ req,
+ res, 1);
+ } else if (IS_ID_GID(req->id1)) {
retcode = pid2sid_second_pass(
&state,
- &batch.idmap_mapping_batch_val[i],
- &result->ids.ids_val[i], 0);
+ req,
+ res, 0);
} else {
/* First stage has already set the error */
continue;
@@ -373,18 +441,20 @@ idmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
goto out;
for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
+ req = &batch.idmap_mapping_batch_val[i];
+ res = &result->ids.ids_val[i];
state.curpos = i;
- if (IS_BATCH_SID(batch, i)) {
+ if (IS_ID_SID(req->id1)) {
(void) update_cache_sid2pid(
&state,
- &batch.idmap_mapping_batch_val[i],
- &result->ids.ids_val[i]);
- } else if ((IS_BATCH_UID(batch, i)) ||
- (IS_BATCH_GID(batch, i))) {
+ req,
+ res);
+ } else if ((IS_ID_UID(req->id1)) ||
+ (IS_ID_GID(req->id1))) {
(void) update_cache_pid2sid(
&state,
- &batch.idmap_mapping_batch_val[i],
- &result->ids.ids_val[i]);
+ req,
+ res);
}
}
@@ -399,11 +469,36 @@ idmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
out:
cleanup_lookup_state(&state);
if (IDMAP_ERROR(result->retcode)) {
+ if (any_tracing) {
+ for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
+ req = &batch.idmap_mapping_batch_val[i];
+ res = &result->ids.ids_val[i];
+ TRACE(req, res,
+ "Failure code %d", result->retcode);
+ }
+ }
xdr_free(xdr_idmap_ids_res, (caddr_t)result);
result->ids.ids_len = 0;
result->ids.ids_val = NULL;
+ } else {
+ if (any_tracing) {
+ for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
+ req = &batch.idmap_mapping_batch_val[i];
+ res = &result->ids.ids_val[i];
+ TRACE(req, res, "Done");
+ }
+ }
}
result->retcode = idmap_stat4prot(result->retcode);
+
+ for (i = 0; i < result->ids.ids_len; i++) {
+ req = &batch.idmap_mapping_batch_val[i];
+ res = &result->ids.ids_val[i];
+
+ if (!(req->flag & IDMAP_REQ_FLG_MAPPING_INFO) &&
+ res->retcode == IDMAP_SUCCESS)
+ idmap_how_clear(&res->info.how);
+ }
return (TRUE);
}
@@ -1087,11 +1182,7 @@ idmap_get_mapped_id_by_name_1_svc(idmap_mapping request,
result->retcode = batch_result.ids.ids_val[0].retcode;
- if (map->flag & IDMAP_REQ_FLG_MAPPING_INFO ||
- result->retcode != IDMAP_SUCCESS) {
- (void) idmap_info_mov(&map->info,
- &batch_result.ids.ids_val[0].info);
- }
+ idmap_info_mov(&map->info, &batch_result.ids.ids_val[0].info);
out:
if (IDMAP_FATAL_ERROR(result->retcode)) {
diff --git a/usr/src/cmd/idmap/idmapd/wksids.c b/usr/src/cmd/idmap/idmapd/wksids.c
index 3e2c87eab1..90d749d336 100644
--- a/usr/src/cmd/idmap/idmapd/wksids.c
+++ b/usr/src/cmd/idmap/idmapd/wksids.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -223,7 +222,7 @@ static wksids_table_t wksids[] = {
*/
const
wksids_table_t *
-find_wksid_by_name(const char *name, const char *domain, int type)
+find_wksid_by_name(const char *name, const char *domain, idmap_id_type type)
{
int i;
@@ -286,7 +285,7 @@ find_wksid_by_name(const char *name, const char *domain, int type)
*/
const
wksids_table_t *
-find_wksid_by_sid(const char *sid, int rid, int type)
+find_wksid_by_sid(const char *sid, int rid, idmap_id_type type)
{
int i;
diff --git a/usr/src/cmd/mdb/common/modules/smbsrv/smbsrv.c b/usr/src/cmd/mdb/common/modules/smbsrv/smbsrv.c
index 49708383c9..58ebaa2945 100644
--- a/usr/src/cmd/mdb/common/modules/smbsrv/smbsrv.c
+++ b/usr/src/cmd/mdb/common/modules/smbsrv/smbsrv.c
@@ -19,11 +19,11 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#include <sys/mdb_modapi.h>
+#include <mdb/mdb_modapi.h>
+#include <mdb/mdb_ks.h>
#include <sys/thread.h>
#include <sys/taskq_impl.h>
#include <smbsrv/smb_vops.h>
@@ -35,16 +35,15 @@
#define ACE_TYPE_ENTRY(_v_) {_v_, #_v_}
#define SMB_COM_ENTRY(_v_, _x_) {#_v_, _x_}
-#define SMB_MDB_MAX_OPTS 10
+#define SMB_MDB_MAX_OPTS 9
#define SMB_OPT_SERVER 0x00000001
-#define SMB_OPT_VFS 0x00000002
-#define SMB_OPT_SESSION 0x00000004
-#define SMB_OPT_REQUEST 0x00000008
-#define SMB_OPT_USER 0x00000010
-#define SMB_OPT_TREE 0x00000020
-#define SMB_OPT_OFILE 0x00000040
-#define SMB_OPT_ODIR 0x00000080
+#define SMB_OPT_SESSION 0x00000002
+#define SMB_OPT_REQUEST 0x00000004
+#define SMB_OPT_USER 0x00000008
+#define SMB_OPT_TREE 0x00000010
+#define SMB_OPT_OFILE 0x00000020
+#define SMB_OPT_ODIR 0x00000040
#define SMB_OPT_WALK 0x00000100
#define SMB_OPT_VERBOSE 0x00000200
#define SMB_OPT_ALL_OBJ 0x000000FF
@@ -78,9 +77,22 @@ typedef struct {
/*
* List of supported options. Ther order has the match the bits SMB_OPT_xxx.
*/
-static const char *smb_opts[SMB_MDB_MAX_OPTS] =
+typedef struct smb_mdb_opts {
+ char *o_name;
+ uint32_t o_value;
+} smb_mdb_opts_t;
+
+static smb_mdb_opts_t smb_opts[SMB_MDB_MAX_OPTS] =
{
- "-s", "-m", "-e", "-r", "-u", "-t", "-f", "-d", "-w", "-v"
+ { "-s", SMB_OPT_SERVER },
+ { "-e", SMB_OPT_SESSION },
+ { "-r", SMB_OPT_REQUEST },
+ { "-u", SMB_OPT_USER },
+ { "-t", SMB_OPT_TREE },
+ { "-f", SMB_OPT_OFILE },
+ { "-d", SMB_OPT_ODIR },
+ { "-w", SMB_OPT_WALK },
+ { "-v", SMB_OPT_VERBOSE }
};
static smb_com_entry_t smb_com[256] =
@@ -346,7 +358,6 @@ static smb_com_entry_t smb_com[256] =
static int smb_dcmd_list(uintptr_t, uint_t, int, const mdb_arg_t *);
static void smb_dcmd_list_help(void);
static int smb_dcmd_server(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_dcmd_vfs(uintptr_t, uint_t, int, const mdb_arg_t *);
static void smb_dcmd_session_help(void);
static int smb_dcmd_session(uintptr_t, uint_t, int, const mdb_arg_t *);
static int smb_dcmd_request(uintptr_t, uint_t, int, const mdb_arg_t *);
@@ -356,12 +367,14 @@ static void smb_dcmd_tree_help(void);
static int smb_dcmd_tree(uintptr_t, uint_t, int, const mdb_arg_t *);
static int smb_dcmd_odir(uintptr_t, uint_t, int, const mdb_arg_t *);
static int smb_dcmd_ofile(uintptr_t, uint_t, int, const mdb_arg_t *);
+static int smb_vfs(uintptr_t, uint_t, int, const mdb_arg_t *);
+static int smb_vfs_walk_init(mdb_walk_state_t *);
+static int smb_vfs_walk_step(mdb_walk_state_t *);
static void smb_node_help(void);
static int smb_node(uintptr_t, uint_t, int, const mdb_arg_t *);
static int smb_node_walk_init(mdb_walk_state_t *);
static int smb_node_walk_step(mdb_walk_state_t *);
static int smb_lock(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_stats(uintptr_t, uint_t, int, const mdb_arg_t *);
static int smb_ace(uintptr_t, uint_t, int, const mdb_arg_t *);
static int smb_ace_walk_init(mdb_walk_state_t *);
static int smb_ace_walk_step(mdb_walk_state_t *);
@@ -375,6 +388,7 @@ static int smb_dcmd_setopt(uint_t, int, mdb_arg_t *);
static int smb_obj_expand(uintptr_t, uint_t, const smb_exp_t *, ulong_t);
static int smb_obj_list(const char *, uint_t, uint_t);
static int smb_worker_findstack(uintptr_t);
+static int smb_stats(uintptr_t, uint_t, int, const mdb_arg_t *);
/*
* MDB module linkage information:
@@ -396,7 +410,7 @@ static const mdb_dcmd_t dcmds[] = {
{ "smbvfs",
"[-v]",
"print smb_vfs information",
- smb_dcmd_vfs },
+ smb_vfs },
{ "smbnode",
"?[-vps]",
"print smb_node_t information",
@@ -431,8 +445,9 @@ static const mdb_dcmd_t dcmds[] = {
"[-v]",
"print smb_odir_t information",
smb_dcmd_ofile },
- { "smbstats", NULL,
- "print all smb dispatched requests statistics", smb_stats },
+ { "smbstat", NULL,
+ "print all smb dispatched requests statistics",
+ smb_stats },
{ "smbace", "[-v]",
"print smb_ace_t information", smb_ace },
{ "smbacl", "[-v]",
@@ -453,6 +468,12 @@ static const mdb_walker_t walkers[] = {
smb_node_walk_step,
NULL,
NULL },
+ { "smbvfs_walker",
+ "walk list of smb_vfs_t structures",
+ smb_vfs_walk_init,
+ smb_vfs_walk_step,
+ NULL,
+ NULL },
{ "smbace_walker",
"walk list of smb_ace_t structures",
smb_ace_walk_init,
@@ -490,7 +511,6 @@ smb_dcmd_list_help(void)
mdb_printf(
"-v\tDisplay verbose information\n"
"-s\tDisplay the list of servers\n"
- "-m\tDisplay the list of shared file systems\n"
"-e\tDisplay the list of sessions\n"
"-r\tDisplay the list of smb requests\n"
"-u\tDisplay the list of users\n"
@@ -569,9 +589,6 @@ static const smb_exp_t smb_server_exp[] =
{ SMB_OPT_ALL_OBJ,
offsetof(smb_server_t, sv_tcp_daemon.ld_session_list.se_act.lst),
"smbsess", "smb_session"},
- { SMB_OPT_ALL_OBJ,
- offsetof(smb_server_t, sv_vfs_list.ll_list),
- "smbvfs", "smb_vfs"},
{ 0, 0, NULL, NULL }
};
@@ -620,20 +637,16 @@ smb_dcmd_server(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
"%<b>%<u>%-?s% "
"%-4s% "
"%-32s% "
- "%-6s% "
- "%-6s% "
- "%-6s%</u>%</b>\n",
- "SERVER", "ZONE", "STATE", "USERS",
- "TREES", "FILES");
+ "%</u>%</b>\n",
+ "SERVER", "ZONE", "STATE");
if (sv->sv_state >= SMB_SERVER_STATE_SENTINEL)
state = "UNKNOWN";
else
state = smb_server_state[sv->sv_state];
- mdb_printf("%-?p %-4d %-32s %-6d %-6d %-6d \n",
- addr, sv->sv_zid, state, sv->sv_open_users,
- sv->sv_open_trees, sv->sv_open_files);
+ mdb_printf("%-?p %-4d %-32s \n",
+ addr, sv->sv_zid, state);
}
}
if (smb_obj_expand(addr, opts, smb_server_exp, indent))
@@ -643,68 +656,6 @@ smb_dcmd_server(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
/*
* *****************************************************************************
- * ******************************** smb_vfs_t **********************************
- * *****************************************************************************
- */
-
-/*
- * ::smbvfs
- *
- * smbvfs dcmd - Prints out smb_vfs structures.
- */
-/*ARGSUSED*/
-static int
-smb_dcmd_vfs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
-
- uint_t opts;
-
- if (smb_dcmd_getopt(&opts, argc, argv))
- return (DCMD_USAGE);
-
- if (!(flags & DCMD_ADDRSPEC)) {
- return (smb_obj_list("smb_vfs", SMB_OPT_VFS, flags));
- }
-
- if (((opts & SMB_OPT_WALK) && (opts & SMB_OPT_VFS)) ||
- !(opts & SMB_OPT_WALK)) {
- smb_vfs_t *sf;
- vnode_t *vn;
- char *path;
-
- sf = mdb_alloc(sizeof (*sf), UM_SLEEP | UM_GC);
- if (mdb_vread(sf, sizeof (*sf), addr) == -1) {
- mdb_warn("failed to read smb_vfs at %p", addr);
- return (DCMD_ERR);
- }
- vn = mdb_alloc(sizeof (*vn), UM_SLEEP | UM_GC);
- if (mdb_vread(vn, sizeof (*vn),
- (uintptr_t)sf->sv_rootvp) == -1) {
- mdb_warn("failed to read vnode at %p", sf->sv_rootvp);
- return (DCMD_ERR);
- }
- path = mdb_zalloc(MAXPATHLEN, UM_SLEEP | UM_GC);
- (void) mdb_vread(path, MAXPATHLEN, (uintptr_t)vn->v_path);
-
- if (DCMD_HDRSPEC(flags))
- mdb_printf(
- "%<b>%<u>"
- "%-?s "
- "%-10s "
- "%-16s "
- "%-16s"
- "%-s"
- "%</u>%</b>\n",
- "SMB_VFS", "REFCNT", "VFS", "VNODE", "ROOT");
- mdb_printf(
- "%-?p %-10d %-?p %-?p %-s\n", addr, sf->sv_refcnt,
- sf->sv_vfsp, sf->sv_rootvp, path);
- }
- return (DCMD_OK);
-}
-
-/*
- * *****************************************************************************
* ***************************** smb_session_t *********************************
* *****************************************************************************
*/
@@ -784,7 +735,6 @@ smb_dcmd_session(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_warn("failed to read smb_session at %p", addr);
return (DCMD_ERR);
}
-
if (se->s_state >= SMB_SESSION_STATE_SENTINEL)
state = "INVALID";
else
@@ -812,13 +762,13 @@ smb_dcmd_session(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_printf(
"%<b>%<u>%-?s "
"%-16s "
- "%-16s%</u>%</b>\n",
+ "%-16s %-16s%</u>%</b>\n",
"SESSION", "CLIENT_IP_ADDR",
- "LOCAL_IP_ADDR");
+ "LOCAL_IP_ADDR", "STATE");
mdb_printf(
- "%-?p %-16I %-16I\n", addr, se->ipaddr.a_ipv4,
- se->local_ipaddr.a_ipv4);
+ "%-?p %-16I %-16I %s\n", addr, se->ipaddr.a_ipv4,
+ se->local_ipaddr.a_ipv4, state);
}
}
if (smb_obj_expand(addr, opts, smb_session_exp, indent))
@@ -846,6 +796,11 @@ static const char *smb_request_state[SMB_REQ_STATE_SENTINEL] =
"CLEANED_UP"
};
+#define SMB_REQUEST_BANNER \
+ "%<b>%<u>%-?s %-?s %-14s %-14s %-16s %-32s%</u>%</b>\n"
+#define SMB_REQUEST_FORMAT \
+ "%-?p %-?p %e %e %-16s %s\n"
+
static int
smb_dcmd_request(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
@@ -864,12 +819,33 @@ smb_dcmd_request(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
!(opts & SMB_OPT_WALK)) {
smb_request_t *sr;
const char *state;
+ uint64_t waiting;
+ uint64_t running;
sr = mdb_alloc(sizeof (*sr), UM_SLEEP | UM_GC);
if (mdb_vread(sr, sizeof (*sr), addr) == -1) {
mdb_warn("failed to read smb_request at %p", addr);
return (DCMD_ERR);
}
+ if (sr->sr_magic != SMB_REQ_MAGIC) {
+ mdb_warn("not an smb_request_t (%p)>", addr);
+ return (DCMD_ERR);
+ }
+ waiting = 0;
+ running = 0;
+ if (sr->sr_time_submitted != 0) {
+ if (sr->sr_time_active != 0) {
+ waiting = sr->sr_time_active -
+ sr->sr_time_submitted;
+ running = mdb_gethrtime() -
+ sr->sr_time_active;
+ } else {
+ waiting = mdb_gethrtime() -
+ sr->sr_time_submitted;
+ }
+ }
+ waiting /= NANOSEC;
+ running /= NANOSEC;
if (sr->sr_state >= SMB_REQ_STATE_SENTINEL)
state = "INVALID";
@@ -880,27 +856,48 @@ smb_dcmd_request(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_printf(
"%</b>%</u>SMB request information (%p):"
"%</u>%</b>\n\n", addr);
- mdb_printf("First SMB COM: %u (%s)\n",
- sr->first_smb_com,
- smb_com[sr->first_smb_com]);
- mdb_printf("State: %u (%s)\n", sr->sr_state, state);
- mdb_printf("Tree: %u (%p)\n", sr->smb_tid,
- sr->tid_tree);
- mdb_printf("User: %u (%p)\n", sr->smb_uid,
- sr->uid_user);
- mdb_printf("File: %u (%p)\n",
- sr->smb_fid, sr->fid_ofile);
- mdb_printf("PID: %u\n", sr->smb_pid);
- mdb_printf("MID: %u\n\n", sr->smb_mid);
+
+ mdb_printf(
+ "first SMB COM: %u (%s)\n"
+ "current SMB COM: %u (%s)\n"
+ "state: %u (%s)\n"
+ "TID(tree): %u (%p)\n"
+ "UID(user): %u (%p)\n"
+ "FID(file): %u (%p)\n"
+ "PID: %u\n"
+ "MID: %u\n\n"
+ "waiting time: %1.3e\n"
+ "running time: %1.3e",
+ sr->first_smb_com, smb_com[sr->first_smb_com],
+ sr->smb_com, smb_com[sr->smb_com],
+ sr->sr_state, state,
+ sr->smb_tid, sr->tid_tree,
+ sr->smb_uid, sr->uid_user,
+ sr->smb_fid, sr->fid_ofile,
+ sr->smb_pid,
+ sr->smb_mid,
+ waiting,
+ running);
+
smb_worker_findstack((uintptr_t)sr->sr_worker);
} else {
if (DCMD_HDRSPEC(flags))
mdb_printf(
- "%<b>%<u>%-?s %-?s %-16s %s%</u>%</b>\n",
- "ADDR", "Worker", "STATE", "COM");
-
- mdb_printf("%-?p %-?p %-16s %s\n", addr, sr->sr_worker,
- state, smb_com[sr->first_smb_com]);
+ SMB_REQUEST_BANNER,
+ "ADDR",
+ "WORKER",
+ "WAITING(s)",
+ "RUNNING(s)",
+ "STATE",
+ "COMMAND");
+
+ mdb_printf(SMB_REQUEST_FORMAT,
+ addr,
+ sr->sr_worker,
+ waiting,
+ running,
+ state,
+ smb_com[sr->smb_com]);
}
}
return (DCMD_OK);
@@ -972,7 +969,6 @@ smb_dcmd_user(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_warn("failed to read smb_user at %p", addr);
return (DCMD_ERR);
}
-
account = mdb_zalloc(user->u_domain_len + user->u_name_len + 2,
UM_SLEEP | UM_GC);
@@ -1088,7 +1084,6 @@ smb_dcmd_tree(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_warn("failed to read smb_tree at %p", addr);
return (DCMD_ERR);
}
-
if (opts & SMB_OPT_VERBOSE) {
const char *state;
@@ -1162,7 +1157,6 @@ smb_dcmd_odir(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_warn("failed to read smb_odir at %p", addr);
return (DCMD_ERR);
}
-
if (opts & SMB_OPT_VERBOSE) {
const char *state;
@@ -1232,7 +1226,6 @@ smb_dcmd_ofile(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_warn("failed to read smb_ofile at %p", addr);
return (DCMD_ERR);
}
-
if (opts & SMB_OPT_VERBOSE) {
const char *state;
@@ -1271,6 +1264,117 @@ smb_dcmd_ofile(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
/*
* *****************************************************************************
+ * ******************************** smb_vfs_t **********************************
+ * *****************************************************************************
+ */
+
+/*
+ * ::smbvfs
+ *
+ * smbvfs dcmd - Prints out smb_vfs structures.
+ */
+/*ARGSUSED*/
+static int
+smb_vfs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+{
+ int verbose = FALSE;
+ smb_vfs_t *sf;
+ vnode_t *vn;
+ char *path;
+
+ if (mdb_getopts(argc, argv,
+ 'v', MDB_OPT_SETBITS, TRUE, &verbose,
+ NULL) != argc)
+ return (DCMD_USAGE);
+
+ /*
+ * If no smb_vfs address was specified on the command line, we can
+ * print out all smb_vfs by invoking the smb_vfs walker, using
+ * this dcmd itself as the callback.
+ */
+ if (!(flags & DCMD_ADDRSPEC)) {
+ if (mdb_walk_dcmd("smbvfs_walker", "smbvfs",
+ argc, argv) == -1) {
+ mdb_warn("failed to walk 'smb_vfs'");
+ return (DCMD_ERR);
+ }
+ return (DCMD_OK);
+ }
+
+ if (DCMD_HDRSPEC(flags)) {
+ mdb_printf(
+ "%<b>%<u>"
+ "%-?s "
+ "%-10s "
+ "%-16s "
+ "%-16s"
+ "%-s"
+ "%</u>%</b>\n",
+ "SMB_VFS", "REFCNT", "VFS", "VNODE", "ROOT");
+ }
+
+ sf = mdb_alloc(sizeof (*sf), UM_SLEEP | UM_GC);
+ if (mdb_vread(sf, sizeof (*sf), addr) == -1) {
+ mdb_warn("failed to read smb_vfs at %p", addr);
+ return (DCMD_ERR);
+ }
+
+ vn = mdb_alloc(sizeof (*vn), UM_SLEEP | UM_GC);
+ if (mdb_vread(vn, sizeof (*vn),
+ (uintptr_t)sf->sv_rootvp) == -1) {
+ mdb_warn("failed to read vnode at %p", sf->sv_rootvp);
+ return (DCMD_ERR);
+ }
+
+ path = mdb_zalloc(MAXPATHLEN, UM_SLEEP | UM_GC);
+ (void) mdb_vread(path, MAXPATHLEN, (uintptr_t)vn->v_path);
+
+ mdb_printf(
+ "%-?p %-10d %-?p %-?p %-s\n", addr, sf->sv_refcnt,
+ sf->sv_vfsp, sf->sv_rootvp, path);
+
+ return (DCMD_OK);
+}
+
+/*
+ * Initialize the smb_vfs_t walker by reading the value of smb_export
+ * in the kernel's symbol table. Only global walk supported.
+ */
+static int
+smb_vfs_walk_init(mdb_walk_state_t *wsp)
+{
+ GElf_Sym sym;
+
+ if (wsp->walk_addr != NULL) {
+ mdb_printf("smb_vfs walk only supports global walks\n");
+ return (WALK_ERR);
+ }
+
+ if (mdb_lookup_by_name("smb_export", &sym) == -1) {
+ mdb_warn("failed to find 'smb_export'");
+ return (WALK_ERR);
+ }
+
+ wsp->walk_addr = (uintptr_t)sym.st_value +
+ offsetof(smb_export_t, e_vfs_list) + offsetof(smb_llist_t, ll_list);
+
+ if (mdb_layered_walk("list", wsp) == -1) {
+ mdb_warn("failed to walk list of VFS");
+ return (WALK_ERR);
+ }
+
+ return (WALK_NEXT);
+}
+
+static int
+smb_vfs_walk_step(mdb_walk_state_t *wsp)
+{
+ return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
+ wsp->walk_cbdata));
+}
+
+/*
+ * *****************************************************************************
* ******************************* smb_node_t **********************************
* *****************************************************************************
*/
@@ -1609,41 +1713,38 @@ smb_lock(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
}
/*
- * ::smb_dispatch_stats
+ * ::smbstat
*
- * smb_dispatch_stats dcmd - Prints all dispatched SMB requests statistics.
+ * Prints SMB requests statistics.
*/
/*ARGSUSED*/
static int
smb_stats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
- smb_disp_entry_t *disp;
- GElf_Sym sym;
- int nstats = 0, i;
+ smb_server_t *sv;
- if ((flags & DCMD_ADDRSPEC) || argc != 0)
+ if (!(flags & DCMD_ADDRSPEC))
return (DCMD_USAGE);
- if (mdb_lookup_by_obj(MDB_OBJ_EVERY, "dispatch", &sym)) {
- mdb_warn("failed to find dispatch object");
+ sv = mdb_alloc(sizeof (*sv), UM_SLEEP | UM_GC);
+ if (mdb_vread(sv, sizeof (*sv), addr) == -1) {
+ mdb_warn("failed to read server object at %p", addr);
return (DCMD_ERR);
}
-
- disp = mdb_alloc(sym.st_size, UM_SLEEP | UM_GC);
- if (mdb_vread(disp, sym.st_size, sym.st_value) == -1) {
- mdb_warn("failed to read from dispatch object");
+ if (sv->sv_magic != SMB_SERVER_MAGIC) {
+ mdb_warn("not an smb_server_t (%p)>", addr);
return (DCMD_ERR);
}
+ mdb_printf(
+ "\n%<b> nbt tcp users trees files pipes%</b>\n"
+ "%5d %5d %5d %5d %5d %5d\n",
+ sv->sv_nbt_sess,
+ sv->sv_tcp_sess,
+ sv->sv_users,
+ sv->sv_trees,
+ sv->sv_files,
+ sv->sv_pipes);
- nstats = sym.st_size / sizeof (smb_disp_entry_t);
-
- mdb_printf("All dispatched SMB requests statistics:\n\n");
- for (i = 0; i < nstats; i++) {
- if (disp[i].sdt_function)
- mdb_printf(" %40s\t: %lld\n",
- disp[i].sdt_dispatch_stats.name,
- disp[i].sdt_dispatch_stats.value.ui64);
- }
return (DCMD_OK);
}
@@ -2043,7 +2144,6 @@ smb_dcmd_getopt(uint_t *opts, int argc, const mdb_arg_t *argv)
if (mdb_getopts(argc, argv,
's', MDB_OPT_SETBITS, SMB_OPT_SERVER, opts,
- 'm', MDB_OPT_SETBITS, SMB_OPT_VFS, opts,
'e', MDB_OPT_SETBITS, SMB_OPT_SESSION, opts,
'r', MDB_OPT_SETBITS, SMB_OPT_REQUEST, opts,
'u', MDB_OPT_SETBITS, SMB_OPT_USER, opts,
@@ -2071,17 +2171,15 @@ static int
smb_dcmd_setopt(uint_t opts, int max_argc, mdb_arg_t *argv)
{
int i;
- uint_t mask = 0x00000001;
int argc = 0;
for (i = 0; i < SMB_MDB_MAX_OPTS; i++) {
- if ((opts & mask) && (argc < max_argc)) {
+ if ((opts & smb_opts[i].o_value) && (argc < max_argc)) {
argv->a_type = MDB_TYPE_STRING;
- argv->a_un.a_str = smb_opts[i];
+ argv->a_un.a_str = smb_opts[i].o_name;
argc++;
argv++;
}
- mask = mask << 1;
}
return (argc);
}
diff --git a/usr/src/cmd/smbsrv/dtrace/cifs.d b/usr/src/cmd/smbsrv/dtrace/cifs.d
index 0e902e7604..c9748b4b40 100644
--- a/usr/src/cmd/smbsrv/dtrace/cifs.d
+++ b/usr/src/cmd/smbsrv/dtrace/cifs.d
@@ -20,8 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -69,17 +68,62 @@ sdt:smbsrv::-smb_op*-done
self->status = sr->smb_error.status;
}
+sdt:smbsrv::-smb_op-Negotiate-done
+{
+ sr = (struct smb_request *)arg0;
+ negprot = (smb_arg_negotiate_t *)arg1;
+
+ printf("dialect=%s index=%u caps=0x%08x maxmpx=%u tz=%d time=%u",
+ stringof(negprot->ni_name),
+ negprot->ni_index,
+ negprot->ni_capabilities,
+ negprot->ni_maxmpxcount,
+ negprot->ni_tzcorrection,
+ negprot->ni_servertime.tv_sec);
+
+ printf(" [status=0x%08x (class=%d code=%d)]",
+ sr->smb_error.status,
+ sr->smb_error.errcls, sr->smb_error.errcode);
+
+ self->status = sr->smb_error.status;
+}
+
sdt:smbsrv::-smb_op-SessionSetupX-start
{
sr = (struct smb_request *)arg0;
+ ssetup = (smb_arg_sessionsetup_t *)arg1;
- printf("[%s] %s",
+ printf("[%s] %s %s %s",
(sr->session->s_local_port == 139) ? "NBT" : "TCP",
(sr->session->s_local_port == 139) ?
- stringof(sr->session->workstation) : "");
+ stringof(sr->session->workstation) : "",
+ stringof(ssetup->ssi_domain),
+ stringof(ssetup->ssi_user));
+
+ printf(" maxmpx=%u vc=%u maxbuf=%u",
+ ssetup->ssi_maxmpxcount,
+ sr->session->vcnumber,
+ sr->session->smb_msg_size);
+}
+
+sdt:smbsrv::-smb_op-SessionSetupX-done
+{
+ sr = (struct smb_request *)arg0;
+ ssetup = (smb_arg_sessionsetup_t *)arg1;
+
+ printf("%s/%s: smbuid=%d (%s)",
+ stringof(sr->uid_user->u_domain),
+ stringof(sr->uid_user->u_name),
+ sr->smb_uid,
+ (ssetup->ssi_guest == 0) ? "user" : "guest");
+
+ printf(" [status=0x%08x (class=%d code=%d)]",
+ sr->smb_error.status,
+ sr->smb_error.errcls, sr->smb_error.errcode);
+
+ self->status = sr->smb_error.status;
}
-sdt:smbsrv::-smb_op-SessionSetupX-done,
sdt:smbsrv::-smb_op-LogoffX-start
{
sr = (struct smb_request *)arg0;
@@ -98,7 +142,19 @@ sdt:smbsrv::-smb_op-TreeConnectX-start
stringof(tcon->path));
}
-sdt:smbsrv::-smb_op-TreeConnectX-done,
+sdt:smbsrv::-smb_op-TreeConnectX-done
+{
+ sr = (struct smb_request *)arg0;
+
+ printf("tid %d: %s", sr->smb_tid,
+ (sr->smb_error.status == 0) ?
+ stringof(sr->tid_tree->t_sharename) : "");
+
+ printf(" [status=0x%08x (class=%d code=%d)]",
+ sr->smb_error.status,
+ sr->smb_error.errcls, sr->smb_error.errcode);
+}
+
sdt:smbsrv::-smb_op-TreeDisconnect-start
{
sr = (struct smb_request *)arg0;
@@ -172,8 +228,8 @@ sdt:smbsrv::-smb_op-Rename-start
p = (struct dirop *)arg1;
printf("%s to %s",
- stringof(p->fqi.fq_path.pn_path),
- stringof(p->dst_fqi.fq_path.pn_path));
+ stringof(p->fqi.fq_path.pn_path),
+ stringof(p->dst_fqi.fq_path.pn_path));
}
sdt:smbsrv::-smb_op-CheckDirectory-start,
@@ -192,7 +248,7 @@ smb_dispatch_request:return,
smb_pre_*:return,
smb_com_*:return,
smb_post_*:return,
-smbsr_error:return,
+smbsr_status:return,
smbsr_errno:return
{
}
@@ -207,7 +263,7 @@ smb_post_*:entry
sr->smb_com, sr->smb_uid, sr->smb_tid);
}
-smbsr_error:entry
+smbsr_status:entry
{
printf("status=0x%08x class=%d, code=%d\n", arg1, arg2, arg3);
}
diff --git a/usr/src/cmd/smbsrv/dtrace/msrpc.d b/usr/src/cmd/smbsrv/dtrace/msrpc.d
index 4462934cd6..609140bff3 100644
--- a/usr/src/cmd/smbsrv/dtrace/msrpc.d
+++ b/usr/src/cmd/smbsrv/dtrace/msrpc.d
@@ -19,9 +19,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -150,7 +150,7 @@ smb_com_logoff_andx:return
/*
* Raise error functions (no return).
*/
-smbsr_error:entry
+smbsr_status:entry
{
printf("status=0x%08x class=%d, code=%d", arg1, arg2, arg3);
}
@@ -160,7 +160,7 @@ smbsr_errno:entry
printf("errno=%d", arg1);
}
-smbsr_error:return,
+smbsr_status:return,
smbsr_errno:return
{
}
diff --git a/usr/src/cmd/smbsrv/dtrace/stype.d b/usr/src/cmd/smbsrv/dtrace/stype.d
index bf0d143790..ce157e5877 100755..100644
--- a/usr/src/cmd/smbsrv/dtrace/stype.d
+++ b/usr/src/cmd/smbsrv/dtrace/stype.d
@@ -22,12 +22,9 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#pragma ident "@(#)stype.d 1.4 08/08/07 SMI"
-
#pragma D option flowindent
/*
@@ -53,14 +50,37 @@ END
sdt:smbsrv::-smb_op-SessionSetupX-start
{
sr = (struct smb_request *)arg0;
+ ssetup = (smb_arg_sessionsetup_t *)arg1;
- printf("[%s] %s",
+ printf("[%s] %s %s %s",
(sr->session->s_local_port == 139) ? "NBT" : "TCP",
(sr->session->s_local_port == 139) ?
- stringof(sr->session->workstation) : "");
+ stringof(sr->session->workstation) : "",
+ stringof(ssetup->ssi_domain),
+ stringof(ssetup->ssi_user));
+
+ printf(" maxmpx=%u vc=%u maxbuf=%u",
+ ssetup->ssi_maxmpxcount,
+ sr->session->vcnumber,
+ sr->session->smb_msg_size);
+}
+
+sdt:smbsrv::-smb_op-SessionSetupX-done
+{
+ sr = (struct smb_request *)arg0;
+ ssetup = (smb_arg_sessionsetup_t *)arg1;
+
+ printf("%s/%s: smbuid=%d (%s)",
+ stringof(sr->uid_user->u_domain),
+ stringof(sr->uid_user->u_name),
+ sr->smb_uid,
+ (ssetup->ssi_guest == 0) ? "user" : "guest");
+
+ printf(" [status=0x%08x (class=%d code=%d)]",
+ sr->smb_error.status,
+ sr->smb_error.errcls, sr->smb_error.errcode);
}
-sdt:smbsrv::-smb_op-SessionSetupX-done,
sdt:smbsrv::-smb_op-LogoffX-start
{
sr = (struct smb_request *)arg0;
@@ -79,8 +99,20 @@ sdt:smbsrv::-smb_op-TreeConnectX-start
stringof(tcon->path));
}
-sdt:smbsrv::-smb_op-TreeConnectX-done,
-sdt:smbsrv::-smb_op-TreeDisconnect-done
+sdt:smbsrv::-smb_op-TreeConnectX-done
+{
+ sr = (struct smb_request *)arg0;
+
+ printf("tid %d: %s", sr->smb_tid,
+ (sr->smb_error.status == 0) ?
+ stringof(sr->tid_tree->t_sharename) : "");
+
+ printf(" [status=0x%08x (class=%d code=%d)]",
+ sr->smb_error.status,
+ sr->smb_error.errcls, sr->smb_error.errcode);
+}
+
+sdt:smbsrv::-smb_op-TreeDisconnect-start
{
sr = (struct smb_request *)arg0;
@@ -92,7 +124,7 @@ sdt:smbsrv::-smb_op-TreeDisconnect-done
/*
* Error functions
*/
-smbsr_error:entry
+smbsr_status:entry
{
printf("status=0x%08x class=%d, code=%d", arg1, arg2, arg3);
}
@@ -102,7 +134,7 @@ smbsr_errno:entry
printf("errno=%d", arg1);
}
-smbsr_error:return,
+smbsr_status:return,
smbsr_errno:return
{
}
@@ -119,15 +151,16 @@ smb_tree_get_sharename:entry
printf("uncpath=%s", stringof(arg0));
}
-smb_tree_get_stype:entry
+smb_tree_connect_disk:entry
{
- printf("sharename=%s service=%s", stringof(arg0), stringof(arg1));
+ printf("sharename=%s", stringof(arg1));
+ self->stype = 0;
}
-smb_tree_connect_disk:entry
+smb_tree_connect_printq:entry
{
printf("sharename=%s", stringof(arg1));
- self->stype = 0;
+ self->stype = 1;
}
smb_tree_connect_ipc:entry
@@ -138,7 +171,6 @@ smb_tree_connect_ipc:entry
smb_tree_connect:return,
smb_tree_get_sharename:return,
-smb_tree_get_stype:return,
smb_tree_connect_disk:return,
smb_tree_connect_ipc:return
{
diff --git a/usr/src/cmd/smbsrv/smbadm/smbadm.c b/usr/src/cmd/smbsrv/smbadm/smbadm.c
index ecf0f52615..df7f163599 100644
--- a/usr/src/cmd/smbsrv/smbadm/smbadm.c
+++ b/usr/src/cmd/smbsrv/smbadm/smbadm.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -748,14 +747,6 @@ smbadm_group_create(int argc, char **argv)
smbadm_usage(B_FALSE);
}
- if (getgrnam(gname) == NULL) {
- (void) fprintf(stderr,
- gettext("failed to get the Solaris group '%s'\n"), gname);
- (void) fprintf(stderr,
- gettext("use 'groupadd' to add '%s'\n"), gname);
- return (1);
- }
-
status = smb_lgrp_add(gname, desc);
if (status != SMB_LGRP_SUCCESS) {
(void) fprintf(stderr,
@@ -994,14 +985,6 @@ smbadm_group_rename(int argc, char **argv)
smbadm_usage(B_FALSE);
}
- if (getgrnam(ngname) == NULL) {
- (void) fprintf(stderr,
- gettext("failed to get the Solaris group '%s'\n"), ngname);
- (void) fprintf(stderr,
- gettext("use 'groupadd' to add '%s'\n"), ngname);
- return (1);
- }
-
status = smb_lgrp_rename(gname, ngname);
if (status != SMB_LGRP_SUCCESS) {
if (status == SMB_LGRP_EXISTS)
diff --git a/usr/src/cmd/smbsrv/smbd/Makefile b/usr/src/cmd/smbsrv/smbd/Makefile
index dff759c94f..2078b536ad 100644
--- a/usr/src/cmd/smbsrv/smbd/Makefile
+++ b/usr/src/cmd/smbsrv/smbd/Makefile
@@ -19,8 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
@@ -30,6 +29,7 @@ SRCS= \
smbd_join.c \
smbd_logon.c \
smbd_main.c \
+ smbd_nicmon.c \
smbd_opipe_doorsvc.c \
smbd_share_doorsvc.c \
smbd_vss.c
@@ -51,7 +51,7 @@ $(ROOTVARSMBDLL):= FILEMODE = 0755
include ../Makefile.smbsrv.defs
LDLIBS += -L$(ROOT)/usr/lib/smbsrv -lmlsvc -lmlrpc -lsmbns -lsmb \
- -lzfs -lbsm -lnsl -lumem
+ -lzfs -lbsm -lsocket -lnsl -lscf -lumem
LDFLAGS += -R/usr/lib/smbsrv
ROOTSMBDDIR = $(ROOTLIB)/smbsrv
diff --git a/usr/src/cmd/smbsrv/smbd/server.xml b/usr/src/cmd/smbsrv/smbd/server.xml
index 30bbedd595..e5c45813c6 100644
--- a/usr/src/cmd/smbsrv/smbd/server.xml
+++ b/usr/src/cmd/smbsrv/smbd/server.xml
@@ -21,8 +21,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
CDDL HEADER END
-Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-Use is subject to license terms.
+Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
NOTE: This service manifest is not editable; its contents will
be overwritten by package or patch operations, including
@@ -207,6 +206,8 @@ file.
value='false' override='true'/>
<propval name='sv_version' type='astring'
value='5.0' override='true'/>
+ <propval name='dfs_stdroot_num' type='integer'
+ value='0' override='true'/>
</property_group>
<!-- SMB service-specific shares exec configuration defaults -->
diff --git a/usr/src/cmd/smbsrv/smbd/smbd.h b/usr/src/cmd/smbsrv/smbd/smbd.h
index 23bba19cbb..00fa2f5ca7 100644
--- a/usr/src/cmd/smbsrv/smbd/smbd.h
+++ b/usr/src/cmd/smbsrv/smbd/smbd.h
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMBD_H
@@ -43,6 +42,9 @@ int smbd_opipe_start(void);
void smbd_opipe_stop(void);
int smbd_share_start(void);
void smbd_share_stop(void);
+int smbd_nicmon_start(const char *);
+void smbd_nicmon_stop(void);
+int smbd_nicmon_refresh(void);
boolean_t smbd_set_netlogon_cred(void);
int smbd_locate_dc_start(void);
smb_token_t *smbd_user_auth_logon(smb_logon_t *);
@@ -78,8 +80,12 @@ typedef struct smbd {
pthread_t s_nbt_listener_id;
pthread_t s_tcp_listener_id;
boolean_t s_fatal_error;
+ smb_log_hdl_t s_loghd;
} smbd_t;
+#define SMBD_LOGNAME "smbd"
+#define SMBD_LOGSIZE 1024
+
#define SMBD_DOOR_NAMESZ 16
typedef struct smbd_door {
diff --git a/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c b/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c
index e936029edc..5fb3695a16 100644
--- a/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c
+++ b/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c
@@ -90,6 +90,8 @@ static int smbd_dop_ads_find_host(smbd_arg_t *);
static int smbd_dop_quota_query(smbd_arg_t *);
static int smbd_dop_quota_set(smbd_arg_t *);
static int smbd_dop_dfs_get_referrals(smbd_arg_t *);
+static int smbd_dop_shr_hostaccess(smbd_arg_t *);
+static int smbd_dop_shr_exec(smbd_arg_t *);
typedef int (*smbd_dop_t)(smbd_arg_t *);
@@ -114,7 +116,9 @@ smbd_doorop_t smbd_doorops[] = {
{ SMB_DR_ADS_FIND_HOST, smbd_dop_ads_find_host },
{ SMB_DR_QUOTA_QUERY, smbd_dop_quota_query },
{ SMB_DR_QUOTA_SET, smbd_dop_quota_set },
- { SMB_DR_DFS_GET_REFERRALS, smbd_dop_dfs_get_referrals }
+ { SMB_DR_DFS_GET_REFERRALS, smbd_dop_dfs_get_referrals },
+ { SMB_DR_SHR_HOSTACCESS, smbd_dop_shr_hostaccess },
+ { SMB_DR_SHR_EXEC, smbd_dop_shr_exec }
};
static int smbd_ndoorop = (sizeof (smbd_doorops) / sizeof (smbd_doorops[0]));
@@ -952,3 +956,56 @@ smbd_dop_dfs_get_referrals(smbd_arg_t *arg)
return (SMB_DOP_ENCODE_ERROR);
return (SMB_DOP_SUCCESS);
}
+
+static int
+smbd_dop_shr_hostaccess(smbd_arg_t *arg)
+{
+ smb_shr_hostaccess_query_t request;
+ uint32_t reply;
+
+ bzero(&request, sizeof (request));
+ bzero(&reply, sizeof (reply));
+
+ if (smb_common_decode(arg->data, arg->datalen,
+ smb_shr_hostaccess_query_xdr, &request) != 0)
+ return (SMB_DOP_DECODE_ERROR);
+
+ reply = smb_shr_hostaccess(&request.shq_ipaddr, request.shq_none,
+ request.shq_ro, request.shq_rw, request.shq_flag);
+
+ arg->rbuf = smb_common_encode(&reply, xdr_uint32_t, &arg->rsize);
+
+ xdr_free(smb_shr_hostaccess_query_xdr, (char *)&request);
+
+ if (arg->rbuf == NULL)
+ return (SMB_DOP_ENCODE_ERROR);
+ return (SMB_DOP_SUCCESS);
+}
+
+static int
+smbd_dop_shr_exec(smbd_arg_t *arg)
+{
+ smb_shr_execinfo_t request;
+ int reply;
+
+ bzero(&request, sizeof (request));
+ bzero(&reply, sizeof (reply));
+
+ if (smb_common_decode(arg->data, arg->datalen,
+ smb_shr_execinfo_xdr, &request) != 0)
+ return (SMB_DOP_DECODE_ERROR);
+
+ reply = smb_shr_exec(&request);
+
+ if (reply != 0)
+ syslog(LOG_NOTICE, "Failed to execute %s command",
+ (request.e_type == SMB_EXEC_MAP) ? "map" : "unmap");
+
+ arg->rbuf = smb_common_encode(&reply, xdr_int, &arg->rsize);
+
+ xdr_free(smb_shr_execinfo_xdr, (char *)&request);
+
+ if (arg->rbuf == NULL)
+ return (SMB_DOP_ENCODE_ERROR);
+ return (SMB_DOP_SUCCESS);
+}
diff --git a/usr/src/cmd/smbsrv/smbd/smbd_join.c b/usr/src/cmd/smbsrv/smbd/smbd_join.c
index a4b57bbeb5..f0bbf9b18c 100644
--- a/usr/src/cmd/smbsrv/smbd/smbd_join.c
+++ b/usr/src/cmd/smbsrv/smbd/smbd_join.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <syslog.h>
@@ -35,7 +35,6 @@
#include <smbsrv/libsmbns.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/smbinfo.h>
-#include <smbsrv/ntstatus.h>
#include "smbd.h"
diff --git a/usr/src/cmd/smbsrv/smbd/smbd_main.c b/usr/src/cmd/smbsrv/smbd/smbd_main.c
index 72c5b110b8..0d1ba63615 100644
--- a/usr/src/cmd/smbsrv/smbd/smbd_main.c
+++ b/usr/src/cmd/smbsrv/smbd/smbd_main.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
@@ -172,11 +171,13 @@ main(int argc, char *argv[])
(void) sigaction(SIGHUP, &act, NULL);
(void) sigaction(SIGINT, &act, NULL);
(void) sigaction(SIGPIPE, &act, NULL);
+ (void) sigaction(SIGUSR1, &act, NULL);
(void) sigdelset(&set, SIGTERM);
(void) sigdelset(&set, SIGHUP);
(void) sigdelset(&set, SIGINT);
(void) sigdelset(&set, SIGPIPE);
+ (void) sigdelset(&set, SIGUSR1);
if (smbd.s_fg) {
(void) sigdelset(&set, SIGTSTP);
@@ -223,6 +224,10 @@ main(int argc, char *argv[])
(void) pthread_cond_signal(&refresh_cond);
break;
+ case SIGUSR1:
+ smb_log_dumpall();
+ break;
+
default:
/*
* Typically SIGINT or SIGTERM.
@@ -465,10 +470,11 @@ smbd_service_init(void)
return (-1);
}
+ smbd.s_loghd = smb_log_create(SMBD_LOGSIZE, SMBD_LOGNAME);
smb_codepage_init();
- if (smb_nicmon_start(SMBD_DEFAULT_INSTANCE_FMRI) != 0)
- smbd_report("NIC monitoring failed to start");
+ if (smbd_nicmon_start(SMBD_DEFAULT_INSTANCE_FMRI) != 0)
+ smbd_report("NIC monitor failed to start");
(void) dyndns_start();
smb_ipc_init();
@@ -583,7 +589,7 @@ smbd_service_fini(void)
smbd_share_stop();
smb_shr_stop();
dyndns_stop();
- smb_nicmon_stop();
+ smbd_nicmon_stop();
smb_ccache_remove(SMB_CCACHE_PATH);
smb_pwd_fini();
smb_domain_fini();
@@ -683,9 +689,8 @@ smbd_refresh_monitor(void *arg)
(void) dyndns_start();
dyndns_clear_zones();
- /* re-initialize NIC table */
- if (smb_nic_init() != SMB_NIC_SUCCESS)
- smbd_report("failed to get NIC information");
+ if (smbd_nicmon_refresh() != 0)
+ smbd_report("NIC monitor refresh failed");
smb_netbios_name_reconfig();
smb_browser_reconfig();
smbd_refresh_dc();
@@ -742,8 +747,8 @@ smbd_refresh_dc(void)
if (smb_getfqdomainname(fqdomain, MAXHOSTNAMELEN))
return;
- if (smb_locate_dc(fqdomain, "", NULL))
- smbd_report("DC discovery failed");
+ if (!smb_locate_dc(fqdomain, "", NULL))
+ smbd_report("DC refresh failed");
}
void
diff --git a/usr/src/cmd/smbsrv/smbd/smbd_nicmon.c b/usr/src/cmd/smbsrv/smbd/smbd_nicmon.c
new file mode 100644
index 0000000000..bc6739843c
--- /dev/null
+++ b/usr/src/cmd/smbsrv/smbd/smbd_nicmon.c
@@ -0,0 +1,323 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * smbd NIC monitor.
+ */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <net/if.h>
+#include <net/route.h>
+#include <sys/sockio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <syslog.h>
+#include <smbsrv/libsmb.h>
+#include "smbd.h"
+
+#define SMBD_NICMON_ENABLE "nicmon_enable"
+#define SMBD_NICMON_THROTTLE 100
+#define SMBD_NICMON_DEBOUNCE 2
+
+extern smbd_t smbd;
+
+static boolean_t smbd_nicmon_enabled = B_TRUE;
+
+/* Use this to stop monitoring */
+static int eventpipe_write = -1;
+
+/* Use this to refresh service instance */
+static char *smbd_nicmon_caller_fmri = NULL;
+
+static void smbd_nicmon_run_check(void);
+static int smbd_nicmon_setup_rtsock(int);
+static int smbd_nicmon_needscan(int);
+static int smbd_nicmon_setup_eventpipe(int *, int *);
+static void *smbd_nicmon_daemon(void *);
+
+/*
+ * Start the nic monitor thread.
+ */
+int
+smbd_nicmon_start(const char *svc_fmri)
+{
+ pthread_t smbd_nicmon_tid;
+ int rc;
+
+ if (smb_nic_init() != SMB_NIC_SUCCESS)
+ return (-1);
+
+ rc = pthread_create(&smbd_nicmon_tid, NULL, smbd_nicmon_daemon, NULL);
+ if (rc != 0)
+ return (-1);
+
+ if (svc_fmri)
+ smbd_nicmon_caller_fmri = (char *)svc_fmri;
+
+ smbd_nicmon_run_check();
+ return (0);
+}
+
+void
+smbd_nicmon_stop(void)
+{
+ uchar_t buf = 1;
+
+ if (eventpipe_write < 0)
+ return;
+
+ (void) write(eventpipe_write, &buf, sizeof (buf));
+ smbd_nicmon_caller_fmri = NULL;
+ smb_nic_fini();
+}
+
+int
+smbd_nicmon_refresh(void)
+{
+ if (smb_nic_init() != SMB_NIC_SUCCESS)
+ return (-1);
+
+ smbd_nicmon_run_check();
+ return (0);
+}
+
+/*
+ * The monitor is enabled unless it is explicitly
+ * disabled by setting smbd/nicmon_enable to false.
+ * smbd/nicmon_enable is not defined by default.
+ */
+static void
+smbd_nicmon_run_check(void)
+{
+ smb_scfhandle_t *hd;
+ uint8_t status;
+ int rc;
+
+ smbd_nicmon_enabled = B_TRUE;
+
+ if ((hd = smb_smf_scf_init(SMBD_FMRI_PREFIX)) == NULL) {
+ smb_log(smbd.s_loghd, LOG_DEBUG,
+ "smbd_nicmon: smb_smf_scf_init failed");
+ return;
+ }
+
+ rc = smb_smf_create_service_pgroup(hd, SMBD_PG_NAME);
+ if (rc != SMBD_SMF_OK) {
+ smb_smf_scf_fini(hd);
+ smb_log(smbd.s_loghd, LOG_DEBUG,
+ "smbd_nicmon: smb_smf_create_service_pgroup failed");
+ return;
+ }
+
+ rc = smb_smf_get_boolean_property(hd, SMBD_NICMON_ENABLE, &status);
+ if (rc == SMBD_SMF_OK && status == 0)
+ smbd_nicmon_enabled = B_FALSE;
+
+ smb_smf_scf_fini(hd);
+}
+
+/*
+ * Setup routing socket for getting RTM messages.
+ */
+static int
+smbd_nicmon_setup_rtsock(int af)
+{
+ int sd;
+ int flags;
+
+ if ((sd = socket(PF_ROUTE, SOCK_RAW, af)) == -1) {
+ smb_log(smbd.s_loghd, LOG_ERR,
+ "smbd_nicmon: routing socket failed: %d", errno);
+ return (-1);
+ }
+
+ if ((flags = fcntl(sd, F_GETFL, 0)) < 0) {
+ smb_log(smbd.s_loghd, LOG_ERR,
+ "smbd_nicmon: fcntl F_GETFL failed: %d", errno);
+ (void) close(sd);
+ return (-1);
+ }
+
+ if ((fcntl(sd, F_SETFL, flags | O_NONBLOCK)) < 0) {
+ smb_log(smbd.s_loghd, LOG_ERR,
+ "smbd_nicmon: fcntl F_SETFL failed: %d", errno);
+ (void) close(sd);
+ return (-1);
+ }
+
+ return (sd);
+}
+
+static int
+smbd_nicmon_needscan(int sock)
+{
+ static uint32_t throttle;
+ struct rt_msghdr *rtm;
+ int64_t msg[2048 / 8];
+ int need_if_scan = 0;
+ int nbytes;
+
+ /* Read as many messages as possible and try to empty the sockets */
+ for (;;) {
+ nbytes = read(sock, msg, sizeof (msg));
+ if (nbytes <= 0)
+ break;
+
+ rtm = (struct rt_msghdr *)msg;
+ if (rtm->rtm_version != RTM_VERSION)
+ continue;
+
+ if (nbytes < rtm->rtm_msglen) {
+ if ((throttle % SMBD_NICMON_THROTTLE) == 0) {
+ smb_log(smbd.s_loghd, LOG_DEBUG,
+ "smbd_nicmon: short read: %d of %d",
+ nbytes, rtm->rtm_msglen);
+ }
+ ++throttle;
+ continue;
+ }
+
+ switch (rtm->rtm_type) {
+ case RTM_NEWADDR:
+ case RTM_DELADDR:
+ case RTM_IFINFO:
+ need_if_scan = 1;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return (need_if_scan);
+}
+
+/*
+ * Create pipe for signal delivery and set up signal handlers.
+ */
+static int
+smbd_nicmon_setup_eventpipe(int *read_pipe, int *write_pipe)
+{
+ int fds[2];
+
+ if ((pipe(fds)) < 0) {
+ smb_log(smbd.s_loghd, LOG_ERR,
+ "smbd_nicmon: event pipe failed: %d", errno);
+ return (-1);
+ }
+
+ *read_pipe = fds[0];
+ *write_pipe = fds[1];
+ return (0);
+}
+
+/*
+ * Create the global routing socket to monitor changes in NIC interfaces.
+ * We are only interested in new inerface addition/deletion and changes
+ * in UP/DOWN status.
+ *
+ * Note: only supports AF_INET routing socket. Need to add AF_INET6 to
+ * support IPv6.
+ */
+/*ARGSUSED*/
+static void *
+smbd_nicmon_daemon(void *arg)
+{
+ static uint32_t throttle;
+ static int rtsock_v4;
+ static int eventpipe_read = -1;
+ struct pollfd pollfds[2];
+ int pollfd_num = 2;
+ int i, nic_changed;
+ int rc;
+
+ if ((rtsock_v4 = smbd_nicmon_setup_rtsock(AF_INET)) == -1)
+ return (NULL);
+
+ rc = smbd_nicmon_setup_eventpipe(&eventpipe_read, &eventpipe_write);
+ if (rc != 0)
+ return (NULL);
+
+ /*
+ * Listen for activity on any of the sockets.
+ * The delay before checking the rtsock will hopefully
+ * smooth things out when there is a lot of activity.
+ */
+ for (;;) {
+ errno = 0;
+ nic_changed = 0;
+ pollfds[0].fd = rtsock_v4;
+ pollfds[0].events = POLLIN;
+ pollfds[1].fd = eventpipe_read;
+ pollfds[1].events = POLLIN;
+
+ if (poll(pollfds, pollfd_num, -1) < 0) {
+ if (errno == EINTR)
+ continue;
+ if ((throttle % SMBD_NICMON_THROTTLE) == 0)
+ smb_log(smbd.s_loghd, LOG_DEBUG,
+ "smbd_nicmon: poll failed: %d", errno);
+ ++throttle;
+ break;
+ }
+
+ for (i = 0; i < pollfd_num; i++) {
+ if ((pollfds[i].fd < 0) ||
+ !(pollfds[i].revents & POLLIN))
+ continue;
+ if (pollfds[i].fd == rtsock_v4) {
+ (void) sleep(SMBD_NICMON_DEBOUNCE);
+ nic_changed = smbd_nicmon_needscan(rtsock_v4);
+ }
+ if (pollfds[i].fd == eventpipe_read)
+ goto done;
+ }
+
+ /*
+ * If the monitor is enabled and something has changed,
+ * refresh the registered SMF service.
+ */
+ if (smbd_nicmon_enabled && nic_changed &&
+ smbd_nicmon_caller_fmri) {
+ if (smf_refresh_instance(smbd_nicmon_caller_fmri) != 0)
+ smb_log(smbd.s_loghd, LOG_ERR,
+ "smbd_nicmon: %s refresh failed",
+ smbd_nicmon_caller_fmri);
+ }
+ }
+done:
+ (void) close(rtsock_v4);
+ (void) close(eventpipe_read);
+ (void) close(eventpipe_write);
+ eventpipe_write = -1;
+ return (NULL);
+}
diff --git a/usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c b/usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c
index 3792e23853..887e8c5b22 100644
--- a/usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c
+++ b/usr/src/cmd/smbsrv/smbd/smbd_share_doorsvc.c
@@ -49,7 +49,6 @@ static pthread_mutex_t smb_share_dsrv_mtx = PTHREAD_MUTEX_INITIALIZER;
static smbd_door_t smb_share_sdh;
static void smbd_share_dispatch(void *, char *, size_t, door_desc_t *, uint_t);
-static int smbd_share_enum(smb_enumshare_info_t *esi);
/*
* Start the LanMan share door service.
@@ -145,11 +144,7 @@ smbd_share_dispatch(void *cookie, char *ptr, size_t size, door_desc_t *dp,
char *sharename, *sharename2;
smb_share_t lmshr_info;
smb_shrlist_t lmshr_list;
- smb_enumshare_info_t esi;
int offset;
- smb_inaddr_t ipaddr;
- int exec_type;
- smb_execsub_info_t subs;
smbd_door_enter(&smb_share_sdh);
@@ -203,23 +198,6 @@ smbd_share_dispatch(void *cookie, char *ptr, size_t size, door_desc_t *dp,
smb_dr_free_string(sharename2);
break;
- case SMB_SHROP_GETINFO:
- sharename = smb_dr_get_string(dec_ctx);
- (void) smb_dr_get_buf(dec_ctx, (unsigned char *)&ipaddr,
- sizeof (smb_inaddr_t));
- if ((dec_status = smb_dr_decode_finish(dec_ctx)) != 0) {
- smb_dr_free_string(sharename);
- goto decode_error;
- }
- rc = smb_shr_get(sharename, &lmshr_info);
- if (rc == NERR_Success)
- smb_shr_hostaccess(&lmshr_info, &ipaddr);
- smb_dr_put_int32(enc_ctx, SMB_SHARE_DSUCCESS);
- smb_dr_put_uint32(enc_ctx, rc);
- smb_dr_put_share(enc_ctx, &lmshr_info);
- smb_dr_free_string(sharename);
- break;
-
case SMB_SHROP_ADD:
smb_dr_get_share(dec_ctx, &lmshr_info);
if ((dec_status = smb_dr_decode_finish(dec_ctx)) != 0)
@@ -254,59 +232,6 @@ smbd_share_dispatch(void *cookie, char *ptr, size_t size, door_desc_t *dp,
sizeof (smb_shrlist_t));
break;
- case SMB_SHROP_ENUM:
- esi.es_bufsize = smb_dr_get_ushort(dec_ctx);
- esi.es_posix_uid = smb_dr_get_uint32(dec_ctx);
- if ((dec_status = smb_dr_decode_finish(dec_ctx)) != 0)
- goto decode_error;
-
- rc = smbd_share_enum(&esi);
-
- smb_dr_put_int32(enc_ctx, SMB_SHARE_DSUCCESS);
- smb_dr_put_uint32(enc_ctx, rc);
- if (rc == NERR_Success) {
- smb_dr_put_ushort(enc_ctx, esi.es_ntotal);
- smb_dr_put_ushort(enc_ctx, esi.es_nsent);
- smb_dr_put_ushort(enc_ctx, esi.es_datasize);
- smb_dr_put_buf(enc_ctx,
- (unsigned char *)esi.es_buf, esi.es_bufsize);
- free(esi.es_buf);
- }
- break;
-
- case SMB_SHROP_EXEC:
- sharename = smb_dr_get_string(dec_ctx);
- subs.e_winname = smb_dr_get_string(dec_ctx);
- subs.e_userdom = smb_dr_get_string(dec_ctx);
- (void) smb_dr_get_buf(dec_ctx,
- (unsigned char *)&subs.e_srv_ipaddr, sizeof (smb_inaddr_t));
- (void) smb_dr_get_buf(dec_ctx,
- (unsigned char *)&subs.e_cli_ipaddr, sizeof (smb_inaddr_t));
- subs.e_cli_netbiosname = smb_dr_get_string(dec_ctx);
- subs.e_uid = smb_dr_get_int32(dec_ctx);
- exec_type = smb_dr_get_int32(dec_ctx);
- if ((dec_status = smb_dr_decode_finish(dec_ctx)) != 0) {
- smb_dr_free_string(sharename);
- smb_dr_free_string(subs.e_winname);
- smb_dr_free_string(subs.e_userdom);
- smb_dr_free_string(subs.e_cli_netbiosname);
- goto decode_error;
- }
-
- rc = smb_shr_exec(sharename, &subs, exec_type);
-
- if (rc != 0)
- syslog(LOG_NOTICE, "Failed to execute %s command",
- (exec_type == SMB_SHR_UNMAP) ? "unmap" : "map");
-
- smb_dr_put_int32(enc_ctx, SMB_SHARE_DSUCCESS);
- smb_dr_put_uint32(enc_ctx, rc);
- smb_dr_free_string(sharename);
- smb_dr_free_string(subs.e_winname);
- smb_dr_free_string(subs.e_userdom);
- smb_dr_free_string(subs.e_cli_netbiosname);
- break;
-
default:
dec_status = smb_dr_decode_finish(dec_ctx);
goto decode_error;
@@ -328,109 +253,3 @@ decode_error:
(void) smb_dr_encode_finish(enc_ctx, &used);
smbd_door_return(&smb_share_sdh, buf, used, NULL, 0);
}
-
-/*
- * This function builds a response for a NetShareEnum RAP request which
- * originates from smbsrv kernel module. A response buffer is allocated
- * with the specified size in esi->es_bufsize. List of shares is scanned
- * twice. In the first round the total number of shares which their OEM
- * name is shorter than 13 chars (esi->es_ntotal) and also the number of
- * shares that fit in the given buffer are calculated. In the second
- * round the shares data are encoded in the buffer.
- *
- * The data associated with each share has two parts, a fixed size part and
- * a variable size part which is share's comment. The outline of the response
- * buffer is so that fixed part for all the shares will appear first and follows
- * with the comments for all those shares and that's why the data cannot be
- * encoded in one round without unnecessarily complicating the code.
- */
-static int
-smbd_share_enum(smb_enumshare_info_t *esi)
-{
- smb_shriter_t shi;
- smb_share_t *si;
- int remained;
- uint16_t infolen = 0;
- uint16_t cmntlen = 0;
- uint16_t sharelen;
- uint16_t clen;
- uint32_t cmnt_offs;
- smb_msgbuf_t info_mb;
- smb_msgbuf_t cmnt_mb;
- boolean_t autohome_added = B_FALSE;
-
- esi->es_ntotal = esi->es_nsent = 0;
-
- if ((esi->es_buf = malloc(esi->es_bufsize)) == NULL)
- return (NERR_InternalError);
-
- bzero(esi->es_buf, esi->es_bufsize);
- remained = esi->es_bufsize;
-
- /* Do the necessary calculations in the first round */
- smb_shr_iterinit(&shi);
-
- while ((si = smb_shr_iterate(&shi)) != NULL) {
- if (si->shr_flags & SMB_SHRF_LONGNAME)
- continue;
-
- if ((si->shr_flags & SMB_SHRF_AUTOHOME) && !autohome_added) {
- if (esi->es_posix_uid == si->shr_uid)
- autohome_added = B_TRUE;
- else
- continue;
- }
-
- esi->es_ntotal++;
-
- if (remained <= 0)
- continue;
-
- clen = strlen(si->shr_cmnt) + 1;
- sharelen = SHARE_INFO_1_SIZE + clen;
-
- if (sharelen <= remained) {
- infolen += SHARE_INFO_1_SIZE;
- cmntlen += clen;
- }
-
- remained -= sharelen;
- }
-
- esi->es_datasize = infolen + cmntlen;
-
- smb_msgbuf_init(&info_mb, (uint8_t *)esi->es_buf, infolen, 0);
- smb_msgbuf_init(&cmnt_mb, (uint8_t *)esi->es_buf + infolen, cmntlen, 0);
- cmnt_offs = infolen;
-
- /* Encode the data in the second round */
- smb_shr_iterinit(&shi);
- autohome_added = B_FALSE;
-
- while ((si = smb_shr_iterate(&shi)) != NULL) {
- if (si->shr_flags & SMB_SHRF_LONGNAME)
- continue;
-
- if ((si->shr_flags & SMB_SHRF_AUTOHOME) && !autohome_added) {
- if (esi->es_posix_uid == si->shr_uid)
- autohome_added = B_TRUE;
- else
- continue;
- }
-
- if (smb_msgbuf_encode(&info_mb, "13c.wl",
- si->shr_oemname, si->shr_type, cmnt_offs) < 0)
- break;
-
- if (smb_msgbuf_encode(&cmnt_mb, "s", si->shr_cmnt) < 0)
- break;
-
- cmnt_offs += strlen(si->shr_cmnt) + 1;
- esi->es_nsent++;
- }
-
- smb_msgbuf_term(&info_mb);
- smb_msgbuf_term(&cmnt_mb);
-
- return (NERR_Success);
-}
diff --git a/usr/src/cmd/smbsrv/smbd/smbd_vss.c b/usr/src/cmd/smbsrv/smbd/smbd_vss.c
index c49c541a74..411037b8e6 100644
--- a/usr/src/cmd/smbsrv/smbd/smbd_vss.c
+++ b/usr/src/cmd/smbsrv/smbd/smbd_vss.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <synch.h>
@@ -35,7 +35,6 @@
#include <smbsrv/libsmbns.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/smbinfo.h>
-#include <smbsrv/ntstatus.h>
#include "smbd.h"
/*
diff --git a/usr/src/cmd/smbsrv/smbstat/Makefile b/usr/src/cmd/smbsrv/smbstat/Makefile
index c44c076464..64268ccf70 100644
--- a/usr/src/cmd/smbsrv/smbstat/Makefile
+++ b/usr/src/cmd/smbsrv/smbstat/Makefile
@@ -19,10 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
PROG= smbstat
@@ -34,6 +31,6 @@ OBJS= $(SRCS:%.c=%.o)
include ../Makefile.smbsrv.defs
-LDLIBS += -lkstat
+LDLIBS += -lkstat -lm -lumem
include ../Makefile.smbsrv.targ
include ../../Makefile.targ
diff --git a/usr/src/cmd/smbsrv/smbstat/smbstat.c b/usr/src/cmd/smbsrv/smbstat/smbstat.c
index aad8655318..de3773d247 100644
--- a/usr/src/cmd/smbsrv/smbstat/smbstat.c
+++ b/usr/src/cmd/smbsrv/smbstat/smbstat.c
@@ -20,17 +20,74 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* smbstat: Server Message Block File System statistics
+ *
+ * The statistics this CLI displays come from two sources:
+ *
+ * 1) The kernel module 'smbsrv'.
+ * 2) The SMB workers task queue statistics the task queue manager of Solaris
+ * maintains.
+ *
+ * The flow of the code is the following:
+ *
+ *
+ * +----------------+
+ * | Initialization |
+ * +----------------+
+ * |
+ * |
+ * v
+ * +--------------------------*
+ * | Take a snapshot the data | <--------+
+ * +--------------------------+ |
+ * | |
+ * | |
+ * v |
+ * +----------------------+ |
+ * | Process the snapshot | |
+ * +----------------------+ |
+ * | |
+ * | |
+ * v |
+ * +------------------------------------+ |
+ * | Print the result of the processing | |
+ * +------------------------------------+ |
+ * | |
+ * | |
+ * v |
+ * Yes --------------- |
+ * +------------ < interval == 0 ? > |
+ * | --------------- |
+ * | | |
+ * | | No |
+ * | v |
+ * | +------------------------+ |
+ * | | Sleep for the duration | ----------+
+ * | | of the interval. |
+ * | +------------------------+
+ * |
+ * +---------------------+
+ * |
+ * v
+ *
+ * Exit
+ *
+ * There are two sets of snapshots. One set for the smbsrv module and the other
+ * for the task queue (SMB workers). Each set contains 2 snapshots. One is
+ * labeled 'current' the other one 'previous'. Their role changes after each
+ * snapshot. The 'current' becomes 'previous' and vice versa.
+ * The first snapshot taken is compared against the data gathered since the
+ * smbsrv module was loaded. Subsequent snapshots will be compared against the
+ * previous snapshot.
*/
+
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include <kstat.h>
#include <stdarg.h>
#include <errno.h>
@@ -39,32 +96,216 @@
#include <utility.h>
#include <libintl.h>
#include <zone.h>
+#include <termios.h>
+#include <stropts.h>
+#include <math.h>
+#include <umem.h>
+#include <locale.h>
#include <smbsrv/smb_kstat.h>
-static kstat_ctl_t *kc; /* libkstat cookie */
-static kstat_t *smb_server;
-static kstat_t *smb_cmds;
+#if !defined(TEXT_DOMAIN)
+#define TEXT_DOMAIN "SYS_TEST"
+#endif /* TEXT_DOMAIN */
+
+#define SMBSTAT_ID_NO_CPU -1
+#define SMBSTAT_SNAPSHOT_COUNT 2 /* Must be a power of 2 */
+#define SMBSTAT_SNAPSHOT_MASK (SMBSTAT_SNAPSHOT_COUNT - 1)
+
+#define SMBSTAT_HELP \
+ "Usage: smbstat [-acnrtuz] [interval]\n" \
+ " -c: display counters\n" \
+ " -t: display throughput\n" \
+ " -u: display utilization\n" \
+ " -r: display requests\n" \
+ " -a: all the requests (supported and unsupported)\n" \
+ " -z: skip the requests not received\n" \
+ " -n: display in alphabetic order\n" \
+ " interval: refresh cycle in seconds\n"
+
+#define SMBSRV_COUNTERS_BANNER "\n nbt tcp users trees files pipes\n"
+#define SMBSRV_COUNTERS_FORMAT "%5d %5d %5d %5d %5d %5d\n"
+
+#define SMBSRV_THROUGHPUT_BANNER \
+ "\nrbytes/s tbytes/s reqs/s reads/s writes/s\n"
+#define SMBSRV_THROUGHPUT_FORMAT \
+ "%1.3e %1.3e %1.3e %1.3e %1.3e\n"
+
+#define SMBSRV_UTILIZATION_BANNER \
+ "\n wcnt rcnt wtime rtime" \
+ " w%% r%% u%% sat usr%% sys%% idle%%\n"
+#define SMBSRV_UTILIZATION_FORMAT \
+ "%1.3e %1.3e %1.3e %1.3e %3.0f %3.0f %3.0f %s " \
+ "%3.0f %3.0f %3.0f\n"
+
+#define SMBSRV_REQUESTS_BANNER \
+ "\n%30s code %% rbytes/s tbytes/s req/s rt-mean" \
+ " rt-stddev\n"
+#define SMBSRV_REQUESTS_FORMAT \
+ "%30s %02X %3.0f %1.3e %1.3e %1.3e %1.3e %1.3e\n"
+
+typedef enum {
+ CPU_TICKS_IDLE = 0,
+ CPU_TICKS_USER,
+ CPU_TICKS_KERNEL,
+ CPU_TICKS_SENTINEL
+} cpu_state_idx_t;
+
+typedef struct smbstat_cpu_snapshot {
+ processorid_t cs_id;
+ int cs_state;
+ uint64_t cs_ticks[CPU_TICKS_SENTINEL];
+} smbstat_cpu_snapshot_t;
+
+typedef struct smbstat_srv_snapshot {
+ hrtime_t ss_snaptime;
+ smbsrv_kstats_t ss_data;
+} smbstat_srv_snapshot_t;
+
+typedef struct smbstat_wrk_snapshot {
+ uint64_t ws_maxthreads;
+ uint64_t ws_bnalloc;
+} smbstat_wrk_snapshot_t;
+
+typedef struct smbstat_req_info {
+ char ri_name[KSTAT_STRLEN];
+ int ri_opcode;
+ double ri_pct;
+ double ri_tbs;
+ double ri_rbs;
+ double ri_rqs;
+ double ri_stddev;
+ double ri_mean;
+} smbstat_req_info_t;
+
+typedef struct smbstat_srv_info {
+ double si_hretime;
+ double si_etime;
+ double si_total_nreqs;
+ /*
+ * Counters
+ */
+ uint32_t si_nbt_sess; /* NBT sessions */
+ uint32_t si_tcp_sess; /* TCP sessions */
+ uint32_t si_users; /* Users logged in */
+ uint32_t si_trees; /* Trees connected */
+ uint32_t si_files; /* Open files */
+ uint32_t si_pipes; /* Open pipes */
+ /*
+ * Throughput of the server
+ */
+ double si_tbs; /* Bytes transmitted / second */
+ double si_rbs; /* Bytes received / second */
+ double si_rqs; /* Requests treated / second */
+ double si_rds; /* Reads treated / second */
+ double si_wrs; /* Writes treated / second */
+ /*
+ * Utilization of the server
+ */
+ double si_wpct; /* */
+ double si_rpct; /* */
+ double si_upct; /* Utilization in % */
+ double si_avw; /* Average number of requests waiting */
+ double si_avr; /* Average number of requests running */
+ double si_wserv; /* Average waiting time */
+ double si_rserv; /* Average running time */
+ boolean_t si_sat;
+ double si_ticks[CPU_TICKS_SENTINEL];
+ /*
+ * Latency & Throughput per request
+ */
+ smbstat_req_info_t si_reqs[SMB_COM_NUM];
+} smbstat_srv_info_t;
-static int get_smbinfo_stat(void);
-static int get_smbdispatch_stat(void);
static void smbstat_init(void);
static void smbstat_fini(void);
-static void smbstat_smb_server_print();
-static void smbstat_smb_cmds_print();
-static void smbstat_print(const char *, kstat_t *, int);
-static int smbstat_width(kstat_t *, int);
+static void smbstat_kstat_snapshot(void);
+static void smbstat_kstat_process(void);
+static void smbstat_kstat_print(void);
+
+static void smbstat_print_counters(void);
+static void smbstat_print_throughput(void);
+static void smbstat_print_utilization(void);
+static void smbstat_print_requests(void);
+
+static void smbstat_cpu_init(void);
+static void smbstat_cpu_fini(void);
+static smbstat_cpu_snapshot_t *smbstat_cpu_current_snapshot(void);
+static smbstat_cpu_snapshot_t *smbstat_cpu_previous_snapshot(void);
+static void smbstat_cpu_snapshot(void);
+static void smbstat_cpu_process(void);
+
+static void smbstat_wrk_init(void);
+static void smbstat_wrk_fini(void);
+static void smbstat_wrk_snapshot(void);
+static void smbstat_wrk_process(void);
+static smbstat_wrk_snapshot_t *smbstat_wrk_current_snapshot(void);
+
+static void smbstat_srv_init(void);
+static void smbstat_srv_fini(void);
+static void smbstat_srv_snapshot(void);
+static void smbstat_srv_process(void);
+static void smbstat_srv_process_counters(smbstat_srv_snapshot_t *);
+static void smbstat_srv_process_throughput(smbstat_srv_snapshot_t *,
+ smbstat_srv_snapshot_t *);
+static void smbstat_srv_process_utilization(smbstat_srv_snapshot_t *,
+ smbstat_srv_snapshot_t *);
+static void smbstat_srv_process_requests(smbstat_srv_snapshot_t *,
+ smbstat_srv_snapshot_t *);
+static smbstat_srv_snapshot_t *smbstat_srv_current_snapshot(void);
+static smbstat_srv_snapshot_t *smbstat_srv_previous_snapshot(void);
+
+static void *smbstat_zalloc(size_t);
+static void smbstat_free(void *, size_t);
static void smbstat_fail(int, char *, ...);
-static kid_t smbstat_kstat_read(kstat_ctl_t *, kstat_t *, void *);
-static void smbstat_usage(void);
+static void smbstat_snapshot_inc_idx(void);
+static void smbstat_usage(FILE *, int);
+static uint_t smbstat_strtoi(char const *, char *);
+static double smbstat_hrtime_delta(hrtime_t, hrtime_t);
+static double smbstat_sub_64(uint64_t, uint64_t);
+static void smbstat_req_order(void);
+static double smbstat_zero(double);
+static void smbstat_termio_init(void);
+
+#pragma does_not_return(smbstat_fail, smbstat_usage)
+
+static char *smbstat_cpu_states[CPU_TICKS_SENTINEL] = {
+ "cpu_ticks_idle",
+ "cpu_ticks_user",
+ "cpu_ticks_kernel"
+};
-#define MAX_COLUMNS 80
+static boolean_t smbstat_opt_a = B_FALSE; /* all */
+static boolean_t smbstat_opt_c = B_FALSE; /* counters */
+static boolean_t smbstat_opt_n = B_FALSE; /* by name */
+static boolean_t smbstat_opt_u = B_FALSE; /* utilization */
+static boolean_t smbstat_opt_t = B_FALSE; /* throughput */
+static boolean_t smbstat_opt_r = B_FALSE; /* requests */
+static boolean_t smbstat_opt_z = B_FALSE; /* non-zero requests */
+static uint_t smbstat_interval = 0;
+static long smbstat_nrcpus = 0;
+static kstat_ctl_t *smbstat_ksc = NULL;
+static kstat_t *smbstat_srv_ksp = NULL;
+static kstat_t *smbstat_wrk_ksp = NULL;
+static struct winsize smbstat_ws;
+static uint16_t smbstat_rows = 0;
+
+static int smbstat_snapshot_idx = 0;
+static smbstat_cpu_snapshot_t *smbstat_cpu_snapshots[SMBSTAT_SNAPSHOT_COUNT];
+static smbstat_srv_snapshot_t smbstat_srv_snapshots[SMBSTAT_SNAPSHOT_COUNT];
+static smbstat_wrk_snapshot_t smbstat_wrk_snapshots[SMBSTAT_SNAPSHOT_COUNT];
+static smbstat_srv_info_t smbstat_srv_info;
+
+/*
+ * main
+ */
int
main(int argc, char *argv[])
{
- int c;
- int iflag = 0; /* smb_server stats */
- int dflag = 0; /* smb_cmds_all stats */
+ int c;
+
+ (void) setlocale(LC_ALL, "");
+ (void) textdomain(TEXT_DOMAIN);
if (getzoneid() != GLOBAL_ZONEID) {
(void) fprintf(stderr,
@@ -80,192 +321,781 @@ main(int argc, char *argv[])
return (0);
}
- while ((c = getopt(argc, argv, "id")) != EOF) {
+ while ((c = getopt(argc, argv, "achnrtuz")) != EOF) {
switch (c) {
- case 'i':
- iflag++;
+ case 'a':
+ smbstat_opt_a = B_TRUE;
break;
- case 'd':
- dflag++;
+ case 'n':
+ smbstat_opt_n = B_TRUE;
break;
- case '?':
+ case 'u':
+ smbstat_opt_u = B_TRUE;
+ break;
+ case 'c':
+ smbstat_opt_c = B_TRUE;
+ break;
+ case 'r':
+ smbstat_opt_r = B_TRUE;
+ break;
+ case 't':
+ smbstat_opt_t = B_TRUE;
+ break;
+ case 'z':
+ smbstat_opt_z = B_TRUE;
+ break;
+ case 'h':
+ smbstat_usage(stdout, 0);
default:
- smbstat_usage();
+ smbstat_usage(stderr, 1);
}
}
- if ((argc - optind) > 0) {
- smbstat_usage();
+ if (!smbstat_opt_u &&
+ !smbstat_opt_c &&
+ !smbstat_opt_r &&
+ !smbstat_opt_t) {
+ /* Default options when none is specified. */
+ smbstat_opt_u = B_TRUE;
+ smbstat_opt_t = B_TRUE;
}
- smbstat_init();
-
- if (iflag) {
- smbstat_smb_server_print();
- } else if (dflag) {
- smbstat_smb_cmds_print();
- } else {
- smbstat_smb_server_print();
- smbstat_smb_cmds_print();
+ if (optind < argc) {
+ smbstat_interval =
+ smbstat_strtoi(argv[optind], "invalid count");
+ optind++;
}
- smbstat_fini();
+ if ((argc - optind) > 1)
+ smbstat_usage(stderr, 1);
+
+ (void) atexit(smbstat_fini);
+ smbstat_init();
+ for (;;) {
+ smbstat_kstat_snapshot();
+ smbstat_kstat_process();
+ smbstat_kstat_print();
+ if (smbstat_interval == 0)
+ break;
+ (void) sleep(smbstat_interval);
+ smbstat_snapshot_inc_idx();
+ }
return (0);
}
+/*
+ * smbstat_init
+ *
+ * Global initialization.
+ */
+static void
+smbstat_init(void)
+{
+ if ((smbstat_ksc = kstat_open()) == NULL)
+ smbstat_fail(1, gettext("kstat_open(): can't open /dev/kstat"));
-static int
-get_smbinfo_stat(void)
+ smbstat_cpu_init();
+ smbstat_srv_init();
+ smbstat_wrk_init();
+ smbstat_req_order();
+}
+
+/*
+ * smbstat_fini
+ *
+ * Releases the resources smbstat_init() allocated.
+ */
+static void
+smbstat_fini(void)
{
- (void) smbstat_kstat_read(kc, smb_server, NULL);
- return (smbstat_width(smb_server, 0));
+ smbstat_wrk_fini();
+ smbstat_srv_fini();
+ smbstat_cpu_fini();
+ (void) kstat_close(smbstat_ksc);
}
-static int
-get_smbdispatch_stat(void)
+/*
+ * smbstat_kstat_snapshot
+ *
+ * Takes a snapshot of the data.
+ */
+static void
+smbstat_kstat_snapshot(void)
+{
+ smbstat_cpu_snapshot();
+ smbstat_srv_snapshot();
+ smbstat_wrk_snapshot();
+}
+
+/*
+ * smbstat_kstat_process
+ */
+static void
+smbstat_kstat_process(void)
+{
+ smbstat_cpu_process();
+ smbstat_srv_process();
+ smbstat_wrk_process();
+}
+
+/*
+ * smbstat_kstat_print
+ *
+ * Print the data processed.
+ */
+static void
+smbstat_kstat_print(void)
+{
+ smbstat_termio_init();
+ smbstat_print_counters();
+ smbstat_print_throughput();
+ smbstat_print_utilization();
+ smbstat_print_requests();
+}
+
+/*
+ * smbstat_print_counters
+ *
+ * Displays the SMB server counters (session, users...).
+ */
+static void
+smbstat_print_counters(void)
+{
+ if (!smbstat_opt_c)
+ return;
+
+ if (smbstat_opt_u || smbstat_opt_r || smbstat_opt_t ||
+ (smbstat_rows == 0) || (smbstat_rows >= smbstat_ws.ws_row)) {
+ (void) printf(SMBSRV_COUNTERS_BANNER);
+ smbstat_rows = 1;
+ }
+
+ (void) printf(SMBSRV_COUNTERS_FORMAT,
+ smbstat_srv_info.si_nbt_sess,
+ smbstat_srv_info.si_tcp_sess,
+ smbstat_srv_info.si_users,
+ smbstat_srv_info.si_trees,
+ smbstat_srv_info.si_files,
+ smbstat_srv_info.si_pipes);
+
+ ++smbstat_rows;
+}
+/*
+ * smbstat_print_throughput
+ *
+ * Formats the SMB server throughput output.
+ */
+static void
+smbstat_print_throughput(void)
+{
+ if (!smbstat_opt_t)
+ return;
+
+ if (smbstat_opt_u || smbstat_opt_r || smbstat_opt_c ||
+ (smbstat_rows == 0) || (smbstat_rows >= smbstat_ws.ws_row)) {
+ (void) printf(SMBSRV_THROUGHPUT_BANNER);
+ smbstat_rows = 1;
+ }
+ (void) printf(SMBSRV_THROUGHPUT_FORMAT,
+ smbstat_zero(smbstat_srv_info.si_rbs),
+ smbstat_zero(smbstat_srv_info.si_tbs),
+ smbstat_zero(smbstat_srv_info.si_rqs),
+ smbstat_zero(smbstat_srv_info.si_rds),
+ smbstat_zero(smbstat_srv_info.si_wrs));
+
+ ++smbstat_rows;
+}
+
+/*
+ * smbstat_print_utilization
+ */
+static void
+smbstat_print_utilization(void)
{
- (void) smbstat_kstat_read(kc, smb_cmds, NULL);
- return (smbstat_width(smb_cmds, 0));
+ char *sat;
+ if (!smbstat_opt_u)
+ return;
+
+ if (smbstat_opt_t || smbstat_opt_r || smbstat_opt_c ||
+ (smbstat_rows == 0) || (smbstat_rows >= smbstat_ws.ws_row)) {
+ (void) printf(SMBSRV_UTILIZATION_BANNER);
+ smbstat_rows = 1;
+ }
+
+ if (smbstat_srv_info.si_sat)
+ sat = "yes";
+ else
+ sat = "no ";
+
+ (void) printf(SMBSRV_UTILIZATION_FORMAT,
+ smbstat_srv_info.si_avw,
+ smbstat_srv_info.si_avr,
+ smbstat_srv_info.si_wserv,
+ smbstat_srv_info.si_rserv,
+ smbstat_zero(smbstat_srv_info.si_wpct),
+ smbstat_zero(smbstat_srv_info.si_rpct),
+ smbstat_zero(smbstat_srv_info.si_upct),
+ sat,
+ smbstat_srv_info.si_ticks[CPU_TICKS_USER],
+ smbstat_srv_info.si_ticks[CPU_TICKS_KERNEL],
+ smbstat_srv_info.si_ticks[CPU_TICKS_IDLE]);
+
+ ++smbstat_rows;
}
+/*
+ * smbstat_print_requests
+ */
static void
-smbstat_smb_server_print()
+smbstat_print_requests(void)
{
- int field_width;
- int i, j, nreq, ncolumns;
- char fixlen[128];
- kstat_named_t *knp;
+ smbstat_req_info_t *prq;
+ int i;
- field_width = get_smbinfo_stat();
- if (field_width == 0)
+ if (!smbstat_opt_r)
return;
- (void) printf("%s\n", "\nSMB Info:\n");
- ncolumns = (MAX_COLUMNS -1)/field_width;
+ prq = smbstat_srv_info.si_reqs;
+
+ (void) printf(SMBSRV_REQUESTS_BANNER, " ");
- knp = KSTAT_NAMED_PTR(smb_server);
- nreq = smb_server->ks_ndata;
+ for (i = 0; i < SMB_COM_NUM; i++) {
+ if (!smbstat_opt_a &&
+ strncmp(prq[i].ri_name, "Invalid", sizeof ("Invalid")) == 0)
+ continue;
- for (i = 0; i < nreq; i += ncolumns) {
- /* prints out the titles of the columns */
- for (j = i; j < MIN(i + ncolumns, nreq); j++) {
- (void) printf("%-*s", field_width, knp[j].name);
+ if (!smbstat_opt_z || (prq[i].ri_pct != 0)) {
+ (void) printf(SMBSRV_REQUESTS_FORMAT,
+ prq[i].ri_name,
+ prq[i].ri_opcode,
+ smbstat_zero(prq[i].ri_pct),
+ smbstat_zero(prq[i].ri_rbs),
+ smbstat_zero(prq[i].ri_tbs),
+ smbstat_zero(prq[i].ri_rqs),
+ prq[i].ri_mean,
+ prq[i].ri_stddev);
}
- (void) printf("\n");
- /* prints out the stat numbers */
- for (j = i; j < MIN(i + ncolumns, nreq); j++) {
- (void) sprintf(fixlen, "%" PRIu32 " ",
- knp[j].value.ui32);
- (void) printf("%-*s", field_width, fixlen);
+ }
+}
+
+/*
+ * smbstat_cpu_init
+ */
+static void
+smbstat_cpu_init(void)
+{
+ size_t size;
+ int i;
+
+ smbstat_nrcpus = sysconf(_SC_CPUID_MAX) + 1;
+ size = smbstat_nrcpus * sizeof (smbstat_cpu_snapshot_t);
+
+ for (i = 0; i < SMBSTAT_SNAPSHOT_COUNT; i++)
+ smbstat_cpu_snapshots[i] = smbstat_zalloc(size);
+}
+
+/*
+ * smbstat_cpu_fini
+ */
+static void
+smbstat_cpu_fini(void)
+{
+ size_t size;
+ int i;
+
+ size = smbstat_nrcpus * sizeof (smbstat_cpu_snapshot_t);
+
+ for (i = 0; i < SMBSTAT_SNAPSHOT_COUNT; i++)
+ smbstat_free(smbstat_cpu_snapshots[i], size);
+}
+
+/*
+ * smbstat_cpu_current_snapshot
+ */
+static smbstat_cpu_snapshot_t *
+smbstat_cpu_current_snapshot(void)
+{
+ return (smbstat_cpu_snapshots[smbstat_snapshot_idx]);
+}
+
+/*
+ * smbstat_cpu_previous_snapshot
+ */
+static smbstat_cpu_snapshot_t *
+smbstat_cpu_previous_snapshot(void)
+{
+ int idx;
+
+ idx = (smbstat_snapshot_idx - 1) & SMBSTAT_SNAPSHOT_MASK;
+ return (smbstat_cpu_snapshots[idx]);
+}
+
+/*
+ * smbstat_cpu_snapshot
+ */
+static void
+smbstat_cpu_snapshot(void)
+{
+ kstat_t *ksp;
+ kstat_named_t *ksn;
+ smbstat_cpu_snapshot_t *curr;
+ long i;
+ int j;
+
+ curr = smbstat_cpu_current_snapshot();
+
+ for (i = 0; i < smbstat_nrcpus; i++, curr++) {
+ curr->cs_id = SMBSTAT_ID_NO_CPU;
+ curr->cs_state = p_online(i, P_STATUS);
+ /* If no valid CPU is present, move on to the next one */
+ if (curr->cs_state == -1)
+ continue;
+
+ curr->cs_id = i;
+
+ ksp = kstat_lookup(smbstat_ksc, "cpu", i, "sys");
+ if (ksp == NULL)
+ smbstat_fail(1,
+ gettext("kstat_lookup('cpu sys %d') failed"), i);
+
+ if (kstat_read(smbstat_ksc, ksp, NULL) == -1)
+ smbstat_fail(1,
+ gettext("kstat_read('cpu sys %d') failed"), i);
+
+ for (j = 0; j < CPU_TICKS_SENTINEL; j++) {
+ ksn = kstat_data_lookup(ksp, smbstat_cpu_states[j]);
+ if (ksn == NULL)
+ smbstat_fail(1,
+ gettext("kstat_data_lookup('%s') failed"),
+ smbstat_cpu_states[j]);
+ curr->cs_ticks[j] = ksn->value.ui64;
}
- (void) printf("\n");
}
}
+/*
+ * smbstat_cpu_process
+ */
static void
-smbstat_smb_cmds_print()
+smbstat_cpu_process(void)
{
- int field_width;
+ smbstat_cpu_snapshot_t *curr, *prev;
+ double total_ticks;
+ double agg_ticks[CPU_TICKS_SENTINEL];
+ int i, j;
- field_width = get_smbdispatch_stat();
- if (field_width == 0)
- return;
+ curr = smbstat_cpu_current_snapshot();
+ prev = smbstat_cpu_previous_snapshot();
+ bzero(agg_ticks, sizeof (agg_ticks));
+ total_ticks = 0;
- smbstat_print(gettext("\nAll dispatched SMB requests statistics:\n"),
- smb_cmds, field_width);
+ for (i = 0; i < smbstat_nrcpus; i++, curr++, prev++) {
+ for (j = 0; j < CPU_TICKS_SENTINEL; j++) {
+ agg_ticks[j] += smbstat_sub_64(curr->cs_ticks[j],
+ prev->cs_ticks[j]);
+ total_ticks += smbstat_sub_64(curr->cs_ticks[j],
+ prev->cs_ticks[j]);
+ }
+ }
+
+ for (j = 0; j < CPU_TICKS_SENTINEL; j++)
+ smbstat_srv_info.si_ticks[j] =
+ (agg_ticks[j] * 100.0) / total_ticks;
}
+/*
+ * smbstat_wrk_init
+ */
static void
-smbstat_init(void)
+smbstat_wrk_init(void)
{
- char smbsrv_name[KSTAT_STRLEN];
+ smbstat_wrk_ksp =
+ kstat_lookup(smbstat_ksc, "unix", -1, SMBSRV_KSTAT_WORKERS);
+ if (smbstat_wrk_ksp == NULL)
+ smbstat_fail(1,
+ gettext("cannot retrieve smbsrv workers kstat\n"));
+}
- (void) snprintf(smbsrv_name, sizeof (smbsrv_name), "%s%d",
- SMBSRV_KSTAT_NAME, getzoneid());
+static void
+smbstat_wrk_fini(void)
+{
+ smbstat_wrk_ksp = NULL;
+}
- if ((kc = kstat_open()) == NULL)
- smbstat_fail(1, gettext("kstat_open(): can't open /dev/kstat"));
+/*
+ * smbstat_wrk_snapshot
+ */
+static void
+smbstat_wrk_snapshot(void)
+{
+ smbstat_wrk_snapshot_t *curr;
+ kstat_named_t *kn;
- smb_server = kstat_lookup(kc, SMBSRV_KSTAT_MODULE, 0, smbsrv_name);
- smb_cmds = kstat_lookup(kc, SMBSRV_KSTAT_MODULE, 0,
- SMBSRV_KSTAT_NAME_CMDS);
+ curr = smbstat_wrk_current_snapshot();
- if ((smb_server == NULL) || (smb_cmds == NULL))
- smbstat_fail(0, gettext("kstat lookups failed for smb. "
- "Your kernel module may not be loaded\n"));
+ if (kstat_read(smbstat_ksc, smbstat_wrk_ksp, NULL) == -1)
+ smbstat_fail(1, gettext("kstat_read('%s') failed"),
+ smbstat_wrk_ksp->ks_name);
+
+ kn = kstat_data_lookup(smbstat_wrk_ksp, "maxthreads");
+ if ((kn == NULL) || (kn->data_type != KSTAT_DATA_UINT64))
+ smbstat_fail(1, gettext("kstat_read('%s') failed"),
+ "maxthreads");
+ curr->ws_maxthreads = kn->value.ui64;
+
+ kn = kstat_data_lookup(smbstat_wrk_ksp, "bnalloc");
+ if ((kn == NULL) || (kn->data_type != KSTAT_DATA_UINT64))
+ smbstat_fail(1, gettext("kstat_read('%s') failed"),
+ "bnalloc");
+ curr->ws_bnalloc = kn->value.ui64;
}
+/*
+ * smbstat_wrk_process
+ */
static void
-smbstat_fini(void)
+smbstat_wrk_process(void)
{
- (void) kstat_close(kc);
+ smbstat_wrk_snapshot_t *curr;
+
+ curr = smbstat_wrk_current_snapshot();
+
+ if (curr->ws_maxthreads >= curr->ws_bnalloc)
+ smbstat_srv_info.si_sat = B_TRUE;
+ else
+ smbstat_srv_info.si_sat = B_FALSE;
}
-static int
-smbstat_width(kstat_t *req, int field_width)
-{
- int i, nreq, len;
- char fixlen[128];
- kstat_named_t *knp;
-
- knp = KSTAT_NAMED_PTR(req);
- nreq = req->ks_ndata;
-
- for (i = 0; i < nreq; i++) {
- len = strlen(knp[i].name) + 1;
- if (field_width < len)
- field_width = len;
- (void) sprintf(fixlen, "%" PRIu64, knp[i].value.ui64);
- len = strlen(fixlen) + 1;
- if (field_width < len)
- field_width = len;
+/*
+ * smbstat_wrk_current_snapshot
+ */
+static smbstat_wrk_snapshot_t *
+smbstat_wrk_current_snapshot(void)
+{
+ return (&smbstat_wrk_snapshots[smbstat_snapshot_idx]);
+}
+
+/*
+ * smbstat_srv_init
+ */
+static void
+smbstat_srv_init(void)
+{
+ smbstat_srv_ksp = kstat_lookup(smbstat_ksc, SMBSRV_KSTAT_MODULE,
+ getzoneid(), SMBSRV_KSTAT_STATISTICS);
+ if (smbstat_srv_ksp == NULL)
+ smbstat_fail(1, gettext("cannot retrieve smbsrv kstat\n"));
+}
+
+/*
+ * smbstat_srv_fini
+ */
+static void
+smbstat_srv_fini(void)
+{
+ smbstat_srv_ksp = NULL;
+}
+
+/*
+ * smbstat_srv_snapshot
+ *
+ * Take a snapshot of the smbsrv module statistics.
+ */
+static void
+smbstat_srv_snapshot(void)
+{
+ smbstat_srv_snapshot_t *curr;
+
+ curr = smbstat_srv_current_snapshot();
+
+ if ((kstat_read(smbstat_ksc, smbstat_srv_ksp, NULL) == -1) ||
+ (smbstat_srv_ksp->ks_data_size != sizeof (curr->ss_data)))
+ smbstat_fail(1, gettext("kstat_read('%s') failed"),
+ smbstat_srv_ksp->ks_name);
+
+ curr->ss_snaptime = smbstat_srv_ksp->ks_snaptime;
+ bcopy(smbstat_srv_ksp->ks_data, &curr->ss_data, sizeof (curr->ss_data));
+}
+
+/*
+ * smbstat_srv_process
+ *
+ * Processes the snapshot data.
+ */
+static void
+smbstat_srv_process(void)
+{
+ smbstat_srv_snapshot_t *curr, *prev;
+
+ curr = smbstat_srv_current_snapshot();
+ prev = smbstat_srv_previous_snapshot();
+
+ if (prev->ss_snaptime == 0)
+ smbstat_srv_info.si_hretime =
+ smbstat_hrtime_delta(curr->ss_data.ks_start_time,
+ curr->ss_snaptime);
+ else
+ smbstat_srv_info.si_hretime =
+ smbstat_hrtime_delta(prev->ss_snaptime, curr->ss_snaptime);
+
+ smbstat_srv_info.si_etime = smbstat_srv_info.si_hretime / NANOSEC;
+ smbstat_srv_info.si_total_nreqs =
+ smbstat_sub_64(curr->ss_data.ks_nreq, prev->ss_data.ks_nreq);
+
+ if (smbstat_opt_c)
+ smbstat_srv_process_counters(curr);
+ if (smbstat_opt_t)
+ smbstat_srv_process_throughput(curr, prev);
+ if (smbstat_opt_u)
+ smbstat_srv_process_utilization(curr, prev);
+ if (smbstat_opt_r)
+ smbstat_srv_process_requests(curr, prev);
+}
+
+/*
+ * smbstat_srv_process_counters
+ */
+static void
+smbstat_srv_process_counters(smbstat_srv_snapshot_t *curr)
+{
+ smbstat_srv_info.si_nbt_sess = curr->ss_data.ks_nbt_sess;
+ smbstat_srv_info.si_tcp_sess = curr->ss_data.ks_tcp_sess;
+ smbstat_srv_info.si_users = curr->ss_data.ks_users;
+ smbstat_srv_info.si_trees = curr->ss_data.ks_trees;
+ smbstat_srv_info.si_files = curr->ss_data.ks_files;
+ smbstat_srv_info.si_pipes = curr->ss_data.ks_pipes;
+}
+
+/*
+ * smbstat_srv_process_throughput
+ *
+ * Processes the data relative to the throughput of the smbsrv module and
+ * stores the results in the structure smbstat_srv_info.
+ */
+static void
+smbstat_srv_process_throughput(
+ smbstat_srv_snapshot_t *curr,
+ smbstat_srv_snapshot_t *prev)
+{
+ smbstat_srv_info.si_tbs =
+ smbstat_sub_64(curr->ss_data.ks_txb, prev->ss_data.ks_txb);
+ smbstat_srv_info.si_tbs /= smbstat_srv_info.si_etime;
+ smbstat_srv_info.si_rbs =
+ smbstat_sub_64(curr->ss_data.ks_rxb, prev->ss_data.ks_rxb);
+ smbstat_srv_info.si_rbs /= smbstat_srv_info.si_etime;
+ smbstat_srv_info.si_rqs = smbstat_srv_info.si_total_nreqs;
+ smbstat_srv_info.si_rqs /= smbstat_srv_info.si_etime;
+
+ smbstat_srv_info.si_rds = smbstat_sub_64(
+ curr->ss_data.ks_reqs[SMB_COM_READ].kr_nreq,
+ prev->ss_data.ks_reqs[SMB_COM_READ].kr_nreq);
+ smbstat_srv_info.si_rds += smbstat_sub_64(
+ curr->ss_data.ks_reqs[SMB_COM_LOCK_AND_READ].kr_nreq,
+ prev->ss_data.ks_reqs[SMB_COM_LOCK_AND_READ].kr_nreq);
+ smbstat_srv_info.si_rds += smbstat_sub_64(
+ curr->ss_data.ks_reqs[SMB_COM_READ_RAW].kr_nreq,
+ prev->ss_data.ks_reqs[SMB_COM_READ_RAW].kr_nreq);
+ smbstat_srv_info.si_rds += smbstat_sub_64(
+ curr->ss_data.ks_reqs[SMB_COM_READ_ANDX].kr_nreq,
+ prev->ss_data.ks_reqs[SMB_COM_READ_ANDX].kr_nreq);
+ smbstat_srv_info.si_rds /= smbstat_srv_info.si_etime;
+
+ smbstat_srv_info.si_wrs = smbstat_sub_64(
+ curr->ss_data.ks_reqs[SMB_COM_WRITE].kr_nreq,
+ prev->ss_data.ks_reqs[SMB_COM_WRITE].kr_nreq);
+ smbstat_srv_info.si_wrs += smbstat_sub_64(
+ curr->ss_data.ks_reqs[SMB_COM_WRITE_AND_UNLOCK].kr_nreq,
+ prev->ss_data.ks_reqs[SMB_COM_WRITE_AND_UNLOCK].kr_nreq);
+ smbstat_srv_info.si_wrs += smbstat_sub_64(
+ curr->ss_data.ks_reqs[SMB_COM_WRITE_RAW].kr_nreq,
+ prev->ss_data.ks_reqs[SMB_COM_WRITE_RAW].kr_nreq);
+ smbstat_srv_info.si_wrs += smbstat_sub_64(
+ curr->ss_data.ks_reqs[SMB_COM_WRITE_AND_CLOSE].kr_nreq,
+ prev->ss_data.ks_reqs[SMB_COM_WRITE_AND_CLOSE].kr_nreq);
+ smbstat_srv_info.si_wrs += smbstat_sub_64(
+ curr->ss_data.ks_reqs[SMB_COM_WRITE_ANDX].kr_nreq,
+ prev->ss_data.ks_reqs[SMB_COM_WRITE_ANDX].kr_nreq);
+ smbstat_srv_info.si_wrs /= smbstat_srv_info.si_etime;
+}
+
+/*
+ * smbstat_srv_process_utilization
+ *
+ * Processes the data relative to the utilization of the smbsrv module and
+ * stores the results in the structure smbstat_srv_info.
+ */
+static void
+smbstat_srv_process_utilization(
+ smbstat_srv_snapshot_t *curr,
+ smbstat_srv_snapshot_t *prev)
+{
+ double tw_delta, tr_delta;
+ double w_delta, r_delta;
+ double tps, rqs;
+
+ w_delta = smbstat_hrtime_delta(prev->ss_data.ks_utilization.ku_wlentime,
+ curr->ss_data.ks_utilization.ku_wlentime);
+ r_delta = smbstat_hrtime_delta(prev->ss_data.ks_utilization.ku_rlentime,
+ curr->ss_data.ks_utilization.ku_rlentime);
+ tw_delta = smbstat_hrtime_delta(prev->ss_data.ks_utilization.ku_wtime,
+ curr->ss_data.ks_utilization.ku_wtime);
+ tr_delta = smbstat_hrtime_delta(prev->ss_data.ks_utilization.ku_rtime,
+ curr->ss_data.ks_utilization.ku_rtime);
+ rqs = smbstat_srv_info.si_total_nreqs / smbstat_srv_info.si_etime;
+
+ /* Average number of requests waiting */
+ if (w_delta != 0)
+ smbstat_srv_info.si_avw = w_delta / smbstat_srv_info.si_hretime;
+ else
+ smbstat_srv_info.si_avw = 0.0;
+
+ /* Average number of request running */
+ if (r_delta != 0)
+ smbstat_srv_info.si_avr = r_delta / smbstat_srv_info.si_hretime;
+ else
+ smbstat_srv_info.si_avr = 0.0;
+
+ /* Utilization */
+ smbstat_srv_info.si_upct =
+ (smbstat_srv_info.si_avr / curr->ss_data.ks_maxreqs) * 100;
+
+ /* Average wait service time in milliseconds */
+ smbstat_srv_info.si_rserv = 0.0;
+ smbstat_srv_info.si_wserv = 0.0;
+ if (rqs > 0.0 &&
+ (smbstat_srv_info.si_avw != 0.0 ||
+ smbstat_srv_info.si_avr != 0.0)) {
+ tps = 1 / rqs;
+ if (smbstat_srv_info.si_avw != 0.0)
+ smbstat_srv_info.si_wserv =
+ smbstat_srv_info.si_avw * tps;
+ if (smbstat_srv_info.si_avr != 0.0)
+ smbstat_srv_info.si_rserv =
+ smbstat_srv_info.si_avr * tps;
+ }
+
+ /* % of time there is a transaction waiting for service */
+ if (tw_delta != 0) {
+ smbstat_srv_info.si_wpct = tw_delta;
+ smbstat_srv_info.si_wpct /= smbstat_srv_info.si_hretime;
+ smbstat_srv_info.si_wpct *= 100.0;
+ } else {
+ smbstat_srv_info.si_wpct = 0.0;
+ }
+
+ /* % of time there is a transaction running */
+ if (tr_delta != 0) {
+ smbstat_srv_info.si_rpct = tr_delta;
+ smbstat_srv_info.si_rpct /= smbstat_srv_info.si_hretime;
+ smbstat_srv_info.si_rpct *= 100.0;
+ } else {
+ smbstat_srv_info.si_rpct = 0.0;
}
- return (field_width);
}
+/*
+ * smbstat_srv_process_requests
+ *
+ * Processes the data relative to the SMB requests and stores the results in
+ * the structure smbstat_srv_info.
+ */
static void
-smbstat_print(const char *title_string, kstat_t *req, int field_width)
+smbstat_srv_process_requests(
+ smbstat_srv_snapshot_t *curr,
+ smbstat_srv_snapshot_t *prev)
{
- int i, j, nreq, ncolumns;
- char fixlen[128];
- kstat_named_t *knp;
+ smbstat_req_info_t *info;
+ double nrqs;
+ int i, idx;
- if (req == NULL)
- return;
+ info = smbstat_srv_info.si_reqs;
- if (field_width == 0)
- return;
+ for (i = 0; i < SMB_COM_NUM; i++) {
+ idx = info[i].ri_opcode;
+
+ nrqs = smbstat_sub_64(curr->ss_data.ks_reqs[idx].kr_nreq,
+ prev->ss_data.ks_reqs[idx].kr_nreq);
+
+ info[i].ri_rqs = nrqs / smbstat_srv_info.si_etime;
- (void) printf("%s\n", title_string);
- ncolumns = (MAX_COLUMNS -1)/field_width;
+ info[i].ri_rbs = smbstat_sub_64(
+ curr->ss_data.ks_reqs[idx].kr_rxb,
+ prev->ss_data.ks_reqs[idx].kr_rxb) /
+ smbstat_srv_info.si_etime;
- knp = KSTAT_NAMED_PTR(req);
- nreq = req->ks_ndata;
+ info[i].ri_tbs = smbstat_sub_64(
+ curr->ss_data.ks_reqs[idx].kr_txb,
+ prev->ss_data.ks_reqs[idx].kr_txb) /
+ smbstat_srv_info.si_etime;
- for (i = 0; i < nreq; i += ncolumns) {
- /* prints out the titles of the columns */
- for (j = i; j < MIN(i + ncolumns, nreq); j++) {
- (void) printf("%-*s", field_width, knp[j].name);
+ info[i].ri_pct = nrqs * 100;
+ if (smbstat_srv_info.si_total_nreqs > 0)
+ info[i].ri_pct /= smbstat_srv_info.si_total_nreqs;
+
+ if (prev->ss_snaptime == 0) {
+ /* First time. Take the aggregate */
+ info[i].ri_stddev =
+ curr->ss_data.ks_reqs[idx].kr_a_stddev;
+ info[i].ri_mean = curr->ss_data.ks_reqs[idx].kr_a_mean;
+ } else {
+ /* Take the differential */
+ info[i].ri_stddev =
+ curr->ss_data.ks_reqs[idx].kr_d_stddev;
+ info[i].ri_mean = curr->ss_data.ks_reqs[idx].kr_d_mean;
}
- (void) printf("\n");
- /* prints out the stat numbers */
- for (j = i; j < MIN(i + ncolumns, nreq); j++) {
- (void) sprintf(fixlen, "%" PRIu64 " ",
- knp[j].value.ui64);
- (void) printf("%-*s", field_width, fixlen);
+ if (nrqs > 0) {
+ info[i].ri_stddev /= nrqs;
+ info[i].ri_stddev = sqrt(info[i].ri_stddev);
+ } else {
+ info[i].ri_stddev = 0;
}
- (void) printf("\n");
-
+ info[i].ri_stddev /= NANOSEC;
+ info[i].ri_mean /= NANOSEC;
}
}
+/*
+ * smbstat_srv_current_snapshot
+ *
+ * Returns the current snapshot.
+ */
+static smbstat_srv_snapshot_t *
+smbstat_srv_current_snapshot(void)
+{
+ return (&smbstat_srv_snapshots[smbstat_snapshot_idx]);
+}
+
+/*
+ * smbstat_srv_previous_snapshot
+ *
+ * Returns the previous snapshot.
+ */
+static smbstat_srv_snapshot_t *
+smbstat_srv_previous_snapshot(void)
+{
+ int idx;
+
+ idx = (smbstat_snapshot_idx - 1) & SMBSTAT_SNAPSHOT_MASK;
+ return (&smbstat_srv_snapshots[idx]);
+}
+
+/*
+ * smbstat_usage
+ *
+ * Prints out a help message.
+ */
static void
-smbstat_usage(void)
+smbstat_usage(FILE *fd, int exit_code)
{
- (void) fprintf(stderr, gettext("Usage: smbstat [-id]\n"));
- exit(1);
+ (void) fprintf(fd, gettext(SMBSTAT_HELP));
+ exit(exit_code);
}
+/*
+ * smbstat_fail
+ *
+ * Prints out to stderr an error message and exits the process.
+ */
static void
smbstat_fail(int do_perror, char *message, ...)
{
@@ -282,30 +1112,196 @@ smbstat_fail(int do_perror, char *message, ...)
exit(1);
}
-static kid_t
-smbstat_kstat_read(kstat_ctl_t *kc, kstat_t *ksp, void *data)
+/*
+ * smbstat_sub_64
+ *
+ * Substract 2 uint64_t and returns a double.
+ */
+static double
+smbstat_sub_64(uint64_t a, uint64_t b)
{
- kid_t kstat_chain_id = kstat_read(kc, ksp, data);
+ return ((double)(a - b));
+}
- if (kstat_chain_id == -1)
- smbstat_fail(1, gettext("kstat_read('%s') failed"),
- ksp->ks_name);
- return (kstat_chain_id);
+/*
+ * smbstat_zero
+ *
+ * Returns zero if the value passed in is less than 1.
+ */
+static double
+smbstat_zero(double value)
+{
+ if (value < 1)
+ value = 0;
+ return (value);
+}
+
+/*
+ * smbstat_strtoi
+ *
+ * Converts a string representing an integer value into its binary value.
+ * If the conversion fails this routine exits the process.
+ */
+static uint_t
+smbstat_strtoi(char const *val, char *errmsg)
+{
+ char *end;
+ long tmp;
+
+ errno = 0;
+ tmp = strtol(val, &end, 10);
+ if (*end != '\0' || errno)
+ smbstat_fail(1, "%s %s", errmsg, val);
+ return ((uint_t)tmp);
+}
+
+/*
+ * smbstat_termio_init
+ *
+ * Determines the size of the terminal associated with the process.
+ */
+static void
+smbstat_termio_init(void)
+{
+ char *envp;
+
+ if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &smbstat_ws) != -1) {
+ if (smbstat_ws.ws_row == 0) {
+ envp = getenv("LINES");
+ if (envp != NULL)
+ smbstat_ws.ws_row = atoi(envp);
+ }
+
+ if (smbstat_ws.ws_col == 0) {
+ envp = getenv("COLUMNS");
+ if (envp != NULL)
+ smbstat_ws.ws_row = atoi(envp);
+ }
+ }
+ if (smbstat_ws.ws_col == 0)
+ smbstat_ws.ws_col = 80;
+ if (smbstat_ws.ws_row == 0)
+ smbstat_ws.ws_row = 25;
+}
+
+/*
+ * smbstat_snapshot_idx_inc
+ *
+ * Increments the snapshot index.
+ */
+static void
+smbstat_snapshot_inc_idx(void)
+{
+ smbstat_snapshot_idx++;
+ smbstat_snapshot_idx &= SMBSTAT_SNAPSHOT_MASK;
}
/*
- * Enable libumem debugging by default on DEBUG builds.
+ * smbstat_req_cmp_name
+ *
+ * Call back function passed to qsort() when the list of requests must be sorted
+ * by name.
*/
-#ifdef DEBUG
-const char *
-_umem_debug_init(void)
+static int
+smbstat_req_cmp_name(const void *obj1, const void *obj2)
{
- return ("default,verbose"); /* $UMEM_DEBUG setting */
+ return (strncasecmp(
+ ((smbstat_req_info_t *)obj1)->ri_name,
+ ((smbstat_req_info_t *)obj2)->ri_name,
+ sizeof (((smbstat_req_info_t *)obj2)->ri_name)));
}
-const char *
-_umem_logging_init(void)
+/*
+ * smbstat_req_order
+ *
+ * Snapshots the smbsrv module statistics once to get the name of the requests.
+ * The request list is smbstat_srv_info is then sorted by name or by code
+ * depending on the boolean smbstat_opt_a.
+ * The function should be called once during initialization.
+ */
+static void
+smbstat_req_order(void)
+{
+ smbstat_req_info_t *info;
+ smb_kstat_req_t *reqs;
+ int i;
+
+ smbstat_srv_snapshot();
+ reqs = smbstat_srv_current_snapshot()->ss_data.ks_reqs;
+ info = smbstat_srv_info.si_reqs;
+
+ for (i = 0; i < SMB_COM_NUM; i++) {
+ (void) strlcpy(info[i].ri_name, reqs[i].kr_name,
+ sizeof (reqs[i].kr_name));
+ info[i].ri_opcode = i;
+ }
+ if (smbstat_opt_n)
+ qsort(info, SMB_COM_NUM, sizeof (smbstat_req_info_t),
+ smbstat_req_cmp_name);
+}
+
+/*
+ * Return the number of ticks delta between two hrtime_t
+ * values. Attempt to cater for various kinds of overflow
+ * in hrtime_t - no matter how improbable.
+ */
+static double
+smbstat_hrtime_delta(hrtime_t old, hrtime_t new)
+{
+ uint64_t del;
+
+ if ((new >= old) && (old >= 0L))
+ return ((double)(new - old));
+ /*
+ * We've overflowed the positive portion of an hrtime_t.
+ */
+ if (new < 0L) {
+ /*
+ * The new value is negative. Handle the case where the old
+ * value is positive or negative.
+ */
+ uint64_t n1;
+ uint64_t o1;
+
+ n1 = -new;
+ if (old > 0L)
+ return ((double)(n1 - old));
+
+ o1 = -old;
+ del = n1 - o1;
+ return ((double)del);
+ }
+
+ /*
+ * Either we've just gone from being negative to positive *or* the last
+ * entry was positive and the new entry is also positive but *less* than
+ * the old entry. This implies we waited quite a few days on a very fast
+ * system between displays.
+ */
+ if (old < 0L) {
+ uint64_t o2;
+ o2 = -old;
+ del = UINT64_MAX - o2;
+ } else {
+ del = UINT64_MAX - old;
+ }
+ del += new;
+ return ((double)del);
+}
+
+static void *
+smbstat_zalloc(size_t size)
+{
+ void *ptr;
+
+ ptr = umem_zalloc(size, UMEM_DEFAULT);
+ if (ptr == NULL)
+ smbstat_fail(1, gettext("out of memory"));
+ return (ptr);
+}
+
+static void
+smbstat_free(void *ptr, size_t size)
{
- return ("fail,contents"); /* $UMEM_LOGGING setting */
+ umem_free(ptr, size);
}
-#endif
diff --git a/usr/src/common/smbsrv/smb_match.c b/usr/src/common/smbsrv/smb_match.c
index 88758926fe..4e1f174fcf 100644
--- a/usr/src/common/smbsrv/smb_match.c
+++ b/usr/src/common/smbsrv/smb_match.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _KERNEL
@@ -45,20 +44,14 @@ static int smb_match_private(const char *, const char *, int *);
static int smb_match_ci_private(const char *, const char *, int *);
/*
- * Returns:
- * 1 match
- * 0 no-match
+ * smb_match
*/
-int
+boolean_t
smb_match(char *patn, char *str)
{
int depth = 0;
- int rc;
-
- if ((rc = smb_match_private(patn, str, &depth)) == -1)
- rc = 0;
- return (rc);
+ return (smb_match_private(patn, str, &depth) == 1);
}
/*
@@ -121,56 +114,15 @@ smb_match_private(const char *patn, const char *str, int *depth)
/*NOTREACHED*/
}
-int
-smb_match83(char *patn, char *str83)
-{
- int avail;
- char *ptr;
- char name83[14];
-
- ptr = name83;
- for (avail = SMB_NAME83_BASELEN;
- (avail > 0) && (*patn != '.') && (*patn != 0);
- avail--) {
- *(ptr++) = *(patn++);
- }
- while (avail--)
- *(ptr++) = ' ';
- *(ptr++) = '.';
-
- if (*patn == '.')
- patn++;
- else if (*patn != 0)
- return (0);
-
- for (avail = SMB_NAME83_EXTLEN; (avail > 0) && (*patn != 0); avail--) {
- *(ptr++) = *(patn++);
- }
- if (*patn != 0)
- return (0);
-
- while (avail--)
- *(ptr++) = ' ';
- *ptr = 0;
-
- return (smb_match_ci(name83, str83));
-}
-
/*
- * Returns:
- * 1 match
- * 0 no-match
+ * smb_match_ci
*/
-int
+boolean_t
smb_match_ci(char *patn, char *str)
{
int depth = 0;
- int rc;
-
- if ((rc = smb_match_ci_private(patn, str, &depth)) == -1)
- rc = 0;
- return (rc);
+ return (smb_match_ci_private(patn, str, &depth) == 1);
}
/*
diff --git a/usr/src/common/smbsrv/smb_sid.c b/usr/src/common/smbsrv/smb_sid.c
index 4e5c25ca76..763b3616f5 100644
--- a/usr/src/common/smbsrv/smb_sid.c
+++ b/usr/src/common/smbsrv/smb_sid.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _KERNEL
@@ -282,7 +281,7 @@ smb_sid_islocal(smb_sid_t *sid)
* binary sid.
*/
void
-smb_sid_tostr(smb_sid_t *sid, char *strsid)
+smb_sid_tostr(const smb_sid_t *sid, char *strsid)
{
char *p = strsid;
int i;
@@ -325,11 +324,11 @@ smb_sid_tostr(smb_sid_t *sid, char *strsid)
*/
#ifdef _KERNEL
smb_sid_t *
-smb_sid_fromstr(char *sidstr)
+smb_sid_fromstr(const char *sidstr)
{
smb_sid_t *sid;
smb_sid_t *retsid;
- char *p;
+ const char *p;
int size;
uint8_t i;
unsigned long sua;
@@ -373,10 +372,10 @@ smb_sid_fromstr(char *sidstr)
}
#else /* _KERNEL */
smb_sid_t *
-smb_sid_fromstr(char *sidstr)
+smb_sid_fromstr(const char *sidstr)
{
smb_sid_t *sid;
- char *p;
+ const char *p;
int size;
uint8_t i;
diff --git a/usr/src/common/smbsrv/smb_status_xlat.c b/usr/src/common/smbsrv/smb_status_xlat.c
deleted file mode 100644
index 987a154403..0000000000
--- a/usr/src/common/smbsrv/smb_status_xlat.c
+++ /dev/null
@@ -1,597 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * This file provides a text translation service for NT status codes.
- */
-
-#ifdef _KERNEL
-#include <sys/types.h>
-#include <sys/sunddi.h>
-#else
-#include <syslog.h>
-#include <stdio.h>
-#endif /* _KERNEL */
-#include <smbsrv/ntstatus.h>
-
-typedef struct xlate_table {
- DWORD value;
- char *name;
-} xlate_table_t;
-
-
-static xlate_table_t ntx_table[] = {
- { NT_STATUS_SUCCESS, "SUCCESS" },
- { NT_STATUS_UNSUCCESSFUL, "UNSUCCESSFUL" },
- { NT_STATUS_NOT_IMPLEMENTED, "NOT_IMPLEMENTED" },
- { NT_STATUS_INVALID_INFO_CLASS, "INVALID_INFO_CLASS" },
- { NT_STATUS_INFO_LENGTH_MISMATCH, "INFO_LENGTH_MISMATCH" },
- { NT_STATUS_BUFFER_OVERFLOW, "BUFFER_OVERFLOW" },
- /*
- * There seems to be some overloading of status codes.
- * NT_STATUS_IN_PAGE_ERROR is NT_STATUS_NO_MORE_FILES
- */
- { NT_STATUS_NO_MORE_FILES, "NO MORE FILES" },
- { NT_STATUS_PAGEFILE_QUOTA, "PAGEFILE_QUOTA" },
- { NT_STATUS_INVALID_HANDLE, "INVALID_HANDLE" },
- { NT_STATUS_BAD_INITIAL_STACK, "BAD_INITIAL_STACK" },
- { NT_STATUS_BAD_INITIAL_PC, "BAD_INITIAL_PC" },
- { NT_STATUS_INVALID_CID, "INVALID_CID" },
- { NT_STATUS_TIMER_NOT_CANCELED, "TIMER_NOT_CANCELED" },
- { NT_STATUS_INVALID_PARAMETER, "INVALID_PARAMETER" },
- { NT_STATUS_NO_SUCH_DEVICE, "NO_SUCH_DEVICE" },
- { NT_STATUS_NO_SUCH_FILE, "NO_SUCH_FILE" },
- { NT_STATUS_INVALID_DEVICE_REQUEST, "INVALID_DEVICE_REQUEST" },
- { NT_STATUS_END_OF_FILE, "END_OF_FILE" },
- { NT_STATUS_WRONG_VOLUME, "WRONG_VOLUME" },
- { NT_STATUS_NO_MEDIA_IN_DEVICE, "NO_MEDIA_IN_DEVICE" },
- { NT_STATUS_UNRECOGNIZED_MEDIA, "UNRECOGNIZED_MEDIA" },
- { NT_STATUS_NONEXISTENT_SECTOR, "NONEXISTENT_SECTOR" },
- { NT_STATUS_MORE_PROCESSING_REQUIRED, "MORE_PROCESSING_REQUIRED" },
- { NT_STATUS_NO_MEMORY, "NO_MEMORY" },
- { NT_STATUS_CONFLICTING_ADDRESSES, "CONFLICTING_ADDRESSES" },
- { NT_STATUS_NOT_MAPPED_VIEW, "NOT_MAPPED_VIEW" },
-
- /*
- * There seems to be some overloading of status codes.
- * When we get NT_STATUS_UNABLE_TO_FREE_VM it really
- * means NT_STATUS_NO_MORE_DATA.
- */
- { NT_STATUS_UNABLE_TO_FREE_VM, "NO_MORE_DATA" },
-
- { NT_STATUS_UNABLE_TO_DELETE_SECTION, "UNABLE_TO_DELETE_SECTION" },
- { NT_STATUS_INVALID_SYSTEM_SERVICE, "INVALID_SYSTEM_SERVICE" },
- { NT_STATUS_ILLEGAL_INSTRUCTION, "ILLEGAL_INSTRUCTION" },
- { NT_STATUS_INVALID_LOCK_SEQUENCE, "INVALID_LOCK_SEQUENCE" },
- { NT_STATUS_INVALID_VIEW_SIZE, "INVALID_VIEW_SIZE" },
- { NT_STATUS_INVALID_FILE_FOR_SECTION, "INVALID_FILE_FOR_SECTION" },
- { NT_STATUS_ALREADY_COMMITTED, "ALREADY_COMMITTED" },
- { NT_STATUS_ACCESS_DENIED, "ACCESS_DENIED" },
- { NT_STATUS_BUFFER_TOO_SMALL, "BUFFER_TOO_SMALL" },
- { NT_STATUS_OBJECT_TYPE_MISMATCH, "OBJECT_TYPE_MISMATCH" },
- { NT_STATUS_NONCONTINUABLE_EXCEPTION, "NONCONTINUABLE_EXCEPTION" },
- { NT_STATUS_INVALID_DISPOSITION, "INVALID_DISPOSITION" },
- { NT_STATUS_UNWIND, "UNWIND" },
- { NT_STATUS_BAD_STACK, "BAD_STACK" },
- { NT_STATUS_INVALID_UNWIND_TARGET, "INVALID_UNWIND_TARGET" },
- { NT_STATUS_NOT_LOCKED, "NOT_LOCKED" },
- { NT_STATUS_PARITY_ERROR, "PARITY_ERROR" },
- { NT_STATUS_UNABLE_TO_DECOMMIT_VM, "UNABLE_TO_DECOMMIT_VM" },
- { NT_STATUS_NOT_COMMITTED, "NOT_COMMITTED" },
- { NT_STATUS_INVALID_PORT_ATTRIBUTES, "INVALID_PORT_ATTRIBUTES" },
- { NT_STATUS_PORT_MESSAGE_TOO_LONG, "PORT_MESSAGE_TOO_LONG" },
- { NT_STATUS_INVALID_PARAMETER_MIX, "INVALID_PARAMETER_MIX" },
- { NT_STATUS_INVALID_QUOTA_LOWER, "INVALID_QUOTA_LOWER" },
- { NT_STATUS_DISK_CORRUPT_ERROR, "DISK_CORRUPT_ERROR" },
- { NT_STATUS_OBJECT_NAME_INVALID, "OBJECT_NAME_INVALID" },
- { NT_STATUS_OBJECT_NAME_NOT_FOUND, "OBJECT_NAME_NOT_FOUND" },
- { NT_STATUS_OBJECT_NAME_COLLISION, "OBJECT_NAME_COLLISION" },
- { NT_STATUS_HANDLE_NOT_WAITABLE, "HANDLE_NOT_WAITABLE" },
- { NT_STATUS_PORT_DISCONNECTED, "PORT_DISCONNECTED" },
- { NT_STATUS_DEVICE_ALREADY_ATTACHED, "DEVICE_ALREADY_ATTACHED" },
- { NT_STATUS_OBJECT_PATH_INVALID, "OBJECT_PATH_INVALID" },
- { NT_STATUS_OBJECT_PATH_NOT_FOUND, "OBJECT_PATH_NOT_FOUND" },
- { NT_STATUS_OBJECT_PATH_SYNTAX_BAD, "OBJECT_PATH_SYNTAX_BAD" },
- { NT_STATUS_DATA_OVERRUN, "DATA_OVERRUN" },
- { NT_STATUS_DATA_LATE_ERROR, "DATA_LATE_ERROR" },
- { NT_STATUS_DATA_ERROR, "DATA_ERROR" },
- { NT_STATUS_CRC_ERROR, "CRC_ERROR" },
- { NT_STATUS_SECTION_TOO_BIG, "SECTION_TOO_BIG" },
- { NT_STATUS_PORT_CONNECTION_REFUSED, "PORT_CONNECTION_REFUSED" },
- { NT_STATUS_INVALID_PORT_HANDLE, "INVALID_PORT_HANDLE" },
- { NT_STATUS_SHARING_VIOLATION, "SHARING_VIOLATION" },
- { NT_STATUS_QUOTA_EXCEEDED, "QUOTA_EXCEEDED" },
- { NT_STATUS_INVALID_PAGE_PROTECTION, "INVALID_PAGE_PROTECTION" },
- { NT_STATUS_MUTANT_NOT_OWNED, "MUTANT_NOT_OWNED" },
- { NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED, "SEMAPHORE_LIMIT_EXCEEDED" },
- { NT_STATUS_PORT_ALREADY_SET, "PORT_ALREADY_SET" },
- { NT_STATUS_SECTION_NOT_IMAGE, "SECTION_NOT_IMAGE" },
- { NT_STATUS_SUSPEND_COUNT_EXCEEDED, "SUSPEND_COUNT_EXCEEDED" },
- { NT_STATUS_THREAD_IS_TERMINATING, "THREAD_IS_TERMINATING" },
- { NT_STATUS_BAD_WORKING_SET_LIMIT, "BAD_WORKING_SET_LIMIT" },
- { NT_STATUS_INCOMPATIBLE_FILE_MAP, "INCOMPATIBLE_FILE_MAP" },
- { NT_STATUS_SECTION_PROTECTION, "SECTION_PROTECTION" },
- { NT_STATUS_EAS_NOT_SUPPORTED, "EAS_NOT_SUPPORTED" },
- { NT_STATUS_EA_TOO_LARGE, "EA_TOO_LARGE" },
- { NT_STATUS_NONEXISTENT_EA_ENTRY, "NONEXISTENT_EA_ENTRY" },
- { NT_STATUS_NO_EAS_ON_FILE, "NO_EAS_ON_FILE" },
- { NT_STATUS_EA_CORRUPT_ERROR, "EA_CORRUPT_ERROR" },
- { NT_STATUS_FILE_LOCK_CONFLICT, "FILE_LOCK_CONFLICT" },
- { NT_STATUS_LOCK_NOT_GRANTED, "LOCK_NOT_GRANTED" },
- { NT_STATUS_DELETE_PENDING, "DELETE_PENDING" },
- { NT_STATUS_CTL_FILE_NOT_SUPPORTED, "CTL_FILE_NOT_SUPPORTED" },
- { NT_STATUS_UNKNOWN_REVISION, "UNKNOWN_REVISION" },
- { NT_STATUS_REVISION_MISMATCH, "REVISION_MISMATCH" },
- { NT_STATUS_INVALID_OWNER, "INVALID_OWNER" },
- { NT_STATUS_INVALID_PRIMARY_GROUP, "INVALID_PRIMARY_GROUP" },
- { NT_STATUS_NO_IMPERSONATION_TOKEN, "NO_IMPERSONATION_TOKEN" },
- { NT_STATUS_CANT_DISABLE_MANDATORY, "CANT_DISABLE_MANDATORY" },
- { NT_STATUS_NO_LOGON_SERVERS, "NO_LOGON_SERVERS" },
- { NT_STATUS_NO_SUCH_LOGON_SESSION, "NO_SUCH_LOGON_SESSION" },
- { NT_STATUS_NO_SUCH_PRIVILEGE, "NO_SUCH_PRIVILEGE" },
- { NT_STATUS_PRIVILEGE_NOT_HELD, "PRIVILEGE_NOT_HELD" },
- { NT_STATUS_INVALID_ACCOUNT_NAME, "INVALID_ACCOUNT_NAME" },
- { NT_STATUS_USER_EXISTS, "USER_EXISTS" },
- { NT_STATUS_NO_SUCH_USER, "NO_SUCH_USER" },
- { NT_STATUS_GROUP_EXISTS, "GROUP_EXISTS" },
- { NT_STATUS_NO_SUCH_GROUP, "NO_SUCH_GROUP" },
- { NT_STATUS_MEMBER_IN_GROUP, "MEMBER_IN_GROUP" },
- { NT_STATUS_MEMBER_NOT_IN_GROUP, "MEMBER_NOT_IN_GROUP" },
- { NT_STATUS_LAST_ADMIN, "LAST_ADMIN" },
- { NT_STATUS_WRONG_PASSWORD, "WRONG_PASSWORD" },
- { NT_STATUS_ILL_FORMED_PASSWORD, "ILL_FORMED_PASSWORD" },
- { NT_STATUS_PASSWORD_RESTRICTION, "PASSWORD_RESTRICTION" },
- { NT_STATUS_LOGON_FAILURE, "LOGON_FAILURE" },
- { NT_STATUS_ACCOUNT_RESTRICTION, "ACCOUNT_RESTRICTION" },
- { NT_STATUS_INVALID_LOGON_HOURS, "INVALID_LOGON_HOURS" },
- { NT_STATUS_INVALID_WORKSTATION, "INVALID_WORKSTATION" },
- { NT_STATUS_PASSWORD_EXPIRED, "PASSWORD_EXPIRED" },
- { NT_STATUS_ACCOUNT_DISABLED, "ACCOUNT_DISABLED" },
- { NT_STATUS_NONE_MAPPED, "NONE_MAPPED" },
- { NT_STATUS_TOO_MANY_LUIDS_REQUESTED, "TOO_MANY_LUIDS_REQUESTED" },
- { NT_STATUS_LUIDS_EXHAUSTED, "LUIDS_EXHAUSTED" },
- { NT_STATUS_INVALID_SUB_AUTHORITY, "INVALID_SUB_AUTHORITY" },
- { NT_STATUS_INVALID_ACL, "INVALID_ACL" },
- { NT_STATUS_INVALID_SID, "INVALID_SID" },
- { NT_STATUS_INVALID_SECURITY_DESCR, "INVALID_SECURITY_DESCR" },
- { NT_STATUS_PROCEDURE_NOT_FOUND, "PROCEDURE_NOT_FOUND" },
- { NT_STATUS_INVALID_IMAGE_FORMAT, "INVALID_IMAGE_FORMAT" },
- { NT_STATUS_NO_TOKEN, "NO_TOKEN" },
- { NT_STATUS_BAD_INHERITANCE_ACL, "BAD_INHERITANCE_ACL" },
- { NT_STATUS_RANGE_NOT_LOCKED, "RANGE_NOT_LOCKED" },
- { NT_STATUS_DISK_FULL, "DISK_FULL" },
- { NT_STATUS_SERVER_DISABLED, "SERVER_DISABLED" },
- { NT_STATUS_SERVER_NOT_DISABLED, "SERVER_NOT_DISABLED" },
- { NT_STATUS_TOO_MANY_GUIDS_REQUESTED, "TOO_MANY_GUIDS_REQUESTED" },
- { NT_STATUS_GUIDS_EXHAUSTED, "GUIDS_EXHAUSTED" },
- { NT_STATUS_INVALID_ID_AUTHORITY, "INVALID_ID_AUTHORITY" },
- { NT_STATUS_AGENTS_EXHAUSTED, "AGENTS_EXHAUSTED" },
- { NT_STATUS_INVALID_VOLUME_LABEL, "INVALID_VOLUME_LABEL" },
- { NT_STATUS_SECTION_NOT_EXTENDED, "SECTION_NOT_EXTENDED" },
- { NT_STATUS_NOT_MAPPED_DATA, "NOT_MAPPED_DATA" },
- { NT_STATUS_RESOURCE_DATA_NOT_FOUND, "RESOURCE_DATA_NOT_FOUND" },
- { NT_STATUS_RESOURCE_TYPE_NOT_FOUND, "RESOURCE_TYPE_NOT_FOUND" },
- { NT_STATUS_RESOURCE_NAME_NOT_FOUND, "RESOURCE_NAME_NOT_FOUND" },
- { NT_STATUS_ARRAY_BOUNDS_EXCEEDED, "ARRAY_BOUNDS_EXCEEDED" },
- { NT_STATUS_FLOAT_DENORMAL_OPERAND, "FLOAT_DENORMAL_OPERAND" },
- { NT_STATUS_FLOAT_DIVIDE_BY_ZERO, "FLOAT_DIVIDE_BY_ZERO" },
- { NT_STATUS_FLOAT_INEXACT_RESULT, "FLOAT_INEXACT_RESULT" },
- { NT_STATUS_FLOAT_INVALID_OPERATION, "FLOAT_INVALID_OPERATION" },
- { NT_STATUS_FLOAT_OVERFLOW, "FLOAT_OVERFLOW" },
- { NT_STATUS_FLOAT_STACK_CHECK, "FLOAT_STACK_CHECK" },
- { NT_STATUS_FLOAT_UNDERFLOW, "FLOAT_UNDERFLOW" },
- { NT_STATUS_INTEGER_DIVIDE_BY_ZERO, "INTEGER_DIVIDE_BY_ZERO" },
- { NT_STATUS_INTEGER_OVERFLOW, "INTEGER_OVERFLOW" },
- { NT_STATUS_PRIVILEGED_INSTRUCTION, "PRIVILEGED_INSTRUCTION" },
- { NT_STATUS_TOO_MANY_PAGING_FILES, "TOO_MANY_PAGING_FILES" },
- { NT_STATUS_FILE_INVALID, "FILE_INVALID" },
- { NT_STATUS_ALLOTTED_SPACE_EXCEEDED, "ALLOTTED_SPACE_EXCEEDED" },
- { NT_STATUS_INSUFFICIENT_RESOURCES, "INSUFFICIENT_RESOURCES" },
- { NT_STATUS_DFS_EXIT_PATH_FOUND, "DFS_EXIT_PATH_FOUND" },
- { NT_STATUS_DEVICE_DATA_ERROR, "DEVICE_DATA_ERROR" },
- { NT_STATUS_DEVICE_NOT_CONNECTED, "DEVICE_NOT_CONNECTED" },
- { NT_STATUS_DEVICE_POWER_FAILURE, "DEVICE_POWER_FAILURE" },
- { NT_STATUS_FREE_VM_NOT_AT_BASE, "FREE_VM_NOT_AT_BASE" },
- { NT_STATUS_MEMORY_NOT_ALLOCATED, "MEMORY_NOT_ALLOCATED" },
- { NT_STATUS_WORKING_SET_QUOTA, "WORKING_SET_QUOTA" },
- { NT_STATUS_MEDIA_WRITE_PROTECTED, "MEDIA_WRITE_PROTECTED" },
- { NT_STATUS_DEVICE_NOT_READY, "DEVICE_NOT_READY" },
- { NT_STATUS_INVALID_GROUP_ATTRIBUTES, "INVALID_GROUP_ATTRIBUTES" },
- { NT_STATUS_BAD_IMPERSONATION_LEVEL, "BAD_IMPERSONATION_LEVEL" },
- { NT_STATUS_CANT_OPEN_ANONYMOUS, "CANT_OPEN_ANONYMOUS" },
- { NT_STATUS_BAD_VALIDATION_CLASS, "BAD_VALIDATION_CLASS" },
- { NT_STATUS_BAD_TOKEN_TYPE, "BAD_TOKEN_TYPE" },
- { NT_STATUS_BAD_MASTER_BOOT_RECORD, "BAD_MASTER_BOOT_RECORD" },
- { NT_STATUS_INSTRUCTION_MISALIGNMENT, "INSTRUCTION_MISALIGNMENT" },
- { NT_STATUS_INSTANCE_NOT_AVAILABLE, "INSTANCE_NOT_AVAILABLE" },
- { NT_STATUS_PIPE_NOT_AVAILABLE, "PIPE_NOT_AVAILABLE" },
- { NT_STATUS_INVALID_PIPE_STATE, "INVALID_PIPE_STATE" },
- { NT_STATUS_PIPE_BUSY, "PIPE_BUSY" },
- { NT_STATUS_ILLEGAL_FUNCTION, "ILLEGAL_FUNCTION" },
- { NT_STATUS_PIPE_DISCONNECTED, "PIPE_DISCONNECTED" },
- { NT_STATUS_PIPE_CLOSING, "PIPE_CLOSING" },
- { NT_STATUS_PIPE_CONNECTED, "PIPE_CONNECTED" },
- { NT_STATUS_PIPE_LISTENING, "PIPE_LISTENING" },
- { NT_STATUS_INVALID_READ_MODE, "INVALID_READ_MODE" },
- { NT_STATUS_IO_TIMEOUT, "IO_TIMEOUT" },
- { NT_STATUS_FILE_FORCED_CLOSED, "FILE_FORCED_CLOSED" },
- { NT_STATUS_PROFILING_NOT_STARTED, "PROFILING_NOT_STARTED" },
- { NT_STATUS_PROFILING_NOT_STOPPED, "PROFILING_NOT_STOPPED" },
- { NT_STATUS_COULD_NOT_INTERPRET, "COULD_NOT_INTERPRET" },
- { NT_STATUS_FILE_IS_A_DIRECTORY, "FILE_IS_A_DIRECTORY" },
- { NT_STATUS_NOT_SUPPORTED, "NOT_SUPPORTED" },
- { NT_STATUS_REMOTE_NOT_LISTENING, "REMOTE_NOT_LISTENING" },
- { NT_STATUS_DUPLICATE_NAME, "DUPLICATE_NAME" },
- { NT_STATUS_BAD_NETWORK_PATH, "BAD_NETWORK_PATH" },
- { NT_STATUS_NETWORK_BUSY, "NETWORK_BUSY" },
- { NT_STATUS_DEVICE_DOES_NOT_EXIST, "DEVICE_DOES_NOT_EXIST" },
- { NT_STATUS_TOO_MANY_COMMANDS, "TOO_MANY_COMMANDS" },
- { NT_STATUS_ADAPTER_HARDWARE_ERROR, "ADAPTER_HARDWARE_ERROR" },
- { NT_STATUS_INVALID_NETWORK_RESPONSE, "INVALID_NETWORK_RESPONSE" },
- { NT_STATUS_UNEXPECTED_NETWORK_ERROR, "UNEXPECTED_NETWORK_ERROR" },
- { NT_STATUS_BAD_REMOTE_ADAPTER, "BAD_REMOTE_ADAPTER" },
- { NT_STATUS_PRINT_QUEUE_FULL, "PRINT_QUEUE_FULL" },
- { NT_STATUS_NO_SPOOL_SPACE, "NO_SPOOL_SPACE" },
- { NT_STATUS_PRINT_CANCELLED, "PRINT_CANCELLED" },
- { NT_STATUS_NETWORK_NAME_DELETED, "NETWORK_NAME_DELETED" },
- { NT_STATUS_NETWORK_ACCESS_DENIED, "NETWORK_ACCESS_DENIED" },
- { NT_STATUS_BAD_DEVICE_TYPE, "BAD_DEVICE_TYPE" },
- { NT_STATUS_BAD_NETWORK_NAME, "BAD_NETWORK_NAME" },
- { NT_STATUS_TOO_MANY_NAMES, "TOO_MANY_NAMES" },
- { NT_STATUS_TOO_MANY_SESSIONS, "TOO_MANY_SESSIONS" },
- { NT_STATUS_SHARING_PAUSED, "SHARING_PAUSED" },
- { NT_STATUS_REQUEST_NOT_ACCEPTED, "REQUEST_NOT_ACCEPTED" },
- { NT_STATUS_REDIRECTOR_PAUSED, "REDIRECTOR_PAUSED" },
- { NT_STATUS_NET_WRITE_FAULT, "NET_WRITE_FAULT" },
- { NT_STATUS_PROFILING_AT_LIMIT, "PROFILING_AT_LIMIT" },
- { NT_STATUS_NOT_SAME_DEVICE, "NOT_SAME_DEVICE" },
- { NT_STATUS_FILE_RENAMED, "FILE_RENAMED" },
- { NT_STATUS_VIRTUAL_CIRCUIT_CLOSED, "VIRTUAL_CIRCUIT_CLOSED" },
- { NT_STATUS_NO_SECURITY_ON_OBJECT, "NO_SECURITY_ON_OBJECT" },
- { NT_STATUS_CANT_WAIT, "CANT_WAIT" },
- { NT_STATUS_PIPE_EMPTY, "PIPE_EMPTY" },
- { NT_STATUS_CANT_ACCESS_DOMAIN_INFO, "CANT_ACCESS_DOMAIN_INFO" },
- { NT_STATUS_CANT_TERMINATE_SELF, "CANT_TERMINATE_SELF" },
- { NT_STATUS_INVALID_SERVER_STATE, "INVALID_SERVER_STATE" },
- { NT_STATUS_INVALID_DOMAIN_STATE, "INVALID_DOMAIN_STATE" },
- { NT_STATUS_INVALID_DOMAIN_ROLE, "INVALID_DOMAIN_ROLE" },
- { NT_STATUS_NO_SUCH_DOMAIN, "NO_SUCH_DOMAIN" },
- { NT_STATUS_DOMAIN_EXISTS, "DOMAIN_EXISTS" },
- { NT_STATUS_DOMAIN_LIMIT_EXCEEDED, "DOMAIN_LIMIT_EXCEEDED" },
- { NT_STATUS_OPLOCK_NOT_GRANTED, "OPLOCK_NOT_GRANTED" },
- { NT_STATUS_INVALID_OPLOCK_PROTOCOL, "INVALID_OPLOCK_PROTOCOL" },
- { NT_STATUS_INTERNAL_DB_CORRUPTION, "INTERNAL_DB_CORRUPTION" },
- { NT_STATUS_INTERNAL_ERROR, "INTERNAL_ERROR" },
- { NT_STATUS_GENERIC_NOT_MAPPED, "GENERIC_NOT_MAPPED" },
- { NT_STATUS_BAD_DESCRIPTOR_FORMAT, "BAD_DESCRIPTOR_FORMAT" },
- { NT_STATUS_INVALID_USER_BUFFER, "INVALID_USER_BUFFER" },
- { NT_STATUS_UNEXPECTED_IO_ERROR, "UNEXPECTED_IO_ERROR" },
- { NT_STATUS_UNEXPECTED_MM_CREATE_ERR, "UNEXPECTED_MM_CREATE_ERR" },
- { NT_STATUS_UNEXPECTED_MM_MAP_ERROR, "UNEXPECTED_MM_MAP_ERROR" },
- { NT_STATUS_UNEXPECTED_MM_EXTEND_ERR, "UNEXPECTED_MM_EXTEND_ERR" },
- { NT_STATUS_NOT_LOGON_PROCESS, "NOT_LOGON_PROCESS" },
- { NT_STATUS_LOGON_SESSION_EXISTS, "LOGON_SESSION_EXISTS" },
- { NT_STATUS_INVALID_PARAMETER_1, "INVALID_PARAMETER_1" },
- { NT_STATUS_INVALID_PARAMETER_2, "INVALID_PARAMETER_2" },
- { NT_STATUS_INVALID_PARAMETER_3, "INVALID_PARAMETER_3" },
- { NT_STATUS_INVALID_PARAMETER_4, "INVALID_PARAMETER_4" },
- { NT_STATUS_INVALID_PARAMETER_5, "INVALID_PARAMETER_5" },
- { NT_STATUS_INVALID_PARAMETER_6, "INVALID_PARAMETER_6" },
- { NT_STATUS_INVALID_PARAMETER_7, "INVALID_PARAMETER_7" },
- { NT_STATUS_INVALID_PARAMETER_8, "INVALID_PARAMETER_8" },
- { NT_STATUS_INVALID_PARAMETER_9, "INVALID_PARAMETER_9" },
- { NT_STATUS_INVALID_PARAMETER_10, "INVALID_PARAMETER_10" },
- { NT_STATUS_INVALID_PARAMETER_11, "INVALID_PARAMETER_11" },
- { NT_STATUS_INVALID_PARAMETER_12, "INVALID_PARAMETER_12" },
- { NT_STATUS_REDIRECTOR_NOT_STARTED, "REDIRECTOR_NOT_STARTED" },
- { NT_STATUS_REDIRECTOR_STARTED, "REDIRECTOR_STARTED" },
- { NT_STATUS_STACK_OVERFLOW, "STACK_OVERFLOW" },
- { NT_STATUS_NO_SUCH_PACKAGE, "NO_SUCH_PACKAGE" },
- { NT_STATUS_BAD_FUNCTION_TABLE, "BAD_FUNCTION_TABLE" },
- { NT_STATUS_DIRECTORY_NOT_EMPTY, "DIRECTORY_NOT_EMPTY" },
- { NT_STATUS_FILE_CORRUPT_ERROR, "FILE_CORRUPT_ERROR" },
- { NT_STATUS_NOT_A_DIRECTORY, "NOT_A_DIRECTORY" },
- { NT_STATUS_BAD_LOGON_SESSION_STATE, "BAD_LOGON_SESSION_STATE" },
- { NT_STATUS_LOGON_SESSION_COLLISION, "LOGON_SESSION_COLLISION" },
- { NT_STATUS_NAME_TOO_LONG, "NAME_TOO_LONG" },
- { NT_STATUS_FILES_OPEN, "FILES_OPEN" },
- { NT_STATUS_CONNECTION_IN_USE, "CONNECTION_IN_USE" },
- { NT_STATUS_MESSAGE_NOT_FOUND, "MESSAGE_NOT_FOUND" },
- { NT_STATUS_PROCESS_IS_TERMINATING, "PROCESS_IS_TERMINATING" },
- { NT_STATUS_INVALID_LOGON_TYPE, "INVALID_LOGON_TYPE" },
- { NT_STATUS_NO_GUID_TRANSLATION, "NO_GUID_TRANSLATION" },
- { NT_STATUS_CANNOT_IMPERSONATE, "CANNOT_IMPERSONATE" },
- { NT_STATUS_IMAGE_ALREADY_LOADED, "IMAGE_ALREADY_LOADED" },
- { NT_STATUS_ABIOS_NOT_PRESENT, "ABIOS_NOT_PRESENT" },
- { NT_STATUS_ABIOS_LID_NOT_EXIST, "ABIOS_LID_NOT_EXIST" },
- { NT_STATUS_ABIOS_LID_ALREADY_OWNED, "ABIOS_LID_ALREADY_OWNED" },
- { NT_STATUS_ABIOS_NOT_LID_OWNER, "ABIOS_NOT_LID_OWNER" },
- { NT_STATUS_ABIOS_INVALID_COMMAND, "ABIOS_INVALID_COMMAND" },
- { NT_STATUS_ABIOS_INVALID_LID, "ABIOS_INVALID_LID" },
- { NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE,
- "ABIOS_SELECTOR_NOT_AVAILABLE" },
- { NT_STATUS_ABIOS_INVALID_SELECTOR, "ABIOS_INVALID_SELECTOR" },
- { NT_STATUS_NO_LDT, "NO_LDT" },
- { NT_STATUS_INVALID_LDT_SIZE, "INVALID_LDT_SIZE" },
- { NT_STATUS_INVALID_LDT_OFFSET, "INVALID_LDT_OFFSET" },
- { NT_STATUS_INVALID_LDT_DESCRIPTOR, "INVALID_LDT_DESCRIPTOR" },
- { NT_STATUS_INVALID_IMAGE_NE_FORMAT, "INVALID_IMAGE_NE_FORMAT" },
- { NT_STATUS_RXACT_INVALID_STATE, "RXACT_INVALID_STATE" },
- { NT_STATUS_RXACT_COMMIT_FAILURE, "RXACT_COMMIT_FAILURE" },
- { NT_STATUS_MAPPED_FILE_SIZE_ZERO, "MAPPED_FILE_SIZE_ZERO" },
- { NT_STATUS_TOO_MANY_OPENED_FILES, "TOO_MANY_OPENED_FILES" },
- { NT_STATUS_CANCELLED, "CANCELLED" },
- { NT_STATUS_CANNOT_DELETE, "CANNOT_DELETE" },
- { NT_STATUS_INVALID_COMPUTER_NAME, "INVALID_COMPUTER_NAME" },
- { NT_STATUS_FILE_DELETED, "FILE_DELETED" },
- { NT_STATUS_SPECIAL_ACCOUNT, "SPECIAL_ACCOUNT" },
- { NT_STATUS_SPECIAL_GROUP, "SPECIAL_GROUP" },
- { NT_STATUS_SPECIAL_USER, "SPECIAL_USER" },
- { NT_STATUS_MEMBERS_PRIMARY_GROUP, "MEMBERS_PRIMARY_GROUP" },
- { NT_STATUS_FILE_CLOSED, "FILE_CLOSED" },
- { NT_STATUS_TOO_MANY_THREADS, "TOO_MANY_THREADS" },
- { NT_STATUS_THREAD_NOT_IN_PROCESS, "THREAD_NOT_IN_PROCESS" },
- { NT_STATUS_TOKEN_ALREADY_IN_USE, "TOKEN_ALREADY_IN_USE" },
- { NT_STATUS_PAGEFILE_QUOTA_EXCEEDED, "PAGEFILE_QUOTA_EXCEEDED" },
- { NT_STATUS_COMMITMENT_LIMIT, "COMMITMENT_LIMIT" },
- { NT_STATUS_INVALID_IMAGE_LE_FORMAT, "INVALID_IMAGE_LE_FORMAT" },
- { NT_STATUS_INVALID_IMAGE_NOT_MZ, "INVALID_IMAGE_NOT_MZ" },
- { NT_STATUS_INVALID_IMAGE_PROTECT, "INVALID_IMAGE_PROTECT" },
- { NT_STATUS_INVALID_IMAGE_WIN_16, "INVALID_IMAGE_WIN_16" },
- { NT_STATUS_LOGON_SERVER_CONFLICT, "LOGON_SERVER_CONFLICT" },
- { NT_STATUS_TIME_DIFFERENCE_AT_DC, "TIME_DIFFERENCE_AT_DC" },
- { NT_STATUS_SYNCHRONIZATION_REQUIRED, "SYNCHRONIZATION_REQUIRED" },
- { NT_STATUS_DLL_NOT_FOUND, "DLL_NOT_FOUND" },
- { NT_STATUS_OPEN_FAILED, "OPEN_FAILED" },
- { NT_STATUS_IO_PRIVILEGE_FAILED, "IO_PRIVILEGE_FAILED" },
- { NT_STATUS_ORDINAL_NOT_FOUND, "ORDINAL_NOT_FOUND" },
- { NT_STATUS_ENTRYPOINT_NOT_FOUND, "ENTRYPOINT_NOT_FOUND" },
- { NT_STATUS_CONTROL_C_EXIT, "CONTROL_C_EXIT" },
- { NT_STATUS_LOCAL_DISCONNECT, "LOCAL_DISCONNECT" },
- { NT_STATUS_REMOTE_DISCONNECT, "REMOTE_DISCONNECT" },
- { NT_STATUS_REMOTE_RESOURCES, "REMOTE_RESOURCES" },
- { NT_STATUS_LINK_FAILED, "LINK_FAILED" },
- { NT_STATUS_LINK_TIMEOUT, "LINK_TIMEOUT" },
- { NT_STATUS_INVALID_CONNECTION, "INVALID_CONNECTION" },
- { NT_STATUS_INVALID_ADDRESS, "INVALID_ADDRESS" },
- { NT_STATUS_DLL_INIT_FAILED, "DLL_INIT_FAILED" },
- { NT_STATUS_MISSING_SYSTEMFILE, "MISSING_SYSTEMFILE" },
- { NT_STATUS_UNHANDLED_EXCEPTION, "UNHANDLED_EXCEPTION" },
- { NT_STATUS_APP_INIT_FAILURE, "APP_INIT_FAILURE" },
- { NT_STATUS_PAGEFILE_CREATE_FAILED, "PAGEFILE_CREATE_FAILED" },
- { NT_STATUS_NO_PAGEFILE, "NO_PAGEFILE" },
- { NT_STATUS_INVALID_LEVEL, "INVALID_LEVEL" },
- { NT_STATUS_WRONG_PASSWORD_CORE, "WRONG_PASSWORD_CORE" },
- { NT_STATUS_ILLEGAL_FLOAT_CONTEXT, "ILLEGAL_FLOAT_CONTEXT" },
- { NT_STATUS_PIPE_BROKEN, "PIPE_BROKEN" },
- { NT_STATUS_REGISTRY_CORRUPT, "REGISTRY_CORRUPT" },
- { NT_STATUS_REGISTRY_IO_FAILED, "REGISTRY_IO_FAILED" },
- { NT_STATUS_NO_EVENT_PAIR, "NO_EVENT_PAIR" },
- { NT_STATUS_UNRECOGNIZED_VOLUME, "UNRECOGNIZED_VOLUME" },
- { NT_STATUS_SERIAL_NO_DEVICE_INITED, "SERIAL_NO_DEVICE_INITED" },
- { NT_STATUS_NO_SUCH_ALIAS, "NO SUCH ALIAS" },
- { NT_STATUS_MEMBER_NOT_IN_ALIAS, "MEMBER NOT IN ALIAS" },
- { NT_STATUS_MEMBER_IN_ALIAS, "MEMBER IN ALIAS" },
- { NT_STATUS_ALIAS_EXISTS, "ALIAS EXISTS" },
- { NT_STATUS_LOGON_NOT_GRANTED, "LOGON_NOT_GRANTED" },
- { NT_STATUS_TOO_MANY_SECRETS, "TOO_MANY_SECRETS" },
- { NT_STATUS_SECRET_TOO_LONG, "SECRET_TOO_LONG" },
- { NT_STATUS_INTERNAL_DB_ERROR, "INTERNAL_DB_ERROR" },
- { NT_STATUS_FULLSCREEN_MODE, "FULLSCREEN_MODE" },
- { NT_STATUS_TOO_MANY_CONTEXT_IDS, "TOO_MANY_CONTEXT_IDS" },
- { NT_STATUS_LOGON_TYPE_NOT_GRANTED, "LOGON_TYPE_NOT_GRANTED" },
- { NT_STATUS_NOT_REGISTRY_FILE, "NOT_REGISTRY_FILE" },
- { NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED,
- "NT_CROSS_ENCRYPTION_REQUIRED" },
- { NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR, "DOMAIN_CTRLR_CONFIG_ERROR" },
- { NT_STATUS_FT_MISSING_MEMBER, "FT_MISSING_MEMBER" },
- { NT_STATUS_ILL_FORMED_SERVICE_ENTRY, "ILL_FORMED_SERVICE_ENTRY" },
- { NT_STATUS_ILLEGAL_CHARACTER, "ILLEGAL_CHARACTER" },
- { NT_STATUS_UNMAPPABLE_CHARACTER, "UNMAPPABLE_CHARACTER" },
- { NT_STATUS_UNDEFINED_CHARACTER, "UNDEFINED_CHARACTER" },
- { NT_STATUS_FLOPPY_VOLUME, "FLOPPY_VOLUME" },
- { NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND, "FLOPPY_ID_MARK_NOT_FOUND" },
- { NT_STATUS_FLOPPY_WRONG_CYLINDER, "FLOPPY_WRONG_CYLINDER" },
- { NT_STATUS_FLOPPY_UNKNOWN_ERROR, "FLOPPY_UNKNOWN_ERROR" },
- { NT_STATUS_FLOPPY_BAD_REGISTERS, "FLOPPY_BAD_REGISTERS" },
- { NT_STATUS_DISK_RECALIBRATE_FAILED, "DISK_RECALIBRATE_FAILED" },
- { NT_STATUS_DISK_OPERATION_FAILED, "DISK_OPERATION_FAILED" },
- { NT_STATUS_DISK_RESET_FAILED, "DISK_RESET_FAILED" },
- { NT_STATUS_SHARED_IRQ_BUSY, "SHARED_IRQ_BUSY" },
- { NT_STATUS_FT_ORPHANING, "FT_ORPHANING" },
- { NT_STATUS_PARTITION_FAILURE, "PARTITION_FAILURE" },
- { NT_STATUS_INVALID_BLOCK_LENGTH, "INVALID_BLOCK_LENGTH" },
- { NT_STATUS_DEVICE_NOT_PARTITIONED, "DEVICE_NOT_PARTITIONED" },
- { NT_STATUS_UNABLE_TO_LOCK_MEDIA, "UNABLE_TO_LOCK_MEDIA" },
- { NT_STATUS_UNABLE_TO_UNLOAD_MEDIA, "UNABLE_TO_UNLOAD_MEDIA" },
- { NT_STATUS_EOM_OVERFLOW, "EOM_OVERFLOW" },
- { NT_STATUS_NO_MEDIA, "NO_MEDIA" },
- { NT_STATUS_NO_SUCH_MEMBER, "NO SUCH MEMBER" },
- { NT_STATUS_INVALID_MEMBER, "INVALID MEMBER" },
- { NT_STATUS_KEY_DELETED, "KEY_DELETED" },
- { NT_STATUS_NO_LOG_SPACE, "NO_LOG_SPACE" },
- { NT_STATUS_TOO_MANY_SIDS, "TOO MANY SIDS" },
- { NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED,
- "LM_CROSS_ENCRYPTION_REQUIRED" },
- { NT_STATUS_KEY_HAS_CHILDREN, "KEY_HAS_CHILDREN" },
- { NT_STATUS_CHILD_MUST_BE_VOLATILE, "CHILD_MUST_BE_VOLATILE" },
- { NT_STATUS_DEVICE_CONFIGURATION_ERROR, "DEVICE_CONFIGURATION_ERROR" },
- { NT_STATUS_DRIVER_INTERNAL_ERROR, "DRIVER_INTERNAL_ERROR" },
- { NT_STATUS_INVALID_DEVICE_STATE, "INVALID_DEVICE_STATE" },
- { NT_STATUS_IO_DEVICE_ERROR, "IO_DEVICE_ERROR" },
- { NT_STATUS_DEVICE_PROTOCOL_ERROR, "DEVICE_PROTOCOL_ERROR" },
- { NT_STATUS_BACKUP_CONTROLLER, "BACKUP_CONTROLLER" },
- { NT_STATUS_LOG_FILE_FULL, "LOG_FILE_FULL" },
- { NT_STATUS_TOO_LATE, "TOO_LATE" },
- { NT_STATUS_NO_TRUST_LSA_SECRET, "NO_TRUST_LSA_SECRET" },
- { NT_STATUS_NO_TRUST_SAM_ACCOUNT, "NO_TRUST_SAM_ACCOUNT" },
- { NT_STATUS_TRUSTED_DOMAIN_FAILURE, "TRUSTED_DOMAIN_FAILURE" },
- { NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE,
- "TRUSTED_RELATIONSHIP_FAILURE" },
- { NT_STATUS_EVENTLOG_FILE_CORRUPT, "EVENTLOG_FILE_CORRUPT" },
- { NT_STATUS_EVENTLOG_CANT_START, "EVENTLOG_CANT_START" },
- { NT_STATUS_TRUST_FAILURE, "TRUST_FAILURE" },
- { NT_STATUS_MUTANT_LIMIT_EXCEEDED, "MUTANT_LIMIT_EXCEEDED" },
- { NT_STATUS_NETLOGON_NOT_STARTED, "NETLOGON_NOT_STARTED" },
- { NT_STATUS_ACCOUNT_EXPIRED, "ACCOUNT_EXPIRED" },
- { NT_STATUS_POSSIBLE_DEADLOCK, "POSSIBLE_DEADLOCK" },
- { NT_STATUS_NETWORK_CREDENTIAL_CONFLICT,
- "NETWORK_CREDENTIAL_CONFLICT" },
- { NT_STATUS_REMOTE_SESSION_LIMIT, "REMOTE_SESSION_LIMIT" },
- { NT_STATUS_EVENTLOG_FILE_CHANGED, "EVENTLOG_FILE_CHANGED" },
- { NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT,
- "NOLOGON_INTERDOMAIN_TRUST_ACCOUNT" },
- { NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT,
- "NOLOGON_WORKSTATION_TRUST_ACCOUNT" },
- { NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT,
- "NOLOGON_SERVER_TRUST_ACCOUNT" },
- { NT_STATUS_DOMAIN_TRUST_INCONSISTENT, "DOMAIN_TRUST_INCONSISTENT" },
- { NT_STATUS_FS_DRIVER_REQUIRED, "FS_DRIVER_REQUIRED" },
- { NT_STATUS_NO_USER_SESSION_KEY, "NO_USER_SESSION_KEY" },
- { NT_STATUS_USER_SESSION_DELETED, "USER_SESSION_DELETED" },
- { NT_STATUS_RESOURCE_LANG_NOT_FOUND, "RESOURCE_LANG_NOT_FOUND" },
- { NT_STATUS_INSUFF_SERVER_RESOURCES, "INSUFF_SERVER_RESOURCES" },
- { NT_STATUS_INVALID_BUFFER_SIZE, "INVALID_BUFFER_SIZE" },
- { NT_STATUS_INVALID_ADDRESS_COMPONENT, "INVALID_ADDRESS_COMPONENT" },
- { NT_STATUS_INVALID_ADDRESS_WILDCARD, "INVALID_ADDRESS_WILDCARD" },
- { NT_STATUS_TOO_MANY_ADDRESSES, "TOO_MANY_ADDRESSES" },
- { NT_STATUS_ADDRESS_ALREADY_EXISTS, "ADDRESS_ALREADY_EXISTS" },
- { NT_STATUS_ADDRESS_CLOSED, "ADDRESS_CLOSED" },
- { NT_STATUS_CONNECTION_DISCONNECTED, "CONNECTION_DISCONNECTED" },
- { NT_STATUS_CONNECTION_RESET, "CONNECTION_RESET" },
- { NT_STATUS_TOO_MANY_NODES, "TOO_MANY_NODES" },
- { NT_STATUS_TRANSACTION_ABORTED, "TRANSACTION_ABORTED" },
- { NT_STATUS_TRANSACTION_TIMED_OUT, "TRANSACTION_TIMED_OUT" },
- { NT_STATUS_TRANSACTION_NO_RELEASE, "TRANSACTION_NO_RELEASE" },
- { NT_STATUS_TRANSACTION_NO_MATCH, "TRANSACTION_NO_MATCH" },
- { NT_STATUS_TRANSACTION_RESPONDED, "TRANSACTION_RESPONDED" },
- { NT_STATUS_TRANSACTION_INVALID_ID, "TRANSACTION_INVALID_ID" },
- { NT_STATUS_TRANSACTION_INVALID_TYPE, "TRANSACTION_INVALID_TYPE" },
- { NT_STATUS_NOT_SERVER_SESSION, "NOT_SERVER_SESSION" },
- { NT_STATUS_NOT_CLIENT_SESSION, "NOT_CLIENT_SESSION" },
- { NT_STATUS_CANNOT_LOAD_REGISTRY_FILE, "CANNOT_LOAD_REGISTRY_FILE" },
- { NT_STATUS_DEBUG_ATTACH_FAILED, "DEBUG_ATTACH_FAILED" },
- { NT_STATUS_SYSTEM_PROCESS_TERMINATED, "SYSTEM_PROCESS_TERMINATED" },
- { NT_STATUS_DATA_NOT_ACCEPTED, "DATA_NOT_ACCEPTED" },
- { NT_STATUS_NO_BROWSER_SERVERS_FOUND, "NO_BROWSER_SERVERS_FOUND" },
- { NT_STATUS_VDM_HARD_ERROR, "VDM_HARD_ERROR" },
- { NT_STATUS_DRIVER_CANCEL_TIMEOUT, "DRIVER_CANCEL_TIMEOUT" },
- { NT_STATUS_REPLY_MESSAGE_MISMATCH, "REPLY_MESSAGE_MISMATCH" },
- { NT_STATUS_MAPPED_ALIGNMENT, "MAPPED_ALIGNMENT" },
- { NT_STATUS_IMAGE_CHECKSUM_MISMATCH, "IMAGE_CHECKSUM_MISMATCH" },
- { NT_STATUS_LOST_WRITEBEHIND_DATA, "LOST_WRITEBEHIND_DATA" },
- { NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID,
- "CLIENT_SERVER_PARAMETERS_INVALID" },
- { NT_STATUS_PASSWORD_MUST_CHANGE, "PASSWORD_MUST_CHANGE" },
- { NT_STATUS_NOT_FOUND, "NOT_FOUND" },
- { NT_STATUS_NOT_TINY_STREAM, "NOT_TINY_STREAM" },
- { NT_STATUS_RECOVERY_FAILURE, "RECOVERY_FAILURE" },
- { NT_STATUS_STACK_OVERFLOW_READ, "STACK_OVERFLOW_READ" },
- { NT_STATUS_FAIL_CHECK, "FAIL_CHECK" },
- { NT_STATUS_DUPLICATE_OBJECTID, "DUPLICATE_OBJECTID" },
- { NT_STATUS_OBJECTID_EXISTS, "OBJECTID_EXISTS" },
- { NT_STATUS_CONVERT_TO_LARGE, "CONVERT_TO_LARGE" },
- { NT_STATUS_RETRY, "RETRY" },
- { NT_STATUS_FOUND_OUT_OF_SCOPE, "FOUND_OUT_OF_SCOPE" },
- { NT_STATUS_ALLOCATE_BUCKET, "ALLOCATE_BUCKET" },
- { NT_STATUS_PROPSET_NOT_FOUND, "PROPSET_NOT_FOUND" },
- { NT_STATUS_MARSHALL_OVERFLOW, "MARSHALL_OVERFLOW" },
- { NT_STATUS_INVALID_VARIANT, "INVALID_VARIANT" },
- { NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND,
- "DOMAIN_CONTROLLER_NOT_FOUND" },
- { NT_STATUS_ACCOUNT_LOCKED_OUT, "ACCOUNT_LOCKED_OUT" },
- { NT_STATUS_HANDLE_NOT_CLOSABLE, "HANDLE_NOT_CLOSABLE" },
- { NT_STATUS_CONNECTION_REFUSED, "CONNECTION_REFUSED" },
- { NT_STATUS_GRACEFUL_DISCONNECT, "GRACEFUL_DISCONNECT" },
- { NT_STATUS_ADDRESS_ALREADY_ASSOCIATED, "ADDRESS_ALREADY_ASSOCIATED" },
- { NT_STATUS_ADDRESS_NOT_ASSOCIATED, "ADDRESS_NOT_ASSOCIATED" },
- { NT_STATUS_CONNECTION_INVALID, "CONNECTION_INVALID" },
- { NT_STATUS_CONNECTION_ACTIVE, "CONNECTION_ACTIVE" },
- { NT_STATUS_NETWORK_UNREACHABLE, "NETWORK_UNREACHABLE" },
- { NT_STATUS_HOST_UNREACHABLE, "HOST/PARTNER UNREACHABLE" },
- { NT_STATUS_PROTOCOL_UNREACHABLE, "PROTOCOL_UNREACHABLE" },
- { NT_STATUS_PORT_UNREACHABLE, "PORT_UNREACHABLE" },
- { NT_STATUS_REQUEST_ABORTED, "REQUEST_ABORTED" },
- { NT_STATUS_CONNECTION_ABORTED, "CONNECTION_ABORTED" },
- { NT_STATUS_BAD_COMPRESSION_BUFFER, "BAD_COMPRESSION_BUFFER" },
- { NT_STATUS_USER_MAPPED_FILE, "USER_MAPPED_FILE" },
- { NT_STATUS_AUDIT_FAILED, "AUDIT_FAILED" },
- { NT_STATUS_TIMER_RESOLUTION_NOT_SET, "TIMER_RESOLUTION_NOT_SET" },
- { NT_STATUS_CONNECTION_COUNT_LIMIT, "CONNECTION_COUNT_LIMIT" },
- { NT_STATUS_LOGIN_TIME_RESTRICTION, "LOGIN_TIME_RESTRICTION" },
- { NT_STATUS_LOGIN_WKSTA_RESTRICTION, "LOGIN_WKSTA_RESTRICTION" },
- { NT_STATUS_IMAGE_MP_UP_MISMATCH, "IMAGE_MP_UP_MISMATCH" },
- { NT_STATUS_INSUFFICIENT_LOGON_INFO, "INSUFFICIENT_LOGON_INFO" },
- { NT_STATUS_BAD_DLL_ENTRYPOINT, "BAD_DLL_ENTRYPOINT" },
- { NT_STATUS_BAD_SERVICE_ENTRYPOINT, "BAD_SERVICE_ENTRYPOINT" },
- { NT_STATUS_LPC_REPLY_LOST, "LPC_REPLY_LOST" },
- { NT_STATUS_IP_ADDRESS_CONFLICT1, "IP_ADDRESS_CONFLICT1" },
- { NT_STATUS_IP_ADDRESS_CONFLICT2, "IP_ADDRESS_CONFLICT2" },
- { NT_STATUS_REGISTRY_QUOTA_LIMIT, "REGISTRY_QUOTA_LIMIT" },
- { NT_STATUS_PATH_NOT_COVERED, "PATH_NOT_COVERED" },
- { NT_STATUS_NO_CALLBACK_ACTIVE, "NO_CALLBACK_ACTIVE" },
- { NT_STATUS_LICENSE_QUOTA_EXCEEDED, "LICENSE_QUOTA_EXCEEDED" },
- { NT_STATUS_PWD_TOO_SHORT, "PWD_TOO_SHORT" },
- { NT_STATUS_PWD_TOO_RECENT, "PWD_TOO_RECENT" },
- { NT_STATUS_PWD_HISTORY_CONFLICT, "PWD_HISTORY_CONFLICT" },
- { NT_STATUS_PLUGPLAY_NO_DEVICE, "PLUGPLAY_NO_DEVICE" },
- { NT_STATUS_UNSUPPORTED_COMPRESSION, "UNSUPPORTED_COMPRESSION" },
- { NT_STATUS_INVALID_HW_PROFILE, "INVALID_HW_PROFILE" },
- { NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH,
- "INVALID_PLUGPLAY_DEVICE_PATH" },
- { NT_STATUS_DRIVER_ORDINAL_NOT_FOUND, "DRIVER_ORDINAL_NOT_FOUND" },
- { NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND,
- "DRIVER_ENTRYPOINT_NOT_FOUND" },
- { NT_STATUS_RESOURCE_NOT_OWNED, "RESOURCE_NOT_OWNED" },
- { NT_STATUS_TOO_MANY_LINKS, "TOO_MANY_LINKS" },
- { NT_STATUS_QUOTA_LIST_INCONSISTENT, "QUOTA_LIST_INCONSISTENT" },
- { NT_STATUS_FILE_IS_OFFLINE, "FILE_IS_OFFLINE" },
-};
-
-
-/*
- * Translate an ntstatus value to a meaningful text string. If there isn't
- * a corresponding text string in the table, the text representation of the
- * status value is returned. This uses a static buffer so there is a
- * possible concurrency issue if the caller hangs on to this pointer for a
- * while but it should be harmless and really remote since the value will
- * almost always be found in the table.
- */
-char *
-xlate_nt_status(DWORD ntstatus)
-{
- static char unknown[16];
- int i;
-
- for (i = 0; i < sizeof (ntx_table)/sizeof (ntx_table[0]); ++i) {
- if (ntx_table[i].value == NT_SC_VALUE(ntstatus))
- return (ntx_table[i].name);
- }
-
- (void) sprintf(unknown, "0x%08x", ntstatus);
- return (unknown);
-}
diff --git a/usr/src/common/smbsrv/smb_xdr.c b/usr/src/common/smbsrv/smb_xdr.c
index 46d2e2ca49..33013b20b9 100644
--- a/usr/src/common/smbsrv/smb_xdr.c
+++ b/usr/src/common/smbsrv/smb_xdr.c
@@ -29,7 +29,6 @@
#include <stddef.h>
#endif /* _KERNEL */
#include <smbsrv/smb_door.h>
-#include <smbsrv/smb_xdr.h>
#include <smbsrv/alloc.h>
#include <sys/socket.h>
#include <sys/sysmacros.h>
@@ -95,7 +94,9 @@ smb_doorhdr_opname(uint32_t op)
{ SMB_DR_ADS_FIND_HOST, "ads_find_host" },
{ SMB_DR_QUOTA_QUERY, "quota_query" },
{ SMB_DR_QUOTA_SET, "quota_set" },
- { SMB_DR_DFS_GET_REFERRALS, "dfs_get_referrals" }
+ { SMB_DR_DFS_GET_REFERRALS, "dfs_get_referrals" },
+ { SMB_DR_SHR_HOSTACCESS, "share_hostaccess" },
+ { SMB_DR_SHR_EXEC, "share_exec" }
};
int i;
@@ -403,18 +404,6 @@ smb_netfileinfo_xdr(XDR *xdrs, smb_netfileinfo_t *objp)
}
bool_t
-smb_dr_kshare_xdr(XDR *xdrs, smb_dr_kshare_t *objp)
-{
- if (!xdr_int32_t(xdrs, &objp->k_op))
- return (FALSE);
- if (!xdr_string(xdrs, &objp->k_path, MAXPATHLEN))
- return (FALSE);
- if (!xdr_string(xdrs, &objp->k_sharename, MAXNAMELEN))
- return (FALSE);
- return (TRUE);
-}
-
-bool_t
smb_gmttoken_query_xdr(XDR *xdrs, smb_gmttoken_query_t *objp)
{
if (!xdr_uint32_t(xdrs, &objp->gtq_count)) {
@@ -694,3 +683,54 @@ dfs_referral_response_xdr(XDR *xdrs, dfs_referral_response_t *objp)
return (TRUE);
}
+
+bool_t
+smb_shr_hostaccess_query_xdr(XDR *xdrs, smb_shr_hostaccess_query_t *objp)
+{
+ if (!xdr_string(xdrs, &objp->shq_none, ~0))
+ return (FALSE);
+
+ if (!xdr_string(xdrs, &objp->shq_ro, ~0))
+ return (FALSE);
+
+ if (!xdr_string(xdrs, &objp->shq_rw, ~0))
+ return (FALSE);
+
+ if (!xdr_uint32_t(xdrs, &objp->shq_flag))
+ return (FALSE);
+
+ if (!smb_inaddr_xdr(xdrs, &objp->shq_ipaddr))
+ return (FALSE);
+
+ return (TRUE);
+}
+
+bool_t
+smb_shr_execinfo_xdr(XDR *xdrs, smb_shr_execinfo_t *objp)
+{
+ if (!xdr_string(xdrs, &objp->e_sharename, ~0))
+ return (FALSE);
+
+ if (!xdr_string(xdrs, &objp->e_winname, ~0))
+ return (FALSE);
+
+ if (!xdr_string(xdrs, &objp->e_userdom, ~0))
+ return (FALSE);
+
+ if (!smb_inaddr_xdr(xdrs, &objp->e_srv_ipaddr))
+ return (FALSE);
+
+ if (!smb_inaddr_xdr(xdrs, &objp->e_cli_ipaddr))
+ return (FALSE);
+
+ if (!xdr_string(xdrs, &objp->e_cli_netbiosname, ~0))
+ return (FALSE);
+
+ if (!xdr_u_int(xdrs, &objp->e_uid))
+ return (FALSE);
+
+ if (!xdr_int(xdrs, &objp->e_type))
+ return (FALSE);
+
+ return (TRUE);
+}
diff --git a/usr/src/lib/libadutils/common/addisc.c b/usr/src/lib/libadutils/common/addisc.c
index 187981b5a2..a0bbfe1c0f 100644
--- a/usr/src/lib/libadutils/common/addisc.c
+++ b/usr/src/lib/libadutils/common/addisc.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -171,6 +171,7 @@ typedef struct ad_disc {
/* port array */
ad_item_t site_global_catalog; /* Directory hostname and */
/* port array */
+ int debug[AD_DEBUG_MAX+1]; /* Debug levels */
} ad_disc;
@@ -202,8 +203,6 @@ typedef struct ad_disc {
#define is_changed(item, num, param) \
((item)->param_version[num] != (param)->version)
-/*LINTLIBRARY*/
-
/*
* Function definitions
*/
@@ -312,7 +311,7 @@ ds_dup(const idmap_ad_disc_ds_t *srv)
size = (i + 1) * sizeof (idmap_ad_disc_ds_t);
new = malloc(size);
if (new != NULL)
- memcpy(new, srv, size);
+ (void) memcpy(new, srv, size);
return (new);
}
@@ -367,7 +366,7 @@ td_dup(const ad_disc_trusteddomains_t *td)
size = (i + 1) * sizeof (ad_disc_trusteddomains_t);
new = malloc(size);
if (new != NULL)
- memcpy(new, td, size);
+ (void) memcpy(new, td, size);
return (new);
}
@@ -424,7 +423,7 @@ df_dup(const ad_disc_domainsinforest_t *df)
size = (i + 1) * sizeof (ad_disc_domainsinforest_t);
new = malloc(size);
if (new != NULL)
- memcpy(new, df, size);
+ (void) memcpy(new, df, size);
return (new);
}
@@ -461,13 +460,13 @@ find_subnets()
logger(LOG_ERR,
"Failed to find the number of network interfaces (%s)",
strerror(errno));
- close(sock);
+ (void) close(sock);
return (NULL);
}
if (lifn.lifn_count < 1) {
logger(LOG_ERR, "No IPv4 network interfaces found");
- close(sock);
+ (void) close(sock);
return (NULL);
}
@@ -478,7 +477,7 @@ find_subnets()
if (lifc.lifc_buf == NULL) {
logger(LOG_ERR, "Out of memory");
- close(sock);
+ (void) close(sock);
return (NULL);
}
@@ -486,7 +485,7 @@ find_subnets()
logger(LOG_ERR, "Failed to list network interfaces (%s)",
strerror(errno));
free(lifc.lifc_buf);
- close(sock);
+ (void) close(sock);
return (NULL);
}
@@ -494,7 +493,7 @@ find_subnets()
if ((results = calloc(n + 1, sizeof (ad_subnet_t))) == NULL) {
free(lifc.lifc_buf);
- close(sock);
+ (void) close(sock);
return (NULL);
}
@@ -518,7 +517,7 @@ find_subnets()
}
free(lifc.lifc_buf);
- close(sock);
+ (void) close(sock);
return (results);
}
@@ -690,34 +689,42 @@ srv_query(res_state state, const char *svc_name, const char *dname,
/* Search, querydomain or query */
if (rrname != NULL) {
*rrname = NULL;
+ if (DBG(DNS, 1)) {
+ logger(LOG_DEBUG, "Looking for SRV RRs '%s.*'",
+ svc_name);
+ }
len = res_nsearch(state, svc_name, C_IN, T_SRV,
msg.buf, sizeof (msg.buf));
- logger(LOG_DEBUG, "Searching DNS for SRV RRs named '%s'",
- svc_name);
if (len < 0) {
- logger(LOG_DEBUG, "DNS search for '%s' failed (%s)",
- svc_name, hstrerror(state->res_h_errno));
+ if (DBG(DNS, 0)) {
+ logger(LOG_DEBUG,
+ "DNS search for '%s' failed (%s)",
+ svc_name, hstrerror(state->res_h_errno));
+ }
return (NULL);
}
} else if (dname != NULL) {
- logger(LOG_DEBUG,
- "Querying DNS for SRV RRs named '%s' for '%s' ",
- svc_name, dname);
+ if (DBG(DNS, 1)) {
+ logger(LOG_DEBUG, "Looking for SRV RRs '%s.%s' ",
+ svc_name, dname);
+ }
len = res_nquerydomain(state, svc_name, dname, C_IN, T_SRV,
msg.buf, sizeof (msg.buf));
if (len < 0) {
- logger(LOG_DEBUG,
- "DNS query for '%s' for '%s' failed (%s)",
- svc_name, dname, hstrerror(state->res_h_errno));
+ if (DBG(DNS, 0)) {
+ logger(LOG_DEBUG, "DNS: %s.%s: %s",
+ svc_name, dname,
+ hstrerror(state->res_h_errno));
+ }
return (NULL);
}
}
if (len > sizeof (msg.buf)) {
- logger(LOG_ERR, "DNS query %ib message doesn't fit"
- " into %ib buffer",
+ logger(LOG_ERR,
+ "DNS query %ib message doesn't fit into %ib buffer",
len, sizeof (msg.buf));
return (NULL);
}
@@ -791,9 +798,13 @@ srv_query(res_state state, const char *svc_name, const char *dname,
if (rttl < *ttl)
*ttl = rttl;
- logger(LOG_DEBUG, "Found %s %d IN SRV [%d][%d] %s:%d",
- namebuf, rttl, srv->priority, srv->weight, srv->host,
- srv->port);
+ if (DBG(DNS, 1)) {
+ logger(LOG_DEBUG, " %s", namebuf);
+ logger(LOG_DEBUG,
+ " ttl=%d pri=%d weight=%d %s:%d",
+ rttl, srv->priority, srv->weight,
+ srv->host, srv->port);
+ }
/* 3. move ptr to the end of current record */
@@ -835,10 +846,12 @@ ldap_lookup_init(idmap_ad_disc_ds_t *ds)
for (i = 0; ds[i].host[0] != '\0'; i++) {
ld = ldap_init(ds[i].host, ds[i].port);
if (ld == NULL) {
- logger(LOG_DEBUG, "Couldn't connect to "
- "AD DC %s:%d (%s)",
- ds[i].host, ds[i].port,
- strerror(errno));
+ if (DBG(LDAP, 1)) {
+ logger(LOG_DEBUG,
+ "Couldn't connect to AD DC %s:%d (%s)",
+ ds[i].host, ds[i].port,
+ strerror(errno));
+ }
continue;
}
@@ -869,8 +882,11 @@ ldap_lookup_init(idmap_ad_disc_ds_t *ds)
if (rc == LDAP_SUCCESS)
break;
- logger(LOG_INFO, "LDAP SASL bind to %s:%d failed (%s)",
- ds[i].host, ds[i].port, ldap_err2string(rc));
+ if (DBG(LDAP, 0)) {
+ logger(LOG_INFO, "LDAP: %s:%d: %s",
+ ds[i].host, ds[i].port, ldap_err2string(rc));
+ ldap_perror(ld, ds[i].host);
+ }
(void) ldap_unbind(ld);
ld = NULL;
}
@@ -956,6 +972,8 @@ ldap_lookup_trusted_domains(LDAP **ld, idmap_ad_disc_ds_t *globalCatalog,
int num = 0;
ad_disc_trusteddomains_t *trusted_domains = NULL;
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, "Looking for trusted domains...");
if (*ld == NULL)
*ld = ldap_lookup_init(globalCatalog);
@@ -967,11 +985,18 @@ ldap_lookup_trusted_domains(LDAP **ld, idmap_ad_disc_ds_t *globalCatalog,
attrs[1] = "trustDirection";
attrs[2] = NULL;
- /* trustDirection values - inbound = 1 and bidirectional = 3 */
+ /*
+ * Trust direction values:
+ * 1 - inbound (they trust us)
+ * 2 - outbound (we trust them)
+ * 3 - bidirectional (we trust each other)
+ */
filter = "(&(objectclass=trustedDomain)"
- "(|(trustDirection=3)(trustDirection=1)))";
+ "(|(trustDirection=3)(trustDirection=2)))";
rc = ldap_search_s(*ld, base_dn, scope, filter, attrs, 0, &results);
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, "Trusted domains:");
if (rc == LDAP_SUCCESS) {
for (entry = ldap_first_entry(*ld, results);
entry != NULL; entry = ldap_next_entry(*ld, entry)) {
@@ -980,6 +1005,10 @@ ldap_lookup_trusted_domains(LDAP **ld, idmap_ad_disc_ds_t *globalCatalog,
*ld, entry, "trustDirection");
if (partner != NULL && direction != NULL) {
+ if (DBG(DISC, 1)) {
+ logger(LOG_DEBUG, " %s (%s)",
+ partner[0], direction[0]);
+ }
num++;
void *tmp = realloc(trusted_domains,
(num + 1) *
@@ -988,14 +1017,14 @@ ldap_lookup_trusted_domains(LDAP **ld, idmap_ad_disc_ds_t *globalCatalog,
free(trusted_domains);
ldap_value_free(partner);
ldap_value_free(direction);
- ldap_msgfree(results);
+ (void) ldap_msgfree(results);
return (NULL);
}
trusted_domains = tmp;
/* Last element should be zero */
- memset(&trusted_domains[num], 0,
+ (void) memset(&trusted_domains[num], 0,
sizeof (ad_disc_trusteddomains_t));
- strcpy(trusted_domains[num - 1].domain,
+ (void) strcpy(trusted_domains[num - 1].domain,
partner[0]);
trusted_domains[num - 1].direction =
atoi(direction[0]);
@@ -1008,9 +1037,11 @@ ldap_lookup_trusted_domains(LDAP **ld, idmap_ad_disc_ds_t *globalCatalog,
} else if (rc == LDAP_NO_RESULTS_RETURNED) {
/* This is not an error - return empty trusted domain */
trusted_domains = calloc(1, sizeof (ad_disc_trusteddomains_t));
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, " not found");
}
if (results != NULL)
- ldap_msgfree(results);
+ (void) ldap_msgfree(results);
return (trusted_domains);
}
@@ -1033,16 +1064,20 @@ ldap_lookup_domains_in_forest(LDAP **ld, idmap_ad_disc_ds_t *globalCatalogs)
int nresults;
ad_disc_domainsinforest_t *domains = NULL;
+ if (DBG(DISC, 2))
+ logger(LOG_DEBUG, "Looking for domains in forest...");
+
if (*ld == NULL)
*ld = ldap_lookup_init(globalCatalogs);
if (*ld == NULL)
return (NULL);
- logger(LOG_DEBUG, "Looking for domains in forest...");
/* Find domains */
rc = ldap_search_s(*ld, "", LDAP_SCOPE_SUBTREE,
"(objectClass=Domain)", attrs, 0, &result);
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, "Domains in forest:");
if (rc != LDAP_SUCCESS)
goto err;
@@ -1073,7 +1108,7 @@ ldap_lookup_domains_in_forest(LDAP **ld, idmap_ad_disc_ds_t *globalCatalogs)
if ((sid_str = adutils_sid2txt(&sid)) == NULL)
goto err;
- strcpy(domains[ndomains].sid, sid_str);
+ (void) strcpy(domains[ndomains].sid, sid_str);
free(sid_str);
dn = ldap_get_dn(*ld, entry);
@@ -1082,16 +1117,20 @@ ldap_lookup_domains_in_forest(LDAP **ld, idmap_ad_disc_ds_t *globalCatalogs)
if (name == NULL)
goto err;
- strcpy(domains[ndomains].domain, name);
+ (void) strcpy(domains[ndomains].domain, name);
free(name);
- logger(LOG_DEBUG, " found %s", domains[ndomains].domain);
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, " %s", domains[ndomains].domain);
ndomains++;
}
- if (ndomains == 0)
+ if (ndomains == 0) {
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, " not found");
goto err;
+ }
if (ndomains < nresults) {
ad_disc_domainsinforest_t *tmp;
@@ -1102,14 +1141,14 @@ ldap_lookup_domains_in_forest(LDAP **ld, idmap_ad_disc_ds_t *globalCatalogs)
}
if (result != NULL)
- ldap_msgfree(result);
+ (void) ldap_msgfree(result);
return (domains);
err:
free(domains);
if (result != NULL)
- ldap_msgfree(result);
+ (void) ldap_msgfree(result);
return (NULL);
}
@@ -1135,7 +1174,6 @@ ad_disc_init(void)
return (ctx);
}
-
void
ad_disc_fini(ad_disc_t ctx)
{
@@ -1248,15 +1286,21 @@ validate_DomainName(ad_disc_t ctx)
/* Try to find our domain by searching for DCs for it */
DO_RES_NINIT(ctx);
- domain_controller = srv_query(&ctx->res_state, LDAP_SRV_HEAD
- DC_SRV_TAIL, ctx->domain_name.value, &srvname, &ttl);
+ if (DBG(DISC, 2))
+ logger(LOG_DEBUG, "Looking for our AD domain name...");
+ domain_controller = srv_query(&ctx->res_state,
+ LDAP_SRV_HEAD DC_SRV_TAIL,
+ ctx->domain_name.value, &srvname, &ttl);
/*
* If we can't find DCs by via res_nsearch() then there's no
* point in trying anything else to discover the AD domain name.
*/
- if (domain_controller == NULL)
+ if (domain_controller == NULL) {
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, "Can't find our domain name.");
return (NULL);
+ }
free(domain_controller);
/*
@@ -1278,6 +1322,8 @@ validate_DomainName(ad_disc_t ctx)
if (len > 0 && dname[len - 1] == '.')
dname[len - 1] = '\0';
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, "Our domain name: %s", dname);
update_item(&ctx->domain_name, dname, AD_STATE_AUTO, ttl);
return (&ctx->domain_name);
@@ -1337,6 +1383,10 @@ validate_DomainController(ad_disc_t ctx, enum ad_disc_req req)
if (!is_valid(&ctx->domain_controller) ||
is_changed(&ctx->domain_controller, PARAM1,
domain_name_item)) {
+ if (DBG(DISC, 2)) {
+ logger(LOG_DEBUG, "Looking for DCs for %s",
+ domain_name_item->value);
+ }
/*
* Lookup DNS SRV RR named
* _ldap._tcp.dc._msdcs.<DomainName>
@@ -1346,8 +1396,27 @@ validate_DomainController(ad_disc_t ctx, enum ad_disc_req req)
LDAP_SRV_HEAD DC_SRV_TAIL,
domain_name_item->value, NULL, &ttl);
- if (domain_controller == NULL)
+ if (DBG(DISC, 1)) {
+ logger(LOG_DEBUG, "DCs for %s:",
+ domain_name_item->value);
+ }
+ if (domain_controller == NULL) {
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, " not found");
return (NULL);
+ }
+
+ if (DBG(DISC, 1)) {
+ int i;
+
+ for (i = 0;
+ domain_controller[i].host[0] != '\0';
+ i++) {
+ logger(LOG_DEBUG, " %s:%d",
+ domain_controller[i].host,
+ domain_controller[i].port);
+ }
+ }
update_item(&ctx->domain_controller, domain_controller,
AD_STATE_AUTO, ttl);
@@ -1364,6 +1433,12 @@ validate_DomainController(ad_disc_t ctx, enum ad_disc_req req)
is_changed(&ctx->site_domain_controller, PARAM2,
site_name_item)) {
char rr_name[DNS_MAX_NAME];
+ if (DBG(DISC, 2)) {
+ logger(LOG_DEBUG,
+ "Looking for DCs for %s in %s",
+ domain_name_item->value,
+ site_name_item->value);
+ }
/*
* Lookup DNS SRV RR named
* _ldap._tcp.<SiteName>._sites.dc._msdcs.<DomainName>
@@ -1374,8 +1449,29 @@ validate_DomainController(ad_disc_t ctx, enum ad_disc_req req)
DO_RES_NINIT(ctx);
domain_controller = srv_query(&ctx->res_state, rr_name,
domain_name_item->value, NULL, &ttl);
- if (domain_controller == NULL)
+ if (DBG(DISC, 1)) {
+ logger(LOG_DEBUG,
+ "DCs for %s in %s",
+ domain_name_item->value,
+ site_name_item->value);
+ }
+ if (domain_controller == NULL) {
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, " not found");
return (NULL);
+ }
+
+ if (DBG(DISC, 1)) {
+ int i;
+
+ for (i = 0;
+ domain_controller[i].host[0] != '\0';
+ i++) {
+ logger(LOG_DEBUG, " %s:%d",
+ domain_controller[i].host,
+ domain_controller[i].port);
+ }
+ }
update_item(&ctx->site_domain_controller,
domain_controller, AD_STATE_AUTO, ttl);
@@ -1423,7 +1519,6 @@ validate_SiteName(ad_disc_t ctx)
char *site_name = NULL;
char *forest_name;
int len;
- int i;
boolean_t update_required = B_FALSE;
ad_item_t *domain_controller_item;
@@ -1460,6 +1555,9 @@ validate_SiteName(ad_disc_t ctx)
dn_root[0] = "";
dn_root[1] = NULL;
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, "Getting site name");
+
config_naming_context = ldap_lookup_entry_attr(
&ld, ctx->domain_controller.value,
dn_root, "configurationNamingContext");
@@ -1481,6 +1579,10 @@ validate_SiteName(ad_disc_t ctx)
int len = strlen(str);
if (strncasecmp(config_naming_context, str, len) == 0) {
forest_name = DN_to_DNS(config_naming_context + len);
+ if (DBG(DISC, 1)) {
+ logger(LOG_DEBUG, " forest: %s",
+ forest_name);
+ }
update_item(&ctx->forest_name, forest_name,
AD_STATE_AUTO, 0);
update_version(&ctx->forest_name, PARAM1,
@@ -1488,6 +1590,17 @@ validate_SiteName(ad_disc_t ctx)
}
}
+ if (DBG(DISC, 2))
+ logger(LOG_DEBUG, " CNC: %s", config_naming_context);
+
+ if (DBG(DISC, 2)) {
+ int i;
+ logger(LOG_DEBUG, " Looking for sites for subnets:");
+ for (i = 0; subnets[i].subnet[0] != '\0'; i++) {
+ logger(LOG_DEBUG, " %s", subnets[i].subnet);
+ }
+ }
+
dn_subnets = subnets_to_DNs(subnets, config_naming_context);
if (dn_subnets == NULL)
goto out;
@@ -1501,12 +1614,18 @@ validate_SiteName(ad_disc_t ctx)
* CN=<site>,CN=Sites,CN=Configuration,
* <DN Domain>
*/
+ if (DBG(DISC, 2))
+ logger(LOG_DEBUG, " Site object: %s", site_object);
if (strncasecmp(site_object, "CN=", 3) == 0) {
for (len = 0; site_object[len + 3] != ','; len++)
;
site_name = malloc(len + 1);
(void) strncpy(site_name, &site_object[3], len);
site_name[len] = '\0';
+ if (DBG(DISC, 1)) {
+ logger(LOG_DEBUG, " Site name \"%s\"",
+ site_name);
+ }
update_item(&ctx->site_name, site_name,
AD_STATE_AUTO, 0);
update_version(&ctx->site_name, PARAM1,
@@ -1527,6 +1646,7 @@ out:
(void) ldap_unbind(ld);
if (dn_subnets != NULL) {
+ int i;
for (i = 0; dn_subnets[i] != NULL; i++)
free(dn_subnets[i]);
free(dn_subnets);
@@ -1590,6 +1710,8 @@ validate_ForestName(ad_disc_t ctx)
dn_list[0] = "";
dn_list[1] = NULL;
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, "Getting forest name");
config_naming_context = ldap_lookup_entry_attr(
&ld, ctx->domain_controller.value,
dn_list, "configurationNamingContext");
@@ -1612,8 +1734,14 @@ validate_ForestName(ad_disc_t ctx)
if (ld != NULL)
(void) ldap_unbind(ld);
- if (forest_name == NULL)
+ if (forest_name == NULL) {
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, " not found");
return (NULL);
+ }
+
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, " %s", forest_name);
update_item(&ctx->forest_name, forest_name, AD_STATE_AUTO, 0);
update_version(&ctx->forest_name, PARAM1,
@@ -1686,8 +1814,27 @@ validate_GlobalCatalog(ad_disc_t ctx, enum ad_disc_req req)
LDAP_SRV_HEAD GC_SRV_TAIL,
ctx->forest_name.value, NULL, &ttl);
- if (global_catalog == NULL)
+ if (DBG(DISC, 1)) {
+ logger(LOG_DEBUG,
+ "GC servers for %s:",
+ ctx->forest_name.value);
+ }
+ if (global_catalog == NULL) {
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, " not found");
return (NULL);
+ }
+
+ if (DBG(DISC, 1)) {
+ int i;
+ for (i = 0;
+ global_catalog[i].host[0] != '\0';
+ i++) {
+ logger(LOG_DEBUG, " %s:%d",
+ global_catalog[i].host,
+ global_catalog[i].port);
+ }
+ }
update_item(&ctx->global_catalog, global_catalog,
AD_STATE_AUTO, ttl);
@@ -1718,8 +1865,29 @@ validate_GlobalCatalog(ad_disc_t ctx, enum ad_disc_req req)
global_catalog = srv_query(&ctx->res_state, rr_name,
ctx->forest_name.value, NULL, &ttl);
- if (global_catalog == NULL)
+ if (DBG(DISC, 1)) {
+ logger(LOG_DEBUG,
+ "GC servers for %s in %s",
+ ctx->forest_name.value,
+ ctx->site_name.value);
+ }
+ if (global_catalog == NULL) {
+ if (DBG(DISC, 1))
+ logger(LOG_DEBUG, " not found");
return (NULL);
+ }
+
+ if (DBG(DISC, 1)) {
+ int i;
+ for (i = 0;
+ global_catalog[i].host[0] != '\0';
+ i++) {
+ logger(LOG_DEBUG, " %s:%d",
+ global_catalog[i].host,
+ global_catalog[i].port);
+ }
+ }
+
update_item(&ctx->site_global_catalog, global_catalog,
AD_STATE_AUTO, ttl);
update_version(&ctx->site_global_catalog, PARAM1,
diff --git a/usr/src/lib/libadutils/common/addisc.h b/usr/src/lib/libadutils/common/addisc.h
index c8a3ca17d2..786e79a66d 100644
--- a/usr/src/lib/libadutils/common/addisc.h
+++ b/usr/src/lib/libadutils/common/addisc.h
@@ -20,13 +20,14 @@
*/
/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _ADINFO_H
#define _ADINFO_H
#include <rpcsvc/idmap_prot.h>
+#include "libadutils.h"
#ifdef __cplusplus
diff --git a/usr/src/lib/libadutils/common/adutils.c b/usr/src/lib/libadutils/common/adutils.c
index 6afed3b132..1a29e6fe9e 100644
--- a/usr/src/lib/libadutils/common/adutils.c
+++ b/usr/src/lib/libadutils/common/adutils.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <alloca.h>
@@ -57,6 +56,8 @@ static char *adutils_sid_ber2str(BerValue *bvalues);
static void adutils_lookup_batch_unlock(adutils_query_state_t **state);
static void delete_ds(adutils_ad_t *ad, const char *host, int port);
+int ad_debug[AD_DEBUG_MAX+1] = {0};
+
typedef struct binary_attrs {
const char *name;
char *(*ber2str)(BerValue *bvalues);
@@ -1703,3 +1704,10 @@ domain_eq(const char *a, const char *b)
return (u8_strcmp(a, b, 0, U8_STRCMP_CI_LOWER, U8_UNICODE_LATEST, &err)
== 0 && err == 0);
}
+
+void
+adutils_set_debug(enum ad_debug item, int value)
+{
+ if (item >= 0 && item <= AD_DEBUG_MAX)
+ ad_debug[item] = value;
+}
diff --git a/usr/src/lib/libadutils/common/adutils_impl.h b/usr/src/lib/libadutils/common/adutils_impl.h
index 448134c786..f82282ff97 100644
--- a/usr/src/lib/libadutils/common/adutils_impl.h
+++ b/usr/src/lib/libadutils/common/adutils_impl.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _ADUTILS_IMPL_H
@@ -39,6 +38,11 @@
extern "C" {
#endif
+#define DBG(type, lev) \
+ (ad_debug[AD_DEBUG_##type] >= (lev) || \
+ ad_debug[AD_DEBUG_ALL] >= (lev))
+extern int ad_debug[AD_DEBUG_MAX + 1];
+
#define ADUTILS_SEARCH_TIMEOUT 3
#define ADUTILS_LDAP_OPEN_TIMEOUT 1
diff --git a/usr/src/lib/libadutils/common/libadutils.h b/usr/src/lib/libadutils/common/libadutils.h
index a184769cd0..0f6f35b429 100644
--- a/usr/src/lib/libadutils/common/libadutils.h
+++ b/usr/src/lib/libadutils/common/libadutils.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _LIBADUTILS_H
@@ -37,6 +36,18 @@ extern "C" {
#endif
#define ADUTILS_DEF_NUM_RETRIES 2
+
+/*
+ * Symbolic constants for different sets of debug messages.
+ */
+enum ad_debug {
+ AD_DEBUG_ALL = 0,
+ AD_DEBUG_DNS = 1,
+ AD_DEBUG_LDAP = 2,
+ AD_DEBUG_DISC = 3,
+ AD_DEBUG_MAX = 3
+};
+
#define ADUTILS_SID_MAX_SUB_AUTHORITIES 15
#define ADUTILS_MAXBINSID\
(1 + 1 + 6 + (ADUTILS_SID_MAX_SUB_AUTHORITIES * 4))
@@ -131,6 +142,7 @@ typedef enum adutils_ad_partition {
typedef void (*adutils_logger)(int, const char *, ...);
+extern void adutils_set_debug(enum ad_debug item, int val);
extern adutils_rc adutils_ad_alloc(adutils_ad_t **new_ad,
const char *domain_name,
diff --git a/usr/src/lib/libadutils/common/mapfile-vers b/usr/src/lib/libadutils/common/mapfile-vers
index e1e580bd9a..3058643eb8 100644
--- a/usr/src/lib/libadutils/common/mapfile-vers
+++ b/usr/src/lib/libadutils/common/mapfile-vers
@@ -59,6 +59,7 @@ SUNWprivate {
adutils_add_ds;
adutils_add_domain;
adutils_set_logger;
+ adutils_set_debug;
ad_disc_fini;
ad_disc_init;
ad_disc_get_DomainName;
diff --git a/usr/src/lib/libidmap/Makefile.com b/usr/src/lib/libidmap/Makefile.com
index 5f5f3363b0..9a6cdec780 100644
--- a/usr/src/lib/libidmap/Makefile.com
+++ b/usr/src/lib/libidmap/Makefile.com
@@ -44,7 +44,7 @@ include ../../Makefile.lib
C99MODE = $(C99_ENABLE)
LIBS = $(DYNLIB) $(LINTLIB)
-LDLIBS += -lc -lavl -lnsl
+LDLIBS += -lc -lavl -lnsl -lnvpair
SRCDIR = ../common
$(LINTLIB):= SRCS = $(SRCDIR)/$(LINTSRC)
diff --git a/usr/src/lib/libidmap/common/idmap_api.c b/usr/src/lib/libidmap/common/idmap_api.c
index 6566de1db9..e31ff1ffc3 100644
--- a/usr/src/lib/libidmap/common/idmap_api.c
+++ b/usr/src/lib/libidmap/common/idmap_api.c
@@ -40,11 +40,10 @@
#include <libintl.h>
#include <ucontext.h>
#include <syslog.h>
+#include <assert.h>
#include "idmap_impl.h"
#include "idmap_cache.h"
-/*LINTLIBRARY*/
-
static struct timeval TIMEOUT = { 25, 0 };
static int idmap_stat2errno(idmap_stat);
@@ -989,10 +988,8 @@ idmap_iter_next_mapping(idmap_iter_t *iter, char **sidprefix,
.idtype == IDMAP_USID)?1:0;
if (info) {
- retcode = idmap_info_cpy(info,
+ idmap_info_mov(info,
&mappings->mappings.mappings_val[iter->next].info);
- if (retcode != IDMAP_SUCCESS)
- goto errout;
}
iter->next++;
@@ -1695,9 +1692,10 @@ idmap_get_mappings(idmap_get_handle_t *gh)
*gh->retlist[i].stat = IDMAP_ERR_NORESULT;
break;
}
- if (gh->retlist[i].info != NULL)
- (void) idmap_info_cpy(gh->retlist[i].info,
+ if (gh->retlist[i].info != NULL) {
+ idmap_info_mov(gh->retlist[i].info,
&res.ids.ids_val[i].info);
+ }
}
retcode = IDMAP_SUCCESS;
@@ -1807,6 +1805,9 @@ idmap_get_w2u_mapping(idmap_handle_t *handle,
goto out;
}
+ if (info != NULL)
+ idmap_info_mov(info, &mapping->info);
+
if (mapping->id2.idtype == IDMAP_UID) {
*is_user = 1;
} else if (mapping->id2.idtype == IDMAP_GID) {
@@ -1832,10 +1833,6 @@ idmap_get_w2u_mapping(idmap_handle_t *handle,
if (rc != IDMAP_SUCCESS)
retcode = rc;
- rc = idmap_info_cpy(info, &mapping->info);
- if (rc != IDMAP_SUCCESS)
- retcode = rc;
-
out:
if (request.id1name != NULL)
free(request.id1name);
@@ -1924,6 +1921,9 @@ idmap_get_u2w_mapping(idmap_handle_t *handle,
goto out;
}
+ if (info != NULL)
+ idmap_info_mov(info, &mapping->info);
+
if (direction != NULL)
*direction = mapping->direction;
@@ -1955,10 +1955,6 @@ idmap_get_u2w_mapping(idmap_handle_t *handle,
if (rc != IDMAP_SUCCESS)
retcode = rc;
- rc = idmap_info_cpy(info, &mapping->info);
- if (rc != IDMAP_SUCCESS)
- retcode = rc;
-
goto out;
errout:
@@ -2225,163 +2221,33 @@ idmap_namerule_cpy(idmap_namerule *to, idmap_namerule *from)
}
-static
-idmap_stat
-idmap_how_ds_based_cpy(idmap_how_ds_based *to, idmap_how_ds_based *from)
-{
- idmap_stat retval;
-
- if (to == NULL)
- return (IDMAP_SUCCESS);
-
- retval = idmap_strdupnull(&to->dn, from->dn);
- if (retval != IDMAP_SUCCESS)
- return (retval);
-
- retval = idmap_strdupnull(&to->attr, from->attr);
- if (retval != IDMAP_SUCCESS) {
- free(to->dn);
- to->dn = NULL;
- return (retval);
- }
-
- retval = idmap_strdupnull(&to->value, from->value);
- if (retval != IDMAP_SUCCESS) {
- free(to->dn);
- to->dn = NULL;
- free(to->attr);
- to->attr = NULL;
- return (retval);
- }
-
- return (retval);
-}
-
-idmap_stat
-idmap_info_cpy(idmap_info *to, idmap_info *from)
-{
- idmap_stat retval = IDMAP_SUCCESS;
-
- if (to == NULL)
- return (IDMAP_SUCCESS);
-
- (void) memset(to, 0, sizeof (idmap_info));
-
- to->src = from->src;
- to->how.map_type = from->how.map_type;
- switch (to->how.map_type) {
- case IDMAP_MAP_TYPE_DS_AD:
- retval = idmap_how_ds_based_cpy(&to->how.idmap_how_u.ad,
- &from->how.idmap_how_u.ad);
- break;
-
- case IDMAP_MAP_TYPE_DS_NLDAP:
- retval = idmap_how_ds_based_cpy(&to->how.idmap_how_u.nldap,
- &from->how.idmap_how_u.nldap);
- break;
-
- case IDMAP_MAP_TYPE_RULE_BASED:
- retval = idmap_namerule_cpy(&to->how.idmap_how_u.rule,
- &from->how.idmap_how_u.rule);
- break;
-
- case IDMAP_MAP_TYPE_EPHEMERAL:
- break;
-
- case IDMAP_MAP_TYPE_LOCAL_SID:
- break;
-
- case IDMAP_MAP_TYPE_KNOWN_SID:
- break;
-
- case IDMAP_MAP_TYPE_IDMU:
- retval = idmap_how_ds_based_cpy(&to->how.idmap_how_u.idmu,
- &from->how.idmap_how_u.idmu);
- break;
- }
- return (retval);
-}
-
-
/*
- * This routine is similar to idmap_info_cpy, but the strings
- * are moved from the "from" info to the "to" info.
- * This routine is equivalent to:
- *
- * idmap_info_cpy(to,from);
- * idmap_info_free(from);
+ * Move the contents of the "info" structure from "from" to "to".
*/
-idmap_stat
+void
idmap_info_mov(idmap_info *to, idmap_info *from)
{
- idmap_stat retval = IDMAP_SUCCESS;
-
- if (to == NULL) {
- idmap_info_free(from);
- return (IDMAP_SUCCESS);
- }
(void) memcpy(to, from, sizeof (idmap_info));
-
(void) memset(from, 0, sizeof (idmap_info));
-
- return (retval);
}
void
idmap_info_free(idmap_info *info)
{
- idmap_how *how;
-
if (info == NULL)
return;
- how = &info->how;
- switch (how->map_type) {
- case IDMAP_MAP_TYPE_DS_AD:
- free(how->idmap_how_u.ad.dn);
- how->idmap_how_u.ad.dn = NULL;
- free(how->idmap_how_u.ad.attr);
- how->idmap_how_u.ad.attr = NULL;
- free(how->idmap_how_u.ad.value);
- how->idmap_how_u.ad.value = NULL;
- break;
-
- case IDMAP_MAP_TYPE_DS_NLDAP:
- free(how->idmap_how_u.nldap.dn);
- how->idmap_how_u.nldap.dn = NULL;
- free(how->idmap_how_u.nldap.attr);
- how->idmap_how_u.nldap.attr = NULL;
- free(how->idmap_how_u.nldap.value);
- how->idmap_how_u.nldap.value = NULL;
- break;
-
- case IDMAP_MAP_TYPE_RULE_BASED:
- free(how->idmap_how_u.rule.windomain);
- how->idmap_how_u.rule.windomain = NULL;
- free(how->idmap_how_u.rule.winname);
- how->idmap_how_u.rule.winname = NULL;
- free(how->idmap_how_u.rule.unixname);
- how->idmap_how_u.rule.unixname = NULL;
- break;
+ xdr_free(xdr_idmap_info, (caddr_t)info);
+ (void) memset(info, 0, sizeof (idmap_info));
+}
- case IDMAP_MAP_TYPE_EPHEMERAL:
- break;
- case IDMAP_MAP_TYPE_LOCAL_SID:
- break;
-
- case IDMAP_MAP_TYPE_IDMU:
- free(how->idmap_how_u.idmu.dn);
- how->idmap_how_u.idmu.dn = NULL;
- free(how->idmap_how_u.idmu.attr);
- how->idmap_how_u.idmu.attr = NULL;
- free(how->idmap_how_u.idmu.value);
- how->idmap_how_u.idmu.value = NULL;
- break;
- }
- how->map_type = IDMAP_MAP_TYPE_UNKNOWN;
- info->src = IDMAP_MAP_SRC_UNKNOWN;
+void
+idmap_how_clear(idmap_how *how)
+{
+ xdr_free(xdr_idmap_how, (caddr_t)how);
+ (void) memset(how, 0, sizeof (*how));
}
@@ -2596,3 +2462,120 @@ idmap_set_logger(idmap_logger_t funct)
{
logger = funct;
}
+
+/*
+ * Helper functions that concatenate two parts of a name and then
+ * look up a value, so that the same set of functions can be used to
+ * process both "in" and "out" parameters.
+ */
+static
+boolean_t
+idmap_trace_get_str(nvlist_t *entry, char *n1, char *n2, char **ret)
+{
+ char name[IDMAP_TRACE_NAME_MAX+1]; /* Max used is about 11 */
+ int err;
+
+ (void) strlcpy(name, n1, sizeof (name));
+ if (n2 != NULL)
+ (void) strlcat(name, n2, sizeof (name));
+
+ err = nvlist_lookup_string(entry, name, ret);
+ return (err == 0);
+}
+
+static
+boolean_t
+idmap_trace_get_int(nvlist_t *entry, char *n1, char *n2, int64_t *ret)
+{
+ char name[IDMAP_TRACE_NAME_MAX+1]; /* Max used is about 11 */
+ int err;
+
+ (void) strlcpy(name, n1, sizeof (name));
+ if (n2 != NULL)
+ (void) strlcat(name, n2, sizeof (name));
+
+ err = nvlist_lookup_int64(entry, name, ret);
+ return (err == 0);
+}
+
+static
+void
+idmap_trace_print_id(FILE *out, nvlist_t *entry, char *fromto)
+{
+ char *s;
+ int64_t i64;
+
+ if (idmap_trace_get_int(entry, fromto, IDMAP_TRACE_TYPE, &i64)) {
+ switch (i64) {
+ case IDMAP_POSIXID:
+ (void) fprintf(out, "unixname ");
+ break;
+ case IDMAP_UID:
+ (void) fprintf(out, "unixuser ");
+ break;
+ case IDMAP_GID:
+ (void) fprintf(out, "unixgroup ");
+ break;
+ case IDMAP_SID:
+ (void) fprintf(out, "winname ");
+ break;
+ case IDMAP_USID:
+ (void) fprintf(out, "winuser ");
+ break;
+ case IDMAP_GSID:
+ (void) fprintf(out, "wingroup ");
+ break;
+ case IDMAP_NONE:
+ (void) fprintf(out, gettext("unknown "));
+ break;
+ default:
+ (void) fprintf(out, gettext("bad %d "), (int)i64);
+ break;
+ }
+ }
+
+ if (idmap_trace_get_str(entry, fromto, IDMAP_TRACE_NAME, &s))
+ (void) fprintf(out, "%s ", s);
+
+ if (idmap_trace_get_str(entry, fromto, IDMAP_TRACE_SID, &s))
+ (void) fprintf(out, "%s ", s);
+
+ if (idmap_trace_get_int(entry, fromto, IDMAP_TRACE_UNIXID, &i64))
+ (void) fprintf(out, "%u ", (uid_t)i64);
+}
+
+void
+idmap_trace_print_1(FILE *out, char *prefix, nvlist_t *entry)
+{
+ char *s;
+ int64_t i64;
+
+ (void) fprintf(out, "%s", prefix);
+ idmap_trace_print_id(out, entry, "from");
+ (void) fprintf(out, "-> ");
+ idmap_trace_print_id(out, entry, "to");
+ if (idmap_trace_get_int(entry, IDMAP_TRACE_ERROR, NULL, &i64))
+ (void) fprintf(out, gettext("Error %d "), (int)i64);
+ (void) fprintf(out, "-");
+ if (idmap_trace_get_str(entry, IDMAP_TRACE_MESSAGE, NULL, &s))
+ (void) fprintf(out, " %s", s);
+ (void) fprintf(out, "\n");
+}
+
+void
+idmap_trace_print(FILE *out, char *prefix, nvlist_t *trace)
+{
+ nvpair_t *nvp;
+
+ for (nvp = nvlist_next_nvpair(trace, NULL);
+ nvp != NULL;
+ nvp = nvlist_next_nvpair(trace, nvp)) {
+ nvlist_t *entry;
+ int err;
+
+ err = nvpair_value_nvlist(nvp, &entry);
+ assert(err == 0);
+
+ idmap_trace_print_1(out, prefix, entry);
+ }
+}
diff --git a/usr/src/lib/libidmap/common/idmap_priv.h b/usr/src/lib/libidmap/common/idmap_priv.h
index c3a68b76c9..30547b881d 100644
--- a/usr/src/lib/libidmap/common/idmap_priv.h
+++ b/usr/src/lib/libidmap/common/idmap_priv.h
@@ -155,14 +155,12 @@ extern idmap_stat idmap_stat4prot(idmap_stat);
/* copy idmap_namerule including strings */
extern idmap_stat idmap_namerule_cpy(idmap_namerule *, idmap_namerule *);
-/* copy idmap_info info including strings */
-extern idmap_stat idmap_info_cpy(idmap_info *to, idmap_info *from);
-
/* Move idmap_info info including strings */
-extern idmap_stat idmap_info_mov(idmap_info *to, idmap_info *from);
+extern void idmap_info_mov(idmap_info *to, idmap_info *from);
/* free idmap_info info from user supplied struct */
extern void idmap_info_free(idmap_info *);
+extern void idmap_how_clear(idmap_how *);
/*
@@ -195,6 +193,23 @@ extern idmap_stat idmap_get_prop_ds(idmap_handle_t *, idmap_prop_type,
extern idmap_stat idmap_get_prop_str(idmap_handle_t *, idmap_prop_type,
char **);
+/*
+ * Trace
+ *
+ * These are the names of the trace parameters that may be returned
+ * when tracing is requested.
+ */
+#define IDMAP_TRACE_NAME_MAX 100 /* max length of a trace param name */
+#define IDMAP_TRACE_TYPE "-type" /* prefix with "from" or "to" */
+#define IDMAP_TRACE_NAME "-name" /* prefix with "from" or "to" */
+#define IDMAP_TRACE_SID "-sid" /* prefix with "from" or "to" */
+#define IDMAP_TRACE_UNIXID "-unixid" /* prefix with "from" or "to" */
+#define IDMAP_TRACE_ERROR "error"
+#define IDMAP_TRACE_MESSAGE "message"
+
+extern void idmap_trace_print_1(FILE *out, char *prefix, nvlist_t *entry);
+extern void idmap_trace_print(FILE *out, char *prefix, nvlist_t *trace);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/lib/libidmap/common/mapfile-vers b/usr/src/lib/libidmap/common/mapfile-vers
index e52fa5da30..4e65bafc61 100644
--- a/usr/src/lib/libidmap/common/mapfile-vers
+++ b/usr/src/lib/libidmap/common/mapfile-vers
@@ -62,15 +62,6 @@ SUNWprivate {
idmap_fini;
idmap_flush;
idmap_free;
- idmap_getext_gidbysid;
- idmap_getext_pidbysid;
- idmap_getext_sidbygid;
- idmap_getext_sidbyuid;
- idmap_getext_uidbysid;
- idmap_getgidbywinname;
- idmap_getuidbywinname;
- idmap_getwinnamebygid;
- idmap_getwinnamebyuid;
idmap_get_create;
idmap_get_destroy;
idmap_get_gidbysid;
@@ -83,7 +74,16 @@ SUNWprivate {
idmap_get_u2w_mapping;
idmap_get_uidbysid;
idmap_get_w2u_mapping;
- idmap_info_cpy;
+ idmap_getext_gidbysid;
+ idmap_getext_pidbysid;
+ idmap_getext_sidbygid;
+ idmap_getext_sidbyuid;
+ idmap_getext_uidbysid;
+ idmap_getgidbywinname;
+ idmap_getuidbywinname;
+ idmap_getwinnamebygid;
+ idmap_getwinnamebyuid;
+ idmap_how_clear;
idmap_info_free;
idmap_info_mov;
idmap_init;
@@ -97,6 +97,8 @@ SUNWprivate {
idmap_stat2string;
idmap_stat4prot;
idmap_string2stat;
+ idmap_trace_print;
+ idmap_trace_print_1;
idmap_udt_add_namerule;
idmap_udt_commit;
idmap_udt_create;
@@ -123,13 +125,13 @@ SUNWprivate {
xdr_directory_get_common_1_argument;
xdr_directory_results_rpc;
xdr_idmap_flush_op;
- xdr_idmap_ids_res;
xdr_idmap_id_res;
+ xdr_idmap_ids_res;
xdr_idmap_list_mappings_1_argument;
xdr_idmap_list_namerules_1_argument;
xdr_idmap_mapping;
- xdr_idmap_mappings_res;
xdr_idmap_mapping_batch;
+ xdr_idmap_mappings_res;
xdr_idmap_namerule;
xdr_idmap_namerules_res;
xdr_idmap_prop_res;
@@ -137,6 +139,7 @@ SUNWprivate {
xdr_idmap_retcode;
xdr_idmap_update_batch;
xdr_idmap_update_res;
+
local:
*;
};
diff --git a/usr/src/lib/libshare/Makefile.com b/usr/src/lib/libshare/Makefile.com
index 2250917c9b..9efcf9887e 100644
--- a/usr/src/lib/libshare/Makefile.com
+++ b/usr/src/lib/libshare/Makefile.com
@@ -18,11 +18,7 @@
#
# CDDL HEADER END
#
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
#
LIBRARY = libshare.a
VERS = .1
@@ -41,7 +37,7 @@ LIBSRCS = $(LIBOBJS:%.o=$(SRCDIR)/%.c)
lintcheck := SRCS = $(LIBSRCS)
LIBS = $(DYNLIB) $(LINTLIB)
-LDLIBS += -lc -lnsl -lscf -lzfs -luuid -lxml2
+LDLIBS += -lc -lnsl -lscf -lzfs -luuid -lxml2 -lnvpair
$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
#add nfs/lib directory as part of the include path
diff --git a/usr/src/lib/libshare/common/libshare.c b/usr/src/lib/libshare/common/libshare.c
index 22ad595c6d..30c2c486f1 100644
--- a/usr/src/lib/libshare/common/libshare.c
+++ b/usr/src/lib/libshare/common/libshare.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -99,6 +98,8 @@ struct doc2handle {
sa_handle_impl_t handle;
};
+mutex_t sa_dfstab_lock;
+
/* definitions used in a couple of property functions */
#define SA_PROP_OP_REMOVE 1
#define SA_PROP_OP_ADD 2
@@ -594,18 +595,26 @@ validpath(sa_handle_t handle, char *path, int strictness)
*
* "group" can be either an sa_group_t or an sa_share_t. (void *)
* works since both thse types are also void *.
+ * If the share is a ZFS share, mark it as persistent.
*/
int
sa_is_persistent(void *group)
{
char *type;
int persist = 1;
+ sa_group_t grp;
type = sa_get_group_attr((sa_group_t)group, "type");
- if (type != NULL && strcmp(type, "transient") == 0)
- persist = 0;
- if (type != NULL)
+ if (type != NULL) {
+ if (strcmp(type, "transient") == 0)
+ persist = 0;
sa_free_attr_string(type);
+ }
+
+ grp = (sa_is_share(group)) ? sa_get_parent_group(group) : group;
+ if (sa_group_is_zfs(grp))
+ persist = 1;
+
return (persist);
}
@@ -869,6 +878,7 @@ sa_init(int init_service)
extern int errno;
errno = 0;
(void) lockf(lockfd, F_LOCK, 0);
+ (void) mutex_lock(&sa_dfstab_lock);
/*
* Check whether we are going to need
* to merge any dfstab changes. This
@@ -905,13 +915,15 @@ sa_init(int init_service)
*/
updatelegacy = B_TRUE;
}
- }
- if (updatelegacy == B_FALSE) {
- /* Don't need the lock anymore */
- (void) lockf(lockfd, F_ULOCK, 0);
- (void) close(lockfd);
- }
+ if (updatelegacy == B_FALSE) {
+ (void) mutex_unlock(
+ &sa_dfstab_lock);
+ (void) lockf(lockfd, F_ULOCK,
+ 0);
+ (void) close(lockfd);
+ }
+ }
/*
* It is essential that the document tree and
* the internal list of roots to handles be
@@ -954,6 +966,13 @@ sa_init(int init_service)
* sa_init().
*/
sa_fini(handle);
+ if (updatelegacy == B_TRUE) {
+ (void) mutex_unlock(
+ &sa_dfstab_lock);
+ (void) lockf(lockfd,
+ F_ULOCK, 0);
+ (void) close(lockfd);
+ }
return (NULL);
}
@@ -979,6 +998,7 @@ sa_init(int init_service)
* Safe to unlock now to allow
* others to run
*/
+ (void) mutex_unlock(&sa_dfstab_lock);
(void) lockf(lockfd, F_ULOCK, 0);
(void) close(lockfd);
}
@@ -2502,7 +2522,8 @@ sa_set_share_description(sa_share_t share, char *content)
xmlFreeNode(node);
}
group = sa_get_parent_group(share);
- if (group != NULL && sa_is_persistent(share)) {
+ if (group != NULL &&
+ sa_is_persistent(share) && (!sa_group_is_zfs(group))) {
sa_handle_impl_t impl_handle;
impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
if (impl_handle != NULL) {
@@ -4335,9 +4356,11 @@ sa_set_resource_description(sa_resource_t resource, char *content)
xmlUnlinkNode(node);
xmlFreeNode(node);
}
+
share = sa_get_resource_parent(resource);
group = sa_get_parent_group(share);
- if (group != NULL && sa_is_persistent(share)) {
+ if (group != NULL &&
+ sa_is_persistent(share) && (!sa_group_is_zfs(group))) {
sa_handle_impl_t impl_handle;
impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
if (impl_handle != NULL)
diff --git a/usr/src/lib/libshare/common/libshare.h b/usr/src/lib/libshare/common/libshare.h
index e733ea4d10..5d32f60e8f 100644
--- a/usr/src/lib/libshare/common/libshare.h
+++ b/usr/src/lib/libshare/common/libshare.h
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -36,6 +35,7 @@ extern "C" {
#endif
#include <sys/types.h>
+#include <libnvpair.h>
/*
* Basic datatypes for most functions
@@ -268,6 +268,7 @@ extern int sa_delete_sharetab(sa_handle_t, char *, char *);
extern int sa_zfs_is_shared(sa_handle_t, char *);
extern int sa_group_is_zfs(sa_group_t);
extern int sa_path_is_zfs(char *);
+extern int sa_zfs_setprop(sa_handle_t, char *, nvlist_t *);
/* SA Handle specific functions */
extern sa_handle_t sa_find_group_handle(sa_group_t);
diff --git a/usr/src/lib/libshare/common/libshare_zfs.c b/usr/src/lib/libshare/common/libshare_zfs.c
index 5adef70b4c..b96abc505d 100644
--- a/usr/src/lib/libshare/common/libshare_zfs.c
+++ b/usr/src/lib/libshare/common/libshare_zfs.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <stdio.h>
@@ -1446,3 +1445,138 @@ sa_zfs_get_info(libzfs_handle_t *libzfs, char *path, char *mountpointp,
return (ret);
}
+
+/*
+ * This method builds values for "sharesmb" property from the
+ * nvlist argument. The values are returned in sharesmb_val variable.
+ */
+static int
+sa_zfs_sprintf_new_prop(nvlist_t *nvl, char *sharesmb_val)
+{
+ char cur_val[MAXPATHLEN];
+ char *name, *val;
+ nvpair_t *cur;
+ int err = 0;
+
+ cur = nvlist_next_nvpair(nvl, NULL);
+ while (cur != NULL) {
+ name = nvpair_name(cur);
+ err = nvpair_value_string(cur, &val);
+ if ((err != 0) || (name == NULL) || (val == NULL))
+ return (-1);
+
+ (void) snprintf(cur_val, MAXPATHLEN, "%s=%s,", name, val);
+ (void) strlcat(sharesmb_val, cur_val, MAXPATHLEN);
+
+ cur = nvlist_next_nvpair(nvl, cur);
+ }
+
+ return (0);
+}
+
+/*
+ * This method builds values for "sharesmb" property from values
+ * already existing on the share. The properties set via sa_zfs_sprint_new_prop
+ * method are passed in sharesmb_val. If a existing property is already
+ * set via sa_zfs_sprint_new_prop method, then they are not appended
+ * to the sharesmb_val string. The returned sharesmb_val string is a combination
+ * of new and existing values for 'sharesmb' property.
+ */
+static int
+sa_zfs_sprintf_existing_prop(zfs_handle_t *handle, char *sharesmb_val)
+{
+ char shareopts[ZFS_MAXPROPLEN], cur_val[MAXPATHLEN];
+ char *token, *last, *value;
+
+ if (zfs_prop_get(handle, ZFS_PROP_SHARESMB, shareopts,
+ sizeof (shareopts), NULL, NULL, 0, B_FALSE) != 0)
+ return (-1);
+
+ if (strstr(shareopts, "=") == NULL)
+ return (0);
+
+ for (token = strtok_r(shareopts, ",", &last); token != NULL;
+ token = strtok_r(NULL, ",", &last)) {
+ value = strchr(token, '=');
+ if (value == NULL)
+ return (-1);
+ *value++ = '\0';
+
+ (void) snprintf(cur_val, MAXPATHLEN, "%s=", token);
+ if (strstr(sharesmb_val, cur_val) == NULL) {
+ (void) strlcat(cur_val, value, MAXPATHLEN);
+ (void) strlcat(cur_val, ",", MAXPATHLEN);
+ (void) strlcat(sharesmb_val, cur_val, MAXPATHLEN);
+ }
+ }
+
+ return (0);
+}
+
+/*
+ * Sets the share properties on a ZFS share. For now, this method sets only
+ * the "sharesmb" property.
+ *
+ * This method includes building a comma seperated name-value string to be
+ * set on the "sharesmb" property of a ZFS share. This name-value string is
+ * build in 2 steps:
+ * - New property values given as name-value pair are set first.
+ * - Existing optionset properties, which are not part of the new properties
+ * passed in step 1, are appended to the newly set properties.
+ */
+int
+sa_zfs_setprop(sa_handle_t handle, char *path, nvlist_t *nvl)
+{
+ zfs_handle_t *z_fs;
+ libzfs_handle_t *z_lib;
+ char sharesmb_val[MAXPATHLEN];
+ char *dataset, *lastcomma;
+
+ if (nvlist_empty(nvl))
+ return (0);
+
+ if ((handle == NULL) || (path == NULL))
+ return (-1);
+
+ if ((dataset = get_zfs_dataset(handle, path, B_FALSE)) == NULL)
+ return (-1);
+
+ if ((z_lib = libzfs_init()) == NULL) {
+ free(dataset);
+ return (-1);
+ }
+
+ z_fs = zfs_open(z_lib, dataset, ZFS_TYPE_DATASET);
+ if (z_fs == NULL) {
+ free(dataset);
+ libzfs_fini(z_lib);
+ return (-1);
+ }
+
+ bzero(sharesmb_val, MAXPATHLEN);
+ if (sa_zfs_sprintf_new_prop(nvl, sharesmb_val) != 0) {
+ free(dataset);
+ zfs_close(z_fs);
+ libzfs_fini(z_lib);
+ return (-1);
+ }
+
+ if (sa_zfs_sprintf_existing_prop(z_fs, sharesmb_val) != 0) {
+ free(dataset);
+ zfs_close(z_fs);
+ libzfs_fini(z_lib);
+ return (-1);
+ }
+
+ lastcomma = strrchr(sharesmb_val, ',');
+ if ((lastcomma != NULL) && (lastcomma[1] == '\0'))
+ *lastcomma = '\0';
+
+ (void) zfs_prop_set(z_fs, zfs_prop_to_name(ZFS_PROP_SHARESMB),
+ sharesmb_val);
+ free(dataset);
+ zfs_close(z_fs);
+ libzfs_fini(z_lib);
+
+ return (0);
+}
diff --git a/usr/src/lib/libshare/common/libsharecore.c b/usr/src/lib/libshare/common/libsharecore.c
index 18e5f3c793..02b44052ca 100644
--- a/usr/src/lib/libshare/common/libsharecore.c
+++ b/usr/src/lib/libshare/common/libsharecore.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -69,6 +68,7 @@ static char *notice[DFSTAB_NOTICE_LINES] = {
#define MAXARGSFORSHARE 256
static mutex_t sharetab_lock = DEFAULTMUTEX;
+extern mutex_t sa_dfstab_lock;
/* used internally only */
typedef
@@ -545,6 +545,7 @@ sa_comment_line(char *line, char *err)
(void) setvbuf(dfstab, NULL, _IOLBF, BUFSIZ * 8);
sablocksigs(&old);
(void) lockf(fileno(dfstab), F_LOCK, 0);
+ (void) mutex_lock(&sa_dfstab_lock);
list = getdfstab(dfstab);
rewind(dfstab);
/*
@@ -555,6 +556,7 @@ sa_comment_line(char *line, char *err)
outdfstab(dfstab, list);
(void) fprintf(dfstab, "# Error: %s: %s", err, line);
(void) fsync(fileno(dfstab));
+ (void) mutex_unlock(&sa_dfstab_lock);
(void) lockf(fileno(dfstab), F_ULOCK, 0);
(void) fclose(dfstab);
saunblocksigs(&old);
@@ -596,6 +598,7 @@ sa_delete_legacy(sa_share_t share, char *protocol)
parent = sa_get_parent_group(share);
if (parent != NULL) {
(void) lockf(fileno(dfstab), F_LOCK, 0);
+ (void) mutex_lock(&sa_dfstab_lock);
list = getdfstab(dfstab);
rewind(dfstab);
if (protocol != NULL) {
@@ -634,6 +637,7 @@ sa_delete_legacy(sa_share_t share, char *protocol)
if (list != NULL)
dfs_free_list(list);
(void) fflush(dfstab);
+ (void) mutex_unlock(&sa_dfstab_lock);
(void) lockf(fileno(dfstab), F_ULOCK, 0);
}
(void) fsync(fileno(dfstab));
@@ -701,6 +705,7 @@ sa_update_legacy(sa_share_t share, char *proto)
(void) setvbuf(dfstab, NULL, _IOLBF, BUFSIZ * 8);
sablocksigs(&old);
(void) lockf(fileno(dfstab), F_LOCK, 0);
+ (void) mutex_lock(&sa_dfstab_lock);
list = getdfstab(dfstab);
rewind(dfstab);
if (list != NULL)
@@ -708,6 +713,7 @@ sa_update_legacy(sa_share_t share, char *proto)
list = adddfsentry(list, share, proto);
outdfstab(dfstab, list);
(void) fflush(dfstab);
+ (void) mutex_unlock(&sa_dfstab_lock);
(void) lockf(fileno(dfstab), F_ULOCK, 0);
(void) fsync(fileno(dfstab));
saunblocksigs(&old);
diff --git a/usr/src/lib/libshare/common/mapfile-vers b/usr/src/lib/libshare/common/mapfile-vers
index 73c08b1e05..e0b1fa56f7 100644
--- a/usr/src/lib/libshare/common/mapfile-vers
+++ b/usr/src/lib/libshare/common/mapfile-vers
@@ -19,8 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
@@ -149,6 +148,7 @@ SUNWprivate {
sa_get_zfs_handle;
sa_zfs_process_share;
sa_update_sharetab_ts;
+ sa_zfs_setprop;
local:
*;
};
diff --git a/usr/src/lib/libshare/smb/libshare_smb.c b/usr/src/lib/libshare/smb/libshare_smb.c
index be6f6be2e2..7694ccbfa7 100644
--- a/usr/src/lib/libshare/smb/libshare_smb.c
+++ b/usr/src/lib/libshare/smb/libshare_smb.c
@@ -174,6 +174,7 @@ struct option_defs optdefs[] = {
{ SHOPT_CSC, OPT_TYPE_CSC },
{ SHOPT_GUEST, OPT_TYPE_BOOLEAN },
{ SHOPT_DFSROOT, OPT_TYPE_BOOLEAN },
+ { SHOPT_DESCRIPTION, OPT_TYPE_STRING },
{ NULL, NULL }
};
@@ -1625,8 +1626,20 @@ smb_add_transient(sa_handle_t handle, smb_share_t *si)
opt = (si->shr_flags & SMB_SHRF_ABE) ? "true" : "false";
err |= nvlist_add_string(nvl, SHOPT_ABE, opt);
- opt = (si->shr_flags & SMB_SHRF_GUEST_OK) ? "true" : "false";
- err |= nvlist_add_string(nvl, SHOPT_GUEST, opt);
+ if ((si->shr_flags & SMB_SHRF_AUTOHOME) == 0) {
+ opt = (si->shr_flags & SMB_SHRF_GUEST_OK) ? "true" : "false";
+ err |= nvlist_add_string(nvl, SHOPT_GUEST, opt);
+ }
+
+ if (si->shr_access_ro[0] != '\0')
+ err |= nvlist_add_string(nvl, SHOPT_RO, si->shr_access_ro);
+
+ if (si->shr_access_rw[0] != '\0')
+ err |= nvlist_add_string(nvl, SHOPT_RW, si->shr_access_rw);
+
+ if (si->shr_access_none[0] != '\0')
+ err |= nvlist_add_string(nvl, SHOPT_NONE, si->shr_access_none);
+
if (err) {
nvlist_free(nvl);
return (SA_CONFIG_ERR);
@@ -1745,7 +1758,8 @@ smb_parse_optstring(sa_group_t group, char *options)
* SA_PROP_SHARE_ONLY, so we come back in with a share
* instead of a group.
*/
- if (strncmp(options, "name=", sizeof ("name=") - 1) == 0 ||
+ if (iszfs ||
+ strncmp(options, "name=", sizeof ("name=") - 1) == 0 ||
strstr(options, ",name=") != NULL) {
return (SA_PROP_SHARE_ONLY);
}
@@ -1811,7 +1825,7 @@ smb_parse_optstring(sa_group_t group, char *options)
* "name" property for special handling.
*/
- if (strcmp(token, "name") == 0) {
+ if (strcmp(token, SHOPT_NAME) == 0) {
char *prefix;
char *name = NULL;
/*
@@ -1866,6 +1880,16 @@ smb_parse_optstring(sa_group_t group, char *options)
continue;
}
+ if (iszfs && strcmp(token, SHOPT_DESCRIPTION) == 0) {
+ if (resource == NULL)
+ (void) sa_set_share_description(
+ (sa_share_t)group, value);
+ else
+ (void) sa_set_resource_description(
+ resource, value);
+ continue;
+ }
+
if (need_optionset) {
optionset = sa_create_optionset(resource,
"smb");
@@ -2300,8 +2324,8 @@ disposition_validator(int index, char *value)
if (*value == '\0')
return (SA_OK);
- if ((strcasecmp(value, SMB_SHR_DISP_CONT_STR) == 0) ||
- (strcasecmp(value, SMB_SHR_DISP_TERM_STR) == 0))
+ if ((strcasecmp(value, SMB_EXEC_DISP_CONTINUE) == 0) ||
+ (strcasecmp(value, SMB_EXEC_DISP_TERMINATE) == 0))
return (SA_OK);
return (SA_BAD_VALUE);
diff --git a/usr/src/lib/libshare/smb/smb_share_doorclnt.c b/usr/src/lib/libshare/smb/smb_share_doorclnt.c
index af9f3efa6d..fdd5706f2d 100644
--- a/usr/src/lib/libshare/smb/smb_share_doorclnt.c
+++ b/usr/src/lib/libshare/smb/smb_share_doorclnt.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -41,7 +40,6 @@
#include <smbsrv/libsmb.h>
#include <smbsrv/smb_share.h>
-#include <smbsrv/lmerr.h>
#include <smbsrv/smb.h>
#define SMB_SHARE_DOOR_CALL_RETRIES 3
diff --git a/usr/src/lib/libsmbfs/smb/netshareenum.c b/usr/src/lib/libsmbfs/smb/netshareenum.c
index bd2c24caec..af5a0bb9bd 100644
--- a/usr/src/lib/libsmbfs/smb/netshareenum.c
+++ b/usr/src/lib/libsmbfs/smb/netshareenum.c
@@ -37,8 +37,7 @@
/* END CSTYLED */
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <stdlib.h>
@@ -313,7 +312,7 @@ rap_netshareenum(struct smb_ctx *ctx, int *entriesp, int *totalp,
error = smb_rap_NetShareEnum(ctx, 1, rpbuf, &bufsize, &entries, &total);
if (error &&
- error != (SMB_ERROR_MORE_DATA | SMB_RAP_ERROR)) {
+ error != (ERROR_MORE_DATA | SMB_RAP_ERROR)) {
free(rpbuf);
return (error);
}
diff --git a/usr/src/lib/libsmbfs/smb/ssnsetup.c b/usr/src/lib/libsmbfs/smb/ssnsetup.c
index c8234c8040..03f92dc62c 100644
--- a/usr/src/lib/libsmbfs/smb/ssnsetup.c
+++ b/usr/src/lib/libsmbfs/smb/ssnsetup.c
@@ -72,11 +72,6 @@
#include "ntlm.h"
#include "smb_crypt.h"
-/*
- * When we have a _real_ ntstatus.h, eliminate this.
- * XXX: Current smb.h defines it without the high bits.
- */
-#define STATUS_MORE_PROCESSING_REQUIRED 0xC0000016
static int
smb__ssnsetup(struct smb_ctx *ctx,
@@ -284,7 +279,7 @@ smb_ssnsetup_spnego(struct smb_ctx *ctx, struct mbdata *hint_mb)
goto out;
if (ntstatus == 0)
break; /* normal loop termination */
- if (ntstatus != STATUS_MORE_PROCESSING_REQUIRED) {
+ if (ntstatus != NT_STATUS_MORE_PROCESSING_REQUIRED) {
err = EAUTH;
goto out;
}
@@ -424,7 +419,7 @@ smb__ssnsetup(struct smb_ctx *ctx,
* Note: err=0, means rq_status is valid.
*/
if (rqp->rq_status != 0 &&
- rqp->rq_status != STATUS_MORE_PROCESSING_REQUIRED) {
+ rqp->rq_status != NT_STATUS_MORE_PROCESSING_REQUIRED) {
goto out;
}
diff --git a/usr/src/lib/smbsrv/libmlrpc/common/ndr_ops.c b/usr/src/lib/smbsrv/libmlrpc/common/ndr_ops.c
index a8b5c1e388..0e8fdf575e 100644
--- a/usr/src/lib/smbsrv/libmlrpc/common/ndr_ops.c
+++ b/usr/src/lib/smbsrv/libmlrpc/common/ndr_ops.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -50,7 +50,6 @@
#include <smbsrv/libsmb.h>
#include <smbsrv/libmlrpc.h>
-#include <smbsrv/ntstatus.h>
#define NDOBUFSZ 128
diff --git a/usr/src/lib/smbsrv/libmlsvc/Makefile.com b/usr/src/lib/smbsrv/libmlsvc/Makefile.com
index e9beaf6948..60a07f57d3 100644
--- a/usr/src/lib/smbsrv/libmlsvc/Makefile.com
+++ b/usr/src/lib/smbsrv/libmlsvc/Makefile.com
@@ -19,9 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
LIBRARY = libmlsvc.a
@@ -32,7 +30,7 @@ OBJS_COMMON = \
dssetup_clnt.o \
dssetup_svc.o \
eventlog_svc.o \
- eventlog_syslog.o \
+ eventlog_log.o \
lsalib.o \
lsar_clnt.o \
lsar_svc.o \
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/dfs.c b/usr/src/lib/smbsrv/libmlsvc/common/dfs.c
index b8ed853a3a..95db141bf0 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/dfs.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/dfs.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <strings.h>
@@ -28,16 +28,16 @@
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
+#include <dlfcn.h>
#include <pthread.h>
#include <syslog.h>
#include <sys/fs_reparse.h>
#include <uuid/uuid.h>
-#include <smbsrv/nterror.h>
-#include <smbsrv/smb_dfs.h>
-#include <smbsrv/smb_share.h>
#include <smbsrv/libsmb.h>
#include <smbsrv/libmlsvc.h>
+#include <smbsrv/smb_dfs.h>
+#include <smbsrv/smb_share.h>
#include <dfs.h>
/*
@@ -60,6 +60,12 @@
#define DFS_INFO_ALL 0
+static void *dfs_intr_hdl = NULL;
+
+static struct {
+ int (*dfsops_remote_count)(uint32_t *);
+} dfs_intr_ops;
+
/*
* Namespace cache
*
@@ -143,6 +149,18 @@ dfs_init(void)
return;
(void) strlcpy(dfs_nbname, di.di_nbname, NETBIOS_NAME_SZ);
+
+ bzero((void *)&dfs_intr_ops, sizeof (dfs_intr_ops));
+
+ if ((dfs_intr_hdl = smb_dlopen()) == NULL)
+ return;
+
+ if ((dfs_intr_ops.dfsops_remote_count =
+ (int (*)())dlsym(dfs_intr_hdl, "smb_dfs_remote_count")) == NULL) {
+ smb_dlclose(dfs_intr_hdl);
+ dfs_intr_hdl = NULL;
+ bzero((void *)&dfs_intr_ops, sizeof (dfs_intr_ops));
+ }
}
/*
@@ -153,6 +171,7 @@ dfs_init(void)
void
dfs_fini(void)
{
+ smb_dlclose(dfs_intr_hdl);
smb_cache_destroy(&dfs_nscache);
}
@@ -251,6 +270,20 @@ dfs_namespace_count(void)
smb_shriter_t shi;
smb_share_t *si;
uint32_t nroot = 0;
+ int rc;
+
+ if (dfs_intr_ops.dfsops_remote_count != NULL &&
+ (rc = dfs_intr_ops.dfsops_remote_count(&nroot)) != 0) {
+ /*
+ * If this call fails, let's assume there's at least one root
+ * namespace already configured. The interposer library cannot
+ * confirm or deny the presence of a namespace, so let's take
+ * the safe approach and assume one exists.
+ */
+ nroot = 1;
+ syslog(LOG_WARNING, "dfs: dfsops_remote_count() failed: %d, "
+ "assuming one namespace exists", rc);
+ }
smb_shr_iterinit(&shi);
while ((si = smb_shr_iterate(&shi)) != NULL) {
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/dssetup_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/dssetup_svc.c
index 501c74c391..07986c2c93 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/dssetup_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/dssetup_svc.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -36,7 +36,6 @@
#include <smbsrv/libmlrpc.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/dssetup.ndl>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/nmpipes.h>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/eventlog_syslog.c b/usr/src/lib/smbsrv/libmlsvc/common/eventlog_log.c
index c5169ee758..5c36ac0fc0 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/eventlog_syslog.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/eventlog_log.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <stdio.h>
@@ -40,6 +39,17 @@
#include <smbsrv/ndl/eventlog.ndl>
#include <smbsrv/libmlsvc.h>
+typedef struct logr_eventlog {
+ const char *el_name;
+ const char *el_path;
+} logr_eventlog_t;
+
+logr_eventlog_t logr_eventlog[] = {
+ { "System", "/var/adm/messages" },
+ { "smbd", "/var/smb/smbd_log.txt" },
+ { "smbrdr", "/var/smb/smbrdr_log.txt" }
+};
+
typedef enum {
LOGR_MONTH = 0,
LOGR_DAY,
@@ -301,11 +311,20 @@ static int
logr_syslog_snapshot(char *logname, logr_info_t *loginfo)
{
FILE *fp;
+ char path[MAXPATHLEN];
+ int i;
if ((loginfo == NULL) || (!logr_is_supported(logname)))
return (-1);
- if ((fp = fopen("/var/adm/messages", "r")) == 0)
+ path[0] = '\0';
+ for (i = 0; i < sizeof (logr_eventlog)/sizeof (logr_eventlog[0]); ++i) {
+ if (strcasecmp(logname, logr_eventlog[i].el_name) == 0)
+ (void) strlcpy(path, logr_eventlog[i].el_path,
+ MAXPATHLEN);
+ }
+
+ if ((fp = fopen(path, "r")) == 0)
return (-1);
if (logr_syslog_load(fp, loginfo) < 0) {
@@ -329,16 +348,20 @@ logr_syslog_snapshot(char *logname, logr_info_t *loginfo)
boolean_t
logr_is_supported(char *log_name)
{
+ int i;
+
if (log_name == NULL)
return (B_FALSE);
if (logr_interposer_ops.logr_op_supported != NULL)
return (logr_interposer_ops.logr_op_supported(log_name));
- if (strcasecmp(log_name, LOGR_SYSTEM_LOG) != 0)
- return (B_FALSE);
+ for (i = 0; i < sizeof (logr_eventlog)/sizeof (logr_eventlog[0]); ++i) {
+ if (strcasecmp(log_name, logr_eventlog[i].el_name) == 0)
+ return (B_TRUE);
+ }
- return (B_TRUE);
+ return (B_FALSE);
}
/*
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/eventlog_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/eventlog_svc.c
index 3a47a3041d..34438c6cae 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/eventlog_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/eventlog_svc.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -31,11 +31,9 @@
#include <strings.h>
#include <smbsrv/libsmb.h>
#include <smbsrv/libmlrpc.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/nmpipes.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/eventlog.ndl>
-#include <smbsrv/nterror.h>
#define LOGR_FWD +1
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/libmlsvc.h b/usr/src/lib/smbsrv/libmlsvc/common/libmlsvc.h
index 01484483b1..de73911afb 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/libmlsvc.h
+++ b/usr/src/lib/smbsrv/libmlsvc/common/libmlsvc.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _LIBMLSVC_H
@@ -95,10 +94,6 @@ int mlsvc_encrypt_nt_password(char *password, char *key, int keylen, char *out,
#define SMB_AUTOHOME_FILE "smbautohome"
#define SMB_AUTOHOME_PATH "/etc"
-#define SMB_CVOL "/var/smb/cvol"
-#define SMB_SYSROOT "/var/smb/cvol/windows"
-#define SMB_SYSTEM32 "/var/smb/cvol/windows/system32"
-#define SMB_VSS "/var/smb/cvol/windows/system32/vss"
typedef struct smb_autohome {
struct smb_autohome *ah_next;
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/lsalib.c b/usr/src/lib/smbsrv/libmlsvc/common/lsalib.c
index 5545ab1d3a..62732106c6 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/lsalib.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/lsalib.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -32,7 +32,6 @@
#include <smbsrv/libsmb.h>
#include <smbsrv/libmlsvc.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/smb_token.h>
@@ -239,9 +238,9 @@ lsa_enum_trusted_domains(char *server, char *domain,
enum_context = 0;
status = lsar_enum_trusted_domains(&domain_handle, &enum_context, info);
- if (status == NT_STATUS_NO_MORE_DATA) {
+ if (status == NT_STATUS_NO_MORE_ENTRIES) {
/*
- * NT_STATUS_NO_MORE_DATA indicates that we
+ * STATUS_NO_MORE_ENTRIES indicates that we
* have all of the available information.
*/
status = NT_STATUS_SUCCESS;
@@ -279,9 +278,9 @@ lsa_enum_trusted_domains_ex(char *server, char *domain,
status = lsar_enum_trusted_domains_ex(&domain_handle, &enum_context,
info);
- if (status == NT_STATUS_NO_MORE_DATA) {
+ if (status == NT_STATUS_NO_MORE_ENTRIES) {
/*
- * NT_STATUS_NO_MORE_DATA indicates that we
+ * STATUS_NO_MORE_ENTRIES indicates that we
* have all of the available information.
*/
status = NT_STATUS_SUCCESS;
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/lsar_clnt.c b/usr/src/lib/smbsrv/libmlsvc/common/lsar_clnt.c
index e01ac58363..df29495ed1 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/lsar_clnt.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/lsar_clnt.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -36,7 +36,6 @@
#include <smbsrv/libmlsvc.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/ntaccess.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/ntlocale.h>
#include <smbsrv/string.h>
#include <lsalib.h>
@@ -986,8 +985,7 @@ lsar_enum_accounts(mlsvc_handle_t *lsa_handle, DWORD *enum_context,
rc = ndr_rpc_call(lsa_handle, opnum, &arg);
if (rc == 0) {
if (arg.status != 0) {
- if ((arg.status & 0x00FFFFFF) ==
- NT_STATUS_NO_MORE_DATA) {
+ if (arg.status == NT_STATUS_NO_MORE_ENTRIES) {
*enum_context = arg.enum_context;
} else {
ndr_rpc_status(lsa_handle, opnum, arg.status);
@@ -1057,10 +1055,10 @@ lsar_enum_trusted_domains(mlsvc_handle_t *lsa_handle, DWORD *enum_context,
status = NT_SC_VALUE(arg.status);
/*
- * status 0x8000001A means NO_MORE_DATA,
- * which is not an error.
+ * STATUS_NO_MORE_ENTRIES provides call
+ * status but does not indicate an error.
*/
- if (status != NT_STATUS_NO_MORE_DATA)
+ if (status != NT_STATUS_NO_MORE_ENTRIES)
ndr_rpc_status(lsa_handle, opnum, arg.status);
} else if (arg.enum_buf->entries_read == 0) {
*enum_context = arg.enum_context;
@@ -1101,10 +1099,10 @@ lsar_enum_trusted_domains_ex(mlsvc_handle_t *lsa_handle, DWORD *enum_context,
status = NT_SC_VALUE(arg.status);
/*
- * status 0x8000001A means NO_MORE_DATA,
- * which is not an error.
+ * STATUS_NO_MORE_ENTRIES provides call
+ * status but does not indicate an error.
*/
- if (status != NT_STATUS_NO_MORE_DATA)
+ if (status != NT_STATUS_NO_MORE_ENTRIES)
ndr_rpc_status(lsa_handle, opnum, arg.status);
} else if (arg.enum_buf->entries_read == 0) {
*enum_context = arg.enum_context;
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/lsar_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/lsar_svc.c
index 7e9a3aa0e0..652164bce1 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/lsar_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/lsar_svc.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -37,8 +37,6 @@
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/lsarpc.ndl>
#include <lsalib.h>
-#include <smbsrv/ntstatus.h>
-#include <smbsrv/nterror.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/nmpipes.h>
#include <smbsrv/ntlocale.h>
@@ -220,7 +218,7 @@ lsarpc_s_QuerySecurityObject(void *arg, ndr_xa_t *mxa)
* multiple enumeration calls to obtain the complete list of SIDs.
* It should be set to 0 on the first call and passed unchanged on
* subsequent calls until there are no more accounts - the server will
- * return NT_SC_WARNING(NT_STATUS_NO_MORE_DATA).
+ * return STATUS_NO_MORE_ENTRIES.
*
* For now just set the status to access-denied. Note that we still have
* to provide a valid address for enum_buf because it's a reference and
@@ -257,7 +255,7 @@ lsarpc_s_EnumAccounts(void *arg, ndr_xa_t *mxa)
* support multiple enumeration calls to obtain the complete list.
* It should be set to 0 on the first call and passed unchanged on
* subsequent calls until there are no more accounts - the server will
- * return NT_SC_WARNING(NT_STATUS_NO_MORE_DATA).
+ * return STATUS_NO_MORE_ENTRIES.
*
* For now just set the status to access-denied. Note that we still have
* to provide a valid address for enum_buf because it's a reference and
@@ -292,7 +290,7 @@ lsarpc_s_EnumTrustedDomain(void *arg, ndr_xa_t *mxa)
* support multiple enumeration calls to obtain the complete list.
* It should be set to 0 on the first call and passed unchanged on
* subsequent calls until there are no more accounts - the server will
- * return NT_SC_WARNING(NT_STATUS_NO_MORE_DATA).
+ * return STATUS_NO_MORE_ENTRIES.
*
* For now just set the status to access-denied. Note that we still have
* to provide a valid address for enum_buf because it's a reference and
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_client.c b/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_client.c
index b941e4fcc0..db7dabff06 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_client.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_client.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -407,14 +407,20 @@ ndr_rpc_status(mlsvc_handle_t *handle, int opnum, DWORD status)
char *name = "NDR RPC";
char *s = "unknown";
- if (status == 0)
+ switch (NT_SC_SEVERITY(status)) {
+ case NT_STATUS_SEVERITY_SUCCESS:
s = "success";
- else if (NT_SC_IS_ERROR(status))
- s = "error";
- else if (NT_SC_IS_WARNING(status))
- s = "warning";
- else if (NT_SC_IS_INFO(status))
+ break;
+ case NT_STATUS_SEVERITY_INFORMATIONAL:
s = "info";
+ break;
+ case NT_STATUS_SEVERITY_WARNING:
+ s = "warning";
+ break;
+ case NT_STATUS_SEVERITY_ERROR:
+ s = "error";
+ break;
+ }
if (handle) {
svc = handle->clnt->binding->service;
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_domain.c b/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_domain.c
index a0ee06feec..f2ea5f7270 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_domain.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_domain.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <syslog.h>
@@ -42,7 +42,6 @@
#include <smbsrv/libmlsvc.h>
#include <smbsrv/smbinfo.h>
-#include <smbsrv/ntstatus.h>
#include <lsalib.h>
/*
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_netr.c b/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_netr.c
index 5f1cfa7417..b27fc29cd2 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_netr.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_netr.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -34,8 +34,6 @@
#include <smbsrv/libsmb.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/netlogon.ndl>
-#include <smbsrv/ntstatus.h>
-#include <smbsrv/nterror.h>
#include <smbsrv/nmpipes.h>
#include <smbsrv/netrauth.h>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/msgsvc_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/msgsvc_svc.c
index e630322c1f..78538e6291 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/msgsvc_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/msgsvc_svc.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -34,7 +34,6 @@
#include <smbsrv/libmlrpc.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/msgsvc.ndl>
-#include <smbsrv/nterror.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/nmpipes.h>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/netdfs.c b/usr/src/lib/smbsrv/libmlsvc/common/netdfs.c
index 97df584fe3..f9155aa949 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/netdfs.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/netdfs.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -36,10 +36,9 @@
#include <strings.h>
#include <sys/sysmacros.h>
-#include <smbsrv/ndl/netdfs.ndl>
-#include <smbsrv/nmpipes.h>
-#include <smbsrv/nterror.h>
#include <smbsrv/libmlsvc.h>
+#include <smbsrv/nmpipes.h>
+#include <smbsrv/ndl/netdfs.ndl>
#include <dfs.h>
/*
@@ -711,10 +710,13 @@ netdfs_s_addstdroot(void *arg, ndr_xa_t *mxa)
dfs_setpriv(PRIV_ON);
/* For now only allow a single standalone namespace */
- if (dfs_namespace_count() == 0)
+ if (dfs_namespace_count() == 0) {
param->status = dfs_namespace_add(share, comment);
- else
+ if (param->status == ERROR_SUCCESS)
+ (void) smb_config_setnum(SMB_CI_DFS_STDROOT_NUM, 1);
+ } else {
param->status = ERROR_NOT_SUPPORTED;
+ }
dfs_setpriv(PRIV_OFF);
return (NDR_DRC_OK);
@@ -735,10 +737,13 @@ netdfs_s_remstdroot(void *arg, ndr_xa_t *mxa)
dfs_setpriv(PRIV_ON);
- if (ndr_is_admin(mxa))
+ if (ndr_is_admin(mxa)) {
param->status = dfs_namespace_remove(share);
- else
+ if (param->status == ERROR_SUCCESS)
+ (void) smb_config_setnum(SMB_CI_DFS_STDROOT_NUM, 0);
+ } else {
param->status = ERROR_ACCESS_DENIED;
+ }
dfs_setpriv(PRIV_OFF);
return (NDR_DRC_OK);
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/netr_auth.c b/usr/src/lib/smbsrv/libmlsvc/common/netr_auth.c
index 0df79c5044..96fc566706 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/netr_auth.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/netr_auth.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -43,7 +43,6 @@
#include <smbsrv/libsmbns.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/netlogon.ndl>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/netrauth.h>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/netr_logon.c b/usr/src/lib/smbsrv/libmlsvc/common/netr_logon.c
index 7988becfa1..46e7117f92 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/netr_logon.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/netr_logon.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -41,7 +41,6 @@
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/netlogon.ndl>
#include <smbsrv/netrauth.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/smb_token.h>
#include <mlsvc.h>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/samlib.c b/usr/src/lib/smbsrv/libmlsvc/common/samlib.c
index 1c659bcc16..601283fa5e 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/samlib.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/samlib.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -32,8 +32,6 @@
#include <smbsrv/libsmb.h>
#include <smbsrv/libmlsvc.h>
-
-#include <smbsrv/ntstatus.h>
#include <smbsrv/ntaccess.h>
#include <lsalib.h>
#include <samlib.h>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/samr_clnt.c b/usr/src/lib/smbsrv/libmlsvc/common/samr_clnt.c
index 3236ab5381..24cb122717 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/samr_clnt.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/samr_clnt.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -47,7 +47,6 @@
#include <smbsrv/libmlrpc.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/smbinfo.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/ntaccess.h>
#include <smbsrv/smb_sid.h>
#include <samlib.h>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/samr_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/samr_svc.c
index 109a29801f..9371410b54 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/samr_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/samr_svc.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -40,8 +41,6 @@
#include <smbsrv/libsmb.h>
#include <smbsrv/libmlrpc.h>
#include <smbsrv/libmlsvc.h>
-#include <smbsrv/ntstatus.h>
-#include <smbsrv/nterror.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/nmpipes.h>
#include <smbsrv/ndl/samrpc.ndl>
@@ -1287,7 +1286,7 @@ samr_s_QueryDispInfo(void *arg, ndr_xa_t *mxa)
retcnt = max_retcnt;
param->status = status;
} else {
- param->status = ERROR_MORE_ENTRIES;
+ param->status = NT_STATUS_MORE_ENTRIES;
}
param->users.total_size = num_users;
@@ -1500,12 +1499,6 @@ samr_s_CreateDomainAlias(void *arg, ndr_xa_t *mxa)
return (NDR_DRC_OK);
}
- if (getgrnam(gname) == NULL) {
- bzero(&param->alias_handle, sizeof (samr_handle_t));
- param->status = NT_SC_ERROR(NT_STATUS_INVALID_PARAMETER);
- return (NDR_DRC_OK);
- }
-
rc = smb_lgrp_add(gname, "");
if (rc != SMB_LGRP_SUCCESS) {
bzero(&param->alias_handle, sizeof (samr_handle_t));
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/smb_autohome.c b/usr/src/lib/smbsrv/libmlsvc/common/smb_autohome.c
index a82bbae956..8ffc4f6f28 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/smb_autohome.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/smb_autohome.c
@@ -516,6 +516,24 @@ smb_autohome_parse_options(smb_share_t *si)
continue;
}
+ if (strncasecmp(value, "rw=", 3) == 0) {
+ (void) strlcpy(si->shr_access_rw, (value + 3),
+ sizeof (si->shr_access_rw));
+ continue;
+ }
+
+ if (strncasecmp(value, "ro=", 3) == 0) {
+ (void) strlcpy(si->shr_access_ro, (value + 3),
+ sizeof (si->shr_access_ro));
+ continue;
+ }
+
+ if (strncasecmp(value, "none=", 5) == 0) {
+ (void) strlcpy(si->shr_access_none, (value + 5),
+ sizeof (si->shr_access_none));
+ continue;
+ }
+
if (separator)
(void) strlcat(bp, ",", MAXPATHLEN);
(void) strlcat(bp, value, MAXPATHLEN);
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/smb_quota.c b/usr/src/lib/smbsrv/libmlsvc/common/smb_quota.c
index 9f3932d5d1..ab6c74bff7 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/smb_quota.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/smb_quota.c
@@ -18,9 +18,11 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
+
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@@ -34,7 +36,6 @@
#include <errno.h>
#include <synch.h>
#include <smbsrv/smb_xdr.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/smb_idmap.h>
#include <mlsvc.h>
@@ -494,7 +495,7 @@ smb_quota_query_all(smb_quota_tree_t *qtree, smb_quota_query_t *request,
} else if (request->qq_restart) {
quota = avl_first(avl_tree);
if (quota == NULL)
- return (NT_STATUS_NO_MORE_DATA);
+ return (NT_STATUS_NO_MORE_ENTRIES);
} else {
sid_list = &request->qq_sid_list;
sid = list_head(sid_list);
@@ -504,7 +505,7 @@ smb_quota_query_all(smb_quota_tree_t *qtree, smb_quota_query_t *request,
return (NT_STATUS_INVALID_PARAMETER);
quota = AVL_NEXT(avl_tree, quota);
if (quota == NULL)
- return (NT_STATUS_NO_MORE_DATA);
+ return (NT_STATUS_NO_MORE_ENTRIES);
}
if ((request->qq_single) && (request->qq_max_quota > 1))
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/smb_share.c b/usr/src/lib/smbsrv/libmlsvc/common/smb_share.c
index 5c7154b82d..902efd1b71 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/smb_share.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/smb_share.c
@@ -197,14 +197,12 @@ static void smb_shr_unpublish(const char *, const char *);
*/
static uint32_t smb_shr_lookup(char *, smb_share_t *);
static uint32_t smb_shr_add_transient(char *, char *, char *);
-static void smb_shr_set_oemname(smb_share_t *);
static int smb_shr_enable_all_privs(void);
-static int smb_shr_expand_subs(char **, smb_share_t *, smb_execsub_info_t *);
+static int smb_shr_expand_subs(char **, smb_share_t *, smb_shr_execinfo_t *);
static char **smb_shr_tokenize_cmd(char *);
static void smb_shr_sig_abnormal_term(int);
static void smb_shr_sig_child(int);
-static void smb_shr_get_exec_info(void);
-static void smb_shr_set_exec_flags(smb_share_t *);
+static int smb_shr_encode(smb_share_t *, nvlist_t **);
/*
* libshare handle and synchronization
@@ -217,7 +215,6 @@ typedef struct smb_sa_handle {
static smb_sa_handle_t smb_sa_handle;
-static int smb_shr_exec_flags;
static char smb_shr_exec_map[MAXPATHLEN];
static char smb_shr_exec_unmap[MAXPATHLEN];
static mutex_t smb_shr_exec_mtx;
@@ -327,7 +324,10 @@ smb_shr_load(void)
rc = pthread_create(&load_thr, &tattr, smb_shr_sa_loadall, 0);
(void) pthread_attr_destroy(&tattr);
- smb_shr_get_exec_info();
+ (void) mutex_lock(&smb_shr_exec_mtx);
+ (void) smb_config_get_execinfo(smb_shr_exec_map, smb_shr_exec_unmap,
+ MAXPATHLEN);
+ (void) mutex_unlock(&smb_shr_exec_mtx);
return (rc);
}
@@ -383,7 +383,6 @@ smb_shr_iterate(smb_shriter_t *shi)
if ((cached_si = smb_shr_cache_iterate(shi)) != NULL) {
share = &shi->si_share;
bcopy(cached_si, share, sizeof (smb_share_t));
- smb_shr_set_exec_flags(share);
}
smb_shr_cache_unlock();
}
@@ -406,6 +405,7 @@ uint32_t
smb_shr_add(smb_share_t *si)
{
smb_share_t *cached_si;
+ nvlist_t *shrlist;
uint32_t status;
int rc;
@@ -437,16 +437,19 @@ smb_shr_add(smb_share_t *si)
/* don't hold the lock across door call */
smb_shr_cache_unlock();
- /* call kernel to take a hold on the shared file system */
- rc = smb_kmod_share(si->shr_path, si->shr_name);
+ if ((rc = smb_shr_encode(si, &shrlist)) == 0) {
+ /* send the share to kernel */
+ rc = smb_kmod_share(shrlist);
+ nvlist_free(shrlist);
- if (rc == 0) {
- smb_shr_publish(si->shr_name, si->shr_container);
+ if (rc == 0) {
+ smb_shr_publish(si->shr_name, si->shr_container);
- /* If path is ZFS, add the .zfs/shares/<share> entry. */
- smb_shr_zfs_add(si);
+ /* If path is ZFS, add the .zfs/shares/<share> entry. */
+ smb_shr_zfs_add(si);
- return (NERR_Success);
+ return (NERR_Success);
+ }
}
if (smb_shr_cache_lock(SMB_SHR_CACHE_WRLOCK) == NERR_Success) {
@@ -472,9 +475,9 @@ uint32_t
smb_shr_remove(char *sharename)
{
smb_share_t *si;
- char path[MAXPATHLEN];
char container[MAXPATHLEN];
boolean_t dfsroot;
+ nvlist_t *shrlist;
assert(sharename != NULL);
@@ -507,8 +510,8 @@ smb_shr_remove(char *sharename)
* to remove before cleanup of cache occurs.
*/
smb_shr_zfs_remove(si);
+ (void) smb_shr_encode(si, &shrlist);
- (void) strlcpy(path, si->shr_path, sizeof (path));
(void) strlcpy(container, si->shr_container, sizeof (container));
dfsroot = ((si->shr_flags & SMB_SHRF_DFSROOT) != 0);
smb_shr_cache_delent(sharename);
@@ -517,7 +520,10 @@ smb_shr_remove(char *sharename)
smb_shr_unpublish(sharename, container);
/* call kernel to release the hold on the shared file system */
- (void) smb_kmod_unshare(path, sharename);
+ if (shrlist != NULL) {
+ (void) smb_kmod_unshare(shrlist);
+ nvlist_free(shrlist);
+ }
if (dfsroot)
dfs_namespace_unload(sharename);
@@ -536,6 +542,7 @@ smb_shr_rename(char *from_name, char *to_name)
smb_share_t *from_si;
smb_share_t to_si;
uint32_t status;
+ nvlist_t *shrlist;
assert((from_name != NULL) && (to_name != NULL));
@@ -576,6 +583,16 @@ smb_shr_rename(char *from_name, char *to_name)
smb_shr_cache_delent(from_name);
smb_shr_cache_unlock();
+ if (smb_shr_encode(from_si, &shrlist) == 0) {
+ (void) smb_kmod_unshare(shrlist);
+ nvlist_free(shrlist);
+
+ if (smb_shr_encode(&to_si, &shrlist) == 0) {
+ (void) smb_kmod_share(shrlist);
+ nvlist_free(shrlist);
+ }
+ }
+
smb_shr_unpublish(from_name, to_si.shr_container);
smb_shr_publish(to_name, to_si.shr_container);
@@ -621,6 +638,7 @@ smb_shr_modify(smb_share_t *new_si)
boolean_t adc_changed = B_FALSE;
char old_container[MAXPATHLEN];
uint32_t access, flag;
+ nvlist_t *shrlist;
assert(new_si != NULL);
@@ -687,6 +705,16 @@ smb_shr_modify(smb_share_t *new_si)
smb_shr_cache_unlock();
+ if (smb_shr_encode(si, &shrlist) == 0) {
+ (void) smb_kmod_unshare(shrlist);
+ nvlist_free(shrlist);
+
+ if (smb_shr_encode(new_si, &shrlist) == 0) {
+ (void) smb_kmod_share(shrlist);
+ nvlist_free(shrlist);
+ }
+ }
+
if (adc_changed) {
smb_shr_unpublish(new_si->shr_name, old_container);
smb_shr_publish(new_si->shr_name, new_si->shr_container);
@@ -732,29 +760,30 @@ smb_shr_exists(char *sharename)
* needed. If x is wildcard (< 0) then check to see if the other
* values are a match. If a match, that wins.
*
- * ipv6 is wide open for now, see smb_chk_hostaccess
+ * ipv6 is wide open (returns SMB_SHRF_ACC_OPEN) for now until the underlying
+ * functions support ipv6.
*/
-void
-smb_shr_hostaccess(smb_share_t *si, smb_inaddr_t *ipaddr)
+uint32_t
+smb_shr_hostaccess(smb_inaddr_t *ipaddr, char *none_list, char *ro_list,
+ char *rw_list, uint32_t flag)
{
- int acc = SMB_SHRF_ACC_OPEN;
+ uint32_t acc = SMB_SHRF_ACC_NONE;
+ int none = 0;
+ int ro = 0;
+ int rw = 0;
+
+ if (!smb_inet_iszero(ipaddr)) {
+
+ if (ipaddr->a_family == AF_INET6)
+ return (SMB_SHRF_ACC_OPEN);
+
+ if ((flag & SMB_SHRF_ACC_NONE) != 0)
+ none = smb_chk_hostaccess(ipaddr, none_list);
+ if ((flag & SMB_SHRF_ACC_RO) != 0)
+ ro = smb_chk_hostaccess(ipaddr, ro_list);
+ if ((flag & SMB_SHRF_ACC_RW) != 0)
+ rw = smb_chk_hostaccess(ipaddr, rw_list);
- /*
- * Check to see if there area any share level access
- * restrictions.
- */
- if ((!smb_inet_iszero(ipaddr)) &&
- (si->shr_flags & SMB_SHRF_ACC_ALL) != 0) {
- int none = SMB_SHRF_ACC_OPEN;
- int rw = SMB_SHRF_ACC_OPEN;
- int ro = SMB_SHRF_ACC_OPEN;
-
- if (si->shr_flags & SMB_SHRF_ACC_NONE)
- none = smb_chk_hostaccess(ipaddr, si->shr_access_none);
- if (si->shr_flags & SMB_SHRF_ACC_RW)
- rw = smb_chk_hostaccess(ipaddr, si->shr_access_rw);
- if (si->shr_flags & SMB_SHRF_ACC_RO)
- ro = smb_chk_hostaccess(ipaddr, si->shr_access_ro);
/* make first pass to get basic value */
if (none != 0)
acc = SMB_SHRF_ACC_NONE;
@@ -784,7 +813,8 @@ smb_shr_hostaccess(smb_share_t *si, smb_inaddr_t *ipaddr)
acc = SMB_SHRF_ACC_RO;
}
}
- si->shr_access_value = acc; /* return access here */
+
+ return (acc);
}
/*
@@ -995,7 +1025,7 @@ smb_shr_list(int offset, smb_shrlist_t *list)
* Returns 0 on success. Otherwise non-zero for errors.
*/
int
-smb_shr_exec(char *share, smb_execsub_info_t *subs, int exec_type)
+smb_shr_exec(smb_shr_execinfo_t *subs)
{
char cmd[MAXPATHLEN], **cmd_tokens, *path, *ptr;
pid_t child_pid;
@@ -1003,18 +1033,18 @@ smb_shr_exec(char *share, smb_execsub_info_t *subs, int exec_type)
struct sigaction pact, cact;
smb_share_t si;
- if (smb_shr_get(share, &si) != 0)
+ if (smb_shr_get(subs->e_sharename, &si) != 0)
return (-1);
*cmd = '\0';
(void) mutex_lock(&smb_shr_exec_mtx);
- switch (exec_type) {
- case SMB_SHR_MAP:
+ switch (subs->e_type) {
+ case SMB_EXEC_MAP:
(void) strlcpy(cmd, smb_shr_exec_map, sizeof (cmd));
break;
- case SMB_SHR_UNMAP:
+ case SMB_EXEC_UNMAP:
(void) strlcpy(cmd, smb_shr_exec_unmap, sizeof (cmd));
break;
default:
@@ -1146,7 +1176,6 @@ smb_shr_lookup(char *sharename, smb_share_t *si)
cached_si = smb_shr_cache_findent(sharename);
if (cached_si != NULL) {
bcopy(cached_si, si, sizeof (smb_share_t));
- smb_shr_set_exec_flags(si);
status = NERR_Success;
}
@@ -1189,50 +1218,6 @@ smb_shr_add_transient(char *name, char *cmnt, char *path)
}
/*
- * smb_shr_set_oemname
- *
- * Generate the OEM name for the specified share. If the name is
- * shorter than 13 bytes the oemname will be saved in si->shr_oemname.
- * Otherwise si->shr_oemname will be empty and SMB_SHRF_LONGNAME will
- * be set in si->shr_flags.
- */
-static void
-smb_shr_set_oemname(smb_share_t *si)
-{
- smb_wchar_t *unibuf;
- char *oem_name;
- int length;
-
- length = strlen(si->shr_name) + 1;
-
- oem_name = malloc(length);
- unibuf = malloc(length * sizeof (smb_wchar_t));
- if ((oem_name == NULL) || (unibuf == NULL)) {
- free(oem_name);
- free(unibuf);
- return;
- }
-
- (void) smb_mbstowcs(unibuf, si->shr_name, length);
-
- if (ucstooem(oem_name, unibuf, length, OEM_CPG_850) == 0)
- (void) strcpy(oem_name, si->shr_name);
-
- free(unibuf);
-
- if (strlen(oem_name) + 1 > SMB_SHARE_OEMNAME_MAX) {
- si->shr_flags |= SMB_SHRF_LONGNAME;
- *si->shr_oemname = '\0';
- } else {
- si->shr_flags &= ~SMB_SHRF_LONGNAME;
- (void) strlcpy(si->shr_oemname, oem_name,
- SMB_SHARE_OEMNAME_MAX);
- }
-
- free(oem_name);
-}
-
-/*
* ============================================
* Cache management functions
*
@@ -1407,17 +1392,16 @@ smb_shr_cache_addent(smb_share_t *si)
if ((cache_ent = malloc(sizeof (smb_share_t))) == NULL)
return (ERROR_NOT_ENOUGH_MEMORY);
- bcopy(si, cache_ent, sizeof (smb_share_t));
-
- (void) smb_strlwr(cache_ent->shr_name);
- smb_shr_set_oemname(cache_ent);
+ (void) smb_strlwr(si->shr_name);
if ((si->shr_type & STYPE_IPC) == 0)
- cache_ent->shr_type = STYPE_DISKTREE;
- cache_ent->shr_type |= smb_shr_is_special(cache_ent->shr_name);
+ si->shr_type = STYPE_DISKTREE;
+ si->shr_type |= smb_shr_is_special(cache_ent->shr_name);
if (smb_shr_is_admin(cache_ent->shr_name))
- cache_ent->shr_flags |= SMB_SHRF_ADMIN;
+ si->shr_flags |= SMB_SHRF_ADMIN;
+
+ bcopy(si, cache_ent, sizeof (smb_share_t));
if (si->shr_flags & SMB_SHRF_AUTOHOME)
cache_ent->shr_refcnt = 1;
@@ -2251,7 +2235,7 @@ smb_shr_tokenize_cmd(char *cmdstr)
* Returns 0 on success. Otherwise -1.
*/
static int
-smb_shr_expand_subs(char **cmd_toks, smb_share_t *si, smb_execsub_info_t *subs)
+smb_shr_expand_subs(char **cmd_toks, smb_share_t *si, smb_shr_execinfo_t *subs)
{
char *fmt, *sub_chr, *ptr;
boolean_t unknown;
@@ -2388,46 +2372,76 @@ smb_shr_sig_child(int sig_val)
}
/*
- * Gets the exec bit flags for each share.
+ * This is a temporary function which converts the given smb_share_t
+ * structure to the nvlist format that will be provided by libsharev2
*/
-static void
-smb_shr_get_exec_info(void)
+static int
+smb_shr_encode(smb_share_t *si, nvlist_t **nvlist)
{
- char buf[MAXPATHLEN];
+ nvlist_t *list;
+ nvlist_t *share;
+ nvlist_t *smb;
+ char *csc;
+ int rc = 0;
- (void) mutex_lock(&smb_shr_exec_mtx);
+ *nvlist = NULL;
- smb_shr_exec_flags = 0;
+ if ((rc = nvlist_alloc(&list, NV_UNIQUE_NAME, 0)) != 0)
+ return (rc);
- *smb_shr_exec_map = '\0';
- (void) smb_config_getstr(SMB_CI_MAP, smb_shr_exec_map,
- sizeof (smb_shr_exec_map));
- if (*smb_shr_exec_map != '\0')
- smb_shr_exec_flags |= SMB_SHRF_MAP;
+ if ((rc = nvlist_alloc(&share, NV_UNIQUE_NAME, 0)) != 0) {
+ nvlist_free(list);
+ return (rc);
+ }
- *smb_shr_exec_unmap = '\0';
- (void) smb_config_getstr(SMB_CI_UNMAP, smb_shr_exec_unmap,
- sizeof (smb_shr_exec_unmap));
- if (*smb_shr_exec_unmap != '\0')
- smb_shr_exec_flags |= SMB_SHRF_UNMAP;
+ if ((rc = nvlist_alloc(&smb, NV_UNIQUE_NAME, 0)) != 0) {
+ nvlist_free(share);
+ nvlist_free(list);
+ return (rc);
+ }
- *buf = '\0';
- (void) smb_config_getstr(SMB_CI_DISPOSITION, buf, sizeof (buf));
- if (*buf != '\0')
- if (strcasecmp(buf, SMB_SHR_DISP_TERM_STR) == 0)
- smb_shr_exec_flags |= SMB_SHRF_DISP_TERM;
+ /* global share properties */
+ rc |= nvlist_add_string(share, "name", si->shr_name);
+ rc |= nvlist_add_string(share, "path", si->shr_path);
+ rc |= nvlist_add_string(share, "desc", si->shr_cmnt);
- (void) mutex_unlock(&smb_shr_exec_mtx);
-}
+ /* smb protocol properties */
+ rc = nvlist_add_string(smb, SHOPT_AD_CONTAINER, si->shr_container);
+ if ((si->shr_flags & SMB_SHRF_ACC_NONE) != 0)
+ rc |= nvlist_add_string(smb, SHOPT_NONE, si->shr_access_none);
+ if ((si->shr_flags & SMB_SHRF_ACC_RO) != 0)
+ rc |= nvlist_add_string(smb, SHOPT_RO, si->shr_access_ro);
+ if ((si->shr_flags & SMB_SHRF_ACC_RW) != 0)
+ rc |= nvlist_add_string(smb, SHOPT_RW, si->shr_access_rw);
-/*
- * Sets the exec bit flags for each share.
- */
-static void
-smb_shr_set_exec_flags(smb_share_t *si)
-{
- (void) mutex_lock(&smb_shr_exec_mtx);
- si->shr_flags &= ~SMB_SHRF_EXEC_MASK;
- si->shr_flags |= smb_shr_exec_flags;
- (void) mutex_unlock(&smb_shr_exec_mtx);
+ if ((si->shr_flags & SMB_SHRF_ABE) != 0)
+ rc |= nvlist_add_string(smb, SHOPT_ABE, "true");
+ if ((si->shr_flags & SMB_SHRF_CATIA) != 0)
+ rc |= nvlist_add_string(smb, SHOPT_CATIA, "true");
+ if ((si->shr_flags & SMB_SHRF_GUEST_OK) != 0)
+ rc |= nvlist_add_string(smb, SHOPT_GUEST, "true");
+ if ((si->shr_flags & SMB_SHRF_DFSROOT) != 0)
+ rc |= nvlist_add_string(smb, SHOPT_DFSROOT, "true");
+
+ if ((si->shr_flags & SMB_SHRF_AUTOHOME) != 0) {
+ rc |= nvlist_add_string(smb, "Autohome", "true");
+ rc |= nvlist_add_uint32(smb, "uid", si->shr_uid);
+ rc |= nvlist_add_uint32(smb, "gid", si->shr_gid);
+ }
+
+ if ((csc = smb_shr_sa_csc_name(si)) != NULL)
+ rc |= nvlist_add_string(smb, SHOPT_CSC, csc);
+
+ rc |= nvlist_add_nvlist(share, "smb", smb);
+ rc |= nvlist_add_nvlist(list, si->shr_name, share);
+
+ nvlist_free(share);
+ nvlist_free(smb);
+
+ if (rc != 0)
+ nvlist_free(list);
+ else
+ *nvlist = list;
+
+ return (rc);
}
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c
index 60337c6407..e49facd936 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -33,7 +33,6 @@
#include <smbsrv/libmlrpc.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/spoolss.ndl>
-#include <smbsrv/nterror.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/nmpipes.h>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_clnt.c b/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_clnt.c
index aea2011630..819f5f1aa7 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_clnt.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_clnt.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -40,7 +40,6 @@
#include <smbsrv/libsmb.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/smbinfo.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/ndl/srvsvc.ndl>
/*
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_sd.c b/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_sd.c
index 5ee879eb36..0ef6ba7658 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_sd.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_sd.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -29,8 +29,8 @@
*/
#include <strings.h>
#include <libzfs.h>
-#include <smbsrv/nterror.h>
-#include <smbsrv/ntstatus.h>
+
+#include <smbsrv/libsmb.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/srvsvc.ndl>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_svc.c
index dba55e7ffb..19645f3536 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_svc.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -51,7 +52,6 @@
#include <nss_dbdefs.h>
#include <smbsrv/libsmb.h>
#include <smbsrv/libmlsvc.h>
-#include <smbsrv/lmerr.h>
#include <smbsrv/nmpipes.h>
#include <smbsrv/smb.h>
#include <smbsrv/netrauth.h>
@@ -2959,7 +2959,8 @@ srvsvc_sa_modify(smb_share_t *si, srvsvc_netshare_setinfo_t *info)
sa_handle_t handle;
sa_share_t share;
sa_resource_t resource;
- boolean_t renamed = B_FALSE;
+ boolean_t renamed = B_FALSE, is_zfs = B_FALSE;
+ nvlist_t *nvl;
uint32_t nerr = NERR_Success;
if ((handle = smb_shr_sa_enter()) == NULL)
@@ -2975,20 +2976,45 @@ srvsvc_sa_modify(smb_share_t *si, srvsvc_netshare_setinfo_t *info)
return (NERR_InternalError);
}
+ if (sa_group_is_zfs(sa_get_parent_group(share))) {
+ is_zfs = B_TRUE;
+ if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) {
+ smb_shr_sa_exit();
+ return (NERR_InternalError);
+ }
+ }
+
if (info->nss_netname != NULL && info->nss_netname[0] != '\0' &&
smb_strcasecmp(info->nss_netname, si->shr_name, 0) != 0) {
- (void) sa_set_resource_attr(resource, SHOPT_NAME,
- info->nss_netname);
+ if (is_zfs)
+ (void) nvlist_add_string(nvl, SHOPT_NAME,
+ info->nss_netname);
+ else
+ (void) sa_set_resource_attr(resource, SHOPT_NAME,
+ info->nss_netname);
renamed = B_TRUE;
}
if ((info->nss_comment != NULL) &&
(strcmp(info->nss_comment, si->shr_cmnt) != 0)) {
- (void) sa_set_resource_description(resource, info->nss_comment);
+ if (is_zfs)
+ (void) nvlist_add_string(nvl, SHOPT_DESCRIPTION,
+ info->nss_comment);
+ else
+ (void) sa_set_resource_description(resource,
+ info->nss_comment);
(void) strlcpy(si->shr_cmnt, info->nss_comment,
SMB_SHARE_CMNT_MAX);
}
+ if (is_zfs) {
+ if (sa_zfs_setprop(handle, si->shr_path, nvl) != 0) {
+ smb_shr_sa_exit();
+ nvlist_free(nvl);
+ return (NERR_InternalError);
+ }
+ nvlist_free(nvl);
+ }
smb_shr_sa_exit();
if (renamed) {
@@ -3003,12 +3029,12 @@ srvsvc_sa_modify(smb_share_t *si, srvsvc_netshare_setinfo_t *info)
}
/*
- * Update the share properties.
+ * Sets the share properties.
*
- * Updates the optionset properties of the share resource.
- * The properties are given as a list of name-value pair.
- * The name argument should be the optionset property name and the value
- * should be a valid value for the specified property.
+ * This method sets share properties. If its a ZFS share, then properties
+ * are set by calling the sa_zfs_setprop method. Else the optionset properties
+ * of the share resource are set.The properties to be set are given as a list
+ * of name-value pair.
*/
static uint32_t
srvsvc_sa_setprop(smb_share_t *si, nvlist_t *nvl)
@@ -3036,6 +3062,13 @@ srvsvc_sa_setprop(smb_share_t *si, nvlist_t *nvl)
return (NERR_InternalError);
}
+ if (sa_group_is_zfs(sa_get_parent_group(share))) {
+ if (sa_zfs_setprop(handle, si->shr_path, nvl) != 0)
+ nerr = NERR_InternalError;
+ sa_fini(handle);
+ return (nerr);
+ }
+
if ((opts = sa_get_optionset(resource, SMB_PROTOCOL_NAME)) == NULL) {
opts = sa_create_optionset(resource, SMB_PROTOCOL_NAME);
if (opts == NULL) {
@@ -3083,7 +3116,6 @@ srvsvc_sa_setprop(smb_share_t *si, nvlist_t *nvl)
return (nerr);
}
-
static ndr_stub_table_t srvsvc_stub_table[] = {
{ srvsvc_s_NetConnectEnum, SRVSVC_OPNUM_NetConnectEnum },
{ srvsvc_s_NetFileEnum, SRVSVC_OPNUM_NetFileEnum },
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/svcctl_scm.c b/usr/src/lib/smbsrv/libmlsvc/common/svcctl_scm.c
index 5587c66131..8c99612583 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/svcctl_scm.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/svcctl_scm.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -41,10 +41,11 @@
#include <time.h>
#include <dlfcn.h>
#include <sys/types.h>
+
+#include <smbsrv/libsmb.h>
+#include <smbsrv/libmlsvc.h>
#include <smbsrv/winsvc.h>
-#include <smbsrv/nterror.h>
#include <smbsrv/ndl/svcctl.ndl>
-#include <smbsrv/libmlsvc.h>
#define LEGACY_UNKNOWN "unknown"
#define SVC_NAME_PROP "name"
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/svcctl_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/svcctl_svc.c
index 1cc2c17cc2..760d47262e 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/svcctl_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/svcctl_svc.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -34,11 +34,12 @@
#include <stdio.h>
#include <strings.h>
-#include <smbsrv/ntstatus.h>
+
+#include <smbsrv/libsmb.h>
+#include <smbsrv/libmlsvc.h>
#include <smbsrv/nmpipes.h>
#include <smbsrv/ntifs.h>
#include <smbsrv/winsvc.h>
-#include <smbsrv/nterror.h>
#include <smbsrv/ndl/svcctl.ndl>
#include <smbsrv/libmlsvc.h>
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/winreg_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/winreg_svc.c
index 95db3b19df..a53ad919e7 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/winreg_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/winreg_svc.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -50,8 +50,6 @@
#include <strings.h>
#include <smbsrv/libsmb.h>
-#include <smbsrv/ntstatus.h>
-#include <smbsrv/nterror.h>
#include <smbsrv/nmpipes.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/ndl/winreg.ndl>
@@ -64,25 +62,26 @@ static char *winreg_keys[] = {
"HKU",
"HKLM\\SOFTWARE",
"HKLM\\SYSTEM",
- "Application",
- "Security",
"System",
"CurrentControlSet",
"SunOS",
"Solaris",
"System\\CurrentControlSet\\Services\\Eventlog",
- "System\\CurrentControlSet\\Services\\Eventlog\\Application",
- "System\\CurrentControlSet\\Services\\Eventlog\\"
- "Application\\Application",
- "System\\CurrentControlSet\\Services\\Eventlog\\Security",
- "System\\CurrentControlSet\\Services\\Eventlog\\Security\\Security",
- "System\\CurrentControlSet\\Services\\Eventlog\\System",
- "System\\CurrentControlSet\\Services\\Eventlog\\System\\System",
"System\\CurrentControlSet\\Control\\ProductOptions",
"SOFTWARE",
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
};
+static char *winreg_eventlog = "System\\CurrentControlSet\\Services\\Eventlog";
+
+static char *winreg_log[] = {
+ "Application",
+ "Security",
+ "System",
+ "smbd",
+ "smbrdr"
+};
+
typedef struct winreg_subkey {
list_node_t sk_lnd;
ndr_hdid_t sk_handle;
@@ -98,6 +97,7 @@ typedef struct winreg_keylist {
static winreg_keylist_t winreg_keylist;
static mutex_t winreg_mutex;
+static void winreg_add_predefined(const char *);
static ndr_hdid_t *winreg_alloc_id(ndr_xa_t *, const char *);
static void winreg_dealloc_id(ndr_xa_t *, ndr_hdid_t *);
static boolean_t winreg_key_has_subkey(const char *);
@@ -192,9 +192,9 @@ static char winreg_sysver[SMB_VERSTR_LEN];
void
winreg_initialize(void)
{
- winreg_subkey_t *key;
smb_version_t version;
struct utsname name;
+ char subkey[MAXPATHLEN];
char *sysname;
int i;
@@ -204,16 +204,20 @@ winreg_initialize(void)
offsetof(winreg_subkey_t, sk_lnd));
winreg_keylist.kl_count = 0;
- for (i = 0; i < sizeof (winreg_keys)/sizeof (winreg_keys[0]); ++i) {
- if ((key = malloc(sizeof (winreg_subkey_t))) != NULL) {
- bzero(key, sizeof (winreg_subkey_t));
- (void) strlcpy(key->sk_name, winreg_keys[i],
- MAXPATHLEN);
- key->sk_predefined = B_TRUE;
+ for (i = 0; i < sizeof (winreg_keys)/sizeof (winreg_keys[0]); ++i)
+ winreg_add_predefined(winreg_keys[i]);
- list_insert_tail(&winreg_keylist.kl_list, key);
- ++winreg_keylist.kl_count;
- }
+ for (i = 0; i < sizeof (winreg_log)/sizeof (winreg_log[0]); ++i) {
+ (void) snprintf(subkey, MAXPATHLEN, "%s", winreg_log[i]);
+ winreg_add_predefined(subkey);
+
+ (void) snprintf(subkey, MAXPATHLEN, "%s\\%s",
+ winreg_eventlog, winreg_log[i]);
+ winreg_add_predefined(subkey);
+
+ (void) snprintf(subkey, MAXPATHLEN, "%s\\%s\\%s",
+ winreg_eventlog, winreg_log[i], winreg_log[i]);
+ winreg_add_predefined(subkey);
}
(void) mutex_unlock(&winreg_mutex);
@@ -232,6 +236,21 @@ winreg_initialize(void)
(void) ndr_svc_register(&winreg_service);
}
+static void
+winreg_add_predefined(const char *subkey)
+{
+ winreg_subkey_t *key;
+
+ if ((key = malloc(sizeof (winreg_subkey_t))) != NULL) {
+ bzero(key, sizeof (winreg_subkey_t));
+ (void) strlcpy(key->sk_name, subkey, MAXPATHLEN);
+ key->sk_predefined = B_TRUE;
+
+ list_insert_tail(&winreg_keylist.kl_list, key);
+ ++winreg_keylist.kl_count;
+ }
+}
+
static int
winreg_s_OpenHKCR(void *arg, ndr_xa_t *mxa)
{
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/wkssvc_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/wkssvc_svc.c
index b379eacd33..85aab133bc 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/wkssvc_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/wkssvc_svc.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <netdb.h>
@@ -31,8 +31,6 @@
#include <smbsrv/libmlsvc.h>
#include <smbsrv/smbinfo.h>
#include <smbsrv/nmpipes.h>
-#include <smbsrv/nterror.h>
-#include <smbsrv/lmerr.h>
#include <smbsrv/ndl/srvsvc.ndl>
static int wkssvc_s_NetWkstaGetInfo(void *, ndr_xa_t *);
diff --git a/usr/src/lib/smbsrv/libsmb/Makefile b/usr/src/lib/smbsrv/libsmb/Makefile
index cbe44c764c..1477f0ce9c 100644
--- a/usr/src/lib/smbsrv/libsmb/Makefile
+++ b/usr/src/lib/smbsrv/libsmb/Makefile
@@ -19,12 +19,18 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
HDRS= libsmb.h
+GENSRCS = common/smb_status_tbl.h
+CLEANFILES += $(GENSRCS)
+
+all install lint: $(GENSRCS)
+
include ../Makefile.smbsrv
+
+$(GENSRCS): common/smb_status_gen.awk $(SRC)/uts/common/smb/ntstatus.h
+ nawk -f common/smb_status_gen.awk \
+ $(SRC)/uts/common/smb/ntstatus.h > $@
diff --git a/usr/src/lib/smbsrv/libsmb/Makefile.com b/usr/src/lib/smbsrv/libsmb/Makefile.com
index a9408ab9cc..468dac6f28 100644
--- a/usr/src/lib/smbsrv/libsmb/Makefile.com
+++ b/usr/src/lib/smbsrv/libsmb/Makefile.com
@@ -19,8 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
LIBRARY= libsmb.a
@@ -34,7 +33,6 @@ OBJS_SHARED = \
smb_native.o \
smb_oem.o \
smb_sid.o \
- smb_status_xlat.o \
smb_string.o \
smb_token.o \
smb_token_xdr.o \
@@ -59,13 +57,13 @@ OBJS_COMMON = \
smb_lgrp.o \
smb_mac.o \
smb_nic.o \
- smb_nicmon.o \
smb_pwdutil.o \
smb_privilege.o \
smb_reparse.o \
smb_sam.o \
smb_scfutil.o \
smb_sd.o \
+ smb_status_tbl.o \
smb_util.o \
smb_wksids.o
diff --git a/usr/src/lib/smbsrv/libsmb/common/libsmb.h b/usr/src/lib/smbsrv/libsmb/common/libsmb.h
index a99b7eacf5..fa2477f906 100644
--- a/usr/src/lib/smbsrv/libsmb/common/libsmb.h
+++ b/usr/src/lib/smbsrv/libsmb/common/libsmb.h
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -48,8 +49,8 @@ extern "C" {
#include <smbsrv/smb_idmap.h>
#include <smbsrv/netbios.h>
#include <smbsrv/smb_share.h>
-#include <smbsrv/nterror.h>
-#include <smbsrv/ntstatus.h>
+#include <smb/nterror.h>
+#include <smb/ntstatus.h>
#include <smbsrv/smb_door.h>
#include <smbsrv/alloc.h>
#include <smbsrv/hash_table.h>
@@ -59,6 +60,7 @@ extern "C" {
#include <smbsrv/smbinfo.h>
#include <smbsrv/ntifs.h>
+#define SMB_VARSMB_DIR "/var/smb"
#define SMB_VARRUN_DIR "/var/run/smb"
#define SMB_CCACHE_FILE "ccache"
#define SMB_CCACHE_PATH SMB_VARRUN_DIR "/" SMB_CCACHE_FILE
@@ -145,6 +147,7 @@ typedef enum {
SMB_CI_MAP,
SMB_CI_UNMAP,
SMB_CI_DISPOSITION,
+ SMB_CI_DFS_STDROOT_NUM,
SMB_CI_MAX
} smb_cfg_id_t;
@@ -193,6 +196,8 @@ extern int smb_config_set_idmap_domain(char *);
extern int smb_config_refresh_idmap(void);
extern int smb_config_getip(smb_cfg_id_t, smb_inaddr_t *);
extern void smb_config_get_version(smb_version_t *);
+uint32_t smb_config_get_execinfo(char *, char *, size_t);
+
extern void smb_load_kconfig(smb_kmod_cfg_t *kcfg);
extern uint32_t smb_crc_gen(uint8_t *, size_t);
@@ -280,6 +285,8 @@ extern int smb_getnameinfo(smb_inaddr_t *, char *, int, int);
void smb_trace(const char *s);
void smb_tracef(const char *fmt, ...);
+const char *xlate_nt_status(unsigned int);
+
/*
* Authentication
*/
@@ -739,6 +746,7 @@ int smb_lookup_name(const char *, sid_type_t, lsa_account_t *);
#define SMB_LGRP_LOOKUP_FAILED 30
#define SMB_LGRP_NOT_SUPPORTED 31
#define SMB_LGRP_OFFLINE 32
+#define SMB_LGRP_POSIXCREATE_FAILED 33
#define SMB_LGRP_COMMENT_MAX 256
@@ -800,10 +808,6 @@ boolean_t smb_nic_is_same_subnet(smb_inaddr_t *);
#define SMB_NIC_IOCTL 15
#define SMB_NIC_CHANGED 16
-/* NIC Monitoring functions */
-int smb_nicmon_start(const char *);
-void smb_nicmon_stop(void);
-
/*
* Well-known account structure
*
@@ -883,8 +887,8 @@ int smb_kmod_nbtlisten(int);
int smb_kmod_tcpreceive(void);
int smb_kmod_nbtreceive(void);
void smb_kmod_unbind(void);
-int smb_kmod_share(char *, char *);
-int smb_kmod_unshare(char *, char *);
+int smb_kmod_share(nvlist_t *);
+int smb_kmod_unshare(nvlist_t *);
int smb_kmod_get_open_num(smb_opennum_t *);
int smb_kmod_enum(smb_netsvc_t *);
smb_netsvc_t *smb_kmod_enum_init(smb_svcenum_t *);
@@ -977,6 +981,40 @@ int smb_reparse_svcadd(const char *, const char *, const char *);
int smb_reparse_svcdel(const char *, const char *);
int smb_reparse_svcget(const char *, const char *, char **);
+uint32_t smb_get_txid(void);
+
+#define SMB_LOG_LINE_SZ 256
+
+typedef uint32_t smb_log_hdl_t;
+
+typedef struct smb_log_item {
+ list_node_t li_lnd;
+ char li_msg[SMB_LOG_LINE_SZ];
+} smb_log_item_t;
+
+typedef struct smb_log {
+ smb_log_hdl_t l_handle;
+ int l_cnt;
+ int l_max_cnt;
+ mutex_t l_mtx;
+ list_t l_list;
+ char l_file[MAXPATHLEN];
+} smb_log_t;
+
+typedef struct smb_loglist_item {
+ list_node_t lli_lnd;
+ smb_log_t lli_log;
+} smb_loglist_item_t;
+
+typedef struct smb_loglist {
+ mutex_t ll_mtx;
+ list_t ll_list;
+} smb_loglist_t;
+
+smb_log_hdl_t smb_log_create(int, char *);
+void smb_log(smb_log_hdl_t, int, const char *, ...);
+void smb_log_dumpall(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/lib/smbsrv/libsmb/common/mapfile-vers b/usr/src/lib/smbsrv/libsmb/common/mapfile-vers
index cb103606f1..ea37cac092 100644
--- a/usr/src/lib/smbsrv/libsmb/common/mapfile-vers
+++ b/usr/src/lib/smbsrv/libsmb/common/mapfile-vers
@@ -109,6 +109,7 @@ SUNWprivate {
smb_common_decode;
smb_common_encode;
smb_config_get;
+ smb_config_get_execinfo;
smb_config_get_fg_flag;
smb_config_get_localsid;
smb_config_get_secmode;
@@ -187,6 +188,7 @@ SUNWprivate {
smb_fssd_term;
smb_get_dcinfo;
smb_get_nameservers;
+ smb_get_txid;
smb_getdataset;
smb_getdomainname;
smb_getfqdomainname;
@@ -265,6 +267,9 @@ SUNWprivate {
smb_lgrp_stop;
smb_lgrp_strerror;
smb_load_kconfig;
+ smb_log;
+ smb_log_create;
+ smb_log_dumpall;
smb_logon_decode;
smb_logon_free;
smb_lookup_name;
@@ -274,7 +279,6 @@ SUNWprivate {
smb_mac_inc_seqnum;
smb_mac_init;
smb_mac_sign;
- smb_match83;
smb_match;
smb_match_ci;
smb_match_netlogon_seqnum;
@@ -315,8 +319,6 @@ SUNWprivate {
smb_nic_getnext;
smb_nic_getnum;
smb_nic_init;
- smb_nicmon_start;
- smb_nicmon_stop;
smb_priv_getbyname;
smb_priv_getbyvalue;
smb_priv_presentable_ids;
@@ -349,6 +351,8 @@ SUNWprivate {
smb_sam_grp_cnt;
smb_sam_usr_cnt;
smb_sam_usr_groups;
+ smb_shr_execinfo_xdr;
+ smb_shr_hostaccess_query_xdr;
smb_quota_query_xdr;
smb_quota_response_xdr;
smb_quota_set_xdr;
@@ -376,8 +380,12 @@ SUNWprivate {
smb_sid_splitstr;
smb_sid_tostr;
smb_sid_type2str;
+ smb_smf_create_service_pgroup;
+ smb_smf_get_boolean_property;
smb_smf_maintenance_mode;
smb_smf_restart_service;
+ smb_smf_scf_fini;
+ smb_smf_scf_init;
smb_stombs;
smb_strcasecmp;
smb_string_decode;
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_cfg.c b/usr/src/lib/smbsrv/libsmb/common/smb_cfg.c
index 4aad3094bc..2869263eb7 100644
--- a/usr/src/lib/smbsrv/libsmb/common/smb_cfg.c
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_cfg.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -131,7 +130,9 @@ static smb_cfg_param_t smb_cfg_table[] =
{SMB_CI_IPV6_ENABLE, "ipv6_enable", SCF_TYPE_BOOLEAN, 0},
{SMB_CI_MAP, "map", SCF_TYPE_ASTRING, SMB_CF_EXEC},
{SMB_CI_UNMAP, "unmap", SCF_TYPE_ASTRING, SMB_CF_EXEC},
- {SMB_CI_DISPOSITION, "disposition", SCF_TYPE_ASTRING, SMB_CF_EXEC}
+ {SMB_CI_DISPOSITION, "disposition", SCF_TYPE_ASTRING, SMB_CF_EXEC},
+
+ {SMB_CI_DFS_STDROOT_NUM, "dfs_stdroot_num", SCF_TYPE_INTEGER, 0}
/* SMB_CI_MAX */
};
@@ -906,6 +907,44 @@ smb_config_get_version(smb_version_t *version)
}
}
+/*
+ * Reads share exec script properties
+ */
+uint32_t
+smb_config_get_execinfo(char *map, char *unmap, size_t bufsz)
+{
+ char buf[MAXPATHLEN];
+ uint32_t flags = 0;
+
+ if (map == NULL) {
+ map = buf;
+ bufsz = MAXPATHLEN;
+ }
+
+ *map = '\0';
+ (void) smb_config_getstr(SMB_CI_MAP, map, bufsz);
+ if (*map != '\0')
+ flags |= SMB_EXEC_MAP;
+
+ if (unmap == NULL) {
+ unmap = buf;
+ bufsz = MAXPATHLEN;
+ }
+
+ *unmap = '\0';
+ (void) smb_config_getstr(SMB_CI_UNMAP, unmap, bufsz);
+ if (*unmap != '\0')
+ flags |= SMB_EXEC_UNMAP;
+
+ *buf = '\0';
+ (void) smb_config_getstr(SMB_CI_DISPOSITION, buf, sizeof (buf));
+ if (*buf != '\0')
+ if (strcasecmp(buf, SMB_EXEC_DISP_TERMINATE) == 0)
+ flags |= SMB_EXEC_TERM;
+
+ return (flags);
+}
+
static smb_cfg_param_t *
smb_config_getent(smb_cfg_id_t id)
{
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_door_encdec.c b/usr/src/lib/smbsrv/libsmb/common/smb_door_encdec.c
index 87cc6e7b96..749310c389 100644
--- a/usr/src/lib/smbsrv/libsmb/common/smb_door_encdec.c
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_door_encdec.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <stdlib.h>
@@ -93,38 +92,6 @@ smb_common_decode(char *buf, size_t len, xdrproc_t proc, void *data)
return (rc);
}
-/*
- * smb_kshare_mkselfrel
- *
- * encode: structure -> flat buffer (buffer size)
- * Pre-condition: kshare is non-null.
- */
-uint8_t *
-smb_kshare_mkselfrel(smb_dr_kshare_t *kshare, uint32_t *len)
-{
- uint8_t *buf;
- XDR xdrs;
-
- if (!kshare)
- return (NULL);
-
- *len = xdr_sizeof(smb_dr_kshare_xdr, kshare);
- buf = (uint8_t *)malloc(*len);
- if (!buf)
- return (NULL);
-
- xdrmem_create(&xdrs, (const caddr_t)buf, *len, XDR_ENCODE);
-
- if (!smb_dr_kshare_xdr(&xdrs, kshare)) {
- *len = 0;
- free(buf);
- buf = NULL;
- }
-
- xdr_destroy(&xdrs);
- return (buf);
-}
-
char *
smb_string_encode(char *s, size_t *rsize)
{
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_doorclnt.c b/usr/src/lib/smbsrv/libsmb/common/smb_doorclnt.c
index bf6f226131..23e4d311e1 100644
--- a/usr/src/lib/smbsrv/libsmb/common/smb_doorclnt.c
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_doorclnt.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <assert.h>
@@ -43,7 +42,6 @@ static int smb_door_encode(smb_doorarg_t *, uint32_t);
static int smb_door_decode(smb_doorarg_t *);
static void smb_door_sethdr(smb_doorhdr_t *, uint32_t, uint32_t);
static boolean_t smb_door_chkhdr(smb_doorarg_t *, smb_doorhdr_t *);
-static uint32_t smb_door_txid(void);
static void smb_door_free(door_arg_t *arg);
/*
@@ -214,6 +212,7 @@ boolean_t
smb_find_ads_server(char *fqdn, char *buf, int buflen)
{
smb_string_t server;
+ smb_string_t domain;
boolean_t found = B_FALSE;
int rc;
@@ -226,7 +225,9 @@ smb_find_ads_server(char *fqdn, char *buf, int buflen)
bzero(&server, sizeof (smb_string_t));
*buf = '\0';
- rc = smb_door_call(SMB_DR_ADS_FIND_HOST, fqdn, smb_string_xdr,
+ domain.buf = fqdn;
+
+ rc = smb_door_call(SMB_DR_ADS_FIND_HOST, &domain, smb_string_xdr,
&server, smb_string_xdr);
if (rc != 0)
@@ -429,7 +430,7 @@ smb_door_sethdr(smb_doorhdr_t *hdr, uint32_t cmd, uint32_t datalen)
hdr->dh_magic = SMB_DOOR_HDR_MAGIC;
hdr->dh_flags = SMB_DF_USERSPACE;
hdr->dh_op = cmd;
- hdr->dh_txid = smb_door_txid();
+ hdr->dh_txid = smb_get_txid();
hdr->dh_datalen = datalen;
hdr->dh_door_rc = SMB_DOP_NOT_CALLED;
}
@@ -455,35 +456,6 @@ smb_door_chkhdr(smb_doorarg_t *da, smb_doorhdr_t *hdr)
}
/*
- * The txid is an arbitrary transaction id used to associate door
- * requests with responses. A new txid is returned on each call.
- *
- * 0 or -1 are not assigned so that they can be used to detect
- * invalid conditions.
- */
-static uint32_t
-smb_door_txid(void)
-{
- static mutex_t txmutex;
- static uint32_t txid;
- uint32_t txid_ret;
-
- (void) mutex_lock(&txmutex);
-
- if (txid == 0)
- txid = time(NULL);
-
- do {
- ++txid;
- } while (txid == 0 || txid == (uint32_t)-1);
-
- txid_ret = txid;
- (void) mutex_unlock(&txmutex);
-
- return (txid_ret);
-}
-
-/*
* Free resources allocated for a door call. If the result buffer provided
* by the client is too small, doorfs will have allocated a new buffer,
* which must be unmapped here.
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_info.c b/usr/src/lib/smbsrv/libsmb/common/smb_info.c
index 5a312c2aee..02ffae625c 100644
--- a/usr/src/lib/smbsrv/libsmb/common/smb_info.c
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_info.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <assert.h>
@@ -102,6 +101,7 @@ smb_load_kconfig(smb_kmod_cfg_t *kcfg)
(void) smb_config_getstr(SMB_CI_SYS_CMNT, kcfg->skc_system_comment,
sizeof (kcfg->skc_system_comment));
smb_config_get_version(&kcfg->skc_version);
+ kcfg->skc_execflags = smb_config_get_execinfo(NULL, NULL, 0);
}
/*
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_kmod.c b/usr/src/lib/smbsrv/libsmb/common/smb_kmod.c
index a6500651fe..ebc99295b4 100644
--- a/usr/src/lib/smbsrv/libsmb/common/smb_kmod.c
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_kmod.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
@@ -79,6 +78,8 @@ smb_kmod_setcfg(smb_kmod_cfg_t *cfg)
ioc.sync_enable = cfg->skc_sync_enable;
ioc.secmode = cfg->skc_secmode;
ioc.ipv6_enable = cfg->skc_ipv6_enable;
+ ioc.exec_flags = cfg->skc_execflags;
+ ioc.version = cfg->skc_version;
(void) strlcpy(ioc.nbdomain, cfg->skc_nbdomain, sizeof (ioc.nbdomain));
(void) strlcpy(ioc.fqdn, cfg->skc_fqdn, sizeof (ioc.fqdn));
@@ -162,38 +163,52 @@ smb_kmod_nbtreceive(void)
}
int
-smb_kmod_share(char *path, char *name)
+smb_kmod_share(nvlist_t *shrlist)
{
smb_ioc_share_t *ioc;
+ uint32_t ioclen;
+ char *shrbuf = NULL;
+ size_t bufsz;
int rc = ENOMEM;
- ioc = malloc(sizeof (smb_ioc_share_t));
+ if ((rc = nvlist_pack(shrlist, &shrbuf, &bufsz, NV_ENCODE_XDR, 0)) != 0)
+ return (rc);
+
+ ioclen = sizeof (smb_ioc_share_t) + bufsz;
- if (ioc != NULL) {
- (void) strlcpy(ioc->path, path, sizeof (ioc->path));
- (void) strlcpy(ioc->name, name, sizeof (ioc->name));
- rc = smb_kmod_ioctl(SMB_IOC_SHARE, &ioc->hdr,
- sizeof (smb_ioc_share_t));
+ if ((ioc = malloc(ioclen)) != NULL) {
+ ioc->shrlen = bufsz;
+ bcopy(shrbuf, ioc->shr, bufsz);
+ rc = smb_kmod_ioctl(SMB_IOC_SHARE, &ioc->hdr, ioclen);
free(ioc);
}
+
+ free(shrbuf);
return (rc);
}
int
-smb_kmod_unshare(char *path, char *name)
+smb_kmod_unshare(nvlist_t *shrlist)
{
smb_ioc_share_t *ioc;
+ uint32_t ioclen;
+ char *shrbuf = NULL;
+ size_t bufsz;
int rc = ENOMEM;
- ioc = malloc(sizeof (smb_ioc_share_t));
+ if ((rc = nvlist_pack(shrlist, &shrbuf, &bufsz, NV_ENCODE_XDR, 0)) != 0)
+ return (rc);
+
+ ioclen = sizeof (smb_ioc_share_t) + bufsz;
- if (ioc != NULL) {
- (void) strlcpy(ioc->path, path, sizeof (ioc->path));
- (void) strlcpy(ioc->name, name, sizeof (ioc->name));
- rc = smb_kmod_ioctl(SMB_IOC_UNSHARE, &ioc->hdr,
- sizeof (smb_ioc_share_t));
+ if ((ioc = malloc(ioclen)) != NULL) {
+ ioc->shrlen = bufsz;
+ bcopy(shrbuf, ioc->shr, bufsz);
+ rc = smb_kmod_ioctl(SMB_IOC_UNSHARE, &ioc->hdr, ioclen);
free(ioc);
}
+
+ free(shrbuf);
return (rc);
}
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_lgrp.c b/usr/src/lib/smbsrv/libsmb/common/smb_lgrp.c
index 096526f20b..ea51a7e369 100644
--- a/usr/src/lib/smbsrv/libsmb/common/smb_lgrp.c
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_lgrp.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -33,6 +34,9 @@
#include <libintl.h>
#include <smbsrv/libsmb.h>
#include <smb_sqlite.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/param.h>
/*
* Local domain SID (aka machine SID) is not stored in the domain table
@@ -114,6 +118,18 @@
#define SMB_LGRP_INFO_MEMB 0x10
#define SMB_LGRP_INFO_ALL 0x1F
+#define SMB_LGRP_PGRP_GRPTMP "/etc/gtmp"
+#define SMB_LGRP_PGRP_GRPBUFSIZ 5120
+#define SMB_LGRP_PGRP_GROUP "/etc/group"
+#define SMB_LGRP_PGRP_MAXGLEN 9 /* max length of group name */
+#define SMB_LGRP_PGRP_DEFRID 99 /* max reserved id */
+
+#define SMB_LGRP_PGRP_NOTUNIQUE 0
+#define SMB_LGRP_PGRP_RESERVED 1
+#define SMB_LGRP_PGRP_UNIQUE 2
+#define SMB_LGRP_PGRP_TOOBIG 3
+#define SMB_LGRP_PGRP_INVALID 4
+
#define NULL_MSGCHK(msg) ((msg) ? (msg) : "NULL")
/* Member ID */
@@ -176,7 +192,8 @@ static struct {
{ SMB_LGRP_DELETE_FAILED, "group delete failed" },
{ SMB_LGRP_UPDATE_FAILED, "group update failed" },
{ SMB_LGRP_LOOKUP_FAILED, "group lookup failed" },
- { SMB_LGRP_OFFLINE, "local group service is offline" }
+ { SMB_LGRP_OFFLINE, "local group service is offline" },
+ { SMB_LGRP_POSIXCREATE_FAILED, "posix group create failed" }
};
/*
@@ -231,6 +248,7 @@ static boolean_t smb_lgrp_chkmember(uint16_t);
static int smb_lgrp_getsid(int, uint32_t *, uint16_t, sqlite *, smb_sid_t **);
static int smb_lgrp_getgid(uint32_t rid, gid_t *gid);
static boolean_t smb_lgrp_exists(char *);
+static int smb_lgrp_pgrp_add(char *);
/*
* smb_lgrp_add
@@ -270,8 +288,15 @@ smb_lgrp_add(char *gname, char *cmnt)
wka = smb_wka_lookup_name(gname);
if (wka == NULL) {
if ((pxgrp = getgrnam(gname)) == NULL) {
- smb_lgrp_exit();
- return (SMB_LGRP_NOT_FOUND);
+ if (smb_lgrp_pgrp_add(gname) != 0) {
+ smb_lgrp_exit();
+ return (SMB_LGRP_POSIXCREATE_FAILED);
+ }
+
+ if ((pxgrp = getgrnam(gname)) == NULL) {
+ smb_lgrp_exit();
+ return (SMB_LGRP_NOT_FOUND);
+ }
}
/*
@@ -364,6 +389,18 @@ smb_lgrp_rename(char *gname, char *new_gname)
if (!smb_lgrp_enter())
return (SMB_LGRP_OFFLINE);
+ if (getgrnam(new_gname) == NULL) {
+ if (smb_lgrp_pgrp_add(new_gname) != 0) {
+ smb_lgrp_exit();
+ return (SMB_LGRP_POSIXCREATE_FAILED);
+ }
+
+ if (getgrnam(new_gname) == NULL) {
+ smb_lgrp_exit();
+ return (SMB_LGRP_NOT_FOUND);
+ }
+ }
+
db = smb_lgrp_db_open(SMB_LGRP_DB_ORW);
rc = smb_lgrp_gtbl_update(db, gname, &grp, SMB_LGRP_GTBL_NAME);
smb_lgrp_db_close(db);
@@ -969,7 +1006,7 @@ smb_lgrp_err_to_ntstatus(uint32_t lgrp_err)
{ SMB_LGRP_PRIV_HELD, NT_STATUS_SUCCESS },
{ SMB_LGRP_PRIV_NOT_HELD, NT_STATUS_PRIVILEGE_NOT_HELD },
{ SMB_LGRP_BAD_DATA, NT_STATUS_DATA_ERROR },
- { SMB_LGRP_NO_MORE, NT_STATUS_NO_MORE_DATA },
+ { SMB_LGRP_NO_MORE, NT_STATUS_NO_MORE_ENTRIES },
{ SMB_LGRP_DBOPEN_FAILED, NT_STATUS_INTERNAL_DB_ERROR },
{ SMB_LGRP_DBEXEC_FAILED, NT_STATUS_INTERNAL_DB_ERROR },
{ SMB_LGRP_DBINIT_FAILED, NT_STATUS_INTERNAL_DB_ERROR },
@@ -980,7 +1017,8 @@ smb_lgrp_err_to_ntstatus(uint32_t lgrp_err)
{ SMB_LGRP_UPDATE_FAILED, NT_STATUS_INTERNAL_DB_ERROR },
{ SMB_LGRP_LOOKUP_FAILED, NT_STATUS_INTERNAL_DB_ERROR },
{ SMB_LGRP_NOT_SUPPORTED, NT_STATUS_NOT_SUPPORTED },
- { SMB_LGRP_OFFLINE, NT_STATUS_INTERNAL_ERROR }
+ { SMB_LGRP_OFFLINE, NT_STATUS_INTERNAL_ERROR },
+ { SMB_LGRP_POSIXCREATE_FAILED, NT_STATUS_UNSUCCESSFUL }
};
for (i = 0; i < sizeof (err_map)/sizeof (err_map[0]); ++i) {
@@ -2454,3 +2492,184 @@ smb_lgrp_exists(char *gname)
return (rc);
}
+
+/*
+ * smb_lgrp_pgrp_valid_gname
+ *
+ * Validate posix group name string.
+ */
+static int
+smb_lgrp_pgrp_valid_gname(char *group)
+{
+ char *ptr = group;
+ char c;
+ int len = 0;
+ int badchar = 0;
+
+ if (!group || !*group)
+ return (SMB_LGRP_PGRP_INVALID);
+
+ for (c = *ptr; c != NULL; ptr++, c = *ptr) {
+ len++;
+ if (!isprint(c) || (c == ':') || (c == '\n'))
+ return (SMB_LGRP_PGRP_INVALID);
+
+ if (!(islower(c) || isdigit(c)))
+ badchar++;
+ }
+
+ if ((len > SMB_LGRP_PGRP_MAXGLEN - 1) || (badchar != 0))
+ return (SMB_LGRP_PGRP_INVALID);
+
+ if (getgrnam(group) != NULL)
+ return (SMB_LGRP_PGRP_NOTUNIQUE);
+
+ return (SMB_LGRP_PGRP_UNIQUE);
+}
+
+/*
+ * smb_lgrp_pgrp_valid_gid
+ *
+ * Check to see that the gid is not a reserved gid
+ * -- nobody (60001), noaccess (60002) or nogroup (65534)
+ */
+static int
+smb_lgrp_pgrp_valid_gid(gid_t gid)
+{
+ return (gid != 60001 && gid != 60002 && gid != 65534);
+}
+
+/*
+ * smb_lgrp_pgrp_findnextgid(void)
+ *
+ * This method finds the next valid GID.
+ * It sorts the used GIDs in decreasing order to return MAXUSED + 1.
+ * It then adds one to obtain the next valid GID.
+ * On failure, -1 is returned. On success, a valid GID is returned.
+ */
+static int
+smb_lgrp_pgrp_findnextgid(void)
+{
+ FILE *fptr;
+ gid_t last, next;
+ int gid;
+
+ if ((fptr = popen("exec sh -c "
+ "\"getent group|cut -f3 -d:|sort -nr|uniq \" 2>/dev/null",
+ "r")) == NULL)
+ return (-1);
+
+ if (fscanf(fptr, "%u\n", &next) == EOF) {
+ (void) pclose(fptr);
+ return (SMB_LGRP_PGRP_DEFRID + 1);
+ }
+
+ last = MAXUID;
+ gid = -1;
+ do {
+ if (!smb_lgrp_pgrp_valid_gid(next))
+ continue;
+
+ if (next <= SMB_LGRP_PGRP_DEFRID) {
+ if (last != SMB_LGRP_PGRP_DEFRID + 1)
+ gid = SMB_LGRP_PGRP_DEFRID + 1;
+ break;
+ }
+
+ if ((gid = next + 1) != last) {
+ while (!smb_lgrp_pgrp_valid_gid((gid_t)gid))
+ gid++;
+ if (gid > 0 && gid < last)
+ break;
+ }
+
+ gid = -1;
+ last = next;
+ } while (fscanf(fptr, "%u\n", &next) != EOF);
+
+ (void) pclose(fptr);
+ return (gid);
+}
+
+/*
+ * smb_lgrp_pgrp_add
+ *
+ * Create a posix group with the given name.
+ * This group will be added to the /etc/group file.
+ */
+static int
+smb_lgrp_pgrp_add(char *group)
+{
+ FILE *etcgrp;
+ FILE *etctmp;
+ int o_mask, gret;
+ int newdone = 0;
+ struct stat sb;
+ char buf[SMB_LGRP_PGRP_GRPBUFSIZ];
+ gid_t gid;
+ int rc = 0;
+
+ rc = smb_lgrp_pgrp_valid_gname(group);
+ if ((rc == SMB_LGRP_PGRP_INVALID) || (rc == SMB_LGRP_PGRP_NOTUNIQUE))
+ return (-1);
+
+ if ((gret = smb_lgrp_pgrp_findnextgid()) < 0)
+ return (-1);
+ gid = gret;
+
+ if ((etcgrp = fopen(SMB_LGRP_PGRP_GROUP, "r")) == NULL)
+ return (-1);
+
+ if (fstat(fileno(etcgrp), &sb) < 0)
+ sb.st_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
+
+ o_mask = umask(077);
+ etctmp = fopen(SMB_LGRP_PGRP_GRPTMP, "w+");
+ (void) umask(o_mask);
+
+ if (etctmp == NULL) {
+ (void) fclose(etcgrp);
+ return (-1);
+ }
+
+ if (lockf(fileno(etctmp), F_LOCK, 0) != 0) {
+ (void) fclose(etcgrp);
+ (void) fclose(etctmp);
+ (void) unlink(SMB_LGRP_PGRP_GRPTMP);
+ return (-1);
+ }
+
+ if (fchmod(fileno(etctmp), sb.st_mode) != 0 ||
+ fchown(fileno(etctmp), sb.st_uid, sb.st_gid) != 0) {
+ (void) lockf(fileno(etctmp), F_ULOCK, 0);
+ (void) fclose(etcgrp);
+ (void) fclose(etctmp);
+ (void) unlink(SMB_LGRP_PGRP_GRPTMP);
+ return (-1);
+ }
+
+ while (fgets(buf, SMB_LGRP_PGRP_GRPBUFSIZ, etcgrp) != NULL) {
+ /* Check for NameService reference */
+ if (!newdone && (buf[0] == '+' || buf[0] == '-')) {
+ (void) fprintf(etctmp, "%s::%u:\n", group, gid);
+ newdone = 1;
+ }
+
+ (void) fputs(buf, etctmp);
+ }
+ (void) fclose(etcgrp);
+
+ if (!newdone)
+ (void) fprintf(etctmp, "%s::%u:\n", group, gid);
+
+ if (rename(SMB_LGRP_PGRP_GRPTMP, SMB_LGRP_PGRP_GROUP) < 0) {
+ (void) lockf(fileno(etctmp), F_ULOCK, 0);
+ (void) fclose(etctmp);
+ (void) unlink(SMB_LGRP_PGRP_GRPTMP);
+ return (-1);
+ }
+
+ (void) lockf(fileno(etctmp), F_ULOCK, 0);
+ (void) fclose(etctmp);
+ return (0);
+}
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_nicmon.c b/usr/src/lib/smbsrv/libsmb/common/smb_nicmon.c
deleted file mode 100644
index a485031531..0000000000
--- a/usr/src/lib/smbsrv/libsmb/common/smb_nicmon.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "@(#)smb_nicmon.c 1.7 08/07/24 SMI"
-
-/*
- * This is the SMB NIC monitoring module.
- */
-#include <sys/types.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <net/if.h>
-#include <net/route.h>
-#include <sys/sockio.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <syslog.h>
-#include <smbsrv/libsmb.h>
-#include <smbsrv/libsmbns.h>
-
-static pthread_t smb_nicmon_thread;
-
-static void smb_nicmon_setup_rtsock(int, int *);
-static int smb_nicmon_needscan(int);
-static void *smb_nicmon_daemon(void *);
-static int smb_nicmon_setup_eventpipe(int *, int *);
-
-/* Use this to stop monitoring */
-static int eventpipe_write = -1;
-
-/* Use this to refresh service instance */
-static char *smb_nicmon_caller_fmri = NULL;
-
-/*
- * Start the nic monitor thread.
- */
-int
-smb_nicmon_start(const char *svc_fmri)
-{
- if (smb_nic_init() != SMB_NIC_SUCCESS)
- return (-1);
-
- if (pthread_create(&smb_nicmon_thread, NULL, smb_nicmon_daemon, 0) != 0)
- return (-1);
-
- if (svc_fmri)
- smb_nicmon_caller_fmri = (char *)svc_fmri;
-
- return (0);
-}
-
-/*
- * Stop the nic monitor.
- */
-void
-smb_nicmon_stop(void)
-{
- uchar_t buf = 1;
-
- if (eventpipe_write < 0)
- return;
-
- (void) write(eventpipe_write, &buf, sizeof (buf));
- smb_nicmon_caller_fmri = NULL;
- smb_nic_fini();
-}
-
-/*
- * Setup routing socket for getting RTM messages.
- */
-static void
-smb_nicmon_setup_rtsock(int af, int *s)
-{
- int flags;
-
- *s = socket(PF_ROUTE, SOCK_RAW, af);
- if (*s == -1) {
- syslog(LOG_ERR, "smb_nicmon_daemon: failed to "
- "create routing socket");
- return;
- }
- if ((flags = fcntl(*s, F_GETFL, 0)) < 0) {
- syslog(LOG_ERR, "smb_nicmon_daemon: "
- "failed to fcntl F_GETFL");
- (void) close(*s);
- *s = -1;
- return;
- }
- if ((fcntl(*s, F_SETFL, flags | O_NONBLOCK)) < 0) {
- syslog(LOG_ERR, "smb_nicmon_daemon: "
- "failed to fcntl F_SETFL");
- (void) close(*s);
- *s = -1;
- return;
- }
-}
-
-static int
-smb_nicmon_needscan(int sock)
-{
- int nbytes;
- int64_t msg[2048 / 8];
- struct rt_msghdr *rtm;
- int need_if_scan = 0;
-
- /* Read as many messages as possible and try to empty the sockets */
- for (;;) {
- nbytes = read(sock, msg, sizeof (msg));
- if (nbytes <= 0) {
- break;
- }
- rtm = (struct rt_msghdr *)msg;
- if (rtm->rtm_version != RTM_VERSION) {
- continue;
- }
- if (nbytes < rtm->rtm_msglen) {
- syslog(LOG_DEBUG, "smb_nicmon_daemon: short read: %d "
- "of %d", nbytes, rtm->rtm_msglen);
- continue;
- }
-
- switch (rtm->rtm_type) {
- case RTM_NEWADDR:
- case RTM_DELADDR:
- case RTM_IFINFO:
- need_if_scan = 1;
- break;
- default:
- break;
- }
- }
-
- return (need_if_scan);
-}
-
-/*
- * Create pipe for signal delivery and set up signal handlers.
- */
-static int
-smb_nicmon_setup_eventpipe(int *read_pipe, int *write_pipe)
-{
- int fds[2];
-
- if ((pipe(fds)) < 0) {
- syslog(LOG_ERR, "smb_nicmon_daemon: failed to open pipe");
- return (1);
- }
- *read_pipe = fds[0];
- *write_pipe = fds[1];
- return (0);
-}
-
-/*ARGSUSED*/
-static void *
-smb_nicmon_daemon(void *args)
-{
- struct pollfd pollfds[2];
- int pollfd_num = 2;
- int i, nic_changed;
- /* AF_INET routing socket add AF_INET6 when we support IPv6 */
- static int rtsock_v4;
- static int eventpipe_read = -1;
-
- /*
- * Create the global routing socket. We use this to
- * monitor changes in NIC interfaces. We are only interested
- * in new inerface addition/deletion and change in UP/DOWN status.
- */
- smb_nicmon_setup_rtsock(AF_INET, &rtsock_v4);
- if (rtsock_v4 == -1) {
- syslog(LOG_ERR, "smb_nicmon_daemon: "
- "cannot open routing socket");
- return (NULL);
- }
-
- if (smb_nicmon_setup_eventpipe(&eventpipe_read, &eventpipe_write)
- != 0) {
- syslog(LOG_ERR, "smb_nicmon_daemon: cannot open event pipes");
- return (NULL);
- }
-
- /*
- * Keep listening for activity on any of the sockets.
- */
- for (;;) {
- nic_changed = 0;
- pollfds[0].fd = rtsock_v4;
- pollfds[0].events = POLLIN;
- pollfds[1].fd = eventpipe_read;
- pollfds[1].events = POLLIN;
- if (poll(pollfds, pollfd_num, -1) < 0) {
- if (errno == EINTR)
- continue;
- syslog(LOG_ERR, "smb_nicmon_daemon: "
- "poll failed with errno %d", errno);
- break;
- }
- for (i = 0; i < pollfd_num; i++) {
- if ((pollfds[i].fd < 0) ||
- !(pollfds[i].revents & POLLIN))
- continue;
- if (pollfds[i].fd == rtsock_v4)
- nic_changed = smb_nicmon_needscan(rtsock_v4);
- if (pollfds[i].fd == eventpipe_read)
- goto done;
- }
-
- /*
- * If anything changed, do refresh the instance
- * of the registered SMF service.
- */
- if (nic_changed && smb_nicmon_caller_fmri)
- if (smf_refresh_instance(smb_nicmon_caller_fmri) != 0)
- syslog(LOG_ERR, "smb_nicmon_daemon: "
- "failed to refresh SMF instance %s",
- smb_nicmon_caller_fmri);
- }
-done:
- /* Close sockets */
- (void) close(rtsock_v4);
- (void) close(eventpipe_read);
- (void) close(eventpipe_write);
- eventpipe_write = -1;
- return (NULL);
-}
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_sd.c b/usr/src/lib/smbsrv/libsmb/common/smb_sd.c
index 448f1d393b..1f36038f53 100644
--- a/usr/src/lib/smbsrv/libsmb/common/smb_sd.c
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_sd.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -31,7 +31,6 @@
#include <assert.h>
#include <smbsrv/ntifs.h>
#include <smbsrv/smb_idmap.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/libsmb.h>
#define SMB_SHR_ACE_READ_PERMS (ACE_READ_PERMS | ACE_EXECUTE | ACE_SYNCHRONIZE)
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_status_gen.awk b/usr/src/lib/smbsrv/libsmb/common/smb_status_gen.awk
new file mode 100644
index 0000000000..a64f0d65c1
--- /dev/null
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_status_gen.awk
@@ -0,0 +1,61 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Generate the table mapping NT status codes to strings.
+# The table is sorted in numerical order by putting the
+# numeric constants as a comment first on each line, and
+# then running the table body through sort(1).
+#
+
+BEGIN {
+ printf("/* Table generated by smb_status_gen.awk */\n");
+ printf("#include <smb/ntstatus.h>\n\n");
+ printf("typedef struct smb_status_table {\n");
+ printf("\tunsigned int value;\n");
+ printf("\tconst char *name;\n");
+ printf("} smb_status_table_t;\n\n");
+ printf("static const smb_status_table_t ntx_table[] = {\n");
+}
+/^#define.NT_STATUS_/ {
+ # Skip the _SEVERITY defines.
+ if ( $2 ~ /^NT_STATUS_SEVERITY_/ )
+ next
+
+
+ # Make sure the constant looks as expected.
+ if ( $3 !~ /^0x[0-9A-F]+$/ ) {
+ print "Warning: Unexpected format: "$0 > "/dev/stderr"
+ exit 1;
+ }
+
+ # print: comment { macro, string },
+ printf("\t/* %s */\t{ %s,\t\"%s\" },\n",
+ $3, $2, substr($2,11)) | "sort" ;
+}
+END {
+ close("sort");
+ printf("};\n");
+}
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_status_tbl.c b/usr/src/lib/smbsrv/libsmb/common/smb_status_tbl.c
new file mode 100644
index 0000000000..994779ffb7
--- /dev/null
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_status_tbl.c
@@ -0,0 +1,81 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * This file provides a text translation service for NT status codes.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+ * Include the generated file with ntx_table[]
+ * See smb_status_gen.awk
+ */
+#include "smb_status_tbl.h"
+static const int ntx_rows = sizeof (ntx_table) / sizeof (ntx_table[0]);
+
+/*
+ * Comparison function for bsearch(3C).
+ */
+static int
+xlate_compare(const void *vkey, const void *vrow)
+{
+ const smb_status_table_t *key = vkey;
+ const smb_status_table_t *row = vrow;
+
+ if (key->value == row->value)
+ return (0);
+ if (key->value < row->value)
+ return (-1);
+ return (1);
+}
+
+/*
+ * Translate an ntstatus value to a meaningful text string. If there isn't
+ * a corresponding text string in the table, the text representation of the
+ * status value is returned. This uses a static buffer so there is a
+ * possible concurrency issue if the caller hangs on to this pointer for a
+ * while but it should be harmless and really remote since the value will
+ * almost always be found in the table.
+ */
+const char *
+xlate_nt_status(unsigned int ntstatus)
+{
+ static char unknown[16];
+ smb_status_table_t key;
+ const smb_status_table_t *tep;
+
+ key.value = ntstatus;
+ key.name = NULL;
+ tep = bsearch(&key, ntx_table, ntx_rows,
+ sizeof (*tep), xlate_compare);
+
+ if (tep != NULL)
+ return (tep->name);
+
+ (void) sprintf(unknown, "0x%08X", ntstatus);
+ return ((const char *)unknown);
+}
diff --git a/usr/src/lib/smbsrv/libsmb/common/smb_util.c b/usr/src/lib/smbsrv/libsmb/common/smb_util.c
index f41b5a3f11..102708b26a 100644
--- a/usr/src/lib/smbsrv/libsmb/common/smb_util.c
+++ b/usr/src/lib/smbsrv/libsmb/common/smb_util.c
@@ -19,12 +19,14 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <ctype.h>
#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <sys/fcntl.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
@@ -39,11 +41,41 @@
#include <sys/utsname.h>
#include <libzfs.h>
#include <dlfcn.h>
+#include <time.h>
+#include <syslog.h>
#include <smbsrv/string.h>
#include <smbsrv/libsmb.h>
#define SMB_LIB_ALT "/usr/lib/smbsrv/libsmbex.so"
+#define SMB_TIMEBUF_SZ 16
+#define SMB_TRACEBUF_SZ 200
+
+#define SMB_LOG_FILE_FMT "/var/smb/%s_log.txt"
+
+typedef struct smb_log_pri {
+ char *lp_name;
+ int lp_value;
+} smb_log_pri_t;
+
+static smb_log_pri_t smb_log_pri[] = {
+ "panic", LOG_EMERG,
+ "emerg", LOG_EMERG,
+ "alert", LOG_ALERT,
+ "crit", LOG_CRIT,
+ "error", LOG_ERR,
+ "err", LOG_ERR,
+ "warn", LOG_WARNING,
+ "warning", LOG_WARNING,
+ "notice", LOG_NOTICE,
+ "info", LOG_INFO,
+ "debug", LOG_DEBUG
+};
+
+static void smb_log_trace(int, const char *);
+static smb_log_t *smb_log_get(smb_log_hdl_t);
+static void smb_log_dump(smb_log_t *);
+
static uint_t smb_make_mask(char *, uint_t);
static boolean_t smb_netmatch(struct netbuf *, char *);
static boolean_t smb_netgroup_match(struct nd_hostservlist *, char *, int);
@@ -52,6 +84,8 @@ extern int __multi_innetgr();
extern int __netdir_getbyaddr_nosrv(struct netconfig *,
struct nd_hostservlist **, struct netbuf *);
+static smb_loglist_t smb_loglist;
+
#define C2H(c) "0123456789ABCDEF"[(c)]
#define H2C(c) (((c) >= '0' && (c) <= '9') ? ((c) - '0') : \
((c) >= 'a' && (c) <= 'f') ? ((c) - 'a' + 10) : \
@@ -362,18 +396,16 @@ rand_hash(
/*
* smb_chk_hostaccess
*
- * Determine whether an access list grants rights to a particular host.
+ * Determines whether the specified host is in the given access list.
+ *
* We match on aliases of the hostname as well as on the canonical name.
* Names in the access list may be either hosts or netgroups; they're
* not distinguished syntactically. We check for hosts first because
* it's cheaper (just M*N strcmp()s), then try netgroups.
*
- * Currently this function always returns B_TRUE for ipv6 until
- * the underlying functions support ipv6
- *
* Function returns:
- * -1 for "all"
- * 0 not found
+ * -1 for "all" (list is empty "" or "*")
+ * 0 not found (host is not in the list or list is NULL)
* 1 found
*
*/
@@ -394,16 +426,15 @@ smb_chk_hostaccess(smb_inaddr_t *ipaddr, char *access_list)
struct netbuf buf;
struct netconfig *config;
- if (ipaddr->a_family == AF_INET6)
- return (B_TRUE);
+ if (access_list == NULL)
+ return (0);
inaddr.s_addr = ipaddr->a_ipv4;
/*
- * If no access list - then it's "all"
+ * If access list is empty or "*" - then it's "all"
*/
- if (access_list == NULL || *access_list == '\0' ||
- strcmp(access_list, "*") == 0)
+ if (*access_list == '\0' || strcmp(access_list, "*") == 0)
return (-1);
nentries = 0;
@@ -1125,3 +1156,217 @@ smb_name_parse(char *arg, char **account, char **domain)
}
}
}
+
+/*
+ * The txid is an arbitrary transaction. A new txid is returned on each call.
+ *
+ * 0 or -1 are not assigned so that they can be used to detect
+ * invalid conditions.
+ */
+uint32_t
+smb_get_txid(void)
+{
+ static mutex_t txmutex;
+ static uint32_t txid;
+ uint32_t txid_ret;
+
+ (void) mutex_lock(&txmutex);
+
+ if (txid == 0)
+ txid = time(NULL);
+
+ do {
+ ++txid;
+ } while (txid == 0 || txid == (uint32_t)-1);
+
+ txid_ret = txid;
+ (void) mutex_unlock(&txmutex);
+
+ return (txid_ret);
+}
+
+/*
+ * Creates a log object and inserts it into a list of logs.
+ */
+smb_log_hdl_t
+smb_log_create(int max_cnt, char *name)
+{
+ smb_loglist_item_t *log_node;
+ smb_log_t *log = NULL;
+ smb_log_hdl_t handle = 0;
+
+ if (max_cnt <= 0 || name == NULL)
+ return (0);
+
+ (void) mutex_lock(&smb_loglist.ll_mtx);
+
+ log_node = malloc(sizeof (smb_loglist_item_t));
+
+ if (log_node != NULL) {
+ log = &log_node->lli_log;
+
+ bzero(log, sizeof (smb_log_t));
+
+ handle = log->l_handle = smb_get_txid();
+ log->l_max_cnt = max_cnt;
+ (void) snprintf(log->l_file, sizeof (log->l_file),
+ SMB_LOG_FILE_FMT, name);
+
+ list_create(&log->l_list, sizeof (smb_log_item_t),
+ offsetof(smb_log_item_t, li_lnd));
+
+ if (smb_loglist.ll_list.list_size == 0)
+ list_create(&smb_loglist.ll_list,
+ sizeof (smb_loglist_item_t),
+ offsetof(smb_loglist_item_t, lli_lnd));
+
+ list_insert_tail(&smb_loglist.ll_list, log_node);
+ }
+
+ (void) mutex_unlock(&smb_loglist.ll_mtx);
+
+ return (handle);
+}
+
+/*
+ * Keep the most recent log entries, based on max count.
+ * If the priority is LOG_ERR or higher then the entire log is
+ * dumped to a file.
+ *
+ * The date format for each message is the same as a syslog entry.
+ *
+ * The log is also added to syslog via smb_log_trace().
+ */
+void
+smb_log(smb_log_hdl_t hdl, int priority, const char *fmt, ...)
+{
+ va_list ap;
+ smb_log_t *log;
+ smb_log_item_t *msg;
+ time_t now;
+ struct tm *tm;
+ char timebuf[SMB_TIMEBUF_SZ];
+ char buf[SMB_TRACEBUF_SZ];
+ char netbiosname[NETBIOS_NAME_SZ];
+ char *pri_name;
+ int i;
+
+ va_start(ap, fmt);
+ (void) vsnprintf(buf, SMB_TRACEBUF_SZ, fmt, ap);
+ va_end(ap);
+
+ priority &= LOG_PRIMASK;
+ smb_log_trace(priority, buf);
+
+ if ((log = smb_log_get(hdl)) == NULL)
+ return;
+
+ (void) mutex_lock(&log->l_mtx);
+
+ (void) time(&now);
+ tm = localtime(&now);
+ (void) strftime(timebuf, SMB_TIMEBUF_SZ, "%b %d %H:%M:%S", tm);
+
+ if (smb_getnetbiosname(netbiosname, NETBIOS_NAME_SZ) != 0)
+ (void) strlcpy(netbiosname, "unknown", NETBIOS_NAME_SZ);
+
+ if (log->l_cnt == log->l_max_cnt) {
+ msg = list_head(&log->l_list);
+ list_remove(&log->l_list, msg);
+ } else {
+ if ((msg = malloc(sizeof (smb_log_item_t))) == NULL) {
+ (void) mutex_unlock(&log->l_mtx);
+ return;
+ }
+ log->l_cnt++;
+ }
+
+ pri_name = "info";
+ for (i = 0; i < sizeof (smb_log_pri) / sizeof (smb_log_pri[0]); i++) {
+ if (priority == smb_log_pri[i].lp_value) {
+ pri_name = smb_log_pri[i].lp_name;
+ break;
+ }
+ }
+
+ (void) snprintf(msg->li_msg, SMB_LOG_LINE_SZ,
+ "%s %s smb[%d]: [ID 0 daemon.%s] %s",
+ timebuf, netbiosname, getpid(), pri_name, buf);
+ list_insert_tail(&log->l_list, msg);
+
+ if (priority <= LOG_ERR)
+ smb_log_dump(log);
+
+ (void) mutex_unlock(&log->l_mtx);
+}
+
+/*
+ * Dumps all the logs in the log list.
+ */
+void
+smb_log_dumpall()
+{
+ smb_loglist_item_t *log_node;
+
+ (void) mutex_lock(&smb_loglist.ll_mtx);
+
+ log_node = list_head(&smb_loglist.ll_list);
+
+ while (log_node != NULL) {
+ smb_log_dump(&log_node->lli_log);
+ log_node = list_next(&smb_loglist.ll_list, log_node);
+ }
+
+ (void) mutex_unlock(&smb_loglist.ll_mtx);
+}
+
+static void
+smb_log_trace(int priority, const char *s)
+{
+ syslog(priority, "%s", s);
+}
+
+static smb_log_t *
+smb_log_get(smb_log_hdl_t hdl)
+{
+ smb_loglist_item_t *log_node;
+ smb_log_t *log;
+
+ (void) mutex_lock(&smb_loglist.ll_mtx);
+
+ log_node = list_head(&smb_loglist.ll_list);
+
+ while (log_node != NULL) {
+ if (log_node->lli_log.l_handle == hdl) {
+ log = &log_node->lli_log;
+ (void) mutex_unlock(&smb_loglist.ll_mtx);
+ return (log);
+ }
+ log_node = list_next(&smb_loglist.ll_list, log_node);
+ }
+
+ (void) mutex_unlock(&smb_loglist.ll_mtx);
+ return (NULL);
+}
+
+/*
+ * Dumps the log to a file.
+ */
+static void
+smb_log_dump(smb_log_t *log)
+{
+ smb_log_item_t *msg;
+ FILE *fp;
+
+ if ((fp = fopen(log->l_file, "w")) == NULL)
+ return;
+
+ msg = list_head(&log->l_list);
+
+ while (msg != NULL) {
+ (void) fprintf(fp, "%s\n", msg->li_msg);
+ msg = list_next(&log->l_list, msg);
+ }
+
+ (void) fclose(fp);
+}
diff --git a/usr/src/lib/smbsrv/libsmbns/common/smbns_ads.c b/usr/src/lib/smbsrv/libsmbns/common/smbns_ads.c
index 0a8d570b3a..0dbde7ff3d 100644
--- a/usr/src/lib/smbsrv/libsmbns/common/smbns_ads.c
+++ b/usr/src/lib/smbsrv/libsmbns/common/smbns_ads.c
@@ -101,6 +101,20 @@
#define SMB_ADS_ENC_AES128 8
#define SMB_ADS_ENC_AES256 16
+static krb5_enctype w2k8enctypes[] = {
+ ENCTYPE_AES256_CTS_HMAC_SHA1_96,
+ ENCTYPE_AES128_CTS_HMAC_SHA1_96,
+ ENCTYPE_ARCFOUR_HMAC,
+ ENCTYPE_DES_CBC_CRC,
+ ENCTYPE_DES_CBC_MD5,
+};
+
+static krb5_enctype pre_w2k8enctypes[] = {
+ ENCTYPE_ARCFOUR_HMAC,
+ ENCTYPE_DES_CBC_CRC,
+ ENCTYPE_DES_CBC_MD5,
+};
+
#define SMB_ADS_ATTR_SAMACCT "sAMAccountName"
#define SMB_ADS_ATTR_UPN "userPrincipalName"
#define SMB_ADS_ATTR_SPN "servicePrincipalName"
@@ -197,8 +211,6 @@ static int smb_ads_update_computer_cntrl_attr(smb_ads_handle_t *, int, char *);
static krb5_kvno smb_ads_lookup_computer_attr_kvno(smb_ads_handle_t *, char *);
static int smb_ads_gen_machine_passwd(char *, size_t);
static void smb_ads_free_cached_host(void);
-static int smb_ads_get_spnset(char *, char **);
-static void smb_ads_free_spnset(char **);
static int smb_ads_alloc_attr(LDAPMod **, int);
static void smb_ads_free_attr(LDAPMod **);
static int smb_ads_get_dc_level(smb_ads_handle_t *);
@@ -214,6 +226,7 @@ static boolean_t smb_ads_is_same_domain(char *, char *);
static boolean_t smb_ads_is_pdc_configured(void);
static smb_ads_host_info_t *smb_ads_dup_host_info(smb_ads_host_info_t *);
static char *smb_ads_get_sharedn(const char *, const char *, const char *);
+static krb5_enctype *smb_ads_get_enctypes(int, int *);
/*
* smb_ads_init
@@ -1276,43 +1289,6 @@ smb_ads_free_attr(LDAPMod *attrs[])
}
/*
- * smb_ads_get_spnset
- *
- * Derives the core set of SPNs based on the FQHN.
- * The spn_set is a null-terminated array of char pointers.
- *
- * Returns 0 upon success. Otherwise, returns -1.
- */
-static int
-smb_ads_get_spnset(char *fqhost, char **spn_set)
-{
- int i;
-
- bzero(spn_set, (SMBKRB5_SPN_IDX_MAX + 1) * sizeof (char *));
- for (i = 0; i < SMBKRB5_SPN_IDX_MAX; i++) {
- if ((spn_set[i] = smb_krb5_get_spn(i, fqhost)) == NULL) {
- smb_ads_free_spnset(spn_set);
- return (-1);
- }
- }
-
- return (0);
-}
-
-/*
- * smb_ads_free_spnset
- *
- * Free the memory allocated for the set of SPNs.
- */
-static void
-smb_ads_free_spnset(char **spn_set)
-{
- int i;
- for (i = 0; spn_set[i]; i++)
- free(spn_set[i]);
-}
-
-/*
* Returns share DN in an allocated buffer. The format of the DN is
* cn=<sharename>,<container RDNs>,<domain DN>
*
@@ -1799,17 +1775,17 @@ static int
smb_ads_computer_op(smb_ads_handle_t *ah, int op, int dclevel, char *dn)
{
LDAPMod *attrs[SMB_ADS_COMPUTER_NUM_ATTR];
- char *sam_val[2], *usr_val[2];
- char *spn_set[SMBKRB5_SPN_IDX_MAX + 1], *ctl_val[2], *fqh_val[2];
+ char *sam_val[2];
+ char *ctl_val[2], *fqh_val[2];
char *encrypt_val[2];
int j = -1;
int ret, usrctl_flags = 0;
char sam_acct[SMB_SAMACCT_MAXLEN];
char fqhost[MAXHOSTNAMELEN];
- char *user_principal;
char usrctl_buf[16];
char encrypt_buf[16];
int max;
+ smb_krb5_pn_set_t spn, upn;
if (smb_getsamaccount(sam_acct, sizeof (sam_acct)) != 0)
return (-1);
@@ -1817,14 +1793,14 @@ smb_ads_computer_op(smb_ads_handle_t *ah, int op, int dclevel, char *dn)
if (smb_ads_getfqhostname(ah, fqhost, MAXHOSTNAMELEN))
return (-1);
- if (smb_ads_get_spnset(fqhost, spn_set) != 0)
+ /* The SPN attribute is multi-valued and must be 1 or greater */
+ if (smb_krb5_get_pn_set(&spn, SMB_PN_SPN_ATTR, ah->domain) == 0)
return (-1);
- user_principal = smb_krb5_get_upn(spn_set[SMBKRB5_SPN_IDX_HOST],
- ah->domain);
-
- if (user_principal == NULL) {
- smb_ads_free_spnset(spn_set);
+ /* The UPN attribute is single-valued and cannot be zero */
+ if (smb_krb5_get_pn_set(&upn, SMB_PN_UPN_ATTR, ah->domain) != 1) {
+ smb_krb5_free_pn_set(&spn);
+ smb_krb5_free_pn_set(&upn);
return (-1);
}
@@ -1832,8 +1808,8 @@ smb_ads_computer_op(smb_ads_handle_t *ah, int op, int dclevel, char *dn)
- (dclevel >= SMB_ADS_DCLEVEL_W2K8 ? 0 : 1);
if (smb_ads_alloc_attr(attrs, max) != 0) {
- free(user_principal);
- smb_ads_free_spnset(spn_set);
+ smb_krb5_free_pn_set(&spn);
+ smb_krb5_free_pn_set(&upn);
return (-1);
}
@@ -1852,13 +1828,11 @@ smb_ads_computer_op(smb_ads_handle_t *ah, int op, int dclevel, char *dn)
attrs[++j]->mod_op = op;
attrs[j]->mod_type = SMB_ADS_ATTR_UPN;
- usr_val[0] = user_principal;
- usr_val[1] = 0;
- attrs[j]->mod_values = usr_val;
+ attrs[j]->mod_values = upn.s_pns;
attrs[++j]->mod_op = op;
attrs[j]->mod_type = SMB_ADS_ATTR_SPN;
- attrs[j]->mod_values = spn_set;
+ attrs[j]->mod_values = spn.s_pns;
attrs[++j]->mod_op = op;
attrs[j]->mod_type = SMB_ADS_ATTR_CTL;
@@ -1911,8 +1885,8 @@ smb_ads_computer_op(smb_ads_handle_t *ah, int op, int dclevel, char *dn)
}
smb_ads_free_attr(attrs);
- free(user_principal);
- smb_ads_free_spnset(spn_set);
+ smb_krb5_free_pn_set(&spn);
+ smb_krb5_free_pn_set(&upn);
return (ret);
}
@@ -2235,7 +2209,7 @@ smb_ads_join(char *domain, char *user, char *usr_passwd, char *machine_passwd,
{
smb_ads_handle_t *ah = NULL;
krb5_context ctx = NULL;
- krb5_principal krb5princs[SMBKRB5_SPN_IDX_MAX];
+ krb5_principal *krb5princs = NULL;
krb5_kvno kvno;
boolean_t des_only, delete = B_TRUE;
smb_adjoin_status_t rc = SMB_ADJOIN_SUCCESS;
@@ -2244,24 +2218,8 @@ smb_ads_join(char *domain, char *user, char *usr_passwd, char *machine_passwd,
smb_ads_qstat_t qstat;
char dn[SMB_ADS_DN_MAX];
char *tmpfile;
-
- /*
- * Call library functions that can be used to get
- * the list of encryption algorithms available on the system.
- * (similar to what 'encrypt -l' CLI does). For now,
- * unless someone has modified the configuration of the
- * cryptographic framework (very unlikely), the following is the
- * list of algorithms available on any system running Nevada
- * by default.
- */
- krb5_enctype w2k8enctypes[] = {ENCTYPE_AES256_CTS_HMAC_SHA1_96,
- ENCTYPE_AES128_CTS_HMAC_SHA1_96, ENCTYPE_ARCFOUR_HMAC,
- ENCTYPE_DES_CBC_CRC, ENCTYPE_DES_CBC_MD5,
- };
-
- krb5_enctype pre_w2k8enctypes[] = {ENCTYPE_ARCFOUR_HMAC,
- ENCTYPE_DES_CBC_CRC, ENCTYPE_DES_CBC_MD5,
- };
+ int cnt;
+ smb_krb5_pn_set_t spns;
krb5_enctype *encptr;
@@ -2321,13 +2279,22 @@ smb_ads_join(char *domain, char *user, char *usr_passwd, char *machine_passwd,
goto adjoin_cleanup;
}
- if (smb_krb5_get_principals(ah->domain, ctx, krb5princs) != 0) {
+ if (smb_krb5_get_pn_set(&spns, SMB_PN_KEYTAB_ENTRY, ah->domain) == 0) {
rc = SMB_ADJOIN_ERR_GET_SPNS;
goto adjoin_cleanup;
}
- if (smb_krb5_setpwd(ctx, krb5princs[SMBKRB5_SPN_IDX_HOST],
- machine_passwd) != 0) {
+ if (smb_krb5_get_kprincs(ctx, spns.s_pns, spns.s_cnt, &krb5princs)
+ != 0) {
+ smb_krb5_free_pn_set(&spns);
+ rc = SMB_ADJOIN_ERR_GET_SPNS;
+ goto adjoin_cleanup;
+ }
+
+ cnt = spns.s_cnt;
+ smb_krb5_free_pn_set(&spns);
+
+ if (smb_krb5_setpwd(ctx, ah->domain, machine_passwd) != 0) {
rc = SMB_ADJOIN_ERR_KSETPWD;
goto adjoin_cleanup;
}
@@ -2365,20 +2332,13 @@ smb_ads_join(char *domain, char *user, char *usr_passwd, char *machine_passwd,
goto adjoin_cleanup;
}
- if (dclevel >= SMB_ADS_DCLEVEL_W2K8) {
- num = sizeof (w2k8enctypes) / sizeof (krb5_enctype);
- encptr = w2k8enctypes;
- } else {
- num = sizeof (pre_w2k8enctypes) / sizeof (krb5_enctype);
- encptr = pre_w2k8enctypes;
- }
-
tmpfile = mktemp(SMBNS_KRB5_KEYTAB_TMP);
if (tmpfile == NULL)
tmpfile = SMBNS_KRB5_KEYTAB_TMP;
- if (smb_krb5_add_keytab_entries(ctx, krb5princs, tmpfile,
- kvno, machine_passwd, encptr, num) != 0) {
+ encptr = smb_ads_get_enctypes(dclevel, &num);
+ if (smb_krb5_kt_populate(ctx, ah->domain, krb5princs, cnt,
+ tmpfile, kvno, machine_passwd, encptr, num) != 0) {
rc = SMB_ADJOIN_ERR_WRITE_KEYTAB;
goto adjoin_cleanup;
}
@@ -2390,8 +2350,7 @@ adjoin_cleanup:
if (rc != SMB_ADJOIN_ERR_INIT_KRB_CTX) {
if (rc != SMB_ADJOIN_ERR_GET_SPNS)
- smb_krb5_free_principals(ctx, krb5princs,
- SMBKRB5_SPN_IDX_MAX);
+ smb_krb5_free_kprincs(ctx, krb5princs, cnt);
smb_krb5_ctx_fini(ctx);
}
@@ -2678,3 +2637,19 @@ smb_ads_lookup_msdcs(char *fqdn, char *server, char *buf, uint32_t buflen)
free(hinfo);
return (B_TRUE);
}
+
+static krb5_enctype *
+smb_ads_get_enctypes(int dclevel, int *num)
+{
+ krb5_enctype *encptr;
+
+ if (dclevel >= SMB_ADS_DCLEVEL_W2K8) {
+ *num = sizeof (w2k8enctypes) / sizeof (krb5_enctype);
+ encptr = w2k8enctypes;
+ } else {
+ *num = sizeof (pre_w2k8enctypes) / sizeof (krb5_enctype);
+ encptr = pre_w2k8enctypes;
+ }
+
+ return (encptr);
+}
diff --git a/usr/src/lib/smbsrv/libsmbns/common/smbns_dyndns.c b/usr/src/lib/smbsrv/libsmbns/common/smbns_dyndns.c
index 052b668ee5..24e1d175ac 100644
--- a/usr/src/lib/smbsrv/libsmbns/common/smbns_dyndns.c
+++ b/usr/src/lib/smbsrv/libsmbns/common/smbns_dyndns.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <assert.h>
@@ -1805,6 +1804,8 @@ dyndns_add_remove_entry(int update_zone, const char *hostname,
int buf_sz;
int level = 0;
smb_inaddr_t dns_ip;
+ char *fqdn;
+ char *p;
assert(dns_str);
assert(*dns_str);
@@ -1868,9 +1869,18 @@ retry_higher:
return (-1);
}
- if (smb_krb5_find_keytab_entries(hostname, SMBNS_KRB5_KEYTAB))
+ if ((p = strchr(hostname, '.')) == NULL)
+ return (-1);
+
+ fqdn = ++p;
+ if (smb_krb5_kt_find(SMB_KRB5_PN_ID_HOST_FQHN, fqdn,
+ SMBNS_KRB5_KEYTAB)) {
ret = dyndns_sec_add_remove_entry(update_zone, hostname,
ip_addr, life_time, update_type, del_type, dns_str);
+ } else {
+ syslog(LOG_NOTICE, "dyndns: secure update failed: cannot find "
+ "host principal \"%s\" in local keytab file.", hostname);
+ }
return (ret);
}
diff --git a/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.c b/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.c
index ec9f2777a4..4bb8ef49d6 100644
--- a/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.c
+++ b/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Copyright 1990 by the Massachusetts Institute of Technology.
@@ -82,20 +81,20 @@ smb_kinit(char *principal_name, char *principal_passwd)
code = krb5_init_context(&ctx);
if (code) {
- doing = "initializing context";
+ doing = "smbns_krb: initializing context";
goto cleanup;
}
code = krb5_cc_default(ctx, &cc);
if (code != 0) {
- doing = "resolve default credentials cache";
+ doing = "smbns_krb: resolve default credentials cache";
goto cleanup;
}
/* Use specified name */
code = krb5_parse_name(ctx, principal_name, &me);
if (code != 0) {
- doing = "parsing principal name";
+ doing = "smbns_krb: parsing principal name";
goto cleanup;
}
@@ -103,10 +102,10 @@ smb_kinit(char *principal_name, char *principal_passwd)
principal_passwd, NULL, 0, (krb5_deltat)0,
NULL, NULL);
if (code != 0) {
- doing = "getting initial credentials";
+ doing = "smbns_krb: getting initial credentials";
if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY) {
- errmsg = "Password incorrect";
+ errmsg = "smbns_krb: Password incorrect";
}
goto cleanup;
@@ -114,13 +113,13 @@ smb_kinit(char *principal_name, char *principal_passwd)
code = krb5_cc_initialize(ctx, cc, me);
if (code != 0) {
- doing = "initializing cache";
+ doing = "smbns_krb: initializing cache";
goto cleanup;
}
code = krb5_cc_store_cred(ctx, cc, &my_creds);
if (code != 0) {
- doing = "storing credentials";
+ doing = "smbns_krb: storing credentials";
goto cleanup;
}
@@ -129,8 +128,9 @@ smb_kinit(char *principal_name, char *principal_passwd)
cleanup:
if (code != 0) {
if (errmsg == NULL)
- errmsg = error_message(code);
- syslog(LOG_ERR, "k5_kinit: %s (%s)", doing, errmsg);
+ smb_krb5_log_errmsg(ctx, doing, code);
+ else
+ syslog(LOG_ERR, "%s (%s)", doing, errmsg);
}
if (my_creds.client == me) {
@@ -149,6 +149,19 @@ cleanup:
}
/*
+ * Invoke krb5_get_error_message() to generate a richer error message.
+ */
+void
+smb_krb5_log_errmsg(krb5_context ctx, const char *prefix, krb5_error_code code)
+{
+ const char *msg;
+
+ msg = krb5_get_error_message(ctx, code);
+ syslog(LOG_ERR, "%s (%s)", prefix, msg);
+ krb5_free_error_message(ctx, msg);
+}
+
+/*
* smb_ccache_init
*
* Creates the directory where the Kerberos ccache file is located
@@ -176,5 +189,6 @@ void
smb_ccache_remove(char *path)
{
if ((remove(path) < 0) && (errno != ENOENT))
- syslog(LOG_ERR, "failed to remove ccache (%s)", path);
+ syslog(LOG_ERR, "smbns_krb: failed to remove ccache (%s)",
+ path);
}
diff --git a/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.h b/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.h
index ad8b247dcf..279634afc2 100644
--- a/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.h
+++ b/usr/src/lib/smbsrv/libsmbns/common/smbns_krb.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMBSRV_SMB_KRB_H
@@ -35,29 +34,64 @@ extern "C" {
#define SMBNS_KRB5_KEYTAB "/etc/krb5/krb5.keytab"
#define SMBNS_KRB5_KEYTAB_TMP "/etc/krb5/krb5.keytab.tmp.XXXXXX"
-/* core set of SPNs */
-typedef enum smb_krb5_spn_idx {
- SMBKRB5_SPN_IDX_HOST = 0,
- SMBKRB5_SPN_IDX_NFS,
- SMBKRB5_SPN_IDX_HTTP,
- SMBKRB5_SPN_IDX_ROOT,
- SMBKRB5_SPN_IDX_MAX
-} smb_krb5_spn_idx_t;
+#define SMB_PN_SPN_ATTR 0x0001 /* w/o REALM portion */
+#define SMB_PN_UPN_ATTR 0x0002 /* w/ REALM */
+#define SMB_PN_KEYTAB_ENTRY 0x0004 /* w/ REALM */
+#define SMB_PN_SALT 0x0008 /* w/ REALM */
+
+#define SMB_PN_SVC_HOST "host"
+#define SMB_PN_SVC_NFS "nfs"
+#define SMB_PN_SVC_HTTP "HTTP"
+#define SMB_PN_SVC_ROOT "root"
+
+/* Assign an identifier for each principal name format */
+typedef enum smb_krb5_pn_id {
+ SMB_KRB5_PN_ID_SALT,
+ SMB_KRB5_PN_ID_HOST_FQHN,
+ SMB_KRB5_PN_ID_NFS_FQHN,
+ SMB_KRB5_PN_ID_HTTP_FQHN,
+ SMB_KRB5_PN_ID_ROOT_FQHN,
+} smb_krb5_pn_id_t;
+
+/*
+ * A principal name can be constructed based on the following:
+ *
+ * p_id - identifier for a principal name.
+ * p_svc - service with which the principal is associated.
+ * p_flags - usage of the principal is identified - whether it can be used as a
+ * SPN attribute, UPN attribute, or/and keytab entry, etc.
+ */
+typedef struct smb_krb5_pn {
+ smb_krb5_pn_id_t p_id;
+ char *p_svc;
+ uint32_t p_flags;
+} smb_krb5_pn_t;
+
+/*
+ * A set of principal names
+ *
+ * ps_cnt - the number of principal names in the array.
+ * ps_set - An array of principal names terminated with a NULL pointer.
+ */
+typedef struct smb_krb5_pn_set {
+ uint32_t s_cnt;
+ char **s_pns;
+} smb_krb5_pn_set_t;
int smb_kinit(char *, char *);
-char *smb_krb5_get_spn(smb_krb5_spn_idx_t idx, char *fqhost);
-char *smb_krb5_get_upn(char *spn, char *domain);
-int smb_krb5_ctx_init(krb5_context *ctx);
-void smb_krb5_ctx_fini(krb5_context ctx);
-int smb_krb5_get_principals(char *domain, krb5_context ctx,
- krb5_principal *krb5princs);
-void smb_krb5_free_principals(krb5_context ctx, krb5_principal *krb5princs,
- size_t num);
-int smb_krb5_setpwd(krb5_context ctx, krb5_principal princ, char *passwd);
-int smb_krb5_add_keytab_entries(krb5_context ctx, krb5_principal *princs,
- char *fname, krb5_kvno kvno, char *passwd, krb5_enctype *enctypes,
- int enctype_count);
-boolean_t smb_krb5_find_keytab_entries(const char *fqhn, char *fname);
+int smb_krb5_ctx_init(krb5_context *);
+void smb_krb5_ctx_fini(krb5_context);
+int smb_krb5_get_kprincs(krb5_context, char **, size_t, krb5_principal **);
+void smb_krb5_free_kprincs(krb5_context, krb5_principal *, size_t);
+int smb_krb5_setpwd(krb5_context, const char *, char *);
+
+int smb_krb5_kt_populate(krb5_context, const char *, krb5_principal *,
+ int, char *, krb5_kvno, char *, krb5_enctype *, int);
+boolean_t smb_krb5_kt_find(smb_krb5_pn_id_t, const char *, char *);
+
+uint32_t smb_krb5_get_pn_set(smb_krb5_pn_set_t *, uint32_t, char *);
+void smb_krb5_free_pn_set(smb_krb5_pn_set_t *);
+void smb_krb5_log_errmsg(krb5_context, const char *, krb5_error_code);
#ifdef __cplusplus
}
diff --git a/usr/src/lib/smbsrv/libsmbns/common/smbns_ksetpwd.c b/usr/src/lib/smbsrv/libsmbns/common/smbns_ksetpwd.c
index 965c2fd473..946ca6461a 100644
--- a/usr/src/lib/smbsrv/libsmbns/common/smbns_ksetpwd.c
+++ b/usr/src/lib/smbsrv/libsmbns/common/smbns_ksetpwd.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <stdio.h>
@@ -40,118 +39,121 @@
#include <smbsrv/libsmb.h>
#include <smbns_krb.h>
-static char *spn_prefix[] = {"host/", "nfs/", "HTTP/", "root/"};
-
-static int smb_krb5_open_wrfile(krb5_context ctx, char *fname,
- krb5_keytab *kt);
-static int smb_krb5_ktadd(krb5_context ctx, krb5_keytab kt,
- const krb5_principal princ, krb5_enctype enctype, krb5_kvno kvno,
- const char *pw);
-
/*
- * smb_krb5_get_spn
- *
- * Gets Service Principal Name.
- * Caller must free the memory allocated for the spn.
+ * Kerberized services available on the system.
*/
-char *
-smb_krb5_get_spn(smb_krb5_spn_idx_t idx, char *fqhost)
-{
- int len;
- char *princ;
- char *spn;
+static smb_krb5_pn_t smb_krb5_pn_tab[] = {
+ /*
+ * Service keys are salted with the SMB_KRB_PN_ID_ID_SALT prinipal
+ * name.
+ */
+ {SMB_KRB5_PN_ID_SALT, SMB_PN_SVC_HOST, SMB_PN_SALT},
- if (!fqhost)
- return (NULL);
+ /* HOST */
+ {SMB_KRB5_PN_ID_HOST_FQHN, SMB_PN_SVC_HOST,
+ SMB_PN_KEYTAB_ENTRY | SMB_PN_SPN_ATTR | SMB_PN_UPN_ATTR},
- if ((idx < 0) || (idx >= SMBKRB5_SPN_IDX_MAX))
- return (NULL);
+ /* NFS */
+ {SMB_KRB5_PN_ID_NFS_FQHN, SMB_PN_SVC_NFS,
+ SMB_PN_KEYTAB_ENTRY | SMB_PN_SPN_ATTR},
- spn = spn_prefix[idx];
- len = strlen(spn) + strlen(fqhost) + 1;
- princ = (char *)malloc(len);
+ /* HTTP */
+ {SMB_KRB5_PN_ID_HTTP_FQHN, SMB_PN_SVC_HTTP,
+ SMB_PN_KEYTAB_ENTRY | SMB_PN_SPN_ATTR},
- if (!princ)
- return (NULL);
+ /* ROOT */
+ {SMB_KRB5_PN_ID_ROOT_FQHN, SMB_PN_SVC_ROOT,
+ SMB_PN_KEYTAB_ENTRY | SMB_PN_SPN_ATTR},
+};
+
+#define SMB_KRB5_SPN_TAB_SZ \
+ (sizeof (smb_krb5_pn_tab) / sizeof (smb_krb5_pn_tab[0]))
+
+#define SMB_KRB5_MAX_BUFLEN 128
+
+static int smb_krb5_kt_open(krb5_context, char *, krb5_keytab *);
+static int smb_krb5_kt_addkey(krb5_context, krb5_keytab, const krb5_principal,
+ krb5_enctype, krb5_kvno, const krb5_data *, const char *);
+static int smb_krb5_spn_count(uint32_t);
+static smb_krb5_pn_t *smb_krb5_lookup_pn(smb_krb5_pn_id_t);
+static char *smb_krb5_get_pn_by_id(smb_krb5_pn_id_t, uint32_t,
+ const char *);
+static int smb_krb5_get_kprinc(krb5_context, smb_krb5_pn_id_t, uint32_t,
+ const char *, krb5_principal *);
- (void) snprintf(princ, len, "%s%s", spn, fqhost);
- return (princ);
-}
/*
- * smb_krb5_get_upn
+ * Generates a null-terminated array of principal names that
+ * represents the list of the available Kerberized services
+ * of the specified type (SPN attribute, UPN attribute, or
+ * keytab entry).
+ *
+ * Returns the number of principal names returned via the 1st
+ * output parameter (i.e. vals).
*
- * Gets User Principal Name.
- * Caller must free the memory allocated for the upn.
+ * Caller must invoke smb_krb5_free_spns to free the allocated
+ * memory when finished.
*/
-char *
-smb_krb5_get_upn(char *spn, char *domain)
+uint32_t
+smb_krb5_get_pn_set(smb_krb5_pn_set_t *set, uint32_t type, char *fqdn)
{
- int len;
- char *realm;
- char *upn;
+ int cnt, i;
+ smb_krb5_pn_t *tabent;
- if (!spn || !domain)
- return (NULL);
+ if (!set || !fqdn)
+ return (0);
- realm = strdup(domain);
- if (!realm)
- return (NULL);
+ bzero(set, sizeof (smb_krb5_pn_set_t));
+ cnt = smb_krb5_spn_count(type);
+ set->s_pns = (char **)calloc(cnt + 1, sizeof (char *));
- (void) smb_strupr(realm);
+ if (set->s_pns == NULL)
+ return (0);
- len = strlen(spn) + 1 + strlen(realm) + 1;
- upn = (char *)malloc(len);
- if (!upn) {
- free(realm);
- return (NULL);
- }
+ for (i = 0, set->s_cnt = 0; i < SMB_KRB5_SPN_TAB_SZ; i++) {
+ tabent = &smb_krb5_pn_tab[i];
- (void) snprintf(upn, len, "%s@%s", spn, realm);
- free(realm);
+ if (set->s_cnt == cnt)
+ break;
- return (upn);
-}
+ if ((tabent->p_flags & type) != type)
+ continue;
-/*
- * smb_krb5_get_host_upn
- *
- * Derives UPN by the given fully-qualified hostname.
- * Caller must free the memory allocated for the upn.
- */
-static char *
-smb_krb5_get_host_upn(const char *fqhn)
-{
- char *upn;
- char *realm;
- char *dom;
- int len;
+ set->s_pns[set->s_cnt] = smb_krb5_get_pn_by_id(tabent->p_id,
+ type, fqdn);
+ if (set->s_pns[set->s_cnt] == NULL) {
+ syslog(LOG_ERR, "smbns_ksetpwd: failed to obtain "
+ "principal names: possible transient memory "
+ "shortage");
+ smb_krb5_free_pn_set(set);
+ return (0);
+ }
- if ((dom = strchr(fqhn, '.')) == NULL)
- return (NULL);
+ set->s_cnt++;
+ }
- if ((realm = strdup(++dom)) == NULL)
- return (NULL);
+ if (set->s_cnt == 0)
+ smb_krb5_free_pn_set(set);
- (void) smb_strupr(realm);
+ return (set->s_cnt);
+}
- len = strlen(spn_prefix[SMBKRB5_SPN_IDX_HOST]) + strlen(fqhn) +
- + 1 + strlen(realm) + 1;
- if ((upn = malloc(len)) == NULL) {
- free(realm);
- return (NULL);
- }
+void
+smb_krb5_free_pn_set(smb_krb5_pn_set_t *set)
+{
+ int i;
- (void) snprintf(upn, len, "%s%s@%s", spn_prefix[SMBKRB5_SPN_IDX_HOST],
- fqhn, realm);
+ if (set == NULL || set->s_pns == NULL)
+ return;
- free(realm);
- return (upn);
+ for (i = 0; i < set->s_cnt; i++)
+ free(set->s_pns[i]);
+
+ free(set->s_pns);
+ set->s_pns = NULL;
}
/*
- * smb_krb5_ctx_init
- *
* Initialize the kerberos context.
* Return 0 on success. Otherwise, return -1.
*/
@@ -165,135 +167,126 @@ smb_krb5_ctx_init(krb5_context *ctx)
}
/*
- * smb_krb5_get_principals
+ * Free the kerberos context.
+ */
+void
+smb_krb5_ctx_fini(krb5_context ctx)
+{
+ krb5_free_context(ctx);
+}
+
+/*
+ * Create an array of Kerberos Princiapls given an array of principal names.
+ * Caller must free the allocated memory using smb_krb5_free_kprincs()
+ * upon success.
*
- * Setup the krb5_principal array given the principals in string format.
- * Parameters:
- * domain - fully-qualified domain name in lower case.
- * Return 0 on success. Otherwise, return -1.
+ * Returns 0 on success. Otherwise, returns -1.
*/
int
-smb_krb5_get_principals(char *domain, krb5_context ctx,
- krb5_principal *krb5princs)
+smb_krb5_get_kprincs(krb5_context ctx, char **names, size_t num,
+ krb5_principal **krb5princs)
{
- char fqhn[MAXHOSTNAMELEN];
int i;
- char *spn, *upn;
-
- if (smb_gethostname(fqhn, MAXHOSTNAMELEN, SMB_CASE_LOWER) != 0)
- return (-1);
- /*
- * To comply with RFC 4120 section 6.2.1, the fully-qualified hostname
- * must be set to lower case.
- */
- (void) snprintf(fqhn, MAXHOSTNAMELEN, "%s.%s", fqhn,
- domain);
-
- for (i = 0; i < SMBKRB5_SPN_IDX_MAX; i++) {
-
- if ((spn = smb_krb5_get_spn(i, fqhn)) == NULL) {
- return (-1);
- }
-
- upn = smb_krb5_get_upn(spn, domain);
- free(spn);
+ if ((*krb5princs = calloc(num, sizeof (krb5_principal *))) == NULL) {
+ return (-1);
+ }
- if (krb5_parse_name(ctx, upn, &krb5princs[i]) != 0) {
- smb_krb5_free_principals(ctx, krb5princs, i - 1);
- free(upn);
+ for (i = 0; i < num; i++) {
+ if (krb5_parse_name(ctx, names[i], &(*krb5princs)[i]) != 0) {
+ smb_krb5_free_kprincs(ctx, *krb5princs, i);
return (-1);
}
- free(upn);
}
+
return (0);
}
void
-smb_krb5_free_principals(krb5_context ctx, krb5_principal *krb5princs,
+smb_krb5_free_kprincs(krb5_context ctx, krb5_principal *krb5princs,
size_t num)
{
int i;
for (i = 0; i < num; i++)
krb5_free_principal(ctx, krb5princs[i]);
-}
-/*
- * smb_krb5_ctx_fini
- *
- * Free the kerberos context.
- */
-void
-smb_krb5_ctx_fini(krb5_context ctx)
-{
- krb5_free_context(ctx);
+ free(krb5princs);
}
/*
- * smb_ksetpw
- *
* Set the workstation trust account password.
* Returns 0 on success. Otherwise, returns non-zero value.
*/
int
-smb_krb5_setpwd(krb5_context ctx, krb5_principal princ, char *passwd)
+smb_krb5_setpwd(krb5_context ctx, const char *fqdn, char *passwd)
{
krb5_error_code code;
krb5_ccache cc = NULL;
- int result_code;
+ int result_code = 0;
krb5_data result_code_string, result_string;
+ krb5_principal princ;
+ char msg[SMB_KRB5_MAX_BUFLEN];
+
+ if (smb_krb5_get_kprinc(ctx, SMB_KRB5_PN_ID_HOST_FQHN,
+ SMB_PN_UPN_ATTR, fqdn, &princ) != 0)
+ return (-1);
(void) memset(&result_code_string, 0, sizeof (result_code_string));
(void) memset(&result_string, 0, sizeof (result_string));
if ((code = krb5_cc_default(ctx, &cc)) != 0) {
- syslog(LOG_ERR, "smb_krb5_setpwd: failed to find a ccache\n");
+ (void) snprintf(msg, sizeof (msg), "smbns_ksetpwd: failed to "
+ "find %s", SMB_CCACHE_PATH);
+ smb_krb5_log_errmsg(ctx, msg, code);
+ krb5_free_principal(ctx, princ);
return (-1);
}
code = krb5_set_password_using_ccache(ctx, cc, passwd, princ,
&result_code, &result_code_string, &result_string);
+ if (code != 0)
+ smb_krb5_log_errmsg(ctx, "smbns_ksetpwd: KPASSWD protocol "
+ "exchange failed", code);
+
(void) krb5_cc_close(ctx, cc);
- if (code != 0)
- (void) syslog(LOG_ERR,
- "smb_krb5_setpwd: Result: %.*s (%d) %.*s\n",
- result_code == 0 ?
- strlen("success") : result_code_string.length,
- result_code == 0 ? "success" : result_code_string.data,
- result_code, result_string.length, result_string.data);
+ if (result_code != 0)
+ syslog(LOG_ERR, "smbns_ksetpwd: KPASSWD failed: %s",
+ result_code_string.data);
+ krb5_free_principal(ctx, princ);
free(result_code_string.data);
free(result_string.data);
return (code);
}
/*
- * smb_krb5_open_wrfile
- *
* Open the keytab file for writing.
* The keytab should be closed by calling krb5_kt_close().
*/
static int
-smb_krb5_open_wrfile(krb5_context ctx, char *fname, krb5_keytab *kt)
+smb_krb5_kt_open(krb5_context ctx, char *fname, krb5_keytab *kt)
{
char *ktname;
+ krb5_error_code code;
int len;
+ char msg[SMB_KRB5_MAX_BUFLEN];
*kt = NULL;
len = snprintf(NULL, 0, "WRFILE:%s", fname) + 1;
if ((ktname = malloc(len)) == NULL) {
- syslog(LOG_ERR, "smb_krb5_write_keytab: resource shortage");
+ syslog(LOG_ERR, "smbns_ksetpwd: unable to open keytab %s: "
+ "possible transient memory shortage", fname);
return (-1);
}
(void) snprintf(ktname, len, "WRFILE:%s", fname);
- if (krb5_kt_resolve(ctx, ktname, kt) != 0) {
- syslog(LOG_ERR, "smb_krb5_write_keytab: failed to open/create "
- "keytab %s\n", fname);
+ if ((code = krb5_kt_resolve(ctx, ktname, kt)) != 0) {
+ (void) snprintf(msg, sizeof (msg), "smbns_ksetpwd: %s", fname);
+ smb_krb5_log_errmsg(ctx, msg, code);
free(ktname);
return (-1);
}
@@ -303,65 +296,79 @@ smb_krb5_open_wrfile(krb5_context ctx, char *fname, krb5_keytab *kt)
}
/*
- * smb_krb5_add_keytab_entries
- *
- * Update the keys for the specified principal in the keytab.
- * Returns 0 on success. Otherwise, returns -1.
+ * Populate the keytab with keys of the specified key version for the
+ * specified set of krb5 principals. All service keys will be salted by:
+ * host/<truncated@15_lower_case_hostname>.<fqdn>@<REALM>
*/
int
-smb_krb5_add_keytab_entries(krb5_context ctx, krb5_principal *princs,
- char *fname, krb5_kvno kvno, char *passwd, krb5_enctype *enctypes,
- int enctype_count)
+smb_krb5_kt_populate(krb5_context ctx, const char *fqdn,
+ krb5_principal *princs, int count, char *fname, krb5_kvno kvno,
+ char *passwd, krb5_enctype *enctypes, int enctype_count)
{
krb5_keytab kt = NULL;
+ krb5_data salt;
+ krb5_error_code code;
+ krb5_principal salt_princ;
int i, j;
- if (smb_krb5_open_wrfile(ctx, fname, &kt) != 0)
+ if (smb_krb5_kt_open(ctx, fname, &kt) != 0)
+ return (-1);
+
+ if (smb_krb5_get_kprinc(ctx, SMB_KRB5_PN_ID_SALT, SMB_PN_SALT,
+ fqdn, &salt_princ) != 0) {
+ (void) krb5_kt_close(ctx, kt);
+ return (-1);
+ }
+
+ code = krb5_principal2salt(ctx, salt_princ, &salt);
+ if (code != 0) {
+ smb_krb5_log_errmsg(ctx, "smbns_ksetpwd: salt computation "
+ "failed", code);
+ krb5_free_principal(ctx, salt_princ);
+ (void) krb5_kt_close(ctx, kt);
return (-1);
+ }
- for (j = 0; j < SMBKRB5_SPN_IDX_MAX; j++) {
+ for (j = 0; j < count; j++) {
for (i = 0; i < enctype_count; i++) {
- if (smb_krb5_ktadd(ctx, kt, princs[j], enctypes[i],
- kvno, passwd) != 0) {
+ if (smb_krb5_kt_addkey(ctx, kt, princs[j], enctypes[i],
+ kvno, &salt, passwd) != 0) {
+ krb5_free_principal(ctx, salt_princ);
+ krb5_xfree(salt.data);
(void) krb5_kt_close(ctx, kt);
return (-1);
}
}
}
+ krb5_free_principal(ctx, salt_princ);
+ krb5_xfree(salt.data);
(void) krb5_kt_close(ctx, kt);
return (0);
}
boolean_t
-smb_krb5_find_keytab_entries(const char *fqhn, char *fname)
+smb_krb5_kt_find(smb_krb5_pn_id_t id, const char *fqdn, char *fname)
{
krb5_context ctx;
krb5_keytab kt;
krb5_keytab_entry entry;
krb5_principal princ;
char ktname[MAXPATHLEN];
- char *upn;
boolean_t found = B_FALSE;
- if (!fqhn || !fname)
+ if (!fqdn || !fname)
return (found);
- if ((upn = smb_krb5_get_host_upn((char *)fqhn)) == NULL)
+ if (smb_krb5_ctx_init(&ctx) != 0)
return (found);
- if (smb_krb5_ctx_init(&ctx) != 0) {
- free(upn);
- return (found);
- }
-
- if (krb5_parse_name(ctx, upn, &princ) != 0) {
- free(upn);
+ if (smb_krb5_get_kprinc(ctx, id, SMB_PN_KEYTAB_ENTRY, fqdn,
+ &princ) != 0) {
smb_krb5_ctx_fini(ctx);
return (found);
}
- free(upn);
(void) snprintf(ktname, MAXPATHLEN, "FILE:%s", fname);
if (krb5_kt_resolve(ctx, ktname, &kt) == 0) {
if (krb5_kt_get_entry(ctx, kt, princ, 0, 0, &entry) == 0) {
@@ -378,31 +385,32 @@ smb_krb5_find_keytab_entries(const char *fqhn, char *fname)
}
/*
- * smb_krb5_ktadd
- *
- * Add a Keberos key to the keytab file.
+ * Add a key of the specified encryption type for the specified principal
+ * to the keytab file.
* Returns 0 on success. Otherwise, returns -1.
*/
static int
-smb_krb5_ktadd(krb5_context ctx, krb5_keytab kt, const krb5_principal princ,
- krb5_enctype enctype, krb5_kvno kvno, const char *pw)
+smb_krb5_kt_addkey(krb5_context ctx, krb5_keytab kt, const krb5_principal princ,
+ krb5_enctype enctype, krb5_kvno kvno, const krb5_data *salt,
+ const char *pw)
{
krb5_keytab_entry *entry;
- krb5_data password, salt;
+ krb5_data password;
krb5_keyblock key;
krb5_error_code code;
- char buf[100];
+ char buf[SMB_KRB5_MAX_BUFLEN], msg[SMB_KRB5_MAX_BUFLEN];
int rc = 0;
if ((code = krb5_enctype_to_string(enctype, buf, sizeof (buf)))) {
- syslog(LOG_ERR, "smb_krb5_ktadd[%d]: unknown enctype",
- enctype);
+ (void) snprintf(msg, sizeof (msg), "smbns_ksetpwd: unknown "
+ "encryption type (%d)", enctype);
+ smb_krb5_log_errmsg(ctx, msg, code);
return (-1);
}
if ((entry = (krb5_keytab_entry *) malloc(sizeof (*entry))) == NULL) {
- syslog(LOG_ERR, "smb_krb5_ktadd[%d]: resource shortage",
- enctype);
+ syslog(LOG_ERR, "smbns_ksetpwd: possible transient "
+ "memory shortage");
return (-1);
}
@@ -411,18 +419,11 @@ smb_krb5_ktadd(krb5_context ctx, krb5_keytab kt, const krb5_principal princ,
password.length = strlen(pw);
password.data = (char *)pw;
- if ((code = krb5_principal2salt(ctx, princ, &salt)) != 0) {
- syslog(LOG_ERR, "smb_krb5_ktadd[%d]: failed to compute salt",
- enctype);
- free(entry);
- return (-1);
- }
-
- code = krb5_c_string_to_key(ctx, enctype, &password, &salt, &key);
- krb5_xfree(salt.data);
+ code = krb5_c_string_to_key(ctx, enctype, &password, salt, &key);
if (code != 0) {
- syslog(LOG_ERR, "smb_krb5_ktadd[%d]: failed to generate key",
- enctype);
+ (void) snprintf(msg, sizeof (msg), "smbns_ksetpwd: failed to "
+ "generate key (%d)", enctype);
+ smb_krb5_log_errmsg(ctx, msg, code);
free(entry);
return (-1);
}
@@ -432,8 +433,9 @@ smb_krb5_ktadd(krb5_context ctx, krb5_keytab kt, const krb5_principal princ,
entry->principal = princ;
if ((code = krb5_kt_add_entry(ctx, kt, entry)) != 0) {
- syslog(LOG_ERR, "smb_krb5_ktadd[%d] failed to add entry to "
- "keytab (%d)", enctype, code);
+ (void) snprintf(msg, sizeof (msg), "smbns_ksetpwd: failed to "
+ "add key (%d)", enctype);
+ smb_krb5_log_errmsg(ctx, msg, code);
rc = -1;
}
@@ -442,3 +444,122 @@ smb_krb5_ktadd(krb5_context ctx, krb5_keytab kt, const krb5_principal princ,
krb5_free_keyblock_contents(ctx, &key);
return (rc);
}
+
+static int
+smb_krb5_spn_count(uint32_t type)
+{
+ int i, cnt;
+
+ for (i = 0, cnt = 0; i < SMB_KRB5_SPN_TAB_SZ; i++) {
+ if (smb_krb5_pn_tab[i].p_flags & type)
+ cnt++;
+ }
+
+ return (cnt);
+}
+
+/*
+ * Generate the Kerberos Principal given a principal name format and the
+ * fully qualified domain name. On success, caller must free the allocated
+ * memory by calling krb5_free_principal().
+ */
+static int
+smb_krb5_get_kprinc(krb5_context ctx, smb_krb5_pn_id_t id, uint32_t type,
+ const char *fqdn, krb5_principal *princ)
+{
+ char *buf;
+
+ if ((buf = smb_krb5_get_pn_by_id(id, type, fqdn)) == NULL)
+ return (-1);
+
+ if (krb5_parse_name(ctx, buf, princ) != 0) {
+ free(buf);
+ return (-1);
+ }
+
+ free(buf);
+ return (0);
+}
+
+/*
+ * Looks up an entry in the principal name table given the ID.
+ */
+static smb_krb5_pn_t *
+smb_krb5_lookup_pn(smb_krb5_pn_id_t id)
+{
+ int i;
+ smb_krb5_pn_t *tabent;
+
+ for (i = 0; i < SMB_KRB5_SPN_TAB_SZ; i++) {
+ tabent = &smb_krb5_pn_tab[i];
+ if (id == tabent->p_id)
+ return (tabent);
+ }
+
+ return (NULL);
+}
+
+/*
+ * Construct the principal name given an ID, the requested type, and the
+ * fully-qualified name of the domain of which the principal is a member.
+ */
+static char *
+smb_krb5_get_pn_by_id(smb_krb5_pn_id_t id, uint32_t type,
+ const char *fqdn)
+{
+ char nbname[NETBIOS_NAME_SZ];
+ char hostname[MAXHOSTNAMELEN];
+ char *realm = NULL;
+ smb_krb5_pn_t *pn;
+ char *buf;
+
+ (void) smb_getnetbiosname(nbname, NETBIOS_NAME_SZ);
+ (void) smb_gethostname(hostname, MAXHOSTNAMELEN, SMB_CASE_LOWER);
+
+ pn = smb_krb5_lookup_pn(id);
+
+ /* detect inconsistent requested format and type */
+ if ((type & pn->p_flags) != type)
+ return (NULL);
+
+ switch (id) {
+ case SMB_KRB5_PN_ID_SALT:
+ (void) asprintf(&buf, "%s/%s.%s",
+ pn->p_svc, smb_strlwr(nbname), fqdn);
+ break;
+
+ case SMB_KRB5_PN_ID_HOST_FQHN:
+ case SMB_KRB5_PN_ID_NFS_FQHN:
+ case SMB_KRB5_PN_ID_HTTP_FQHN:
+ case SMB_KRB5_PN_ID_ROOT_FQHN:
+ (void) asprintf(&buf, "%s/%s.%s",
+ pn->p_svc, hostname, fqdn);
+ break;
+ }
+
+ /*
+ * If the requested principal is either added to keytab / the machine
+ * account as the UPN attribute or used for key salt generation,
+ * the principal name must have the @<REALM> portion.
+ */
+ if (type & (SMB_PN_KEYTAB_ENTRY | SMB_PN_UPN_ATTR | SMB_PN_SALT)) {
+ if ((realm = strdup(fqdn)) == NULL) {
+ free(buf);
+ return (NULL);
+ }
+
+ (void) smb_strupr(realm);
+ if (buf != NULL) {
+ char *tmp;
+
+ (void) asprintf(&tmp, "%s@%s", buf,
+ realm);
+ free(buf);
+ buf = tmp;
+ }
+
+ free(realm);
+ }
+
+ return (buf);
+}
diff --git a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr.h b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr.h
index 8d91fa09cb..ad1c356014 100644
--- a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr.h
+++ b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMBRDR_H_
@@ -39,6 +38,9 @@
#include <smbsrv/smb.h>
#include <smbsrv/wintypes.h>
+#define SMBRDR_LOG_NAME "smbrdr"
+#define SMBRDR_LOG_MAXCNT 1024
+
#define SMBRDR_REQ_BUFSZ 4096
#define MAX_ACCOUNT_NAME 32
@@ -311,4 +313,6 @@ void smbrdr_sign_unset_key(struct sdb_session *);
void smbrdr_lock_transport(void);
void smbrdr_unlock_transport(void);
+extern smb_log_hdl_t smbrdr_log_hdl;
+
#endif /* _SMBRDR_H_ */
diff --git a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_lib.c b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_lib.c
index 13895560b6..8b9412e91a 100644
--- a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_lib.c
+++ b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_lib.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -31,9 +31,10 @@
#include <unistd.h>
#include <string.h>
#include <strings.h>
-#include <smbsrv/ntstatus.h>
#include <smbrdr.h>
+smb_log_hdl_t smbrdr_log_hdl;
+
static DWORD smbrdr_handle_setup(smbrdr_handle_t *, unsigned char,
struct sdb_session *, struct sdb_logon *, struct sdb_netuse *);
static int smbrdr_hdr_setup(smbrdr_handle_t *);
@@ -44,6 +45,14 @@ static int smbrdr_sign_chk(smb_sign_ctx_t *, smb_msgbuf_t *, unsigned char *);
void smbrdr_lock_transport() { nb_lock(); }
void smbrdr_unlock_transport() { nb_unlock(); }
+#pragma init(_smbrdr_init)
+
+void
+_smbrdr_init(void)
+{
+ smbrdr_log_hdl = smb_log_create(SMBRDR_LOG_MAXCNT, SMBRDR_LOG_NAME);
+}
+
/*
* smbrdr_request_init
*
@@ -96,8 +105,8 @@ smbrdr_send(smbrdr_handle_t *srh)
if (smbrdr_sign(&srh->srh_session->sign_ctx, &srh->srh_mbuf) !=
SMBAUTH_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_send[%d]: signing failed",
- srh->srh_cmd);
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_send[%d]: signing failed", srh->srh_cmd);
return (NT_STATUS_INTERNAL_ERROR);
}
@@ -111,6 +120,8 @@ smbrdr_send(smbrdr_handle_t *srh)
* ACCESS_DENIED.
*/
smb_mac_dec_seqnum(&srh->srh_session->sign_ctx);
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_send[%d]: send failed (%d)", srh->srh_cmd, rc);
return (NT_STATUS_UNEXPECTED_NETWORK_ERROR);
}
@@ -153,6 +164,8 @@ smbrdr_rcv(smbrdr_handle_t *srh, int is_first_rsp)
rc = nb_rcv(srh->srh_session->sock, srh->srh_buf, SMBRDR_REQ_BUFSZ, 0);
if (rc < 0) {
smb_mac_inc_seqnum(sign_ctx);
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_rcv[%d]: receive failed (%d)", srh->srh_cmd, rc);
return (NT_STATUS_UNEXPECTED_NETWORK_ERROR);
}
@@ -161,6 +174,9 @@ smbrdr_rcv(smbrdr_handle_t *srh, int is_first_rsp)
status = smbrdr_hdr_process(srh, &smb_hdr);
if (status != NT_STATUS_SUCCESS) {
smb_mac_inc_seqnum(sign_ctx);
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_rcv[%d]: failed (%s)", srh->srh_cmd,
+ xlate_nt_status(status));
return (status);
}
@@ -169,8 +185,8 @@ smbrdr_rcv(smbrdr_handle_t *srh, int is_first_rsp)
if (!smbrdr_sign_chk(sign_ctx,
&srh->srh_mbuf, smb_hdr.extra.extra.security_sig)) {
- syslog(LOG_DEBUG, "smbrdr_rcv[%d]: bad signature",
- srh->srh_cmd);
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_rcv[%d]: bad signature", srh->srh_cmd);
return (NT_STATUS_INVALID_NETWORK_RESPONSE);
}
@@ -212,8 +228,8 @@ smbrdr_exchange(smbrdr_handle_t *srh, smb_hdr_t *smb_hdr, long timeout)
sign_ctx = &srh->srh_session->sign_ctx;
if (smbrdr_sign(sign_ctx, mb) != SMBAUTH_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_exchange[%d]: signing failed",
- srh->srh_cmd);
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_exchange[%d]: signing failed", srh->srh_cmd);
smbrdr_unlock_transport();
return (NT_STATUS_INTERNAL_ERROR);
}
@@ -223,8 +239,8 @@ smbrdr_exchange(smbrdr_handle_t *srh, smb_hdr_t *smb_hdr, long timeout)
srh->srh_buf, SMBRDR_REQ_BUFSZ, timeout);
if (rc < 0) {
- syslog(LOG_DEBUG, "smbrdr_exchange[%d]: failed (%d)",
- srh->srh_cmd, rc);
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_exchange[%d]: failed (%d)", srh->srh_cmd, rc);
if (srh->srh_cmd != SMB_COM_ECHO) {
/*
@@ -244,6 +260,9 @@ smbrdr_exchange(smbrdr_handle_t *srh, smb_hdr_t *smb_hdr, long timeout)
status = smbrdr_hdr_process(srh, smb_hdr);
if (status != NT_STATUS_SUCCESS) {
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_exchange[%d]: failed (%s)", srh->srh_cmd,
+ xlate_nt_status(status));
smb_mac_inc_seqnum(sign_ctx);
smbrdr_unlock_transport();
return (status);
@@ -251,8 +270,8 @@ smbrdr_exchange(smbrdr_handle_t *srh, smb_hdr_t *smb_hdr, long timeout)
/* Signature validation */
if (!smbrdr_sign_chk(sign_ctx, mb, smb_hdr->extra.extra.security_sig)) {
- syslog(LOG_DEBUG, "smbrdr_exchange[%d]: bad signature",
- srh->srh_cmd);
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_exchange[%d]: bad signature", srh->srh_cmd);
smbrdr_unlock_transport();
return (NT_STATUS_INVALID_NETWORK_RESPONSE);
}
@@ -469,7 +488,8 @@ smbrdr_hdr_process(smbrdr_handle_t *srh, smb_hdr_t *smb_hdr)
rc = smb_decode_nt_hdr(&srh->srh_mbuf, smb_hdr);
if (rc < SMB_HEADER_LEN) {
- syslog(LOG_DEBUG, "smbrdr[%d]: invalid header (%d)",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_hdr_process[%d]: invalid header (%d)",
srh->srh_cmd, rc);
return (NT_STATUS_INVALID_NETWORK_RESPONSE);
}
@@ -480,13 +500,15 @@ smbrdr_hdr_process(smbrdr_handle_t *srh, smb_hdr_t *smb_hdr)
break;
default:
- syslog(LOG_DEBUG, "smbrdr[%d]: request failed (%s)",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_hdr_process[%d]: request failed (%s)",
srh->srh_cmd, xlate_nt_status(smb_hdr->status.ntstatus));
return (smb_hdr->status.ntstatus);
}
if (smb_hdr->command != srh->srh_cmd) {
- syslog(LOG_DEBUG, "smbrdr[%d]: reply mismatch (%d)",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_hdr_process[%d]: reply mismatch (%d)",
srh->srh_cmd, smb_hdr->command);
return (NT_STATUS_REPLY_MESSAGE_MISMATCH);
}
@@ -521,7 +543,8 @@ smbrdr_sign(smb_sign_ctx_t *sign_ctx, smb_msgbuf_t *mb)
{
if (sign_ctx->ssc_flags & SMB_SCF_STARTED) {
if (sign_ctx->ssc_seqnum % 2) {
- syslog(LOG_DEBUG, "smbrdr_sign: invalid sequence (%d)",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_sign: invalid sequence (%d)",
sign_ctx->ssc_seqnum);
}
if (smb_mac_sign(sign_ctx, smb_msgbuf_base(mb),
diff --git a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_logon.c b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_logon.c
index 4ceb339063..b4b40499fb 100644
--- a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_logon.c
+++ b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_logon.c
@@ -18,24 +18,22 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <pthread.h>
#include <string.h>
#include <strings.h>
-#include <syslog.h>
#include <synch.h>
-#include <sys/errno.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <smbsrv/wintypes.h>
#include <smbsrv/libsmbrdr.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/smb.h>
#include <smbrdr.h>
@@ -58,7 +56,7 @@ smbrdr_logon(char *domain_controller, char *domain, char *username)
int rc;
if (username == NULL || *username == 0) {
- syslog(LOG_DEBUG, "smbrdr: no username");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_logon: no username");
return (-1);
}
@@ -66,13 +64,15 @@ smbrdr_logon(char *domain_controller, char *domain, char *username)
if (smb_strcasecmp(username, SMBRDR_ANON_USER, 0) != 0) {
smb_ipc_get_passwd(pwd_hash, SMBAUTH_HASH_SZ);
if (*pwd_hash == 0) {
- syslog(LOG_DEBUG, "smbrdr: no password");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_logon: no password");
return (-1);
}
}
if (smbrdr_negotiate(domain_controller, domain) != 0) {
- syslog(LOG_DEBUG, "smbrdr: negotiate failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_logon: negotiate failed");
return (-1);
}
@@ -138,7 +138,8 @@ smbrdr_authenticate(char *server, char *username, uint8_t *pwd)
session = smbrdr_session_lock(server, SDB_SLCK_WRITE);
if (session == NULL) {
- syslog(LOG_DEBUG, "smbrdr_authenticate: %s: no session with %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_authenticate: %s: no session with %s",
username, server);
return (-1);
}
@@ -160,7 +161,8 @@ smbrdr_authenticate(char *server, char *username, uint8_t *pwd)
logon = smbrdr_logon_init(session, username, pwd);
if (logon == NULL) {
- syslog(LOG_DEBUG, "smbrdr_authenticate: %s: %m", username);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_authenticate: %s: %s", username, strerror(errno));
smbrdr_session_unlock(session);
return (-1);
}
@@ -210,6 +212,7 @@ smbrdr_session_setupx(struct sdb_logon *logon)
size_t (*strlen_fn)(const char *s);
DWORD status;
int rc;
+ int64_t lmlevel;
/*
* Paranoia check - we should never get this
@@ -228,7 +231,7 @@ smbrdr_session_setupx(struct sdb_logon *logon)
}
if (smbrdr_sign_init(session, logon) < 0) {
- syslog(LOG_DEBUG,
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
"smbrdr_session_setupx: smbrdr_sign_init failed");
return (-1);
}
@@ -238,7 +241,7 @@ smbrdr_session_setupx(struct sdb_logon *logon)
if (status != NT_STATUS_SUCCESS) {
smbrdr_sign_fini(session);
- syslog(LOG_DEBUG, "smbrdr_session_setupx: %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_session_setupx: %s",
xlate_nt_status(status));
return (-1);
}
@@ -309,16 +312,31 @@ smbrdr_session_setupx(struct sdb_logon *logon)
}
if (rc <= 0) {
- syslog(LOG_DEBUG, "smbrdr_session_setupx: encode failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_session_setupx: encode failed");
smbrdr_handle_free(&srh);
smbrdr_sign_fini(session);
return (-1);
}
status = smbrdr_exchange(&srh, &smb_hdr, 0);
+
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_session_setupx: %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_session_setupx: %s",
xlate_nt_status(status));
+
+ if (status == NT_STATUS_INVALID_PARAMETER) {
+ rc = smb_config_getnum(SMB_CI_LM_LEVEL, &lmlevel);
+ if (rc != SMBD_SMF_OK || lmlevel > 2)
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "If the DC is running Windows Server 2008: "
+ "apply hotfix KB 957441");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "If the DC is running Windows Server 2008 "
+ "R2: do not apply the hotfix but update "
+ "the registry as described in KB 957441");
+ }
+
smbrdr_handle_free(&srh);
smbrdr_sign_fini(session);
return (-1);
@@ -355,7 +373,8 @@ smbrdr_session_setupx(struct sdb_logon *logon)
}
if (rc <= 0) {
- syslog(LOG_DEBUG, "smbrdr_session_setupx: decode failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_session_setupx: decode failed");
smbrdr_handle_free(&srh);
smbrdr_sign_fini(session);
return (-1);
@@ -421,8 +440,8 @@ smbrdr_logoffx(struct sdb_logon *logon)
if (status != NT_STATUS_SUCCESS) {
logon->state = SDB_LSTATE_SETUP;
- syslog(LOG_DEBUG, "smbrdr_logoffx: %s: %s", logon->username,
- xlate_nt_status(status));
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_logoffx: %s: %s",
+ logon->username, xlate_nt_status(status));
return (-1);
}
@@ -430,15 +449,15 @@ smbrdr_logoffx(struct sdb_logon *logon)
if (rc < 0) {
logon->state = SDB_LSTATE_SETUP;
smbrdr_handle_free(&srh);
- syslog(LOG_DEBUG, "smbrdr_logoffx: %s: encode failed",
- logon->username);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_logoffx: %s: encode failed", logon->username);
return (rc);
}
status = smbrdr_exchange(&srh, &smb_hdr, 0);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_logoffx: %s: %s", logon->username,
- xlate_nt_status(status));
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_logoffx: %s: %s",
+ logon->username, xlate_nt_status(status));
rc = -1;
} else {
rc = 0;
diff --git a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netbios.c b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netbios.c
index 5f327205e4..dc8122b732 100644
--- a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netbios.c
+++ b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netbios.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -103,10 +102,8 @@ void
nb_close(int fd)
{
(void) mutex_lock(&nb_mutex);
- if (fd > 0) {
+ if (fd > 0)
(void) close(fd);
- (void) printf("[%d] socket (%d) closed\n", pthread_self(), fd);
- }
(void) mutex_unlock(&nb_mutex);
}
diff --git a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netuse.c b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netuse.c
index e33dfcbc7f..b2ce3d1ec8 100644
--- a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netuse.c
+++ b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_netuse.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -32,13 +32,11 @@
#include <sys/errno.h>
#include <string.h>
#include <strings.h>
-#include <syslog.h>
#include <synch.h>
#include <pthread.h>
#include <smbsrv/libsmbrdr.h>
#include <smbrdr.h>
-#include <smbsrv/ntstatus.h>
/*
@@ -94,14 +92,16 @@ smbrdr_tree_connect(char *hostname, char *domain, char *username,
session = smbrdr_session_lock(hostname, SDB_SLCK_READ);
if (session == NULL) {
- syslog(LOG_DEBUG, "smbrdr_tree_connect: no session for %s@%s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_tree_connect: no session for %s@%s",
username, hostname);
return (NT_STATUS_INTERNAL_ERROR);
}
if ((netuse = smbrdr_netuse_alloc(session, sharename)) == 0) {
- syslog(LOG_DEBUG, "smbrdr_tree_connect: init failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_tree_connect: init failed");
smbrdr_session_unlock(session);
return (NT_STATUS_INTERNAL_ERROR);
}
@@ -115,7 +115,8 @@ smbrdr_tree_connect(char *hostname, char *domain, char *username,
if ((path = (char *)malloc(path_len)) == 0) {
smbrdr_netuse_free(netuse);
smbrdr_session_unlock(session);
- syslog(LOG_DEBUG, "smbrdr_tree_connect: %s", strerror(ENOMEM));
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_tree_connect: %s",
+ strerror(ENOMEM));
return (NT_STATUS_NO_MEMORY);
}
@@ -130,7 +131,8 @@ smbrdr_tree_connect(char *hostname, char *domain, char *username,
!= NT_STATUS_SUCCESS) {
smbrdr_netuse_free(netuse);
smbrdr_session_unlock(session);
- syslog(LOG_DEBUG, "smbrdr_tree_connect: %s failed", path);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_tree_connect: %s failed", path);
free(path);
return (status);
}
@@ -173,7 +175,7 @@ smbrdr_tree_connectx(struct sdb_session *session, struct sdb_netuse *netuse,
session, &session->logon, 0);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_tree_connectx: %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_tree_connectx: %s",
xlate_nt_status(status));
return (status);
}
@@ -206,14 +208,15 @@ smbrdr_tree_connectx(struct sdb_session *session, struct sdb_netuse *netuse,
service); /* Service */
if (rc <= 0) {
- syslog(LOG_DEBUG, "smbrdr_tree_connectx: encode failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_tree_connectx: encode failed");
smbrdr_handle_free(&srh);
return (NT_STATUS_INTERNAL_ERROR);
}
status = smbrdr_exchange(&srh, &smb_hdr, 0);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_tree_connectx: %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_tree_connectx: %s",
xlate_nt_status(status));
smbrdr_handle_free(&srh);
return (status);
@@ -303,7 +306,8 @@ smbrdr_tdcon(struct sdb_netuse *netuse)
session, &session->logon, netuse);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_tdcon: %s", xlate_nt_status(status));
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_tdcon: %s",
+ xlate_nt_status(status));
/* should we clear here? */
smbrdr_netuse_clear(netuse);
return (-1);
@@ -311,7 +315,8 @@ smbrdr_tdcon(struct sdb_netuse *netuse)
rc = smb_msgbuf_encode(&srh.srh_mbuf, "bw.", 0, 0);
if (rc < 0) {
- syslog(LOG_DEBUG, "smbrdr_tdcon: encode failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_tdcon: encode failed");
smbrdr_handle_free(&srh);
/* should we clear here? */
smbrdr_netuse_clear(netuse);
@@ -320,7 +325,8 @@ smbrdr_tdcon(struct sdb_netuse *netuse)
status = smbrdr_exchange(&srh, &smb_hdr, 0);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_tdcon: %s", xlate_nt_status(status));
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_tdcon: %s",
+ xlate_nt_status(status));
rc = -1;
} else {
rc = 0;
@@ -370,7 +376,7 @@ smbrdr_netuse_alloc(struct sdb_session *session, char *sharename)
(void) mutex_unlock(&netuse->mtx);
}
- syslog(LOG_DEBUG, "smbrdr_netuse_alloc: table full");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_netuse_alloc: table full");
return (0);
}
@@ -432,7 +438,8 @@ smbrdr_netuse_get(int tid)
(void) mutex_unlock(&netuse->mtx);
}
- syslog(LOG_DEBUG, "smbrdr_netuse_get: %d: no such TID", tid);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_netuse_get: %d: no such TID",
+ tid);
return (0);
}
@@ -449,10 +456,12 @@ smbrdr_dump_netuse()
netuse = &netuse_table[i];
(void) mutex_lock(&netuse->mtx);
if (netuse->session) {
- syslog(LOG_DEBUG, "tree[%d]: %s (tid=%d)", i,
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_dump_netuse: tree[%d]: %s (tid=%d)", i,
netuse->share, netuse->tid);
- syslog(LOG_DEBUG, "tree[%d]: session(%d), user(%d)",
- i, netuse->session->sock, netuse->uid);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_dump_netuse: tree[%d]: session(%d), "
+ "user(%d)", i, netuse->session->sock, netuse->uid);
}
(void) mutex_unlock(&netuse->mtx);
}
diff --git a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_read_andx.c b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_read_andx.c
index e152e5b860..7028d7fccd 100644
--- a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_read_andx.c
+++ b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_read_andx.c
@@ -18,21 +18,19 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* SMB ReadX functions.
*/
-#include <syslog.h>
#include <strings.h>
#include <smbsrv/libsmbrdr.h>
#include <smbsrv/netbios.h>
-#include <smbsrv/ntstatus.h>
#include <smbrdr.h>
#define SMBRDR_READX_RSP_OVERHEAD \
@@ -68,7 +66,8 @@ smbrdr_readx(int fid, char *in_buf, int in_len)
netuse->session, &netuse->session->logon, netuse);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_readx: %s", xlate_nt_status(status));
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_readx: %s",
+ xlate_nt_status(status));
smbrdr_ofile_put(ofile);
return (-1);
}
@@ -99,7 +98,7 @@ smbrdr_readx(int fid, char *in_buf, int in_len)
0); /* Count of data bytes = 0 */
if (rc < 0) {
- syslog(LOG_DEBUG, "smbrdr_readx: prep failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_readx: prep failed");
smbrdr_handle_free(&srh);
smbrdr_ofile_put(ofile);
return (rc);
@@ -112,14 +111,15 @@ smbrdr_readx(int fid, char *in_buf, int in_len)
smbrdr_unlock_transport();
smbrdr_handle_free(&srh);
smbrdr_ofile_put(ofile);
- syslog(LOG_DEBUG, "smbrdr_readx: send failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_readx: send failed");
return (-1);
}
status = smbrdr_rcv(&srh, 1);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_readx: nb_rcv failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_readx: nb_rcv failed");
smbrdr_unlock_transport();
smbrdr_handle_free(&srh);
smbrdr_ofile_put(ofile);
@@ -129,7 +129,8 @@ smbrdr_readx(int fid, char *in_buf, int in_len)
rc = smbrdr_decode_readx_rsp(mb, in_buf, in_len, &rsp);
if (rc < 0) {
- syslog(LOG_DEBUG, "smbrdr_readx: decode failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_readx: decode failed");
smbrdr_unlock_transport();
smbrdr_handle_free(&srh);
smbrdr_ofile_put(ofile);
diff --git a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_rpcpipe.c b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_rpcpipe.c
index a549827476..f87fb2496b 100644
--- a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_rpcpipe.c
+++ b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_rpcpipe.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -32,11 +32,9 @@
#include <pthread.h>
#include <string.h>
#include <strings.h>
-#include <syslog.h>
#include <synch.h>
#include <smbsrv/libsmbrdr.h>
-#include <smbsrv/ntstatus.h>
#include <smbrdr.h>
static int smbrdr_close(struct sdb_ofile *);
@@ -94,7 +92,8 @@ smbrdr_open_pipe(char *hostname, char *domain, char *username, char *pipename)
continue;
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_open: %s %s %s %s %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_open_pipe: %s %s %s %s %s",
hostname, domain, username, pipename,
xlate_nt_status(status));
return (-1);
@@ -106,14 +105,16 @@ smbrdr_open_pipe(char *hostname, char *domain, char *username, char *pipename)
netuse = smbrdr_netuse_get(tid);
if (netuse == NULL) {
- syslog(LOG_DEBUG, "smbrdr_open: %s %s %s %s %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_open_pipe: %s %s %s %s %s",
hostname, domain, username, pipename,
xlate_nt_status(NT_STATUS_CONNECTION_INVALID));
return (-1);
}
if ((ofile = smbrdr_ofile_alloc(netuse, pipename)) == 0) {
- syslog(LOG_DEBUG, "smbrdr_open: %s %s %s %s %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_open_pipe: %s %s %s %s %s",
hostname, domain, username, pipename,
xlate_nt_status(NT_STATUS_INSUFFICIENT_RESOURCES));
(void) smbrdr_tdcon(netuse);
@@ -154,7 +155,7 @@ smbrdr_open_pipe(char *hostname, char *domain, char *username, char *pipename)
}
}
- syslog(LOG_DEBUG, "smbrdr_open: %s %s %s %s %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_open_pipe: %s %s %s %s %s",
hostname, domain, username, pipename,
xlate_nt_status(status));
smbrdr_ofile_free(ofile);
@@ -291,10 +292,12 @@ smbrdr_dump_ofiles()
netuse = ofile->netuse;
if (netuse) {
- syslog(LOG_DEBUG, "file[%d]: %s (fid=%d)", i,
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_dump_ofiles: file[%d]: %s (fid=%d)", i,
ofile->path, ofile->fid);
- syslog(LOG_DEBUG,
- "file[%d]: session(%d), user(%d), tree(%d)",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_dump_ofiles: file[%d]: session(%d), "
+ "user(%d), tree(%d)",
i, netuse->session->sock, netuse->uid,
netuse->tid);
}
@@ -361,7 +364,8 @@ smbrdr_close(struct sdb_ofile *ofile)
status = smbrdr_exchange(&srh, &smb_hdr, 0);
if (status != NT_STATUS_SUCCESS)
- syslog(LOG_DEBUG, "smbrdr_close: %s", xlate_nt_status(status));
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_close: %s",
+ xlate_nt_status(status));
smbrdr_handle_free(&srh);
smbrdr_ofile_clear(ofile);
@@ -460,8 +464,8 @@ smbrdr_ntcreatex(struct sdb_ofile *ofile)
sess, logon, netuse);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_ntcreatex: %s %s", path,
- xlate_nt_status(status));
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_ntcreatex: %s %s",
+ path, xlate_nt_status(status));
return (NT_STATUS_INVALID_PARAMETER_1);
}
@@ -492,27 +496,31 @@ smbrdr_ntcreatex(struct sdb_ofile *ofile)
if (rc <= 0) {
smbrdr_handle_free(&srh);
- syslog(LOG_DEBUG, "smbrdr_ntcreatex: %s encode failed", path);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_ntcreatex: %s encode failed", path);
return (NT_STATUS_INVALID_PARAMETER_1);
}
status = smbrdr_exchange(&srh, &smb_hdr, 0);
if (status != NT_STATUS_SUCCESS) {
smbrdr_handle_free(&srh);
- syslog(LOG_DEBUG, "smbrdr_ntcreatex: %s exchange failed", path);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_ntcreatex: %s exchange failed", path);
return (NT_SC_VALUE(status));
}
rc = smb_msgbuf_decode(mb, "(wct). (andx)4. (opl)1. (fid)w", &fid);
if (rc <= 0) {
smbrdr_handle_free(&srh);
- syslog(LOG_DEBUG, "smbrdr_ntcreatex: %s decode failed", path);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_ntcreatex: %s decode failed", path);
return (NT_STATUS_INVALID_PARAMETER_2);
}
ofile->fid = fid;
ofile->state = SDB_FSTATE_OPEN;
- syslog(LOG_DEBUG, "smbrdr_ntcreatex: %s fid=%d", path, ofile->fid);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_ntcreatex: %s fid=%d",
+ path, ofile->fid);
smbrdr_handle_free(&srh);
return (NT_STATUS_SUCCESS);
}
diff --git a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_session.c b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_session.c
index 96355b3e95..87e256f45a 100644
--- a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_session.c
+++ b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_session.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -29,7 +28,6 @@
*/
#include <unistd.h>
-#include <syslog.h>
#include <synch.h>
#include <string.h>
#include <strings.h>
@@ -136,7 +134,8 @@ done:
(void) mutex_unlock(&smbrdr_screate_mtx);
if (rc != 0)
- syslog(LOG_DEBUG, "smbrdr_negotiate: cannot access domain");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_negotiate: cannot access domain");
return (rc);
}
@@ -163,7 +162,8 @@ smbrdr_session_connect(char *domain_controller, char *domain)
*/
if ((session = smbrdr_session_init(domain_controller, domain))
== NULL) {
- syslog(LOG_DEBUG, "smbrdr_session_init failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_session_init failed");
return (-1);
}
@@ -176,7 +176,8 @@ smbrdr_session_connect(char *domain_controller, char *domain)
if (rc < 0) {
smbrdr_session_clear(session);
smbrdr_session_unlock(session);
- syslog(LOG_DEBUG, "smbrdr: connect failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_session_connect: connect failed");
return (-1);
}
@@ -184,7 +185,8 @@ smbrdr_session_connect(char *domain_controller, char *domain)
(void) close(session->sock);
smbrdr_session_clear(session);
smbrdr_session_unlock(session);
- syslog(LOG_DEBUG, "smbrdr: negotiate failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_session_connect: negotiate failed");
return (-1);
}
@@ -215,7 +217,9 @@ smbrdr_trnsprt_connect(struct sdb_session *sess, uint16_t port)
char ipstr[INET6_ADDRSTRLEN];
if ((sock = socket(sess->srv_ipaddr.a_family, SOCK_STREAM, 0)) <= 0) {
- syslog(LOG_DEBUG, "smbrdr: socket failed: %s", strerror(errno));
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_trnsprt_connect: socket failed: %s",
+ strerror(errno));
return (-1);
}
if (sess->srv_ipaddr.a_family == AF_INET) {
@@ -236,7 +240,8 @@ smbrdr_trnsprt_connect(struct sdb_session *sess, uint16_t port)
}
if (rc < 0) {
- syslog(LOG_DEBUG, "smbrdr: connect failed: %s",
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_trnsprt_connect: connect failed: %s",
strerror(errno));
if (sock != 0)
(void) close(sock);
@@ -248,7 +253,8 @@ smbrdr_trnsprt_connect(struct sdb_session *sess, uint16_t port)
rc = ucstooem(server_name, unicode_server_name, SMB_PI_MAX_DOMAIN,
OEM_CPG_850);
if (rc == 0) {
- syslog(LOG_DEBUG, "smbrdr: unicode conversion failed");
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_trnsprt_connect: unicode conversion failed");
if (sock != 0)
(void) close(sock);
return (-1);
@@ -262,7 +268,8 @@ smbrdr_trnsprt_connect(struct sdb_session *sess, uint16_t port)
*/
if (port == IPPORT_NETBIOS_SSN) {
if (smb_getnetbiosname(hostname, MAXHOSTNAMELEN) != 0) {
- syslog(LOG_DEBUG, "smbrdr: no hostname");
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_trnsprt_connect: no hostname");
if (sock != 0)
(void) close(sock);
return (-1);
@@ -272,9 +279,9 @@ smbrdr_trnsprt_connect(struct sdb_session *sess, uint16_t port)
server_name, sess->scope, hostname, sess->scope);
if (rc != 0) {
- syslog(LOG_DEBUG,
- "smbrdr: NBT session request to %s failed %d",
- server_name, rc);
+ smb_log(smbrdr_log_hdl, LOG_ERR,
+ "smbrdr_trnsprt_connect: NBT session request "
+ "to %s failed %d", server_name, rc);
if (sock != 0)
(void) close(sock);
return (-1);
@@ -283,7 +290,8 @@ smbrdr_trnsprt_connect(struct sdb_session *sess, uint16_t port)
sess->sock = sock;
sess->port = port;
- syslog(LOG_DEBUG, "smbrdr: connected on port %d", port);
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_trnsprt_connect: connected on port %d", port);
sess->state = SDB_SSTATE_CONNECTED;
return (0);
}
@@ -326,7 +334,7 @@ smbrdr_smb_negotiate(struct sdb_session *sess)
status = smbrdr_exchange(&srh, &smb_hdr, 0);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr: negotiate: %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_smb_negotiate: %s",
xlate_nt_status(status));
smbrdr_handle_free(&srh);
return (-1);
@@ -360,7 +368,8 @@ smbrdr_smb_negotiate(struct sdb_session *sess)
if ((sess->secmode & NEGOTIATE_SECURITY_SIGNATURES_REQUIRED) &&
(sess->secmode & NEGOTIATE_SECURITY_SIGNATURES_ENABLED)) {
sess->sign_ctx.ssc_flags |= SMB_SCF_REQUIRED;
- syslog(LOG_DEBUG, "smbrdr: %s: signing required",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_smb_negotiate: %s: signing required",
sess->srv_name);
}
@@ -390,7 +399,8 @@ smbrdr_session_init(char *domain_controller, char *domain)
return (NULL);
if ((h = smb_gethostbyname(domain_controller, &rc)) == NULL) {
- syslog(LOG_DEBUG, "smbrdr: failed to resolve %s to IP (%d)",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_session_init: failed to resolve %s to IP (%d)",
domain_controller, rc);
return (NULL);
}
@@ -442,7 +452,8 @@ smbrdr_session_init(char *domain_controller, char *domain)
(void) rw_unlock(&session->rwl);
}
- syslog(LOG_DEBUG, "smbrdr: no session available");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_session_init: no session available");
return (NULL);
}
@@ -561,17 +572,23 @@ smbrdr_dump_sessions(void)
if (session->state != SDB_SSTATE_START) {
(void) smb_inet_ntop(&session->srv_ipaddr, ipstr,
SMB_IPSTRLEN(session->srv_ipaddr.a_family));
- syslog(LOG_DEBUG, "session[%d]: state=%d",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_dump_sessions: session[%d]: state=%d",
i, session->state);
- syslog(LOG_DEBUG, "session[%d]: %s %s (%s)", i,
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_dump_sessions: session[%d]: %s %s (%s)", i,
session->domain, session->srv_name, ipstr);
- syslog(LOG_DEBUG, "session[%d]: %s %s (sock=%d)", i,
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_dump_sessions: session[%d]: %s %s "
+ "(sock=%d)", i,
session->native_os, session->native_lanman,
session->sock);
logon = &session->logon;
if (logon->type != SDB_LOGON_NONE)
- syslog(LOG_DEBUG, "logon[%d]: %s (uid=%d)",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_dump_sessions: logon[%d]: %s "
+ "(uid=%d)",
i, logon->username, logon->uid);
}
(void) rw_unlock(&session->rwl);
diff --git a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_transact.c b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_transact.c
index d5e46a953d..dd7dfa38ad 100644
--- a/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_transact.c
+++ b/usr/src/lib/smbsrv/libsmbrdr/common/smbrdr_transact.c
@@ -18,20 +18,18 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* SMB transaction functions.
*/
-#include <syslog.h>
#include <strings.h>
#include <smbsrv/libsmbrdr.h>
-#include <smbsrv/ntstatus.h>
#include <smbsrv/smb.h>
#include <smbrdr.h>
@@ -82,7 +80,7 @@ smbrdr_transact(int fid, char *out_buf, int out_len, char *in_buf, int in_len)
session, logon, netuse);
if (status != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_transact: %s",
+ smb_log(smbrdr_log_hdl, LOG_DEBUG, "smbrdr_transact: %s",
xlate_nt_status(status));
smbrdr_ofile_put(ofile);
return (-1);
@@ -93,7 +91,8 @@ smbrdr_transact(int fid, char *out_buf, int out_len, char *in_buf, int in_len)
rc = prep_smb_transact(mb, ofile->fid, out_buf, out_len, in_len,
session->remote_caps & CAP_UNICODE);
if (rc < 0) {
- syslog(LOG_DEBUG, "smbrdr_transact: prep failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_transact: prep failed");
smbrdr_handle_free(&srh);
smbrdr_ofile_put(ofile);
return (rc);
@@ -106,7 +105,8 @@ smbrdr_transact(int fid, char *out_buf, int out_len, char *in_buf, int in_len)
smbrdr_unlock_transport();
smbrdr_handle_free(&srh);
smbrdr_ofile_put(ofile);
- syslog(LOG_DEBUG, "smbrdr_transact: send failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_transact: send failed");
return (-1);
}
@@ -116,14 +116,15 @@ smbrdr_transact(int fid, char *out_buf, int out_len, char *in_buf, int in_len)
do {
if (smbrdr_rcv(&srh, first_rsp) != NT_STATUS_SUCCESS) {
- syslog(LOG_DEBUG, "smbrdr_transact: nb_rcv failed");
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
+ "smbrdr_transact: nb_rcv failed");
rc = -1;
break;
}
rc = decode_smb_transact(mb, in_buf, cur_inlen, &rsp);
if (rc < 0 || rsp.TotalDataCount > in_len) {
- syslog(LOG_DEBUG,
+ smb_log(smbrdr_log_hdl, LOG_DEBUG,
"smbrdr_transact: decode failed");
rc = -1;
break;
diff --git a/usr/src/uts/Makefile b/usr/src/uts/Makefile
index febe148c93..baab403295 100644
--- a/usr/src/uts/Makefile
+++ b/usr/src/uts/Makefile
@@ -19,8 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
#
# include global definitions
include ../Makefile.master
@@ -150,6 +149,7 @@ COMMON_HDRDIRS= common/avs \
common/rpc \
common/rpcsvc \
common/sharefs \
+ common/smb \
common/smbsrv \
common/sys \
common/vm
diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files
index 6f5b7809fc..a279a3757e 100644
--- a/usr/src/uts/common/Makefile.files
+++ b/usr/src/uts/common/Makefile.files
@@ -1178,7 +1178,6 @@ SMBSRV_SHARED_OBJS += \
smb_token.o \
smb_token_xdr.o \
smb_sid.o \
- smb_status_xlat.o \
smb_native.o \
smb_netbios_util.o
@@ -1248,8 +1247,7 @@ SMBSRV_OBJS += $(SMBSRV_SHARED_OBJS) \
smb_vops.o \
smb_vss.o \
smb_write.o \
- smb_write_raw.o \
- smb_xlate.o
+ smb_write_raw.o
PCFS_OBJS += pc_alloc.o pc_dir.o pc_node.o pc_subr.o \
pc_vfsops.o pc_vnops.o
diff --git a/usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.c b/usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.c
index 0ce241b0ce..997b7318dd 100644
--- a/usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.c
+++ b/usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.c
@@ -33,8 +33,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/param.h>
@@ -644,13 +643,6 @@ smb_t2_done(struct smb_t2rq *t2p)
kmem_free(t2p, sizeof (*t2p));
}
-u_int32_t
-smb_t2_err(struct smb_t2rq *t2p)
-{
- /* mask off "severity" and the "component" bit */
- return (t2p->t2_sr_error & ~(0xe0000000));
-}
-
void
smb_nt_done(struct smb_ntrq *ntp)
{
diff --git a/usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.h b/usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.h
index 1aeefcedd7..0184022a65 100644
--- a/usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.h
+++ b/usr/src/uts/common/fs/smbclnt/netsmb/smb_rq.h
@@ -33,8 +33,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _NETSMB_SMB_RQ_H_
@@ -201,7 +200,6 @@ int smb_t2_init(struct smb_t2rq *rqp, struct smb_connobj *layer,
ushort_t *setup, int setupcnt, struct smb_cred *scred);
void smb_t2_done(struct smb_t2rq *t2p);
int smb_t2_request(struct smb_t2rq *t2p);
-uint32_t smb_t2_err(struct smb_t2rq *t2p);
int smb_nt_alloc(struct smb_connobj *layer, ushort_t fn,
struct smb_cred *scred, struct smb_ntrq **rqpp);
diff --git a/usr/src/uts/common/fs/smbclnt/netsmb/smb_subr.h b/usr/src/uts/common/fs/smbclnt/netsmb/smb_subr.h
index 675fa62b8d..19cf466391 100644
--- a/usr/src/uts/common/fs/smbclnt/netsmb/smb_subr.h
+++ b/usr/src/uts/common/fs/smbclnt/netsmb/smb_subr.h
@@ -33,8 +33,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _NETSMB_SMB_SUBR_H_
@@ -108,7 +107,7 @@ int smb_lmresponse(const uchar_t *hash, const uchar_t *C8, uchar_t *RN);
int smb_ntlmv2response(const uchar_t *hash, const uchar_t *C8,
const uchar_t *blob, size_t bloblen, uchar_t **RN, size_t *RNlen);
int smb_maperror(int eclass, int eno);
-uint32_t smb_maperr32(uint32_t eno);
+int smb_maperr32(uint32_t eno);
int smb_put_dmem(struct mbchain *mbp, struct smb_vc *vcp,
const char *src, int len, int caseopt, int *lenp);
int smb_put_dstring(struct mbchain *mbp, struct smb_vc *vcp,
diff --git a/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c b/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c
index bfacaaa55d..a83f027b50 100644
--- a/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c
+++ b/usr/src/uts/common/fs/smbclnt/netsmb/smb_subrs.c
@@ -33,8 +33,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/param.h>
@@ -192,10 +191,12 @@ m_dumpm(mblk_t *m)
#define ETIME ETIMEDOUT
#endif
-static const struct {
+typedef struct nt2errno {
unsigned int nterr;
- unsigned int errno;
-} nt2errno[] = {
+ int errno;
+} nt2errno_t;
+
+static const nt2errno_t nt2errno[] = {
/* Alphabetical order. */
{NT_STATUS_ACCESS_DENIED, EACCES},
{NT_STATUS_ACCESS_VIOLATION, EACCES},
@@ -231,8 +232,10 @@ static const struct {
{NT_STATUS_INVALID_HANDLE, EBADF},
{NT_STATUS_INVALID_LEVEL, ENOTSUP},
{NT_STATUS_INVALID_LOGON_HOURS, EACCES},
+ {NT_STATUS_INVALID_OWNER, EINVAL},
{NT_STATUS_INVALID_PARAMETER, EINVAL},
{NT_STATUS_INVALID_PIPE_STATE, EPIPE},
+ {NT_STATUS_INVALID_PRIMARY_GROUP, EINVAL},
{NT_STATUS_INVALID_WORKSTATION, EACCES},
{NT_STATUS_IN_PAGE_ERROR, EFAULT},
{NT_STATUS_IO_TIMEOUT, ETIMEDOUT},
@@ -296,104 +299,109 @@ static const struct {
{0, 0}
};
-static const struct {
+/*
+ * Table for converting NT STATUS values to DOS class/code.
+ * Rows ordered by integer value of last column (NT STATUS)
+ */
+typedef struct nt2doserr {
unsigned short dclass;
unsigned short derr;
unsigned int nterr;
-} nt2doserr[] = {
+} nt2doserr_t;
+
+static const nt2doserr_t nt2doserr[] = {
{ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL},
{ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_INFO_CLASS},
- {ERRDOS, ERRbadlength, NT_STATUS_INFO_LENGTH_MISMATCH},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_INFO_CLASS},
+ {ERRDOS, ERROR_BAD_LENGTH, 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, ERRinvalidparam, NT_STATUS_INVALID_CID},
+ {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_BAD_INITIAL_PC},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_CID},
{ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER},
+ {ERRDOS, ERROR_INVALID_PARAMETER, 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, ERRhandleeof, NT_STATUS_END_OF_FILE},
- {ERRDOS, ERRwrongdisk, NT_STATUS_WRONG_VOLUME},
- {ERRDOS, ERRnotready, NT_STATUS_NO_MEDIA_IN_DEVICE},
+ {ERRDOS, ERROR_HANDLE_EOF, NT_STATUS_END_OF_FILE},
+ {ERRDOS, ERROR_WRONG_DISK, NT_STATUS_WRONG_VOLUME},
+ {ERRDOS, ERROR_NOT_READY, NT_STATUS_NO_MEDIA_IN_DEVICE},
{ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA},
- {ERRDOS, ERRsectornotfound, NT_STATUS_NONEXISTENT_SECTOR},
+ {ERRDOS, ERROR_SECTOR_NOT_FOUND, NT_STATUS_NONEXISTENT_SECTOR},
{ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY},
- {ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES},
- {ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW},
- {ERRDOS, ERRinvalidparam, NT_STATUS_UNABLE_TO_FREE_VM},
- {ERRDOS, ERRinvalidparam, NT_STATUS_UNABLE_TO_DELETE_SECTION},
- {ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE},
+ {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_CONFLICTING_ADDRESSES},
+ {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_NOT_MAPPED_VIEW},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_UNABLE_TO_FREE_VM},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_UNABLE_TO_DELETE_SECTION},
+ {ERRDOS, NERR_InvalidAPI, 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, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_FILE_FOR_SECTION},
{ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED},
{ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED},
- {ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL},
+ {ERRDOS, ERROR_BUFFER_OVERFLOW, NT_STATUS_BUFFER_TOO_SMALL},
{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},
+ {ERRDOS, ERROR_NOT_LOCKED, NT_STATUS_NOT_LOCKED},
{ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR},
- {ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM},
- {ERRDOS, 487, NT_STATUS_NOT_COMMITTED},
+ {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_UNABLE_TO_DECOMMIT_VM},
+ {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_NOT_COMMITTED},
{ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES},
{ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_MIX},
+ {ERRDOS, ERROR_INVALID_PARAMETER, 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, ERROR_INVALID_NAME, 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, ERROR_ALREADY_EXISTS, NT_STATUS_OBJECT_NAME_COLLISION},
{ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED},
{ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED},
- {ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID},
+ {ERRDOS, ERROR_BAD_PATHNAME, NT_STATUS_OBJECT_PATH_INVALID},
{ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND},
- {ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD},
+ {ERRDOS, ERROR_BAD_PATHNAME, NT_STATUS_OBJECT_PATH_SYNTAX_BAD},
{ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN},
{ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR},
- {ERRDOS, ERRcrc, NT_STATUS_DATA_ERROR},
- {ERRDOS, ERRcrc, NT_STATUS_CRC_ERROR},
+ {ERRDOS, ERROR_CRC, NT_STATUS_DATA_ERROR},
+ {ERRDOS, ERROR_CRC, 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},
+ {ERRDOS, ERROR_SHARING_VIOLATION, NT_STATUS_SHARING_VIOLATION},
{ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PAGE_PROTECTION},
- {ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED},
- {ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
- {ERRDOS, ERRinvalidparam, NT_STATUS_PORT_ALREADY_SET},
- {ERRDOS, ERRinvalidparam, NT_STATUS_SECTION_NOT_IMAGE},
- {ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PAGE_PROTECTION},
+ {ERRDOS, ERROR_NOT_OWNER, NT_STATUS_MUTANT_NOT_OWNED},
+ {ERRDOS, ERROR_TOO_MANY_POSTS, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_PORT_ALREADY_SET},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_SECTION_NOT_IMAGE},
+ {ERRDOS, ERROR_SIGNAL_REFUSED, NT_STATUS_SUSPEND_COUNT_EXCEEDED},
{ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING},
- {ERRDOS, ERRinvalidparam, NT_STATUS_BAD_WORKING_SET_LIMIT},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INCOMPATIBLE_FILE_MAP},
- {ERRDOS, ERRinvalidparam, NT_STATUS_SECTION_PROTECTION},
- {ERRDOS, 282, NT_STATUS_EAS_NOT_SUPPORTED},
- {ERRDOS, 255, NT_STATUS_EA_TOO_LARGE},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_BAD_WORKING_SET_LIMIT},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INCOMPATIBLE_FILE_MAP},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_SECTION_PROTECTION},
+ {ERRDOS, ERROR_EAS_NOT_SUPPORTED, NT_STATUS_EAS_NOT_SUPPORTED},
+ {ERRDOS, ERROR_EA_LIST_INCONSISTENT, 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, ERROR_LOCK_VIOLATION, NT_STATUS_FILE_LOCK_CONFLICT},
+ {ERRDOS, ERROR_LOCK_VIOLATION, NT_STATUS_LOCK_NOT_GRANTED},
{ERRDOS, ERRnoaccess, NT_STATUS_DELETE_PENDING},
- {ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED},
+ {ERRDOS, ERROR_NOT_SUPPORTED, 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},
+ {ERRDOS, NERR_LogonServerNotFound, 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},
@@ -410,10 +418,10 @@ static const struct {
{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},
+ {ERRSRV, NERR_InvalidLogonHours, NT_STATUS_INVALID_LOGON_HOURS},
+ {ERRSRV, NERR_InvalidWorkstation, NT_STATUS_INVALID_WORKSTATION},
+ {ERRSRV, NERR_PasswordExpired, NT_STATUS_PASSWORD_EXPIRED},
+ {ERRSRV, NERR_AccountExpired, NT_STATUS_ACCOUNT_DISABLED},
{ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED},
{ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED},
{ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED},
@@ -421,21 +429,21 @@ static const struct {
{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},
+ {ERRDOS, ERROR_PROC_NOT_FOUND, NT_STATUS_PROCEDURE_NOT_FOUND},
+ {ERRDOS, ERROR_BAD_EXE_FORMAT, 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},
+ {ERRDOS, ERROR_NOT_LOCKED, NT_STATUS_RANGE_NOT_LOCKED},
+ {ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL},
{ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED},
{ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED},
- {ERRDOS, ERRtoomanynames, NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
- {ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED},
+ {ERRDOS, ERROR_TOO_MANY_NAMES, NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
+ {ERRDOS, ERROR_NO_MORE_ITEMS, 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, ERRoutofmem, NT_STATUS_SECTION_NOT_EXTENDED},
- {ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA},
+ {ERRDOS, ERROR_NO_MORE_ITEMS, NT_STATUS_AGENTS_EXHAUSTED},
+ {ERRDOS, ERROR_LABEL_TOO_LONG, NT_STATUS_INVALID_VOLUME_LABEL},
+ {ERRDOS, ERROR_OUTOFMEMORY, NT_STATUS_SECTION_NOT_EXTENDED},
+ {ERRDOS, ERROR_INVALID_ADDRESS, 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},
@@ -448,75 +456,75 @@ static const struct {
{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},
+ {ERRDOS, ERROR_ARITHMETIC_OVERFLOW, 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},
{ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES},
{ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND},
- {ERRDOS, ERRcrc, NT_STATUS_DEVICE_DATA_ERROR},
+ {ERRDOS, ERROR_CRC, NT_STATUS_DEVICE_DATA_ERROR},
{ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED},
- {ERRDOS, ERRnotready, NT_STATUS_DEVICE_POWER_FAILURE},
- {ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE},
- {ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED},
+ {ERRDOS, ERROR_NOT_READY, NT_STATUS_DEVICE_POWER_FAILURE},
+ {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_FREE_VM_NOT_AT_BASE},
+ {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_MEMORY_NOT_ALLOCATED},
{ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA},
- {ERRDOS, ERRwriteprotect, NT_STATUS_MEDIA_WRITE_PROTECTED},
- {ERRDOS, ERRnotready, NT_STATUS_DEVICE_NOT_READY},
+ {ERRDOS, ERROR_WRITE_PROTECT, NT_STATUS_MEDIA_WRITE_PROTECTED},
+ {ERRDOS, ERROR_NOT_READY, 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, ERRinvalidparam, NT_STATUS_BAD_MASTER_BOOT_RECORD},
+ {ERRDOS, ERROR_INVALID_PARAMETER, 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, ERROR_PIPE_BUSY, NT_STATUS_INSTANCE_NOT_AVAILABLE},
+ {ERRDOS, ERROR_PIPE_BUSY, NT_STATUS_PIPE_NOT_AVAILABLE},
+ {ERRDOS, ERROR_BAD_PIPE, NT_STATUS_INVALID_PIPE_STATE},
+ {ERRDOS, ERROR_PIPE_BUSY, NT_STATUS_PIPE_BUSY},
{ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION},
- {ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED},
- {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING},
+ {ERRDOS, ERROR_PIPE_NOT_CONNECTED, NT_STATUS_PIPE_DISCONNECTED},
+ {ERRDOS, ERROR_NO_DATA, 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, ERRhandleeof, NT_STATUS_FILE_FORCED_CLOSED},
+ {ERRDOS, ERROR_BAD_PIPE, NT_STATUS_INVALID_READ_MODE},
+ {ERRDOS, ERROR_SEM_TIMEOUT, NT_STATUS_IO_TIMEOUT},
+ {ERRDOS, ERROR_HANDLE_EOF, 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},
+ {ERRDOS, ERROR_NOT_SUPPORTED, NT_STATUS_NOT_SUPPORTED},
+ {ERRDOS, ERROR_REM_NOT_LIST, NT_STATUS_REMOTE_NOT_LISTENING},
+ {ERRDOS, ERROR_DUP_NAME, NT_STATUS_DUPLICATE_NAME},
+ {ERRDOS, ERROR_BAD_NETPATH, NT_STATUS_BAD_NETWORK_PATH},
+ {ERRDOS, ERROR_NETWORK_BUSY, NT_STATUS_NETWORK_BUSY},
+ {ERRDOS, ERROR_DEV_NOT_EXIST, NT_STATUS_DEVICE_DOES_NOT_EXIST},
+ {ERRDOS, ERROR_TOO_MANY_CMDS, NT_STATUS_TOO_MANY_COMMANDS},
+ {ERRDOS, ERROR_ADAP_HDW_ERR, NT_STATUS_ADAPTER_HARDWARE_ERROR},
+ {ERRDOS, ERROR_BAD_NET_RESP, NT_STATUS_INVALID_NETWORK_RESPONSE},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_UNEXPECTED_NETWORK_ERROR},
+ {ERRDOS, ERROR_BAD_REM_ADAP, NT_STATUS_BAD_REMOTE_ADAPTER},
+ {ERRDOS, ERROR_PRINTQ_FULL, NT_STATUS_PRINT_QUEUE_FULL},
+ {ERRDOS, ERROR_NO_SPOOL_SPACE, NT_STATUS_NO_SPOOL_SPACE},
+ {ERRDOS, ERROR_PRINT_CANCELLED, NT_STATUS_PRINT_CANCELLED},
+ {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_NETWORK_NAME_DELETED},
+ {ERRDOS, ERROR_NETWORK_ACCESS_DENIED, NT_STATUS_NETWORK_ACCESS_DENIED},
+ {ERRDOS, ERROR_BAD_DEV_TYPE, NT_STATUS_BAD_DEVICE_TYPE},
+ {ERRDOS, ERROR_BAD_NET_NAME, NT_STATUS_BAD_NETWORK_NAME},
+ {ERRDOS, ERROR_TOO_MANY_NAMES, NT_STATUS_TOO_MANY_NAMES},
+ {ERRDOS, ERROR_TOO_MANY_SESS, NT_STATUS_TOO_MANY_SESSIONS},
+ {ERRDOS, ERROR_SHARING_PAUSED, NT_STATUS_SHARING_PAUSED},
+ {ERRDOS, ERROR_REQ_NOT_ACCEP, NT_STATUS_REQUEST_NOT_ACCEPTED},
+ {ERRDOS, ERROR_REDIR_PAUSED, NT_STATUS_REDIRECTOR_PAUSED},
+ {ERRDOS, ERROR_NET_WRITE_FAULT, NT_STATUS_NET_WRITE_FAULT},
{ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT},
- {ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE},
+ {ERRDOS, ERROR_NOT_SAME_DEVICE, NT_STATUS_NOT_SAME_DEVICE},
{ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED},
- {ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
+ {ERRDOS, ERROR_VC_DISCONNECTED, 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},
+ {ERRDOS, ERROR_NO_DATA, 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},
@@ -525,8 +533,9 @@ static const struct {
{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},
+ {ERRDOS, ERROR_OPLOCK_NOT_GRANTED, NT_STATUS_OPLOCK_NOT_GRANTED},
+ {ERRDOS, ERROR_INVALID_OPLOCK_PROTOCOL,
+ 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},
@@ -538,32 +547,32 @@ static const struct {
{ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR},
{ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS},
{ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_1},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_2},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_3},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_4},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_5},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_6},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_7},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_8},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_9},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_10},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_11},
- {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_12},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_1},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_2},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_3},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_4},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_5},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_6},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_7},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_8},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_9},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_10},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_11},
+ {ERRDOS, ERROR_INVALID_PARAMETER, 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_VARIABLE_NOT_FOUND},
- {ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY},
+ {ERRDOS, ERROR_ENVVAR_NOT_FOUND, NT_STATUS_VARIABLE_NOT_FOUND},
+ {ERRDOS, ERROR_DIR_NOT_EMPTY, NT_STATUS_DIRECTORY_NOT_EMPTY},
{ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR},
- {ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY},
+ {ERRDOS, ERROR_DIRECTORY, 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},
+ {ERRDOS, ERROR_FILENAME_EXCED_RANGE, NT_STATUS_NAME_TOO_LONG},
+ {ERRDOS, NERR_OpenFiles, NT_STATUS_FILES_OPEN},
+ {ERRDOS, NERR_DevInUse, 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},
@@ -582,7 +591,7 @@ static const struct {
{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},
+ {ERRDOS, ERROR_BAD_EXE_FORMAT, 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},
@@ -601,36 +610,36 @@ static const struct {
{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},
+ {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_IMAGE_LE_FORMAT},
+ {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_IMAGE_NOT_MZ},
+ {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_IMAGE_PROTECT},
+ {ERRDOS, ERROR_BAD_EXE_FORMAT, 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},
+ {ERRDOS, ERROR_MOD_NOT_FOUND, 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},
+ {ERRDOS, ERROR_INVALID_ORDINAL, NT_STATUS_ORDINAL_NOT_FOUND},
+ {ERRDOS, ERROR_PROC_NOT_FOUND, 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},
+ {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_LOCAL_DISCONNECT},
+ {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_REMOTE_DISCONNECT},
+ {ERRDOS, ERROR_REM_NOT_LIST, NT_STATUS_REMOTE_RESOURCES},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_LINK_FAILED},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_LINK_TIMEOUT},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_INVALID_CONNECTION},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, 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},
+ {ERRDOS, ERROR_INVALID_LEVEL, NT_STATUS_INVALID_LEVEL},
+ {ERRDOS, ERROR_INVALID_PASSWORD, NT_STATUS_WRONG_PASSWORD_CORE},
{ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT},
- {ERRDOS, 109, NT_STATUS_PIPE_BROKEN},
+ {ERRDOS, ERROR_BROKEN_PIPE, NT_STATUS_PIPE_BROKEN},
{ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT},
{ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED},
{ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR},
@@ -667,9 +676,6 @@ static const struct {
{ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING},
{ERRHRD, ERRgeneral,
NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT},
- {ERRHRD, ERRgeneral, NT_STATUS_16F},
- {ERRHRD, ERRgeneral, NT_STATUS_170},
- {ERRHRD, ERRgeneral, NT_STATUS_171},
{ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE},
{ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH},
{ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED},
@@ -677,7 +683,6 @@ static const struct {
{ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA},
{ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW},
{ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA},
- {ERRHRD, ERRgeneral, NT_STATUS_179},
{ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER},
{ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER},
{ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED},
@@ -686,14 +691,14 @@ static const struct {
{ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED},
{ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN},
{ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE},
- {ERRDOS, ERRinvalidparam, NT_STATUS_DEVICE_CONFIGURATION_ERROR},
+ {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_DEVICE_CONFIGURATION_ERROR},
{ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR},
- {ERRDOS, ERRbadcmd, NT_STATUS_INVALID_DEVICE_STATE},
+ {ERRDOS, ERROR_BAD_COMMAND, 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, ERRwriteprotect, NT_STATUS_TOO_LATE},
+ {ERRDOS, ERROR_WRITE_PROTECT, NT_STATUS_TOO_LATE},
{ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET},
{ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT},
{ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE},
@@ -702,8 +707,8 @@ static const struct {
{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},
+ {ERRDOS, NERR_NetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED},
+ {ERRSRV, NERR_AccountExpired, NT_STATUS_ACCOUNT_EXPIRED},
{ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK},
{ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT},
{ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT},
@@ -716,27 +721,27 @@ static const struct {
{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},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, 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},
+ {ERRDOS, ERROR_TOO_MANY_NAMES, NT_STATUS_TOO_MANY_ADDRESSES},
+ {ERRDOS, ERROR_DUP_NAME, NT_STATUS_ADDRESS_ALREADY_EXISTS},
+ {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_ADDRESS_CLOSED},
+ {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_CONNECTION_DISCONNECTED},
+ {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_CONNECTION_RESET},
+ {ERRDOS, ERROR_TOO_MANY_NAMES, NT_STATUS_TOO_MANY_NODES},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_ABORTED},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_TIMED_OUT},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_NO_RELEASE},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_NO_MATCH},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_RESPONDED},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_INVALID_ID},
+ {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_INVALID_TYPE},
+ {ERRDOS, ERROR_NOT_SUPPORTED, NT_STATUS_NOT_SERVER_SESSION},
+ {ERRDOS, ERROR_NOT_SUPPORTED, 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},
@@ -746,10 +751,10 @@ static const struct {
{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},
+ {ERRDOS, ERROR_BAD_EXE_FORMAT, 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},
+ {ERRSRV, NERR_PasswordExpired, NT_STATUS_PASSWORD_MUST_CHANGE},
{ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND},
{ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM},
{ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE},
@@ -786,13 +791,7 @@ static const struct {
{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, 0x000024a},
- {ERRHRD, ERRgeneral, 0x000024b},
- {ERRHRD, ERRgeneral, 0x000024c},
- {ERRHRD, ERRgeneral, 0x000024d},
- {ERRHRD, ERRgeneral, 0x000024e},
- {ERRHRD, ERRgeneral, 0x000024f},
+ {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_IMAGE_MP_UP_MISMATCH},
{ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO},
{ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT},
{ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT},
@@ -806,19 +805,18 @@ static const struct {
{ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT},
{ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT},
{ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT},
- {ERRHRD, ERRgeneral, 0x000025d},
{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},
+ {ERRDOS, ERROR_INVALID_ORDINAL, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND},
+ {ERRDOS, ERROR_PROC_NOT_FOUND, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND},
+ {ERRDOS, ERROR_NOT_OWNER, 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, ERRnotready, NT_STATUS_VOLUME_DISMOUNTED},
- {ERRDOS, 161, NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT},
+ {ERRDOS, ERROR_NOT_READY, NT_STATUS_VOLUME_DISMOUNTED},
+ {ERRDOS, ERROR_BAD_PATHNAME, NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT},
{ERRDOS, ERRnoaccess, NT_STATUS_ENCRYPTION_FAILED},
{ERRDOS, ERRnoaccess, NT_STATUS_DECRYPTION_FAILED},
{ERRHRD, ERRgeneral, NT_STATUS_RANGE_NOT_FOUND},
@@ -827,35 +825,32 @@ static const struct {
{ERRDOS, ERRnoaccess, NT_STATUS_WRONG_EFS},
{ERRDOS, ERRnoaccess, NT_STATUS_NO_USER_KEYS},
{ERRDOS, ERRbadfunc, NT_STATUS_VOLUME_NOT_UPGRADED},
+ {0, 0, 0}
};
-u_int32_t
-smb_maperr32(u_int32_t eno)
+int
+smb_maperr32(uint32_t nterr)
{
- int i;
- unsigned orig = eno;
+ const nt2errno_t *nt2e;
+ const nt2doserr_t *nt2d;
- /*
- * Hi two bits are "severity". Ignore "success" (0) and
- * "informational" (1) values.
- */
- if (!(eno & 0x80000000))
+ switch (NT_SC_SEVERITY(nterr)) {
+ case NT_STATUS_SEVERITY_SUCCESS:
+ case NT_STATUS_SEVERITY_INFORMATIONAL:
return (0);
- /* mask off "severity" and the "component" bit */
- eno &= ~(0xe0000000);
+ }
/* first try direct map to unix */
- for (i = 0; nt2errno[i].errno; i++)
- if (nt2errno[i].nterr == eno)
- return (nt2errno[i].errno);
- SMBERROR("no direct map for 32 bit server error (0x%x)\n", orig);
+ for (nt2e = nt2errno; nt2e->errno; nt2e++)
+ if (nt2e->nterr == nterr)
+ return (nt2e->errno);
+ SMBERROR("no direct map for 32 bit server error (0x%x)\n", nterr);
/* ok, then try mapping to dos to unix */
- for (i = 0; nt2doserr[i].derr; i++)
- if (nt2doserr[i].nterr == eno)
- return (smb_maperror(nt2doserr[i].dclass,
- nt2doserr[i].derr));
- return (smb_maperror(ERRHRD, ERRgeneral));
+ for (nt2d = nt2doserr; nt2d->nterr; nt2d++)
+ if (nt2d->nterr == nterr)
+ return (smb_maperror(nt2d->dclass, nt2d->derr));
+ return (EIO);
}
@@ -867,7 +862,7 @@ smb_maperror(int eclass, int eno)
switch (eclass) {
case ERRDOS:
switch (eno) {
- case ERRunknownlevel:
+ case ERROR_INVALID_LEVEL:
return (ENOTSUP);
case ERRbadfunc:
case ERRbadenv:
@@ -877,8 +872,8 @@ smb_maperror(int eclass, int eno)
return (EINVAL);
case ERRbadfile:
case ERRbadpath:
- case ERRnoipc:
- case ERRnosuchshare:
+ case ERROR_BAD_DEV_TYPE:
+ case ERROR_BAD_NET_NAME:
return (ENOENT);
case ERRnofids:
return (EMFILE);
@@ -928,13 +923,13 @@ smb_maperror(int eclass, int eno)
return (EAGAIN);
case ERRfilexists:
return (EEXIST);
- case ERRinvalidname: /* samba maps as noent */
+ case ERROR_INVALID_NAME:
return (ENOENT);
- case ERRdirnotempty: /* samba */
+ case ERROR_DIR_NOT_EMPTY:
return (ENOTEMPTY);
- case ERRnotlocked:
- return (0); /* 0 since bsd unlocks on any close */
- case ERRrename:
+ case ERROR_NOT_LOCKED:
+ return (0); /* we unlock on any close */
+ case ERROR_ALREADY_EXISTS:
return (EEXIST);
case ERRmoredata:
return (EMOREDATA);
@@ -955,7 +950,7 @@ smb_maperror(int eclass, int eno)
return (ENXIO);
case ERRbadtype: /* reserved and returned */
return (EIO);
- case ERRacctexpired: /* NT: account exists but disabled */
+ case NERR_AccountExpired: /* account exists but disabled */
return (EPERM);
}
break;
diff --git a/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_xattr.c b/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_xattr.c
index 0ff265ef0f..75241cc1f0 100644
--- a/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_xattr.c
+++ b/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_xattr.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -346,7 +345,7 @@ smbfs_xa_findopen(struct smbfs_fctx *ctx, struct smbnode *dnp,
t2p->t2_maxdcount = INT16_MAX;
error = smb_t2_request(t2p);
if (error) {
- if (smb_t2_err(t2p) == NT_STATUS_INVALID_PARAMETER)
+ if (t2p->t2_sr_error == NT_STATUS_INVALID_PARAMETER)
error = ENOTSUP;
}
/*
diff --git a/usr/src/uts/common/fs/smbsrv/smb_alloc.c b/usr/src/uts/common/fs/smbsrv/smb_alloc.c
index 3d7372dd13..2c4cf05362 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_alloc.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_alloc.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
@@ -194,6 +193,18 @@ smb_srm_rezalloc(smb_request_t *sr, void *p, size_t size)
return (smb_realloc(sr, p, size, B_TRUE));
}
+char *
+smb_srm_strdup(smb_request_t *sr, const char *s)
+{
+ char *p;
+ size_t size;
+
+ size = strlen(s) + 1;
+ p = smb_srm_alloc(sr, size);
+ bcopy(s, p, size);
+ return (p);
+}
+
/*
* Allocate memory.
*
diff --git a/usr/src/uts/common/fs/smbsrv/smb_common_open.c b/usr/src/uts/common/fs/smbsrv/smb_common_open.c
index 6afa9b0c6d..4d053a63ad 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_common_open.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_common_open.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -175,7 +175,7 @@ smb_ofun_to_crdisposition(uint16_t ofun)
uint32_t
smb_common_open(smb_request_t *sr)
{
- open_param_t *parg;
+ smb_arg_open_t *parg;
uint32_t status = NT_STATUS_SUCCESS;
int count;
@@ -302,7 +302,7 @@ smb_open_subr(smb_request_t *sr)
smb_node_t *node = NULL;
smb_node_t *dnode = NULL;
smb_node_t *cur_node = NULL;
- open_param_t *op = &sr->arg.open;
+ smb_arg_open_t *op = &sr->sr_open;
int rc;
smb_ofile_t *of;
smb_attr_t new_attr;
@@ -341,9 +341,8 @@ smb_open_subr(smb_request_t *sr)
if (sr->session->s_file_cnt >= SMB_SESSION_OFILE_MAX) {
ASSERT(sr->uid_user);
- cmn_err(CE_NOTE, "smbd[%s\\%s]: %s", sr->uid_user->u_domain,
- sr->uid_user->u_name,
- xlate_nt_status(NT_STATUS_TOO_MANY_OPENED_FILES));
+ cmn_err(CE_NOTE, "smbd[%s\\%s]: TOO_MANY_OPENED_FILES",
+ sr->uid_user->u_domain, sr->uid_user->u_name);
smbsr_error(sr, NT_STATUS_TOO_MANY_OPENED_FILES,
ERRDOS, ERROR_TOO_MANY_OPEN_FILES);
@@ -905,7 +904,7 @@ static int
smb_set_open_timestamps(smb_request_t *sr, smb_ofile_t *of, boolean_t created)
{
int rc = 0;
- open_param_t *op = &sr->arg.open;
+ smb_arg_open_t *op = &sr->sr_open;
smb_node_t *node = of->f_node;
boolean_t existing_file, set_times;
smb_attr_t attr;
@@ -946,7 +945,7 @@ smb_set_open_timestamps(smb_request_t *sr, smb_ofile_t *of, boolean_t created)
static void
smb_delete_new_object(smb_request_t *sr)
{
- open_param_t *op = &sr->arg.open;
+ smb_arg_open_t *op = &sr->sr_open;
smb_fqi_t *fqi = &(op->fqi);
uint32_t flags = 0;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_common_transact.c b/usr/src/uts/common/fs/smbsrv/smb_common_transact.c
index 1ac6ff079a..ce95e1c809 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_common_transact.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_common_transact.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -28,7 +29,6 @@
#include <smbsrv/string.h>
#include <smbsrv/nmpipes.h>
#include <smbsrv/mailslot.h>
-#include <smbsrv/lmerr.h>
/*
* count of bytes in server response packet
@@ -724,8 +724,6 @@ smb_encode_SHARE_INFO_2(struct mbuf_chain *output, struct mbuf_chain *text,
int
smb_trans_net_share_enum(struct smb_request *sr, struct smb_xa *xa)
{
- door_handle_t dhdl = sr->sr_server->sv_lmshrd;
-
/*
* Number of data bytes that will
* be sent in the current response
@@ -796,15 +794,14 @@ smb_trans_net_share_enum(struct smb_request *sr, struct smb_xa *xa)
return (SDRC_SUCCESS);
}
- esi.es_buf = kmem_zalloc(esi.es_bufsize, KM_SLEEP);
+ esi.es_buf = smb_srm_zalloc(sr, esi.es_bufsize);
esi.es_posix_uid = crgetuid(sr->uid_user->u_cred);
- (void) smb_kshare_enum(dhdl, &esi);
+ smb_kshare_enum(&esi);
/* client buffer size is not big enough to hold any shares */
if (esi.es_nsent == 0) {
(void) smb_mbc_encodef(&xa->rep_param_mb, "wwww",
ERROR_MORE_DATA, 0, esi.es_nsent, esi.es_ntotal);
- kmem_free(esi.es_buf, esi.es_bufsize);
return (SDRC_SUCCESS);
}
@@ -916,7 +913,6 @@ smb_trans_net_share_enum(struct smb_request *sr, struct smb_xa *xa)
(void) smb_session_send(sr->session, 0, &reply);
}
- kmem_free(esi.es_buf, esi.es_bufsize);
return (SDRC_NO_REPLY);
}
@@ -927,18 +923,18 @@ smb_trans_net_share_getinfo(smb_request_t *sr, struct smb_xa *xa)
struct mbuf_chain str_mb;
char *share;
char *password;
- smb_share_t si;
- int rc;
+ smb_kshare_t *si;
if (smb_mbc_decodef(&xa->req_param_mb, "%sww", sr,
&share, &level, &max_bytes) != 0)
return (SDRC_NOT_IMPLEMENTED);
- (void) smb_strlwr(share);
- rc = smb_kshare_getinfo(sr->sr_server->sv_lmshrd, share, &si, NULL);
- if ((rc != NERR_Success) || (si.shr_flags & SMB_SHRF_LONGNAME)) {
+ si = smb_kshare_lookup(share);
+ if ((si == NULL) || (si->shr_oemname == NULL)) {
(void) smb_mbc_encodef(&xa->rep_param_mb, "www",
NERR_NetNameNotFound, 0, 0);
+ if (si)
+ smb_kshare_release(si);
return (SDRC_SUCCESS);
}
@@ -949,27 +945,30 @@ smb_trans_net_share_getinfo(smb_request_t *sr, struct smb_xa *xa)
switch (level) {
case 0 :
- (void) smb_mbc_encodef(&xa->rep_data_mb, "13c", si.shr_oemname);
+ (void) smb_mbc_encodef(&xa->rep_data_mb, "13c",
+ si->shr_oemname);
break;
case 1 :
smb_encode_SHARE_INFO_1(&xa->rep_data_mb, &str_mb,
- si.shr_oemname, si.shr_type, si.shr_cmnt);
+ si->shr_oemname, si->shr_type, si->shr_cmnt);
break;
case 2 :
smb_encode_SHARE_INFO_2(&xa->rep_data_mb, &str_mb, sr,
- si.shr_oemname, si.shr_type, si.shr_cmnt, access,
- si.shr_path, password);
+ si->shr_oemname, si->shr_type, si->shr_cmnt, access,
+ si->shr_path, password);
break;
default:
+ smb_kshare_release(si);
(void) smb_mbc_encodef(&xa->rep_param_mb, "www",
ERROR_INVALID_LEVEL, 0, 0);
m_freem(str_mb.chain);
return (SDRC_NOT_IMPLEMENTED);
}
+ smb_kshare_release(si);
(void) smb_mbc_encodef(&xa->rep_param_mb, "www", NERR_Success,
-MBC_LENGTH(&xa->rep_data_mb),
MBC_LENGTH(&xa->rep_data_mb) + MBC_LENGTH(&str_mb));
diff --git a/usr/src/uts/common/fs/smbsrv/smb_delete.c b/usr/src/uts/common/fs/smbsrv/smb_delete.c
index d90926e5fb..27e37908b2 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_delete.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_delete.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <smbsrv/smb_kproto.h>
@@ -304,7 +304,7 @@ smb_delete_multiple_files(smb_request_t *sr, smb_error_t *err)
if (rc != 0)
break;
- rc = smb_fsop_lookup_name(sr, sr->user_cr, 0,
+ rc = smb_fsop_lookup_name(sr, sr->user_cr, SMB_CASE_SENSITIVE,
sr->tid_tree->t_snode, fqi->fq_dnode,
namebuf, &fqi->fq_fnode);
if (rc != 0)
@@ -362,13 +362,6 @@ smb_delete_multiple_files(smb_request_t *sr, smb_error_t *err)
* Find next filename that matches search pattern and return it
* in namebuf.
*
- * Case insensitivity note:
- * If the tree is case insensitive and there's a case conflict
- * with the name returned from smb_odir_read, smb_delete_find_fname
- * performs case conflict name mangling to produce a unique filename.
- * This ensures that any subsequent smb_fsop_lookup, (which will
- * find the first case insensitive match) will find the correct file.
- *
* Returns: 0 - success
* errno
*/
@@ -378,35 +371,18 @@ smb_delete_find_fname(smb_request_t *sr, smb_odir_t *od, char *namebuf, int len)
int rc;
smb_odirent_t *odirent;
boolean_t eos;
- char *name;
- char shortname[SMB_SHORTNAMELEN];
- char name83[SMB_SHORTNAMELEN];
odirent = kmem_alloc(sizeof (smb_odirent_t), KM_SLEEP);
rc = smb_odir_read(sr, od, odirent, &eos);
- if (rc != 0) {
- kmem_free(odirent, sizeof (smb_odirent_t));
- return (rc);
- }
- if (eos) {
- kmem_free(odirent, sizeof (smb_odirent_t));
- return (ENOENT);
- }
-
- /* if case conflict, force mangle and use shortname */
- if ((od->d_flags & SMB_ODIR_FLAG_IGNORE_CASE) &&
- (odirent->od_eflags & ED_CASE_CONFLICT)) {
- (void) smb_mangle_name(odirent->od_ino, odirent->od_name,
- shortname, name83, 1);
- name = shortname;
- } else {
- name = odirent->od_name;
+ if (rc == 0) {
+ if (eos)
+ rc = ENOENT;
+ else
+ (void) strlcpy(namebuf, odirent->od_name, len);
}
- (void) strlcpy(namebuf, name, len);
-
kmem_free(odirent, sizeof (smb_odirent_t));
- return (0);
+ return (rc);
}
/*
@@ -592,7 +568,6 @@ static void
smb_delete_error(smb_error_t *err,
uint32_t status, uint16_t errcls, uint16_t errcode)
{
- err->severity = ERROR_SEVERITY_ERROR;
err->status = status;
err->errcls = errcls;
err->errcode = errcode;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_dispatch.c b/usr/src/uts/common/fs/smbsrv/smb_dispatch.c
index 19db44323c..e6ce5e92b4 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_dispatch.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_dispatch.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -138,390 +138,335 @@
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_kstat.h>
#include <sys/sdt.h>
-
-#define SMB_ALL_DISPATCH_STAT_INCR(stat) atomic_inc_64(&stat);
-#define SMB_COM_NUM 256
-
-static kstat_t *smb_dispatch_ksp = NULL;
-static kmutex_t smb_dispatch_ksmtx;
+#include <sys/spl.h>
static int is_andx_com(unsigned char);
static int smbsr_check_result(struct smb_request *, int, int);
-static smb_disp_entry_t dispatch[SMB_COM_NUM] = {
- { SMB_SDT_OPS(create_directory), /* 0x00 000 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbCreateDirectory", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(delete_directory), /* 0x01 001 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbDeleteDirectory", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(open), /* 0x02 002 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbOpen", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(create), /* 0x03 003 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbCreate", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(close), /* 0x04 004 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbClose", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(flush), /* 0x05 005 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbFlush", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(delete), /* 0x06 006 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbDelete", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(rename), /* 0x07 007 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbRename", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(query_information), /* 0x08 008 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbQueryInformation", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(set_information), /* 0x09 009 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbSetInformation", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(read), /* 0x0A 010 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbRead", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(write), /* 0x0B 011 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbWrite", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(lock_byte_range), /* 0x0C 012 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbLockByteRange", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(unlock_byte_range), /* 0x0D 013 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbUnlockByteRange", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(create_temporary), /* 0x0E 014 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbCreateTemporary", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(create_new), /* 0x0F 015 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbCreateNew", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(check_directory), /* 0x10 016 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbCheckDirectory", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(process_exit), /* 0x11 017 */
- PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID,
- { "SmbProcessExit", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(seek), /* 0x12 018 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbSeek", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(lock_and_read), /* 0x13 019 */
- LANMAN1_0, 0,
- { "SmbLockAndRead", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(write_and_unlock), /* 0x14 020 */
- LANMAN1_0, 0,
- { "SmbWriteAndUnlock", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x15 021 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x16 022 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x17 023 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x18 024 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x19 025 */
- { SMB_SDT_OPS(read_raw), /* 0x1A 026 */
- LANMAN1_0, 0,
- { "SmbReadRaw", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x1B 027 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x1C 028 */
- { SMB_SDT_OPS(write_raw), /* 0x1D 029 */
- LANMAN1_0, 0,
- { "SmbWriteRaw", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x1E 030 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x1F 031 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x20 032 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x21 033 */
- { SMB_SDT_OPS(set_information2), /* 0x22 034 */
- LANMAN1_0, 0,
- { "SmbSetInformation2", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(query_information2), /* 0x23 035 */
- LANMAN1_0, 0,
- { "SmbQueryInformation2", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(locking_andx), /* 0x24 036 */
- LANMAN1_0, 0,
- { "SmbLockingX", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(transaction), /* 0x25 037 */
- LANMAN1_0, 0,
- { "SmbTransaction", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(transaction_secondary), /* 0x26 038 */
- LANMAN1_0, 0,
- { "SmbTransactionSecondary", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(ioctl), /* 0x27 039 */
- LANMAN1_0, 0,
- { "SmbIoctl", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x28 040 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x29 041 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x2A 042 */
- { SMB_SDT_OPS(echo), /* 0x2B 043 */
- LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID,
- { "SmbEcho", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(write_and_close), /* 0x2C 044 */
- LANMAN1_0, 0,
- { "SmbWriteAndClose", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(open_andx), /* 0x2D 045 */
- LANMAN1_0, 0,
- { "SmbOpenX", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(read_andx), /* 0x2E 046 */
- LANMAN1_0, 0,
- { "SmbReadX", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(write_andx), /* 0x2F 047 */
- LANMAN1_0, 0,
- { "SmbWriteX", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x30 048 */
- { SMB_SDT_OPS(close_and_tree_disconnect), /* 0x31 049 */
- LANMAN1_0, 0,
- { "SmbCloseAndTreeDisconnect", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(transaction2), /* 0x32 050 */
- LM1_2X002, 0,
- { "SmbTransaction2", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(transaction2_secondary), /* 0x33 051 */
- LM1_2X002, 0,
- { "SmbTransaction2Secondary", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(find_close2), /* 0x34 052 */
- LM1_2X002, 0,
- { "SmbFindClose2", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x35 053 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x36 054 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x37 055 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x38 056 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x39 057 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3A 058 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3B 059 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3C 060 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3D 061 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3E 062 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x3F 063 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x40 064 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x41 065 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x42 066 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x43 067 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x44 068 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x45 069 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x46 070 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x47 071 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x48 072 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x49 073 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4A 074 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4B 075 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4C 076 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4D 077 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4E 078 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x4F 079 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x50 080 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x51 081 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x52 082 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x53 083 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x54 084 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x55 085 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x56 086 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x57 087 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x58 088 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x59 089 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5A 090 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5B 091 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5C 092 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5D 093 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5E 094 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x5F 095 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x60 096 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x61 097 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x62 098 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x63 099 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x64 100 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x65 101 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x66 102 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x67 103 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x68 104 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x69 105 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6A 106 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6B 107 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6C 108 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6D 109 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6E 110 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x6F 111 */
- { SMB_SDT_OPS(tree_connect), /* 0x70 112 */
- PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID,
- { "SmbTreeConnect", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(tree_disconnect), /* 0x71 113 */
- PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID,
- { "SmbTreeDisconnect", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(negotiate), /* 0x72 114 */
- PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID,
- { "SmbNegotiate", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(session_setup_andx), /* 0x73 115 */
- LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID,
- { "SmbSessionSetupX", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(logoff_andx), /* 0x74 116 */
- LM1_2X002, SDDF_SUPPRESS_TID,
- { "SmbLogoffX", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(tree_connect_andx), /* 0x75 117 */
- LANMAN1_0, SDDF_SUPPRESS_TID,
- { "SmbTreeConnectX", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x76 118 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x77 119 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x78 120 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x79 121 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7A 122 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7B 123 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7C 124 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7D 125 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7E 126 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x7F 127 */
- { SMB_SDT_OPS(query_information_disk), /* 0x80 128 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbQueryInformationDisk", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(search), /* 0x81 129 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbSearch", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(find), /* 0x82 130 */
- LANMAN1_0, 0,
- { "SmbFind", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(find_unique), /* 0x83 131 */
- LANMAN1_0, 0,
- { "SmbFindUnique", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(find_close), /* 0x84 132 */
- LANMAN1_0, 0,
- { "SmbFindClose", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x85 133 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x86 134 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x87 135 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x88 136 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x89 137 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8A 138 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8B 139 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8C 140 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8D 141 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8E 142 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x8F 143 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x90 144 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x91 145 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x92 146 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x93 147 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x94 148 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x95 149 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x96 150 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x97 151 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x98 152 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x99 153 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9A 154 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9B 155 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9C 156 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9D 157 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9E 158 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0x9F 159 */
- { SMB_SDT_OPS(nt_transact), /* 0xA0 160 */
- NT_LM_0_12, 0,
- { "SmbNtTransact", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(nt_transact_secondary), /* 0xA1 161 */
- NT_LM_0_12, 0,
- { "SmbNtTransactSecondary", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(nt_create_andx), /* 0xA2 162 */
- NT_LM_0_12, 0,
- { "SmbNtCreateX", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA3 163 */
- { SMB_SDT_OPS(nt_cancel), /* 0xA4 164 */
- NT_LM_0_12, 0,
- { "SmbNtCancel", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(nt_rename), /* 0xA5 165 */
- NT_LM_0_12, 0,
- { "SmbNtRename", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA6 166 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA7 167 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA8 168 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xA9 169 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAA 170 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAB 171 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAC 172 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAD 173 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAE 174 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xAF 175 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB0 176 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB1 177 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB2 178 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB3 179 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB4 180 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB5 181 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB6 182 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB7 183 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB8 184 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xB9 185 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBA 186 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBB 187 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBC 188 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBD 189 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBE 190 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xBF 191 */
- { SMB_SDT_OPS(open_print_file), /* 0xC0 192 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbOpenPrintFile", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(write_print_file), /* 0xC1 193 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbWritePrintFile", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(close_print_file), /* 0xC2 194 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbClosePrintFile", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(get_print_queue), /* 0xC3 195 */
- PC_NETWORK_PROGRAM_1_0, 0,
- { "SmbGetPrintQueue", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC4 196 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC5 197 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC6 198 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC7 199 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC8 200 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xC9 201 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCA 202 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCB 203 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCC 204 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCD 205 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCE 206 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xCF 207 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD0 208 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD1 209 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD2 210 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD3 211 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD4 212 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD5 213 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD6 214 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD7 215 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD8 216 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xD9 217 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDA 218 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDB 219 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDC 220 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDD 221 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDE 222 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xDF 223 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE0 224 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE1 225 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE2 226 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE3 227 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE4 228 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE5 229 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE6 230 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE7 231 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE8 232 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xE9 233 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEA 234 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEB 235 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEC 236 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xED 237 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEE 238 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xEF 239 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF0 240 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF1 241 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF2 242 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF3 243 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF4 244 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF5 245 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF6 246 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF7 247 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF8 248 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xF9 249 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xFA 250 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xFB 251 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xFC 252 */
- { SMB_SDT_OPS(invalid), 0, 0, 0 }, /* 0xFD 253 */
- { SMB_SDT_OPS(invalid), LANMAN1_0, 0, /* 0xFE 254 */
- { "SmbInvalidCommand", KSTAT_DATA_UINT64 } },
- { SMB_SDT_OPS(invalid), 0, 0, 0 } /* 0xFF 255 */
+static smb_disp_entry_t smb_disp_table[SMB_COM_NUM] = {
+ { "SmbCreateDirectory", SMB_SDT_OPS(create_directory), /* 0x00 000 */
+ 0x00, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbDeleteDirectory", SMB_SDT_OPS(delete_directory), /* 0x01 001 */
+ 0x01, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbOpen", SMB_SDT_OPS(open), /* 0x02 002 */
+ 0x02, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbCreate", SMB_SDT_OPS(create), /* 0x03 003 */
+ 0x03, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbClose", SMB_SDT_OPS(close), /* 0x04 004 */
+ 0x04, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbFlush", SMB_SDT_OPS(flush), /* 0x05 005 */
+ 0x05, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbDelete", SMB_SDT_OPS(delete), /* 0x06 006 */
+ 0x06, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbRename", SMB_SDT_OPS(rename), /* 0x07 007 */
+ 0x07, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbQueryInformation", SMB_SDT_OPS(query_information), /* 0x08 008 */
+ 0x08, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbSetInformation", SMB_SDT_OPS(set_information), /* 0x09 009 */
+ 0x09, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbRead", SMB_SDT_OPS(read), /* 0x0A 010 */
+ 0x0A, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbWrite", SMB_SDT_OPS(write), /* 0x0B 011 */
+ 0x0B, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbLockByteRange", SMB_SDT_OPS(lock_byte_range), /* 0x0C 012 */
+ 0x0C, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbUnlockByteRange", SMB_SDT_OPS(unlock_byte_range), /* 0x0D 013 */
+ 0x0D, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbCreateTemporary", SMB_SDT_OPS(create_temporary), /* 0x0E 014 */
+ 0x0E, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbCreateNew", SMB_SDT_OPS(create_new), /* 0x0F 015 */
+ 0x0F, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbCheckDirectory", SMB_SDT_OPS(check_directory), /* 0x10 016 */
+ 0x10, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbProcessExit", SMB_SDT_OPS(process_exit), /* 0x11 017 */
+ 0x11, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID,
+ 0, 0, { 0 } },
+ { "SmbSeek", SMB_SDT_OPS(seek), /* 0x12 018 */
+ 0x12, PC_NETWORK_PROGRAM_1_0 },
+ { "SmbLockAndRead", SMB_SDT_OPS(lock_and_read), /* 0x13 019 */
+ 0x13, LANMAN1_0 },
+ { "SmbWriteAndUnlock", SMB_SDT_OPS(write_and_unlock), /* 0x14 020 */
+ 0x14, LANMAN1_0 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0x15, 0 }, /* 0x15 021 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x16, 0 }, /* 0x16 022 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x17, 0 }, /* 0x17 023 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x18, 0 }, /* 0x18 024 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x19, 0 }, /* 0x19 025 */
+ { "SmbReadRaw", SMB_SDT_OPS(read_raw), /* 0x1A 026 */
+ 0x1A, LANMAN1_0 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0x1B, 0 }, /* 0x1B 027 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x1C, 0 }, /* 0x1C 028 */
+ { "SmbWriteRaw", SMB_SDT_OPS(write_raw), /* 0x1D 029 */
+ 0x1D, LANMAN1_0 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0x1E, 0 }, /* 0x1E 030 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x1F, 0 }, /* 0x1F 031 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x20, 0 }, /* 0x20 032 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x21, 0 }, /* 0x21 033 */
+ { "SmbSetInformation2", SMB_SDT_OPS(set_information2), /* 0x22 034 */
+ 0x22, LANMAN1_0 },
+ { "SmbQueryInformation2",
+ SMB_SDT_OPS(query_information2), /* 0x23 035 */
+ 0x23, LANMAN1_0 },
+ { "SmbLockingX", SMB_SDT_OPS(locking_andx), /* 0x24 036 */
+ 0x24, LANMAN1_0 },
+ { "SmbTransaction", SMB_SDT_OPS(transaction), /* 0x25 037 */
+ 0x25, LANMAN1_0 },
+ { "SmbTransactionSecondary",
+ SMB_SDT_OPS(transaction_secondary), /* 0x26 038 */
+ 0x26, LANMAN1_0 },
+ { "SmbIoctl", SMB_SDT_OPS(ioctl), /* 0x27 039 */
+ 0x27, LANMAN1_0 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0x28, 0 }, /* 0x28 040 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x29, 0 }, /* 0x29 041 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x2A, 0 }, /* 0x2A 042 */
+ { "SmbEcho", SMB_SDT_OPS(echo), /* 0x2B 043 */
+ 0x2B, LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
+ { "SmbWriteAndClose", SMB_SDT_OPS(write_and_close), /* 0x2C 044 */
+ 0x2C, LANMAN1_0 },
+ { "SmbOpenX", SMB_SDT_OPS(open_andx), /* 0x2D 045 */
+ 0x2D, LANMAN1_0 },
+ { "SmbReadX", SMB_SDT_OPS(read_andx), /* 0x2E 046 */
+ 0x2E, LANMAN1_0 },
+ { "SmbWriteX", SMB_SDT_OPS(write_andx), /* 0x2F 047 */
+ 0x2F, LANMAN1_0 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0x30, 0 }, /* 0x30 048 */
+ { "SmbCloseAndTreeDisconnect",
+ SMB_SDT_OPS(close_and_tree_disconnect), /* 0x31 049 */
+ 0x31, LANMAN1_0 },
+ { "SmbTransaction2", SMB_SDT_OPS(transaction2), /* 0x32 050 */
+ 0x32, LM1_2X002 },
+ { "SmbTransaction2Secondary",
+ SMB_SDT_OPS(transaction2_secondary), /* 0x33 051 */
+ 0x33, LM1_2X002 },
+ { "SmbFindClose2", SMB_SDT_OPS(find_close2), /* 0x34 052 */
+ 0x34, LM1_2X002 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0x35, 0 }, /* 0x35 053 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x36, 0 }, /* 0x36 054 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x37, 0 }, /* 0x37 055 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x38, 0 }, /* 0x38 056 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x39, 0 }, /* 0x39 057 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x3A, 0 }, /* 0x3A 058 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x3B, 0 }, /* 0x3B 059 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x3C, 0 }, /* 0x3C 060 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x3D, 0 }, /* 0x3D 061 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x3E, 0 }, /* 0x3E 062 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x3F, 0 }, /* 0x3F 063 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x40, 0 }, /* 0x40 064 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x47, 0 }, /* 0x47 065 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x48, 0 }, /* 0x48 066 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x49, 0 }, /* 0x49 067 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x44, 0 }, /* 0x44 068 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x45, 0 }, /* 0x45 069 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x46, 0 }, /* 0x46 070 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x47, 0 }, /* 0x47 071 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x48, 0 }, /* 0x48 072 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x49, 0 }, /* 0x49 073 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x4A, 0 }, /* 0x4A 074 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x4B, 0 }, /* 0x4B 075 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x4C, 0 }, /* 0x4C 076 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x4D, 0 }, /* 0x4D 077 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x4E, 0 }, /* 0x4E 078 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x4F, 0 }, /* 0x4F 079 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x50, 0 }, /* 0x50 080 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x51, 0 }, /* 0x51 081 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x52, 0 }, /* 0x52 082 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x53, 0 }, /* 0x53 083 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x54, 0 }, /* 0x54 084 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x55, 0 }, /* 0x55 085 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x56, 0 }, /* 0x56 086 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x57, 0 }, /* 0x57 087 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x58, 0 }, /* 0x58 088 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x59, 0 }, /* 0x59 089 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x5A, 0 }, /* 0x5A 090 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x5B, 0 }, /* 0x5B 091 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x5C, 0 }, /* 0x5C 092 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x5D, 0 }, /* 0x5D 093 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x5E, 0 }, /* 0x5E 094 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x5F, 0 }, /* 0x5F 095 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x60, 0 }, /* 0x60 096 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x61, 0 }, /* 0x61 097 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x62, 0 }, /* 0x62 098 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x63, 0 }, /* 0x63 099 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x64, 0 }, /* 0x64 100 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x65, 0 }, /* 0x65 101 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x66, 0 }, /* 0x66 102 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x67, 0 }, /* 0x67 103 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x68, 0 }, /* 0x68 104 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x69, 0 }, /* 0x69 105 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x6A, 0 }, /* 0x6A 106 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x6B, 0 }, /* 0x6B 107 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x6C, 0 }, /* 0x6C 108 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x6D, 0 }, /* 0x6D 109 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x6E, 0 }, /* 0x6E 110 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x6F, 0 }, /* 0x6F 111 */
+ { "SmbTreeConnect", SMB_SDT_OPS(tree_connect), /* 0x70 112 */
+ 0x70, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID },
+ { "SmbTreeDisconnect", SMB_SDT_OPS(tree_disconnect), /* 0x71 113 */
+ 0x71, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID,
+ NULL },
+ { "SmbNegotiate", SMB_SDT_OPS(negotiate), /* 0x72 114 */
+ 0x72, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID,
+ NULL },
+ { "SmbSessionSetupX", SMB_SDT_OPS(session_setup_andx), /* 0x73 115 */
+ 0x73, LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
+ { "SmbLogoffX", SMB_SDT_OPS(logoff_andx), /* 0x74 116 */
+ 0x74, LM1_2X002, SDDF_SUPPRESS_TID },
+ { "SmbTreeConnectX", SMB_SDT_OPS(tree_connect_andx), /* 0x75 117 */
+ 0x75, LANMAN1_0, SDDF_SUPPRESS_TID },
+ { "Invalid", SMB_SDT_OPS(invalid), 0x76, 0, 0 }, /* 0x76 118 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x77, 0, 0 }, /* 0x77 119 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x78, 0, 0 }, /* 0x78 120 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x79, 0, 0 }, /* 0x79 121 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x7A, 0, 0 }, /* 0x7A 122 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x7B, 0, 0 }, /* 0x7B 123 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x7C, 0, 0 }, /* 0x7C 124 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x7D, 0, 0 }, /* 0x7D 125 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x7E, 0, 0 }, /* 0x7E 126 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x7F, 0, 0 }, /* 0x7F 127 */
+ { "SmbQueryInformationDisk",
+ SMB_SDT_OPS(query_information_disk), /* 0x80 128 */
+ 0x80, PC_NETWORK_PROGRAM_1_0, 0 },
+ { "SmbSearch", SMB_SDT_OPS(search), /* 0x81 129 */
+ 0x81, PC_NETWORK_PROGRAM_1_0, 0 },
+ { "SmbFind", SMB_SDT_OPS(find), /* 0x82 130 */
+ 0x82, LANMAN1_0, 0 },
+ { "SmbFindUnique", SMB_SDT_OPS(find_unique), /* 0x83 131 */
+ 0x83, LANMAN1_0, 0 },
+ { "SmbFindClose", SMB_SDT_OPS(find_close), /* 0x84 132 */
+ 0x84, LANMAN1_0, 0 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0x85, 0, 0 }, /* 0x85 133 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x86, 0, 0 }, /* 0x86 134 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x87, 0, 0 }, /* 0x87 135 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x88, 0, 0 }, /* 0x88 136 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x89, 0, 0 }, /* 0x89 137 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x8A, 0, 0 }, /* 0x8A 138 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x8B, 0, 0 }, /* 0x8B 139 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x8C, 0, 0 }, /* 0x8C 140 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x8D, 0, 0 }, /* 0x8D 141 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x8E, 0, 0 }, /* 0x8E 142 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x8F, 0, 0 }, /* 0x8F 143 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x90, 0, 0 }, /* 0x90 144 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x91, 0, 0 }, /* 0x91 145 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x92, 0, 0 }, /* 0x92 146 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x93, 0, 0 }, /* 0x93 147 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x94, 0, 0 }, /* 0x94 148 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x95, 0, 0 }, /* 0x95 149 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x96, 0, 0 }, /* 0x96 150 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x97, 0, 0 }, /* 0x97 151 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x98, 0, 0 }, /* 0x98 152 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x99, 0, 0 }, /* 0x99 153 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x9A, 0, 0 }, /* 0x9A 154 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x9B, 0, 0 }, /* 0x9B 155 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x9C, 0, 0 }, /* 0x9C 156 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x9D, 0, 0 }, /* 0x9D 157 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x9E, 0, 0 }, /* 0x9E 158 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0x9F, 0, 0 }, /* 0x9F 159 */
+ { "SmbNtTransact", SMB_SDT_OPS(nt_transact), /* 0xA0 160 */
+ 0xA0, NT_LM_0_12, 0 },
+ { "SmbNtTransactSecondary",
+ SMB_SDT_OPS(nt_transact_secondary), /* 0xA1 161 */
+ 0xA1, NT_LM_0_12, 0 },
+ { "SmbNtCreateX", SMB_SDT_OPS(nt_create_andx), /* 0xA2 162 */
+ 0xA2, NT_LM_0_12, 0 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0xA3, 0, 0 }, /* 0xA3 163 */
+ { "SmbNtCancel", SMB_SDT_OPS(nt_cancel), /* 0xA4 164 */
+ 0xA4, NT_LM_0_12, 0 },
+ { "SmbNtRename", SMB_SDT_OPS(nt_rename), /* 0xA5 165 */
+ 0xA5, NT_LM_0_12, 0 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0xA6, 0, 0 }, /* 0xA6 166 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xA7, 0, 0 }, /* 0xA7 167 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xA8, 0, 0 }, /* 0xA8 168 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xA9, 0, 0 }, /* 0xA9 169 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xAA, 0, 0 }, /* 0xAA 170 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xAB, 0, 0 }, /* 0xAB 171 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xAC, 0, 0 }, /* 0xAC 172 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xAD, 0, 0 }, /* 0xAD 173 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xAE, 0, 0 }, /* 0xAE 174 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xAF, 0, 0 }, /* 0xAF 175 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB0, 0, 0 }, /* 0xB0 176 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB1, 0, 0 }, /* 0xB1 177 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB2, 0, 0 }, /* 0xB2 178 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB3, 0, 0 }, /* 0xB3 179 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB4, 0, 0 }, /* 0xB4 180 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB5, 0, 0 }, /* 0xB5 181 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB6, 0, 0 }, /* 0xB6 182 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB7, 0, 0 }, /* 0xB7 183 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB8, 0, 0 }, /* 0xB8 184 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xB9, 0, 0 }, /* 0xB9 185 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xBA, 0, 0 }, /* 0xBA 186 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xBB, 0, 0 }, /* 0xBB 187 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xBC, 0, 0 }, /* 0xBC 188 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xBD, 0, 0 }, /* 0xBD 189 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xBE, 0, 0 }, /* 0xBE 190 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xBF, 0, 0 }, /* 0xBF 191 */
+ { "SmbOpenPrintFile", SMB_SDT_OPS(open_print_file), /* 0xC0 192 */
+ 0xC0, PC_NETWORK_PROGRAM_1_0, 0 },
+ { "SmbWritePrintFile", SMB_SDT_OPS(write_print_file), /* 0xC1 193 */
+ 0xC1, PC_NETWORK_PROGRAM_1_0, 0 },
+ { "SmbClosePrintFile", SMB_SDT_OPS(close_print_file), /* 0xC2 194 */
+ 0xC2, PC_NETWORK_PROGRAM_1_0, 0 },
+ { "SmbGetPrintQueue", SMB_SDT_OPS(get_print_queue), /* 0xC3 195 */
+ 0xC3, PC_NETWORK_PROGRAM_1_0, 0 },
+ { "Invalid", SMB_SDT_OPS(invalid), 0xC4, 0, 0 }, /* 0xC4 196 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xC5, 0, 0 }, /* 0xC5 197 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xC6, 0, 0 }, /* 0xC6 198 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xC7, 0, 0 }, /* 0xC7 199 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xC8, 0, 0 }, /* 0xC8 200 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xC9, 0, 0 }, /* 0xC9 201 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xCA, 0, 0 }, /* 0xCA 202 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xCB, 0, 0 }, /* 0xCB 203 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xCC, 0, 0 }, /* 0xCC 204 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xCD, 0, 0 }, /* 0xCD 205 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xCE, 0, 0 }, /* 0xCE 206 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xCF, 0, 0 }, /* 0xCF 207 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD0, 0, 0 }, /* 0xD0 208 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD1, 0, 0 }, /* 0xD1 209 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD2, 0, 0 }, /* 0xD2 210 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD3, 0, 0 }, /* 0xD3 211 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD4, 0, 0 }, /* 0xD4 212 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD5, 0, 0 }, /* 0xD5 213 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD6, 0, 0 }, /* 0xD6 214 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD7, 0, 0 }, /* 0xD7 215 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD8, 0, 0 }, /* 0xD8 216 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xD9, 0, 0 }, /* 0xD9 217 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xDA, 0, 0 }, /* 0xDA 218 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xDB, 0, 0 }, /* 0xDB 219 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xDC, 0, 0 }, /* 0xDC 220 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xDD, 0, 0 }, /* 0xDD 221 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xDE, 0, 0 }, /* 0xDE 222 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xDF, 0, 0 }, /* 0xDF 223 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE0, 0, 0 }, /* 0xE0 224 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE1, 0, 0 }, /* 0xE1 225 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE2, 0, 0 }, /* 0xE2 226 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE3, 0, 0 }, /* 0xE3 227 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE4, 0, 0 }, /* 0xE4 228 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE5, 0, 0 }, /* 0xE5 229 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE6, 0, 0 }, /* 0xE6 230 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE7, 0, 0 }, /* 0xE7 231 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE8, 0, 0 }, /* 0xE8 232 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xE9, 0, 0 }, /* 0xE9 233 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xEA, 0, 0 }, /* 0xEA 234 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xEB, 0, 0 }, /* 0xEB 235 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xEC, 0, 0 }, /* 0xEC 236 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xED, 0, 0 }, /* 0xED 237 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xEE, 0, 0 }, /* 0xEE 238 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xEF, 0, 0 }, /* 0xEF 239 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF0, 0, 0 }, /* 0xF0 240 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF1, 0, 0 }, /* 0xF1 241 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF2, 0, 0 }, /* 0xF2 242 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF3, 0, 0 }, /* 0xF3 243 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF4, 0, 0 }, /* 0xF4 244 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF5, 0, 0 }, /* 0xF5 245 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF6, 0, 0 }, /* 0xF6 246 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF7, 0, 0 }, /* 0xF7 247 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF8, 0, 0 }, /* 0xF8 248 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xF9, 0, 0 }, /* 0xF9 249 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xFA, 0, 0 }, /* 0xFA 250 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xFB, 0, 0 }, /* 0xFB 251 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xFC, 0, 0 }, /* 0xFC 252 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xFD, 0, 0 }, /* 0xFD 253 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xFE, 0, 0 }, /* 0xFE 254 */
+ { "Invalid", SMB_SDT_OPS(invalid), 0xFF, 0, 0 } /* 0xFF 255 */
};
/*
@@ -650,7 +595,7 @@ smb_dispatch_request(struct smb_request *sr)
}
andx_more:
- sdd = &dispatch[sr->smb_com];
+ sdd = &smb_disp_table[sr->smb_com];
ASSERT(sdd->sdt_function);
if (smb_mbc_decodef(&sr->command, "b", &sr->smb_wct) != 0) {
@@ -666,6 +611,10 @@ andx_more:
goto report_error;
}
+ atomic_add_64(&sdd->sdt_rxb,
+ (int64_t)(sr->smb_wct * 2 + sr->smb_bcc + 1));
+ sr->sr_txb = sr->reply.chain_offset;
+
/*
* Ignore smb_bcc if CAP_LARGE_READX/CAP_LARGE_WRITEX
* and this is SmbReadX/SmbWriteX since this enables
@@ -761,14 +710,7 @@ andx_more:
}
smb_rwx_rwexit(&session->s_lock);
- /*
- * Increment method invocation count. This value is exposed
- * via kstats, and it represents a count of all the dispatched
- * requests, including the ones that have a return value, other
- * than SDRC_SUCCESS.
- */
- SMB_ALL_DISPATCH_STAT_INCR(sdd->sdt_dispatch_stats.value.ui64);
-
+ sr->sr_time_start = gethrtime();
if ((sdrc = (*sdd->sdt_pre_op)(sr)) == SDRC_SUCCESS)
sdrc = (*sdd->sdt_function)(sr);
@@ -776,6 +718,10 @@ andx_more:
(*sdd->sdt_post_op)(sr);
smbsr_cleanup(sr);
}
+ smb_latency_add_sample(&sdd->sdt_lat, gethrtime() - sr->sr_time_start);
+
+ atomic_add_64(&sdd->sdt_txb,
+ (int64_t)(sr->reply.chain_offset - sr->sr_txb));
if (sdrc != SDRC_SUCCESS) {
/*
@@ -977,8 +923,14 @@ smbsr_decode_data(struct smb_request *sr, char *fmt, ...)
return (rc);
}
+boolean_t
+smbsr_decode_data_avail(smb_request_t *sr)
+{
+ return (sr->smb_data.chain_offset < sr->smb_data.max_bytes);
+}
+
void
-smbsr_send_reply(struct smb_request *sr)
+smbsr_send_reply(smb_request_t *sr)
{
if (SMB_TREE_IS_CASEINSENSITIVE(sr))
sr->smb_flg |= SMB_FLAGS_CASE_INSENSITIVE;
@@ -1002,6 +954,7 @@ smbsr_send_reply(struct smb_request *sr)
if (sr->session->signing.flags & SMB_SIGNING_ENABLED)
smb_sign_reply(sr, NULL);
+ smb_server_inc_req(sr->session->s_server);
if (smb_session_send(sr->session, 0, &sr->reply) == 0)
sr->reply.chain = 0;
}
@@ -1054,7 +1007,6 @@ smbsr_map_errno(int errnum, smb_error_t *err)
for (i = 0; i < sizeof (smb_errno_map)/sizeof (smb_errno_map[0]); ++i) {
if (smb_errno_map[i].errnum == errnum) {
- err->severity = ERROR_SEVERITY_ERROR;
err->status = smb_errno_map[i].status32;
err->errcls = smb_errno_map[i].errcls;
err->errcode = smb_errno_map[i].errcode;
@@ -1062,7 +1014,6 @@ smbsr_map_errno(int errnum, smb_error_t *err)
}
}
- err->severity = ERROR_SEVERITY_ERROR;
err->status = NT_STATUS_INTERNAL_ERROR;
err->errcls = ERRDOS;
err->errcode = ERROR_INTERNAL_ERROR;
@@ -1076,26 +1027,11 @@ smbsr_errno(struct smb_request *sr, int errnum)
}
/*
- * Report a request processing warning.
- */
-void
-smbsr_warn(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode)
-{
- sr->smb_error.severity = ERROR_SEVERITY_WARNING;
- sr->smb_error.status = status;
- sr->smb_error.errcls = errcls;
- sr->smb_error.errcode = errcode;
-
- smbsr_set_error(sr, &sr->smb_error);
-}
-
-/*
- * Report a request processing error. This function will not return.
+ * Report a request processing status (error or warning).
*/
void
-smbsr_error(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode)
+smbsr_status(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode)
{
- sr->smb_error.severity = ERROR_SEVERITY_ERROR;
sr->smb_error.status = status;
sr->smb_error.errcls = errcls;
sr->smb_error.errcode = errcode;
@@ -1116,14 +1052,12 @@ void
smbsr_set_error(smb_request_t *sr, smb_error_t *err)
{
uint32_t status;
- uint32_t severity;
uint32_t capabilities;
ASSERT(sr);
ASSERT(err);
status = err->status;
- severity = (err->severity == 0) ? ERROR_SEVERITY_ERROR : err->severity;
capabilities = sr->session->capabilities;
if ((err->errcls == 0) && (err->errcode == 0)) {
@@ -1133,7 +1067,6 @@ smbsr_set_error(smb_request_t *sr, smb_error_t *err)
}
if ((capabilities & CAP_STATUS32) && (status != 0)) {
- status |= severity;
sr->smb_rcls = status & 0xff;
sr->smb_reh = (status >> 8) & 0xff;
sr->smb_err = status >> 16;
@@ -1240,76 +1173,62 @@ smb_com_invalid(smb_request_t *sr)
}
/*
- * smb_dispatch_kstat_update
+ * smb_dispatch_stats_init
*
- * This callback function updates the smb_dispatch_kstat_data when kstat
- * command is invoked.
+ * Initializes dispatch statistics.
*/
-static int
-smb_dispatch_kstat_update(kstat_t *ksp, int rw)
+void
+smb_dispatch_stats_init(smb_kstat_req_t *ksr)
{
- smb_disp_entry_t *sdd;
- kstat_named_t *ks_named;
- int i;
+ int i;
- if (rw == KSTAT_WRITE)
- return (EACCES);
-
- ASSERT(MUTEX_HELD(ksp->ks_lock));
-
- ks_named = ksp->ks_data;
- for (i = 0; i < SMB_COM_NUM; i++) {
- sdd = &dispatch[i];
-
- if (sdd->sdt_function != smb_com_invalid) {
- bcopy(&sdd->sdt_dispatch_stats, ks_named,
- sizeof (kstat_named_t));
- ++ks_named;
- }
+ for (i = 0; i < SMB_COM_NUM; i++, ksr++) {
+ smb_latency_init(&smb_disp_table[i].sdt_lat);
+ (void) strlcpy(ksr->kr_name, smb_disp_table[i].sdt_name,
+ sizeof (ksr->kr_name));
}
-
- return (0);
}
/*
- * smb_dispatch_kstat_init
+ * smb_dispatch_stats_fini
*
- * Initialize dispatch kstats.
+ * Frees and destroyes the resources used for statistics.
*/
void
-smb_dispatch_kstat_init(void)
+smb_dispatch_stats_fini(void)
{
- int ks_ndata;
- int i;
-
- for (i = 0, ks_ndata = 0; i < SMB_COM_NUM; i++) {
- if (dispatch[i].sdt_function != smb_com_invalid)
- ks_ndata++;
- }
-
- smb_dispatch_ksp = kstat_create(SMBSRV_KSTAT_MODULE, 0,
- SMBSRV_KSTAT_NAME_CMDS, SMBSRV_KSTAT_CLASS,
- KSTAT_TYPE_NAMED, ks_ndata, 0);
+ int i;
- if (smb_dispatch_ksp) {
- mutex_init(&smb_dispatch_ksmtx, NULL, MUTEX_DEFAULT, NULL);
- smb_dispatch_ksp->ks_update = smb_dispatch_kstat_update;
- smb_dispatch_ksp->ks_lock = &smb_dispatch_ksmtx;
- kstat_install(smb_dispatch_ksp);
- }
+ for (i = 0; i < SMB_COM_NUM; i++)
+ smb_latency_destroy(&smb_disp_table[i].sdt_lat);
}
-/*
- * smb_dispatch_kstat_fini
- *
- * Remove dispatch kstats.
- */
void
-smb_dispatch_kstat_fini(void)
+smb_dispatch_stats_update(smb_kstat_req_t *ksr, int first, int nreq)
{
- if (smb_dispatch_ksp != NULL) {
- kstat_delete(smb_dispatch_ksp);
- mutex_destroy(&smb_dispatch_ksmtx);
- smb_dispatch_ksp = NULL;
+ int i;
+ int last;
+
+ last = first + nreq - 1;
+
+ if ((first < SMB_COM_NUM) && (last < SMB_COM_NUM)) {
+ for (i = first; i <= last; i++, ksr++) {
+ ksr->kr_rxb = smb_disp_table[i].sdt_rxb;
+ ksr->kr_txb = smb_disp_table[i].sdt_txb;
+ mutex_enter(&smb_disp_table[i].sdt_lat.ly_mutex);
+ ksr->kr_nreq = smb_disp_table[i].sdt_lat.ly_a_nreq;
+ ksr->kr_sum = smb_disp_table[i].sdt_lat.ly_a_sum;
+ ksr->kr_a_mean = smb_disp_table[i].sdt_lat.ly_a_mean;
+ ksr->kr_a_stddev =
+ smb_disp_table[i].sdt_lat.ly_a_stddev;
+ ksr->kr_d_mean = smb_disp_table[i].sdt_lat.ly_d_mean;
+ ksr->kr_d_stddev =
+ smb_disp_table[i].sdt_lat.ly_d_stddev;
+ smb_disp_table[i].sdt_lat.ly_d_mean = 0;
+ smb_disp_table[i].sdt_lat.ly_d_nreq = 0;
+ smb_disp_table[i].sdt_lat.ly_d_stddev = 0;
+ smb_disp_table[i].sdt_lat.ly_d_sum = 0;
+ mutex_exit(&smb_disp_table[i].sdt_lat.ly_mutex);
+ }
}
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_find.c b/usr/src/uts/common/fs/smbsrv/smb_find.c
index ab0c9a4974..a100ffac48 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_find.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_find.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <smbsrv/smb_kproto.h>
@@ -195,6 +194,9 @@
* circuit to the consumer.
*/
+#define SMB_NAME83_BUFLEN 12
+static void smb_name83(const char *, char *, size_t);
+
/* *** smb_com_search *** */
smb_sdrc_t
@@ -219,6 +221,7 @@ smb_com_search(smb_request_t *sr)
uint16_t key_len;
uint32_t client_key;
char name[SMB_SHORTNAMELEN];
+ char name83[SMB_SHORTNAMELEN];
smb_pathname_t *pn;
unsigned char resume_char;
unsigned char type;
@@ -328,25 +331,20 @@ smb_com_search(smb_request_t *sr)
if ((rc != 0 || (eos == B_TRUE)))
break;
- (void) memset(name, ' ', sizeof (name));
if (*fileinfo.fi_shortname == '\0') {
- (void) strlcpy(name, fileinfo.fi_name,
+ (void) strlcpy(fileinfo.fi_shortname, fileinfo.fi_name,
SMB_SHORTNAMELEN - 1);
if (to_upper)
- (void) smb_strupr(name);
- } else {
- (void) strlcpy(name, fileinfo.fi_shortname,
- SMB_SHORTNAMELEN - 1);
+ (void) smb_strupr(fileinfo.fi_shortname);
}
+ smb_name83(fileinfo.fi_shortname, name83, SMB_SHORTNAMELEN);
- (void) smb_mbc_encodef(&sr->reply, "b8c3c.wwlbYl13c",
- resume_char,
- fileinfo.fi_name83, fileinfo.fi_name83+9,
- index, odid, client_key,
+ (void) smb_mbc_encodef(&sr->reply, "b11c.wwlbYl13c",
+ resume_char, name83, index, odid, client_key,
fileinfo.fi_dosattr & 0xff,
smb_time_gmt_to_local(sr, fileinfo.fi_mtime.tv_sec),
(int32_t)fileinfo.fi_size,
- name);
+ fileinfo.fi_shortname);
smb_odir_save_cookie(od, index, fileinfo.fi_cookie);
@@ -404,7 +402,7 @@ smb_com_find(smb_request_t *sr)
uint16_t sattr, odid;
uint16_t key_len;
uint32_t client_key;
- char name[SMB_SHORTNAMELEN];
+ char name83[SMB_SHORTNAMELEN];
smb_odir_t *od;
smb_fileinfo_t fileinfo;
boolean_t eos;
@@ -477,23 +475,18 @@ smb_com_find(smb_request_t *sr)
if ((rc != 0 || (eos == B_TRUE)))
break;
- (void) memset(name, ' ', sizeof (name));
if (*fileinfo.fi_shortname == '\0') {
- (void) strlcpy(name, fileinfo.fi_name,
- SMB_SHORTNAMELEN - 1);
- } else {
- (void) strlcpy(name, fileinfo.fi_shortname,
+ (void) strlcpy(fileinfo.fi_shortname, fileinfo.fi_name,
SMB_SHORTNAMELEN - 1);
}
+ smb_name83(fileinfo.fi_shortname, name83, SMB_SHORTNAMELEN);
- (void) smb_mbc_encodef(&sr->reply, "b8c3c.wwlbYl13c",
- resume_char,
- fileinfo.fi_name83, fileinfo.fi_name83+9,
- index, odid, client_key,
+ (void) smb_mbc_encodef(&sr->reply, "b11c.wwlbYl13c",
+ resume_char, name83, index, odid, client_key,
fileinfo.fi_dosattr & 0xff,
smb_time_gmt_to_local(sr, fileinfo.fi_mtime.tv_sec),
(int32_t)fileinfo.fi_size,
- name);
+ fileinfo.fi_shortname);
smb_odir_save_cookie(od, index, fileinfo.fi_cookie);
@@ -618,7 +611,7 @@ smb_com_find_unique(struct smb_request *sr)
smb_pathname_t *pn;
unsigned char resume_char = '\0';
uint32_t client_key = 0;
- char name[SMB_SHORTNAMELEN];
+ char name83[SMB_SHORTNAMELEN];
smb_odir_t *od;
smb_fileinfo_t fileinfo;
boolean_t eos;
@@ -666,23 +659,18 @@ smb_com_find_unique(struct smb_request *sr)
if ((rc != 0 || (eos == B_TRUE)))
break;
- (void) memset(name, ' ', sizeof (name));
if (*fileinfo.fi_shortname == '\0') {
- (void) strlcpy(name, fileinfo.fi_name,
- SMB_SHORTNAMELEN - 1);
- } else {
- (void) strlcpy(name, fileinfo.fi_shortname,
+ (void) strlcpy(fileinfo.fi_shortname, fileinfo.fi_name,
SMB_SHORTNAMELEN - 1);
}
+ smb_name83(fileinfo.fi_shortname, name83, SMB_SHORTNAMELEN);
- (void) smb_mbc_encodef(&sr->reply, "b8c3c.wwlbYl13c",
- resume_char,
- fileinfo.fi_name83, fileinfo.fi_name83+9,
- index, odid, client_key,
+ (void) smb_mbc_encodef(&sr->reply, "b11c.wwlbYl13c",
+ resume_char, name83, index, odid, client_key,
fileinfo.fi_dosattr & 0xff,
smb_time_gmt_to_local(sr, fileinfo.fi_mtime.tv_sec),
(int32_t)fileinfo.fi_size,
- name);
+ fileinfo.fi_shortname);
count++;
index++;
@@ -708,3 +696,56 @@ smb_com_find_unique(struct smb_request *sr)
return (SDRC_SUCCESS);
}
+
+/*
+ * smb_name83
+ *
+ * Format the filename for inclusion in the resume key. The filename
+ * returned in the resume key is 11 bytes:
+ * - up to 8 bytes of filename, space padded to 8 bytes
+ * - up to 3 bytes of ext, space padded to 3 bytes
+ *
+ * The name passed to smb_name83 should be a shortname or a name that
+ * doesn't require mangling.
+ *
+ * Examples:
+ * "fname.txt" -> "FNAME TXT"
+ * "fname.tx" -> "FNAME TX "
+ * "filename" -> "FILENAME "
+ * "filename.txt" -> "FILENAMETXT"
+ * "FILE~1.TXT" -> "FILE~1 TXT"
+ */
+static void
+smb_name83(const char *name, char *buf, size_t buflen)
+{
+ const char *p;
+ char *pbuf;
+ int i;
+
+ ASSERT(name && buf && (buflen >= SMB_NAME83_BUFLEN));
+
+ (void) strlcpy(buf, " ", SMB_NAME83_BUFLEN);
+
+ /* Process "." and ".." up front */
+ if ((strcmp(name, ".") == 0) || (strcmp(name, "..") == 0)) {
+ (void) strncpy(buf, name, strlen(name));
+ return;
+ }
+
+ ASSERT(smb_needs_mangled(name) == B_FALSE);
+
+ /* Process basename */
+ for (i = 0, p = name, pbuf = buf;
+ (i < SMB_NAME83_BASELEN) && (*p != '\0') && (*p != '.'); ++i)
+ *pbuf++ = *p++;
+
+ /* Process the extension from the last dot in name */
+ if ((p = strchr(name, '.')) != NULL) {
+ ++p;
+ pbuf = &buf[SMB_NAME83_BASELEN];
+ for (i = 0; (i < SMB_NAME83_EXTLEN) && (*p != '\0'); ++i)
+ *pbuf++ = *p++;
+ }
+
+ (void) smb_strupr(buf);
+}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_fsops.c b/usr/src/uts/common/fs/smbsrv/smb_fsops.c
index 1609bfea87..bf0b296076 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_fsops.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_fsops.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/sid.h>
@@ -355,10 +354,9 @@ smb_fsop_create(smb_request_t *sr, cred_t *cr, smb_node_t *dnode,
/* Not a named stream */
- if (smb_maybe_mangled_name(name)) {
+ if (smb_maybe_mangled(name)) {
longname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
- rc = smb_unmangle_name(dnode, name, longname,
- MAXNAMELEN, flags);
+ rc = smb_unmangle(dnode, name, longname, MAXNAMELEN, flags);
kmem_free(longname, MAXNAMELEN);
if (rc == 0)
@@ -468,7 +466,7 @@ smb_fsop_create_file(smb_request_t *sr, cred_t *cr,
smb_node_t *dnode, char *name, int flags,
smb_attr_t *attr, smb_node_t **ret_snode)
{
- open_param_t *op = &sr->arg.open;
+ smb_arg_open_t *op = &sr->sr_open;
vnode_t *vp;
smb_fssd_t fs_sd;
uint32_t secinfo;
@@ -586,10 +584,9 @@ smb_fsop_mkdir(
if (SMB_TREE_SUPPORTS_ABE(sr))
flags |= SMB_ABE;
- if (smb_maybe_mangled_name(name)) {
+ if (smb_maybe_mangled(name)) {
longname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
- rc = smb_unmangle_name(dnode, name, longname,
- MAXNAMELEN, flags);
+ rc = smb_unmangle(dnode, name, longname, MAXNAMELEN, flags);
kmem_free(longname, MAXNAMELEN);
/*
@@ -749,7 +746,7 @@ smb_fsop_remove(
rc = smb_vop_remove(dnode->vp, name, flags, cr);
if (rc == ENOENT) {
- if (smb_maybe_mangled_name(name) == 0) {
+ if (!smb_maybe_mangled(name)) {
kmem_free(fname, MAXNAMELEN);
kmem_free(sname, MAXNAMELEN);
return (rc);
@@ -759,8 +756,8 @@ smb_fsop_remove(
if (SMB_TREE_SUPPORTS_ABE(sr))
flags |= SMB_ABE;
- rc = smb_unmangle_name(dnode, name,
- longname, MAXNAMELEN, flags);
+ rc = smb_unmangle(dnode, name, longname, MAXNAMELEN,
+ flags);
if (rc == 0) {
/*
@@ -892,15 +889,14 @@ smb_fsop_rmdir(
rc = smb_vop_rmdir(dnode->vp, name, flags, cr);
if (rc == ENOENT) {
- if (smb_maybe_mangled_name(name) == 0)
+ if (!smb_maybe_mangled(name))
return (rc);
longname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
if (SMB_TREE_SUPPORTS_ABE(sr))
flags |= SMB_ABE;
- rc = smb_unmangle_name(dnode, name, longname,
- MAXNAMELEN, flags);
+ rc = smb_unmangle(dnode, name, longname, MAXNAMELEN, flags);
if (rc == 0) {
/*
@@ -1035,10 +1031,10 @@ smb_fsop_link(smb_request_t *sr, cred_t *cr, smb_node_t *from_fnode,
if (SMB_TREE_SUPPORTS_ABE(sr))
flags |= SMB_ABE;
- if (smb_maybe_mangled_name(to_name)) {
+ if (smb_maybe_mangled(to_name)) {
longname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
- rc = smb_unmangle_name(to_dnode, to_name,
- longname, MAXNAMELEN, flags);
+ rc = smb_unmangle(to_dnode, to_name, longname,
+ MAXNAMELEN, flags);
kmem_free(longname, MAXNAMELEN);
if (rc == 0)
@@ -1593,6 +1589,13 @@ smb_fsop_access(smb_request_t *sr, cred_t *cr, smb_node_t *snode,
*
* Return an error if the looked-up file is in outside the tree.
* (Required when invoked from open path.)
+ *
+ * Case sensitivity flags (SMB_IGNORE_CASE, SMB_CASE_SENSITIVE):
+ * if SMB_CASE_SENSITIVE is set, the SMB_IGNORE_CASE flag will NOT be set
+ * based on the tree's case sensitivity. However, if the SMB_IGNORE_CASE
+ * flag is set in the flags value passed as a parameter, a case insensitive
+ * lookup WILL be done (regardless of whether SMB_CASE_SENSITIVE is set
+ * or not).
*/
int
@@ -1622,8 +1625,10 @@ smb_fsop_lookup_name(
* The following check is required for streams processing, below
*/
- if (SMB_TREE_IS_CASEINSENSITIVE(sr))
- flags |= SMB_IGNORE_CASE;
+ if (!(flags & SMB_CASE_SENSITIVE)) {
+ if (SMB_TREE_IS_CASEINSENSITIVE(sr))
+ flags |= SMB_IGNORE_CASE;
+ }
fname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
sname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
@@ -1774,14 +1779,13 @@ smb_fsop_lookup(
&ret_flags, root_node ? root_node->vp : NULL, &attr, cr);
if (rc != 0) {
- if (smb_maybe_mangled_name(name) == 0) {
+ if (!smb_maybe_mangled(name)) {
kmem_free(od_name, MAXNAMELEN);
return (rc);
}
longname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
- rc = smb_unmangle_name(dnode, name, longname,
- MAXNAMELEN, flags);
+ rc = smb_unmangle(dnode, name, longname, MAXNAMELEN, flags);
if (rc != 0) {
kmem_free(od_name, MAXNAMELEN);
kmem_free(longname, MAXNAMELEN);
diff --git a/usr/src/uts/common/fs/smbsrv/smb_init.c b/usr/src/uts/common/fs/smbsrv/smb_init.c
index 469b74e4c8..56c4dbe2c2 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_init.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_init.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
@@ -133,14 +132,21 @@ static dev_info_t *smb_drv_dip = NULL;
int
_init(void)
{
- int rc;
+ int rc;
+
+ if ((rc = smb_kshare_init()) != 0)
+ return (rc);
+
+ if ((rc = smb_server_svc_init()) != 0) {
+ smb_kshare_fini();
+ return (rc);
+ }
- rc = smb_server_svc_init();
- if (rc == 0) {
- rc = mod_install(&modlinkage);
- if (rc != 0)
- (void) smb_server_svc_fini();
+ if ((rc = mod_install(&modlinkage)) != 0) {
+ smb_kshare_fini();
+ (void) smb_server_svc_fini();
}
+
return (rc);
}
@@ -155,9 +161,11 @@ _fini(void)
{
int rc;
- rc = mod_remove(&modlinkage);
- if (rc == 0)
+ if ((rc = mod_remove(&modlinkage)) == 0) {
rc = smb_server_svc_fini();
+ smb_kshare_fini();
+ }
+
return (rc);
}
@@ -244,10 +252,10 @@ smb_drv_ioctl(dev_t drv, int cmd, intptr_t argp, int flags, cred_t *cred,
rc = smb_server_set_gmtoff(&ioc->ioc_gmt);
break;
case SMB_IOC_SHARE:
- rc = smb_server_share_export(&ioc->ioc_share);
+ rc = smb_kshare_export_list(&ioc->ioc_share);
break;
case SMB_IOC_UNSHARE:
- rc = smb_server_share_unexport(&ioc->ioc_share);
+ rc = smb_kshare_unexport_list(&ioc->ioc_share);
break;
case SMB_IOC_NUMOPEN:
rc = smb_server_numopen(&ioc->ioc_opennum);
diff --git a/usr/src/uts/common/fs/smbsrv/smb_kshare.c b/usr/src/uts/common/fs/smbsrv/smb_kshare.c
index c65f69e814..bf17a244f5 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_kshare.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_kshare.c
@@ -18,230 +18,69 @@
*
* CDDL HEADER END
*/
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- */
/*
- * Kernel door client for LanMan share management.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#include <sys/ddi.h>
-#include <sys/sunddi.h>
-#include <sys/cmn_err.h>
-#include <sys/door.h>
-#include <smbsrv/lmerr.h>
-#include <smbsrv/smb_share.h>
#include <smbsrv/smb_door.h>
-#include <smbsrv/smbinfo.h>
+#include <smbsrv/smb_kproto.h>
+#include <smbsrv/smb_ktypes.h>
+
+typedef struct smb_unshare {
+ list_node_t us_lnd;
+ char us_sharename[MAXNAMELEN];
+} smb_unshare_t;
+
+static smb_export_t smb_export;
+
+static int smb_kshare_cmp(const void *, const void *);
+static void smb_kshare_hold(const void *);
+static boolean_t smb_kshare_rele(const void *);
+static void smb_kshare_destroy(void *);
+static char *smb_kshare_oemname(const char *);
+static int smb_kshare_is_special(const char *);
+static boolean_t smb_kshare_is_admin(const char *);
+static smb_kshare_t *smb_kshare_decode(nvlist_t *);
+static uint32_t smb_kshare_decode_bool(nvlist_t *, const char *, uint32_t);
+static void smb_kshare_unexport_thread(smb_thread_t *, void *);
+static int smb_kshare_export(smb_kshare_t *);
+static int smb_kshare_unexport(const char *);
+static int smb_kshare_export_trans(char *, char *, char *);
+static void smb_kshare_csc_flags(smb_kshare_t *, const char *);
+
+static boolean_t smb_export_isready(void);
static int smb_kshare_chk_dsrv_status(int, smb_dr_ctx_t *);
+static smb_avl_nops_t smb_kshare_avlops = {
+ smb_kshare_cmp,
+ smb_kshare_hold,
+ smb_kshare_rele,
+ smb_kshare_destroy
+};
+
/*
- * smb_kshare_init
- *
* This function is not MultiThread safe. The caller has to make sure only one
* thread calls this function.
*/
door_handle_t
-smb_kshare_init(int door_id)
+smb_kshare_door_init(int door_id)
{
return (door_ki_lookup(door_id));
}
/*
- * smb_kshare_fini
- *
* This function is not MultiThread safe. The caller has to make sure only one
* thread calls this function.
*/
void
-smb_kshare_fini(door_handle_t dhdl)
+smb_kshare_door_fini(door_handle_t dhdl)
{
if (dhdl)
door_ki_rele(dhdl);
}
-uint32_t
-smb_kshare_getinfo(door_handle_t dhdl, char *share_name, smb_share_t *si,
- smb_inaddr_t *ipaddr)
-{
- door_arg_t arg;
- char *buf;
- unsigned int used;
- smb_dr_ctx_t *dec_ctx;
- smb_dr_ctx_t *enc_ctx;
- uint32_t rc;
- int opcode = SMB_SHROP_GETINFO;
-
- buf = kmem_alloc(SMB_SHARE_DSIZE, KM_SLEEP);
-
- enc_ctx = smb_dr_encode_start(buf, SMB_SHARE_DSIZE);
- smb_dr_put_uint32(enc_ctx, opcode);
- smb_dr_put_string(enc_ctx, share_name);
- smb_dr_put_buf(enc_ctx, (uchar_t *)ipaddr, sizeof (smb_inaddr_t));
-
- if (smb_dr_encode_finish(enc_ctx, &used) != 0) {
- kmem_free(buf, SMB_SHARE_DSIZE);
- return (NERR_InternalError);
- }
-
- arg.data_ptr = buf;
- arg.data_size = used;
- arg.desc_ptr = NULL;
- arg.desc_num = 0;
- arg.rbuf = buf;
- arg.rsize = SMB_SHARE_DSIZE;
-
- if (door_ki_upcall_limited(dhdl, &arg, NULL, SIZE_MAX, 0) != 0) {
- kmem_free(buf, SMB_SHARE_DSIZE);
- return (NERR_InternalError);
- }
-
- dec_ctx = smb_dr_decode_start(arg.data_ptr, arg.data_size);
- if (smb_kshare_chk_dsrv_status(opcode, dec_ctx) != 0) {
- kmem_free(buf, SMB_SHARE_DSIZE);
- return (NERR_InternalError);
- }
-
- rc = smb_dr_get_uint32(dec_ctx);
- smb_dr_get_share(dec_ctx, si);
- if (smb_dr_decode_finish(dec_ctx) != 0)
- rc = NERR_InternalError;
-
- kmem_free(buf, SMB_SHARE_DSIZE);
- return (rc);
-}
-
-uint32_t
-smb_kshare_enum(door_handle_t dhdl, smb_enumshare_info_t *enuminfo)
-{
- door_arg_t arg;
- char *door_buf;
- int door_bufsz;
- unsigned int used;
- smb_dr_ctx_t *dec_ctx;
- smb_dr_ctx_t *enc_ctx;
- uint32_t rc;
- int opcode = SMB_SHROP_ENUM;
-
- enuminfo->es_ntotal = enuminfo->es_nsent = 0;
-
- door_bufsz = enuminfo->es_bufsize + sizeof (smb_enumshare_info_t);
- door_buf = kmem_alloc(door_bufsz, KM_SLEEP);
-
- enc_ctx = smb_dr_encode_start(door_buf, door_bufsz);
- smb_dr_put_uint32(enc_ctx, opcode);
- smb_dr_put_ushort(enc_ctx, enuminfo->es_bufsize);
- smb_dr_put_uint32(enc_ctx, enuminfo->es_posix_uid);
-
- if (smb_dr_encode_finish(enc_ctx, &used) != 0) {
- kmem_free(door_buf, door_bufsz);
- return (NERR_InternalError);
- }
-
- arg.data_ptr = door_buf;
- arg.data_size = used;
- arg.desc_ptr = NULL;
- arg.desc_num = 0;
- arg.rbuf = door_buf;
- arg.rsize = door_bufsz;
-
- if (door_ki_upcall_limited(dhdl, &arg, NULL, SIZE_MAX, 0) != 0) {
- kmem_free(door_buf, door_bufsz);
- return (NERR_InternalError);
- }
-
- dec_ctx = smb_dr_decode_start(arg.data_ptr, arg.data_size);
- if (smb_kshare_chk_dsrv_status(opcode, dec_ctx) != 0) {
- kmem_free(door_buf, door_bufsz);
- return (NERR_InternalError);
- }
-
- rc = smb_dr_get_uint32(dec_ctx);
- if (rc == NERR_Success) {
- enuminfo->es_ntotal = smb_dr_get_ushort(dec_ctx);
- enuminfo->es_nsent = smb_dr_get_ushort(dec_ctx);
- enuminfo->es_datasize = smb_dr_get_ushort(dec_ctx);
- (void) smb_dr_get_buf(dec_ctx,
- (unsigned char *)enuminfo->es_buf,
- enuminfo->es_bufsize);
- }
-
- if (smb_dr_decode_finish(dec_ctx) != 0)
- rc = NERR_InternalError;
-
- kmem_free(door_buf, door_bufsz);
- return (rc);
-}
-
-/*
- * Executes map and unmap command for shares.
- */
-uint32_t
-smb_kshare_exec(door_handle_t dhdl, char *sharename, smb_execsub_info_t *subs,
- int exec_type)
-{
- door_arg_t arg;
- char *buf;
- int bufsz;
- unsigned int used;
- smb_dr_ctx_t *dec_ctx;
- smb_dr_ctx_t *enc_ctx;
- uint32_t rc;
- int opcode = SMB_SHROP_EXEC;
-
- bufsz = (2 * sizeof (int)) + strlen(sharename) + strlen(subs->e_winname)
- + strlen(subs->e_userdom) + strlen(subs->e_cli_netbiosname) +
- (2 * sizeof (smb_inaddr_t)) + sizeof (uid_t) +
- sizeof (smb_execsub_info_t);
-
- buf = kmem_alloc(bufsz, KM_SLEEP);
-
- enc_ctx = smb_dr_encode_start(buf, bufsz);
- smb_dr_put_uint32(enc_ctx, opcode);
- smb_dr_put_string(enc_ctx, sharename);
- smb_dr_put_string(enc_ctx, subs->e_winname);
- smb_dr_put_string(enc_ctx, subs->e_userdom);
- smb_dr_put_buf(enc_ctx, (uchar_t *)&subs->e_srv_ipaddr,
- sizeof (smb_inaddr_t));
- smb_dr_put_buf(enc_ctx, (uchar_t *)&subs->e_cli_ipaddr,
- sizeof (smb_inaddr_t));
- smb_dr_put_string(enc_ctx, subs->e_cli_netbiosname);
- smb_dr_put_int32(enc_ctx, subs->e_uid);
- smb_dr_put_int32(enc_ctx, exec_type);
-
- if (smb_dr_encode_finish(enc_ctx, &used) != 0) {
- kmem_free(buf, bufsz);
- return (NERR_InternalError);
- }
-
- arg.data_ptr = buf;
- arg.data_size = used;
- arg.desc_ptr = NULL;
- arg.desc_num = 0;
- arg.rbuf = buf;
- arg.rsize = bufsz;
-
- if (door_ki_upcall_limited(dhdl, &arg, NULL, SIZE_MAX, 0) != 0) {
- kmem_free(buf, bufsz);
- return (NERR_InternalError);
- }
-
- dec_ctx = smb_dr_decode_start(arg.data_ptr, arg.data_size);
- if (smb_kshare_chk_dsrv_status(opcode, dec_ctx) != 0) {
- kmem_free(buf, bufsz);
- return (NERR_InternalError);
- }
-
- rc = smb_dr_get_uint32(dec_ctx);
- if (smb_dr_decode_finish(dec_ctx) != 0)
- rc = NERR_InternalError;
-
- kmem_free(buf, bufsz);
- return (rc);
-}
-
/*
* This is a special interface that will be utilized by ZFS to cause
* a share to be added/removed
@@ -337,6 +176,970 @@ smb_kshare_upcall(door_handle_t dhdl, void *arg, boolean_t add_share)
}
/*
+ * Executes map and unmap command for shares.
+ */
+int
+smb_kshare_exec(smb_shr_execinfo_t *execinfo)
+{
+ int exec_rc = 0;
+
+ (void) smb_kdoor_upcall(SMB_DR_SHR_EXEC,
+ execinfo, smb_shr_execinfo_xdr, &exec_rc, xdr_int);
+
+ return (exec_rc);
+}
+
+/*
+ * Obtains any host access restriction on the specified
+ * share for the given host (ipaddr) by calling smbd
+ */
+uint32_t
+smb_kshare_hostaccess(smb_kshare_t *shr, smb_inaddr_t *ipaddr)
+{
+ smb_shr_hostaccess_query_t req;
+ uint32_t host_access = SMB_SHRF_ACC_OPEN;
+ uint32_t flag = SMB_SHRF_ACC_OPEN;
+ uint32_t access;
+
+ if (smb_inet_iszero(ipaddr))
+ return (ACE_ALL_PERMS);
+
+ if ((shr->shr_access_none == NULL || *shr->shr_access_none == '\0') &&
+ (shr->shr_access_ro == NULL || *shr->shr_access_ro == '\0') &&
+ (shr->shr_access_rw == NULL || *shr->shr_access_rw == '\0'))
+ return (ACE_ALL_PERMS);
+
+ if (shr->shr_access_none != NULL)
+ flag |= SMB_SHRF_ACC_NONE;
+ if (shr->shr_access_ro != NULL)
+ flag |= SMB_SHRF_ACC_RO;
+ if (shr->shr_access_rw != NULL)
+ flag |= SMB_SHRF_ACC_RW;
+
+ req.shq_none = shr->shr_access_none;
+ req.shq_ro = shr->shr_access_ro;
+ req.shq_rw = shr->shr_access_rw;
+ req.shq_flag = flag;
+ req.shq_ipaddr = *ipaddr;
+
+ (void) smb_kdoor_upcall(SMB_DR_SHR_HOSTACCESS,
+ &req, smb_shr_hostaccess_query_xdr, &host_access, xdr_uint32_t);
+
+ switch (host_access) {
+ case SMB_SHRF_ACC_RO:
+ access = ACE_ALL_PERMS & ~ACE_ALL_WRITE_PERMS;
+ break;
+ case SMB_SHRF_ACC_OPEN:
+ case SMB_SHRF_ACC_RW:
+ access = ACE_ALL_PERMS;
+ break;
+ case SMB_SHRF_ACC_NONE:
+ default:
+ access = 0;
+ }
+
+ return (access);
+}
+
+/*
+ * This function is called when smb_server_t is
+ * created which means smb/service is ready for
+ * exporting SMB shares
+ */
+void
+smb_export_start(void)
+{
+ mutex_enter(&smb_export.e_mutex);
+ if (smb_export.e_ready) {
+ mutex_exit(&smb_export.e_mutex);
+ return;
+ }
+
+ smb_export.e_ready = B_TRUE;
+ mutex_exit(&smb_export.e_mutex);
+
+ smb_avl_create(&smb_export.e_share_avl, sizeof (smb_kshare_t),
+ offsetof(smb_kshare_t, shr_link), &smb_kshare_avlops);
+
+ (void) smb_kshare_export_trans("IPC$", "IPC$", "Remote IPC");
+ (void) smb_kshare_export_trans("c$", SMB_CVOL, "Default Share");
+ (void) smb_kshare_export_trans("vss$", SMB_VSS, "VSS");
+}
+
+/*
+ * This function is called when smb_server_t goes
+ * away which means SMB shares should not be made
+ * available to clients
+ */
+void
+smb_export_stop(void)
+{
+ mutex_enter(&smb_export.e_mutex);
+ if (!smb_export.e_ready) {
+ mutex_exit(&smb_export.e_mutex);
+ return;
+ }
+ smb_export.e_ready = B_FALSE;
+ mutex_exit(&smb_export.e_mutex);
+
+ smb_avl_destroy(&smb_export.e_share_avl);
+ smb_vfs_rele_all(&smb_export);
+}
+
+int
+smb_kshare_init(void)
+{
+ int rc;
+
+ smb_export.e_cache_share = kmem_cache_create("smb_share_cache",
+ sizeof (smb_kshare_t), 8, NULL, NULL, NULL, NULL, NULL, 0);
+
+ smb_export.e_cache_unexport = kmem_cache_create("smb_unexport_cache",
+ sizeof (smb_unshare_t), 8, NULL, NULL, NULL, NULL, NULL, 0);
+
+ smb_export.e_cache_vfs = kmem_cache_create("smb_vfs_cache",
+ sizeof (smb_vfs_t), 8, NULL, NULL, NULL, NULL, NULL, 0);
+
+ smb_llist_constructor(&smb_export.e_vfs_list, sizeof (smb_vfs_t),
+ offsetof(smb_vfs_t, sv_lnd));
+
+ smb_slist_constructor(&smb_export.e_unexport_list,
+ sizeof (smb_unshare_t), offsetof(smb_unshare_t, us_lnd));
+
+ smb_thread_init(&smb_export.e_unexport_thread, "smb_thread_unexport",
+ smb_kshare_unexport_thread, NULL, NULL, NULL);
+
+ if ((rc = smb_thread_start(&smb_export.e_unexport_thread)) != 0)
+ return (rc);
+
+ return (0);
+}
+
+void
+smb_kshare_fini(void)
+{
+ smb_unshare_t *ux;
+
+ smb_thread_stop(&smb_export.e_unexport_thread);
+ smb_thread_destroy(&smb_export.e_unexport_thread);
+
+ while ((ux = list_head(&smb_export.e_unexport_list.sl_list)) != NULL) {
+ smb_slist_remove(&smb_export.e_unexport_list, ux);
+ kmem_cache_free(smb_export.e_cache_unexport, ux);
+ }
+ smb_slist_destructor(&smb_export.e_unexport_list);
+
+ smb_vfs_rele_all(&smb_export);
+
+ smb_llist_destructor(&smb_export.e_vfs_list);
+
+ kmem_cache_destroy(smb_export.e_cache_unexport);
+ kmem_cache_destroy(smb_export.e_cache_share);
+ kmem_cache_destroy(smb_export.e_cache_vfs);
+}
+
+/*
+ * A list of shares in nvlist format can be sent down
+ * from userspace thourgh the IOCTL interface. The nvlist
+ * is unpacked here and all the shares in the list will
+ * be exported.
+ */
+int
+smb_kshare_export_list(smb_ioc_share_t *ioc)
+{
+ nvlist_t *shrlist;
+ nvlist_t *share;
+ nvpair_t *nvp;
+ smb_kshare_t *shr;
+ char *shrname;
+ int rc;
+
+ if (!smb_export_isready())
+ return (ENOTACTIVE);
+
+ if ((rc = nvlist_unpack(ioc->shr, ioc->shrlen, &shrlist, KM_SLEEP))
+ != 0)
+ return (rc);
+
+ for (nvp = nvlist_next_nvpair(shrlist, NULL); nvp != NULL;
+ nvp = nvlist_next_nvpair(shrlist, nvp)) {
+ if (nvpair_type(nvp) != DATA_TYPE_NVLIST)
+ continue;
+
+ shrname = nvpair_name(nvp);
+ ASSERT(shrname);
+
+ if ((rc = nvpair_value_nvlist(nvp, &share)) != 0) {
+ cmn_err(CE_WARN, "export[%s]: failed accessing",
+ shrname);
+ continue;
+ }
+
+ if ((shr = smb_kshare_decode(share)) == NULL) {
+ cmn_err(CE_WARN, "export[%s]: failed decoding",
+ shrname);
+ continue;
+ }
+
+ if ((rc = smb_kshare_export(shr)) != 0) {
+ smb_kshare_destroy(shr);
+ continue;
+ }
+ }
+
+ nvlist_free(shrlist);
+
+ return (0);
+}
+
+/*
+ * This function is invoked when a share is disabled to disconnect trees
+ * and close files. Cleaning up may involve VOP and/or VFS calls, which
+ * may conflict/deadlock with stuck threads if something is amiss with the
+ * file system. Queueing the request for asynchronous processing allows the
+ * call to return immediately so that, if the unshare is being done in the
+ * context of a forced unmount, the forced unmount will always be able to
+ * proceed (unblocking stuck I/O and eventually allowing all blocked unshare
+ * processes to complete).
+ *
+ * The path lookup to find the root vnode of the VFS in question and the
+ * release of this vnode are done synchronously prior to any associated
+ * unmount. Doing these asynchronous to an associated unmount could run
+ * the risk of a spurious EBUSY for a standard unmount or an EIO during
+ * the path lookup due to a forced unmount finishing first.
+ */
+int
+smb_kshare_unexport_list(smb_ioc_share_t *ioc)
+{
+ smb_unshare_t *ux;
+ nvlist_t *shrlist;
+ nvpair_t *nvp;
+ boolean_t unexport = B_FALSE;
+ char *shrname;
+ int rc;
+
+ if ((rc = nvlist_unpack(ioc->shr, ioc->shrlen, &shrlist, 0)) != 0)
+ return (rc);
+
+ for (nvp = nvlist_next_nvpair(shrlist, NULL); nvp != NULL;
+ nvp = nvlist_next_nvpair(shrlist, nvp)) {
+ if (nvpair_type(nvp) != DATA_TYPE_NVLIST)
+ continue;
+
+ shrname = nvpair_name(nvp);
+ ASSERT(shrname);
+
+ if ((rc = smb_kshare_unexport(shrname)) != 0)
+ continue;
+
+ ux = kmem_cache_alloc(smb_export.e_cache_unexport, KM_SLEEP);
+ (void) strlcpy(ux->us_sharename, shrname, MAXNAMELEN);
+
+ smb_slist_insert_tail(&smb_export.e_unexport_list, ux);
+ unexport = B_TRUE;
+ }
+
+ nvlist_free(shrlist);
+
+ if (unexport)
+ smb_thread_signal(&smb_export.e_unexport_thread);
+
+ return (0);
+}
+
+/*
+ * This function builds a response for a NetShareEnum RAP request.
+ * List of shares is scanned twice. In the first round the total number
+ * of shares which their OEM name is shorter than 13 chars (esi->es_ntotal)
+ * and also the number of shares that fit in the given buffer are calculated.
+ * In the second round the shares data are encoded in the buffer.
+ *
+ * The data associated with each share has two parts, a fixed size part and
+ * a variable size part which is share's comment. The outline of the response
+ * buffer is so that fixed part for all the shares will appear first and follows
+ * with the comments for all those shares and that's why the data cannot be
+ * encoded in one round without unnecessarily complicating the code.
+ */
+void
+smb_kshare_enum(smb_enumshare_info_t *esi)
+{
+ smb_avl_t *share_avl;
+ smb_avl_cursor_t cursor;
+ smb_kshare_t *shr;
+ int remained;
+ uint16_t infolen = 0;
+ uint16_t cmntlen = 0;
+ uint16_t sharelen;
+ uint16_t clen;
+ uint32_t cmnt_offs;
+ smb_msgbuf_t info_mb;
+ smb_msgbuf_t cmnt_mb;
+ boolean_t autohome_added = B_FALSE;
+
+ if (!smb_export_isready()) {
+ esi->es_ntotal = esi->es_nsent = 0;
+ esi->es_datasize = 0;
+ return;
+ }
+
+ esi->es_ntotal = esi->es_nsent = 0;
+ remained = esi->es_bufsize;
+ share_avl = &smb_export.e_share_avl;
+
+ /* Do the necessary calculations in the first round */
+ smb_avl_iterinit(share_avl, &cursor);
+
+ while ((shr = smb_avl_iterate(share_avl, &cursor)) != NULL) {
+ if (shr->shr_oemname == NULL) {
+ smb_avl_release(share_avl, shr);
+ continue;
+ }
+
+ if ((shr->shr_flags & SMB_SHRF_AUTOHOME) && !autohome_added) {
+ if (esi->es_posix_uid == shr->shr_uid) {
+ autohome_added = B_TRUE;
+ } else {
+ smb_avl_release(share_avl, shr);
+ continue;
+ }
+ }
+
+ esi->es_ntotal++;
+
+ if (remained <= 0) {
+ smb_avl_release(share_avl, shr);
+ continue;
+ }
+
+ clen = strlen(shr->shr_cmnt) + 1;
+ sharelen = SHARE_INFO_1_SIZE + clen;
+
+ if (sharelen <= remained) {
+ infolen += SHARE_INFO_1_SIZE;
+ cmntlen += clen;
+ }
+
+ remained -= sharelen;
+ smb_avl_release(share_avl, shr);
+ }
+
+ esi->es_datasize = infolen + cmntlen;
+
+ smb_msgbuf_init(&info_mb, (uint8_t *)esi->es_buf, infolen, 0);
+ smb_msgbuf_init(&cmnt_mb, (uint8_t *)esi->es_buf + infolen, cmntlen, 0);
+ cmnt_offs = infolen;
+
+ /* Encode the data in the second round */
+ smb_avl_iterinit(share_avl, &cursor);
+ autohome_added = B_FALSE;
+
+ while ((shr = smb_avl_iterate(share_avl, &cursor)) != NULL) {
+ if (shr->shr_oemname == NULL) {
+ smb_avl_release(share_avl, shr);
+ continue;
+ }
+
+ if ((shr->shr_flags & SMB_SHRF_AUTOHOME) && !autohome_added) {
+ if (esi->es_posix_uid == shr->shr_uid) {
+ autohome_added = B_TRUE;
+ } else {
+ smb_avl_release(share_avl, shr);
+ continue;
+ }
+ }
+
+ if (smb_msgbuf_encode(&info_mb, "13c.wl",
+ shr->shr_oemname, shr->shr_type, cmnt_offs) < 0) {
+ smb_avl_release(share_avl, shr);
+ break;
+ }
+
+ if (smb_msgbuf_encode(&cmnt_mb, "s", shr->shr_cmnt) < 0) {
+ smb_avl_release(share_avl, shr);
+ break;
+ }
+
+ cmnt_offs += strlen(shr->shr_cmnt) + 1;
+ esi->es_nsent++;
+
+ smb_avl_release(share_avl, shr);
+ }
+
+ smb_msgbuf_term(&info_mb);
+ smb_msgbuf_term(&cmnt_mb);
+}
+
+/*
+ * Looks up the given share and returns a pointer
+ * to its definition if it's found. A hold on the
+ * object is taken before the pointer is returned
+ * in which case the caller MUST always call
+ * smb_kshare_release().
+ */
+smb_kshare_t *
+smb_kshare_lookup(const char *shrname)
+{
+ smb_kshare_t key;
+ smb_kshare_t *shr;
+
+ ASSERT(shrname);
+
+ if (!smb_export_isready())
+ return (NULL);
+
+ key.shr_name = (char *)shrname;
+ shr = smb_avl_lookup(&smb_export.e_share_avl, &key);
+
+ return (shr);
+}
+
+/*
+ * Releases the hold taken on the specified share object
+ */
+void
+smb_kshare_release(smb_kshare_t *shr)
+{
+ ASSERT(shr);
+ ASSERT(shr->shr_magic == SMB_SHARE_MAGIC);
+
+ smb_avl_release(&smb_export.e_share_avl, shr);
+}
+
+
+/*
+ * Add the given share in the specified server.
+ * If the share is a disk share, smb_vfs_hold() is
+ * invoked to ensure that there is a hold on the
+ * corresponding file system before the share is
+ * added to shares AVL.
+ *
+ * If the share is an Autohome share and it is
+ * already in the AVL only a reference count for
+ * that share is incremented.
+ */
+static int
+smb_kshare_export(smb_kshare_t *shr)
+{
+ smb_avl_t *share_avl;
+ smb_kshare_t *auto_shr;
+ vnode_t *vp;
+ int rc = 0;
+
+ share_avl = &smb_export.e_share_avl;
+
+ if (!STYPE_ISDSK(shr->shr_type)) {
+ if ((rc = smb_avl_add(share_avl, shr)) != 0) {
+ cmn_err(CE_WARN, "export[%s]: failed caching (%d)",
+ shr->shr_name, rc);
+ }
+
+ return (rc);
+ }
+
+ if ((auto_shr = smb_avl_lookup(share_avl, shr)) != NULL) {
+ if ((auto_shr->shr_flags & SMB_SHRF_AUTOHOME) == 0) {
+ smb_avl_release(share_avl, auto_shr);
+ return (EEXIST);
+ }
+
+ mutex_enter(&auto_shr->shr_mutex);
+ auto_shr->shr_autocnt++;
+ mutex_exit(&auto_shr->shr_mutex);
+ smb_avl_release(share_avl, auto_shr);
+ return (0);
+ }
+
+ if ((rc = smb_server_sharevp(shr->shr_path, &vp)) != 0) {
+ cmn_err(CE_WARN, "export[%s(%s)]: failed obtaining vnode (%d)",
+ shr->shr_name, shr->shr_path, rc);
+ return (rc);
+ }
+
+ if ((rc = smb_vfs_hold(&smb_export, vp->v_vfsp)) == 0) {
+ if ((rc = smb_avl_add(share_avl, shr)) != 0) {
+ cmn_err(CE_WARN, "export[%s]: failed caching (%d)",
+ shr->shr_name, rc);
+ smb_vfs_rele(&smb_export, vp->v_vfsp);
+ }
+ } else {
+ cmn_err(CE_WARN, "export[%s(%s)]: failed holding VFS (%d)",
+ shr->shr_name, shr->shr_path, rc);
+ }
+
+ VN_RELE(vp);
+ return (rc);
+}
+
+/*
+ * Removes the share specified by 'shrname' from the AVL
+ * tree of the given server if it's there.
+ *
+ * If the share is an Autohome share, the autohome count
+ * is decremented and the share is only removed if the
+ * count goes to zero.
+ *
+ * If the share is a disk share, the hold on the corresponding
+ * file system is released before removing the share from
+ * the AVL tree.
+ */
+static int
+smb_kshare_unexport(const char *shrname)
+{
+ smb_avl_t *share_avl;
+ smb_kshare_t key;
+ smb_kshare_t *shr;
+ vnode_t *vp;
+ int rc;
+ boolean_t auto_unexport;
+
+ share_avl = &smb_export.e_share_avl;
+
+ key.shr_name = (char *)shrname;
+ if ((shr = smb_avl_lookup(share_avl, &key)) == NULL)
+ return (ENOENT);
+
+ if ((shr->shr_flags & SMB_SHRF_AUTOHOME) != 0) {
+ mutex_enter(&shr->shr_mutex);
+ shr->shr_autocnt--;
+ auto_unexport = (shr->shr_autocnt == 0);
+ mutex_exit(&shr->shr_mutex);
+ if (!auto_unexport) {
+ smb_avl_release(share_avl, shr);
+ return (0);
+ }
+ }
+
+ if (STYPE_ISDSK(shr->shr_type)) {
+ if ((rc = smb_server_sharevp(shr->shr_path, &vp)) != 0) {
+ smb_avl_release(share_avl, shr);
+ cmn_err(CE_WARN, "unexport[%s]: failed obtaining vnode"
+ " (%d)", shrname, rc);
+ return (rc);
+ }
+
+ smb_vfs_rele(&smb_export, vp->v_vfsp);
+ VN_RELE(vp);
+ }
+
+ smb_avl_remove(share_avl, shr);
+ smb_avl_release(share_avl, shr);
+
+ return (0);
+}
+
+/*
+ * Exports IPC$ or Admin shares
+ */
+static int
+smb_kshare_export_trans(char *name, char *path, char *cmnt)
+{
+ smb_kshare_t *shr;
+
+ ASSERT(name);
+ ASSERT(path);
+
+ shr = kmem_cache_alloc(smb_export.e_cache_share, KM_SLEEP);
+ bzero(shr, sizeof (smb_kshare_t));
+
+ shr->shr_magic = SMB_SHARE_MAGIC;
+ shr->shr_cache = smb_export.e_cache_share;
+ shr->shr_refcnt = 1;
+ shr->shr_flags = SMB_SHRF_TRANS | smb_kshare_is_admin(shr->shr_name);
+ if (strcasecmp(name, "IPC$") == 0)
+ shr->shr_type = STYPE_IPC;
+ else
+ shr->shr_type = STYPE_DISKTREE;
+
+ shr->shr_type |= smb_kshare_is_special(shr->shr_name);
+
+ shr->shr_name = smb_mem_strdup(name);
+ if (path)
+ shr->shr_path = smb_mem_strdup(path);
+ if (cmnt)
+ shr->shr_cmnt = smb_mem_strdup(cmnt);
+ shr->shr_oemname = smb_kshare_oemname(name);
+
+ return (smb_kshare_export(shr));
+}
+
+/*
+ * Decodes share information in an nvlist format into a smb_kshare_t
+ * structure.
+ *
+ * This is a temporary function and will be replaced by functions
+ * provided by libsharev2 code after it's available.
+ */
+static smb_kshare_t *
+smb_kshare_decode(nvlist_t *share)
+{
+ smb_kshare_t tmp;
+ smb_kshare_t *shr;
+ nvlist_t *smb;
+ char *csc_name = NULL;
+ int rc;
+
+ ASSERT(share);
+
+ bzero(&tmp, sizeof (smb_kshare_t));
+
+ rc = nvlist_lookup_string(share, "name", &tmp.shr_name);
+ rc |= nvlist_lookup_string(share, "path", &tmp.shr_path);
+ (void) nvlist_lookup_string(share, "desc", &tmp.shr_cmnt);
+
+ ASSERT(tmp.shr_name && tmp.shr_path);
+
+ rc |= nvlist_lookup_nvlist(share, "smb", &smb);
+ if (rc != 0) {
+ cmn_err(CE_WARN, "kshare: failed looking up SMB properties"
+ " (%d)", rc);
+ return (NULL);
+ }
+
+ (void) nvlist_lookup_string(smb, SHOPT_AD_CONTAINER,
+ &tmp.shr_container);
+ (void) nvlist_lookup_string(smb, SHOPT_NONE, &tmp.shr_access_none);
+ (void) nvlist_lookup_string(smb, SHOPT_RO, &tmp.shr_access_ro);
+ (void) nvlist_lookup_string(smb, SHOPT_RW, &tmp.shr_access_rw);
+
+ tmp.shr_flags |= smb_kshare_decode_bool(smb, SHOPT_ABE, SMB_SHRF_ABE);
+ tmp.shr_flags |= smb_kshare_decode_bool(smb, SHOPT_CATIA,
+ SMB_SHRF_CATIA);
+ tmp.shr_flags |= smb_kshare_decode_bool(smb, SHOPT_GUEST,
+ SMB_SHRF_GUEST_OK);
+ tmp.shr_flags |= smb_kshare_decode_bool(smb, SHOPT_DFSROOT,
+ SMB_SHRF_DFSROOT);
+ tmp.shr_flags |= smb_kshare_decode_bool(smb, "Autohome",
+ SMB_SHRF_AUTOHOME);
+
+ if ((tmp.shr_flags & SMB_SHRF_AUTOHOME) == SMB_SHRF_AUTOHOME) {
+ rc = nvlist_lookup_uint32(smb, "uid", &tmp.shr_uid);
+ rc |= nvlist_lookup_uint32(smb, "gid", &tmp.shr_gid);
+ if (rc != 0) {
+ cmn_err(CE_WARN, "kshare: failed looking up UID/GID"
+ " (%d)", rc);
+ return (NULL);
+ }
+ }
+
+ (void) nvlist_lookup_string(smb, SHOPT_CSC, &csc_name);
+ smb_kshare_csc_flags(&tmp, csc_name);
+
+ shr = kmem_cache_alloc(smb_export.e_cache_share, KM_SLEEP);
+ bzero(shr, sizeof (smb_kshare_t));
+
+ shr->shr_magic = SMB_SHARE_MAGIC;
+ shr->shr_cache = smb_export.e_cache_share;
+ shr->shr_refcnt = 1;
+
+ shr->shr_name = smb_mem_strdup(tmp.shr_name);
+ shr->shr_path = smb_mem_strdup(tmp.shr_path);
+ if (tmp.shr_cmnt)
+ shr->shr_cmnt = smb_mem_strdup(tmp.shr_cmnt);
+ if (tmp.shr_container)
+ shr->shr_container = smb_mem_strdup(tmp.shr_container);
+ if (tmp.shr_access_none)
+ shr->shr_access_none = smb_mem_strdup(tmp.shr_access_none);
+ if (tmp.shr_access_ro)
+ shr->shr_access_ro = smb_mem_strdup(tmp.shr_access_ro);
+ if (tmp.shr_access_rw)
+ shr->shr_access_rw = smb_mem_strdup(tmp.shr_access_rw);
+
+ shr->shr_oemname = smb_kshare_oemname(shr->shr_name);
+ shr->shr_flags = tmp.shr_flags | smb_kshare_is_admin(shr->shr_name);
+ shr->shr_type = STYPE_DISKTREE | smb_kshare_is_special(shr->shr_name);
+
+ shr->shr_uid = tmp.shr_uid;
+ shr->shr_gid = tmp.shr_gid;
+
+ if ((shr->shr_flags & SMB_SHRF_AUTOHOME) == SMB_SHRF_AUTOHOME)
+ shr->shr_autocnt = 1;
+
+ return (shr);
+}
+
+#if 0
+static void
+smb_kshare_log(smb_kshare_t *shr)
+{
+ cmn_err(CE_NOTE, "Share info:");
+ cmn_err(CE_NOTE, "\tname: %s", (shr->shr_name) ? shr->shr_name : "");
+ cmn_err(CE_NOTE, "\tpath: %s", (shr->shr_path) ? shr->shr_path : "");
+ cmn_err(CE_NOTE, "\tcmnt: (%s)",
+ (shr->shr_cmnt) ? shr->shr_cmnt : "NULL");
+ cmn_err(CE_NOTE, "\toemname: (%s)",
+ (shr->shr_oemname) ? shr->shr_oemname : "NULL");
+ cmn_err(CE_NOTE, "\tflags: %X", shr->shr_flags);
+ cmn_err(CE_NOTE, "\ttype: %d", shr->shr_type);
+}
+#endif
+
+/*
+ * Compare function used by shares AVL
+ */
+static int
+smb_kshare_cmp(const void *p1, const void *p2)
+{
+ smb_kshare_t *shr1 = (smb_kshare_t *)p1;
+ smb_kshare_t *shr2 = (smb_kshare_t *)p2;
+ int rc;
+
+ ASSERT(shr1);
+ ASSERT(shr1->shr_name);
+
+ ASSERT(shr2);
+ ASSERT(shr2->shr_name);
+
+ rc = smb_strcasecmp(shr1->shr_name, shr2->shr_name, 0);
+
+ if (rc < 0)
+ return (-1);
+
+ if (rc > 0)
+ return (1);
+
+ return (0);
+}
+
+/*
+ * This function is called by smb_avl routines whenever
+ * there is a need to take a hold on a share structure
+ * inside AVL
+ */
+static void
+smb_kshare_hold(const void *p)
+{
+ smb_kshare_t *shr = (smb_kshare_t *)p;
+
+ ASSERT(shr);
+ ASSERT(shr->shr_magic == SMB_SHARE_MAGIC);
+
+ mutex_enter(&shr->shr_mutex);
+ shr->shr_refcnt++;
+ mutex_exit(&shr->shr_mutex);
+}
+
+/*
+ * This function must be called by smb_avl routines whenever
+ * smb_kshare_hold is called and the hold needs to be released.
+ */
+static boolean_t
+smb_kshare_rele(const void *p)
+{
+ smb_kshare_t *shr = (smb_kshare_t *)p;
+ boolean_t destroy;
+
+ ASSERT(shr);
+ ASSERT(shr->shr_magic == SMB_SHARE_MAGIC);
+
+ mutex_enter(&shr->shr_mutex);
+ ASSERT(shr->shr_refcnt > 0);
+ shr->shr_refcnt--;
+ destroy = (shr->shr_refcnt == 0);
+ mutex_exit(&shr->shr_mutex);
+
+ return (destroy);
+}
+
+/*
+ * Frees all the memory allocated for the given
+ * share structure. It also removes the structure
+ * from the share cache.
+ */
+static void
+smb_kshare_destroy(void *p)
+{
+ smb_kshare_t *shr = (smb_kshare_t *)p;
+
+ ASSERT(shr);
+ ASSERT(shr->shr_magic == SMB_SHARE_MAGIC);
+
+ smb_mem_free(shr->shr_name);
+ smb_mem_free(shr->shr_path);
+ smb_mem_free(shr->shr_cmnt);
+ smb_mem_free(shr->shr_container);
+ smb_mem_free(shr->shr_oemname);
+ smb_mem_free(shr->shr_access_none);
+ smb_mem_free(shr->shr_access_ro);
+ smb_mem_free(shr->shr_access_rw);
+
+ kmem_cache_free(shr->shr_cache, shr);
+}
+
+
+/*
+ * Generate an OEM name for the given share name. If the name is
+ * shorter than 13 bytes the oemname will be returned; otherwise NULL
+ * is returned.
+ */
+static char *
+smb_kshare_oemname(const char *shrname)
+{
+ smb_wchar_t *unibuf;
+ char *oem_name;
+ int length;
+
+ length = strlen(shrname) + 1;
+
+ oem_name = smb_mem_alloc(length);
+ unibuf = smb_mem_alloc(length * sizeof (smb_wchar_t));
+
+ (void) smb_mbstowcs(unibuf, shrname, length);
+
+ if (ucstooem(oem_name, unibuf, length, OEM_CPG_850) == 0)
+ (void) strcpy(oem_name, shrname);
+
+ smb_mem_free(unibuf);
+
+ if (strlen(oem_name) + 1 > SMB_SHARE_OEMNAME_MAX) {
+ smb_mem_free(oem_name);
+ return (NULL);
+ }
+
+ return (oem_name);
+}
+
+/*
+ * Special share reserved for interprocess communication (IPC$) or
+ * remote administration of the server (ADMIN$). Can also refer to
+ * administrative shares such as C$, D$, E$, and so forth.
+ */
+static int
+smb_kshare_is_special(const char *sharename)
+{
+ int len;
+
+ if (sharename == NULL)
+ return (0);
+
+ if ((len = strlen(sharename)) == 0)
+ return (0);
+
+ if (sharename[len - 1] == '$')
+ return (STYPE_SPECIAL);
+
+ return (0);
+}
+
+/*
+ * Check whether or not this is a default admin share: C$, D$ etc.
+ */
+static boolean_t
+smb_kshare_is_admin(const char *sharename)
+{
+ if (sharename == NULL)
+ return (B_FALSE);
+
+ if (strlen(sharename) == 2 &&
+ smb_isalpha(sharename[0]) && sharename[1] == '$') {
+ return (B_TRUE);
+ }
+
+ return (B_FALSE);
+}
+
+/*
+ * Decodes the given boolean share option.
+ * If the option is present in the nvlist and it's value is true
+ * returns the corresponding flag value, otherwise returns 0.
+ */
+static uint32_t
+smb_kshare_decode_bool(nvlist_t *nvl, const char *propname, uint32_t flag)
+{
+ char *boolp;
+
+ if (nvlist_lookup_string(nvl, propname, &boolp) == 0)
+ if (strcasecmp(boolp, "true") == 0)
+ return (flag);
+
+ return (0);
+}
+
+/*
+ * Map a client-side caching (CSC) option to the appropriate share
+ * flag. Only one option is allowed; an error will be logged if
+ * multiple options have been specified. We don't need to do anything
+ * about multiple values here because the SRVSVC will not recognize
+ * a value containing multiple flags and will return the default value.
+ *
+ * If the option value is not recognized, it will be ignored: invalid
+ * values will typically be caught and rejected by sharemgr.
+ */
+static void
+smb_kshare_csc_flags(smb_kshare_t *shr, const char *value)
+{
+ int i;
+ static struct {
+ char *value;
+ uint32_t flag;
+ } cscopt[] = {
+ { "disabled", SMB_SHRF_CSC_DISABLED },
+ { "manual", SMB_SHRF_CSC_MANUAL },
+ { "auto", SMB_SHRF_CSC_AUTO },
+ { "vdo", SMB_SHRF_CSC_VDO }
+ };
+
+ if (value == NULL)
+ return;
+
+ for (i = 0; i < (sizeof (cscopt) / sizeof (cscopt[0])); ++i) {
+ if (strcasecmp(value, cscopt[i].value) == 0) {
+ shr->shr_flags |= cscopt[i].flag;
+ break;
+ }
+ }
+
+ switch (shr->shr_flags & SMB_SHRF_CSC_MASK) {
+ case 0:
+ case SMB_SHRF_CSC_DISABLED:
+ case SMB_SHRF_CSC_MANUAL:
+ case SMB_SHRF_CSC_AUTO:
+ case SMB_SHRF_CSC_VDO:
+ break;
+
+ default:
+ cmn_err(CE_NOTE, "csc option conflict: 0x%08x",
+ shr->shr_flags & SMB_SHRF_CSC_MASK);
+ break;
+ }
+}
+
+/*
+ * This function processes the unexport event list and disconnects shares
+ * asynchronously. The function executes as a zone-specific thread.
+ *
+ * The server arg passed in is safe to use without a reference count, because
+ * the server cannot be deleted until smb_thread_stop()/destroy() return,
+ * which is also when the thread exits.
+ */
+/*ARGSUSED*/
+static void
+smb_kshare_unexport_thread(smb_thread_t *thread, void *arg)
+{
+ smb_unshare_t *ux;
+
+ while (smb_thread_continue(thread)) {
+ while ((ux = list_head(&smb_export.e_unexport_list.sl_list))
+ != NULL) {
+ smb_slist_remove(&smb_export.e_unexport_list, ux);
+ (void) smb_server_unshare(ux->us_sharename);
+ kmem_cache_free(smb_export.e_cache_unexport, ux);
+ }
+ }
+}
+
+static boolean_t
+smb_export_isready(void)
+{
+ boolean_t ready;
+
+ mutex_enter(&smb_export.e_mutex);
+ ready = smb_export.e_ready;
+ mutex_exit(&smb_export.e_mutex);
+
+ return (ready);
+}
+
+/*
* Return 0 upon success. Otherwise > 0
*/
static int
diff --git a/usr/src/uts/common/fs/smbsrv/smb_kutil.c b/usr/src/uts/common/fs/smbsrv/smb_kutil.c
index e6ddda8ef5..60b36a6939 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_kutil.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_kutil.c
@@ -28,7 +28,9 @@
#include <sys/atomic.h>
#include <sys/kidmap.h>
#include <sys/time.h>
+#include <sys/spl.h>
#include <sys/cpuvar.h>
+#include <sys/random.h>
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_fsops.h>
#include <smbsrv/smbinfo.h>
@@ -44,6 +46,9 @@ static boolean_t smb_llist_initialized = B_FALSE;
static boolean_t smb_thread_continue_timedwait_locked(smb_thread_t *, int);
+static boolean_t smb_avl_hold(smb_avl_t *);
+static void smb_avl_rele(smb_avl_t *);
+
time_t tzh_leapcnt = 0;
struct tm
@@ -694,7 +699,7 @@ void
smb_slist_destructor(
smb_slist_t *sl)
{
- ASSERT(sl->sl_count == 0);
+ VERIFY(sl->sl_count == 0);
mutex_destroy(&sl->sl_mutex);
cv_destroy(&sl->sl_cv);
@@ -1856,246 +1861,489 @@ smb_timegm(struct tm *tm)
}
/*
- * smb_cred_set_sid
+ * smb_pad_align
*
- * Initialize the ksid based on the given smb_id_t.
+ * Returns the number of bytes required to pad an offset to the
+ * specified alignment.
*/
-static void
-smb_cred_set_sid(smb_id_t *id, ksid_t *ksid)
+uint32_t
+smb_pad_align(uint32_t offset, uint32_t align)
{
- char sidstr[SMB_SID_STRSZ];
- int rc;
-
- ASSERT(id);
- ASSERT(id->i_sid);
+ uint32_t pad = offset % align;
- ksid->ks_id = id->i_id;
- smb_sid_tostr(id->i_sid, sidstr);
- rc = smb_sid_splitstr(sidstr, &ksid->ks_rid);
- ASSERT(rc == 0);
+ if (pad != 0)
+ pad = align - pad;
- ksid->ks_attr = id->i_attrs;
- ksid->ks_domain = ksid_lookupdomain(sidstr);
+ return (pad);
}
/*
- * smb_cred_set_sidlist
+ * smb_panic
*
- * Allocate and initialize the ksidlist based on the Windows group list of the
- * access token.
+ * Logs the file name, function name and line number passed in and panics the
+ * system.
*/
-static ksidlist_t *
-smb_cred_set_sidlist(smb_ids_t *token_grps)
+void
+smb_panic(char *file, const char *func, int line)
{
- int i;
- ksidlist_t *lp;
+ cmn_err(CE_PANIC, "%s:%s:%d\n", file, func, line);
+}
+
+/*
+ * Creates an AVL tree and initializes the given smb_avl_t
+ * structure using the passed args
+ */
+void
+smb_avl_create(smb_avl_t *avl, size_t size, size_t offset, smb_avl_nops_t *ops)
+{
+ ASSERT(avl);
+ ASSERT(ops);
- lp = kmem_zalloc(KSIDLIST_MEM(token_grps->i_cnt), KM_SLEEP);
- lp->ksl_ref = 1;
- lp->ksl_nsid = token_grps->i_cnt;
- lp->ksl_neid = 0;
+ rw_init(&avl->avl_lock, NULL, RW_DEFAULT, NULL);
+ mutex_init(&avl->avl_mutex, NULL, MUTEX_DEFAULT, NULL);
- for (i = 0; i < lp->ksl_nsid; i++) {
- smb_cred_set_sid(&token_grps->i_ids[i], &lp->ksl_sids[i]);
- if (lp->ksl_sids[i].ks_id > IDMAP_WK__MAX_GID)
- lp->ksl_neid++;
- }
+ avl->avl_nops = ops;
+ avl->avl_state = SMB_AVL_STATE_READY;
+ avl->avl_refcnt = 0;
+ (void) random_get_pseudo_bytes((uint8_t *)&avl->avl_sequence,
+ sizeof (uint32_t));
- return (lp);
+ avl_create(&avl->avl_tree, ops->avln_cmp, size, offset);
}
/*
- * A Solaris credential (cred_t structure) will be allocated and
- * initialized based on the given Windows style user access token.
- *
- * cred's gid is set to the primary group of the mapped Solaris user.
- * When there is no such mapped user (i.e. the mapped UID is ephemeral)
- * or his/her primary group could not be obtained, cred's gid is set to
- * the mapped Solaris group of token's primary group.
+ * Destroys the specified AVL tree.
+ * It waits for all the in-flight operations to finish
+ * before destroying the AVL.
*/
-cred_t *
-smb_cred_create(smb_token_t *token, uint32_t *privileges)
+void
+smb_avl_destroy(smb_avl_t *avl)
{
- ksid_t ksid;
- ksidlist_t *ksidlist = NULL;
- smb_posix_grps_t *posix_grps;
- cred_t *cr;
- gid_t gid;
+ void *cookie = NULL;
+ void *node;
- ASSERT(token);
- ASSERT(token->tkn_posix_grps);
- posix_grps = token->tkn_posix_grps;
+ ASSERT(avl);
- ASSERT(privileges);
+ mutex_enter(&avl->avl_mutex);
+ if (avl->avl_state != SMB_AVL_STATE_READY) {
+ mutex_exit(&avl->avl_mutex);
+ return;
+ }
- cr = crget();
- ASSERT(cr != NULL);
+ avl->avl_state = SMB_AVL_STATE_DESTROYING;
- if (!IDMAP_ID_IS_EPHEMERAL(token->tkn_user.i_id) &&
- (posix_grps->pg_ngrps != 0)) {
- gid = posix_grps->pg_grps[0];
- } else {
- gid = token->tkn_primary_grp.i_id;
- }
+ while (avl->avl_refcnt > 0)
+ (void) cv_wait(&avl->avl_cv, &avl->avl_mutex);
+ mutex_exit(&avl->avl_mutex);
- if (crsetugid(cr, token->tkn_user.i_id, gid) != 0) {
- crfree(cr);
- return (NULL);
- }
+ rw_enter(&avl->avl_lock, RW_WRITER);
+ while ((node = avl_destroy_nodes(&avl->avl_tree, &cookie)) != NULL)
+ avl->avl_nops->avln_destroy(node);
- if (crsetgroups(cr, posix_grps->pg_ngrps, posix_grps->pg_grps) != 0) {
- crfree(cr);
- return (NULL);
- }
+ avl_destroy(&avl->avl_tree);
+ rw_exit(&avl->avl_lock);
- smb_cred_set_sid(&token->tkn_user, &ksid);
- crsetsid(cr, &ksid, KSID_USER);
- smb_cred_set_sid(&token->tkn_primary_grp, &ksid);
- crsetsid(cr, &ksid, KSID_GROUP);
- smb_cred_set_sid(&token->tkn_owner, &ksid);
- crsetsid(cr, &ksid, KSID_OWNER);
- ksidlist = smb_cred_set_sidlist(&token->tkn_win_grps);
- crsetsidlist(cr, ksidlist);
+ rw_destroy(&avl->avl_lock);
+
+ mutex_destroy(&avl->avl_mutex);
+ bzero(avl, sizeof (smb_avl_t));
+}
- *privileges = 0;
+/*
+ * Adds the given item to the AVL if it's
+ * not already there.
+ *
+ * Returns:
+ *
+ * ENOTACTIVE AVL is not in READY state
+ * EEXIST The item is already in AVL
+ */
+int
+smb_avl_add(smb_avl_t *avl, void *item)
+{
+ avl_index_t where;
- if (smb_token_query_privilege(token, SE_BACKUP_LUID))
- *privileges |= SMB_USER_PRIV_BACKUP;
+ ASSERT(avl);
+ ASSERT(item);
- if (smb_token_query_privilege(token, SE_RESTORE_LUID))
- *privileges |= SMB_USER_PRIV_RESTORE;
+ if (!smb_avl_hold(avl))
+ return (ENOTACTIVE);
- if (smb_token_query_privilege(token, SE_TAKE_OWNERSHIP_LUID)) {
- *privileges |= SMB_USER_PRIV_TAKE_OWNERSHIP;
- (void) crsetpriv(cr, PRIV_FILE_CHOWN, NULL);
+ rw_enter(&avl->avl_lock, RW_WRITER);
+ if (avl_find(&avl->avl_tree, item, &where) != NULL) {
+ rw_exit(&avl->avl_lock);
+ smb_avl_rele(avl);
+ return (EEXIST);
}
- if (smb_token_query_privilege(token, SE_SECURITY_LUID))
- *privileges |= SMB_USER_PRIV_SECURITY;
+ avl_insert(&avl->avl_tree, item, where);
+ avl->avl_sequence++;
+ rw_exit(&avl->avl_lock);
- return (cr);
+ smb_avl_rele(avl);
+ return (0);
}
/*
- * smb_cred_rele
- *
- * The reference count of the user's credential will get decremented if it
- * is non-zero. Otherwise, the credential will be freed.
+ * Removes the given item from the AVL.
+ * If no reference is left on the item
+ * it will also be destroyed by calling the
+ * registered destroy operation.
*/
void
-smb_cred_rele(cred_t *cr)
+smb_avl_remove(smb_avl_t *avl, void *item)
{
- ASSERT(cr);
- crfree(cr);
+ avl_index_t where;
+ void *rm_item;
+
+ ASSERT(avl);
+ ASSERT(item);
+
+ if (!smb_avl_hold(avl))
+ return;
+
+ rw_enter(&avl->avl_lock, RW_WRITER);
+ if ((rm_item = avl_find(&avl->avl_tree, item, &where)) == NULL) {
+ rw_exit(&avl->avl_lock);
+ smb_avl_rele(avl);
+ return;
+ }
+
+ avl_remove(&avl->avl_tree, rm_item);
+ if (avl->avl_nops->avln_rele(rm_item))
+ avl->avl_nops->avln_destroy(rm_item);
+ avl->avl_sequence++;
+ rw_exit(&avl->avl_lock);
+
+ smb_avl_rele(avl);
}
/*
- * smb_cred_is_member
- *
- * Same as smb_token_is_member. The only difference is that
- * we compare the given SID against user SID and the ksidlist
- * of the user's cred.
+ * Looks up the AVL for the given item.
+ * If the item is found a hold on the object
+ * is taken before the pointer to it is
+ * returned to the caller. The caller MUST
+ * always call smb_avl_release() after it's done
+ * using the returned object to release the hold
+ * taken on the object.
*/
-int
-smb_cred_is_member(cred_t *cr, smb_sid_t *sid)
+void *
+smb_avl_lookup(smb_avl_t *avl, void *item)
{
- ksidlist_t *ksidlist;
- ksid_t ksid1, *ksid2;
- smb_id_t id;
- int i, rc = 0;
+ void *node = NULL;
- ASSERT(cr);
+ ASSERT(avl);
+ ASSERT(item);
- bzero(&id, sizeof (smb_id_t));
- id.i_sid = sid;
- smb_cred_set_sid(&id, &ksid1);
+ if (!smb_avl_hold(avl))
+ return (NULL);
- ksidlist = crgetsidlist(cr);
- ASSERT(ksidlist);
- ASSERT(ksid1.ks_domain);
- ASSERT(ksid1.ks_domain->kd_name);
+ rw_enter(&avl->avl_lock, RW_READER);
+ node = avl_find(&avl->avl_tree, item, NULL);
+ if (node != NULL)
+ avl->avl_nops->avln_hold(node);
+ rw_exit(&avl->avl_lock);
- i = 0;
- ksid2 = crgetsid(cr, KSID_USER);
- do {
- ASSERT(ksid2->ks_domain);
- ASSERT(ksid2->ks_domain->kd_name);
+ if (node == NULL)
+ smb_avl_rele(avl);
- if (strcmp(ksid1.ks_domain->kd_name,
- ksid2->ks_domain->kd_name) == 0 &&
- ksid1.ks_rid == ksid2->ks_rid) {
- rc = 1;
- break;
- }
+ return (node);
+}
+
+/*
+ * The hold on the given object is released.
+ * This function MUST always be called after
+ * smb_avl_lookup() and smb_avl_iterate() for
+ * the returned object.
+ *
+ * If AVL is in DESTROYING state, the destroying
+ * thread will be notified.
+ */
+void
+smb_avl_release(smb_avl_t *avl, void *item)
+{
+ ASSERT(avl);
+ ASSERT(item);
- ksid2 = &ksidlist->ksl_sids[i];
- } while (i++ < ksidlist->ksl_nsid);
+ if (avl->avl_nops->avln_rele(item))
+ avl->avl_nops->avln_destroy(item);
- ksid_rele(&ksid1);
- return (rc);
+ smb_avl_rele(avl);
}
/*
- * smb_cred_create_privs
+ * Initializes the given cursor for the AVL.
+ * The cursor will be used to iterate through the AVL
+ */
+void
+smb_avl_iterinit(smb_avl_t *avl, smb_avl_cursor_t *cursor)
+{
+ ASSERT(avl);
+ ASSERT(cursor);
+
+ cursor->avlc_next = NULL;
+ cursor->avlc_sequence = avl->avl_sequence;
+}
+
+/*
+ * Iterates through the AVL using the given cursor.
+ * It always starts at the beginning and then returns
+ * a pointer to the next object on each subsequent call.
*
- * Creates a duplicate credential that contains system privileges for
- * certain SMB privileges: Backup and Restore.
+ * If a new object is added to or removed from the AVL
+ * between two calls to this function, the iteration
+ * will terminate prematurely.
*
+ * The caller MUST always call smb_avl_release() after it's
+ * done using the returned object to release the hold taken
+ * on the object.
*/
-cred_t *
-smb_cred_create_privs(cred_t *user_cr, uint32_t privileges)
+void *
+smb_avl_iterate(smb_avl_t *avl, smb_avl_cursor_t *cursor)
{
- cred_t *cr = NULL;
+ void *node;
- ASSERT(user_cr != NULL);
+ ASSERT(avl);
+ ASSERT(cursor);
- if (privileges & (SMB_USER_PRIV_BACKUP | SMB_USER_PRIV_RESTORE))
- cr = crdup(user_cr);
-
- if (cr == NULL)
+ if (!smb_avl_hold(avl))
return (NULL);
- if (privileges & SMB_USER_PRIV_BACKUP) {
- (void) crsetpriv(cr, PRIV_FILE_DAC_READ,
- PRIV_FILE_DAC_SEARCH, PRIV_SYS_MOUNT, NULL);
+ rw_enter(&avl->avl_lock, RW_READER);
+ if (cursor->avlc_sequence != avl->avl_sequence) {
+ rw_exit(&avl->avl_lock);
+ smb_avl_rele(avl);
+ return (NULL);
}
- if (privileges & SMB_USER_PRIV_RESTORE) {
- (void) crsetpriv(cr, PRIV_FILE_DAC_WRITE,
- PRIV_FILE_CHOWN, PRIV_FILE_CHOWN_SELF,
- PRIV_FILE_DAC_SEARCH, PRIV_FILE_LINK_ANY,
- PRIV_FILE_OWNER, PRIV_FILE_SETID, PRIV_SYS_LINKDIR,
- PRIV_SYS_MOUNT, NULL);
+ if (cursor->avlc_next == NULL)
+ node = avl_first(&avl->avl_tree);
+ else
+ node = AVL_NEXT(&avl->avl_tree, cursor->avlc_next);
+
+ if (node != NULL)
+ avl->avl_nops->avln_hold(node);
+
+ cursor->avlc_next = node;
+ rw_exit(&avl->avl_lock);
+
+ if (node == NULL)
+ smb_avl_rele(avl);
+
+ return (node);
+}
+
+/*
+ * Increments the AVL reference count in order to
+ * prevent the avl from being destroyed while it's
+ * being accessed.
+ */
+static boolean_t
+smb_avl_hold(smb_avl_t *avl)
+{
+ mutex_enter(&avl->avl_mutex);
+ if (avl->avl_state != SMB_AVL_STATE_READY) {
+ mutex_exit(&avl->avl_mutex);
+ return (B_FALSE);
}
+ avl->avl_refcnt++;
+ mutex_exit(&avl->avl_mutex);
- return (cr);
+ return (B_TRUE);
}
/*
- * smb_pad_align
- *
- * Returns the number of bytes required to pad an offset to the
- * specified alignment.
+ * Decrements the AVL reference count to release the
+ * hold. If another thread is trying to destroy the
+ * AVL and is waiting for the reference count to become
+ * 0, it is signaled to wake up.
*/
-uint32_t
-smb_pad_align(uint32_t offset, uint32_t align)
+static void
+smb_avl_rele(smb_avl_t *avl)
{
- uint32_t pad = offset % align;
+ mutex_enter(&avl->avl_mutex);
+ ASSERT(avl->avl_refcnt > 0);
+ avl->avl_refcnt--;
+ if (avl->avl_state == SMB_AVL_STATE_DESTROYING)
+ cv_broadcast(&avl->avl_cv);
+ mutex_exit(&avl->avl_mutex);
+}
- if (pad != 0)
- pad = align - pad;
+/*
+ * smb_latency_init
+ */
+void
+smb_latency_init(smb_latency_t *lat)
+{
+ bzero(lat, sizeof (*lat));
+ mutex_init(&lat->ly_mutex, NULL, MUTEX_SPIN, (void *)ipltospl(SPL7));
+}
- return (pad);
+/*
+ * smb_latency_destroy
+ */
+void
+smb_latency_destroy(smb_latency_t *lat)
+{
+ mutex_destroy(&lat->ly_mutex);
}
/*
- * smb_panic
+ * smb_latency_add_sample
*
- * Logs the file name, function name and line number passed in and panics the
- * system.
+ * Uses the new sample to calculate the new mean and standard deviation. The
+ * sample must be a scaled value.
*/
void
-smb_panic(char *file, const char *func, int line)
+smb_latency_add_sample(smb_latency_t *lat, hrtime_t sample)
+{
+ hrtime_t a_mean;
+ hrtime_t d_mean;
+
+ mutex_enter(&lat->ly_mutex);
+ lat->ly_a_nreq++;
+ lat->ly_a_sum += sample;
+ if (lat->ly_a_nreq != 0) {
+ a_mean = lat->ly_a_sum / lat->ly_a_nreq;
+ lat->ly_a_stddev =
+ (sample - a_mean) * (sample - lat->ly_a_mean);
+ lat->ly_a_mean = a_mean;
+ }
+ lat->ly_d_nreq++;
+ lat->ly_d_sum += sample;
+ if (lat->ly_d_nreq != 0) {
+ d_mean = lat->ly_d_sum / lat->ly_d_nreq;
+ lat->ly_d_stddev =
+ (sample - d_mean) * (sample - lat->ly_d_mean);
+ lat->ly_d_mean = d_mean;
+ }
+ mutex_exit(&lat->ly_mutex);
+}
+
+/*
+ * smb_srqueue_init
+ */
+void
+smb_srqueue_init(smb_srqueue_t *srq)
{
- cmn_err(CE_PANIC, "%s:%s:%d\n", file, func, line);
+ bzero(srq, sizeof (*srq));
+ mutex_init(&srq->srq_mutex, NULL, MUTEX_SPIN, (void *)ipltospl(SPL7));
+ srq->srq_wlastupdate = srq->srq_rlastupdate = gethrtime_unscaled();
+}
+
+/*
+ * smb_srqueue_destroy
+ */
+void
+smb_srqueue_destroy(smb_srqueue_t *srq)
+{
+ mutex_destroy(&srq->srq_mutex);
+}
+
+/*
+ * smb_srqueue_waitq_enter
+ */
+void
+smb_srqueue_waitq_enter(smb_srqueue_t *srq)
+{
+ hrtime_t new;
+ hrtime_t delta;
+ uint32_t wcnt;
+
+ mutex_enter(&srq->srq_mutex);
+ new = gethrtime_unscaled();
+ delta = new - srq->srq_wlastupdate;
+ srq->srq_wlastupdate = new;
+ wcnt = srq->srq_wcnt++;
+ if (wcnt != 0) {
+ srq->srq_wlentime += delta * wcnt;
+ srq->srq_wtime += delta;
+ }
+ mutex_exit(&srq->srq_mutex);
+}
+
+/*
+ * smb_srqueue_runq_exit
+ */
+void
+smb_srqueue_runq_exit(smb_srqueue_t *srq)
+{
+ hrtime_t new;
+ hrtime_t delta;
+ uint32_t rcnt;
+
+ mutex_enter(&srq->srq_mutex);
+ new = gethrtime_unscaled();
+ delta = new - srq->srq_rlastupdate;
+ srq->srq_rlastupdate = new;
+ rcnt = srq->srq_rcnt--;
+ ASSERT(rcnt > 0);
+ srq->srq_rlentime += delta * rcnt;
+ srq->srq_rtime += delta;
+ mutex_exit(&srq->srq_mutex);
+}
+
+/*
+ * smb_srqueue_waitq_to_runq
+ */
+void
+smb_srqueue_waitq_to_runq(smb_srqueue_t *srq)
+{
+ hrtime_t new;
+ hrtime_t delta;
+ uint32_t wcnt;
+ uint32_t rcnt;
+
+ mutex_enter(&srq->srq_mutex);
+ new = gethrtime_unscaled();
+ delta = new - srq->srq_wlastupdate;
+ srq->srq_wlastupdate = new;
+ wcnt = srq->srq_wcnt--;
+ ASSERT(wcnt > 0);
+ srq->srq_wlentime += delta * wcnt;
+ srq->srq_wtime += delta;
+ delta = new - srq->srq_rlastupdate;
+ srq->srq_rlastupdate = new;
+ rcnt = srq->srq_rcnt++;
+ if (rcnt != 0) {
+ srq->srq_rlentime += delta * rcnt;
+ srq->srq_rtime += delta;
+ }
+ mutex_exit(&srq->srq_mutex);
+}
+
+/*
+ * smb_srqueue_update
+ *
+ * Takes a snapshot of the smb_sr_stat_t structure passed in.
+ */
+void
+smb_srqueue_update(smb_srqueue_t *srq, smb_kstat_utilization_t *kd)
+{
+ hrtime_t delta;
+ hrtime_t snaptime;
+
+ mutex_enter(&srq->srq_mutex);
+ snaptime = gethrtime_unscaled();
+ delta = snaptime - srq->srq_wlastupdate;
+ srq->srq_wlastupdate = snaptime;
+ if (srq->srq_wcnt != 0) {
+ srq->srq_wlentime += delta * srq->srq_wcnt;
+ srq->srq_wtime += delta;
+ }
+ delta = snaptime - srq->srq_rlastupdate;
+ srq->srq_rlastupdate = snaptime;
+ if (srq->srq_rcnt != 0) {
+ srq->srq_rlentime += delta * srq->srq_rcnt;
+ srq->srq_rtime += delta;
+ }
+ kd->ku_rlentime = srq->srq_rlentime;
+ kd->ku_rtime = srq->srq_rtime;
+ kd->ku_wlentime = srq->srq_wlentime;
+ kd->ku_wtime = srq->srq_wtime;
+ mutex_exit(&srq->srq_mutex);
+ scalehrtime(&kd->ku_rlentime);
+ scalehrtime(&kd->ku_rtime);
+ scalehrtime(&kd->ku_wlentime);
+ scalehrtime(&kd->ku_wtime);
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_lock.c b/usr/src/uts/common/fs/smbsrv/smb_lock.c
index 5032bac80b..53d93a3eaf 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_lock.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_lock.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -53,18 +52,28 @@ static void smb_lock_destroy(smb_lock_t *);
static void smb_lock_free(smb_lock_t *);
/*
- * Return the number of range locks on the specified node.
+ * Return the number of range locks on the specified ofile.
*/
uint32_t
-smb_lock_get_lock_count(smb_node_t *node)
+smb_lock_get_lock_count(smb_node_t *node, smb_ofile_t *of)
{
- uint32_t count;
+ smb_lock_t *lock;
+ smb_llist_t *llist;
+ uint32_t count = 0;
SMB_NODE_VALID(node);
+ SMB_OFILE_VALID(of);
- smb_llist_enter(&node->n_lock_list, RW_READER);
- count = smb_llist_get_count(&node->n_ofile_list);
- smb_llist_exit(&node->n_lock_list);
+ llist = &node->n_lock_list;
+
+ smb_llist_enter(llist, RW_READER);
+ for (lock = smb_llist_head(llist);
+ lock != NULL;
+ lock = smb_llist_next(llist, lock)) {
+ if (lock->l_file == of)
+ ++count;
+ }
+ smb_llist_exit(llist);
return (count);
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_locking_andx.c b/usr/src/uts/common/fs/smbsrv/smb_locking_andx.c
index 98906e97e2..d0507fedc2 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_locking_andx.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_locking_andx.c
@@ -18,10 +18,11 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
+
/*
* SMB: locking_andx
*
@@ -281,7 +282,8 @@ smb_com_locking_andx(smb_request_t *sr)
* implement this)
*/
if (lock_type & LOCKING_ANDX_CHANGE_LOCK_TYPE) {
- smbsr_error(sr, 0, ERRDOS, ERRnoatomiclocks);
+ smbsr_error(sr, 0, ERRDOS,
+ ERROR_ATOMIC_LOCKS_NOT_SUPPORTED);
return (SDRC_ERROR);
}
@@ -320,7 +322,7 @@ smb_com_locking_andx(smb_request_t *sr)
offset64, length64);
if (result != NT_STATUS_SUCCESS) {
smbsr_error(sr, NT_STATUS_RANGE_NOT_LOCKED,
- ERRDOS, ERRnotlocked);
+ ERRDOS, ERROR_NOT_LOCKED);
return (SDRC_ERROR);
}
}
@@ -353,7 +355,7 @@ smb_com_locking_andx(smb_request_t *sr)
(uint64_t)offset32, (uint64_t)length32);
if (result != NT_STATUS_SUCCESS) {
smbsr_error(sr, NT_STATUS_RANGE_NOT_LOCKED,
- ERRDOS, ERRnotlocked);
+ ERRDOS, ERROR_NOT_LOCKED);
return (SDRC_ERROR);
}
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_mangle_name.c b/usr/src/uts/common/fs/smbsrv/smb_mangle_name.c
index da19a902af..8017d8d5c5 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_mangle_name.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_mangle_name.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
@@ -56,123 +55,38 @@ static char *special_chars = "[];=,+";
#define isinvalid(c) (strchr(invalid_dos_chars, c) || (c & 0x80))
-static int smb_match_unknown(char *name, char *pattern);
static boolean_t smb_is_reserved_dos_name(const char *name);
+static int smb_generate_mangle(uint64_t, char *, size_t);
+static char smb_mangle_char(char);
/*
* smb_match_name
*
- * This function will mangle the "name" field and save the resulted
- * shortname to the "shortname" field and 8.3 name to "name83" field.
- * The three fields, "name", "shortname" and "name83" will then be
- * sent for pattern match with "pattern" field.
+ * Don't match reserved dos filenames.
+ * Check name to see if it matches pattern.
+ * Generate the shortname (even if !smb_needs_mangled()) since names may
+ * be mangled to address case conflicts) and check if shortname matches
+ * pattern.
*
- * The 0 is returned when the name is a reserved dos name, no match
- * for the pattern or any type of failure. The 1 is returned when
- * there is a match.
+ * Returns: B_TRUE - if there is a match
+ * B_FALSE - otherwise
*/
-int
-smb_match_name(ino64_t fileid, char *name, char *pattern, boolean_t ignore_case)
+boolean_t
+smb_match_name(ino64_t fid, char *name, char *pattern)
{
- int rc = 0;
- int force;
- char name83[SMB_SHORTNAMELEN];
char shortname[SMB_SHORTNAMELEN];
- /* Leading or trailing dots are disallowed */
if (smb_is_reserved_dos_name(name))
- return (0);
-
- for (force = 0; (force < 2 && rc == 0); force++) {
- (void) smb_mangle_name(fileid, name, shortname, name83, force);
-
- rc = smb_match_ci(pattern, name);
-
- /* If no match, check for shortname (if any) */
-
- if (rc == 0 && strchr(pattern, '~'))
- if (*shortname != 0)
- rc = smb_match_ci(pattern, shortname);
-
- /*
- * Sigh... DOS Shells use short name
- * interchangeably with long case sensitive
- * names. So check that too...
- */
- if ((rc == 0) && !ignore_case)
- rc = smb_match83(pattern, name83);
-
- /*
- * Still not found and potentially a premangled name...
- * Check to see if the butt-head programmer is
- * assuming that we mangle names in the same manner
- * as NT...
- */
- if (rc == 0)
- rc = smb_match_unknown(name, pattern);
- }
-
- return (rc);
-}
-
-/*
- * smb_match_unknown
- *
- * I couldn't figure out what the assumptions of this peice of
- * code about the format of pattern and name are and so how
- * it's trying to match them. I just cleaned it up a little bit!
- *
- * If anybody could figure out what this is doing, please put
- * comment here and change the function's name!
- */
-static int
-smb_match_unknown(char *name, char *pattern)
-{
- int rc;
- char nc, pc;
- char *np, *pp;
-
- rc = 0;
- if (smb_isstrupr(pattern) <= 0)
- return (rc);
-
- np = name;
- pp = pattern;
-
- pc = *pattern;
- while ((nc = *np++) != 0) {
- if (nc == ' ')
- continue;
-
- nc = smb_toupper(nc);
- if ((pc = *pp++) != nc)
- break;
- }
-
- if ((pc == '~') &&
- (pp != (pattern + 1)) &&
- ((pc = *pp++) != 0)) {
- while (smb_isdigit(pc))
- pc = *pp++;
-
- if (pc == '.') {
- while ((nc = *np++) != 0) {
- if (nc == '.')
- break;
- }
+ return (B_FALSE);
- while ((nc = *np++) != 0) {
- nc = smb_toupper(nc);
- if ((pc = *pp++) != nc)
- break;
- }
- }
+ if (smb_match_ci(pattern, name))
+ return (B_TRUE);
- if (pc == 0)
- rc = 1;
- }
+ smb_mangle(name, fid, shortname, SMB_SHORTNAMELEN);
+ if (smb_match_ci(pattern, shortname))
+ return (B_TRUE);
- return (rc);
+ return (B_FALSE);
}
/*
@@ -252,195 +166,99 @@ smb_is_reserved_dos_name(const char *name)
}
/*
- * smb_needs_mangle
- *
- * Determines whether the given name needs to get mangled.
- *
- * Here are the (known) rules:
- *
- * 1st char is dot (.)
- * name length > 12 chars
- * # dots > 1
- * # dots == 0 and length > 8
- * # dots == 1 and name isn't 8.3
- * contains illegal chars
+ * smb_needs_mangled
+ *
+ * A name needs to be mangled if any of the following are true:
+ * - the first character is dot (.) and the name is not "." or ".."
+ * - the name contains illegal or special charsacter
+ * - the name name length > 12
+ * - the number of dots == 0 and length > 8
+ * - the number of dots > 1
+ * - the number of dots == 1 and name is not 8.3
*/
-int
-smb_needs_mangle(char *name, char **dot_pos)
+boolean_t
+smb_needs_mangled(const char *name)
{
- int len, ndots;
- char *namep;
- char *last_dot;
+ int len, extlen, ndots;
+ const char *p;
+ const char *last_dot;
- /*
- * Returning (1) for these cases forces consistency with how
- * these names are treated (smb_mangle_name() will produce an 8.3 name
- * for these)
- */
if ((strcmp(name, ".") == 0) || (strcmp(name, "..") == 0))
- return (1);
-
- /* skip the leading dots (if any) */
- for (namep = name; *namep == '.'; namep++)
- ;
-
- len = ndots = 0;
- last_dot = 0;
- for (; *namep; namep++) {
- len++;
- if (*namep == '.') {
- /* keep the position of last dot */
- last_dot = namep;
- ndots++;
- }
- }
- *dot_pos = last_dot;
+ return (B_FALSE);
- /* Windows mangles names like .a, .abc, or .abcd */
if (*name == '.')
- return (1);
-
- if (len > 12)
- return (1);
-
- switch (ndots) {
- case 0:
- /* no dot */
- if (len > 8)
- return (1);
- break;
-
- case 1:
- /* just one dot */
- /*LINTED E_PTR_DIFF_OVERFLOW*/
- if (((last_dot - name) > 8) || /* name length > 8 */
- (strlen(last_dot + 1) > 3)) /* extention > 3 */
- return (1);
- break;
+ return (B_TRUE);
+
+ len = 0;
+ ndots = 0;
+ last_dot = NULL;
+ for (p = name; *p != '\0'; ++p) {
+ if (smb_iscntrl(*p) ||
+ (strchr(special_chars, *p) != NULL) ||
+ (strchr(invalid_dos_chars, *p)) != NULL)
+ return (B_TRUE);
- default:
- /* more than one dot */
- return (1);
+ if (*p == '.') {
+ ++ndots;
+ last_dot = p;
+ }
+ ++len;
}
- for (namep = name; *namep; namep++) {
- if (!smb_isascii(*namep) ||
- strchr(special_chars, *namep) ||
- strchr(invalid_dos_chars, *namep))
- return (1);
+ if ((len > SMB_NAME83_LEN) ||
+ (ndots == 0 && len > SMB_NAME83_BASELEN) ||
+ (ndots > 1)) {
+ return (B_TRUE);
}
- return (0);
-}
+ if (last_dot != NULL) {
+ extlen = strlen(last_dot + 1);
+ if ((extlen == 0) || (extlen > SMB_NAME83_EXTLEN))
+ return (B_TRUE);
-/*
- * smb_needs_shortname
- *
- * Determine whether a shortname should be generated for a file name that is
- * already in 8.3 format.
- *
- * Paramters:
- * name - original file name
- *
- * Return:
- * 1 - Shortname is required to be generated.
- * 0 - No shortname needs to be generated.
- *
- * Note
- * =======
- * Windows NT server: shortname is created only if either
- * the filename or extension portion of
- * a file is made up of mixed case.
- * Windows 2000 server: shortname is not created regardless
- * of the case.
- * Windows 2003 server: [Same as Windows NT server.]
- *
- * StorEdge will conform to the rule used by Windows NT/2003 server.
- *
- * For instance:
- * File | Create shortname?
- * ================================
- * nf.txt | N
- * NF.TXT | N
- * NF.txt | N
- * nf | N
- * NF | N
- * nF.txt | Y
- * nf.TxT | Y
- * Nf | Y
- * nF | Y
- *
- */
-static int
-smb_needs_shortname(char *name)
-{
- char buf[9];
- int len;
- int create = 0;
- const char *dot_pos = 0;
-
- dot_pos = strrchr(name, '.');
- /*LINTED E_PTRDIFF_OVERFLOW*/
- len = (!dot_pos) ? strlen(name) : (dot_pos - name);
- /* First, examine the name portion of the file */
- if (len) {
- (void) snprintf(buf, len + 1, "%s", name);
- /* if the name contains both lower and upper cases */
- if (smb_isstrupr(buf) == 0 && smb_isstrlwr(buf) == 0) {
- /* create shortname */
- create = 1;
- } else if (dot_pos) {
- /* Next, examine the extension portion of the file */
- (void) snprintf(buf, sizeof (buf), "%s", dot_pos + 1);
- /*
- * if the extension contains both lower and upper
- * cases
- */
- if (smb_isstrupr(buf) == 0 && smb_isstrlwr(buf) == 0)
- /* create shortname */
- create = 1;
- }
+ if ((len - extlen - 1) > SMB_NAME83_BASELEN)
+ return (B_TRUE);
}
- return (create);
+ return (B_FALSE);
}
/*
* smb_mangle_char
*
- * If given char is an invalid DOS character or it's not an
- * ascii char, it should be deleted from mangled and 8.3 name.
+ * If c is an invalid DOS character or non-ascii, it should
+ * not be used in the mangled name. We return -1 to indicate
+ * an invalid character.
*
- * If given char is one of special chars, it should be replaced
- * with '_'.
+ * If c is a special chars, it should be replaced with '_'.
*
- * Otherwise just make it upper case.
+ * Otherwise c is returned as uppercase.
*/
-static unsigned char
-smb_mangle_char(unsigned char ch)
+static char
+smb_mangle_char(char c)
{
- if (isinvalid(ch))
- return (0);
+ if (isinvalid(c))
+ return (-1);
- if (strchr(special_chars, ch))
+ if (strchr(special_chars, c))
return ('_');
- return (smb_toupper(ch));
+ return (smb_toupper(c));
}
/*
* smb_generate_mangle
*
- * Generate a mangle string containing at least 2 characters and at most
- * (buflen - 1) characters. Note: fid cannot be 0.
+ * Generate a mangle string containing at least 2 characters and
+ * at most (buflen - 1) characters.
*
* Returns the number of chars in the generated mangle.
*/
static int
-smb_generate_mangle(uint64_t fid, unsigned char *buf, size_t buflen)
+smb_generate_mangle(uint64_t fid, char *buf, size_t buflen)
{
static char *base36 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- unsigned char *p = buf;
+ char *p = buf;
int i;
if (fid == 0)
@@ -455,7 +273,7 @@ smb_generate_mangle(uint64_t fid, unsigned char *buf, size_t buflen)
}
/*
- * smb_maybe_mangled_name
+ * smb_maybe_mangled
*
* Mangled names should be valid DOS file names: less than 12 characters
* long, contain at least one tilde character and conform to an 8.3 name
@@ -463,8 +281,8 @@ smb_generate_mangle(uint64_t fid, unsigned char *buf, size_t buflen)
*
* Returns true if the name looks like a mangled name.
*/
-int
-smb_maybe_mangled_name(char *name)
+boolean_t
+smb_maybe_mangled(char *name)
{
const char *p;
boolean_t has_tilde = B_FALSE;
@@ -488,162 +306,79 @@ smb_maybe_mangled_name(char *name)
return (B_FALSE);
}
- return ((*p == 0) && has_tilde);
+ return ((*p == '\0') && has_tilde);
}
/*
- * smb_mangle_name
+ * smb_mangle
*
* Microsoft knowledge base article #142982 describes how Windows
* generates 8.3 filenames from long file names. Some other details
* can be found in article #114816.
*
- * The function first checks to see whether the given name needs mangling.
- * If not, and the force parameter is not set, then no mangling is done,
- * but both the shortname (if needed) and the 8.3 name are produced and
- * returned.
- *
- * If the "force" parameter is set (as will be the case for case-insensitive
- * collisions), then the name will be mangled.
- *
- * Whenever mangling is needed, both the shortname and the 8.3 names are
- * produced and returned.
+ * This function will mangle the name whether mangling is required
+ * or not. Callers should use smb_needs_mangled() to determine whether
+ * mangling is required.
*
- * For example, the xxx.xy in 8.3 format will be "xxx .xy ".
+ * name original file name
+ * fid inode number to generate unique mangle
+ * buf output buffer (buflen bytes) to contain mangled name
*/
-
-int smb_mangle_name(
- ino64_t fileid, /* inode number to generate unique mangle */
- char *name, /* original file name */
- char *shortname, /* mangled name (if applicable) */
- char *name83, /* (mangled) name in 8.3 format */
- int force) /* force mangling even if mangling is not */
- /* needed according to standard algorithm */
+void
+smb_mangle(const char *name, ino64_t fid, char *buf, size_t buflen)
{
- int avail, len;
- unsigned char ch;
- unsigned char mangle_buf[SMB_NAME83_BASELEN];
- unsigned char *namep;
- unsigned char *manglep;
- unsigned char *out_short;
- unsigned char *out_83;
- char *dot_pos = NULL;
-
- /*
- * NOTE:
- * This function used to consider filename case
- * in order to mangle. I removed those checks.
- */
-
- *shortname = *name83 = 0;
-
- /* Allow dot and dot dot up front */
- if (strcmp(name, ".") == 0) {
- /* no shortname */
- (void) strcpy(name83, ". . ");
- return (1);
- }
-
- if (strcmp(name, "..") == 0) {
- /* no shortname */
- (void) strcpy(name83, ".. . ");
- return (1);
- }
-
- out_short = (unsigned char *)shortname;
- out_83 = (unsigned char *)name83;
-
- if ((smb_needs_mangle(name, &dot_pos) == 0) && (force == 0)) {
- /* no mangle */
-
- /* check if shortname is required or not */
- if (smb_needs_shortname(name)) {
- namep = (unsigned char *)name;
- while (*namep)
- *out_short++ = smb_toupper(*namep++);
- *out_short = '\0';
- }
+ int i, avail;
+ const char *p;
+ char c;
+ char *pbuf;
+ char mangle_buf[SMB_NAME83_BASELEN];
- out_83 = (unsigned char *)name83;
- (void) strcpy((char *)out_83, " . ");
- while (*name && *name != '.')
- *out_83++ = smb_toupper(*name++);
-
- if (*name == '.') {
- /* copy extension */
- name++;
- out_83 = (unsigned char *)name83 + 9;
- while (*name)
- *out_83++ = smb_toupper(*name++);
- }
- return (1);
- }
+ ASSERT(name && buf && (buflen >= SMB_SHORTNAMELEN));
- len = smb_generate_mangle(fileid, mangle_buf, SMB_NAME83_BASELEN);
- avail = SMB_NAME83_BASELEN - len;
+ avail = SMB_NAME83_BASELEN -
+ smb_generate_mangle(fid, mangle_buf, SMB_NAME83_BASELEN);
+ name += strspn(name, ".");
/*
- * generated mangle part has always less than 8 chars, so
- * use the chars before the first dot in filename
- * and try to generate a full 8 char name.
+ * Copy up to avail characters from the base part of name
+ * to buf then append the generated mangle string.
*/
-
- /* skip the leading dots (if any) */
- for (namep = (unsigned char *)name; *namep == '.'; namep++)
- ;
-
- for (; avail && *namep && (*namep != '.'); namep++) {
- ch = smb_mangle_char(*namep);
- if (ch == 0)
+ p = name;
+ pbuf = buf;
+ for (i = 0; (i < avail) && (*p != '\0') && (*p != '.'); ++i, ++p) {
+ if ((c = smb_mangle_char(*p)) == -1)
continue;
- *out_short++ = *out_83++ = ch;
- avail--;
+ *pbuf++ = c;
}
+ *pbuf = '\0';
+ (void) strlcat(pbuf, mangle_buf, SMB_NAME83_BASELEN);
+ pbuf = strchr(pbuf, '\0');
- /* Copy in mangled part */
- manglep = mangle_buf;
-
- while (*manglep)
- *out_short++ = *out_83++ = *(manglep++);
-
- /* Pad any leftover in 8.3 name with spaces */
- while (avail--)
- *out_83++ = ' ';
-
- /* Work on extension now */
- avail = 3;
- *out_83++ = '.';
- if (dot_pos) {
- namep = (unsigned char *)dot_pos + 1;
- if (*namep != 0) {
- *out_short++ = '.';
- for (; avail && *namep; namep++) {
- ch = smb_mangle_char(*namep);
- if (ch == 0)
- continue;
-
- *out_short++ = *out_83++ = ch;
- avail--;
- }
+ /*
+ * Find the last dot in the name. If there is a dot and an
+ * extension, append '.' and up to SMB_NAME83_EXTLEN extension
+ * characters to the mangled name.
+ */
+ if (((p = strrchr(name, '.')) != NULL) && (*(++p) != '\0')) {
+ *pbuf++ = '.';
+ for (i = 0; (i < SMB_NAME83_EXTLEN) && (*p != '\0'); ++i, ++p) {
+ if ((c = smb_mangle_char(*p)) == -1)
+ continue;
+ *pbuf++ = c;
}
}
- while (avail--)
- *out_83++ = ' ';
-
- *out_short = *out_83 = '\0';
-
- return (1);
+ *pbuf = '\0';
}
/*
- * smb_unmangle_name
+ * smb_unmangle
*
* Given a mangled name, try to find the real file name as it appears
* in the directory entry.
*
- * smb_unmangle_name should only be called on names for which
- * smb_maybe_mangled_name() is true
+ * smb_unmangle should only be called on names for which
+ * smb_maybe_mangled() is true
*
* File systems which support VFSFT_EDIRENT_FLAGS will return the
* directory entries as a buffer of edirent_t structure. Others will
@@ -659,7 +394,7 @@ int smb_mangle_name(
*/
#define SMB_UNMANGLE_BUFSIZE (4 * 1024)
int
-smb_unmangle_name(smb_node_t *dnode, char *name, char *namebuf,
+smb_unmangle(smb_node_t *dnode, char *name, char *namebuf,
int buflen, uint32_t flags)
{
int err, eof, bufsize, reclen;
@@ -668,7 +403,6 @@ smb_unmangle_name(smb_node_t *dnode, char *name, char *namebuf,
boolean_t is_edp;
char *namep, *buf;
char shortname[SMB_SHORTNAMELEN];
- char name83[SMB_SHORTNAMELEN];
vnode_t *vp;
union {
char *bufptr;
@@ -682,7 +416,7 @@ smb_unmangle_name(smb_node_t *dnode, char *name, char *namebuf,
if (dnode == NULL || name == NULL || namebuf == NULL || buflen == 0)
return (EINVAL);
- ASSERT(smb_maybe_mangled_name(name) != 0);
+ ASSERT(smb_maybe_mangled(name) == B_TRUE);
if (!smb_node_is_dir(dnode))
return (ENOTDIR);
@@ -723,8 +457,7 @@ smb_unmangle_name(smb_node_t *dnode, char *name, char *namebuf,
U8_VALIDATE_ENTIRE, &err) < 0)
continue;
- (void) smb_mangle_name(ino, namep,
- shortname, name83, 1);
+ smb_mangle(namep, ino, shortname, SMB_SHORTNAMELEN);
if (smb_strcasecmp(name, shortname, 0) == 0) {
(void) strlcpy(namebuf, namep, buflen);
diff --git a/usr/src/uts/common/fs/smbsrv/smb_negotiate.c b/usr/src/uts/common/fs/smbsrv/smb_negotiate.c
index 7cb09f1c2a..472ca550f1 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_negotiate.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_negotiate.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -194,6 +193,21 @@
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smbinfo.h>
+static smb_xlate_t smb_dialect[] = {
+ { DIALECT_UNKNOWN, "DIALECT_UNKNOWN" },
+ { PC_NETWORK_PROGRAM_1_0, "PC NETWORK PROGRAM 1.0" },
+ { PCLAN1_0, "PCLAN1.0" },
+ { MICROSOFT_NETWORKS_1_03, "MICROSOFT NETWORKS 1.03" },
+ { MICROSOFT_NETWORKS_3_0, "MICROSOFT NETWORKS 3.0" },
+ { LANMAN1_0, "LANMAN1.0" },
+ { LM1_2X002, "LM1.2X002" },
+ { DOS_LM1_2X002, "DOS LM1.2X002" },
+ { DOS_LANMAN2_1, "DOS LANMAN2.1" },
+ { LANMAN2_1, "LANMAN2.1" },
+ { Windows_for_Workgroups_3_1a, "Windows for Workgroups 3.1a" },
+ { NT_LM_0_12, "NT LM 0.12" }
+};
+
/*
* Maximum buffer size for DOS: chosen to be the same as NT.
* Do not change this value, DOS is very sensitive to it.
@@ -215,50 +229,69 @@
static uint32_t smb_dos_tcp_rcvbuf = 8700;
static uint32_t smb_nt_tcp_rcvbuf = 1048560; /* scale factor of 4 */
-static void smb_get_security_info(smb_request_t *, unsigned short *,
- unsigned char *, unsigned char *, uint32_t *);
+static void smb_negotiate_genkey(smb_request_t *);
+static int smb_xlate_dialect(const char *);
int smb_cap_passthru = 1;
-/*
- * Function: int smb_com_negotiate(struct smb_request *)
- */
smb_sdrc_t
smb_pre_negotiate(smb_request_t *sr)
{
- DTRACE_SMB_1(op__Negotiate__start, smb_request_t *, sr);
+ smb_arg_negotiate_t *negprot;
+ int dialect;
+ int pos;
+ int rc = 0;
+
+ negprot = smb_srm_zalloc(sr, sizeof (smb_arg_negotiate_t));
+ negprot->ni_index = -1;
+ sr->sr_negprot = negprot;
+
+ for (pos = 0; smbsr_decode_data_avail(sr); pos++) {
+ if (smbsr_decode_data(sr, "%L", sr, &negprot->ni_name) != 0) {
+ smbsr_error(sr, 0, ERRSRV, ERRerror);
+ rc = -1;
+ break;
+ }
+
+ if ((dialect = smb_xlate_dialect(negprot->ni_name)) < 0)
+ continue;
+
+ if (negprot->ni_dialect < dialect) {
+ negprot->ni_dialect = dialect;
+ negprot->ni_index = pos;
+ }
+ }
+
+ DTRACE_SMB_2(op__Negotiate__start, smb_request_t *, sr,
+ smb_arg_negotiate_t, negprot);
smb_rwx_rwenter(&sr->session->s_lock, RW_WRITER);
- return (SDRC_SUCCESS);
+ return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_negotiate(smb_request_t *sr)
{
- DTRACE_SMB_1(op__Negotiate__done, smb_request_t *, sr);
+ smb_arg_negotiate_t *negprot = sr->sr_negprot;
+
+ DTRACE_SMB_2(op__Negotiate__done, smb_request_t *, sr,
+ smb_arg_negotiate_t, negprot);
smb_rwx_rwexit(&sr->session->s_lock);
+
+ bzero(negprot, sizeof (smb_arg_negotiate_t));
}
smb_sdrc_t
smb_com_negotiate(smb_request_t *sr)
{
- int dialect = 0;
- int this_dialect;
- unsigned char keylen;
- int sel_pos = -1;
- int pos;
- char key[32];
- char *p;
- timestruc_t time_val;
- unsigned short secmode;
+ smb_arg_negotiate_t *negprot = sr->sr_negprot;
+ uint16_t secmode;
uint32_t sesskey;
- uint32_t capabilities = 0;
- int rc;
- unsigned short max_mpx_count;
- int16_t tz_correction;
char ipaddr_buf[INET6_ADDRSTRLEN];
- char *tmpbuf;
- int buflen;
+ char *nbdomain;
+ uint8_t *wcbuf;
+ int wclen;
smb_msgbuf_t mb;
+ int rc;
if (sr->session->s_state != SMB_SESSION_STATE_ESTABLISHED) {
/* The protocol has already been negotiated. */
@@ -266,37 +299,52 @@ smb_com_negotiate(smb_request_t *sr)
return (SDRC_ERROR);
}
- for (pos = 0;
- sr->smb_data.chain_offset < sr->smb_data.max_bytes;
- pos++) {
- if (smb_mbc_decodef(&sr->smb_data, "%L", sr, &p) != 0) {
- smbsr_error(sr, 0, ERRSRV, ERRerror);
- return (SDRC_ERROR);
- }
-
- this_dialect = smb_xlate_dialect_str_to_cd(p);
-
- if (this_dialect < 0)
- continue;
-
- if (dialect < this_dialect) {
- dialect = this_dialect;
- sel_pos = pos;
- }
- }
+ sr->session->secmode = NEGOTIATE_SECURITY_CHALLENGE_RESPONSE |
+ NEGOTIATE_SECURITY_USER_LEVEL;
+ secmode = sr->session->secmode;
- smb_get_security_info(sr, &secmode, (unsigned char *)key,
- &keylen, &sesskey);
+ smb_negotiate_genkey(sr);
+ sesskey = sr->session->sesskey;
- (void) microtime(&time_val);
- tz_correction = sr->sr_gmtoff / 60;
+ (void) microtime(&negprot->ni_servertime);
+ negprot->ni_tzcorrection = sr->sr_gmtoff / 60;
+ negprot->ni_maxmpxcount = sr->sr_cfg->skc_maxworkers;
+ nbdomain = sr->sr_cfg->skc_nbdomain;
- switch (dialect) {
+ /*
+ * UNICODE support is required for long share names,
+ * long file names and streams.
+ */
+ negprot->ni_capabilities = CAP_LARGE_FILES
+ | CAP_UNICODE
+ | CAP_NT_SMBS
+ | CAP_STATUS32
+ | CAP_NT_FIND
+ | CAP_RAW_MODE
+ | CAP_LEVEL_II_OPLOCKS
+ | CAP_LOCK_AND_READ
+ | CAP_RPC_REMOTE_APIS
+ | CAP_LARGE_READX
+ | CAP_LARGE_WRITEX
+ | CAP_DFS;
+
+ if (smb_cap_passthru)
+ negprot->ni_capabilities |= CAP_INFOLEVEL_PASSTHRU;
+ else
+ cmn_err(CE_NOTE, "smbsrv: cap passthru is %s",
+ (negprot->ni_capabilities & CAP_INFOLEVEL_PASSTHRU) ?
+ "enabled" : "disabled");
+
+ (void) smb_inet_ntop(&sr->session->ipaddr, ipaddr_buf,
+ SMB_IPSTRLEN(sr->session->ipaddr.a_family));
+
+ switch (negprot->ni_dialect) {
case PC_NETWORK_PROGRAM_1_0: /* core */
(void) ksocket_setsockopt(sr->session->sock, SOL_SOCKET,
SO_RCVBUF, (const void *)&smb_dos_tcp_rcvbuf,
sizeof (smb_dos_tcp_rcvbuf), CRED());
- rc = smbsr_encode_result(sr, 1, 0, "bww", 1, sel_pos, 0);
+ rc = smbsr_encode_result(sr, 1, 0, "bww", 1,
+ negprot->ni_index, 0);
break;
case Windows_for_Workgroups_3_1a:
@@ -312,21 +360,21 @@ smb_com_negotiate(smb_request_t *sr)
sr->smb_flg |= SMB_FLAGS_LOCK_AND_READ_OK;
rc = smbsr_encode_result(sr, 13, VAR_BCC,
"bwwwwwwlYww2.w#c",
- 13, /* wct */
- sel_pos, /* dialect index */
- secmode, /* security mode */
- SMB_DOS_MAXBUF, /* max buffer size */
- 1, /* max MPX (temporary) */
- 1, /* max VCs (temporary, ambiguous) */
- 3, /* raw mode (s/b 3) */
- sesskey, /* session key */
- time_val.tv_sec, /* server time/date */
- tz_correction,
- (short)keylen, /* Encryption Key Length */
- /* reserved field handled 2. */
+ 13, /* wct */
+ negprot->ni_index, /* dialect index */
+ secmode, /* security mode */
+ SMB_DOS_MAXBUF, /* max buffer size */
+ 1, /* max MPX */
+ 1, /* max VCs */
+ 3, /* raw mode (s/b 3) */
+ sesskey, /* session key */
+ negprot->ni_servertime.tv_sec, /* server date/time */
+ negprot->ni_tzcorrection,
+ (uint16_t)negprot->ni_keylen, /* encryption key length */
+ /* reserved field handled 2. */
VAR_BCC,
- (int)keylen,
- key); /* encryption key */
+ (int)negprot->ni_keylen,
+ negprot->ni_key); /* encryption key */
break;
case DOS_LANMAN2_1:
@@ -337,51 +385,28 @@ smb_com_negotiate(smb_request_t *sr)
sr->smb_flg |= SMB_FLAGS_LOCK_AND_READ_OK;
rc = smbsr_encode_result(sr, 13, VAR_BCC,
"bwwwwwwlYww2.w#cs",
- 13, /* wct */
- sel_pos, /* dialect index */
- secmode, /* security mode */
- SMB_DOS_MAXBUF, /* max buffer size */
- 1, /* max MPX (temporary) */
- 1, /* max VCs (temporary, ambiguous) */
- 3, /* raw mode (s/b 3) */
- sesskey, /* session key */
- time_val.tv_sec, /* server time/date */
- tz_correction,
- (short)keylen, /* Encryption Key Length */
- /* reserved field handled 2. */
+ 13, /* wct */
+ negprot->ni_index, /* dialect index */
+ secmode, /* security mode */
+ SMB_DOS_MAXBUF, /* max buffer size */
+ 1, /* max MPX */
+ 1, /* max VCs */
+ 3, /* raw mode (s/b 3) */
+ sesskey, /* session key */
+ negprot->ni_servertime.tv_sec, /* server date/time */
+ negprot->ni_tzcorrection,
+ (uint16_t)negprot->ni_keylen, /* encryption key length */
+ /* reserved field handled 2. */
VAR_BCC,
- (int)keylen,
- key, /* encryption key */
- sr->sr_cfg->skc_nbdomain);
+ (int)negprot->ni_keylen,
+ negprot->ni_key, /* encryption key */
+ nbdomain);
break;
case NT_LM_0_12:
(void) ksocket_setsockopt(sr->session->sock, SOL_SOCKET,
SO_RCVBUF, (const void *)&smb_nt_tcp_rcvbuf,
sizeof (smb_nt_tcp_rcvbuf), CRED());
- /*
- * UNICODE support is required for long share names,
- * long file names and streams.
- */
- capabilities = CAP_LARGE_FILES
- | CAP_UNICODE
- | CAP_NT_SMBS
- | CAP_STATUS32
- | CAP_NT_FIND
- | CAP_RAW_MODE
- | CAP_LEVEL_II_OPLOCKS
- | CAP_LOCK_AND_READ
- | CAP_RPC_REMOTE_APIS
- | CAP_LARGE_READX
- | CAP_LARGE_WRITEX
- | CAP_DFS;
-
- if (smb_cap_passthru)
- capabilities |= CAP_INFOLEVEL_PASSTHRU;
- else
- cmn_err(CE_NOTE, "smbsrv: cap passthru is %s",
- (capabilities & CAP_INFOLEVEL_PASSTHRU) ?
- "enabled" : "disabled");
/*
* Turn off Extended Security Negotiation
@@ -400,55 +425,45 @@ smb_com_negotiate(smb_request_t *sr)
sr->session->secmode = secmode;
}
- (void) smb_inet_ntop(&sr->session->ipaddr, ipaddr_buf,
- SMB_IPSTRLEN(sr->session->ipaddr.a_family));
-
- max_mpx_count = sr->sr_cfg->skc_maxworkers;
/*
- * skc_nbdomain is not expected to be aligned.
+ * nbdomain is not expected to be aligned.
* Use temporary buffer to avoid alignment padding
*/
- buflen = smb_wcequiv_strlen(sr->sr_cfg->skc_nbdomain) +
- sizeof (smb_wchar_t);
- tmpbuf = kmem_zalloc(buflen, KM_SLEEP);
- smb_msgbuf_init(&mb, (uint8_t *)tmpbuf, buflen,
- SMB_MSGBUF_UNICODE);
- if (smb_msgbuf_encode(&mb, "U",
- sr->sr_cfg->skc_nbdomain) < 0) {
+ wclen = smb_wcequiv_strlen(nbdomain) + sizeof (smb_wchar_t);
+ wcbuf = smb_srm_zalloc(sr, wclen);
+ smb_msgbuf_init(&mb, wcbuf, wclen, SMB_MSGBUF_UNICODE);
+ if (smb_msgbuf_encode(&mb, "U", nbdomain) < 0) {
smb_msgbuf_term(&mb);
- kmem_free(tmpbuf, buflen);
smbsr_error(sr, 0, ERRSRV, ERRerror);
return (SDRC_ERROR);
}
rc = smbsr_encode_result(sr, 17, VAR_BCC,
"bwbwwllllTwbw#c#c",
- 17, /* wct */
- sel_pos, /* dialect index */
- secmode, /* security mode */
- max_mpx_count, /* max MPX (temporary) */
- 1, /* max VCs (temporary, ambiguous) */
+ 17, /* wct */
+ negprot->ni_index, /* dialect index */
+ secmode, /* security mode */
+ negprot->ni_maxmpxcount, /* max MPX */
+ 1, /* max VCs */
(DWORD)smb_maxbufsize, /* max buffer size */
- 0xFFFF, /* max raw size */
- sesskey, /* session key */
- capabilities,
- &time_val, /* system time */
- tz_correction,
- keylen, /* Encryption Key Length */
+ 0xFFFF, /* max raw size */
+ sesskey, /* session key */
+ negprot->ni_capabilities,
+ &negprot->ni_servertime, /* system time */
+ negprot->ni_tzcorrection,
+ negprot->ni_keylen, /* encryption key length */
VAR_BCC,
- (int)keylen,
- key, /* encryption key */
- buflen,
- tmpbuf); /* skc_nbdomain */
+ (int)negprot->ni_keylen,
+ negprot->ni_key, /* encryption key */
+ wclen,
+ wcbuf); /* nbdomain (unicode) */
smb_msgbuf_term(&mb);
- kmem_free(tmpbuf, buflen);
break;
default:
- sel_pos = -1;
- rc = smbsr_encode_result(sr, 1, 0, "bww", 1, sel_pos, 0);
+ rc = smbsr_encode_result(sr, 1, 0, "bww", 1, -1, 0);
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
@@ -459,34 +474,40 @@ smb_com_negotiate(smb_request_t *sr)
* Save the agreed dialect. Note that this value is also
* used to detect and reject attempts to re-negotiate.
*/
- sr->session->dialect = dialect;
+ sr->session->dialect = negprot->ni_dialect;
sr->session->s_state = SMB_SESSION_STATE_NEGOTIATED;
return (SDRC_SUCCESS);
}
static void
-smb_get_security_info(
- struct smb_request *sr,
- unsigned short *secmode,
- unsigned char *key,
- unsigned char *keylen,
- uint32_t *sesskey)
+smb_negotiate_genkey(smb_request_t *sr)
{
- uchar_t tmp_key[8];
+ smb_arg_negotiate_t *negprot = sr->sr_negprot;
+ uint8_t tmp_key[8];
(void) random_get_pseudo_bytes(tmp_key, 8);
bcopy(tmp_key, &sr->session->challenge_key, 8);
sr->session->challenge_len = 8;
- *keylen = 8;
- bcopy(tmp_key, key, 8);
-
- sr->session->secmode = NEGOTIATE_SECURITY_CHALLENGE_RESPONSE|
- NEGOTIATE_SECURITY_USER_LEVEL;
+ negprot->ni_keylen = 8;
+ bcopy(tmp_key, negprot->ni_key, 8);
(void) random_get_pseudo_bytes(tmp_key, 4);
sr->session->sesskey = tmp_key[0] | tmp_key[1] << 8 |
tmp_key[2] << 16 | tmp_key[3] << 24;
+}
+
+static int
+smb_xlate_dialect(const char *dialect)
+{
+ smb_xlate_t *dp;
+ int i;
+
+ for (i = 0; i < sizeof (smb_dialect) / sizeof (smb_dialect[0]); ++i) {
+ dp = &smb_dialect[i];
+
+ if (strcmp(dp->str, dialect) == 0)
+ return (dp->code);
+ }
- *secmode = sr->session->secmode;
- *sesskey = sr->session->sesskey;
+ return (-1);
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_node.c b/usr/src/uts/common/fs/smbsrv/smb_node.c
index c59b58a773..d29e9e8703 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_node.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_node.c
@@ -557,7 +557,7 @@ smb_node_delete_on_close(smb_node_t *node)
else
rc = smb_fsop_remove(0, node->delete_on_close_cred,
d_snode, node->od_name, flags);
- smb_cred_rele(node->delete_on_close_cred);
+ crfree(node->delete_on_close_cred);
}
if (rc != 0)
cmn_err(CE_WARN, "File %s could not be removed, rc=%d\n",
diff --git a/usr/src/uts/common/fs/smbsrv/smb_nt_transact_notify_change.c b/usr/src/uts/common/fs/smbsrv/smb_nt_transact_notify_change.c
index cf48247da3..92a9ffb294 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_nt_transact_notify_change.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_nt_transact_notify_change.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -276,11 +276,16 @@ void
smb_reply_notify_change_request(smb_request_t *sr)
{
smb_node_t *node;
+ smb_srqueue_t *srq;
int total_bytes, n_setup, n_param, n_data;
int param_off, param_pad, data_off, data_pad;
struct smb_xa *xa;
smb_error_t err;
+ SMB_REQ_VALID(sr);
+ srq = sr->session->s_srqueue;
+ smb_srqueue_waitq_to_runq(srq);
+
xa = sr->r_xa;
node = sr->sr_ncr.nc_node;
@@ -335,7 +340,6 @@ smb_reply_notify_change_request(smb_request_t *sr)
break;
case SMB_REQ_STATE_CANCELED:
- err.severity = ERROR_SEVERITY_ERROR;
err.status = NT_STATUS_CANCELLED;
err.errcls = ERRDOS;
err.errcode = ERROR_OPERATION_ABORTED;
@@ -377,6 +381,7 @@ smb_reply_notify_change_request(smb_request_t *sr)
mutex_enter(&sr->sr_mutex);
sr->sr_state = SMB_REQ_STATE_COMPLETED;
mutex_exit(&sr->sr_mutex);
+ smb_srqueue_runq_exit(srq);
smb_request_free(sr);
}
@@ -411,6 +416,8 @@ smb_process_session_notify_change_queue(
&smb_nce_list,
&smb_ncr_list,
sr);
+ smb_srqueue_waitq_enter(
+ sr->session->s_srqueue);
sr->sr_state = SMB_REQ_STATE_CANCELED;
sig = B_TRUE;
break;
@@ -454,6 +461,8 @@ smb_process_file_notify_change_queue(struct smb_ofile *of)
case SMB_REQ_STATE_WAITING_EVENT:
smb_slist_obj_move(&smb_nce_list,
&smb_ncr_list, sr);
+ smb_srqueue_waitq_enter(
+ sr->session->s_srqueue);
sr->sr_state = SMB_REQ_STATE_CANCELED;
sig = B_TRUE;
break;
@@ -501,6 +510,8 @@ smb_reply_specific_cancel_request(struct smb_request *zsr)
case SMB_REQ_STATE_WAITING_EVENT:
smb_slist_obj_move(&smb_nce_list,
&smb_ncr_list, sr);
+ smb_srqueue_waitq_enter(
+ sr->session->s_srqueue);
sr->sr_state = SMB_REQ_STATE_CANCELED;
sig = B_TRUE;
break;
@@ -561,6 +572,8 @@ smb_process_node_notify_change_queue(smb_node_t *node)
case SMB_REQ_STATE_WAITING_EVENT:
smb_slist_obj_move(&smb_nce_list,
&smb_ncr_list, sr);
+ smb_srqueue_waitq_enter(
+ sr->session->s_srqueue);
sr->sr_state = SMB_REQ_STATE_EVENT_OCCURRED;
sig = B_TRUE;
break;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_nt_transact_quota.c b/usr/src/uts/common/fs/smbsrv/smb_nt_transact_quota.c
index b0fdc7bb47..041f05f3e3 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_nt_transact_quota.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_nt_transact_quota.c
@@ -18,15 +18,15 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
+
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_fsops.h>
#include <smbsrv/smb_share.h>
#include <smbsrv/string.h>
-#include <smbsrv/lmerr.h>
#include <sys/fs/zfs.h>
#include <smbsrv/smb_xdr.h>
#include <smbsrv/smb_door.h>
@@ -202,7 +202,7 @@ smb_nt_transact_query_quota(smb_request_t *sr, smb_xa_t *xa)
smb_quota_free_sids(&request);
if (status != NT_STATUS_SUCCESS) {
- if (status == NT_STATUS_NO_MORE_DATA) {
+ if (status == NT_STATUS_NO_MORE_ENTRIES) {
smb_ofile_set_quota_resume(ofile, NULL);
smbsr_warn(sr, status, 0, 0);
status = NT_STATUS_SUCCESS;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_nt_transact_security.c b/usr/src/uts/common/fs/smbsrv/smb_nt_transact_security.c
index 948dad7102..cb24963d29 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_nt_transact_security.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_nt_transact_security.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <smbsrv/smb_kproto.h>
@@ -116,7 +116,6 @@ smb_nt_transact_query_security_info(struct smb_request *sr, struct smb_xa *xa)
* should provide a buffer size hint for the client.
*/
(void) smb_mbc_encodef(&xa->rep_param_mb, "l", sdlen);
- err.severity = ERROR_SEVERITY_ERROR;
err.status = NT_STATUS_BUFFER_TOO_SMALL;
err.errcls = ERRDOS;
err.errcode = ERROR_INSUFFICIENT_BUFFER;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_odir.c b/usr/src/uts/common/fs/smbsrv/smb_odir.c
index 372f4e2a4b..b421e890fa 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_odir.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_odir.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -493,7 +492,6 @@ smb_odir_read(smb_request_t *sr, smb_odir_t *od,
smb_odirent_t *odirent, boolean_t *eof)
{
int rc;
- boolean_t ignore_case;
ASSERT(sr);
ASSERT(sr->sr_magic == SMB_REQ_MAGIC);
@@ -515,13 +513,11 @@ smb_odir_read(smb_request_t *sr, smb_odir_t *od,
return (-1);
}
- ignore_case = (od->d_flags & SMB_ODIR_FLAG_IGNORE_CASE);
-
for (;;) {
if ((rc = smb_odir_next_odirent(od, odirent)) != 0)
break;
if (smb_match_name(odirent->od_ino, odirent->od_name,
- od->d_pattern, ignore_case))
+ od->d_pattern))
break;
}
@@ -569,7 +565,6 @@ smb_odir_read_fileinfo(smb_request_t *sr, smb_odir_t *od,
{
int rc, errnum;
smb_odirent_t *odirent;
- boolean_t ignore_case;
ASSERT(sr);
ASSERT(sr->sr_magic == SMB_REQ_MAGIC);
@@ -591,8 +586,6 @@ smb_odir_read_fileinfo(smb_request_t *sr, smb_odir_t *od,
return (-1);
}
- ignore_case = (od->d_flags & SMB_ODIR_FLAG_IGNORE_CASE);
-
if (!(od->d_flags & SMB_ODIR_FLAG_WILDCARDS)) {
if (od->d_eof)
rc = ENOENT;
@@ -613,7 +606,7 @@ smb_odir_read_fileinfo(smb_request_t *sr, smb_odir_t *od,
continue;
if (!smb_match_name(odirent->od_ino, odirent->od_name,
- od->d_pattern, ignore_case))
+ od->d_pattern))
continue;
rc = smb_odir_wildcard_fileinfo(sr, od, odirent,
@@ -638,7 +631,6 @@ smb_odir_read_fileinfo(smb_request_t *sr, smb_odir_t *od,
}
}
-
/*
* smb_odir_read_streaminfo
*
@@ -1090,11 +1082,6 @@ smb_odir_single_fileinfo(smb_request_t *sr, smb_odir_t *od,
return (rc);
}
- ino = attr.sa_vattr.va_nodeid;
- (void) smb_mangle_name(ino, fnode->od_name,
- fileinfo->fi_shortname, fileinfo->fi_name83, case_conflict);
- name = (case_conflict) ? fileinfo->fi_shortname : fnode->od_name;
- (void) strlcpy(fileinfo->fi_name, name, sizeof (fileinfo->fi_name));
/* follow link to get target node & attr */
if (smb_node_is_symlink(fnode) &&
@@ -1113,6 +1100,15 @@ smb_odir_single_fileinfo(smb_request_t *sr, smb_odir_t *od,
return (ENOENT);
}
+ name = fnode->od_name;
+ ino = attr.sa_vattr.va_nodeid;
+ if (case_conflict || smb_needs_mangled(name))
+ smb_mangle(name, ino, fileinfo->fi_shortname, SMB_SHORTNAMELEN);
+ if (case_conflict)
+ name = fileinfo->fi_shortname;
+
+ (void) strlcpy(fileinfo->fi_name, name, sizeof (fileinfo->fi_name));
+
fileinfo->fi_dosattr = attr.sa_dosattr;
fileinfo->fi_nodeid = attr.sa_vattr.va_nodeid;
fileinfo->fi_size = attr.sa_vattr.va_size;
@@ -1134,11 +1130,7 @@ smb_odir_single_fileinfo(smb_request_t *sr, smb_odir_t *od,
*
* odirent contains a directory entry, obtained from a vop_readdir.
* If a case conflict is identified the filename is mangled and the
- * shortname is used as 'name', in place of odirent->od_name. This
- * name will be used in the smb_fsop_lookup because smb_fsop_lookup
- * performs a case insensitive lookup if the tree is case insesitive,
- * so the mangled name is required in the case conflict scenario to
- * ensure the correct match.
+ * shortname is used as 'name', in place of odirent->od_name.
*
* If the looked up file is a link, we attempt to lookup the link target
* to use its attributes in place of those of the files's.
@@ -1173,21 +1165,14 @@ smb_odir_wildcard_fileinfo(smb_request_t *sr, smb_odir_t *od,
ASSERT(MUTEX_HELD(&od->d_mutex));
bzero(fileinfo, sizeof (smb_fileinfo_t));
- case_conflict = ((od->d_flags & SMB_ODIR_FLAG_IGNORE_CASE) &&
- (odirent->od_eflags & ED_CASE_CONFLICT));
- (void) smb_mangle_name(odirent->od_ino, odirent->od_name,
- fileinfo->fi_shortname, fileinfo->fi_name83, case_conflict);
- name = (case_conflict) ? fileinfo->fi_shortname : odirent->od_name;
- (void) strlcpy(fileinfo->fi_name, name, sizeof (fileinfo->fi_name));
-
- rc = smb_fsop_lookup(sr, od->d_cred, 0, od->d_tree->t_snode,
- od->d_dnode, name, &fnode);
+ rc = smb_fsop_lookup(sr, od->d_cred, SMB_CASE_SENSITIVE,
+ od->d_tree->t_snode, od->d_dnode, odirent->od_name, &fnode);
if (rc != 0)
return (rc);
/* follow link to get target node & attr */
if (smb_node_is_symlink(fnode) &&
- smb_odir_lookup_link(sr, od, name, &tgt_node)) {
+ smb_odir_lookup_link(sr, od, odirent->od_name, &tgt_node)) {
smb_node_release(fnode);
fnode = tgt_node;
}
@@ -1209,6 +1194,16 @@ smb_odir_wildcard_fileinfo(smb_request_t *sr, smb_odir_t *od,
return (ENOENT);
}
+ case_conflict = ((od->d_flags & SMB_ODIR_FLAG_IGNORE_CASE) &&
+ (odirent->od_eflags & ED_CASE_CONFLICT));
+ if (case_conflict || smb_needs_mangled(odirent->od_name)) {
+ smb_mangle(odirent->od_name, odirent->od_ino,
+ fileinfo->fi_shortname, SMB_SHORTNAMELEN);
+ }
+
+ name = (case_conflict) ? fileinfo->fi_shortname : odirent->od_name;
+ (void) strlcpy(fileinfo->fi_name, name, sizeof (fileinfo->fi_name));
+
fileinfo->fi_cookie = (uint32_t)od->d_offset;
fileinfo->fi_dosattr = attr.sa_dosattr;
fileinfo->fi_nodeid = attr.sa_vattr.va_nodeid;
@@ -1241,7 +1236,7 @@ smb_odir_wildcard_fileinfo(smb_request_t *sr, smb_odir_t *od,
* symlinks to directories. Symlinks to other object types
* should be unaffected.
*
- * Returns: B_TRUE - followed link. tgt_node and tgt_attr set
+ * Returns: B_TRUE - followed link. tgt_node and tgt_attr set
* B_FALSE - link not followed
*/
static boolean_t
@@ -1249,8 +1244,9 @@ smb_odir_lookup_link(smb_request_t *sr, smb_odir_t *od,
char *fname, smb_node_t **tgt_node)
{
int rc;
+ uint32_t flags = SMB_FOLLOW_LINKS | SMB_CASE_SENSITIVE;
- rc = smb_fsop_lookup(sr, od->d_cred, SMB_FOLLOW_LINKS,
+ rc = smb_fsop_lookup(sr, od->d_cred, flags,
od->d_tree->t_snode, od->d_dnode, fname, tgt_node);
if (rc != 0) {
*tgt_node = NULL;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_ofile.c b/usr/src/uts/common/fs/smbsrv/smb_ofile.c
index 75e96791c1..e3759046da 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_ofile.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_ofile.c
@@ -220,6 +220,7 @@ smb_ofile_open(
if (ftype == SMB_FTYPE_MESG_PIPE) {
of->f_pipe = smb_opipe_alloc(tree->t_server);
+ smb_server_inc_pipes(of->f_server);
} else {
ASSERT(ftype == SMB_FTYPE_DISK); /* Regular file, not a pipe */
ASSERT(node);
@@ -274,14 +275,13 @@ smb_ofile_open(
smb_node_inc_open_ofiles(node);
smb_node_add_ofile(node, of);
smb_node_ref(node);
+ smb_server_inc_files(of->f_server);
}
smb_llist_enter(&tree->t_ofile_list, RW_WRITER);
smb_llist_insert_tail(&tree->t_ofile_list, of);
smb_llist_exit(&tree->t_ofile_list);
atomic_inc_32(&tree->t_open_files);
- atomic_inc_32(&tree->t_server->sv_open_files);
atomic_inc_32(&of->f_session->s_file_cnt);
-
return (of);
}
@@ -305,6 +305,7 @@ smb_ofile_close(smb_ofile_t *of, uint32_t last_wtime)
if (of->f_ftype == SMB_FTYPE_MESG_PIPE) {
smb_opipe_close(of);
+ smb_server_dec_pipes(of->f_server);
} else {
smb_ofile_set_close_attrs(of, last_wtime);
@@ -329,9 +330,9 @@ smb_ofile_close(smb_ofile_t *of, uint32_t last_wtime)
*/
if (of->f_node->flags & NODE_FLAGS_NOTIFY_CHANGE)
smb_process_file_notify_change_queue(of);
+ smb_server_dec_files(of->f_server);
}
atomic_dec_32(&of->f_tree->t_open_files);
- atomic_dec_32(&of->f_tree->t_server->sv_open_files);
mutex_enter(&of->f_mutex);
ASSERT(of->f_refcnt);
@@ -1217,16 +1218,13 @@ smb_ofile_netinfo_init(smb_ofile_t *of, smb_netfileinfo_t *fi)
ASSERT(node);
fi->fi_permissions = of->f_granted_access;
- fi->fi_numlocks = smb_lock_get_lock_count(node);
+ fi->fi_numlocks = smb_lock_get_lock_count(node, of);
path = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
if (node != tree->t_snode) {
- rc = vnodetopath(tree->t_snode->vp, node->vp, path,
- MAXPATHLEN, kcred);
- if (rc == 0)
- (void) strsubst(path, '/', '\\');
- else
+ rc = smb_node_getshrpath(node, tree, path, MAXPATHLEN);
+ if (rc != 0)
(void) strlcpy(path, node->od_name, MAXPATHLEN);
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_opipe.c b/usr/src/uts/common/fs/smbsrv/smb_opipe.c
index c2a78813fd..238bcf2db0 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_opipe.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_opipe.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -111,7 +110,7 @@ smb_opipe_dealloc(smb_opipe_t *opipe)
int
smb_opipe_open(smb_request_t *sr)
{
- open_param_t *op = &sr->arg.open;
+ smb_arg_open_t *op = &sr->sr_open;
smb_ofile_t *of;
smb_opipe_t *opipe;
smb_doorhdr_t hdr;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_oplock.c b/usr/src/uts/common/fs/smbsrv/smb_oplock.c
index 53685acdb0..632293fc5a 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_oplock.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_oplock.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* SMB Locking library functions.
@@ -141,7 +140,7 @@ static void smb_oplock_wait(smb_node_t *);
* done earlier in the calling path.)
*/
void
-smb_oplock_acquire(smb_node_t *node, smb_ofile_t *of, open_param_t *op)
+smb_oplock_acquire(smb_node_t *node, smb_ofile_t *of, smb_arg_open_t *op)
{
smb_session_t *session;
smb_oplock_t *ol;
@@ -368,7 +367,8 @@ smb_oplock_release(smb_node_t *node, smb_ofile_t *of)
* pointer so as to do the session check.
*/
boolean_t
-smb_oplock_conflict(smb_node_t *node, smb_session_t *session, open_param_t *op)
+smb_oplock_conflict(smb_node_t *node, smb_session_t *session,
+ smb_arg_open_t *op)
{
boolean_t rb;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_pathname.c b/usr/src/uts/common/fs/smbsrv/smb_pathname.c
index 21afa79353..bd6fd5cd10 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_pathname.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_pathname.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <smbsrv/smb_kproto.h>
@@ -204,7 +203,7 @@ smb_pathname_reduce(
local_cur_node = cur_node;
local_root_node = root_node;
- if (sr && (sr->smb_flg2 & SMB_FLAGS2_DFS)) {
+ if (SMB_TREE_IS_DFSROOT(sr) && (sr->smb_flg2 & SMB_FLAGS2_DFS)) {
err = smb_pathname_dfs_preprocess(sr, usepath, MAXPATHLEN);
if (err != 0) {
kmem_free(usepath, MAXPATHLEN);
@@ -403,10 +402,10 @@ smb_pathname(smb_request_t *sr, char *path, int flags,
&vp, rootvp, dnode->vp, &attr, cred);
if (err) {
- if (smb_maybe_mangled_name(component) == 0)
+ if (!smb_maybe_mangled(component))
break;
- if ((err = smb_unmangle_name(dnode, component,
+ if ((err = smb_unmangle(dnode, component,
real_name, MAXNAMELEN, abe_flag)) != 0)
break;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_print.c b/usr/src/uts/common/fs/smbsrv/smb_print.c
index de0afea6a6..8e0382c204 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_print.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_print.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -54,6 +53,7 @@ smb_pre_open_print_file(smb_request_t *sr)
struct open_param *op = &sr->arg.open;
char *path;
char *identifier;
+ uint32_t new_id;
uint16_t setup;
uint16_t mode;
int rc;
@@ -64,11 +64,12 @@ smb_pre_open_print_file(smb_request_t *sr)
if (rc == 0)
rc = smbsr_decode_data(sr, "%S", sr, &identifier);
- atomic_inc_32(&tmp_id);
-
- path = smb_srm_zalloc(sr, MAXPATHLEN);
- (void) snprintf(path, MAXPATHLEN, "%s%05u", identifier, tmp_id);
- op->fqi.fq_path.pn_path = path;
+ if (rc == 0) {
+ path = smb_srm_zalloc(sr, MAXPATHLEN);
+ op->fqi.fq_path.pn_path = path;
+ new_id = atomic_inc_32_nv(&tmp_id);
+ (void) snprintf(path, MAXPATHLEN, "%s%05u", identifier, new_id);
+ }
op->create_disposition = FILE_OVERWRITE_IF;
op->create_options = FILE_NON_DIRECTORY_FILE;
diff --git a/usr/src/uts/common/fs/smbsrv/smb_query_fileinfo.c b/usr/src/uts/common/fs/smbsrv/smb_query_fileinfo.c
index 4dc99479a2..6c82440b87 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_query_fileinfo.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_query_fileinfo.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -68,7 +69,6 @@ typedef struct smb_queryinfo {
smb_attr_t qi_attr;
boolean_t qi_delete_on_close;
uint32_t qi_namelen;
- char qi_name83[SMB_SHORTNAMELEN];
char qi_shortname[SMB_SHORTNAMELEN];
char qi_name[MAXPATHLEN];
} smb_queryinfo_t;
@@ -90,8 +90,9 @@ static int smb_query_encode_response(smb_request_t *, smb_xa_t *,
uint16_t, smb_queryinfo_t *);
static void smb_encode_stream_info(smb_request_t *, smb_xa_t *,
smb_queryinfo_t *);
-static int smb_query_pathname(smb_tree_t *, smb_node_t *, boolean_t,
- char *, size_t);
+static int smb_query_pathname(smb_request_t *, smb_node_t *, boolean_t,
+ smb_queryinfo_t *);
+static void smb_query_shortname(smb_node_t *, smb_queryinfo_t *);
int smb_query_passthru;
@@ -232,7 +233,7 @@ smb_query_by_fid(smb_request_t *sr, smb_xa_t *xa, uint16_t infolev)
}
if (infolev == SMB_INFO_IS_NAME_VALID) {
- smbsr_error(sr, 0, ERRDOS, ERRunknownlevel);
+ smbsr_error(sr, 0, ERRDOS, ERROR_INVALID_LEVEL);
smbsr_release_file(sr);
return (-1);
}
@@ -292,7 +293,7 @@ smb_query_by_path(smb_request_t *sr, smb_xa_t *xa, uint16_t infolev)
/* VALID, but not yet supported */
if (infolev == SMB_FILE_ACCESS_INFORMATION) {
- smbsr_error(sr, 0, ERRDOS, ERRunknownlevel);
+ smbsr_error(sr, 0, ERRDOS, ERROR_INVALID_LEVEL);
return (-1);
}
@@ -559,7 +560,7 @@ smb_query_encode_response(smb_request_t *sr, smb_xa_t *xa,
smbsr_error(sr, NT_STATUS_NOT_SUPPORTED,
ERRDOS, ERROR_NOT_SUPPORTED);
else
- smbsr_error(sr, 0, ERRDOS, ERRunknownlevel);
+ smbsr_error(sr, 0, ERRDOS, ERROR_INVALID_LEVEL);
return (-1);
}
@@ -693,45 +694,6 @@ smb_encode_stream_info(smb_request_t *sr, smb_xa_t *xa, smb_queryinfo_t *qinfo)
}
/*
- * smb_query_pathname
- *
- * Determine the absolute pathname of 'node' within the share.
- * For some levels (e.g. ALL_INFO) the pathname should include the
- * sharename for others (e.g. NAME_INFO) the pathname should be
- * relative to the share.
- * For example if the node represents file "test1.txt" in directory
- * "dir1" on share "share1"
- * - if include_share is TRUE the pathname would be: \share1\dir1\test1.txt
- * - if include_share is FALSE the pathname would be: \dir1\test1.txt
- */
-static int
-smb_query_pathname(smb_tree_t *tree, smb_node_t *node, boolean_t include_share,
- char *buf, size_t buflen)
-{
- char *sharename = tree->t_sharename;
- int rc;
- size_t len;
-
- if (include_share) {
- len = snprintf(buf, buflen, "\\%s", sharename);
- if (len == (buflen - 1))
- return (ENAMETOOLONG);
-
- buf += len;
- buflen -= len;
- }
-
- if (node == tree->t_snode) {
- if (!include_share)
- (void) strlcpy(buf, "\\", buflen);
- return (0);
- }
-
- rc = smb_node_getshrpath(node, tree, buf, buflen);
- return (rc);
-}
-
-/*
* smb_query_fileinfo
*
* Populate smb_queryinfo_t structure for SMB_FTYPE_DISK
@@ -741,9 +703,7 @@ int
smb_query_fileinfo(smb_request_t *sr, smb_node_t *node, uint16_t infolev,
smb_queryinfo_t *qinfo)
{
- int rc;
- boolean_t include_sharename = B_FALSE;
- char *namep;
+ int rc = 0;
(void) bzero(qinfo, sizeof (smb_queryinfo_t));
@@ -767,55 +727,113 @@ smb_query_fileinfo(smb_request_t *sr, smb_node_t *node, uint16_t infolev,
--(qinfo->qi_attr.sa_vattr.va_nlink);
}
- /* populate name, namelen and shortname */
-
- /* ALL_INFO levels include the sharename in the name field */
- if ((infolev == SMB_QUERY_FILE_ALL_INFO) ||
- (infolev == SMB_FILE_ALL_INFORMATION)) {
- include_sharename = B_TRUE;
+ /*
+ * populate name, namelen and shortname ONLY for the information
+ * levels that require these fields
+ */
+ switch (infolev) {
+ case SMB_QUERY_FILE_ALL_INFO:
+ case SMB_FILE_ALL_INFORMATION:
+ rc = smb_query_pathname(sr, node, B_TRUE, qinfo);
+ break;
+ case SMB_QUERY_FILE_NAME_INFO:
+ case SMB_FILE_NAME_INFORMATION:
+ rc = smb_query_pathname(sr, node, B_FALSE, qinfo);
+ break;
+ case SMB_QUERY_FILE_ALT_NAME_INFO:
+ case SMB_FILE_ALT_NAME_INFORMATION:
+ smb_query_shortname(node, qinfo);
+ break;
+ default:
+ break;
}
- rc = smb_query_pathname(sr->tid_tree, node, include_sharename,
- qinfo->qi_name, MAXPATHLEN);
if (rc != 0) {
smbsr_errno(sr, rc);
return (-1);
}
+ return (0);
+}
- qinfo->qi_namelen = smb_ascii_or_unicode_strlen(sr, qinfo->qi_name);
+/*
+ * smb_query_pathname
+ *
+ * Determine the absolute pathname of 'node' within the share.
+ * For some levels (e.g. ALL_INFO) the pathname should include the
+ * sharename for others (e.g. NAME_INFO) the pathname should be
+ * relative to the share.
+ * For example if the node represents file "test1.txt" in directory
+ * "dir1" on share "share1"
+ * - if include_share is TRUE the pathname would be: \share1\dir1\test1.txt
+ * - if include_share is FALSE the pathname would be: \dir1\test1.txt
+ *
+ * For some reason NT will not show the security tab in the root
+ * directory of a mapped drive unless the filename length is greater
+ * than one. So if the length is 1 we set it to 2 to persuade NT to
+ * show the tab. It should be safe because of the null terminator.
+ */
+static int
+smb_query_pathname(smb_request_t *sr, smb_node_t *node, boolean_t include_share,
+ smb_queryinfo_t *qinfo)
+{
+ smb_tree_t *tree = sr->tid_tree;
+ char *buf = qinfo->qi_name;
+ size_t buflen = MAXPATHLEN;
+ size_t len;
+ int rc;
- /*
- * For some reason NT will not show the security tab in the root
- * directory of a mapped drive unless the filename length is
- * greater than one. So we hack the length here to persuade NT
- * to show the tab. It should be safe because of the null
- * terminator character.
- */
- if (qinfo->qi_namelen == 1)
- qinfo->qi_namelen = 2;
+ if (include_share) {
+ len = snprintf(buf, buflen, "\\%s", tree->t_sharename);
+ if (len == (buflen - 1))
+ return (ENAMETOOLONG);
+
+ buf += len;
+ buflen -= len;
+ }
+
+ if (node == tree->t_snode) {
+ if (!include_share)
+ (void) strlcpy(buf, "\\", buflen);
+ return (0);
+ }
+
+ rc = smb_node_getshrpath(node, tree, buf, buflen);
+ if (rc == 0) {
+ qinfo->qi_namelen =
+ smb_ascii_or_unicode_strlen(sr, qinfo->qi_name);
+ if (qinfo->qi_namelen == 1)
+ qinfo->qi_namelen = 2;
+ }
+ return (rc);
+}
+
+/*
+ * smb_query_shortname
+ *
+ * If the node is a named stream, use its associated
+ * unnamed stream name to determine the shortname.
+ * If a shortname is required (smb_needs_mangle()), generate it
+ * using smb_mangle(), otherwise, convert the original name to
+ * upper-case and return it as the alternative name.
+ */
+static void
+smb_query_shortname(smb_node_t *node, smb_queryinfo_t *qinfo)
+{
+ char *namep;
- /*
- * If the node is an named stream, use its associated
- * unnamed stream name to determine the shortname.
- * If the shortname is generated by smb_mangle_name()
- * it will be returned as the alternative name.
- * Otherwise, convert the original name to upper-case
- * and return it as the alternative name.
- */
if (SMB_IS_STREAM(node))
namep = node->n_unode->od_name;
else
namep = node->od_name;
- (void) smb_mangle_name(qinfo->qi_attr.sa_vattr.va_nodeid,
- namep, qinfo->qi_shortname, qinfo->qi_name83, 0);
- if (*qinfo->qi_shortname == 0) {
+ if (smb_needs_mangled(namep)) {
+ smb_mangle(namep, qinfo->qi_attr.sa_vattr.va_nodeid,
+ qinfo->qi_shortname, SMB_SHORTNAMELEN);
+ } else {
(void) strlcpy(qinfo->qi_shortname, namep,
SMB_SHORTNAMELEN);
(void) smb_strupr(qinfo->qi_shortname);
}
-
- return (0);
}
/*
diff --git a/usr/src/uts/common/fs/smbsrv/smb_server.c b/usr/src/uts/common/fs/smbsrv/smb_server.c
index 9c62e05092..324d4ac770 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_server.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_server.c
@@ -231,13 +231,10 @@
#define SMB_EVENT_TIMEOUT 45 /* seconds */
-extern void smb_dispatch_kstat_init(void);
-extern void smb_dispatch_kstat_fini(void);
extern void smb_reply_notify_change_request(smb_request_t *);
-static int smb_server_kstat_init(smb_server_t *);
+static void smb_server_kstat_init(smb_server_t *);
static void smb_server_kstat_fini(smb_server_t *);
-static int smb_server_kstat_update_info(kstat_t *, int);
static void smb_server_timers(smb_thread_t *, void *);
static int smb_server_listen(smb_server_t *, smb_listener_daemon_t *,
in_port_t, int, int);
@@ -255,11 +252,11 @@ static void smb_event_notify(smb_server_t *, uint32_t);
static uint32_t smb_event_alloc_txid(void);
static void smb_server_disconnect_share(smb_session_list_t *, const char *);
-static void smb_server_thread_unexport(smb_thread_t *, void *);
static void smb_server_enum_private(smb_session_list_t *, smb_svcenum_t *);
static int smb_server_sesion_disconnect(smb_session_list_t *, const char *,
const char *);
static int smb_server_fclose(smb_session_list_t *, uint32_t);
+static int smb_server_kstat_update(kstat_t *, int);
int smb_event_debug = 0;
@@ -293,8 +290,6 @@ smb_server_svc_init(void)
continue;
if (rc = smb_fem_init())
continue;
- if (rc = smb_user_init())
- continue;
if (rc = smb_notify_init())
continue;
if (rc = smb_net_init())
@@ -308,7 +303,6 @@ smb_server_svc_init(void)
smb_llist_fini();
smb_net_fini();
smb_notify_fini();
- smb_user_fini();
smb_fem_fini();
smb_node_fini();
smb_vop_fini();
@@ -331,7 +325,6 @@ smb_server_svc_fini(void)
smb_llist_fini();
smb_net_fini();
smb_notify_fini();
- smb_user_fini();
smb_fem_fini();
smb_node_fini();
smb_vop_fini();
@@ -373,25 +366,15 @@ smb_server_create(void)
return (ENOMEM);
}
- smb_llist_constructor(&sv->sv_vfs_list, sizeof (smb_vfs_t),
- offsetof(smb_vfs_t, sv_lnd));
-
smb_llist_constructor(&sv->sv_opipe_list, sizeof (smb_opipe_t),
offsetof(smb_opipe_t, p_lnd));
smb_llist_constructor(&sv->sv_event_list, sizeof (smb_event_t),
offsetof(smb_event_t, se_lnd));
- smb_slist_constructor(&sv->sv_unexport_list, sizeof (smb_unexport_t),
- offsetof(smb_unexport_t, ux_lnd));
-
smb_session_list_constructor(&sv->sv_nbt_daemon.ld_session_list);
smb_session_list_constructor(&sv->sv_tcp_daemon.ld_session_list);
- sv->si_cache_unexport = kmem_cache_create("smb_unexport_cache",
- sizeof (smb_unexport_t), 8, NULL, NULL, NULL, NULL, NULL, 0);
- sv->si_cache_vfs = kmem_cache_create("smb_vfs_cache",
- sizeof (smb_vfs_t), 8, NULL, NULL, NULL, NULL, NULL, 0);
sv->si_cache_request = kmem_cache_create("smb_request_cache",
sizeof (smb_request_t), 8, NULL, NULL, NULL, NULL, NULL, 0);
sv->si_cache_session = kmem_cache_create("smb_session_cache",
@@ -413,14 +396,12 @@ smb_server_create(void)
"smb_timers", smb_server_timers, sv,
NULL, NULL);
- smb_thread_init(&sv->si_thread_unexport, "smb_thread_unexport",
- smb_server_thread_unexport, sv, NULL, NULL);
-
sv->sv_pid = curproc->p_pid;
+ smb_srqueue_init(&sv->sv_srqueue);
smb_kdoor_init();
smb_opipe_door_init();
- (void) smb_server_kstat_init(sv);
+ smb_server_kstat_init(sv);
mutex_init(&sv->sv_mutex, NULL, MUTEX_DEFAULT, NULL);
cv_init(&sv->sv_cv, NULL, CV_DEFAULT, NULL);
@@ -443,7 +424,6 @@ int
smb_server_delete(void)
{
smb_server_t *sv;
- smb_unexport_t *ux;
kt_did_t nbt_tid;
kt_did_t tcp_tid;
int rc;
@@ -501,18 +481,9 @@ smb_server_delete(void)
smb_opipe_door_fini();
smb_kdoor_fini();
smb_server_kstat_fini(sv);
- smb_llist_destructor(&sv->sv_vfs_list);
smb_llist_destructor(&sv->sv_opipe_list);
smb_llist_destructor(&sv->sv_event_list);
- while ((ux = list_head(&sv->sv_unexport_list.sl_list)) != NULL) {
- smb_slist_remove(&sv->sv_unexport_list, ux);
- kmem_cache_free(sv->si_cache_unexport, ux);
- }
- smb_slist_destructor(&sv->sv_unexport_list);
-
- kmem_cache_destroy(sv->si_cache_unexport);
- kmem_cache_destroy(sv->si_cache_vfs);
kmem_cache_destroy(sv->si_cache_request);
kmem_cache_destroy(sv->si_cache_session);
kmem_cache_destroy(sv->si_cache_user);
@@ -522,8 +493,9 @@ smb_server_delete(void)
kmem_cache_destroy(sv->si_cache_opipe);
kmem_cache_destroy(sv->si_cache_event);
+ smb_srqueue_destroy(&sv->sv_srqueue);
+
smb_thread_destroy(&sv->si_thread_timers);
- smb_thread_destroy(&sv->si_thread_unexport);
mutex_destroy(&sv->sv_mutex);
cv_destroy(&sv->sv_cv);
sv->sv_magic = 0;
@@ -608,7 +580,7 @@ smb_server_start(smb_ioc_start_t *ioc)
if (rc = smb_server_fsop_start(sv))
break;
ASSERT(sv->sv_lmshrd == NULL);
- sv->sv_lmshrd = smb_kshare_init(ioc->lmshrd);
+ sv->sv_lmshrd = smb_kshare_door_init(ioc->lmshrd);
if (sv->sv_lmshrd == NULL)
break;
if (rc = smb_kdoor_open(ioc->udoor)) {
@@ -621,11 +593,12 @@ smb_server_start(smb_ioc_start_t *ioc)
}
if (rc = smb_thread_start(&sv->si_thread_timers))
break;
- if (rc = smb_thread_start(&sv->si_thread_unexport))
- break;
sv->sv_state = SMB_SERVER_STATE_RUNNING;
+ sv->sv_start_time = gethrtime();
mutex_exit(&sv->sv_mutex);
smb_server_release(sv);
+
+ smb_export_start();
return (0);
default:
SMB_SERVER_STATE_VALID(sv->sv_state);
@@ -671,7 +644,7 @@ smb_server_stop(void)
boolean_t
smb_server_is_stopping(void)
{
- smb_server_t *sv;
+ smb_server_t *sv;
boolean_t status;
if (smb_server_lookup(&sv) != 0)
@@ -773,7 +746,6 @@ smb_server_nbt_listen(smb_ioc_listen_t *ioc)
mutex_enter(&sv->sv_mutex);
sv->sv_nbt_daemon.ld_kth = NULL;
-
mutex_exit(&sv->sv_mutex);
smb_server_release(sv);
@@ -827,7 +799,6 @@ smb_server_tcp_listen(smb_ioc_listen_t *ioc)
mutex_enter(&sv->sv_mutex);
sv->sv_tcp_daemon.ld_kth = NULL;
-
mutex_exit(&sv->sv_mutex);
smb_server_release(sv);
@@ -889,9 +860,9 @@ smb_server_numopen(smb_ioc_opennum_t *ioc)
int rc;
if ((rc = smb_server_lookup(&sv)) == 0) {
- ioc->open_users = sv->sv_open_users;
- ioc->open_trees = sv->sv_open_trees;
- ioc->open_files = sv->sv_open_files;
+ ioc->open_users = sv->sv_users;
+ ioc->open_trees = sv->sv_trees;
+ ioc->open_files = sv->sv_files + sv->sv_pipes;
smb_server_release(sv);
}
return (rc);
@@ -1015,156 +986,107 @@ smb_server_get_session_count(void)
}
/*
- * Disconnect the specified share.
- * Typically called when a share has been removed.
- */
-static void
-smb_server_disconnect_share(smb_session_list_t *slist, const char *sharename)
-{
- smb_session_t *session;
-
- rw_enter(&slist->se_lock, RW_READER);
-
- session = list_head(&slist->se_act.lst);
- while (session) {
- ASSERT(session->s_magic == SMB_SESSION_MAGIC);
- smb_rwx_rwenter(&session->s_lock, RW_READER);
- switch (session->s_state) {
- case SMB_SESSION_STATE_NEGOTIATED:
- case SMB_SESSION_STATE_OPLOCK_BREAKING:
- case SMB_SESSION_STATE_WRITE_RAW_ACTIVE:
- smb_session_disconnect_share(session, sharename);
- break;
- default:
- break;
- }
- smb_rwx_rwexit(&session->s_lock);
- session = list_next(&slist->se_act.lst, session);
- }
-
- rw_exit(&slist->se_lock);
-}
-
-/*
- * smb_server_share_export()
- *
- * This function handles kernel processing at share enable time.
+ * Gets the vnode of the specified share path.
*
- * At share-enable time (LMSHRD_ADD), the file system corresponding to
- * the share is checked for characteristics that are required for SMB
- * sharing. If this check passes, then a hold is taken on the root vnode
- * of the file system (or a reference count on the corresponding smb_vfs_t
- * is bumped), preventing an unmount. (See smb_vfs_hold()).
+ * A hold on the returned vnode pointer is taken so the caller
+ * must call VN_RELE.
*/
-
int
-smb_server_share_export(smb_ioc_share_t *ioc)
+smb_server_sharevp(const char *shr_path, vnode_t **vp)
{
smb_server_t *sv;
- int error = 0;
+ smb_request_t *sr;
smb_node_t *fnode = NULL;
smb_node_t *dnode;
char last_comp[MAXNAMELEN];
- smb_request_t *sr;
+ int rc = 0;
- if (smb_server_lookup(&sv))
- return (EINVAL);
+ ASSERT(shr_path);
+
+ if ((rc = smb_server_lookup(&sv)))
+ return (rc);
mutex_enter(&sv->sv_mutex);
switch (sv->sv_state) {
case SMB_SERVER_STATE_RUNNING:
- case SMB_SERVER_STATE_STOPPING:
break;
default:
mutex_exit(&sv->sv_mutex);
+ smb_server_release(sv);
return (ENOTACTIVE);
}
mutex_exit(&sv->sv_mutex);
- sr = smb_request_alloc(sv->sv_session, 0);
- if (sr == NULL) {
+ if ((sr = smb_request_alloc(sv->sv_session, 0)) == NULL) {
smb_server_release(sv);
return (ENOMEM);
}
-
sr->user_cr = kcred;
- error = smb_pathname_reduce(sr, kcred, ioc->path,
+ rc = smb_pathname_reduce(sr, sr->user_cr, shr_path,
NULL, NULL, &dnode, last_comp);
- if (error) {
- smb_request_free(sr);
- smb_server_release(sv);
- return (error);
+ if (rc == 0) {
+ rc = smb_fsop_lookup(sr, sr->user_cr, SMB_FOLLOW_LINKS,
+ sv->si_root_smb_node, dnode, last_comp, &fnode);
+ smb_node_release(dnode);
}
- error = smb_fsop_lookup(sr, sr->user_cr, SMB_FOLLOW_LINKS,
- sv->si_root_smb_node, dnode, last_comp, &fnode);
-
- smb_node_release(dnode);
+ smb_request_free(sr);
+ smb_server_release(sv);
- if (error) {
- smb_request_free(sr);
- smb_server_release(sv);
- return (error);
- }
+ if (rc != 0)
+ return (rc);
ASSERT(fnode->vp && fnode->vp->v_vfsp);
-#ifdef SMB_ENFORCE_NODEV
- if (vfs_optionisset(fnode->vp->v_vfsp, MNTOPT_NODEVICES, NULL) == 0) {
- smb_node_release(fnode);
- smb_request_free(sr);
- smb_server_release(sv);
- return (EINVAL);
- }
-#endif /* SMB_ENFORCE_NODEV */
-
- if (!smb_vfs_hold(sv, fnode->vp->v_vfsp))
- error = ENOMEM;
-
- /*
- * The refcount on the smb_vfs has been incremented.
- * If it wasn't already, a hold has also been taken
- * on the root vnode of the file system.
- */
+ VN_HOLD(fnode->vp);
+ *vp = fnode->vp;
smb_node_release(fnode);
- smb_request_free(sr);
- smb_server_release(sv);
- return (error);
+
+ return (0);
}
+
/*
- * smb_server_share_unexport()
- *
- * This function is invoked when a share is disabled to disconnect trees
- * and close files. Cleaning up may involve VOP and/or VFS calls, which
- * may conflict/deadlock with stuck threads if something is amiss with the
- * file system. Queueing the request for asynchronous processing allows the
- * call to return immediately so that, if the unshare is being done in the
- * context of a forced unmount, the forced unmount will always be able to
- * proceed (unblocking stuck I/O and eventually allowing all blocked unshare
- * processes to complete).
+ * This is a special interface that will be utilized by ZFS to cause a share to
+ * be added/removed.
*
- * The path lookup to find the root vnode of the VFS in question and the
- * release of this vnode are done synchronously prior to any associated
- * unmount. Doing these asynchronous to an associated unmount could run
- * the risk of a spurious EBUSY for a standard unmount or an EIO during
- * the path lookup due to a forced unmount finishing first.
+ * arg is either a lmshare_info_t or share_name from userspace.
+ * It will need to be copied into the kernel. It is lmshare_info_t
+ * for add operations and share_name for delete operations.
*/
-
int
-smb_server_share_unexport(smb_ioc_share_t *ioc)
+smb_server_share(void *arg, boolean_t add_share)
{
smb_server_t *sv;
- smb_request_t *sr;
- smb_unexport_t *ux;
- smb_node_t *fnode = NULL;
- smb_node_t *dnode;
- char last_comp[MAXNAMELEN];
int rc;
+ if ((rc = smb_server_lookup(&sv)) == 0) {
+ mutex_enter(&sv->sv_mutex);
+ switch (sv->sv_state) {
+ case SMB_SERVER_STATE_RUNNING:
+ mutex_exit(&sv->sv_mutex);
+ (void) smb_kshare_upcall(sv->sv_lmshrd, arg, add_share);
+ break;
+ default:
+ mutex_exit(&sv->sv_mutex);
+ break;
+ }
+ smb_server_release(sv);
+ }
+
+ return (rc);
+}
+
+int
+smb_server_unshare(const char *sharename)
+{
+ smb_server_t *sv;
+ smb_session_list_t *slist;
+ int rc;
+
if ((rc = smb_server_lookup(&sv)))
return (rc);
@@ -1175,119 +1097,50 @@ smb_server_share_unexport(smb_ioc_share_t *ioc)
break;
default:
mutex_exit(&sv->sv_mutex);
+ smb_server_release(sv);
return (ENOTACTIVE);
}
mutex_exit(&sv->sv_mutex);
- sr = smb_request_alloc(sv->sv_session, 0);
-
- if (sr == NULL) {
- smb_server_release(sv);
- return (ENOMEM);
- }
-
- sr->user_cr = kcred;
-
- rc = smb_pathname_reduce(sr, kcred, ioc->path, NULL, NULL,
- &dnode, last_comp);
-
- if (rc) {
- smb_request_free(sr);
- smb_server_release(sv);
- return (rc);
- }
-
- rc = smb_fsop_lookup(sr, kcred, SMB_FOLLOW_LINKS, sv->si_root_smb_node,
- dnode, last_comp, &fnode);
-
- smb_node_release(dnode);
- smb_request_free(sr);
-
- if (rc) {
- smb_server_release(sv);
- return (rc);
- }
-
- ASSERT(fnode->vp && fnode->vp->v_vfsp);
-
- smb_vfs_rele(sv, fnode->vp->v_vfsp);
-
- smb_node_release(fnode);
-
- ux = kmem_cache_alloc(sv->si_cache_unexport, KM_SLEEP);
+ slist = &sv->sv_nbt_daemon.ld_session_list;
+ smb_server_disconnect_share(slist, sharename);
- (void) strlcpy(ux->ux_sharename, ioc->name, MAXNAMELEN);
-
- smb_slist_insert_tail(&sv->sv_unexport_list, ux);
- smb_thread_signal(&sv->si_thread_unexport);
+ slist = &sv->sv_tcp_daemon.ld_session_list;
+ smb_server_disconnect_share(slist, sharename);
smb_server_release(sv);
return (0);
}
/*
- * smb_server_thread_unexport
- *
- * This function processes the unexport event list and disconnects shares
- * asynchronously. The function executes as a zone-specific thread.
- *
- * The server arg passed in is safe to use without a reference count, because
- * the server cannot be deleted until smb_thread_stop()/destroy() return,
- * which is also when the thread exits.
+ * Disconnect the specified share.
+ * Typically called when a share has been removed.
*/
-
static void
-smb_server_thread_unexport(smb_thread_t *thread, void *arg)
+smb_server_disconnect_share(smb_session_list_t *slist, const char *sharename)
{
- smb_server_t *sv = (smb_server_t *)arg;
- smb_unexport_t *ux;
- smb_session_list_t *slist;
-
- while (smb_thread_continue(thread)) {
- while ((ux = list_head(&sv->sv_unexport_list.sl_list))
- != NULL) {
- smb_slist_remove(&sv->sv_unexport_list, ux);
-
- slist = &sv->sv_nbt_daemon.ld_session_list;
- smb_server_disconnect_share(slist, ux->ux_sharename);
-
- slist = &sv->sv_tcp_daemon.ld_session_list;
- smb_server_disconnect_share(slist, ux->ux_sharename);
-
- kmem_cache_free(sv->si_cache_unexport, ux);
- }
- }
-}
+ smb_session_t *session;
-/*
- * This is a special interface that will be utilized by ZFS to cause a share to
- * be added/removed.
- *
- * arg is either a lmshare_info_t or share_name from userspace.
- * It will need to be copied into the kernel. It is lmshare_info_t
- * for add operations and share_name for delete operations.
- */
-int
-smb_server_share(void *arg, boolean_t add_share)
-{
- smb_server_t *sv;
- int rc;
+ rw_enter(&slist->se_lock, RW_READER);
- rc = smb_server_lookup(&sv);
- if (rc == 0) {
- mutex_enter(&sv->sv_mutex);
- switch (sv->sv_state) {
- case SMB_SERVER_STATE_RUNNING:
- mutex_exit(&sv->sv_mutex);
- (void) smb_kshare_upcall(sv->sv_lmshrd, arg, add_share);
+ session = list_head(&slist->se_act.lst);
+ while (session) {
+ ASSERT(session->s_magic == SMB_SESSION_MAGIC);
+ smb_rwx_rwenter(&session->s_lock, RW_READER);
+ switch (session->s_state) {
+ case SMB_SESSION_STATE_NEGOTIATED:
+ case SMB_SESSION_STATE_OPLOCK_BREAKING:
+ case SMB_SESSION_STATE_WRITE_RAW_ACTIVE:
+ smb_session_disconnect_share(session, sharename);
break;
default:
- mutex_exit(&sv->sv_mutex);
break;
}
- smb_server_release(sv);
+ smb_rwx_rwexit(&session->s_lock);
+ session = list_next(&slist->se_act.lst, session);
}
- return (0);
+
+ rw_exit(&slist->se_lock);
}
/*
@@ -1318,6 +1171,114 @@ smb_server_get_cfg(smb_server_t *sv, smb_kmod_cfg_t *cfg)
}
/*
+ *
+ */
+void
+smb_server_inc_nbt_sess(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_inc_32(&sv->sv_nbt_sess);
+}
+
+void
+smb_server_dec_nbt_sess(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_dec_32(&sv->sv_nbt_sess);
+}
+
+void
+smb_server_inc_tcp_sess(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_inc_32(&sv->sv_tcp_sess);
+}
+
+void
+smb_server_dec_tcp_sess(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_dec_32(&sv->sv_tcp_sess);
+}
+
+void
+smb_server_inc_users(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_inc_32(&sv->sv_users);
+}
+
+void
+smb_server_dec_users(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_dec_32(&sv->sv_users);
+}
+
+void
+smb_server_inc_trees(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_inc_32(&sv->sv_trees);
+}
+
+void
+smb_server_dec_trees(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_dec_32(&sv->sv_trees);
+}
+
+void
+smb_server_inc_files(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_inc_32(&sv->sv_files);
+}
+
+void
+smb_server_dec_files(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_dec_32(&sv->sv_files);
+}
+
+void
+smb_server_inc_pipes(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_inc_32(&sv->sv_pipes);
+}
+
+void
+smb_server_dec_pipes(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_dec_32(&sv->sv_pipes);
+}
+
+void
+smb_server_add_rxb(smb_server_t *sv, int64_t value)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_add_64(&sv->sv_rxb, value);
+}
+
+void
+smb_server_add_txb(smb_server_t *sv, int64_t value)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_add_64(&sv->sv_txb, value);
+}
+
+void
+smb_server_inc_req(smb_server_t *sv)
+{
+ SMB_SERVER_VALID(sv);
+ atomic_inc_64(&sv->sv_nreq);
+}
+
+/*
* *****************************************************************************
* *************************** Static Functions ********************************
* *****************************************************************************
@@ -1339,39 +1300,24 @@ smb_server_timers(smb_thread_t *thread, void *arg)
/*
* smb_server_kstat_init
*/
-static int
+static void
smb_server_kstat_init(smb_server_t *sv)
{
- (void) snprintf(sv->sv_ksp_name, sizeof (sv->sv_ksp_name), "%s%d",
- SMBSRV_KSTAT_NAME, sv->sv_zid);
-
- sv->sv_ksp = kstat_create(SMBSRV_KSTAT_MODULE, 0, sv->sv_ksp_name,
- SMBSRV_KSTAT_CLASS, KSTAT_TYPE_NAMED,
- sizeof (sv->sv_ks_data) / sizeof (kstat_named_t),
- KSTAT_FLAG_VIRTUAL);
-
- if (sv->sv_ksp) {
- (void) strlcpy(sv->sv_ks_data.open_files.name, "open_files",
- sizeof (sv->sv_ks_data.open_files.name));
- sv->sv_ks_data.open_files.data_type = KSTAT_DATA_UINT32;
- (void) strlcpy(sv->sv_ks_data.open_trees.name, "connections",
- sizeof (sv->sv_ks_data.open_trees.name));
- sv->sv_ks_data.open_trees.data_type = KSTAT_DATA_UINT32;
- (void) strlcpy(sv->sv_ks_data.open_users.name, "sessions",
- sizeof (sv->sv_ks_data.open_users.name));
- sv->sv_ks_data.open_users.data_type = KSTAT_DATA_UINT32;
-
- mutex_init(&sv->sv_ksp_mutex, NULL, MUTEX_DEFAULT, NULL);
- sv->sv_ksp->ks_lock = &sv->sv_ksp_mutex;
- sv->sv_ksp->ks_data = (void *)&sv->sv_ks_data;
- sv->sv_ksp->ks_update = smb_server_kstat_update_info;
+ sv->sv_ksp = kstat_create_zone(SMBSRV_KSTAT_MODULE, sv->sv_zid,
+ SMBSRV_KSTAT_STATISTICS, SMBSRV_KSTAT_CLASS, KSTAT_TYPE_RAW,
+ sizeof (smbsrv_kstats_t), 0, sv->sv_zid);
+
+ if (sv->sv_ksp != NULL) {
+ sv->sv_ksp->ks_update = smb_server_kstat_update;
+ sv->sv_ksp->ks_private = sv;
+ ((smbsrv_kstats_t *)sv->sv_ksp->ks_data)->ks_start_time =
+ sv->sv_start_time;
+ smb_dispatch_stats_init(
+ ((smbsrv_kstats_t *)sv->sv_ksp->ks_data)->ks_reqs);
kstat_install(sv->sv_ksp);
+ } else {
+ cmn_err(CE_WARN, "SMB Server: Statistics unavailable");
}
-
- /* create and initialize smb kstats - smb_dispatch stats */
- smb_dispatch_kstat_init();
-
- return (0);
}
/*
@@ -1380,36 +1326,57 @@ smb_server_kstat_init(smb_server_t *sv)
static void
smb_server_kstat_fini(smb_server_t *sv)
{
- if (sv->sv_ksp) {
+ if (sv->sv_ksp != NULL) {
kstat_delete(sv->sv_ksp);
- mutex_destroy(&sv->sv_ksp_mutex);
sv->sv_ksp = NULL;
+ smb_dispatch_stats_fini();
}
- smb_dispatch_kstat_fini();
}
-/* ARGSUSED */
+/*
+ * smb_server_kstat_update
+ */
static int
-smb_server_kstat_update_info(kstat_t *ksp, int rw)
+smb_server_kstat_update(kstat_t *ksp, int rw)
{
smb_server_t *sv;
+ smbsrv_kstats_t *ksd;
- if (rw == KSTAT_WRITE) {
- return (EACCES);
- } else {
- ASSERT(MUTEX_HELD(ksp->ks_lock));
-
- _NOTE(LINTED("pointer cast may result in improper alignment"))
- sv = (smb_server_t *)((uint8_t *)(ksp->ks_data) -
- offsetof(smb_server_t, sv_ks_data));
-
+ if (rw == KSTAT_READ) {
+ sv = ksp->ks_private;
SMB_SERVER_VALID(sv);
-
- sv->sv_ks_data.open_files.value.ui32 = sv->sv_open_files;
- sv->sv_ks_data.open_trees.value.ui32 = sv->sv_open_trees;
- sv->sv_ks_data.open_users.value.ui32 = sv->sv_open_users;
+ ksd = (smbsrv_kstats_t *)ksp->ks_data;
+ /*
+ * Counters
+ */
+ ksd->ks_nbt_sess = sv->sv_nbt_sess;
+ ksd->ks_tcp_sess = sv->sv_tcp_sess;
+ ksd->ks_users = sv->sv_users;
+ ksd->ks_trees = sv->sv_trees;
+ ksd->ks_files = sv->sv_files;
+ ksd->ks_pipes = sv->sv_pipes;
+ /*
+ * Throughput
+ */
+ ksd->ks_txb = sv->sv_txb;
+ ksd->ks_rxb = sv->sv_rxb;
+ ksd->ks_nreq = sv->sv_nreq;
+ /*
+ * Busyness
+ */
+ ksd->ks_maxreqs = sv->sv_cfg.skc_maxworkers;
+ smb_srqueue_update(&sv->sv_srqueue,
+ &ksd->ks_utilization);
+ /*
+ * Latency & Throughput of the requests
+ */
+ smb_dispatch_stats_update(ksd->ks_reqs, 0, SMB_COM_NUM);
+ return (0);
}
- return (0);
+ if (rw == KSTAT_WRITE)
+ return (EACCES);
+
+ return (EIO);
}
/*
@@ -1422,10 +1389,10 @@ smb_server_shutdown(smb_server_t *sv)
smb_opipe_door_close();
smb_thread_stop(&sv->si_thread_timers);
- smb_thread_stop(&sv->si_thread_unexport);
smb_kdoor_close();
- smb_kshare_fini(sv->sv_lmshrd);
+ smb_kshare_door_fini(sv->sv_lmshrd);
sv->sv_lmshrd = NULL;
+ smb_export_stop();
smb_server_fsop_stop(sv);
if (sv->sv_session) {
@@ -1802,6 +1769,8 @@ smb_server_store_cfg(smb_server_t *sv, smb_ioc_cfg_t *ioc)
sv->sv_cfg.skc_sync_enable = ioc->sync_enable;
sv->sv_cfg.skc_secmode = ioc->secmode;
sv->sv_cfg.skc_ipv6_enable = ioc->ipv6_enable;
+ sv->sv_cfg.skc_execflags = ioc->exec_flags;
+ sv->sv_cfg.skc_version = ioc->version;
(void) strlcpy(sv->sv_cfg.skc_nbdomain, ioc->nbdomain,
sizeof (sv->sv_cfg.skc_nbdomain));
(void) strlcpy(sv->sv_cfg.skc_fqdn, ioc->fqdn,
@@ -1828,7 +1797,6 @@ static void
smb_server_fsop_stop(smb_server_t *sv)
{
if (sv->si_root_smb_node != NULL) {
- smb_vfs_rele_all(sv);
smb_node_release(sv->si_root_smb_node);
sv->si_root_smb_node = NULL;
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_session.c b/usr/src/uts/common/fs/smbsrv/smb_session.c
index 003321a126..b17ca1cfff 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_session.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_session.c
@@ -19,10 +19,8 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-
#include <sys/atomic.h>
#include <sys/strsubr.h>
#include <sys/synch.h>
@@ -196,6 +194,7 @@ smb_session_send(smb_session_t *session, uint8_t type, mbuf_chain_t *mbc)
return (rc);
}
txr->tr_len += NETBIOS_HDR_SZ;
+ smb_server_add_txb(session->s_server, (int64_t)txr->tr_len);
return (smb_net_txr_send(session->sock, &session->s_txlst, txr));
}
@@ -539,12 +538,15 @@ smb_session_daemon(smb_session_list_t *se)
static int
smb_session_message(smb_session_t *session)
{
+ smb_server_t *sv;
smb_request_t *sr = NULL;
smb_xprt_t hdr;
uint8_t *req_buf;
uint32_t resid;
int rc;
+ sv = session->s_server;
+
for (;;) {
rc = smb_session_xprt_gethdr(session, &hdr);
@@ -573,7 +575,6 @@ smb_session_message(smb_session_t *session)
return (EPROTO);
session->keep_alive = smb_keep_alive;
-
/*
* Allocate a request context, read the SMB header and validate
* it. The sr includes a buffer large enough to hold the SMB
@@ -606,7 +607,8 @@ smb_session_message(smb_session_t *session)
return (rc);
}
}
-
+ smb_server_add_rxb(sv,
+ (int64_t)(hdr.xh_length + NETBIOS_HDR_SZ));
/*
* Initialize command MBC to represent the received data.
*/
@@ -624,8 +626,20 @@ smb_session_message(smb_session_t *session)
continue;
return (rc);
}
-
+ if (sr->session->signing.flags & SMB_SIGNING_ENABLED) {
+ if (SMB_IS_NT_CANCEL(sr)) {
+ sr->session->signing.seqnum++;
+ sr->sr_seqnum = sr->session->signing.seqnum + 1;
+ sr->reply_seqnum = 0;
+ } else {
+ sr->session->signing.seqnum += 2;
+ sr->sr_seqnum = sr->session->signing.seqnum;
+ sr->reply_seqnum = sr->sr_seqnum + 1;
+ }
+ }
+ sr->sr_time_submitted = gethrtime();
sr->sr_state = SMB_REQ_STATE_SUBMITTED;
+ smb_srqueue_waitq_enter(session->s_srqueue);
(void) taskq_dispatch(session->s_server->sv_thread_pool,
smb_session_worker, sr, TQ_SLEEP);
}
@@ -677,7 +691,7 @@ smb_session_create(ksocket_t new_so, uint16_t port, smb_server_t *sv,
smb_rwx_init(&session->s_lock);
- if (new_so) {
+ if (new_so != NULL) {
if (family == AF_INET) {
slen = sizeof (sin);
(void) ksocket_getsockname(new_so,
@@ -709,10 +723,15 @@ smb_session_create(ksocket_t new_so, uint16_t port, smb_server_t *sv,
session->local_ipaddr.a_family = family;
session->s_local_port = port;
session->sock = new_so;
+ if (port == IPPORT_NETBIOS_SSN)
+ smb_server_inc_nbt_sess(sv);
+ else
+ smb_server_inc_tcp_sess(sv);
}
-
session->s_server = sv;
smb_server_get_cfg(sv, &session->s_cfg);
+ session->s_srqueue = &sv->sv_srqueue;
+
session->s_cache_request = sv->si_cache_request;
session->s_cache = sv->si_cache_session;
session->s_magic = SMB_SESSION_MAGIC;
@@ -728,6 +747,11 @@ smb_session_delete(smb_session_t *session)
session->s_magic = 0;
+ if (session->s_local_port == IPPORT_NETBIOS_SSN)
+ smb_server_dec_nbt_sess(session->s_server);
+ else
+ smb_server_dec_tcp_sess(session->s_server);
+
smb_rwx_destroy(&session->s_lock);
smb_net_txl_destructor(&session->s_txlst);
@@ -813,13 +837,16 @@ void
smb_session_worker(void *arg)
{
smb_request_t *sr;
+ smb_srqueue_t *srq;
sr = (smb_request_t *)arg;
+ SMB_REQ_VALID(sr);
- ASSERT(sr->sr_magic == SMB_REQ_MAGIC);
-
+ srq = sr->session->s_srqueue;
+ smb_srqueue_waitq_to_runq(srq);
sr->sr_worker = curthread;
mutex_enter(&sr->sr_mutex);
+ sr->sr_time_active = gethrtime();
switch (sr->sr_state) {
case SMB_REQ_STATE_SUBMITTED:
mutex_exit(&sr->sr_mutex);
@@ -838,6 +865,7 @@ smb_session_worker(void *arg)
smb_request_free(sr);
break;
}
+ smb_srqueue_runq_exit(srq);
}
void
diff --git a/usr/src/uts/common/fs/smbsrv/smb_session_setup_andx.c b/usr/src/uts/common/fs/smbsrv/smb_session_setup_andx.c
index a7411eede2..2f100da845 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_session_setup_andx.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_session_setup_andx.c
@@ -19,194 +19,190 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
+#include <sys/sid.h>
+#include <sys/priv_names.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <smbsrv/smb_idmap.h>
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_token.h>
-typedef struct smb_sessionsetup_info {
- char *ssi_user;
- char *ssi_domain;
- char *ssi_native_os;
- char *ssi_native_lm;
- uint16_t ssi_cipwlen;
- uint8_t *ssi_cipwd;
- uint16_t ssi_cspwlen;
- uint8_t *ssi_cspwd;
- uint16_t ssi_maxbufsize;
- uint16_t ssi_maxmpxcount;
- uint16_t ssi_vcnumber;
- uint32_t ssi_capabilities;
- uint32_t ssi_sesskey;
-} smb_sessionsetup_info_t;
-
-#define SMB_AUTH_FAILED -1
-#define SMB_AUTH_USER 0
-#define SMB_AUTH_GUEST 1
-
-static int smb_authenticate(smb_request_t *, smb_sessionsetup_info_t *,
+static int smb_authenticate(smb_request_t *, smb_arg_sessionsetup_t *,
smb_session_key_t **);
+static cred_t *smb_cred_create(smb_token_t *);
+static void smb_cred_set_sid(smb_id_t *id, ksid_t *ksid);
+static ksidlist_t *smb_cred_set_sidlist(smb_ids_t *token_grps);
+static uint32_t smb_priv_xlate(smb_token_t *);
+/*
+ * In NTLM 0.12, the padding between the Native OS and Native LM is a bit
+ * strange. On NT4.0, there is a 2 byte pad between the OS (Windows NT 1381)
+ * and LM (Windows NT 4.0). On Windows 2000, there is no padding between
+ * the OS (Windows 2000 2195) and LM (Windows 2000 5.0).
+ * If the padding is removed from the decode string the NT4.0 LM comes out
+ * as an empty string. So if the client's native OS is Win NT we consider
+ * the padding otherwise we don't.
+ *
+ * For Pre-NTLM 0.12, despite the CIFS/1.0 spec, the user and domain are
+ * not always present in the message. We try to get the account name and
+ * the primary domain but we don't care about the the native OS or native
+ * LM fields.
+ *
+ * If the Native LM cannot be determined, default to Windows NT.
+ */
smb_sdrc_t
smb_pre_session_setup_andx(smb_request_t *sr)
{
- DTRACE_SMB_1(op__SessionSetupX__start, smb_request_t *, sr);
- return (SDRC_SUCCESS);
-}
-
-void
-smb_post_session_setup_andx(smb_request_t *sr)
-{
- DTRACE_SMB_1(op__SessionSetupX__done, smb_request_t *, sr);
-}
-
-smb_sdrc_t
-smb_com_session_setup_andx(smb_request_t *sr)
-{
- smb_sessionsetup_info_t sinfo;
- smb_session_key_t *session_key = NULL;
- char ipaddr_buf[INET6_ADDRSTRLEN];
- int native_lm;
- int auth_res;
- int rc;
+ smb_arg_sessionsetup_t *sinfo;
+ char *native_os;
+ char *native_lm;
+ uint16_t maxbufsize;
+ uint16_t vcnumber;
+ int rc = 0;
- bzero(&sinfo, sizeof (smb_sessionsetup_info_t));
+ sinfo = smb_srm_zalloc(sr, sizeof (smb_arg_sessionsetup_t));
+ sr->sr_ssetup = sinfo;
if (sr->session->dialect >= NT_LM_0_12) {
rc = smbsr_decode_vwv(sr, "b.wwwwlww4.l", &sr->andx_com,
- &sr->andx_off, &sinfo.ssi_maxbufsize,
- &sinfo.ssi_maxmpxcount, &sinfo.ssi_vcnumber,
- &sinfo.ssi_sesskey, &sinfo.ssi_cipwlen,
- &sinfo.ssi_cspwlen, &sinfo.ssi_capabilities);
-
+ &sr->andx_off, &maxbufsize,
+ &sinfo->ssi_maxmpxcount, &vcnumber,
+ &sinfo->ssi_sesskey, &sinfo->ssi_cipwlen,
+ &sinfo->ssi_cspwlen, &sinfo->ssi_capabilities);
if (rc != 0)
- return (SDRC_ERROR);
-
- sinfo.ssi_cipwd = smb_srm_zalloc(sr, sinfo.ssi_cipwlen + 1);
- sinfo.ssi_cspwd = smb_srm_zalloc(sr, sinfo.ssi_cspwlen + 1);
-
- /*
- * The padding between the Native OS and Native LM is a
- * bit strange. On NT4.0, there is a 2 byte pad between
- * the OS (Windows NT 1381) and LM (Windows NT 4.0).
- * On Windows 2000, there is no padding between the OS
- * (Windows 2000 2195) and LM (Windows 2000 5.0).
- *
- * If the padding is removed from this decode string
- * the NT4.0 LM comes out as an empty string.
- *
- * So if the client's native OS is Win NT we consider
- * the padding otherwise we don't.
- */
+ goto pre_session_setup_andx_done;
+
+ sinfo->ssi_cipwd = smb_srm_zalloc(sr, sinfo->ssi_cipwlen + 1);
+ sinfo->ssi_cspwd = smb_srm_zalloc(sr, sinfo->ssi_cspwlen + 1);
+
rc = smbsr_decode_data(sr, "%#c#cuuu",
sr,
- sinfo.ssi_cipwlen, sinfo.ssi_cipwd,
- sinfo.ssi_cspwlen, sinfo.ssi_cspwd,
- &sinfo.ssi_user,
- &sinfo.ssi_domain,
- &sinfo.ssi_native_os);
-
+ sinfo->ssi_cipwlen, sinfo->ssi_cipwd,
+ sinfo->ssi_cspwlen, sinfo->ssi_cspwd,
+ &sinfo->ssi_user,
+ &sinfo->ssi_domain,
+ &native_os);
if (rc != 0)
- return (SDRC_ERROR);
+ goto pre_session_setup_andx_done;
- sinfo.ssi_cipwd[sinfo.ssi_cipwlen] = 0;
- sinfo.ssi_cspwd[sinfo.ssi_cspwlen] = 0;
+ sinfo->ssi_cipwd[sinfo->ssi_cipwlen] = 0;
+ sinfo->ssi_cspwd[sinfo->ssi_cspwlen] = 0;
- sr->session->native_os =
- smbnative_os_value(sinfo.ssi_native_os);
+ sr->session->native_os = smbnative_os_value(native_os);
if (sr->session->native_os == NATIVE_OS_WINNT)
- rc = smbsr_decode_data(sr, "%,u", sr,
- &sinfo.ssi_native_lm);
+ rc = smbsr_decode_data(sr, "%,u", sr, &native_lm);
else
- rc = smbsr_decode_data(sr, "%u", sr,
- &sinfo.ssi_native_lm);
-
- /*
- * If the Native Lanman cannot be determined,
- * default to Windows NT.
- */
- if (rc != 0 || sinfo.ssi_native_lm == NULL)
- sinfo.ssi_native_lm = "NT LAN Manager 4.0";
+ rc = smbsr_decode_data(sr, "%u", sr, &native_lm);
+
+ if (rc != 0 || native_lm == NULL)
+ native_lm = "NT LAN Manager 4.0";
+
+ sr->session->native_lm = smbnative_lm_value(native_lm);
} else {
rc = smbsr_decode_vwv(sr, "b.wwwwlw4.", &sr->andx_com,
- &sr->andx_off, &sinfo.ssi_maxbufsize,
- &sinfo.ssi_maxmpxcount,
- &sinfo.ssi_vcnumber, &sinfo.ssi_sesskey,
- &sinfo.ssi_cipwlen);
-
+ &sr->andx_off, &maxbufsize,
+ &sinfo->ssi_maxmpxcount, &vcnumber,
+ &sinfo->ssi_sesskey, &sinfo->ssi_cipwlen);
if (rc != 0)
- return (SDRC_ERROR);
+ goto pre_session_setup_andx_done;
- sinfo.ssi_cipwd = smb_srm_zalloc(sr, sinfo.ssi_cipwlen + 1);
- rc = smbsr_decode_data(sr, "%#c", sr, sinfo.ssi_cipwlen,
- sinfo.ssi_cipwd);
+ sinfo->ssi_cipwd = smb_srm_zalloc(sr, sinfo->ssi_cipwlen + 1);
+ rc = smbsr_decode_data(sr, "%#c", sr, sinfo->ssi_cipwlen,
+ sinfo->ssi_cipwd);
if (rc != 0)
- return (SDRC_ERROR);
+ goto pre_session_setup_andx_done;
- sinfo.ssi_cipwd[sinfo.ssi_cipwlen] = 0;
+ sinfo->ssi_cipwd[sinfo->ssi_cipwlen] = 0;
- /*
- * Despite the CIFS/1.0 spec, the rest of this message is
- * not always present. We need to try to get the account
- * name and the primary domain but we don't care about the
- * the native OS or native LanMan fields.
- */
- if (smbsr_decode_data(sr, "%u", sr, &sinfo.ssi_user) != 0)
- sinfo.ssi_user = "";
+ if (smbsr_decode_data(sr, "%u", sr, &sinfo->ssi_user) != 0)
+ sinfo->ssi_user = "";
- if (smbsr_decode_data(sr, "%u", sr, &sinfo.ssi_domain) != 0)
- sinfo.ssi_domain = "";
+ if (smbsr_decode_data(sr, "%u", sr, &sinfo->ssi_domain) != 0)
+ sinfo->ssi_domain = "";
+ native_lm = "NT LAN Manager 4.0";
sr->session->native_os = NATIVE_OS_WINNT;
- sinfo.ssi_native_lm = "NT LAN Manager 4.0";
+ sr->session->native_lm = smbnative_lm_value(native_lm);
}
- /*
- * If the sinfo.ssi_vcnumber is zero, we can discard any
- * other connections associated with this client.
- */
- sr->session->vcnumber = sinfo.ssi_vcnumber;
- if (sinfo.ssi_vcnumber == 0)
+ sr->session->vcnumber = vcnumber;
+ sr->session->smb_msg_size = maxbufsize;
+
+pre_session_setup_andx_done:
+ DTRACE_SMB_2(op__SessionSetupX__start, smb_request_t *, sr,
+ smb_arg_sessionsetup_t, sinfo);
+ return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
+}
+
+void
+smb_post_session_setup_andx(smb_request_t *sr)
+{
+ smb_arg_sessionsetup_t *sinfo = sr->sr_ssetup;
+
+ DTRACE_SMB_2(op__SessionSetupX__done, smb_request_t *, sr,
+ smb_arg_sessionsetup_t, sinfo);
+
+ if (sinfo->ssi_cipwd != NULL)
+ bzero(sinfo->ssi_cipwd, sinfo->ssi_cipwlen + 1);
+
+ if (sinfo->ssi_cspwd != NULL)
+ bzero(sinfo->ssi_cspwd, sinfo->ssi_cspwlen + 1);
+}
+
+/*
+ * If the vcnumber is zero, discard any other connections associated with
+ * this client.
+ *
+ * If signing has not already been enabled on this session check to see if
+ * it should be enabled. The first authenticated logon provides the MAC
+ * key and sequence numbers for signing all subsequent sessions on the same
+ * connection.
+ *
+ * NT systems use different native OS and native LanMan values dependent on
+ * whether they are acting as a client or a server. NT 4.0 server responds
+ * with the following values:
+ *
+ * NativeOS: Windows NT 4.0
+ * NativeLM: NT LAN Manager 4.0
+ */
+smb_sdrc_t
+smb_com_session_setup_andx(smb_request_t *sr)
+{
+ smb_arg_sessionsetup_t *sinfo = sr->sr_ssetup;
+ smb_session_key_t *session_key = NULL;
+ char ipaddr_buf[INET6_ADDRSTRLEN];
+ int rc;
+
+ if (sr->session->vcnumber == 0)
smb_server_reconnection_check(sr->sr_server, sr->session);
- auth_res = smb_authenticate(sr, &sinfo, &session_key);
- if (auth_res == SMB_AUTH_FAILED)
+ if (smb_authenticate(sr, sinfo, &session_key) != 0)
return (SDRC_ERROR);
- native_lm = smbnative_lm_value(sinfo.ssi_native_lm);
- if (native_lm == NATIVE_LM_WIN2000)
- sinfo.ssi_capabilities |= CAP_LARGE_FILES |
+ if (sr->session->native_lm == NATIVE_LM_WIN2000)
+ sinfo->ssi_capabilities |= CAP_LARGE_FILES |
CAP_LARGE_READX | CAP_LARGE_WRITEX;
- sr->session->smb_msg_size = sinfo.ssi_maxbufsize;
- sr->session->capabilities = sinfo.ssi_capabilities;
+ sr->session->capabilities = sinfo->ssi_capabilities;
- /*
- * Check to see if SMB signing is enable, but if it is already turned
- * on leave it.
- * The first authenticated logon provides the MAC key and sequence
- * numbers for signing all further session on the
- * same network connection.
- */
if (!(sr->session->signing.flags & SMB_SIGNING_ENABLED) &&
(sr->session->secmode & NEGOTIATE_SECURITY_SIGNATURES_ENABLED) &&
(sr->smb_flg2 & SMB_FLAGS2_SMB_SECURITY_SIGNATURE) &&
session_key)
- smb_sign_init(sr, session_key, (char *)sinfo.ssi_cspwd,
- sinfo.ssi_cspwlen);
+ smb_sign_init(sr, session_key, (char *)sinfo->ssi_cspwd,
+ sinfo->ssi_cspwlen);
if (!(sr->smb_flg2 & SMB_FLAGS2_SMB_SECURITY_SIGNATURE) &&
(sr->sr_cfg->skc_signing_required)) {
(void) smb_inet_ntop(&sr->session->ipaddr, ipaddr_buf,
SMB_IPSTRLEN(sr->session->ipaddr.a_family));
cmn_err(CE_NOTE,
- "SmbSessonSetupX: client %s is not capable of signing",
+ "SmbSessonSetupX: client %s does not support signing",
ipaddr_buf);
smbsr_error(sr, NT_STATUS_LOGON_FAILURE,
ERRDOS, ERROR_LOGON_FAILURE);
@@ -217,7 +213,7 @@ smb_com_session_setup_andx(smb_request_t *sr)
3,
sr->andx_com,
-1, /* andx_off */
- (auth_res == SMB_AUTH_GUEST) ? 1 : 0,
+ sinfo->ssi_guest ? 1 : 0,
VAR_BCC,
sr,
smbnative_os_str(&sr->sr_cfg->skc_version),
@@ -228,22 +224,20 @@ smb_com_session_setup_andx(smb_request_t *sr)
}
/*
- * Tries to authenticate the connected user.
+ * Authenticate a user. If the user has already been authenticated on
+ * this session, we can simply dup the user and return.
*
- * It first tries to see if the user has already been authenticated.
- * If a match is found, the user structure in the session is duplicated
- * and the function returns. Otherwise, user information is passed to
- * smbd for authentication. If smbd can authenticate the user an access
- * token structure is returned. A cred_t and user structure is created
- * based on the returned access token.
+ * Otherwise, the user information is passed to smbd for authentication.
+ * If smbd can authenticate the user an access token is returned and we
+ * generate a cred and new user based on the token.
*/
static int
-smb_authenticate(smb_request_t *sr, smb_sessionsetup_info_t *sinfo,
+smb_authenticate(smb_request_t *sr, smb_arg_sessionsetup_t *sinfo,
smb_session_key_t **session_key)
{
char *hostname = sr->sr_cfg->skc_hostname;
int security = sr->sr_cfg->skc_secmode;
- smb_token_t *usr_token = NULL;
+ smb_token_t *token = NULL;
smb_user_t *user = NULL;
smb_logon_t user_info;
boolean_t need_lookup = B_FALSE;
@@ -253,6 +247,7 @@ smb_authenticate(smb_request_t *sr, smb_sessionsetup_info_t *sinfo,
char *p;
bzero(&user_info, sizeof (smb_logon_t));
+ user_info.lg_e_domain = sinfo->ssi_domain;
if ((*sinfo->ssi_user == '\0') &&
(sinfo->ssi_cspwlen == 0) &&
@@ -263,17 +258,13 @@ smb_authenticate(smb_request_t *sr, smb_sessionsetup_info_t *sinfo,
} else {
user_info.lg_e_username = sinfo->ssi_user;
}
- user_info.lg_e_domain = sinfo->ssi_domain;
/*
- * Handle user@domain format.
- *
- * We need to extract the user and domain names but
- * should keep the request data as is. This is important
- * for some forms of authentication.
+ * Handle user@domain format. We need to retain the original
+ * data as this is important in some forms of authentication.
*/
if (*sinfo->ssi_domain == '\0') {
- buf = smb_mem_strdup(sinfo->ssi_user);
+ buf = smb_srm_strdup(sr, sinfo->ssi_user);
if ((p = strchr(buf, '@')) != NULL) {
*p = '\0';
user_info.lg_e_username = buf;
@@ -282,11 +273,10 @@ smb_authenticate(smb_request_t *sr, smb_sessionsetup_info_t *sinfo,
}
/*
- * See if this user has already been authenticated.
- *
- * If no domain name is provided we cannot determine whether
- * this is a local or domain user when server is operating
- * in domain mode, so lookup will be done after authentication.
+ * If no domain name has been provided in domain mode we cannot
+ * determine if this is a local user or a domain user without
+ * obtaining an access token. So we postpone the lookup until
+ * after authentication.
*/
if (security == SMB_SECMODE_WORKGRP) {
user = smb_session_dup_user(sr->session, hostname,
@@ -299,14 +289,11 @@ smb_authenticate(smb_request_t *sr, smb_sessionsetup_info_t *sinfo,
}
if (user != NULL) {
+ sinfo->ssi_guest = SMB_USER_IS_GUEST(user);
sr->user_cr = user->u_cred;
sr->smb_uid = user->u_uid;
sr->uid_user = user;
-
- smb_mem_free(buf);
-
- return ((user->u_flags & SMB_USER_FLAG_GUEST)
- ? SMB_AUTH_GUEST : SMB_AUTH_USER);
+ return (0);
}
user_info.lg_level = NETR_NETWORK_LOGON;
@@ -323,65 +310,182 @@ smb_authenticate(smb_request_t *sr, smb_sessionsetup_info_t *sinfo,
user_info.lg_lm_password.val = sinfo->ssi_cipwd;
user_info.lg_lm_password.len = sinfo->ssi_cipwlen;
user_info.lg_native_os = sr->session->native_os;
- user_info.lg_native_lm = smbnative_lm_value(sinfo->ssi_native_lm);
+ user_info.lg_native_lm = sr->session->native_lm;
- DTRACE_PROBE1(smb__sessionsetup__clntinfo, smb_logon_t *,
- &user_info);
+ DTRACE_PROBE1(smb__sessionsetup__clntinfo, smb_logon_t *, &user_info);
- usr_token = smb_get_token(&user_info);
-
- smb_mem_free(buf);
-
- if (usr_token == NULL) {
+ if ((token = smb_get_token(&user_info)) == NULL) {
smbsr_error(sr, 0, ERRSRV, ERRbadpw);
- return (SMB_AUTH_FAILED);
+ return (-1);
}
if (need_lookup) {
user = smb_session_dup_user(sr->session,
- usr_token->tkn_domain_name, usr_token->tkn_account_name);
-
+ token->tkn_domain_name, token->tkn_account_name);
if (user != NULL) {
+ sinfo->ssi_guest = SMB_USER_IS_GUEST(user);
sr->user_cr = user->u_cred;
sr->smb_uid = user->u_uid;
sr->uid_user = user;
-
- smb_token_free(usr_token);
- return ((user->u_flags & SMB_USER_FLAG_GUEST)
- ? SMB_AUTH_GUEST : SMB_AUTH_USER);
+ smb_token_free(token);
+ return (0);
}
}
- if (usr_token->tkn_session_key) {
+ if (token->tkn_session_key) {
*session_key = smb_srm_zalloc(sr, sizeof (smb_session_key_t));
- (void) memcpy(*session_key, usr_token->tkn_session_key,
+ bcopy(token->tkn_session_key, *session_key,
sizeof (smb_session_key_t));
}
- if ((cr = smb_cred_create(usr_token, &privileges)) != NULL) {
- user = smb_user_login(sr->session, cr,
- usr_token->tkn_domain_name,
- usr_token->tkn_account_name,
- usr_token->tkn_flags,
- privileges,
- usr_token->tkn_audit_sid);
-
- smb_cred_rele(user->u_cred);
- if (user->u_privcred)
- smb_cred_rele(user->u_privcred);
+ if ((cr = smb_cred_create(token)) == NULL) {
+ smb_token_free(token);
+ smbsr_error(sr, 0, ERRDOS, ERROR_INVALID_HANDLE);
+ return (-1);
}
- smb_token_free(usr_token);
+ privileges = smb_priv_xlate(token);
+
+ user = smb_user_login(sr->session, cr,
+ token->tkn_domain_name, token->tkn_account_name,
+ token->tkn_flags, privileges, token->tkn_audit_sid);
+
+ crfree(cr);
+ smb_token_free(token);
if (user == NULL) {
smbsr_error(sr, 0, ERRDOS, ERROR_INVALID_HANDLE);
- return (SMB_AUTH_FAILED);
+ return (-1);
}
+ sinfo->ssi_guest = SMB_USER_IS_GUEST(user);
sr->user_cr = user->u_cred;
sr->smb_uid = user->u_uid;
sr->uid_user = user;
+ return (0);
+}
+
+/*
+ * Allocate a Solaris cred and initialize it based on the access token.
+ *
+ * If the user can be mapped to a non-ephemeral ID, the cred gid is set
+ * to the Solaris user's primary group.
+ *
+ * If the mapped UID is ephemeral, or the primary group could not be
+ * obtained, the cred gid is set to whatever Solaris group is mapped
+ * to the token's primary group.
+ */
+static cred_t *
+smb_cred_create(smb_token_t *token)
+{
+ ksid_t ksid;
+ ksidlist_t *ksidlist = NULL;
+ smb_posix_grps_t *posix_grps;
+ cred_t *cr;
+ gid_t gid;
+
+ ASSERT(token);
+ ASSERT(token->tkn_posix_grps);
+ posix_grps = token->tkn_posix_grps;
+
+ cr = crget();
+ ASSERT(cr != NULL);
+
+ if (!IDMAP_ID_IS_EPHEMERAL(token->tkn_user.i_id) &&
+ (posix_grps->pg_ngrps != 0)) {
+ gid = posix_grps->pg_grps[0];
+ } else {
+ gid = token->tkn_primary_grp.i_id;
+ }
+
+ if (crsetugid(cr, token->tkn_user.i_id, gid) != 0) {
+ crfree(cr);
+ return (NULL);
+ }
+
+ if (crsetgroups(cr, posix_grps->pg_ngrps, posix_grps->pg_grps) != 0) {
+ crfree(cr);
+ return (NULL);
+ }
+
+ smb_cred_set_sid(&token->tkn_user, &ksid);
+ crsetsid(cr, &ksid, KSID_USER);
+ smb_cred_set_sid(&token->tkn_primary_grp, &ksid);
+ crsetsid(cr, &ksid, KSID_GROUP);
+ smb_cred_set_sid(&token->tkn_owner, &ksid);
+ crsetsid(cr, &ksid, KSID_OWNER);
+ ksidlist = smb_cred_set_sidlist(&token->tkn_win_grps);
+ crsetsidlist(cr, ksidlist);
+
+ if (smb_token_query_privilege(token, SE_TAKE_OWNERSHIP_LUID))
+ (void) crsetpriv(cr, PRIV_FILE_CHOWN, NULL);
+
+ return (cr);
+}
+
+/*
+ * Initialize the ksid based on the given smb_id_t.
+ */
+static void
+smb_cred_set_sid(smb_id_t *id, ksid_t *ksid)
+{
+ char sidstr[SMB_SID_STRSZ];
+ int rc;
+
+ ASSERT(id);
+ ASSERT(id->i_sid);
+
+ ksid->ks_id = id->i_id;
+ smb_sid_tostr(id->i_sid, sidstr);
+ rc = smb_sid_splitstr(sidstr, &ksid->ks_rid);
+ ASSERT(rc == 0);
+
+ ksid->ks_attr = id->i_attrs;
+ ksid->ks_domain = ksid_lookupdomain(sidstr);
+}
+
+/*
+ * Allocate and initialize the ksidlist based on the access token group list.
+ */
+static ksidlist_t *
+smb_cred_set_sidlist(smb_ids_t *token_grps)
+{
+ int i;
+ ksidlist_t *lp;
+
+ lp = kmem_zalloc(KSIDLIST_MEM(token_grps->i_cnt), KM_SLEEP);
+ lp->ksl_ref = 1;
+ lp->ksl_nsid = token_grps->i_cnt;
+ lp->ksl_neid = 0;
+
+ for (i = 0; i < lp->ksl_nsid; i++) {
+ smb_cred_set_sid(&token_grps->i_ids[i], &lp->ksl_sids[i]);
+ if (lp->ksl_sids[i].ks_id > IDMAP_WK__MAX_GID)
+ lp->ksl_neid++;
+ }
+
+ return (lp);
+}
+
+/*
+ * Convert access token privileges to local definitions.
+ */
+static uint32_t
+smb_priv_xlate(smb_token_t *token)
+{
+ uint32_t privileges = 0;
+
+ if (smb_token_query_privilege(token, SE_BACKUP_LUID))
+ privileges |= SMB_USER_PRIV_BACKUP;
+
+ if (smb_token_query_privilege(token, SE_RESTORE_LUID))
+ privileges |= SMB_USER_PRIV_RESTORE;
+
+ if (smb_token_query_privilege(token, SE_TAKE_OWNERSHIP_LUID))
+ privileges |= SMB_USER_PRIV_TAKE_OWNERSHIP;
+
+ if (smb_token_query_privilege(token, SE_SECURITY_LUID))
+ privileges |= SMB_USER_PRIV_SECURITY;
- return ((user->u_flags & SMB_USER_FLAG_GUEST)
- ? SMB_AUTH_GUEST : SMB_AUTH_USER);
+ return (privileges);
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_signing.c b/usr/src/uts/common/fs/smbsrv/smb_signing.c
index 55c7e45b0b..63d6130c48 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_signing.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_signing.c
@@ -19,10 +19,8 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-
/*
* These routines provide the SMB MAC signing for the SMB server.
* The routines calculate the signature of a SMB message in an mbuf chain.
@@ -56,25 +54,29 @@ smb_sign_calc(struct mbuf_chain *mbc,
#ifdef DEBUG
void smb_sign_find_seqnum(
+ uint32_t seqnum,
struct smb_sign *sign,
struct mbuf_chain *command,
unsigned char *mac_sig,
unsigned char *sr_sig,
boolean_t *found);
-
-#define SMB_CHECK_SEQNUM(sign, command, mac_sig, sr_sig, found) \
+#define SMB_CHECK_SEQNUM(seqnum, sign, command, mac_sig, sr_sig, found) \
{ \
if (smb_sign_debug) \
- smb_sign_find_seqnum(sign, command, mac_sig, sr_sig, found); \
+ smb_sign_find_seqnum(seqnum, sign, \
+ command, mac_sig, sr_sig, found); \
}
#else
-#define SMB_CHECK_SEQNUM(sign, command, mac_sig, sr_sig, found) \
- { }
+#define SMB_CHECK_SEQNUM(seqnum, sign, command, mac_sig, sr_sig, found) \
+ { \
+ *found = 0; \
+ }
#endif
#ifdef DEBUG
void
smb_sign_find_seqnum(
+ uint32_t seqnum,
struct smb_sign *sign,
struct mbuf_chain *command,
unsigned char *mac_sig,
@@ -86,21 +88,22 @@ int i;
/* Debug code to hunt for the sequence number */
*found = B_FALSE;
- start_seqnum = (int)sign->seqnum - 6;
+ start_seqnum = seqnum - 10;
if (start_seqnum < 0)
start_seqnum = 0;
- for (i = start_seqnum; i <= start_seqnum + 6; i++) {
+ for (i = start_seqnum; i <= start_seqnum + 20; i++) {
(void) smb_sign_calc(command, sign, i, mac_sig);
if (memcmp(mac_sig, sr_sig, SMB_SIG_SIZE) == 0) {
sign->seqnum = i;
*found = B_TRUE;
break;
}
- cmn_err(CE_WARN, "smb_sign_find_seqnum: seqnum%d mismatch", i);
+ cmn_err(CE_WARN, "smb_sign_find_seqnum: seqnum:%d mismatch", i);
}
cmn_err(CE_WARN, "smb_sign_find_seqnum: found=%d", *found);
}
#endif
+
/* This holds the MD5 mechanism */
static crypto_mechanism_t crypto_mech = {CRYPTO_MECHANISM_INVALID, 0, 0};
@@ -143,8 +146,9 @@ smb_sign_init(smb_request_t *sr, smb_session_key_t *session_key,
resp_len);
sign->mackey_len = sizeof (smb_session_key_t) + resp_len;
+ sr->session->signing.seqnum = 0;
+ sr->sr_seqnum = 2;
sr->reply_seqnum = 1;
- sign->seqnum = 2;
sign->flags = SMB_SIGNING_ENABLED;
}
@@ -327,6 +331,7 @@ smb_sign_check_request(smb_request_t *sr)
struct smb_sign *sign = &sr->session->signing;
int rtn = 0;
boolean_t found = B_TRUE;
+
/*
* Don't check secondary transactions - we dont know the sequence
* number.
@@ -340,34 +345,22 @@ smb_sign_check_request(smb_request_t *sr)
command.chain_offset = sr->orig_request_hdr;
/* calculate mac signature */
- if (smb_sign_calc(&command, sign, sign->seqnum, mac_sig) != 0)
+ if (smb_sign_calc(&command, sign, sr->sr_seqnum, mac_sig) != 0)
return (-1);
/* compare the signatures */
if (memcmp(mac_sig, sr->smb_sig, SMB_SIG_SIZE) != 0) {
DTRACE_PROBE2(smb__signing__req, smb_request_t, sr,
smb_sign_t *, sr->smb_sig);
- cmn_err(CE_NOTE, "message signing: bad signature");
+ cmn_err(CE_NOTE, "smb_sign_check_request: bad signature");
/*
* check nearby sequence numbers in debug mode
*/
- SMB_CHECK_SEQNUM(sign, &command, mac_sig, sr->smb_sig, &found);
+ SMB_CHECK_SEQNUM(sr->sr_seqnum, sign, &command,
+ mac_sig, sr->smb_sig, &found);
if (found == B_FALSE)
rtn = -1;
}
- /*
- * Increment the sequence number for the reply, save the reply
- * and set it for the next expect command.
- * There is no reply for NT Cancel so just increment it for the
- * next expected command.
- */
- sign->seqnum++;
-
- if (sr->smb_com == SMB_COM_NT_CANCEL)
- sr->reply_seqnum = 0;
- else
- sr->reply_seqnum = sign->seqnum++;
-
return (rtn);
}
@@ -407,9 +400,6 @@ smb_sign_check_secondary(smb_request_t *sr, unsigned int reply_seqnum)
return (rtn);
}
-
-
-
/*
* smb_sign_reply
*
@@ -440,8 +430,10 @@ smb_sign_reply(smb_request_t *sr, struct mbuf_chain *reply)
/*
* Calculate MAC signature
*/
- if (smb_sign_calc(&resp, sign, sr->reply_seqnum, signature) != 0)
+ if (smb_sign_calc(&resp, sign, sr->reply_seqnum, signature) != 0) {
+ cmn_err(CE_WARN, "smb_sign_reply: error in smb_sign_calc");
return;
+ }
/*
* Put signature in the response
diff --git a/usr/src/uts/common/fs/smbsrv/smb_tree.c b/usr/src/uts/common/fs/smbsrv/smb_tree.c
index 641a83d01b..92b9777c1f 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_tree.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_tree.c
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -160,86 +161,87 @@
* being queued in that list is NOT registered by incrementing the
* reference count.
*/
-#include <sys/types.h>
+
#include <sys/refstr_impl.h>
-#include <sys/feature_tests.h>
-#include <sys/sunddi.h>
-#include <sys/fsid.h>
-#include <sys/vfs.h>
-#include <sys/stat.h>
-#include <sys/varargs.h>
-#include <sys/cred.h>
#include <smbsrv/smb_kproto.h>
-#include <smbsrv/lmerr.h>
+#include <smbsrv/smb_ktypes.h>
#include <smbsrv/smb_fsops.h>
-#include <smbsrv/smb_share.h>
-#include <sys/pathname.h>
int smb_tcon_mute = 0;
static smb_tree_t *smb_tree_connect_disk(smb_request_t *, const char *);
+static smb_tree_t *smb_tree_connect_printq(smb_request_t *, const char *);
static smb_tree_t *smb_tree_connect_ipc(smb_request_t *, const char *);
-static smb_tree_t *smb_tree_alloc(smb_user_t *, const smb_share_t *,
- int32_t, smb_node_t *, uint32_t);
+static smb_tree_t *smb_tree_alloc(smb_user_t *, const smb_kshare_t *,
+ smb_node_t *, uint32_t, uint32_t);
static boolean_t smb_tree_is_connected_locked(smb_tree_t *);
static boolean_t smb_tree_is_disconnected(smb_tree_t *);
static const char *smb_tree_get_sharename(const char *);
-static int smb_tree_get_stype(const char *, const char *, int32_t *);
-static int smb_tree_getattr(const smb_share_t *, smb_node_t *, smb_tree_t *);
+static int smb_tree_getattr(const smb_kshare_t *, smb_node_t *, smb_tree_t *);
static void smb_tree_get_volname(vfs_t *, smb_tree_t *);
-static void smb_tree_get_flags(const smb_share_t *, vfs_t *, smb_tree_t *);
+static void smb_tree_get_flags(const smb_kshare_t *, vfs_t *, smb_tree_t *);
static void smb_tree_log(smb_request_t *, const char *, const char *, ...);
static void smb_tree_close_odirs(smb_tree_t *, uint16_t);
static smb_ofile_t *smb_tree_get_ofile(smb_tree_t *, smb_ofile_t *);
static smb_odir_t *smb_tree_get_odir(smb_tree_t *, smb_odir_t *);
-static void smb_tree_set_execsub_info(smb_tree_t *, smb_execsub_info_t *);
+static void smb_tree_set_execinfo(smb_tree_t *, smb_shr_execinfo_t *, int);
static int smb_tree_enum_private(smb_tree_t *, smb_svcenum_t *);
static int smb_tree_netinfo_encode(smb_tree_t *, uint8_t *, size_t, uint32_t *);
static void smb_tree_netinfo_init(smb_tree_t *tree, smb_netconnectinfo_t *);
static void smb_tree_netinfo_fini(smb_netconnectinfo_t *);
/*
- * Extract the share name and share type and connect as appropriate.
+ * Lookup the share name dispatch the appropriate stype handler.
* Share names are case insensitive so we map the share name to
* lower-case as a convenience for internal processing.
+ *
+ * Valid service values are:
+ * A: Disk share
+ * LPT1: Printer
+ * IPC Named pipe (IPC$ is reserved as the named pipe share).
+ * COMM Communications device
+ * ????? Any type of device (wildcard)
*/
smb_tree_t *
smb_tree_connect(smb_request_t *sr)
{
- char *unc_path = sr->arg.tcon.path;
- char *service = sr->arg.tcon.service;
- smb_tree_t *tree = NULL;
- const char *name;
- int32_t stype;
+ char *unc_path = sr->sr_tcon.path;
+ smb_tree_t *tree = NULL;
+ smb_kshare_t *si;
+ const char *name;
(void) smb_strlwr(unc_path);
if ((name = smb_tree_get_sharename(unc_path)) == NULL) {
+ smb_tree_log(sr, name, "invalid UNC path");
smbsr_error(sr, 0, ERRSRV, ERRinvnetname);
return (NULL);
}
- if (smb_tree_get_stype(name, service, &stype) != 0) {
- smbsr_error(sr, NT_STATUS_BAD_DEVICE_TYPE,
- ERRDOS, ERROR_BAD_DEV_TYPE);
+ if ((si = smb_kshare_lookup(name)) == NULL) {
+ smb_tree_log(sr, name, "share not found");
+ smbsr_error(sr, 0, ERRSRV, ERRinvnetname);
return (NULL);
}
+ sr->sr_tcon.si = si;
- switch (stype & STYPE_MASK) {
+ switch (si->shr_type & STYPE_MASK) {
case STYPE_DISKTREE:
tree = smb_tree_connect_disk(sr, name);
break;
-
case STYPE_IPC:
tree = smb_tree_connect_ipc(sr, name);
break;
-
+ case STYPE_PRINTQ:
+ tree = smb_tree_connect_printq(sr, name);
+ break;
default:
smbsr_error(sr, NT_STATUS_BAD_DEVICE_TYPE,
ERRDOS, ERROR_BAD_DEV_TYPE);
break;
}
+ smb_kshare_release(si);
return (tree);
}
@@ -249,7 +251,7 @@ smb_tree_connect(smb_request_t *sr)
void
smb_tree_disconnect(smb_tree_t *tree, boolean_t do_exec)
{
- smb_execsub_info_t subs;
+ smb_shr_execinfo_t execinfo;
ASSERT(tree->t_magic == SMB_TREE_MAGIC);
@@ -262,7 +264,6 @@ smb_tree_disconnect(smb_tree_t *tree, boolean_t do_exec)
*/
tree->t_state = SMB_TREE_STATE_DISCONNECTING;
mutex_exit(&tree->t_mutex);
- atomic_dec_32(&tree->t_server->sv_open_trees);
if (do_exec) {
/*
@@ -277,17 +278,16 @@ smb_tree_disconnect(smb_tree_t *tree, boolean_t do_exec)
mutex_enter(&tree->t_mutex);
tree->t_state = SMB_TREE_STATE_DISCONNECTED;
+ smb_server_dec_trees(tree->t_server);
}
mutex_exit(&tree->t_mutex);
- if (do_exec && tree->t_state == SMB_TREE_STATE_DISCONNECTED &&
- tree->t_shr_flags & SMB_SHRF_UNMAP) {
-
- (void) smb_tree_set_execsub_info(tree, &subs);
+ if (do_exec && (tree->t_state == SMB_TREE_STATE_DISCONNECTED) &&
+ (tree->t_execflags & SMB_EXEC_UNMAP)) {
- (void) smb_kshare_exec(tree->t_server->sv_lmshrd,
- (char *)tree->t_sharename, &subs, SMB_SHR_UNMAP);
+ smb_tree_set_execinfo(tree, &execinfo, SMB_EXEC_UNMAP);
+ (void) smb_kshare_exec(&execinfo);
}
}
@@ -454,9 +454,20 @@ smb_tree_fclose(smb_tree_t *tree, uint32_t uniqid)
/* *************************** Static Functions ***************************** */
#define SHARES_DIR ".zfs/shares/"
-static void
-smb_tree_acl_access(smb_request_t *sr, const smb_share_t *si, vnode_t *pathvp,
- uint32_t *access)
+
+/*
+ * Calculates permissions given by the share's ACL to the
+ * user in the passed request. The default is full access.
+ * If any error occurs, full access is granted.
+ *
+ * Using the vnode of the share path find the root directory
+ * of the mounted file system. Then look to see if there is a
+ * .zfs/shares directory and if there is, lookup the file with
+ * the same name as the share name in it. The ACL set for this
+ * file is the share's ACL which is used for access check here.
+ */
+static uint32_t
+smb_tree_acl_access(smb_request_t *sr, const smb_kshare_t *si, vnode_t *pathvp)
{
smb_user_t *user;
cred_t *cred;
@@ -467,10 +478,11 @@ smb_tree_acl_access(smb_request_t *sr, const smb_share_t *si, vnode_t *pathvp,
char *sharepath;
struct pathname pnp;
size_t size;
+ uint32_t access;
user = sr->uid_user;
cred = user->u_cred;
- *access = ACE_ALL_PERMS; /* default to full "UNIX" access */
+ access = ACE_ALL_PERMS;
if (si->shr_flags & SMB_SHRF_AUTOHOME) {
/*
@@ -478,16 +490,13 @@ smb_tree_acl_access(smb_request_t *sr, const smb_share_t *si, vnode_t *pathvp,
* Everyone else is denied access.
*/
if (si->shr_uid != crgetuid(cred))
- *access = 0;
- return;
+ access = 0;
+
+ return (access);
}
/*
- * Using the vnode of the share path, we then find the root
- * directory of the mounted file system. We will then look to
- * see if there is a .zfs/shares directory and if there is,
- * get the access information from the ACL/ACES values and
- * check against the cred.
+ * The hold on 'root' is released by the lookuppnvp() that follows
*/
vfsp = pathvp->v_vfsp;
if (vfsp != NULL)
@@ -496,119 +505,165 @@ smb_tree_acl_access(smb_request_t *sr, const smb_share_t *si, vnode_t *pathvp,
rc = ENOENT;
if (rc != 0)
- return;
+ return (access);
- /*
- * Find the share object, if there is one. Need to construct
- * the path to the .zfs/shares/<sharename> object and look it
- * up. root is called held but will be released by
- * lookuppnvp().
- */
-
size = sizeof (SHARES_DIR) + strlen(si->shr_name) + 1;
- sharepath = kmem_alloc(size, KM_SLEEP);
+ sharepath = smb_srm_alloc(sr, size);
(void) sprintf(sharepath, "%s%s", SHARES_DIR, si->shr_name);
pn_alloc(&pnp);
(void) pn_set(&pnp, sharepath);
- rc = lookuppnvp(&pnp, NULL, NO_FOLLOW, NULL,
- &sharevp, rootdir, root, kcred);
+ rc = lookuppnvp(&pnp, NULL, NO_FOLLOW, NULL, &sharevp, rootdir, root,
+ kcred);
pn_free(&pnp);
- kmem_free(sharepath, size);
-
/*
- * Now get the effective access value based on cred and ACL
- * values.
+ * Now get the effective access value based on cred and ACL values.
*/
-
if (rc == 0) {
- smb_vop_eaccess(sharevp, (int *)access, V_ACE_MASK, NULL, cred);
+ smb_vop_eaccess(sharevp, (int *)&access, V_ACE_MASK, NULL,
+ cred);
VN_RELE(sharevp);
}
+
+ return (access);
}
/*
- * Connect a share for use with files and directories.
+ * Performs the following access checks for a disk share:
+ *
+ * - No IPC/anonymous user is allowed
+ *
+ * - If user is Guest, guestok property of the share should be
+ * enabled
+ *
+ * - If this is an Admin share, the user should have administrative
+ * privileges
+ *
+ * - Host based access control lists
+ *
+ * - Share ACL
+ *
+ * Returns the access allowed or 0 if access is denied.
*/
+static uint32_t
+smb_tree_chkaccess(smb_request_t *sr, smb_kshare_t *shr, vnode_t *vp)
+{
+ smb_user_t *user = sr->uid_user;
+ char *sharename = shr->shr_name;
+ uint32_t host_access;
+ uint32_t acl_access;
+ uint32_t access;
+ if (user->u_flags & SMB_USER_FLAG_IPC) {
+ smb_tree_log(sr, sharename, "access denied: IPC only");
+ return (0);
+ }
+
+ if ((user->u_flags & SMB_USER_FLAG_GUEST) &&
+ ((shr->shr_flags & SMB_SHRF_GUEST_OK) == 0)) {
+ smb_tree_log(sr, sharename, "access denied: guest disabled");
+ return (0);
+ }
+
+ if ((shr->shr_flags & SMB_SHRF_ADMIN) && !smb_user_is_admin(user)) {
+ smb_tree_log(sr, sharename, "access denied: not admin");
+ return (0);
+ }
+
+ host_access = smb_kshare_hostaccess(shr, &sr->session->ipaddr);
+ if ((host_access & ACE_ALL_PERMS) == 0) {
+ smb_tree_log(sr, sharename, "access denied: host access");
+ return (0);
+ }
+
+ acl_access = smb_tree_acl_access(sr, shr, vp);
+ if ((acl_access & ACE_ALL_PERMS) == 0) {
+ smb_tree_log(sr, sharename, "access denied: share ACL");
+ return (0);
+ }
+
+ access = host_access & acl_access;
+ if ((access & ACE_ALL_PERMS) == 0) {
+ smb_tree_log(sr, sharename, "access denied");
+ return (0);
+ }
+
+ return (access);
+}
+
+/*
+ * Connect a share for use with files and directories.
+ */
static smb_tree_t *
smb_tree_connect_disk(smb_request_t *sr, const char *sharename)
{
+ const char *any = "?????";
smb_user_t *user = sr->uid_user;
smb_node_t *dnode = NULL;
smb_node_t *snode = NULL;
+ smb_kshare_t *si = sr->sr_tcon.si;
+ char *service = sr->sr_tcon.service;
char last_component[MAXNAMELEN];
smb_tree_t *tree;
- smb_share_t *si;
- cred_t *u_cred;
int rc;
- uint32_t access = 0; /* read/write is assumed */
- uint32_t hostaccess = ACE_ALL_PERMS;
- uint32_t aclaccess;
- smb_execsub_info_t subs;
+ uint32_t access;
+ smb_shr_execinfo_t execinfo;
ASSERT(user);
- u_cred = user->u_cred;
- ASSERT(u_cred);
+ ASSERT(user->u_cred);
- if (user->u_flags & SMB_USER_FLAG_IPC) {
- smb_tree_log(sr, sharename, "access denied: IPC only");
- smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRSRV, ERRaccess);
+ if ((strcmp(service, any) != 0) && (strcasecmp(service, "A:") != 0)) {
+ smb_tree_log(sr, sharename, "invalid service (%s)", service);
+ smbsr_error(sr, NT_STATUS_BAD_DEVICE_TYPE,
+ ERRDOS, ERROR_BAD_DEV_TYPE);
return (NULL);
}
- si = kmem_zalloc(sizeof (smb_share_t), KM_SLEEP);
+ /*
+ * Check that the shared directory exists.
+ */
+ rc = smb_pathname_reduce(sr, user->u_cred, si->shr_path, 0, 0, &dnode,
+ last_component);
- if (smb_kshare_getinfo(sr->sr_server->sv_lmshrd, (char *)sharename, si,
- &sr->session->ipaddr) != NERR_Success) {
- smb_tree_log(sr, sharename, "share not found");
- smbsr_error(sr, 0, ERRSRV, ERRinvnetname);
- kmem_free(si, sizeof (smb_share_t));
- return (NULL);
+ if (rc == 0) {
+ rc = smb_fsop_lookup(sr, user->u_cred, SMB_FOLLOW_LINKS,
+ sr->sr_server->si_root_smb_node, dnode, last_component,
+ &snode);
+
+ smb_node_release(dnode);
}
- if (user->u_flags & SMB_USER_FLAG_GUEST) {
- if ((si->shr_flags & SMB_SHRF_GUEST_OK) == 0) {
- smb_tree_log(sr, sharename,
- "access denied: guest disabled");
- smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRSRV,
- ERRaccess);
- kmem_free(si, sizeof (smb_share_t));
- return (NULL);
- }
+ if (rc) {
+ if (snode)
+ smb_node_release(snode);
+
+ smb_tree_log(sr, sharename, "bad path: %s", si->shr_path);
+ smbsr_error(sr, 0, ERRSRV, ERRinvnetname);
+ return (NULL);
}
- /*
- * Handle the default administration shares: C$, D$ etc.
- * Only a user with admin rights is allowed to map these
- * shares.
- */
- if (si->shr_flags & SMB_SHRF_ADMIN) {
- if (!smb_user_is_admin(user)) {
- smb_tree_log(sr, sharename, "access denied: not admin");
- smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
- ERRSRV, ERRaccess);
- kmem_free(si, sizeof (smb_share_t));
- return (NULL);
- }
+ if ((access = smb_tree_chkaccess(sr, si, snode->vp)) == 0) {
+ smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRSRV, ERRaccess);
+ smb_node_release(snode);
+ return (NULL);
}
/*
* Set up the OptionalSupport for this share.
*/
- sr->arg.tcon.optional_support = SMB_SUPPORT_SEARCH_BITS;
+ sr->sr_tcon.optional_support = SMB_SUPPORT_SEARCH_BITS;
switch (si->shr_flags & SMB_SHRF_CSC_MASK) {
case SMB_SHRF_CSC_DISABLED:
- sr->arg.tcon.optional_support |= SMB_CSC_CACHE_NONE;
+ sr->sr_tcon.optional_support |= SMB_CSC_CACHE_NONE;
break;
case SMB_SHRF_CSC_AUTO:
- sr->arg.tcon.optional_support |= SMB_CSC_CACHE_AUTO_REINT;
+ sr->sr_tcon.optional_support |= SMB_CSC_CACHE_AUTO_REINT;
break;
case SMB_SHRF_CSC_VDO:
- sr->arg.tcon.optional_support |= SMB_CSC_CACHE_VDO;
+ sr->sr_tcon.optional_support |= SMB_CSC_CACHE_VDO;
break;
case SMB_SHRF_CSC_MANUAL:
default:
@@ -620,31 +675,76 @@ smb_tree_connect_disk(smb_request_t *sr, const char *sharename)
/* ABE support */
if (si->shr_flags & SMB_SHRF_ABE)
- sr->arg.tcon.optional_support |=
+ sr->sr_tcon.optional_support |=
SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM;
if (si->shr_flags & SMB_SHRF_DFSROOT)
- sr->arg.tcon.optional_support |= SMB_SHARE_IS_IN_DFS;
+ sr->sr_tcon.optional_support |= SMB_SHARE_IS_IN_DFS;
- access = si->shr_access_value & SMB_SHRF_ACC_ALL;
+ tree = smb_tree_alloc(user, si, snode, access,
+ sr->sr_cfg->skc_execflags);
- if (access == SMB_SHRF_ACC_RO) {
- hostaccess &= ~ACE_ALL_WRITE_PERMS;
- } else if (access == SMB_SHRF_ACC_NONE) {
- kmem_free(si, sizeof (smb_share_t));
- smb_tree_log(sr, sharename, "access denied: host access");
+ smb_node_release(snode);
+
+ if (tree) {
+ if (tree->t_execflags & SMB_EXEC_MAP) {
+ smb_tree_set_execinfo(tree, &execinfo, SMB_EXEC_MAP);
+
+ rc = smb_kshare_exec(&execinfo);
+
+ if ((rc != 0) && (tree->t_execflags & SMB_EXEC_TERM)) {
+ smb_tree_disconnect(tree, B_FALSE);
+ smb_tree_release(tree);
+ smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRSRV,
+ ERRaccess);
+ return (NULL);
+ }
+ }
+ } else {
smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRSRV, ERRaccess);
+ }
+
+ return (tree);
+}
+
+/*
+ * Shares have both a share and host based access control. The access
+ * granted will be minimum permissions based on both hostaccess
+ * (permissions allowed by host based access) and aclaccess (from the
+ * share ACL).
+ */
+static smb_tree_t *
+smb_tree_connect_printq(smb_request_t *sr, const char *sharename)
+{
+ const char *any = "?????";
+ smb_user_t *user = sr->uid_user;
+ smb_node_t *dnode = NULL;
+ smb_node_t *snode = NULL;
+ smb_kshare_t *si = sr->sr_tcon.si;
+ char *service = sr->sr_tcon.service;
+ char last_component[MAXNAMELEN];
+ smb_tree_t *tree;
+ int rc;
+ uint32_t access;
+
+ ASSERT(user);
+ ASSERT(user->u_cred);
+
+ if ((strcmp(service, any) != 0) &&
+ (strcasecmp(service, "LPT1:") != 0)) {
+ smb_tree_log(sr, sharename, "invalid service (%s)", service);
+ smbsr_error(sr, NT_STATUS_BAD_DEVICE_TYPE,
+ ERRDOS, ERROR_BAD_DEV_TYPE);
return (NULL);
}
/*
* Check that the shared directory exists.
*/
- rc = smb_pathname_reduce(sr, u_cred, si->shr_path, 0, 0, &dnode,
+ rc = smb_pathname_reduce(sr, user->u_cred, si->shr_path, 0, 0, &dnode,
last_component);
-
if (rc == 0) {
- rc = smb_fsop_lookup(sr, u_cred, SMB_FOLLOW_LINKS,
+ rc = smb_fsop_lookup(sr, user->u_cred, SMB_FOLLOW_LINKS,
sr->sr_server->si_root_smb_node, dnode, last_component,
&snode);
@@ -657,61 +757,24 @@ smb_tree_connect_disk(smb_request_t *sr, const char *sharename)
smb_tree_log(sr, sharename, "bad path: %s", si->shr_path);
smbsr_error(sr, 0, ERRSRV, ERRinvnetname);
- kmem_free(si, sizeof (smb_share_t));
return (NULL);
}
- /*
- * Find share level ACL if it exists in the designated
- * location. Needs to be done after finding a valid path but
- * before the tree is allocated.
- */
- smb_tree_acl_access(sr, si, snode->vp, &aclaccess);
- if ((aclaccess & ACE_ALL_PERMS) == 0) {
- smb_tree_log(sr, sharename, "access denied: share ACL");
- smbsr_error(sr, 0, ERRSRV, ERRaccess);
- kmem_free(si, sizeof (smb_share_t));
+ if ((access = smb_tree_chkaccess(sr, si, snode->vp)) == 0) {
+ smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRSRV, ERRaccess);
smb_node_release(snode);
return (NULL);
}
- /*
- * Set tree ACL access to the minimum ACL permissions based on
- * hostaccess (those allowed by host based access) and
- * aclaccess (those from the ACL object for the share). This
- * is done during the alloc.
- */
+ sr->sr_tcon.optional_support = SMB_SUPPORT_SEARCH_BITS;
- (void) strlcpy(si->shr_name, sharename, MAXNAMELEN);
- tree = smb_tree_alloc(user, si, STYPE_DISKTREE, snode,
- hostaccess & aclaccess);
+ tree = smb_tree_alloc(user, si, snode, access,
+ sr->sr_cfg->skc_execflags);
smb_node_release(snode);
if (tree == NULL)
smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRSRV, ERRaccess);
- else {
-
- tree->t_shr_flags = si->shr_flags;
-
- if (tree->t_shr_flags & SMB_SHRF_MAP) {
- (void) smb_tree_set_execsub_info(tree, &subs);
-
- rc = smb_kshare_exec(sr->sr_server->sv_lmshrd,
- (char *)sharename, &subs, SMB_SHR_MAP);
-
- if (rc != 0 && tree->t_shr_flags & SMB_SHRF_DISP_TERM) {
- smb_tree_disconnect(tree, B_FALSE);
- smb_tree_release(tree);
- smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRSRV,
- ERRaccess);
- kmem_free(si, sizeof (smb_share_t));
- return (NULL);
- }
- }
- }
-
- kmem_free(si, sizeof (smb_share_t));
return (tree);
}
@@ -722,9 +785,11 @@ smb_tree_connect_disk(smb_request_t *sr, const char *sharename)
static smb_tree_t *
smb_tree_connect_ipc(smb_request_t *sr, const char *name)
{
+ const char *any = "?????";
smb_user_t *user = sr->uid_user;
smb_tree_t *tree;
- smb_share_t *si;
+ smb_kshare_t *si = sr->sr_tcon.si;
+ char *service = sr->sr_tcon.service;
ASSERT(user);
@@ -735,20 +800,21 @@ smb_tree_connect_ipc(smb_request_t *sr, const char *name)
return (NULL);
}
- sr->arg.tcon.optional_support = SMB_SUPPORT_SEARCH_BITS;
+ if ((strcmp(service, any) != 0) && (strcasecmp(service, "IPC") != 0)) {
+ smb_tree_log(sr, name, "invalid service (%s)", service);
+ smbsr_error(sr, NT_STATUS_BAD_DEVICE_TYPE,
+ ERRDOS, ERROR_BAD_DEV_TYPE);
+ return (NULL);
+ }
- si = kmem_zalloc(sizeof (smb_share_t), KM_SLEEP);
- (void) strlcpy(si->shr_name, name, MAXNAMELEN);
- (void) strlcpy(si->shr_path, name, MAXPATHLEN);
- si->shr_type = STYPE_IPC | STYPE_SPECIAL;
+ sr->sr_tcon.optional_support = SMB_SUPPORT_SEARCH_BITS;
- tree = smb_tree_alloc(user, si, STYPE_IPC, NULL, ACE_ALL_PERMS);
+ tree = smb_tree_alloc(user, si, NULL, ACE_ALL_PERMS, 0);
if (tree == NULL) {
smb_tree_log(sr, name, "access denied");
smbsr_error(sr, NT_STATUS_ACCESS_DENIED, ERRSRV, ERRaccess);
}
- kmem_free(si, sizeof (smb_share_t));
return (tree);
}
@@ -756,14 +822,11 @@ smb_tree_connect_ipc(smb_request_t *sr, const char *name)
* Allocate a tree.
*/
static smb_tree_t *
-smb_tree_alloc(
- smb_user_t *user,
- const smb_share_t *si,
- int32_t stype,
- smb_node_t *snode,
- uint32_t access)
+smb_tree_alloc(smb_user_t *user, const smb_kshare_t *si, smb_node_t *snode,
+ uint32_t access, uint32_t execflags)
{
smb_tree_t *tree;
+ uint32_t stype = si->shr_type;
uint16_t tid;
if (smb_idpool_alloc(&user->u_tid_pool, &tid))
@@ -772,7 +835,7 @@ smb_tree_alloc(
tree = kmem_cache_alloc(user->u_server->si_cache_tree, KM_SLEEP);
bzero(tree, sizeof (smb_tree_t));
- if (STYPE_ISDSK(stype)) {
+ if (STYPE_ISDSK(stype) || STYPE_ISPRN(stype)) {
if (smb_tree_getattr(si, snode, tree) != 0) {
smb_idpool_free(&user->u_tid_pool, tid);
kmem_cache_free(user->u_server->si_cache_tree, tree);
@@ -816,12 +879,13 @@ smb_tree_alloc(
tree->t_magic = SMB_TREE_MAGIC;
tree->t_access = access;
tree->t_connect_time = gethrestime_sec();
+ tree->t_execflags = execflags;
/* if FS is readonly, enforce that here */
if (tree->t_flags & SMB_TREE_READONLY)
tree->t_access &= ~ACE_ALL_WRITE_PERMS;
- if (STYPE_ISDSK(stype)) {
+ if (STYPE_ISDSK(stype) || STYPE_ISPRN(stype)) {
smb_node_ref(snode);
tree->t_snode = snode;
tree->t_acltype = smb_fsop_acltype(snode);
@@ -831,8 +895,7 @@ smb_tree_alloc(
smb_llist_insert_head(&user->u_tree_list, tree);
smb_llist_exit(&user->u_tree_list);
atomic_inc_32(&user->u_session->s_tree_cnt);
- atomic_inc_32(&user->u_server->sv_open_trees);
-
+ smb_server_inc_trees(user->u_server);
return (tree);
}
@@ -955,46 +1018,10 @@ smb_tree_get_sharename(const char *unc_path)
}
/*
- * Map the service to a resource type. Valid values for service are:
- *
- * A: Disk share
- * LPT1: Printer
- * IPC Named pipe
- * COMM Communications device
- * ????? Any type of device (wildcard)
- *
- * We support IPC and disk shares; anything else is currently treated
- * as an error. IPC$ is reserved as the named pipe share.
- */
-static int
-smb_tree_get_stype(const char *sharename, const char *service,
- int32_t *stype_ret)
-{
- const char *any = "?????";
-
- if ((strcmp(service, any) == 0) || (strcasecmp(service, "IPC") == 0)) {
- if (strcasecmp(sharename, "IPC$") == 0) {
- *stype_ret = STYPE_IPC;
- return (0);
- }
- }
-
- if ((strcmp(service, any) == 0) || (strcasecmp(service, "A:") == 0)) {
- if (strcasecmp(sharename, "IPC$") == 0)
- return (-1);
-
- *stype_ret = STYPE_DISKTREE;
- return (0);
- }
-
- return (-1);
-}
-
-/*
* Obtain the tree attributes: volume name, typename and flags.
*/
static int
-smb_tree_getattr(const smb_share_t *si, smb_node_t *node, smb_tree_t *tree)
+smb_tree_getattr(const smb_kshare_t *si, smb_node_t *node, smb_tree_t *tree)
{
vfs_t *vfsp = SMB_NODE_VFS(node);
@@ -1040,7 +1067,7 @@ smb_tree_get_volname(vfs_t *vfsp, smb_tree_t *tree)
* File system types are hardcoded in uts/common/os/vfs_conf.c.
*/
static void
-smb_tree_get_flags(const smb_share_t *si, vfs_t *vfsp, smb_tree_t *tree)
+smb_tree_get_flags(const smb_kshare_t *si, vfs_t *vfsp, smb_tree_t *tree)
{
typedef struct smb_mtype {
char *mt_name;
@@ -1299,14 +1326,16 @@ smb_tree_close_odirs(smb_tree_t *tree, uint16_t pid)
}
static void
-smb_tree_set_execsub_info(smb_tree_t *tree, smb_execsub_info_t *subs)
+smb_tree_set_execinfo(smb_tree_t *tree, smb_shr_execinfo_t *exec, int exec_type)
{
- subs->e_winname = tree->t_user->u_name;
- subs->e_userdom = tree->t_user->u_domain;
- subs->e_srv_ipaddr = tree->t_session->local_ipaddr;
- subs->e_cli_ipaddr = tree->t_session->ipaddr;
- subs->e_cli_netbiosname = tree->t_session->workstation;
- subs->e_uid = crgetuid(tree->t_user->u_cred);
+ exec->e_sharename = tree->t_sharename;
+ exec->e_winname = tree->t_user->u_name;
+ exec->e_userdom = tree->t_user->u_domain;
+ exec->e_srv_ipaddr = tree->t_session->local_ipaddr;
+ exec->e_cli_ipaddr = tree->t_session->ipaddr;
+ exec->e_cli_netbiosname = tree->t_session->workstation;
+ exec->e_uid = crgetuid(tree->t_user->u_cred);
+ exec->e_type = exec_type;
}
/*
diff --git a/usr/src/uts/common/fs/smbsrv/smb_tree_connect.c b/usr/src/uts/common/fs/smbsrv/smb_tree_connect.c
index 6e71b86b90..6ede8fe0b3 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_tree_connect.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_tree_connect.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <smbsrv/smb_kproto.h>
@@ -61,19 +60,20 @@
smb_sdrc_t
smb_pre_tree_connect(smb_request_t *sr)
{
- int rc;
+ smb_arg_tcon_t *tcon = &sr->sr_tcon;
+ int rc;
/*
* Perhaps this should be "%A.sA" now that unicode is enabled.
*/
- rc = smbsr_decode_data(sr, "%AAA", sr, &sr->arg.tcon.path,
- &sr->arg.tcon.password, &sr->arg.tcon.service);
+ rc = smbsr_decode_data(sr, "%AAA", sr, &tcon->path,
+ &tcon->password, &tcon->service);
- sr->arg.tcon.flags = 0;
- sr->arg.tcon.optional_support = 0;
+ tcon->flags = 0;
+ tcon->optional_support = 0;
DTRACE_SMB_2(op__TreeConnect__start, smb_request_t *, sr,
- struct tcon *, &sr->arg.tcon);
+ smb_arg_tcon_t *, tcon);
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
@@ -243,27 +243,28 @@ smb_com_tree_connect(smb_request_t *sr)
smb_sdrc_t
smb_pre_tree_connect_andx(smb_request_t *sr)
{
- uint8_t *pwbuf = NULL;
- uint16_t pwlen = 0;
- int rc;
+ smb_arg_tcon_t *tcon = &sr->sr_tcon;
+ uint8_t *pwbuf = NULL;
+ uint16_t pwlen = 0;
+ int rc;
rc = smbsr_decode_vwv(sr, "b.www", &sr->andx_com, &sr->andx_off,
- &sr->arg.tcon.flags, &pwlen);
+ &tcon->flags, &pwlen);
if (rc == 0) {
if (pwlen != 0)
pwbuf = smb_srm_zalloc(sr, pwlen);
rc = smbsr_decode_data(sr, "%#cus", sr, pwlen, pwbuf,
- &sr->arg.tcon.path, &sr->arg.tcon.service);
+ &tcon->path, &tcon->service);
- sr->arg.tcon.pwdlen = pwlen;
- sr->arg.tcon.password = (char *)pwbuf;
+ tcon->pwdlen = pwlen;
+ tcon->password = (char *)pwbuf;
}
- sr->arg.tcon.optional_support = 0;
+ tcon->optional_support = 0;
DTRACE_SMB_2(op__TreeConnectX__start, smb_request_t *, sr,
- struct tcon *, &sr->arg.tcon);
+ smb_arg_tcon_t *, tcon);
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
@@ -277,9 +278,10 @@ smb_post_tree_connect_andx(smb_request_t *sr)
smb_sdrc_t
smb_com_tree_connect_andx(smb_request_t *sr)
{
- smb_tree_t *tree;
- char *service;
- int rc;
+ smb_arg_tcon_t *tcon = &sr->sr_tcon;
+ smb_tree_t *tree;
+ char *service;
+ int rc;
if ((tree = smb_tree_connect(sr)) == NULL)
return (SDRC_ERROR);
@@ -287,10 +289,17 @@ smb_com_tree_connect_andx(smb_request_t *sr)
sr->smb_tid = tree->t_tid;
sr->tid_tree = tree;
- if (STYPE_ISIPC(tree->t_res_type))
+ switch (tree->t_res_type & STYPE_MASK) {
+ case STYPE_IPC:
service = "IPC";
- else
+ break;
+ case STYPE_PRINTQ:
+ service = "LPT1:";
+ break;
+ case STYPE_DISKTREE:
+ default:
service = "A:";
+ }
if (sr->session->dialect < NT_LM_0_12) {
rc = smbsr_encode_result(sr, 2, VAR_BCC, "bb.wwss",
@@ -305,7 +314,7 @@ smb_com_tree_connect_andx(smb_request_t *sr)
(char)3, /* wct */
sr->andx_com,
(short)64,
- sr->arg.tcon.optional_support,
+ tcon->optional_support,
VAR_BCC,
service,
sr,
@@ -352,6 +361,10 @@ smb_com_tree_connect_andx(smb_request_t *sr)
smb_sdrc_t
smb_pre_tree_disconnect(smb_request_t *sr)
{
+ sr->uid_user = smb_session_lookup_uid(sr->session, sr->smb_uid);
+ if (sr->uid_user != NULL)
+ sr->tid_tree = smb_user_lookup_tree(sr->uid_user, sr->smb_tid);
+
DTRACE_SMB_1(op__TreeDisconnect__start, smb_request_t *, sr);
return (SDRC_SUCCESS);
}
@@ -376,11 +389,6 @@ smb_post_tree_disconnect(smb_request_t *sr)
smb_sdrc_t
smb_com_tree_disconnect(smb_request_t *sr)
{
- sr->uid_user = smb_session_lookup_uid(sr->session, sr->smb_uid);
- if (sr->uid_user != NULL)
- sr->tid_tree = smb_user_lookup_tree(sr->uid_user,
- sr->smb_tid);
-
if (sr->uid_user == NULL || sr->tid_tree == NULL) {
smbsr_error(sr, NT_STATUS_INVALID_HANDLE, ERRDOS, ERRinvnid);
return (SDRC_ERROR);
diff --git a/usr/src/uts/common/fs/smbsrv/smb_unlock_byte_range.c b/usr/src/uts/common/fs/smbsrv/smb_unlock_byte_range.c
index 5fc5654f4a..82bbdcf5c4 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_unlock_byte_range.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_unlock_byte_range.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -86,7 +86,7 @@ smb_com_unlock_byte_range(smb_request_t *sr)
(u_offset_t)Offset, (uint64_t)Length);
if (result != NT_STATUS_SUCCESS) {
smbsr_error(sr, NT_STATUS_RANGE_NOT_LOCKED,
- ERRDOS, ERRnotlocked);
+ ERRDOS, ERROR_NOT_LOCKED);
return (SDRC_ERROR);
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_user.c b/usr/src/uts/common/fs/smbsrv/smb_user.c
index 7217dedadb..cc3fde7f38 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_user.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_user.c
@@ -160,45 +160,23 @@
* being queued in that list is NOT registered by incrementing the
* reference count.
*/
+#include <sys/types.h>
+#include <sys/sid.h>
+#include <sys/priv_names.h>
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_door.h>
-
#define ADMINISTRATORS_SID "S-1-5-32-544"
-static smb_sid_t *smb_admins_sid = NULL;
-
static boolean_t smb_user_is_logged_in(smb_user_t *);
static int smb_user_enum_private(smb_user_t *, smb_svcenum_t *);
static smb_tree_t *smb_user_get_tree(smb_llist_t *, smb_tree_t *);
+static void smb_user_setcred(smb_user_t *, cred_t *, uint32_t);
static void smb_user_nonauth_logon(uint32_t);
static void smb_user_auth_logoff(uint32_t);
-int
-smb_user_init(void)
-{
- if (smb_admins_sid != NULL)
- return (0);
-
- if ((smb_admins_sid = smb_sid_fromstr(ADMINISTRATORS_SID)) == NULL)
- return (-1);
-
- return (0);
-}
-
-void
-smb_user_fini(void)
-{
- if (smb_admins_sid != NULL) {
- smb_sid_free(smb_admins_sid);
- smb_admins_sid = NULL;
- }
-}
-
/*
- * smb_user_login
- *
- *
+ * Create a new user.
*/
smb_user_t *
smb_user_login(
@@ -225,13 +203,10 @@ smb_user_login(
user->u_server = session->s_server;
user->u_logon_time = gethrestime_sec();
user->u_flags = flags;
- user->u_privileges = privileges;
user->u_name_len = strlen(account_name) + 1;
user->u_domain_len = strlen(domain_name) + 1;
user->u_name = smb_mem_strdup(account_name);
user->u_domain = smb_mem_strdup(domain_name);
- user->u_cred = cr;
- user->u_privcred = smb_cred_create_privs(cr, privileges);
user->u_audit_sid = audit_sid;
if (!smb_idpool_alloc(&session->s_uid_pool, &user->u_uid)) {
@@ -239,15 +214,13 @@ smb_user_login(
smb_llist_constructor(&user->u_tree_list,
sizeof (smb_tree_t), offsetof(smb_tree_t, t_lnd));
mutex_init(&user->u_mutex, NULL, MUTEX_DEFAULT, NULL);
- crhold(user->u_cred);
- if (user->u_privcred)
- crhold(user->u_privcred);
+ smb_user_setcred(user, cr, privileges);
user->u_state = SMB_USER_STATE_LOGGED_IN;
user->u_magic = SMB_USER_MAGIC;
smb_llist_enter(&session->s_user_list, RW_WRITER);
smb_llist_insert_tail(&session->s_user_list, user);
smb_llist_exit(&session->s_user_list);
- atomic_inc_32(&session->s_server->sv_open_users);
+ smb_server_inc_users(session->s_server);
return (user);
}
smb_idpool_free(&session->s_uid_pool, user->u_uid);
@@ -306,7 +279,6 @@ smb_user_logoff(
*/
user->u_state = SMB_USER_STATE_LOGGING_OFF;
mutex_exit(&user->u_mutex);
- atomic_dec_32(&user->u_server->sv_open_users);
/*
* All the trees hanging off of this user are disconnected.
*/
@@ -314,6 +286,7 @@ smb_user_logoff(
smb_user_auth_logoff(user->u_audit_sid);
mutex_enter(&user->u_mutex);
user->u_state = SMB_USER_STATE_LOGGED_OFF;
+ smb_server_dec_users(user->u_server);
break;
}
case SMB_USER_STATE_LOGGED_OFF:
@@ -631,22 +604,50 @@ smb_user_fclose(smb_user_t *user, uint32_t uniqid)
* Members of the administrators group have administrative rights.
*/
boolean_t
-smb_user_is_admin(
- smb_user_t *user)
+smb_user_is_admin(smb_user_t *user)
{
- cred_t *u_cred;
+ char sidstr[SMB_SID_STRSZ];
+ ksidlist_t *ksidlist;
+ ksid_t ksid1;
+ ksid_t *ksid2;
+ boolean_t rc = B_FALSE;
+ int i;
ASSERT(user);
- u_cred = user->u_cred;
- ASSERT(u_cred);
-
- if (smb_admins_sid == NULL)
- return (B_FALSE);
+ ASSERT(user->u_cred);
- if (smb_cred_is_member(u_cred, smb_admins_sid))
+ if (SMB_USER_IS_ADMIN(user))
return (B_TRUE);
- return (B_FALSE);
+ bzero(&ksid1, sizeof (ksid_t));
+ (void) strlcpy(sidstr, ADMINISTRATORS_SID, SMB_SID_STRSZ);
+ ASSERT(smb_sid_splitstr(sidstr, &ksid1.ks_rid) == 0);
+ ksid1.ks_domain = ksid_lookupdomain(sidstr);
+
+ ksidlist = crgetsidlist(user->u_cred);
+ ASSERT(ksidlist);
+ ASSERT(ksid1.ks_domain);
+ ASSERT(ksid1.ks_domain->kd_name);
+
+ i = 0;
+ ksid2 = crgetsid(user->u_cred, KSID_USER);
+ do {
+ ASSERT(ksid2->ks_domain);
+ ASSERT(ksid2->ks_domain->kd_name);
+
+ if (strcmp(ksid1.ks_domain->kd_name,
+ ksid2->ks_domain->kd_name) == 0 &&
+ ksid1.ks_rid == ksid2->ks_rid) {
+ user->u_flags |= SMB_USER_FLAG_ADMIN;
+ rc = B_TRUE;
+ break;
+ }
+
+ ksid2 = &ksidlist->ksl_sids[i];
+ } while (i++ < ksidlist->ksl_nsid);
+
+ ksid_rele(&ksid1);
+ return (rc);
}
/*
@@ -770,7 +771,8 @@ smb_user_delete(void *arg)
mutex_destroy(&user->u_mutex);
smb_llist_destructor(&user->u_tree_list);
smb_idpool_destructor(&user->u_tid_pool);
- crfree(user->u_cred);
+ if (user->u_cred)
+ crfree(user->u_cred);
if (user->u_privcred)
crfree(user->u_privcred);
smb_mem_free(user->u_name);
@@ -828,6 +830,43 @@ smb_user_getprivcred(smb_user_t *user)
}
/*
+ * Assign the user cred and privileges.
+ *
+ * If the user has backup and/or restore privleges, dup the cred
+ * and add those privileges to this new privileged cred.
+ */
+static void
+smb_user_setcred(smb_user_t *user, cred_t *cr, uint32_t privileges)
+{
+ cred_t *privcred = NULL;
+
+ ASSERT(cr);
+ crhold(cr);
+
+ if (privileges & (SMB_USER_PRIV_BACKUP | SMB_USER_PRIV_RESTORE))
+ privcred = crdup(cr);
+
+ if (privcred != NULL) {
+ if (privileges & SMB_USER_PRIV_BACKUP) {
+ (void) crsetpriv(privcred, PRIV_FILE_DAC_READ,
+ PRIV_FILE_DAC_SEARCH, PRIV_SYS_MOUNT, NULL);
+ }
+
+ if (privileges & SMB_USER_PRIV_RESTORE) {
+ (void) crsetpriv(privcred, PRIV_FILE_DAC_WRITE,
+ PRIV_FILE_CHOWN, PRIV_FILE_CHOWN_SELF,
+ PRIV_FILE_DAC_SEARCH, PRIV_FILE_LINK_ANY,
+ PRIV_FILE_OWNER, PRIV_FILE_SETID,
+ PRIV_SYS_LINKDIR, PRIV_SYS_MOUNT, NULL);
+ }
+ }
+
+ user->u_cred = cr;
+ user->u_privcred = privcred;
+ user->u_privileges = privileges;
+}
+
+/*
* Private function to support smb_user_enum.
*/
static int
diff --git a/usr/src/uts/common/fs/smbsrv/smb_vfs.c b/usr/src/uts/common/fs/smbsrv/smb_vfs.c
index cbbd77c8a5..53027a37a2 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_vfs.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_vfs.c
@@ -19,43 +19,48 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#include <sys/types.h>
-#include <sys/fsid.h>
#include <sys/vfs.h>
-#include <sys/stat.h>
#include <smbsrv/smb_ktypes.h>
#include <smbsrv/smb_kproto.h>
-static smb_vfs_t *smb_vfs_lookup(smb_server_t *, vnode_t *);
+static smb_vfs_t *smb_vfs_find(smb_export_t *, vfs_t *);
+static void smb_vfs_destroy(smb_export_t *, smb_vfs_t *);
/*
- * smb_vfs_hold
- *
- * Increments the reference count of the fs passed in. If no smb_vfs_t structure
- * has been created yet for the fs passed in it is created.
+ * If a hold on the specified VFS has already been taken
+ * then only increment the reference count of the corresponding
+ * smb_vfs_t structure. If no smb_vfs_t structure has been created
+ * yet for the specified VFS then create one and take a hold on
+ * the VFS.
*/
-boolean_t
-smb_vfs_hold(smb_server_t *sv, vfs_t *vfsp)
+int
+smb_vfs_hold(smb_export_t *se, vfs_t *vfsp)
{
smb_vfs_t *smb_vfs;
vnode_t *rootvp;
+ int rc;
- if ((vfsp == NULL) || VFS_ROOT(vfsp, &rootvp))
- return (B_FALSE);
+ if (se == NULL || vfsp == NULL)
+ return (EINVAL);
- smb_llist_enter(&sv->sv_vfs_list, RW_WRITER);
- smb_vfs = smb_vfs_lookup(sv, rootvp);
- if (smb_vfs) {
+ smb_llist_enter(&se->e_vfs_list, RW_WRITER);
+
+ if ((smb_vfs = smb_vfs_find(se, vfsp)) != NULL) {
+ smb_vfs->sv_refcnt++;
DTRACE_PROBE1(smb_vfs_hold_hit, smb_vfs_t *, smb_vfs);
- smb_llist_exit(&sv->sv_vfs_list);
- VN_RELE(rootvp);
- return (B_TRUE);
+ smb_llist_exit(&se->e_vfs_list);
+ return (0);
}
- smb_vfs = kmem_cache_alloc(sv->si_cache_vfs, KM_SLEEP);
+
+ if ((rc = VFS_ROOT(vfsp, &rootvp)) != 0) {
+ smb_llist_exit(&se->e_vfs_list);
+ return (rc);
+ }
+
+ smb_vfs = kmem_cache_alloc(se->e_cache_vfs, KM_SLEEP);
bzero(smb_vfs, sizeof (smb_vfs_t));
@@ -67,10 +72,12 @@ smb_vfs_hold(smb_server_t *sv, vfs_t *vfsp)
* from the VFS_ROOT call above.
*/
smb_vfs->sv_rootvp = rootvp;
- smb_llist_insert_head(&sv->sv_vfs_list, smb_vfs);
+
+ smb_llist_insert_head(&se->e_vfs_list, smb_vfs);
DTRACE_PROBE1(smb_vfs_hold_miss, smb_vfs_t *, smb_vfs);
- smb_llist_exit(&sv->sv_vfs_list);
- return (B_TRUE);
+ smb_llist_exit(&se->e_vfs_list);
+
+ return (0);
}
/*
@@ -80,34 +87,25 @@ smb_vfs_hold(smb_server_t *sv, vfs_t *vfsp)
* drops to zero the smb_vfs_t structure associated with the fs is freed.
*/
void
-smb_vfs_rele(smb_server_t *sv, vfs_t *vfsp)
+smb_vfs_rele(smb_export_t *se, vfs_t *vfsp)
{
smb_vfs_t *smb_vfs;
- vnode_t *rootvp;
ASSERT(vfsp);
- if (VFS_ROOT(vfsp, &rootvp))
- return;
-
- smb_llist_enter(&sv->sv_vfs_list, RW_WRITER);
- smb_vfs = smb_vfs_lookup(sv, rootvp);
- DTRACE_PROBE2(smb_vfs_release, smb_vfs_t *, smb_vfs, vnode_t *, rootvp);
- VN_RELE(rootvp);
+ smb_llist_enter(&se->e_vfs_list, RW_WRITER);
+ smb_vfs = smb_vfs_find(se, vfsp);
+ DTRACE_PROBE1(smb_vfs_release, smb_vfs_t *, smb_vfs)
if (smb_vfs) {
- --smb_vfs->sv_refcnt;
ASSERT(smb_vfs->sv_refcnt);
if (--smb_vfs->sv_refcnt == 0) {
- smb_llist_remove(&sv->sv_vfs_list, smb_vfs);
- smb_llist_exit(&sv->sv_vfs_list);
- ASSERT(rootvp == smb_vfs->sv_rootvp);
- VN_RELE(smb_vfs->sv_rootvp);
- smb_vfs->sv_magic = (uint32_t)~SMB_VFS_MAGIC;
- kmem_cache_free(sv->si_cache_vfs, smb_vfs);
+ smb_llist_remove(&se->e_vfs_list, smb_vfs);
+ smb_llist_exit(&se->e_vfs_list);
+ smb_vfs_destroy(se, smb_vfs);
return;
}
}
- smb_llist_exit(&sv->sv_vfs_list);
+ smb_llist_exit(&se->e_vfs_list);
}
/*
@@ -118,25 +116,22 @@ smb_vfs_rele(smb_server_t *sv, vfs_t *vfsp)
* Called at driver close time.
*/
void
-smb_vfs_rele_all(smb_server_t *sv)
+smb_vfs_rele_all(smb_export_t *se)
{
smb_vfs_t *smb_vfs;
- smb_llist_enter(&sv->sv_vfs_list, RW_WRITER);
- while ((smb_vfs = smb_llist_head(&sv->sv_vfs_list)) != NULL) {
+ smb_llist_enter(&se->e_vfs_list, RW_WRITER);
+ while ((smb_vfs = smb_llist_head(&se->e_vfs_list)) != NULL) {
ASSERT(smb_vfs->sv_magic == SMB_VFS_MAGIC);
DTRACE_PROBE1(smb_vfs_rele_all_hit, smb_vfs_t *, smb_vfs);
- smb_llist_remove(&sv->sv_vfs_list, smb_vfs);
- VN_RELE(smb_vfs->sv_rootvp);
- kmem_cache_free(sv->si_cache_vfs, smb_vfs);
+ smb_llist_remove(&se->e_vfs_list, smb_vfs);
+ smb_vfs_destroy(se, smb_vfs);
}
- smb_llist_exit(&sv->sv_vfs_list);
+ smb_llist_exit(&se->e_vfs_list);
}
/*
- * smb_vfs_lookup
- *
* Goes through the list of smb_vfs_t structure and returns the one matching
* the vnode passed in. If no match is found a NULL pointer is returned.
*
@@ -144,64 +139,25 @@ smb_vfs_rele_all(smb_server_t *sv)
* this function.
*/
static smb_vfs_t *
-smb_vfs_lookup(smb_server_t *sv, vnode_t *rootvp)
+smb_vfs_find(smb_export_t *se, vfs_t *vfsp)
{
- smb_vfs_t *smb_vfs;
+ smb_vfs_t *smb_vfs;
- smb_vfs = smb_llist_head(&sv->sv_vfs_list);
+ smb_vfs = smb_llist_head(&se->e_vfs_list);
while (smb_vfs) {
ASSERT(smb_vfs->sv_magic == SMB_VFS_MAGIC);
- if (smb_vfs->sv_rootvp == rootvp) {
- smb_vfs->sv_refcnt++;
- ASSERT(smb_vfs->sv_refcnt);
+ if (smb_vfs->sv_vfsp == vfsp)
return (smb_vfs);
- }
- smb_vfs = smb_llist_next(&sv->sv_vfs_list, smb_vfs);
- }
- return (NULL);
-}
-
-/*
- * Returns true if both VFS pointers represent the same mounted
- * file system. Otherwise returns false.
- */
-boolean_t
-smb_vfs_cmp(vfs_t *vfsp1, vfs_t *vfsp2)
-{
- fsid_t *fsid1 = &vfsp1->vfs_fsid;
- fsid_t *fsid2 = &vfsp2->vfs_fsid;
- boolean_t result = B_FALSE;
-
- if ((vfsp1 = getvfs(fsid1)) == NULL)
- return (B_FALSE);
-
- if ((vfsp2 = getvfs(fsid2)) == NULL) {
- VFS_RELE(vfsp1);
- return (B_FALSE);
+ smb_vfs = smb_llist_next(&se->e_vfs_list, smb_vfs);
}
- if ((fsid1->val[0] == fsid2->val[0]) &&
- (fsid1->val[1] == fsid2->val[1])) {
- result = B_TRUE;
- }
-
- VFS_RELE(vfsp2);
- VFS_RELE(vfsp1);
- return (result);
+ return (NULL);
}
-/*
- * Check whether or not a file system is readonly.
- */
-boolean_t
-smb_vfs_is_readonly(vfs_t *vfsp)
+static void
+smb_vfs_destroy(smb_export_t *se, smb_vfs_t *smb_vfs)
{
- boolean_t result;
-
- if (getvfs(&vfsp->vfs_fsid) == NULL)
- return (B_FALSE);
-
- result = (vfsp->vfs_flag & VFS_RDONLY);
- VFS_RELE(vfsp);
- return (result);
+ VN_RELE(smb_vfs->sv_rootvp);
+ smb_vfs->sv_magic = (uint32_t)~SMB_VFS_MAGIC;
+ kmem_cache_free(se->e_cache_vfs, smb_vfs);
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_vss.c b/usr/src/uts/common/fs/smbsrv/smb_vss.c
index a7b7a8b2e4..786d4d75ef 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_vss.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_vss.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -60,6 +59,8 @@ static uint32_t smb_vss_get_count(char *);
static void smb_vss_map_gmttoken(char *, char *, char *);
static void smb_vss_get_snapshots(char *, uint32_t, smb_gmttoken_response_t *);
static void smb_vss_get_snapshots_free(smb_gmttoken_response_t *);
+static int smb_vss_lookup_node(smb_request_t *sr, smb_node_t *, vnode_t *,
+ char *, smb_node_t *, char *, smb_node_t **);
/*
* This is to respond to the nt_transact_ioctl to either respond with the
@@ -130,7 +131,7 @@ smb_vss_ioctl_enumerate_snaps(smb_request_t *sr, smb_xa_t *xa)
* created that is the same place in the directory tree, but
* in the snapshot. We also use root_node to do the same for
* the root.
- * One the new smb node is found, the path is modified by
+ * Once the new smb node is found, the path is modified by
* removing the @GMT token from the path in the buf.
*/
int
@@ -138,115 +139,104 @@ smb_vss_lookup_nodes(smb_request_t *sr, smb_node_t *root_node,
smb_node_t *cur_node, char *buf, smb_node_t **vss_cur_node,
smb_node_t **vss_root_node)
{
- const char *p;
- smb_node_t *tnode;
- char *rootpath;
- char *snapname;
- char *nodepath;
- char gmttoken[SMB_VSS_GMT_SIZE];
- vnode_t *fsrootvp;
- vnode_t *vp = NULL;
- int err = 0;
+ const char *p;
+ smb_node_t *tnode;
+ char *snapname, *path;
+ char gmttoken[SMB_VSS_GMT_SIZE];
+ vnode_t *fsrootvp = NULL;
+ int err = 0;
if (sr->tid_tree == NULL)
return (ESTALE);
- ASSERT(sr->tid_tree->t_snode);
- ASSERT(sr->tid_tree->t_snode->vp);
- ASSERT(sr->tid_tree->t_snode->vp->v_vfsp);
+ tnode = sr->tid_tree->t_snode;
+ ASSERT(tnode);
+ ASSERT(tnode->vp);
+ ASSERT(tnode->vp->v_vfsp);
+
+ /* get gmttoken from buf and find corresponding snapshot name */
if ((p = smb_vss_find_gmttoken(buf)) == NULL)
return (ENOENT);
bcopy(p, gmttoken, SMB_VSS_GMT_SIZE);
gmttoken[SMB_VSS_GMT_SIZE - 1] = '\0';
- tnode = sr->tid_tree->t_snode;
- err = VFS_ROOT(tnode->vp->v_vfsp, &fsrootvp);
- if (err != 0)
- return (err);
+ path = smb_srm_alloc(sr, MAXPATHLEN);
+ snapname = smb_srm_alloc(sr, MAXPATHLEN);
- rootpath = kmem_alloc(MAXPATHLEN, KM_SLEEP);
- snapname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
- nodepath = kmem_alloc(MAXPATHLEN, KM_SLEEP);
-
- err = smb_node_getmntpath(tnode, rootpath, MAXPATHLEN);
+ err = smb_node_getmntpath(tnode, path, MAXPATHLEN);
if (err != 0)
- goto error;
+ return (err);
*snapname = '\0';
+ smb_vss_map_gmttoken(path, gmttoken, snapname);
+ if (!*snapname)
+ return (ENOENT);
- smb_vss_map_gmttoken(rootpath, gmttoken, snapname);
-
- if (!*snapname) {
- err = ENOENT;
- goto error;
- }
-
- /* note the value of root_node->vp */
- err = vnodetopath(fsrootvp, root_node->vp, nodepath,
- MAXPATHLEN, kcred);
-
+ /* find snapshot nodes */
+ err = VFS_ROOT(tnode->vp->v_vfsp, &fsrootvp);
if (err != 0)
- goto error;
-
- (void) snprintf(rootpath, MAXPATHLEN, ".zfs/snapshot/%s/%s",
- snapname, nodepath);
-
- vp = smb_lookuppathvptovp(sr, rootpath, fsrootvp, fsrootvp);
+ return (err);
- if (vp) {
- /* note the value of cur_node->vp */
- err = vnodetopath(fsrootvp, cur_node->vp, nodepath,
- MAXPATHLEN, kcred);
- if (err != 0) {
- VN_RELE(vp);
- goto error;
- }
+ /* find snapshot node corresponding to root_node */
+ err = smb_vss_lookup_node(sr, root_node, fsrootvp,
+ snapname, cur_node, gmttoken, vss_root_node);
+ if (err == 0) {
+ /* find snapshot node corresponding to cur_node */
+ err = smb_vss_lookup_node(sr, cur_node, fsrootvp,
+ snapname, cur_node, gmttoken, vss_cur_node);
+ if (err != 0)
+ smb_node_release(*vss_root_node);
+ }
- *vss_root_node = smb_node_lookup(sr, NULL, kcred, vp,
- gmttoken, cur_node, NULL);
- VN_RELE(vp);
+ VN_RELE(fsrootvp);
- if (*vss_root_node == NULL) {
- err = ENOENT;
- goto error;
- }
+ smb_vss_remove_first_token_from_path(buf);
+ return (err);
+}
- (void) snprintf(rootpath, MAXPATHLEN, ".zfs/snapshot/%s/%s",
- snapname, nodepath);
+/*
+ * Find snapshot node corresponding to 'node', and return it in
+ * 'vss_node', as follows:
+ * - find the path from fsrootvp to node, appending it to the
+ * the snapshot path
+ * - lookup the vnode and smb_node (vss_node).
+ */
+static int
+smb_vss_lookup_node(smb_request_t *sr, smb_node_t *node, vnode_t *fsrootvp,
+ char *snapname, smb_node_t *dnode, char *odname, smb_node_t **vss_node)
+{
+ char *p, *path;
+ int err, len;
+ vnode_t *vp = NULL;
+ *vss_node = NULL;
- vp = smb_lookuppathvptovp(sr, rootpath, fsrootvp, fsrootvp);
+ path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
+ (void) snprintf(path, MAXPATHLEN, ".zfs/snapshot/%s/", snapname);
+ len = strlen(path);
+ p = path + len;
+ err = smb_node_getpath(node, fsrootvp, p, MAXPATHLEN - len);
+ if (err == 0) {
+ vp = smb_lookuppathvptovp(sr, path, fsrootvp, fsrootvp);
if (vp) {
- *vss_cur_node = smb_node_lookup(sr, NULL, kcred, vp,
- gmttoken, cur_node, NULL);
+ *vss_node = smb_node_lookup(sr, NULL, kcred, vp,
+ odname, dnode, NULL);
VN_RELE(vp);
-
- if (*vss_cur_node != NULL) {
- smb_vss_remove_first_token_from_path(buf);
- } else {
- (void) smb_node_release(*vss_root_node);
- err = ENOENT;
- }
- } else {
- (void) smb_node_release(*vss_root_node);
- err = ENOENT;
}
- } else {
- err = ENOENT;
}
-error:
- VN_RELE(fsrootvp);
- kmem_free(rootpath, MAXPATHLEN);
- kmem_free(snapname, MAXNAMELEN);
- kmem_free(nodepath, MAXPATHLEN);
+ kmem_free(path, MAXPATHLEN);
- return (err);
+ if (*vss_node != NULL)
+ return (0);
+
+ return (err ? err : ENOENT);
}
+
static boolean_t
smb_vss_is_gmttoken(const char *s)
{
diff --git a/usr/src/uts/common/fs/smbsrv/smb_write.c b/usr/src/uts/common/fs/smbsrv/smb_write.c
index 2b9d5ffb3c..6894aad7b6 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_write.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_write.c
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/sdt.h>
@@ -317,7 +317,7 @@ smb_com_write_and_unlock(smb_request_t *sr)
(uint64_t)param->rw_count);
if (status != NT_STATUS_SUCCESS) {
smbsr_error(sr, NT_STATUS_RANGE_NOT_LOCKED,
- ERRDOS, ERRnotlocked);
+ ERRDOS, ERROR_NOT_LOCKED);
return (SDRC_ERROR);
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_write_raw.c b/usr/src/uts/common/fs/smbsrv/smb_write_raw.c
index fd9f5a0cc7..b56a2018f7 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_write_raw.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_write_raw.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -421,6 +420,7 @@ smb_handle_write_raw(smb_session_t *session, smb_request_t *sr)
case SMB_SESSION_STATE_OPLOCK_BREAKING:
session->s_state = SMB_SESSION_STATE_WRITE_RAW_ACTIVE;
smb_rwx_rwexit(&session->s_lock);
+ smb_srqueue_waitq_enter(session->s_srqueue);
sr->sr_state = SMB_REQ_STATE_SUBMITTED;
(void) taskq_dispatch(session->s_server->sv_thread_pool,
smb_session_worker, sr, TQ_SLEEP);
diff --git a/usr/src/uts/common/fs/smbsrv/smb_xlate.c b/usr/src/uts/common/fs/smbsrv/smb_xlate.c
deleted file mode 100644
index 7f215bcc1c..0000000000
--- a/usr/src/uts/common/fs/smbsrv/smb_xlate.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <smbsrv/smb_kproto.h>
-
-struct xlate_table {
- int code;
- char *str;
-};
-
-struct xlate_table smb_xlate_com[] = {
- { SMB_COM_CREATE_DIRECTORY, "CREATE_DIRECTORY" },
- { SMB_COM_DELETE_DIRECTORY, "DELETE_DIRECTORY" },
- { SMB_COM_OPEN, "OPEN" },
- { SMB_COM_CREATE, "COM_CREATE" },
- { SMB_COM_CLOSE, "CLOSE" },
- { SMB_COM_FLUSH, "FLUSH" },
- { SMB_COM_DELETE, "DELETE" },
- { SMB_COM_RENAME, "RENAME" },
- { SMB_COM_QUERY_INFORMATION, "QUERY_INFORMATION" },
- { SMB_COM_SET_INFORMATION, "SET_INFORMATION" },
- { SMB_COM_READ, "READ" },
- { SMB_COM_WRITE, "WRITE" },
- { SMB_COM_LOCK_BYTE_RANGE, "LOCK_BYTE_RANGE" },
- { SMB_COM_UNLOCK_BYTE_RANGE, "UNLOCK_BYTE_RANGE" },
- { SMB_COM_CREATE_TEMPORARY, "CREATE_TEMPORARY" },
- { SMB_COM_CREATE_NEW, "CREATE_NEW" },
- { SMB_COM_CHECK_DIRECTORY, "CHECK_DIRECTORY" },
- { SMB_COM_PROCESS_EXIT, "PROCESS_EXIT" },
- { SMB_COM_SEEK, "SEEK" },
- { SMB_COM_LOCK_AND_READ, "LOCK_AND_READ" },
- { SMB_COM_WRITE_AND_UNLOCK, "WRITE_AND_UNLOCK" },
- { SMB_COM_READ_RAW, "READ_RAW" },
- { SMB_COM_READ_MPX, "READ_MPX" },
- { SMB_COM_READ_MPX_SECONDARY, "READ_MPX_SECONDARY" },
- { SMB_COM_WRITE_RAW, "WRITE_RAW" },
- { SMB_COM_WRITE_MPX, "WRITE_MPX" },
- { SMB_COM_WRITE_COMPLETE, "WRITE_COMPLETE" },
- { SMB_COM_SET_INFORMATION2, "SET_INFORMATION2" },
- { SMB_COM_QUERY_INFORMATION2, "QUERY_INFORMATION2" },
- { SMB_COM_LOCKING_ANDX, "LOCKING_ANDX" },
- { SMB_COM_TRANSACTION, "TRANSACTION" },
- { SMB_COM_TRANSACTION_SECONDARY, "TRANSACTION_SECONDARY" },
- { SMB_COM_IOCTL, "IOCTL" },
- { SMB_COM_IOCTL_SECONDARY, "IOCTL_SECONDARY" },
- { SMB_COM_COPY, "COPY" },
- { SMB_COM_MOVE, "MOVE" },
- { SMB_COM_ECHO, "ECHO" },
- { SMB_COM_WRITE_AND_CLOSE, "WRITE_AND_CLOSE" },
- { SMB_COM_OPEN_ANDX, "OPEN_ANDX" },
- { SMB_COM_READ_ANDX, "READ_ANDX" },
- { SMB_COM_WRITE_ANDX, "WRITE_ANDX" },
- { SMB_COM_CLOSE_AND_TREE_DISC, "CLOSE_AND_TREE_DISC" },
- { SMB_COM_TRANSACTION2, "TRANSACTION2" },
- { SMB_COM_TRANSACTION2_SECONDARY, "TRANSACTION2_SECONDARY" },
- { SMB_COM_FIND_CLOSE2, "FIND_CLOSE2" },
- { SMB_COM_FIND_NOTIFY_CLOSE, "FIND_NOTIFY_CLOSE" },
- { SMB_COM_TREE_CONNECT, "TREE_CONNECT" },
- { SMB_COM_TREE_DISCONNECT, "TREE_DISCONNECT" },
- { SMB_COM_NEGOTIATE, "NEGOTIATE" },
- { SMB_COM_SESSION_SETUP_ANDX, "SESSION_SETUP_ANDX" },
- { SMB_COM_LOGOFF_ANDX, "LOGOFF_ANDX" },
- { SMB_COM_TREE_CONNECT_ANDX, "TREE_CONNECT_ANDX" },
- { SMB_COM_QUERY_INFORMATION_DISK, "QUERY_INFORMATION_DISK" },
- { SMB_COM_SEARCH, "SEARCH" },
- { SMB_COM_FIND, "FIND" },
- { SMB_COM_FIND_UNIQUE, "FIND_UNIQUE" },
- { SMB_COM_NT_TRANSACT, "NT_TRANSACT" },
- { SMB_COM_NT_TRANSACT_SECONDARY, "NT_TRANSACT_SECONDARY" },
- { SMB_COM_NT_CREATE_ANDX, "NT_CREATE_ANDX" },
- { SMB_COM_NT_CANCEL, "NT_CANCEL" },
- { SMB_COM_OPEN_PRINT_FILE, "OPEN_PRINT_FILE" },
- { SMB_COM_WRITE_PRINT_FILE, "WRITE_PRINT_FILE" },
- { SMB_COM_CLOSE_PRINT_FILE, "CLOSE_PRINT_FILE" },
- { SMB_COM_GET_PRINT_QUEUE, "GET_PRINT_QUEUE" },
- { 0 }
-};
-
-struct xlate_table smb_xlate_rcls[] = {
- { 0, "SUCCESS" },
- { ERRDOS, "ERRDOS" },
- { ERRSRV, "ERRSRV" },
- { ERRHRD, "ERRHRD" },
- { ERRCMD, "ERRCMD" },
- { 0 }
-};
-
-struct xlate_table smb_xlate_errdos[] = {
- { ERRbadfunc, "ERRbadfunc" },
- { ERRbadfile, "ERRbadfile" },
- { ERRbadpath, "ERRbadpath" },
- { ERRnofids, "ERRnofids" },
- { ERRnoaccess, "ERRnoaccess" },
- { ERRbadfid, "ERRbadfid" },
- { ERRbadmcb, "ERRbadmcb" },
- { ERRnomem, "ERRnomem" },
- { ERRbadmem, "ERRbadmem" },
- { ERRbadenv, "ERRbadenv" },
- { ERRbadformat, "ERRbadformat" },
- { ERRbadaccess, "ERRbadaccess" },
- { ERRbaddata, "ERRbaddata" },
- { ERRbaddrive, "ERRbaddrive" },
- { ERRremcd, "ERRremcd" },
- { ERRdiffdevice, "ERRdiffdevice" },
- { ERRnofiles, "ERRnofiles" },
- { ERRbadshare, "ERRbadshare" },
- { ERRlock, "ERRlock" },
- { ERRfilexists, "ERRfilexists" },
- { ERRbadpipe, "ERRbadpipe" },
- { ERRpipebusy, "ERRpipebusy" },
- { ERRpipeclosing, "ERRpipeclosing" },
- { ERRnotconnected, "ERRnotconnected" },
- { ERRmoredata, "ERRmoredata" },
- { 0 }
-};
-
-struct xlate_table smb_xlate_errsrv[] = {
- { ERRerror, "ERRerror" },
- { ERRbadpw, "ERRbadpw" },
- { ERRaccess, "ERRaccess" },
- { ERRinvnid, "ERRinvnid" },
- { ERRinvnetname, "ERRinvnetname" },
- { ERRinvdevice, "ERRinvdevice" },
- { ERRqfull, "ERRqfull" },
- { ERRqtoobig, "ERRqtoobig" },
- { ERRqeof, "ERRqeof" },
- { ERRinvpfid, "ERRinvpfid" },
- { ERRsmbcmd, "ERRsmbcmd" },
- { ERRsrverror, "ERRsrverror" },
- { ERRfilespecs, "ERRfilespecs" },
- { ERRbadpermits, "ERRbadpermits" },
- { ERRsetattrmode, "ERRsetattrmode" },
- { ERRpaused, "ERRpaused" },
- { ERRmsgoff, "ERRmsgoff" },
- { ERRnoroom, "ERRnoroom" },
- { ERRrmuns, "ERRrmuns" },
- { ERRtimeout, "ERRtimeout" },
- { ERRnoresource, "ERRnoresource" },
- { ERRtoomanyuids, "ERRtoomanyuids" },
- { ERRbaduid, "ERRbaduid" },
- { ERRusempx, "ERRusempx" },
- { ERRusestd, "ERRusestd" },
- { ERRcontmpx, "ERRcontmpx" },
- { ERRnosupport, "ERRnosupport" },
- { 0 }
-};
-
-struct xlate_table smb_xlate_errhrd[] = {
- { ERRnowrite, "ERRnowrite" },
- { ERRbadunit, "ERRbadunit" },
- { ERRnotready, "ERRnotready" },
- { ERRbadcmd, "ERRbadcmd" },
- { ERRdata, "ERRdata" },
- { ERRbadreq, "ERRbadreq" },
- { ERRseek, "ERRseek" },
- { ERRbadmedia, "ERRbadmedia" },
- { ERRbadsector, "ERRbadsector" },
- { ERRnopaper, "ERRnopaper" },
- { ERRwrite, "ERRwrite" },
- { ERRread, "ERRread" },
- { ERRgeneral, "ERRgeneral" },
- { ERRbadshare, "ERRbadshare" },
- { ERRlock, "ERRlock" },
- { ERRwrongdisk, "ERRwrongdisk" },
- { ERRFCBUnavail, "ERRFCBUnavail" },
- { ERRsharebufexc, "ERRsharebufexc" },
- { 0 }
-};
-
-struct xlate_table smb_xlate_dialect[] = {
- { DIALECT_UNKNOWN, "DIALECT_UNKNOWN" },
- { PC_NETWORK_PROGRAM_1_0, "PC NETWORK PROGRAM 1.0" },
- { PCLAN1_0, "PCLAN1.0" },
- { MICROSOFT_NETWORKS_1_03, "MICROSOFT NETWORKS 1.03" },
- { MICROSOFT_NETWORKS_3_0, "MICROSOFT NETWORKS 3.0" },
- { LANMAN1_0, "LANMAN1.0" },
- { LM1_2X002, "LM1.2X002" },
- { DOS_LM1_2X002, "DOS LM1.2X002" },
- { DOS_LANMAN2_1, "DOS LANMAN2.1" },
- { LANMAN2_1, "LANMAN2.1" },
- { Windows_for_Workgroups_3_1a, "Windows for Workgroups 3.1a" },
- { NT_LM_0_12, "NT LM 0.12" },
- { 0 }
-};
-
-static char *
-smb_xlate_cd_to_str(struct xlate_table *xl, int cd)
-{
- static char no_answer[32];
-
- for (; xl->str; xl++)
- if (xl->code == cd)
- return (xl->str);
-
- (void) sprintf(no_answer, "-%x-", cd);
-
- return (no_answer);
-}
-
-static int
-smb_xlate_str_to_cd(struct xlate_table *xl, char *str)
-{
- for (; xl->str; xl++)
- if (strcmp(xl->str, str) == 0)
- return (xl->code);
- return (-1);
-}
-
-
-char *
-smb_xlate_com_cd_to_str(int com)
-{
- return (smb_xlate_cd_to_str(smb_xlate_com, com));
-}
-
-char *
-smb_xlate_dialect_cd_to_str(int dialect)
-{
- return (smb_xlate_cd_to_str(smb_xlate_dialect, dialect));
-}
-
-int
-smb_xlate_dialect_str_to_cd(char *str)
-{
- return (smb_xlate_str_to_cd(smb_xlate_dialect, str));
-}
diff --git a/usr/src/uts/common/idmap/Makefile b/usr/src/uts/common/idmap/Makefile
index e88c7dfbbe..c61cfc7efe 100644
--- a/usr/src/uts/common/idmap/Makefile
+++ b/usr/src/uts/common/idmap/Makefile
@@ -18,8 +18,7 @@
#
# CDDL HEADER END
#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# uts/common/idmap/Makefile
@@ -46,7 +45,7 @@ all_h: $(DERIVED_FILES)
idmap_xdr.c: $(IDMAP_PROT_X)
$(RM) $@
- $(RPCGEN) -CMNc -D_KERNEL -o $@ $(IDMAP_PROT_X)
+ $(RPCGEN) -CMNc -DIDMAP_XDR_MAPPING_ONLY -o $@ $(IDMAP_PROT_X)
check: $(CHECKHDRS)
diff --git a/usr/src/uts/common/netsmb/smb.h b/usr/src/uts/common/netsmb/smb.h
index f0957634cb..e3bfc5144c 100644
--- a/usr/src/uts/common/netsmb/smb.h
+++ b/usr/src/uts/common/netsmb/smb.h
@@ -39,17 +39,23 @@
*/
/*
- * Common definintions and structures for SMB/CIFS protocol
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _NETSMB_SMB_H_
#define _NETSMB_SMB_H_
/*
+ * Common definitions and structures for SMB/CIFS protocol
* This file should be purely SMB protocol definition stuff.
* (Please don't make it a catch-all:)
*/
+#include <smb/doserror.h>
+#include <smb/lmerr.h>
+#include <smb/nterror.h>
+#include <smb/ntstatus.h>
+
/*
* SMB dialects that we have to deal with.
*/
@@ -748,693 +754,6 @@ typedef struct ntsid ntsid_t;
#define SMB_LOCKING_ANDX_CANCEL_LOCK 0x08
#define SMB_LOCKING_ANDX_LARGE_FILES 0x10
-/*
- * Error classes
- */
-#define SMBSUCCESS 0x00
-#define ERRDOS 0x01
-#define ERRSRV 0x02
-#define ERRHRD 0x03 /* Error is an hardware error. */
-#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
-
-/*
- * Error codes for the ERRDOS class
- */
-#define ERRbadfunc 1 /* Invalid function */
-#define ERRbadfile 2 /* File not found (last component) */
-#define ERRbadpath 3 /* Directory invalid */
-#define ERRnofids 4 /* Too many open files */
-#define ERRnoaccess 5 /* Access denied */
-#define ERRbadfid 6 /* Invalid file handle */
-#define ERRbadmcb 7 /* Memory control blocks destroyed (huh ?) */
-#define ERRnomem 8 /* Insufficient memory */
-#define ERRbadmem 9 /* Invalid memory block address */
-#define ERRbadenv 10 /* Invalid environment */
-#define ERRbadformat 11 /* Invalid format */
-#define ERRbadaccess 12 /* Invalid open mode */
-#define ERRbaddata 13 /* Invalid data */
-#define ERRoutofmem 14 /* out of memory */
-#define ERRbaddrive 15 /* Invalid drive specified */
-#define ERRremcd 16 /* An attempt to delete current directory */
-#define ERRdiffdevice 17 /* cross fs rename/move */
-#define ERRnofiles 18 /* no more files found in file search */
-#define ERRwriteprotect 19
-#define ERRnotready 21
-#define ERRbadcmd 22
-#define ERRcrc 23
-#define ERRbadlength 24
-#define ERRsectornotfound 27
-#define ERRbadshare 32 /* Share mode can't be granted */
-#define ERRlock 33 /* Lock conflicts with existing lock */
-#define ERRwrongdisk 34
-#define ERRhandleeof 38
-#define ERRunsup 50 /* unsupported - Win 95 */
-#define ERRnetnamedel 64
-#define ERRnoipc 66 /* ipc unsupported */
-#define ERRnosuchshare 67 /* invalid share name */
-#define ERRtoomanynames 68
-#define ERRfilexists 80 /* requested file name already exists */
-#define ERRinvalidparam 87
-#define ERRcannotopen 110 /* cannot open the file */
-#define ERRinsufficientbuffer 122
-#define ERRinvalidname 123
-#define ERRunknownlevel 124
-#define ERRdirnotempty 145
-#define ERRnotlocked 158 /* region was not locked by this context */
-#define ERRrename 183
-#define ERRbadpipe 230 /* named pipe invalid */
-#define ERRpipebusy 231 /* all pipe instances are busy */
-#define ERRpipeclosing 232 /* close in progress */
-#define ERRnotconnected 233 /* nobody on other end of pipe */
-#define ERRmoredata 234 /* more data to be returned */
-#define ERRnomoreitems 259
-#define ERRbaddirectory 267 /* invalid directory name */
-#define ERReasunsupported 282 /* extended attributes not supported */
-#define ERRlogonfailure 1326
-#define ERRbuftoosmall 2123
-#define ERRunknownipc 2142
-#define ERRnosuchprintjob 2151
-#define ERRinvgroup 2455
-
-/*
- * Error codes for the ERRSRV class
- */
-#define ERRerror 1 /* Non-specific error code */
-#define ERRbadpw 2 /* Bad password */
-#define ERRbadtype 3 /* reserved */
-#define ERRaccess 4 /* client doesn't have enough access rights */
-#define ERRinvnid 5 /* The Tid specified in a command is invalid */
-#define ERRinvnetname 6 /* Invalid server name in the tree connect */
-#define ERRinvdevice 7 /* Printer and not printer devices are mixed */
-#define ERRqfull 49 /* Print queue full */
-#define ERRqtoobig 50 /* Print queue full - no space */
-#define ERRinvpfid 52 /* Invalid print file FID */
-#define ERRsmbcmd 64 /* The server did not recognise the command */
-#define ERRsrverror 65 /* The server encountered and internal error */
-#define ERRfilespecs 67 /* The Fid and path name contains an */
- /* invalid combination */
-#define ERRbadpermits 69 /* Access mode invalid */
-#define ERRsetattrmode 71 /* Attribute mode invalid */
-#define ERRpaused 81 /* Server is paused */
-#define ERRmsgoff 82 /* Not receiving messages */
-#define ERRnoroom 83 /* No room to buffer message */
-#define ERRrmuns 87 /* Too many remote user names */
-#define ERRtimeout 88 /* Operation timed out */
-#define ERRnoresource 89 /* No resources currently available for req */
-#define ERRtoomanyuids 90 /* Too many UIDs active on this session */
-#define ERRbaduid 91 /* The UID is not known in this session */
-#define ERRusempx 250 /* Temporarily unable to support Raw, */
- /* use MPX mode */
-#define ERRusestd 251 /* Temporarily unable to support Raw, */
- /* use stdandard r/w */
-#define ERRcontmpx 252 /* Continue in MPX mode */
-#define ERRacctexpired 2239
-#define ERRnosupport 65535 /* Invalid function */
-
-/*
- * Error codes for the ERRHRD class
- */
-#define ERRnowrite 19 /* write protected media */
-#define ERRbadunit 20 /* Unknown unit */
-#define ERRnotready 21 /* Drive not ready */
-#define ERRbadcmd 22 /* Unknown command */
-#define ERRdata 23 /* Data error (CRC) */
-#define ERRbadreq 24 /* Bad request structure length */
-#define ERRseek 25 /* Seek error */
-#define ERRbadmedia 26 /* Unknown media type */
-#define ERRbadsector 27 /* Sector not found */
-#define ERRnopaper 28 /* Printer out of paper */
-#define ERRwrite 29 /* Write fault */
-#define ERRread 30 /* Read fault */
-#define ERRgeneral 31 /* General failure */
-#define ERRbadshare 32 /* A open conflicts with an existing open */
-#define ERRlock 33 /* lock/unlock conflict */
-#define ERRwrongdisk 34 /* The wrong disk was found in a drive */
-#define ERRFCBunavail 35 /* No FCBs available */
-#define ERRsharebufexc 36 /* A sharing buffer has been exceeded */
-#define ERRdiskfull 39
-
-/*
- * RAP error codes (it seems that they returned not only by RAP)
- */
-#define SMB_ERROR_ACCESS_DENIED 5
-#define SMB_ERROR_NETWORK_ACCESS_DENIED 65
-#define SMB_ERROR_MORE_DATA ERRmoredata
-
-/*
- * An INCOMPLETE list of 32 bit error codes
- * For more detail see MSDN and ntstatus.h in the MS DDK
- *
- * XXX - these should have the severity and "customer defined" fields
- * added back in, and smb_maperr32() shouldn't mask those fields out;
- * 0x80000005 is STATUS_BUFFER_OVERFLOW, with 0xC0000000 is
- * STATUS_ACCESS_VIOLATION, and we need to distinguish between them.
- * We use STATUS_BUFFER_OVERFLOW, and need to know its exact value,
- * so we #define it correctly here; don't strip off the leading
- * 0x80000000 from it!
- */
-#define NT_STATUS_BUFFER_OVERFLOW 0x80000005
-#define NT_STATUS_UNSUCCESSFUL 0x0001
-#define NT_STATUS_NOT_IMPLEMENTED 0x0002
-#define NT_STATUS_INVALID_INFO_CLASS 0x0003
-#define NT_STATUS_INFO_LENGTH_MISMATCH 0x0004
-#define NT_STATUS_ACCESS_VIOLATION 0x0005
-#define NT_STATUS_IN_PAGE_ERROR 0x0006
-#define NT_STATUS_PAGEFILE_QUOTA 0x0007
-#define NT_STATUS_INVALID_HANDLE 0x0008
-#define NT_STATUS_BAD_INITIAL_STACK 0x0009
-#define NT_STATUS_BAD_INITIAL_PC 0x000a
-#define NT_STATUS_INVALID_CID 0x000b
-#define NT_STATUS_TIMER_NOT_CANCELED 0x000c
-#define NT_STATUS_INVALID_PARAMETER 0x000d
-#define NT_STATUS_NO_SUCH_DEVICE 0x000e
-#define NT_STATUS_NO_SUCH_FILE 0x000f
-#define NT_STATUS_INVALID_DEVICE_REQUEST 0x0010
-#define NT_STATUS_END_OF_FILE 0x0011
-#define NT_STATUS_WRONG_VOLUME 0x0012
-#define NT_STATUS_NO_MEDIA_IN_DEVICE 0x0013
-#define NT_STATUS_UNRECOGNIZED_MEDIA 0x0014
-#define NT_STATUS_NONEXISTENT_SECTOR 0x0015
-#define NT_STATUS_MORE_PROCESSING_REQUIRED 0x0016
-#define NT_STATUS_NO_MEMORY 0x0017
-#define NT_STATUS_CONFLICTING_ADDRESSES 0x0018
-#define NT_STATUS_NOT_MAPPED_VIEW 0x0019
-#define NT_STATUS_UNABLE_TO_FREE_VM 0x001a
-#define NT_STATUS_UNABLE_TO_DELETE_SECTION 0x001b
-#define NT_STATUS_INVALID_SYSTEM_SERVICE 0x001c
-#define NT_STATUS_ILLEGAL_INSTRUCTION 0x001d
-#define NT_STATUS_INVALID_LOCK_SEQUENCE 0x001e
-#define NT_STATUS_INVALID_VIEW_SIZE 0x001f
-#define NT_STATUS_INVALID_FILE_FOR_SECTION 0x0020
-#define NT_STATUS_ALREADY_COMMITTED 0x0021
-#define NT_STATUS_ACCESS_DENIED 0x0022
-#define NT_STATUS_BUFFER_TOO_SMALL 0x0023
-#define NT_STATUS_OBJECT_TYPE_MISMATCH 0x0024
-#define NT_STATUS_NONCONTINUABLE_EXCEPTION 0x0025
-#define NT_STATUS_INVALID_DISPOSITION 0x0026
-#define NT_STATUS_UNWIND 0x0027
-#define NT_STATUS_BAD_STACK 0x0028
-#define NT_STATUS_INVALID_UNWIND_TARGET 0x0029
-#define NT_STATUS_NOT_LOCKED 0x002a
-#define NT_STATUS_PARITY_ERROR 0x002b
-#define NT_STATUS_UNABLE_TO_DECOMMIT_VM 0x002c
-#define NT_STATUS_NOT_COMMITTED 0x002d
-#define NT_STATUS_INVALID_PORT_ATTRIBUTES 0x002e
-#define NT_STATUS_PORT_MESSAGE_TOO_LONG 0x002f
-#define NT_STATUS_INVALID_PARAMETER_MIX 0x0030
-#define NT_STATUS_INVALID_QUOTA_LOWER 0x0031
-#define NT_STATUS_DISK_CORRUPT_ERROR 0x0032
-#define NT_STATUS_OBJECT_NAME_INVALID 0x0033
-#define NT_STATUS_OBJECT_NAME_NOT_FOUND 0x0034
-#define NT_STATUS_OBJECT_NAME_COLLISION 0x0035
-#define NT_STATUS_HANDLE_NOT_WAITABLE 0x0036
-#define NT_STATUS_PORT_DISCONNECTED 0x0037
-#define NT_STATUS_DEVICE_ALREADY_ATTACHED 0x0038
-#define NT_STATUS_OBJECT_PATH_INVALID 0x0039
-#define NT_STATUS_OBJECT_PATH_NOT_FOUND 0x003a
-#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD 0x003b
-#define NT_STATUS_DATA_OVERRUN 0x003c
-#define NT_STATUS_DATA_LATE_ERROR 0x003d
-#define NT_STATUS_DATA_ERROR 0x003e
-#define NT_STATUS_CRC_ERROR 0x003f
-#define NT_STATUS_SECTION_TOO_BIG 0x0040
-#define NT_STATUS_PORT_CONNECTION_REFUSED 0x0041
-#define NT_STATUS_INVALID_PORT_HANDLE 0x0042
-#define NT_STATUS_SHARING_VIOLATION 0x0043
-#define NT_STATUS_QUOTA_EXCEEDED 0x0044
-#define NT_STATUS_INVALID_PAGE_PROTECTION 0x0045
-#define NT_STATUS_MUTANT_NOT_OWNED 0x0046
-#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED 0x0047
-#define NT_STATUS_PORT_ALREADY_SET 0x0048
-#define NT_STATUS_SECTION_NOT_IMAGE 0x0049
-#define NT_STATUS_SUSPEND_COUNT_EXCEEDED 0x004a
-#define NT_STATUS_THREAD_IS_TERMINATING 0x004b
-#define NT_STATUS_BAD_WORKING_SET_LIMIT 0x004c
-#define NT_STATUS_INCOMPATIBLE_FILE_MAP 0x004d
-#define NT_STATUS_SECTION_PROTECTION 0x004e
-#define NT_STATUS_EAS_NOT_SUPPORTED 0x004f
-#define NT_STATUS_EA_TOO_LARGE 0x0050
-#define NT_STATUS_NONEXISTENT_EA_ENTRY 0x0051
-#define NT_STATUS_NO_EAS_ON_FILE 0x0052
-#define NT_STATUS_EA_CORRUPT_ERROR 0x0053
-#define NT_STATUS_FILE_LOCK_CONFLICT 0x0054
-#define NT_STATUS_LOCK_NOT_GRANTED 0x0055
-#define NT_STATUS_DELETE_PENDING 0x0056
-#define NT_STATUS_CTL_FILE_NOT_SUPPORTED 0x0057
-#define NT_STATUS_UNKNOWN_REVISION 0x0058
-#define NT_STATUS_REVISION_MISMATCH 0x0059
-#define NT_STATUS_INVALID_OWNER 0x005a
-#define NT_STATUS_INVALID_PRIMARY_GROUP 0x005b
-#define NT_STATUS_NO_IMPERSONATION_TOKEN 0x005c
-#define NT_STATUS_CANT_DISABLE_MANDATORY 0x005d
-#define NT_STATUS_NO_LOGON_SERVERS 0x005e
-#define NT_STATUS_NO_SUCH_LOGON_SESSION 0x005f
-#define NT_STATUS_NO_SUCH_PRIVILEGE 0x0060
-#define NT_STATUS_PRIVILEGE_NOT_HELD 0x0061
-#define NT_STATUS_INVALID_ACCOUNT_NAME 0x0062
-#define NT_STATUS_USER_EXISTS 0x0063
-#define NT_STATUS_NO_SUCH_USER 0x0064
-#define NT_STATUS_GROUP_EXISTS 0x0065
-#define NT_STATUS_NO_SUCH_GROUP 0x0066
-#define NT_STATUS_MEMBER_IN_GROUP 0x0067
-#define NT_STATUS_MEMBER_NOT_IN_GROUP 0x0068
-#define NT_STATUS_LAST_ADMIN 0x0069
-#define NT_STATUS_WRONG_PASSWORD 0x006a
-#define NT_STATUS_ILL_FORMED_PASSWORD 0x006b
-#define NT_STATUS_PASSWORD_RESTRICTION 0x006c
-#define NT_STATUS_LOGON_FAILURE 0x006d
-#define NT_STATUS_ACCOUNT_RESTRICTION 0x006e
-#define NT_STATUS_INVALID_LOGON_HOURS 0x006f
-#define NT_STATUS_INVALID_WORKSTATION 0x0070
-#define NT_STATUS_PASSWORD_EXPIRED 0x0071
-#define NT_STATUS_ACCOUNT_DISABLED 0x0072
-#define NT_STATUS_NONE_MAPPED 0x0073
-#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED 0x0074
-#define NT_STATUS_LUIDS_EXHAUSTED 0x0075
-#define NT_STATUS_INVALID_SUB_AUTHORITY 0x0076
-#define NT_STATUS_INVALID_ACL 0x0077
-#define NT_STATUS_INVALID_SID 0x0078
-#define NT_STATUS_INVALID_SECURITY_DESCR 0x0079
-#define NT_STATUS_PROCEDURE_NOT_FOUND 0x007a
-#define NT_STATUS_INVALID_IMAGE_FORMAT 0x007b
-#define NT_STATUS_NO_TOKEN 0x007c
-#define NT_STATUS_BAD_INHERITANCE_ACL 0x007d
-#define NT_STATUS_RANGE_NOT_LOCKED 0x007e
-#define NT_STATUS_DISK_FULL 0x007f
-#define NT_STATUS_SERVER_DISABLED 0x0080
-#define NT_STATUS_SERVER_NOT_DISABLED 0x0081
-#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED 0x0082
-#define NT_STATUS_GUIDS_EXHAUSTED 0x0083
-#define NT_STATUS_INVALID_ID_AUTHORITY 0x0084
-#define NT_STATUS_AGENTS_EXHAUSTED 0x0085
-#define NT_STATUS_INVALID_VOLUME_LABEL 0x0086
-#define NT_STATUS_SECTION_NOT_EXTENDED 0x0087
-#define NT_STATUS_NOT_MAPPED_DATA 0x0088
-#define NT_STATUS_RESOURCE_DATA_NOT_FOUND 0x0089
-#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND 0x008a
-#define NT_STATUS_RESOURCE_NAME_NOT_FOUND 0x008b
-#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED 0x008c
-#define NT_STATUS_FLOAT_DENORMAL_OPERAND 0x008d
-#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO 0x008e
-#define NT_STATUS_FLOAT_INEXACT_RESULT 0x008f
-#define NT_STATUS_FLOAT_INVALID_OPERATION 0x0090
-#define NT_STATUS_FLOAT_OVERFLOW 0x0091
-#define NT_STATUS_FLOAT_STACK_CHECK 0x0092
-#define NT_STATUS_FLOAT_UNDERFLOW 0x0093
-#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO 0x0094
-#define NT_STATUS_INTEGER_OVERFLOW 0x0095
-#define NT_STATUS_PRIVILEGED_INSTRUCTION 0x0096
-#define NT_STATUS_TOO_MANY_PAGING_FILES 0x0097
-#define NT_STATUS_FILE_INVALID 0x0098
-#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED 0x0099
-#define NT_STATUS_INSUFFICIENT_RESOURCES 0x009a
-#define NT_STATUS_DFS_EXIT_PATH_FOUND 0x009b
-#define NT_STATUS_DEVICE_DATA_ERROR 0x009c
-#define NT_STATUS_DEVICE_NOT_CONNECTED 0x009d
-#define NT_STATUS_DEVICE_POWER_FAILURE 0x009e
-#define NT_STATUS_FREE_VM_NOT_AT_BASE 0x009f
-#define NT_STATUS_MEMORY_NOT_ALLOCATED 0x00a0
-#define NT_STATUS_WORKING_SET_QUOTA 0x00a1
-#define NT_STATUS_MEDIA_WRITE_PROTECTED 0x00a2
-#define NT_STATUS_DEVICE_NOT_READY 0x00a3
-#define NT_STATUS_INVALID_GROUP_ATTRIBUTES 0x00a4
-#define NT_STATUS_BAD_IMPERSONATION_LEVEL 0x00a5
-#define NT_STATUS_CANT_OPEN_ANONYMOUS 0x00a6
-#define NT_STATUS_BAD_VALIDATION_CLASS 0x00a7
-#define NT_STATUS_BAD_TOKEN_TYPE 0x00a8
-#define NT_STATUS_BAD_MASTER_BOOT_RECORD 0x00a9
-#define NT_STATUS_INSTRUCTION_MISALIGNMENT 0x00aa
-#define NT_STATUS_INSTANCE_NOT_AVAILABLE 0x00ab
-#define NT_STATUS_PIPE_NOT_AVAILABLE 0x00ac
-#define NT_STATUS_INVALID_PIPE_STATE 0x00ad
-#define NT_STATUS_PIPE_BUSY 0x00ae
-#define NT_STATUS_ILLEGAL_FUNCTION 0x00af
-#define NT_STATUS_PIPE_DISCONNECTED 0x00b0
-#define NT_STATUS_PIPE_CLOSING 0x00b1
-#define NT_STATUS_PIPE_CONNECTED 0x00b2
-#define NT_STATUS_PIPE_LISTENING 0x00b3
-#define NT_STATUS_INVALID_READ_MODE 0x00b4
-#define NT_STATUS_IO_TIMEOUT 0x00b5
-#define NT_STATUS_FILE_FORCED_CLOSED 0x00b6
-#define NT_STATUS_PROFILING_NOT_STARTED 0x00b7
-#define NT_STATUS_PROFILING_NOT_STOPPED 0x00b8
-#define NT_STATUS_COULD_NOT_INTERPRET 0x00b9
-#define NT_STATUS_FILE_IS_A_DIRECTORY 0x00ba
-#define NT_STATUS_NOT_SUPPORTED 0x00bb
-#define NT_STATUS_REMOTE_NOT_LISTENING 0x00bc
-#define NT_STATUS_DUPLICATE_NAME 0x00bd
-#define NT_STATUS_BAD_NETWORK_PATH 0x00be
-#define NT_STATUS_NETWORK_BUSY 0x00bf
-#define NT_STATUS_DEVICE_DOES_NOT_EXIST 0x00c0
-#define NT_STATUS_TOO_MANY_COMMANDS 0x00c1
-#define NT_STATUS_ADAPTER_HARDWARE_ERROR 0x00c2
-#define NT_STATUS_INVALID_NETWORK_RESPONSE 0x00c3
-#define NT_STATUS_UNEXPECTED_NETWORK_ERROR 0x00c4
-#define NT_STATUS_BAD_REMOTE_ADAPTER 0x00c5
-#define NT_STATUS_PRINT_QUEUE_FULL 0x00c6
-#define NT_STATUS_NO_SPOOL_SPACE 0x00c7
-#define NT_STATUS_PRINT_CANCELLED 0x00c8
-#define NT_STATUS_NETWORK_NAME_DELETED 0x00c9
-#define NT_STATUS_NETWORK_ACCESS_DENIED 0x00ca
-#define NT_STATUS_BAD_DEVICE_TYPE 0x00cb
-#define NT_STATUS_BAD_NETWORK_NAME 0x00cc
-#define NT_STATUS_TOO_MANY_NAMES 0x00cd
-#define NT_STATUS_TOO_MANY_SESSIONS 0x00ce
-#define NT_STATUS_SHARING_PAUSED 0x00cf
-#define NT_STATUS_REQUEST_NOT_ACCEPTED 0x00d0
-#define NT_STATUS_REDIRECTOR_PAUSED 0x00d1
-#define NT_STATUS_NET_WRITE_FAULT 0x00d2
-#define NT_STATUS_PROFILING_AT_LIMIT 0x00d3
-#define NT_STATUS_NOT_SAME_DEVICE 0x00d4
-#define NT_STATUS_FILE_RENAMED 0x00d5
-#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED 0x00d6
-#define NT_STATUS_NO_SECURITY_ON_OBJECT 0x00d7
-#define NT_STATUS_CANT_WAIT 0x00d8
-#define NT_STATUS_PIPE_EMPTY 0x00d9
-#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO 0x00da
-#define NT_STATUS_CANT_TERMINATE_SELF 0x00db
-#define NT_STATUS_INVALID_SERVER_STATE 0x00dc
-#define NT_STATUS_INVALID_DOMAIN_STATE 0x00dd
-#define NT_STATUS_INVALID_DOMAIN_ROLE 0x00de
-#define NT_STATUS_NO_SUCH_DOMAIN 0x00df
-#define NT_STATUS_DOMAIN_EXISTS 0x00e0
-#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED 0x00e1
-#define NT_STATUS_OPLOCK_NOT_GRANTED 0x00e2
-#define NT_STATUS_INVALID_OPLOCK_PROTOCOL 0x00e3
-#define NT_STATUS_INTERNAL_DB_CORRUPTION 0x00e4
-#define NT_STATUS_INTERNAL_ERROR 0x00e5
-#define NT_STATUS_GENERIC_NOT_MAPPED 0x00e6
-#define NT_STATUS_BAD_DESCRIPTOR_FORMAT 0x00e7
-#define NT_STATUS_INVALID_USER_BUFFER 0x00e8
-#define NT_STATUS_UNEXPECTED_IO_ERROR 0x00e9
-#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR 0x00ea
-#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR 0x00eb
-#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR 0x00ec
-#define NT_STATUS_NOT_LOGON_PROCESS 0x00ed
-#define NT_STATUS_LOGON_SESSION_EXISTS 0x00ee
-#define NT_STATUS_INVALID_PARAMETER_1 0x00ef
-#define NT_STATUS_INVALID_PARAMETER_2 0x00f0
-#define NT_STATUS_INVALID_PARAMETER_3 0x00f1
-#define NT_STATUS_INVALID_PARAMETER_4 0x00f2
-#define NT_STATUS_INVALID_PARAMETER_5 0x00f3
-#define NT_STATUS_INVALID_PARAMETER_6 0x00f4
-#define NT_STATUS_INVALID_PARAMETER_7 0x00f5
-#define NT_STATUS_INVALID_PARAMETER_8 0x00f6
-#define NT_STATUS_INVALID_PARAMETER_9 0x00f7
-#define NT_STATUS_INVALID_PARAMETER_10 0x00f8
-#define NT_STATUS_INVALID_PARAMETER_11 0x00f9
-#define NT_STATUS_INVALID_PARAMETER_12 0x00fa
-#define NT_STATUS_REDIRECTOR_NOT_STARTED 0x00fb
-#define NT_STATUS_REDIRECTOR_STARTED 0x00fc
-#define NT_STATUS_STACK_OVERFLOW 0x00fd
-#define NT_STATUS_NO_SUCH_PACKAGE 0x00fe
-#define NT_STATUS_BAD_FUNCTION_TABLE 0x00ff
-#define NT_STATUS_VARIABLE_NOT_FOUND 0x0100
-#define NT_STATUS_DIRECTORY_NOT_EMPTY 0x0101
-#define NT_STATUS_FILE_CORRUPT_ERROR 0x0102
-#define NT_STATUS_NOT_A_DIRECTORY 0x0103
-#define NT_STATUS_BAD_LOGON_SESSION_STATE 0x0104
-#define NT_STATUS_LOGON_SESSION_COLLISION 0x0105
-#define NT_STATUS_NAME_TOO_LONG 0x0106
-#define NT_STATUS_FILES_OPEN 0x0107
-#define NT_STATUS_CONNECTION_IN_USE 0x0108
-#define NT_STATUS_MESSAGE_NOT_FOUND 0x0109
-#define NT_STATUS_PROCESS_IS_TERMINATING 0x010a
-#define NT_STATUS_INVALID_LOGON_TYPE 0x010b
-#define NT_STATUS_NO_GUID_TRANSLATION 0x010c
-#define NT_STATUS_CANNOT_IMPERSONATE 0x010d
-#define NT_STATUS_IMAGE_ALREADY_LOADED 0x010e
-#define NT_STATUS_ABIOS_NOT_PRESENT 0x010f
-#define NT_STATUS_ABIOS_LID_NOT_EXIST 0x0110
-#define NT_STATUS_ABIOS_LID_ALREADY_OWNED 0x0111
-#define NT_STATUS_ABIOS_NOT_LID_OWNER 0x0112
-#define NT_STATUS_ABIOS_INVALID_COMMAND 0x0113
-#define NT_STATUS_ABIOS_INVALID_LID 0x0114
-#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE 0x0115
-#define NT_STATUS_ABIOS_INVALID_SELECTOR 0x0116
-#define NT_STATUS_NO_LDT 0x0117
-#define NT_STATUS_INVALID_LDT_SIZE 0x0118
-#define NT_STATUS_INVALID_LDT_OFFSET 0x0119
-#define NT_STATUS_INVALID_LDT_DESCRIPTOR 0x011a
-#define NT_STATUS_INVALID_IMAGE_NE_FORMAT 0x011b
-#define NT_STATUS_RXACT_INVALID_STATE 0x011c
-#define NT_STATUS_RXACT_COMMIT_FAILURE 0x011d
-#define NT_STATUS_MAPPED_FILE_SIZE_ZERO 0x011e
-#define NT_STATUS_TOO_MANY_OPENED_FILES 0x011f
-#define NT_STATUS_CANCELLED 0x0120
-#define NT_STATUS_CANNOT_DELETE 0x0121
-#define NT_STATUS_INVALID_COMPUTER_NAME 0x0122
-#define NT_STATUS_FILE_DELETED 0x0123
-#define NT_STATUS_SPECIAL_ACCOUNT 0x0124
-#define NT_STATUS_SPECIAL_GROUP 0x0125
-#define NT_STATUS_SPECIAL_USER 0x0126
-#define NT_STATUS_MEMBERS_PRIMARY_GROUP 0x0127
-#define NT_STATUS_FILE_CLOSED 0x0128
-#define NT_STATUS_TOO_MANY_THREADS 0x0129
-#define NT_STATUS_THREAD_NOT_IN_PROCESS 0x012a
-#define NT_STATUS_TOKEN_ALREADY_IN_USE 0x012b
-#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED 0x012c
-#define NT_STATUS_COMMITMENT_LIMIT 0x012d
-#define NT_STATUS_INVALID_IMAGE_LE_FORMAT 0x012e
-#define NT_STATUS_INVALID_IMAGE_NOT_MZ 0x012f
-#define NT_STATUS_INVALID_IMAGE_PROTECT 0x0130
-#define NT_STATUS_INVALID_IMAGE_WIN_16 0x0131
-#define NT_STATUS_LOGON_SERVER_CONFLICT 0x0132
-#define NT_STATUS_TIME_DIFFERENCE_AT_DC 0x0133
-#define NT_STATUS_SYNCHRONIZATION_REQUIRED 0x0134
-#define NT_STATUS_DLL_NOT_FOUND 0x0135
-#define NT_STATUS_OPEN_FAILED 0x0136
-#define NT_STATUS_IO_PRIVILEGE_FAILED 0x0137
-#define NT_STATUS_ORDINAL_NOT_FOUND 0x0138
-#define NT_STATUS_ENTRYPOINT_NOT_FOUND 0x0139
-#define NT_STATUS_CONTROL_C_EXIT 0x013a
-#define NT_STATUS_LOCAL_DISCONNECT 0x013b
-#define NT_STATUS_REMOTE_DISCONNECT 0x013c
-#define NT_STATUS_REMOTE_RESOURCES 0x013d
-#define NT_STATUS_LINK_FAILED 0x013e
-#define NT_STATUS_LINK_TIMEOUT 0x013f
-#define NT_STATUS_INVALID_CONNECTION 0x0140
-#define NT_STATUS_INVALID_ADDRESS 0x0141
-#define NT_STATUS_DLL_INIT_FAILED 0x0142
-#define NT_STATUS_MISSING_SYSTEMFILE 0x0143
-#define NT_STATUS_UNHANDLED_EXCEPTION 0x0144
-#define NT_STATUS_APP_INIT_FAILURE 0x0145
-#define NT_STATUS_PAGEFILE_CREATE_FAILED 0x0146
-#define NT_STATUS_NO_PAGEFILE 0x0147
-#define NT_STATUS_INVALID_LEVEL 0x0148
-#define NT_STATUS_WRONG_PASSWORD_CORE 0x0149
-#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT 0x014a
-#define NT_STATUS_PIPE_BROKEN 0x014b
-#define NT_STATUS_REGISTRY_CORRUPT 0x014c
-#define NT_STATUS_REGISTRY_IO_FAILED 0x014d
-#define NT_STATUS_NO_EVENT_PAIR 0x014e
-#define NT_STATUS_UNRECOGNIZED_VOLUME 0x014f
-#define NT_STATUS_SERIAL_NO_DEVICE_INITED 0x0150
-#define NT_STATUS_NO_SUCH_ALIAS 0x0151
-#define NT_STATUS_MEMBER_NOT_IN_ALIAS 0x0152
-#define NT_STATUS_MEMBER_IN_ALIAS 0x0153
-#define NT_STATUS_ALIAS_EXISTS 0x0154
-#define NT_STATUS_LOGON_NOT_GRANTED 0x0155
-#define NT_STATUS_TOO_MANY_SECRETS 0x0156
-#define NT_STATUS_SECRET_TOO_LONG 0x0157
-#define NT_STATUS_INTERNAL_DB_ERROR 0x0158
-#define NT_STATUS_FULLSCREEN_MODE 0x0159
-#define NT_STATUS_TOO_MANY_CONTEXT_IDS 0x015a
-#define NT_STATUS_LOGON_TYPE_NOT_GRANTED 0x015b
-#define NT_STATUS_NOT_REGISTRY_FILE 0x015c
-#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED 0x015d
-#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR 0x015e
-#define NT_STATUS_FT_MISSING_MEMBER 0x015f
-#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY 0x0160
-#define NT_STATUS_ILLEGAL_CHARACTER 0x0161
-#define NT_STATUS_UNMAPPABLE_CHARACTER 0x0162
-#define NT_STATUS_UNDEFINED_CHARACTER 0x0163
-#define NT_STATUS_FLOPPY_VOLUME 0x0164
-#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND 0x0165
-#define NT_STATUS_FLOPPY_WRONG_CYLINDER 0x0166
-#define NT_STATUS_FLOPPY_UNKNOWN_ERROR 0x0167
-#define NT_STATUS_FLOPPY_BAD_REGISTERS 0x0168
-#define NT_STATUS_DISK_RECALIBRATE_FAILED 0x0169
-#define NT_STATUS_DISK_OPERATION_FAILED 0x016a
-#define NT_STATUS_DISK_RESET_FAILED 0x016b
-#define NT_STATUS_SHARED_IRQ_BUSY 0x016c
-#define NT_STATUS_FT_ORPHANING 0x016d
-#define NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT 0x016e
-#define NT_STATUS_16F 0x016f
-#define NT_STATUS_170 0x0170
-#define NT_STATUS_171 0x0171
-#define NT_STATUS_PARTITION_FAILURE 0x0172
-#define NT_STATUS_INVALID_BLOCK_LENGTH 0x0173
-#define NT_STATUS_DEVICE_NOT_PARTITIONED 0x0174
-#define NT_STATUS_UNABLE_TO_LOCK_MEDIA 0x0175
-#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA 0x0176
-#define NT_STATUS_EOM_OVERFLOW 0x0177
-#define NT_STATUS_NO_MEDIA 0x0178
-#define NT_STATUS_179 0x0179
-#define NT_STATUS_NO_SUCH_MEMBER 0x017a
-#define NT_STATUS_INVALID_MEMBER 0x017b
-#define NT_STATUS_KEY_DELETED 0x017c
-#define NT_STATUS_NO_LOG_SPACE 0x017d
-#define NT_STATUS_TOO_MANY_SIDS 0x017e
-#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0x017f
-#define NT_STATUS_KEY_HAS_CHILDREN 0x0180
-#define NT_STATUS_CHILD_MUST_BE_VOLATILE 0x0181
-#define NT_STATUS_DEVICE_CONFIGURATION_ERROR 0x0182
-#define NT_STATUS_DRIVER_INTERNAL_ERROR 0x0183
-#define NT_STATUS_INVALID_DEVICE_STATE 0x0184
-#define NT_STATUS_IO_DEVICE_ERROR 0x0185
-#define NT_STATUS_DEVICE_PROTOCOL_ERROR 0x0186
-#define NT_STATUS_BACKUP_CONTROLLER 0x0187
-#define NT_STATUS_LOG_FILE_FULL 0x0188
-#define NT_STATUS_TOO_LATE 0x0189
-#define NT_STATUS_NO_TRUST_LSA_SECRET 0x018a
-#define NT_STATUS_NO_TRUST_SAM_ACCOUNT 0x018b
-#define NT_STATUS_TRUSTED_DOMAIN_FAILURE 0x018c
-#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE 0x018d
-#define NT_STATUS_EVENTLOG_FILE_CORRUPT 0x018e
-#define NT_STATUS_EVENTLOG_CANT_START 0x018f
-#define NT_STATUS_TRUST_FAILURE 0x0190
-#define NT_STATUS_MUTANT_LIMIT_EXCEEDED 0x0191
-#define NT_STATUS_NETLOGON_NOT_STARTED 0x0192
-#define NT_STATUS_ACCOUNT_EXPIRED 0x0193
-#define NT_STATUS_POSSIBLE_DEADLOCK 0x0194
-#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT 0x0195
-#define NT_STATUS_REMOTE_SESSION_LIMIT 0x0196
-#define NT_STATUS_EVENTLOG_FILE_CHANGED 0x0197
-#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0x0198
-#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0x0199
-#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0x019a
-#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT 0x019b
-#define NT_STATUS_FS_DRIVER_REQUIRED 0x019c
-#define NT_STATUS_NO_USER_SESSION_KEY 0x0202
-#define NT_STATUS_USER_SESSION_DELETED 0x0203
-#define NT_STATUS_RESOURCE_LANG_NOT_FOUND 0x0204
-#define NT_STATUS_INSUFF_SERVER_RESOURCES 0x0205
-#define NT_STATUS_INVALID_BUFFER_SIZE 0x0206
-#define NT_STATUS_INVALID_ADDRESS_COMPONENT 0x0207
-#define NT_STATUS_INVALID_ADDRESS_WILDCARD 0x0208
-#define NT_STATUS_TOO_MANY_ADDRESSES 0x0209
-#define NT_STATUS_ADDRESS_ALREADY_EXISTS 0x020a
-#define NT_STATUS_ADDRESS_CLOSED 0x020b
-#define NT_STATUS_CONNECTION_DISCONNECTED 0x020c
-#define NT_STATUS_CONNECTION_RESET 0x020d
-#define NT_STATUS_TOO_MANY_NODES 0x020e
-#define NT_STATUS_TRANSACTION_ABORTED 0x020f
-#define NT_STATUS_TRANSACTION_TIMED_OUT 0x0210
-#define NT_STATUS_TRANSACTION_NO_RELEASE 0x0211
-#define NT_STATUS_TRANSACTION_NO_MATCH 0x0212
-#define NT_STATUS_TRANSACTION_RESPONDED 0x0213
-#define NT_STATUS_TRANSACTION_INVALID_ID 0x0214
-#define NT_STATUS_TRANSACTION_INVALID_TYPE 0x0215
-#define NT_STATUS_NOT_SERVER_SESSION 0x0216
-#define NT_STATUS_NOT_CLIENT_SESSION 0x0217
-#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE 0x0218
-#define NT_STATUS_DEBUG_ATTACH_FAILED 0x0219
-#define NT_STATUS_SYSTEM_PROCESS_TERMINATED 0x021a
-#define NT_STATUS_DATA_NOT_ACCEPTED 0x021b
-#define NT_STATUS_NO_BROWSER_SERVERS_FOUND 0x021c
-#define NT_STATUS_VDM_HARD_ERROR 0x021d
-#define NT_STATUS_DRIVER_CANCEL_TIMEOUT 0x021e
-#define NT_STATUS_REPLY_MESSAGE_MISMATCH 0x021f
-#define NT_STATUS_MAPPED_ALIGNMENT 0x0220
-#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH 0x0221
-#define NT_STATUS_LOST_WRITEBEHIND_DATA 0x0222
-#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID 0x0223
-#define NT_STATUS_PASSWORD_MUST_CHANGE 0x0224
-#define NT_STATUS_NOT_FOUND 0x0225
-#define NT_STATUS_NOT_TINY_STREAM 0x0226
-#define NT_STATUS_RECOVERY_FAILURE 0x0227
-#define NT_STATUS_STACK_OVERFLOW_READ 0x0228
-#define NT_STATUS_FAIL_CHECK 0x0229
-#define NT_STATUS_DUPLICATE_OBJECTID 0x022a
-#define NT_STATUS_OBJECTID_EXISTS 0x022b
-#define NT_STATUS_CONVERT_TO_LARGE 0x022c
-#define NT_STATUS_RETRY 0x022d
-#define NT_STATUS_FOUND_OUT_OF_SCOPE 0x022e
-#define NT_STATUS_ALLOCATE_BUCKET 0x022f
-#define NT_STATUS_PROPSET_NOT_FOUND 0x0230
-#define NT_STATUS_MARSHALL_OVERFLOW 0x0231
-#define NT_STATUS_INVALID_VARIANT 0x0232
-#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND 0x0233
-#define NT_STATUS_ACCOUNT_LOCKED_OUT 0x0234
-#define NT_STATUS_HANDLE_NOT_CLOSABLE 0x0235
-#define NT_STATUS_CONNECTION_REFUSED 0x0236
-#define NT_STATUS_GRACEFUL_DISCONNECT 0x0237
-#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED 0x0238
-#define NT_STATUS_ADDRESS_NOT_ASSOCIATED 0x0239
-#define NT_STATUS_CONNECTION_INVALID 0x023a
-#define NT_STATUS_CONNECTION_ACTIVE 0x023b
-#define NT_STATUS_NETWORK_UNREACHABLE 0x023c
-#define NT_STATUS_HOST_UNREACHABLE 0x023d
-#define NT_STATUS_PROTOCOL_UNREACHABLE 0x023e
-#define NT_STATUS_PORT_UNREACHABLE 0x023f
-#define NT_STATUS_REQUEST_ABORTED 0x0240
-#define NT_STATUS_CONNECTION_ABORTED 0x0241
-#define NT_STATUS_BAD_COMPRESSION_BUFFER 0x0242
-#define NT_STATUS_USER_MAPPED_FILE 0x0243
-#define NT_STATUS_AUDIT_FAILED 0x0244
-#define NT_STATUS_TIMER_RESOLUTION_NOT_SET 0x0245
-#define NT_STATUS_CONNECTION_COUNT_LIMIT 0x0246
-#define NT_STATUS_LOGIN_TIME_RESTRICTION 0x0247
-#define NT_STATUS_LOGIN_WKSTA_RESTRICTION 0x0248
-#define NT_STATUS_IMAGE_MP_UP_MISMATCH 0x0249
-#define NT_STATUS_INSUFFICIENT_LOGON_INFO 0x0250
-#define NT_STATUS_BAD_DLL_ENTRYPOINT 0x0251
-#define NT_STATUS_BAD_SERVICE_ENTRYPOINT 0x0252
-#define NT_STATUS_LPC_REPLY_LOST 0x0253
-#define NT_STATUS_IP_ADDRESS_CONFLICT1 0x0254
-#define NT_STATUS_IP_ADDRESS_CONFLICT2 0x0255
-#define NT_STATUS_REGISTRY_QUOTA_LIMIT 0x0256
-#define NT_STATUS_PATH_NOT_COVERED 0x0257
-#define NT_STATUS_NO_CALLBACK_ACTIVE 0x0258
-#define NT_STATUS_LICENSE_QUOTA_EXCEEDED 0x0259
-#define NT_STATUS_PWD_TOO_SHORT 0x025a
-#define NT_STATUS_PWD_TOO_RECENT 0x025b
-#define NT_STATUS_PWD_HISTORY_CONFLICT 0x025c
-#define NT_STATUS_PLUGPLAY_NO_DEVICE 0x025e
-#define NT_STATUS_UNSUPPORTED_COMPRESSION 0x025f
-#define NT_STATUS_INVALID_HW_PROFILE 0x0260
-#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH 0x0261
-#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND 0x0262
-#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND 0x0263
-#define NT_STATUS_RESOURCE_NOT_OWNED 0x0264
-#define NT_STATUS_TOO_MANY_LINKS 0x0265
-#define NT_STATUS_QUOTA_LIST_INCONSISTENT 0x0266
-#define NT_STATUS_FILE_IS_OFFLINE 0x0267
-
-#define NT_STATUS_LICENSE_VIOLATION 0x026a
-
-#define NT_STATUS_DFS_UNAVAILABLE 0x026d
-#define NT_STATUS_VOLUME_DISMOUNTED 0x026e
-
-#define NT_STATUS_NOT_A_REPARSE_POINT 0x0275
-
-#define NT_STATUS_REPARSE_POINT_NOT_RESOLVED 0x0280
-#define NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT 0x0281
-
-#define NT_STATUS_ENCRYPTION_FAILED 0x028a
-#define NT_STATUS_DECRYPTION_FAILED 0x028b
-#define NT_STATUS_RANGE_NOT_FOUND 0x028c
-#define NT_STATUS_NO_RECOVERY_POLICY 0x028d
-#define NT_STATUS_NO_EFS 0x028e
-#define NT_STATUS_WRONG_EFS 0x028f
-#define NT_STATUS_NO_USER_KEYS 0x0290
-#define NT_STATUS_FILE_NOT_ENCRYPTED 0x0291
-
-#define NT_STATUS_FILE_ENCRYPTED 0x0293
-
-#define NT_STATUS_VOLUME_NOT_UPGRADED 0x029c
-
-#define NT_STATUS_KDC_CERT_EXPIRED 0x040e
-/*
- * 0x00010000-0x0001ffff are "DBG" errors
- * 0x00020000-0x0003ffff are "RPC" errors
- * 0x00040000-0x0004ffff are "PNP" errors
- * 0x000A0000-0x000Affff are "CTX" errors
- * 0x00130000-0x0013ffff are "CLUSTER" errors
- * 0x00140000-0x0014ffff are "ACPI" errors
- * 0x00150000-0x0015ffff are "SXS" errors
- */
/*
* size of the GUID returned in an extended security negotiate response
diff --git a/usr/src/uts/common/rpcsvc/idmap_prot.x b/usr/src/uts/common/rpcsvc/idmap_prot.x
index 2028bcf434..4729ab43e7 100644
--- a/usr/src/uts/common/rpcsvc/idmap_prot.x
+++ b/usr/src/uts/common/rpcsvc/idmap_prot.x
@@ -19,10 +19,122 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
+%#if defined(_KERNEL)
+%#include <sys/nvpair.h>
+%#else
+%#include <libnvpair.h>
+%#endif
+
+/*
+ * XDR support for nvlist_t. libnvpair includes support for serializing
+ * an nvlist, but does not include any direct XDR plug-in support. Support
+ * is made trickier by the fact that on read xdr_pointer() wants to allocate
+ * structures on its own, even when there's a custom xdr_*() function for
+ * the structure. nvlist_unpack *also* wants to allocate the nvlist_t,
+ * and it seems wrong to burn sizeof(nvlist_t) into the program binary.
+ *
+ * Another possibility is to use opaque<> in this declaration, but that
+ * requires moving part of the encoding (the interaction with nvlist_pack
+ * and nvlist_unpack) out into the application, instead of keeping it
+ * all encapsulated in this layer.
+ *
+ * The resolution here is to put an nvlist_t * into a new typedef, and have
+ * *that* typedef have a custom xdr_*() function. xdr allocates space for
+ * the pointer, but leaves all initialization of it nvlist_t *) to the
+ * custom function.
+ */
+#if defined(RPC_HDR)
+%typedef nvlist_t *nvlist_t_ptr;
+#endif
+
+#if defined(RPC_XDR)
+%#if !defined(_KERNEL)
+%#include <string.h>
+%#include <stdio.h>
+%#endif
+%
+%bool_t
+%xdr_nvlist_t_ptr(XDR *xdrs, nvlist_t_ptr *n)
+%{
+% char *buf;
+% u_int len;
+% bool_t ret;
+% int err;
+% size_t sz;
+% bool_t present;
+%
+% switch (xdrs->x_op) {
+% case XDR_DECODE:
+% if (!xdr_bool(xdrs, &present))
+% return (FALSE);
+% if (!present) {
+% *n = NULL;
+% return (TRUE);
+% }
+% buf = NULL;
+% if (!xdr_bytes(xdrs, &buf, &len, ~0))
+% return (FALSE);
+%
+% err = nvlist_unpack(buf, (size_t)len, n, 0);
+%#if defined(_KERNEL)
+% kmem_free(buf, len);
+%#else
+% free(buf);
+%#endif
+%
+% if (err != 0) {
+%#if !defined(_KERNEL)
+% fprintf(stderr, "xdr_nvlist_t unpack: %s\n",
+% strerror(err));
+%#endif
+% return (FALSE);
+% }
+% return (TRUE);
+%
+% case XDR_ENCODE:
+% present = (*n != NULL);
+% if (!xdr_bool(xdrs, &present))
+% return (FALSE);
+% if (!present)
+% return (TRUE);
+% buf = NULL;
+% err = nvlist_pack(*n, &buf, &sz, NV_ENCODE_XDR, 0);
+% if (err != 0) {
+%#if !defined(_KERNEL)
+% fprintf(stderr, "xdr_nvlist_t pack: %s\n",
+% strerror(err));
+%#endif
+% return (FALSE);
+% }
+%
+% /* nvlist_pack() and xdr_bytes() want different types */
+% len = (u_int) sz;
+%
+% ret = xdr_bytes(xdrs, &buf, &len, ~0);
+%#if defined(_KERNEL)
+% kmem_free(buf, len);
+%#else
+% free(buf);
+%#endif
+%
+% return (ret);
+%
+% case XDR_FREE:
+% if (*n != NULL) {
+% nvlist_free(*n);
+% *n = NULL;
+% }
+% return (TRUE);
+%
+% default:
+% return (FALSE);
+% }
+%}
+#endif
+
/* opaque type to support non-ASCII strings */
typedef string idmap_utf8str<>;
typedef idmap_utf8str idmap_utf8str_list<>;
@@ -119,6 +231,7 @@ union idmap_how switch(idmap_map_type map_type) {
struct idmap_info {
idmap_map_src src;
idmap_how how;
+ nvlist_t_ptr trace;
};
@@ -160,6 +273,9 @@ const IDMAP_REQ_FLG_MAPPING_INFO = 0x00000008;
/* Request mapping for well-known or local SIDs only */
const IDMAP_REQ_FLG_WK_OR_LOCAL_SIDS_ONLY = 0x00000020;
+/* Request trace of mapping process */
+const IDMAP_REQ_FLG_TRACE = 0x00000040;
+
/*
* Mapping direction definitions
@@ -185,6 +301,7 @@ struct idmap_mapping {
typedef idmap_mapping idmap_mapping_batch<>;
+#ifndef IDMAP_XDR_MAPPING_ONLY
struct idmap_mappings_res {
idmap_retcode retcode;
uint64_t lastrowid;
@@ -218,7 +335,6 @@ typedef idmap_update_op idmap_update_batch<>;
const AD_DISC_MAXHOSTNAME = 256;
-#ifndef _KERNEL
struct idmap_ad_disc_ds_t {
int port;
int priority;
@@ -269,7 +385,6 @@ struct idmap_prop_res {
idmap_prop_val value;
bool auto_discovered;
};
-#endif
enum idmap_flush_op {
IDMAP_FLUSH_EXPIRE = 0,
@@ -345,16 +460,20 @@ union directory_results_rpc switch (bool failed) {
case FALSE:
directory_entry_rpc entries<>;
};
+#endif /* IDMAP_XDR_MAPPING_ONLY */
program IDMAP_PROG {
version IDMAP_V1 {
+#ifndef IDMAP_XDR_MAPPING_ONLY
void
IDMAP_NULL(void) = 0;
+#endif /* IDMAP_XDR_MAPPING_ONLY */
/* Batch of requests to get mapped identities */
idmap_ids_res
IDMAP_GET_MAPPED_IDS(idmap_mapping_batch batch) = 1;
+#ifndef IDMAP_XDR_MAPPING_ONLY
/* List all identity mappings */
idmap_mappings_res
IDMAP_LIST_MAPPINGS(int64_t lastrowid,
@@ -373,11 +492,10 @@ program IDMAP_PROG {
idmap_mappings_res
IDMAP_GET_MAPPED_ID_BY_NAME(idmap_mapping request) = 5;
-#ifndef _KERNEL
/* Get configuration property */
idmap_prop_res
IDMAP_GET_PROP(idmap_prop_type) = 6;
-#endif
+
/*
* Retrieve directory information about a list of users
* or groups by name or SID.
@@ -402,5 +520,6 @@ program IDMAP_PROG {
idmap_retcode
IDMAP_FLUSH(idmap_flush_op) = 8;
+#endif /* IDMAP_XDR_MAPPING_ONLY */
} = 1;
} = 100172;
diff --git a/usr/src/uts/common/smb/Makefile b/usr/src/uts/common/smb/Makefile
new file mode 100644
index 0000000000..2efb11c19c
--- /dev/null
+++ b/usr/src/uts/common/smb/Makefile
@@ -0,0 +1,51 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../../../Makefile.master
+
+HDRS= \
+ doserror.h \
+ lmerr.h \
+ nterror.h \
+ ntstatus.h
+
+
+ROOTDIR= $(ROOT)/usr/include/smb
+ROOTHDRS= $(HDRS:%=$(ROOTDIR)/%)
+CHECKHDRS= $(HDRS:%.h=%.check)
+
+$(ROOTDIR)/%: %
+ $(INS.file)
+
+$(ROOTDIR):
+ $(INS.dir)
+
+.KEEP_STATE:
+
+.PARALLEL: $(CHECKHDRS)
+
+install_h: $(ROOTDIR) $(ROOTHDRS)
+
+check: $(CHECKHDRS)
diff --git a/usr/src/uts/common/smb/doserror.h b/usr/src/uts/common/smb/doserror.h
new file mode 100644
index 0000000000..63e2180519
--- /dev/null
+++ b/usr/src/uts/common/smb/doserror.h
@@ -0,0 +1,149 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _SMB_DOSERROR_H
+#define _SMB_DOSERROR_H
+
+/*
+ * This file defines the list of DOS error codes. I think the error
+ * codes are divided into different classes, which is why there are
+ * duplicate values.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * Error source or class
+ */
+#define ERRDOS 0x01 /* Core DOS operating system error. */
+#define ERRSRV 0x02 /* Server network file error */
+#define ERRHRD 0x03 /* Hardware error */
+#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
+
+
+/*
+ * ERRDOS error codes
+ */
+#define ERRbadfunc 1 /* Invalid function. */
+#define ERRbadfile 2 /* File not found (last component) */
+#define ERRbadpath 3 /* path not found (directory part) */
+#define ERRnofids 4 /* Too many open files. */
+#define ERRnoaccess 5 /* Access denied. */
+#define ERRbadfid 6 /* Invalid file handle. */
+#define ERRbadmcb 7 /* Memory control blocks destroyed. */
+#define ERRnomem 8 /* Insufficient memory. */
+#define ERRbadmem 9 /* Invalid memory block address. */
+#define ERRbadenv 10 /* Invalid environment. */
+#define ERRbadformat 11 /* Invalid format. */
+#define ERRbadaccess 12 /* Invalid open mode. */
+#define ERRbaddata 13 /* Invalid data (from IOCTL calls) */
+#define ERRbaddrive 15 /* Invalid drive specified. */
+#define ERRremcd 16 /* Attempted to delete current directory. */
+#define ERRdiffdevice 17 /* Not same device (cross volume rename) */
+#define ERRnofiles 18 /* File search found no more files. */
+#define ERRbadshare 32 /* Share mode conflict with existing open. */
+#define ERRlock 33 /* Lock conflict with existing lock, etc. */
+#define ERRdiskfull 39 /* No space left on device. */
+#define ERRfilexists 80 /* Requested file name already exists. */
+
+/*
+ * These are compatible with the MS header files, but the
+ * smb/nterror.h names for these are preferred.
+ */
+#define ERRbadpipe 230 /* See ERROR_BAD_PIPE (named pipe invalid) */
+#define ERRpipebusy 231 /* See ERROR_PIPE_BUSY (all instances busy) */
+#define ERRpipeclosing 232 /* See ERROR_NO_DATA (pipe closing) */
+#define ERRnotconnected 233 /* See ERROR_PIPE_NOT_CONNECTED */
+#define ERRmoredata 234 /* See ERROR_MORE_DATA (pipe has more) */
+
+
+/*
+ * ERRSRV error codes
+ */
+#define ERRerror 1 /* Non-specific error code. */
+#define ERRbadpw 2 /* Bad password (tree connect, etc) */
+#define ERRbadtype 3 /* reserved */
+#define ERRaccess 4 /* access denied */
+#define ERRinvnid 5 /* Invalid tree ID */
+#define ERRinvnetname 6 /* Invalid network name (tree connect) */
+#define ERRinvdevice 7 /* Invalid device (print jobs, etc.) */
+#define ERRqfull 49 /* Print queue full (files) */
+#define ERRqtoobig 50 /* Print queue full (no space) */
+#define ERRqeof 51 /* EOF on print queue dump. */
+#define ERRinvpfid 52 /* Invalid print file FID. */
+#define ERRsmbcmd 64 /* Server did not recognize the command. */
+#define ERRsrverror 65 /* Server encountered an internal error. */
+#define ERRfilespecs 67 /* FID and path param combination is bad. */
+#define ERRbadpermits 69 /* Access permissions invalid (SetF*) */
+#define ERRsetattrmode 71 /* Attribute mode invalid (SetF*) */
+#define ERRpaused 81 /* Server is paused. */
+#define ERRmsgoff 82 /* Not receiving messages. */
+#define ERRnoroom 83 /* No room to buffer message. */
+#define ERRrmuns 87 /* Too many remote user names (messaging) */
+#define ERRtimeout 88 /* Operation timed out. */
+#define ERRnoresource 89 /* No resources available for request. */
+#define ERRtoomanyuids 90 /* Too many UIDs active on connection. */
+#define ERRbaduid 91 /* UID is not valid. */
+
+#define ERRusempx 250 /* Temporarily unable to support Raw, */
+ /* use MPX mode */
+#define ERRusestd 251 /* Temporarily unable to support Raw, */
+ /* use stdandard r/w */
+#define ERRcontmpx 252 /* Continue in MPX mode */
+
+#define ERRnosupport 0xffff /* Function not supported. */
+
+
+/*
+ * ERRHRD error codes
+ */
+#define ERRnowrite 19 /* Attempt to write on write-protected media */
+#define ERRbadunit 20 /* Unknown unit. */
+#define ERRnotready 21 /* Drive not ready. */
+#define ERRbadcmd 22 /* Unknown command. */
+#define ERRdata 23 /* Data error (CRC). */
+#define ERRbadreq 24 /* Bad request structure length. */
+#define ERRseek 25 /* Seek error. */
+#define ERRbadmedia 26 /* Unknown media type. */
+#define ERRbadsector 27 /* Sector not found. */
+#define ERRnopaper 28 /* Printer out of paper. */
+#define ERRwrite 29 /* Write fault. */
+#define ERRread 30 /* Read fault. */
+#define ERRgeneral 31 /* General failure. */
+/* ERRbadshare 32 Same as for DOSERR (see above) */
+/* ERRlock 33 Same as for DOSERR (see above) */
+#define ERRwrongdisk 34 /* The wrong disk was found in a drive. */
+#define ERRFCBUnavail 35 /* No FCBs are available to process request. */
+#define ERRsharebufexc 36 /* A sharing buffer has been exceeded. */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SMB_DOSERROR_H */
diff --git a/usr/src/uts/common/smbsrv/lmerr.h b/usr/src/uts/common/smb/lmerr.h
index 13e8843bbc..cf8c651d4c 100644
--- a/usr/src/uts/common/smbsrv/lmerr.h
+++ b/usr/src/uts/common/smb/lmerr.h
@@ -18,15 +18,13 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#ifndef _SMBSRV_LMERR_H
-#define _SMBSRV_LMERR_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+#ifndef _SMB_LMERR_H
+#define _SMB_LMERR_H
/*
* This file contains the LAN Manager network error definitions. All
@@ -46,6 +44,9 @@
*
* See msdn.microsoft.com for additional information on the meaning
* of each error code.
+ *
+ * This file is compatible with the Windows SDK file: Include/LMErr.h
+ * Please preserve this compatibility.
*/
#ifdef __cplusplus
@@ -65,8 +66,8 @@ extern "C" {
#define NERR_NoNetworkResource (NERR_BASE+5)
#define NERR_RemoteOnly (NERR_BASE+6)
#define NERR_DevNotRedirected (NERR_BASE+7)
-/* NERR_BASE+8 is used for ERROR_CONNECTED_OTHER_PASSWORD */
-/* UNUSED BASE+9 */
+/* NERR_BASE+8 is ERROR_CONNECTED_OTHER_PASSWORD */
+/* NERR_BASE+9 is ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT */
/* UNUSED BASE+10 */
/* UNUSED BASE+11 */
/* UNUSED BASE+12 */
@@ -256,6 +257,13 @@ extern "C" {
#define NERR_MultipleNets (NERR_BASE+200)
/*
+ * NERR_BASE+201 is ERROR_OPEN_FILES
+ * NERR_BASE+202 is ERROR_ACTIVE_CONNECTIONS
+ * NERR_BASE+204 is ERROR_DEVICE_IN_USE
+ * (see nterror.h)
+ */
+
+/*
* Server API related
* Error codes BASE+210 to BASE+229
*/
@@ -293,16 +301,16 @@ extern "C" {
* NetIListCanon and NetINameCheck
* Error codes BASE+250 to BASE+269
*/
-#define NERR_InvalidComputer (NERR_BASE+251)
+#define NERR_InvalidComputer (NERR_BASE+251)
/* UNUSED BASE+252 */
/* UNUSED BASE+253 */
-#define NERR_MaxLenExceeded (NERR_BASE+254)
+#define NERR_MaxLenExceeded (NERR_BASE+254)
/* UNUSED BASE+255 */
#define NERR_BadComponent (NERR_BASE+256)
#define NERR_CantType (NERR_BASE+257)
/* UNUSED BASE+258 */
/* UNUSED BASE+259 */
-#define NERR_TooManyEntries (NERR_BASE+262)
+#define NERR_TooManyEntries (NERR_BASE+262)
/*
* NetProfile
@@ -402,17 +410,17 @@ extern "C" {
#define NERR_NoAlternateServers (NERR_BASE+367)
/* UNUSED BASE+368 */
/* UNUSED BASE+369 */
-#define NERR_TryDownLevel (NERR_BASE+370)
+#define NERR_TryDownLevel (NERR_BASE+370)
/*
* UPS error codes.
* NERR_BASE + (380-384)
*/
-#define NERR_UPSDriverNotStarted (NERR_BASE+380)
-#define NERR_UPSInvalidConfig (NERR_BASE+381)
-#define NERR_UPSInvalidCommPort (NERR_BASE+382)
-#define NERR_UPSSignalAsserted (NERR_BASE+383)
-#define NERR_UPSShutdownFailed (NERR_BASE+384)
+#define NERR_UPSDriverNotStarted (NERR_BASE+380)
+#define NERR_UPSInvalidConfig (NERR_BASE+381)
+#define NERR_UPSInvalidCommPort (NERR_BASE+382)
+#define NERR_UPSSignalAsserted (NERR_BASE+383)
+#define NERR_UPSShutdownFailed (NERR_BASE+384)
/*
* Remoteboot error codes.
@@ -423,26 +431,26 @@ extern "C" {
* Error code 418 is for when REMOTEBOOT can't start
* Error code 419 is for a disallowed 2nd rpl connection
*/
-#define NERR_BadDosRetCode (NERR_BASE+400)
-#define NERR_ProgNeedsExtraMem (NERR_BASE+401)
-#define NERR_BadDosFunction (NERR_BASE+402)
-#define NERR_RemoteBootFailed (NERR_BASE+403)
-#define NERR_BadFileCheckSum (NERR_BASE+404)
-#define NERR_NoRplBootSystem (NERR_BASE+405)
-#define NERR_RplLoadrNetBiosErr (NERR_BASE+406)
-#define NERR_RplLoadrDiskErr (NERR_BASE+407)
-#define NERR_ImageParamErr (NERR_BASE+408)
-#define NERR_TooManyImageParams (NERR_BASE+409)
-#define NERR_NonDosFloppyUsed (NERR_BASE+410)
-#define NERR_RplBootRestart (NERR_BASE+411)
-#define NERR_RplSrvrCallFailed (NERR_BASE+412)
-#define NERR_CantConnectRplSrvr (NERR_BASE+413)
-#define NERR_CantOpenImageFile (NERR_BASE+414)
-#define NERR_CallingRplSrvr (NERR_BASE+415)
-#define NERR_StartingRplBoot (NERR_BASE+416)
-#define NERR_RplBootServiceTerm (NERR_BASE+417)
-#define NERR_RplBootStartFailed (NERR_BASE+418)
-#define NERR_RPL_CONNECTED (NERR_BASE+419)
+#define NERR_BadDosRetCode (NERR_BASE+400)
+#define NERR_ProgNeedsExtraMem (NERR_BASE+401)
+#define NERR_BadDosFunction (NERR_BASE+402)
+#define NERR_RemoteBootFailed (NERR_BASE+403)
+#define NERR_BadFileCheckSum (NERR_BASE+404)
+#define NERR_NoRplBootSystem (NERR_BASE+405)
+#define NERR_RplLoadrNetBiosErr (NERR_BASE+406)
+#define NERR_RplLoadrDiskErr (NERR_BASE+407)
+#define NERR_ImageParamErr (NERR_BASE+408)
+#define NERR_TooManyImageParams (NERR_BASE+409)
+#define NERR_NonDosFloppyUsed (NERR_BASE+410)
+#define NERR_RplBootRestart (NERR_BASE+411)
+#define NERR_RplSrvrCallFailed (NERR_BASE+412)
+#define NERR_CantConnectRplSrvr (NERR_BASE+413)
+#define NERR_CantOpenImageFile (NERR_BASE+414)
+#define NERR_CallingRplSrvr (NERR_BASE+415)
+#define NERR_StartingRplBoot (NERR_BASE+416)
+#define NERR_RplBootServiceTerm (NERR_BASE+417)
+#define NERR_RplBootStartFailed (NERR_BASE+418)
+#define NERR_RPL_CONNECTED (NERR_BASE+419)
/*
* FTADMIN API error codes
@@ -454,83 +462,88 @@ extern "C" {
* Browser service API error codes
* NERR_BASE + (450-475)
*/
-#define NERR_BrowserConfiguredToNotRun (NERR_BASE+450)
+#define NERR_BrowserConfiguredToNotRun (NERR_BASE+450)
/*
* Additional Remoteboot error codes.
* NERR_BASE + (510-550)
*/
-#define NERR_RplNoAdaptersStarted (NERR_BASE+510)
-#define NERR_RplBadRegistry (NERR_BASE+511)
-#define NERR_RplBadDatabase (NERR_BASE+512)
-#define NERR_RplRplfilesShare (NERR_BASE+513)
-#define NERR_RplNotRplServer (NERR_BASE+514)
-#define NERR_RplCannotEnum (NERR_BASE+515)
-#define NERR_RplWkstaInfoCorrupted (NERR_BASE+516)
-#define NERR_RplWkstaNotFound (NERR_BASE+517)
-#define NERR_RplWkstaNameUnavailable (NERR_BASE+518)
-#define NERR_RplProfileInfoCorrupted (NERR_BASE+519)
-#define NERR_RplProfileNotFound (NERR_BASE+520)
-#define NERR_RplProfileNameUnavailable (NERR_BASE+521)
-#define NERR_RplProfileNotEmpty (NERR_BASE+522)
-#define NERR_RplConfigInfoCorrupted (NERR_BASE+523)
-#define NERR_RplConfigNotFound (NERR_BASE+524)
-#define NERR_RplAdapterInfoCorrupted (NERR_BASE+525)
-#define NERR_RplInternal (NERR_BASE+526)
-#define NERR_RplVendorInfoCorrupted (NERR_BASE+527)
-#define NERR_RplBootInfoCorrupted (NERR_BASE+528)
-#define NERR_RplWkstaNeedsUserAcct (NERR_BASE+529)
-#define NERR_RplNeedsRPLUSERAcct (NERR_BASE+530)
-#define NERR_RplBootNotFound (NERR_BASE+531)
-#define NERR_RplIncompatibleProfile (NERR_BASE+532)
-#define NERR_RplAdapterNameUnavailable (NERR_BASE+533)
-#define NERR_RplConfigNotEmpty (NERR_BASE+534)
-#define NERR_RplBootInUse (NERR_BASE+535)
-#define NERR_RplBackupDatabase (NERR_BASE+536)
-#define NERR_RplAdapterNotFound (NERR_BASE+537)
-#define NERR_RplVendorNotFound (NERR_BASE+538)
-#define NERR_RplVendorNameUnavailable (NERR_BASE+539)
-#define NERR_RplBootNameUnavailable (NERR_BASE+540)
-#define NERR_RplConfigNameUnavailable (NERR_BASE+541)
+#define NERR_RplNoAdaptersStarted (NERR_BASE+510)
+#define NERR_RplBadRegistry (NERR_BASE+511)
+#define NERR_RplBadDatabase (NERR_BASE+512)
+#define NERR_RplRplfilesShare (NERR_BASE+513)
+#define NERR_RplNotRplServer (NERR_BASE+514)
+#define NERR_RplCannotEnum (NERR_BASE+515)
+#define NERR_RplWkstaInfoCorrupted (NERR_BASE+516)
+#define NERR_RplWkstaNotFound (NERR_BASE+517)
+#define NERR_RplWkstaNameUnavailable (NERR_BASE+518)
+#define NERR_RplProfileInfoCorrupted (NERR_BASE+519)
+#define NERR_RplProfileNotFound (NERR_BASE+520)
+#define NERR_RplProfileNameUnavailable (NERR_BASE+521)
+#define NERR_RplProfileNotEmpty (NERR_BASE+522)
+#define NERR_RplConfigInfoCorrupted (NERR_BASE+523)
+#define NERR_RplConfigNotFound (NERR_BASE+524)
+#define NERR_RplAdapterInfoCorrupted (NERR_BASE+525)
+#define NERR_RplInternal (NERR_BASE+526)
+#define NERR_RplVendorInfoCorrupted (NERR_BASE+527)
+#define NERR_RplBootInfoCorrupted (NERR_BASE+528)
+#define NERR_RplWkstaNeedsUserAcct (NERR_BASE+529)
+#define NERR_RplNeedsRPLUSERAcct (NERR_BASE+530)
+#define NERR_RplBootNotFound (NERR_BASE+531)
+#define NERR_RplIncompatibleProfile (NERR_BASE+532)
+#define NERR_RplAdapterNameUnavailable (NERR_BASE+533)
+#define NERR_RplConfigNotEmpty (NERR_BASE+534)
+#define NERR_RplBootInUse (NERR_BASE+535)
+#define NERR_RplBackupDatabase (NERR_BASE+536)
+#define NERR_RplAdapterNotFound (NERR_BASE+537)
+#define NERR_RplVendorNotFound (NERR_BASE+538)
+#define NERR_RplVendorNameUnavailable (NERR_BASE+539)
+#define NERR_RplBootNameUnavailable (NERR_BASE+540)
+#define NERR_RplConfigNameUnavailable (NERR_BASE+541)
/*
* Dfs API error codes.
* NERR_BASE + (560-590)
*/
-#define NERR_DfsInternalCorruption (NERR_BASE+560)
-#define NERR_DfsVolumeDataCorrupt (NERR_BASE+561)
-#define NERR_DfsNoSuchVolume (NERR_BASE+562)
-#define NERR_DfsVolumeAlreadyExists (NERR_BASE+563)
-#define NERR_DfsAlreadyShared (NERR_BASE+564)
-#define NERR_DfsNoSuchShare (NERR_BASE+565)
-#define NERR_DfsNotALeafVolume (NERR_BASE+566)
-#define NERR_DfsLeafVolume (NERR_BASE+567)
-#define NERR_DfsVolumeHasMultipleServers (NERR_BASE+568)
-#define NERR_DfsCantCreateJunctionPoint (NERR_BASE+569)
-#define NERR_DfsServerNotDfsAware (NERR_BASE+570)
-#define NERR_DfsBadRenamePath (NERR_BASE+571)
-#define NERR_DfsVolumeIsOffline (NERR_BASE+572)
-#define NERR_DfsNoSuchServer (NERR_BASE+573)
-#define NERR_DfsCyclicalName (NERR_BASE+574)
-#define NERR_DfsNotSupportedInServerDfs (NERR_BASE+575)
-#define NERR_DfsInternalError (NERR_BASE+590)
+#define NERR_DfsInternalCorruption (NERR_BASE+560)
+#define NERR_DfsVolumeDataCorrupt (NERR_BASE+561)
+#define NERR_DfsNoSuchVolume (NERR_BASE+562)
+#define NERR_DfsVolumeAlreadyExists (NERR_BASE+563)
+#define NERR_DfsAlreadyShared (NERR_BASE+564)
+#define NERR_DfsNoSuchShare (NERR_BASE+565)
+#define NERR_DfsNotALeafVolume (NERR_BASE+566)
+#define NERR_DfsLeafVolume (NERR_BASE+567)
+#define NERR_DfsVolumeHasMultipleServers (NERR_BASE+568)
+#define NERR_DfsCantCreateJunctionPoint (NERR_BASE+569)
+#define NERR_DfsServerNotDfsAware (NERR_BASE+570)
+#define NERR_DfsBadRenamePath (NERR_BASE+571)
+#define NERR_DfsVolumeIsOffline (NERR_BASE+572)
+#define NERR_DfsNoSuchServer (NERR_BASE+573)
+#define NERR_DfsCyclicalName (NERR_BASE+574)
+#define NERR_DfsNotSupportedInServerDfs (NERR_BASE+575)
+#define NERR_DfsInternalError (NERR_BASE+590)
/*
* Net setup error codes.
* NERR_BASE + (591-595)
*/
-#define NERR_SetupAlreadyJoined (NERR_BASE+591)
-#define NERR_SetupNotJoined (NERR_BASE+592)
-#define NERR_SetupDomainController (NERR_BASE+593)
+#define NERR_SetupAlreadyJoined (NERR_BASE+591)
+#define NERR_SetupNotJoined (NERR_BASE+592)
+#define NERR_SetupDomainController (NERR_BASE+593)
+#define NERR_DefaultJoinRequired (NERR_BASE+594)
+#define NERR_InvalidWorkgroupName (NERR_BASE+595)
+#define NERR_NameUsesIncompatibleCodePage (NERR_BASE+596)
+#define NERR_ComputerAccountNotFound (NERR_BASE+597)
+#define NERR_PersonalSku (NERR_BASE+598)
/*
* MAX_NERR is the last value in the NERR range.
* Do not exceed this value here.
*/
-#define MAX_NERR (NERR_BASE+899)
+#define MAX_NERR (NERR_BASE+899)
#ifdef __cplusplus
}
#endif
-#endif /* _SMBSRV_LMERR_H */
+#endif /* _SMB_LMERR_H */
diff --git a/usr/src/uts/common/smb/nterror.h b/usr/src/uts/common/smb/nterror.h
new file mode 100644
index 0000000000..d34edf49d0
--- /dev/null
+++ b/usr/src/uts/common/smb/nterror.h
@@ -0,0 +1,1644 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _SMB_NTERROR_H
+#define _SMB_NTERROR_H
+
+/*
+ * This file defines the list of Win32 error codes. If you need
+ * an error code that is defined in the [MS-ERREF] document but
+ * is not listed here, please add it to the file. This file is
+ * compatible with the Windows SDK file Include/WinError.h
+ * Please preserve this compatibility.
+ *
+ * Be careful not to confuse status codes with error codes. The status
+ * codes are listed in ntstatus.h. Some mappings between NT status
+ * codes and Win32 error codes is provided in the Microsoft knowledge
+ * base article Q113996.
+ *
+ * Win32 error codes are 32-bit values with the following format
+ * (winerror.h):
+ *
+ * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +---+-+-+-----------------------+-------------------------------+
+ * |Sev|C|R| Facility | Code |
+ * +---+-+-+-----------------------+-------------------------------+
+ *
+ * Sev severity code
+ * 00 - Success
+ * 01 - Informational
+ * 10 - Warning
+ * 11 - Error
+ *
+ * C customer/client flag (set to 1 for user defined codes).
+ * R reserved (set to zero)
+ * Facility facility code
+ * Code facility's status code
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * Facility codes
+ */
+#define FACILITY_NULL 0
+#define FACILITY_RPC 1
+#define FACILITY_DISPATCH 2
+#define FACILITY_STORAGE 3
+#define FACILITY_ITF 4
+/* 5 */
+/* 6 */
+#define FACILITY_WIN32 7
+#define FACILITY_WINDOWS 8
+#define FACILITY_SSPI 9
+#define FACILITY_CONTROL 10
+#define FACILITY_CERT 11
+#define FACILITY_INTERNET 12
+#define FACILITY_MEDIASERVER 13
+#define FACILITY_MSMQ 14
+#define FACILITY_SETUPAPI 15
+
+
+/*
+ * Complete list of Win32 error codes. For error description
+ * you can look at MS-KB articles 155011 and 155012
+ */
+
+#define ERROR_SUCCESS 0
+#define NO_ERROR 0
+#define ERROR_INVALID_FUNCTION 1
+#define ERROR_FILE_NOT_FOUND 2
+#define ERROR_PATH_NOT_FOUND 3
+#define ERROR_TOO_MANY_OPEN_FILES 4
+#define ERROR_ACCESS_DENIED 5
+#define ERROR_INVALID_HANDLE 6
+#define ERROR_ARENA_TRASHED 7
+#define ERROR_NOT_ENOUGH_MEMORY 8
+#define ERROR_INVALID_BLOCK 9
+#define ERROR_BAD_ENVIRONMENT 10
+#define ERROR_BAD_FORMAT 11
+#define ERROR_INVALID_ACCESS 12
+#define ERROR_INVALID_DATA 13
+#define ERROR_OUTOFMEMORY 14
+#define ERROR_INVALID_DRIVE 15
+#define ERROR_CURRENT_DIRECTORY 16
+#define ERROR_NOT_SAME_DEVICE 17
+#define ERROR_NO_MORE_FILES 18
+#define ERROR_WRITE_PROTECT 19
+#define ERROR_BAD_UNIT 20
+#define ERROR_NOT_READY 21
+#define ERROR_BAD_COMMAND 22
+#define ERROR_CRC 23
+#define ERROR_BAD_LENGTH 24
+#define ERROR_SEEK 25
+#define ERROR_NOT_DOS_DISK 26
+#define ERROR_SECTOR_NOT_FOUND 27
+#define ERROR_OUT_OF_PAPER 28
+#define ERROR_WRITE_FAULT 29
+#define ERROR_READ_FAULT 30
+#define ERROR_GEN_FAILURE 31
+#define ERROR_SHARING_VIOLATION 32
+#define ERROR_LOCK_VIOLATION 33
+#define ERROR_WRONG_DISK 34
+#define ERROR_SHARING_BUFFER_EXCEEDED 36
+#define ERROR_HANDLE_EOF 38
+#define ERROR_HANDLE_DISK_FULL 39
+#define ERROR_NOT_SUPPORTED 50
+#define ERROR_REM_NOT_LIST 51
+#define ERROR_DUP_NAME 52
+#define ERROR_BAD_NETPATH 53
+#define ERROR_NETWORK_BUSY 54
+#define ERROR_DEV_NOT_EXIST 55
+#define ERROR_TOO_MANY_CMDS 56
+#define ERROR_ADAP_HDW_ERR 57
+#define ERROR_BAD_NET_RESP 58
+#define ERROR_UNEXP_NET_ERR 59
+#define ERROR_BAD_REM_ADAP 60
+#define ERROR_PRINTQ_FULL 61
+#define ERROR_NO_SPOOL_SPACE 62
+#define ERROR_PRINT_CANCELLED 63
+#define ERROR_NETNAME_DELETED 64
+#define ERROR_NETWORK_ACCESS_DENIED 65
+#define ERROR_BAD_DEV_TYPE 66
+#define ERROR_BAD_NET_NAME 67
+#define ERROR_TOO_MANY_NAMES 68
+#define ERROR_TOO_MANY_SESS 69
+#define ERROR_SHARING_PAUSED 70
+#define ERROR_REQ_NOT_ACCEP 71
+#define ERROR_REDIR_PAUSED 72
+#define ERROR_FILE_EXISTS 80
+#define ERROR_CANNOT_MAKE 82
+#define ERROR_FAIL_I24 83
+#define ERROR_OUT_OF_STRUCTURES 84
+#define ERROR_ALREADY_ASSIGNED 85
+#define ERROR_INVALID_PASSWORD 86
+#define ERROR_INVALID_PARAMETER 87
+#define ERROR_NET_WRITE_FAULT 88
+#define ERROR_NO_PROC_SLOTS 89
+#define ERROR_TOO_MANY_SEMAPHORES 100
+#define ERROR_EXCL_SEM_ALREADY_OWNED 101
+#define ERROR_SEM_IS_SET 102
+#define ERROR_TOO_MANY_SEM_REQUESTS 103
+#define ERROR_INVALID_AT_INTERRUPT_TIME 104
+#define ERROR_SEM_OWNER_DIED 105
+#define ERROR_SEM_USER_LIMIT 106
+#define ERROR_DISK_CHANGE 107
+#define ERROR_DRIVE_LOCKED 108
+#define ERROR_BROKEN_PIPE 109
+#define ERROR_OPEN_FAILED 110
+#define ERROR_BUFFER_OVERFLOW 111
+#define ERROR_DISK_FULL 112
+#define ERROR_NO_MORE_SEARCH_HANDLES 113
+#define ERROR_INVALID_TARGET_HANDLE 114
+#define ERROR_INVALID_CATEGORY 117
+#define ERROR_INVALID_VERIFY_SWITCH 118
+#define ERROR_BAD_DRIVER_LEVEL 119
+#define ERROR_CALL_NOT_IMPLEMENTED 120
+#define ERROR_SEM_TIMEOUT 121
+#define ERROR_INSUFFICIENT_BUFFER 122
+#define ERROR_INVALID_NAME 123
+#define ERROR_INVALID_LEVEL 124
+#define ERROR_NO_VOLUME_LABEL 125
+#define ERROR_MOD_NOT_FOUND 126
+#define ERROR_PROC_NOT_FOUND 127
+#define ERROR_WAIT_NO_CHILDREN 128
+#define ERROR_CHILD_NOT_COMPLETE 129
+#define ERROR_DIRECT_ACCESS_HANDLE 130
+#define ERROR_NEGATIVE_SEEK 131
+#define ERROR_SEEK_ON_DEVICE 132
+#define ERROR_IS_JOIN_TARGET 133
+#define ERROR_IS_JOINED 134
+#define ERROR_IS_SUBSTED 135
+#define ERROR_NOT_JOINED 136
+#define ERROR_NOT_SUBSTED 137
+#define ERROR_JOIN_TO_JOIN 138
+#define ERROR_SUBST_TO_SUBST 139
+#define ERROR_JOIN_TO_SUBST 140
+#define ERROR_SUBST_TO_JOIN 141
+#define ERROR_BUSY_DRIVE 142
+#define ERROR_SAME_DRIVE 143
+#define ERROR_DIR_NOT_ROOT 144
+#define ERROR_DIR_NOT_EMPTY 145
+#define ERROR_IS_SUBST_PATH 146
+#define ERROR_IS_JOIN_PATH 147
+#define ERROR_PATH_BUSY 148
+#define ERROR_IS_SUBST_TARGET 149
+#define ERROR_SYSTEM_TRACE 150
+#define ERROR_INVALID_EVENT_COUNT 151
+#define ERROR_TOO_MANY_MUXWAITERS 152
+#define ERROR_INVALID_LIST_FORMAT 153
+#define ERROR_LABEL_TOO_LONG 154
+#define ERROR_TOO_MANY_TCBS 155
+#define ERROR_SIGNAL_REFUSED 156
+#define ERROR_DISCARDED 157
+#define ERROR_NOT_LOCKED 158
+#define ERROR_BAD_THREADID_ADDR 159
+#define ERROR_BAD_ARGUMENTS 160
+#define ERROR_BAD_PATHNAME 161
+#define ERROR_SIGNAL_PENDING 162
+#define ERROR_MAX_THRDS_REACHED 164
+#define ERROR_LOCK_FAILED 167
+#define ERROR_BUSY 170
+#define ERROR_CANCEL_VIOLATION 173
+#define ERROR_ATOMIC_LOCKS_NOT_SUPPORTED 174
+#define ERROR_INVALID_SEGMENT_NUMBER 180
+#define ERROR_INVALID_ORDINAL 182
+#define ERROR_ALREADY_EXISTS 183
+#define ERROR_INVALID_FLAG_NUMBER 186
+#define ERROR_SEM_NOT_FOUND 187
+#define ERROR_INVALID_STARTING_CODESEG 188
+#define ERROR_INVALID_STACKSEG 189
+#define ERROR_INVALID_MODULETYPE 190
+#define ERROR_INVALID_EXE_SIGNATURE 191
+#define ERROR_EXE_MARKED_INVALID 192
+#define ERROR_BAD_EXE_FORMAT 193
+#define ERROR_ITERATED_DATA_EXCEEDS_64k 194
+#define ERROR_INVALID_MINALLOCSIZE 195
+#define ERROR_DYNLINK_FROM_INVALID_RING 196
+#define ERROR_IOPL_NOT_ENABLED 197
+#define ERROR_INVALID_SEGDPL 198
+#define ERROR_AUTODATASEG_EXCEEDS_64k 199
+#define ERROR_RING2SEG_MUST_BE_MOVABLE 200
+#define ERROR_RELOC_CHAIN_XEEDS_SEGLIM 201
+#define ERROR_INFLOOP_IN_RELOC_CHAIN 202
+#define ERROR_ENVVAR_NOT_FOUND 203
+#define ERROR_NO_SIGNAL_SENT 205
+#define ERROR_FILENAME_EXCED_RANGE 206
+#define ERROR_RING2_STACK_IN_USE 207
+#define ERROR_META_EXPANSION_TOO_LONG 208
+#define ERROR_INVALID_SIGNAL_NUMBER 209
+#define ERROR_THREAD_1_INACTIVE 210
+#define ERROR_LOCKED 212
+#define ERROR_TOO_MANY_MODULES 214
+#define ERROR_NESTING_NOT_ALLOWED 215
+#define ERROR_EXE_MACHINE_TYPE_MISMATCH 216
+#define ERROR_BAD_PIPE 230
+#define ERROR_PIPE_BUSY 231
+#define ERROR_NO_DATA 232
+#define ERROR_PIPE_NOT_CONNECTED 233
+#define ERROR_MORE_DATA 234
+#define ERROR_VC_DISCONNECTED 240
+#define ERROR_INVALID_EA_NAME 254
+#define ERROR_EA_LIST_INCONSISTENT 255
+#define ERROR_NO_MORE_ITEMS 259
+#define ERROR_CANNOT_COPY 266
+#define ERROR_DIRECTORY 267
+#define ERROR_EAS_DIDNT_FIT 275
+#define ERROR_EA_FILE_CORRUPT 276
+#define ERROR_EA_TABLE_FULL 277
+#define ERROR_INVALID_EA_HANDLE 278
+#define ERROR_EAS_NOT_SUPPORTED 282
+#define ERROR_NOT_OWNER 288
+#define ERROR_TOO_MANY_POSTS 298
+#define ERROR_PARTIAL_COPY 299
+#define ERROR_OPLOCK_NOT_GRANTED 300
+#define ERROR_INVALID_OPLOCK_PROTOCOL 301
+#define ERROR_DISK_TOO_FRAGMENTED 302
+#define ERROR_DELETE_PENDING 303
+#define ERROR_MR_MID_NOT_FOUND 317
+#define ERROR_INVALID_ADDRESS 487
+#define ERROR_ARITHMETIC_OVERFLOW 534
+#define ERROR_PIPE_CONNECTED 535
+#define ERROR_PIPE_LISTENING 536
+#define ERROR_EA_ACCESS_DENIED 994
+#define ERROR_OPERATION_ABORTED 995
+#define ERROR_IO_INCOMPLETE 996
+#define ERROR_IO_PENDING 997
+#define ERROR_NOACCESS 998
+#define ERROR_SWAPERROR 999
+#define ERROR_STACK_OVERFLOW 1001
+#define ERROR_INVALID_MESSAGE 1002
+#define ERROR_CAN_NOT_COMPLETE 1003
+#define ERROR_INVALID_FLAGS 1004
+#define ERROR_UNRECOGNIZED_VOLUME 1005
+#define ERROR_FILE_INVALID 1006
+#define ERROR_FULLSCREEN_MODE 1007
+#define ERROR_NO_TOKEN 1008
+#define ERROR_BADDB 1009
+#define ERROR_BADKEY 1010
+#define ERROR_CANTOPEN 1011
+#define ERROR_CANTREAD 1012
+#define ERROR_CANTWRITE 1013
+#define ERROR_REGISTRY_RECOVERED 1014
+#define ERROR_REGISTRY_CORRUPT 1015
+#define ERROR_REGISTRY_IO_FAILED 1016
+#define ERROR_NOT_REGISTRY_FILE 1017
+#define ERROR_KEY_DELETED 1018
+#define ERROR_NO_LOG_SPACE 1019
+#define ERROR_KEY_HAS_CHILDREN 1020
+#define ERROR_CHILD_MUST_BE_VOLATILE 1021
+#define ERROR_NOTIFY_ENUM_DIR 1022
+#define ERROR_DEPENDENT_SERVICES_RUNNING 1051
+#define ERROR_INVALID_SERVICE_CONTROL 1052
+#define ERROR_SERVICE_REQUEST_TIMEOUT 1053
+#define ERROR_SERVICE_NO_THREAD 1054
+#define ERROR_SERVICE_DATABASE_LOCKED 1055
+#define ERROR_SERVICE_ALREADY_RUNNING 1056
+#define ERROR_INVALID_SERVICE_ACCOUNT 1057
+#define ERROR_SERVICE_DISABLED 1058
+#define ERROR_CIRCULAR_DEPENDENCY 1059
+#define ERROR_SERVICE_DOES_NOT_EXIST 1060
+#define ERROR_SERVICE_CANNOT_ACCEPT_CTRL 1061
+#define ERROR_SERVICE_NOT_ACTIVE 1062
+#define ERROR_FAILED_SERVICE_CONTROLLER_CONNECT 1063
+#define ERROR_EXCEPTION_IN_SERVICE 1064
+#define ERROR_DATABASE_DOES_NOT_EXIST 1065
+#define ERROR_SERVICE_SPECIFIC_ERROR 1066
+#define ERROR_PROCESS_ABORTED 1067
+#define ERROR_SERVICE_DEPENDENCY_FAIL 1068
+#define ERROR_SERVICE_LOGON_FAILED 1069
+#define ERROR_SERVICE_START_HANG 1070
+#define ERROR_INVALID_SERVICE_LOCK 1071
+#define ERROR_SERVICE_MARKED_FOR_DELETE 1072
+#define ERROR_SERVICE_EXISTS 1073
+#define ERROR_ALREADY_RUNNING_LKG 1074
+#define ERROR_SERVICE_DEPENDENCY_DELETED 1075
+#define ERROR_BOOT_ALREADY_ACCEPTED 1076
+#define ERROR_SERVICE_NEVER_STARTED 1077
+#define ERROR_DUPLICATE_SERVICE_NAME 1078
+#define ERROR_DIFFERENT_SERVICE_ACCOUNT 1079
+#define ERROR_CANNOT_DETECT_DRIVER_FAILURE 1080
+#define ERROR_CANNOT_DETECT_PROCESS_ABORT 1081
+#define ERROR_NO_RECOVERY_PROGRAM 1082
+#define ERROR_SERVICE_NOT_IN_EXE 1083
+#define ERROR_NOT_SAFEBOOT_SERVICE 1084
+
+#define ERROR_END_OF_MEDIA 1100
+#define ERROR_FILEMARK_DETECTED 1101
+#define ERROR_BEGINNING_OF_MEDIA 1102
+#define ERROR_SETMARK_DETECTED 1103
+#define ERROR_NO_DATA_DETECTED 1104
+#define ERROR_PARTITION_FAILURE 1105
+#define ERROR_INVALID_BLOCK_LENGTH 1106
+#define ERROR_DEVICE_NOT_PARTITIONED 1107
+#define ERROR_UNABLE_TO_LOCK_MEDIA 1108
+#define ERROR_UNABLE_TO_UNLOAD_MEDIA 1109
+#define ERROR_MEDIA_CHANGED 1110
+#define ERROR_BUS_RESET 1111
+#define ERROR_NO_MEDIA_IN_DRIVE 1112
+#define ERROR_NO_UNICODE_TRANSLATION 1113
+#define ERROR_DLL_INIT_FAILED 1114
+#define ERROR_SHUTDOWN_IN_PROGRESS 1115
+#define ERROR_NO_SHUTDOWN_IN_PROGRESS 1116
+#define ERROR_IO_DEVICE 1117
+#define ERROR_SERIAL_NO_DEVICE 1118
+#define ERROR_IRQ_BUSY 1119
+#define ERROR_MORE_WRITES 1120
+#define ERROR_COUNTER_TIMEOUT 1121
+#define ERROR_FLOPPY_ID_MARK_NOT_FOUND 1122
+#define ERROR_FLOPPY_WRONG_CYLINDER 1123
+#define ERROR_FLOPPY_UNKNOWN_ERROR 1124
+#define ERROR_FLOPPY_BAD_REGISTERS 1125
+#define ERROR_DISK_RECALIBRATE_FAILED 1126
+#define ERROR_DISK_OPERATION_FAILED 1127
+#define ERROR_DISK_RESET_FAILED 1128
+#define ERROR_EOM_OVERFLOW 1129
+#define ERROR_NOT_ENOUGH_SERVER_MEMORY 1130
+#define ERROR_POSSIBLE_DEADLOCK 1131
+#define ERROR_MAPPED_ALIGNMENT 1132
+#define ERROR_SET_POWER_STATE_VETOED 1140
+#define ERROR_SET_POWER_STATE_FAILED 1141
+#define ERROR_TOO_MANY_LINKS 1142
+#define ERROR_OLD_WIN_VERSION 1150
+#define ERROR_APP_WRONG_OS 1151
+#define ERROR_SINGLE_INSTANCE_APP 1152
+#define ERROR_RMODE_APP 1153
+#define ERROR_INVALID_DLL 1154
+#define ERROR_NO_ASSOCIATION 1155
+#define ERROR_DDE_FAIL 1156
+#define ERROR_DLL_NOT_FOUND 1157
+#define ERROR_NO_MORE_USER_HANDLES 1158
+#define ERROR_MESSAGE_SYNC_ONLY 1159
+#define ERROR_SOURCE_ELEMENT_EMPTY 1160
+#define ERROR_DESTINATION_ELEMENT_FULL 1161
+#define ERROR_ILLEGAL_ELEMENT_ADDRESS 1162
+#define ERROR_MAGAZINE_NOT_PRESENT 1163
+#define ERROR_DEVICE_REINITIALIZATION_NEEDED 1164
+#define ERROR_DEVICE_REQUIRES_CLEANING 1165
+#define ERROR_DEVICE_DOOR_OPEN 1166
+#define ERROR_DEVICE_NOT_CONNECTED 1167
+#define ERROR_NOT_FOUND 1168
+#define ERROR_NO_MATCH 1169
+#define ERROR_SET_NOT_FOUND 1170
+#define ERROR_POINT_NOT_FOUND 1171
+#define ERROR_NO_TRACKING_SERVICE 1172
+#define ERROR_NO_VOLUME_ID 1173
+#define ERROR_UNABLE_TO_REMOVE_REPLACED 1175
+#define ERROR_UNABLE_TO_MOVE_REPLACEMENT 1176
+#define ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 1177
+#define ERROR_JOURNAL_DELETE_IN_PROGRESS 1178
+#define ERROR_JOURNAL_NOT_ACTIVE 1179
+#define ERROR_POTENTIAL_FILE_FOUND 1180
+#define ERROR_JOURNAL_ENTRY_DELETED 1181
+
+#define ERROR_BAD_DEVICE 1200
+#define ERROR_CONNECTION_UNAVAIL 1201
+#define ERROR_DEVICE_ALREADY_REMEMBERED 1202
+#define ERROR_NO_NET_OR_BAD_PATH 1203
+#define ERROR_BAD_PROVIDER 1204
+#define ERROR_CANNOT_OPEN_PROFILE 1205
+#define ERROR_BAD_PROFILE 1206
+#define ERROR_NOT_CONTAINER 1207
+#define ERROR_EXTENDED_ERROR 1208
+#define ERROR_INVALID_GROUPNAME 1209
+#define ERROR_INVALID_COMPUTERNAME 1210
+#define ERROR_INVALID_EVENTNAME 1211
+#define ERROR_INVALID_DOMAINNAME 1212
+#define ERROR_INVALID_SERVICENAME 1213
+#define ERROR_INVALID_NETNAME 1214
+#define ERROR_INVALID_SHARENAME 1215
+#define ERROR_INVALID_PASSWORDNAME 1216
+#define ERROR_INVALID_MESSAGENAME 1217
+#define ERROR_INVALID_MESSAGEDEST 1218
+#define ERROR_SESSION_CREDENTIAL_CONFLICT 1219
+#define ERROR_REMOTE_SESSION_LIMIT_EXCEEDED 1220
+#define ERROR_DUP_DOMAINNAME 1221
+#define ERROR_NO_NETWORK 1222
+#define ERROR_CANCELLED 1223
+#define ERROR_USER_MAPPED_FILE 1224
+#define ERROR_CONNECTION_REFUSED 1225
+#define ERROR_GRACEFUL_DISCONNECT 1226
+#define ERROR_ADDRESS_ALREADY_ASSOCIATED 1227
+#define ERROR_ADDRESS_NOT_ASSOCIATED 1228
+#define ERROR_CONNECTION_INVALID 1229
+#define ERROR_CONNECTION_ACTIVE 1230
+#define ERROR_NETWORK_UNREACHABLE 1231
+#define ERROR_HOST_UNREACHABLE 1232
+#define ERROR_PROTOCOL_UNREACHABLE 1233
+#define ERROR_PORT_UNREACHABLE 1234
+#define ERROR_REQUEST_ABORTED 1235
+#define ERROR_CONNECTION_ABORTED 1236
+#define ERROR_RETRY 1237
+#define ERROR_CONNECTION_COUNT_LIMIT 1238
+#define ERROR_LOGIN_TIME_RESTRICTION 1239
+#define ERROR_LOGIN_WKSTA_RESTRICTION 1240
+#define ERROR_INCORRECT_ADDRESS 1241
+#define ERROR_ALREADY_REGISTERED 1242
+#define ERROR_SERVICE_NOT_FOUND 1243
+#define ERROR_NOT_AUTHENTICATED 1244
+#define ERROR_NOT_LOGGED_ON 1245
+#define ERROR_CONTINUE 1246
+#define ERROR_ALREADY_INITIALIZED 1247
+#define ERROR_NO_MORE_DEVICES 1248
+#define ERROR_NO_SUCH_SITE 1249
+#define ERROR_DOMAIN_CONTROLLER_EXISTS 1250
+#define ERROR_ONLY_IF_CONNECTED 1251
+#define ERROR_OVERRIDE_NOCHANGES 1252
+#define ERROR_BAD_USER_PROFILE 1253
+#define ERROR_NOT_SUPPORTED_ON_SBS 1254
+#define ERROR_SERVER_SHUTDOWN_IN_PROGRESS 1255
+#define ERROR_HOST_DOWN 1256
+#define ERROR_NON_ACCOUNT_SID 1257
+#define ERROR_NON_DOMAIN_SID 1258
+#define ERROR_APPHELP_BLOCK 1259
+#define ERROR_ACCESS_DISABLED_BY_POLICY 1260
+#define ERROR_REG_NAT_CONSUMPTION 1261
+#define ERROR_CSCSHARE_OFFLINE 1262
+#define ERROR_PKINIT_FAILURE 1263
+#define ERROR_SMARTCARD_SUBSYSTEM_FAILURE 1264
+#define ERROR_DOWNGRADE_DETECTED 1265
+
+#define SEC_E_SMARTCARD_CERT_REVOKED 1266
+#define SEC_E_ISSUING_CA_UNTRUSTED 1267
+#define SEC_E_REVOCATION_OFFLINE_C 1268
+#define SEC_E_PKINIT_CLIENT_FAILURE 1269
+#define SEC_E_SMARTCARD_CERT_EXPIRED 1270
+
+#define ERROR_MACHINE_LOCKED 1271
+#define ERROR_CALLBACK_SUPPLIED_INVALID_DATA 1273
+#define ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED 1274
+#define ERROR_DRIVER_BLOCKED 1275
+#define ERROR_INVALID_IMPORT_OF_NON_DLL 1276
+
+#define ERROR_NOT_ALL_ASSIGNED 1300
+#define ERROR_SOME_NOT_MAPPED 1301
+#define ERROR_NO_QUOTAS_FOR_ACCOUNT 1302
+#define ERROR_LOCAL_USER_SESSION_KEY 1303
+#define ERROR_NULL_LM_PASSWORD 1304
+#define ERROR_UNKNOWN_REVISION 1305
+#define ERROR_REVISION_MISMATCH 1306
+#define ERROR_INVALID_OWNER 1307
+#define ERROR_INVALID_PRIMARY_GROUP 1308
+#define ERROR_NO_IMPERSONATION_TOKEN 1309
+#define ERROR_CANT_DISABLE_MANDATORY 1310
+#define ERROR_NO_LOGON_SERVERS 1311
+#define ERROR_NO_SUCH_LOGON_SESSION 1312
+#define ERROR_NO_SUCH_PRIVILEGE 1313
+#define ERROR_PRIVILEGE_NOT_HELD 1314
+#define ERROR_INVALID_ACCOUNT_NAME 1315
+#define ERROR_USER_EXISTS 1316
+#define ERROR_NO_SUCH_USER 1317
+#define ERROR_GROUP_EXISTS 1318
+#define ERROR_NO_SUCH_GROUP 1319
+#define ERROR_MEMBER_IN_GROUP 1320
+#define ERROR_MEMBER_NOT_IN_GROUP 1321
+#define ERROR_LAST_ADMIN 1322
+#define ERROR_WRONG_PASSWORD 1323
+#define ERROR_ILL_FORMED_PASSWORD 1324
+#define ERROR_PASSWORD_RESTRICTION 1325
+#define ERROR_LOGON_FAILURE 1326
+#define ERROR_ACCOUNT_RESTRICTION 1327
+#define ERROR_INVALID_LOGON_HOURS 1328
+#define ERROR_INVALID_WORKSTATION 1329
+#define ERROR_PASSWORD_EXPIRED 1330
+#define ERROR_ACCOUNT_DISABLED 1331
+#define ERROR_NONE_MAPPED 1332
+#define ERROR_TOO_MANY_LUIDS_REQUESTED 1333
+#define ERROR_LUIDS_EXHAUSTED 1334
+#define ERROR_INVALID_SUB_AUTHORITY 1335
+#define ERROR_INVALID_ACL 1336
+#define ERROR_INVALID_SID 1337
+#define ERROR_INVALID_SECURITY_DESCR 1338
+#define ERROR_BAD_INHERITANCE_ACL 1340
+#define ERROR_SERVER_DISABLED 1341
+#define ERROR_SERVER_NOT_DISABLED 1342
+#define ERROR_INVALID_ID_AUTHORITY 1343
+#define ERROR_ALLOTTED_SPACE_EXCEEDED 1344
+#define ERROR_INVALID_GROUP_ATTRIBUTES 1345
+#define ERROR_BAD_IMPERSONATION_LEVEL 1346
+#define ERROR_CANT_OPEN_ANONYMOUS 1347
+#define ERROR_BAD_VALIDATION_CLASS 1348
+#define ERROR_BAD_TOKEN_TYPE 1349
+#define ERROR_NO_SECURITY_ON_OBJECT 1350
+#define ERROR_CANT_ACCESS_DOMAIN_INFO 1351
+#define ERROR_INVALID_SERVER_STATE 1352
+#define ERROR_INVALID_DOMAIN_STATE 1353
+#define ERROR_INVALID_DOMAIN_ROLE 1354
+#define ERROR_NO_SUCH_DOMAIN 1355
+#define ERROR_DOMAIN_EXISTS 1356
+#define ERROR_DOMAIN_LIMIT_EXCEEDED 1357
+#define ERROR_INTERNAL_DB_CORRUPTION 1358
+#define ERROR_INTERNAL_ERROR 1359
+#define ERROR_GENERIC_NOT_MAPPED 1360
+#define ERROR_BAD_DESCRIPTOR_FORMAT 1361
+#define ERROR_NOT_LOGON_PROCESS 1362
+#define ERROR_LOGON_SESSION_EXISTS 1363
+#define ERROR_NO_SUCH_PACKAGE 1364
+#define ERROR_BAD_LOGON_SESSION_STATE 1365
+#define ERROR_LOGON_SESSION_COLLISION 1366
+#define ERROR_INVALID_LOGON_TYPE 1367
+#define ERROR_CANNOT_IMPERSONATE 1368
+#define ERROR_RXACT_INVALID_STATE 1369
+#define ERROR_RXACT_COMMIT_FAILURE 1370
+#define ERROR_SPECIAL_ACCOUNT 1371
+#define ERROR_SPECIAL_GROUP 1372
+#define ERROR_SPECIAL_USER 1373
+#define ERROR_MEMBERS_PRIMARY_GROUP 1374
+#define ERROR_TOKEN_ALREADY_IN_USE 1375
+#define ERROR_NO_SUCH_ALIAS 1376
+#define ERROR_MEMBER_NOT_IN_ALIAS 1377
+#define ERROR_MEMBER_IN_ALIAS 1378
+#define ERROR_ALIAS_EXISTS 1379
+#define ERROR_LOGON_NOT_GRANTED 1380
+#define ERROR_TOO_MANY_SECRETS 1381
+#define ERROR_SECRET_TOO_LONG 1382
+#define ERROR_INTERNAL_DB_ERROR 1383
+#define ERROR_TOO_MANY_CONTEXT_IDS 1384
+#define ERROR_LOGON_TYPE_NOT_GRANTED 1385
+#define ERROR_NT_CROSS_ENCRYPTION_REQUIRED 1386
+#define ERROR_NO_SUCH_MEMBER 1387
+#define ERROR_INVALID_MEMBER 1388
+#define ERROR_TOO_MANY_SIDS 1389
+#define ERROR_LM_CROSS_ENCRYPTION_REQUIRED 1390
+#define ERROR_NO_INHERITANCE 1391
+#define ERROR_FILE_CORRUPT 1392
+#define ERROR_DISK_CORRUPT 1393
+#define ERROR_NO_USER_SESSION_KEY 1394
+#define ERROR_LICENSE_QUOTA_EXCEEDED 1395
+#define ERROR_WRONG_TARGET_NAME 1396
+#define ERROR_MUTUAL_AUTH_FAILED 1397
+#define ERROR_TIME_SKEW 1398
+#define ERROR_CURRENT_DOMAIN_NOT_ALLOWED 1399
+#define ERROR_INVALID_WINDOW_HANDLE 1400
+#define ERROR_INVALID_MENU_HANDLE 1401
+#define ERROR_INVALID_CURSOR_HANDLE 1402
+#define ERROR_INVALID_ACCEL_HANDLE 1403
+#define ERROR_INVALID_HOOK_HANDLE 1404
+#define ERROR_INVALID_DWP_HANDLE 1405
+#define ERROR_TLW_WITH_WSCHILD 1406
+#define ERROR_CANNOT_FIND_WND_CLASS 1407
+#define ERROR_WINDOW_OF_OTHER_THREAD 1408
+#define ERROR_HOTKEY_ALREADY_REGISTERED 1409
+#define ERROR_CLASS_ALREADY_EXISTS 1410
+#define ERROR_CLASS_DOES_NOT_EXIST 1411
+#define ERROR_CLASS_HAS_WINDOWS 1412
+#define ERROR_INVALID_INDEX 1413
+#define ERROR_INVALID_ICON_HANDLE 1414
+#define ERROR_PRIVATE_DIALOG_INDEX 1415
+#define ERROR_LISTBOX_ID_NOT_FOUND 1416
+#define ERROR_NO_WILDCARD_CHARACTERS 1417
+#define ERROR_CLIPBOARD_NOT_OPEN 1418
+#define ERROR_HOTKEY_NOT_REGISTERED 1419
+#define ERROR_WINDOW_NOT_DIALOG 1420
+#define ERROR_CONTROL_ID_NOT_FOUND 1421
+#define ERROR_INVALID_COMBOBOX_MESSAGE 1422
+#define ERROR_WINDOW_NOT_COMBOBOX 1423
+#define ERROR_INVALID_EDIT_HEIGHT 1424
+#define ERROR_DC_NOT_FOUND 1425
+#define ERROR_INVALID_HOOK_FILTER 1426
+#define ERROR_INVALID_FILTER_PROC 1427
+#define ERROR_HOOK_NEEDS_HMOD 1428
+#define ERROR_GLOBAL_ONLY_HOOK 1429
+#define ERROR_JOURNAL_HOOK_SET 1430
+#define ERROR_HOOK_NOT_INSTALLED 1431
+#define ERROR_INVALID_LB_MESSAGE 1432
+#define ERROR_SETCOUNT_ON_BAD_LB 1433
+#define ERROR_LB_WITHOUT_TABSTOPS 1434
+#define ERROR_DESTROY_OBJECT_OF_OTHER_THREAD 1435
+#define ERROR_CHILD_WINDOW_MENU 1436
+#define ERROR_NO_SYSTEM_MENU 1437
+#define ERROR_INVALID_MSGBOX_STYLE 1438
+#define ERROR_INVALID_SPI_VALUE 1439
+#define ERROR_SCREEN_ALREADY_LOCKED 1440
+#define ERROR_HWNDS_HAVE_DIFF_PARENT 1441
+#define ERROR_NOT_CHILD_WINDOW 1442
+#define ERROR_INVALID_GW_COMMAND 1443
+#define ERROR_INVALID_THREAD_ID 1444
+#define ERROR_NON_MDICHILD_WINDOW 1445
+#define ERROR_POPUP_ALREADY_ACTIVE 1446
+#define ERROR_NO_SCROLLBARS 1447
+#define ERROR_INVALID_SCROLLBAR_RANGE 1448
+#define ERROR_INVALID_SHOWWIN_COMMAND 1449
+#define ERROR_NO_SYSTEM_RESOURCES 1450
+#define ERROR_NONPAGED_SYSTEM_RESOURCES 1451
+#define ERROR_PAGED_SYSTEM_RESOURCES 1452
+#define ERROR_WORKING_SET_QUOTA 1453
+#define ERROR_PAGEFILE_QUOTA 1454
+#define ERROR_COMMITMENT_LIMIT 1455
+#define ERROR_MENU_ITEM_NOT_FOUND 1456
+#define ERROR_INVALID_KEYBOARD_HANDLE 1457
+#define ERROR_HOOK_TYPE_NOT_ALLOWED 1458
+#define ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION 1459
+#define ERROR_TIMEOUT 1460
+#define ERROR_INVALID_MONITOR_HANDLE 1461
+
+#define ERROR_EVENTLOG_FILE_CORRUPT 1500
+#define ERROR_EVENTLOG_CANT_START 1501
+#define ERROR_LOG_FILE_FULL 1502
+#define ERROR_EVENTLOG_FILE_CHANGED 1503
+
+/*
+ * 1600-1699 installer errors
+ */
+#define ERROR_INSTALL_SERVICE_FAILURE 1601
+#define ERROR_INSTALL_USEREXIT 1602
+#define ERROR_INSTALL_FAILURE 1603
+#define ERROR_INSTALL_SUSPEND 1604
+#define ERROR_UNKNOWN_PRODUCT 1605
+#define ERROR_UNKNOWN_FEATURE 1606
+#define ERROR_UNKNOWN_COMPONENT 1607
+#define ERROR_UNKNOWN_PROPERTY 1608
+#define ERROR_INVALID_HANDLE_STATE 1609
+#define ERROR_BAD_CONFIGURATION 1610
+#define ERROR_INDEX_ABSENT 1611
+#define ERROR_INSTALL_SOURCE_ABSENT 1612
+#define ERROR_INSTALL_PACKAGE_VERSION 1613
+#define ERROR_PRODUCT_UNINSTALLED 1614
+#define ERROR_BAD_QUERY_SYNTAX 1615
+#define ERROR_INVALID_FIELD 1616
+#define ERROR_DEVICE_REMOVED 1617
+#define ERROR_INSTALL_ALREADY_RUNNING 1618
+#define ERROR_INSTALL_PACKAGE_OPEN_FAILED 1619
+#define ERROR_INSTALL_PACKAGE_INVALID 1620
+#define ERROR_INSTALL_UI_FAILURE 1621
+#define ERROR_INSTALL_LOG_FAILURE 1622
+#define ERROR_INSTALL_LANGUAGE_UNSUPPORTED 1623
+#define ERROR_INSTALL_TRANSFORM_FAILURE 1624
+#define ERROR_INSTALL_PACKAGE_REJECTED 1625
+#define ERROR_FUNCTION_NOT_CALLED 1626
+#define ERROR_FUNCTION_FAILED 1627
+#define ERROR_INVALID_TABLE 1628
+#define ERROR_DATATYPE_MISMATCH 1629
+#define ERROR_UNSUPPORTED_TYPE 1630
+#define ERROR_CREATE_FAILED 1631
+#define ERROR_INSTALL_TEMP_UNWRITABLE 1632
+#define ERROR_INSTALL_PLATFORM_UNSUPPORTED 1633
+#define ERROR_INSTALL_NOTUSED 1634
+#define ERROR_PATCH_PACKAGE_OPEN_FAILED 1635
+#define ERROR_PATCH_PACKAGE_INVALID 1636
+#define ERROR_PATCH_PACKAGE_UNSUPPORTED 1637
+#define ERROR_PRODUCT_VERSION 1638
+#define ERROR_INVALID_COMMAND_LINE 1639
+#define ERROR_INSTALL_REMOTE_DISALLOWED 1640
+#define ERROR_SUCCESS_REBOOT_INITIATED 1641
+#define ERROR_PATCH_TARGET_NOT_FOUND 1642
+#define ERROR_PATCH_PACKAGE_REJECTED 1643
+#define ERROR_INSTALL_TRANSFORM_REJECTED 1644
+
+#define RPC_S_INVALID_STRING_BINDING 1700
+#define RPC_S_WRONG_KIND_OF_BINDING 1701
+#define RPC_S_INVALID_BINDING 1702
+#define RPC_S_PROTSEQ_NOT_SUPPORTED 1703
+#define RPC_S_INVALID_RPC_PROTSEQ 1704
+#define RPC_S_INVALID_STRING_UUID 1705
+#define RPC_S_INVALID_ENDPOINT_FORMAT 1706
+#define RPC_S_INVALID_NET_ADDR 1707
+#define RPC_S_NO_ENDPOINT_FOUND 1708
+#define RPC_S_INVALID_TIMEOUT 1709
+#define RPC_S_OBJECT_NOT_FOUND 1710
+#define RPC_S_ALREADY_REGISTERED 1711
+#define RPC_S_TYPE_ALREADY_REGISTERED 1712
+#define RPC_S_ALREADY_LISTENING 1713
+#define RPC_S_NO_PROTSEQS_REGISTERED 1714
+#define RPC_S_NOT_LISTENING 1715
+#define RPC_S_UNKNOWN_MGR_TYPE 1716
+#define RPC_S_UNKNOWN_IF 1717
+#define RPC_S_NO_BINDINGS 1718
+#define RPC_S_NO_PROTSEQS 1719
+#define RPC_S_CANT_CREATE_ENDPOINT 1720
+#define RPC_S_OUT_OF_RESOURCES 1721
+#define RPC_S_SERVER_UNAVAILABLE 1722
+#define RPC_S_SERVER_TOO_BUSY 1723
+#define RPC_S_INVALID_NETWORK_OPTIONS 1724
+#define RPC_S_NO_CALL_ACTIVE 1725
+#define RPC_S_CALL_FAILED 1726
+#define RPC_S_CALL_FAILED_DNE 1727
+#define RPC_S_PROTOCOL_ERROR 1728
+#define RPC_S_UNSUPPORTED_TRANS_SYN 1730
+#define RPC_S_UNSUPPORTED_TYPE 1732
+#define RPC_S_INVALID_TAG 1733
+#define RPC_S_INVALID_BOUND 1734
+#define RPC_S_NO_ENTRY_NAME 1735
+#define RPC_S_INVALID_NAME_SYNTAX 1736
+#define RPC_S_UNSUPPORTED_NAME_SYNTAX 1737
+#define RPC_S_UUID_NO_ADDRESS 1739
+#define RPC_S_DUPLICATE_ENDPOINT 1740
+#define RPC_S_UNKNOWN_AUTHN_TYPE 1741
+#define RPC_S_MAX_CALLS_TOO_SMALL 1742
+#define RPC_S_STRING_TOO_LONG 1743
+#define RPC_S_PROTSEQ_NOT_FOUND 1744
+#define RPC_S_PROCNUM_OUT_OF_RANGE 1745
+#define RPC_S_BINDING_HAS_NO_AUTH 1746
+#define RPC_S_UNKNOWN_AUTHN_SERVICE 1747
+#define RPC_S_UNKNOWN_AUTHN_LEVEL 1748
+#define RPC_S_INVALID_AUTH_IDENTITY 1749
+#define RPC_S_UNKNOWN_AUTHZ_SERVICE 1750
+#define EPT_S_INVALID_ENTRY 1751
+#define EPT_S_CANT_PERFORM_OP 1752
+#define EPT_S_NOT_REGISTERED 1753
+#define RPC_S_NOTHING_TO_EXPORT 1754
+#define RPC_S_INCOMPLETE_NAME 1755
+#define RPC_S_INVALID_VERS_OPTION 1756
+#define RPC_S_NO_MORE_MEMBERS 1757
+#define RPC_S_NOT_ALL_OBJS_UNEXPORTED 1758
+#define RPC_S_INTERFACE_NOT_FOUND 1759
+#define RPC_S_ENTRY_ALREADY_EXISTS 1760
+#define RPC_S_ENTRY_NOT_FOUND 1761
+#define RPC_S_NAME_SERVICE_UNAVAILABLE 1762
+#define RPC_S_INVALID_NAF_ID 1763
+#define RPC_S_CANNOT_SUPPORT 1764
+#define RPC_S_NO_CONTEXT_AVAILABLE 1765
+#define RPC_S_INTERNAL_ERROR 1766
+#define RPC_S_ZERO_DIVIDE 1767
+#define RPC_S_ADDRESS_ERROR 1768
+#define RPC_S_FP_DIV_ZERO 1769
+#define RPC_S_FP_UNDERFLOW 1770
+#define RPC_S_FP_OVERFLOW 1771
+#define RPC_X_NO_MORE_ENTRIES 1772
+#define RPC_X_SS_CHAR_TRANS_OPEN_FAIL 1773
+#define RPC_X_SS_CHAR_TRANS_SHORT_FILE 1774
+#define RPC_X_SS_IN_NULL_CONTEXT 1775
+#define RPC_X_SS_CONTEXT_DAMAGED 1777
+#define RPC_X_SS_HANDLES_MISMATCH 1778
+#define RPC_X_SS_CANNOT_GET_CALL_HANDLE 1779
+#define RPC_X_NULL_REF_POINTER 1780
+#define RPC_X_ENUM_VALUE_OUT_OF_RANGE 1781
+#define RPC_X_BYTE_COUNT_TOO_SMALL 1782
+#define RPC_X_BAD_STUB_DATA 1783
+#define ERROR_INVALID_USER_BUFFER 1784
+#define ERROR_UNRECOGNIZED_MEDIA 1785
+#define ERROR_NO_TRUST_LSA_SECRET 1786
+#define ERROR_NO_TRUST_SAM_ACCOUNT 1787
+#define ERROR_TRUSTED_DOMAIN_FAILURE 1788
+#define ERROR_TRUSTED_RELATIONSHIP_FAILURE 1789
+#define ERROR_TRUST_FAILURE 1790
+#define RPC_S_CALL_IN_PROGRESS 1791
+#define ERROR_NETLOGON_NOT_STARTED 1792
+#define ERROR_ACCOUNT_EXPIRED 1793
+#define ERROR_REDIRECTOR_HAS_OPEN_HANDLES 1794
+#define ERROR_PRINTER_DRIVER_ALREADY_INSTALLED 1795
+#define ERROR_UNKNOWN_PORT 1796
+#define ERROR_UNKNOWN_PRINTER_DRIVER 1797
+#define ERROR_UNKNOWN_PRINTPROCESSOR 1798
+#define ERROR_INVALID_SEPARATOR_FILE 1799
+#define ERROR_INVALID_PRIORITY 1800
+#define ERROR_INVALID_PRINTER_NAME 1801
+#define ERROR_PRINTER_ALREADY_EXISTS 1802
+#define ERROR_INVALID_PRINTER_COMMAND 1803
+#define ERROR_INVALID_DATATYPE 1804
+#define ERROR_INVALID_ENVIRONMENT 1805
+#define RPC_S_NO_MORE_BINDINGS 1806
+#define ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 1807
+#define ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT 1808
+#define ERROR_NOLOGON_SERVER_TRUST_ACCOUNT 1809
+#define ERROR_DOMAIN_TRUST_INCONSISTENT 1810
+#define ERROR_SERVER_HAS_OPEN_HANDLES 1811
+#define ERROR_RESOURCE_DATA_NOT_FOUND 1812
+#define ERROR_RESOURCE_TYPE_NOT_FOUND 1813
+#define ERROR_RESOURCE_NAME_NOT_FOUND 1814
+#define ERROR_RESOURCE_LANG_NOT_FOUND 1815
+#define ERROR_NOT_ENOUGH_QUOTA 1816
+#define RPC_S_NO_INTERFACES 1817
+#define RPC_S_CALL_CANCELLED 1818
+#define RPC_S_BINDING_INCOMPLETE 1819
+#define RPC_S_COMM_FAILURE 1820
+#define RPC_S_UNSUPPORTED_AUTHN_LEVEL 1821
+#define RPC_S_NO_PRINC_NAME 1822
+#define RPC_S_NOT_RPC_ERROR 1823
+#define RPC_S_UUID_LOCAL_ONLY 1824
+#define RPC_S_SEC_PKG_ERROR 1825
+#define RPC_S_NOT_CANCELLED 1826
+#define RPC_X_INVALID_ES_ACTION 1827
+#define RPC_X_WRONG_ES_VERSION 1828
+#define RPC_X_WRONG_STUB_VERSION 1829
+#define RPC_X_INVALID_PIPE_OBJECT 1830
+#define RPC_X_WRONG_PIPE_ORDER 1831
+#define RPC_X_WRONG_PIPE_VERSION 1832
+#define RPC_S_GROUP_MEMBER_NOT_FOUND 1898
+#define EPT_S_CANT_CREATE 1899
+#define RPC_S_INVALID_OBJECT 1900
+#define ERROR_INVALID_TIME 1901
+#define ERROR_INVALID_FORM_NAME 1902
+#define ERROR_INVALID_FORM_SIZE 1903
+#define ERROR_ALREADY_WAITING 1904
+#define ERROR_PRINTER_DELETED 1905
+#define ERROR_INVALID_PRINTER_STATE 1906
+#define ERROR_PASSWORD_MUST_CHANGE 1907
+#define ERROR_DOMAIN_CONTROLLER_NOT_FOUND 1908
+#define ERROR_ACCOUNT_LOCKED_OUT 1909
+#define OR_INVALID_OXID 1910
+#define OR_INVALID_OID 1911
+#define OR_INVALID_SET 1912
+#define RPC_S_SEND_INCOMPLETE 1913
+#define RPC_S_INVALID_ASYNC_HANDLE 1914
+#define RPC_S_INVALID_ASYNC_CALL 1915
+#define RPC_X_PIPE_CLOSED 1916
+#define RPC_X_PIPE_DISCIPLINE_ERROR 1917
+#define RPC_X_PIPE_EMPTY 1918
+#define ERROR_NO_SITENAME 1919
+#define ERROR_CANT_ACCESS_FILE 1920
+#define ERROR_CANT_RESOLVE_FILENAME 1921
+#define RPC_S_ENTRY_TYPE_MISMATCH 1922
+#define RPC_S_NOT_ALL_OBJS_EXPORTED 1923
+#define RPC_S_INTERFACE_NOT_EXPORTED 1924
+#define RPC_S_PROFILE_NOT_ADDED 1925
+#define RPC_S_PRF_ELT_NOT_ADDED 1926
+#define RPC_S_PRF_ELT_NOT_REMOVED 1927
+#define RPC_S_GRP_ELT_NOT_ADDED 1928
+#define RPC_S_GRP_ELT_NOT_REMOVED 1929
+#define ERROR_KM_DRIVER_BLOCKED 1930
+#define ERROR_CONTEXT_EXPIRED 1931
+
+#define ERROR_INVALID_PIXEL_FORMAT 2000
+#define ERROR_BAD_DRIVER 2001
+#define ERROR_INVALID_WINDOW_STYLE 2002
+#define ERROR_METAFILE_NOT_SUPPORTED 2003
+#define ERROR_TRANSFORM_NOT_SUPPORTED 2004
+#define ERROR_CLIPPING_NOT_SUPPORTED 2005
+
+/*
+ * Note: See lmerr.h for codes 2100-2999
+ * (except for these next few)
+ */
+#define ERROR_CONNECTED_OTHER_PASSWORD 2108
+#define ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT 2109
+#define ERROR_BAD_USERNAME 2202
+#define ERROR_NOT_CONNECTED 2250
+#define ERROR_OPEN_FILES 2401
+#define ERROR_ACTIVE_CONNECTIONS 2402
+#define ERROR_DEVICE_IN_USE 2404
+
+#define ERROR_UNKNOWN_PRINT_MONITOR 3000
+#define ERROR_PRINTER_DRIVER_IN_USE 3001
+#define ERROR_SPOOL_FILE_NOT_FOUND 3002
+#define ERROR_SPL_NO_STARTDOC 3003
+#define ERROR_SPL_NO_ADDJOB 3004
+#define ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED 3005
+#define ERROR_PRINT_MONITOR_ALREADY_INSTALLED 3006
+#define ERROR_INVALID_PRINT_MONITOR 3007
+#define ERROR_PRINT_MONITOR_IN_USE 3008
+#define ERROR_PRINTER_HAS_JOBS_QUEUED 3009
+#define ERROR_SUCCESS_REBOOT_REQUIRED 3010
+#define ERROR_SUCCESS_RESTART_REQUIRED 3011
+#define ERROR_PRINTER_NOT_FOUND 3012
+#define ERROR_PRINTER_DRIVER_WARNED 3013
+#define ERROR_PRINTER_DRIVER_BLOCKED 3014
+
+#define ERROR_WINS_INTERNAL 4000
+#define ERROR_CAN_NOT_DEL_LOCAL_WINS 4001
+#define ERROR_STATIC_INIT 4002
+#define ERROR_INC_BACKUP 4003
+#define ERROR_FULL_BACKUP 4004
+#define ERROR_REC_NON_EXISTENT 4005
+#define ERROR_RPL_NOT_ALLOWED 4006
+
+#define ERROR_DHCP_ADDRESS_CONFLICT 4100
+#define ERROR_WMI_GUID_NOT_FOUND 4200
+#define ERROR_WMI_INSTANCE_NOT_FOUND 4201
+#define ERROR_WMI_ITEMID_NOT_FOUND 4202
+#define ERROR_WMI_TRY_AGAIN 4203
+#define ERROR_WMI_DP_NOT_FOUND 4204
+#define ERROR_WMI_UNRESOLVED_INSTANCE_REF 4205
+#define ERROR_WMI_ALREADY_ENABLED 4206
+#define ERROR_WMI_GUID_DISCONNECTED 4207
+#define ERROR_WMI_SERVER_UNAVAILABLE 4208
+#define ERROR_WMI_DP_FAILED 4209
+#define ERROR_WMI_INVALID_MOF 4210
+#define ERROR_WMI_INVALID_REGINFO 4211
+#define ERROR_WMI_ALREADY_DISABLED 4212
+#define ERROR_WMI_READ_ONLY 4213
+#define ERROR_WMI_SET_FAILURE 4214
+
+#define ERROR_INVALID_MEDIA 4300
+#define ERROR_INVALID_LIBRARY 4301
+#define ERROR_INVALID_MEDIA_POOL 4302
+#define ERROR_DRIVE_MEDIA_MISMATCH 4303
+#define ERROR_MEDIA_OFFLINE 4304
+#define ERROR_LIBRARY_OFFLINE 4305
+#define ERROR_EMPTY 4306
+#define ERROR_NOT_EMPTY 4307
+#define ERROR_MEDIA_UNAVAILABLE 4308
+#define ERROR_RESOURCE_DISABLED 4309
+#define ERROR_INVALID_CLEANER 4310
+#define ERROR_UNABLE_TO_CLEAN 4311
+#define ERROR_OBJECT_NOT_FOUND 4312
+#define ERROR_DATABASE_FAILURE 4313
+#define ERROR_DATABASE_FULL 4314
+#define ERROR_MEDIA_INCOMPATIBLE 4315
+#define ERROR_RESOURCE_NOT_PRESENT 4316
+#define ERROR_INVALID_OPERATION 4317
+#define ERROR_MEDIA_NOT_AVAILABLE 4318
+#define ERROR_DEVICE_NOT_AVAILABLE 4319
+#define ERROR_REQUEST_REFUSED 4320
+#define ERROR_INVALID_DRIVE_OBJECT 4321
+#define ERROR_LIBRARY_FULL 4322
+#define ERROR_MEDIUM_NOT_ACCESSIBLE 4323
+#define ERROR_UNABLE_TO_LOAD_MEDIUM 4324
+#define ERROR_UNABLE_TO_INVENTORY_DRIVE 4325
+#define ERROR_UNABLE_TO_INVENTORY_SLOT 4326
+#define ERROR_UNABLE_TO_INVENTORY_TRANSPORT 4327
+#define ERROR_TRANSPORT_FULL 4328
+#define ERROR_CONTROLLING_IEPORT 4329
+#define ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA 4330
+#define ERROR_CLEANER_SLOT_SET 4331
+#define ERROR_CLEANER_SLOT_NOT_SET 4332
+#define ERROR_CLEANER_CARTRIDGE_SPENT 4333
+#define ERROR_UNEXPECTED_OMID 4334
+#define ERROR_CANT_DELETE_LAST_ITEM 4335
+#define ERROR_MESSAGE_EXCEEDS_MAX_SIZE 4336
+#define ERROR_VOLUME_CONTAINS_SYS_FILES 4337
+#define ERROR_INDIGENOUS_TYPE 4338
+#define ERROR_NO_SUPPORTING_DRIVES 4339
+#define ERROR_CLEANER_CARTRIDGE_INSTALLED 4340
+
+#define ERROR_FILE_OFFLINE 4350
+#define ERROR_REMOTE_STORAGE_NOT_ACTIVE 4351
+#define ERROR_REMOTE_STORAGE_MEDIA_ERROR 4352
+#define ERROR_NOT_A_REPARSE_POINT 4390
+#define ERROR_REPARSE_ATTRIBUTE_CONFLICT 4391
+#define ERROR_INVALID_REPARSE_DATA 4392
+#define ERROR_REPARSE_TAG_INVALID 4393
+#define ERROR_REPARSE_TAG_MISMATCH 4394
+
+#define ERROR_VOLUME_NOT_SIS_ENABLED 4500
+
+/*
+ * 5000-5999 appear to be cluster sub-system errors.
+ */
+#define ERROR_DEPENDENT_RESOURCE_EXISTS 5001
+#define ERROR_DEPENDENCY_NOT_FOUND 5002
+#define ERROR_DEPENDENCY_ALREADY_EXISTS 5003
+#define ERROR_RESOURCE_NOT_ONLINE 5004
+#define ERROR_HOST_NODE_NOT_AVAILABLE 5005
+#define ERROR_RESOURCE_NOT_AVAILABLE 5006
+#define ERROR_RESOURCE_NOT_FOUND 5007
+#define ERROR_SHUTDOWN_CLUSTER 5008
+#define ERROR_CANT_EVICT_ACTIVE_NODE 5009
+#define ERROR_OBJECT_ALREADY_EXISTS 5010
+#define ERROR_OBJECT_IN_LIST 5011
+#define ERROR_GROUP_NOT_AVAILABLE 5012
+#define ERROR_GROUP_NOT_FOUND 5013
+#define ERROR_GROUP_NOT_ONLINE 5014
+#define ERROR_HOST_NODE_NOT_RESOURCE_OWNER 5015
+#define ERROR_HOST_NODE_NOT_GROUP_OWNER 5016
+#define ERROR_RESMON_CREATE_FAILED 5017
+#define ERROR_RESMON_ONLINE_FAILED 5018
+#define ERROR_RESOURCE_ONLINE 5019
+#define ERROR_QUORUM_RESOURCE 5020
+#define ERROR_NOT_QUORUM_CAPABLE 5021
+#define ERROR_CLUSTER_SHUTTING_DOWN 5022
+#define ERROR_INVALID_STATE 5023
+#define ERROR_RESOURCE_PROPERTIES_STORED 5024
+#define ERROR_NOT_QUORUM_CLASS 5025
+#define ERROR_CORE_RESOURCE 5026
+#define ERROR_QUORUM_RESOURCE_ONLINE_FAILED 5027
+#define ERROR_QUORUMLOG_OPEN_FAILED 5028
+#define ERROR_CLUSTERLOG_CORRUPT 5029
+#define ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE 5030
+#define ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE 5031
+#define ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND 5032
+#define ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE 5033
+#define ERROR_QUORUM_OWNER_ALIVE 5034
+#define ERROR_NETWORK_NOT_AVAILABLE 5035
+#define ERROR_NODE_NOT_AVAILABLE 5036
+#define ERROR_ALL_NODES_NOT_AVAILABLE 5037
+#define ERROR_RESOURCE_FAILED 5038
+#define ERROR_CLUSTER_INVALID_NODE 5039
+#define ERROR_CLUSTER_NODE_EXISTS 5040
+#define ERROR_CLUSTER_JOIN_IN_PROGRESS 5041
+#define ERROR_CLUSTER_NODE_NOT_FOUND 5042
+#define ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND 5043
+#define ERROR_CLUSTER_NETWORK_EXISTS 5044
+#define ERROR_CLUSTER_NETWORK_NOT_FOUND 5045
+#define ERROR_CLUSTER_NETINTERFACE_EXISTS 5046
+#define ERROR_CLUSTER_NETINTERFACE_NOT_FOUND 5047
+#define ERROR_CLUSTER_INVALID_REQUEST 5048
+#define ERROR_CLUSTER_INVALID_NETWORK_PROVIDER 5049
+#define ERROR_CLUSTER_NODE_DOWN 5050
+#define ERROR_CLUSTER_NODE_UNREACHABLE 5051
+#define ERROR_CLUSTER_NODE_NOT_MEMBER 5052
+#define ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS 5053
+#define ERROR_CLUSTER_INVALID_NETWORK 5054
+#define ERROR_CLUSTER_NODE_UP 5056
+#define ERROR_CLUSTER_IPADDR_IN_USE 5057
+#define ERROR_CLUSTER_NODE_NOT_PAUSED 5058
+#define ERROR_CLUSTER_NO_SECURITY_CONTEXT 5059
+#define ERROR_CLUSTER_NETWORK_NOT_INTERNAL 5060
+#define ERROR_CLUSTER_NODE_ALREADY_UP 5061
+#define ERROR_CLUSTER_NODE_ALREADY_DOWN 5062
+#define ERROR_CLUSTER_NETWORK_ALREADY_ONLINE 5063
+#define ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE 5064
+#define ERROR_CLUSTER_NODE_ALREADY_MEMBER 5065
+#define ERROR_CLUSTER_LAST_INTERNAL_NETWORK 5066
+#define ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS 5067
+#define ERROR_INVALID_OPERATION_ON_QUORUM 5068
+#define ERROR_DEPENDENCY_NOT_ALLOWED 5069
+#define ERROR_CLUSTER_NODE_PAUSED 5070
+#define ERROR_NODE_CANT_HOST_RESOURCE 5071
+#define ERROR_CLUSTER_NODE_NOT_READY 5072
+#define ERROR_CLUSTER_NODE_SHUTTING_DOWN 5073
+#define ERROR_CLUSTER_JOIN_ABORTED 5074
+#define ERROR_CLUSTER_INCOMPATIBLE_VERSIONS 5075
+#define ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED 5076
+#define ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED 5077
+#define ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND 5078
+#define ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED 5079
+#define ERROR_CLUSTER_RESNAME_NOT_FOUND 5080
+#define ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED 5081
+#define ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST 5082
+#define ERROR_CLUSTER_DATABASE_SEQMISMATCH 5083
+#define ERROR_RESMON_INVALID_STATE 5084
+#define ERROR_CLUSTER_GUM_NOT_LOCKER 5085
+#define ERROR_QUORUM_DISK_NOT_FOUND 5086
+#define ERROR_DATABASE_BACKUP_CORRUPT 5087
+#define ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT 5088
+#define ERROR_RESOURCE_PROPERTY_UNCHANGEABLE 5089
+#define ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE 5890
+#define ERROR_CLUSTER_QUORUMLOG_NOT_FOUND 5891
+#define ERROR_CLUSTER_MEMBERSHIP_HALT 5892
+#define ERROR_CLUSTER_INSTANCE_ID_MISMATCH 5893
+#define ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP 5894
+#define ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH 5895
+#define ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP 5896
+#define ERROR_CLUSTER_PARAMETER_MISMATCH 5897
+#define ERROR_NODE_CANNOT_BE_CLUSTERED 5898
+#define ERROR_CLUSTER_WRONG_OS_VERSION 5899
+#define ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME 5900
+
+/*
+ * 6000-6099? encrypted file system error codes
+ */
+#define ERROR_ENCRYPTION_FAILED 6000
+#define ERROR_DECRYPTION_FAILED 6001
+#define ERROR_FILE_ENCRYPTED 6002
+#define ERROR_NO_RECOVERY_POLICY 6003
+#define ERROR_NO_EFS 6004
+#define ERROR_WRONG_EFS 6005
+#define ERROR_NO_USER_KEYS 6006
+#define ERROR_FILE_NOT_ENCRYPTED 6007
+#define ERROR_NOT_EXPORT_FORMAT 6008
+#define ERROR_FILE_READ_ONLY 6009
+#define ERROR_DIR_EFS_DISALLOWED 6010
+#define ERROR_EFS_SERVER_NOT_TRUSTED 6011
+#define ERROR_BAD_RECOVERY_POLICY 6012
+#define ERROR_EFS_ALG_BLOB_TOO_BIG 6013
+#define ERROR_VOLUME_NOT_SUPPORT_EFS 6014
+#define ERROR_EFS_DISABLED 6015
+#define ERROR_EFS_VERSION_NOT_SUPPORT 6016
+
+#define ERROR_NO_BROWSER_SERVERS_FOUND 6118
+
+/*
+ * 8200-8999? directory service errors
+ */
+#define ERROR_DS_NOT_INSTALLED 8200
+#define ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY 8201
+#define ERROR_DS_NO_ATTRIBUTE_OR_VALUE 8202
+#define ERROR_DS_INVALID_ATTRIBUTE_SYNTAX 8203
+#define ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED 8204
+#define ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS 8205
+#define ERROR_DS_BUSY 8206
+#define ERROR_DS_UNAVAILABLE 8207
+#define ERROR_DS_NO_RIDS_ALLOCATED 8208
+#define ERROR_DS_NO_MORE_RIDS 8209
+#define ERROR_DS_INCORRECT_ROLE_OWNER 8210
+#define ERROR_DS_RIDMGR_INIT_ERROR 8211
+#define ERROR_DS_OBJ_CLASS_VIOLATION 8212
+#define ERROR_DS_CANT_ON_NON_LEAF 8213
+#define ERROR_DS_CANT_ON_RDN 8214
+#define ERROR_DS_CANT_MOD_OBJ_CLASS 8215
+#define ERROR_DS_CROSS_DOM_MOVE_ERROR 8216
+#define ERROR_DS_GC_NOT_AVAILABLE 8217
+#define ERROR_SHARED_POLICY 8218
+#define ERROR_POLICY_OBJECT_NOT_FOUND 8219
+#define ERROR_POLICY_ONLY_IN_DS 8220
+#define ERROR_PROMOTION_ACTIVE 8221
+#define ERROR_NO_PROMOTION_ACTIVE 8222
+#define ERROR_DS_OPERATIONS_ERROR 8224
+#define ERROR_DS_PROTOCOL_ERROR 8225
+#define ERROR_DS_TIMELIMIT_EXCEEDED 8226
+#define ERROR_DS_SIZELIMIT_EXCEEDED 8227
+#define ERROR_DS_ADMIN_LIMIT_EXCEEDED 8228
+#define ERROR_DS_COMPARE_FALSE 8229
+#define ERROR_DS_COMPARE_TRUE 8230
+#define ERROR_DS_AUTH_METHOD_NOT_SUPPORTED 8231
+#define ERROR_DS_STRONG_AUTH_REQUIRED 8232
+#define ERROR_DS_INAPPROPRIATE_AUTH 8233
+#define ERROR_DS_AUTH_UNKNOWN 8234
+#define ERROR_DS_REFERRAL 8235
+#define ERROR_DS_UNAVAILABLE_CRIT_EXTENSION 8236
+#define ERROR_DS_CONFIDENTIALITY_REQUIRED 8237
+#define ERROR_DS_INAPPROPRIATE_MATCHING 8238
+#define ERROR_DS_CONSTRAINT_VIOLATION 8239
+#define ERROR_DS_NO_SUCH_OBJECT 8240
+#define ERROR_DS_ALIAS_PROBLEM 8241
+#define ERROR_DS_INVALID_DN_SYNTAX 8242
+#define ERROR_DS_IS_LEAF 8243
+#define ERROR_DS_ALIAS_DEREF_PROBLEM 8244
+#define ERROR_DS_UNWILLING_TO_PERFORM 8245
+#define ERROR_DS_LOOP_DETECT 8246
+#define ERROR_DS_NAMING_VIOLATION 8247
+#define ERROR_DS_OBJECT_RESULTS_TOO_LARGE 8248
+#define ERROR_DS_AFFECTS_MULTIPLE_DSAS 8249
+#define ERROR_DS_SERVER_DOWN 8250
+#define ERROR_DS_LOCAL_ERROR 8251
+#define ERROR_DS_ENCODING_ERROR 8252
+#define ERROR_DS_DECODING_ERROR 8253
+#define ERROR_DS_FILTER_UNKNOWN 8254
+#define ERROR_DS_PARAM_ERROR 8255
+#define ERROR_DS_NOT_SUPPORTED 8256
+#define ERROR_DS_NO_RESULTS_RETURNED 8257
+#define ERROR_DS_CONTROL_NOT_FOUND 8258
+#define ERROR_DS_CLIENT_LOOP 8259
+#define ERROR_DS_REFERRAL_LIMIT_EXCEEDED 8260
+#define ERROR_DS_SORT_CONTROL_MISSING 8261
+#define ERROR_DS_OFFSET_RANGE_ERROR 8262
+#define ERROR_DS_ROOT_MUST_BE_NC 8301
+#define ERROR_DS_ADD_REPLICA_INHIBITED 8302
+#define ERROR_DS_ATT_NOT_DEF_IN_SCHEMA 8303
+#define ERROR_DS_MAX_OBJ_SIZE_EXCEEDED 8304
+#define ERROR_DS_OBJ_STRING_NAME_EXISTS 8305
+#define ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA 8306
+#define ERROR_DS_RDN_DOESNT_MATCH_SCHEMA 8307
+#define ERROR_DS_NO_REQUESTED_ATTS_FOUND 8308
+#define ERROR_DS_USER_BUFFER_TO_SMALL 8309
+#define ERROR_DS_ATT_IS_NOT_ON_OBJ 8310
+#define ERROR_DS_ILLEGAL_MOD_OPERATION 8311
+#define ERROR_DS_OBJ_TOO_LARGE 8312
+#define ERROR_DS_BAD_INSTANCE_TYPE 8313
+#define ERROR_DS_MASTERDSA_REQUIRED 8314
+#define ERROR_DS_OBJECT_CLASS_REQUIRED 8315
+#define ERROR_DS_MISSING_REQUIRED_ATT 8316
+#define ERROR_DS_ATT_NOT_DEF_FOR_CLASS 8317
+#define ERROR_DS_ATT_ALREADY_EXISTS 8318
+#define ERROR_DS_CANT_ADD_ATT_VALUES 8320
+#define ERROR_DS_SINGLE_VALUE_CONSTRAINT 8321
+#define ERROR_DS_RANGE_CONSTRAINT 8322
+#define ERROR_DS_ATT_VAL_ALREADY_EXISTS 8323
+#define ERROR_DS_CANT_REM_MISSING_ATT 8324
+#define ERROR_DS_CANT_REM_MISSING_ATT_VAL 8325
+#define ERROR_DS_ROOT_CANT_BE_SUBREF 8326
+#define ERROR_DS_NO_CHAINING 8327
+#define ERROR_DS_NO_CHAINED_EVAL 8328
+#define ERROR_DS_NO_PARENT_OBJECT 8329
+#define ERROR_DS_PARENT_IS_AN_ALIAS 8330
+#define ERROR_DS_CANT_MIX_MASTER_AND_REPS 8331
+#define ERROR_DS_CHILDREN_EXIST 8332
+#define ERROR_DS_OBJ_NOT_FOUND 8333
+#define ERROR_DS_ALIASED_OBJ_MISSING 8334
+#define ERROR_DS_BAD_NAME_SYNTAX 8335
+#define ERROR_DS_ALIAS_POINTS_TO_ALIAS 8336
+#define ERROR_DS_CANT_DEREF_ALIAS 8337
+#define ERROR_DS_OUT_OF_SCOPE 8338
+#define ERROR_DS_OBJECT_BEING_REMOVED 8339
+#define ERROR_DS_CANT_DELETE_DSA_OBJ 8340
+#define ERROR_DS_GENERIC_ERROR 8341
+#define ERROR_DS_DSA_MUST_BE_INT_MASTER 8342
+#define ERROR_DS_CLASS_NOT_DSA 8343
+#define ERROR_DS_INSUFF_ACCESS_RIGHTS 8344
+#define ERROR_DS_ILLEGAL_SUPERIOR 8345
+#define ERROR_DS_ATTRIBUTE_OWNED_BY_SAM 8346
+#define ERROR_DS_NAME_TOO_MANY_PARTS 8347
+#define ERROR_DS_NAME_TOO_LONG 8348
+#define ERROR_DS_NAME_VALUE_TOO_LONG 8349
+#define ERROR_DS_NAME_UNPARSEABLE 8350
+#define ERROR_DS_NAME_TYPE_UNKNOWN 8351
+#define ERROR_DS_NOT_AN_OBJECT 8352
+#define ERROR_DS_SEC_DESC_TOO_SHORT 8353
+#define ERROR_DS_SEC_DESC_INVALID 8354
+#define ERROR_DS_NO_DELETED_NAME 8355
+#define ERROR_DS_SUBREF_MUST_HAVE_PARENT 8356
+#define ERROR_DS_NCNAME_MUST_BE_NC 8357
+#define ERROR_DS_CANT_ADD_SYSTEM_ONLY 8358
+#define ERROR_DS_CLASS_MUST_BE_CONCRETE 8359
+#define ERROR_DS_INVALID_DMD 8360
+#define ERROR_DS_OBJ_GUID_EXISTS 8361
+#define ERROR_DS_NOT_ON_BACKLINK 8362
+#define ERROR_DS_NO_CROSSREF_FOR_NC 8363
+#define ERROR_DS_SHUTTING_DOWN 8364
+#define ERROR_DS_UNKNOWN_OPERATION 8365
+#define ERROR_DS_INVALID_ROLE_OWNER 8366
+#define ERROR_DS_COULDNT_CONTACT_FSMO 8367
+#define ERROR_DS_CROSS_NC_DN_RENAME 8368
+#define ERROR_DS_CANT_MOD_SYSTEM_ONLY 8369
+#define ERROR_DS_REPLICATOR_ONLY 8370
+#define ERROR_DS_OBJ_CLASS_NOT_DEFINED 8371
+#define ERROR_DS_OBJ_CLASS_NOT_SUBCLASS 8372
+#define ERROR_DS_NAME_REFERENCE_INVALID 8373
+#define ERROR_DS_CROSS_REF_EXISTS 8374
+#define ERROR_DS_CANT_DEL_MASTER_CROSSREF 8375
+#define ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD 8376
+#define ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX 8377
+#define ERROR_DS_DUP_RDN 8378
+#define ERROR_DS_DUP_OID 8379
+#define ERROR_DS_DUP_MAPI_ID 8380
+#define ERROR_DS_DUP_SCHEMA_ID_GUID 8381
+#define ERROR_DS_DUP_LDAP_DISPLAY_NAME 8382
+#define ERROR_DS_SEMANTIC_ATT_TEST 8383
+#define ERROR_DS_SYNTAX_MISMATCH 8384
+#define ERROR_DS_EXISTS_IN_MUST_HAVE 8385
+#define ERROR_DS_EXISTS_IN_MAY_HAVE 8386
+#define ERROR_DS_NONEXISTENT_MAY_HAVE 8387
+#define ERROR_DS_NONEXISTENT_MUST_HAVE 8388
+#define ERROR_DS_AUX_CLS_TEST_FAIL 8389
+#define ERROR_DS_NONEXISTENT_POSS_SUP 8390
+#define ERROR_DS_SUB_CLS_TEST_FAIL 8391
+#define ERROR_DS_BAD_RDN_ATT_ID_SYNTAX 8392
+#define ERROR_DS_EXISTS_IN_AUX_CLS 8393
+#define ERROR_DS_EXISTS_IN_SUB_CLS 8394
+#define ERROR_DS_EXISTS_IN_POSS_SUP 8395
+#define ERROR_DS_RECALCSCHEMA_FAILED 8396
+#define ERROR_DS_TREE_DELETE_NOT_FINISHED 8397
+#define ERROR_DS_CANT_DELETE 8398
+#define ERROR_DS_ATT_SCHEMA_REQ_ID 8399
+#define ERROR_DS_BAD_ATT_SCHEMA_SYNTAX 8400
+#define ERROR_DS_CANT_CACHE_ATT 8401
+#define ERROR_DS_CANT_CACHE_CLASS 8402
+#define ERROR_DS_CANT_REMOVE_ATT_CACHE 8403
+#define ERROR_DS_CANT_REMOVE_CLASS_CACHE 8404
+#define ERROR_DS_CANT_RETRIEVE_DN 8405
+#define ERROR_DS_MISSING_SUPREF 8406
+#define ERROR_DS_CANT_RETRIEVE_INSTANCE 8407
+#define ERROR_DS_CODE_INCONSISTENCY 8408
+#define ERROR_DS_DATABASE_ERROR 8409
+#define ERROR_DS_GOVERNSID_MISSING 8410
+#define ERROR_DS_MISSING_EXPECTED_ATT 8411
+#define ERROR_DS_NCNAME_MISSING_CR_REF 8412
+#define ERROR_DS_SECURITY_CHECKING_ERROR 8413
+#define ERROR_DS_SCHEMA_NOT_LOADED 8414
+#define ERROR_DS_SCHEMA_ALLOC_FAILED 8415
+#define ERROR_DS_ATT_SCHEMA_REQ_SYNTAX 8416
+#define ERROR_DS_GCVERIFY_ERROR 8417
+#define ERROR_DS_DRA_SCHEMA_MISMATCH 8418
+#define ERROR_DS_CANT_FIND_DSA_OBJ 8419
+#define ERROR_DS_CANT_FIND_EXPECTED_NC 8420
+#define ERROR_DS_CANT_FIND_NC_IN_CACHE 8421
+#define ERROR_DS_CANT_RETRIEVE_CHILD 8422
+#define ERROR_DS_SECURITY_ILLEGAL_MODIFY 8423
+#define ERROR_DS_CANT_REPLACE_HIDDEN_REC 8424
+#define ERROR_DS_BAD_HIERARCHY_FILE 8425
+#define ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED 8426
+#define ERROR_DS_CONFIG_PARAM_MISSING 8427
+#define ERROR_DS_COUNTING_AB_INDICES_FAILED 8428
+#define ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED 8429
+#define ERROR_DS_INTERNAL_FAILURE 8430
+#define ERROR_DS_UNKNOWN_ERROR 8431
+#define ERROR_DS_ROOT_REQUIRES_CLASS_TOP 8432
+#define ERROR_DS_REFUSING_FSMO_ROLES 8433
+#define ERROR_DS_MISSING_FSMO_SETTINGS 8434
+#define ERROR_DS_UNABLE_TO_SURRENDER_ROLES 8435
+#define ERROR_DS_DRA_GENERIC 8436
+#define ERROR_DS_DRA_INVALID_PARAMETER 8437
+#define ERROR_DS_DRA_BUSY 8438
+#define ERROR_DS_DRA_BAD_DN 8439
+#define ERROR_DS_DRA_BAD_NC 8440
+#define ERROR_DS_DRA_DN_EXISTS 8441
+#define ERROR_DS_DRA_INTERNAL_ERROR 8442
+#define ERROR_DS_DRA_INCONSISTENT_DIT 8443
+#define ERROR_DS_DRA_CONNECTION_FAILED 8444
+#define ERROR_DS_DRA_BAD_INSTANCE_TYPE 8445
+#define ERROR_DS_DRA_OUT_OF_MEM 8446
+#define ERROR_DS_DRA_MAIL_PROBLEM 8447
+#define ERROR_DS_DRA_REF_ALREADY_EXISTS 8448
+#define ERROR_DS_DRA_REF_NOT_FOUND 8449
+#define ERROR_DS_DRA_OBJ_IS_REP_SOURCE 8450
+#define ERROR_DS_DRA_DB_ERROR 8451
+#define ERROR_DS_DRA_NO_REPLICA 8452
+#define ERROR_DS_DRA_ACCESS_DENIED 8453
+#define ERROR_DS_DRA_NOT_SUPPORTED 8454
+#define ERROR_DS_DRA_RPC_CANCELLED 8455
+#define ERROR_DS_DRA_SOURCE_DISABLED 8456
+#define ERROR_DS_DRA_SINK_DISABLED 8457
+#define ERROR_DS_DRA_NAME_COLLISION 8458
+#define ERROR_DS_DRA_SOURCE_REINSTALLED 8459
+#define ERROR_DS_DRA_MISSING_PARENT 8460
+#define ERROR_DS_DRA_PREEMPTED 8461
+#define ERROR_DS_DRA_ABANDON_SYNC 8462
+#define ERROR_DS_DRA_SHUTDOWN 8463
+#define ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET 8464
+#define ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA 8465
+#define ERROR_DS_DRA_EXTN_CONNECTION_FAILED 8466
+#define ERROR_DS_INSTALL_SCHEMA_MISMATCH 8467
+#define ERROR_DS_DUP_LINK_ID 8468
+#define ERROR_DS_NAME_ERROR_RESOLVING 8469
+#define ERROR_DS_NAME_ERROR_NOT_FOUND 8470
+#define ERROR_DS_NAME_ERROR_NOT_UNIQUE 8471
+#define ERROR_DS_NAME_ERROR_NO_MAPPING 8472
+#define ERROR_DS_NAME_ERROR_DOMAIN_ONLY 8473
+#define ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING 8474
+#define ERROR_DS_CONSTRUCTED_ATT_MOD 8475
+#define ERROR_DS_WRONG_OM_OBJ_CLASS 8476
+#define ERROR_DS_DRA_REPL_PENDING 8477
+#define ERROR_DS_DS_REQUIRED 8478
+#define ERROR_DS_INVALID_LDAP_DISPLAY_NAME 8479
+#define ERROR_DS_NON_BASE_SEARCH 8480
+#define ERROR_DS_CANT_RETRIEVE_ATTS 8481
+#define ERROR_DS_BACKLINK_WITHOUT_LINK 8482
+#define ERROR_DS_EPOCH_MISMATCH 8483
+#define ERROR_DS_SRC_NAME_MISMATCH 8484
+#define ERROR_DS_SRC_AND_DST_NC_IDENTICAL 8485
+#define ERROR_DS_DST_NC_MISMATCH 8486
+#define ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC 8487
+#define ERROR_DS_SRC_GUID_MISMATCH 8488
+#define ERROR_DS_CANT_MOVE_DELETED_OBJECT 8489
+#define ERROR_DS_PDC_OPERATION_IN_PROGRESS 8490
+#define ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD 8491
+#define ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION 8492
+#define ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS 8493
+#define ERROR_DS_NC_MUST_HAVE_NC_PARENT 8494
+#define ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE 8495
+#define ERROR_DS_DST_DOMAIN_NOT_NATIVE 8496
+#define ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER 8497
+#define ERROR_DS_CANT_MOVE_ACCOUNT_GROUP 8498
+#define ERROR_DS_CANT_MOVE_RESOURCE_GROUP 8499
+#define ERROR_DS_INVALID_SEARCH_FLAG 8500
+#define ERROR_DS_NO_TREE_DELETE_ABOVE_NC 8501
+#define ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE 8502
+#define ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE 8503
+#define ERROR_DS_SAM_INIT_FAILURE 8504
+#define ERROR_DS_SENSITIVE_GROUP_VIOLATION 8505
+#define ERROR_DS_CANT_MOD_PRIMARYGROUPID 8506
+#define ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD 8507
+#define ERROR_DS_NONSAFE_SCHEMA_CHANGE 8508
+#define ERROR_DS_SCHEMA_UPDATE_DISALLOWED 8509
+#define ERROR_DS_CANT_CREATE_UNDER_SCHEMA 8510
+#define ERROR_DS_INSTALL_NO_SRC_SCH_VERSION 8511
+#define ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE 8512
+#define ERROR_DS_INVALID_GROUP_TYPE 8513
+#define ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN 8514
+#define ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN 8515
+#define ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER 8516
+#define ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER 8517
+#define ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER 8518
+#define ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER 8519
+#define ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER 8520
+#define ERROR_DS_HAVE_PRIMARY_MEMBERS 8521
+#define ERROR_DS_STRING_SD_CONVERSION_FAILED 8522
+#define ERROR_DS_NAMING_MASTER_GC 8523
+#define ERROR_DS_DNS_LOOKUP_FAILURE 8524
+#define ERROR_DS_COULDNT_UPDATE_SPNS 8525
+#define ERROR_DS_CANT_RETRIEVE_SD 8526
+#define ERROR_DS_KEY_NOT_UNIQUE 8527
+#define ERROR_DS_WRONG_LINKED_ATT_SYNTAX 8528
+#define ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD 8529
+#define ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY 8530
+#define ERROR_DS_CANT_START 8531
+#define ERROR_DS_INIT_FAILURE 8532
+#define ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION 8533
+#define ERROR_DS_SOURCE_DOMAIN_IN_FOREST 8534
+#define ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST 8535
+#define ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED 8536
+#define ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN 8537
+#define ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER 8538
+#define ERROR_DS_SRC_SID_EXISTS_IN_FOREST 8539
+#define ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH 8540
+#define ERROR_SAM_INIT_FAILURE 8541
+#define ERROR_DS_DRA_SCHEMA_INFO_SHIP 8542
+#define ERROR_DS_DRA_SCHEMA_CONFLICT 8543
+#define ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT 8544
+#define ERROR_DS_DRA_OBJ_NC_MISMATCH 8545
+#define ERROR_DS_NC_STILL_HAS_DSAS 8546
+#define ERROR_DS_GC_REQUIRED 8547
+#define ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY 8548
+#define ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS 8549
+#define ERROR_DS_CANT_ADD_TO_GC 8550
+#define ERROR_DS_NO_CHECKPOINT_WITH_PDC 8551
+#define ERROR_DS_SOURCE_AUDITING_NOT_ENABLED 8552
+#define ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC 8553
+#define ERROR_DS_INVALID_NAME_FOR_SPN 8554
+#define ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS 8555
+#define ERROR_DS_UNICODEPWD_NOT_IN_QUOTES 8556
+#define ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED 8557
+#define ERROR_DS_MUST_BE_RUN_ON_DST_DC 8558
+#define ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER 8559
+#define ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ 8560
+#define ERROR_DS_INIT_FAILURE_CONSOLE 8561
+#define ERROR_DS_SAM_INIT_FAILURE_CONSOLE 8562
+#define ERROR_DS_FOREST_VERSION_TOO_HIGH 8563
+#define ERROR_DS_DOMAIN_VERSION_TOO_HIGH 8564
+#define ERROR_DS_FOREST_VERSION_TOO_LOW 8565
+#define ERROR_DS_DOMAIN_VERSION_TOO_LOW 8566
+#define ERROR_DS_INCOMPATIBLE_VERSION 8567
+#define ERROR_DS_LOW_DSA_VERSION 8568
+#define ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN 8569
+#define ERROR_DS_NOT_SUPPORTED_SORT_ORDER 8570
+#define ERROR_DS_NAME_NOT_UNIQUE 8571
+#define ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 8572
+#define ERROR_DS_OUT_OF_VERSION_STORE 8573
+#define ERROR_DS_INCOMPATIBLE_CONTROLS_USED 8574
+#define ERROR_DS_NO_REF_DOMAIN 8575
+#define ERROR_DS_RESERVED_LINK_ID 8576
+#define ERROR_DS_LINK_ID_NOT_AVAILABLE 8577
+#define ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER 8578
+#define ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE 8579
+#define ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC 8580
+#define ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG 8581
+#define ERROR_DS_MODIFYDN_WRONG_GRANDPARENT 8582
+#define ERROR_DS_NAME_ERROR_TRUST_REFERRAL 8583
+#define ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER 8584
+#define ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD 8585
+#define ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2 8586
+#define ERROR_DS_THREAD_LIMIT_EXCEEDED 8587
+#define ERROR_DS_NOT_CLOSEST 8588
+#define ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF 8589
+#define ERROR_DS_SINGLE_USER_MODE_FAILED 8590
+#define ERROR_DS_NTDSCRIPT_SYNTAX_ERROR 8591
+#define ERROR_DS_NTDSCRIPT_PROCESS_ERROR 8592
+#define ERROR_DS_DIFFERENT_REPL_EPOCHS 8593
+#define ERROR_DS_DRS_EXTENSIONS_CHANGED 8594
+#define ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR 8595
+#define ERROR_DS_NO_MSDS_INTID 8596
+#define ERROR_DS_DUP_MSDS_INTID 8597
+#define ERROR_DS_EXISTS_IN_RDNATTID 8598
+#define ERROR_DS_AUTHORIZATION_FAILED 8599
+#define ERROR_DS_INVALID_SCRIPT 8600
+#define ERROR_DS_REMOTE_CROSSREF_OP_FAILED 8601
+
+/*
+ * 9000-9999? domain name service errors
+ */
+#define DNS_ERROR_RESPONSE_CODES_BASE 9000
+#define DNS_ERROR_RCODE_NO_ERROR NO_ERROR
+#define DNS_ERROR_MASK DNS_ERROR_RESPONSE_CODES_BASE
+#define DNS_ERROR_RCODE_FORMAT_ERROR 9001
+#define DNS_ERROR_RCODE_SERVER_FAILURE 9002
+#define DNS_ERROR_RCODE_NAME_ERROR 9003
+#define DNS_ERROR_RCODE_NOT_IMPLEMENTED 9004
+#define DNS_ERROR_RCODE_REFUSED 9005
+#define DNS_ERROR_RCODE_YXDOMAIN 9006
+#define DNS_ERROR_RCODE_YXRRSET 9007
+#define DNS_ERROR_RCODE_NXRRSET 9008
+#define DNS_ERROR_RCODE_NOTAUTH 9009
+#define DNS_ERROR_RCODE_NOTZONE 9010
+#define DNS_ERROR_RCODE_BADSIG 9016
+#define DNS_ERROR_RCODE_BADKEY 9017
+#define DNS_ERROR_RCODE_BADTIME 9018
+#define DNS_ERROR_RCODE_LAST DNS_ERROR_RCODE_BADTIME
+#define DNS_ERROR_PACKET_FMT_BASE 9500
+#define DNS_INFO_NO_RECORDS 9501
+#define DNS_ERROR_BAD_PACKET 9502
+#define DNS_ERROR_NO_PACKET 9503
+#define DNS_ERROR_RCODE 9504
+#define DNS_ERROR_UNSECURE_PACKET 9505
+#define DNS_STATUS_PACKET_UNSECURE DNS_ERROR_UNSECURE_PACKET
+#define DNS_ERROR_NO_MEMORY ERROR_OUTOFMEMORY
+#define DNS_ERROR_INVALID_NAME ERROR_INVALID_NAME
+#define DNS_ERROR_INVALID_DATA ERROR_INVALID_DATA
+#define DNS_ERROR_GENERAL_API_BASE 9550
+#define DNS_ERROR_INVALID_TYPE 9551
+#define DNS_ERROR_INVALID_IP_ADDRESS 9552
+#define DNS_ERROR_INVALID_PROPERTY 9553
+#define DNS_ERROR_TRY_AGAIN_LATER 9554
+#define DNS_ERROR_NOT_UNIQUE 9555
+#define DNS_ERROR_NON_RFC_NAME 9556
+#define DNS_STATUS_FQDN 9557
+#define DNS_STATUS_DOTTED_NAME 9558
+#define DNS_STATUS_SINGLE_PART_NAME 9559
+#define DNS_ERROR_INVALID_NAME_CHAR 9560
+#define DNS_ERROR_NUMERIC_NAME 9561
+#define DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER 9562
+#define DNS_ERROR_ZONE_BASE 9600
+#define DNS_ERROR_ZONE_DOES_NOT_EXIST 9601
+#define DNS_ERROR_NO_ZONE_INFO 9602
+#define DNS_ERROR_INVALID_ZONE_OPERATION 9603
+#define DNS_ERROR_ZONE_CONFIGURATION_ERROR 9604
+#define DNS_ERROR_ZONE_HAS_NO_SOA_RECORD 9605
+#define DNS_ERROR_ZONE_HAS_NO_NS_RECORDS 9606
+#define DNS_ERROR_ZONE_LOCKED 9607
+#define DNS_ERROR_ZONE_CREATION_FAILED 9608
+#define DNS_ERROR_ZONE_ALREADY_EXISTS 9609
+#define DNS_ERROR_AUTOZONE_ALREADY_EXISTS 9610
+#define DNS_ERROR_INVALID_ZONE_TYPE 9611
+#define DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP 9612
+#define DNS_ERROR_ZONE_NOT_SECONDARY 9613
+#define DNS_ERROR_NEED_SECONDARY_ADDRESSES 9614
+#define DNS_ERROR_WINS_INIT_FAILED 9615
+#define DNS_ERROR_NEED_WINS_SERVERS 9616
+#define DNS_ERROR_NBSTAT_INIT_FAILED 9617
+#define DNS_ERROR_SOA_DELETE_INVALID 9618
+#define DNS_ERROR_FORWARDER_ALREADY_EXISTS 9619
+#define DNS_ERROR_ZONE_REQUIRES_MASTER_IP 9620
+#define DNS_ERROR_ZONE_IS_SHUTDOWN 9621
+#define DNS_ERROR_DATAFILE_BASE 9650
+#define DNS_ERROR_PRIMARY_REQUIRES_DATAFILE 9651
+#define DNS_ERROR_INVALID_DATAFILE_NAME 9652
+#define DNS_ERROR_DATAFILE_OPEN_FAILURE 9653
+#define DNS_ERROR_FILE_WRITEBACK_FAILED 9654
+#define DNS_ERROR_DATAFILE_PARSING 9655
+#define DNS_ERROR_DATABASE_BASE 9700
+#define DNS_ERROR_RECORD_DOES_NOT_EXIST 9701
+#define DNS_ERROR_RECORD_FORMAT 9702
+#define DNS_ERROR_NODE_CREATION_FAILED 9703
+#define DNS_ERROR_UNKNOWN_RECORD_TYPE 9704
+#define DNS_ERROR_RECORD_TIMED_OUT 9705
+#define DNS_ERROR_NAME_NOT_IN_ZONE 9706
+#define DNS_ERROR_CNAME_LOOP 9707
+#define DNS_ERROR_NODE_IS_CNAME 9708
+#define DNS_ERROR_CNAME_COLLISION 9709
+#define DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT 9710
+#define DNS_ERROR_RECORD_ALREADY_EXISTS 9711
+#define DNS_ERROR_SECONDARY_DATA 9712
+#define DNS_ERROR_NO_CREATE_CACHE_DATA 9713
+#define DNS_ERROR_NAME_DOES_NOT_EXIST 9714
+#define DNS_WARNING_PTR_CREATE_FAILED 9715
+#define DNS_WARNING_DOMAIN_UNDELETED 9716
+#define DNS_ERROR_DS_UNAVAILABLE 9717
+#define DNS_ERROR_DS_ZONE_ALREADY_EXISTS 9718
+#define DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE 9719
+#define DNS_ERROR_OPERATION_BASE 9750
+#define DNS_INFO_AXFR_COMPLETE 9751
+#define DNS_ERROR_AXFR 9752
+#define DNS_INFO_ADDED_LOCAL_WINS 9753
+#define DNS_ERROR_SECURE_BASE 9800
+#define DNS_STATUS_CONTINUE_NEEDED 9801
+#define DNS_ERROR_SETUP_BASE 9850
+#define DNS_ERROR_NO_TCPIP 9851
+#define DNS_ERROR_NO_DNS_SERVERS 9852
+#define DNS_ERROR_DP_BASE 9900
+#define DNS_ERROR_DP_DOES_NOT_EXIST 9901
+#define DNS_ERROR_DP_ALREADY_EXISTS 9902
+#define DNS_ERROR_DP_NOT_ENLISTED 9903
+#define DNS_ERROR_DP_ALREADY_ENLISTED 9904
+
+#define RPC_E_CALL_REJECTED 0x80010001U
+#define RPC_E_CALL_CANCELED 0x80010002U
+#define RPC_E_CANTPOST_INSENDCALL 0x80010003U
+#define RPC_E_CANTCALLOUT_INASYNCCALL 0x80010004U
+#define RPC_E_CANTCALLOUT_INEXTERNALCALL 0x80010005U
+#define RPC_E_CONNECTION_TERMINATED 0x80010006U
+#define RPC_E_SERVER_DIED 0x80010007U
+#define RPC_E_CLIENT_DIED 0x80010008U
+#define RPC_E_INVALID_DATAPACKET 0x80010009U
+#define RPC_E_CANTTRANSMIT_CALL 0x8001000AU
+#define RPC_E_CLIENT_CANTMARSHAL_DATA 0x8001000BU
+#define RPC_E_CLIENT_CANTUNMARSHAL_DATA 0x8001000CU
+#define RPC_E_SERVER_CANTMARSHAL_DATA 0x8001000DU
+#define RPC_E_SERVER_CANTUNMARSHAL_DATA 0x8001000EU
+#define RPC_E_INVALID_DATA 0x8001000FU
+#define RPC_E_INVALID_PARAMETER 0x80010010U
+#define RPC_E_CANTCALLOUT_AGAIN 0x80010011U
+#define RPC_E_SERVER_DIED_DNE 0x80010012U
+#define RPC_E_SYS_CALL_FAILED 0x80010100U
+#define RPC_E_OUT_OF_RESOURCES 0x80010101U
+#define RPC_E_ATTEMPTED_MULTITHREAD 0x80010102U
+#define RPC_E_NOT_REGISTERED 0x80010103U
+#define RPC_E_FAULT 0x80010104U
+#define RPC_E_SERVERFAULT 0x80010105U
+#define RPC_E_CHANGED_MODE 0x80010106U
+#define RPC_E_INVALIDMETHOD 0x80010107U
+#define RPC_E_DISCONNECTED 0x80010108U
+#define RPC_E_RETRY 0x80010109U
+#define RPC_E_SERVERCALL_RETRYLATER 0x8001010AU
+#define RPC_E_SERVERCALL_REJECTED 0x8001010BU
+#define RPC_E_INVALID_CALLDATA 0x8001010CU
+#define RPC_E_CANTCALLOUT_ININPUTSYNCCALL 0x8001010DU
+#define RPC_E_WRONG_THREAD 0x8001010EU
+#define RPC_E_THREAD_NOT_INIT 0x8001010FU
+#define RPC_E_VERSION_MISMATCH 0x80010110U
+#define RPC_E_INVALID_HEADER 0x80010111U
+#define RPC_E_INVALID_EXTENSION 0x80010112U
+#define RPC_E_INVALID_IPID 0x80010113U
+#define RPC_E_INVALID_OBJECT 0x80010114U
+#define RPC_S_CALLPENDING 0x80010115U
+#define RPC_S_WAITONTIMER 0x80010116U
+#define RPC_E_CALL_COMPLETE 0x80010117U
+#define RPC_E_UNSECURE_CALL 0x80010118U
+#define RPC_E_TOO_LATE 0x80010119U
+#define RPC_E_NO_GOOD_SECURITY_PACKAGES 0x8001011AU
+#define RPC_E_ACCESS_DENIED 0x8001011BU
+#define RPC_E_REMOTE_DISABLED 0x8001011CU
+#define RPC_E_UNEXPECTED 0x8001FFFFU
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _SMB_NTERROR_H */
diff --git a/usr/src/uts/common/smb/ntstatus.h b/usr/src/uts/common/smb/ntstatus.h
new file mode 100644
index 0000000000..12ccc263a4
--- /dev/null
+++ b/usr/src/uts/common/smb/ntstatus.h
@@ -0,0 +1,1054 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _SMB_NTSTATUS_H
+#define _SMB_NTSTATUS_H
+
+/*
+ * This file defines the list of Win32 status codes. If you need
+ * a status code that is defined in the [MS-ERREF] document but
+ * is not listed here, please add it to the file. This file is
+ * compatible with the Windows DDK file inc/ntstatus.h
+ * Please preserve this compatibility.
+ *
+ * Be careful not to confuse error codes with status codes. The error
+ * codes are listed in nterror.h. Some mappings between NT status
+ * codes and Win32 error codes is provided in the Microsoft knowledge
+ * base article Q113996.
+ *
+ * Also note that this file is used as the input to a small AWK program
+ * to generate an error name lookup table. If you modify this file,
+ * please check that a make in libsmb is successful. At present, the
+ * AWK program checks that the NTSTATUS constants are in this format:
+ * 0x0123CDEF Please keep that format.
+ *
+ * Win32 error codes are 32-bit values with the following format
+ * (ntstatus.h):
+ *
+ * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +---+-+-+-----------------------+-------------------------------+
+ * |Sev|C|R| Facility | Code |
+ * +---+-+-+-----------------------+-------------------------------+
+ *
+ * Sev severity code
+ * 00 - Success
+ * 01 - Informational
+ * 10 - Warning
+ * 11 - Error
+ *
+ * C - is the Customer code flag
+ * R - is a reserved bit
+ * Facility - is the facility code
+ * Code - is the facility's status code
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * XXX: Some temporary left-overs from the old ntstatus.h
+ * Should eliminate uses of these macros when convenient.
+ */
+/* This used to OR in the severity bits. */
+#define NT_SC_ERROR(S) (S)
+/* This used to mask off the severity bits. */
+#define NT_SC_VALUE(S) (S)
+/* XXX end of temporary left-overs. */
+
+/*
+ * One non-NT macro added for getting the severity value
+ * from a given NT status code. Evaluates to one of the
+ * SEVERITY values defined below.
+ */
+#define NT_SC_SEVERITY(S) (((S) >> 30) & 3)
+
+/*
+ * All NT-compatible from here on.
+ * (modulo the "NT_" prefix)
+ */
+
+/*
+ * Define the severity codes (same as in the NT DDK).
+ * These are the top two bits, so shift left 30 bits.
+ */
+#define NT_STATUS_SEVERITY_SUCCESS 0
+#define NT_STATUS_SEVERITY_INFORMATIONAL 1 /* 0x40000000 */
+#define NT_STATUS_SEVERITY_WARNING 2 /* 0x80000000 */
+#define NT_STATUS_SEVERITY_ERROR 3 /* 0xC0000000 */
+
+#define NT_STATUS_SUCCESS 0x00000000
+
+/* Facility OS (0x..00....) */
+/* All severity zero (success) */
+#define NT_STATUS_ABANDONED 0x00000080
+#define NT_STATUS_USER_APC 0x000000C0
+#define NT_STATUS_KERNEL_APC 0x00000100
+#define NT_STATUS_ALERTED 0x00000101
+#define NT_STATUS_TIMEOUT 0x00000102
+#define NT_STATUS_PENDING 0x00000103
+#define NT_STATUS_REPARSE 0x00000104
+#define NT_STATUS_MORE_ENTRIES 0x00000105
+#define NT_STATUS_NOT_ALL_ASSIGNED 0x00000106
+#define NT_STATUS_SOME_NOT_MAPPED 0x00000107
+#define NT_STATUS_OPLOCK_BREAK_IN_PROGRESS 0x00000108
+#define NT_STATUS_VOLUME_MOUNTED 0x00000109
+#define NT_STATUS_RXACT_COMMITTED 0x0000010A
+#define NT_STATUS_NOTIFY_CLEANUP 0x0000010B
+#define NT_STATUS_NOTIFY_ENUM_DIR 0x0000010C
+#define NT_STATUS_NO_QUOTAS_FOR_ACCOUNT 0x0000010D
+#define NT_STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED 0x0000010E
+#define NT_STATUS_PAGE_FAULT_TRANSITION 0x00000110
+#define NT_STATUS_PAGE_FAULT_DEMAND_ZERO 0x00000111
+#define NT_STATUS_PAGE_FAULT_COPY_ON_WRITE 0x00000112
+#define NT_STATUS_PAGE_FAULT_GUARD_PAGE 0x00000113
+#define NT_STATUS_PAGE_FAULT_PAGING_FILE 0x00000114
+#define NT_STATUS_CACHE_PAGE_LOCKED 0x00000115
+#define NT_STATUS_CRASH_DUMP 0x00000116
+#define NT_STATUS_BUFFER_ALL_ZEROS 0x00000117
+#define NT_STATUS_REPARSE_OBJECT 0x00000118
+#define NT_STATUS_RESOURCE_REQUIREMENTS_CHANGED 0x00000119
+#define NT_STATUS_TRANSLATION_COMPLETE 0x00000120
+#define NT_STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY 0x00000121
+#define NT_STATUS_NOTHING_TO_TERMINATE 0x00000122
+#define NT_STATUS_PROCESS_NOT_IN_JOB 0x00000123
+#define NT_STATUS_PROCESS_IN_JOB 0x00000124
+
+/* All severity 1 (informational) */
+#define NT_STATUS_OBJECT_NAME_EXISTS 0x40000000
+#define NT_STATUS_THREAD_WAS_SUSPENDED 0x40000001
+#define NT_STATUS_WORKING_SET_LIMIT_RANGE 0x40000002
+#define NT_STATUS_IMAGE_NOT_AT_BASE 0x40000003
+#define NT_STATUS_RXACT_STATE_CREATED 0x40000004
+#define NT_STATUS_SEGMENT_NOTIFICATION 0x40000005
+#define NT_STATUS_LOCAL_USER_SESSION_KEY 0x40000006
+#define NT_STATUS_BAD_CURRENT_DIRECTORY 0x40000007
+#define NT_STATUS_SERIAL_MORE_WRITES 0x40000008
+#define NT_STATUS_REGISTRY_RECOVERED 0x40000009
+#define NT_STATUS_FT_READ_RECOVERY_FROM_BACKUP 0x4000000A
+#define NT_STATUS_FT_WRITE_RECOVERY 0x4000000B
+#define NT_STATUS_SERIAL_COUNTER_TIMEOUT 0x4000000C
+#define NT_STATUS_NULL_LM_PASSWORD 0x4000000D
+#define NT_STATUS_IMAGE_MACHINE_TYPE_MISMATCH 0x4000000E
+#define NT_STATUS_RECEIVE_PARTIAL 0x4000000F
+#define NT_STATUS_RECEIVE_EXPEDITED 0x40000010
+#define NT_STATUS_RECEIVE_PARTIAL_EXPEDITED 0x40000011
+#define NT_STATUS_EVENT_DONE 0x40000012
+#define NT_STATUS_EVENT_PENDING 0x40000013
+#define NT_STATUS_CHECKING_FILE_SYSTEM 0x40000014
+#define NT_STATUS_FATAL_APP_EXIT 0x40000015
+#define NT_STATUS_PREDEFINED_HANDLE 0x40000016
+#define NT_STATUS_WAS_UNLOCKED 0x40000017
+#define NT_STATUS_SERVICE_NOTIFICATION 0x40000018
+#define NT_STATUS_WAS_LOCKED 0x40000019
+#define NT_STATUS_LOG_HARD_ERROR 0x4000001A
+#define NT_STATUS_ALREADY_WIN32 0x4000001B
+#define NT_STATUS_WX86_UNSIMULATE 0x4000001C
+#define NT_STATUS_WX86_CONTINUE 0x4000001D
+#define NT_STATUS_WX86_SINGLE_STEP 0x4000001E
+#define NT_STATUS_WX86_BREAKPOINT 0x4000001F
+#define NT_STATUS_WX86_EXCEPTION_CONTINUE 0x40000020
+#define NT_STATUS_WX86_EXCEPTION_LASTCHANCE 0x40000021
+#define NT_STATUS_WX86_EXCEPTION_CHAIN 0x40000022
+#define NT_STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE 0x40000023
+#define NT_STATUS_NO_YIELD_PERFORMED 0x40000024
+#define NT_STATUS_TIMER_RESUME_IGNORED 0x40000025
+#define NT_STATUS_ARBITRATION_UNHANDLED 0x40000026
+#define NT_STATUS_CARDBUS_NOT_SUPPORTED 0x40000027
+#define NT_STATUS_WX86_CREATEWX86TIB 0x40000028
+#define NT_STATUS_MP_PROCESSOR_MISMATCH 0x40000029
+#define NT_STATUS_HIBERNATED 0x4000002A
+#define NT_STATUS_RESUME_HIBERNATION 0x4000002B
+
+/* All severity 2 (warning) */
+#define NT_STATUS_GUARD_PAGE_VIOLATION 0x80000001
+#define NT_STATUS_DATATYPE_MISALIGNMENT 0x80000002
+#define NT_STATUS_BREAKPOINT 0x80000003
+#define NT_STATUS_SINGLE_STEP 0x80000004
+#define NT_STATUS_BUFFER_OVERFLOW 0x80000005
+#define NT_STATUS_NO_MORE_FILES 0x80000006
+#define NT_STATUS_WAKE_SYSTEM_DEBUGGER 0x80000007
+#define NT_STATUS_HANDLES_CLOSED 0x8000000A
+#define NT_STATUS_NO_INHERITANCE 0x8000000B
+#define NT_STATUS_GUID_SUBSTITUTION_MADE 0x8000000C
+#define NT_STATUS_PARTIAL_COPY 0x8000000D
+#define NT_STATUS_DEVICE_PAPER_EMPTY 0x8000000E
+#define NT_STATUS_DEVICE_POWERED_OFF 0x8000000F
+#define NT_STATUS_DEVICE_OFF_LINE 0x80000010
+#define NT_STATUS_DEVICE_BUSY 0x80000011
+#define NT_STATUS_NO_MORE_EAS 0x80000012
+#define NT_STATUS_INVALID_EA_NAME 0x80000013
+#define NT_STATUS_EA_LIST_INCONSISTENT 0x80000014
+#define NT_STATUS_INVALID_EA_FLAG 0x80000015
+#define NT_STATUS_VERIFY_REQUIRED 0x80000016
+#define NT_STATUS_EXTRANEOUS_INFORMATION 0x80000017
+#define NT_STATUS_RXACT_COMMIT_NECESSARY 0x80000018
+#define NT_STATUS_NO_MORE_ENTRIES 0x8000001A
+#define NT_STATUS_FILEMARK_DETECTED 0x8000001B
+#define NT_STATUS_MEDIA_CHANGED 0x8000001C
+#define NT_STATUS_BUS_RESET 0x8000001D
+#define NT_STATUS_END_OF_MEDIA 0x8000001E
+#define NT_STATUS_BEGINNING_OF_MEDIA 0x8000001F
+#define NT_STATUS_MEDIA_CHECK 0x80000020
+#define NT_STATUS_SETMARK_DETECTED 0x80000021
+#define NT_STATUS_NO_DATA_DETECTED 0x80000022
+#define NT_STATUS_REDIRECTOR_HAS_OPEN_HANDLES 0x80000023
+#define NT_STATUS_SERVER_HAS_OPEN_HANDLES 0x80000024
+#define NT_STATUS_ALREADY_DISCONNECTED 0x80000025
+#define NT_STATUS_LONGJUMP 0x80000026
+#define NT_STATUS_CLEANER_CARTRIDGE_INSTALLED 0x80000027
+#define NT_STATUS_PLUGPLAY_QUERY_VETOED 0x80000028
+#define NT_STATUS_UNWIND_CONSOLIDATE 0x80000029
+
+/* Mostly severity 3 (error) - but NOT all! */
+#define NT_STATUS_UNSUCCESSFUL 0xC0000001
+#define NT_STATUS_NOT_IMPLEMENTED 0xC0000002
+#define NT_STATUS_INVALID_INFO_CLASS 0xC0000003
+#define NT_STATUS_INFO_LENGTH_MISMATCH 0xC0000004
+#define NT_STATUS_ACCESS_VIOLATION 0xC0000005
+#define NT_STATUS_IN_PAGE_ERROR 0xC0000006
+#define NT_STATUS_PAGEFILE_QUOTA 0xC0000007
+#define NT_STATUS_INVALID_HANDLE 0xC0000008
+#define NT_STATUS_BAD_INITIAL_STACK 0xC0000009
+#define NT_STATUS_BAD_INITIAL_PC 0xC000000A
+#define NT_STATUS_INVALID_CID 0xC000000B
+#define NT_STATUS_TIMER_NOT_CANCELED 0xC000000C
+#define NT_STATUS_INVALID_PARAMETER 0xC000000D
+#define NT_STATUS_NO_SUCH_DEVICE 0xC000000E
+#define NT_STATUS_NO_SUCH_FILE 0xC000000F
+#define NT_STATUS_INVALID_DEVICE_REQUEST 0xC0000010
+#define NT_STATUS_END_OF_FILE 0xC0000011
+#define NT_STATUS_WRONG_VOLUME 0xC0000012
+#define NT_STATUS_NO_MEDIA_IN_DEVICE 0xC0000013
+#define NT_STATUS_UNRECOGNIZED_MEDIA 0xC0000014
+#define NT_STATUS_NONEXISTENT_SECTOR 0xC0000015
+#define NT_STATUS_MORE_PROCESSING_REQUIRED 0xC0000016
+#define NT_STATUS_NO_MEMORY 0xC0000017
+#define NT_STATUS_CONFLICTING_ADDRESSES 0xC0000018
+#define NT_STATUS_NOT_MAPPED_VIEW 0xC0000019
+#define NT_STATUS_UNABLE_TO_FREE_VM 0xC000001A
+#define NT_STATUS_UNABLE_TO_DELETE_SECTION 0xC000001B
+#define NT_STATUS_INVALID_SYSTEM_SERVICE 0xC000001C
+#define NT_STATUS_ILLEGAL_INSTRUCTION 0xC000001D
+#define NT_STATUS_INVALID_LOCK_SEQUENCE 0xC000001E
+#define NT_STATUS_INVALID_VIEW_SIZE 0xC000001F
+#define NT_STATUS_INVALID_FILE_FOR_SECTION 0xC0000020
+#define NT_STATUS_ALREADY_COMMITTED 0xC0000021
+#define NT_STATUS_ACCESS_DENIED 0xC0000022
+#define NT_STATUS_BUFFER_TOO_SMALL 0xC0000023
+#define NT_STATUS_OBJECT_TYPE_MISMATCH 0xC0000024
+#define NT_STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
+#define NT_STATUS_INVALID_DISPOSITION 0xC0000026
+#define NT_STATUS_UNWIND 0xC0000027
+#define NT_STATUS_BAD_STACK 0xC0000028
+#define NT_STATUS_INVALID_UNWIND_TARGET 0xC0000029
+#define NT_STATUS_NOT_LOCKED 0xC000002A
+#define NT_STATUS_PARITY_ERROR 0xC000002B
+#define NT_STATUS_UNABLE_TO_DECOMMIT_VM 0xC000002C
+#define NT_STATUS_NOT_COMMITTED 0xC000002D
+#define NT_STATUS_INVALID_PORT_ATTRIBUTES 0xC000002E
+#define NT_STATUS_PORT_MESSAGE_TOO_LONG 0xC000002F
+#define NT_STATUS_INVALID_PARAMETER_MIX 0xC0000030
+#define NT_STATUS_INVALID_QUOTA_LOWER 0xC0000031
+#define NT_STATUS_DISK_CORRUPT_ERROR 0xC0000032
+#define NT_STATUS_OBJECT_NAME_INVALID 0xC0000033
+#define NT_STATUS_OBJECT_NAME_NOT_FOUND 0xC0000034
+#define NT_STATUS_OBJECT_NAME_COLLISION 0xC0000035
+#define NT_STATUS_PORT_DISCONNECTED 0xC0000037
+#define NT_STATUS_DEVICE_ALREADY_ATTACHED 0xC0000038
+#define NT_STATUS_OBJECT_PATH_INVALID 0xC0000039
+#define NT_STATUS_OBJECT_PATH_NOT_FOUND 0xC000003A
+#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD 0xC000003B
+#define NT_STATUS_DATA_OVERRUN 0xC000003C
+#define NT_STATUS_DATA_LATE_ERROR 0xC000003D
+#define NT_STATUS_DATA_ERROR 0xC000003E
+#define NT_STATUS_CRC_ERROR 0xC000003F
+#define NT_STATUS_SECTION_TOO_BIG 0xC0000040
+#define NT_STATUS_PORT_CONNECTION_REFUSED 0xC0000041
+#define NT_STATUS_INVALID_PORT_HANDLE 0xC0000042
+#define NT_STATUS_SHARING_VIOLATION 0xC0000043
+#define NT_STATUS_QUOTA_EXCEEDED 0xC0000044
+#define NT_STATUS_INVALID_PAGE_PROTECTION 0xC0000045
+#define NT_STATUS_MUTANT_NOT_OWNED 0xC0000046
+#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED 0xC0000047
+#define NT_STATUS_PORT_ALREADY_SET 0xC0000048
+#define NT_STATUS_SECTION_NOT_IMAGE 0xC0000049
+#define NT_STATUS_SUSPEND_COUNT_EXCEEDED 0xC000004A
+#define NT_STATUS_THREAD_IS_TERMINATING 0xC000004B
+#define NT_STATUS_BAD_WORKING_SET_LIMIT 0xC000004C
+#define NT_STATUS_INCOMPATIBLE_FILE_MAP 0xC000004D
+#define NT_STATUS_SECTION_PROTECTION 0xC000004E
+#define NT_STATUS_EAS_NOT_SUPPORTED 0xC000004F
+#define NT_STATUS_EA_TOO_LARGE 0xC0000050
+#define NT_STATUS_NONEXISTENT_EA_ENTRY 0xC0000051
+#define NT_STATUS_NO_EAS_ON_FILE 0xC0000052
+#define NT_STATUS_EA_CORRUPT_ERROR 0xC0000053
+#define NT_STATUS_FILE_LOCK_CONFLICT 0xC0000054
+#define NT_STATUS_LOCK_NOT_GRANTED 0xC0000055
+#define NT_STATUS_DELETE_PENDING 0xC0000056
+#define NT_STATUS_CTL_FILE_NOT_SUPPORTED 0xC0000057
+#define NT_STATUS_UNKNOWN_REVISION 0xC0000058
+#define NT_STATUS_REVISION_MISMATCH 0xC0000059
+#define NT_STATUS_INVALID_OWNER 0xC000005A
+#define NT_STATUS_INVALID_PRIMARY_GROUP 0xC000005B
+#define NT_STATUS_NO_IMPERSONATION_TOKEN 0xC000005C
+#define NT_STATUS_CANT_DISABLE_MANDATORY 0xC000005D
+#define NT_STATUS_NO_LOGON_SERVERS 0xC000005E
+#define NT_STATUS_NO_SUCH_LOGON_SESSION 0xC000005F
+#define NT_STATUS_NO_SUCH_PRIVILEGE 0xC0000060
+#define NT_STATUS_PRIVILEGE_NOT_HELD 0xC0000061
+#define NT_STATUS_INVALID_ACCOUNT_NAME 0xC0000062
+#define NT_STATUS_USER_EXISTS 0xC0000063
+#define NT_STATUS_NO_SUCH_USER 0xC0000064
+#define NT_STATUS_GROUP_EXISTS 0xC0000065
+#define NT_STATUS_NO_SUCH_GROUP 0xC0000066
+#define NT_STATUS_MEMBER_IN_GROUP 0xC0000067
+#define NT_STATUS_MEMBER_NOT_IN_GROUP 0xC0000068
+#define NT_STATUS_LAST_ADMIN 0xC0000069
+#define NT_STATUS_WRONG_PASSWORD 0xC000006A
+#define NT_STATUS_ILL_FORMED_PASSWORD 0xC000006B
+#define NT_STATUS_PASSWORD_RESTRICTION 0xC000006C
+#define NT_STATUS_LOGON_FAILURE 0xC000006D
+#define NT_STATUS_ACCOUNT_RESTRICTION 0xC000006E
+#define NT_STATUS_INVALID_LOGON_HOURS 0xC000006F
+#define NT_STATUS_INVALID_WORKSTATION 0xC0000070
+#define NT_STATUS_PASSWORD_EXPIRED 0xC0000071
+#define NT_STATUS_ACCOUNT_DISABLED 0xC0000072
+#define NT_STATUS_NONE_MAPPED 0xC0000073
+#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED 0xC0000074
+#define NT_STATUS_LUIDS_EXHAUSTED 0xC0000075
+#define NT_STATUS_INVALID_SUB_AUTHORITY 0xC0000076
+#define NT_STATUS_INVALID_ACL 0xC0000077
+#define NT_STATUS_INVALID_SID 0xC0000078
+#define NT_STATUS_INVALID_SECURITY_DESCR 0xC0000079
+#define NT_STATUS_PROCEDURE_NOT_FOUND 0xC000007A
+#define NT_STATUS_INVALID_IMAGE_FORMAT 0xC000007B
+#define NT_STATUS_NO_TOKEN 0xC000007C
+#define NT_STATUS_BAD_INHERITANCE_ACL 0xC000007D
+#define NT_STATUS_RANGE_NOT_LOCKED 0xC000007E
+#define NT_STATUS_DISK_FULL 0xC000007F
+#define NT_STATUS_SERVER_DISABLED 0xC0000080
+#define NT_STATUS_SERVER_NOT_DISABLED 0xC0000081
+#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED 0xC0000082
+#define NT_STATUS_GUIDS_EXHAUSTED 0xC0000083
+#define NT_STATUS_INVALID_ID_AUTHORITY 0xC0000084
+#define NT_STATUS_AGENTS_EXHAUSTED 0xC0000085
+#define NT_STATUS_INVALID_VOLUME_LABEL 0xC0000086
+#define NT_STATUS_SECTION_NOT_EXTENDED 0xC0000087
+#define NT_STATUS_NOT_MAPPED_DATA 0xC0000088
+#define NT_STATUS_RESOURCE_DATA_NOT_FOUND 0xC0000089
+#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND 0xC000008A
+#define NT_STATUS_RESOURCE_NAME_NOT_FOUND 0xC000008B
+#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
+#define NT_STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
+#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
+#define NT_STATUS_FLOAT_INEXACT_RESULT 0xC000008F
+#define NT_STATUS_FLOAT_INVALID_OPERATION 0xC0000090
+#define NT_STATUS_FLOAT_OVERFLOW 0xC0000091
+#define NT_STATUS_FLOAT_STACK_CHECK 0xC0000092
+#define NT_STATUS_FLOAT_UNDERFLOW 0xC0000093
+#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
+#define NT_STATUS_INTEGER_OVERFLOW 0xC0000095
+#define NT_STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
+#define NT_STATUS_TOO_MANY_PAGING_FILES 0xC0000097
+#define NT_STATUS_FILE_INVALID 0xC0000098
+#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED 0xC0000099
+#define NT_STATUS_INSUFFICIENT_RESOURCES 0xC000009A
+#define NT_STATUS_DFS_EXIT_PATH_FOUND 0xC000009B
+#define NT_STATUS_DEVICE_DATA_ERROR 0xC000009C
+#define NT_STATUS_DEVICE_NOT_CONNECTED 0xC000009D
+#define NT_STATUS_DEVICE_POWER_FAILURE 0xC000009E
+#define NT_STATUS_FREE_VM_NOT_AT_BASE 0xC000009F
+#define NT_STATUS_MEMORY_NOT_ALLOCATED 0xC00000A0
+#define NT_STATUS_WORKING_SET_QUOTA 0xC00000A1
+#define NT_STATUS_MEDIA_WRITE_PROTECTED 0xC00000A2
+#define NT_STATUS_DEVICE_NOT_READY 0xC00000A3
+#define NT_STATUS_INVALID_GROUP_ATTRIBUTES 0xC00000A4
+#define NT_STATUS_BAD_IMPERSONATION_LEVEL 0xC00000A5
+#define NT_STATUS_CANT_OPEN_ANONYMOUS 0xC00000A6
+#define NT_STATUS_BAD_VALIDATION_CLASS 0xC00000A7
+#define NT_STATUS_BAD_TOKEN_TYPE 0xC00000A8
+#define NT_STATUS_BAD_MASTER_BOOT_RECORD 0xC00000A9
+#define NT_STATUS_INSTRUCTION_MISALIGNMENT 0xC00000AA
+#define NT_STATUS_INSTANCE_NOT_AVAILABLE 0xC00000AB
+#define NT_STATUS_PIPE_NOT_AVAILABLE 0xC00000AC
+#define NT_STATUS_INVALID_PIPE_STATE 0xC00000AD
+#define NT_STATUS_PIPE_BUSY 0xC00000AE
+#define NT_STATUS_ILLEGAL_FUNCTION 0xC00000AF
+#define NT_STATUS_PIPE_DISCONNECTED 0xC00000B0
+#define NT_STATUS_PIPE_CLOSING 0xC00000B1
+#define NT_STATUS_PIPE_CONNECTED 0xC00000B2
+#define NT_STATUS_PIPE_LISTENING 0xC00000B3
+#define NT_STATUS_INVALID_READ_MODE 0xC00000B4
+#define NT_STATUS_IO_TIMEOUT 0xC00000B5
+#define NT_STATUS_FILE_FORCED_CLOSED 0xC00000B6
+#define NT_STATUS_PROFILING_NOT_STARTED 0xC00000B7
+#define NT_STATUS_PROFILING_NOT_STOPPED 0xC00000B8
+#define NT_STATUS_COULD_NOT_INTERPRET 0xC00000B9
+#define NT_STATUS_FILE_IS_A_DIRECTORY 0xC00000BA
+#define NT_STATUS_NOT_SUPPORTED 0xC00000BB
+#define NT_STATUS_REMOTE_NOT_LISTENING 0xC00000BC
+#define NT_STATUS_DUPLICATE_NAME 0xC00000BD
+#define NT_STATUS_BAD_NETWORK_PATH 0xC00000BE
+#define NT_STATUS_NETWORK_BUSY 0xC00000BF
+#define NT_STATUS_DEVICE_DOES_NOT_EXIST 0xC00000C0
+#define NT_STATUS_TOO_MANY_COMMANDS 0xC00000C1
+#define NT_STATUS_ADAPTER_HARDWARE_ERROR 0xC00000C2
+#define NT_STATUS_INVALID_NETWORK_RESPONSE 0xC00000C3
+#define NT_STATUS_UNEXPECTED_NETWORK_ERROR 0xC00000C4
+#define NT_STATUS_BAD_REMOTE_ADAPTER 0xC00000C5
+#define NT_STATUS_PRINT_QUEUE_FULL 0xC00000C6
+#define NT_STATUS_NO_SPOOL_SPACE 0xC00000C7
+#define NT_STATUS_PRINT_CANCELLED 0xC00000C8
+#define NT_STATUS_NETWORK_NAME_DELETED 0xC00000C9
+#define NT_STATUS_NETWORK_ACCESS_DENIED 0xC00000CA
+#define NT_STATUS_BAD_DEVICE_TYPE 0xC00000CB
+#define NT_STATUS_BAD_NETWORK_NAME 0xC00000CC
+#define NT_STATUS_TOO_MANY_NAMES 0xC00000CD
+#define NT_STATUS_TOO_MANY_SESSIONS 0xC00000CE
+#define NT_STATUS_SHARING_PAUSED 0xC00000CF
+#define NT_STATUS_REQUEST_NOT_ACCEPTED 0xC00000D0
+#define NT_STATUS_REDIRECTOR_PAUSED 0xC00000D1
+#define NT_STATUS_NET_WRITE_FAULT 0xC00000D2
+#define NT_STATUS_PROFILING_AT_LIMIT 0xC00000D3
+#define NT_STATUS_NOT_SAME_DEVICE 0xC00000D4
+#define NT_STATUS_FILE_RENAMED 0xC00000D5
+#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED 0xC00000D6
+#define NT_STATUS_NO_SECURITY_ON_OBJECT 0xC00000D7
+#define NT_STATUS_CANT_WAIT 0xC00000D8
+#define NT_STATUS_PIPE_EMPTY 0xC00000D9
+#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO 0xC00000DA
+#define NT_STATUS_CANT_TERMINATE_SELF 0xC00000DB
+#define NT_STATUS_INVALID_SERVER_STATE 0xC00000DC
+#define NT_STATUS_INVALID_DOMAIN_STATE 0xC00000DD
+#define NT_STATUS_INVALID_DOMAIN_ROLE 0xC00000DE
+#define NT_STATUS_NO_SUCH_DOMAIN 0xC00000DF
+#define NT_STATUS_DOMAIN_EXISTS 0xC00000E0
+#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED 0xC00000E1
+#define NT_STATUS_OPLOCK_NOT_GRANTED 0xC00000E2
+#define NT_STATUS_INVALID_OPLOCK_PROTOCOL 0xC00000E3
+#define NT_STATUS_INTERNAL_DB_CORRUPTION 0xC00000E4
+#define NT_STATUS_INTERNAL_ERROR 0xC00000E5
+#define NT_STATUS_GENERIC_NOT_MAPPED 0xC00000E6
+#define NT_STATUS_BAD_DESCRIPTOR_FORMAT 0xC00000E7
+#define NT_STATUS_INVALID_USER_BUFFER 0xC00000E8
+#define NT_STATUS_UNEXPECTED_IO_ERROR 0xC00000E9
+#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR 0xC00000EA
+#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR 0xC00000EB
+#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR 0xC00000EC
+#define NT_STATUS_NOT_LOGON_PROCESS 0xC00000ED
+#define NT_STATUS_LOGON_SESSION_EXISTS 0xC00000EE
+#define NT_STATUS_INVALID_PARAMETER_1 0xC00000EF
+#define NT_STATUS_INVALID_PARAMETER_2 0xC00000F0
+#define NT_STATUS_INVALID_PARAMETER_3 0xC00000F1
+#define NT_STATUS_INVALID_PARAMETER_4 0xC00000F2
+#define NT_STATUS_INVALID_PARAMETER_5 0xC00000F3
+#define NT_STATUS_INVALID_PARAMETER_6 0xC00000F4
+#define NT_STATUS_INVALID_PARAMETER_7 0xC00000F5
+#define NT_STATUS_INVALID_PARAMETER_8 0xC00000F6
+#define NT_STATUS_INVALID_PARAMETER_9 0xC00000F7
+#define NT_STATUS_INVALID_PARAMETER_10 0xC00000F8
+#define NT_STATUS_INVALID_PARAMETER_11 0xC00000F9
+#define NT_STATUS_INVALID_PARAMETER_12 0xC00000FA
+#define NT_STATUS_REDIRECTOR_NOT_STARTED 0xC00000FB
+#define NT_STATUS_REDIRECTOR_STARTED 0xC00000FC
+#define NT_STATUS_STACK_OVERFLOW 0xC00000FD
+#define NT_STATUS_NO_SUCH_PACKAGE 0xC00000FE
+#define NT_STATUS_BAD_FUNCTION_TABLE 0xC00000FF
+#define NT_STATUS_VARIABLE_NOT_FOUND 0xC0000100
+#define NT_STATUS_DIRECTORY_NOT_EMPTY 0xC0000101
+#define NT_STATUS_FILE_CORRUPT_ERROR 0xC0000102
+#define NT_STATUS_NOT_A_DIRECTORY 0xC0000103
+#define NT_STATUS_BAD_LOGON_SESSION_STATE 0xC0000104
+#define NT_STATUS_LOGON_SESSION_COLLISION 0xC0000105
+#define NT_STATUS_NAME_TOO_LONG 0xC0000106
+#define NT_STATUS_FILES_OPEN 0xC0000107
+#define NT_STATUS_CONNECTION_IN_USE 0xC0000108
+#define NT_STATUS_MESSAGE_NOT_FOUND 0xC0000109
+#define NT_STATUS_PROCESS_IS_TERMINATING 0xC000010A
+#define NT_STATUS_INVALID_LOGON_TYPE 0xC000010B
+#define NT_STATUS_NO_GUID_TRANSLATION 0xC000010C
+#define NT_STATUS_CANNOT_IMPERSONATE 0xC000010D
+#define NT_STATUS_IMAGE_ALREADY_LOADED 0xC000010E
+#define NT_STATUS_ABIOS_NOT_PRESENT 0xC000010F
+#define NT_STATUS_ABIOS_LID_NOT_EXIST 0xC0000110
+#define NT_STATUS_ABIOS_LID_ALREADY_OWNED 0xC0000111
+#define NT_STATUS_ABIOS_NOT_LID_OWNER 0xC0000112
+#define NT_STATUS_ABIOS_INVALID_COMMAND 0xC0000113
+#define NT_STATUS_ABIOS_INVALID_LID 0xC0000114
+#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE 0xC0000115
+#define NT_STATUS_ABIOS_INVALID_SELECTOR 0xC0000116
+#define NT_STATUS_NO_LDT 0xC0000117
+#define NT_STATUS_INVALID_LDT_SIZE 0xC0000118
+#define NT_STATUS_INVALID_LDT_OFFSET 0xC0000119
+#define NT_STATUS_INVALID_LDT_DESCRIPTOR 0xC000011A
+#define NT_STATUS_INVALID_IMAGE_NE_FORMAT 0xC000011B
+#define NT_STATUS_RXACT_INVALID_STATE 0xC000011C
+#define NT_STATUS_RXACT_COMMIT_FAILURE 0xC000011D
+#define NT_STATUS_MAPPED_FILE_SIZE_ZERO 0xC000011E
+#define NT_STATUS_TOO_MANY_OPENED_FILES 0xC000011F
+#define NT_STATUS_CANCELLED 0xC0000120
+#define NT_STATUS_CANNOT_DELETE 0xC0000121
+#define NT_STATUS_INVALID_COMPUTER_NAME 0xC0000122
+#define NT_STATUS_FILE_DELETED 0xC0000123
+#define NT_STATUS_SPECIAL_ACCOUNT 0xC0000124
+#define NT_STATUS_SPECIAL_GROUP 0xC0000125
+#define NT_STATUS_SPECIAL_USER 0xC0000126
+#define NT_STATUS_MEMBERS_PRIMARY_GROUP 0xC0000127
+#define NT_STATUS_FILE_CLOSED 0xC0000128
+#define NT_STATUS_TOO_MANY_THREADS 0xC0000129
+#define NT_STATUS_THREAD_NOT_IN_PROCESS 0xC000012A
+#define NT_STATUS_TOKEN_ALREADY_IN_USE 0xC000012B
+#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED 0xC000012C
+#define NT_STATUS_COMMITMENT_LIMIT 0xC000012D
+#define NT_STATUS_INVALID_IMAGE_LE_FORMAT 0xC000012E
+#define NT_STATUS_INVALID_IMAGE_NOT_MZ 0xC000012F
+#define NT_STATUS_INVALID_IMAGE_PROTECT 0xC0000130
+#define NT_STATUS_INVALID_IMAGE_WIN_16 0xC0000131
+#define NT_STATUS_LOGON_SERVER_CONFLICT 0xC0000132
+#define NT_STATUS_TIME_DIFFERENCE_AT_DC 0xC0000133
+#define NT_STATUS_SYNCHRONIZATION_REQUIRED 0xC0000134
+#define NT_STATUS_DLL_NOT_FOUND 0xC0000135
+#define NT_STATUS_OPEN_FAILED 0xC0000136
+#define NT_STATUS_IO_PRIVILEGE_FAILED 0xC0000137
+#define NT_STATUS_ORDINAL_NOT_FOUND 0xC0000138
+#define NT_STATUS_ENTRYPOINT_NOT_FOUND 0xC0000139
+#define NT_STATUS_CONTROL_C_EXIT 0xC000013A
+#define NT_STATUS_LOCAL_DISCONNECT 0xC000013B
+#define NT_STATUS_REMOTE_DISCONNECT 0xC000013C
+#define NT_STATUS_REMOTE_RESOURCES 0xC000013D
+#define NT_STATUS_LINK_FAILED 0xC000013E
+#define NT_STATUS_LINK_TIMEOUT 0xC000013F
+#define NT_STATUS_INVALID_CONNECTION 0xC0000140
+#define NT_STATUS_INVALID_ADDRESS 0xC0000141
+#define NT_STATUS_DLL_INIT_FAILED 0xC0000142
+#define NT_STATUS_MISSING_SYSTEMFILE 0xC0000143
+#define NT_STATUS_UNHANDLED_EXCEPTION 0xC0000144
+#define NT_STATUS_APP_INIT_FAILURE 0xC0000145
+#define NT_STATUS_PAGEFILE_CREATE_FAILED 0xC0000146
+#define NT_STATUS_NO_PAGEFILE 0xC0000147
+#define NT_STATUS_INVALID_LEVEL 0xC0000148
+#define NT_STATUS_WRONG_PASSWORD_CORE 0xC0000149
+#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT 0xC000014A
+#define NT_STATUS_PIPE_BROKEN 0xC000014B
+#define NT_STATUS_REGISTRY_CORRUPT 0xC000014C
+#define NT_STATUS_REGISTRY_IO_FAILED 0xC000014D
+#define NT_STATUS_NO_EVENT_PAIR 0xC000014E
+#define NT_STATUS_UNRECOGNIZED_VOLUME 0xC000014F
+#define NT_STATUS_SERIAL_NO_DEVICE_INITED 0xC0000150
+#define NT_STATUS_NO_SUCH_ALIAS 0xC0000151
+#define NT_STATUS_MEMBER_NOT_IN_ALIAS 0xC0000152
+#define NT_STATUS_MEMBER_IN_ALIAS 0xC0000153
+#define NT_STATUS_ALIAS_EXISTS 0xC0000154
+#define NT_STATUS_LOGON_NOT_GRANTED 0xC0000155
+#define NT_STATUS_TOO_MANY_SECRETS 0xC0000156
+#define NT_STATUS_SECRET_TOO_LONG 0xC0000157
+#define NT_STATUS_INTERNAL_DB_ERROR 0xC0000158
+#define NT_STATUS_FULLSCREEN_MODE 0xC0000159
+#define NT_STATUS_TOO_MANY_CONTEXT_IDS 0xC000015A
+#define NT_STATUS_LOGON_TYPE_NOT_GRANTED 0xC000015B
+#define NT_STATUS_NOT_REGISTRY_FILE 0xC000015C
+#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED 0xC000015D
+#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR 0xC000015E
+#define NT_STATUS_FT_MISSING_MEMBER 0xC000015F
+#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY 0xC0000160
+#define NT_STATUS_ILLEGAL_CHARACTER 0xC0000161
+#define NT_STATUS_UNMAPPABLE_CHARACTER 0xC0000162
+#define NT_STATUS_UNDEFINED_CHARACTER 0xC0000163
+#define NT_STATUS_FLOPPY_VOLUME 0xC0000164
+#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND 0xC0000165
+#define NT_STATUS_FLOPPY_WRONG_CYLINDER 0xC0000166
+#define NT_STATUS_FLOPPY_UNKNOWN_ERROR 0xC0000167
+#define NT_STATUS_FLOPPY_BAD_REGISTERS 0xC0000168
+#define NT_STATUS_DISK_RECALIBRATE_FAILED 0xC0000169
+#define NT_STATUS_DISK_OPERATION_FAILED 0xC000016A
+#define NT_STATUS_DISK_RESET_FAILED 0xC000016B
+#define NT_STATUS_SHARED_IRQ_BUSY 0xC000016C
+#define NT_STATUS_FT_ORPHANING 0xC000016D
+#define NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT 0xC000016E
+#define NT_STATUS_PARTITION_FAILURE 0xC0000172
+#define NT_STATUS_INVALID_BLOCK_LENGTH 0xC0000173
+#define NT_STATUS_DEVICE_NOT_PARTITIONED 0xC0000174
+#define NT_STATUS_UNABLE_TO_LOCK_MEDIA 0xC0000175
+#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA 0xC0000176
+#define NT_STATUS_EOM_OVERFLOW 0xC0000177
+#define NT_STATUS_NO_MEDIA 0xC0000178
+#define NT_STATUS_NO_SUCH_MEMBER 0xC000017A
+#define NT_STATUS_INVALID_MEMBER 0xC000017B
+#define NT_STATUS_KEY_DELETED 0xC000017C
+#define NT_STATUS_NO_LOG_SPACE 0xC000017D
+#define NT_STATUS_TOO_MANY_SIDS 0xC000017E
+#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017F
+#define NT_STATUS_KEY_HAS_CHILDREN 0xC0000180
+#define NT_STATUS_CHILD_MUST_BE_VOLATILE 0xC0000181
+#define NT_STATUS_DEVICE_CONFIGURATION_ERROR 0xC0000182
+#define NT_STATUS_DRIVER_INTERNAL_ERROR 0xC0000183
+#define NT_STATUS_INVALID_DEVICE_STATE 0xC0000184
+#define NT_STATUS_IO_DEVICE_ERROR 0xC0000185
+#define NT_STATUS_DEVICE_PROTOCOL_ERROR 0xC0000186
+#define NT_STATUS_BACKUP_CONTROLLER 0xC0000187
+#define NT_STATUS_LOG_FILE_FULL 0xC0000188
+#define NT_STATUS_TOO_LATE 0xC0000189
+#define NT_STATUS_NO_TRUST_LSA_SECRET 0xC000018A
+#define NT_STATUS_NO_TRUST_SAM_ACCOUNT 0xC000018B
+#define NT_STATUS_TRUSTED_DOMAIN_FAILURE 0xC000018C
+#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018D
+#define NT_STATUS_EVENTLOG_FILE_CORRUPT 0xC000018E
+#define NT_STATUS_EVENTLOG_CANT_START 0xC000018F
+#define NT_STATUS_TRUST_FAILURE 0xC0000190
+#define NT_STATUS_MUTANT_LIMIT_EXCEEDED 0xC0000191
+#define NT_STATUS_NETLOGON_NOT_STARTED 0xC0000192
+#define NT_STATUS_ACCOUNT_EXPIRED 0xC0000193
+#define NT_STATUS_POSSIBLE_DEADLOCK 0xC0000194
+#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195
+#define NT_STATUS_REMOTE_SESSION_LIMIT 0xC0000196
+#define NT_STATUS_EVENTLOG_FILE_CHANGED 0xC0000197
+#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198
+#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199
+#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019A
+#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019B
+#define NT_STATUS_FS_DRIVER_REQUIRED 0xC000019C
+#define NT_STATUS_NO_USER_SESSION_KEY 0xC0000202
+#define NT_STATUS_USER_SESSION_DELETED 0xC0000203
+#define NT_STATUS_RESOURCE_LANG_NOT_FOUND 0xC0000204
+#define NT_STATUS_INSUFF_SERVER_RESOURCES 0xC0000205
+#define NT_STATUS_INVALID_BUFFER_SIZE 0xC0000206
+#define NT_STATUS_INVALID_ADDRESS_COMPONENT 0xC0000207
+#define NT_STATUS_INVALID_ADDRESS_WILDCARD 0xC0000208
+#define NT_STATUS_TOO_MANY_ADDRESSES 0xC0000209
+#define NT_STATUS_ADDRESS_ALREADY_EXISTS 0xC000020A
+#define NT_STATUS_ADDRESS_CLOSED 0xC000020B
+#define NT_STATUS_CONNECTION_DISCONNECTED 0xC000020C
+#define NT_STATUS_CONNECTION_RESET 0xC000020D
+#define NT_STATUS_TOO_MANY_NODES 0xC000020E
+#define NT_STATUS_TRANSACTION_ABORTED 0xC000020F
+#define NT_STATUS_TRANSACTION_TIMED_OUT 0xC0000210
+#define NT_STATUS_TRANSACTION_NO_RELEASE 0xC0000211
+#define NT_STATUS_TRANSACTION_NO_MATCH 0xC0000212
+#define NT_STATUS_TRANSACTION_RESPONDED 0xC0000213
+#define NT_STATUS_TRANSACTION_INVALID_ID 0xC0000214
+#define NT_STATUS_TRANSACTION_INVALID_TYPE 0xC0000215
+#define NT_STATUS_NOT_SERVER_SESSION 0xC0000216
+#define NT_STATUS_NOT_CLIENT_SESSION 0xC0000217
+#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE 0xC0000218
+#define NT_STATUS_DEBUG_ATTACH_FAILED 0xC0000219
+#define NT_STATUS_SYSTEM_PROCESS_TERMINATED 0xC000021A
+#define NT_STATUS_DATA_NOT_ACCEPTED 0xC000021B
+#define NT_STATUS_NO_BROWSER_SERVERS_FOUND 0xC000021C
+#define NT_STATUS_VDM_HARD_ERROR 0xC000021D
+#define NT_STATUS_DRIVER_CANCEL_TIMEOUT 0xC000021E
+#define NT_STATUS_REPLY_MESSAGE_MISMATCH 0xC000021F
+#define NT_STATUS_MAPPED_ALIGNMENT 0xC0000220
+#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH 0xC0000221
+#define NT_STATUS_LOST_WRITEBEHIND_DATA 0xC0000222
+#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID 0xC0000223
+#define NT_STATUS_PASSWORD_MUST_CHANGE 0xC0000224
+#define NT_STATUS_NOT_FOUND 0xC0000225
+#define NT_STATUS_NOT_TINY_STREAM 0xC0000226
+#define NT_STATUS_RECOVERY_FAILURE 0xC0000227
+#define NT_STATUS_STACK_OVERFLOW_READ 0xC0000228
+#define NT_STATUS_FAIL_CHECK 0xC0000229
+#define NT_STATUS_DUPLICATE_OBJECTID 0xC000022A
+#define NT_STATUS_OBJECTID_EXISTS 0xC000022B
+#define NT_STATUS_CONVERT_TO_LARGE 0xC000022C
+#define NT_STATUS_RETRY 0xC000022D
+#define NT_STATUS_FOUND_OUT_OF_SCOPE 0xC000022E
+#define NT_STATUS_ALLOCATE_BUCKET 0xC000022F
+#define NT_STATUS_PROPSET_NOT_FOUND 0xC0000230
+#define NT_STATUS_MARSHALL_OVERFLOW 0xC0000231
+#define NT_STATUS_INVALID_VARIANT 0xC0000232
+#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND 0xC0000233
+#define NT_STATUS_ACCOUNT_LOCKED_OUT 0xC0000234
+#define NT_STATUS_HANDLE_NOT_CLOSABLE 0xC0000235
+#define NT_STATUS_CONNECTION_REFUSED 0xC0000236
+#define NT_STATUS_GRACEFUL_DISCONNECT 0xC0000237
+#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED 0xC0000238
+#define NT_STATUS_ADDRESS_NOT_ASSOCIATED 0xC0000239
+#define NT_STATUS_CONNECTION_INVALID 0xC000023A
+#define NT_STATUS_CONNECTION_ACTIVE 0xC000023B
+#define NT_STATUS_NETWORK_UNREACHABLE 0xC000023C
+#define NT_STATUS_HOST_UNREACHABLE 0xC000023D
+#define NT_STATUS_PROTOCOL_UNREACHABLE 0xC000023E
+#define NT_STATUS_PORT_UNREACHABLE 0xC000023F
+#define NT_STATUS_REQUEST_ABORTED 0xC0000240
+#define NT_STATUS_CONNECTION_ABORTED 0xC0000241
+#define NT_STATUS_BAD_COMPRESSION_BUFFER 0xC0000242
+#define NT_STATUS_USER_MAPPED_FILE 0xC0000243
+#define NT_STATUS_AUDIT_FAILED 0xC0000244
+#define NT_STATUS_TIMER_RESOLUTION_NOT_SET 0xC0000245
+#define NT_STATUS_CONNECTION_COUNT_LIMIT 0xC0000246
+#define NT_STATUS_LOGIN_TIME_RESTRICTION 0xC0000247
+#define NT_STATUS_LOGIN_WKSTA_RESTRICTION 0xC0000248
+#define NT_STATUS_IMAGE_MP_UP_MISMATCH 0xC0000249
+#define NT_STATUS_INSUFFICIENT_LOGON_INFO 0xC0000250
+#define NT_STATUS_BAD_DLL_ENTRYPOINT 0xC0000251
+#define NT_STATUS_BAD_SERVICE_ENTRYPOINT 0xC0000252
+#define NT_STATUS_LPC_REPLY_LOST 0xC0000253
+#define NT_STATUS_IP_ADDRESS_CONFLICT1 0xC0000254
+#define NT_STATUS_IP_ADDRESS_CONFLICT2 0xC0000255
+#define NT_STATUS_REGISTRY_QUOTA_LIMIT 0xC0000256
+#define NT_STATUS_PATH_NOT_COVERED 0xC0000257
+#define NT_STATUS_NO_CALLBACK_ACTIVE 0xC0000258
+#define NT_STATUS_LICENSE_QUOTA_EXCEEDED 0xC0000259
+#define NT_STATUS_PWD_TOO_SHORT 0xC000025A
+#define NT_STATUS_PWD_TOO_RECENT 0xC000025B
+#define NT_STATUS_PWD_HISTORY_CONFLICT 0xC000025C
+#define NT_STATUS_PLUGPLAY_NO_DEVICE 0xC000025E
+#define NT_STATUS_UNSUPPORTED_COMPRESSION 0xC000025F
+#define NT_STATUS_INVALID_HW_PROFILE 0xC0000260
+#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH 0xC0000261
+#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND 0xC0000262
+#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND 0xC0000263
+#define NT_STATUS_RESOURCE_NOT_OWNED 0xC0000264
+#define NT_STATUS_TOO_MANY_LINKS 0xC0000265
+#define NT_STATUS_QUOTA_LIST_INCONSISTENT 0xC0000266
+#define NT_STATUS_FILE_IS_OFFLINE 0xC0000267
+#define NT_STATUS_EVALUATION_EXPIRATION 0xC0000268
+#define NT_STATUS_ILLEGAL_DLL_RELOCATION 0xC0000269
+#define NT_STATUS_LICENSE_VIOLATION 0xC000026A
+#define NT_STATUS_DLL_INIT_FAILED_LOGOFF 0xC000026B
+#define NT_STATUS_DRIVER_UNABLE_TO_LOAD 0xC000026C
+#define NT_STATUS_DFS_UNAVAILABLE 0xC000026D
+#define NT_STATUS_VOLUME_DISMOUNTED 0xC000026E
+#define NT_STATUS_WX86_INTERNAL_ERROR 0xC000026F
+#define NT_STATUS_WX86_FLOAT_STACK_CHECK 0xC0000270
+#define NT_STATUS_VALIDATE_CONTINUE 0xC0000271
+#define NT_STATUS_NO_MATCH 0xC0000272
+#define NT_STATUS_NO_MORE_MATCHES 0xC0000273
+#define NT_STATUS_NOT_A_REPARSE_POINT 0xC0000275
+#define NT_STATUS_IO_REPARSE_TAG_INVALID 0xC0000276
+#define NT_STATUS_IO_REPARSE_TAG_MISMATCH 0xC0000277
+#define NT_STATUS_IO_REPARSE_DATA_INVALID 0xC0000278
+#define NT_STATUS_IO_REPARSE_TAG_NOT_HANDLED 0xC0000279
+#define NT_STATUS_REPARSE_POINT_NOT_RESOLVED 0xC0000280
+#define NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT 0xC0000281
+#define NT_STATUS_RANGE_LIST_CONFLICT 0xC0000282
+#define NT_STATUS_SOURCE_ELEMENT_EMPTY 0xC0000283
+#define NT_STATUS_DESTINATION_ELEMENT_FULL 0xC0000284
+#define NT_STATUS_ILLEGAL_ELEMENT_ADDRESS 0xC0000285
+#define NT_STATUS_MAGAZINE_NOT_PRESENT 0xC0000286
+#define NT_STATUS_REINITIALIZATION_NEEDED 0xC0000287
+#define NT_STATUS_DEVICE_REQUIRES_CLEANING 0x80000288
+#define NT_STATUS_DEVICE_DOOR_OPEN 0x80000289
+#define NT_STATUS_ENCRYPTION_FAILED 0xC000028A
+#define NT_STATUS_DECRYPTION_FAILED 0xC000028B
+#define NT_STATUS_RANGE_NOT_FOUND 0xC000028C
+#define NT_STATUS_NO_RECOVERY_POLICY 0xC000028D
+#define NT_STATUS_NO_EFS 0xC000028E
+#define NT_STATUS_WRONG_EFS 0xC000028F
+#define NT_STATUS_NO_USER_KEYS 0xC0000290
+#define NT_STATUS_FILE_NOT_ENCRYPTED 0xC0000291
+#define NT_STATUS_NOT_EXPORT_FORMAT 0xC0000292
+#define NT_STATUS_FILE_ENCRYPTED 0xC0000293
+#define NT_STATUS_WAKE_SYSTEM 0x40000294
+#define NT_STATUS_WMI_GUID_NOT_FOUND 0xC0000295
+#define NT_STATUS_WMI_INSTANCE_NOT_FOUND 0xC0000296
+#define NT_STATUS_WMI_ITEMID_NOT_FOUND 0xC0000297
+#define NT_STATUS_WMI_TRY_AGAIN 0xC0000298
+#define NT_STATUS_SHARED_POLICY 0xC0000299
+#define NT_STATUS_POLICY_OBJECT_NOT_FOUND 0xC000029A
+#define NT_STATUS_POLICY_ONLY_IN_DS 0xC000029B
+#define NT_STATUS_VOLUME_NOT_UPGRADED 0xC000029C
+#define NT_STATUS_REMOTE_STORAGE_NOT_ACTIVE 0xC000029D
+#define NT_STATUS_REMOTE_STORAGE_MEDIA_ERROR 0xC000029E
+#define NT_STATUS_NO_TRACKING_SERVICE 0xC000029F
+#define NT_STATUS_SERVER_SID_MISMATCH 0xC00002A0
+#define NT_STATUS_DS_NO_ATTRIBUTE_OR_VALUE 0xC00002A1
+#define NT_STATUS_DS_INVALID_ATTRIBUTE_SYNTAX 0xC00002A2
+#define NT_STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED 0xC00002A3
+#define NT_STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS 0xC00002A4
+#define NT_STATUS_DS_BUSY 0xC00002A5
+#define NT_STATUS_DS_UNAVAILABLE 0xC00002A6
+#define NT_STATUS_DS_NO_RIDS_ALLOCATED 0xC00002A7
+#define NT_STATUS_DS_NO_MORE_RIDS 0xC00002A8
+#define NT_STATUS_DS_INCORRECT_ROLE_OWNER 0xC00002A9
+#define NT_STATUS_DS_RIDMGR_INIT_ERROR 0xC00002AA
+#define NT_STATUS_DS_OBJ_CLASS_VIOLATION 0xC00002AB
+#define NT_STATUS_DS_CANT_ON_NON_LEAF 0xC00002AC
+#define NT_STATUS_DS_CANT_ON_RDN 0xC00002AD
+#define NT_STATUS_DS_CANT_MOD_OBJ_CLASS 0xC00002AE
+#define NT_STATUS_DS_CROSS_DOM_MOVE_FAILED 0xC00002AF
+#define NT_STATUS_DS_GC_NOT_AVAILABLE 0xC00002B0
+#define NT_STATUS_DIRECTORY_SERVICE_REQUIRED 0xC00002B1
+#define NT_STATUS_REPARSE_ATTRIBUTE_CONFLICT 0xC00002B2
+#define NT_STATUS_CANT_ENABLE_DENY_ONLY 0xC00002B3
+#define NT_STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
+#define NT_STATUS_FLOAT_MULTIPLE_TRAPS 0xC00002B5
+#define NT_STATUS_DEVICE_REMOVED 0xC00002B6
+#define NT_STATUS_JOURNAL_DELETE_IN_PROGRESS 0xC00002B7
+#define NT_STATUS_JOURNAL_NOT_ACTIVE 0xC00002B8
+#define NT_STATUS_NOINTERFACE 0xC00002B9
+#define NT_STATUS_DS_ADMIN_LIMIT_EXCEEDED 0xC00002C1
+#define NT_STATUS_DRIVER_FAILED_SLEEP 0xC00002C2
+#define NT_STATUS_MUTUAL_AUTHENTICATION_FAILED 0xC00002C3
+#define NT_STATUS_CORRUPT_SYSTEM_FILE 0xC00002C4
+#define NT_STATUS_DATATYPE_MISALIGNMENT_ERROR 0xC00002C5
+#define NT_STATUS_WMI_READ_ONLY 0xC00002C6
+#define NT_STATUS_WMI_SET_FAILURE 0xC00002C7
+#define NT_STATUS_COMMITMENT_MINIMUM 0xC00002C8
+#define NT_STATUS_REG_NAT_CONSUMPTION 0xC00002C9
+#define NT_STATUS_TRANSPORT_FULL 0xC00002CA
+#define NT_STATUS_DS_SAM_INIT_FAILURE 0xC00002CB
+#define NT_STATUS_ONLY_IF_CONNECTED 0xC00002CC
+#define NT_STATUS_DS_SENSITIVE_GROUP_VIOLATION 0xC00002CD
+#define NT_STATUS_PNP_RESTART_ENUMERATION 0xC00002CE
+#define NT_STATUS_JOURNAL_ENTRY_DELETED 0xC00002CF
+#define NT_STATUS_DS_CANT_MOD_PRIMARYGROUPID 0xC00002D0
+#define NT_STATUS_SYSTEM_IMAGE_BAD_SIGNATURE 0xC00002D1
+#define NT_STATUS_PNP_REBOOT_REQUIRED 0xC00002D2
+#define NT_STATUS_POWER_STATE_INVALID 0xC00002D3
+#define NT_STATUS_DS_INVALID_GROUP_TYPE 0xC00002D4
+#define NT_STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN 0xC00002D5
+#define NT_STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN 0xC00002D6
+#define NT_STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER 0xC00002D7
+#define NT_STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER 0xC00002D8
+#define NT_STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER 0xC00002D9
+#define NT_STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER 0xC00002DA
+#define NT_STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER 0xC00002DB
+#define NT_STATUS_DS_HAVE_PRIMARY_MEMBERS 0xC00002DC
+#define NT_STATUS_WMI_NOT_SUPPORTED 0xC00002DD
+#define NT_STATUS_INSUFFICIENT_POWER 0xC00002DE
+#define NT_STATUS_SAM_NEED_BOOTKEY_PASSWORD 0xC00002DF
+#define NT_STATUS_SAM_NEED_BOOTKEY_FLOPPY 0xC00002E0
+#define NT_STATUS_DS_CANT_START 0xC00002E1
+#define NT_STATUS_DS_INIT_FAILURE 0xC00002E2
+#define NT_STATUS_SAM_INIT_FAILURE 0xC00002E3
+#define NT_STATUS_DS_GC_REQUIRED 0xC00002E4
+#define NT_STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY 0xC00002E5
+#define NT_STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS 0xC00002E6
+#define NT_STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED 0xC00002E7
+#define NT_STATUS_MULTIPLE_FAULT_VIOLATION 0xC00002E8
+#define NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED 0xC00002E9
+#define NT_STATUS_CANNOT_MAKE 0xC00002EA
+#define NT_STATUS_SYSTEM_SHUTDOWN 0xC00002EB
+#define NT_STATUS_DS_INIT_FAILURE_CONSOLE 0xC00002EC
+#define NT_STATUS_DS_SAM_INIT_FAILURE_CONSOLE 0xC00002ED
+#define NT_STATUS_UNFINISHED_CONTEXT_DELETED 0xC00002EE
+#define NT_STATUS_NO_TGT_REPLY 0xC00002EF
+#define NT_STATUS_OBJECTID_NOT_FOUND 0xC00002F0
+#define NT_STATUS_NO_IP_ADDRESSES 0xC00002F1
+#define NT_STATUS_WRONG_CREDENTIAL_HANDLE 0xC00002F2
+#define NT_STATUS_CRYPTO_SYSTEM_INVALID 0xC00002F3
+#define NT_STATUS_MAX_REFERRALS_EXCEEDED 0xC00002F4
+#define NT_STATUS_MUST_BE_KDC 0xC00002F5
+#define NT_STATUS_STRONG_CRYPTO_NOT_SUPPORTED 0xC00002F6
+#define NT_STATUS_TOO_MANY_PRINCIPALS 0xC00002F7
+#define NT_STATUS_NO_PA_DATA 0xC00002F8
+#define NT_STATUS_PKINIT_NAME_MISMATCH 0xC00002F9
+#define NT_STATUS_SMARTCARD_LOGON_REQUIRED 0xC00002FA
+#define NT_STATUS_KDC_INVALID_REQUEST 0xC00002FB
+#define NT_STATUS_KDC_UNABLE_TO_REFER 0xC00002FC
+#define NT_STATUS_KDC_UNKNOWN_ETYPE 0xC00002FD
+#define NT_STATUS_SHUTDOWN_IN_PROGRESS 0xC00002FE
+#define NT_STATUS_SERVER_SHUTDOWN_IN_PROGRESS 0xC00002FF
+#define NT_STATUS_NOT_SUPPORTED_ON_SBS 0xC0000300
+#define NT_STATUS_WMI_GUID_DISCONNECTED 0xC0000301
+#define NT_STATUS_WMI_ALREADY_DISABLED 0xC0000302
+#define NT_STATUS_WMI_ALREADY_ENABLED 0xC0000303
+#define NT_STATUS_MFT_TOO_FRAGMENTED 0xC0000304
+#define NT_STATUS_COPY_PROTECTION_FAILURE 0xC0000305
+#define NT_STATUS_CSS_AUTHENTICATION_FAILURE 0xC0000306
+#define NT_STATUS_CSS_KEY_NOT_PRESENT 0xC0000307
+#define NT_STATUS_CSS_KEY_NOT_ESTABLISHED 0xC0000308
+#define NT_STATUS_CSS_SCRAMBLED_SECTOR 0xC0000309
+#define NT_STATUS_CSS_REGION_MISMATCH 0xC000030A
+#define NT_STATUS_CSS_RESETS_EXHAUSTED 0xC000030B
+#define NT_STATUS_PKINIT_FAILURE 0xC0000320
+#define NT_STATUS_SMARTCARD_SUBSYSTEM_FAILURE 0xC0000321
+#define NT_STATUS_NO_KERB_KEY 0xC0000322
+#define NT_STATUS_HOST_DOWN 0xC0000350
+#define NT_STATUS_UNSUPPORTED_PREAUTH 0xC0000351
+#define NT_STATUS_EFS_ALG_BLOB_TOO_BIG 0xC0000352
+#define NT_STATUS_PORT_NOT_SET 0xC0000353
+#define NT_STATUS_DEBUGGER_INACTIVE 0xC0000354
+#define NT_STATUS_DS_VERSION_CHECK_FAILURE 0xC0000355
+#define NT_STATUS_AUDITING_DISABLED 0xC0000356
+#define NT_STATUS_PRENT4_MACHINE_ACCOUNT 0xC0000357
+#define NT_STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER 0xC0000358
+#define NT_STATUS_INVALID_IMAGE_WIN_32 0xC0000359
+#define NT_STATUS_INVALID_IMAGE_WIN_64 0xC000035A
+#define NT_STATUS_BAD_BINDINGS 0xC000035B
+#define NT_STATUS_NETWORK_SESSION_EXPIRED 0xC000035C
+#define NT_STATUS_APPHELP_BLOCK 0xC000035D
+#define NT_STATUS_ALL_SIDS_FILTERED 0xC000035E
+#define NT_STATUS_NOT_SAFE_MODE_DRIVER 0xC000035F
+#define NT_STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT 0xC0000361
+#define NT_STATUS_ACCESS_DISABLED_BY_POLICY_PATH 0xC0000362
+#define NT_STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER 0xC0000363
+#define NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER 0xC0000364
+#define NT_STATUS_FAILED_DRIVER_ENTRY 0xC0000365
+#define NT_STATUS_DEVICE_ENUMERATION_ERROR 0xC0000366
+#define NT_STATUS_WAIT_FOR_OPLOCK 0x00000367
+#define NT_STATUS_MOUNT_POINT_NOT_RESOLVED 0xC0000368
+#define NT_STATUS_INVALID_DEVICE_OBJECT_PARAMETER 0xC0000369
+#define NT_STATUS_MCA_OCCURED 0xC000036A
+#define NT_STATUS_DRIVER_BLOCKED_CRITICAL 0xC000036B
+#define NT_STATUS_DRIVER_BLOCKED 0xC000036C
+#define NT_STATUS_DRIVER_DATABASE_ERROR 0xC000036D
+#define NT_STATUS_SYSTEM_HIVE_TOO_LARGE 0xC000036E
+#define NT_STATUS_INVALID_IMPORT_OF_NON_DLL 0xC000036F
+#define NT_STATUS_DS_SHUTTING_DOWN 0x40000370
+#define NT_STATUS_SMARTCARD_WRONG_PIN 0xC0000380
+#define NT_STATUS_SMARTCARD_CARD_BLOCKED 0xC0000381
+#define NT_STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED 0xC0000382
+#define NT_STATUS_SMARTCARD_NO_CARD 0xC0000383
+#define NT_STATUS_SMARTCARD_NO_KEY_CONTAINER 0xC0000384
+#define NT_STATUS_SMARTCARD_NO_CERTIFICATE 0xC0000385
+#define NT_STATUS_SMARTCARD_NO_KEYSET 0xC0000386
+#define NT_STATUS_SMARTCARD_IO_ERROR 0xC0000387
+#define NT_STATUS_DOWNGRADE_DETECTED 0xC0000388
+#define NT_STATUS_SMARTCARD_CERT_REVOKED 0xC0000389
+#define NT_STATUS_ISSUING_CA_UNTRUSTED 0xC000038A
+#define NT_STATUS_REVOCATION_OFFLINE_C 0xC000038B
+#define NT_STATUS_PKINIT_CLIENT_FAILURE 0xC000038C
+#define NT_STATUS_SMARTCARD_CERT_EXPIRED 0xC000038D
+#define NT_STATUS_DRIVER_FAILED_PRIOR_UNLOAD 0xC000038E
+#define NT_STATUS_WOW_ASSERTION 0xC0009898
+
+/* Facility Debugger (0x..01....) not used */
+
+/* Facility RPC Runtime (0x..02....) */
+#define RPC_NT_INVALID_STRING_BINDING 0xC0020001
+#define RPC_NT_WRONG_KIND_OF_BINDING 0xC0020002
+#define RPC_NT_INVALID_BINDING 0xC0020003
+#define RPC_NT_PROTSEQ_NOT_SUPPORTED 0xC0020004
+#define RPC_NT_INVALID_RPC_PROTSEQ 0xC0020005
+#define RPC_NT_INVALID_STRING_UUID 0xC0020006
+#define RPC_NT_INVALID_ENDPOINT_FORMAT 0xC0020007
+#define RPC_NT_INVALID_NET_ADDR 0xC0020008
+#define RPC_NT_NO_ENDPOINT_FOUND 0xC0020009
+#define RPC_NT_INVALID_TIMEOUT 0xC002000A
+#define RPC_NT_OBJECT_NOT_FOUND 0xC002000B
+#define RPC_NT_ALREADY_REGISTERED 0xC002000C
+#define RPC_NT_TYPE_ALREADY_REGISTERED 0xC002000D
+#define RPC_NT_ALREADY_LISTENING 0xC002000E
+#define RPC_NT_NO_PROTSEQS_REGISTERED 0xC002000F
+#define RPC_NT_NOT_LISTENING 0xC0020010
+#define RPC_NT_UNKNOWN_MGR_TYPE 0xC0020011
+#define RPC_NT_UNKNOWN_IF 0xC0020012
+#define RPC_NT_NO_BINDINGS 0xC0020013
+#define RPC_NT_NO_PROTSEQS 0xC0020014
+#define RPC_NT_CANT_CREATE_ENDPOINT 0xC0020015
+#define RPC_NT_OUT_OF_RESOURCES 0xC0020016
+#define RPC_NT_SERVER_UNAVAILABLE 0xC0020017
+#define RPC_NT_SERVER_TOO_BUSY 0xC0020018
+#define RPC_NT_INVALID_NETWORK_OPTIONS 0xC0020019
+#define RPC_NT_NO_CALL_ACTIVE 0xC002001A
+#define RPC_NT_CALL_FAILED 0xC002001B
+#define RPC_NT_CALL_FAILED_DNE 0xC002001C
+#define RPC_NT_PROTOCOL_ERROR 0xC002001D
+#define RPC_NT_UNSUPPORTED_TRANS_SYN 0xC002001F
+#define RPC_NT_UNSUPPORTED_TYPE 0xC0020021
+#define RPC_NT_INVALID_TAG 0xC0020022
+#define RPC_NT_INVALID_BOUND 0xC0020023
+#define RPC_NT_NO_ENTRY_NAME 0xC0020024
+#define RPC_NT_INVALID_NAME_SYNTAX 0xC0020025
+#define RPC_NT_UNSUPPORTED_NAME_SYNTAX 0xC0020026
+#define RPC_NT_UUID_NO_ADDRESS 0xC0020028
+#define RPC_NT_DUPLICATE_ENDPOINT 0xC0020029
+#define RPC_NT_UNKNOWN_AUTHN_TYPE 0xC002002A
+#define RPC_NT_MAX_CALLS_TOO_SMALL 0xC002002B
+#define RPC_NT_STRING_TOO_LONG 0xC002002C
+#define RPC_NT_PROTSEQ_NOT_FOUND 0xC002002D
+#define RPC_NT_PROCNUM_OUT_OF_RANGE 0xC002002E
+#define RPC_NT_BINDING_HAS_NO_AUTH 0xC002002F
+#define RPC_NT_UNKNOWN_AUTHN_SERVICE 0xC0020030
+#define RPC_NT_UNKNOWN_AUTHN_LEVEL 0xC0020031
+#define RPC_NT_INVALID_AUTH_IDENTITY 0xC0020032
+#define RPC_NT_UNKNOWN_AUTHZ_SERVICE 0xC0020033
+#define EPT_NT_INVALID_ENTRY 0xC0020034
+#define EPT_NT_CANT_PERFORM_OP 0xC0020035
+#define EPT_NT_NOT_REGISTERED 0xC0020036
+#define RPC_NT_NOTHING_TO_EXPORT 0xC0020037
+#define RPC_NT_INCOMPLETE_NAME 0xC0020038
+#define RPC_NT_INVALID_VERS_OPTION 0xC0020039
+#define RPC_NT_NO_MORE_MEMBERS 0xC002003A
+#define RPC_NT_NOT_ALL_OBJS_UNEXPORTED 0xC002003B
+#define RPC_NT_INTERFACE_NOT_FOUND 0xC002003C
+#define RPC_NT_ENTRY_ALREADY_EXISTS 0xC002003D
+#define RPC_NT_ENTRY_NOT_FOUND 0xC002003E
+#define RPC_NT_NAME_SERVICE_UNAVAILABLE 0xC002003F
+#define RPC_NT_INVALID_NAF_ID 0xC0020040
+#define RPC_NT_CANNOT_SUPPORT 0xC0020041
+#define RPC_NT_NO_CONTEXT_AVAILABLE 0xC0020042
+#define RPC_NT_INTERNAL_ERROR 0xC0020043
+#define RPC_NT_ZERO_DIVIDE 0xC0020044
+#define RPC_NT_ADDRESS_ERROR 0xC0020045
+#define RPC_NT_FP_DIV_ZERO 0xC0020046
+#define RPC_NT_FP_UNDERFLOW 0xC0020047
+#define RPC_NT_FP_OVERFLOW 0xC0020048
+#define RPC_NT_CALL_IN_PROGRESS 0xC0020049
+#define RPC_NT_NO_MORE_BINDINGS 0xC002004A
+#define RPC_NT_GROUP_MEMBER_NOT_FOUND 0xC002004B
+#define EPT_NT_CANT_CREATE 0xC002004C
+#define RPC_NT_INVALID_OBJECT 0xC002004D
+#define RPC_NT_NO_INTERFACES 0xC002004F
+#define RPC_NT_CALL_CANCELLED 0xC0020050
+#define RPC_NT_BINDING_INCOMPLETE 0xC0020051
+#define RPC_NT_COMM_FAILURE 0xC0020052
+#define RPC_NT_UNSUPPORTED_AUTHN_LEVEL 0xC0020053
+#define RPC_NT_NO_PRINC_NAME 0xC0020054
+#define RPC_NT_NOT_RPC_ERROR 0xC0020055
+#define RPC_NT_UUID_LOCAL_ONLY 0x40020056
+#define RPC_NT_SEC_PKG_ERROR 0xC0020057
+#define RPC_NT_NOT_CANCELLED 0xC0020058
+#define RPC_NT_INVALID_ASYNC_HANDLE 0xC0020062
+#define RPC_NT_INVALID_ASYNC_CALL 0xC0020063
+#define RPC_NT_PROXY_ACCESS_DENIED 0xC0020064
+#define RPC_NT_SEND_INCOMPLETE 0x400200AF
+
+/* Facility RPC Stubs (0x..03....) */
+#define RPC_NT_NO_MORE_ENTRIES 0xC0030001
+#define RPC_NT_SS_CHAR_TRANS_OPEN_FAIL 0xC0030002
+#define RPC_NT_SS_CHAR_TRANS_SHORT_FILE 0xC0030003
+#define RPC_NT_SS_IN_NULL_CONTEXT 0xC0030004
+#define RPC_NT_SS_CONTEXT_MISMATCH 0xC0030005
+#define RPC_NT_SS_CONTEXT_DAMAGED 0xC0030006
+#define RPC_NT_SS_HANDLES_MISMATCH 0xC0030007
+#define RPC_NT_SS_CANNOT_GET_CALL_HANDLE 0xC0030008
+#define RPC_NT_NULL_REF_POINTER 0xC0030009
+#define RPC_NT_ENUM_VALUE_OUT_OF_RANGE 0xC003000A
+#define RPC_NT_BYTE_COUNT_TOO_SMALL 0xC003000B
+#define RPC_NT_BAD_STUB_DATA 0xC003000C
+#define RPC_NT_INVALID_ES_ACTION 0xC0030059
+#define RPC_NT_WRONG_ES_VERSION 0xC003005A
+#define RPC_NT_WRONG_STUB_VERSION 0xC003005B
+#define RPC_NT_INVALID_PIPE_OBJECT 0xC003005C
+#define RPC_NT_INVALID_PIPE_OPERATION 0xC003005D
+#define RPC_NT_WRONG_PIPE_VERSION 0xC003005E
+#define RPC_NT_PIPE_CLOSED 0xC003005F
+#define RPC_NT_PIPE_DISCIPLINE_ERROR 0xC0030060
+#define RPC_NT_PIPE_EMPTY 0xC0030061
+
+/*
+ * Status codes from higher numbered facilities are not used.
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SMB_NTSTATUS_H */
diff --git a/usr/src/uts/common/smbsrv/Makefile b/usr/src/uts/common/smbsrv/Makefile
index a7939abc4b..946bf8317e 100644
--- a/usr/src/uts/common/smbsrv/Makefile
+++ b/usr/src/uts/common/smbsrv/Makefile
@@ -19,17 +19,15 @@
# CDDL HEADER END
#
#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+#
include ../../../Makefile.master
HDRS= alloc.h \
cp_unicode.h \
cp_usascii.h \
- doserror.h \
hash_table.h \
- lmerr.h \
mac_cifs.h \
mailslot.h \
mbuf.h \
@@ -39,11 +37,9 @@ HDRS= alloc.h \
netrauth.h \
nmpipes.h \
ntaccess.h \
- nterror.h \
ntifs.h \
ntlocale.h \
smb_sid.h \
- ntstatus.h \
smb.h \
smb_door.h \
smb_dfs.h \
diff --git a/usr/src/uts/common/smbsrv/doserror.h b/usr/src/uts/common/smbsrv/doserror.h
deleted file mode 100644
index b6898c80eb..0000000000
--- a/usr/src/uts/common/smbsrv/doserror.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SMBSRV_DOSERROR_H
-#define _SMBSRV_DOSERROR_H
-
-/*
- * This file defines the list of DOS error codes. I think the error
- * codes are divided into different classes, which is why there are
- * duplicate values.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*
- * Error source or class
- */
-#define ERRDOS 0x01 /* Core DOS operating system error. */
-#define ERRSRV 0x02 /* Server network file error */
-#define ERRHRD 0x03 /* Hardware error */
-#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
-
-
-/*
- * ERRDOS error codes
- */
-#define ERRbadfunc 1 /* Invalid function. The server did not */
-#define ERRbadfile 2 /* File not found. The last component of a */
-#define ERRbadpath 3 /* Directory invalid. A directory component in */
-#define ERRnofids 4 /* Too many open files. The server has no file */
-#define ERRnoaccess 5 /* Access denied, the client's context does not */
-#define ERRbadfid 6 /* Invalid file handle. The file handle */
-#define ERRbadmcb 7 /* Memory control blocks destroyed. */
-#define ERRnomem 8 /* Insufficient server memory to perform the */
-#define ERRbadmem 9 /* Invalid memory block address. */
-#define ERRbadenv 10 /* Invalid environment. */
-#define ERRbadformat 11 /* Invalid format. */
-#define ERRbadaccess 12 /* Invalid open mode. */
-#define ERRbaddata 13 /* Invalid data (generated only by IOCTL calls */
-#define ERRbaddrive 15 /* Invalid drive specified. */
-#define ERRremcd 16 /* A Delete Directory request attempted to */
-#define ERRdiffdevice 17 /* Not same device (e.g., a cross volume rename */
-#define ERRnofiles 18 /* A File Search command can find no more files */
-#define ERRbadshare 32 /* The sharing mode specified for an Open */
-#define ERRlock 33 /* A Lock request conflicted with an existing */
-#define ERRfilexists 80 /* The file named in a Create Directory, Make */
-#define ERRnotlocked 158 /* No lock matched the unlock range */
-#define ERRnoatomiclocks 174 /* Change lock type not supported */
-#define ERRbadpipe 230 /* Pipe invalid. */
-#define ERRpipebusy 231 /* All instances of the requested pipe are busy. */
-#define ERRpipeclosing 232 /* Pipe close in progress. */
-#define ERRnotconnected 233 /* No process on other end of pipe. */
-#define ERRmoredata 234 /* There is more data to be returned. */
-#define ERRunknownlevel 124
-
-
-/*
- * ERRSRV error codes
- */
-#define ERRerror 1 /* Non-specific error code. It is returned */
-#define ERRbadpw 2 /* Bad password - name/password pair in a Tree */
-#define ERRaccess 4 /* The client does not have the necessary access */
-#define ERRinvnid 5 /* The Tid specified in a command was invalid. */
-#define ERRinvnetname 6 /* Invalid network name in tree connect. */
-#define ERRinvdevice 7 /* Invalid device - printer request made to non- */
-#define ERRqfull 49 /* Print queue full (files) -- returned by open */
-#define ERRqtoobig 50 /* Print queue full -- no space. */
-#define ERRqeof 51 /* EOF on print queue dump. */
-#define ERRinvpfid 52 /* Invalid print file FID. */
-#define ERRsmbcmd 64 /* The server did not recognize the command */
-#define ERRsrverror 65 /* The server encountered an internal error, */
-#define ERRfilespecs 67 /* The Fid and pathname parameters contained an */
-#define ERRbadpermits 69 /* The access permissions specified for a file */
-#define ERRsetattrmode 71 /* The attribute mode in the Set File Attribute */
-#define ERRpaused 81 /* Server is paused. (reserved for messaging) */
-#define ERRmsgoff 82 /* Not receiving messages. (reserved for */
-#define ERRnoroom 83 /* No room to buffer message. (reserved for */
-#define ERRrmuns 87 /* Too many remote user names. (reserved for */
-#define ERRtimeout 88 /* Operation timed out. */
-#define ERRnoresource 89 /* No resources currently available for request. */
-#define ERRtoomanyuids 90 /* Too many Uids active on this session. */
-#define ERRbaduid 91 /* The Uid is not known as a valid user */
-#define ERRusempx 250 /* Temporarily unable to support Raw, use MPX */
-#define ERRusestd 251 /* Temporarily unable to support Raw, use */
-#define ERRcontmpx 252 /* Continue in MPX mode. */
-#define ERRnosupport 65535 /* Function not supported. */
-
-
-/*
- * ERRHRD error codes
- */
-#define ERRnowrite 19 /* Attempt to write on write-protected media */
-#define ERRbadunit 20 /* Unknown unit. */
-#define ERRnotready 21 /* Drive not ready. */
-#define ERRbadcmd 22 /* Unknown command. */
-#define ERRdata 23 /* Data error (CRC). */
-#define ERRbadreq 24 /* Bad request structure length. */
-#define ERRseek 25 /* Seek error. */
-#define ERRbadmedia 26 /* Unknown media type. */
-#define ERRbadsector 27 /* Sector not found. */
-#define ERRnopaper 28 /* Printer out of paper. */
-#define ERRwrite 29 /* Write fault. */
-#define ERRread 30 /* Read fault. */
-#define ERRgeneral 31 /* General failure. */
-#define ERRbadshare 32 /* A open conflicts with an existing open. */
-#define ERRlock 33 /* A Lock request conflicted with an existing */
-#define ERRwrongdisk 34 /* The wrong disk was found in a drive. */
-#define ERRFCBUnavail 35 /* No FCBs are available to process request. */
-#define ERRsharebufexc 36 /* A sharing buffer has been exceeded. */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SMBSRV_DOSERROR_H */
diff --git a/usr/src/uts/common/smbsrv/nterror.h b/usr/src/uts/common/smbsrv/nterror.h
deleted file mode 100644
index 1ba435c66f..0000000000
--- a/usr/src/uts/common/smbsrv/nterror.h
+++ /dev/null
@@ -1,942 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-
-#ifndef _SMBSRV_NTERROR_H
-#define _SMBSRV_NTERROR_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * This file defines the list of Win32 error codes. If you need an
- * error code that is defined in the Win32 Error Codes document but
- * is not listed here, please add it to the file. There is a list
- * of Win32 error codes on:
- *
- * http://msdn.microsoft.com/library/psdk/psdkref/errlist_9usz.htm
- *
- * Be careful not to confuse status codes with error codes. The status
- * codes are listed in ntstatus.h. Some mappings between NT status
- * codes and Win32 error codes is provided in the Microsoft knowledge
- * base article Q113996.
- *
- * Win32 error codes are 32-bit values with the following format
- * (winerror.h):
- *
- * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
- * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- * +---+-+-+-----------------------+-------------------------------+
- * |Sev|C|R| Facility | Code |
- * +---+-+-+-----------------------+-------------------------------+
- *
- * Sev severity code
- * 00 - Success
- * 01 - Informational
- * 10 - Warning
- * 11 - Error
- *
- * C customer/client flag (set to 1 for user defined codes).
- * R reserved (set to zero)
- * Facility facility code
- * Code facility's status code
- */
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*
- * Facility codes
- */
-#define FACILITY_NULL 0
-#define FACILITY_RPC 1
-#define FACILITY_DISPATCH 2
-#define FACILITY_STORAGE 3
-#define FACILITY_ITF 4
-/* 5 */
-/* 6 */
-#define FACILITY_WIN32 7
-#define FACILITY_WINDOWS 8
-#define FACILITY_SSPI 9
-#define FACILITY_CONTROL 10
-#define FACILITY_CERT 11
-#define FACILITY_INTERNET 12
-#define FACILITY_MEDIASERVER 13
-#define FACILITY_MSMQ 14
-#define FACILITY_SETUPAPI 15
-
-
-/*
- * Complete list of Win32 error codes. For error description
- * you can look at MS-KB articles 155011 and 155012
- */
-
-#define ERROR_SUCCESS 0
-#define NO_ERROR 0
-#define ERROR_INVALID_FUNCTION 1
-#define ERROR_FILE_NOT_FOUND 2
-#define ERROR_PATH_NOT_FOUND 3
-#define ERROR_TOO_MANY_OPEN_FILES 4
-#define ERROR_ACCESS_DENIED 5
-#define ERROR_INVALID_HANDLE 6
-#define ERROR_ARENA_TRASHED 7
-#define ERROR_NOT_ENOUGH_MEMORY 8
-#define ERROR_INVALID_BLOCK 9
-#define ERROR_BAD_ENVIRONMENT 10
-#define ERROR_BAD_FORMAT 11
-#define ERROR_INVALID_ACCESS 12
-#define ERROR_INVALID_DATA 13
-#define ERROR_OUTOFMEMORY 14
-#define ERROR_INVALID_DRIVE 15
-#define ERROR_CURRENT_DIRECTORY 16
-#define ERROR_NOT_SAME_DEVICE 17
-#define ERROR_NO_MORE_FILES 18
-#define ERROR_WRITE_PROTECT 19
-#define ERROR_BAD_UNIT 20
-#define ERROR_NOT_READY 21
-#define ERROR_BAD_COMMAND 22
-#define ERROR_CRC 23
-#define ERROR_BAD_LENGTH 24
-#define ERROR_SEEK 25
-#define ERROR_NOT_DOS_DISK 26
-#define ERROR_SECTOR_NOT_FOUND 27
-#define ERROR_OUT_OF_PAPER 28
-#define ERROR_WRITE_FAULT 29
-#define ERROR_READ_FAULT 30
-#define ERROR_GEN_FAILURE 31
-#define ERROR_SHARING_VIOLATION 32
-#define ERROR_LOCK_VIOLATION 33
-#define ERROR_WRONG_DISK 34
-#define ERROR_SHARING_BUFFER_EXCEEDED 36
-#define ERROR_HANDLE_EOF 38
-#define ERROR_HANDLE_DISK_FULL 39
-#define ERROR_NOT_SUPPORTED 50
-#define ERROR_REM_NOT_LIST 51
-#define ERROR_DUP_NAME 52
-#define ERROR_BAD_NETPATH 53
-#define ERROR_NETWORK_BUSY 54
-#define ERROR_DEV_NOT_EXIST 55
-#define ERROR_TOO_MANY_CMDS 56
-#define ERROR_ADAP_HDW_ERR 57
-#define ERROR_BAD_NET_RESP 58
-#define ERROR_UNEXP_NET_ERR 59
-#define ERROR_BAD_REM_ADAP 60
-#define ERROR_PRINTQ_FULL 61
-#define ERROR_NO_SPOOL_SPACE 62
-#define ERROR_PRINT_CANCELLED 63
-#define ERROR_NETNAME_DELETED 64
-#define ERROR_NETWORK_ACCESS_DENIED 65
-#define ERROR_BAD_DEV_TYPE 66
-#define ERROR_BAD_NET_NAME 67
-#define ERROR_TOO_MANY_NAMES 68
-#define ERROR_TOO_MANY_SESS 69
-#define ERROR_SHARING_PAUSED 70
-#define ERROR_REQ_NOT_ACCEP 71
-#define ERROR_REDIR_PAUSED 72
-#define ERROR_FILE_EXISTS 80
-#define ERROR_CANNOT_MAKE 82
-#define ERROR_FAIL_I24 83
-#define ERROR_OUT_OF_STRUCTURES 84
-#define ERROR_ALREADY_ASSIGNED 85
-#define ERROR_INVALID_PASSWORD 86
-#define ERROR_INVALID_PARAMETER 87
-#define ERROR_NET_WRITE_FAULT 88
-#define ERROR_NO_PROC_SLOTS 89
-#define ERROR_TOO_MANY_SEMAPHORES 100
-#define ERROR_EXCL_SEM_ALREADY_OWNED 101
-#define ERROR_SEM_IS_SET 102
-#define ERROR_TOO_MANY_SEM_REQUESTS 103
-#define ERROR_INVALID_AT_INTERRUPT_TIME 104
-#define ERROR_SEM_OWNER_DIED 105
-#define ERROR_SEM_USER_LIMIT 106
-#define ERROR_DISK_CHANGE 107
-#define ERROR_DRIVE_LOCKED 108
-#define ERROR_BROKEN_PIPE 109
-#define ERROR_OPEN_FAILED 110
-#define ERROR_BUFFER_OVERFLOW 111
-#define ERROR_DISK_FULL 112
-#define ERROR_NO_MORE_SEARCH_HANDLES 113
-#define ERROR_INVALID_TARGET_HANDLE 114
-#define ERROR_INVALID_CATEGORY 117
-#define ERROR_INVALID_VERIFY_SWITCH 118
-#define ERROR_BAD_DRIVER_LEVEL 119
-#define ERROR_CALL_NOT_IMPLEMENTED 120
-#define ERROR_SEM_TIMEOUT 121
-#define ERROR_INSUFFICIENT_BUFFER 122
-#define ERROR_INVALID_NAME 123
-#define ERROR_INVALID_LEVEL 124
-#define ERROR_NO_VOLUME_LABEL 125
-#define ERROR_MOD_NOT_FOUND 126
-#define ERROR_PROC_NOT_FOUND 127
-#define ERROR_WAIT_NO_CHILDREN 128
-#define ERROR_CHILD_NOT_COMPLETE 129
-#define ERROR_DIRECT_ACCESS_HANDLE 130
-#define ERROR_NEGATIVE_SEEK 131
-#define ERROR_SEEK_ON_DEVICE 132
-#define ERROR_IS_JOIN_TARGET 133
-#define ERROR_IS_JOINED 134
-#define ERROR_IS_SUBSTED 135
-#define ERROR_NOT_JOINED 136
-#define ERROR_NOT_SUBSTED 137
-#define ERROR_JOIN_TO_JOIN 138
-#define ERROR_SUBST_TO_SUBST 139
-#define ERROR_JOIN_TO_SUBST 140
-#define ERROR_SUBST_TO_JOIN 141
-#define ERROR_BUSY_DRIVE 142
-#define ERROR_SAME_DRIVE 143
-#define ERROR_DIR_NOT_ROOT 144
-#define ERROR_DIR_NOT_EMPTY 145
-#define ERROR_IS_SUBST_PATH 146
-#define ERROR_IS_JOIN_PATH 147
-#define ERROR_PATH_BUSY 148
-#define ERROR_IS_SUBST_TARGET 149
-#define ERROR_SYSTEM_TRACE 150
-#define ERROR_INVALID_EVENT_COUNT 151
-#define ERROR_TOO_MANY_MUXWAITERS 152
-#define ERROR_INVALID_LIST_FORMAT 153
-#define ERROR_LABEL_TOO_LONG 154
-#define ERROR_TOO_MANY_TCBS 155
-#define ERROR_SIGNAL_REFUSED 156
-#define ERROR_DISCARDED 157
-#define ERROR_NOT_LOCKED 158
-#define ERROR_BAD_THREADID_ADDR 159
-#define ERROR_BAD_ARGUMENTS 160
-#define ERROR_BAD_PATHNAME 161
-#define ERROR_SIGNAL_PENDING 162
-#define ERROR_MAX_THRDS_REACHED 164
-#define ERROR_LOCK_FAILED 167
-#define ERROR_BUSY 170
-#define ERROR_CANCEL_VIOLATION 173
-#define ERROR_ATOMIC_LOCKS_NOT_SUPPORTED 174
-#define ERROR_INVALID_SEGMENT_NUMBER 180
-#define ERROR_INVALID_ORDINAL 182
-#define ERROR_ALREADY_EXISTS 183
-#define ERROR_INVALID_FLAG_NUMBER 186
-#define ERROR_SEM_NOT_FOUND 187
-#define ERROR_INVALID_STARTING_CODESEG 188
-#define ERROR_INVALID_STACKSEG 189
-#define ERROR_INVALID_MODULETYPE 190
-#define ERROR_INVALID_EXE_SIGNATURE 191
-#define ERROR_EXE_MARKED_INVALID 192
-#define ERROR_BAD_EXE_FORMAT 193
-#define ERROR_ITERATED_DATA_EXCEEDS_64k 194
-#define ERROR_INVALID_MINALLOCSIZE 195
-#define ERROR_DYNLINK_FROM_INVALID_RING 196
-#define ERROR_IOPL_NOT_ENABLED 197
-#define ERROR_INVALID_SEGDPL 198
-#define ERROR_AUTODATASEG_EXCEEDS_64k 199
-#define ERROR_RING2SEG_MUST_BE_MOVABLE 200
-#define ERROR_RELOC_CHAIN_XEEDS_SEGLIM 201
-#define ERROR_INFLOOP_IN_RELOC_CHAIN 202
-#define ERROR_ENVVAR_NOT_FOUND 203
-#define ERROR_NO_SIGNAL_SENT 205
-#define ERROR_FILENAME_EXCED_RANGE 206
-#define ERROR_RING2_STACK_IN_USE 207
-#define ERROR_META_EXPANSION_TOO_LONG 208
-#define ERROR_INVALID_SIGNAL_NUMBER 209
-#define ERROR_THREAD_1_INACTIVE 210
-#define ERROR_LOCKED 212
-#define ERROR_TOO_MANY_MODULES 214
-#define ERROR_NESTING_NOT_ALLOWED 215
-#define ERROR_EXE_MACHINE_TYPE_MISMATCH 216
-#define ERROR_BAD_PIPE 230
-#define ERROR_PIPE_BUSY 231
-#define ERROR_NO_DATA 232
-#define ERROR_PIPE_NOT_CONNECTED 233
-#define ERROR_MORE_DATA 234
-#define ERROR_VC_DISCONNECTED 240
-#define ERROR_INVALID_EA_NAME 254
-#define ERROR_EA_LIST_INCONSISTENT 255
-#define ERROR_NO_MORE_ITEMS 259
-#define ERROR_MORE_ENTRIES 261
-#define ERROR_CANNOT_COPY 266
-#define ERROR_DIRECTORY 267
-#define ERROR_EAS_DIDNT_FIT 275
-#define ERROR_EA_FILE_CORRUPT 276
-#define ERROR_EA_TABLE_FULL 277
-#define ERROR_INVALID_EA_HANDLE 278
-#define ERROR_EAS_NOT_SUPPORTED 282
-#define ERROR_NOT_OWNER 288
-#define ERROR_TOO_MANY_POSTS 298
-#define ERROR_PARTIAL_COPY 299
-#define ERROR_OPLOCK_NOT_GRANTED 300
-#define ERROR_INVALID_OPLOCK_PROTOCOL 301
-#define ERROR_MR_MID_NOT_FOUND 317
-#define ERROR_INVALID_ADDRESS 487
-#define ERROR_ARITHMETIC_OVERFLOW 534
-#define ERROR_PIPE_CONNECTED 535
-#define ERROR_PIPE_LISTENING 536
-#define ERROR_EA_ACCESS_DENIED 994
-#define ERROR_OPERATION_ABORTED 995
-#define ERROR_IO_INCOMPLETE 996
-#define ERROR_IO_PENDING 997
-#define ERROR_NOACCESS 998
-#define ERROR_SWAPERROR 999
-#define ERROR_STACK_OVERFLOW 1001
-#define ERROR_INVALID_MESSAGE 1002
-#define ERROR_CAN_NOT_COMPLETE 1003
-#define ERROR_INVALID_FLAGS 1004
-#define ERROR_UNRECOGNIZED_VOLUME 1005
-#define ERROR_FILE_INVALID 1006
-#define ERROR_FULLSCREEN_MODE 1007
-#define ERROR_NO_TOKEN 1008
-#define ERROR_BADDB 1009
-#define ERROR_BADKEY 1010
-#define ERROR_CANTOPEN 1011
-#define ERROR_CANTREAD 1012
-#define ERROR_CANTWRITE 1013
-#define ERROR_REGISTRY_RECOVERED 1014
-#define ERROR_REGISTRY_CORRUPT 1015
-#define ERROR_REGISTRY_IO_FAILED 1016
-#define ERROR_NOT_REGISTRY_FILE 1017
-#define ERROR_KEY_DELETED 1018
-#define ERROR_NO_LOG_SPACE 1019
-#define ERROR_KEY_HAS_CHILDREN 1020
-#define ERROR_CHILD_MUST_BE_VOLATILE 1021
-#define ERROR_NOTIFY_ENUM_DIR 1022
-#define ERROR_DEPENDENT_SERVICES_RUNNING 1051
-#define ERROR_INVALID_SERVICE_CONTROL 1052
-#define ERROR_SERVICE_REQUEST_TIMEOUT 1053
-#define ERROR_SERVICE_NO_THREAD 1054
-#define ERROR_SERVICE_DATABASE_LOCKED 1055
-#define ERROR_SERVICE_ALREADY_RUNNING 1056
-#define ERROR_INVALID_SERVICE_ACCOUNT 1057
-#define ERROR_SERVICE_DISABLED 1058
-#define ERROR_CIRCULAR_DEPENDENCY 1059
-#define ERROR_SERVICE_DOES_NOT_EXIST 1060
-#define ERROR_SERVICE_CANNOT_ACCEPT_CTRL 1061
-#define ERROR_SERVICE_NOT_ACTIVE 1062
-#define ERROR_FAILED_SERVICE_CONTROLLER_CONNECT 1063
-#define ERROR_EXCEPTION_IN_SERVICE 1064
-#define ERROR_DATABASE_DOES_NOT_EXIST 1065
-#define ERROR_SERVICE_SPECIFIC_ERROR 1066
-#define ERROR_PROCESS_ABORTED 1067
-#define ERROR_SERVICE_DEPENDENCY_FAIL 1068
-#define ERROR_SERVICE_LOGON_FAILED 1069
-#define ERROR_SERVICE_START_HANG 1070
-#define ERROR_INVALID_SERVICE_LOCK 1071
-#define ERROR_SERVICE_MARKED_FOR_DELETE 1072
-#define ERROR_SERVICE_EXISTS 1073
-#define ERROR_ALREADY_RUNNING_LKG 1074
-#define ERROR_SERVICE_DEPENDENCY_DELETED 1075
-#define ERROR_BOOT_ALREADY_ACCEPTED 1076
-#define ERROR_SERVICE_NEVER_STARTED 1077
-#define ERROR_DUPLICATE_SERVICE_NAME 1078
-#define ERROR_DIFFERENT_SERVICE_ACCOUNT 1079
-#define ERROR_CANNOT_DETECT_DRIVER_FAILURE 1080
-#define ERROR_CANNOT_DETECT_PROCESS_ABORT 1081
-#define ERROR_NO_RECOVERY_PROGRAM 1082
-#define ERROR_END_OF_MEDIA 1100
-#define ERROR_FILEMARK_DETECTED 1101
-#define ERROR_BEGINNING_OF_MEDIA 1102
-#define ERROR_SETMARK_DETECTED 1103
-#define ERROR_NO_DATA_DETECTED 1104
-#define ERROR_PARTITION_FAILURE 1105
-#define ERROR_INVALID_BLOCK_LENGTH 1106
-#define ERROR_DEVICE_NOT_PARTITIONED 1107
-#define ERROR_UNABLE_TO_LOCK_MEDIA 1108
-#define ERROR_UNABLE_TO_UNLOAD_MEDIA 1109
-#define ERROR_MEDIA_CHANGED 1110
-#define ERROR_BUS_RESET 1111
-#define ERROR_NO_MEDIA_IN_DRIVE 1112
-#define ERROR_NO_UNICODE_TRANSLATION 1113
-#define ERROR_DLL_INIT_FAILED 1114
-#define ERROR_SHUTDOWN_IN_PROGRESS 1115
-#define ERROR_NO_SHUTDOWN_IN_PROGRESS 1116
-#define ERROR_IO_DEVICE 1117
-#define ERROR_SERIAL_NO_DEVICE 1118
-#define ERROR_IRQ_BUSY 1119
-#define ERROR_MORE_WRITES 1120
-#define ERROR_COUNTER_TIMEOUT 1121
-#define ERROR_FLOPPY_ID_MARK_NOT_FOUND 1122
-#define ERROR_FLOPPY_WRONG_CYLINDER 1123
-#define ERROR_FLOPPY_UNKNOWN_ERROR 1124
-#define ERROR_FLOPPY_BAD_REGISTERS 1125
-#define ERROR_DISK_RECALIBRATE_FAILED 1126
-#define ERROR_DISK_OPERATION_FAILED 1127
-#define ERROR_DISK_RESET_FAILED 1128
-#define ERROR_EOM_OVERFLOW 1129
-#define ERROR_NOT_ENOUGH_SERVER_MEMORY 1130
-#define ERROR_POSSIBLE_DEADLOCK 1131
-#define ERROR_MAPPED_ALIGNMENT 1132
-#define ERROR_SET_POWER_STATE_VETOED 1140
-#define ERROR_SET_POWER_STATE_FAILED 1141
-#define ERROR_TOO_MANY_LINKS 1142
-#define ERROR_OLD_WIN_VERSION 1150
-#define ERROR_APP_WRONG_OS 1151
-#define ERROR_SINGLE_INSTANCE_APP 1152
-#define ERROR_RMODE_APP 1153
-#define ERROR_INVALID_DLL 1154
-#define ERROR_NO_ASSOCIATION 1155
-#define ERROR_DDE_FAIL 1156
-#define ERROR_DLL_NOT_FOUND 1157
-#define ERROR_NO_MORE_USER_HANDLES 1158
-#define ERROR_MESSAGE_SYNC_ONLY 1159
-#define ERROR_SOURCE_ELEMENT_EMPTY 1160
-#define ERROR_DESTINATION_ELEMENT_FULL 1161
-#define ERROR_ILLEGAL_ELEMENT_ADDRESS 1162
-#define ERROR_MAGAZINE_NOT_PRESENT 1163
-#define ERROR_DEVICE_REINITIALIZATION_NEEDED 1164
-#define ERROR_DEVICE_REQUIRES_CLEANING 1165
-#define ERROR_DEVICE_DOOR_OPEN 1166
-#define ERROR_DEVICE_NOT_CONNECTED 1167
-#define ERROR_NOT_FOUND 1168
-#define ERROR_NO_MATCH 1169
-#define ERROR_SET_NOT_FOUND 1170
-#define ERROR_POINT_NOT_FOUND 1171
-#define ERROR_NO_TRACKING_SERVICE 1172
-#define ERROR_NO_VOLUME_ID 1173
-#define ERROR_CONNECTED_OTHER_PASSWORD 2108
-#define ERROR_BAD_USERNAME 2202
-#define ERROR_NOT_CONNECTED 2250
-#define ERROR_OPEN_FILES 2401
-#define ERROR_ACTIVE_CONNECTIONS 2402
-#define ERROR_DEVICE_IN_USE 2404
-#define ERROR_BAD_DEVICE 1200
-#define ERROR_CONNECTION_UNAVAIL 1201
-#define ERROR_DEVICE_ALREADY_REMEMBERED 1202
-#define ERROR_NO_NET_OR_BAD_PATH 1203
-#define ERROR_BAD_PROVIDER 1204
-#define ERROR_CANNOT_OPEN_PROFILE 1205
-#define ERROR_BAD_PROFILE 1206
-#define ERROR_NOT_CONTAINER 1207
-#define ERROR_EXTENDED_ERROR 1208
-#define ERROR_INVALID_GROUPNAME 1209
-#define ERROR_INVALID_COMPUTERNAME 1210
-#define ERROR_INVALID_EVENTNAME 1211
-#define ERROR_INVALID_DOMAINNAME 1212
-#define ERROR_INVALID_SERVICENAME 1213
-#define ERROR_INVALID_NETNAME 1214
-#define ERROR_INVALID_SHARENAME 1215
-#define ERROR_INVALID_PASSWORDNAME 1216
-#define ERROR_INVALID_MESSAGENAME 1217
-#define ERROR_INVALID_MESSAGEDEST 1218
-#define ERROR_SESSION_CREDENTIAL_CONFLICT 1219
-#define ERROR_REMOTE_SESSION_LIMIT_EXCEEDED 1220
-#define ERROR_DUP_DOMAINNAME 1221
-#define ERROR_NO_NETWORK 1222
-#define ERROR_CANCELLED 1223
-#define ERROR_USER_MAPPED_FILE 1224
-#define ERROR_CONNECTION_REFUSED 1225
-#define ERROR_GRACEFUL_DISCONNECT 1226
-#define ERROR_ADDRESS_ALREADY_ASSOCIATED 1227
-#define ERROR_ADDRESS_NOT_ASSOCIATED 1228
-#define ERROR_CONNECTION_INVALID 1229
-#define ERROR_CONNECTION_ACTIVE 1230
-#define ERROR_NETWORK_UNREACHABLE 1231
-#define ERROR_HOST_UNREACHABLE 1232
-#define ERROR_PROTOCOL_UNREACHABLE 1233
-#define ERROR_PORT_UNREACHABLE 1234
-#define ERROR_REQUEST_ABORTED 1235
-#define ERROR_CONNECTION_ABORTED 1236
-#define ERROR_RETRY 1237
-#define ERROR_CONNECTION_COUNT_LIMIT 1238
-#define ERROR_LOGIN_TIME_RESTRICTION 1239
-#define ERROR_LOGIN_WKSTA_RESTRICTION 1240
-#define ERROR_INCORRECT_ADDRESS 1241
-#define ERROR_ALREADY_REGISTERED 1242
-#define ERROR_SERVICE_NOT_FOUND 1243
-#define ERROR_NOT_AUTHENTICATED 1244
-#define ERROR_NOT_LOGGED_ON 1245
-#define ERROR_CONTINUE 1246
-#define ERROR_ALREADY_INITIALIZED 1247
-#define ERROR_NO_MORE_DEVICES 1248
-#define ERROR_NO_SUCH_SITE 1249
-#define ERROR_DOMAIN_CONTROLLER_EXISTS 1250
-#define ERROR_DS_NOT_INSTALLED 1251
-#define ERROR_NOT_ALL_ASSIGNED 1300
-#define ERROR_SOME_NOT_MAPPED 1301
-#define ERROR_NO_QUOTAS_FOR_ACCOUNT 1302
-#define ERROR_LOCAL_USER_SESSION_KEY 1303
-#define ERROR_NULL_LM_PASSWORD 1304
-#define ERROR_UNKNOWN_REVISION 1305
-#define ERROR_REVISION_MISMATCH 1306
-#define ERROR_INVALID_OWNER 1307
-#define ERROR_INVALID_PRIMARY_GROUP 1308
-#define ERROR_NO_IMPERSONATION_TOKEN 1309
-#define ERROR_CANT_DISABLE_MANDATORY 1310
-#define ERROR_NO_LOGON_SERVERS 1311
-#define ERROR_NO_SUCH_LOGON_SESSION 1312
-#define ERROR_NO_SUCH_PRIVILEGE 1313
-#define ERROR_PRIVILEGE_NOT_HELD 1314
-#define ERROR_INVALID_ACCOUNT_NAME 1315
-#define ERROR_USER_EXISTS 1316
-#define ERROR_NO_SUCH_USER 1317
-#define ERROR_GROUP_EXISTS 1318
-#define ERROR_NO_SUCH_GROUP 1319
-#define ERROR_MEMBER_IN_GROUP 1320
-#define ERROR_MEMBER_NOT_IN_GROUP 1321
-#define ERROR_LAST_ADMIN 1322
-#define ERROR_WRONG_PASSWORD 1323
-#define ERROR_ILL_FORMED_PASSWORD 1324
-#define ERROR_PASSWORD_RESTRICTION 1325
-#define ERROR_LOGON_FAILURE 1326
-#define ERROR_ACCOUNT_RESTRICTION 1327
-#define ERROR_INVALID_LOGON_HOURS 1328
-#define ERROR_INVALID_WORKSTATION 1329
-#define ERROR_PASSWORD_EXPIRED 1330
-#define ERROR_ACCOUNT_DISABLED 1331
-#define ERROR_NONE_MAPPED 1332
-#define ERROR_TOO_MANY_LUIDS_REQUESTED 1333
-#define ERROR_LUIDS_EXHAUSTED 1334
-#define ERROR_INVALID_SUB_AUTHORITY 1335
-#define ERROR_INVALID_ACL 1336
-#define ERROR_INVALID_SID 1337
-#define ERROR_INVALID_SECURITY_DESCR 1338
-#define ERROR_BAD_INHERITANCE_ACL 1340
-#define ERROR_SERVER_DISABLED 1341
-#define ERROR_SERVER_NOT_DISABLED 1342
-#define ERROR_INVALID_ID_AUTHORITY 1343
-#define ERROR_ALLOTTED_SPACE_EXCEEDED 1344
-#define ERROR_INVALID_GROUP_ATTRIBUTES 1345
-#define ERROR_BAD_IMPERSONATION_LEVEL 1346
-#define ERROR_CANT_OPEN_ANONYMOUS 1347
-#define ERROR_BAD_VALIDATION_CLASS 1348
-#define ERROR_BAD_TOKEN_TYPE 1349
-#define ERROR_NO_SECURITY_ON_OBJECT 1350
-#define ERROR_CANT_ACCESS_DOMAIN_INFO 1351
-#define ERROR_INVALID_SERVER_STATE 1352
-#define ERROR_INVALID_DOMAIN_STATE 1353
-#define ERROR_INVALID_DOMAIN_ROLE 1354
-#define ERROR_NO_SUCH_DOMAIN 1355
-#define ERROR_DOMAIN_EXISTS 1356
-#define ERROR_DOMAIN_LIMIT_EXCEEDED 1357
-#define ERROR_INTERNAL_DB_CORRUPTION 1358
-#define ERROR_INTERNAL_ERROR 1359
-#define ERROR_GENERIC_NOT_MAPPED 1360
-#define ERROR_BAD_DESCRIPTOR_FORMAT 1361
-#define ERROR_NOT_LOGON_PROCESS 1362
-#define ERROR_LOGON_SESSION_EXISTS 1363
-#define ERROR_NO_SUCH_PACKAGE 1364
-#define ERROR_BAD_LOGON_SESSION_STATE 1365
-#define ERROR_LOGON_SESSION_COLLISION 1366
-#define ERROR_INVALID_LOGON_TYPE 1367
-#define ERROR_CANNOT_IMPERSONATE 1368
-#define ERROR_RXACT_INVALID_STATE 1369
-#define ERROR_RXACT_COMMIT_FAILURE 1370
-#define ERROR_SPECIAL_ACCOUNT 1371
-#define ERROR_SPECIAL_GROUP 1372
-#define ERROR_SPECIAL_USER 1373
-#define ERROR_MEMBERS_PRIMARY_GROUP 1374
-#define ERROR_TOKEN_ALREADY_IN_USE 1375
-#define ERROR_NO_SUCH_ALIAS 1376
-#define ERROR_MEMBER_NOT_IN_ALIAS 1377
-#define ERROR_MEMBER_IN_ALIAS 1378
-#define ERROR_ALIAS_EXISTS 1379
-#define ERROR_LOGON_NOT_GRANTED 1380
-#define ERROR_TOO_MANY_SECRETS 1381
-#define ERROR_SECRET_TOO_LONG 1382
-#define ERROR_INTERNAL_DB_ERROR 1383
-#define ERROR_TOO_MANY_CONTEXT_IDS 1384
-#define ERROR_LOGON_TYPE_NOT_GRANTED 1385
-#define ERROR_NT_CROSS_ENCRYPTION_REQUIRED 1386
-#define ERROR_NO_SUCH_MEMBER 1387
-#define ERROR_INVALID_MEMBER 1388
-#define ERROR_TOO_MANY_SIDS 1389
-#define ERROR_LM_CROSS_ENCRYPTION_REQUIRED 1390
-#define ERROR_NO_INHERITANCE 1391
-#define ERROR_FILE_CORRUPT 1392
-#define ERROR_DISK_CORRUPT 1393
-#define ERROR_NO_USER_SESSION_KEY 1394
-#define ERROR_LICENSE_QUOTA_EXCEEDED 1395
-#define ERROR_INVALID_WINDOW_HANDLE 1400
-#define ERROR_INVALID_MENU_HANDLE 1401
-#define ERROR_INVALID_CURSOR_HANDLE 1402
-#define ERROR_INVALID_ACCEL_HANDLE 1403
-#define ERROR_INVALID_HOOK_HANDLE 1404
-#define ERROR_INVALID_DWP_HANDLE 1405
-#define ERROR_TLW_WITH_WSCHILD 1406
-#define ERROR_CANNOT_FIND_WND_CLASS 1407
-#define ERROR_WINDOW_OF_OTHER_THREAD 1408
-#define ERROR_HOTKEY_ALREADY_REGISTERED 1409
-#define ERROR_CLASS_ALREADY_EXISTS 1410
-#define ERROR_CLASS_DOES_NOT_EXIST 1411
-#define ERROR_CLASS_HAS_WINDOWS 1412
-#define ERROR_INVALID_INDEX 1413
-#define ERROR_INVALID_ICON_HANDLE 1414
-#define ERROR_PRIVATE_DIALOG_INDEX 1415
-#define ERROR_LISTBOX_ID_NOT_FOUND 1416
-#define ERROR_NO_WILDCARD_CHARACTERS 1417
-#define ERROR_CLIPBOARD_NOT_OPEN 1418
-#define ERROR_HOTKEY_NOT_REGISTERED 1419
-#define ERROR_WINDOW_NOT_DIALOG 1420
-#define ERROR_CONTROL_ID_NOT_FOUND 1421
-#define ERROR_INVALID_COMBOBOX_MESSAGE 1422
-#define ERROR_WINDOW_NOT_COMBOBOX 1423
-#define ERROR_INVALID_EDIT_HEIGHT 1424
-#define ERROR_DC_NOT_FOUND 1425
-#define ERROR_INVALID_HOOK_FILTER 1426
-#define ERROR_INVALID_FILTER_PROC 1427
-#define ERROR_HOOK_NEEDS_HMOD 1428
-#define ERROR_GLOBAL_ONLY_HOOK 1429
-#define ERROR_JOURNAL_HOOK_SET 1430
-#define ERROR_HOOK_NOT_INSTALLED 1431
-#define ERROR_INVALID_LB_MESSAGE 1432
-#define ERROR_SETCOUNT_ON_BAD_LB 1433
-#define ERROR_LB_WITHOUT_TABSTOPS 1434
-#define ERROR_DESTROY_OBJECT_OF_OTHER_THREAD 1435
-#define ERROR_CHILD_WINDOW_MENU 1436
-#define ERROR_NO_SYSTEM_MENU 1437
-#define ERROR_INVALID_MSGBOX_STYLE 1438
-#define ERROR_INVALID_SPI_VALUE 1439
-#define ERROR_SCREEN_ALREADY_LOCKED 1440
-#define ERROR_HWNDS_HAVE_DIFF_PARENT 1441
-#define ERROR_NOT_CHILD_WINDOW 1442
-#define ERROR_INVALID_GW_COMMAND 1443
-#define ERROR_INVALID_THREAD_ID 1444
-#define ERROR_NON_MDICHILD_WINDOW 1445
-#define ERROR_POPUP_ALREADY_ACTIVE 1446
-#define ERROR_NO_SCROLLBARS 1447
-#define ERROR_INVALID_SCROLLBAR_RANGE 1448
-#define ERROR_INVALID_SHOWWIN_COMMAND 1449
-#define ERROR_NO_SYSTEM_RESOURCES 1450
-#define ERROR_NONPAGED_SYSTEM_RESOURCES 1451
-#define ERROR_PAGED_SYSTEM_RESOURCES 1452
-#define ERROR_WORKING_SET_QUOTA 1453
-#define ERROR_PAGEFILE_QUOTA 1454
-#define ERROR_COMMITMENT_LIMIT 1455
-#define ERROR_MENU_ITEM_NOT_FOUND 1456
-#define ERROR_INVALID_KEYBOARD_HANDLE 1457
-#define ERROR_HOOK_TYPE_NOT_ALLOWED 1458
-#define ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION 1459
-#define ERROR_TIMEOUT 1460
-#define ERROR_INVALID_MONITOR_HANDLE 1461
-#define ERROR_EVENTLOG_FILE_CORRUPT 1500
-#define ERROR_EVENTLOG_CANT_START 1501
-#define ERROR_LOG_FILE_FULL 1502
-#define ERROR_EVENTLOG_FILE_CHANGED 1503
-#define ERROR_INSTALL_SERVICE 1601
-#define ERROR_INSTALL_USEREXIT 1602
-#define ERROR_INSTALL_FAILURE 1603
-#define ERROR_INSTALL_SUSPEND 1604
-#define ERROR_UNKNOWN_PRODUCT 1605
-#define ERROR_UNKNOWN_FEATURE 1606
-#define ERROR_UNKNOWN_COMPONENT 1607
-#define ERROR_UNKNOWN_PROPERTY 1608
-#define ERROR_INVALID_HANDLE_STATE 1609
-#define ERROR_BAD_CONFIGURATION 1610
-#define ERROR_INDEX_ABSENT 1611
-#define ERROR_INSTALL_SOURCE_ABSENT 1612
-#define ERROR_BAD_DATABASE_VERSION 1613
-#define ERROR_PRODUCT_UNINSTALLED 1614
-#define ERROR_BAD_QUERY_SYNTAX 1615
-#define ERROR_INVALID_FIELD 1616
-#define RPC_S_INVALID_STRING_BINDING 1700
-#define RPC_S_WRONG_KIND_OF_BINDING 1701
-#define RPC_S_INVALID_BINDING 1702
-#define RPC_S_PROTSEQ_NOT_SUPPORTED 1703
-#define RPC_S_INVALID_RPC_PROTSEQ 1704
-#define RPC_S_INVALID_STRING_UUID 1705
-#define RPC_S_INVALID_ENDPOINT_FORMAT 1706
-#define RPC_S_INVALID_NET_ADDR 1707
-#define RPC_S_NO_ENDPOINT_FOUND 1708
-#define RPC_S_INVALID_TIMEOUT 1709
-#define RPC_S_OBJECT_NOT_FOUND 1710
-#define RPC_S_ALREADY_REGISTERED 1711
-#define RPC_S_TYPE_ALREADY_REGISTERED 1712
-#define RPC_S_ALREADY_LISTENING 1713
-#define RPC_S_NO_PROTSEQS_REGISTERED 1714
-#define RPC_S_NOT_LISTENING 1715
-#define RPC_S_UNKNOWN_MGR_TYPE 1716
-#define RPC_S_UNKNOWN_IF 1717
-#define RPC_S_NO_BINDINGS 1718
-#define RPC_S_NO_PROTSEQS 1719
-#define RPC_S_CANT_CREATE_ENDPOINT 1720
-#define RPC_S_OUT_OF_RESOURCES 1721
-#define RPC_S_SERVER_UNAVAILABLE 1722
-#define RPC_S_SERVER_TOO_BUSY 1723
-#define RPC_S_INVALID_NETWORK_OPTIONS 1724
-#define RPC_S_NO_CALL_ACTIVE 1725
-#define RPC_S_CALL_FAILED 1726
-#define RPC_S_CALL_FAILED_DNE 1727
-#define RPC_S_PROTOCOL_ERROR 1728
-#define RPC_S_UNSUPPORTED_TRANS_SYN 1730
-#define RPC_S_UNSUPPORTED_TYPE 1732
-#define RPC_S_INVALID_TAG 1733
-#define RPC_S_INVALID_BOUND 1734
-#define RPC_S_NO_ENTRY_NAME 1735
-#define RPC_S_INVALID_NAME_SYNTAX 1736
-#define RPC_S_UNSUPPORTED_NAME_SYNTAX 1737
-#define RPC_S_UUID_NO_ADDRESS 1739
-#define RPC_S_DUPLICATE_ENDPOINT 1740
-#define RPC_S_UNKNOWN_AUTHN_TYPE 1741
-#define RPC_S_MAX_CALLS_TOO_SMALL 1742
-#define RPC_S_STRING_TOO_LONG 1743
-#define RPC_S_PROTSEQ_NOT_FOUND 1744
-#define RPC_S_PROCNUM_OUT_OF_RANGE 1745
-#define RPC_S_BINDING_HAS_NO_AUTH 1746
-#define RPC_S_UNKNOWN_AUTHN_SERVICE 1747
-#define RPC_S_UNKNOWN_AUTHN_LEVEL 1748
-#define RPC_S_INVALID_AUTH_IDENTITY 1749
-#define RPC_S_UNKNOWN_AUTHZ_SERVICE 1750
-#define EPT_S_INVALID_ENTRY 1751
-#define EPT_S_CANT_PERFORM_OP 1752
-#define EPT_S_NOT_REGISTERED 1753
-#define RPC_S_NOTHING_TO_EXPORT 1754
-#define RPC_S_INCOMPLETE_NAME 1755
-#define RPC_S_INVALID_VERS_OPTION 1756
-#define RPC_S_NO_MORE_MEMBERS 1757
-#define RPC_S_NOT_ALL_OBJS_UNEXPORTED 1758
-#define RPC_S_INTERFACE_NOT_FOUND 1759
-#define RPC_S_ENTRY_ALREADY_EXISTS 1760
-#define RPC_S_ENTRY_NOT_FOUND 1761
-#define RPC_S_NAME_SERVICE_UNAVAILABLE 1762
-#define RPC_S_INVALID_NAF_ID 1763
-#define RPC_S_CANNOT_SUPPORT 1764
-#define RPC_S_NO_CONTEXT_AVAILABLE 1765
-#define RPC_S_INTERNAL_ERROR 1766
-#define RPC_S_ZERO_DIVIDE 1767
-#define RPC_S_ADDRESS_ERROR 1768
-#define RPC_S_FP_DIV_ZERO 1769
-#define RPC_S_FP_UNDERFLOW 1770
-#define RPC_S_FP_OVERFLOW 1771
-#define RPC_X_NO_MORE_ENTRIES 1772
-#define RPC_X_SS_CHAR_TRANS_OPEN_FAIL 1773
-#define RPC_X_SS_CHAR_TRANS_SHORT_FILE 1774
-#define RPC_X_SS_IN_NULL_CONTEXT 1775
-#define RPC_X_SS_CONTEXT_DAMAGED 1777
-#define RPC_X_SS_HANDLES_MISMATCH 1778
-#define RPC_X_SS_CANNOT_GET_CALL_HANDLE 1779
-#define RPC_X_NULL_REF_POINTER 1780
-#define RPC_X_ENUM_VALUE_OUT_OF_RANGE 1781
-#define RPC_X_BYTE_COUNT_TOO_SMALL 1782
-#define RPC_X_BAD_STUB_DATA 1783
-#define ERROR_INVALID_USER_BUFFER 1784
-#define ERROR_UNRECOGNIZED_MEDIA 1785
-#define ERROR_NO_TRUST_LSA_SECRET 1786
-#define ERROR_NO_TRUST_SAM_ACCOUNT 1787
-#define ERROR_TRUSTED_DOMAIN_FAILURE 1788
-#define ERROR_TRUSTED_RELATIONSHIP_FAILURE 1789
-#define ERROR_TRUST_FAILURE 1790
-#define RPC_S_CALL_IN_PROGRESS 1791
-#define ERROR_NETLOGON_NOT_STARTED 1792
-#define ERROR_ACCOUNT_EXPIRED 1793
-#define ERROR_REDIRECTOR_HAS_OPEN_HANDLES 1794
-#define ERROR_PRINTER_DRIVER_ALREADY_INSTALLED 1795
-#define ERROR_UNKNOWN_PORT 1796
-#define ERROR_UNKNOWN_PRINTER_DRIVER 1797
-#define ERROR_UNKNOWN_PRINTPROCESSOR 1798
-#define ERROR_INVALID_SEPARATOR_FILE 1799
-#define ERROR_INVALID_PRIORITY 1800
-#define ERROR_INVALID_PRINTER_NAME 1801
-#define ERROR_PRINTER_ALREADY_EXISTS 1802
-#define ERROR_INVALID_PRINTER_COMMAND 1803
-#define ERROR_INVALID_DATATYPE 1804
-#define ERROR_INVALID_ENVIRONMENT 1805
-#define RPC_S_NO_MORE_BINDINGS 1806
-#define ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 1807
-#define ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT 1808
-#define ERROR_NOLOGON_SERVER_TRUST_ACCOUNT 1809
-#define ERROR_DOMAIN_TRUST_INCONSISTENT 1810
-#define ERROR_SERVER_HAS_OPEN_HANDLES 1811
-#define ERROR_RESOURCE_DATA_NOT_FOUND 1812
-#define ERROR_RESOURCE_TYPE_NOT_FOUND 1813
-#define ERROR_RESOURCE_NAME_NOT_FOUND 1814
-#define ERROR_RESOURCE_LANG_NOT_FOUND 1815
-#define ERROR_NOT_ENOUGH_QUOTA 1816
-#define RPC_S_NO_INTERFACES 1817
-#define RPC_S_CALL_CANCELLED 1818
-#define RPC_S_BINDING_INCOMPLETE 1819
-#define RPC_S_COMM_FAILURE 1820
-#define RPC_S_UNSUPPORTED_AUTHN_LEVEL 1821
-#define RPC_S_NO_PRINC_NAME 1822
-#define RPC_S_NOT_RPC_ERROR 1823
-#define RPC_S_UUID_LOCAL_ONLY 1824
-#define RPC_S_SEC_PKG_ERROR 1825
-#define RPC_S_NOT_CANCELLED 1826
-#define RPC_X_INVALID_ES_ACTION 1827
-#define RPC_X_WRONG_ES_VERSION 1828
-#define RPC_X_WRONG_STUB_VERSION 1829
-#define RPC_X_INVALID_PIPE_OBJECT 1830
-#define RPC_X_WRONG_PIPE_ORDER 1831
-#define RPC_X_WRONG_PIPE_VERSION 1832
-#define RPC_S_GROUP_MEMBER_NOT_FOUND 1898
-#define EPT_S_CANT_CREATE 1899
-#define RPC_S_INVALID_OBJECT 1900
-#define ERROR_INVALID_TIME 1901
-#define ERROR_INVALID_FORM_NAME 1902
-#define ERROR_INVALID_FORM_SIZE 1903
-#define ERROR_ALREADY_WAITING 1904
-#define ERROR_PRINTER_DELETED 1905
-#define ERROR_INVALID_PRINTER_STATE 1906
-#define ERROR_PASSWORD_MUST_CHANGE 1907
-#define ERROR_DOMAIN_CONTROLLER_NOT_FOUND 1908
-#define ERROR_ACCOUNT_LOCKED_OUT 1909
-#define OR_INVALID_OXID 1910
-#define OR_INVALID_OID 1911
-#define OR_INVALID_SET 1912
-#define RPC_S_SEND_INCOMPLETE 1913
-#define RPC_S_INVALID_ASYNC_HANDLE 1914
-#define RPC_S_INVALID_ASYNC_CALL 1915
-#define RPC_X_PIPE_CLOSED 1916
-#define RPC_X_PIPE_DISCIPLINE_ERROR 1917
-#define RPC_X_PIPE_EMPTY 1918
-#define ERROR_NO_SITENAME 1919
-#define ERROR_CANT_ACCESS_FILE 1920
-#define ERROR_CANT_RESOLVE_FILENAME 1921
-#define ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY 1922
-#define ERROR_DS_NO_ATTRIBUTE_OR_VALUE 1923
-#define ERROR_DS_INVALID_ATTRIBUTE_SYNTAX 1924
-#define ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED 1925
-#define ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS 1926
-#define ERROR_DS_BUSY 1927
-#define ERROR_DS_UNAVAILABLE 1928
-#define ERROR_DS_NO_RIDS_ALLOCATED 1929
-#define ERROR_DS_NO_MORE_RIDS 1930
-#define ERROR_DS_INCORRECT_ROLE_OWNER 1931
-#define ERROR_DS_RIDMGR_INIT_ERROR 1932
-#define ERROR_DS_OBJ_CLASS_VIOLATION 1933
-#define ERROR_DS_CANT_ON_NON_LEAF 1934
-#define ERROR_DS_CANT_ON_RDN 1935
-#define ERROR_DS_CANT_MOD_OBJ_CLASS 1936
-#define ERROR_DS_CROSS_DOM_MOVE_ERROR 1937
-#define ERROR_DS_GC_NOT_AVAILABLE 1938
-#define ERROR_NO_BROWSER_SERVERS_FOUND 6118
-#define ERROR_INVALID_PIXEL_FORMAT 2000
-#define ERROR_BAD_DRIVER 2001
-#define ERROR_INVALID_WINDOW_STYLE 2002
-#define ERROR_METAFILE_NOT_SUPPORTED 2003
-#define ERROR_TRANSFORM_NOT_SUPPORTED 2004
-#define ERROR_CLIPPING_NOT_SUPPORTED 2005
-#define ERROR_INVALID_CMM 2300
-#define ERROR_INVALID_PROFILE 2301
-#define ERROR_TAG_NOT_FOUND 2302
-#define ERROR_TAG_NOT_PRESENT 2303
-#define ERROR_DUPLICATE_TAG 2304
-#define ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE 2305
-#define ERROR_PROFILE_NOT_FOUND 2306
-#define ERROR_INVALID_COLORSPACE 2307
-#define ERROR_ICM_NOT_ENABLED 2308
-#define ERROR_DELETING_ICM_XFORM 2309
-#define ERROR_INVALID_TRANSFORM 2310
-#define ERROR_UNKNOWN_PRINT_MONITOR 3000
-#define ERROR_PRINTER_DRIVER_IN_USE 3001
-#define ERROR_SPOOL_FILE_NOT_FOUND 3002
-#define ERROR_SPL_NO_STARTDOC 3003
-#define ERROR_SPL_NO_ADDJOB 3004
-#define ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED 3005
-#define ERROR_PRINT_MONITOR_ALREADY_INSTALLED 3006
-#define ERROR_INVALID_PRINT_MONITOR 3007
-#define ERROR_PRINT_MONITOR_IN_USE 3008
-#define ERROR_PRINTER_HAS_JOBS_QUEUED 3009
-#define ERROR_SUCCESS_REBOOT_REQUIRED 3010
-#define ERROR_SUCCESS_RESTART_REQUIRED 3011
-#define ERROR_WINS_INTERNAL 4000
-#define ERROR_CAN_NOT_DEL_LOCAL_WINS 4001
-#define ERROR_STATIC_INIT 4002
-#define ERROR_INC_BACKUP 4003
-#define ERROR_FULL_BACKUP 4004
-#define ERROR_REC_NON_EXISTENT 4005
-#define ERROR_RPL_NOT_ALLOWED 4006
-#define ERROR_DHCP_ADDRESS_CONFLICT 4100
-#define ERROR_WMI_GUID_NOT_FOUND 4200
-#define ERROR_WMI_INSTANCE_NOT_FOUND 4201
-#define ERROR_WMI_ITEMID_NOT_FOUND 4202
-#define ERROR_WMI_TRY_AGAIN 4203
-#define ERROR_WMI_DP_NOT_FOUND 4204
-#define ERROR_WMI_UNRESOLVED_INSTANCE_REF 4205
-#define ERROR_WMI_ALREADY_ENABLED 4206
-#define ERROR_WMI_GUID_DISCONNECTED 4207
-#define ERROR_WMI_SERVER_UNAVAILABLE 4208
-#define ERROR_WMI_DP_FAILED 4209
-#define ERROR_WMI_INVALID_MOF 4210
-#define ERROR_WMI_INVALID_REGINFO 4211
-#define ERROR_INVALID_MEDIA 4300
-#define ERROR_INVALID_LIBRARY 4301
-#define ERROR_INVALID_MEDIA_POOL 4302
-#define ERROR_DRIVE_MEDIA_MISMATCH 4303
-#define ERROR_MEDIA_OFFLINE 4304
-#define ERROR_LIBRARY_OFFLINE 4305
-#define ERROR_EMPTY 4306
-#define ERROR_NOT_EMPTY 4307
-#define ERROR_MEDIA_UNAVAILABLE 4308
-#define ERROR_RESOURCE_DISABLED 4309
-#define ERROR_INVALID_CLEANER 4310
-#define ERROR_UNABLE_TO_CLEAN 4311
-#define ERROR_OBJECT_NOT_FOUND 4312
-#define ERROR_DATABASE_FAILURE 4313
-#define ERROR_DATABASE_FULL 4314
-#define ERROR_MEDIA_INCOMPATIBLE 4315
-#define ERROR_RESOURCE_NOT_PRESENT 4316
-#define ERROR_INVALID_OPERATION 4317
-#define ERROR_MEDIA_NOT_AVAILABLE 4318
-#define ERROR_DEVICE_NOT_AVAILABLE 4319
-#define ERROR_REQUEST_REFUSED 4320
-#define ERROR_FILE_OFFLINE 4350
-#define ERROR_REMOTE_STORAGE_NOT_ACTIVE 4351
-#define ERROR_REMOTE_STORAGE_MEDIA_ERROR 4352
-#define ERROR_NOT_A_REPARSE_POINT 4390
-#define ERROR_REPARSE_ATTRIBUTE_CONFLICT 4391
-#define ERROR_DEPENDENT_RESOURCE_EXISTS 5001
-#define ERROR_DEPENDENCY_NOT_FOUND 5002
-#define ERROR_DEPENDENCY_ALREADY_EXISTS 5003
-#define ERROR_RESOURCE_NOT_ONLINE 5004
-#define ERROR_HOST_NODE_NOT_AVAILABLE 5005
-#define ERROR_RESOURCE_NOT_AVAILABLE 5006
-#define ERROR_RESOURCE_NOT_FOUND 5007
-#define ERROR_SHUTDOWN_CLUSTER 5008
-#define ERROR_CANT_EVICT_ACTIVE_NODE 5009
-#define ERROR_OBJECT_ALREADY_EXISTS 5010
-#define ERROR_OBJECT_IN_LIST 5011
-#define ERROR_GROUP_NOT_AVAILABLE 5012
-#define ERROR_GROUP_NOT_FOUND 5013
-#define ERROR_GROUP_NOT_ONLINE 5014
-#define ERROR_HOST_NODE_NOT_RESOURCE_OWNER 5015
-#define ERROR_HOST_NODE_NOT_GROUP_OWNER 5016
-#define ERROR_RESMON_CREATE_FAILED 5017
-#define ERROR_RESMON_ONLINE_FAILED 5018
-#define ERROR_RESOURCE_ONLINE 5019
-#define ERROR_QUORUM_RESOURCE 5020
-#define ERROR_NOT_QUORUM_CAPABLE 5021
-#define ERROR_CLUSTER_SHUTTING_DOWN 5022
-#define ERROR_INVALID_STATE 5023
-#define ERROR_RESOURCE_PROPERTIES_STORED 5024
-#define ERROR_NOT_QUORUM_CLASS 5025
-#define ERROR_CORE_RESOURCE 5026
-#define ERROR_QUORUM_RESOURCE_ONLINE_FAILED 5027
-#define ERROR_QUORUMLOG_OPEN_FAILED 5028
-#define ERROR_CLUSTERLOG_CORRUPT 5029
-#define ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE 5030
-#define ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE 5031
-#define ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND 5032
-#define ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE 5033
-#define ERROR_ENCRYPTION_FAILED 6000
-#define ERROR_DECRYPTION_FAILED 6001
-#define ERROR_FILE_ENCRYPTED 6002
-#define ERROR_NO_RECOVERY_POLICY 6003
-#define ERROR_NO_EFS 6004
-#define ERROR_WRONG_EFS 6005
-#define ERROR_NO_USER_KEYS 6006
-#define ERROR_FILE_NOT_ENCRYPTED 6007
-#define ERROR_NOT_EXPORT_FORMAT 6008
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _SMBSRV_NTERROR_H */
diff --git a/usr/src/uts/common/smbsrv/ntstatus.h b/usr/src/uts/common/smbsrv/ntstatus.h
deleted file mode 100644
index f58e3c13ba..0000000000
--- a/usr/src/uts/common/smbsrv/ntstatus.h
+++ /dev/null
@@ -1,707 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SMBSRV_NTSTATUS_H
-#define _SMBSRV_NTSTATUS_H
-
-/*
- * This file defines the list of NT status codes.
- *
- * Be careful not to confuse status codes with error
- * codes. The error codes are listed in nterror.h.
- */
-
-#include <smbsrv/wintypes.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*
- * Status codes are 32-bit values in which the top 2 bits represent
- * the severity and the lower 16-bits contain a Win32 status code.
- * The severity levels are:
- *
- * 00 success
- * 01 information
- * 10 warning
- * 11 error
- *
- * NT also defines an application mask, which is included here
- * for completeness.
- */
-#define APPLICATION_ERROR_MASK 0x20000000
-#define ERROR_SEVERITY_SUCCESS 0x00000000
-#define ERROR_SEVERITY_INFORMATIONAL 0x40000000
-#define ERROR_SEVERITY_WARNING 0x80000000
-#define ERROR_SEVERITY_ERROR 0xC0000000
-
-/*
- * Severity code helper macros.
- */
-#define NT_SC_SUCCESS(STATUS) (ERROR_SEVERITY_SUCCESS+(STATUS))
-#define NT_SC_INFO(STATUS) (ERROR_SEVERITY_INFORMATIONAL+(STATUS))
-#define NT_SC_WARNING(STATUS) (ERROR_SEVERITY_WARNING+(STATUS))
-#define NT_SC_ERROR(STATUS) (ERROR_SEVERITY_ERROR+(STATUS))
-
-#define NT_SC_IS_SUCCESS(S) (((S) & 0xC0000000) == ERROR_SEVERITY_SUCCESS)
-#define NT_SC_IS_INFO(S) (((S) & 0xC0000000) == ERROR_SEVERITY_INFORMATIONAL)
-#define NT_SC_IS_WARNING(S) (((S) & 0xC0000000) == ERROR_SEVERITY_WARNING)
-#define NT_SC_IS_ERROR(S) (((S) & 0xC0000000) == ERROR_SEVERITY_ERROR)
-
-#define NT_SC_VALUE(S) ((S) & 0x0FFFFFFF)
-
-/*
- * Win32 status codes
- */
-#define NT_STATUS_SUCCESS 0
-#define NT_STATUS_UNSUCCESSFUL 1
-#define NT_STATUS_NOT_IMPLEMENTED 2
-#define NT_STATUS_INVALID_INFO_CLASS 3
-#define NT_STATUS_INFO_LENGTH_MISMATCH 4
-#define NT_STATUS_BUFFER_OVERFLOW 5
-#define NT_STATUS_NO_MORE_FILES 6
-#define NT_STATUS_IN_PAGE_ERROR NT_STATUS_NO_MORE_FILES
-#define NT_STATUS_PAGEFILE_QUOTA 7
-#define NT_STATUS_INVALID_HANDLE 8
-#define NT_STATUS_BAD_INITIAL_STACK 9
-#define NT_STATUS_BAD_INITIAL_PC 10
-#define NT_STATUS_INVALID_CID 11
-#define NT_STATUS_TIMER_NOT_CANCELED 12
-#define NT_STATUS_INVALID_PARAMETER 13
-#define NT_STATUS_NO_SUCH_DEVICE 14
-#define NT_STATUS_NO_SUCH_FILE 15
-#define NT_STATUS_INVALID_DEVICE_REQUEST 16
-#define NT_STATUS_END_OF_FILE 17
-#define NT_STATUS_WRONG_VOLUME 18
-#define NT_STATUS_NO_MEDIA_IN_DEVICE 19
-#define NT_STATUS_UNRECOGNIZED_MEDIA 20
-#define NT_STATUS_NONEXISTENT_SECTOR 21
-#define NT_STATUS_MORE_PROCESSING_REQUIRED 22
-#define NT_STATUS_NO_MEMORY 23
-#define NT_STATUS_CONFLICTING_ADDRESSES 24
-#define NT_STATUS_NOT_MAPPED_VIEW 25
-#define NT_STATUS_UNABLE_TO_FREE_VM 26
-#define NT_STATUS_NO_MORE_DATA NT_STATUS_UNABLE_TO_FREE_VM
-#define NT_STATUS_UNABLE_TO_DELETE_SECTION 27
-#define NT_STATUS_INVALID_SYSTEM_SERVICE 28
-#define NT_STATUS_ILLEGAL_INSTRUCTION 29
-#define NT_STATUS_INVALID_LOCK_SEQUENCE 30
-#define NT_STATUS_INVALID_VIEW_SIZE 31
-#define NT_STATUS_INVALID_FILE_FOR_SECTION 32
-#define NT_STATUS_ALREADY_COMMITTED 33
-#define NT_STATUS_ACCESS_DENIED 34
-#define NT_STATUS_BUFFER_TOO_SMALL 35
-#define NT_STATUS_OBJECT_TYPE_MISMATCH 36
-#define NT_STATUS_NONCONTINUABLE_EXCEPTION 37
-#define NT_STATUS_INVALID_DISPOSITION 38
-#define NT_STATUS_UNWIND 39
-#define NT_STATUS_BAD_STACK 40
-#define NT_STATUS_INVALID_UNWIND_TARGET 41
-#define NT_STATUS_NOT_LOCKED 42
-#define NT_STATUS_PARITY_ERROR 43
-#define NT_STATUS_UNABLE_TO_DECOMMIT_VM 44
-#define NT_STATUS_NOT_COMMITTED 45
-#define NT_STATUS_INVALID_PORT_ATTRIBUTES 46
-#define NT_STATUS_PORT_MESSAGE_TOO_LONG 47
-#define NT_STATUS_INVALID_PARAMETER_MIX 48
-#define NT_STATUS_INVALID_QUOTA_LOWER 49
-#define NT_STATUS_DISK_CORRUPT_ERROR 50
-#define NT_STATUS_OBJECT_NAME_INVALID 51
-#define NT_STATUS_OBJECT_NAME_NOT_FOUND 52
-#define NT_STATUS_OBJECT_NAME_COLLISION 53
-#define NT_STATUS_HANDLE_NOT_WAITABLE 54
-#define NT_STATUS_PORT_DISCONNECTED 55
-#define NT_STATUS_DEVICE_ALREADY_ATTACHED 56
-#define NT_STATUS_OBJECT_PATH_INVALID 57
-#define NT_STATUS_OBJECT_PATH_NOT_FOUND 58
-#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD 59
-#define NT_STATUS_DATA_OVERRUN 60
-#define NT_STATUS_DATA_LATE_ERROR 61
-#define NT_STATUS_DATA_ERROR 62
-#define NT_STATUS_CRC_ERROR 63
-#define NT_STATUS_SECTION_TOO_BIG 64
-#define NT_STATUS_PORT_CONNECTION_REFUSED 65
-#define NT_STATUS_INVALID_PORT_HANDLE 66
-#define NT_STATUS_SHARING_VIOLATION 67
-#define NT_STATUS_QUOTA_EXCEEDED 68
-#define NT_STATUS_INVALID_PAGE_PROTECTION 69
-#define NT_STATUS_MUTANT_NOT_OWNED 70
-#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED 71
-#define NT_STATUS_PORT_ALREADY_SET 72
-#define NT_STATUS_SECTION_NOT_IMAGE 73
-#define NT_STATUS_SUSPEND_COUNT_EXCEEDED 74
-#define NT_STATUS_THREAD_IS_TERMINATING 75
-#define NT_STATUS_BAD_WORKING_SET_LIMIT 76
-#define NT_STATUS_INCOMPATIBLE_FILE_MAP 77
-#define NT_STATUS_SECTION_PROTECTION 78
-#define NT_STATUS_EAS_NOT_SUPPORTED 79
-#define NT_STATUS_EA_TOO_LARGE 80
-#define NT_STATUS_NONEXISTENT_EA_ENTRY 81
-#define NT_STATUS_NO_EAS_ON_FILE 82
-#define NT_STATUS_EA_CORRUPT_ERROR 83
-#define NT_STATUS_FILE_LOCK_CONFLICT 84
-#define NT_STATUS_LOCK_NOT_GRANTED 85
-#define NT_STATUS_DELETE_PENDING 86
-#define NT_STATUS_CTL_FILE_NOT_SUPPORTED 87
-#define NT_STATUS_UNKNOWN_REVISION 88
-#define NT_STATUS_REVISION_MISMATCH 89
-#define NT_STATUS_INVALID_OWNER 90
-#define NT_STATUS_INVALID_PRIMARY_GROUP 91
-#define NT_STATUS_NO_IMPERSONATION_TOKEN 92
-#define NT_STATUS_CANT_DISABLE_MANDATORY 93
-#define NT_STATUS_NO_LOGON_SERVERS 94
-#define NT_STATUS_NO_SUCH_LOGON_SESSION 95
-#define NT_STATUS_NO_SUCH_PRIVILEGE 96
-#define NT_STATUS_PRIVILEGE_NOT_HELD 97
-#define NT_STATUS_INVALID_ACCOUNT_NAME 98
-#define NT_STATUS_USER_EXISTS 99
-#define NT_STATUS_NO_SUCH_USER 100
-#define NT_STATUS_GROUP_EXISTS 101
-#define NT_STATUS_NO_SUCH_GROUP 102
-#define NT_STATUS_MEMBER_IN_GROUP 103
-#define NT_STATUS_MEMBER_NOT_IN_GROUP 104
-#define NT_STATUS_LAST_ADMIN 105
-#define NT_STATUS_WRONG_PASSWORD 106
-#define NT_STATUS_ILL_FORMED_PASSWORD 107
-#define NT_STATUS_PASSWORD_RESTRICTION 108
-#define NT_STATUS_LOGON_FAILURE 109
-#define NT_STATUS_ACCOUNT_RESTRICTION 110
-#define NT_STATUS_INVALID_LOGON_HOURS 111
-#define NT_STATUS_INVALID_WORKSTATION 112
-#define NT_STATUS_PASSWORD_EXPIRED 113
-#define NT_STATUS_ACCOUNT_DISABLED 114
-#define NT_STATUS_NONE_MAPPED 115
-#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED 116
-#define NT_STATUS_LUIDS_EXHAUSTED 117
-#define NT_STATUS_INVALID_SUB_AUTHORITY 118
-#define NT_STATUS_INVALID_ACL 119
-#define NT_STATUS_INVALID_SID 120
-#define NT_STATUS_INVALID_SECURITY_DESCR 121
-#define NT_STATUS_PROCEDURE_NOT_FOUND 122
-#define NT_STATUS_INVALID_IMAGE_FORMAT 123
-#define NT_STATUS_NO_TOKEN 124
-#define NT_STATUS_BAD_INHERITANCE_ACL 125
-#define NT_STATUS_RANGE_NOT_LOCKED 126
-#define NT_STATUS_DISK_FULL 127
-#define NT_STATUS_SERVER_DISABLED 128
-#define NT_STATUS_SERVER_NOT_DISABLED 129
-#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED 130
-#define NT_STATUS_GUIDS_EXHAUSTED 131
-#define NT_STATUS_INVALID_ID_AUTHORITY 132
-#define NT_STATUS_AGENTS_EXHAUSTED 133
-#define NT_STATUS_INVALID_VOLUME_LABEL 134
-#define NT_STATUS_SECTION_NOT_EXTENDED 135
-#define NT_STATUS_NOT_MAPPED_DATA 136
-#define NT_STATUS_RESOURCE_DATA_NOT_FOUND 137
-#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND 138
-#define NT_STATUS_RESOURCE_NAME_NOT_FOUND 139
-#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED 140
-#define NT_STATUS_FLOAT_DENORMAL_OPERAND 141
-#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO 142
-#define NT_STATUS_FLOAT_INEXACT_RESULT 143
-#define NT_STATUS_FLOAT_INVALID_OPERATION 144
-#define NT_STATUS_FLOAT_OVERFLOW 145
-#define NT_STATUS_FLOAT_STACK_CHECK 146
-#define NT_STATUS_FLOAT_UNDERFLOW 147
-#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO 148
-#define NT_STATUS_INTEGER_OVERFLOW 149
-#define NT_STATUS_PRIVILEGED_INSTRUCTION 150
-#define NT_STATUS_TOO_MANY_PAGING_FILES 151
-#define NT_STATUS_FILE_INVALID 152
-#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED 153
-#define NT_STATUS_INSUFFICIENT_RESOURCES 154
-#define NT_STATUS_DFS_EXIT_PATH_FOUND 155
-#define NT_STATUS_DEVICE_DATA_ERROR 156
-#define NT_STATUS_DEVICE_NOT_CONNECTED 157
-#define NT_STATUS_DEVICE_POWER_FAILURE 158
-#define NT_STATUS_FREE_VM_NOT_AT_BASE 159
-#define NT_STATUS_MEMORY_NOT_ALLOCATED 160
-#define NT_STATUS_WORKING_SET_QUOTA 161
-#define NT_STATUS_MEDIA_WRITE_PROTECTED 162
-#define NT_STATUS_DEVICE_NOT_READY 163
-#define NT_STATUS_INVALID_GROUP_ATTRIBUTES 164
-#define NT_STATUS_BAD_IMPERSONATION_LEVEL 165
-#define NT_STATUS_CANT_OPEN_ANONYMOUS 166
-#define NT_STATUS_BAD_VALIDATION_CLASS 167
-#define NT_STATUS_BAD_TOKEN_TYPE 168
-#define NT_STATUS_BAD_MASTER_BOOT_RECORD 169
-#define NT_STATUS_INSTRUCTION_MISALIGNMENT 170
-#define NT_STATUS_INSTANCE_NOT_AVAILABLE 171
-#define NT_STATUS_PIPE_NOT_AVAILABLE 172
-#define NT_STATUS_INVALID_PIPE_STATE 173
-#define NT_STATUS_PIPE_BUSY 174
-#define NT_STATUS_ILLEGAL_FUNCTION 175
-#define NT_STATUS_PIPE_DISCONNECTED 176
-#define NT_STATUS_PIPE_CLOSING 177
-#define NT_STATUS_PIPE_CONNECTED 178
-#define NT_STATUS_PIPE_LISTENING 179
-#define NT_STATUS_INVALID_READ_MODE 180
-#define NT_STATUS_IO_TIMEOUT 181
-#define NT_STATUS_FILE_FORCED_CLOSED 182
-#define NT_STATUS_PROFILING_NOT_STARTED 183
-#define NT_STATUS_PROFILING_NOT_STOPPED 184
-#define NT_STATUS_COULD_NOT_INTERPRET 185
-#define NT_STATUS_FILE_IS_A_DIRECTORY 186
-#define NT_STATUS_NOT_SUPPORTED 187
-#define NT_STATUS_REMOTE_NOT_LISTENING 188
-#define NT_STATUS_DUPLICATE_NAME 189
-#define NT_STATUS_BAD_NETWORK_PATH 190
-#define NT_STATUS_NETWORK_BUSY 191
-#define NT_STATUS_DEVICE_DOES_NOT_EXIST 192
-#define NT_STATUS_TOO_MANY_COMMANDS 193
-#define NT_STATUS_ADAPTER_HARDWARE_ERROR 194
-#define NT_STATUS_INVALID_NETWORK_RESPONSE 195
-#define NT_STATUS_UNEXPECTED_NETWORK_ERROR 196
-#define NT_STATUS_BAD_REMOTE_ADAPTER 197
-#define NT_STATUS_PRINT_QUEUE_FULL 198
-#define NT_STATUS_NO_SPOOL_SPACE 199
-#define NT_STATUS_PRINT_CANCELLED 200
-#define NT_STATUS_NETWORK_NAME_DELETED 201
-#define NT_STATUS_NETWORK_ACCESS_DENIED 202
-#define NT_STATUS_BAD_DEVICE_TYPE 203
-#define NT_STATUS_BAD_NETWORK_NAME 204
-#define NT_STATUS_TOO_MANY_NAMES 205
-#define NT_STATUS_TOO_MANY_SESSIONS 206
-#define NT_STATUS_SHARING_PAUSED 207
-#define NT_STATUS_REQUEST_NOT_ACCEPTED 208
-#define NT_STATUS_REDIRECTOR_PAUSED 209
-#define NT_STATUS_NET_WRITE_FAULT 210
-#define NT_STATUS_PROFILING_AT_LIMIT 211
-#define NT_STATUS_NOT_SAME_DEVICE 212
-#define NT_STATUS_FILE_RENAMED 213
-#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED 214
-#define NT_STATUS_NO_SECURITY_ON_OBJECT 215
-#define NT_STATUS_CANT_WAIT 216
-#define NT_STATUS_PIPE_EMPTY 217
-#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO 218
-#define NT_STATUS_CANT_TERMINATE_SELF 219
-#define NT_STATUS_INVALID_SERVER_STATE 220
-#define NT_STATUS_INVALID_DOMAIN_STATE 221
-#define NT_STATUS_INVALID_DOMAIN_ROLE 222
-#define NT_STATUS_NO_SUCH_DOMAIN 223
-#define NT_STATUS_DOMAIN_EXISTS 224
-#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED 225
-#define NT_STATUS_OPLOCK_NOT_GRANTED 226
-#define NT_STATUS_INVALID_OPLOCK_PROTOCOL 227
-#define NT_STATUS_INTERNAL_DB_CORRUPTION 228
-#define NT_STATUS_INTERNAL_ERROR 229
-#define NT_STATUS_GENERIC_NOT_MAPPED 230
-#define NT_STATUS_BAD_DESCRIPTOR_FORMAT 231
-#define NT_STATUS_INVALID_USER_BUFFER 232
-#define NT_STATUS_UNEXPECTED_IO_ERROR 233
-#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR 234
-#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR 235
-#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR 236
-#define NT_STATUS_NOT_LOGON_PROCESS 237
-#define NT_STATUS_LOGON_SESSION_EXISTS 238
-#define NT_STATUS_INVALID_PARAMETER_1 239
-#define NT_STATUS_INVALID_PARAMETER_2 240
-#define NT_STATUS_INVALID_PARAMETER_3 241
-#define NT_STATUS_INVALID_PARAMETER_4 242
-#define NT_STATUS_INVALID_PARAMETER_5 243
-#define NT_STATUS_INVALID_PARAMETER_6 244
-#define NT_STATUS_INVALID_PARAMETER_7 245
-#define NT_STATUS_INVALID_PARAMETER_8 246
-#define NT_STATUS_INVALID_PARAMETER_9 247
-#define NT_STATUS_INVALID_PARAMETER_10 248
-#define NT_STATUS_INVALID_PARAMETER_11 249
-#define NT_STATUS_INVALID_PARAMETER_12 250
-#define NT_STATUS_REDIRECTOR_NOT_STARTED 251
-#define NT_STATUS_REDIRECTOR_STARTED 252
-#define NT_STATUS_STACK_OVERFLOW 253
-#define NT_STATUS_NO_SUCH_PACKAGE 254
-#define NT_STATUS_BAD_FUNCTION_TABLE 255
-#define NT_STATUS_DIRECTORY_NOT_EMPTY 257
-#define NT_STATUS_FILE_CORRUPT_ERROR 258
-#define NT_STATUS_NOT_A_DIRECTORY 259
-#define NT_STATUS_BAD_LOGON_SESSION_STATE 260
-#define NT_STATUS_LOGON_SESSION_COLLISION 261
-#define NT_STATUS_NAME_TOO_LONG 262
-#define NT_STATUS_FILES_OPEN 263
-#define NT_STATUS_SOME_NOT_MAPPED NT_STATUS_FILES_OPEN
-#define NT_STATUS_CONNECTION_IN_USE 264
-#define NT_STATUS_MESSAGE_NOT_FOUND 265
-#define NT_STATUS_PROCESS_IS_TERMINATING 266
-#define NT_STATUS_INVALID_LOGON_TYPE 267
-#define NT_STATUS_NO_GUID_TRANSLATION 268
-#define NT_STATUS_CANNOT_IMPERSONATE 269
-#define NT_STATUS_IMAGE_ALREADY_LOADED 270
-#define NT_STATUS_ABIOS_NOT_PRESENT 271
-#define NT_STATUS_ABIOS_LID_NOT_EXIST 272
-#define NT_STATUS_ABIOS_LID_ALREADY_OWNED 273
-#define NT_STATUS_ABIOS_NOT_LID_OWNER 274
-#define NT_STATUS_ABIOS_INVALID_COMMAND 275
-#define NT_STATUS_ABIOS_INVALID_LID 276
-#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE 277
-#define NT_STATUS_ABIOS_INVALID_SELECTOR 278
-#define NT_STATUS_NO_LDT 279
-#define NT_STATUS_INVALID_LDT_SIZE 280
-#define NT_STATUS_INVALID_LDT_OFFSET 281
-#define NT_STATUS_INVALID_LDT_DESCRIPTOR 282
-#define NT_STATUS_INVALID_IMAGE_NE_FORMAT 283
-#define NT_STATUS_RXACT_INVALID_STATE 284
-#define NT_STATUS_RXACT_COMMIT_FAILURE 285
-#define NT_STATUS_MAPPED_FILE_SIZE_ZERO 286
-#define NT_STATUS_TOO_MANY_OPENED_FILES 287
-#define NT_STATUS_CANCELLED 288
-#define NT_STATUS_CANNOT_DELETE 289
-#define NT_STATUS_INVALID_COMPUTER_NAME 290
-#define NT_STATUS_FILE_DELETED 291
-#define NT_STATUS_SPECIAL_ACCOUNT 292
-#define NT_STATUS_SPECIAL_GROUP 293
-#define NT_STATUS_SPECIAL_USER 294
-#define NT_STATUS_MEMBERS_PRIMARY_GROUP 295
-#define NT_STATUS_FILE_CLOSED 296
-#define NT_STATUS_TOO_MANY_THREADS 297
-#define NT_STATUS_THREAD_NOT_IN_PROCESS 298
-#define NT_STATUS_TOKEN_ALREADY_IN_USE 299
-#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED 300
-#define NT_STATUS_COMMITMENT_LIMIT 301
-#define NT_STATUS_INVALID_IMAGE_LE_FORMAT 302
-#define NT_STATUS_INVALID_IMAGE_NOT_MZ 303
-#define NT_STATUS_INVALID_IMAGE_PROTECT 304
-#define NT_STATUS_INVALID_IMAGE_WIN_16 305
-#define NT_STATUS_LOGON_SERVER_CONFLICT 306
-#define NT_STATUS_TIME_DIFFERENCE_AT_DC 307
-#define NT_STATUS_SYNCHRONIZATION_REQUIRED 308
-#define NT_STATUS_DLL_NOT_FOUND 309
-#define NT_STATUS_OPEN_FAILED 310
-#define NT_STATUS_IO_PRIVILEGE_FAILED 311
-#define NT_STATUS_ORDINAL_NOT_FOUND 312
-#define NT_STATUS_ENTRYPOINT_NOT_FOUND 313
-#define NT_STATUS_CONTROL_C_EXIT 314
-#define NT_STATUS_LOCAL_DISCONNECT 315
-#define NT_STATUS_REMOTE_DISCONNECT 316
-#define NT_STATUS_REMOTE_RESOURCES 317
-#define NT_STATUS_LINK_FAILED 318
-#define NT_STATUS_LINK_TIMEOUT 319
-#define NT_STATUS_INVALID_CONNECTION 320
-#define NT_STATUS_INVALID_ADDRESS 321
-#define NT_STATUS_DLL_INIT_FAILED 322
-#define NT_STATUS_MISSING_SYSTEMFILE 323
-#define NT_STATUS_UNHANDLED_EXCEPTION 324
-#define NT_STATUS_APP_INIT_FAILURE 325
-#define NT_STATUS_PAGEFILE_CREATE_FAILED 326
-#define NT_STATUS_NO_PAGEFILE 327
-#define NT_STATUS_INVALID_LEVEL 328
-#define NT_STATUS_WRONG_PASSWORD_CORE 329
-#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT 330
-#define NT_STATUS_PIPE_BROKEN 331
-#define NT_STATUS_REGISTRY_CORRUPT 332
-#define NT_STATUS_REGISTRY_IO_FAILED 333
-#define NT_STATUS_NO_EVENT_PAIR 334
-#define NT_STATUS_UNRECOGNIZED_VOLUME 335
-#define NT_STATUS_SERIAL_NO_DEVICE_INITED 336
-#define NT_STATUS_NO_SUCH_ALIAS 337
-#define NT_STATUS_MEMBER_NOT_IN_ALIAS 338
-#define NT_STATUS_MEMBER_IN_ALIAS 339
-#define NT_STATUS_ALIAS_EXISTS 340
-#define NT_STATUS_LOGON_NOT_GRANTED 341
-#define NT_STATUS_TOO_MANY_SECRETS 342
-#define NT_STATUS_SECRET_TOO_LONG 343
-#define NT_STATUS_INTERNAL_DB_ERROR 344
-#define NT_STATUS_FULLSCREEN_MODE 345
-#define NT_STATUS_TOO_MANY_CONTEXT_IDS 346
-#define NT_STATUS_LOGON_TYPE_NOT_GRANTED 347
-#define NT_STATUS_NOT_REGISTRY_FILE 348
-#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED 349
-#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR 350
-#define NT_STATUS_FT_MISSING_MEMBER 351
-#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY 352
-#define NT_STATUS_ILLEGAL_CHARACTER 353
-#define NT_STATUS_UNMAPPABLE_CHARACTER 354
-#define NT_STATUS_UNDEFINED_CHARACTER 355
-#define NT_STATUS_FLOPPY_VOLUME 356
-#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND 357
-#define NT_STATUS_FLOPPY_WRONG_CYLINDER 358
-#define NT_STATUS_FLOPPY_UNKNOWN_ERROR 359
-#define NT_STATUS_FLOPPY_BAD_REGISTERS 360
-#define NT_STATUS_DISK_RECALIBRATE_FAILED 361
-#define NT_STATUS_DISK_OPERATION_FAILED 362
-#define NT_STATUS_DISK_RESET_FAILED 363
-#define NT_STATUS_SHARED_IRQ_BUSY 364
-#define NT_STATUS_FT_ORPHANING 365
-#define NT_STATUS_PARTITION_FAILURE 370
-#define NT_STATUS_INVALID_BLOCK_LENGTH 371
-#define NT_STATUS_DEVICE_NOT_PARTITIONED 372
-#define NT_STATUS_UNABLE_TO_LOCK_MEDIA 373
-#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA 374
-#define NT_STATUS_EOM_OVERFLOW 375
-#define NT_STATUS_NO_MEDIA 376
-#define NT_STATUS_NO_SUCH_MEMBER 378
-#define NT_STATUS_INVALID_MEMBER 379
-#define NT_STATUS_KEY_DELETED 380
-#define NT_STATUS_NO_LOG_SPACE 381
-#define NT_STATUS_TOO_MANY_SIDS 382
-#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED 383
-#define NT_STATUS_KEY_HAS_CHILDREN 384
-#define NT_STATUS_CHILD_MUST_BE_VOLATILE 385
-#define NT_STATUS_DEVICE_CONFIGURATION_ERROR 386
-#define NT_STATUS_DRIVER_INTERNAL_ERROR 387
-#define NT_STATUS_INVALID_DEVICE_STATE 388
-#define NT_STATUS_IO_DEVICE_ERROR 389
-#define NT_STATUS_DEVICE_PROTOCOL_ERROR 390
-#define NT_STATUS_BACKUP_CONTROLLER 391
-#define NT_STATUS_LOG_FILE_FULL 392
-#define NT_STATUS_TOO_LATE 393
-#define NT_STATUS_NO_TRUST_LSA_SECRET 394
-#define NT_STATUS_NO_TRUST_SAM_ACCOUNT 395
-#define NT_STATUS_TRUSTED_DOMAIN_FAILURE 396
-#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE 397
-#define NT_STATUS_EVENTLOG_FILE_CORRUPT 398
-#define NT_STATUS_EVENTLOG_CANT_START 399
-#define NT_STATUS_TRUST_FAILURE 400
-#define NT_STATUS_MUTANT_LIMIT_EXCEEDED 401
-#define NT_STATUS_NETLOGON_NOT_STARTED 402
-#define NT_STATUS_ACCOUNT_EXPIRED 403
-#define NT_STATUS_POSSIBLE_DEADLOCK 404
-#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT 405
-#define NT_STATUS_REMOTE_SESSION_LIMIT 406
-#define NT_STATUS_EVENTLOG_FILE_CHANGED 407
-#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 408
-#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 409
-#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 410
-#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT 411
-#define NT_STATUS_FS_DRIVER_REQUIRED 412
-#define NT_STATUS_NO_USER_SESSION_KEY 514
-#define NT_STATUS_USER_SESSION_DELETED 515
-#define NT_STATUS_RESOURCE_LANG_NOT_FOUND 516
-#define NT_STATUS_INSUFF_SERVER_RESOURCES 517
-#define NT_STATUS_INVALID_BUFFER_SIZE 518
-#define NT_STATUS_INVALID_ADDRESS_COMPONENT 519
-#define NT_STATUS_INVALID_ADDRESS_WILDCARD 520
-#define NT_STATUS_TOO_MANY_ADDRESSES 521
-#define NT_STATUS_ADDRESS_ALREADY_EXISTS 522
-#define NT_STATUS_ADDRESS_CLOSED 523
-#define NT_STATUS_CONNECTION_DISCONNECTED 524
-#define NT_STATUS_CONNECTION_RESET 525
-#define NT_STATUS_TOO_MANY_NODES 526
-#define NT_STATUS_TRANSACTION_ABORTED 527
-#define NT_STATUS_TRANSACTION_TIMED_OUT 528
-#define NT_STATUS_TRANSACTION_NO_RELEASE 529
-#define NT_STATUS_TRANSACTION_NO_MATCH 530
-#define NT_STATUS_TRANSACTION_RESPONDED 531
-#define NT_STATUS_TRANSACTION_INVALID_ID 532
-#define NT_STATUS_TRANSACTION_INVALID_TYPE 533
-#define NT_STATUS_NOT_SERVER_SESSION 534
-#define NT_STATUS_NOT_CLIENT_SESSION 535
-#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE 536
-#define NT_STATUS_DEBUG_ATTACH_FAILED 537
-#define NT_STATUS_SYSTEM_PROCESS_TERMINATED 538
-#define NT_STATUS_DATA_NOT_ACCEPTED 539
-#define NT_STATUS_NO_BROWSER_SERVERS_FOUND 540
-#define NT_STATUS_VDM_HARD_ERROR 541
-#define NT_STATUS_DRIVER_CANCEL_TIMEOUT 542
-#define NT_STATUS_REPLY_MESSAGE_MISMATCH 543
-#define NT_STATUS_MAPPED_ALIGNMENT 544
-#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH 545
-#define NT_STATUS_LOST_WRITEBEHIND_DATA 546
-#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID 547
-#define NT_STATUS_PASSWORD_MUST_CHANGE 548
-#define NT_STATUS_NOT_FOUND 549
-#define NT_STATUS_NOT_TINY_STREAM 550
-#define NT_STATUS_RECOVERY_FAILURE 551
-#define NT_STATUS_STACK_OVERFLOW_READ 552
-#define NT_STATUS_FAIL_CHECK 553
-#define NT_STATUS_DUPLICATE_OBJECTID 554
-#define NT_STATUS_OBJECTID_EXISTS 555
-#define NT_STATUS_CONVERT_TO_LARGE 556
-#define NT_STATUS_RETRY 557
-#define NT_STATUS_FOUND_OUT_OF_SCOPE 558
-#define NT_STATUS_ALLOCATE_BUCKET 559
-#define NT_STATUS_PROPSET_NOT_FOUND 560
-#define NT_STATUS_MARSHALL_OVERFLOW 561
-#define NT_STATUS_INVALID_VARIANT 562
-#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND 563
-#define NT_STATUS_ACCOUNT_LOCKED_OUT 564
-#define NT_STATUS_HANDLE_NOT_CLOSABLE 565
-#define NT_STATUS_CONNECTION_REFUSED 566
-#define NT_STATUS_GRACEFUL_DISCONNECT 567
-#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED 568
-#define NT_STATUS_ADDRESS_NOT_ASSOCIATED 569
-#define NT_STATUS_CONNECTION_INVALID 570
-#define NT_STATUS_CONNECTION_ACTIVE 571
-#define NT_STATUS_NETWORK_UNREACHABLE 572
-#define NT_STATUS_HOST_UNREACHABLE 573
-#define NT_STATUS_PROTOCOL_UNREACHABLE 574
-#define NT_STATUS_PORT_UNREACHABLE 575
-#define NT_STATUS_REQUEST_ABORTED 576
-#define NT_STATUS_CONNECTION_ABORTED 577
-#define NT_STATUS_BAD_COMPRESSION_BUFFER 578
-#define NT_STATUS_USER_MAPPED_FILE 579
-#define NT_STATUS_AUDIT_FAILED 580
-#define NT_STATUS_TIMER_RESOLUTION_NOT_SET 581
-#define NT_STATUS_CONNECTION_COUNT_LIMIT 582
-#define NT_STATUS_LOGIN_TIME_RESTRICTION 583
-#define NT_STATUS_LOGIN_WKSTA_RESTRICTION 584
-#define NT_STATUS_IMAGE_MP_UP_MISMATCH 585
-#define NT_STATUS_INSUFFICIENT_LOGON_INFO 592
-#define NT_STATUS_BAD_DLL_ENTRYPOINT 593
-#define NT_STATUS_BAD_SERVICE_ENTRYPOINT 594
-#define NT_STATUS_LPC_REPLY_LOST 595
-#define NT_STATUS_IP_ADDRESS_CONFLICT1 596
-#define NT_STATUS_IP_ADDRESS_CONFLICT2 597
-#define NT_STATUS_REGISTRY_QUOTA_LIMIT 598
-#define NT_STATUS_PATH_NOT_COVERED 599
-#define NT_STATUS_NO_CALLBACK_ACTIVE 600
-#define NT_STATUS_LICENSE_QUOTA_EXCEEDED 601
-#define NT_STATUS_PWD_TOO_SHORT 602
-#define NT_STATUS_PWD_TOO_RECENT 603
-#define NT_STATUS_PWD_HISTORY_CONFLICT 604
-#define NT_STATUS_PLUGPLAY_NO_DEVICE 606
-#define NT_STATUS_UNSUPPORTED_COMPRESSION 607
-#define NT_STATUS_INVALID_HW_PROFILE 608
-#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH 609
-#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND 610
-#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND 611
-#define NT_STATUS_RESOURCE_NOT_OWNED 612
-#define NT_STATUS_TOO_MANY_LINKS 613
-#define NT_STATUS_QUOTA_LIST_INCONSISTENT 614
-#define NT_STATUS_FILE_IS_OFFLINE 615
-
-#define RPC_NT_UUID_LOCAL_ONLY 0x40020056
-#define RPC_NT_SEND_INCOMPLETE 0x400200AF
-
-#define RPC_NT_INVALID_STRING_BINDING 0xC0020001
-#define RPC_NT_WRONG_KIND_OF_BINDING 0xC0020002
-#define RPC_NT_INVALID_BINDING 0xC0020003
-#define RPC_NT_PROTSEQ_NOT_SUPPORTED 0xC0020004
-#define RPC_NT_INVALID_RPC_PROTSEQ 0xC0020005
-#define RPC_NT_INVALID_STRING_UUID 0xC0020006
-#define RPC_NT_INVALID_ENDPOINT_FORMAT 0xC0020007
-#define RPC_NT_INVALID_NET_ADDR 0xC0020008
-#define RPC_NT_NO_ENDPOINT_FOUND 0xC0020009
-#define RPC_NT_INVALID_TIMEOUT 0xC002000A
-#define RPC_NT_OBJECT_NOT_FOUND 0xC002000B
-#define RPC_NT_ALREADY_REGISTERED 0xC002000C
-#define RPC_NT_TYPE_ALREADY_REGISTERED 0xC002000D
-#define RPC_NT_ALREADY_LISTENING 0xC002000E
-#define RPC_NT_NO_PROTSEQS_REGISTERED 0xC002000F
-#define RPC_NT_NOT_LISTENING 0xC0020010
-#define RPC_NT_UNKNOWN_MGR_TYPE 0xC0020011
-#define RPC_NT_UNKNOWN_IF 0xC0020012
-#define RPC_NT_NO_BINDINGS 0xC0020013
-#define RPC_NT_NO_PROTSEQS 0xC0020014
-#define RPC_NT_CANT_CREATE_ENDPOINT 0xC0020015
-#define RPC_NT_OUT_OF_RESOURCES 0xC0020016
-#define RPC_NT_SERVER_UNAVAILABLE 0xC0020017
-#define RPC_NT_SERVER_TOO_BUSY 0xC0020018
-#define RPC_NT_INVALID_NETWORK_OPTIONS 0xC0020019
-#define RPC_NT_NO_CALL_ACTIVE 0xC002001A
-#define RPC_NT_CALL_FAILED 0xC002001B
-#define RPC_NT_CALL_FAILED_DNE 0xC002001C
-#define RPC_NT_PROTOCOL_ERROR 0xC002001D
-#define RPC_NT_UNSUPPORTED_TRANS_SYN 0xC002001F
-#define RPC_NT_UNSUPPORTED_TYPE 0xC0020021
-#define RPC_NT_INVALID_TAG 0xC0020022
-#define RPC_NT_INVALID_BOUND 0xC0020023
-#define RPC_NT_NO_ENTRY_NAME 0xC0020024
-#define RPC_NT_INVALID_NAME_SYNTAX 0xC0020025
-#define RPC_NT_UNSUPPORTED_NAME_SYNTAX 0xC0020026
-#define RPC_NT_UUID_NO_ADDRESS 0xC0020028
-#define RPC_NT_DUPLICATE_ENDPOINT 0xC0020029
-#define RPC_NT_UNKNOWN_AUTHN_TYPE 0xC002002A
-#define RPC_NT_MAX_CALLS_TOO_SMALL 0xC002002B
-#define RPC_NT_STRING_TOO_LONG 0xC002002C
-#define RPC_NT_PROTSEQ_NOT_FOUND 0xC002002D
-#define RPC_NT_PROCNUM_OUT_OF_RANGE 0xC002002E
-#define RPC_NT_BINDING_HAS_NO_AUTH 0xC002002F
-#define RPC_NT_UNKNOWN_AUTHN_SERVICE 0xC0020030
-#define RPC_NT_UNKNOWN_AUTHN_LEVEL 0xC0020031
-#define RPC_NT_INVALID_AUTH_IDENTITY 0xC0020032
-#define RPC_NT_UNKNOWN_AUTHZ_SERVICE 0xC0020033
-#define EPT_NT_INVALID_ENTRY 0xC0020034
-#define EPT_NT_CANT_PERFORM_OP 0xC0020035
-#define EPT_NT_NOT_REGISTERED 0xC0020036
-#define RPC_NT_NOTHING_TO_EXPORT 0xC0020037
-#define RPC_NT_INCOMPLETE_NAME 0xC0020038
-#define RPC_NT_INVALID_VERS_OPTION 0xC0020039
-#define RPC_NT_NO_MORE_MEMBERS 0xC002003A
-#define RPC_NT_NOT_ALL_OBJS_UNEXPORTED 0xC002003B
-#define RPC_NT_INTERFACE_NOT_FOUND 0xC002003C
-#define RPC_NT_ENTRY_ALREADY_EXISTS 0xC002003D
-#define RPC_NT_ENTRY_NOT_FOUND 0xC002003E
-#define RPC_NT_NAME_SERVICE_UNAVAILABLE 0xC002003F
-#define RPC_NT_INVALID_NAF_ID 0xC0020040
-#define RPC_NT_CANNOT_SUPPORT 0xC0020041
-#define RPC_NT_NO_CONTEXT_AVAILABLE 0xC0020042
-#define RPC_NT_INTERNAL_ERROR 0xC0020043
-#define RPC_NT_ZERO_DIVIDE 0xC0020044
-#define RPC_NT_ADDRESS_ERROR 0xC0020045
-#define RPC_NT_FP_DIV_ZERO 0xC0020046
-#define RPC_NT_FP_UNDERFLOW 0xC0020047
-#define RPC_NT_FP_OVERFLOW 0xC0020048
-#define RPC_NT_CALL_IN_PROGRESS 0xC0020049
-#define RPC_NT_NO_MORE_BINDINGS 0xC002004A
-#define RPC_NT_GROUP_MEMBER_NOT_FOUND 0xC002004B
-#define EPT_NT_CANT_CREATE 0xC002004C
-#define RPC_NT_INVALID_OBJECT 0xC002004D
-#define RPC_NT_NO_INTERFACES 0xC002004F
-#define RPC_NT_CALL_CANCELLED 0xC0020050
-#define RPC_NT_BINDING_INCOMPLETE 0xC0020051
-#define RPC_NT_COMM_FAILURE 0xC0020052
-#define RPC_NT_UNSUPPORTED_AUTHN_LEVEL 0xC0020053
-#define RPC_NT_NO_PRINC_NAME 0xC0020054
-#define RPC_NT_NOT_RPC_ERROR 0xC0020055
-#define RPC_NT_SEC_PKG_ERROR 0xC0020057
-#define RPC_NT_NOT_CANCELLED 0xC0020058
-#define RPC_NT_INVALID_ASYNC_HANDLE 0xC0020062
-#define RPC_NT_INVALID_ASYNC_CALL 0xC0020063
-#define RPC_NT_PROXY_ACCESS_DENIED 0xC0020064
-
-#define RPC_NT_NO_MORE_ENTRIES 0xC0030001
-#define RPC_NT_SS_CHAR_TRANS_OPEN_FAIL 0xC0030002
-#define RPC_NT_SS_CHAR_TRANS_SHORT_FILE 0xC0030003
-#define RPC_NT_SS_IN_NULL_CONTEXT 0xC0030004
-#define RPC_NT_SS_CONTEXT_MISMATCH 0xC0030005
-#define RPC_NT_SS_CONTEXT_DAMAGED 0xC0030006
-#define RPC_NT_SS_HANDLES_MISMATCH 0xC0030007
-#define RPC_NT_SS_CANNOT_GET_CALL_HANDLE 0xC0030008
-#define RPC_NT_NULL_REF_POINTER 0xC0030009
-#define RPC_NT_ENUM_VALUE_OUT_OF_RANGE 0xC003000A
-#define RPC_NT_BYTE_COUNT_TOO_SMALL 0xC003000B
-#define RPC_NT_BAD_STUB_DATA 0xC003000C
-#define RPC_NT_INVALID_ES_ACTION 0xC0030059
-#define RPC_NT_WRONG_ES_VERSION 0xC003005A
-#define RPC_NT_WRONG_STUB_VERSION 0xC003005B
-#define RPC_NT_INVALID_PIPE_OBJECT 0xC003005C
-#define RPC_NT_INVALID_PIPE_OPERATION 0xC003005D
-#define RPC_NT_WRONG_PIPE_VERSION 0xC003005E
-#define RPC_NT_PIPE_CLOSED 0xC003005F
-#define RPC_NT_PIPE_DISCIPLINE_ERROR 0xC0030060
-#define RPC_NT_PIPE_EMPTY 0xC0030061
-
-char *xlate_nt_status(DWORD ntstatus);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _SMBSRV_NTSTATUS_H */
diff --git a/usr/src/uts/common/smbsrv/smb.h b/usr/src/uts/common/smbsrv/smb.h
index 4c41d33430..3576c6dbc3 100644
--- a/usr/src/uts/common/smbsrv/smb.h
+++ b/usr/src/uts/common/smbsrv/smb.h
@@ -18,9 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMBSRV_SMB_H
@@ -36,9 +36,10 @@
#include <smbsrv/string.h>
#include <smbsrv/msgbuf.h>
-#include <smbsrv/ntstatus.h>
-#include <smbsrv/nterror.h>
-#include <smbsrv/doserror.h>
+#include <smb/ntstatus.h>
+#include <smb/nterror.h>
+#include <smb/lmerr.h>
+#include <smb/doserror.h>
#include <smbsrv/ntaccess.h>
/*
@@ -317,6 +318,7 @@ typedef uint32_t smb_utime_t;
#define SMB_COM_CLOSE_PRINT_FILE 0xC2
#define SMB_COM_GET_PRINT_QUEUE 0xC3
+#define SMB_COM_NUM 0x100
/*
* Flags field of the SMB header. The names in parenthesis represent
diff --git a/usr/src/uts/common/smbsrv/smb_door.h b/usr/src/uts/common/smbsrv/smb_door.h
index 695f44ea30..d1e68603d2 100644
--- a/usr/src/uts/common/smbsrv/smb_door.h
+++ b/usr/src/uts/common/smbsrv/smb_door.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMBSRV_SMB_DOOR_H
@@ -65,7 +64,9 @@ typedef enum smb_dopcode {
SMB_DR_ADS_FIND_HOST,
SMB_DR_QUOTA_QUERY,
SMB_DR_QUOTA_SET,
- SMB_DR_DFS_GET_REFERRALS
+ SMB_DR_DFS_GET_REFERRALS,
+ SMB_DR_SHR_HOSTACCESS,
+ SMB_DR_SHR_EXEC
} smb_dopcode_t;
struct smb_event;
@@ -99,6 +100,33 @@ char *smb_string_encode(char *, size_t *);
int smb_string_decode(smb_string_t *, char *, size_t);
#endif /* _KERNEL */
+/*
+ * Legacy door interface
+ */
+#define SMB_SHARE_DNAME "/var/run/smb_share_door"
+#define SMB_SHARE_DSIZE (65 * 1024)
+
+/*
+ * door operations
+ */
+#define SMB_SHROP_NUM_SHARES 1
+#define SMB_SHROP_DELETE 2
+#define SMB_SHROP_RENAME 3
+#define SMB_SHROP_ADD 4
+#define SMB_SHROP_MODIFY 5
+#define SMB_SHROP_LIST 6
+
+/*
+ * Door server status
+ *
+ * SMB_SHARE_DERROR is returned by the door server if there is problem
+ * with marshalling/unmarshalling. Otherwise, SMB_SHARE_DSUCCESS is
+ * returned.
+ *
+ */
+#define SMB_SHARE_DSUCCESS 0
+#define SMB_SHARE_DERROR -1
+
typedef struct smb_dr_ctx {
char *ptr;
char *start_ptr;
@@ -139,6 +167,12 @@ BYTE smb_dr_get_BYTE(smb_dr_ctx_t *);
void smb_dr_put_buf(smb_dr_ctx_t *, unsigned char *, int);
int smb_dr_get_buf(smb_dr_ctx_t *, unsigned char *, int);
+void smb_dr_get_share(smb_dr_ctx_t *, smb_share_t *);
+void smb_dr_put_share(smb_dr_ctx_t *, smb_share_t *);
+
+void smb_share_door_clnt_init(void);
+void smb_share_door_clnt_fini(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/smbsrv/smb_ioctl.h b/usr/src/uts/common/smbsrv/smb_ioctl.h
index 579f648f26..59faa330eb 100644
--- a/usr/src/uts/common/smbsrv/smb_ioctl.h
+++ b/usr/src/uts/common/smbsrv/smb_ioctl.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMB_IOCTL_H_
@@ -68,8 +67,8 @@ typedef struct {
typedef struct smb_ioc_share {
smb_ioc_header_t hdr;
- char path[MAXPATHLEN];
- char name[MAXNAMELEN];
+ uint32_t shrlen;
+ char shr[1];
} smb_ioc_share_t;
typedef struct smb_ioc_listen {
@@ -151,6 +150,8 @@ typedef struct smb_ioc_cfg {
int32_t sync_enable;
int32_t secmode;
int32_t ipv6_enable;
+ uint32_t exec_flags;
+ smb_version_t version;
char nbdomain[NETBIOS_NAME_SZ];
char fqdn[SMB_PI_MAX_DOMAIN];
char hostname[SMB_PI_MAX_HOST];
diff --git a/usr/src/uts/common/smbsrv/smb_kproto.h b/usr/src/uts/common/smbsrv/smb_kproto.h
index b1bc982cf1..38efc1647d 100644
--- a/usr/src/uts/common/smbsrv/smb_kproto.h
+++ b/usr/src/uts/common/smbsrv/smb_kproto.h
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -197,10 +198,10 @@ int smb_net_id(uint32_t);
void smb_process_file_notify_change_queue(smb_ofile_t *of);
-void smb_oplock_acquire(smb_node_t *, smb_ofile_t *, open_param_t *);
+void smb_oplock_acquire(smb_node_t *, smb_ofile_t *, smb_arg_open_t *);
boolean_t smb_oplock_break(smb_node_t *, smb_session_t *, boolean_t);
void smb_oplock_release(smb_node_t *, smb_ofile_t *);
-boolean_t smb_oplock_conflict(smb_node_t *, smb_session_t *, open_param_t *);
+boolean_t smb_oplock_conflict(smb_node_t *, smb_session_t *, smb_arg_open_t *);
boolean_t smb_oplock_broadcast(smb_node_t *);
/*
@@ -221,7 +222,7 @@ boolean_t smb_oplock_broadcast(smb_node_t *);
((op)->create_disposition != FILE_SUPERSEDE) && \
((op)->create_disposition != FILE_OVERWRITE)) \
-uint32_t smb_lock_get_lock_count(smb_node_t *);
+uint32_t smb_lock_get_lock_count(smb_node_t *, smb_ofile_t *);
uint32_t smb_unlock_range(smb_request_t *, smb_node_t *,
uint64_t, uint64_t);
uint32_t smb_lock_range(smb_request_t *, uint64_t, uint64_t, uint32_t,
@@ -231,12 +232,12 @@ void smb_lock_range_error(smb_request_t *, uint32_t);
DWORD smb_range_check(smb_request_t *, smb_node_t *, uint64_t, uint64_t,
boolean_t);
-int smb_mangle_name(ino64_t, char *, char *, char *, int);
-int smb_unmangle_name(smb_node_t *, char *, char *, int, uint32_t);
-int smb_maybe_mangled_name(char *);
-int smb_maybe_mangled_path(const char *, size_t);
-int smb_needs_mangle(char *, char **);
+void smb_mangle(const char *, ino64_t, char *, size_t);
+int smb_unmangle(smb_node_t *, char *, char *, int, uint32_t);
+boolean_t smb_needs_mangled(const char *);
+boolean_t smb_maybe_mangled(char *);
boolean_t smb_is_invalid_filename(const char *);
+boolean_t smb_match_name(ino64_t, char *, char *);
void smbsr_cleanup(smb_request_t *sr);
@@ -269,6 +270,10 @@ uint32_t smb_omode_to_amask(uint32_t desired_access);
void sshow_distribution_info(char *);
+void smb_dispatch_stats_init(smb_kstat_req_t *);
+void smb_dispatch_stats_fini(void);
+void smb_dispatch_stats_update(smb_kstat_req_t *, int, int);
+
boolean_t smb_dispatch_request(smb_request_t *);
int smbsr_encode_empty_result(smb_request_t *);
void smbsr_lookup_file(smb_request_t *);
@@ -276,6 +281,7 @@ void smbsr_release_file(smb_request_t *);
int smbsr_decode_vwv(smb_request_t *sr, char *fmt, ...);
int smbsr_decode_data(smb_request_t *sr, char *fmt, ...);
+boolean_t smbsr_decode_data_avail(smb_request_t *);
int smbsr_encode_result(smb_request_t *, int, int, char *, ...);
smb_xa_t *smbsr_lookup_xa(smb_request_t *sr);
void smbsr_send_reply(smb_request_t *);
@@ -283,8 +289,11 @@ void smbsr_send_reply(smb_request_t *);
void smbsr_map_errno(int, smb_error_t *);
void smbsr_set_error(smb_request_t *, smb_error_t *);
void smbsr_errno(smb_request_t *, int);
-void smbsr_warn(smb_request_t *, DWORD, uint16_t, uint16_t);
-void smbsr_error(smb_request_t *, DWORD, uint16_t, uint16_t);
+void smbsr_status(smb_request_t *, DWORD, uint16_t, uint16_t);
+#define smbsr_error(SR, ST, CL, CO) \
+ smbsr_status(SR, ST, CL, CO)
+#define smbsr_warn(SR, ST, CL, CO) \
+ smbsr_status(SR, ST, CL, CO)
int clock_get_milli_uptime(void);
@@ -298,10 +307,6 @@ int smb_mbc_poke(mbuf_chain_t *, int, char *, ...);
void smbsr_encode_header(smb_request_t *sr, int wct,
int bcc, char *fmt, ...);
-int smb_xlate_dialect_str_to_cd(char *);
-char *smb_xlate_com_cd_to_str(int);
-char *smb_xlate_dialect_cd_to_str(int);
-
int smb_lock_range_access(smb_request_t *, smb_node_t *,
uint64_t, uint64_t, boolean_t);
@@ -366,17 +371,33 @@ int smb_server_tcp_listen(smb_ioc_listen_t *);
int smb_server_nbt_receive(void);
int smb_server_tcp_receive(void);
uint32_t smb_server_get_session_count(void);
-int smb_server_share_export(smb_ioc_share_t *);
-int smb_server_share_unexport(smb_ioc_share_t *);
int smb_server_set_gmtoff(smb_ioc_gmt_t *);
int smb_server_numopen(smb_ioc_opennum_t *);
int smb_server_enum(smb_ioc_svcenum_t *);
int smb_server_session_close(smb_ioc_session_t *);
int smb_server_file_close(smb_ioc_fileid_t *);
+int smb_server_sharevp(const char *, vnode_t **);
+int smb_server_unshare(const char *);
void smb_server_reconnection_check(smb_server_t *, smb_session_t *);
void smb_server_get_cfg(smb_server_t *, smb_kmod_cfg_t *);
+void smb_server_inc_nbt_sess(smb_server_t *);
+void smb_server_dec_nbt_sess(smb_server_t *);
+void smb_server_inc_tcp_sess(smb_server_t *);
+void smb_server_dec_tcp_sess(smb_server_t *);
+void smb_server_inc_users(smb_server_t *);
+void smb_server_dec_users(smb_server_t *);
+void smb_server_inc_trees(smb_server_t *);
+void smb_server_dec_trees(smb_server_t *);
+void smb_server_inc_files(smb_server_t *);
+void smb_server_dec_files(smb_server_t *);
+void smb_server_inc_pipes(smb_server_t *);
+void smb_server_dec_pipes(smb_server_t *);
+void smb_server_add_rxb(smb_server_t *, int64_t);
+void smb_server_add_txb(smb_server_t *, int64_t);
+void smb_server_inc_req(smb_server_t *);
+
smb_event_t *smb_event_create(void);
void smb_event_destroy(smb_event_t *);
uint32_t smb_event_txid(smb_event_t *);
@@ -387,7 +408,7 @@ int smb_event_wait(smb_event_t *);
*/
int smb_node_init(void);
void smb_node_fini(void);
-smb_node_t *smb_node_lookup(smb_request_t *, open_param_t *,
+smb_node_t *smb_node_lookup(smb_request_t *, smb_arg_open_t *,
cred_t *, vnode_t *, char *, smb_node_t *, smb_node_t *);
smb_node_t *smb_stream_node_lookup(smb_request_t *, cred_t *,
smb_node_t *, vnode_t *, vnode_t *, char *);
@@ -447,11 +468,9 @@ int smb_pathname(smb_request_t *, char *, int, smb_node_t *,
* smb_vfs functions
*/
-boolean_t smb_vfs_hold(smb_server_t *, vfs_t *);
-void smb_vfs_rele(smb_server_t *, vfs_t *);
-void smb_vfs_rele_all(smb_server_t *);
-boolean_t smb_vfs_cmp(vfs_t *, vfs_t *);
-boolean_t smb_vfs_is_readonly(vfs_t *);
+int smb_vfs_hold(smb_export_t *, vfs_t *);
+void smb_vfs_rele(smb_export_t *, vfs_t *);
+void smb_vfs_rele_all(smb_export_t *);
/* NOTIFY CHANGE */
void smb_process_session_notify_change_queue(smb_session_t *, smb_tree_t *);
@@ -524,7 +543,7 @@ smb_ofile_t *smb_ofile_lookup_by_fid(smb_tree_t *, uint16_t);
smb_ofile_t *smb_ofile_lookup_by_uniqid(smb_tree_t *, uint32_t);
boolean_t smb_ofile_disallow_fclose(smb_ofile_t *);
smb_ofile_t *smb_ofile_open(smb_tree_t *, smb_node_t *, uint16_t,
- open_param_t *, uint16_t, uint32_t, smb_error_t *);
+ smb_arg_open_t *, uint16_t, uint32_t, smb_error_t *);
void smb_ofile_close(smb_ofile_t *, uint32_t);
void smb_ofile_delete(void *);
uint32_t smb_ofile_access(smb_ofile_t *, cred_t *, uint32_t);
@@ -580,8 +599,6 @@ void smb_odir_resume_at(smb_odir_t *, smb_odir_resume_t *);
/*
* SMB user functions (file smb_user.c)
*/
-int smb_user_init(void);
-void smb_user_fini(void);
smb_user_t *smb_user_login(smb_session_t *, cred_t *,
char *, char *, uint32_t, uint32_t, uint32_t);
smb_user_t *smb_user_dup(smb_user_t *);
@@ -625,14 +642,6 @@ smb_odir_t *smb_tree_lookup_odir(smb_tree_t *, uint16_t);
boolean_t smb_tree_is_connected(smb_tree_t *);
#define SMB_TREE_GET_TID(tree) ((tree)->t_tid)
-/*
- * SMB user's credential functions
- */
-cred_t *smb_cred_create(smb_token_t *, uint32_t *);
-void smb_cred_rele(cred_t *cr);
-int smb_cred_is_member(cred_t *cr, smb_sid_t *sid);
-cred_t *smb_cred_create_privs(cred_t *, uint32_t);
-
smb_xa_t *smb_xa_create(smb_session_t *session, smb_request_t *sr,
uint32_t total_parameter_count, uint32_t total_data_count,
uint32_t max_parameter_count, uint32_t max_data_count,
@@ -665,9 +674,6 @@ int netbios_name_isvalid(char *in, char *out);
int uioxfer(struct uio *src_uio, struct uio *dst_uio, int n);
-int smb_match_name(ino64_t, char *, char *, boolean_t);
-int token2buf(smb_token_t *token, char *buf);
-
/*
* Pool ID function prototypes
*/
@@ -766,6 +772,16 @@ void smb_panic(char *, const char *, int);
#pragma does_not_return(smb_panic)
#define SMB_PANIC() smb_panic(__FILE__, __func__, __LINE__)
+void smb_latency_init(smb_latency_t *);
+void smb_latency_destroy(smb_latency_t *);
+void smb_latency_add_sample(smb_latency_t *, hrtime_t);
+void smb_srqueue_init(smb_srqueue_t *);
+void smb_srqueue_destroy(smb_srqueue_t *);
+void smb_srqueue_waitq_enter(smb_srqueue_t *);
+void smb_srqueue_runq_exit(smb_srqueue_t *);
+void smb_srqueue_waitq_to_runq(smb_srqueue_t *);
+void smb_srqueue_update(smb_srqueue_t *, smb_kstat_utilization_t *);
+
void *smb_mem_alloc(size_t);
void *smb_mem_zalloc(size_t);
void *smb_mem_realloc(void *, size_t);
@@ -779,6 +795,34 @@ void *smb_srm_alloc(smb_request_t *, size_t);
void *smb_srm_zalloc(smb_request_t *, size_t);
void *smb_srm_realloc(smb_request_t *, void *, size_t);
void *smb_srm_rezalloc(smb_request_t *, void *, size_t);
+char *smb_srm_strdup(smb_request_t *, const char *);
+
+void smb_export_start(void);
+void smb_export_stop(void);
+
+door_handle_t smb_kshare_door_init(int);
+void smb_kshare_door_fini(door_handle_t);
+int smb_kshare_upcall(door_handle_t, void *, boolean_t);
+
+int smb_kshare_init(void);
+void smb_kshare_fini(void);
+int smb_kshare_export_list(smb_ioc_share_t *);
+int smb_kshare_unexport_list(smb_ioc_share_t *);
+void smb_kshare_enum(smb_enumshare_info_t *);
+smb_kshare_t *smb_kshare_lookup(const char *);
+void smb_kshare_release(smb_kshare_t *);
+int smb_kshare_exec(smb_shr_execinfo_t *);
+uint32_t smb_kshare_hostaccess(smb_kshare_t *, smb_inaddr_t *);
+
+
+void smb_avl_create(smb_avl_t *, size_t, size_t, smb_avl_nops_t *);
+void smb_avl_destroy(smb_avl_t *);
+int smb_avl_add(smb_avl_t *, void *);
+void smb_avl_remove(smb_avl_t *, void *);
+void *smb_avl_lookup(smb_avl_t *, void *);
+void smb_avl_release(smb_avl_t *, void *);
+void smb_avl_iterinit(smb_avl_t *, smb_avl_cursor_t *);
+void *smb_avl_iterate(smb_avl_t *, smb_avl_cursor_t *);
#ifdef __cplusplus
}
diff --git a/usr/src/uts/common/smbsrv/smb_kstat.h b/usr/src/uts/common/smbsrv/smb_kstat.h
index d77cc84eea..00258a2298 100644
--- a/usr/src/uts/common/smbsrv/smb_kstat.h
+++ b/usr/src/uts/common/smbsrv/smb_kstat.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -29,17 +28,18 @@
#ifndef _SMBSRV_SMB_KSTAT_H
#define _SMBSRV_SMB_KSTAT_H
+#include <smbsrv/smb.h>
+
#ifdef __cplusplus
extern "C" {
#endif
+#define SMBSRV_KSTAT_PROCESS "smbd"
#define SMBSRV_KSTAT_MODULE "smbsrv"
#define SMBSRV_KSTAT_CLASS "net"
#define SMBSRV_KSTAT_NAME "smbsrv"
#define SMBSRV_KSTAT_NAME_CMDS "smbsrv_commands"
#define SMBSRV_KSTAT_TXRCACHE "smb_txreq"
-#define SMBSRV_KSTAT_UNEXPORT_CACHE "smb_unexport_cache"
-#define SMBSRV_KSTAT_VFS_CACHE "smb_vfs_cache"
#define SMBSRV_KSTAT_REQUEST_CACHE "smb_request_cache"
#define SMBSRV_KSTAT_SESSION_CACHE "smb_session_cache"
#define SMBSRV_KSTAT_USER_CACHE "smb_user_cache"
@@ -48,6 +48,49 @@ extern "C" {
#define SMBSRV_KSTAT_ODIR_CACHE "smb_odir_cache"
#define SMBSRV_KSTAT_NODE_CACHE "smb_node_cache"
#define SMBSRV_KSTAT_MBC_CACHE "smb_mbc_cache"
+#define SMBSRV_KSTAT_STATISTICS "smbsrv_statistics"
+#define SMBSRV_KSTAT_UNSUPPORTED "Unsupported"
+#define SMBSRV_KSTAT_WORKERS "smb_workers"
+
+#pragma pack(1)
+
+typedef struct smb_kstat_utilization {
+ hrtime_t ku_wtime;
+ hrtime_t ku_wlentime;
+ hrtime_t ku_rtime;
+ hrtime_t ku_rlentime;
+} smb_kstat_utilization_t;
+
+typedef struct smb_kstat_req {
+ char kr_name[KSTAT_STRLEN];
+ uint64_t kr_sum;
+ uint64_t kr_txb;
+ uint64_t kr_rxb;
+ uint64_t kr_nreq;
+ uint64_t kr_a_mean;
+ uint64_t kr_a_stddev;
+ uint64_t kr_d_mean;
+ uint64_t kr_d_stddev;
+} smb_kstat_req_t;
+
+typedef struct smbsrv_kstats {
+ hrtime_t ks_start_time;
+ uint64_t ks_txb; /* Bytes transmitted */
+ uint64_t ks_rxb; /* Bytes received */
+ uint64_t ks_nreq; /* Requests treated */
+ smb_kstat_utilization_t ks_utilization;
+ smb_kstat_req_t ks_reqs[SMB_COM_NUM];
+ uint32_t ks_nbt_sess; /* NBT sessions */
+ uint32_t ks_tcp_sess; /* TCP sessions */
+ uint32_t ks_users; /* Users logged in */
+ uint32_t ks_trees; /* Trees connected */
+ uint32_t ks_files; /* Open files */
+ uint32_t ks_pipes; /* Open pipes */
+ uint32_t ks_maxreqs; /* Max number of reqs */
+ uint32_t ks_padding;
+} smbsrv_kstats_t;
+
+#pragma pack()
#ifdef __cplusplus
}
diff --git a/usr/src/uts/common/smbsrv/smb_ktypes.h b/usr/src/uts/common/smbsrv/smb_ktypes.h
index d2b54b2a12..b1e951ed1d 100644
--- a/usr/src/uts/common/smbsrv/smb_ktypes.h
+++ b/usr/src/uts/common/smbsrv/smb_ktypes.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -58,12 +57,99 @@ extern "C" {
#include <smbsrv/smb_xdr.h>
#include <smbsrv/netbios.h>
#include <smbsrv/smb_vops.h>
+#include <smbsrv/smb_kstat.h>
struct smb_disp_entry;
struct smb_request;
struct smb_server;
struct smb_event;
+/*
+ * Accumulated time and queue length statistics.
+ *
+ * Accumulated time statistics are kept as a running sum of "active" time.
+ * Queue length statistics are kept as a running sum of the product of queue
+ * length and elapsed time at that length -- i.e., a Riemann sum for queue
+ * length integrated against time. (You can also think of the active time as a
+ * Riemann sum, for the boolean function (queue_length > 0) integrated against
+ * time, or you can think of it as the Lebesgue measure of the set on which
+ * queue_length > 0.)
+ *
+ * ^
+ * | _________
+ * 8 | i4 |
+ * | | |
+ * Queue 6 | |
+ * Length | _________ | |
+ * 4 | i2 |_______| |
+ * | | i3 |
+ * 2_______| |
+ * | i1 |
+ * |_______________________________|
+ * Time-> t1 t2 t3 t4
+ *
+ * At each change of state (entry or exit from the queue), we add the elapsed
+ * time (since the previous state change) to the active time if the queue length
+ * was non-zero during that interval; and we add the product of the elapsed time
+ * times the queue length to the running length*time sum.
+ *
+ * This method is generalizable to measuring residency in any defined system:
+ * instead of queue lengths, think of "outstanding RPC calls to server X".
+ *
+ * A large number of I/O subsystems have at least two basic "lists" of
+ * transactions they manage: one for transactions that have been accepted for
+ * processing but for which processing has yet to begin, and one for
+ * transactions which are actively being processed (but not done). For this
+ * reason, two cumulative time statistics are defined here: wait (pre-service)
+ * time, and run (service) time.
+ *
+ * All times are 64-bit nanoseconds (hrtime_t), as returned by gethrtime().
+ *
+ * The units of cumulative busy time are accumulated nanoseconds. The units of
+ * cumulative length*time products are elapsed time times queue length.
+ *
+ * Updates to the fields below are performed implicitly by calls to
+ * these functions:
+ *
+ * smb_srqueue_init()
+ * smb_srqueue_destroy()
+ * smb_srqueue_waitq_enter()
+ * smb_srqueue_runq_exit()
+ * smb_srqueue_waitq_to_runq()
+ * smb_srqueue_update()
+ *
+ * These fields should never be updated by any other means.
+ */
+typedef struct smb_srqueue {
+ kmutex_t srq_mutex;
+ hrtime_t srq_wlastupdate;
+ hrtime_t srq_wtime;
+ hrtime_t srq_wlentime;
+ hrtime_t srq_rlastupdate;
+ hrtime_t srq_rtime;
+ hrtime_t srq_rlentime;
+ uint32_t srq_wcnt;
+ uint32_t srq_rcnt;
+} smb_srqueue_t;
+
+/*
+ * The fields with the prefix 'ly_a' contain the statistics collected since the
+ * server was last started ('a' for 'aggregated'). The fields with the prefix
+ * 'ly_d' contain the statistics collected since the last snapshot ('d' for
+ * 'delta').
+ */
+typedef struct smb_latency {
+ kmutex_t ly_mutex;
+ uint64_t ly_a_nreq;
+ hrtime_t ly_a_sum;
+ hrtime_t ly_a_mean;
+ hrtime_t ly_a_stddev;
+ uint64_t ly_d_nreq;
+ hrtime_t ly_d_sum;
+ hrtime_t ly_d_mean;
+ hrtime_t ly_d_stddev;
+} smb_latency_t;
+
int smb_noop(void *, size_t, int);
#define SMB_AUDIT_STACK_DEPTH 16
@@ -310,6 +396,62 @@ typedef struct smb_slist {
boolean_t sl_waiting;
} smb_slist_t;
+/*
+ * smb_avl_t State Machine
+ * --------------------
+ *
+ * +-----------------------------+
+ * | SMB_AVL_STATE_START |
+ * +-----------------------------+
+ * | T0
+ * v
+ * +-----------------------------+
+ * | SMB_AVL_STATE_READY |
+ * +-----------------------------+
+ * | T1
+ * v
+ * +-----------------------------+
+ * | SMB_AVL_STATE_DESTROYING |
+ * +-----------------------------+
+ *
+ * Transition T0
+ *
+ * This transition is executed in smb_avl_create().
+ *
+ * Transition T1
+ *
+ * This transition is executed in smb_avl_destroy().
+ *
+ */
+typedef enum {
+ SMB_AVL_STATE_START = 0,
+ SMB_AVL_STATE_READY,
+ SMB_AVL_STATE_DESTROYING
+} smb_avl_state_t;
+
+typedef struct smb_avl_nops {
+ int (*avln_cmp) (const void *, const void *);
+ void (*avln_hold)(const void *);
+ boolean_t (*avln_rele)(const void *);
+ void (*avln_destroy)(void *);
+} smb_avl_nops_t;
+
+typedef struct smb_avl_cursor {
+ void *avlc_next;
+ uint32_t avlc_sequence;
+} smb_avl_cursor_t;
+
+typedef struct smb_avl {
+ krwlock_t avl_lock;
+ avl_tree_t avl_tree;
+ kmutex_t avl_mutex;
+ kcondvar_t avl_cv;
+ smb_avl_state_t avl_state;
+ uint32_t avl_refcnt;
+ uint32_t avl_sequence;
+ smb_avl_nops_t *avl_nops;
+} smb_avl_t;
+
typedef struct smb_session_list {
krwlock_t se_lock;
uint64_t se_wrop;
@@ -436,11 +578,6 @@ typedef struct smb_vfs {
vnode_t *sv_rootvp;
} smb_vfs_t;
-typedef struct smb_unexport {
- list_node_t ux_lnd;
- char ux_sharename[MAXNAMELEN];
-} smb_unexport_t;
-
/*
* Solaris file systems handle timestamps differently from NTFS.
* In order to provide a more similar view of an open file's
@@ -523,6 +660,68 @@ typedef struct smb_node {
#define SMB_NODE_VFS(node) ((node)->vp->v_vfsp)
#define SMB_NODE_FSID(node) ((node)->vp->v_vfsp->vfs_fsid)
+/* Maximum buffer size for encryption key */
+#define SMB_ENCRYPT_KEY_MAXLEN 32
+
+#define SMB_SHARE_MAGIC 0x4B534852 /* KSHR */
+
+typedef struct smb_kshare {
+ uint32_t shr_magic;
+ char *shr_name;
+ char *shr_path;
+ char *shr_cmnt;
+ char *shr_container;
+ char *shr_oemname;
+ uint32_t shr_flags;
+ uint32_t shr_type;
+ uint32_t shr_refcnt;
+ uint32_t shr_autocnt;
+ uid_t shr_uid;
+ gid_t shr_gid;
+ char *shr_access_none;
+ char *shr_access_ro;
+ char *shr_access_rw;
+ avl_node_t shr_link;
+ kmem_cache_t *shr_cache;
+ kmutex_t shr_mutex;
+} smb_kshare_t;
+
+
+typedef struct smb_arg_negotiate {
+ char *ni_name;
+ int ni_dialect;
+ int ni_index;
+ uint32_t ni_capabilities;
+ uint16_t ni_maxmpxcount;
+ int16_t ni_tzcorrection;
+ uint8_t ni_keylen;
+ uint8_t ni_key[SMB_ENCRYPT_KEY_MAXLEN];
+ timestruc_t ni_servertime;
+} smb_arg_negotiate_t;
+
+typedef struct smb_arg_sessionsetup {
+ char *ssi_user;
+ char *ssi_domain;
+ uint16_t ssi_cipwlen;
+ uint8_t *ssi_cipwd;
+ uint16_t ssi_cspwlen;
+ uint8_t *ssi_cspwd;
+ uint16_t ssi_maxmpxcount;
+ uint32_t ssi_capabilities;
+ uint32_t ssi_sesskey;
+ boolean_t ssi_guest;
+} smb_arg_sessionsetup_t;
+
+typedef struct tcon {
+ char *path;
+ char *service;
+ int pwdlen;
+ char *password;
+ uint16_t flags;
+ uint16_t optional_support;
+ smb_kshare_t *si;
+} smb_arg_tcon_t;
+
/*
* Based on section 2.6.1.2 (Connection Management) of the June 13,
* 1996 CIFS spec, a server may terminate the transport connection
@@ -713,6 +912,8 @@ typedef struct smb_session {
char workstation[SMB_PI_MAX_HOST];
int dialect;
int native_os;
+ int native_lm;
+
uint32_t capabilities;
struct smb_sign signing;
@@ -743,6 +944,7 @@ typedef struct smb_session {
int outpipe_datalen;
int outpipe_cookie;
list_t s_oplock_brkreqs;
+ smb_srqueue_t *s_srqueue;
} smb_session_t;
#define SMB_USER_MAGIC 0x55534552 /* 'USER' */
@@ -755,6 +957,9 @@ typedef struct smb_session {
#define SMB_USER_FLAG_POWER_USER SMB_ATF_POWERUSER
#define SMB_USER_FLAG_BACKUP_OPERATOR SMB_ATF_BACKUPOP
+#define SMB_USER_IS_ADMIN(U) (((U)->u_flags & SMB_USER_FLAG_ADMIN) != 0)
+#define SMB_USER_IS_GUEST(U) (((U)->u_flags & SMB_USER_FLAG_GUEST) != 0)
+
#define SMB_USER_PRIV_TAKE_OWNERSHIP 0x00000001
#define SMB_USER_PRIV_BACKUP 0x00000002
#define SMB_USER_PRIV_RESTORE 0x00000004
@@ -855,7 +1060,7 @@ typedef struct smb_tree {
char t_volume[SMB_VOLNAMELEN];
acl_type_t t_acltype;
uint32_t t_access;
- uint32_t t_shr_flags;
+ uint32_t t_execflags;
time_t t_connect_time;
volatile uint32_t t_open_files;
} smb_tree_t;
@@ -1103,7 +1308,6 @@ typedef struct smb_odirent {
typedef struct smb_fileinfo {
char fi_name[MAXNAMELEN];
- char fi_name83[SMB_SHORTNAMELEN];
char fi_shortname[SMB_SHORTNAMELEN];
uint32_t fi_cookie;
uint32_t fi_dosattr; /* DOS attributes */
@@ -1201,12 +1405,18 @@ typedef struct smb_fqi {
char fq_last_comp[MAXNAMELEN];
} smb_fqi_t;
+typedef struct dirop {
+ smb_fqi_t fqi;
+ smb_fqi_t dst_fqi;
+ uint16_t info_level;
+ uint16_t flags;
+} smb_arg_dirop_t;
+
#define OPLOCK_MIN_TIMEOUT (5 * 1000)
#define OPLOCK_STD_TIMEOUT (15 * 1000)
#define OPLOCK_RETRIES 2
typedef struct {
- uint32_t severity;
uint32_t status;
uint16_t errcls;
uint16_t errcode;
@@ -1236,7 +1446,7 @@ typedef struct open_param {
/* This is only set by NTTransactCreate */
struct smb_sd *sd;
uint8_t op_oplock_level;
-} open_param_t;
+} smb_arg_open_t;
#define SMB_OPLOCK_NONE 0
#define SMB_OPLOCK_EXCLUSIVE 1
@@ -1443,31 +1653,32 @@ typedef struct smb_request {
smb_user_t *uid_user;
union {
- struct tcon {
- char *path;
- char *service;
- int pwdlen;
- char *password;
- uint16_t flags;
- uint16_t optional_support;
- } tcon;
-
- struct dirop {
- smb_fqi_t fqi;
- smb_fqi_t dst_fqi;
- uint16_t info_level;
- uint16_t flags;
- } dirop;
-
- open_param_t open;
- smb_rw_param_t *rw;
- uint32_t timestamp;
+ smb_arg_negotiate_t *negprot;
+ smb_arg_sessionsetup_t *ssetup;
+ smb_arg_tcon_t tcon;
+ smb_arg_dirop_t dirop;
+ smb_arg_open_t open;
+ smb_rw_param_t *rw;
+ uint32_t timestamp;
} arg;
cred_t *user_cr;
kthread_t *sr_worker;
+ hrtime_t sr_time_submitted;
+ hrtime_t sr_time_active;
+ hrtime_t sr_time_start;
+ int32_t sr_txb;
+ uint32_t sr_seqnum;
} smb_request_t;
+#define sr_ssetup arg.ssetup
+#define sr_negprot arg.negprot
+#define sr_tcon arg.tcon
+#define sr_dirop arg.dirop
+#define sr_open arg.open
+#define sr_rw arg.rw
+#define sr_timestamp arg.timestamp
+
#define SMB_READ_PROTOCOL(hdr) \
LE_IN32(((smb_hdr_t *)(hdr))->protocol)
@@ -1480,6 +1691,18 @@ typedef struct smb_request {
#define SMB_IS_WRITERAW(rd_sr) \
(SMB_READ_COMMAND((rd_sr)->sr_request_buf) == SMB_COM_WRITE_RAW)
+#define SMB_IS_NT_CANCEL(rd_sr) \
+ (SMB_READ_COMMAND((rd_sr)->sr_request_buf) == SMB_COM_NT_CANCEL)
+
+#define SMB_IS_SESSION_SETUP_ANDX(rd_sr) \
+ (SMB_READ_COMMAND((rd_sr)->sr_request_buf) == \
+ SMB_COM_SESSION_SETUP_ANDX)
+
+#define SMB_IS_NT_NEGOTIATE(rd_sr) \
+ (SMB_READ_COMMAND((rd_sr)->sr_request_buf) == SMB_COM_NEGOTIATE)
+
+#define SMB_IS_TREE_CONNECT_ANDX(rd_sr) \
+ (SMB_READ_COMMAND((rd_sr)->sr_request_buf) == SMB_COM_TREE_CONNECT_ANDX)
#define SMB_XA_FLAG_OPEN 0x0001
#define SMB_XA_FLAG_CLOSE 0x0002
@@ -1561,12 +1784,6 @@ typedef enum {
ASSERT(((s) != NULL) && ((s)->sv_magic == SMB_SERVER_MAGIC))
typedef struct {
- kstat_named_t open_files;
- kstat_named_t open_trees;
- kstat_named_t open_users;
-} smb_server_stats_t;
-
-typedef struct {
kthread_t *ld_kth;
kt_did_t ld_ktdid;
ksocket_t ld_so;
@@ -1584,12 +1801,12 @@ typedef enum smb_server_state {
SMB_SERVER_STATE_SENTINEL
} smb_server_state_t;
-#define SMB_SERVER_STATE_VALID(S) \
- ASSERT(((S) == SMB_SERVER_STATE_CREATED) || \
- ((S) == SMB_SERVER_STATE_CONFIGURED) || \
- ((S) == SMB_SERVER_STATE_RUNNING) || \
- ((S) == SMB_SERVER_STATE_STOPPING) || \
- ((S) == SMB_SERVER_STATE_DELETING))
+#define SMB_SERVER_STATE_VALID(S) \
+ ASSERT(((S) == SMB_SERVER_STATE_CREATED) || \
+ ((S) == SMB_SERVER_STATE_CONFIGURED) || \
+ ((S) == SMB_SERVER_STATE_RUNNING) || \
+ ((S) == SMB_SERVER_STATE_STOPPING) || \
+ ((S) == SMB_SERVER_STATE_DELETING))
typedef struct smb_server {
uint32_t sv_magic;
@@ -1606,22 +1823,14 @@ typedef struct smb_server {
smb_kmod_cfg_t sv_cfg;
smb_session_t *sv_session;
- kstat_t *sv_ksp;
- kmutex_t sv_ksp_mutex;
- char sv_ksp_name[KSTAT_STRLEN];
- smb_server_stats_t sv_ks_data;
-
door_handle_t sv_lmshrd;
int32_t si_gmtoff;
smb_thread_t si_thread_timers;
- smb_thread_t si_thread_unexport;
taskq_t *sv_thread_pool;
- kmem_cache_t *si_cache_unexport;
- kmem_cache_t *si_cache_vfs;
kmem_cache_t *si_cache_request;
kmem_cache_t *si_cache_session;
kmem_cache_t *si_cache_user;
@@ -1631,15 +1840,23 @@ typedef struct smb_server {
kmem_cache_t *si_cache_opipe;
kmem_cache_t *si_cache_event;
- volatile uint32_t sv_open_trees;
- volatile uint32_t sv_open_files;
- volatile uint32_t sv_open_users;
-
smb_node_t *si_root_smb_node;
- smb_llist_t sv_vfs_list;
smb_llist_t sv_opipe_list;
smb_llist_t sv_event_list;
- smb_slist_t sv_unexport_list;
+
+ /* Statistics */
+ hrtime_t sv_start_time;
+ kstat_t *sv_ksp;
+ volatile uint32_t sv_nbt_sess;
+ volatile uint32_t sv_tcp_sess;
+ volatile uint32_t sv_users;
+ volatile uint32_t sv_trees;
+ volatile uint32_t sv_files;
+ volatile uint32_t sv_pipes;
+ volatile uint64_t sv_txb;
+ volatile uint64_t sv_rxb;
+ volatile uint64_t sv_nreq;
+ smb_srqueue_t sv_srqueue;
} smb_server_t;
#define SMB_EVENT_MAGIC 0x45564E54 /* EVNT */
@@ -1675,14 +1892,59 @@ typedef struct smb_tsd {
} smb_tsd_t;
typedef struct smb_disp_entry {
- smb_sdrc_t (*sdt_pre_op)(smb_request_t *);
- smb_sdrc_t (*sdt_function)(smb_request_t *);
- void (*sdt_post_op)(smb_request_t *);
- char sdt_dialect;
- unsigned char sdt_flags;
- kstat_named_t sdt_dispatch_stats; /* invocations */
+ char sdt_name[KSTAT_STRLEN];
+ smb_sdrc_t (*sdt_pre_op)(smb_request_t *);
+ smb_sdrc_t (*sdt_function)(smb_request_t *);
+ void (*sdt_post_op)(smb_request_t *);
+ uint8_t sdt_com;
+ char sdt_dialect;
+ uint8_t sdt_flags;
+ volatile uint64_t sdt_txb;
+ volatile uint64_t sdt_rxb;
+ smb_latency_t sdt_lat;
} smb_disp_entry_t;
+typedef struct smb_xlate {
+ int code;
+ char *str;
+} smb_xlate_t;
+
+typedef struct smb_export {
+ kmutex_t e_mutex;
+ boolean_t e_ready;
+ smb_llist_t e_vfs_list;
+ smb_avl_t e_share_avl;
+ smb_slist_t e_unexport_list;
+
+ kmem_cache_t *e_cache_share;
+ kmem_cache_t *e_cache_vfs;
+ kmem_cache_t *e_cache_unexport;
+
+ smb_thread_t e_unexport_thread;
+} smb_export_t;
+
+/*
+ * This structure is a helper for building RAP NetShareEnum response
+ *
+ * es_posix_uid UID of the user requesting the shares list which
+ * is used to detect if the user has any autohome
+ * es_bufsize size of the response buffer
+ * es_buf pointer to the response buffer
+ * es_ntotal total number of shares exported by server which
+ * their OEM names is less then 13 chars
+ * es_nsent number of shares that can fit in the specified buffer
+ * es_datasize actual data size (share's data) which was encoded
+ * in the response buffer
+ */
+typedef struct smb_enumshare_info {
+ uid_t es_posix_uid;
+ uint16_t es_bufsize;
+ char *es_buf;
+ uint16_t es_ntotal;
+ uint16_t es_nsent;
+ uint16_t es_datasize;
+} smb_enumshare_info_t;
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/smbsrv/smb_share.h b/usr/src/uts/common/smbsrv/smb_share.h
index 679a740d81..fcfe4c4e26 100644
--- a/usr/src/uts/common/smbsrv/smb_share.h
+++ b/usr/src/uts/common/smbsrv/smb_share.h
@@ -18,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMB_SHARE_H
@@ -30,19 +31,21 @@
#include <smbsrv/smb_inet.h>
#include <smbsrv/hash_table.h>
#include <smbsrv/wintypes.h>
-#include <smbsrv/lmerr.h>
-#include <smbsrv/smb_door.h>
+#include <smb/lmerr.h>
#ifndef _KERNEL
#include <libshare.h>
-#else
-#include <sys/door.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
+#define SMB_CVOL "/var/smb/cvol"
+#define SMB_SYSROOT SMB_CVOL "/windows"
+#define SMB_SYSTEM32 SMB_SYSROOT "/system32"
+#define SMB_VSS SMB_SYSTEM32 "/vss"
+
/*
* Share Properties:
*
@@ -82,15 +85,11 @@ extern "C" {
#define SHOPT_RW "rw"
#define SHOPT_NONE "none"
#define SHOPT_DFSROOT "dfsroot"
+#define SHOPT_DESCRIPTION "description"
#define SMB_DEFAULT_SHARE_GROUP "smb"
#define SMB_PROTOCOL_NAME "smb"
-#define SMB_SHR_MAP 0
-#define SMB_SHR_UNMAP 1
-#define SMB_SHR_DISP_CONT_STR "continue"
-#define SMB_SHR_DISP_TERM_STR "terminate"
-
/*
* RAP protocol share related commands only understand
* share names in OEM format and there is a 13 char size
@@ -139,12 +138,7 @@ extern "C" {
* SMB_SHRF_TRANS Transient share
* SMB_SHRF_PERM Permanent share
* SMB_SHRF_AUTOHOME Autohome share.
- * SMB_SHRF_LONGNAME Share name in OEM is longer than 13 chars
* SMB_SHRF_ADMIN Admin share
- * SMB_SHRF_MAP Map command is specified
- * SMB_SHRF_UNMAP Unmap command is specified
- * SMB_SHRF_DISP_TERM Disposition is set to terminate
- * SMB_SHRF_EXEC_MASK All of the exec bits
*
* All autohome shares are transient but not all transient shares are autohome.
* IPC$ and drive letter shares (e.g. d$, e$, etc) are transient but
@@ -174,16 +168,10 @@ extern "C" {
/*
* Runtime flags
*/
-#define SMB_SHRF_MAP 0x00010000
-#define SMB_SHRF_UNMAP 0x00020000
-#define SMB_SHRF_DISP_TERM 0x00040000
-#define SMB_SHRF_EXEC_MASK 0x00070000
-
#define SMB_SHRF_ADMIN 0x01000000
#define SMB_SHRF_TRANS 0x10000000
#define SMB_SHRF_PERM 0x20000000
#define SMB_SHRF_AUTOHOME 0x40000000
-#define SMB_SHRF_LONGNAME 0x80000000
/*
* refcnt is currently only used for autohome. autohome needs a refcnt
@@ -196,7 +184,6 @@ typedef struct smb_share {
char shr_path[MAXPATHLEN];
char shr_cmnt[SMB_SHARE_CMNT_MAX];
char shr_container[MAXPATHLEN];
- char shr_oemname[SMB_SHARE_OEMNAME_MAX];
uint32_t shr_flags;
uint32_t shr_type;
uint32_t shr_refcnt;
@@ -220,37 +207,16 @@ typedef struct smb_shrlist {
smb_share_t sl_shares[LMSHARES_PER_REQUEST];
} smb_shrlist_t;
-/*
- * This structure is a helper for building NetShareEnum response
- * in user space and send it back down to kernel.
- *
- * es_posix_uid UID of the user requesting the shares list which
- * is used to detect if the user has any autohome
- * es_bufsize size of the response buffer
- * es_buf pointer to the response buffer
- * es_ntotal total number of shares exported by server which
- * their OEM names is less then 13 chars
- * es_nsent number of shares that can fit in the specified buffer
- * es_datasize actual data size (share's data) which was encoded
- * in the response buffer
- */
-typedef struct smb_enumshare_info {
- uid_t es_posix_uid;
- uint16_t es_bufsize;
- char *es_buf;
- uint16_t es_ntotal;
- uint16_t es_nsent;
- uint16_t es_datasize;
-} smb_enumshare_info_t;
-
-typedef struct smb_execsub_info {
+typedef struct smb_shr_execinfo {
+ char *e_sharename;
char *e_winname;
char *e_userdom;
smb_inaddr_t e_srv_ipaddr;
smb_inaddr_t e_cli_ipaddr;
char *e_cli_netbiosname;
uid_t e_uid;
-} smb_execsub_info_t;
+ int e_type;
+} smb_shr_execinfo_t;
/*
* LanMan share API (for both SMB kernel module and GUI/CLI sub-system)
@@ -278,8 +244,8 @@ uint32_t smb_shr_rename(char *, char *);
uint32_t smb_shr_get(char *, smb_share_t *);
uint32_t smb_shr_modify(smb_share_t *);
uint32_t smb_shr_get_realpath(const char *, char *, int);
-void smb_shr_hostaccess(smb_share_t *, smb_inaddr_t *);
-int smb_shr_exec(char *, smb_execsub_info_t *, int);
+uint32_t smb_shr_hostaccess(smb_inaddr_t *, char *, char *, char *, uint32_t);
+int smb_shr_exec(smb_shr_execinfo_t *);
boolean_t smb_shr_exists(char *);
int smb_shr_is_special(char *);
@@ -303,53 +269,8 @@ uint32_t smb_share_rename(char *, char *);
uint32_t smb_share_create(smb_share_t *);
uint32_t smb_share_modify(smb_share_t *);
-#else
-
-door_handle_t smb_kshare_init(int);
-void smb_kshare_fini(door_handle_t);
-uint32_t smb_kshare_getinfo(door_handle_t, char *, smb_share_t *,
- smb_inaddr_t *);
-int smb_kshare_upcall(door_handle_t, void *, boolean_t);
-uint32_t smb_kshare_enum(door_handle_t, smb_enumshare_info_t *);
-uint32_t smb_kshare_exec(door_handle_t, char *, smb_execsub_info_t *, int);
-
#endif
-#define SMB_SHARE_DNAME "/var/run/smb_share_door"
-#define SMB_SHARE_DSIZE (65 * 1024)
-
-/*
- * Door interface
- *
- * Define door operations
- */
-#define SMB_SHROP_NUM_SHARES 1
-#define SMB_SHROP_DELETE 2
-#define SMB_SHROP_RENAME 3
-#define SMB_SHROP_GETINFO 4
-#define SMB_SHROP_ADD 5
-#define SMB_SHROP_MODIFY 6
-#define SMB_SHROP_LIST 7
-#define SMB_SHROP_ENUM 8
-#define SMB_SHROP_EXEC 9
-
-/*
- * Door server status
- *
- * SMB_SHARE_DERROR is returned by the door server if there is problem
- * with marshalling/unmarshalling. Otherwise, SMB_SHARE_DSUCCESS is
- * returned.
- *
- */
-#define SMB_SHARE_DSUCCESS 0
-#define SMB_SHARE_DERROR -1
-
-void smb_dr_get_share(smb_dr_ctx_t *, smb_share_t *);
-void smb_dr_put_share(smb_dr_ctx_t *, smb_share_t *);
-
-void smb_share_door_clnt_init(void);
-void smb_share_door_clnt_fini(void);
-
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/smbsrv/smb_sid.h b/usr/src/uts/common/smbsrv/smb_sid.h
index cff9348df3..6bc2f0d6d5 100644
--- a/usr/src/uts/common/smbsrv/smb_sid.h
+++ b/usr/src/uts/common/smbsrv/smb_sid.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMB_SID_H
@@ -285,8 +284,8 @@ boolean_t smb_sid_islocal(smb_sid_t *);
boolean_t smb_sid_indomain(smb_sid_t *, smb_sid_t *);
void smb_sid_free(smb_sid_t *);
int smb_sid_splitstr(char *, uint32_t *);
-void smb_sid_tostr(smb_sid_t *, char *);
-smb_sid_t *smb_sid_fromstr(char *);
+void smb_sid_tostr(const smb_sid_t *, char *);
+smb_sid_t *smb_sid_fromstr(const char *);
char *smb_sid_type2str(uint16_t);
void smb_ids_free(smb_ids_t *);
diff --git a/usr/src/uts/common/smbsrv/smb_xdr.h b/usr/src/uts/common/smbsrv/smb_xdr.h
index cebedb39c4..34c140fc6b 100644
--- a/usr/src/uts/common/smbsrv/smb_xdr.h
+++ b/usr/src/uts/common/smbsrv/smb_xdr.h
@@ -37,24 +37,15 @@ extern "C" {
#include <smbsrv/smbinfo.h>
#include <smbsrv/smb_ioctl.h>
#include <smbsrv/smb_sid.h>
-#include <smbsrv/wintypes.h>
+#include <smbsrv/smb_share.h>
#include <smbsrv/smb_dfs.h>
-
-typedef struct smb_dr_kshare {
- int32_t k_op;
- char *k_path;
- char *k_sharename;
-} smb_dr_kshare_t;
+#include <smbsrv/wintypes.h>
#ifdef _KERNEL
#define xdr_int8_t xdr_char
#define xdr_uint8_t xdr_u_char
#define xdr_int16_t xdr_short
#define xdr_uint16_t xdr_u_short
-
-smb_dr_kshare_t *smb_share_mkabsolute(uint8_t *buf, uint32_t len);
-#else
-uint8_t *smb_kshare_mkselfrel(smb_dr_kshare_t *kshare, uint32_t *len);
#endif /* _KERNEL */
/* null-terminated string */
@@ -184,7 +175,6 @@ typedef struct smb_netsvc {
bool_t smb_buf32_xdr(XDR *, smb_buf32_t *);
bool_t smb_string_xdr(XDR *, smb_string_t *);
-bool_t smb_dr_kshare_xdr(XDR *, smb_dr_kshare_t *);
bool_t smb_inaddr_xdr(XDR *, smb_inaddr_t *);
const char *smb_doorhdr_opname(uint32_t);
@@ -312,6 +302,17 @@ typedef struct dfs_referral_response {
bool_t dfs_referral_query_xdr(XDR *, dfs_referral_query_t *);
bool_t dfs_referral_response_xdr(XDR *, dfs_referral_response_t *);
+typedef struct smb_shr_hostaccess_query {
+ char *shq_none;
+ char *shq_ro;
+ char *shq_rw;
+ uint32_t shq_flag;
+ smb_inaddr_t shq_ipaddr;
+} smb_shr_hostaccess_query_t;
+
+bool_t smb_shr_hostaccess_query_xdr(XDR *, smb_shr_hostaccess_query_t *);
+bool_t smb_shr_execinfo_xdr(XDR *, smb_shr_execinfo_t *);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/smbsrv/smbinfo.h b/usr/src/uts/common/smbsrv/smbinfo.h
index 2cfa02a6a6..aef25b599f 100644
--- a/usr/src/uts/common/smbsrv/smbinfo.h
+++ b/usr/src/uts/common/smbsrv/smbinfo.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMBSRV_SMBINFO_H
@@ -119,6 +118,7 @@ typedef struct smb_kmod_cfg {
int32_t skc_sync_enable;
int32_t skc_secmode;
int32_t skc_ipv6_enable;
+ uint32_t skc_execflags;
smb_version_t skc_version;
char skc_nbdomain[NETBIOS_NAME_SZ];
char skc_fqdn[SMB_PI_MAX_DOMAIN];
@@ -126,6 +126,13 @@ typedef struct smb_kmod_cfg {
char skc_system_comment[SMB_PI_MAX_COMMENT];
} smb_kmod_cfg_t;
+#define SMB_EXEC_MAP 0x01
+#define SMB_EXEC_UNMAP 0x02
+#define SMB_EXEC_TERM 0x04
+
+#define SMB_EXEC_DISP_CONTINUE "continue"
+#define SMB_EXEC_DISP_TERMINATE "terminate"
+
/*
* Major version numbers
*/
diff --git a/usr/src/uts/common/smbsrv/string.h b/usr/src/uts/common/smbsrv/string.h
index 21f9e98afc..ceeb8accde 100644
--- a/usr/src/uts/common/smbsrv/string.h
+++ b/usr/src/uts/common/smbsrv/string.h
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SMBSRV_STRING_H
@@ -124,9 +123,8 @@ int smb_isstrupr(const char *);
int smb_isstrlwr(const char *);
int smb_strcasecmp(const char *, const char *, size_t);
-int smb_match(char *patn, char *str);
-int smb_match_ci(char *patn, char *str);
-int smb_match83(char *patn, char *str83);
+boolean_t smb_match(char *, char *);
+boolean_t smb_match_ci(char *, char *);
size_t smb_mbstowcs(smb_wchar_t *, const char *, size_t);
size_t smb_wcstombs(char *, const smb_wchar_t *, size_t);