Procházet zdrojové kódy

Z991239-1017 #comment feat 解决cef文件权限问题,cef启动添加no-sanbox属性,以管理员权限启动

陈良瑜80374463 před 5 roky
rodič
revize
b3b13fbfcf

+ 3 - 1
CMakeLists.txt

@@ -504,7 +504,9 @@ if(CEF_BIN_DIR)
 		if(IS_DIRECTORY ${item})
 			install(DIRECTORY "${item}" DESTINATION "${RVC_CHROMIUM_PATH}" COMPONENT libraries )
 		else()
-			install(FILES ${item} DESTINATION "${RVC_CHROMIUM_PATH}" COMPONENT libraries)
+			install(FILES ${item} DESTINATION "${RVC_CHROMIUM_PATH}" 
+			PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
+			COMPONENT libraries)
 		endif()
 	endforeach()
 endif(CEF_BIN_DIR)

+ 7 - 5
Module/mod_chromium/CModTools.cpp

@@ -49,7 +49,7 @@ bool CModTools::killAllChromium()
 	}
 	return true;
 #else
-	boost::process::child child_process("killall -9 cefclient");
+	boost::process::child child_process("sudo killall -9 cefclient");
 	child_process.wait();
 	return true;
 #endif
@@ -92,8 +92,9 @@ std::pair<bool, std::string> CModTools::getMainUrl()
 
 std::string CModTools::generateCefclientCmd(bool isExtend, std::string mainUrl)
 {
-	CSimpleStringA strChromiumPath;
-	this->m_pEntity->GetFunction()->GetPath("Base", strChromiumPath);
+	CSimpleStringA strChromiumPath, basePath;
+	this->m_pEntity->GetFunction()->GetPath("Base", basePath);
+	strChromiumPath.Append("sudo ").Append(basePath);
 	strChromiumPath.Append(CSimpleStringA(SPLIT_SLASH_STR) + "bin" + SPLIT_SLASH_STR + "Chromium" + SPLIT_SLASH_STR);
 
 	CSimpleStringA strCmdLine = "";
@@ -109,7 +110,8 @@ std::string CModTools::generateCefclientCmd(bool isExtend, std::string mainUrl)
 	CSimpleStringA cachePath;
 	this->m_pEntity->GetFunction()->GetPath("Temp", cachePath);
 	cachePath.Append(CSimpleStringA(SPLIT_SLASH_STR) + "cefCache");
-	strCmdLine.Append(" --hide-controls=true --cache-path=").Append(cachePath);
+	//strCmdLine.Append(" --hide-controls=true --cache-path=").Append(cachePath);
+	strCmdLine.Append(" --no-sandbox");
 	DbgEx("cmdline : %s", strCmdLine.GetData());
 
 	return strCmdLine.GetData();
@@ -152,6 +154,7 @@ void CModTools::cefClientGuardian(std::string cmdline)
 			boost::process::child child_process(cmdline);
 			DbgEx("open cefclient pid:%d, cmd:%s", child_process.id(), cmdline.c_str());
 			child_process.wait();
+			return;
 		}
 		catch (const std::exception& e)
 		{
@@ -160,7 +163,6 @@ void CModTools::cefClientGuardian(std::string cmdline)
 		}
 		catch (...)
 		{
-			int i = 10;
 			return;
 		}
 		std::this_thread::sleep_for(std::chrono::seconds(1));

+ 2 - 0
Module/mod_chromium/mod_chromium.cpp

@@ -309,6 +309,8 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 	 auto rc = modTools.StartChromiumBrowser();
 	 max_restartTime--;
 	 DbgEx("TaskTimerListen, startChromiumBrowser, rc:%d, pid:%d", rc.first, rc.second);
+	if(0 == rc.first)
+		GetFunction()->KillTimer(CHROMIUM_TIMER_ID);
 
 #if (defined _WIN32 || defined _WIN64)
 	 if (rc.first == Error_Succeed && rc.second != 0)