Mercurial > trustbridge
view common/selftest.c @ 1119:5349e2354c48
(issue54) Merge branch runafterinstall
There is now an NSIS Plugin that executes the Software after
installation using COM in the shell of the current user.
With the way over the shell there is no inheritance /
token management required. As it is impossible to
drop all privileges of a token granted by UAC and
still be able to reelevate the Token again with another
RunAs call later this round trip over the Shell was
necessary.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 16 Sep 2014 19:48:22 +0200 |
parents | edbf5e5e88f4 |
children | a974b61a5cce |
line wrap: on
line source
#include "selftest.h" #include "binverify.h" #include "strhelp.h" #include "logging.h" bool selftest() { bin_verify_result res; #ifdef WIN32 wchar_t wPath[MAX_PATH]; char *utf8path = NULL; if (!GetModuleFileNameW (NULL, wPath, MAX_PATH - 1)) { PRINTLASTERROR ("Failed to obtain module file name. Path too long?"); return false; } /* wPath might not be 0 terminated */ wPath[MAX_PATH - 1] = '\0'; utf8path = wchar_to_utf8 (wPath, wcsnlen(wPath, MAX_PATH)); if (utf8path == NULL) { ERRORPRINTF ("Failed to convert module path to utf-8"); return false; } res = verify_binary (utf8path, strlen(utf8path)); if (res.result != VerifyValid) { ERRORPRINTF ("Verification of the binary failed"); syslog_error_printf ("Integrity check failed."); xfree(utf8path); return false; } fclose(res.fptr); xfree(utf8path); return true; #else res = verify_binary ("/proc/self/exe", 14); if (res.result != VerifyValid) { syslog_error_printf ("Integrity check failed."); return false; } fclose(res.fptr); return true; #endif }