diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-07-21 11:47:57 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-07-21 11:47:57 +0100 |
commit | 98430c35faa073c60d4c00542c090fe0407c5af7 (patch) | |
tree | 9f23e51d4cccf4820556f77d891e3825ff3f4029 /src | |
parent | e315e0723ec8c2f84809f06d7f2ede4955dd6c67 (diff) | |
download | libguestfs-98430c35faa073c60d4c00542c090fe0407c5af7.tar.gz libguestfs-98430c35faa073c60d4c00542c090fe0407c5af7.tar.xz libguestfs-98430c35faa073c60d4c00542c090fe0407c5af7.zip |
Allow TMPDIR to override directory used for temporary files (RHBZ#512905).
Diffstat (limited to 'src')
-rw-r--r-- | src/guestfs.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/guestfs.c b/src/guestfs.c index f445adab..386dee6c 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -875,7 +875,8 @@ static const char *supermin_hostfiles_name = int guestfs_launch (guestfs_h *g) { - static const char *dir_template = "/tmp/libguestfsXXXXXX"; + const char *tmpdir; + char dir_template[PATH_MAX]; int r, i, pmore; size_t len; int wfd[2], rfd[2]; @@ -885,6 +886,15 @@ guestfs_launch (guestfs_h *g) char unixsock[256]; struct sockaddr_un addr; +#ifdef P_tmpdir + tmpdir = P_tmpdir; +#else + tmpdir = "/tmp"; +#endif + + tmpdir = getenv ("TMPDIR") ? : tmpdir; + snprintf (dir_template, sizeof dir_template, "%s/libguestfsXXXXXX", tmpdir); + /* Configured? */ if (!g->cmdline) { error (g, _("you must call guestfs_add_drive before guestfs_launch")); |