Change 1120940 on 2015/02/25 by justing@justing_ns1_likewise

	Fix hang in "lwsm shutdown".
	
	main/lwio/client/ntfileapictx.c:
		When releasing an AsyncCancelContext, NULL the caller's
		pointer irrespective of the reference count.  This avoids
		confusing client code into thinking there is still an
		outstanding operation that needs to be canceled and
		waited on (e.g. in rpc__smb_socket_destroy()).

Change 1120648 on 2015/02/24 by justing@justing_ns1_likewise

	Fix race conditions in the SrvTimer API.
	
	lwio/server/srv/include/elementsapi.h:
	lwio/server/srv/elements/durable.c:
	lwio/server/srv/elements/srvtimer.c:
	lwio/server/srv/protocols/smb1/lockx.c:
	lwio/server/srv/protocols/smb1/oplock.c:
	lwio/server/srv/protocols/smb2/libmain.c:
	lwio/server/srv/protocols/smb2/oplock.c:
		Change SrvTimerRelease to take a PSRV_TIMER_REQUEST *.
		This ensures that all callers have their pointer to
		the timer NULLed after dropping their reference.
		Most callers were already doing this manually, but
		not all.
	
	lwio/server/srv/elements/structs.h:
	lwio/server/srv/elements/srvtimer.c:
		Convert the SrvTimer code over to using standard
		Likewise lists rather than a home grown doubly
		linked list.
	
		When insertion sorting new timer elements, search
		from tail to head.  This optimizes for the common
		case of queuing a timed interim response timer.
		These entries are created for every read, write,
		or create, and always expire 500ms in the future.
		In this environment, new entries almost always need
		to be inserted at the tail which is now O(1) instead
		of O(n).
	
		When canceling a timer request, use the O(1)
		LwListElementIsLinked() API rather than an O(N)
		search to determine if the request is still active
		(in the queue of pending timer requests).
	
		Fix race conditions in SrvTimerMain() caused by failure
		to reassess the current environment after it wakes up.
	
	lwio/server/srv/elements/durable.c:
	lwio/server/srv/elements/srvtimer.c:
	lwio/server/srv/protocols/smb1/lockx.c:
	lwio/server/srv/protocols/smb1/oplock.c:
	lwio/server/srv/protocols/smb2/libmain.c:
	lwio/server/srv/protocols/smb2/oplock.c:
		Audit all consumers of the SrvTimer API for cancel
		races.  All clients, with the exception of the
		durable handle code, failed to check the return
		status of SrvTimerCancelRequest() to avoid a double
		refcount drop when hitting the race of a timer that
		has been fired, but is blocking on the same lock that
		the "canceller" is holding.

Change 1120630 on 2015/02/24 by justing@justing_ns1_likewise

	Allow Likewise lists to be traversed in reverse.
	
	lwbase/include/lw/list.h:
		Fix a typo in a comment.
	
		Add LwListElementIsLinked() which returns
		true if a list element is currently in a list.
	
	lwbase/include/lw/list.h:
	lwbase/src/list.c:
		Add LwListTraverseReverse().

Change 1120625 on 2015/02/24 by justing@justing_ns1_likewise

	Fix wakeup race condition in DCERPC socket teardown
	code.
	
	dcerpc/ncklib/comsoc_smb.c:
		Verify after waiting for a condition that the
		condition has actually occurred.  Since there is
		only one condition variable used in the comsoc_smb
		code, it is possible for the condition variable to
		be signaled for an event unrelated to the one being
		waited for.

