diff --git a/modules/core/app-updater/index.ts b/modules/core/app-updater/index.ts index 5f691da..514e838 100644 --- a/modules/core/app-updater/index.ts +++ b/modules/core/app-updater/index.ts @@ -713,10 +713,17 @@ export async function prepareUpdateExecute(targetVersion: UpdateVersion, callbac console.log("Will prompt the user to execute a command"); } + try { + fs.chmodSync(updateInstallerExecutable, 0o755); + } catch (error) { + console.error("Failed to make update executable executable: %o", error); + throw "failed to make update executable executable"; + } + //We have to unpack it later executeCallback = () => { if(inaccessiblePaths.length > 0) { - const updateCommand = `sudo "${updateInstallerExecutable}" "${installLogFile}" "${installConfigFile}"`; + const updateCommand = `sudo "${updateInstallerExecutable}" "${installLogFile}" "${installConfigFile}" no-daemon`; try { electron.clipboard.writeText(updateCommand); } catch (error) { @@ -728,7 +735,7 @@ export async function prepareUpdateExecute(targetVersion: UpdateVersion, callbac "Please do the following steps:\n" + "1. Close this client\n" + "2. Execute this command:\n" + - ` sudo "${updateInstallerExecutable}" "${installLogFile}" "${installConfigFile}"` + "\n" + + " " + updateCommand + "\n" + "3. Start the client again\n\n" + "Note:\n" + "We've already copied that command to your clipboard." diff --git a/native/updater/main.cpp b/native/updater/main.cpp index 5b8dc75..d18f793 100644 --- a/native/updater/main.cpp +++ b/native/updater/main.cpp @@ -115,14 +115,16 @@ int main(int argc, char** argv) { } + if(argc >= 4 && std::string_view{argv[3]} != "no-daemon") { #ifndef WIN32 - logger::info("Deamonize process"); - if(!daemonize()) { - logger::fatal("Failed to demonize process", argc); - return 4; - } - logger::info("Deamonized process"); + logger::info("Deamonize process"); + if(!daemonize()) { + logger::fatal("Failed to demonize process", argc); + return 4; + } + logger::info("Deamonized process"); #endif + } #ifdef WIN32 if(requires_permission_elevation()) { diff --git a/native/updater/util.cpp b/native/updater/util.cpp index f15e31a..e380809 100644 --- a/native/updater/util.cpp +++ b/native/updater/util.cpp @@ -46,7 +46,11 @@ using namespace std; } #else #include + #include + #include + bool is_executable(const std::string& file) { + chmod(file.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); return access(file.c_str(), F_OK | X_OK) == 0; } @@ -84,7 +88,8 @@ inline std::string build_callback_info(const std::string& error_id, const std::s void execute_callback_fail_exit(const std::string& error, const std::string& error_message) { file::rollback(); - + + //int chmod(const char *path, mode_t mode); if(!is_executable(config::callback_file)) { logger::fatal("callback file (%s) is not executable! Ignoring fail callback", config::callback_file.c_str()); logger::flush();