Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Dec 2017 19:57:47 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 222698] find(1)'s -newer expression doesn't work with symbolic links if '-P' (the default) is requested.
Message-ID:  <bug-222698-8-9PJqE7Nlor@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-222698-8@https.bugs.freebsd.org/bugzilla/>
References:  <bug-222698-8@https.bugs.freebsd.org/bugzilla/>

index | next in thread | previous in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222698

--- Comment #4 from Conrad Meyer <cem@freebsd.org> ---
This change ought to be sufficient to fix -newer:

--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -1201,6 +1201,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 +1215,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;


However, -samefile is similarly broken.  Here's a patch for that part:

--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -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;

-- 
You are receiving this mail because:
You are the assignee for the bug.

help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-222698-8-9PJqE7Nlor>