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

Function readFileWithSudo

daemon/src/service/network_limit_service.ts:61–76  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

59}
60
61async function readFileWithSudo(path: string): Promise<string | null> {
62 try {
63 return (await fs.promises.readFile(path, "utf8")).trim();
64 } catch (err: any) {
65 if (err.code !== "EACCES" && err.code !== "EPERM") {
66 return null;
67 }
68 logger.info(`File requires elevated privileges, retrying with sudo: ${path}`);
69 try {
70 const { stdout } = await runFile("sudo", ["-n", "cat", path]);
71 return (stdout || "").trim();
72 } catch {
73 return null;
74 }
75 }
76}
77
78export interface BandwidthLimit {
79 uploadLimit?: number;

Callers 1

readContainerIflinkMethod · 0.85

Calls 3

runFileFunction · 0.85
infoMethod · 0.80
readFileMethod · 0.45

Tested by

no test coverage detected