MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / execWithSudo

Function execWithSudo

daemon/src/service/network_limit_service.ts:43–59  ·  view source on GitHub ↗
(
  command: string,
  args: string[] = []
)

Source from the content-addressed store, hash-verified

41}
42
43async function execWithSudo(
44 command: string,
45 args: string[] = []
46): Promise<{ stdout: string; stderr: string }> {
47 try {
48 return await runFile(command, args);
49 } catch (err: any) {
50 if (!isPermissionError(err)) {
51 throw err;
52 }
53
54 logger.info(
55 `Command requires elevated privileges, retrying with sudo: ${formatCommand(command, args)}`
56 );
57 return await runFile("sudo", ["-n", command, ...args]);
58 }
59}
60
61async function readFileWithSudo(path: string): Promise<string | null> {
62 try {

Callers 5

readContainerIflinkMethod · 0.85
findVethByIfindexMethod · 0.85
applyEgressLimitMethod · 0.85
applyIngressLimitMethod · 0.85
clearLimitForVethMethod · 0.85

Calls 4

runFileFunction · 0.85
isPermissionErrorFunction · 0.85
formatCommandFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected