up/down file: notice must be run as root

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao
2020-03-01 14:42:08 +08:00
parent e078a49942
commit bbef557ceb
2 changed files with 10 additions and 0 deletions
+5
View File
@@ -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;
+5
View File
@@ -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);