From d6b766f7b4b150eaf4bca8e20f21dd5e4d6484bc Mon Sep 17 00:00:00 2001 From: ballessay Date: Sat, 13 May 2017 22:18:56 +0200 Subject: [PATCH] Fix webserver failure in appimage The radare webserver is looking for http.root or http.homeroot which wasn't included in the appimage, so the webserver failed to start. Since sys/install.sh seems to just symlinks a lot of files in /usr/share/radare2 cp -Lr the folder. Additionally modify the http.root if an AppImage environment is detected. --- .travis.yml | 3 ++- src/radarewebserver.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1cefdf24..903978ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,8 @@ script: - mkdir build ; cd build - qmake PREFIX=/usr ../src - make -j4 - - sudo make INSTALL_ROOT=appdir install ; sudo chown -R $USER appdir ; find appdir/ + - sudo make INSTALL_ROOT=appdir install ; sudo chown -R $USER appdir + - mkdir -p appdir/usr/share/radare2 ; cp -Lr /usr/share/radare2/*-git/ appdir/usr/share/radare2/ ; find appdir/ after_success: - wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" diff --git a/src/radarewebserver.cpp b/src/radarewebserver.cpp index efb8c4f1..616b0bf8 100644 --- a/src/radarewebserver.cpp +++ b/src/radarewebserver.cpp @@ -1,5 +1,7 @@ #include "radarewebserver.h" #include "qrcore.h" +#include +#include #include @@ -18,6 +20,23 @@ void RadareWebServer::start() { assert(core != nullptr); + // FIXME: quick & dirty work around to get this in AppImage working + QProcessEnvironment env(QProcessEnvironment::systemEnvironment()); + if (env.contains("APPIMAGE") && env.contains("APPDIR") && env.contains("OWD")) + { + // pretty sure now iaito runs as AppImage + + //QString defaultPath("/usr/share/radare2/1.5.0-git/www"); + QString defaultHttpRoot(core->config("http.root")); + if (defaultHttpRoot.startsWith("/usr")) + { + QString path(QCoreApplication::applicationDirPath()); + path.replace("bin/", defaultHttpRoot.remove("/usr")); + + core->config("http.root", path); + } + } + if (!started && core != nullptr) { // command: see libr/core/rtr.c