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.

230 lines
6.5 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1989 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: server.c
  7. //
  8. // Description: This module contains support routines for the server
  9. // category API's for the AFP server service. These routines
  10. // are called by the RPC runtime.
  11. //
  12. // History:
  13. // December 15,1992. NarenG Created original version.
  14. //
  15. #include "afpsvcp.h"
  16. //**
  17. //
  18. // Call: AfpAdminrServerGetInfo
  19. //
  20. // Returns: NO_ERROR
  21. // ERROR_ACCESS_DENIED
  22. // non-zero retunrs from AfpServerIOCtrlGetInfo
  23. //
  24. // Description: This routine communicates with the AFP FSD to implement
  25. // the AfpAdminServerGetInfo function.
  26. //
  27. DWORD
  28. AfpAdminrServerGetInfo(
  29. IN AFP_SERVER_HANDLE hServer,
  30. OUT PAFP_SERVER_INFO* ppAfpServerInfo
  31. )
  32. {
  33. AFP_REQUEST_PACKET AfpSrp;
  34. DWORD dwRetCode=0;
  35. DWORD dwAccessStatus=0;
  36. // Check if caller has access
  37. //
  38. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  39. {
  40. AFP_PRINT(( "SFMSVC: AfpAdminrServerGetInfo, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  41. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  42. dwRetCode, EVENTLOG_ERROR_TYPE );
  43. return( ERROR_ACCESS_DENIED );
  44. }
  45. if ( dwAccessStatus )
  46. {
  47. AFP_PRINT(( "SFMSVC: AfpAdminrServerGetInfo, AfpSecObjAccessCheck returned %ld\n",dwRetCode));
  48. return( ERROR_ACCESS_DENIED );
  49. }
  50. // Make IOCTL to get info
  51. //
  52. AfpSrp.dwRequestCode = OP_SERVER_GET_INFO;
  53. AfpSrp.dwApiType = AFP_API_TYPE_GETINFO;
  54. AfpSrp.Type.GetInfo.pInputBuf = NULL;
  55. AfpSrp.Type.GetInfo.cbInputBufSize = 0;
  56. dwRetCode = AfpServerIOCtrlGetInfo( &AfpSrp );
  57. if ( dwRetCode != ERROR_MORE_DATA && dwRetCode != NO_ERROR )
  58. return( dwRetCode );
  59. *ppAfpServerInfo = (PAFP_SERVER_INFO)(AfpSrp.Type.GetInfo.pOutputBuf);
  60. // Convert all offsets to pointers
  61. //
  62. AfpBufOffsetToPointer((LPBYTE)*ppAfpServerInfo,1,AFP_SERVER_STRUCT);
  63. return( dwRetCode );
  64. }
  65. //**
  66. //
  67. // Call: AfpAdminrServerSetInfo
  68. //
  69. // Returns: NO_ERROR
  70. // ERROR_ACCESS_DENIED
  71. // non-zero retunrs from AfpServerIOCtrl
  72. //
  73. // Description: This routine communicates with the AFP FSD to implement
  74. // the AfpAdminServerSetInfo function.
  75. //
  76. DWORD
  77. AfpAdminrServerSetInfo(
  78. IN AFP_SERVER_HANDLE hServer,
  79. IN PAFP_SERVER_INFO pAfpServerInfo,
  80. IN DWORD dwParmNum
  81. )
  82. {
  83. AFP_REQUEST_PACKET AfpSrp;
  84. PAFP_SERVER_INFO pAfpServerInfoSR;
  85. DWORD cbAfpServerInfoSRSize;
  86. DWORD dwRetCode=0;
  87. DWORD dwAccessStatus=0;
  88. LPWSTR lpwsServerName = NULL;
  89. //
  90. // if this is a "notification" that Guest account changed (disable to enable
  91. // or vice versa), don't bother checking access for caller: see if guest
  92. // account was indeed flipped, and let afp server know.
  93. // NOTICE we don't do (dwParmNum & AFP_SERVER_GUEST_ACCT_NOTIFY) here, as an
  94. // extra precaution.
  95. //
  96. if (dwParmNum == AFP_SERVER_GUEST_ACCT_NOTIFY)
  97. {
  98. if (pAfpServerInfo->afpsrv_options ^
  99. (AfpGlobals.dwServerOptions & AFP_SRVROPT_GUESTLOGONALLOWED))
  100. {
  101. AfpGlobals.dwServerOptions ^= AFP_SRVROPT_GUESTLOGONALLOWED;
  102. }
  103. else
  104. {
  105. AFP_PRINT(( "AFPSVC_server: no change in GuestAcct, nothing done\n"));
  106. return(NO_ERROR);
  107. }
  108. }
  109. // Check if caller has access
  110. //
  111. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  112. {
  113. AFP_PRINT(( "AFPSVC_server: Sorry, accessCheck failed! %ld\n",dwRetCode));
  114. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  115. dwRetCode, EVENTLOG_ERROR_TYPE );
  116. return( ERROR_ACCESS_DENIED );
  117. }
  118. if ( dwAccessStatus )
  119. {
  120. AFP_PRINT(("AFPSVC_server: Sorry, accessCheck failed at 2! %ld\n",dwAccessStatus));
  121. return( ERROR_ACCESS_DENIED );
  122. }
  123. // Check to see if the client wants to set the server name as well
  124. //
  125. if ( dwParmNum & AFP_SERVER_PARMNUM_NAME )
  126. {
  127. lpwsServerName = pAfpServerInfo->afpsrv_name;
  128. pAfpServerInfo->afpsrv_name = NULL;
  129. dwParmNum &= (~AFP_SERVER_PARMNUM_NAME);
  130. }
  131. // Make buffer self relative.
  132. //
  133. if ( dwRetCode = AfpBufMakeFSDRequest( (LPBYTE)pAfpServerInfo,
  134. sizeof(SETINFOREQPKT),
  135. AFP_SERVER_STRUCT,
  136. (LPBYTE*)&pAfpServerInfoSR,
  137. &cbAfpServerInfoSRSize ) )
  138. {
  139. return( dwRetCode );
  140. }
  141. // Make IOCTL to set info
  142. //
  143. AfpSrp.dwRequestCode = OP_SERVER_SET_INFO;
  144. AfpSrp.dwApiType = AFP_API_TYPE_SETINFO;
  145. AfpSrp.Type.SetInfo.pInputBuf = pAfpServerInfoSR;
  146. AfpSrp.Type.SetInfo.cbInputBufSize = cbAfpServerInfoSRSize;
  147. AfpSrp.Type.SetInfo.dwParmNum = dwParmNum;
  148. dwRetCode = AfpServerIOCtrl( &AfpSrp );
  149. if ( dwRetCode == NO_ERROR )
  150. {
  151. LPBYTE pServerInfo;
  152. // guest-account notification? nothing to write to registry, done here
  153. if (dwParmNum == AFP_SERVER_GUEST_ACCT_NOTIFY)
  154. {
  155. LocalFree( pAfpServerInfoSR );
  156. return( dwRetCode );
  157. }
  158. // If the client wants to set the servername as well
  159. //
  160. if ( lpwsServerName != NULL ) {
  161. LocalFree( pAfpServerInfoSR );
  162. // Make another self relative buffer with the server name.
  163. //
  164. pAfpServerInfo->afpsrv_name = lpwsServerName;
  165. dwParmNum |= AFP_SERVER_PARMNUM_NAME;
  166. if ( dwRetCode = AfpBufMakeFSDRequest(
  167. (LPBYTE)pAfpServerInfo,
  168. sizeof(SETINFOREQPKT),
  169. AFP_SERVER_STRUCT,
  170. (LPBYTE*)&pAfpServerInfoSR,
  171. &cbAfpServerInfoSRSize ) )
  172. {
  173. return( dwRetCode );
  174. }
  175. AfpSrp.dwRequestCode = OP_SERVER_SET_INFO;
  176. AfpSrp.dwApiType = AFP_API_TYPE_SETINFO;
  177. AfpSrp.Type.SetInfo.pInputBuf = pAfpServerInfoSR;
  178. AfpSrp.Type.SetInfo.cbInputBufSize = cbAfpServerInfoSRSize;
  179. AfpSrp.Type.SetInfo.dwParmNum = dwParmNum;
  180. dwRetCode = AfpServerIOCtrl( &AfpSrp );
  181. }
  182. pServerInfo = ((LPBYTE)pAfpServerInfoSR)+sizeof(SETINFOREQPKT);
  183. if (dwRetCode == NO_ERROR)
  184. {
  185. dwRetCode = AfpRegServerSetInfo( (PAFP_SERVER_INFO)pServerInfo,
  186. dwParmNum );
  187. }
  188. else
  189. {
  190. AFP_PRINT(("AFPSVC_server: AfpServerIOCtrl failed %lx\n",dwRetCode));
  191. }
  192. }
  193. LocalFree( pAfpServerInfoSR );
  194. return( dwRetCode );
  195. }