summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp37
-rw-r--r--node/Dictionary.cpp2
-rw-r--r--node/Utils.cpp14
-rw-r--r--osnet/WindowsEthernetTap.cpp3
4 files changed, 46 insertions, 10 deletions
diff --git a/main.cpp b/main.cpp
index f13f6ee2..5b882d0b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -680,6 +680,43 @@ int main(int argc,char **argv)
#endif // __UNIX_LIKE__
#ifdef __WINDOWS__
+ {
+ char myPath[MAX_PATH];
+ DWORD ps = GetModuleFileNameA(NULL,myPath,sizeof(myPath));
+ if ((ps > 0)&&(ps < (DWORD)sizeof(myPath))) {
+ STARTUPINFOA startupInfo;
+ PROCESS_INFORMATION processInfo;
+ fprintf(stderr,"*** path: %s\n",myPath);
+
+ startupInfo.cb = sizeof(startupInfo);
+ memset(&startupInfo,0,sizeof(STARTUPINFOA));
+ memset(&processInfo,0,sizeof(PROCESS_INFORMATION));
+ if (CreateProcessA(NULL,(LPSTR)(std::string("C:\\Windows\\System32\\netsh.exe advfirewall firewall delete rule name=\"ZeroTier One\" program=\"") + myPath + "\"").c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
+ WaitForSingleObject(processInfo.hProcess,INFINITE);
+ CloseHandle(processInfo.hProcess);
+ CloseHandle(processInfo.hThread);
+ }
+
+ startupInfo.cb = sizeof(startupInfo);
+ memset(&startupInfo,0,sizeof(STARTUPINFOA));
+ memset(&processInfo,0,sizeof(PROCESS_INFORMATION));
+ if (CreateProcessA(NULL,(LPSTR)(std::string("C:\\Windows\\System32\\netsh.exe advfirewall firewall add rule name=\"ZeroTier One\" dir=in action=allow program=\"") + myPath + "\" enable=yes").c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
+ WaitForSingleObject(processInfo.hProcess,INFINITE);
+ CloseHandle(processInfo.hProcess);
+ CloseHandle(processInfo.hThread);
+ }
+
+ startupInfo.cb = sizeof(startupInfo);
+ memset(&startupInfo,0,sizeof(STARTUPINFOA));
+ memset(&processInfo,0,sizeof(PROCESS_INFORMATION));
+ if (CreateProcessA(NULL,(LPSTR)(std::string("C:\\Windows\\System32\\netsh.exe advfirewall firewall add rule name=\"ZeroTier One\" dir=out action=allow program=\"") + myPath + "\" enable=yes").c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
+ WaitForSingleObject(processInfo.hProcess,INFINITE);
+ CloseHandle(processInfo.hProcess);
+ CloseHandle(processInfo.hThread);
+ }
+ }
+ }
+
if (winRunFromCommandLine) {
// Running in "interactive" mode (mostly for debugging)
if (IsCurrentUserLocalAdministrator() != TRUE) {
diff --git a/node/Dictionary.cpp b/node/Dictionary.cpp
index e050143b..50440e5b 100644
--- a/node/Dictionary.cpp
+++ b/node/Dictionary.cpp
@@ -110,7 +110,7 @@ bool Dictionary::verify(const Identity &id) const
if (sig == end())
return false;
std::string sigbin(Utils::unhex(sig->second));
- return id.verify(buf.data(),(unsigned int)buf.length(),sigbin.data(),sigbin.length());
+ return id.verify(buf.data(),(unsigned int)buf.length(),sigbin.data(),(unsigned int)sigbin.length());
} catch ( ... ) {
return false;
}
diff --git a/node/Utils.cpp b/node/Utils.cpp
index 86106386..ba7fb057 100644
--- a/node/Utils.cpp
+++ b/node/Utils.cpp
@@ -260,22 +260,20 @@ void Utils::lockDownFile(const char *path,bool isDir)
#ifdef __WINDOWS__
{
STARTUPINFOA startupInfo;
- startupInfo.cb = sizeof(startupInfo);
PROCESS_INFORMATION processInfo;
+
+ startupInfo.cb = sizeof(startupInfo);
memset(&startupInfo,0,sizeof(STARTUPINFOA));
memset(&processInfo,0,sizeof(PROCESS_INFORMATION));
- /*
- if (CreateProcessA(NULL,(LPSTR)(std::string("C:\\Windows\\System32\\cacls.exe \"") + path + "\" /E /R Users").c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
- WaitForSingleObject(processInfo.hProcess,INFINITE);
- CloseHandle(processInfo.hProcess);
- CloseHandle(processInfo.hThread);
- }
- */
if (CreateProcessA(NULL,(LPSTR)(std::string("C:\\Windows\\System32\\icacls.exe \"") + path + "\" /inheritance:d /Q").c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
WaitForSingleObject(processInfo.hProcess,INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
+
+ startupInfo.cb = sizeof(startupInfo);
+ memset(&startupInfo,0,sizeof(STARTUPINFOA));
+ memset(&processInfo,0,sizeof(PROCESS_INFORMATION));
if (CreateProcessA(NULL,(LPSTR)(std::string("C:\\Windows\\System32\\icacls.exe \"") + path + "\" /remove *S-1-5-32-545 /Q").c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
WaitForSingleObject(processInfo.hProcess,INFINITE);
CloseHandle(processInfo.hProcess);
diff --git a/osnet/WindowsEthernetTap.cpp b/osnet/WindowsEthernetTap.cpp
index 8326597a..0e580643 100644
--- a/osnet/WindowsEthernetTap.cpp
+++ b/osnet/WindowsEthernetTap.cpp
@@ -706,8 +706,9 @@ NET_IFINDEX WindowsEthernetTap::_getDeviceIndex()
for(ULONG i=0;i<ift->NumEntries;++i) {
if (ift->Table[i].InterfaceLuid.Value == _deviceLuid.Value) {
+ NET_IFINDEX idx = ift->Table[i].InterfaceIndex;
FreeMibTable(ift);
- return ift->Table[i].InterfaceIndex;
+ return idx;
}
}