From e525e3a57125d0ef070f67f670badcc74b1fba3e Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Sun, 5 Jan 2014 20:59:41 -0800 Subject: [PATCH] Ready to test app-driven service install on Mac. --- .../Contents/Info.plist | 2 +- .../Contents/Resources/Scripts/main.scpt | Bin 3946 -> 3598 bytes ZeroTierUI/installdialog.cpp | 54 +++++++++++++++++- ZeroTierUI/mainwindow.cpp | 12 ---- 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/ZeroTierUI/helpers/mac/ZeroTier One (Install).app/Contents/Info.plist b/ZeroTierUI/helpers/mac/ZeroTier One (Install).app/Contents/Info.plist index 113156441..20f6fcb0b 100644 --- a/ZeroTierUI/helpers/mac/ZeroTier One (Install).app/Contents/Info.plist +++ b/ZeroTierUI/helpers/mac/ZeroTier One (Install).app/Contents/Info.plist @@ -42,7 +42,7 @@ positionOfDivider 333 savedFrame - 68 169 602 597 0 0 1280 778 + 57 445 602 597 0 0 1920 1058 selectedTabView event log diff --git a/ZeroTierUI/helpers/mac/ZeroTier One (Install).app/Contents/Resources/Scripts/main.scpt b/ZeroTierUI/helpers/mac/ZeroTier One (Install).app/Contents/Resources/Scripts/main.scpt index af0d80f5cc7bc1c79b47314e45a29b91313f9694..8ac66d41cdcb60fc954261d2ac77fa98e92708ff 100644 GIT binary patch delta 1729 zcmaDQ*C(@KHKVXJgZTe1|3C9Gh%+#IGB7a+Fi20{$Ea^A${@uc&C4Lgz?8(mz#zaN z%pk)c%gZ3cz?ci>3o^*@F~~76Ze)-bWRPcIVo>L0kewXCq%JNEQ6kJB!l1y%pa4>$ zD9E5Vc^^wgo+JbF{|^jG|KD@{|G>b)m6Vv0%gdky(ICbk{{J1<|91==+)4TQWhF(W zsciq>GcYjz{{kXDGcYhQh%qoRC^M+=GAJ`J=P)oa$S|lgsQ!QZ{|zsLD#ZOV4C?=1 zGpI4BbNzoku~0Tb4dMYA21N!922EZD4H#dZL5o3~mq80+xeS9WgAN~q4#>5-f(*J0 zd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G3|ib_-2 z{=Z{jVEq3DM0{poU}6wsU}Df@(Bfs#WMIx=U}8{U&}Pv7|K|T|UIuMQ;3+U@|9{1x z!=TIc|JB4o*$5p-=qNC#GUzer^D^kc_{t0h42HZ61`x{?7!(=;%t+{~vPye>izNt9ry!kXxRB z++xAN#9+_hz{_9{af=Bh`g}Ba?!HmI;kHHP(I(I<^_sR9FN;IRC%R;Qjv=*ZjFqz`$HUT&0zEY zCinlFptzRwg&1MWV8;-|#}EWEB3O_im?30xB4@CQI@AAKppf!nU}6aQe}k7H1maK^ zhSdMp8A2Jtxc*0e+#PBji!}y^L zu?%s%46!hNFhe{;0xv^6jPK8o$dJU#kO<@ZG9)vk@G>OB_?`@@3~9U)45<)rxG=ag zr1LSPgS?R;$dEC47DpR@8pPY~3?BclasR&t^0s&iM7<}24?`v&LncUlmLNmcNCtRZZQ4lL48KVAQ=Kg;f!~+m<9~7ky3``6~|IhO>6hRU{D36@`fA;?w#{cI)iq3+FGa%jP85sDq z8JHLt_yri48QA`xW+-MTVJKxN`+th@|7lPWUd+Jq|K$G@|BwGa#`XW?+@G+DyunYV@%259Q$p6C(6%3XC4{`lJI=O*Iw!R#aKNuJ? z8LF5Vsu-9USQ)CB7^)eV76mpm>5JEYMB^n!9`{r6GI)iK&fY9s0Zcd{|A}= z9|XDl2*~A!L5`~c5tR(04BY<@{NK+Y{C^*V5`zkZ+W)-_Mhqqlw*U7qxG@AU1TmyD zWO6cOgQ^m){|6=(g8Z-_#Si;He&FT$zZV+(-2eB0GJU<^|3eH}53+a|7+o*e l6f>kU6fqPt=rbfT6fk5m{y)XQkXW2t#K6eF^XuNdwE&jj&kFzm diff --git a/ZeroTierUI/installdialog.cpp b/ZeroTierUI/installdialog.cpp index 83820e883..2f453e3d2 100644 --- a/ZeroTierUI/installdialog.cpp +++ b/ZeroTierUI/installdialog.cpp @@ -2,13 +2,25 @@ #include "mainwindow.h" #include "ui_installdialog.h" +#include "../node/Constants.hpp" #include "../node/Defaults.hpp" #include "../node/SoftwareUpdater.hpp" +#ifdef __UNIX_LIKE__ +#include +#include +#include +#include +#include +#endif + #include #include #include #include +#include +#include +#include InstallDialog::InstallDialog(QWidget *parent) : QDialog(parent), @@ -40,7 +52,7 @@ void InstallDialog::on_networkReply(QNetworkReply *reply) reply->deleteLater(); if (reply->error() != QNetworkReply::NoError) { - QMessageBox::critical(this,"Download Failed",QString("Download failed: ") + reply->errorString(),QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::critical(this,"Download Failed",QString("Download failed: ") + reply->errorString() + "\n\nAre you connected to the Internet?",QMessageBox::Ok,QMessageBox::NoButton); QApplication::exit(1); } else { if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) { @@ -68,6 +80,44 @@ void InstallDialog::on_networkReply(QNetworkReply *reply) QApplication::exit(1); return; } + +#ifdef __APPLE__ + QString zt1Caches(QDir::homePath() + "/Library/Caches/ZeroTier/One"); + QDir::root().mkpath(zt1Caches); + QString instPath(zt1Caches+"/ZeroTierOneInstaller"); + + int outfd = ::open(instPath.toStdString().c_str(),O_CREAT|O_TRUNC|O_WRONLY,0755); + if (outfd <= 0) { + QMessageBox::critical(this,"Download Failed",QString("Installation failed: unable to write to ")+instPath,QMessageBox::Ok,QMessageBox::NoButton); + QApplication::exit(1); + return; + } + if (::write(outfd,installerData.data(),installerData.length()) != installerData.length()) { + QMessageBox::critical(this,"Installation Failed",QString("Installation failed: unable to write to ")+instPath,QMessageBox::Ok,QMessageBox::NoButton); + QApplication::exit(1); + return; + } + ::close(outfd); + ::chmod(instPath.toStdString().c_str(),0755); + + QString installHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/helpers/mac/ZeroTier One (Install).app/Contents/MacOS/applet"); + if (!QFile::exists(installHelperPath)) { + QMessageBox::critical(this,"Unable to Locate Helper","Unable to locate install helper, cannot install service.",QMessageBox::Ok,QMessageBox::NoButton); + QApplication::exit(1); + return; + } + QProcess::execute(installHelperPath,QStringList()); + + if (!QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) { + QMessageBox::critical(this,"Installation Failed","Installation failed. Are you sure you entered your password correctly?",QMessageBox::Ok,QMessageBox::NoButton); + QApplication::exit(1); + return; + } + + ((QMainWindow *)this->parent())->setHidden(false); + this->close(); + return; +#endif } break; } @@ -86,8 +136,6 @@ void InstallDialog::on_InstallDialog_rejected() QApplication::exit(); } -//((QMainWindow *)this->parent())->setHidden(false); - void InstallDialog::on_cancelButton_clicked() { QApplication::exit(); diff --git a/ZeroTierUI/mainwindow.cpp b/ZeroTierUI/mainwindow.cpp index 1c62d0153..f7d7e399e 100644 --- a/ZeroTierUI/mainwindow.cpp +++ b/ZeroTierUI/mainwindow.cpp @@ -116,18 +116,6 @@ void MainWindow::timerEvent(QTimerEvent *event) id->show(); this->setHidden(true); return; - - // Run the little AppleScript hack that asks for admin credentials and - // then installs the auth token file in the current user's home. - /* - QString installHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/helpers/mac/ZeroTier One (Install).app/Contents/MacOS/applet"); - if (!QFile::exists(installHelperPath)) { - QMessageBox::critical(this,"Unable to Locate Helper","Unable to locate install helper, cannot install service.",QMessageBox::Ok,QMessageBox::NoButton); - QApplication::exit(1); - return; - } - QProcess::execute(installHelperPath,QStringList()); - */ } #endif