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.

309 lines
7.3 KiB

  1. /*************************************************************************
  2. *
  3. * registry.c
  4. *
  5. * Functions to provide easy access to security (ACLs).
  6. *
  7. * Copyright Microsoft, 1998
  8. *
  9. *
  10. *************************************************************************/
  11. /* include files */
  12. #include <nt.h>
  13. #include <ntrtl.h>
  14. #include <nturtl.h>
  15. #include <windows.h>
  16. #include "winsta.h"
  17. #include "syslib.h"
  18. #include "regapi.h"
  19. #if DBG
  20. #define DBGPRINT(x) DbgPrint x
  21. #if DBGTRACE
  22. #define TRACE0(x) DbgPrint x
  23. #define TRACE1(x) DbgPrint x
  24. #else
  25. #define TRACE0(x)
  26. #define TRACE1(x)
  27. #endif
  28. #else
  29. #define DBGPRINT(x)
  30. #define TRACE0(x)
  31. #define TRACE1(x)
  32. #endif
  33. /*
  34. * Data Structure
  35. */
  36. /// NONE YET...
  37. /*
  38. * Definitions
  39. */
  40. #define SZENABLE TEXT("1")
  41. /*
  42. * procedure prototypes
  43. */
  44. BOOL QueryFlatTempKey( VOID );
  45. /*****************************************************************************
  46. *
  47. * QueryFlatTempKey
  48. *
  49. * ENTRY: Nothing.
  50. *
  51. * EXIT: TRUE - enabled
  52. * FALSE - disabled (key doesn't exist or isn't "1")
  53. *
  54. *
  55. ****************************************************************************/
  56. BOOL
  57. QueryFlatTempKey( VOID )
  58. {
  59. DWORD dwType = REG_SZ;
  60. DWORD dwSize = 3 * sizeof(WCHAR);
  61. WCHAR szValue[3];
  62. HKEY Handle;
  63. LONG rc;
  64. //
  65. // Ideally, I could just call TS's RegGetMachinePolicy() and get the policy. But
  66. // that makes a lot of reg reads and I just don't want to slow down the
  67. // login cycle.
  68. // So, for now, I will read the reg policy tree directly.
  69. // 08/15/2000 AraBern
  70. //
  71. // see if there is a policy value:
  72. {
  73. DWORD dwType;
  74. DWORD perSessionTempDir;
  75. LONG Err;
  76. HKEY hKey;
  77. DWORD dwSize = sizeof(DWORD);
  78. Err = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  79. TS_POLICY_SUB_TREE,
  80. 0,
  81. KEY_QUERY_VALUE,
  82. &hKey);
  83. if(Err == ERROR_SUCCESS)
  84. {
  85. Err = RegQueryValueEx(hKey,
  86. REG_TERMSRV_PERSESSIONTEMPDIR ,
  87. NULL,
  88. &dwType,
  89. (LPBYTE)&perSessionTempDir,
  90. &dwSize);
  91. RegCloseKey(hKey);
  92. if(Err == ERROR_SUCCESS)
  93. {
  94. // if we have per session temp folders, then obviously we can't allow flat temp.
  95. if (perSessionTempDir )
  96. {
  97. return FALSE;
  98. }
  99. // else is a fall thru, since not having per session does not mean having flat temp.
  100. }
  101. // else is a fall thru to the below block
  102. }
  103. }
  104. // by now we have no policy present, so if the flat temp is set.
  105. /*
  106. * Open registry
  107. */
  108. if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE,
  109. REG_CONTROL_TSERVER,
  110. 0,
  111. KEY_READ,
  112. &Handle ) != ERROR_SUCCESS ) {
  113. return FALSE;
  114. }
  115. /*
  116. * Read registry value
  117. */
  118. rc = RegQueryValueExW( Handle,
  119. REG_CITRIX_FLATTEMPDIR,
  120. NULL,
  121. &dwType,
  122. (PUCHAR)&szValue,
  123. &dwSize );
  124. szValue[(sizeof(szValue)/sizeof(szValue[0])) - 1] = L'\0';
  125. /*
  126. * Close registry and key handle
  127. */
  128. RegCloseKey( Handle );
  129. return( (rc == ERROR_SUCCESS) && (lstrcmp(szValue,SZENABLE) == 0) );
  130. } // end of QueryFlatTempKey()
  131. // FROM regapi\reguc.c : this function has been modified to get rid of all
  132. // registry accesses.
  133. /*******************************************************************************
  134. *
  135. * RegDefaultUserConfigQueryW (UNICODE)
  136. *
  137. * Query the Default User Configuration from the indicated server's registry.
  138. *
  139. * ENTRY:
  140. * pServerName (input)
  141. * Points to string of server to access (NULL for current machine).
  142. * pUserConfig (input)
  143. * Pointer to a USERCONFIGW structure that will receive the default
  144. * user configuration information.
  145. * UserConfigLength (input)
  146. * Specifies the length in bytes of the pUserConfig buffer.
  147. * pReturnLength (output)
  148. * Receives the number of bytes placed in the pUserConfig buffer.
  149. *
  150. * EXIT:
  151. * Always will return ERROR_SUCCESS, unless UserConfigLength is incorrect.
  152. *
  153. ******************************************************************************/
  154. LONG WINAPI
  155. RegDefaultUserConfigQueryW( WCHAR * pServerName,
  156. PUSERCONFIGW pUserConfig,
  157. ULONG UserConfigLength,
  158. PULONG pReturnLength )
  159. {
  160. UNREFERENCED_PARAMETER( pServerName );
  161. /*
  162. * Validate length and zero-initialize the destination
  163. * USERCONFIGW buffer.
  164. */
  165. if ( UserConfigLength < sizeof(USERCONFIGW) )
  166. return( ERROR_INSUFFICIENT_BUFFER );
  167. /*
  168. * Initialize to an initial default.
  169. */
  170. memset(pUserConfig, 0, UserConfigLength);
  171. pUserConfig->fInheritAutoLogon = TRUE;
  172. pUserConfig->fInheritResetBroken = TRUE;
  173. pUserConfig->fInheritReconnectSame = TRUE;
  174. pUserConfig->fInheritInitialProgram = TRUE;
  175. pUserConfig->fInheritCallback = FALSE;
  176. pUserConfig->fInheritCallbackNumber = TRUE;
  177. pUserConfig->fInheritShadow = TRUE;
  178. pUserConfig->fInheritMaxSessionTime = TRUE;
  179. pUserConfig->fInheritMaxDisconnectionTime = TRUE;
  180. pUserConfig->fInheritMaxIdleTime = TRUE;
  181. pUserConfig->fInheritAutoClient = TRUE;
  182. pUserConfig->fInheritSecurity = FALSE;
  183. pUserConfig->fPromptForPassword = FALSE;
  184. pUserConfig->fResetBroken = FALSE;
  185. pUserConfig->fReconnectSame = FALSE;
  186. pUserConfig->fLogonDisabled = FALSE;
  187. pUserConfig->fAutoClientDrives = TRUE;
  188. pUserConfig->fAutoClientLpts = TRUE;
  189. pUserConfig->fForceClientLptDef = TRUE;
  190. pUserConfig->fDisableEncryption = TRUE;
  191. pUserConfig->fHomeDirectoryMapRoot = FALSE;
  192. pUserConfig->fUseDefaultGina = FALSE;
  193. pUserConfig->fDisableCpm = FALSE;
  194. pUserConfig->fDisableCdm = FALSE;
  195. pUserConfig->fDisableCcm = FALSE;
  196. pUserConfig->fDisableLPT = FALSE;
  197. pUserConfig->fDisableClip = FALSE;
  198. pUserConfig->fDisableExe = FALSE;
  199. pUserConfig->fDisableCam = FALSE;
  200. pUserConfig->UserName[0] = 0;
  201. pUserConfig->Domain[0] = 0;
  202. pUserConfig->Password[0] = 0;
  203. pUserConfig->WorkDirectory[0] = 0;
  204. pUserConfig->InitialProgram[0] = 0;
  205. pUserConfig->CallbackNumber[0] = 0;
  206. pUserConfig->Callback = Callback_Disable;
  207. pUserConfig->Shadow = Shadow_EnableInputNotify;
  208. pUserConfig->MaxConnectionTime = 0;
  209. pUserConfig->MaxDisconnectionTime = 0;
  210. pUserConfig->MaxIdleTime = 0;
  211. pUserConfig->KeyboardLayout = 0;
  212. pUserConfig->MinEncryptionLevel = 1;
  213. pUserConfig->fWallPaperDisabled = FALSE;
  214. pUserConfig->NWLogonServer[0] = 0;
  215. pUserConfig->WFProfilePath[0] = 0;
  216. pUserConfig->WFHomeDir[0] = 0;
  217. pUserConfig->WFHomeDirDrive[0] = 0;
  218. pUserConfig->fCursorBlinkDisabled = FALSE;
  219. *pReturnLength = sizeof(USERCONFIGW);
  220. return( ERROR_SUCCESS );
  221. }