diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-11-24 12:22:53 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-11-24 12:22:53 +0000 |
commit | 60a310d953eeb7b6d9117210874dc6ad8e08952a (patch) | |
tree | b6c9904a9b60d29041bde999bb4eedaaf503864a /manup.c | |
parent | 7d1abf6ddeb956998dd360fb7287733f82ab03d5 (diff) | |
download | mandoc-60a310d953eeb7b6d9117210874dc6ad8e08952a.tar.gz mandoc-60a310d953eeb7b6d9117210874dc6ad8e08952a.tar.zst mandoc-60a310d953eeb7b6d9117210874dc6ad8e08952a.zip |
Have manup(8) put relative paths in its output man.conf. This lets us
have arbitrarily-located cache directories for man.cgi.
Diffstat (limited to 'manup.c')
-rw-r--r-- | manup.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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); |