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 literal 3598 zcmc&%S#wlH6#nKWgm5o?lS`0A0)%AHWm%LD zK3o0_t9uPSt1C*L0X6nD7HiO9M`{e2kCs$1sRHv*1$H<6ek%cUIBo7rEMp-?Q zjX)8MvYAlwJ9@|imsMxV_OQxwqsZ}*qm}I$peL1$quQvOhff@Npp^}tD|_FQ`{)@# zrdGB#(HOU_*=&X6kyiYnR@`TK3%wMl;u0n6CC`aTs^g&-&SDmoh2Tm24 z%BHBd(N7WD`Z>r&e?>5?lLQR#F+gu*V1R*CAYY-s)jS|0cRab%f#!9vOK&bWKO7?z!O)#cMn__lA{eGfJx2Q& zt(h7VU<@tZO!v-XYb}w~kFwPF#{j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| zIziS1xJNblPho&%FK238#qa>1wVa>gN^0o& z#3bM57`Zv_)5SNvbeJs5b~`Q?l>?e1=bXxs`+eDu${Lg<`*WSSbXTf3wP{^8mvtR2 z+R1J?FH&L6f6@CT3xNKxIk)f)ESNuC!r3v!`l3iC7rLLQ3C^TMWTEKt1LB z7`Mtt9*dzI;8quV^;G*dEHVTei}mz{+mSE?8;f)8a-9b;|4@E}>8Ap_!JjPIe+@OpZ?d)7wHUWS(i8^MckyS(qq`+vI;8mxB0 zC+MkN0sWrBcZW<^#g2njZYteZcKWijAP0B5Wm>TuJpluV%k+la{jm$o!Kq8wEFQi! zPN|hnDSEiP=gWHqm0IqUx(ln24w#~;R9{HH)WrVJd(D46I?ll>OR$W`?Yr0@?|3Xu z9=98ul&g`Hw>^3LwBz<2W(V1&uvd?RPZahke5z^VMm`yN%P`T|gMnFJ-jp|FM?~J# zL2oGR(AjUn-n&u8Zvm9Z>-NUjj{$it!Uk{9Srp5w@`}7HFM0ARb51ffkV_}~`g;4j zyMe7-`cX{b&zD#J=6}AtT!8(Eyrg^PFuYt|#6}sE7qAJNWxK~_;pGiKi1OcL>u_Hb z_ff@RxIc>fSuuDZ%5zx1A0CY2K~}EfhX@{GWj3}%v4xen@_baDSH%Za@fTFNO$wVi z%a`ZmSyad~sN{ufl041Rz77rY6c4z?jG(oQ{w}@vd-B{6dDrJ6r@qR3E_de79*-M1 zEBoByT#o%vwqyOi^&=5!dN=WzEq5jk4#p3~2jhq1U!=PECUImi{^iN~Q9EW&V#hJw z_G^w0#=nkhPa=u(!FUp3d^>RzXD3l%addv>3KVsg1-!p7D7J<)a0%0DpC-To?b;S% h8&A?|9zuGd$q?1UIUpjh0m*E8hF{MkPwd_M#9v_gc%%RT 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