Leaked source code of windows server 2003
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.

142 lines
4.1 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1989 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: file.c
  7. //
  8. // Description: This module contains support routines for the file
  9. // category API's for the AFP server service. These routines
  10. // are called by the RPC runtime.
  11. //
  12. // History:
  13. // June 21,1992. NarenG Created original version.
  14. //
  15. #include "afpsvcp.h"
  16. //**
  17. //
  18. // Call: AfpAdminrFileEnum
  19. //
  20. // Returns: NO_ERROR
  21. // ERROR_ACCESS_DENIED
  22. // non-zero returns from AfpServerIOCtrlGetInfo
  23. //
  24. // Description: This routine communicates with the AFP FSD to implement
  25. // the AfpAdminFileEnum function.
  26. //
  27. DWORD
  28. AfpAdminrFileEnum(
  29. IN AFP_SERVER_HANDLE hServer,
  30. IN OUT PFILE_INFO_CONTAINER pInfoStruct,
  31. IN DWORD dwPreferedMaximumLength,
  32. OUT LPDWORD lpdwTotalEntries,
  33. OUT LPDWORD lpdwResumeHandle
  34. )
  35. {
  36. AFP_REQUEST_PACKET AfpSrp;
  37. DWORD dwRetCode=0;
  38. DWORD dwAccessStatus=0;
  39. // Check if caller has access
  40. //
  41. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  42. {
  43. AFP_PRINT(( "SFMSVC: AfpAdminrFileEnum, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  44. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  45. dwRetCode, EVENTLOG_ERROR_TYPE );
  46. return( ERROR_ACCESS_DENIED );
  47. }
  48. if ( dwAccessStatus )
  49. {
  50. AFP_PRINT(( "SFMSVC: AfpAdminrFileEnum, AfpSecObjAccessCheck returned %ld\n",dwAccessStatus));
  51. return( ERROR_ACCESS_DENIED );
  52. }
  53. // Set up request packet and make IOCTL to the FSD
  54. //
  55. AfpSrp.dwRequestCode = OP_FORK_ENUM;
  56. AfpSrp.dwApiType = AFP_API_TYPE_ENUM;
  57. AfpSrp.Type.Enum.cbOutputBufSize = dwPreferedMaximumLength;
  58. if ( lpdwResumeHandle )
  59. AfpSrp.Type.Enum.EnumRequestPkt.erqp_Index = *lpdwResumeHandle;
  60. else
  61. AfpSrp.Type.Enum.EnumRequestPkt.erqp_Index = 0;
  62. dwRetCode = AfpServerIOCtrlGetInfo( &AfpSrp );
  63. if ( dwRetCode != ERROR_MORE_DATA && dwRetCode != NO_ERROR )
  64. return( dwRetCode );
  65. *lpdwTotalEntries = AfpSrp.Type.Enum.dwTotalAvail;
  66. pInfoStruct->pBuffer = (PAFP_FILE_INFO)(AfpSrp.Type.Enum.pOutputBuf);
  67. pInfoStruct->dwEntriesRead = AfpSrp.Type.Enum.dwEntriesRead;
  68. if ( lpdwResumeHandle )
  69. *lpdwResumeHandle = AfpSrp.Type.Enum.EnumRequestPkt.erqp_Index;
  70. // Convert all offsets to pointers
  71. //
  72. AfpBufOffsetToPointer( (LPBYTE)(pInfoStruct->pBuffer),
  73. pInfoStruct->dwEntriesRead,
  74. AFP_FILE_STRUCT );
  75. return( dwRetCode );
  76. }
  77. //**
  78. //
  79. // Call: AfpAdminrFileClose
  80. //
  81. // Returns: NO_ERROR
  82. // ERROR_ACCESS_DENIED
  83. // non-zero returns from AfpServerIOCtrl
  84. //
  85. // Description: This routine communicates with the AFP FSD to implement
  86. // the AfpAdminFileClose function.
  87. //
  88. DWORD
  89. AfpAdminrFileClose(
  90. IN AFP_SERVER_HANDLE hServer,
  91. IN DWORD dwFileId
  92. )
  93. {
  94. AFP_REQUEST_PACKET AfpSrp;
  95. AFP_FILE_INFO AfpFileInfo;
  96. DWORD dwAccessStatus=0;
  97. DWORD dwRetCode=0;
  98. // Check if caller has access
  99. //
  100. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  101. {
  102. AFP_PRINT(( "SFMSVC: AfpAdminrFileClose, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  103. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  104. dwRetCode, EVENTLOG_ERROR_TYPE );
  105. return( ERROR_ACCESS_DENIED );
  106. }
  107. if ( dwAccessStatus )
  108. {
  109. AFP_PRINT(( "SFMSVC: AfpAdminrFileClose, AfpSecObjAccessCheck returned %ld\n",dwAccessStatus));
  110. return( ERROR_ACCESS_DENIED );
  111. }
  112. // The FSD expects an AFP_FILE_INFO structure with only the id field
  113. // filled in.
  114. //
  115. AfpFileInfo.afpfile_id = dwFileId;
  116. // IOCTL the FSD to close the file
  117. //
  118. AfpSrp.dwRequestCode = OP_FORK_CLOSE;
  119. AfpSrp.dwApiType = AFP_API_TYPE_DELETE;
  120. AfpSrp.Type.Delete.pInputBuf = &AfpFileInfo;
  121. AfpSrp.Type.Delete.cbInputBufSize = sizeof(AFP_FILE_INFO);
  122. return ( AfpServerIOCtrl( &AfpSrp ) );
  123. }