Change 1119901 on 2015/02/20 by justing@justing_ns1_likewise

	Implement credit fairness in Likewise.
	
	lwio/etc/srv.reg.in:
	lwio/server/srv/elements/config.c:
	lwio/server/srv/elements/libmain.c:
		Add a new registry key for smb2: GlobalCreditReserve.
		This is a reserve pool of credit which is used to ensure
		a new connection can be establish with at least 4 credits.
		This reserve credit is returned as soon as global credit
		is reaped from existing connections.
	
	lwio/server/srv/elements/config.c:
	lwio/server/srv/elements/prototypes.h:
		Remove accessors and locking for config data which never
		changes.  Convert clients to just access the variables
		directly.
	
	lwio/server/srv/elements/defs.h:
		Default the credit reserve to 1024.
	
		Default to allowing a client's credit window to grow at
		1MB per command exchange.
	
	lwio/server/srv/elements/creditor.c:
	lwio/server/srv/elements/structs.h:
	lwio/server/srv/include/elementsapi.h:
		Keep credit freed by a client local to the per-connection
		credit manager until a reap is triggered.
	
		Simplify credit growth scheme.  Provide the client whatever
		they request up to a minimum value (default 512), then grow
		the window by at most 1MB per-round.
	
		Keep a global serial number which is incremented each time
		a credit shortage is detected.  A credit shortage is defined
		as the inability of a client to acquire enough credit to
		meet the fairness level (#GlobalCredits / #Connections) or
		having to tap into the credit reserve.
	
		When allocating credit for a client, if a credit shortage
		has occurred since the last allocation, shrink the client's
		window to the global client average before attempting to
		acquire more global credit.
	
		When a credit shortage occurs, fire off a task that reaps
		free credit for all existing connections.  This ensures
		that idle connections cannot hold credit that is not being
		used.
	
	lwio/server/srv/elements/libmain.c:
	lwio/server/srv/elements/prototypes.h:
		Initialize the credit reaper task.
	
	lwio/server/srv/elements/prototypes.h:
	lwio/server/srv/elements/srvconnection.c:
		Update the per-client credit average when connections
		are added and removed.

Change 1119017 on 2015/02/16 by justing@justing_ns1_likewise

	No functional changes.
	
	lwio/server/srv/elements/creditor.c:
		Staticize two private functions.
	
	lwio/server/srv/elements/structs.h:
		Remove two unused fields in SRV_CREDITOR.

Change 1118197 on 2015/02/12 by daveb@daveb.p4work.shared.likwise.platform-new

	Validate pResponse->pHeader before dereferencing.
	Not all paths through SrvProtocolExecute_SMB_V2() 
	have a response header.

Change 1118042 on 2015/02/11 by justing@justing_ns1_likewise

	Merge //likewise/r2/... to //likewise/main/...:
	
	Change 1117210 on 2015/02/06 by justing@justing_ns1_likewise
	==============
	Fix spurious log message.
	
	lwio/server/srv/protocols/smb2/notify_request.c:
		In SrvProcessNotify_SMB_V2(), validate the correct
		return code variable when building an interim response.
	
	Change 1117336 on 2015/02/09 by justing@justing_ns1_likewise
	==============
	Simplify some logic.  No functional changes intended.
	
	lwio/server/transport/threadpool/srvsocket.c:
		In SrvSocketProcessTaskWrite(), set the writer active
		flag once instead of toggling it everytime we reacquire
		the socket lock.
	
	Change 1118018 on 2015/02/11 by justing@justing_ns1_likewise
	==============
	Close use-after-free/double-free race condition in the
	Likewise PVFS driver's handling of lease/oplock breaks.
	
	lwio/server/pvfs/scb.c:
		Modify PvfsPendOplockBreakTest() and
		PvfsAddItemPendingOplockBreakAck() to provide a consistent
		object ownership contract.  Calling either function
		transfers the responsibility for cleaning up the passed
		in completion context.
	
		Prior to this change, it was possible for the completion
		context to be freed both in PvfsPendOplockBreakTest() and
		the caller of this function if PvfsPendOplockBreakTest()
		found that the oplock/lease was already broken.  In this
		case, the completion callback would be called immediately.
		In the case of PvfsPendOplockBreakTest(), this callback
		also freed the context.
	
		PvfsPendOplockBreakAck() had the referse problem of 
		leaking the callback context if an immediate completion
		was possible.
	
	lwio/server/pvfs/fileAllocationInfo.c:
	lwio/server/pvfs/fileDispositionInfo.c:
	lwio/server/pvfs/fileEndOfFileInfo.c:
	lwio/server/pvfs/fileRenameInfo.c:
	lwio/server/pvfs/lock.c:
	lwio/server/pvfs/oplock.c:
	lwio/server/pvfs/read.c:
	lwio/server/pvfs/write.c:
		Remove duplicate free of completion context if the context
		has been passed to either of PvfsPendOplockBreakTest() or
		PvfsPendOplockBreakAck().
	
		Remove unnecessary casts.
	
	lwio/server/pvfs/pvfs.h:
	lwio/server/pvfs/scb.c:
	lwio/server/pvfs/oplock.c:
		Change PvfsOplockPendingBreakIfLocked() and 
		PvfsFreeOplockBreakTestContext() to take handles
		(void *) so that casts to
		PPVFS_OPLOCK_PENDING_COMPLETION_CALLBACK and
		PPVFS_OPLOCK_PENDING_COMPLETION_FREE_CTX can be
		avoided.

Change 1117839 on 2015/02/10 by daveb@daveb.p4work.shared.likwise.platform-new

	Add -e option to give everyone full access

Change 1116548 on 2015/02/03 by daveb@daveb.p4work.shared.likwise.platform-new

	Allow session logoff requests to be signed.
	
	Previously, SrvProcessLogoff_SMB_V2() released the session from
	the smb2 Exec Context (PSRV_EXEC_CONTEXT_SMB_V2).
	Since, the session now maintans the signing keys, a logoff response
	could not be signed.
	
	After session logoff, do not release session from 
	PSRV_EXEC_CONTEXT_SMB_V2 and modify SrvConnection2FindSession_SMB_V2()
	to fail a session lookup if the located session is in "rundown".
	
	lwio/server/srv/elements/srvsession2.c
	lwio/server/srv/include/elementsapi.h
	- Rename SrvSession2IsRundown_inlock() to SrvSession2IsRundown() since
	  it does not require a lock.
	- Remove the static designation from the new/renamed 
	  SrvSession2IsRundown().
	
	lwio/server/srv/protocols/smb2/connection.c
	- If a session is located and it is in rundown then drop the
	  located session and return STATUS_USER_SESSION_DELETED.
	- Add missing BAIL_ON_NT_STATUS() that the above change requires.
	
	lwio/server/srv/protocols/smb2/libmain.c
	- Fix interim response bufferUsed calculation error.
	
	lwio/server/srv/protocols/smb2/logoff.c	
	- do not drop the session as described above.

Change 1115772 on 2015/01/30 by justing@justing_ns1_likewise

	Remove internal copy of libedit.  This was missed when I originally
	purged Likewise of "bundled dependencies" that are either provided
	directly by the OS or as ports dependencies.

Change 1115694 on 2015/01/29 by justing@justing_ns1_likewise

	Remove #if 0'ed code.

Change 1115674 on 2015/01/29 by justing@justing_ns1_likewise

	Rather than return STATUS_INSUFFICIENT_RESOURCES for an async
	command that terminates a chain (forcing the client to resend
	that async command againwithout chaining), terminate the
	response chain with an interim response.
	
	This reduces network chatter for notify requests from Windows 7.
	
	lwio/server/srv/protocols/smb2/prototypes.h:
	lwio/server/srv/protocols/smb2/libmain.c:
		Re-factor common code for transmitting interim responses
		from the lock and notify sections of
		SrvProcessRequestSpecific_SMB_V2() into
		SrvProtocolExecute_SMB_V2()
	
		Make SrvBuildInterimResponse_SMB_V2() a private
		method.  Have clients use either SrvInterimResponse_SMB_V2()
		or SrvTimedINterimReponse_SMB_V2().  The first will
		terminate any existing reponse chain with an interim
		response.  The second will send the interim response
		as a separate packet, after the specified delay (e.g.
		for a tardy read or write which otherwise wouldn't send
		an interim response at all).
	
	lwio/server/srv/protocols/smb2/lock.c:
	lwio/server/srv/protocols/smb2/notify_request.c:
		Use the new SrvBuildInterimReponse_SMB_V2() API.
	
		Only issue STATUS_INSUFFICIENT_RESOURCES if the
		command is not at the end of the chain.

Change 1115668 on 2015/01/29 by daveb@daveb.p4work.shared.likwise.platform-new

	Cleanup close processing.
	
	Remove multiple variables tracking the open state
	from SRV_PROTOCOL_EXEC_CONTEXT:
	- FileOpenStatus: records the file open status
	- bFileClosed: recorded if the file was closed or not.
	Remove bFileClosed and use FileOpenStatus == STATUS_SUCCESS
	to indicate the file is opened and any other value to
	indicate that it is closed.
	
	Remove redundant session ID and tree ID validation from 
	SrvProcessClose_SMB_V2(); these parameters are fully 
	validated by SrvConnection2FindSession_SMB_V2() and
	SrvSession2FindTree_SMB_V2().
	
	Ensure that a file once successfully opened is
	marked as STATUS_FILE_CLOSED whenever SrvProcessClose_SMB_V2()
	is executed; a file not successfully opened will already have 
	FileOpenStatus != STATUS_SUCCESS.

Change 1115439 on 2015/01/28 by justing@justing_ns1_likewise

	Per MS-SMB2 3.3.5.2.7.2:
	
	When the current request requires a FileId and the previous request
	either contains or generates a FileId, if the previous request fails
	with an error, the server SHOULD fail the current request with the
	same error code returned by the previous request.

Change 1115420 on 2015/01/28 by justing@justing_ns1_likewise

	lwio/server/srv/protocols/smb2/lock.c:
		Fail requests with 0 lock/unlock bits set by returning
		STATUS_INVALID_PARAMETER.

Change 1115345 on 2015/01/28 by justing@justing_ns1_likewise

	Fail long running, async commands in chained requests with
	STATUS_INSUFFICIENT_RESOURCES.  This will cause the client to
	send the command unchained, guaranteeing that responses to other
	commands in the chain are not adversly delayed.
	
	I have yet to see a client do this, but since we don't take other
	measures to complete partial chains when hitting a lock or notify,
	it is better to have STATUS_INSUFFICIENT_RESOURCES visible on the
	wire than try and to debug why a client reported a timeout.
	
	lwio/server/srv/protocols/smb2/lock.c:
	lwio/server/srv/protocols/smb2/notify_request.c:
		Return STATUS_INSUFFICIENT_RESOURCES for chained lock
		and notify requests.
	
	lwio/server/srv/protocols/smb2/lock.c:
		Clean up validation code so we can easily determine whether
		the operation will take a long time or not.  Unlock requests
		can be chained.  We also allow lock requests with "fail
		immediately" set.
	
		Rather than error out if "fail immediately" is set on an
		unlock request, just ignore it as is allowed by the spec.

Change 1115343 on 2015/01/28 by justing@justing_ns1_likewise

	Fix SMB1 responses for clients requesting DOS error messages which
	was broken in 1114348.
	
	lwio/server/srv/protocols/smb1/libmain.c:
	lwio/server/srv/protocols/smb1/prototypes.h:
	lwio/server/srv/protocols/smb1/sessionsetup.c:
	lwio/server/srv/protocols/smb1/wire.c:
		Add SrvUpdateHeaderError_SMB_V1() API and use it in the
		few places that change the error code in a reply message
		after the SMB header is initially marshalled.

Change 1115335 on 2015/01/28 by justing@justing_ns1_likewise

	lwio/server/srv/protocols/api/libmain.c:
		Restore connection close on STATUS_INSUFFICIENT_RESOURCES.
		If we've gotten to the outer processing loop, attempts
		to send a response with this status have failed, so closing
		the connection is the only way to inform the client that
		something has gone wrong.

Change 1115329 on 2015/01/28 by justing@justing_ns1_likewise

	No functional changes.
	
	lwio/server/srv/protocols/smb2/libmain.c:
		Remove initialized but unused variable.

Change 1115234 on 2015/01/27 by daveb@daveb.p4work.shared.likwise.platform-new

	Correctly Handle previous session ID during session setup.
	
	If a session setup request specifies a previous session 
	ID (prevSessionId) and the prevSessionID maps to a valid
	session created by the same user and the new session ID
	does not equal the previous then the previous session
	must be destroy after the new session is successfully
	created.
	
	lwbase/src/security-token.c
	lwbase/include/lw/security-api.h
	- Define RtlAreUserSidsEqual() to compare the
	  user SIDS of two access tokens.
	
	lwio/server/srv/elements/srvioapi.c
	lwio/server/srv/include/elementsapi.h
	- Define SrvIoSecurityContextUserEqual to compare
	  two create security contexts (_IO_CREATE_SECURITY_CONTEXT); 
	  this is a necessary wraper for RtlAreUserSidsEqual() as
	  _IO_CREATE_SECURITY_CONTEXT is opaque.
	
	lwio/server/srv/elements/srvsession2.c
	lwio/server/srv/include/elementsapi.h
	- Define SrvSession2Lookup() to lookup a session in the 
	  global session hash.
	
	lwio/server/srv/protocols/smb2/session_setup.c
	- If the previous session ID is not zero then look it
	  up via SrvSession2Lookup().
	- Kill the previous session if the conditions defined above are met.
	- Change session ID logging to hex.
	
	lwio/server/srv/elements/includes.h
	- Include lw/security-api.h for RtlAreUserSidsEqual()
	
	lwio/server/srv/elements/MakeKitBuild
	- Add dependency for lw/security-api.h

Change 1114901 on 2015/01/26 by justing@justing_ns1_likewise

	lwio/server/srv/protocols/api/libmain.c:
		Do not terminate a connection on STATUS_INSUFFICIENT_RESOURCES.
		This will be used in the future to terminate chained
		requests that include requests that must be processed
		asynchronously.

Change 1114546 on 2015/01/23 by justing@justing_ns1_likewise

	Further limit when a packet is signed.
	
	lwio/server/srv/protocols/smb2/libmain.c:
		Safeguard against requests that set the SMB2_FLAGS_SIGNED
		flag even though a signing key has not been negotiated.

Change 1114524 on 2015/01/23 by justing@justing_ns1_likewise

	Do not sign oplock/lease break notifications.
	
	lwio/server/srv/protocols/smb2/libmain.c:
		Do not sign responses that have a zeroed session
		id.  This should only happen for lease/oplock break
		notifications.
	
		Note that the check for a NULL session isn't
		sufficient for the oplock/lease break case since
		they are processed via an internal request (exec
		context) which has the session of the current
		holder of the oplock.

Change 1114498 on 2015/01/23 by justing@justing_ns1_likewise

	Fixup notify command handling so that it conforms to the
	rules for chained, related command proccessing and avoids
	the overhead of tearing down and rebuilding an exec context.
	
	This is change is required now that we setup the chain
	offset and sign responses when they are complete instead
	of reaching back one entry in the chain to update the
	chain offset when a subsequent command completes.
	
	lwio/server/srv/protocols/smb2/MakeKitBuild:
	lwio/server/srv/protocols/smb2/notify_state.c:
		Remove now unused notify_state.c.
	
	lwio/server/srv/protocols/smb2/cancel.c:
		Have COM2_NOTIFY uses the standard exec context
		cancel callback.
	
	lwio/server/srv/protocols/smb2/libmain.c:
		Stall the exec context when a notify request
		returns STATUS_PENDING (just like all other
		blocking commands).
	
	lwio/server/srv/protocols/smb2/notify_request.c:
	lwio/server/srv/protocols/smb2/notify_state.c:
	lwio/server/srv/protocols/smb2/structs.h:
		Combine NOTIFY_REQUEST_STATE and NOTIFY_STATE.
	
		When a notify request blocks, block the current
		exec context instead of releasing it, then
		rebuilding it when the notify completes.
	
	lwio/server/srv/protocols/smb2/read.c:
		Minor style fix.

Change 1114348 on 2015/01/23 by justing@justing_ns1_likewise

	Audit and correct issues with multiple SMB2 sessions in a single
	connection and packet signing.
	
	lwio/server/include/smbwire.h:
	lwio/server/rdr/socket.c:
	lwio/server/smbcommon/packet.c:
	lwio/server/srv/protocols/smb2/notify_state.c:
	lwio/server/srv/protocols/smb2/oplock.c:
	lwio/server/srv/protocols/smb2/wire.c:
	lwio/server/srv/protocols/smb2/write.c:
		Remove allowSignature, haveSignature, and useSmbStatus
		from SMB_PACKET.  These are now detected via the
		Connection, Session, or incoming request as needed.
	
	lwio/server/include/smbwire.h:
	lwio/server/smbcommon/packet.c:
	lwio/server/srv/protocols/smb1/readx.c:
	lwio/server/srv/protocols/smb2/create.c:
	lwio/server/srv/protocols/smb2/libmain.c:
	lwio/server/srv/protocols/smb2/negotiate.c:
	lwio/server/srv/protocols/smb2/notify_state.c:
	lwio/server/srv/protocols/smb2/oplock.c:
	lwio/server/srv/protocols/smb2/read.c:
		SMBPacketSign() and SMBPacketMarshallFooter() can't
		fail.  Have them return VOID.
	
	lwio/server/include/smbwire.h:
	lwio/server/srv/protocols/smb2/prototypes.h:
	lwio/server/smbcommon/packet.c:
	lwio/server/srv/protocols/smb2/wire.c:
		Move SMB2PacketVerifySignature to smb2/wire.c and
		have it operate on an individual message, not a
		full chain.  This ensures it will work if a chain
		references different sessions.
	
	lwio/server/rdr/close.c:
	lwio/server/rdr/connect.c:
	lwio/server/rdr/create.c:
	lwio/server/rdr/dfs1.c:
	lwio/server/rdr/querydir.c:
	lwio/server/rdr/queryfs.c:
	lwio/server/rdr/queryinfo.c:
	lwio/server/rdr/read.c:
	lwio/server/rdr/security.c:
	lwio/server/rdr/session.c:
	lwio/server/rdr/setinfo.c:
	lwio/server/rdr/socket.c:
	lwio/server/rdr/tree.c:
	lwio/server/rdr/write.c:
		Adapt to API changes.
	
	lwio/server/rdr/connect.c:
	lwio/server/rdr/socket.h:
	lwio/server/rdr/socket.c:
	lwio/server/rdr/structs.h:
		Remove nonsensical verification of incoming SMB1
		signatures that likely resulted in the RDR code
		always ignoring security signatures.
	
	lwio/server/smbcommon/MakeKitBuild:
	lwio/server/smbcommon/includes.h:
		The code referencing lwstr.h APIs has been removed
		from this subtree, so remove its dependency.
	
	lwio/server/srv/elements/srvconnection.c:
	lwio/server/srv/include/elementsapi.h:
	lwio/server/srv/protocols/api/transport.c:
	lwio/server/srv/protocols/smb1/sessionsetup.c:
		Add SrvConnectionSetSigningKeyIfUnset().  This is
		used on SMB1 sessions where the key from the first
		fully negotiated, non-guest, non-anonymous session
		on a connection is used for all message signing.
	
		Replace SrvConnectionISigningActive() with
		SrvConnectionShouldSign().  For SMB2, the lack of
		a session key can prevent signing from occurring,
		so the connection can't know if signing is truely
		active.  This naming convention also matches
		terminology used in the SMB2 spec.
	
		Since SrvConnectionShouldSign() can only transition
		from false to true once during the negotiate exchange,
		it is safe to execute without the connection lock.
	
	lwio/server/srv/elements/srvconnection.c:
	lwio/server/srv/elements/srvsession.c:
	lwio/server/srv/elements/srvsession2.c:
	lwio/server/srv/protocols/smb1/createx.c:
	lwio/server/srv/protocols/smb1/nttransact.c:
	lwio/server/srv/protocols/smb1/openx.c:
	lwio/server/srv/protocols/smb2/create.c:
		SrvConnectionGetNamedPipeSessionKey() ->
		SrvSession(2)GetNamedPipeSessionKey().  This ensures
		we store and use the per-session key instead of the
		connection global key which is used, on SMB1, for
		signing.
	
	lwio/server/srv/include/elementsapi.h:
	lwio/server/srv/protocols/api/transport.c:
	lwio/server/srv/protocols/smb1/sessionsetup.c:
	lwio/server/srv/protocols/smb2/negotiate.c:
		Store session keys in the session, not the connection.
	
		Add missing hungarian prefixes.
	
		Column align fields.
	
	lwio/server/srv/protocols/api/includes.h:
	lwio/server/srv/protocols/api/negotiate.c:
	lwio/server/srv/protocols/api/transport.c:
		Remove extra blank lines.
	
	lwio/server/srv/protocols/api/libmain.c:
		Close the connection when an error occurs that
		prevents us from otherwise replying to the client:
		STATUS_INTERNAL_ERROR, STATUS_INSUFFICIENT_RESOURCES,
		STATUS_INVALID_NETWORK_RESPONSE.
	
	lwio/server/srv/protocols/api/transport.c:
	lwio/server/transport/include/transportapi.h:
		Remove transport driver send prepare and check
		signature methods.  This was used to perform packet
		signing, signature verification, and SMB1 NTSTATUS
		to DOS error code conversion just before responses
		hit the wire.  However, these call happen without
		sufficient information to properly determine whether
		of not an individual command in a command chain
		must be signed or even the correct session to sign
		it with.  So all of this functionality has moved
		into the protocol specific code.
	
	lwio/server/srv/protocols/smb1/checkdir.c:
	lwio/server/srv/protocols/smb1/close.c:
	lwio/server/srv/protocols/smb1/creatdir.c:
	lwio/server/srv/protocols/smb1/createx.c:
	lwio/server/srv/protocols/smb1/deldir.c:
	lwio/server/srv/protocols/smb1/delete.c:
	lwio/server/srv/protocols/smb1/echo.c:
	lwio/server/srv/protocols/smb1/findclose2.c:
	lwio/server/srv/protocols/smb1/findfirst2.c:
	lwio/server/srv/protocols/smb1/findnext2.c:
	lwio/server/srv/protocols/smb1/flush.c:
	lwio/server/srv/protocols/smb1/libmain.c:
	lwio/server/srv/protocols/smb1/lockx.c:
	lwio/server/srv/protocols/smb1/logoff.c:
	lwio/server/srv/protocols/smb1/negotiate.c:
	lwio/server/srv/protocols/smb1/notify.c:
	lwio/server/srv/protocols/smb1/ntrename.c:
	lwio/server/srv/protocols/smb1/nttransact.c:
	lwio/server/srv/protocols/smb1/openx.c:
	lwio/server/srv/protocols/smb1/oplock.c:
	lwio/server/srv/protocols/smb1/prototypes.h:
	lwio/server/srv/protocols/smb1/queryinfo2.c:
	lwio/server/srv/protocols/smb1/readx.c:
	lwio/server/srv/protocols/smb1/rename.c:
	lwio/server/srv/protocols/smb1/sessionsetup.c:
	lwio/server/srv/protocols/smb1/setinfo.c:
	lwio/server/srv/protocols/smb1/setinfo2.c:
	lwio/server/srv/protocols/smb1/structs.h:
	lwio/server/srv/protocols/smb1/trans.c:
	lwio/server/srv/protocols/smb1/trans2qfsi.c:
	lwio/server/srv/protocols/smb1/trans2qi.c:
	lwio/server/srv/protocols/smb1/trans2sfsq.c:
	lwio/server/srv/protocols/smb1/trans2si.c:
	lwio/server/srv/protocols/smb1/treeconnect.c:
	lwio/server/srv/protocols/smb1/treedisconnect.c:
	lwio/server/srv/protocols/smb1/wire.c:
	lwio/server/srv/protocols/smb1/write.c:
	lwio/server/srv/protocols/smb1/writex.c:
		Indicate, when marshalling a response header, the client's
		choice of NT status or DOS error codes.
	
	lwio/server/srv/protocols/smb1/readx.c:
		Use the presence of a signing key on the connection object
		as indication of whether or not signing is active.
	
	lwio/server/srv/protocols/smb1/notify.c:
	lwio/server/srv/protocols/smb1/oplock.c:
		New locations for signing outgoing SMB1 packets.
	
	lwio/server/srv/protocols/smb2/MakeKitBuild:
	lwio/server/srv/protocols/smb2/includes.h:
		Add lwstr.h and hmac.h dependencies now that smb2's signing
		functions are in the smb2 directory.
	
	lwio/server/srv/protocols/smb2/libmain.c:
		Sign and align responses in a response chain as we go
		rather than reach backward to the previous message to
		update the chain offset.
	
		Simplify logic.  Convert simple switch statements to ifs.
	
		Perform session lookup and signature validation as commands
		in a chain are processed, allowing sessions to vary within
		a chain of unrelated commands.
	
	lwio/server/srv/protocols/smb2/negotiate.c:
		Properly validate and record signature settings for a new
		connection.
	
	lwio/server/srv/protocols/smb2/read.c:
		Use the signing bit on the incoming read request to determine
		if signing is active and using ZCT isn't possible.
	
	lwio/server/srv/protocols/smb2/session_setup.c:
		Simplify logic.
	
	lwio/server/srv/protocols/smb2/session_setup.c:
	lwio/server/srv/protocols/smb2/structs.h:
		Misc style fixes.
	
	lwio/server/transport/threadpool/srvsocket.c:
		Clarify a log message.

Change 1113006 on 2015/01/16 by justing@justing_ns1_likewise

	Store SMB2 session keys in the LWIO_SRV_SESSION_2 object
	so that signatures can vary between sessions operating on
	the same connection.

Change 1113005 on 2015/01/16 by justing@justing_ns1_likewise

	lwio/server/smbcommon/MakeKitBuild:
		Note lwstr.h is now a dependency.

Change 1112781 on 2015/01/15 by daveb@daveb.p4work.shared.likwise.platform-new

	Correctly handle unsupported ioctls.
	
	lwio/include/lwiofsctl.h
	lwio/server/srv/protocols/smb2/ioctl.c
	- Define and add code to return STATUS_NOT_SUPPORTED for 
	  IO_FSCTL_QUERY_NETWORK_INTERFACE_INFO and 
	  IO_FSCTL_VALIDATE_NEGOTIATE_INFO in the same fashion as 
	  IO_FSCTL_PIPE_WAIT.
	
	lwio/server/smbcommon/includes.h
	- Add #include lwstr.h to get LwByteArrayToHexStr() prototype for
	  lwio/server/smbcommon/packet.c.
	
	lwio/server/smbcommon/packet.c
	- Add trace code to debug invalid packet signing.
	
	lwio/server/srv/include/srvutils.h
	- Define SRV_NF_LOG_* family of macros that do NOT require enabling
	  SRV trace filtering; NF is for No Filter.
	
	lwio/server/srv/protocols/smb2/session_setup.c	# edit
	- Use new SRV_NF_LOG_TRACE() to log session ID to help debug.

Change 1110902 on 2015/01/06 by daveb@daveb.p4work.shared.likwise.platform-new

	Changes to support smbtorture smb2.create.gentest.gentest
	
	lwbase/include/lw/security-types.h
	Define mask of valid creat access flags as specified by MS-FSA 
	section 2.1.5.1 
	
	lwio/include/lwio/io-types.h	
	Define mask of valid create attribute flas as defined in MS-FSCC 
	section 2.6.
	
	lwio/server/pvfs/attrib.c
	lwio/server/pvfs/ccb_fileinfo.c
	Move code that declared and error if a directory attribute 
	was applied against a non-directory. This code was removed from 
	PvfspSetAttributes() and added to PvfsCcbSetFileBasicInformation().
	
	The moved code was added to allow smb2.setinfo.setinfo to pass, but
	its presence in PvfspSetAttributes() caused smb2.create.gentest.gentest
	to fail.
	
	lwio/server/pvfs/create.c
	- Test for valid create attribute flags
	- Test for valid create access mask flags
	- Ignore FILE_DELETE_CHILD when maping SMB create/open flags to
	  POSIX  open flags.

Change 1106190 on 2014/12/12 by justing@justing_ns1_likewise

	Return absolute path name for FileNameInformation class requests
	in both SMB1 and SMB2.
	
	lwio/server/srv/protocols/smb1/trans2qi.c:
	lwio/server/srv/protocols/smb2/getfileinfo.c:
		Modify SrvMarshalFileName_SMB_V1/2() to treat requests
		with a NULL pTree as requests for an absolute path.
	
		Properly set pulBytesUsed in SrvMarshalFileName_SMB_V1/2().
	
		Pass a NULL pTree to SrvMarshalFileName_SMB_V1/2() unless
		we are looking for the alternate name (DOS name).

Change 1098358 on 2014/10/21 by daveb@daveb.p4work.shared.likwise.platform-new

	P2_30620: Likewise not correctly handling compound requests
	
	The Nth (N != 0) element of a related compound request is suppose to 
	inherit the sessionID, treeID, and fileID from the first element. 
	Likewise correctly inherits if any of these fields are all 0xF; 
	this requirement is does not comply with the specification. 
	The specification states that these fields should be ignored NOT 
	compared against all 0xF.
	
	When looking up a treeID, sessionID and fileID, check the 
	SMB2_FLAGS_RELATED_OPERATION flag rather than comparing to all 0xF.

Change 1096005 on 2014/10/12 by justing@justing_ns1_likewise

	Simplify logic.  No functional changes intended.
	
	lwio/server/srv/elements/srvfinder.c:
		In SrvFinderBuildSearchPath(), remove tests for unchanging
		values from the predicate for while loops().
	
		When advancing past backslash characters, don't bother
		also testing for non-NUL.  Backslash is a non-NUL character,
		making non-NUL test redundant.

Change 1096004 on 2014/10/12 by justing@justing_ns1_likewise

	Add logging for unsupported commands.
	
	lwio/server/srv/protocols/smb1/libmain.c:
		In SrvProcessRequestSpecific_SMB_V1(), use
		BAIL_ON_NT_STATUS() to exit the default case in the
		command type switch statement.  This allows this
		failure to be captured via a tap-log.

Change 1096002 on 2014/10/12 by justing@justing_ns1_likewise

	Add infrastructure for processing SMB_STRING types in SMB1
	requests (string fields that are either ASCII or UTF-16LE
	at the client's discretion.  Modify find first2, tree
	connect, and session setup to use the new infrastructure,
	instead of assuming UTF-16LE strings.
	
	lwio/server/include/smbwire.h:
		Pass the SMB header into unmarshalling functions.
		This provides both the starting location for alignment
		validation as well as the FLAG2_UNICODE bit for determining
		the SMB string type (ASCII or UTS-16LE) provided by the
		client.
	
	lwio/server/include/smbwire.h:
	lwio/server/smbcommon/packet.c:
		Add unmarshalling functions for SMB_STRING, and UTS-16LE
		and ASCII strings.
	
		NOTE: The SMB_STRING unmarshalling function returns a
		      UTS-16LE duplicated copy of the string, to accomodate
		      any required conversion from ASCII.	
	
	lwio/server/rdr/connect.c:
	lwio/server/srv/protocols/smb1/sessionsetup.c:
	lwio/server/srv/protocols/smb1/treeconnect.c:
		Adjust to changes in unmarshalling APIs, some of which
		now return allocated/duplicated string copies.
	
	lwio/server/smbcommon/wire_session_setup.c:
		Remove module private _GetString(), the usage of which has
		been replaced by the newly created SMBUnmarshalSmbString()
		API.
	
		Conditionalize unicode alignment on the presence of unicode
		strings in the request.
	
	lwio/server/smbcommon/wire_tree_connect.c:
	lwio/server/srv/protocols/smb1/findfirst2.c:
		Convert to use SMBUnmarshal*String() APIs.
	
	lwio/server/smbcommon/wire_tree_connect.c:
		Use Align() API instead of hand rolled code.
	
	lwio/server/srv/protocols/smb1/findfirst2.c:
		Remove unnecessary alignment and comment questioning its need.
	
	lwio/server/srv/protocols/smb1/structs.h:
		Update comments to reflect that some fields now contain
		duplicated strings that must be freed when the structure
		is freed.

Change 1095769 on 2014/10/09 by justing@justing_ns1_likewise

	Honor SMB1 client requests to use SMBSTATUS codes instead of
	NTSTATUS codes.
	
	lwio/server/include/smbwire.h:
	lwio/server/srv/protocols/smb1/libmain.c:
	lwio/server/srv/protocols/smb1/notify.c:
	lwio/server/srv/protocols/smb1/oplock.c:
	lwio/server/srv/protocols/smb1/prototypes.h:
	lwio/server/srv/protocols/smb1/wire.c:
		As is done for per-request signature signing selection,
		track legacy status reporting on a per-packet/request
		basis.
	
	lwio/server/srv/protocols/api/transport.c:
		In SrvProtocolTransportDriverSendPrepare(), if
		requested by the client, convert NTSTATUS codes to
		SMBSTATUS codes just prior to packet signing and
		transmission.

Change 1095766 on 2014/10/09 by justing@justing_ns1_likewise

	Correct style.  No functional changes.
	
	lwio/server/include/smbwire.h:
		tabs -> spaces.

Change 1095765 on 2014/10/09 by justing@justing_ns1_likewise

	For consistency with all other error tables, add DOSECLASS and
	DOSERROR columns to the lwreg tables.

Change 1095764 on 2014/10/09 by justing@justing_ns1_likewise

	Expand Likewise error code tables to allow mapping to legacy
	CIFS SMB status codes.
	
	lwbase/include/lw/types.h:
		Add SMBSTATUS, DOSECLASS (DOS error class), and
		DOSERROR types.
	
	lwadvapi/include/public/lwerror-table-krb5.h:
	lwadvapi/include/public/lwerror-table.h:
	lwbase/src/error-table.h:
	lwadvapi/unthreaded/error/error-conv.c:
	lwbase/src/error-conv.c:
		Add DOSECLASS and DOSERROR columns to error tables.
	
		Default all entries to a generic error.  Use the error
		mappings defined in MS-CIFS to populate conversions that
		have well specified values.
	
	lwbase/include/MakeKitBuild:
	lwbase/include/lw/doserror.h:
		Add dos error class and error code definitions, taken from
		FreeBSD's smbfs implementation.
	
	lwbase/include/lw/base.h:
		Include doserror.h.
	
	lwbase/include/lw/ntstatus.h:
	lwbase/src/error-conv.c:
		Add LwNtStatusToSmbStatus() API.

Change 1095328 on 2014/10/07 by justing@justing_ns1_likewise

	Fix segmentation violation when receiving packets over NetBIOS.
	
	lwio/server/srv/protocols/api/libmain.c:
		In SrvProtocolExecuteInternal(), use SMBPacketBufferAllocate()
		to allocate the raw buffer space for the response for
		NetBIOS session requests.  The free path for packets assumes
		this allocator is used, and using "manually allocated"
		buffer space will cause corruption of the free packet
		pool.

Change 1095044 on 2014/10/06 by justing@justing_ns1_likewise

	Remove unnecessary atomic operation.
	
	lwio/server/smbcommon/packet.c:
		In SMBPacketAllocate(), set the initial packet refcount
		normally instead of using InterlocketIncrement().  The
		newly created packet is only visible to the current thread,
		so there is no possibility for concurrent access.

Change 1094492 on 2014/10/02 by justing@justing_ns1_likewise

	Fix race conditions in Likewise's timer API.  One of these races
	is a cause for Likewise segfaults on shutdown.
	
	lwbase/src/threadpool-timer.c:
		Restructure TimerTask() so it is clear that only one
		condition (cancel, schedule, fire timer) can occur per-loop
		and to reduce duplicate code.
	
		Address several race conditions all caused by the deferred
		action performed by TimerTask() in response to the API user's
		thread making requests to cancel or schedule a timer:
	
			In TimerTask(), when processing a cancel
			request, clear the schedule bit.  This
			handles the case of a cancel occurring after
			a schedule request, but prior to the TimerTask
			being able to schedule the timer.
	
			In TimerTask(), when scheduling a timer, don't
			bother clearing the TIMER_RUN bit.  Instead,
			clear the TIMER_RUN bit at the time the user makes
			the scheduling request.  This ensures that a
			schedule, followed by a cancel performed prior to
			TimerTask() running, cannot allow the client to see
			a stale TIMER_RUN flag from a previous invocation.
	
			In LwRtlScheduleTimer(), clear the TIMER_RUN and
			TIMER_CANCEL flags when setting TIMER_SCHEDULE.
			This ensures that a cancel, followed by a schedule
			that completes before TimerTask() can run will
			leave the timer scheduled.
	
			In LwRtlCancelTimer(), clear the TIMER_RUN flag
			at the same time it is read and TIMER_CANCEL is
			set.  This ensures that only a single cancel call
			will react to losing a cancel race.
	
	lwsm/server/container.c:
		In ContainerStuckTimer(), remove an unused variable.
	
		In ContainerStuckTimer(), clear the Timed flag when the
		timer fires since the timer is no longer active.
	
	lwsm/server/table.c:
		Improve logging of service transitions.  This was useful
		while debugging the segfault on shutdown that was caused
		by timer race conditions.

Change 1094491 on 2014/10/02 by justing@justing_ns1_likewise

	Remove hard coded PREFIX from Likewise's init-base.sh script.
	
	config/init-base.sh:
	config/init-base.sh.in:
		Rename init-base.sh so that it can be used with mk_output_file.
	
	config/init-base.sh.in:
		Replace hard coded prefix path with a local variable which
		is set by mk_output_file's replacement of @PREFIX_DIR@.
	
	config/MakeKitBuild:
		Declare PREFIX_DIR as a replaceable variable for mk_output_file.
	
		Perform mk_output_file on init-base.sh.

Change 1094424 on 2014/10/02 by justing@justing_ns1_likewise

	Fix error message when attempting to start lwsmd
	via it's rc.d script when it is not enabled in rc.conf.
	
	config/init-base.sh:
		In check_load_path(), use 'path_var' instead of 'name' as
		the name for the variable used to iterate over the library
		path envvironment variables being checked.  This avoids
		clobbering the 'name' variable, used by invocations of
		run_rc_command(), that holds the script name.

Change 1091213 on 2014/09/16 by daveb@daveb.p4work.shared.likwise.platform-new

	P2_30238 clicking task scheduler on client causes lwsmd coredump
	
	Initialization of server_principal_name to (UCHAR *)"" results
	in attempts to free data.
	
	(UCHAR *)"" is not the same as NULL.
	Fix multiple instances in ncklib where (UCHAR *)"" was 
	used in lieu of NULL.

Change 1090069 on 2014/09/10 by justing@justing_ns1_likewise

	Fix segmentation violation during Likewise shutdown by properly
	terminating the DCERPC service used by both lsass and srvsvc.
	
	dcerpc/ncklib/comnet.c:
		In rpc_server_listen(), perform close processing on the
		sockets listening for incoming connections.
	
	dcerpc/ncklib/comnlsn.c:
		In copy_listener_state(), only reference socket slots that
		are populated ("busy" in the parlance of this code).  This
		avoids a NULL pointer dereference when sockets are deactivated
		and then freed.
	
	dcerpc/ncklib/comsoc_smb.c:
		Modify rpc__smb_socket_destroy() to cancel and wait for any
		pending RCP calls, timers, or threads to drain so that sockets
		are not accessed after they are destroyed.

Change 1090051 on 2014/09/10 by justing@justing_ns1_likewise

	Style fixes.  No functional changes.
	
	dcerpc/ncklib/comnet.c:
		tabs -> spaces to match prevailing style.

Change 1088131 on 2014/09/02 by justing@justing_ns1_likewise

	Rename WireMarshallTransaction2Response() to WireMarshalTrans2Response()
	and update the API to require a pointer to the parameter word count
	to be passed in.  This allows the setting/calculation of the word
	count to occur in one place: WireMarshalTrans2ResponseSetup().

Change 1087192 on 2014/08/28 by justing@justing_ns1_likewise

	Convert the SMB1 Trans2 query file system info code to use
	a table.  Share common file system info marshaling code between
	SMB1 and SMB2.
	
	lwio/server/srv/protocols/MakeKitBuild:
	lwio/server/srv/protocols/api/MakeKitBuild:
	lwio/server/srv/protocols/smbcommon/MakeKitBuild:
	lwio/server/srv/protocols/include/smbcommon.h:
	lwio/server/srv/protocols/smbcommon/includes.h:
	lwio/server/srv/protocols/smbcommon/marshalfsinfo.c:
	lwio/server/srv/protocols/smb2/getfsinfo.c:
		Extract marshaling functions from getfsinfo.c into
		smbcommon/marshalfsinfo.c.
	
		Hook this new file into the build.
	
	lwio/server/srv/protocols/smb1/includes.h:
	lwio/server/srv/protocols/smb2/includes.h:
		Include smbcommon.h.
	
	lwio/server/srv/protocols/smb1/trans2qfsi.c:
	lwio/server/srv/protocols/smb2/getfsinfo.c:
		Convert to be table driven.

Change 1087081 on 2014/08/28 by justing@justing_ns1_likewise

	Refactor the Trans2 query file info code to use a table driven
	approach as was previously done for SMB2.
	
	lwio/server/srv/include/elementsapi.h:
	lwio/server/srv/elements/processinfo.c:
	lwio/server/srv/protocols/smb2/getfileinfo.c:
		Rename SrvGetFileAltNameInfo() to
		SrvGetFileInfoGeneric_WithFileName().  This method is
		appropriate for any info retrieval that ends with a file
		name/path that must be normalized to be share relative.
	
	lwio/server/srv/include/elementsapi.h:
	lwio/server/srv/elements/processinfo.c:
		Add a generic, table driven, marshal function for info
		classes.
	
	lwio/server/srv/protocols/smb1/structs.h:
		Include a SRV_PROCESS_INFO_STATE structure in
		SRV_TRANS2_STATE_SMB_V1 so that the Trans2 can use
		the common code in processinfo.c
	
	lwio/server/srv/protocols/smb1/trans2.c:
		Setup and teardown of the new SRV_PROCESS_INFO_STATE
		field.
	
	lwio/server/srv/protocols/smb1/trans2qfi.c:
	lwio/server/srv/protocols/smb1/trans2qpi.c:
		Initialize the hFile and usInfoClass fields in
		SRV_PROCESS_INFO_STATE when unmarshaling a query file
		or query path request.
	
	lwio/server/srv/protocols/smb1/trans2qfsi.c:
		Style fixups.
	
	lwio/server/srv/protocols/smb1/trans2qi.c:
		Table conversion.  This removes ~2000 lines of duplication.
	
	lwio/server/srv/protocols/smb2/getfileinfo.c:
		Normalize the path of the returned file name for
		the "file all info" info class.
	
	lwio/server/srv/protocols/smb2/getfileinfo.c:
		Correct leading white space in table entries.
	
		Remove ntStatus variable from methods that always return
		STATUS_SUCCESS.
	
		Change handler for the "all info" class to normalize the
		file name returned.
	
		Fix an off by one bug in SrvMarshalFileStreamInfo_SMB_V2()
		accounting of consumed space.
	
	lwio/server/srv/protocols/smb2/getinfo.c:
	lwio/server/srv/protocols/smb2/getquotainfo.c:
	lwio/server/srv/protocols/smb2/getsecinfo.c:
	lwio/server/srv/protocols/smb2/structs.h:
		Rename the "baseState" member to "infoState".  The previous
		name was chosen before the movement of commen state like
		the refCount and ioStatusBlock were moved to the execContext.
		This also matches the naming convention used in SMBv1.

Change 1087054 on 2014/08/28 by justing@justing_ns1_likewise

	Fix Trans2 response marshaling.
	
	lwio/server/smbcommon/wire_transaction.c:
		In WireMarshalTrans2ResponseFini(), correct an off by one
		error that snuck in with change 1086980.

Change 1086980 on 2014/08/27 by justing@justing_ns1_likewise

	Refactor portions of WireMarshallTransaction2Reponse() into
	separate functions for eventual use in refactoring the Trans2
	query APIs.
	
	lwio/server/include/smbwire.h:
		Function prototypes for WireMarshalTrans2ResponseSetup()
		and WireMarshalTrans2ResponseFini().
	
	lwio/server/smbcommon/wire_transaction.c:
		Implementation of WireMarshalTrans2ResponseSetup()
		and WireMarshalTrans2ResponseFini().  Restructure
		WireMarshallTransaction2Response() to use the new
		functions.

Change 1086966 on 2014/08/27 by justing@justing_ns1_likewise

	Update marshal.h's Align() inline function so that the amount
	of alignment performed (amount of buffer space consumed for
	alignment) is reported.

Change 1086729 on 2014/08/26 by daveb@daveb.p4work.shared.likwise.platform-new

	Further refinements to change 1086597:
	
	Change 1086597 manipulated the socket offset outside of the
	socket lock.
	
	lwio/server/transport/threadpool/srvsocket.c:
	- Use a local copy of the socket offset while processing reads.
	- Acquire the socket lock, update the offset, and call the 
	  protocol data callback.

Change 1086597 on 2014/08/26 by daveb@daveb.p4work.shared.likwise.platform-new

	P2_30217: Likewise deadlock when tearing down socket
	
	When a thread receives a socket read or write error, 
	SrvSocketProcessTaskDisconnect() will eventually be executed.
	SrvSocketProcessTaskDisconnect() runs with the socket lock held and
	excutes a "send done" callback. This callback may execute 
	code that acquires a read/write state lock.
	
	Meanwhile another thread holding the read/write state lock may attempt
	to acquire the socket lock; the result is a deadlock.
	
	See P2_30217 for two stack traces showing this dead lock.
	
	The solution is for the srvsocket.c code to release the socket lock
	when executing the socket callbacks.
	
	
	lwio/server/transport/threadpool/srvsocket.c
	- Refactor SrvSocketProcessTaskWrite(), SrvSocketProcessTaskReadZct(),
	  and SrvSocketProcessTaskReadBuffer() to release the socket lock 
	  when calling the pfnConnectionData() and pfnSendDone() callbacks.
	
	- Refactor SrvSocketProcessTaskDisconnect() move the socket send
	  head to a new head, release the socket lock and execute the 
	  pfnSendDone() and pfnConnectionDone() callbacks
	
	lwbase/include/lw/list.h
	lwbase/src/list.c
	- Define a LwListMoveHead() API that moves a list head from one
	  node to another

Change 1085626 on 2014/08/22 by justing@justing_ns1_likewise

	Remove redundant code and reference counting in command handlers
	by relying on the existing reference counting of the exec
	context and by moving the IO_STATUS_BLOCK for most handlers
	(all but oplocks and notify) into the exec context.
	
	lwio/server/srv/protocols/smb2/structs.h:
	lwio/server/srv/protocols/smb1/structs.h:
		Remove IO_STATUS_BLOCK and refcount fields from
		per-command handler data structures.
	
	lwio/server/srv/protocols/smb1/prototypes.h:
	lwio/server/srv/protocols/smb1/checkdir.c:
	lwio/server/srv/protocols/smb1/close.c:
	lwio/server/srv/protocols/smb1/creatdir.c:
	lwio/server/srv/protocols/smb1/createx.c:
	lwio/server/srv/protocols/smb1/deldir.c:
	lwio/server/srv/protocols/smb1/delete.c:
	lwio/server/srv/protocols/smb1/flush.c:
	lwio/server/srv/protocols/smb1/lockx.c:
	lwio/server/srv/protocols/smb1/ntrename.c:
	lwio/server/srv/protocols/smb1/nttransact.c:
	lwio/server/srv/protocols/smb1/openx.c:
	lwio/server/srv/protocols/smb1/queryinfo2.c:
	lwio/server/srv/protocols/smb1/readx.c:
	lwio/server/srv/protocols/smb1/rename.c:
	lwio/server/srv/protocols/smb1/setinfo.c:
	lwio/server/srv/protocols/smb1/setinfo2.c:
	lwio/server/srv/protocols/smb1/trans.c:
	lwio/server/srv/protocols/smb1/trans2.c:
	lwio/server/srv/protocols/smb1/trans2qfsi.c:
	lwio/server/srv/protocols/smb1/trans2qi.c:
	lwio/server/srv/protocols/smb1/trans2qpi.c:
	lwio/server/srv/protocols/smb1/trans2sfi.c:
	lwio/server/srv/protocols/smb1/trans2sfsq.c:
	lwio/server/srv/protocols/smb1/trans2si.c:
	lwio/server/srv/protocols/smb1/trans2spi.c:
	lwio/server/srv/protocols/smb1/treeconnect.c:
	lwio/server/srv/protocols/smb1/write.c:
	lwio/server/srv/protocols/smb1/writex.c:
	lwio/server/srv/protocols/smb2/close.c:
	lwio/server/srv/protocols/smb2/create.c:
	lwio/server/srv/protocols/smb2/flush.c:
	lwio/server/srv/protocols/smb2/ioctl.c:
	lwio/server/srv/protocols/smb2/lock.c:
	lwio/server/srv/protocols/smb2/read.c:
	lwio/server/srv/protocols/smb2/setinfo.c:
	lwio/server/srv/protocols/smb2/treeconnect.c:
	lwio/server/srv/protocols/smb2/write.c:
		Change command handler data structure release functions
		which are registered with the exec context to unconditionally
		free their data.
	
		commandState->ioStatusBlock -> execContext->ioStatusBlock
	
		Remove unused reference count support code.
	
	lwio/server/srv/protocols/smb1/lockx.c:
		Refactor lock search routines into a single routine
		takeing a "match func".
	
		Adjust internal API so that the lock information state
		no longer needs a back reference to the exec context.

Change 1085590 on 2014/08/22 by daveb@daveb.p4work.shared.likwise.platform-new

	Refactor change 1085313 to ensure that the socket thread gets
	rescheduled by the IO thread that detects the "disconnecting" flag.
	
	Check for "disconnecting" at IO function entry and after re-acquiring
	the socket lock.

Change 1085553 on 2014/08/22 by daveb@daveb.p4work.shared.likwise.platform-new

	Style
	Reformat serveral lines to fit in 80 columns.

Change 1085313 on 2014/08/21 by daveb@daveb.p4work.shared.likwise.platform-new

	Close serialization hole when IO threads receive a socket
	send or receive error.
	
	lwio/server/transport/threadpool/srvsocket.c:
	When a thread is performing socket IO, it releases the 
	socket lock; if another thread is already disconnecting
	via SrvSocketProcessTaskDisconnect() then this second 
	thread is tearing down data structures that the IO thread
	may be accesssing.
	
	To fix, when a thread executes SrvSocketProcessTaskDisconnect(),
	mark the socket as "disconnecting" and if any IO is in progress
	then return without completing the disconnect. When an IO thread
	encounters a "disconnecting" socket it will set an error and
	schedule the socket thread to complete the disconnect.
	
	lwio/server/transport/threadpool/structs.h:
	Define SRV_SOCKET_STATE_DISCONNECTING

Change 1085253 on 2014/08/21 by justing@justing_ns1_likewise

	Improve protocol agnostic info processing support.
	
	lwio/server/srv/include/elementsapi.h:
		Add an IO_STATUS_BLOCK to SRV_EXEC_CONTEXT.  This
		should be usable by all command handlers except
		oplock and notify.  In this changeset, only the
		getinfo handlers have been converted.  This simplifies
		sharing code between protocols and handlers.
	
	lwio/server/srv/include/elementsapi.h:
	lwio/server/srv/elements/processinfo.c:
		Remove the need to store a back pointer to the exec
		context from within the process info state.  This
		is achieved by just passing through the exec context
		in all get/marshal calls.
	
	lwio/server/srv/protocols/smb2/getfileinfo.c:
	lwio/server/srv/protocols/smb2/getfsinfo.c:
	lwio/server/srv/protocols/smb2/getinfo.c:
	lwio/server/srv/protocols/smb2/getquotainfo.c:
	lwio/server/srv/protocols/smb2/getsecinfo.c:
		Adjust to callback API changes.

Change 1085198 on 2014/08/21 by justing@justing_ns1_likewise

	Fix GetFileAltNameInfo.
	
	lwio/server/srv/elements/processinfo.c:
	lwio/server/srv/include/elementsapi.h:
	lwio/server/srv/protocols/smb2/getinfo.c:
		Until the next stage of refactoring is complete, we must
		initialize a back reference to the exec context from
		the process info context for use by the marshal
		data callbacks.

Change 1085190 on 2014/08/21 by justing@justing_ns1_likewise

	Fix Likewise build.
	
	lwio/server/srv/include/elementsapi.h:
		Restore line accidentally removed in 1085189.

Change 1085086 on 2014/08/20 by justing@justing_ns1_likewise

	Commit changes missed in 1085083.
	
	lwio/server/srv/elements/processinfo.c:
	lwio/server/srv/include/elementsapi.h:
		Remove redundant fields in the new SRV_PROCESS_INFO_STATE
		structure.

Change 1085083 on 2014/08/20 by justing@justing_ns1_likewise

	Refactor generic "info processing" code out of SMB2 and
	into the "shared elements" code base.  This is a step toward
	using this code in SMB1 and any future protocols.
	
	lwio/server/srv/elements/MakeKitBuild:
	lwio/server/srv/elements/processinfo.c:
		Add processinfo.c to contain the shared code.
	
	lwio/server/srv/elements/includes.h:
		Include protocolapi.h when building files in the
		elements module so taht processinfo.c can reference
		SrvPrepareExecContextAsync() and SrvReleaseExecContextAsync().
	
	lwio/server/srv/include/elementsapi.h:
	lwio/server/srv/protocols/smb2/structs.h:
		Add shared APIs.  These are mostly identical to what were
		SMB2 private APIs.  The only major change is that "hState
		fields" required by the common code must now be placed
		in a SRV_PROCESS_INFO_STATE field that is contained within
		the protocol specific state object.
	
	lwio/server/srv/protocols/smb2/getfileinfo.c:
	lwio/server/srv/protocols/smb2/getfsinfo.c:
	lwio/server/srv/protocols/smb2/getinfo.c:
	lwio/server/srv/protocols/smb2/getquotainfo.c:
	lwio/server/srv/protocols/smb2/getsecinfo.c:
	lwio/server/srv/protocols/smb2/prototypes.h:
		Adjust to API movement/rename.

Change 1084857 on 2014/08/19 by justing@justing_ns1_likewise

	Refactor code to eliminate ~4000 lines of duplication.
	
	Add an IO_ASYNC_CONTROL block to SRV_EXEC_CONTEXT and
	modify all command handlers except for oplocks and notify
	requests to use this acb and the exec context's lock instead
	of using private data in the command's hState.
	
	oplocks and notify requests are long lived and thus disassociate
	themselves from their initial exec context.  This is why these
	command handlers still use private data.

Change 1084855 on 2014/08/19 by justing@justing_ns1_likewise

	Allow the read-only attribute to be cleared on files.
	
	lwio/server/pvfs/util_open.c:
		In MapPosixOpenAccess(), include FILE_WRITE_ATTRIBUTES
		in the mask of windows permission bits that require
		read access.  Otherwise it is possible for a create
		call (open) to appear to be requesting no access, which
		will cause the create to fail with access denied.

Change 1081200 on 2014/08/01 by kenm@ken.likewise

	Convert the Likewise file flags code from the file flags
	conventions used in //SpectraBSD/stable to the ones I actually
	committed in FreeBSD and are present in FreeBSD stable/10.
	
	This should have no effect on machines that are upgraded, since we
	have not changed the ZFS on-disk format.  The only effect is the
	BSD-visible flags that are used to store the CIFS file attributes.
	
	The changes are:
	1. Instead of mapping UF_IMMUTABLE to the DOS/CIFS READONLY
	   attribute, we now have a UF_READONLY file flag.
	2. Instead of mapping the DOS/CIFS ARCHIVE bit to the inverse of
	   the SF_ARCHIVED file flag, we now map it directly to the new
	   UF_ARCHIVE file flag.
	
	lwio/server/pvfs/attrib_flags.c:
		In PvfsGetFileAttributesFromStat(), and
		PvfsSetFileFlagsFromAttributes(), map UF_READONLY to
		FILE_ATTRIBUTE_READONLY and map UF_ARCHIVE to
		FILE_ATTRIBUTE_ARCHIVE.
	
		In PvfsSetAttributesFlags(), instead of the slightly more
		complex logic to set the SF_ARCHIVED bit by itself, just
		issue the flag setting call twice if the user is trying
		to set other flags and clear the UF_ARCHIVE bit at the same
		time.  In the second call, ZFS should actually clear the 
		UF_ARCHIVE bit since that will be the only change to the
		file.

Change 1080734 on 2014/07/30 by justing@justing_ns1_likewise

	Adjust the Likewise port for FreeBSD's switch to pkg(8).

Change 1080698 on 2014/07/30 by justing@justing_ns1_likewise

	Fix warnings from Clang's static code analyzer.
	
	lsass/server/store/samdb/samdbadd.c:
	lsass/server/store/samdb/samdbfind.c:
	lsass/server/store/samdb/samdbupdate.c:
		Likewise uses two different enums for the same
		values in the samdb API: SAMDB_OBJECT_TYPE which
		is used by clients of the samr front-end, and
		SAMDB_OBJECT_CLASS which is used by the database
		backend.  Explicitly cast between the two where the
		front and backend interfaces meet.

Change 1080696 on 2014/07/30 by justing@justing_ns1_likewise

	Fix warnings from Clang's static code analyzer.
	
	lsass/server/store/samdb/samdbupgrade.c:
		In C, unlike C++, the integer 0 is not the same as
		NULL.  In SamDbFetchRecordsFromTable(), set a C
		string to NULL, not the enum (i.e. an integer of 0)
		SAMDB_ATTR_TYPE_UNKNOWN.

Change 1080536 on 2014/07/29 by justing@justing_ns1_likewise

	Fix Clang "value out of range for enum" error.
	
	lwbase/include/lw/threadpool.h:
	lwbase/src/threadpool-poll.h:
	lwbase/src/threadpool-epoll.h:
	lwbase/src/threadpool-kqueue.h:
	lwbase/src/threadpool-epoll.c:
	lwbase/src/threadpool-kqueue.c:
	lwbase/src/threadpool-poll.c:
	lwbase/src/threadpool-select.c:
		Remove duplicate defines for TASK_COMPLETE_MASK
		in each different "polling scheme", in favor of
		the new LW_TASK_EVEN_COMPLETE_MASK element in the 
		W_TASK_EVENT_MASK enum.  This ensures that the
		type used to express the enum is large enough
		to hold the mask.

Change 1080535 on 2014/07/29 by justing@justing_ns1_likewise

	Silence "use of uninitialized variable" warnings.
	
	dcerpc/idl_compiler/errors.c:
	dcerpc/idl_lib/ndrmi.c:
	dcerpc/idl_lib/ndrui.c:
	dcerpc/ncklib/gssauth.c:
		Initialize several variables where they are
		declared.  These code paths should be properly
		audited in the future, but this at least gets
		things building with Clang.

Change 1080533 on 2014/07/29 by justing@justing_ns1_likewise

	Fix warnings from Clang's static code analyzer.
	
	lwbase/src/threadpool-select.c:
		Remove a spurious semicolon after after a function
		argument in a function declaration.

Change 1080532 on 2014/07/29 by justing@justing_ns1_likewise

	Fix warnings from Clang's static code analyzer.
	
	dcerpc/ncklib/gssauthcn.c:
	dcerpc/ncklib/ntlmsspcn.c:
	dcerpc/ncklib/schnauthcn.c:
		server_princ_name is a pointer to unsigned char.
		Properly cast assignements to "empty string".
	
		Note: It may also be possible to just declare
		      server_princ_name as a pointer to char,
		      but I don't have enough understanding of
		      dcerpc's internals to know if this is a
		      correct solution.  The cast will not change
		      the current behavior of the program.

Change 1080530 on 2014/07/29 by justing@justing_ns1_likewise

	Fix warnings from Clang's static code analyzer.
	
	lwio/server/srv/protocols/smb2/getsecinfo.c:
		Remove superfluous parentheses that disable the
		compiler's ability to check for unintended assignment
		when an equality test is the programmer's intent.

Change 1080529 on 2014/07/29 by justing@justing_ns1_likewise

	Fix Clang's static code analyzer warnings.
	
	lsass/interop/nsswitch/freebsd/nss-group.c:
	lsass/interop/nsswitch/freebsd/nss-user.c:
		Remove unused static variables.

Change 1080528 on 2014/07/29 by justing@justing_ns1_likewise

	Fix bug exposed by Clang's static code analyzer.
	
	lsass/server/rpc/samr/samr_querydomaininfo.c:
		Call memset with the correct size: sizeof(*pInfo6), not
		sizeof(pInfo6).

Change 1080504 on 2014/07/29 by justing@justing_ns1_likewise

	Fix Likewise build.
	
	lwbase/src/security-token.c:
		Re-enable CheckOffset, which was mistakenly ifdefed
		out in change set 1080468.

Change 1080488 on 2014/07/29 by robg@robg.ns1.likewise

	Replace the use of set_rcvar with the actual rcvar.  set_rcvar
	has been removed in FreeBSD 10.

Change 1080487 on 2014/07/29 by justing@justing_ns1_likewise

	Fix Likewise <-> Clang compatibility issues.
	
	lsass/server/include/samdb.h:
	lsass/server/store/samdb/samdbattr.c:
	lsass/server/store/samdb/samdbattr.h:
	lwreg/server/providers/memory/externs.h:
	lwreg/server/providers/memory/globals.c:
		Remove non-sensical inline keyword on functions declared
		but not defined in header files.

Change 1080484 on 2014/07/29 by justing@justing_ns1_likewise

	Fix Likewise <-> Clang incompatibilities.
	
	lsass/server/include/wellknownsids.h:
	lwdns/lwdns/dnserror.h:
	lwio/server/rdr/tree2.h:
		Fix mismatch between idempotency ifdefs and
		the macro being defined.
	
	Found by: Clang static code analysis.

Change 1080471 on 2014/07/29 by justing@justing_ns1_likewise

	Fix a likewise <-> Clang compatibility issue.
	
	templatedriver/test/Makefile.am:
		The template driver uses CC for the link stage.
		Modify LDFLAGS to properly pass rpath arguments
		to the linker via -Wl.  -rpath is not supported
		directly by clang.

Change 1080468 on 2014/07/29 by justing@justing_ns1_likewise

	ifdef UNUSED code that is not currently being used.  This
	code should be audited at some point to decide if it is
	infrastructure for a partially completed feature we care
	about, or should just be permanently removed.
	
	Found by: Clang static code analyzer.

Change 1080425 on 2014/07/29 by justing@justing_ns1_likewise

	lwio/server/srv/elements/srvgss.c:
		Explicitly truncate KRB5KRB_AP_ERR_SKEW to 32bits when
		used as a case in a switch statement.  This avoids
		complaints by the compiler that the conversion of the
		'L' constant to a uint32_t loses information.
	
	Found by: Clang static analysis checker.

Change 1079159 on 2014/07/23 by daveb@daveb.p4work.shared.likwise.platform

	likewise-health: reverse the order of the following two checks:
		1) get the hotpair state and exit if not appropriate
		2) if likewise is not running then exit.
	
	Moving the second test before the first simply avoids contacting HPD
	when it is not necessary.

