Refuse installing Clusterio as root

I have seen multiple people have installed Clusterio as the root account
and then run it as root when tasked with setting up Clusterio on Linux.
Make this mistake harder to do by refusing to install as root by
default.
This commit is contained in:
Hornwitser committed 2022-07-18 20:05:37 +02:00
1 parent c9619397b6
commit 2953eb17d6
2 files changed
+18 -1

No files matched your search

+1 -1
View File
@@ -105,7 +105,7 @@ Otherwise see below for OS specific instructions.
wget -qO - https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install nodejs
2. Create a new directory and run the Clusterio installer:
2. Log in as the user you wish to install Clusterio as (do not use root), and then create a new directory and run the Clusterio installer:
mkdir clusterio
cd clusterio
+17
View File
@@ -168,6 +168,19 @@ async function validateInstallDir() {
}
}
async function validateNotRoot(args) {
if (args.allowInstallAsRoot) {
return;
}
if (os.userInfo().uid === 0) {
throw new InstallError(
"Refusing to install as root. Create a separate user account for clusterio " +
"and then use su/sudo to switch to it before invoking the installer."
);
}
}
async function installClusterio(mode, plugins) {
try {
await safeOutputFile("package.json", JSON.stringify({
@@ -547,6 +560,9 @@ async function main() {
if (process.platform === "linux") {
args = args
.option("allow-install-as-root", {
nargs: 0, describe: "(Linux only) Allow installing as root (not recommended)", type: "boolean",
})
.option("download-headless", {
nargs: 0,
describe: "(Linux only) Automatically download and unpack the latest factorio release. " +
@@ -563,6 +579,7 @@ async function main() {
if (!dev) {
await validateInstallDir();
await validateNotRoot(args);
}
let answers = await inquirerMissingArgs(args);