Skip to content

Commit

Permalink
up/down file: notice must be run as root
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Mar 1, 2020
1 parent e078a49 commit bbef557
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/downfile.c
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions src/upfile.c
Expand Up @@ -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);
Expand Down

0 comments on commit bbef557

Please sign in to comment.