From: <Or...@us...> - 2008-06-08 16:05:00
|
Revision: 228 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=228&view=rev Author: Oracle_ Date: 2008-06-08 09:05:03 -0700 (Sun, 08 Jun 2008) Log Message: ----------- Fixed bug with Temp path. Modified Paths: -------------- ACMServer/branches/sharp tester/ReadMe.txt ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp ACMServer/branches/sharp tester/SourceTest/SourceTest.h Modified: ACMServer/branches/sharp tester/ReadMe.txt =================================================================== --- ACMServer/branches/sharp tester/ReadMe.txt 2008-06-07 19:51:51 UTC (rev 227) +++ ACMServer/branches/sharp tester/ReadMe.txt 2008-06-08 16:05:03 UTC (rev 228) @@ -26,13 +26,14 @@ \xF6\xE5 \xF8\xEB\xFF\xF5 \xE4\xEE \xF1\xEE\xF0\xF1\xE0, \xE0 \xE4\xF0\xF3\xE3\xE8\xE9 - \xF6\xE5 \xF8\xEB\xFF\xF5, \xE4\xE5 \xEF\xEE\xE2\xE8\xED\xED\xE8\xE9 \xF1\xF2\xE2\xEE\xF0\xE8\xF2\xE8\xF1\xFC EXE \xF4\xE0\xE9\xEB. \xC2\xF1\xB3 \xB3\xED\xF8\xB3 \xEE\xEF\xF6\xB3\xBF \xE2\xE8 \xEF\xEE\xE2\xE8\xED\xED\xB3 \xE2\xF1\xF2\xE0\xED\xEE\xE2\xE8\xF2\xE8 \xF1\xE0\xEC\xEE\xF1\xF2\xB3\xE9\xED\xEE (\xED\xE0\xEF\xF0\xE8\xEA\xEB\xE0\xE4 \xE7\xE0 \xE4\xEE\xEF\xEE\xEC\xEE\xE3\xEE\xFE *.bat \xF4\xE0\xE9\xEB\xF3). 4. TestLibrary \xCE\xC1\xCE\xC2'\xDF\xC7\xCA\xCE\xC2\xCE \xEF\xEE\xE2\xE8\xED\xED\xE0 \xE5\xEA\xF1\xEF\xEE\xF0\xF2\xF3\xE2\xE0\xF2\xE8 \xF2\xE0\xEA\xB3 \xF4\xF3\xED\xEA\xF6\xB3\xBF (\xB3\xED\xE0\xEA\xF8\xE5 \xF2\xE5\xF1\xF2\xF3\xE2\xE0\xEB\xEA\xE0 \xEF\xF0\xEE\xF1\xF2\xEE \xE2\xEF\xE0\xE4\xE5): - bool CheckCL(char* src, int cl, char*& details) - must check codelimit - bool CheckDF(char* src, int lang, char*& details) - must check DF - bool CheckRTL(int usedrealtime, int realtimelimit) - must check RTL - bool CheckTL(int usedtime, int timelimit) - must check TL - int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details) - checks WA,OE,PE - void FreeChar(char* buf); - must free memory used by buf - \xE4\xE5\xF2\xE0\xEB\xB3 \xF0\xE5\xE0\xEB\xB3\xE7\xE0\xF6\xB3\xBF \xF6\xE8\xF5 \xF4\xF3\xED\xEA\xF6\xB3\xE9 \xE2 SourceTest.h + bool CheckCL(char* src, int cl, char*& details) - must check codelimit + bool CheckDF(char* src, int lang, char*& details) - must check DF + bool CheckRTL(int usedrealtime, int realtimelimit) - must check RTL + bool CheckTL(int usedtime, int timelimit) - must check TL + int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details) - checks WA,OE,PE + void FreeChar(char* buf); - must free memory used by buf + \xC1\xB3\xE1\xEB\xB3\xEE\xF2\xE5\xEA\xE0 \xEF\xEE\xE2\xE8\xED\xED\xE0 \xF1\xE0\xEC\xE0 \xE2\xE8\xE4\xB3\xEB\xFF\xF2\xE8 \xEF\xE0\xEC'\xFF\xF2\xFC \xEF\xB3\xE4 details, \xE0 \xE2\xE8\xE4\xE0\xEB\xFF\xF2\xE8 \xE1\xF3\xE4\xE5 \xF1\xE0\xEC\xE0 \xF2\xE5\xF1\xF2\xF3\xE2\xE0\xEB\xEA\xE0. + \xC4\xE5\xF2\xE0\xEB\xB3 \xF0\xE5\xE0\xEB\xB3\xE7\xE0\xF6\xB3\xBF \xF6\xE8\xF5 \xF4\xF3\xED\xEA\xF6\xB3\xE9 \xE2 SourceTest.h. //////////////////////////////////////////////////////////////////////// ///////////////////////\xD1\xD2\xD0\xD3\xCA\xD2\xD3\xD0\xC0 \xD4\xC0\xC9˲\xC2///////////////////////////////// //////////////////////////////////////////////////////////////////////// @@ -41,7 +42,7 @@ 2. InData.txt - \xEC\xB3\xF1\xF2\xE8\xF2\xFC 4 \xF0\xFF\xE4\xEA\xE8: \xE2 \xEF\xE5\xF0\xF8\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF2\xEE\xF0\xE0 \xE2 \xE4\xF0\xF3\xE3\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xF2\xE5\xF1\xF2\xF3 - \xE2 \xF2\xF0\xE5\xF2\xFC\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xEF\xE0\xEF\xEA\xE8 \xE2 \xFF\xEA\xB3\xE9 \xE1\xF3\xE4\xF3\xF2\xFC \xE7\xE1\xE5\xF0\xB3\xE3\xE0\xF2\xE8\xF1\xFC \xEF\xF0\xEE\xEC\xB3\xE6\xED\xB3 \xF4\xE0\xE9\xEB\xE8 (\xEE\xE1\xEE\xE2'\xFF\xE7\xEA\xEE\xE2\xEE \xEF\xEE\xE2\xED\xE8\xE9, \xE0 \xED\xE5 \xE2\xB3\xE4\xED\xEE\xF1\xED\xE8\xE9) + \xE2 \xF2\xF0\xE5\xF2\xFC\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xEF\xE0\xEF\xEA\xE8 \xE2 \xFF\xEA\xB3\xE9 \xE1\xF3\xE4\xF3\xF2\xFC \xE7\xE1\xE5\xF0\xB3\xE3\xE0\xF2\xE8\xF1\xFC \xEF\xF0\xEE\xEC\xB3\xE6\xED\xB3 \xF4\xE0\xE9\xEB\xE8 \xE2 \xF7\xE5\xF2\xE2\xE5\xF0\xF2\xEE\xEC\xF3 - \xF8\xEB\xFF\xF5 \xE4\xEE \xF4\xE0\xE9\xEB\xF3, \xF9\xEE \xEC\xB3\xF1\xF2\xE8\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ED\xFF\xF2\xE8 \xEA\xB3\xEB\xFC\xEA\xE0 \xF5\xE2\xE8\xEB\xE8\xED. +\xC2 \xFE\xE7\xE5\xF0\xE0 TestingUser \xEF\xE0\xF0\xEE\xEB\xFC USER12345. \xDF\xEA\xF9\xEE \xEF\xF0\xEE\xE3\xF0\xE0\xEC\xB3 \xED\xE5 \xE2\xE4\xE0\xBA\xF2\xFC\xF1\xFF \xF1\xF2\xE2\xEE\xF0\xE8\xF2\xE8 \xEF\xF0\xEE\xF6\xE5\xF1 \xE2\xB3\xE4 \xB3\xEC\xE5\xED\xB3 TestingUSer, \xF2\xEE \xE2\xEE\xED\xE0 \xE9\xEE\xE3\xEE \xF1\xF2\xE2\xEE\xF0\xFE\xBA \xE2\xB3\xE4 \xB3\xEC\xE5\xED\xB3 \xFE\xE7\xE5\xF0\xE0 \xEF\xB3\xE4 \xFF\xEA\xE8\xEC \xE7\xE0\xEF\xF3\xF1\xEA\xE0\xBA\xF2\xFC\xF1\xFF \xF1\xE0\xEC\xE0. \xD2\xEE\xE4\xB3 \xEF\xF0\xEE\xF6\xE5\xF1 \xF1\xF2\xE0\xBA Unsecured \xB3 \xEC\xEE\xE6\xE5 \xE4\xEE\xF1\xF2\xF3\xEF\xE0\xF2\xE8\xF1\xFC \xE4\xEE \xF4\xE0\xE9\xEB\xEE\xE2\xEE\xBF \xF1\xE8\xF1\xF2\xE5\xEC\xE8. \ No newline at end of file Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-07 19:51:51 UTC (rev 227) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.cpp 2008-06-08 16:05:03 UTC (rev 228) @@ -63,10 +63,18 @@ FCompPath=gcnew String(""); FRunAll=true; lib=LoadLibraryA("TestLibrary.dll"); -FSecurity=new TSecure(); +FSecurity=NULL; +InitSecure(false); init(); //initializing of critical section } +void TSource::InitSecure(bool SetPrivAnyway) +{ + if (FSecurity!=NULL) + delete FSecurity; + FSecurity=new TSecure(SetPrivAnyway); +} + TSource::~TSource() { if (lib!=NULL) @@ -777,7 +785,7 @@ fi->SetAccessControl(fs); } -TSecure::TSecure() +TSecure::TSecure(bool SetPrivAnyway) //if SetPrivAnyway==true, then all destrictions are set to the user even if it already exists { SetUserObjectFullAccess( GetThreadDesktop(GetCurrentThreadId())); //needed for accessing from CreateProcessAsUser SetUserObjectFullAccess( GetProcessWindowStation()); //needed for accessing from CreateProcessAsUser @@ -792,29 +800,35 @@ ui.usri1_priv=USER_PRIV_USER; ui.usri1_script_path=NULL; st=NetUserAdd(NULL,1,(LPBYTE)&ui,NULL); //trying to create new user + bool userex=false; if (st!=NERR_Success) { if (st==NERR_UserExists) - return; //if user exists just do nothing - MessageBox(NULL,L"Can not create testing user - only unsecured mode",L"Warning",MB_ICONWARNING|MB_OK); - return; + userex=true; else + { + MessageBox(NULL,L"Can not create testing user - only unsecured mode",L"Warning",MB_ICONWARNING|MB_OK); + return; + } } - array<DriveInfo^>^ drv=DriveInfo::GetDrives(); - for (int i=0;i<drv->Length;i++) //for all drives set limitation - if (drv[i]->DriveType==DriveType::Fixed) - DenyAccessFolder(drv[i]->Name); - wchar_t buf[MAX_PATH+1]; - GetEnvironmentVariableW(L"ProgramFiles",buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - GetEnvironmentVariable(L"ALLUSERSPROFILE",buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - GetWindowsDirectory(buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - GetSystemDirectory(buf,MAX_PATH); - DenyAccessFolder(gcnew String(buf)); - DWORD size=MAX_PATH; - GetProfilesDirectory(buf,&size); - DenyAccessFolder(gcnew String(buf)); + if ((!userex)||(SetPrivAnyway)) + { + array<DriveInfo^>^ drv=DriveInfo::GetDrives(); + for (int i=0;i<drv->Length;i++) //for all drives set limitation + if (drv[i]->DriveType==DriveType::Fixed) + DenyAccessFolder(drv[i]->Name); + wchar_t buf[MAX_PATH+1]; + GetEnvironmentVariableW(L"ProgramFiles",buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + GetEnvironmentVariable(L"ALLUSERSPROFILE",buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + GetWindowsDirectory(buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + GetSystemDirectory(buf,MAX_PATH); + DenyAccessFolder(gcnew String(buf)); + DWORD size=MAX_PATH; + GetProfilesDirectory(buf,&size); + DenyAccessFolder(gcnew String(buf)); + } } TSecure::~TSecure() @@ -826,6 +840,9 @@ { HANDLE token=NULL,Token=NULL; wchar_t* env=NULL; + wchar_t buflpCommandLine[MAX_PATH+1]; + if (!GetFullPathName(lpCommandLine,MAX_PATH,buflpCommandLine,NULL)) + wcscpy(buflpCommandLine,lpCommandLine); if (LogonUser((LPWSTR)USER_NAME,(LPWSTR)".",(LPWSTR)USER_PASSW,LOGON32_LOGON_NETWORK,LOGON32_PROVIDER_DEFAULT,&Token)) { FileInfo^ fi=gcnew FileInfo(gcnew String(lpCommandLine)); @@ -838,7 +855,7 @@ { if (CreateEnvironmentBlock((LPVOID*)&env,token,FALSE)) { - if (CreateProcessAsUser(token,NULL,lpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags|CREATE_UNICODE_ENVIRONMENT,env,NULL,lpStartupInfo,lpProcessInformation)) + if (CreateProcessAsUser(token,NULL,buflpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags|CREATE_UNICODE_ENVIRONMENT,env,NULL,lpStartupInfo,lpProcessInformation)) { DestroyEnvironmentBlock(env); RevertToSelf(); @@ -858,7 +875,7 @@ if (Token!=NULL) CloseHandle(Token); Details="Unsecured process. Result details: "; - if (CreateProcess(NULL,lpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,lpProcessInformation)) + if (CreateProcess(NULL,buflpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags,NULL,NULL,lpStartupInfo,lpProcessInformation)) return true; return false; } Modified: ACMServer/branches/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-07 19:51:51 UTC (rev 227) +++ ACMServer/branches/sharp tester/SourceTest/SourceTest.h 2008-06-08 16:05:03 UTC (rev 228) @@ -249,7 +249,7 @@ { private: public: - TSecure(); + TSecure(bool SetPrivAnyway); ~TSecure(); bool RunProcess(LPWSTR lpCommandLine,BOOL bInheritHandles,DWORD dwCreationFlags,LPSTARTUPINFOW lpStartupInfo,LPPROCESS_INFORMATION lpProcessInformation,String^% Details); }; @@ -308,6 +308,7 @@ public: TSource(); ~TSource(); + void InitSecure(bool SetPrivAnyway); void CheckCL(); void CheckDF(); void Compile(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |