MFp4 @229485:

Only allow to overwrite lease file.

Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Pawel Jakub Dawidek 2013-07-03 22:19:43 +00:00
parent f73ac8b9de
commit fe5c716394

View File

@ -1842,6 +1842,11 @@ rewrite_client_leases(void)
leaseFile = fopen(path_dhclient_db, "w");
if (!leaseFile)
error("can't create %s: %m", path_dhclient_db);
if (cap_rights_limit(fileno(leaseFile), CAP_FSTAT | CAP_FSYNC |
CAP_FTRUNCATE | CAP_SEEK | CAP_WRITE) < 0 &&
errno != ENOSYS) {
error("can't limit lease descriptor: %m");
}
} else {
fflush(leaseFile);
rewind(leaseFile);