Change 1078909 on 2014/07/22 by daveb@daveb.p4work.shared.likwise.platform

	Refinement of likewise health check scripts:
	
	//likewise/main/config/likewise-health:
	- Add parameters for -p <pid_file> -P <procname>;
	  this allows likewise-health to use check_pidfile() to validate that
	  the main likewise daemon is running. If it is not running
	  then do not check health. Monit manages this process.
	
	- Add logic to not check health if executed on the non-active node.
	
	//likewise/main/config/init-likewise.sh:
	- execute likewise-health with new -p and -P parameters.

Change 1078148 on 2014/07/18 by daveb@daveb.p4work.shared.likwise.platform

	Add monit compatible directives to stop
	and start all likewise services.
	
	'service likewise stopall' will stop
	all likewise services.
	
	'service likewise startall' will start
	all likewise services.

Change 1078105 on 2014/07/18 by daveb@daveb.p4work.shared.likwise.platform

	Misspelled shell variable doesn't provide
	useful log information.

Change 1077944 on 2014/07/17 by daveb@daveb.p4work.shared.likwise.platform

	Health check script for likewise.
	
	Ultimately, health check will be executed by monit via the service
	command. For likewise this will be as follows:
		service likewise health
	
	If it exits non-zero then likwise is determined unhealthy. 
	
	//likewise/main/config/init-likewise.sh
	- This is the implementation of the likewise service start, stop, reload.
	- Add the new 'health' option
	- In order for the health option to be passed down the chain by the 
	  BSD rc infrastructure, extra_commands="health" must be set in
	  /etc/spectra/rc.conf.d/rc.likewise
	
	//likewise/main/config/likewise-health
	- The actual likewise health check script.
	
	//likewise/main/config/likewise	
	- Set health check variables for init-likewise.sh and likewise-health
	
	//likewise/main/config/MakeKitBuild
	- Build details

