diff options
author | pkelsey <pkelsey@FreeBSD.org> | 2015-06-04 04:54:54 +0000 |
---|---|---|
committer | pkelsey <pkelsey@FreeBSD.org> | 2015-06-04 04:54:54 +0000 |
commit | b8022a78066933b27588597a788d2ca57544a094 (patch) | |
tree | b336a5e37ccb4602149f980df0b3f708b9a99f4f | |
parent | 82415e4370d95e7ae43e397fa8b6e4186bcdb505 (diff) | |
download | FreeBSD-src-b8022a78066933b27588597a788d2ca57544a094.zip FreeBSD-src-b8022a78066933b27588597a788d2ca57544a094.tar.gz |
MFC r283641:
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.
-rw-r--r-- | sbin/dhclient/dhclient.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index e059128..97f9d47 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1847,12 +1847,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); |