From owner-svn-src-all@FreeBSD.ORG Sun Mar 30 16:04:48 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5A8CD9F1; Sun, 30 Mar 2014 16:04:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 404A3D5D; Sun, 30 Mar 2014 16:04:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2UG4mQl053408; Sun, 30 Mar 2014 16:04:48 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2UG4mjn053407; Sun, 30 Mar 2014 16:04:48 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201403301604.s2UG4mjn053407@svn.freebsd.org> From: Eitan Adler Date: Sun, 30 Mar 2014 16:04:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263940 - head/usr.bin/units X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Mar 2014 16:04:48 -0000 Author: eadler Date: Sun Mar 30 16:04:47 2014 New Revision: 263940 URL: http://svnweb.freebsd.org/changeset/base/263940 Log: add capsicum to units(1) Modified: head/usr.bin/units/units.c Modified: head/usr.bin/units/units.c ============================================================================== --- head/usr.bin/units/units.c Sun Mar 30 15:30:33 2014 (r263939) +++ head/usr.bin/units/units.c Sun Mar 30 16:04:47 2014 (r263940) @@ -22,11 +22,14 @@ static const char rcsid[] = #include #include +#include #include #include #include #include +#include + #include "pathnames.h" #define VERSION "1.0" @@ -112,6 +115,7 @@ readunits(const char *userfile) FILE *unitfile; char line[512], *lineptr; int len, linenum, i; + cap_rights_t unitfilerights; unitcount = 0; linenum = 0; @@ -143,6 +147,12 @@ readunits(const char *userfile) errx(1, "can't find units file '%s'", UNITSFILE); } } + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + cap_rights_init(&unitfilerights, CAP_READ, CAP_FSTAT); + if (cap_rights_limit(fileno(unitfile), &unitfilerights) < 0 + && errno != ENOSYS) + err(1, "cap_rights_limit() failed"); while (!feof(unitfile)) { if (!fgets(line, sizeof(line), unitfile)) break;