version 1.266, 2020/01/26 21:25:41 |
version 1.269, 2021/08/19 16:55:31 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> |
|
* Copyright (c) 2011-2020 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2011-2020 Ingo Schwarze <schwarze@openbsd.org> |
|
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2016 Ed Maste <emaste@freebsd.org> |
* Copyright (c) 2016 Ed Maste <emaste@freebsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
* |
|
* Implementation of the makewhatis(8) program. |
*/ |
*/ |
#include "config.h" |
#include "config.h" |
|
|
Line 118 struct mdoc_handler { |
|
Line 120 struct mdoc_handler { |
|
int mandocdb(int, char *[]); |
int mandocdb(int, char *[]); |
|
|
static void dbadd(struct dba *, struct mpage *); |
static void dbadd(struct dba *, struct mpage *); |
static void dbadd_mlink(const struct mlink *mlink); |
static void dbadd_mlink(const struct mlink *); |
static void dbprune(struct dba *); |
static void dbprune(struct dba *); |
static void dbwrite(struct dba *); |
static void dbwrite(struct dba *); |
static void filescan(const char *); |
static void filescan(const char *); |
Line 163 static void putkey(const struct mpage *, char *, uint |
|
Line 165 static void putkey(const struct mpage *, char *, uint |
|
static void putkeys(const struct mpage *, char *, size_t, uint64_t); |
static void putkeys(const struct mpage *, char *, size_t, uint64_t); |
static void putmdockey(const struct mpage *, |
static void putmdockey(const struct mpage *, |
const struct roff_node *, uint64_t, int); |
const struct roff_node *, uint64_t, int); |
|
#ifdef READ_ALLOWED_PATH |
|
static int read_allowed(const char *); |
|
#endif |
static int render_string(char **, size_t *); |
static int render_string(char **, size_t *); |
static void say(const char *, const char *, ...) |
static void say(const char *, const char *, ...) |
__attribute__((__format__ (__printf__, 2, 3))); |
__attribute__((__format__ (__printf__, 2, 3))); |
|
|
continue; |
continue; |
} |
} |
if (strncmp(buf, basedir, basedir_len) != 0 |
if (strncmp(buf, basedir, basedir_len) != 0 |
#ifdef HOMEBREWDIR |
#ifdef READ_ALLOWED_PATH |
&& strncmp(buf, HOMEBREWDIR, strlen(HOMEBREWDIR)) |
&& !read_allowed(buf) |
#endif |
#endif |
) { |
) { |
if (warnings) say("", |
if (warnings) say("", |
|
|
say(path, "&stat"); |
say(path, "&stat"); |
continue; |
continue; |
} |
} |
|
if ((ff->fts_statp->st_mode & S_IFMT) != S_IFREG) |
|
continue; |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
|
|
/* |
/* |
Line 821 filescan(const char *infile) |
|
Line 828 filescan(const char *infile) |
|
start = usefile; |
start = usefile; |
else if (strncmp(usefile, basedir, basedir_len) == 0) |
else if (strncmp(usefile, basedir, basedir_len) == 0) |
start = usefile + basedir_len; |
start = usefile + basedir_len; |
#ifdef HOMEBREWDIR |
#ifdef READ_ALLOWED_PATH |
else if (strncmp(usefile, HOMEBREWDIR, strlen(HOMEBREWDIR)) == 0) |
else if (read_allowed(usefile)) |
start = usefile; |
start = usefile; |
#endif |
#endif |
else { |
else { |
Line 2378 set_basedir(const char *targetdir, int report_baddir) |
|
Line 2385 set_basedir(const char *targetdir, int report_baddir) |
|
} |
} |
return 1; |
return 1; |
} |
} |
|
|
|
#ifdef READ_ALLOWED_PATH |
|
static int |
|
read_allowed(const char *candidate) |
|
{ |
|
const char *cp; |
|
size_t len; |
|
|
|
for (cp = READ_ALLOWED_PATH;; cp += len) { |
|
while (*cp == ':') |
|
cp++; |
|
if (*cp == '\0') |
|
return 0; |
|
len = strcspn(cp, ":"); |
|
if (strncmp(candidate, cp, len) == 0) |
|
return 1; |
|
} |
|
} |
|
#endif |
|
|
static void |
static void |
say(const char *file, const char *format, ...) |
say(const char *file, const char *format, ...) |