Change 1070322 on 2014/06/19 by daveb@daveb.p4work.shared.likwise.platform

	Invalid Security Descriptor causes likewise crash.
	smbtorture smb2.create.nulldacl.nulldacl
	Attempts to set a zero DACL; the test, however, uses an invalid
	Security Descriptor (SD). The SD has the Control DP flag set (i.e.
	DACL present) and a DACL offset of zero.
	
	http://msdn.microsoft.com/en-us/library/cc230366.aspx says:
	OffsetDacl (4 bytes): An unsigned 32-bit integer that specifies the 
	offset to the ACL that contains ACEs that control access. Typically, 
	the DACL contains ACEs that grant or deny access to principals or 
	groups. This must be a valid offset if the DP flag is set; if the DP 
	flag is not set, this field MUST be set to zero. 
	If this field is set to zero, the Dacl field MUST not be present.
	
	It seems that proper zero DACL would have DP set and OffsetDacl set
	to the offset of 4 bytes of zeros.  
	
	Running  smbtorture smb2.create.nulldacl.nulldacl against MS does not
	fail, but the change made herein checks for DACL/SACL present and 
	DACL/SACL offset of zero throws an error if both are true. 

Change 1068964 on 2014/06/13 by daveb@daveb.p4work.shared.likwise.platform

	DE403: do not delete the filter when canceling a
	pending notification rather simply remove the
	IRP.

