From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: In fs_lookup(), use stat(2) rather than access(2) to check file
Date: Fri, 3 May 2019 12:31:45 -0500 (EST) [thread overview]
Message-ID: <e3fef64075fc612b@fantadrom.bsd.lv> (raw)
Log Message:
-----------
In fs_lookup(), use stat(2) rather than access(2) to check file existence.
Some mildly broken real-world packages on some operating systems
contain dangling symlinks in manual page directories: pestering the
user to run makewhatis(8) makes no sense because that won't help.
On the other hand, missing read permissions deserve ugly error messages
and are unlikely to occur in practice anyway.
Fixing an issue reported by Lorenzo Beretta <loreb at github>
as part of https://github.com/void-linux/void-packages/issues/9868 .
Modified Files:
--------------
mandoc:
TODO
main.c
Revision Data
-------------
Index: TODO
===================================================================
RCS file: /home/cvs/mandoc/mandoc/TODO,v
retrieving revision 1.293
retrieving revision 1.294
diff -LTODO -LTODO -u -p -r1.293 -r1.294
--- TODO
+++ TODO
@@ -217,12 +217,6 @@ are mere guesses, and some may be wrong.
--- missing misc features ----------------------------------------------
-- dead .so links should be entered into the database to avoid:
- man -M. lvm-config
- man: outdated mandoc.db lacks lvm-config(8) entry, run makewhatis /co/void-man
- https://github.com/void-linux/void-packages/issues/9868
- loc * exist ** algo * size * imp **
-
- man -ks 1,8 route; kn@ Jul 13, 2018 orally
- italic correction (\/) in PostScript mode
Index: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.325
retrieving revision 1.326
diff -Lmain.c -Lmain.c -u -p -r1.325 -r1.326
--- main.c
+++ main.c
@@ -21,6 +21,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/param.h> /* MACHINE */
+#include <sys/stat.h>
#include <sys/wait.h>
#include <assert.h>
@@ -713,6 +714,7 @@ fs_lookup(const struct manpaths *paths,
const char *sec, const char *arch, const char *name,
struct manpage **res, size_t *ressz)
{
+ struct stat sb;
glob_t globinfo;
struct manpage *page;
char *file;
@@ -722,13 +724,13 @@ fs_lookup(const struct manpaths *paths,
form = FORM_SRC;
mandoc_asprintf(&file, "%s/man%s/%s.%s",
paths->paths[ipath], sec, name, sec);
- if (access(file, R_OK) != -1)
+ if (stat(file, &sb) != -1)
goto found;
free(file);
mandoc_asprintf(&file, "%s/cat%s/%s.0",
paths->paths[ipath], sec, name);
- if (access(file, R_OK) != -1) {
+ if (stat(file, &sb) != -1) {
form = FORM_CAT;
goto found;
}
@@ -737,7 +739,7 @@ fs_lookup(const struct manpaths *paths,
if (arch != NULL) {
mandoc_asprintf(&file, "%s/man%s/%s/%s.%s",
paths->paths[ipath], sec, arch, name, sec);
- if (access(file, R_OK) != -1)
+ if (stat(file, &sb) != -1)
goto found;
free(file);
}
@@ -751,13 +753,16 @@ fs_lookup(const struct manpaths *paths,
if (globres == 0)
file = mandoc_strdup(*globinfo.gl_pathv);
globfree(&globinfo);
- if (globres == 0)
- goto found;
+ if (globres == 0) {
+ if (stat(file, &sb) != -1)
+ goto found;
+ free(file);
+ }
if (res != NULL || ipath + 1 != paths->sz)
return 0;
mandoc_asprintf(&file, "%s.%s", name, sec);
- globres = access(file, R_OK);
+ globres = stat(file, &sb);
free(file);
return globres != -1;
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2019-05-03 17:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e3fef64075fc612b@fantadrom.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).