Commit f563eec2526fe1285c5a1a1175d6bbcbb3b23097
Committed by
Gordon Hollingworth
1 parent
f4ff1f08
Update main.c
Added check at top of main() to test if user is running as sudo. Print message and exit if not run as sudo.
Showing
1 changed file
with
8 additions
and
0 deletions
main.c
| ... | ... | @@ -96,6 +96,14 @@ int main(int argc, char *argv[]) |
| 96 | 96 | int length; |
| 97 | 97 | unsigned char signature[20]; |
| 98 | 98 | } message; |
| 99 | + | |
| 100 | + //exit if not run as sudo | |
| 101 | + int user = getuid(); | |
| 102 | + if(user != 0) | |
| 103 | + { | |
| 104 | + printf("Must be run with sudo...\n"); | |
| 105 | + exit(-1); | |
| 106 | + } | |
| 99 | 107 | |
| 100 | 108 | // Skip the command name |
| 101 | 109 | argv++; argc--; | ... | ... |