2014-04-08 15:02:52 +02:00
|
|
|
---
|
2015-05-28 15:24:43 +02:00
|
|
|
src/mandb.c | 12 ++++++++++++
|
2014-04-08 15:02:52 +02:00
|
|
|
1 file changed, 12 insertions(+)
|
|
|
|
|
2012-10-02 19:06:04 +02:00
|
|
|
--- src/mandb.c
|
2015-05-28 15:24:43 +02:00
|
|
|
+++ src/mandb.c 2015-05-28 10:43:41.785520616 +0000
|
2012-10-02 19:06:04 +02:00
|
|
|
@@ -37,6 +37,7 @@
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h> /* for chmod() */
|
|
|
|
+#include <fcntl.h> /* for open () */
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <signal.h>
|
2015-05-28 15:24:43 +02:00
|
|
|
@@ -446,10 +447,19 @@ static int mandb (const char *catpath, c
|
2012-10-02 19:06:04 +02:00
|
|
|
char *dbname;
|
|
|
|
char *cachedir_tag;
|
|
|
|
struct stat st;
|
|
|
|
+ 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);
|
|
|
|
|
2015-05-28 15:24:43 +02:00
|
|
|
@@ -458,11 +468,13 @@ static int mandb (const char *catpath, c
|
|
|
|
if (stat (cachedir_tag, &st) == -1 && errno == ENOENT) {
|
|
|
|
FILE *cachedir_tag_file;
|
2012-10-02 19:06:04 +02:00
|
|
|
|
2015-05-28 15:24:43 +02:00
|
|
|
+ drop_effective_privs ();
|
|
|
|
cachedir_tag_file = fopen (cachedir_tag, "w");
|
|
|
|
if (cachedir_tag_file) {
|
|
|
|
fputs (CACHEDIR_TAG, cachedir_tag_file);
|
|
|
|
fclose (cachedir_tag_file);
|
|
|
|
}
|
|
|
|
+ regain_effective_privs ();
|
2012-10-02 19:06:04 +02:00
|
|
|
}
|
2015-05-28 15:24:43 +02:00
|
|
|
free (cachedir_tag);
|
2012-10-02 19:06:04 +02:00
|
|
|
}
|