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 | 111404fc74972291dad2ea0761de281514975b42 (patch) | |
tree | 054a7c8612b5dbe0749800dd3aaa421af3d940ac /manup.c | |
parent | 2d1ee60475147395c6882b1d665727e5ca188f69 (diff) | |
download | mandoc-111404fc74972291dad2ea0761de281514975b42.tar.gz |
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 | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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); |