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