Commit 2d2cafa
committed
refactor(main): Enforce root-only execution with fail-fast logic
Refactor the application's startup sequence to enforce a strict root-only requirement, removing the previous non-root fallback behavior.
The new logic in main() is as follows:
- On startup, check if the effective UID is 0.
- If not root, check for the availability of an 'su' binary.
- If 'su' is present, attempt self-elevation via `try_elevate_privileges()`. If this function returns (i.e., fails), exit the app with an error.
- If 'su' is not present, exit immediately with an error.
This change ensures that the application will not proceed to the TUI unless it has successfully acquired root privileges, preventing it from running in an unsupported and non-functional state.1 parent a6d4700 commit 2d2cafa
1 file changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
48 | 59 | | |
49 | 60 | | |
| 61 | + | |
| 62 | + | |
50 | 63 | | |
51 | 64 | | |
52 | 65 | | |
| |||
0 commit comments