Add some more environment variables
This commit is contained in:
parent
fd298cbba7
commit
382abe9f6d
|
@ -57,7 +57,7 @@ export class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
get env() {
|
get env() {
|
||||||
return util.getEnv(this.uuid);
|
return util.getEnv(this.context);
|
||||||
}
|
}
|
||||||
|
|
||||||
log = (msg: string) => console.log(`[${this.uuid}] ${msg}`);
|
log = (msg: string) => console.log(`[${this.uuid}] ${msg}`);
|
||||||
|
|
|
@ -44,7 +44,7 @@ async function main() {
|
||||||
await run(privilegedSetup({ uid, uuid }), log);
|
await run(privilegedSetup({ uid, uuid }), log);
|
||||||
const args = privilegedSpawn({ uid, uuid }, ["bash"]);
|
const args = privilegedSpawn({ uid, uuid }, ["bash"]);
|
||||||
const proc = spawn(args[0], args.slice(1), {
|
const proc = spawn(args[0], args.slice(1), {
|
||||||
env: getEnv(uuid),
|
env: getEnv({ uid, uuid }),
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
});
|
});
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { spawn, SpawnOptions } from "child_process";
|
import { spawn, SpawnOptions } from "child_process";
|
||||||
|
import * as os from "os";
|
||||||
import * as process from "process";
|
import * as process from "process";
|
||||||
|
|
||||||
import * as appRoot from "app-root-path";
|
import * as appRoot from "app-root-path";
|
||||||
|
|
||||||
|
import { MIN_UID, MAX_UID } from "./users";
|
||||||
|
|
||||||
export interface Options extends SpawnOptions {
|
export interface Options extends SpawnOptions {
|
||||||
input?: string;
|
input?: string;
|
||||||
check?: boolean;
|
check?: boolean;
|
||||||
|
@ -17,7 +20,7 @@ export const rijuSystemPrivileged = appRoot.resolve(
|
||||||
"system/out/riju-system-privileged"
|
"system/out/riju-system-privileged"
|
||||||
);
|
);
|
||||||
|
|
||||||
export function getEnv(uuid: string) {
|
export function getEnv({ uid, uuid }: Context) {
|
||||||
const cwd = `/tmp/riju/${uuid}`;
|
const cwd = `/tmp/riju/${uuid}`;
|
||||||
const path = [
|
const path = [
|
||||||
`${cwd}/.gem/ruby/2.7.0/bin`,
|
`${cwd}/.gem/ruby/2.7.0/bin`,
|
||||||
|
@ -29,15 +32,20 @@ export function getEnv(uuid: string) {
|
||||||
`/usr/bin`,
|
`/usr/bin`,
|
||||||
`/bin`,
|
`/bin`,
|
||||||
];
|
];
|
||||||
|
const username =
|
||||||
|
uid >= MIN_UID && uid < MAX_UID ? `riju${uid}` : os.userInfo().username;
|
||||||
return {
|
return {
|
||||||
HOME: cwd,
|
HOME: cwd,
|
||||||
HOSTNAME: "riju",
|
HOSTNAME: "riju",
|
||||||
LANG: process.env.LANG || "",
|
LANG: process.env.LANG || "",
|
||||||
LC_ALL: process.env.LC_ALL || "",
|
LC_ALL: process.env.LC_ALL || "",
|
||||||
|
LOGNAME: username,
|
||||||
PATH: path.join(":"),
|
PATH: path.join(":"),
|
||||||
PWD: cwd,
|
PWD: cwd,
|
||||||
SHELL: "/usr/bin/bash",
|
SHELL: "/usr/bin/bash",
|
||||||
TERM: "xterm-color",
|
TERM: "xterm-256color",
|
||||||
|
USER: username,
|
||||||
|
USERNAME: username,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue