Windows: Improve SMB detection of Local System account
[openafs.git] / src / WINNT / afsd / smb.h
index 4f9d894..88e4d3e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -170,6 +170,8 @@ typedef struct smb {
 #define NTNEGOTIATE_CAPABILITY_COMPRESSED              0x40000000L
 #define NTNEGOTIATE_CAPABILITY_EXTENDED_SECURITY       0x80000000L
 
+#define NTSID_LOCAL_SYSTEM L"S-1-5-18"
+
 /* a packet structure for receiving SMB messages; locked by smb_globalLock.
  * Most of the work involved is in handling chained requests and responses.
  *
@@ -287,9 +289,9 @@ typedef struct smb_username {
     time_t last_logoff_t;              /* most recent logoff time */
 } smb_username_t;
 
-/* The SMB_USERNAMEFLAG_AFSLOGON is used to preserve the existence of an 
+/* The SMB_USERNAMEFLAG_AFSLOGON is used to preserve the existence of an
  * smb_username_t even when the refCount is zero.  This is used to ensure
- * that tokens set to a username during the integrated logon process are 
+ * that tokens set to a username during the integrated logon process are
  * preserved until the SMB Session that will require the tokens is created.
  * The cm_IoctlSetTokens() function when executed from the Network Provider
  * connects to the AFS Client Service using the credentials of the machine
@@ -298,12 +300,18 @@ typedef struct smb_username {
 
 /* The SMB_USERNAMEFLAG_LOGOFF is used to indicate that the user most
  * recently logged off at 'last_logoff_t'.  The smb_username_t should not
- * be deleted even if the refCount is zero before 'last_logoff_t' + 
+ * be deleted even if the refCount is zero before 'last_logoff_t' +
  * 'smb_LogoffTransferTimeout' if 'smb_LogoffTokenTransfer' is non-zero.
  * The smb_Daemon() thread is responsible for purging the expired objects */
 
 #define SMB_USERNAMEFLAG_LOGOFF     2
 
+/*
+ * The SMB_USERNAMEFLAG_SID flag indicates that the name is not a username
+ * but a SID string.
+ */
+#define SMB_USERNAMEFLAG_SID        4
+
 #define SMB_MAX_USERNAME_LENGTH 256
 
 /* one per tree-connect */
@@ -468,7 +476,7 @@ typedef struct smb_dirSearch {
     unsigned short attribute;          /* search attribute
                                         * (used for extended protocol) */
     clientchar_t tidPath[256];          /* tid path */
-    clientchar_t relPath[1024];         /* relative path */        
+    clientchar_t relPath[1024];         /* relative path */
     clientchar_t mask[256];            /* search mask for V3 */
 } smb_dirSearch_t;
 
@@ -487,9 +495,9 @@ typedef struct smb_dirListPatch {
 } smb_dirListPatch_t;
 
 /* dirListPatch Flags */
-#define SMB_DIRLISTPATCH_DOTFILE 1  
+#define SMB_DIRLISTPATCH_DOTFILE 1
 /* the file referenced is a dot file
- * Note: will not be set if smb_hideDotFiles is false 
+ * Note: will not be set if smb_hideDotFiles is false
  */
 
 /* individual lock on a waiting lock request */
@@ -600,11 +608,15 @@ extern void smb_ReleaseTID(smb_tid_t *tidp, afs_uint32 locked);
 
 extern smb_user_t *smb_FindUID(smb_vc_t *vcp, unsigned short uid, int flags);
 
+extern afs_int32 smb_userIsLocalSystem(smb_user_t *userp);
+
 extern smb_username_t *smb_FindUserByName(clientchar_t *usern, clientchar_t *machine, afs_uint32 flags);
 
 extern cm_user_t *smb_FindCMUserByName(clientchar_t *usern, clientchar_t *machine, afs_uint32 flags);
 
-extern smb_user_t *smb_FindUserByNameThisSession(smb_vc_t *vcp, clientchar_t *usern); 
+extern cm_user_t *smb_FindCMUserBySID(clientchar_t *usern, clientchar_t *machine, afs_uint32 flags);
+
+extern smb_user_t *smb_FindUserByNameThisSession(smb_vc_t *vcp, clientchar_t *usern);
 
 extern void smb_ReleaseUsername(smb_username_t *unp);
 
@@ -745,11 +757,6 @@ extern unsigned int smb_IsDotFile(clientchar_t *lastComp);
 extern afs_uint32 smb_AsyncStore;
 extern afs_uint32 smb_AsyncStoreSize;
 
-extern int smb_unixModeDefaultFile;
-extern int smb_unixModeDefaultDir;
-extern void smb_SetInitialModeBitsForFile(int smb_attr, cm_attr_t * attr);
-extern void smb_SetInitialModeBitsForDir(int smb_attr, cm_attr_t * attr);
-
 /* the following are used for smb auth */
 extern int smb_authType; /* Type of SMB authentication to be used. One from below. */
 
@@ -768,14 +775,15 @@ extern int smb_ServerLanManagerLength;
 extern GUID smb_ServerGUID;
 extern LSA_STRING smb_lsaLogonOrigin;
 extern LONG smb_UseUnicode;
+extern DWORD smb_monitorReqs;
 
 /* used for getting a challenge for SMB auth */
-typedef struct _MSV1_0_LM20_CHALLENGE_REQUEST {  
+typedef struct _MSV1_0_LM20_CHALLENGE_REQUEST {
     MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
 } MSV1_0_LM20_CHALLENGE_REQUEST, *PMSV1_0_LM20_CHALLENGE_REQUEST;
 
-typedef struct _MSV1_0_LM20_CHALLENGE_RESPONSE {  
-    MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;  
+typedef struct _MSV1_0_LM20_CHALLENGE_RESPONSE {
+    MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
     UCHAR ChallengeToClient[MSV1_0_CHALLENGE_LENGTH];
 } MSV1_0_LM20_CHALLENGE_RESPONSE, *PMSV1_0_LM20_CHALLENGE_RESPONSE;
 /**/
@@ -787,7 +795,7 @@ extern long smb_GetNormalizedUsername(clientchar_t * usern, const clientchar_t *
 extern void smb_FormatResponsePacket(smb_vc_t *vcp, smb_packet_t *inp,
        smb_packet_t *op);
 
-extern char *myCrt_Dispatch(int i); 
+extern char *myCrt_Dispatch(int i);
 
 extern char *myCrt_2Dispatch(int i);
 
@@ -839,6 +847,12 @@ extern void smb_InitReq(cm_req_t *reqp);
 #include "smb_ioctl.h"
 #include "smb_iocons.h"
 #include "smb_rpc.h"
+#include "cm_vnodeops.h"
+
+extern int smb_unixModeDefaultFile;
+extern int smb_unixModeDefaultDir;
+extern void smb_SetInitialModeBitsForFile(int smb_attr, cm_attr_t * attr);
+extern void smb_SetInitialModeBitsForDir(int smb_attr, cm_attr_t * attr);
 
 cm_user_t *smb_FindOrCreateUser(smb_vc_t *vcp, clientchar_t *usern);
 
@@ -860,7 +874,7 @@ typedef struct _MSV1_0_SETPROCESSOPTION_REQUEST {
     MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
     ULONG ProcessOptions;
     BOOLEAN DisableOptions;
-} MSV1_0_SETPROCESSOPTION_REQUEST, *PMSV1_0_SETPROCESSOPTION_REQUEST; 
+} MSV1_0_SETPROCESSOPTION_REQUEST, *PMSV1_0_SETPROCESSOPTION_REQUEST;
 #endif
 
 #endif /* whole file */