-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
166 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
node_modules | ||
.env | ||
.killignore | ||
.tmp | ||
test/*.out | ||
phpmyadmin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root | ||
bridge | ||
do-agent | ||
dbus | ||
earlyoom | ||
mysql | ||
named | ||
nobody | ||
postgres | ||
polkitd | ||
rpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
import { dirname } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
process.chdir(__dirname); | ||
|
||
import './src/index.js'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
cat, | ||
executeLock, | ||
spawnSudoUtil, | ||
writeTo | ||
} from '../util.js'; | ||
import { writeFile } from 'fs/promises'; | ||
|
||
const killIgnoreFile = '.killignore' | ||
|
||
class PodmanExecutor { | ||
constructor() { | ||
} | ||
/** | ||
* @param {string} user | ||
*/ | ||
checkPodmanEnabled(user) { | ||
try { | ||
return cat(killIgnoreFile).split('\n').includes(user); | ||
} catch (err) { | ||
if (err.code === 'ENOENT') { | ||
writeTo(killIgnoreFile, "root\n"); | ||
} else { | ||
throw err; | ||
} | ||
return false; | ||
} | ||
} | ||
/** | ||
* @param {string} user | ||
*/ | ||
async enablePodman(user) { | ||
if (this.checkPodmanEnabled(user)) { | ||
return "Done unchanged"; | ||
} | ||
return await executeLock('podman', async () => { | ||
const content = cat(killIgnoreFile).trim() + `\n${user}\n`; | ||
await writeFile(killIgnoreFile, content, { | ||
encoding: 'utf-8' | ||
}); | ||
await spawnSudoUtil("SHELL_SUDO", ["root", | ||
"usermod", "--add-subuids", "100000-165535", | ||
"--add-subgids", "100000-165535", user]); | ||
return "Updated for podman"; | ||
}); | ||
} | ||
/** | ||
* @param {string} user | ||
*/ | ||
async disablePodman(user) { | ||
if (!this.checkPodmanEnabled(user)) { | ||
return "Done unchanged"; | ||
} | ||
return await executeLock('podman', async () => { | ||
var content = cat(killIgnoreFile).trim().split('\n').filter(x => x !== user); | ||
await writeFile(killIgnoreFile, content.join("\n") + "\n", { | ||
encoding: 'utf-8' | ||
}); | ||
await spawnSudoUtil("SHELL_SUDO", ["root", | ||
"usermod", "--del-subuids", "100000-165535", | ||
"--del-subgids", "100000-165535", user]); | ||
return "Updated for podman"; | ||
}); | ||
} | ||
} | ||
|
||
export const podmanExec = new PodmanExecutor(); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters