Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

372 lines
12 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. admin.h
  5. Abstract:
  6. This module contains admin interface for server service. All data
  7. strucutures anc constants shared between the AFP service and the
  8. AFP server service will be contained in this file.
  9. Author:
  10. Jameel Hyder (microsoft!jameelh)
  11. Revision History:
  12. 25 Apr 1992 JameelH Initial Version
  13. 2 Sept 1992 NarenG Added structure to pass security information
  14. between the service and the server.
  15. 1 Feb 1993 SueA Added structure to pass evenlog infomation
  16. from the server to the service.
  17. --*/
  18. #ifndef _ADMIN_
  19. #define _ADMIN_
  20. #include <lmcons.h> // Need DNLEN and LM20_UNLEN
  21. #include <crypt.h> // Need LM_OWF_PASSWORD_LENGTH
  22. #define AFP_API_BASE 1000
  23. #define AFP_CC(_request_, _Method_) CTL_CODE(FILE_DEVICE_NETWORK, \
  24. _request_ + AFP_API_BASE, \
  25. _Method_, FILE_ANY_ACCESS)
  26. #define AFP_CC_BASE(ControlCode) ((((ControlCode) >> 2) - AFP_API_BASE) & 0xFF)
  27. #define AFP_CC_METHOD(ControlCode) ((ControlCode) & 0x03)
  28. // Do not change this table without also changing the table in SERVER\FSD.C
  29. #define CC_BASE_SERVICE_START 0x01
  30. #define CC_BASE_SERVICE_STOP 0x02
  31. #define CC_BASE_SERVICE_PAUSE 0x03
  32. #define CC_BASE_SERVICE_CONTINUE 0x04
  33. #define CC_BASE_GET_STATISTICS 0x05
  34. #define CC_BASE_GET_STATISTICS_EX 0x06
  35. #define CC_BASE_CLEAR_STATISTICS 0x07
  36. #define CC_BASE_GET_PROF_COUNTERS 0x08
  37. #define CC_BASE_CLEAR_PROF_COUNTERS 0x09
  38. #define CC_BASE_SERVER_ADD_SID_OFFSETS 0x0A
  39. #define CC_BASE_SERVER_GET_INFO 0x0B
  40. #define CC_BASE_SERVER_SET_INFO 0x0C
  41. #define CC_BASE_SERVER_ADD_ETC 0x0D
  42. #define CC_BASE_SERVER_SET_ETC 0x0E
  43. #define CC_BASE_SERVER_DELETE_ETC 0x0F
  44. #define CC_BASE_SERVER_ADD_ICON 0x10
  45. #define CC_BASE_VOLUME_ADD 0x11
  46. #define CC_BASE_VOLUME_DELETE 0x12
  47. #define CC_BASE_VOLUME_GET_INFO 0x13
  48. #define CC_BASE_VOLUME_SET_INFO 0x14
  49. #define CC_BASE_VOLUME_ENUM 0x15
  50. #define CC_BASE_SESSION_ENUM 0x16
  51. #define CC_BASE_SESSION_CLOSE 0x17
  52. #define CC_BASE_CONNECTION_ENUM 0x18
  53. #define CC_BASE_CONNECTION_CLOSE 0x19
  54. #define CC_BASE_DIRECTORY_GET_INFO 0x1A
  55. #define CC_BASE_DIRECTORY_SET_INFO 0x1B
  56. #define CC_BASE_FORK_ENUM 0x1C
  57. #define CC_BASE_FORK_CLOSE 0x1D
  58. #define CC_BASE_MESSAGE_SEND 0x1E
  59. #define CC_BASE_FINDER_SET 0x1F
  60. #define CC_BASE_GET_FSD_COMMAND 0x20
  61. #define CC_BASE_MAX 0x21
  62. #define OP_SERVICE_START AFP_CC(CC_BASE_SERVICE_START, METHOD_BUFFERED)
  63. #define OP_SERVICE_STOP AFP_CC(CC_BASE_SERVICE_STOP, METHOD_BUFFERED)
  64. #define OP_SERVICE_PAUSE AFP_CC(CC_BASE_SERVICE_PAUSE, METHOD_BUFFERED)
  65. #define OP_SERVICE_CONTINUE AFP_CC(CC_BASE_SERVICE_CONTINUE,METHOD_BUFFERED)
  66. #define OP_GET_STATISTICS AFP_CC(CC_BASE_GET_STATISTICS,METHOD_IN_DIRECT)
  67. #define OP_GET_STATISTICS_EX AFP_CC(CC_BASE_GET_STATISTICS_EX,METHOD_IN_DIRECT)
  68. #define OP_CLEAR_STATISTICS AFP_CC(CC_BASE_CLEAR_STATISTICS,METHOD_BUFFERED)
  69. #define OP_GET_PROF_COUNTERS AFP_CC(CC_BASE_GET_PROF_COUNTERS,METHOD_IN_DIRECT)
  70. #define OP_CLEAR_PROF_COUNTERS AFP_CC(CC_BASE_CLEAR_PROF_COUNTERS,METHOD_BUFFERED)
  71. #define OP_SERVER_ADD_SID_OFFSETS AFP_CC(CC_BASE_SERVER_ADD_SID_OFFSETS,METHOD_BUFFERED)
  72. #define OP_SERVER_GET_INFO AFP_CC(CC_BASE_SERVER_GET_INFO,METHOD_IN_DIRECT)
  73. #define OP_SERVER_SET_INFO AFP_CC(CC_BASE_SERVER_SET_INFO,METHOD_BUFFERED)
  74. #define OP_SERVER_ADD_ETC AFP_CC(CC_BASE_SERVER_ADD_ETC,METHOD_BUFFERED)
  75. #define OP_SERVER_SET_ETC AFP_CC(CC_BASE_SERVER_SET_ETC,METHOD_BUFFERED)
  76. #define OP_SERVER_DELETE_ETC AFP_CC(CC_BASE_SERVER_DELETE_ETC,METHOD_BUFFERED)
  77. #define OP_SERVER_ADD_ICON AFP_CC(CC_BASE_SERVER_ADD_ICON,METHOD_BUFFERED)
  78. #define OP_VOLUME_ADD AFP_CC(CC_BASE_VOLUME_ADD,METHOD_BUFFERED)
  79. #define OP_VOLUME_DELETE AFP_CC(CC_BASE_VOLUME_DELETE,METHOD_BUFFERED)
  80. #define OP_VOLUME_GET_INFO AFP_CC(CC_BASE_VOLUME_GET_INFO,METHOD_IN_DIRECT)
  81. #define OP_VOLUME_SET_INFO AFP_CC(CC_BASE_VOLUME_SET_INFO,METHOD_BUFFERED)
  82. #define OP_VOLUME_ENUM AFP_CC(CC_BASE_VOLUME_ENUM,METHOD_IN_DIRECT)
  83. #define OP_SESSION_ENUM AFP_CC(CC_BASE_SESSION_ENUM,METHOD_IN_DIRECT)
  84. #define OP_SESSION_CLOSE AFP_CC(CC_BASE_SESSION_CLOSE,METHOD_BUFFERED)
  85. #define OP_CONNECTION_ENUM AFP_CC(CC_BASE_CONNECTION_ENUM,METHOD_IN_DIRECT)
  86. #define OP_CONNECTION_CLOSE AFP_CC(CC_BASE_CONNECTION_CLOSE,METHOD_BUFFERED)
  87. #define OP_DIRECTORY_GET_INFO AFP_CC(CC_BASE_DIRECTORY_GET_INFO,METHOD_IN_DIRECT)
  88. #define OP_DIRECTORY_SET_INFO AFP_CC(CC_BASE_DIRECTORY_SET_INFO,METHOD_BUFFERED)
  89. #define OP_FORK_ENUM AFP_CC(CC_BASE_FORK_ENUM,METHOD_IN_DIRECT)
  90. #define OP_FORK_CLOSE AFP_CC(CC_BASE_FORK_CLOSE,METHOD_BUFFERED)
  91. #define OP_MESSAGE_SEND AFP_CC(CC_BASE_MESSAGE_SEND,METHOD_BUFFERED)
  92. #define OP_FINDER_SET AFP_CC(CC_BASE_FINDER_SET,METHOD_BUFFERED)
  93. #define OP_GET_FSD_COMMAND AFP_CC(CC_BASE_GET_FSD_COMMAND,METHOD_BUFFERED)
  94. #define POINTER_TO_OFFSET(val,start) \
  95. (val) = ((val) == NULL) ? NULL : (PVOID)( (PCHAR)(val) - (ULONG_PTR)(start) )
  96. #define OFFSET_TO_POINTER(val,start) \
  97. (val) = ((val) == NULL) ? NULL : (PVOID)( (PCHAR)(val) + (ULONG_PTR)(start) )
  98. #define AFPSERVER_DEVICE_NAME TEXT("\\Device\\MacFile")
  99. #define AFPSERVER_REGISTRY_KEY TEXT("\\Registry\\Machine\\System\\CurrentControlSet\\Services\\MacSrv")
  100. #define AFPSERVER_VOLUME_ICON_FILE { L'I', L'C', L'O', L'N', 0xF00D, 0000 }
  101. // Number of wchars in above string, including terminating null
  102. #define AFPSERVER_VOLUME_ICON_FILE_SIZE 6
  103. #define AFPSERVER_RESOURCE_STREAM L":AFP_Resource"
  104. // The following data structures are used exclusively by the
  105. // user-mode/kernel-mode interface.
  106. typedef enum _AFP_SID_TYPE
  107. {
  108. AFP_SID_TYPE_DOMAIN,
  109. AFP_SID_TYPE_PRIMARY_DOMAIN,
  110. AFP_SID_TYPE_WELL_KNOWN,
  111. AFP_SID_TYPE_LOGON
  112. } AFP_SID_TYPE;
  113. typedef struct _AFP_SID_OFFSET
  114. {
  115. DWORD Offset;
  116. AFP_SID_TYPE SidType;
  117. PBYTE pSid; // Actually an Offset from the
  118. // beginning of this structure.
  119. } AFP_SID_OFFSET, *PAFP_SID_OFFSET;
  120. // Packet used to add the SID/OFFSET pairs
  121. typedef struct _AFP_SID_OFFSET_DESC
  122. {
  123. ULONG CountOfSidOffsets; // Number of Sid-Offset pairs
  124. ULONG QuadAlignDummy1;
  125. AFP_SID_OFFSET SidOffsetPairs[1];
  126. }AFP_SID_OFFSET_DESC, *PAFP_SID_OFFSET_DESC;
  127. // Packet used by ServerEtcSet and ServerEtcDelete.
  128. typedef struct _EtcMapInfo2
  129. {
  130. UCHAR etc_type[AFP_TYPE_LEN];
  131. UCHAR etc_creator[AFP_CREATOR_LEN];
  132. WCHAR etc_extension[AFP_EXTENSION_LEN+1];
  133. } ETCMAPINFO2, *PETCMAPINFO2;
  134. // once passed by Service, this is used by Server internally
  135. typedef struct _EtcMapInfo
  136. {
  137. UCHAR etc_type[AFP_TYPE_LEN];
  138. UCHAR etc_creator[AFP_CREATOR_LEN];
  139. UCHAR etc_extension[AFP_EXTENSION_LEN+1]; // extension in ANSI
  140. } ETCMAPINFO, *PETCMAPINFO;
  141. typedef struct _SrvIconInfo
  142. {
  143. UCHAR icon_type[AFP_TYPE_LEN];
  144. UCHAR icon_creator[AFP_CREATOR_LEN];
  145. DWORD icon_icontype;
  146. DWORD icon_length;
  147. // Icon data follows
  148. } SRVICONINFO, *PSRVICONINFO;
  149. // Packet used by ServerEtcAdd.
  150. typedef struct _ServerEtcPacket
  151. {
  152. DWORD retc_NumEtcMaps; // Number of type creator mappings
  153. ETCMAPINFO2 retc_EtcMaps[1]; // List of Etc mappings
  154. } SRVETCPKT, *PSRVETCPKT;
  155. // The following is the generic enumerate request packet.
  156. typedef struct _EnumRequestPacket
  157. {
  158. DWORD erqp_Index; // Starting index from which the
  159. // enum should start. 0 => beginning
  160. DWORD erqp_Filter; // AFP_FILTER_ON_VOLUME_ID
  161. // or AFP_FILTER_ON_SESSION_ID
  162. DWORD erqp_ID; // Volume ID or sessions ID.
  163. DWORD QuadAlignDummy; // Quad Word Alignment enforcement
  164. } ENUMREQPKT, *PENUMREQPKT;
  165. // The following is the generic enumerate response packet.
  166. typedef struct _EnumResponsePacket
  167. {
  168. DWORD ersp_cTotEnts; // Total number of available entries
  169. DWORD ersp_cInBuf; // Number of entries in buffer union
  170. DWORD ersp_hResume; // Index of the first entry that will be
  171. // read on the subsequent call. Valid only
  172. // if the return code is AFPERR_MORE_DATA.
  173. DWORD QuadAlignDummy; // Quad Word Alignment enforcement
  174. // Will contain an array of AFP_FILE_INFO, AFP_SESSION_INFO,
  175. // AFP_CONNECTION_INFO or AFP_VOLUME_INFO structures.
  176. } ENUMRESPPKT, *PENUMRESPPKT;
  177. // The following is the generic set info. request packet.
  178. typedef struct _SetInfoRequestPacket
  179. {
  180. DWORD sirqp_parmnum; // Mask of bits representing fields
  181. DWORD dwAlignDummy; // For QWORD alignment
  182. // Will be followed by AFP_VOLUME_INFO or AFP_DIRECTORY_INFO structure
  183. } SETINFOREQPKT, *PSETINFOREQPKT;
  184. // The following data structures are used to send security information
  185. // from the service down to the server; or to send eventlog information from
  186. // the server up to the service.
  187. #define MAX_FSD_CMD_SIZE 4096
  188. #define NUM_SECURITY_UTILITY_THREADS 4
  189. typedef enum _AFP_FSD_CMD_ID
  190. {
  191. AFP_FSD_CMD_NAME_TO_SID,
  192. AFP_FSD_CMD_SID_TO_NAME,
  193. AFP_FSD_CMD_CHANGE_PASSWORD,
  194. AFP_FSD_CMD_LOG_EVENT,
  195. AFP_FSD_CMD_TERMINATE_THREAD
  196. } AFP_FSD_CMD_ID;
  197. // These used to live in afpconst.h, but now the service needs some of these
  198. // to do the native AppleUam stuff
  199. //
  200. // UAMs strings and values
  201. #define AFP_NUM_UAMS 6
  202. #define NO_USER_AUTHENT 0
  203. #define NO_USER_AUTHENT_NAME "No User Authent"
  204. #define CLEAR_TEXT_AUTHENT 1
  205. #define CLEAR_TEXT_AUTHENT_NAME "ClearTxt Passwrd"
  206. #define CUSTOM_UAM_V1 2
  207. #define CUSTOM_UAM_NAME_V1 "Microsoft V1.0"
  208. #define CUSTOM_UAM_V2 3
  209. #define CUSTOM_UAM_NAME_V2 "MS2.0"
  210. #define RANDNUM_EXCHANGE 4
  211. #define RANDNUM_EXCHANGE_NAME "Randnum Exchange"
  212. #define TWOWAY_EXCHANGE 5
  213. #define TWOWAY_EXCHANGE_NAME "2-Way Randnum exchange"
  214. // how many bytes of response comes back
  215. #define RANDNUM_RESP_LEN 8
  216. #define TWOWAY_RESP_LEN 16
  217. // this define stolen from ntsam.h
  218. #define SAM_MAX_PASSWORD_LENGTH (256)
  219. typedef struct _AFP_PASSWORD_DESC
  220. {
  221. BYTE AuthentMode;
  222. BYTE bPasswordLength;
  223. WCHAR DomainName[DNLEN+1];
  224. WCHAR UserName[LM20_UNLEN+1];
  225. BYTE OldPassword[LM_OWF_PASSWORD_LENGTH+1];
  226. BYTE NewPassword[(SAM_MAX_PASSWORD_LENGTH * 2) + 4];
  227. } AFP_PASSWORD_DESC, *PAFP_PASSWORD_DESC;
  228. typedef struct _AFP_EVENTLOG_DESC
  229. {
  230. DWORD MsgID;
  231. USHORT EventType;
  232. USHORT StringCount;
  233. DWORD DumpDataLen;
  234. DWORD QuadAlignDummy; // Quad Word Alignment enforcement
  235. PVOID pDumpData;
  236. LPWSTR * ppStrings;
  237. // Pointer to an array of string pointers that will follow the DumpData.
  238. } AFP_EVENTLOG_DESC, *PAFP_EVENTLOG_DESC;
  239. typedef struct _AFP_FSD_CMD_HEADER
  240. {
  241. AFP_FSD_CMD_ID FsdCommand;
  242. ULONG ntStatus;
  243. DWORD dwId;
  244. DWORD QuadAlignDummy; // Quad Word Alignment enforcement
  245. } AFP_FSD_CMD_HEADER, *PAFP_FSD_CMD_HEADER;
  246. typedef struct _AFP_FSD_CMD_PKT
  247. {
  248. AFP_FSD_CMD_HEADER Header;
  249. union
  250. {
  251. BYTE Sid[1];
  252. BYTE Name[1];
  253. AFP_PASSWORD_DESC Password;
  254. AFP_EVENTLOG_DESC Eventlog;
  255. } Data;
  256. } AFP_FSD_CMD_PKT, *PAFP_FSD_CMD_PKT;
  257. // The following definitions and macros are used both by the service as well as the
  258. // server. DO NOT CHANGE THIS w/o LOOKING at both the uses.
  259. // Directory Access Permissions
  260. #define DIR_ACCESS_SEARCH 0x01 // See Folders
  261. #define DIR_ACCESS_READ 0x02 // See Files
  262. #define DIR_ACCESS_WRITE 0x04 // Make Changes
  263. #define DIR_ACCESS_OWNER 0x80 // Only for user
  264. // if he has owner rights
  265. #define DIR_ACCESS_ALL (DIR_ACCESS_READ | \
  266. DIR_ACCESS_SEARCH | \
  267. DIR_ACCESS_WRITE)
  268. #define OWNER_RIGHTS_SHIFT 0
  269. #define GROUP_RIGHTS_SHIFT 8
  270. #define WORLD_RIGHTS_SHIFT 16
  271. #define USER_RIGHTS_SHIFT 24
  272. #define AFP_READ_ACCESS (READ_CONTROL | \
  273. FILE_READ_ATTRIBUTES | \
  274. FILE_TRAVERSE | \
  275. FILE_LIST_DIRECTORY | \
  276. FILE_READ_EA)
  277. #define AFP_WRITE_ACCESS (FILE_ADD_FILE | \
  278. FILE_ADD_SUBDIRECTORY| \
  279. FILE_WRITE_ATTRIBUTES| \
  280. FILE_WRITE_EA | \
  281. DELETE)
  282. #define AFP_OWNER_ACCESS (WRITE_DAC | \
  283. WRITE_OWNER)
  284. #define AFP_MIN_ACCESS (FILE_READ_ATTRIBUTES | \
  285. READ_CONTROL)
  286. #define AfpAccessMaskToAfpPermissions(Rights, Mask, Type) \
  287. if ((Type) == ACCESS_ALLOWED_ACE_TYPE) \
  288. { \
  289. if (((Mask) & AFP_READ_ACCESS) == AFP_READ_ACCESS) \
  290. (Rights) |= (DIR_ACCESS_READ | DIR_ACCESS_SEARCH); \
  291. if (((Mask) & AFP_WRITE_ACCESS) == AFP_WRITE_ACCESS) \
  292. (Rights) |= DIR_ACCESS_WRITE; \
  293. } \
  294. else \
  295. { \
  296. ASSERT((Type) == ACCESS_DENIED_ACE_TYPE); \
  297. if ((Mask) & AFP_READ_ACCESS) \
  298. (Rights) &= ~(DIR_ACCESS_READ | DIR_ACCESS_SEARCH); \
  299. if ((Mask) & AFP_WRITE_ACCESS) \
  300. (Rights) &= ~DIR_ACCESS_WRITE; \
  301. }
  302. #endif // _ADMIN_
  303.