2014-04-08 15:02:52 +02:00
|
|
|
---
|
2016-12-16 10:45:04 +01:00
|
|
|
src/mandb.c | 12 +++++++++++-
|
|
|
|
1 file changed, 11 insertions(+), 1 deletion(-)
|
2014-04-08 15:02:52 +02:00
|
|
|
|
2012-10-02 19:06:04 +02:00
|
|
|
--- src/mandb.c
|
2016-12-16 10:45:04 +01:00
|
|
|
+++ src/mandb.c 2016-12-16 07:14:50.995017235 +0000
|
|
|
|
@@ -439,17 +439,26 @@ static int mandb (struct dbpaths *dbpath
|
|
|
|
int ret, amount;
|
2012-10-02 19:06:04 +02:00
|
|
|
char *dbname;
|
2016-12-16 10:45:04 +01:00
|
|
|
int should_create;
|
2012-10-02 19:06:04 +02:00
|
|
|
+ int fd;
|
|
|
|
|
|
|
|
dbname = mkdbname (catpath);
|
2014-04-08 15:02:52 +02:00
|
|
|
database = xasprintf ("%s/%d", catpath, getpid ());
|
|
|
|
|
2012-10-02 19:06:04 +02:00
|
|
|
+ /* Just for the case that catpath isn't a system catpath */
|
|
|
|
+ drop_effective_privs ();
|
|
|
|
+ fd = open (database, O_WRONLY | O_CREAT | O_EXCL, 0644);
|
|
|
|
+ regain_effective_privs ();
|
|
|
|
+ if (fd < 0)
|
|
|
|
+ error (FATAL, errno, _("can't create a temporary filename"));
|
|
|
|
+ close(fd);
|
|
|
|
+
|
|
|
|
if (!quiet)
|
|
|
|
printf (_("Processing manual pages under %s...\n"), manpath);
|
|
|
|
|
2016-12-16 10:45:04 +01:00
|
|
|
if (!STREQ (catpath, manpath)) {
|
|
|
|
char *cachedir_tag;
|
|
|
|
- int fd;
|
2012-10-02 19:06:04 +02:00
|
|
|
|
2016-12-16 10:45:04 +01:00
|
|
|
+ drop_effective_privs ();
|
|
|
|
cachedir_tag = xasprintf ("%s/CACHEDIR.TAG", catpath);
|
|
|
|
fd = open (cachedir_tag, O_RDONLY);
|
|
|
|
if (fd < 0) {
|
|
|
|
@@ -467,6 +476,7 @@ static int mandb (struct dbpaths *dbpath
|
|
|
|
if (global_manpath)
|
|
|
|
chown_if_possible (cachedir_tag);
|
|
|
|
check_chmod (cachedir_tag, DBMODE);
|
|
|
|
+ regain_effective_privs ();
|
2015-05-28 15:24:43 +02:00
|
|
|
free (cachedir_tag);
|
2012-10-02 19:06:04 +02:00
|
|
|
}
|
2016-12-16 10:45:04 +01:00
|
|
|
|