fix(striker-ui-api): apply getent to resolve uid:gid

main
Tsu-ba-me 2 years ago
parent 8a8b2cbc4b
commit d1b53b4a2c
  1. 7
      striker-ui-api/src/lib/consts/PROCESS_OWNER.ts
  2. 1
      striker-ui-api/src/lib/consts/SERVER_PATHS.ts
  3. 10
      striker-ui-api/src/lib/shell.ts

@ -1,2 +1,5 @@
export const PUID = process.env.PUID ?? 'striker-ui-api'; import { resolveGid, resolveUid } from '../shell';
export const PGID = process.env.PGID ?? PUID;
export const PUID = resolveUid(process.env.PUID ?? 'striker-ui-api');
export const PGID = resolveGid(process.env.PGID ?? PUID);

@ -14,6 +14,7 @@ const EMPTY_SERVER_PATHS: ServerPath = {
usr: { usr: {
bin: { bin: {
date: {}, date: {},
getent: {},
mkfifo: {}, mkfifo: {},
openssl: {}, openssl: {},
psql: {}, psql: {},

@ -32,6 +32,9 @@ const systemCall = (
export const date = (...args: string[]) => export const date = (...args: string[]) =>
systemCall(SERVER_PATHS.usr.bin.date.self, args); systemCall(SERVER_PATHS.usr.bin.date.self, args);
export const getent = (...args: string[]) =>
systemCall(SERVER_PATHS.usr.bin.getent.self, args);
export const mkfifo = (...args: string[]) => export const mkfifo = (...args: string[]) =>
systemCall(SERVER_PATHS.usr.bin.mkfifo.self, args); systemCall(SERVER_PATHS.usr.bin.mkfifo.self, args);
@ -44,6 +47,13 @@ export const rm = (...args: string[]) =>
export const uuidgen = (...args: string[]) => export const uuidgen = (...args: string[]) =>
systemCall(SERVER_PATHS.usr.bin.uuidgen.self, args); systemCall(SERVER_PATHS.usr.bin.uuidgen.self, args);
export const resolveId = (id: number | string, database: string) =>
Number.parseInt(getent(database, String(id)).split(':', 3)[2]);
export const resolveGid = (id: number | string) => resolveId(id, 'group');
export const resolveUid = (id: number | string) => resolveId(id, 'passwd');
export const stderr = (message: string) => print(message, { stream: 'stderr' }); export const stderr = (message: string) => print(message, { stream: 'stderr' });
export const stdout = (message: string) => print(message); export const stdout = (message: string) => print(message);

Loading…
Cancel
Save