From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id f1ad03a6 for ; Fri, 3 May 2019 12:31:45 -0500 (EST) Date: Fri, 3 May 2019 12:31:45 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 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 X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: 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 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 #include #include /* MACHINE */ +#include #include #include @@ -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