mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Add support for local user account caching of authtoken.secret as in old UI -- this is now pretty much working.
This commit is contained in:
parent
d56e9fce41
commit
4426899e8c
5 changed files with 97 additions and 172 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -39,4 +39,4 @@
|
||||||
/root-topology/*.secret
|
/root-topology/*.secret
|
||||||
/root-topology/test/supernodes
|
/root-topology/test/supernodes
|
||||||
/root-topology/test/test-root-topology
|
/root-topology/test/test-root-topology
|
||||||
xcuserdata
|
/ext/mac-ui-macgap1-wrapper/MacGap.xcodeproj/project.xcworkspace/xcuserdata/*
|
||||||
|
|
Binary file not shown.
|
@ -1,88 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Scheme
|
|
||||||
LastUpgradeVersion = "0630"
|
|
||||||
version = "1.3">
|
|
||||||
<BuildAction
|
|
||||||
parallelizeBuildables = "YES"
|
|
||||||
buildImplicitDependencies = "YES">
|
|
||||||
<BuildActionEntries>
|
|
||||||
<BuildActionEntry
|
|
||||||
buildForTesting = "YES"
|
|
||||||
buildForRunning = "YES"
|
|
||||||
buildForProfiling = "YES"
|
|
||||||
buildForArchiving = "YES"
|
|
||||||
buildForAnalyzing = "YES">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "FAE451B914BA79C600190544"
|
|
||||||
BuildableName = "ZeroTier One.app"
|
|
||||||
BlueprintName = "MacGap"
|
|
||||||
ReferencedContainer = "container:MacGap.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildActionEntry>
|
|
||||||
</BuildActionEntries>
|
|
||||||
</BuildAction>
|
|
||||||
<TestAction
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
buildConfiguration = "Debug">
|
|
||||||
<Testables>
|
|
||||||
</Testables>
|
|
||||||
<MacroExpansion>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "FAE451B914BA79C600190544"
|
|
||||||
BuildableName = "ZeroTier One.app"
|
|
||||||
BlueprintName = "MacGap"
|
|
||||||
ReferencedContainer = "container:MacGap.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</MacroExpansion>
|
|
||||||
</TestAction>
|
|
||||||
<LaunchAction
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
||||||
launchStyle = "0"
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
buildConfiguration = "Debug"
|
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
|
||||||
debugDocumentVersioning = "YES"
|
|
||||||
allowLocationSimulation = "YES">
|
|
||||||
<BuildableProductRunnable
|
|
||||||
runnableDebuggingMode = "0">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "FAE451B914BA79C600190544"
|
|
||||||
BuildableName = "ZeroTier One.app"
|
|
||||||
BlueprintName = "MacGap"
|
|
||||||
ReferencedContainer = "container:MacGap.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildableProductRunnable>
|
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</LaunchAction>
|
|
||||||
<ProfileAction
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
savedToolIdentifier = ""
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
debugDocumentVersioning = "YES">
|
|
||||||
<BuildableProductRunnable
|
|
||||||
runnableDebuggingMode = "0">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "FAE451B914BA79C600190544"
|
|
||||||
BuildableName = "ZeroTier One.app"
|
|
||||||
BlueprintName = "MacGap"
|
|
||||||
ReferencedContainer = "container:MacGap.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildableProductRunnable>
|
|
||||||
</ProfileAction>
|
|
||||||
<AnalyzeAction
|
|
||||||
buildConfiguration = "Debug">
|
|
||||||
</AnalyzeAction>
|
|
||||||
<ArchiveAction
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
revealArchiveInOrganizer = "YES">
|
|
||||||
</ArchiveAction>
|
|
||||||
</Scheme>
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>SchemeUserState</key>
|
|
||||||
<dict>
|
|
||||||
<key>MacGap.xcscheme</key>
|
|
||||||
<dict>
|
|
||||||
<key>orderHint</key>
|
|
||||||
<integer>0</integer>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<key>SuppressBuildableAutocreation</key>
|
|
||||||
<dict>
|
|
||||||
<key>FAE451B914BA79C600190544</key>
|
|
||||||
<dict>
|
|
||||||
<key>primary</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
|
@ -7,6 +7,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "AppDelegate.h"
|
#import "AppDelegate.h"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
@implementation AppDelegate
|
@implementation AppDelegate
|
||||||
|
|
||||||
|
@ -29,6 +31,37 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
|
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||||
|
char buf[16384],userAuthTokenPath[4096];
|
||||||
|
|
||||||
|
FILE *pf = fopen("/Library/Application Support/ZeroTier/One/zerotier-one.port","r");
|
||||||
|
long port = 9993; // default
|
||||||
|
if (pf) {
|
||||||
|
long n = fread(buf,1,sizeof(buf)-1,pf);
|
||||||
|
if (n > 0) {
|
||||||
|
buf[n] = (char)0;
|
||||||
|
port = strtol(buf,(char **)0,10);
|
||||||
|
}
|
||||||
|
fclose(pf);
|
||||||
|
}
|
||||||
|
|
||||||
|
char url[16384];
|
||||||
|
memset(url,0,sizeof(url));
|
||||||
|
|
||||||
|
const char *homeDir = getenv("HOME");
|
||||||
|
if (homeDir) {
|
||||||
|
snprintf(userAuthTokenPath,sizeof(userAuthTokenPath),"%s/Library/Application Support/ZeroTier/One/authtoken.secret",homeDir);
|
||||||
|
pf = fopen(userAuthTokenPath,"r");
|
||||||
|
if (pf) {
|
||||||
|
long n = fread(buf,1,sizeof(buf)-1,pf);
|
||||||
|
if (n > 0) {
|
||||||
|
buf[n] = (char)0;
|
||||||
|
snprintf(url,sizeof(url),"http://127.0.0.1:%ld/index.html?authToken=%s",port,buf);
|
||||||
|
}
|
||||||
|
fclose(pf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!url[0]) {
|
||||||
// Create authorization reference
|
// Create authorization reference
|
||||||
OSStatus status;
|
OSStatus status;
|
||||||
AuthorizationRef authorizationRef;
|
AuthorizationRef authorizationRef;
|
||||||
|
@ -70,24 +103,25 @@
|
||||||
NSLog(@"Error: %d", status);
|
NSLog(@"Error: %d", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
char url[16384];
|
|
||||||
memset(url,0,sizeof(url));
|
|
||||||
if (pipe) {
|
if (pipe) {
|
||||||
char buf[16384];
|
long n = (long)fread(buf,1,sizeof(buf)-1,pipe);
|
||||||
|
|
||||||
FILE *pf = fopen("/Library/Application Support/ZeroTier/One/zerotier-one.port","r");
|
|
||||||
long n = fread(buf,1,sizeof(buf)-1,pf);
|
|
||||||
long port = 9993; // default
|
|
||||||
if (n > 0) {
|
|
||||||
buf[n] = (char)0;
|
|
||||||
port = strtol(buf,(char **)0,10);
|
|
||||||
}
|
|
||||||
fclose(pf);
|
|
||||||
|
|
||||||
n = (long)fread(buf,1,sizeof(buf)-1,pipe);
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
buf[n] = (char)0;
|
buf[n] = (char)0;
|
||||||
snprintf(url,sizeof(url),"http://127.0.0.1:%ld/index.html?authToken=%s",port,buf);
|
snprintf(url,sizeof(url),"http://127.0.0.1:%ld/index.html?authToken=%s",port,buf);
|
||||||
|
|
||||||
|
if (homeDir) {
|
||||||
|
snprintf(userAuthTokenPath,sizeof(userAuthTokenPath),"%s/Library/Application Support/ZeroTier",homeDir);
|
||||||
|
mkdir(userAuthTokenPath,0755);
|
||||||
|
snprintf(userAuthTokenPath,sizeof(userAuthTokenPath),"%s/Library/Application Support/ZeroTier/One",homeDir);
|
||||||
|
mkdir(userAuthTokenPath,0755);
|
||||||
|
snprintf(userAuthTokenPath,sizeof(userAuthTokenPath),"%s/Library/Application Support/ZeroTier/One/authtoken.secret",homeDir);
|
||||||
|
pf = fopen(userAuthTokenPath,"w");
|
||||||
|
if (pf) {
|
||||||
|
fwrite(buf,1,strlen(buf),pf);
|
||||||
|
fclose(pf);
|
||||||
|
chmod(userAuthTokenPath,0600);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fclose(pipe);
|
fclose(pipe);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +132,7 @@
|
||||||
// function with the flag kAuthorizationFlagDestroyRights.
|
// function with the flag kAuthorizationFlagDestroyRights.
|
||||||
// http://developer.apple.com/documentation/Security/Conceptual/authorization_concepts/02authconcepts/chapter_2_section_7.html
|
// http://developer.apple.com/documentation/Security/Conceptual/authorization_concepts/02authconcepts/chapter_2_section_7.html
|
||||||
status = AuthorizationFree(authorizationRef, kAuthorizationFlagDestroyRights);
|
status = AuthorizationFree(authorizationRef, kAuthorizationFlagDestroyRights);
|
||||||
|
}
|
||||||
|
|
||||||
NSString *urlStr = [[NSString alloc] initWithCString:url];
|
NSString *urlStr = [[NSString alloc] initWithCString:url];
|
||||||
self.windowController = [[WindowController alloc] initWithURL: urlStr];
|
self.windowController = [[WindowController alloc] initWithURL: urlStr];
|
||||||
|
|
Loading…
Add table
Reference in a new issue