From adfec4fcd8ba0e98adf14aab0717348accb001c4 Mon Sep 17 00:00:00 2001 From: ston Date: Tue, 9 Apr 2024 23:07:15 +0800 Subject: [PATCH] add root check Signed-off-by: ston --- .gitignore | 3 +++ extra/service/legiond/legiond-ctl.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 0cc1bd7..52cdb66 100644 --- a/.gitignore +++ b/.gitignore @@ -62,5 +62,8 @@ dkms.conf build/ dist/ + +# Legiond extra/service/legiond/legiond extra/service/legiond/legiond-ctl +.ccls-cache diff --git a/extra/service/legiond/legiond-ctl.c b/extra/service/legiond/legiond-ctl.c index 60048c2..8121e0f 100644 --- a/extra/service/legiond/legiond-ctl.c +++ b/extra/service/legiond/legiond-ctl.c @@ -2,6 +2,11 @@ int main(int argc, char *argv[]) { + if (getuid() != 0){ + printf("require root privileges\n"); + exit(3); + } + if (access(socket_path, F_OK) == -1) { printf("socket not found\n"); exit(1);