- if (preserve_hard_links && check_hard_link(file)) {
- if (verbose > 1)
- fprintf(FINFO,"%s is a hard link\n",file->name);
- return;
- }
-
- if (!S_ISREG(file->mode)) {
- fprintf(FERROR,"skipping non-regular file %s\n",fname);
- return;
- }
-
- if (statret == -1) {
- if (errno == ENOENT) {
- write_int(f_out,i);
- if (!dry_run) send_sums(NULL,f_out);
- } else {
- if (verbose > 1)
- fprintf(FERROR,"recv_generator failed to open %s\n",fname);
- }
- return;
- }
-
- if (!S_ISREG(st.st_mode)) {
- /* its not a regular file on the receiving end, but it is on the
- sending end. If its a directory then skip it (too dangerous to
- do a recursive deletion??) otherwise try to unlink it */
- if (S_ISDIR(st.st_mode)) {
- fprintf(FERROR,"ERROR: %s is a directory\n",fname);
- return;
- }
- if (unlink(fname) != 0) {
- fprintf(FERROR,"%s : not a regular file (generator)\n",fname);
- return;
- }
-
- /* now pretend the file didn't exist */
- write_int(f_out,i);
- if (!dry_run) send_sums(NULL,f_out);
- return;
- }
-
- if (update_only && st.st_mtime >= file->modtime) {
- if (verbose > 1)
- fprintf(FERROR,"%s is newer\n",fname);
- return;
- }
-
- if (always_checksum && S_ISREG(st.st_mode)) {
- file_checksum(fname,sum,st.st_size);
- }
-
- if (st.st_size == file->length &&
- ((!ignore_times && st.st_mtime == file->modtime) ||
- (always_checksum && S_ISREG(st.st_mode) &&
- memcmp(sum,file->sum,csum_length) == 0))) {
- set_perms(fname,file,&st,1);
- return;
- }
-
- if (dry_run) {
- write_int(f_out,i);
- return;
- }
-
- /* open the file */
- fd = open(fname,O_RDONLY);
-
- if (fd == -1) {
- fprintf(FERROR,"failed to open %s : %s\n",fname,strerror(errno));
- return;
- }
-
- if (st.st_size > 0) {
- buf = map_file(fd,st.st_size);
- } else {
- buf = NULL;
- }
-
- if (verbose > 3)
- fprintf(FERROR,"gen mapped %s of size %d\n",fname,(int)st.st_size);
-
- s = generate_sums(buf,st.st_size,block_size);
-
- if (verbose > 2)
- fprintf(FERROR,"sending sums for %d\n",i);
-
- write_int(f_out,i);
- send_sums(s,f_out);
- write_flush(f_out);
-
- close(fd);
- if (buf) unmap_file(buf);
-
- free_sums(s);
-}
-
-
+ if (daemon_chmod_modes && !S_ISLNK(new_mode))
+ new_mode = tweak_mode(new_mode, daemon_chmod_modes);
+#ifdef HAVE_CHMOD
+ if (!BITS_EQUAL(st->st_mode, new_mode, CHMOD_BITS)) {
+ int ret = do_chmod(fname, new_mode);
+ if (ret < 0) {
+ rsyserr(FERROR, errno,
+ "failed to set permissions on %s",
+ full_fname(fname));
+ return 0;
+ }
+ if (ret == 0) /* ret == 1 if symlink could not be set */
+ updated = 1;
+ }
+#endif