summaryrefslogtreecommitdiff
path: root/src/utilities/s6-dns-hosts-compile.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-07-20 16:09:04 +0000
committerLaurent Bercot <ska@appnovation.com>2023-07-20 16:09:04 +0000
commit8c904eff93d7c038855f2c1cee8ea54bdb4dae52 (patch)
treef26f3058991135a633caf2818b3d38ee3a6aa094 /src/utilities/s6-dns-hosts-compile.c
parent05402aede9d952f9e561335dc9ba1dae0f8c6084 (diff)
downloads6-dns-8c904eff93d7c038855f2c1cee8ea54bdb4dae52.tar.xz
More bigfuxes!
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/utilities/s6-dns-hosts-compile.c')
-rw-r--r--src/utilities/s6-dns-hosts-compile.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/utilities/s6-dns-hosts-compile.c b/src/utilities/s6-dns-hosts-compile.c
index 554a569..1f9e85d 100644
--- a/src/utilities/s6-dns-hosts-compile.c
+++ b/src/utilities/s6-dns-hosts-compile.c
@@ -47,10 +47,25 @@ int main (int argc, char const *const *argv)
fdw = mkstemp(tmp) ;
if (fdw == -1) strerr_diefu2sys(111, "create ", tmp) ;
if (!s6dns_hosts_compile(fdr, fdw))
- strerr_diefu4sys(111, "compile ", ifile, " to ", tmp) ;
- if (fsync(fdw) == -1) strerr_diefu2sys(111, "fsync ", tmp) ;
- if (fchmod(fdw, 0644) == -1) strerr_diefu2sys(111, "fchmod ", tmp) ;
- if (rename(tmp, ofile) == -1) strerr_diefu4sys(111, "rename ", tmp, " to ", ofile) ;
+ {
+ unlink_void(tmp) ;
+ strerr_diefu2sys(111, "compile ", ifile) ;
+ }
+ if (fsync(fdw) == -1)
+ {
+ unlink_void(tmp) ;
+ strerr_diefu2sys(111, "fsync ", tmp) ;
+ }
+ if (fchmod(fdw, 0644) == -1)
+ {
+ unlink_void(tmp) ;
+ strerr_diefu2sys(111, "fchmod ", tmp) ;
+ }
+ if (rename(tmp, ofile) == -1)
+ {
+ unlink_void(tmp) ;
+ strerr_diefu4sys(111, "rename ", tmp, " to ", ofile) ;
+ }
}
return 0 ;
}