summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2016-07-20 19:25:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2016-07-20 19:25:40 +0000
commit4236b520f9b1491f880de4fa0cb4a0a31fb30892 (patch)
tree9259042a24f4d2e90adc286342b35330e0ef5a01 /sbin
parentdce636ba3adcd5be51f1539994bf7a05f6340da4 (diff)
As a general rule, fchown before fchmod is a safer order (because many
systems throw away bits upon chown). Not in this case, but code gets copied.. ok krw
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 7f89b1d5777..6e27d0e35e2 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.374 2016/07/19 17:23:20 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.375 2016/07/20 19:25:39 deraadt Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -2586,12 +2586,12 @@ priv_write_file(char *path, int flags, mode_t mode, uid_t uid, gid_t gid,
note("Short contents write to '%s' (%zd vs %zu)", path,
n, sz);
+ if (fchown(fd, 0, 0) == -1)
+ note("fchown(fd, %d, %d) of '%s' failed (%s)",
+ 0, 0, path, strerror(errno));
if (fchmod(fd, mode) == -1)
note("fchmod(fd, 0x%x) of '%s' failed (%s)", mode,
path, strerror(errno));
- if (fchown(fd, uid, gid) == -1)
- note("fchown(fd, %d, %d) of '%s' failed (%s)", uid,
- gid, path, strerror(errno));
close(fd);
}