diff options
author | imp <imp@FreeBSD.org> | 2008-02-24 00:01:06 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2008-02-24 00:01:06 +0000 |
commit | 29bb0c66243b2e29a1207058575893d606140ad6 (patch) | |
tree | 138047f45a1595faa5f0f23479c2e2464549661b /usr.bin/find/function.c | |
parent | 36ece8c357cbb47c9ce1c182457720f93537201b (diff) | |
download | FreeBSD-src-29bb0c66243b2e29a1207058575893d606140ad6.zip FreeBSD-src-29bb0c66243b2e29a1207058575893d606140ad6.tar.gz |
The matching in -lname and -ilname are on the contents of the link
itself, not on the type of the file. As such, do a readlink to get
the symbolic link's contents and fail to match if the path isn't a
symbolic link.
Pointed out by: des@
Diffstat (limited to 'usr.bin/find/function.c')
-rw-r--r-- | usr.bin/find/function.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 4f823a2..c3c90f8 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1087,9 +1087,16 @@ c_ls(OPTION *option, char ***argvp __unused) int f_name(PLAN *plan, FTSENT *entry) { - if ((plan->flags & F_LINK) && !S_ISLNK(entry->fts_statp->st_mode)) - return 0; - return !fnmatch(plan->c_data, entry->fts_name, + char fn[PATH_MAX]; + const char *name; + + if (plan->flags & F_LINK) { + name = fn; + if (readlink(entry->fts_path, fn, sizeof(fn)) == -1) + return 0; + } else + name = entry->fts_name; + return !fnmatch(plan->c_data, name, plan->flags & F_IGNCASE ? FNM_CASEFOLD : 0); } @@ -1102,8 +1109,6 @@ c_name(OPTION *option, char ***argvp) pattern = nextarg(option, argvp); new = palloc(option); new->c_data = pattern; - if (new->flags & F_LINK) - ftsoptions &= ~FTS_NOSTAT; return new; } |