( flagPath: string = operatorModeFlagPath() )
| 490 | * surface. If workers can write that home directory, use a stronger boundary. |
| 491 | */ |
| 492 | export function isOperatorModeEnabled( |
| 493 | flagPath: string = operatorModeFlagPath() |
| 494 | ): boolean { |
| 495 | if (typeof process.getuid !== "function") return false; |
| 496 | try { |
| 497 | const stat = lstatSync(flagPath); |
| 498 | return ( |
| 499 | stat.isFile() && |
| 500 | stat.uid === process.getuid() && |
| 501 | (stat.mode & 0o777) === 0o600 |
| 502 | ); |
| 503 | } catch { |
| 504 | return false; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | export function assertOperatorModeOrBail( |
| 509 | action: string, |
no test coverage detected