man/man-db-2.6.5-security4.dif
Dr. Werner Fink 53653d743a Accepting request 229380 from home:rudi_m:branches:Base:System
- Update to version 2.6.6
- rebase following patches:
  * man-db-2.6.3.dif
  * man-db-2.6.3-security4.dif
  * man-db-2.6.3-firefox.dif
  * man-db-2.6.3-zio.dif
- enable checks

OBS-URL: https://build.opensuse.org/request/show/229380
OBS-URL: https://build.opensuse.org/package/show/Base:System/man?expand=0&rev=54
2014-04-08 13:02:52 +00:00

56 lines
1.5 KiB
Plaintext

---
src/mandb.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git src/mandb.c src/mandb.c
index 86b9e97..5b8c57d 100644
--- src/mandb.c
+++ src/mandb.c
@@ -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>
@@ -422,10 +423,19 @@ static int mandb (const char *catpath, const char *manpath)
char *dbname;
char *cachedir_tag;
struct stat st;
+ int fd;
dbname = mkdbname (catpath);
database = xasprintf ("%s/%d", catpath, getpid ());
+ /* 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);
@@ -433,6 +443,7 @@ static int mandb (const char *catpath, const char *manpath)
if (stat (cachedir_tag, &st) == -1 && errno == ENOENT) {
FILE *cachedir_tag_file;
+ drop_effective_privs ();
cachedir_tag_file = fopen (cachedir_tag, "w");
if (cachedir_tag_file) {
fputs ("Signature: 8a477f597d28d172789f06886806bc55\n"
@@ -444,6 +455,7 @@ static int mandb (const char *catpath, const char *manpath)
cachedir_tag_file);
fclose (cachedir_tag_file);
}
+ regain_effective_privs ();
}
free (cachedir_tag);
--
1.8.4.5