|
|
@@ -18,16 +18,21 @@
|
|
|
#include <signal.h>
|
|
|
#include <pthread.h>
|
|
|
#include <pwd.h>
|
|
|
+
|
|
|
+#include "toolkit.h"
|
|
|
+#include <winpr/library.h>
|
|
|
+
|
|
|
int epfd;
|
|
|
struct epoll_event ev;
|
|
|
#define MAXLINE 128
|
|
|
#define OPEN_MAX 100
|
|
|
#define LISTENQ 20
|
|
|
#define INFTIM 1000
|
|
|
-#else
|
|
|
+
|
|
|
+#else //
|
|
|
+
|
|
|
#undef UNICODE
|
|
|
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
|
|
|
-
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
#include <windows.h>
|
|
|
#include <winsock2.h>
|
|
|
@@ -43,6 +48,10 @@ struct epoll_event ev;
|
|
|
#include "GuardianBase.h"
|
|
|
#include "guardian.h"
|
|
|
|
|
|
+#ifndef MAX_PATH
|
|
|
+ #define MAX_PATH 260
|
|
|
+#endif
|
|
|
+
|
|
|
using namespace std;
|
|
|
#define NET_TYPE_WIRELESS 1
|
|
|
#define NET_TYPE_ETHERNET 2
|
|
|
@@ -73,7 +82,8 @@ const int SHAKEHAND_BUFZIE = 32;
|
|
|
const int default_port = 30005;
|
|
|
|
|
|
int g_needToRollBack = 0;
|
|
|
-bool g_bFrameQuit = false,g_bFrameOnline = false,g_bLogFileOpen = false,g_bAuthSuc = false,g_bInUpgrade = false;
|
|
|
+bool g_bFrameQuit = false, g_bFrameOnline = false;
|
|
|
+bool g_bLogFileOpen = false, g_bAuthSuc = false, g_bInUpgrade = false;
|
|
|
ULONGLONG g_dwTimeBegin = 0;
|
|
|
ULONGLONG g_dwUpgradeRestartTimeBegin = 0;
|
|
|
int cnt = 0;
|
|
|
@@ -93,17 +103,6 @@ extern "C"
|
|
|
void* DoNetControlLinux(void* arg);
|
|
|
}
|
|
|
#define FUNCTION_STDCALL
|
|
|
-typedef unsigned short WORD;
|
|
|
-typedef struct _SYSTEMTIME {
|
|
|
- WORD wYear;
|
|
|
- WORD wMonth;
|
|
|
- WORD wDayOfWeek;
|
|
|
- WORD wDay;
|
|
|
- WORD wHour;
|
|
|
- WORD wMinute;
|
|
|
- WORD wSecond;
|
|
|
- WORD wMilliseconds;
|
|
|
-} SYSTEMTIME;
|
|
|
#else
|
|
|
typedef struct
|
|
|
{
|
|
|
@@ -332,70 +331,27 @@ int FrameworkShutdown(bool bUpgrade=false,bool bRestart = true)
|
|
|
system("killall -9 spshell");
|
|
|
system("killall -9 sphost");
|
|
|
sleep(2);
|
|
|
- FILE* fp = NULL;
|
|
|
- char user[128];
|
|
|
- memset(user, 0, 128);
|
|
|
- fp = popen("cat /etc/passwd|grep /home |head -1|cut -d : -f 1", "r");
|
|
|
- if (fp != NULL)
|
|
|
- {
|
|
|
- if (fgets(user, sizeof(user), fp) != NULL)
|
|
|
- {
|
|
|
- int len = strlen(user);
|
|
|
- if (len > 0)
|
|
|
- user[len-1] = '\0';
|
|
|
- LogSingleMsg(user);
|
|
|
- }
|
|
|
- }
|
|
|
- //struct passwd* pwd = getpwuid(getuid());
|
|
|
- //LogSingleMsg(pwd->pw_name);
|
|
|
- char tmpUser[256];
|
|
|
- memset(tmpUser, 0, 256);
|
|
|
- sprintf(tmpUser, "XAUTHORITY=/home/%s/.Xauthority", user);
|
|
|
- LogSingleMsg(tmpUser);
|
|
|
- pid_t pid = vfork();
|
|
|
- if (pid == 0)
|
|
|
- {
|
|
|
- //XDG_SESSION_PATH = / org / freedesktop / DisplayManager / Session0
|
|
|
- // LANGUAGE = en_US
|
|
|
- // D_DISABLE_RT_SCREEN_SCALE = 1
|
|
|
- // QT_LOGGING_RULES = *.debug = false
|
|
|
- // SSH_AUTH_SOCK = / run / user / 1000 / keyring / ssh
|
|
|
- // XDG_DATA_HOME = / home / guest / .local / share
|
|
|
- // XDG_CONFIG_HOME = / home / guest / .config
|
|
|
- // DESKTOP_SESSION = deepin
|
|
|
- // XDG_SEAT = seat0
|
|
|
- // XDG_SESSION_DESKTOP = deepin
|
|
|
- // LOGNAME = guest
|
|
|
- // XDG_SESSION_TYPE = x11
|
|
|
- // GPG_AGENT_INFO = / run / user / 1000 / gnupg / S.gpg - agent:0 : 1
|
|
|
- // XAUTHORITY = / home / guest / .Xauthority
|
|
|
- // XDG_GREETER_DATA_DIR = / var / lib / lightdm / data / guest
|
|
|
- char* newargv[] = {"oil","--debug",NULL };
|
|
|
- char* newenv[] = {
|
|
|
- "DISPLAY=:0.0",
|
|
|
-
|
|
|
- //"QT_ACCESSIBILITY=1",
|
|
|
- ////"XDG_DATA_HOME=/home/guest/.local/share","XDG_CONFIG_HOME=/home/guest/.config",
|
|
|
- //"XDG_SEAT=seat0",
|
|
|
- //"DESKTOP_SESSION=deepin",
|
|
|
- //"XDG_SESSION_TYPE=x11",
|
|
|
-
|
|
|
- tmpUser,
|
|
|
- //"XAUTHORITY=/home/guest/.Xauthority",
|
|
|
-
|
|
|
- ////"XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/guest",
|
|
|
- //"XDG_VTNR=1",
|
|
|
- //"QT_LINUX_ACCESSIBILITY_ALWAYS_ON = 1",
|
|
|
- //"QT_SCALE_FACTOR_ROUNDING_POLICY = PassThrough",
|
|
|
- //"XDG_RUNTIME_DIR = /run/user/1000",
|
|
|
- NULL };
|
|
|
- if (execve("/opt/run/version/spexplorer.sh", newargv, newenv) < 0)
|
|
|
- {
|
|
|
- LogToFile(true, true, false, "execle failed_error", strerror(errno), errno);
|
|
|
- _exit(0);
|
|
|
- //return false;
|
|
|
- }
|
|
|
+ char tmp[MAX_PATH];
|
|
|
+ char* pos = NULL;
|
|
|
+ GetModuleFileNameA(NULL, tmp, MAX_PATH);
|
|
|
+ LogSingleMsg(tmp);
|
|
|
+ if ((pos = strstr(tmp, "/version")) != NULL) {
|
|
|
+ pos[strlen("/version")+1] = '\0';
|
|
|
+ strcat(tmp, "spexplorer.sh --restart");
|
|
|
+ LogSingleMsg(tmp);
|
|
|
+ tk_process_t* process = NULL;
|
|
|
+ tk_process_option_t option;
|
|
|
+ option.exit_cb = NULL;
|
|
|
+ option.file = NULL;
|
|
|
+ option.flags = 0;
|
|
|
+ option.params = tmp;
|
|
|
+
|
|
|
+ if (0 == process_spawn(&option, &process)) {
|
|
|
+ FREE(process);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
LogSingleMsg("after kill spshell");
|
|
|
return 0;
|
|
|
#else
|
|
|
@@ -1475,22 +1431,3 @@ void LogToFile(bool bRevMsg, bool bCode1,bool bCode2,const char *msg, const char
|
|
|
}
|
|
|
LeaveCriticalSectionRVC(g_cs_event);
|
|
|
}
|
|
|
-//unsigned int __stdcall DoLog(void *pData)
|
|
|
-//{
|
|
|
-// while (1)
|
|
|
-// {
|
|
|
-// cout << "wait..." << endl;
|
|
|
-// WaitForSingleObject(g_logHandle, INFINITE);
|
|
|
-// if (g_bLogFileOpen)
|
|
|
-// {
|
|
|
-// EnterCriticalSection(&g_cs_log);
|
|
|
-// logFile.write(g_allMsg, strlen(g_allMsg));
|
|
|
-// logFile.flush();
|
|
|
-// LeaveCriticalSection(&g_cs_log);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// //_endthreadex(0);
|
|
|
-// EndThreadRVC();
|
|
|
-// return 0;
|
|
|
-//}
|