Change 1068193 on 2014/06/10 by daveb@daveb.p4work.shared.likwise.platform

	Style: indentation

Change 1068192 on 2014/06/10 by daveb@daveb.p4work.shared.likwise.platform

	Style:
	- general alignment.
	- shorten variable name to improve alignment.

Change 1068181 on 2014/06/10 by daveb@daveb.p4work.shared.likwise.platform

	Style: remove superfluous space

Change 1068178 on 2014/06/10 by daveb@daveb.p4work.shared.likwise.platform

	In PvfsIrpContextMakePendedCancellable()
	pIrpContext->QueueType should be initialized 
	from paramter Quetype.
	
	Style corrections:
	- remove extraneous space
	- remove superfluous void casts

Change 1068176 on 2014/06/10 by daveb@daveb.p4work.shared.likwise.platform

	Fix parameters to third argument PvfsIrpContextMakePendedCancellable();
	it should be pIrpContext.

Change 1067915 on 2014/06/09 by daveb@daveb.p4work.shared.likwise.platform-new

	DE403: Specifying a notification request with a zero
	length buffer is legal and should return NOTIFY_ENUM_DIR.
	
	Likewise was returning INVALID_PARAMETER.

Change 1067913 on 2014/06/09 by daveb@daveb.p4work.shared.likwise.platform-new

	DE403: buffered notification overflow never reported to
	client. If the inter notify request buffer overflows 
	than the server should report NOTIFY_ENUM_DIR.
	
	The error was never recorded in pending buffer status
	field.

