X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/2ed790f3541cd5803b285bb46b2cba02103cc88b..9439c0cb5a4b020b9bfcfe0351e33c17b9c53b54:/syscall.c diff --git a/syscall.c b/syscall.c index 20ad131b..ebcb9009 100644 --- a/syscall.c +++ b/syscall.c @@ -27,6 +27,7 @@ #endif extern int dry_run; +extern int am_root; extern int read_only; extern int list_only; extern int preserve_perms; @@ -78,6 +79,15 @@ int do_mknod(const char *pathname, mode_t mode, dev_t dev) { if (dry_run) return 0; RETURN_ERROR_IF_RO_OR_LO; + + /* For --fake-super, we create a normal file with mode 0600. */ + if (am_root < 0) { + int fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR); + if (fd < 0 || close(fd) < 0) + return -1; + return 0; + } + #if !defined MKNOD_CREATES_FIFOS && defined HAVE_MKFIFO if (S_ISFIFO(mode)) return mkfifo(pathname, mode);