summaryrefslogtreecommitdiff
path: root/dpkg-deb/info.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2010-02-22 05:04:54 +0100
committerGuillem Jover <guillem@debian.org>2010-02-25 09:37:41 +0100
commitffccc65580189420a0a64736bba0fb661de56dcb (patch)
treeb16e6491da28c14893936618e669c6f78bf11463 /dpkg-deb/info.c
parent4c9d2d0eeed8b077a19da5bac5f2e8183e27e850 (diff)
downloaddpkg-ffccc65580189420a0a64736bba0fb661de56dcb.tar.gz
Use mkdtemp and path_make_temp_template instead of tempnam and tmpnam
Those two functions are deprecated, produce warnings at link time, and should not be used as they are cause of possible race conditions. As a side effect we don't need to ensure the path is not existing as mkdtemp has done that for us, which slightly simplifies the code.
Diffstat (limited to 'dpkg-deb/info.c')
-rw-r--r--dpkg-deb/info.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c
index b115a2f48..7f04b98ea 100644
--- a/dpkg-deb/info.c
+++ b/dpkg-deb/info.c
@@ -41,6 +41,7 @@
#include <dpkg/dpkg-db.h>
#include <dpkg/pkg-format.h>
#include <dpkg/buffer.h>
+#include <dpkg/path.h>
#include <dpkg/subproc.h>
#include <dpkg/myopt.h>
@@ -69,21 +70,15 @@ static void info_prepare(const char *const **argvp,
const char **directoryp,
int admininfo) {
char *dbuf;
- pid_t c1;
*debarp= *(*argvp)++;
if (!*debarp) badusage(_("--%s needs a .deb filename argument"),cipaction->olong);
- /* This creates a temporary directory, so ignore the warning. */
- if ((dbuf= tempnam(NULL,"dpkg")) == NULL)
- ohshite(_("failed to make temporary directoryname"));
+
+ dbuf = mkdtemp(path_make_temp_template("dpkg"));
+ if (!dbuf)
+ ohshite(_("failed to create temporary directory"));
*directoryp= dbuf;
- c1 = subproc_fork();
- if (!c1) {
- execlp(RM, "rm", "-rf", dbuf, NULL);
- ohshite(_("failed to exec rm -rf"));
- }
- subproc_wait_check(c1, "rm -rf", 0);
push_cleanup(cu_info_prepare, -1, NULL, 0, 1, (void *)dbuf);
extracthalf(*debarp, dbuf, "mx", admininfo);
}