Don't start the app as root

This commit is contained in:
WolverinDEV 2021-05-02 11:36:47 +02:00
parent 44e03dd00f
commit 177d6582ea
2 changed files with 31 additions and 17 deletions

View File

@ -725,8 +725,12 @@ export async function prepareUpdateExecute(targetVersion: UpdateVersion, callbac
callbackLog("error", callbackLog("error",
"We don't have permissions to write to all files.\n" + "We don't have permissions to write to all files.\n" +
"Please close this client and execute the following command:\n" + "Please do the following steps:\n" +
`sudo "${updateInstallerExecutable}" "${installLogFile}" "${installConfigFile}"` + "\n\n" + "1. Close this client\n" +
"2. Execute this command:\n" +
` sudo "${updateInstallerExecutable}" "${installLogFile}" "${installConfigFile}"` + "\n" +
"3. Start the client again\n\n" +
"Note:\n" +
"We've already copied that command to your clipboard." "We've already copied that command to your clipboard."
); );
return; return;

View File

@ -46,6 +46,8 @@ async function handleAppReady() {
} }
console.log("Update success: %o. Update data: %o", success, data); console.log("Update success: %o. Update data: %o", success, data);
const isRootExec = process.getuid && process.getuid() === 0;
let title; let title;
let type; let type;
let message; let message;
@ -63,10 +65,14 @@ async function handleAppReady() {
message = "Update has been successfully installed!\nWhat do you want to do next?"; message = "Update has been successfully installed!\nWhat do you want to do next?";
buttons.push({ if(!isRootExec) {
key: "Launch client", /* Don't start the app automatically if we're still having root privileges */
callback: async () => false buttons.push({
}); key: "Launch client",
callback: async () => false
});
}
if(data.parse_success && data.log_file) { if(data.parse_success && data.log_file) {
buttons.push({ buttons.push({
key: "Open update log", key: "Open update log",
@ -90,17 +96,21 @@ async function handleAppReady() {
message += "\nUnknown error! Lookup the console for more details."; message += "\nUnknown error! Lookup the console for more details.";
} }
buttons.push({ if(!isRootExec) {
key: "Ignore", /* Don't start the app automatically if we're still having root privileges */
callback: async () => false buttons.push({
}); key: "Ignore",
buttons.push({ callback: async () => false
key: "Retry update", });
callback: async () => { buttons.push({
await showUpdateWindow(); key: "Retry update",
return true; callback: async () => {
} await showUpdateWindow();
}); return true;
}
});
}
if(data.parse_success && data.log_file) { if(data.parse_success && data.log_file) {
buttons.push({ buttons.push({
key: "Open update log", key: "Open update log",