- if(n < 0) fatal(errno, "error reading %s", from);
- if(close(fdout) < 0) fatal(errno, "error closing %s", to);
+ if(n < 0)
+ disorder_fatal(errno, "error reading %s", from);
+ if(fstat(fdin, &sb) < 0)
+ disorder_fatal(errno, "error stating %s", from);
+ if(fchown(fdout, sb.st_uid, sb.st_gid) < 0)
+ disorder_fatal(errno, "error chowning %s", from);
+ if(fchmod(fdout, sb.st_mode & 07777) < 0)
+ disorder_fatal(errno, "error chmoding %s", from);
+ if(close(fdout) < 0) disorder_fatal(errno, "error closing %s", to);