Index: b/lib/routines.c
===================================================================
--- a/lib/routines.c
+++ b/lib/routines.c
@@ -242,3 +242,50 @@
/* Don't complain if you can't unlink. Who cares of a tmp file? */
unlink (filename);
}
+
+/*
+ * Securely generate a temp file, and make sure it gets
+ * deleted upon exit.
+ */
+static char ** tempfiles;
+static unsigned ntempfiles;
+
+static void
+cleanup_tempfiles()
+{
+ while (ntempfiles--)
+ unlink(tempfiles[ntempfiles]);
+}
+
+char *
+safe_tempnam(const char *pfx)
+{
+ char *dirname, *filename;
+ int fd;
+
+ if (!(dirname = getenv("TMPDIR")))
+ dirname = "/tmp";
+
+ tempfiles = (char **) realloc(tempfiles,
+ (ntempfiles+1) * sizeof(char *));
+ if (tempfiles == NULL)
+ return NULL;
+
+ filename = malloc(strlen(dirname) + strlen(pfx) + sizeof("/XXXXXX"));
+ if (!filename)
+ return NULL;
+
+ sprintf(filename, "%s/%sXXXXXX", dirname, pfx);
+
+ if ((fd = mkstemp(filename)) < 0) {
+ free(filename);
+ return NULL;
+ }
+ close(fd);
+
+ if (ntempfiles == 0)
+ atexit(cleanup_tempfiles);
+ tempfiles[ntempfiles++] = filename;
+
+ return filename;
+}
Index: b/lib/routines.h
===================================================================
--- a/lib/routines.h
+++ b/lib/routines.h
@@ -255,7 +255,8 @@
/* If _STR_ is not defined, give it a tempname in _TMPDIR_ */
#define tempname_ensure(Str) \
do { \
- (Str) = (Str) ? (Str) : tempnam (NULL, "a2_"); \
+ (Str) = (Str) ? (Str) : safe_tempnam("a2_"); \
} while (0)
+char * safe_tempnam(const char *);
#endif
dc2312428a9899f0'/>
log msg
author
committer
range
Age Commit message (Expand ) Author
2024-04-18 news: Add entry for nss-certs being added to %base-packages. ...* etc/news.scm: New entry.
* NEWS: Update news.
Change-Id: I40e0b859f2af0bb0e652925a53d6447ea6fbacfb
Maxim Cournoyer
2023-03-28 NEWS: Mention new rpm format. ...* NEWS (Package management): Mention new rpm format.
Maxim Cournoyer
2022-12-18 Update NEWS. Ludovic Courtès
2022-12-17 Update NEWS. Marius Bakke
2022-12-02 Update NEWS. Ludovic Courtès
2022-11-23 NEWS: Update it. ...* NEWS: Shepherd is already at 0.9.3 now.
Jonathan Brielmaier
2022-11-16 Update NEWS. Maxim Cournoyer
2022-10-13 NEWS: Update it. ...* NEWS: Add an entry about 'guix shell' --emulate-fhs option.
Mathieu Othacehe
2022-10-07 Update NEWS. ...* NEWS: Add new entry for installation script improvements.
Maxim Cournoyer
2022-09-28 Update NEWS. ...* NEWS: Add new services for the 1.4.0.
Mathieu Othacehe
2022-09-26 NEWS: Update it. ...* NEWS: Add an entry about WSL images.
Mathieu Othacehe
2022-09-24 Update NEWS. Ludovic Courtès
2022-09-23 Update NEWS. Maxim Cournoyer
2022-09-19 Update NEWS. ...* NEWS: Mention Shepherd 0.9.2 upgrade.
Mathieu Othacehe
2022-09-16 Update NEWS. ...Entries extracted from:
git log 3eadcdc63..version-1.4.0
* NEWS: Update entries for v1.4.0
Mathieu Othacehe
2022-09-15 Update NEWS. ...This covers the commits made between v1.3.0..3eadcdc6^.
* NEWS: New entries for the 1.4.0 upcoming release.
Maxim Cournoyer
2022-09-14 Update NEWS. ...These news were extracted from the output of:
git log --reverse v1.3.0..03eb0b1be2cfedd0d9a66fef0edc53a17f7653a5.
* NEWS: Update entries for v1.4.0.
Maxim Cournoyer