From owner-svn-src-user@freebsd.org Tue Feb 28 12:05:59 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 664B1CF1C3B for ; Tue, 28 Feb 2017 12:05:59 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 412311D2; Tue, 28 Feb 2017 12:05:59 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1SC5wBX025814; Tue, 28 Feb 2017 12:05:58 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1SC5wcK025813; Tue, 28 Feb 2017 12:05:58 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201702281205.v1SC5wcK025813@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 28 Feb 2017 12:05:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r314388 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Feb 2017 12:05:59 -0000 Author: pho Date: Tue Feb 28 12:05:58 2017 New Revision: 314388 URL: https://svnweb.freebsd.org/changeset/base/314388 Log: Added a new test scenario. Sponsored by: Dell EMC Isilon Added: user/pho/stress2/misc/umount2.sh (contents, props changed) Added: user/pho/stress2/misc/umount2.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/umount2.sh Tue Feb 28 12:05:58 2017 (r314388) @@ -0,0 +1,92 @@ +#!/bin/sh + +# +# Copyright (c) 2017 Dell EMC Isilon +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# # ps -l +# UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND +# 0 72280 1 0 20 0 5992 1768 mntref D 0- 0:03.20 umount /mnt + +# https://people.freebsd.org/~pho/stress/log/kostik990.txt + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +[ `swapinfo | wc -l` -eq 1 ] && exit 0 + +. ../default.cfg + +mount | grep -q "on $mntpoint " && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 5g -u $mdstart +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint +chmod 777 $mntpoint + +size=$((`sysctl -n hw.physmem` / 1024 / 1024)) +[ $size -gt $((4 * 1024)) ] && + echo "RAM should be capped to 4GB for this test." + +export RUNDIR=$mntpoint/stressX +export runRUNTIME=5m +export TESTPROGS=" +testcases/symlink/symlink +testcases/openat/openat +testcases/fts/fts +testcases/lockf/lockf +" + +export ftsINCARNATIONS=192 +export lockfINCARNATIONS=132 +export openatINCARNATIONS=218 +export symlinkINCARNATIONS=201 + +export ftsLOAD=100 +export lockfLOAD=100 +export openatLOAD=100 +export symlinkLOAD=100 + +export ftsHOG=1 +export lockfHOG=1 +export openatHOG=1 +export symlinkHOG=1 + +su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' + +sync +umount $mntpoint & +sleep 5 +kill -0 $! 2>/dev/null && { ps -lp$! | grep mntref && exit 1; } +wait + +for i in `jot 6`; do + mount | grep -q "on $mntpoint " || break + umount $mntpoint && break || sleep 10 +done +[ $i -eq 6 ] && exit 1 +mdconfig -d -u $mdstart +exit 0 From owner-svn-src-user@freebsd.org Sat Mar 4 20:50:18 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A79BBCF94AE for ; Sat, 4 Mar 2017 20:50:18 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 817F111E7; Sat, 4 Mar 2017 20:50:18 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v24KoHgC062713; Sat, 4 Mar 2017 20:50:17 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v24KoHDA062712; Sat, 4 Mar 2017 20:50:17 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201703042050.v24KoHDA062712@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 4 Mar 2017 20:50:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r314678 - user/bapt/diff X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Mar 2017 20:50:18 -0000 Author: bapt Date: Sat Mar 4 20:50:17 2017 New Revision: 314678 URL: https://svnweb.freebsd.org/changeset/base/314678 Log: Capsicumize diff on regular files To allow to work in capsicum mode: - early spawn pr(1) if needed (lflag) - use pdfork instead of fork - use kevent to track the exit of pr(1) as pdwait4 does not exist yet Modified: user/bapt/diff/diffreg.c Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Sat Mar 4 20:46:57 2017 (r314677) +++ user/bapt/diff/diffreg.c Sat Mar 4 20:50:17 2017 (r314678) @@ -67,9 +67,14 @@ #include __FBSDID("$FreeBSD$"); +#include +#include #include +#include +#include #include +#include #include #include #include @@ -307,7 +312,9 @@ diffreg(char *file1, char *file2, int fl FILE *f1, *f2; int i, rval; int ostdout = -1; - pid_t pid = -1; + int pr_pd, kq; + struct kevent *e; + cap_rights_t rights_ro; f1 = f2 = NULL; rval = D_SAME; @@ -366,26 +373,10 @@ diffreg(char *file1, char *file2, int fl goto closem; } - switch (files_differ(f1, f2, flags)) { - case 0: - goto closem; - case 1: - break; - default: - /* error */ - status |= 2; - goto closem; - } - - if ((flags & D_FORCEASCII) == 0 && - (!asciifile(f1) || !asciifile(f2))) { - rval = D_BINARY; - status |= 1; - goto closem; - } if (lflag) { /* redirect stdout to pr */ int pfd[2]; + pid_t pid; char *header; xasprintf(&header, "%s %s %s", diffargs, file1, file2); @@ -393,7 +384,7 @@ diffreg(char *file1, char *file2, int fl fflush(stdout); rewind(stdout); pipe(pfd); - switch ((pid = fork())) { + switch ((pid = pdfork(&pr_pd, PD_CLOEXEC))) { case -1: status |= 2; free(header); @@ -408,6 +399,7 @@ diffreg(char *file1, char *file2, int fl execl(_PATH_PR, _PATH_PR, "-h", header, (char *)0); _exit(127); default: + /* parent */ if (pfd[1] != STDOUT_FILENO) { ostdout = dup(STDOUT_FILENO); @@ -417,8 +409,46 @@ diffreg(char *file1, char *file2, int fl close(pfd[0]); rewind(stdout); free(header); + kq = kqueue(); + if (kq == -1) + err(2, "kqueue"); + e = xmalloc(sizeof(struct kevent)); + EV_SET(e, pr_pd, EVFILT_PROCDESC, EV_ADD, NOTE_EXIT, 0, + NULL); + if (kevent(kq, e, 1, NULL, 0, NULL) == -1) + err(2, "kevent"); } } + + cap_rights_init(&rights_ro, CAP_READ, CAP_FSTAT, CAP_SEEK); + if (cap_rights_limit(fileno(f1), &rights_ro) < 0) + err(2, "unable to limit rights on: %s", file1); + if (cap_rights_limit(fileno(f2), &rights_ro) < 0) + err(2, "unable to limit rights on: %s", file2); + if (caph_limit_stdio() == -1) + err(2, "unable to limit stdio"); + + caph_cache_catpages(); + if (cap_enter() < 0 && errno != ENOSYS) + err(2, "unable to enter capability mode"); + + switch (files_differ(f1, f2, flags)) { + case 0: + goto closem; + case 1: + break; + default: + /* error */ + status |= 2; + goto closem; + } + + if ((flags & D_FORCEASCII) == 0 && + (!asciifile(f1) || !asciifile(f2))) { + rval = D_BINARY; + status |= 1; + goto closem; + } prepare(0, f1, stb1.st_size, flags); prepare(1, f2, stb2.st_size, flags); @@ -452,19 +482,25 @@ diffreg(char *file1, char *file2, int fl check(f1, f2, flags); output(file1, f1, file2, f2, flags); if (ostdout != -1) { + /* close the pipe to pr and restore stdout */ int wstatus; - /* close the pipe to pr and restore stdout */ fflush(stdout); - rewind(stdout); if (ostdout != STDOUT_FILENO) { close(STDOUT_FILENO); dup2(ostdout, STDOUT_FILENO); close(ostdout); } - waitpid(pid, &wstatus, 0); + if (kevent(kq, NULL, 0, e, 1, NULL) == -1) + err(2, "kevent"); + wstatus = e[0].data; + if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != 0) + errx(2, "pr exited abnormally"); + else if (WIFSIGNALED(wstatus)) + errx(2, "pr killed by signal %d", + WTERMSIG(wstatus)); } - + closem: if (anychange) { status |= 1; From owner-svn-src-user@freebsd.org Sat Mar 4 21:06:41 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CB538CF9F2B for ; Sat, 4 Mar 2017 21:06:41 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 98BCF1641; Sat, 4 Mar 2017 21:06:41 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v24L6eEp070918; Sat, 4 Mar 2017 21:06:40 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v24L6eR9070917; Sat, 4 Mar 2017 21:06:40 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201703042106.v24L6eR9070917@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 4 Mar 2017 21:06:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r314679 - user/bapt/diff X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Mar 2017 21:06:41 -0000 Author: bapt Date: Sat Mar 4 21:06:40 2017 New Revision: 314679 URL: https://svnweb.freebsd.org/changeset/base/314679 Log: Fix passing diffing from stdin in capability mode Modified: user/bapt/diff/diffreg.c Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Sat Mar 4 20:50:17 2017 (r314678) +++ user/bapt/diff/diffreg.c Sat Mar 4 21:06:40 2017 (r314679) @@ -425,8 +425,14 @@ diffreg(char *file1, char *file2, int fl err(2, "unable to limit rights on: %s", file1); if (cap_rights_limit(fileno(f2), &rights_ro) < 0) err(2, "unable to limit rights on: %s", file2); - if (caph_limit_stdio() == -1) - err(2, "unable to limit stdio"); + if (fileno(f1) == STDIN_FILENO || fileno(f2) == STDIN_FILENO) { + /* stding has already been limited */ + if (caph_limit_stderr() == -1) + err(2, "unable to limit stderr"); + if (caph_limit_stdout() == -1) + err(2, "unable to limit stdout"); + } else if (caph_limit_stdio() == -1) + err(2, "unable to limit stdio"); caph_cache_catpages(); if (cap_enter() < 0 && errno != ENOSYS) From owner-svn-src-user@freebsd.org Sat Mar 4 21:32:24 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED913CF5B85 for ; Sat, 4 Mar 2017 21:32:24 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 A3E8C1B58; Sat, 4 Mar 2017 21:32:24 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v24LWNb4083670; Sat, 4 Mar 2017 21:32:23 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v24LWNY4083669; Sat, 4 Mar 2017 21:32:23 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201703042132.v24LWNY4083669@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 4 Mar 2017 21:32:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r314680 - user/bapt/diff X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Mar 2017 21:32:25 -0000 Author: bapt Date: Sat Mar 4 21:32:23 2017 New Revision: 314680 URL: https://svnweb.freebsd.org/changeset/base/314680 Log: Remove code that seems to be useless diff(1) was trying to open the non regular file and copy it to a temporary file. the code will already anyway read it. Modified: user/bapt/diff/diffreg.c Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Sat Mar 4 21:06:40 2017 (r314679) +++ user/bapt/diff/diffreg.c Sat Mar 4 21:32:23 2017 (r314680) @@ -194,7 +194,6 @@ struct context_vec { }; #define diff_output printf -static FILE *opentemp(const char *); static void output(char *, FILE *, char *, FILE *, int); static void check(FILE *, FILE *, int); static void range(int, int, const char *); @@ -334,14 +333,7 @@ diffreg(char *file1, char *file2, int fl if (flags & D_EMPTY1) f1 = fopen(_PATH_DEVNULL, "r"); else { - if (!S_ISREG(stb1.st_mode)) { - if ((f1 = opentemp(file1)) == NULL || - fstat(fileno(f1), &stb1) < 0) { - warn("%s", file1); - status |= 2; - goto closem; - } - } else if (strcmp(file1, "-") == 0) + if (strcmp(file1, "-") == 0) f1 = stdin; else f1 = fopen(file1, "r"); @@ -355,14 +347,7 @@ diffreg(char *file1, char *file2, int fl if (flags & D_EMPTY2) f2 = fopen(_PATH_DEVNULL, "r"); else { - if (!S_ISREG(stb2.st_mode)) { - if ((f2 = opentemp(file2)) == NULL || - fstat(fileno(f2), &stb2) < 0) { - warn("%s", file2); - status |= 2; - goto closem; - } - } else if (strcmp(file2, "-") == 0) + if (strcmp(file2, "-") == 0) f2 = stdin; else f2 = fopen(file2, "r"); @@ -549,37 +534,6 @@ files_differ(FILE *f1, FILE *f2, int fla } } -static FILE * -opentemp(const char *path) -{ - char buf[BUFSIZ], tempfile[PATH_MAX]; - ssize_t nread; - int ifd, ofd; - - if (strcmp(path, "-") == 0) - ifd = STDIN_FILENO; - else if ((ifd = open(path, O_RDONLY, 0644)) < 0) - return (NULL); - - (void)strlcpy(tempfile, _PATH_TMP "/diff.XXXXXXXX", sizeof(tempfile)); - - if ((ofd = mkstemp(tempfile)) < 0) { - close(ifd); - return (NULL); - } - unlink(tempfile); - while ((nread = read(ifd, buf, BUFSIZ)) > 0) { - if (write(ofd, buf, nread) != nread) { - close(ifd); - close(ofd); - return (NULL); - } - } - close(ifd); - lseek(ofd, (off_t)0, SEEK_SET); - return (fdopen(ofd, "r")); -} - char * splice(char *dir, char *path) { From owner-svn-src-user@freebsd.org Sat Mar 4 22:15:34 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09452CF9773 for ; Sat, 4 Mar 2017 22:15:34 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 CD6D41458; Sat, 4 Mar 2017 22:15:33 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v24MFWAK000340; Sat, 4 Mar 2017 22:15:32 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v24MFWEE000339; Sat, 4 Mar 2017 22:15:32 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201703042215.v24MFWEE000339@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 4 Mar 2017 22:15:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r314683 - user/bapt/diff X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Mar 2017 22:15:34 -0000 Author: bapt Date: Sat Mar 4 22:15:32 2017 New Revision: 314683 URL: https://svnweb.freebsd.org/changeset/base/314683 Log: Do not leak kqueue fd Modified: user/bapt/diff/diffreg.c Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Sat Mar 4 22:00:05 2017 (r314682) +++ user/bapt/diff/diffreg.c Sat Mar 4 22:15:32 2017 (r314683) @@ -485,6 +485,7 @@ diffreg(char *file1, char *file2, int fl if (kevent(kq, NULL, 0, e, 1, NULL) == -1) err(2, "kevent"); wstatus = e[0].data; + close(kq); if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != 0) errx(2, "pr exited abnormally"); else if (WIFSIGNALED(wstatus)) From owner-svn-src-user@freebsd.org Sat Mar 4 22:24:00 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93765CF9AE2 for ; Sat, 4 Mar 2017 22:24:00 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 6E21D1D56; Sat, 4 Mar 2017 22:24:00 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v24MNxod004833; Sat, 4 Mar 2017 22:23:59 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v24MNx71004831; Sat, 4 Mar 2017 22:23:59 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201703042223.v24MNx71004831@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 4 Mar 2017 22:23:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r314684 - user/bapt/diff X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Mar 2017 22:24:00 -0000 Author: bapt Date: Sat Mar 4 22:23:59 2017 New Revision: 314684 URL: https://svnweb.freebsd.org/changeset/base/314684 Log: Only capsicumize in case of direct call to direct files For now diffing directories is not capsicumized as it needs more work Modified: user/bapt/diff/diff.c user/bapt/diff/diffdir.c user/bapt/diff/diffreg.c Modified: user/bapt/diff/diff.c ============================================================================== --- user/bapt/diff/diff.c Sat Mar 4 22:15:32 2017 (r314683) +++ user/bapt/diff/diff.c Sat Mar 4 22:23:59 2017 (r314684) @@ -307,8 +307,8 @@ main(int argc, char **argv) if (stat(argv[1], &stb2) < 0) err(2, "%s", argv[1]); } - print_status(diffreg(argv[0], argv[1], dflags), argv[0], argv[1], - ""); + print_status(diffreg(argv[0], argv[1], dflags, 1), argv[0], + argv[1], ""); } exit(status); } Modified: user/bapt/diff/diffdir.c ============================================================================== --- user/bapt/diff/diffdir.c Sat Mar 4 22:15:32 2017 (r314683) +++ user/bapt/diff/diffdir.c Sat Mar 4 22:23:59 2017 (r314684) @@ -207,7 +207,7 @@ diffit(struct dirent *dp, char *path1, s else if (!S_ISREG(stb2.st_mode) && !S_ISDIR(stb2.st_mode)) dp->d_status = D_SKIPPED2; else - dp->d_status = diffreg(path1, path2, flags); + dp->d_status = diffreg(path1, path2, flags, 0); print_status(dp->d_status, path1, path2, ""); } Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Sat Mar 4 22:15:32 2017 (r314683) +++ user/bapt/diff/diffreg.c Sat Mar 4 22:23:59 2017 (r314684) @@ -306,7 +306,7 @@ static u_char cup2low[256] = { }; int -diffreg(char *file1, char *file2, int flags) +diffreg(char *file1, char *file2, int flags, int capsicum) { FILE *f1, *f2; int i, rval; @@ -405,23 +405,25 @@ diffreg(char *file1, char *file2, int fl } } - cap_rights_init(&rights_ro, CAP_READ, CAP_FSTAT, CAP_SEEK); - if (cap_rights_limit(fileno(f1), &rights_ro) < 0) - err(2, "unable to limit rights on: %s", file1); - if (cap_rights_limit(fileno(f2), &rights_ro) < 0) - err(2, "unable to limit rights on: %s", file2); - if (fileno(f1) == STDIN_FILENO || fileno(f2) == STDIN_FILENO) { - /* stding has already been limited */ - if (caph_limit_stderr() == -1) - err(2, "unable to limit stderr"); - if (caph_limit_stdout() == -1) - err(2, "unable to limit stdout"); - } else if (caph_limit_stdio() == -1) - err(2, "unable to limit stdio"); - - caph_cache_catpages(); - if (cap_enter() < 0 && errno != ENOSYS) - err(2, "unable to enter capability mode"); + if (capsicum) { + cap_rights_init(&rights_ro, CAP_READ, CAP_FSTAT, CAP_SEEK); + if (cap_rights_limit(fileno(f1), &rights_ro) < 0) + err(2, "unable to limit rights on: %s", file1); + if (cap_rights_limit(fileno(f2), &rights_ro) < 0) + err(2, "unable to limit rights on: %s", file2); + if (fileno(f1) == STDIN_FILENO || fileno(f2) == STDIN_FILENO) { + /* stding has already been limited */ + if (caph_limit_stderr() == -1) + err(2, "unable to limit stderr"); + if (caph_limit_stdout() == -1) + err(2, "unable to limit stdout"); + } else if (caph_limit_stdio() == -1) + err(2, "unable to limit stdio"); + + caph_cache_catpages(); + if (cap_enter() < 0 && errno != ENOSYS) + err(2, "unable to enter capability mode"); + } switch (files_differ(f1, f2, flags)) { case 0: