tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: Alexis <surryhill@gmail.com>
Cc: Kristaps Dzonsons <kristaps@bsd.lv>, tech@mdocml.bsd.lv
Subject: Re: Allow configure variables to be set from environment
Date: Thu, 22 Jan 2015 00:05:19 +0100	[thread overview]
Message-ID: <20150121230518.GF11796@iris.usta.de> (raw)
In-Reply-To: <20150120151501.GA97151@kei>

Hi Alexis,

Alexis wrote on Tue, Jan 20, 2015 at 04:15:01PM +0100:
> Ingo Schwarze wrote:

>> Oh wait a minute.  I think i see a solution.  If we specifically
>> allow mandoc to follow symlinks only into the homebrew tree, but
>> nowhere else, that seems safe.  It's a bit tricky to avoid race
>> conditions, but i think there is a secure way to implement it.

I just noticed there are more issues with race conditions,
so i shall have to address that separately at some point.

>> Is there are standardized place where homebrew installs its real
>> files, and where nobody in their right mind would ever put any
>> confidential data?  Maybe /Cellar?  Is that right?

> Homebrew may be installed wherever a user desires (though /usr/local
> is recommended) ranging from /opt/homebrew to $HOME/.brew. Because
> of this Homebrew can also be installed and used without sudo
> if the file permissions (e.g. homebrew group with write access)
> are set up accordingly.
> 
> Is it possible to to add a configure.local variable so that the suite
> of mdocml tools are compiled specifically for the user's setup, i.e.
> make the suggested "/Cellar" customizable?

Yes, that is easy and makes sense to me.

>> True, but the above might be a solution.  If we manage to support
>> that, it would actually be a safe man(1) for homebrew, much safer
>> than the traditional BSD or man-db implementations.

> This sounds even better.

See below for a patch i just committed to the HEAD of the mandoc CVS.

Kristaps, Alexis, are you able to test this on your Mac OS X boxes?

The intended behaviour is:

 1. If you compile without setting HOMEBREWDIR in configure.local
    or set it to a wrong value, makewhatis(8) is supposed to
    exlude homebrew-style linked manuals from mandoc.db(5)
    databases, like this:

     $ ./Bin/makewhatis -Dp Test           
    /co/mdocml/Test/: /usr/share/man/man1/cat.1: outside base directory

    In this case, apropos(1) is not supposed to find and man(1)
    is not supposed to show them, and the released version 1.13.2
    actually shouldn't.  In CVS HEAD, man(1) currently shows them,
    anyway, like this:

     $ man -M Test cat
    man: outdated mandoc.db lacks cat(1) entry,
         consider running  # makewhatis /co/mdocml/Test
    CAT(1)                General Commands Manual               CAT(1)
    NAME
         cat - concatenate and print files
    [...]

    I have to look into that...

 2. If you compile with HOMEBREWDIR set correctly in configure.local,
    makewhatis(8), apropos(1), and man(1) are supposed to work as
    expected.

Yours,
  Ingo


Log Message:
-----------
Support homebrew-style linking on Mac OS X.
Idea found together with Alexis Hildebrandt <surryhill at gmail dot com>.

Modified Files:
--------------
    mdocml:
        configure
        configure.local.example
        mandocdb.c

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.183
retrieving revision 1.184
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.183 -r1.184
--- mandocdb.c
+++ mandocdb.c
@@ -613,7 +613,11 @@ treescan(void)
 					say(path, "&realpath");
 				continue;
 			}
-			if (strstr(buf, basedir) != buf) {
+			if (strstr(buf, basedir) != buf
+#ifdef HOMEBREWDIR
+			    && strstr(buf, HOMEBREWDIR) != buf
+#endif
+			) {
 				if (warnings) say("",
 				    "%s: outside base directory", buf);
 				continue;
@@ -818,6 +822,10 @@ filescan(const char *file)
 		start = buf;
 	else if (strstr(buf, basedir) == buf)
 		start = buf + strlen(basedir);
+#ifdef HOMEBREWDIR
+	else if (strstr(buf, HOMEBREWDIR) == buf)
+		start = buf;
+#endif
 	else {
 		exitcode = (int)MANDOCLEVEL_BADARG;
 		say("", "%s: outside base directory", buf);
Index: configure.local.example
===================================================================
RCS file: /home/cvs/mdocml/mdocml/configure.local.example,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lconfigure.local.example -Lconfigure.local.example -u -p -r1.2 -r1.3
--- configure.local.example
+++ configure.local.example
@@ -1,6 +1,6 @@
 # $Id$
 #
-# Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
 #
 # Permission to use, copy, modify, and distribute this software for any
 # purpose with or without fee is hereby granted, provided that the above
@@ -152,6 +152,14 @@ BINM_APROPOS=mapropos		# default is "apr
 BINM_MAN=mman			# default is "man"
 BINM_WHATIS=mwhatis		# default is "whatis"
 BINM_MAKEWHATIS=mandocdb	# default is "makewhatis"
+
+# When using the "homebrew" package manager on Mac OS X, the actual
+# manuals are located in a so-called "cellar" and only symlinked
+# into the manual trees.  To allow mandoc to follow such symlinks,
+# you have to specify the physical location of the cellar as returned
+# by realpath(3), for example:
+
+HOMEBREWDIR=/Cellar
 
 # --- user settings related man.cgi ------------------------------------
 
Index: configure
===================================================================
RCS file: /home/cvs/mdocml/mdocml/configure,v
retrieving revision 1.17
retrieving revision 1.18
diff -Lconfigure -Lconfigure -u -p -r1.17 -r1.18
--- configure
+++ configure
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
 #
 # Permission to use, copy, modify, and distribute this software for any
 # purpose with or without fee is hereby granted, provided that the above
@@ -70,6 +70,7 @@ INCLUDEDIR=
 LIBDIR=
 MANDIR=
 EXAMPLEDIR=
+HOMEBREWDIR=
 
 WWWPREFIX="/var/www"
 HTDOCDIR=
@@ -276,6 +277,7 @@ __HEREDOC__
 echo
 echo "#define VERSION \"${VERSION}\""
 [ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
+[ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
 
 cat << __HEREDOC__
 #define HAVE_DIRENT_NAMLEN ${HAVE_DIRENT_NAMLEN}
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

  reply	other threads:[~2015-01-21 23:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <sfid-H20150116-225859-+021.89-1@spamfilter.osbf.lua>
2015-01-16 21:58 ` Alexis
2015-01-16 23:32   ` Thomas Klausner
2015-01-17  1:31     ` Ingo Schwarze
2015-01-17  1:07   ` Ingo Schwarze
2015-01-17 20:10     ` Kristaps Dzonsons
2015-01-18  3:33       ` Ingo Schwarze
2015-01-20 15:15         ` Alexis
2015-01-21 23:05           ` Ingo Schwarze [this message]
2015-01-22  0:21             ` Kristaps Dzonsons
2015-01-22  0:35               ` Ingo Schwarze
2015-01-22  7:32                 ` Alexis
2015-01-22  7:26             ` Alexis
2015-01-23 22:05               ` Ingo Schwarze
2015-01-20 15:19     ` Alexis
2015-01-21 21:07       ` Ingo Schwarze

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=20150121230518.GF11796@iris.usta.de \
    --to=schwarze@usta.de \
    --cc=kristaps@bsd.lv \
    --cc=surryhill@gmail.com \
    --cc=tech@mdocml.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).