From owner-svn-src-head@freebsd.org Fri Dec 29 22:41:10 2017 Return-Path: Delivered-To: svn-src-head@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 E472BEB416B for ; Fri, 29 Dec 2017 22:41:10 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6F0BB7F000 for ; Fri, 29 Dec 2017 22:41:10 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-wm0-x22b.google.com with SMTP id a79so10983519wma.0 for ; Fri, 29 Dec 2017 14:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/OY9FfCMFlkYN50hnaI71HTEHESXqXv/wm496+VkCbM=; b=BYJbV1IfpbPI7iWj+qP4Af7Bg3OTo78QhGQorIpSZsd4nK+L+vVgkMr67oA/bZwmWX UOjpdtiRFinO1cfw32JAZwIgcFCESpcdMuXF86sgzRD2Ix1fySJ2inowy0pdA9PYj1XV zoGjx1Rkle/qeY06A8JDHci0DYhcze5wJfyhLjJKGlQ+WLAnuI72soZsZoblkNZkol3M lv0f7RzEXpTGlFupIScX6o4eINnXSuu3b8g+LYA77iKhHXpftTL1RpOCzhc6DNza00jv REHAgzozBhuSlnFBhPcjJaRssCzA/7jMu1U7udMLvkISLcPH03emS6GoSV5D/QlohBVO WhjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/OY9FfCMFlkYN50hnaI71HTEHESXqXv/wm496+VkCbM=; b=X8m4wBWU4ajcLWIObalHV1/qIlg8p0N7bezpeVzUpI9pfCzz8wLg5IP8wKtwUjwmOj 29gLPex7aUhO9K09rzWFDSvdXU1epljafTHBW4bErpX8i8PAQL2lxVU0g14H9mAAjUli D98/aBKk3AGNwt8JlJTlwmxy3zOXorP25nGzLX7OjPH0QnR9VSf+OpihNLf2ZvE1AUOM jWVzeA0r4/iOSte0qMYdlJT52TLlXRykvbvEK5123v1FhcrIb4RV29CwZoJU9MuoDMxT 6HOxpGJVsVqlkrZDS0ZbI9HrzyTDLVbRcCRVynB9+UCLr6ocNNMcVsXVY1Ne+Duvkuzi Iw2Q== X-Gm-Message-State: AKGB3mLgVs+rB4YP0omBSWy/69oh4IkaHVCf2cdOljYucpwBxmcBX7My qeEIvW2jceMzI5xFmQH0Os0dtO11kL1zt+9WKsntmQ== X-Google-Smtp-Source: ACJfBotCiY3hgWnZpOcssJIVs3DscCoSRPO41z6O8hrnzArH7yyU2T3E3fw3tkm/v1tEtv0kpJLN108abQzjHTLPXS4= X-Received: by 10.80.208.195 with SMTP id g3mr46280884edf.246.1514587268703; Fri, 29 Dec 2017 14:41:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.149.174 with HTTP; Fri, 29 Dec 2017 14:41:08 -0800 (PST) In-Reply-To: <201712292208.vBTM8hpG048007@repo.freebsd.org> References: <201712292208.vBTM8hpG048007@repo.freebsd.org> From: Oliver Pinter Date: Fri, 29 Dec 2017 23:41:08 +0100 Message-ID: Subject: Re: svn commit: r327362 - in head/usr.bin/find: . tests To: Conrad Meyer Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Dec 2017 22:41:11 -0000 On Friday, December 29, 2017, Conrad Meyer wrote: > Author: cem > Date: Fri Dec 29 22:08:43 2017 > New Revision: 327362 > URL: https://svnweb.freebsd.org/changeset/base/327362 > > Log: > find(1): Fix -newer and -samefile to conform to POSIX[0] > > By default, or with the -P flag, find(1) should evaluate paths > "physically." > For symlinks, this means using the link itself instead of the target. > > Historically (since the import of BSD 4.4-lite from CSRG), find(1) has > failed to refer to the link itself, at least for -newer and -samefile. > > [0]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html > > PR: 222698 > Reported by: Harald Schmalzbauer > Sponsored by: Dell EMC Isilon > > Added: > head/usr.bin/find/tests/ > head/usr.bin/find/tests/Makefile (contents, props changed) > head/usr.bin/find/tests/find_test.sh (contents, props changed) > Modified: > head/usr.bin/find/Makefile > head/usr.bin/find/function.c > > Modified: head/usr.bin/find/Makefile > ============================================================ > ================== > --- head/usr.bin/find/Makefile Fri Dec 29 21:37:36 2017 (r327361) > +++ head/usr.bin/find/Makefile Fri Dec 29 22:08:43 2017 (r327362) > @@ -8,4 +8,7 @@ YFLAGS= > > NO_WMISSING_VARIABLE_DECLARATIONS= > > +#HAS_TESTS= > +#SUBDIR.${MK_TESTS}+= tests Why did you comment out these tests? > + > .include > > Modified: head/usr.bin/find/function.c > ============================================================ > ================== > --- head/usr.bin/find/function.c Fri Dec 29 21:37:36 2017 > (r327361) > +++ head/usr.bin/find/function.c Fri Dec 29 22:08:43 2017 > (r327362) > @@ -1066,12 +1066,17 @@ c_samefile(OPTION *option, char ***argvp) > char *fn; > PLAN *new; > struct stat sb; > + int error; > > fn = nextarg(option, argvp); > ftsoptions &= ~FTS_NOSTAT; > > new = palloc(option); > - if (stat(fn, &sb)) > + if (ftsoptions & FTS_PHYSICAL) > + error = lstat(fn, &sb); > + else > + error = stat(fn, &sb); > + if (error != 0) > err(1, "%s", fn); > new->i_data = sb.st_ino; > return new; > @@ -1201,6 +1206,7 @@ c_newer(OPTION *option, char ***argvp) > char *fn_or_tspec; > PLAN *new; > struct stat sb; > + int error; > > fn_or_tspec = nextarg(option, argvp); > ftsoptions &= ~FTS_NOSTAT; > @@ -1214,7 +1220,11 @@ c_newer(OPTION *option, char ***argvp) > /* Use the seconds only in the comparison. */ > new->t_data.tv_nsec = 999999999; > } else { > - if (stat(fn_or_tspec, &sb)) > + if (ftsoptions & FTS_PHYSICAL) > + error = lstat(fn_or_tspec, &sb); > + else > + error = stat(fn_or_tspec, &sb); > + if (error != 0) > err(1, "%s", fn_or_tspec); > if (option->flags & F_TIME2_C) > new->t_data = sb.st_ctim; > > Added: head/usr.bin/find/tests/Makefile > ============================================================ > ================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.bin/find/tests/Makefile Fri Dec 29 22:08:43 2017 > (r327362) > @@ -0,0 +1,5 @@ > +# $FreeBSD$ > + > +ATF_TESTS_SH= find_test > + > +.include > > Added: head/usr.bin/find/tests/find_test.sh > ============================================================ > ================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.bin/find/tests/find_test.sh Fri Dec 29 22:08:43 2017 > (r327362) > @@ -0,0 +1,73 @@ > +# > +# Copyright 2017, Conrad Meyer . > +# > +# Redistribution and use in source and binary forms, with or without > +# modification, are permitted provided that the following conditions are > +# met: > +# > +# * Redistributions of source code must retain the above copyright > +# notice, this list of conditions and the following disclaimer. > +# * 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 COPYRIGHT HOLDERS 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 COPYRIGHT > +# OWNER 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$ > +# > + > +atf_test_case find_newer_link > +find_newer_link_head() > +{ > + atf_set "descr" "Verifies that -newer correctly uses a symlink, " \ > + "rather than its target, for comparison" > +} > +find_newer_link_body() > +{ > + atf_check -s exit:0 mkdir test > + atf_check -s exit:0 ln -s file1 test/link > + atf_check -s exit:0 sleep 1.1 > + atf_check -s exit:0 touch test/file2 > + atf_check -s exit:0 sleep 1.1 > + atf_check -s exit:0 touch test/file1 > + > + # find(1) should evaluate 'link' as a symlink rather than its > target > + # (with -P / without -L flags). Since link was created first, the > + # other two files should be newer. > + echo -e "test\ntest/file1\ntest/file2" > expout > + atf_check -s exit:0 -o save:output find test -newer test/link > + atf_check -s exit:0 -o file:expout sort < output > +} > + > +atf_test_case find_samefile_link > +find_samefile_link_head() > +{ > + atf_set "descr" "Verifies that -samefile correctly uses a symlink, > " \ > + "rather than its target, for comparison" > +} > +find_samefile_link_body() > +{ > + atf_check -s exit:0 mkdir test > + atf_check -s exit:0 touch test/file3 > + atf_check -s exit:0 ln -s file3 test/link2 > + > + # find(1) should evaluate 'link' as a symlink rather than its > target > + # (with -P / without -L flags). > + atf_check -s exit:0 -o "inline:test/link2\n" find test -samefile > test/link2 > +} > + > +atf_init_test_cases() > +{ > + atf_add_test_case find_newer_link > + atf_add_test_case find_samefile_link > +} > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" >