Author: pkelsey
Date: Thu Jun  4 04:54:54 2015
New Revision: 283978
URL: https://svnweb.freebsd.org/changeset/base/283978

Log:
  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.

Modified:
  stable/10/sbin/dhclient/dhclient.c

Modified: stable/10/sbin/dhclient/dhclient.c
==============================================================================
--- stable/10/sbin/dhclient/dhclient.c  Thu Jun  4 04:50:52 2015        
(r283977)
+++ stable/10/sbin/dhclient/dhclient.c  Thu Jun  4 04:54:54 2015        
(r283978)
@@ -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);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to