summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
authorpkelsey <pkelsey@FreeBSD.org>2015-05-28 05:38:07 +0000
committerpkelsey <pkelsey@FreeBSD.org>2015-05-28 05:38:07 +0000
commite78dd9d8ebd584a44a515ae0711bca71f63243a6 (patch)
treea4a429decdd2db2ce047b274e2e567b2a835c9d1 /sbin/dhclient/dhclient.c
parente347653ba08b12386f2285d9827172ad6eaeefea (diff)
downloadFreeBSD-src-e78dd9d8ebd584a44a515ae0711bca71f63243a6.zip
FreeBSD-src-e78dd9d8ebd584a44a515ae0711bca71f63243a6.tar.gz
Add CAP_FCNTL to the lease file capsicum rights, and limit to
CAP_FCNTL_GETFL. Without CAP_FCNTL_GETFL, the lease file truncation in rewrite_client_leases() will fail to trim old data when rewriting the file with a lesser amount of data. Reviewed by: pjd, rwatson Approved by: jmallett (mentor) MFC after: 1 week
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 22b21f1..7905813 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1845,12 +1845,16 @@ rewrite_client_leases(void)
leaseFile = fopen(path_dhclient_db, "w");
if (!leaseFile)
error("can't create %s: %m", path_dhclient_db);
- cap_rights_init(&rights, CAP_FSTAT, CAP_FSYNC, CAP_FTRUNCATE,
- CAP_SEEK, CAP_WRITE);
+ cap_rights_init(&rights, CAP_FCNTL, CAP_FSTAT, CAP_FSYNC,
+ CAP_FTRUNCATE, CAP_SEEK, CAP_WRITE);
if (cap_rights_limit(fileno(leaseFile), &rights) < 0 &&
errno != ENOSYS) {
error("can't limit lease descriptor: %m");
}
+ if (cap_fcntls_limit(fileno(leaseFile), CAP_FCNTL_GETFL) < 0 &&
+ errno != ENOSYS) {
+ error("can't limit lease descriptor fcntls: %m");
+ }
} else {
fflush(leaseFile);
rewind(leaseFile);
OpenPOWER on IntegriCloud