From 8361bf5469aff201068e12ef9840c84bfa68505b Mon Sep 17 00:00:00 2001 From: schwarze Date: Sun, 10 Jul 2016 10:03:15 +0000 Subject: [PATCH] Simplify the code and the server setup by deleting the pseudo-manpath "mandoc" that was used for man.cgi(8) documentation and by assuming that the apropos(1) and man.cgi(8) manuals are simply installed in the default manpath. Even though man.cgi(8) is not installed by default when installing OpenBSD, it is easy to copy it into the default manpath used for man.cgi(8). Idea found when considering a question asked by wrant dot com. --- usr.bin/mandoc/Makefile | 8 +------- usr.bin/mandoc/cgi.c | 16 ++++------------ usr.bin/mandoc/man.cgi.8 | 25 ++++++++++++------------- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile index e4c65206e66..fe1a7cc15ac 100644 --- a/usr.bin/mandoc/Makefile +++ b/usr.bin/mandoc/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.101 2016/03/30 06:38:46 jmc Exp $ +# $OpenBSD: Makefile,v 1.102 2016/07/10 10:03:15 schwarze Exp $ .include @@ -62,11 +62,5 @@ installcgi: man.cgi ${INSTALL} ${INSTALL_COPY} -S ${INSTALL_STRIP} \ -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ man.cgi ${DESTDIR}/var/www/cgi-bin/man.cgi - ${INSTALL} -d -o root -g wheel -m 755 ${DESTDIR}/var/www/man/mandoc/man1 - ${INSTALL} -d -o root -g wheel -m 755 ${DESTDIR}/var/www/man/mandoc/man8 - ${INSTALL} ${INSTALL_COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ - ${.CURDIR}/apropos.1 ${DESTDIR}/var/www/man/mandoc/man1/apropos.1 - ${INSTALL} ${INSTALL_COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ - ${.CURDIR}/man.cgi.8 ${DESTDIR}/var/www/man/mandoc/man8/man.cgi.8 .include diff --git a/usr.bin/mandoc/cgi.c b/usr.bin/mandoc/cgi.c index 4b9e8da9690..f11ca893b28 100644 --- a/usr.bin/mandoc/cgi.c +++ b/usr.bin/mandoc/cgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cgi.c,v 1.72 2016/07/09 19:44:52 schwarze Exp $ */ +/* $OpenBSD: cgi.c,v 1.73 2016/07/10 10:03:15 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014, 2015, 2016 Ingo Schwarze @@ -468,9 +468,6 @@ validate_manpath(const struct req *req, const char* manpath) { size_t i; - if ( ! strcmp(manpath, "mandoc")) - return 1; - for (i = 0; i < req->psz; i++) if ( ! strcmp(manpath, req->p[i])) return 1; @@ -497,9 +494,9 @@ pg_index(const struct req *req) resp_searchform(req, FOCUS_QUERY); printf("

\n" "This web interface is documented in the\n" - "man.cgi\n" + "man.cgi(8)\n" "manual, and the\n" - "apropos\n" + "apropos(1)\n" "manual explains the query syntax.\n" "

\n", scriptname, *scriptname == '\0' ? "" : "/", @@ -882,12 +879,7 @@ pg_show(struct req *req, const char *fullpath) free(manpath); return; } - - if (strcmp(manpath, "mandoc")) { - free(req->q.manpath); - req->q.manpath = manpath; - } else - free(manpath); + free(manpath); if ( ! validate_filename(file)) { pg_error_badrequest( diff --git a/usr.bin/mandoc/man.cgi.8 b/usr.bin/mandoc/man.cgi.8 index b92e0cdeb58..71c01c47bf2 100644 --- a/usr.bin/mandoc/man.cgi.8 +++ b/usr.bin/mandoc/man.cgi.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: man.cgi.8,v 1.17 2016/07/07 14:32:24 schwarze Exp $ +.\" $OpenBSD: man.cgi.8,v 1.18 2016/07/10 10:03:15 schwarze Exp $ .\" .\" Copyright (c) 2014, 2015, 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 7 2016 $ +.Dd $Mdocdate: July 10 2016 $ .Dt MAN.CGI 8 .Os .Sh NAME @@ -220,13 +220,16 @@ run .Pp .Dl make man.cgi .Pp -and copy the files to the proper locations. -Reading the -.Cm installcgi -target in the -.Pa Makefile -can help with that, but do not run it without carefully checking it -because the directory layouts of web servers vary greatly. +and copy the resulting binary to the proper location, +for example using the command: +.Pp +.Dl make installcgi +.Pp +In addition to that, make sure the default manpath contains the files +.Pa man1/apropos.1 +and +.Pa man8/man.cgi.8 , +or the documentation links at the bottom of the index page will not work. .Ss URI interface .Nm uniform resource identifiers are not needed for interactive use, @@ -367,10 +370,6 @@ Default data directory containing all the manual trees. Can be overridden by .Dv MAN_DIR . -.It Pa /man/mandoc/man1/apropos.1 , /man/mandoc/man8/man.cgi.8 -Manual pages documenting -.Nm -itself, linked from the index page. .It Pa /man/manpath.conf The list of available manpaths, one per line. If any of the lines in this file contains a slash -- 2.20.1