From bbef557ceb10fa5d93ad95e08de1513f2539e000 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Sun, 1 Mar 2020 14:42:08 +0800 Subject: [PATCH] up/down file: notice must be run as root Signed-off-by: Jianhui Zhao --- src/downfile.c | 5 +++++ src/upfile.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/downfile.c b/src/downfile.c index e499d8a..c3383df 100644 --- a/src/downfile.c +++ b/src/downfile.c @@ -79,6 +79,11 @@ void download_file() static struct ev_signal sw; struct ev_io ior; + if (getuid() > 0) { + fprintf(stderr, "Operation not permitted, must be run as root\n"); + return; + } + if (!realpath(".", abspath)) return; diff --git a/src/upfile.c b/src/upfile.c index ddb45c4..cb8719a 100644 --- a/src/upfile.c +++ b/src/upfile.c @@ -73,6 +73,11 @@ void upload_file(const char *path) struct stat st; int fd; + if (getuid() > 0) { + fprintf(stderr, "Operation not permitted, must be run as root\n"); + return; + } + fd = open(path, O_RDONLY); if (fd < 0) { fprintf(stderr, "open '%s' failed: ", path);