Change 1067912 on 2014/06/09 by daveb@daveb.p4work.shared.likwise.platform-new

	DE403: Close multiple notify cancellation race conditions.
	
	1.) Hold the pFcb->NotifyMutex while adding a new
	notify filter; this serializes with PvfsNotifyCancelNotify().
	
	2.) Atomically clear ACTIVE if REQUEST_CANCEL is not set 
	otherwise schedule the cancel.
	
	Smbtorture smb2.notify.valid-req.valid-req readily exposed
	this hole with a notify request immediately followed by a
	cancellation. The cancel request would often arrive at
	PvfsQueueCancelIrp() while the original notify request was
	still active. The IRP deactivation code did not check for
	a cancellation request, thus the cancel was never processed.
	
	Added PvfsQueueCancelIrpIfRequestedElseDeactivate() to
	process the common steps of making a IRP cancelable.

Change 1067889 on 2014/06/09 by daveb@daveb.p4work.shared.likwise.platform-new

	Multiple PVFS IRP completions possible resulting
	in core dumps.
	
	lwio/server/pvfs/irpctx.c:
	Previously, the code atomically checked if PENDED then 
	set COMPLETE; this permits COMPLETE to already be set
	thus allowing multiple completions.
	
	Change logic to atomically check 
	if (PENDED | COMPLETE) == PENDED then set COMPLETE.
	
	Also, PvfsProcessIrpContext() was overloaded to initiate
	PVFS IRPs and to complete IRPs. Separated these actions into
	different functions initiated by PvfsScheduleIrpContextCallback()
	
	
	lwio/server/pvfs/structs.h:
	Function pointer prototype for scheduling IRP callbacks via
	PvfsScheduleIrpContextCallback().

