359 lines
12 KiB
Diff
359 lines
12 KiB
Diff
commit b32de2f6e35b4e7d6ea4d0477db91b12861c09d6
|
|
Author: Peter Hatina <phatina@gmail.com>
|
|
Date: Tue Jan 12 13:56:59 2016 +0100
|
|
|
|
Move default temporary directory to /var/tmp
|
|
|
|
diff --git a/ui/gtk/about_dlg.c b/ui/gtk/about_dlg.c
|
|
index 0ed474a..fb3275b 100644
|
|
--- a/ui/gtk/about_dlg.c
|
|
+++ b/ui/gtk/about_dlg.c
|
|
@@ -30,6 +30,7 @@
|
|
#include <wsutil/filesystem.h>
|
|
#include <wsutil/copyright_info.h>
|
|
#include <wsutil/ws_version_info.h>
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
#ifdef HAVE_LIBSMI
|
|
#include <epan/oids.h>
|
|
#endif
|
|
@@ -407,7 +408,7 @@ about_folders_page_new(void)
|
|
"capture files");
|
|
|
|
/* temp */
|
|
- about_folders_row(table, "Temp", g_get_tmp_dir(),
|
|
+ about_folders_row(table, "Temp", get_tmp_dir(),
|
|
"untitled capture files");
|
|
|
|
/* pers conf */
|
|
diff --git a/ui/gtk/proto_help.c b/ui/gtk/proto_help.c
|
|
index 79cafd4..47eec6c 100644
|
|
--- a/ui/gtk/proto_help.c
|
|
+++ b/ui/gtk/proto_help.c
|
|
@@ -37,6 +37,8 @@
|
|
#include "../file.h"
|
|
|
|
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
+
|
|
#include "ui/gtk/proto_help.h"
|
|
|
|
/*
|
|
@@ -155,7 +157,7 @@ void proto_help_init(void)
|
|
/* Start loop */
|
|
|
|
#ifdef PH_DEBUG_LOG
|
|
- ph_log_path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", g_get_tmp_dir(), PH_FILE_LOG);
|
|
+ ph_log_path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", get_tmp_dir(), PH_FILE_LOG);
|
|
#endif
|
|
|
|
for (i = 0; i < PH_CONF_DIRS; i++) {
|
|
diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp
|
|
index c0899a0..4fada89 100644
|
|
--- a/ui/qt/about_dialog.cpp
|
|
+++ b/ui/qt/about_dialog.cpp
|
|
@@ -49,6 +49,7 @@
|
|
#include "file.h"
|
|
#include "wsutil/file_util.h"
|
|
#include "wsutil/tempfile.h"
|
|
+#include "wsutil/wstmpdir.h" /* for get_tmp_dir() */
|
|
#include "wsutil/plugins.h"
|
|
#include "wsutil/copyright_info.h"
|
|
#include "wsutil/ws_version_info.h"
|
|
@@ -184,7 +185,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
|
|
message += about_folders_row("\"File\" dialogs", get_last_open_dir(), "capture files");
|
|
|
|
/* temp */
|
|
- message += about_folders_row("Temp", g_get_tmp_dir(), "untitled capture files");
|
|
+ message += about_folders_row("Temp", get_tmp_dir(), "untitled capture files");
|
|
|
|
/* pers conf */
|
|
message += about_folders_row("Personal configuration",
|
|
diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp
|
|
index e1ef186..b672b31 100644
|
|
--- a/ui/qt/iax2_analysis_dialog.cpp
|
|
+++ b/ui/qt/iax2_analysis_dialog.cpp
|
|
@@ -41,6 +41,8 @@
|
|
#include <wsutil/g711.h>
|
|
#include <wsutil/pint.h>
|
|
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
+
|
|
#include <QFileDialog>
|
|
#include <QMessageBox>
|
|
#include <QPushButton>
|
|
@@ -271,10 +273,10 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
|
|
|
|
// We keep our temp files open for the lifetime of the dialog. The GTK+
|
|
// UI opens and closes at various points.
|
|
- QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath());
|
|
+ QString tempname = QString("%1/wireshark_iax2_f").arg(get_tmp_dir());
|
|
fwd_tempfile_ = new QTemporaryFile(tempname, this);
|
|
fwd_tempfile_->open();
|
|
- tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath());
|
|
+ tempname = QString("%1/wireshark_iax2_r").arg(get_tmp_dir());
|
|
rev_tempfile_ = new QTemporaryFile(tempname, this);
|
|
rev_tempfile_->open();
|
|
|
|
diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp
|
|
index 87322df..fbe9ffa 100644
|
|
--- a/ui/qt/rtp_analysis_dialog.cpp
|
|
+++ b/ui/qt/rtp_analysis_dialog.cpp
|
|
@@ -38,6 +38,8 @@
|
|
#include <wsutil/g711.h>
|
|
#include <wsutil/pint.h>
|
|
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
+
|
|
#include <QFileDialog>
|
|
#include <QMessageBox>
|
|
#include <QPushButton>
|
|
@@ -321,10 +323,10 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, struct _r
|
|
|
|
// We keep our temp files open for the lifetime of the dialog. The GTK+
|
|
// UI opens and closes at various points.
|
|
- QString tempname = QString("%1/wireshark_rtp_f").arg(QDir::tempPath());
|
|
+ QString tempname = QString("%1/wireshark_rtp_f").arg(get_tmp_dir());
|
|
fwd_tempfile_ = new QTemporaryFile(tempname, this);
|
|
fwd_tempfile_->open();
|
|
- tempname = QString("%1/wireshark_rtp_r").arg(QDir::tempPath());
|
|
+ tempname = QString("%1/wireshark_rtp_r").arg(get_tmp_dir());
|
|
rev_tempfile_ = new QTemporaryFile(tempname, this);
|
|
rev_tempfile_->open();
|
|
|
|
diff --git a/ui/qt/rtp_audio_stream.cpp b/ui/qt/rtp_audio_stream.cpp
|
|
index 1346a4d..4d34a3b 100644
|
|
--- a/ui/qt/rtp_audio_stream.cpp
|
|
+++ b/ui/qt/rtp_audio_stream.cpp
|
|
@@ -33,6 +33,7 @@
|
|
#include <ui/rtp_stream.h>
|
|
|
|
#include <wsutil/nstime.h>
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
|
|
#include <QAudioFormat>
|
|
#include <QAudioOutput>
|
|
@@ -71,7 +72,7 @@ RtpAudioStream::RtpAudioStream(QObject *parent, _rtp_stream_info *rtp_stream) :
|
|
visual_sample_rate_, SPEEX_RESAMPLER_QUALITY_MIN, NULL);
|
|
ws_codec_resampler_skip_zeros(visual_resampler_);
|
|
|
|
- QString tempname = QString("%1/wireshark_rtp_stream").arg(QDir::tempPath());
|
|
+ QString tempname = QString("%1/wireshark_rtp_stream").arg(get_tmp_dir());
|
|
tempfile_ = new QTemporaryFile(tempname, this);
|
|
tempfile_->open();
|
|
|
|
diff --git a/wsutil/Makefile.common b/wsutil/Makefile.common
|
|
index e24f015..49f0a95 100644
|
|
--- a/wsutil/Makefile.common
|
|
+++ b/wsutil/Makefile.common
|
|
@@ -71,7 +71,8 @@ LIBWSUTIL_SRC = \
|
|
ws_mempbrk.c \
|
|
u3.c \
|
|
unicode-utils.c \
|
|
- ws_version_info.c
|
|
+ ws_version_info.c \
|
|
+ wstmpdir.c
|
|
|
|
# Header files that don't declare replacement functions for functions
|
|
# present in the APIs/ABIs of some, but not all, targets.
|
|
@@ -128,7 +129,8 @@ libwsutil_nonrepl_INCLUDES = \
|
|
ws_diag_control.h \
|
|
ws_mempbrk.h \
|
|
ws_mempbrk_int.h \
|
|
- ws_version_info.h
|
|
+ ws_version_info.h \
|
|
+ wstmpdir.h
|
|
|
|
# Header files that are not generated from other files
|
|
LIBWSUTIL_INCLUDES = \
|
|
diff --git a/wsutil/tempfile.c b/wsutil/tempfile.c
|
|
index 93bd66f..757b6c8 100644
|
|
--- a/wsutil/tempfile.c
|
|
+++ b/wsutil/tempfile.c
|
|
@@ -44,6 +44,7 @@
|
|
|
|
#include "tempfile.h"
|
|
#include <wsutil/file_util.h>
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
|
|
#ifndef __set_errno
|
|
#define __set_errno(x) errno=(x)
|
|
@@ -146,7 +147,7 @@ mkdtemp (char *path_template)
|
|
*/
|
|
char *get_tempfile_path(const char *filename)
|
|
{
|
|
- return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", g_get_tmp_dir(), filename);
|
|
+ return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", get_tmp_dir(), filename);
|
|
}
|
|
|
|
#define MAX_TEMPFILES 3
|
|
@@ -203,7 +204,7 @@ create_tempfile(char **namebuf, const char *pfx)
|
|
tf[idx].path = (char *)g_malloc(tf[idx].len);
|
|
}
|
|
|
|
- tmp_dir = g_get_tmp_dir();
|
|
+ tmp_dir = get_tmp_dir();
|
|
|
|
#ifdef _WIN32
|
|
_tzset();
|
|
@@ -237,7 +238,7 @@ create_tempfile(char **namebuf, const char *pfx)
|
|
|
|
/**
|
|
* Create a directory with the given prefix (e.g. "wireshark"). The path
|
|
- * is created using g_get_tmp_dir and mkdtemp.
|
|
+ * is created using get_tmp_dir and mkdtemp.
|
|
*
|
|
* @param namebuf
|
|
* @param pfx A prefix for the temporary directory.
|
|
@@ -265,7 +266,7 @@ create_tempdir(char **namebuf, const char *pfx)
|
|
/*
|
|
* We can't use get_tempfile_path here because we're called from dumpcap.c.
|
|
*/
|
|
- tmp_dir = g_get_tmp_dir();
|
|
+ tmp_dir = get_tmp_dir();
|
|
|
|
while (g_snprintf(td_path[idx], td_path_len[idx], "%s%c%s" TMP_FILE_SUFFIX, tmp_dir, G_DIR_SEPARATOR, pfx) > td_path_len[idx]) {
|
|
td_path_len[idx] *= 2;
|
|
diff --git a/wsutil/tempfile.h b/wsutil/tempfile.h
|
|
index f595632..5e22227 100644
|
|
--- a/wsutil/tempfile.h
|
|
+++ b/wsutil/tempfile.h
|
|
@@ -45,7 +45,7 @@ WS_DLL_PUBLIC char *get_tempfile_path(const char *filename);
|
|
|
|
/**
|
|
* Create a tempfile with the given prefix (e.g. "wireshark"). The path
|
|
- * is created using g_get_tmp_dir and mkstemp.
|
|
+ * is created using get_tmp_dir and mkstemp.
|
|
*
|
|
* @param namebuf [in,out] If not NULL, receives the full path of the temp file.
|
|
* Must NOT be freed.
|
|
@@ -56,7 +56,7 @@ WS_DLL_PUBLIC int create_tempfile(char **namebuf, const char *pfx);
|
|
|
|
/**
|
|
* Create a directory with the given prefix (e.g. "wireshark"). The path
|
|
- * is created using g_get_tmp_dir and mkdtemp.
|
|
+ * is created using get_tmp_dir and mkdtemp.
|
|
*
|
|
* @param namebuf If not NULL, receives the full path of the temp directory.
|
|
* Must NOT be freed.
|
|
diff --git a/wsutil/wstmpdir.c b/wsutil/wstmpdir.c
|
|
new file mode 100644
|
|
index 0000000..d8b733b
|
|
--- /dev/null
|
|
+++ b/wsutil/wstmpdir.c
|
|
@@ -0,0 +1,70 @@
|
|
+/* wstmpdir.c
|
|
+ *
|
|
+ * Copyright (C) 2013 Red Hat, Inc. All right reserved.
|
|
+ *
|
|
+ * Temporary directory routine
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or
|
|
+ * modify it under the terms of the GNU General Public License
|
|
+ * as published by the Free Software Foundation; either version 2
|
|
+ * of the License, or (at your option) any later version.
|
|
+ *
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
+ * GNU General Public License for more details.
|
|
+ *
|
|
+ * You should have received a copy of the GNU General Public License
|
|
+ * along with this program; if not, write to the Free Software
|
|
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
+ *
|
|
+ * Author: Peter Hatina <phatina@redhat.com>
|
|
+ */
|
|
+
|
|
+#include "config.h"
|
|
+
|
|
+#include <glib.h>
|
|
+#include "wstmpdir.h"
|
|
+
|
|
+/**
|
|
+ * Gets the directory to use for temporary files.
|
|
+ *
|
|
+ * Inspired by glib-2.0. If no TMP, TEMP or TMPDIR is set,
|
|
+ * /var/tmp is returned (Fedora specific).
|
|
+ *
|
|
+ * Returns: the directory to use for temporary files.
|
|
+ */
|
|
+const char *get_tmp_dir(void)
|
|
+{
|
|
+ static gchar *tmp_dir;
|
|
+
|
|
+ if (g_once_init_enter(&tmp_dir)) {
|
|
+ gchar *tmp;
|
|
+
|
|
+ tmp = g_strdup(g_getenv("TEMP"));
|
|
+ if (tmp == NULL || *tmp == '\0') {
|
|
+ g_free(tmp);
|
|
+ tmp = g_strdup(g_getenv("TMPDIR"));
|
|
+ }
|
|
+
|
|
+#ifdef P_tmpdir
|
|
+ if (tmp == NULL || *tmp == '\0') {
|
|
+ gsize k;
|
|
+ g_free(tmp);
|
|
+ tmp = g_strdup(P_tmpdir);
|
|
+ k = strlen(tmp);
|
|
+ if (k > 1 && G_IS_DIR_SEPARATOR(tmp[k - 1]))
|
|
+ tmp[k - 1] = '\0';
|
|
+ }
|
|
+#endif /* P_tmpdir */
|
|
+
|
|
+ if (tmp == NULL || *tmp == '\0') {
|
|
+ g_free(tmp);
|
|
+ tmp = g_strdup("/var/tmp");
|
|
+ }
|
|
+
|
|
+ g_once_init_leave(&tmp_dir, tmp);
|
|
+ }
|
|
+
|
|
+ return tmp_dir;
|
|
+}
|
|
diff --git a/wsutil/wstmpdir.h b/wsutil/wstmpdir.h
|
|
new file mode 100644
|
|
index 0000000..021b615
|
|
--- /dev/null
|
|
+++ b/wsutil/wstmpdir.h
|
|
@@ -0,0 +1,39 @@
|
|
+/* wstmpdir.c
|
|
+ *
|
|
+ * Copyright (C) 2013 Red Hat, Inc. All right reserved.
|
|
+ *
|
|
+ * Temporary directory routine
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or
|
|
+ * modify it under the terms of the GNU General Public License
|
|
+ * as published by the Free Software Foundation; either version 2
|
|
+ * of the License, or (at your option) any later version.
|
|
+ *
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
+ * GNU General Public License for more details.
|
|
+ *
|
|
+ * You should have received a copy of the GNU General Public License
|
|
+ * along with this program; if not, write to the Free Software
|
|
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
+ *
|
|
+ * Author: Peter Hatina <phatina@redhat.com>
|
|
+ */
|
|
+
|
|
+#ifndef __WS_TMP_DIR_H__
|
|
+#define __WS_TMP_DIR_H__
|
|
+
|
|
+#include "ws_symbol_export.h"
|
|
+
|
|
+#ifdef __cplusplus
|
|
+extern "C" {
|
|
+#endif // __cplusplus
|
|
+
|
|
+WS_DLL_PUBLIC const char *get_tmp_dir(void);
|
|
+
|
|
+#ifdef __cplusplus
|
|
+}
|
|
+#endif // __cplusplus
|
|
+
|
|
+#endif // __WS_TMP_DIR_H__
|