aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--manup.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/manup.c b/manup.c
index c6406785..be17c333 100644
--- a/manup.c
+++ b/manup.c
@@ -1,4 +1,4 @@
-/* $Id: manup.c,v 1.1 2011/11/24 10:33:38 kristaps Exp $ */
+/* $Id: manup.c,v 1.2 2011/11/24 12:22:53 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -391,8 +391,10 @@ treecpy(char *dst, char *src)
xstrlcat(src, "/mandoc.db", MAXPATHLEN);
xstrlcat(dst, "/mandoc.db", MAXPATHLEN);
- if ((rc = isnewer(dst, src)) <= 0)
+ if (-1 == (rc = isnewer(dst, src)))
return(0);
+ else if (rc == 0)
+ return(1);
dst[(int)dsz] = src[(int)ssz] = '\0';
@@ -425,6 +427,9 @@ manup(const struct manpaths *dirs, const char *dir)
xstrlcat(dst, "/man.conf", MAXPATHLEN);
+ if (verbose)
+ printf("%s\n", dst);
+
if (NULL == (f = fopen(dst, "w"))) {
perror(dst);
return(0);
@@ -451,7 +456,17 @@ manup(const struct manpaths *dirs, const char *dir)
else if (0 == c)
continue;
- fprintf(f, "_whatdb %s/whatis.db\n", path);
+ /*
+ * We want to use a relative path here because manpath.h
+ * will realpath() when invoked with man.cgi, and we'll
+ * make sure to chdir() into the cache directory before.
+ *
+ * This allows the cache directory to be in an arbitrary
+ * place, working in both chroot() and non-chroot()
+ * "safe" modes.
+ */
+ assert('/' == path[0]);
+ fprintf(f, "_whatdb %s/whatis.db\n", path + 1);
}
fclose(f);