|
Martin Sehnoutka |
4cab85 |
From cb54210f7f02b07768cfbf49ae266d487f580e1b Mon Sep 17 00:00:00 2001
|
|
Martin Sehnoutka |
4cab85 |
From: rpm-build <rpm-build>
|
|
Martin Sehnoutka |
4cab85 |
Date: Thu, 29 Jun 2017 15:32:58 +0200
|
|
Martin Sehnoutka |
4cab85 |
Subject: [PATCH] Move /tmp to /var/tmp
|
|
|
c06811 |
|
|
Martin Sehnoutka |
4cab85 |
Fedora is using tmpfs which is limited by the size of RAM, thus we need
|
|
Martin Sehnoutka |
4cab85 |
to use different directory on different filesystem.
|
|
Martin Sehnoutka |
4cab85 |
---
|
|
Martin Sehnoutka |
4cab85 |
ui/qt/about_dialog.cpp | 3 +-
|
|
Martin Sehnoutka |
4cab85 |
ui/qt/iax2_analysis_dialog.cpp | 5 +--
|
|
Martin Sehnoutka |
4cab85 |
ui/qt/rtp_analysis_dialog.cpp | 5 +--
|
|
Martin Sehnoutka |
4cab85 |
ui/qt/rtp_audio_stream.cpp | 3 +-
|
|
Martin Sehnoutka |
4cab85 |
wsutil/tempfile.c | 9 +++---
|
|
Martin Sehnoutka |
4cab85 |
wsutil/tempfile.h | 4 +--
|
|
Martin Sehnoutka |
4cab85 |
wsutil/wstmpdir.c | 70 ++++++++++++++++++++++++++++++++++++++++++
|
|
Martin Sehnoutka |
4cab85 |
wsutil/wstmpdir.h | 39 +++++++++++++++++++++++
|
|
Michal Ruprich |
2313f2 |
8 files changed, 132 insertions(+), 11 deletions(-)
|
|
Martin Sehnoutka |
4cab85 |
create mode 100644 wsutil/wstmpdir.c
|
|
Martin Sehnoutka |
4cab85 |
create mode 100644 wsutil/wstmpdir.h
|
|
|
d3e571 |
|
|
Peter Hatina |
fe8eca |
diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp
|
|
Martin Sehnoutka |
4cab85 |
index 31dc581..2f74285 100644
|
|
Peter Hatina |
fe8eca |
--- a/ui/qt/about_dialog.cpp
|
|
Peter Hatina |
fe8eca |
+++ b/ui/qt/about_dialog.cpp
|
|
Martin Sehnoutka |
4cab85 |
@@ -26,6 +26,7 @@
|
|
Martin Sehnoutka |
4cab85 |
|
|
Martin Sehnoutka |
4cab85 |
#include "wireshark_application.h"
|
|
Martin Sehnoutka |
4cab85 |
#include <wsutil/filesystem.h>
|
|
Martin Sehnoutka |
4cab85 |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Martin Sehnoutka |
4cab85 |
|
|
Michal Ruprich |
97ece0 |
#include <QDesktopServices>
|
|
Michal Ruprich |
97ece0 |
#include <QUrl>
|
|
Michal Ruprich |
97ece0 |
@@ -206,7 +206,7 @@ FolderListModel::FolderListModel(QObject * parent):
|
|
Michal Ruprich |
fb64c4 |
appendRow(QStringList() << tr("\"File\" dialogs") << get_last_open_dir() << tr("capture files"));
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
/* temp */
|
|
Michal Ruprich |
fb64c4 |
- appendRow(QStringList() << tr("Temp") << g_get_tmp_dir() << tr("untitled capture files"));
|
|
Michal Ruprich |
fb64c4 |
+ appendRow(QStringList() << tr("Temp") << get_tmp_dir() << tr("untitled capture files"));
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
/* pers conf */
|
|
Michal Ruprich |
fb64c4 |
appendRow(QStringList() << tr("Personal configuration")
|
|
Peter Hatina |
fe8eca |
diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp
|
|
Martin Sehnoutka |
4cab85 |
index ee4e5fd..fe17a95 100644
|
|
Peter Hatina |
fe8eca |
--- a/ui/qt/iax2_analysis_dialog.cpp
|
|
Peter Hatina |
fe8eca |
+++ b/ui/qt/iax2_analysis_dialog.cpp
|
|
Martin Sehnoutka |
4cab85 |
@@ -37,6 +37,7 @@
|
|
Martin Sehnoutka |
4cab85 |
#include "ui/rtp_stream.h"
|
|
Martin Sehnoutka |
4cab85 |
#endif
|
|
Martin Sehnoutka |
4cab85 |
#include <wsutil/utf8_entities.h>
|
|
Martin Sehnoutka |
4cab85 |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Martin Sehnoutka |
4cab85 |
|
|
Peter Hatina |
fe8eca |
#include <wsutil/g711.h>
|
|
Peter Hatina |
fe8eca |
#include <wsutil/pint.h>
|
|
Martin Sehnoutka |
4cab85 |
@@ -271,10 +272,10 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
// We keep our temp files open for the lifetime of the dialog. The GTK+
|
|
Peter Hatina |
fe8eca |
// UI opens and closes at various points.
|
|
Peter Hatina |
fe8eca |
- QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath());
|
|
Peter Hatina |
fe8eca |
+ QString tempname = QString("%1/wireshark_iax2_f").arg(get_tmp_dir());
|
|
Peter Hatina |
fe8eca |
fwd_tempfile_ = new QTemporaryFile(tempname, this);
|
|
Peter Hatina |
fe8eca |
fwd_tempfile_->open();
|
|
Peter Hatina |
fe8eca |
- tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath());
|
|
Peter Hatina |
fe8eca |
+ tempname = QString("%1/wireshark_iax2_r").arg(get_tmp_dir());
|
|
Peter Hatina |
fe8eca |
rev_tempfile_ = new QTemporaryFile(tempname, this);
|
|
Peter Hatina |
fe8eca |
rev_tempfile_->open();
|
|
Peter Hatina |
fe8eca |
|
|
Michal Ruprich |
63bc18 |
diff --git a/ui/qt/utils/rtp_audio_file.cpp b/ui/qt/utils/rtp_audio_file.cpp
|
|
Michal Ruprich |
63bc18 |
index 591a63b..203f5c5 100644
|
|
Michal Ruprich |
63bc18 |
--- a/ui/qt/utils/rtp_audio_file.cpp
|
|
Michal Ruprich |
63bc18 |
+++ b/ui/qt/utils/rtp_audio_file.cpp
|
|
Michal Ruprich |
63bc18 |
@@ -31,6 +31,7 @@
|
|
Martin Sehnoutka |
4cab85 |
|
|
Michal Ruprich |
63bc18 |
#include "rtp_audio_file.h"
|
|
Michal Ruprich |
63bc18 |
#include <ws_attributes.h>
|
|
Peter Hatina |
fe8eca |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Martin Sehnoutka |
4cab85 |
|
|
Michal Ruprich |
63bc18 |
RtpAudioFile::RtpAudioFile(bool use_disk_for_temp, bool use_disk_for_frames):
|
|
Michal Ruprich |
63bc18 |
real_pos_(0)
|
|
Michal Ruprich |
63bc18 |
@@ -45,7 +46,7 @@ RtpAudioFile::RtpAudioFile(bool use_disk_for_temp, bool use_disk_for_frames):
|
|
Peter Hatina |
fe8eca |
|
|
Michal Ruprich |
63bc18 |
tempname = "memory";
|
|
Michal Ruprich |
63bc18 |
if (use_disk_for_temp) {
|
|
Michal Ruprich |
63bc18 |
- tempname = QString("%1/wireshark_rtp_stream").arg(QDir::tempPath());
|
|
Michal Ruprich |
63bc18 |
+ tempname = QString("%1/wireshark_rtp_stream").arg(get_tmp_dir());
|
|
Michal Ruprich |
63bc18 |
sample_file_ = new QTemporaryFile(tempname, this);
|
|
Michal Ruprich |
63bc18 |
} else {
|
|
Michal Ruprich |
63bc18 |
sample_file_ = new QBuffer(this);
|
|
|
d3e571 |
diff --git a/wsutil/tempfile.c b/wsutil/tempfile.c
|
|
Michal Ruprich |
031511 |
index 5082452..f751a7c 100644
|
|
|
d3e571 |
--- a/wsutil/tempfile.c
|
|
|
d3e571 |
+++ b/wsutil/tempfile.c
|
|
Michal Ruprich |
031511 |
@@ -12,10 +12,12 @@
|
|
Michal Ruprich |
031511 |
|
|
Michal Ruprich |
031511 |
#include <glib.h>
|
|
Peter Hatina |
1fba24 |
#include "tempfile.h"
|
|
Michal Ruprich |
031511 |
+#include <wsutil/file_util.h>
|
|
Peter Hatina |
fe8eca |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Michal Ruprich |
031511 |
|
|
Michal Ruprich |
031511 |
/**
|
|
Michal Ruprich |
031511 |
* Create a tempfile with the given prefix (e.g. "wireshark"). The path
|
|
Michal Ruprich |
031511 |
- * is created using g_file_open_tmp.
|
|
Michal Ruprich |
031511 |
+ * is created using get_tmp_dir.
|
|
Michal Ruprich |
97ece0 |
*
|
|
Michal Ruprich |
031511 |
* @param namebuf [in,out] If not NULL, receives the full path of the temp file.
|
|
Michal Ruprich |
031511 |
* Must be freed.
|
|
Michal Ruprich |
031511 |
@@ -30,6 +31,9 @@ create_tempfile(gchar **namebuf, const char *pfx, const char *sfx, GError **err)
|
|
Michal Ruprich |
031511 |
{
|
|
Michal Ruprich |
031511 |
int fd;
|
|
Michal Ruprich |
031511 |
gchar *safe_pfx = NULL;
|
|
Michal Ruprich |
031511 |
+ gchar *tmp_file;
|
|
Michal Ruprich |
031511 |
+ const char *tmp_dir;
|
|
Michal Ruprich |
031511 |
+ int old_mask;
|
|
Michal Ruprich |
031511 |
|
|
Michal Ruprich |
031511 |
if (pfx) {
|
|
Michal Ruprich |
031511 |
/* The characters in "delimiters" come from:
|
|
Michal Ruprich |
031511 |
@@ -49,7 +53,15 @@ create_tempfile(gchar **namebuf, const char *pfx, const char *sfx, GError **err)
|
|
Michal Ruprich |
031511 |
gchar* filetmpl = g_strdup_printf("%sXXXXXX%s", safe_pfx ? safe_pfx : "", sfx ? sfx : "");
|
|
Michal Ruprich |
031511 |
g_free(safe_pfx);
|
|
Michal Ruprich |
031511 |
|
|
Michal Ruprich |
031511 |
- fd = g_file_open_tmp(filetmpl, namebuf, err);
|
|
Peter Hatina |
fe8eca |
+ tmp_dir = get_tmp_dir();
|
|
Michal Ruprich |
031511 |
+ tmp_file = g_strconcat(tmp_dir, "/", filetmpl, NULL);
|
|
Michal Ruprich |
031511 |
+
|
|
Michal Ruprich |
031511 |
+ if (namebuf)
|
|
Michal Ruprich |
031511 |
+ *namebuf = tmp_file;
|
|
Michal Ruprich |
031511 |
+
|
|
Michal Ruprich |
031511 |
+ old_mask = ws_umask(0077);
|
|
Michal Ruprich |
031511 |
+ fd = mkstemps(tmp_file, sfx ? (int) strlen(sfx) : 0);
|
|
Michal Ruprich |
031511 |
+ ws_umask(old_mask);
|
|
Michal Ruprich |
031511 |
|
|
Michal Ruprich |
031511 |
g_free(filetmpl);
|
|
Michal Ruprich |
031511 |
return fd;
|
|
Peter Hatina |
fe8eca |
diff --git a/wsutil/tempfile.h b/wsutil/tempfile.h
|
|
Peter Hatina |
c9a65b |
index 1dca2df..bb3160c 100644
|
|
Peter Hatina |
fe8eca |
--- a/wsutil/tempfile.h
|
|
Peter Hatina |
fe8eca |
+++ b/wsutil/tempfile.h
|
|
Peter Hatina |
fe8eca |
@@ -45,7 +45,7 @@ WS_DLL_PUBLIC char *get_tempfile_path(const char *filename);
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
/**
|
|
Peter Hatina |
fe8eca |
* Create a tempfile with the given prefix (e.g. "wireshark"). The path
|
|
Michal Ruprich |
031511 |
- * is created using g_file_open_tmp.
|
|
Peter Hatina |
fe8eca |
+ * is created using get_tmp_dir and mkstemp.
|
|
Peter Hatina |
fe8eca |
*
|
|
Peter Hatina |
fe8eca |
* @param namebuf [in,out] If not NULL, receives the full path of the temp file.
|
|
Michal Ruprich |
031511 |
* Must be freed.
|
|
Peter Hatina |
1fba24 |
diff --git a/wsutil/wstmpdir.c b/wsutil/wstmpdir.c
|
|
Peter Hatina |
1fba24 |
new file mode 100644
|
|
Peter Hatina |
1fba24 |
index 0000000..d8b733b
|
|
Peter Hatina |
1fba24 |
--- /dev/null
|
|
Peter Hatina |
1fba24 |
+++ b/wsutil/wstmpdir.c
|
|
Michal Ruprich |
031511 |
@@ -0,0 +1,71 @@
|
|
Peter Hatina |
1fba24 |
+/* wstmpdir.c
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Copyright (C) 2013 Red Hat, Inc. All right reserved.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Temporary directory routine
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * This program is free software; you can redistribute it and/or
|
|
Peter Hatina |
1fba24 |
+ * modify it under the terms of the GNU General Public License
|
|
Peter Hatina |
1fba24 |
+ * as published by the Free Software Foundation; either version 2
|
|
Peter Hatina |
1fba24 |
+ * of the License, or (at your option) any later version.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * This program is distributed in the hope that it will be useful,
|
|
Peter Hatina |
1fba24 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Peter Hatina |
1fba24 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Peter Hatina |
1fba24 |
+ * GNU General Public License for more details.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * You should have received a copy of the GNU General Public License
|
|
Peter Hatina |
1fba24 |
+ * along with this program; if not, write to the Free Software
|
|
Peter Hatina |
1fba24 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Author: Peter Hatina <phatina@redhat.com>
|
|
Peter Hatina |
1fba24 |
+ */
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#include "config.h"
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#include <glib.h>
|
|
Peter Hatina |
1fba24 |
+#include "wstmpdir.h"
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+/**
|
|
Peter Hatina |
1fba24 |
+ * Gets the directory to use for temporary files.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Inspired by glib-2.0. If no TMP, TEMP or TMPDIR is set,
|
|
Peter Hatina |
1fba24 |
+ * /var/tmp is returned (Fedora specific).
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Returns: the directory to use for temporary files.
|
|
Peter Hatina |
1fba24 |
+ */
|
|
Peter Hatina |
1fba24 |
+const char *get_tmp_dir(void)
|
|
Peter Hatina |
1fba24 |
+{
|
|
Peter Hatina |
1fba24 |
+ static gchar *tmp_dir;
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ if (g_once_init_enter(&tmp_dir)) {
|
|
Peter Hatina |
1fba24 |
+ gchar *tmp;
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ tmp = g_strdup(g_getenv("TEMP"));
|
|
Peter Hatina |
1fba24 |
+ if (tmp == NULL || *tmp == '\0') {
|
|
Peter Hatina |
1fba24 |
+ g_free(tmp);
|
|
Peter Hatina |
1fba24 |
+ tmp = g_strdup(g_getenv("TMPDIR"));
|
|
Peter Hatina |
1fba24 |
+ }
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#ifdef P_tmpdir
|
|
Peter Hatina |
1fba24 |
+ if (tmp == NULL || *tmp == '\0') {
|
|
Peter Hatina |
1fba24 |
+ gsize k;
|
|
Peter Hatina |
1fba24 |
+ g_free(tmp);
|
|
Peter Hatina |
1fba24 |
+ tmp = g_strdup(P_tmpdir);
|
|
Peter Hatina |
1fba24 |
+ k = strlen(tmp);
|
|
Peter Hatina |
1fba24 |
+ if (k > 1 && G_IS_DIR_SEPARATOR(tmp[k - 1]))
|
|
Peter Hatina |
1fba24 |
+ tmp[k - 1] = '\0';
|
|
Michal Ruprich |
031511 |
+ fprintf(stderr, "Using P_tmpdir: %s\n", P_tmpdir);
|
|
Peter Hatina |
1fba24 |
+ }
|
|
Peter Hatina |
1fba24 |
+#endif /* P_tmpdir */
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ if (tmp == NULL || *tmp == '\0') {
|
|
Peter Hatina |
1fba24 |
+ g_free(tmp);
|
|
Peter Hatina |
1fba24 |
+ tmp = g_strdup("/var/tmp");
|
|
Peter Hatina |
1fba24 |
+ }
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ g_once_init_leave(&tmp_dir, tmp);
|
|
Peter Hatina |
1fba24 |
+ }
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ return tmp_dir;
|
|
Peter Hatina |
1fba24 |
+}
|
|
Peter Hatina |
1fba24 |
diff --git a/wsutil/wstmpdir.h b/wsutil/wstmpdir.h
|
|
Peter Hatina |
1fba24 |
new file mode 100644
|
|
Martin Sehnoutka |
4cab85 |
index 0000000..07ac583
|
|
Peter Hatina |
1fba24 |
--- /dev/null
|
|
Peter Hatina |
1fba24 |
+++ b/wsutil/wstmpdir.h
|
|
Peter Hatina |
1fba24 |
@@ -0,0 +1,39 @@
|
|
Peter Hatina |
1fba24 |
+/* wstmpdir.c
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Copyright (C) 2013 Red Hat, Inc. All right reserved.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Temporary directory routine
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * This program is free software; you can redistribute it and/or
|
|
Peter Hatina |
1fba24 |
+ * modify it under the terms of the GNU General Public License
|
|
Peter Hatina |
1fba24 |
+ * as published by the Free Software Foundation; either version 2
|
|
Peter Hatina |
1fba24 |
+ * of the License, or (at your option) any later version.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * This program is distributed in the hope that it will be useful,
|
|
Peter Hatina |
1fba24 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Peter Hatina |
1fba24 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Peter Hatina |
1fba24 |
+ * GNU General Public License for more details.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * You should have received a copy of the GNU General Public License
|
|
Peter Hatina |
1fba24 |
+ * along with this program; if not, write to the Free Software
|
|
Peter Hatina |
1fba24 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Author: Peter Hatina <phatina@redhat.com>
|
|
Peter Hatina |
1fba24 |
+ */
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#ifndef __WS_TMP_DIR_H__
|
|
Peter Hatina |
1fba24 |
+#define __WS_TMP_DIR_H__
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#include "ws_symbol_export.h"
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#ifdef __cplusplus
|
|
Peter Hatina |
1fba24 |
+extern "C" {
|
|
Peter Hatina |
1fba24 |
+#endif // __cplusplus
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+WS_DLL_PUBLIC const char *get_tmp_dir(void);
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#ifdef __cplusplus
|
|
Peter Hatina |
1fba24 |
+}
|
|
Peter Hatina |
1fba24 |
+#endif // __cplusplus
|
|
Peter Hatina |
1fba24 |
+
|
|
Martin Sehnoutka |
4cab85 |
+#endif
|
|
Martin Sehnoutka |
4cab85 |
--
|
|
Martin Sehnoutka |
4cab85 |
2.13.0
|