Blame SOURCES/wireshark-0006-Move-tmp-to-var-tmp.patch

4a42e1
From cb54210f7f02b07768cfbf49ae266d487f580e1b Mon Sep 17 00:00:00 2001
4a42e1
From: rpm-build <rpm-build>
4a42e1
Date: Thu, 29 Jun 2017 15:32:58 +0200
4a42e1
Subject: [PATCH] Move /tmp to /var/tmp
4a42e1
4a42e1
Fedora is using tmpfs which is limited by the size of RAM, thus we need
4a42e1
to use different directory on different filesystem.
4a42e1
---
4a42e1
 ui/gtk/about_dlg.c             |  3 +-
4a42e1
 ui/qt/about_dialog.cpp         |  3 +-
4a42e1
 ui/qt/iax2_analysis_dialog.cpp |  5 +--
4a42e1
 ui/qt/rtp_analysis_dialog.cpp  |  5 +--
4a42e1
 ui/qt/rtp_audio_stream.cpp     |  3 +-
4a42e1
 wsutil/Makefile.am             |  6 ++--
4a42e1
 wsutil/tempfile.c              |  9 +++---
4a42e1
 wsutil/tempfile.h              |  4 +--
4a42e1
 wsutil/wstmpdir.c              | 70 ++++++++++++++++++++++++++++++++++++++++++
4a42e1
 wsutil/wstmpdir.h              | 39 +++++++++++++++++++++++
4a42e1
 10 files changed, 132 insertions(+), 15 deletions(-)
4a42e1
 create mode 100644 wsutil/wstmpdir.c
4a42e1
 create mode 100644 wsutil/wstmpdir.h
4a42e1
4a42e1
diff --git a/ui/gtk/about_dlg.c b/ui/gtk/about_dlg.c
4a42e1
index 22ca841..6bcb527 100644
4a42e1
--- a/ui/gtk/about_dlg.c
4a42e1
+++ b/ui/gtk/about_dlg.c
4a42e1
@@ -28,6 +28,7 @@
4a42e1
 #include <gtk/gtk.h>
4a42e1
 
4a42e1
 #include <wsutil/filesystem.h>
4a42e1
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
4a42e1
 #include <wsutil/copyright_info.h>
4a42e1
 #include <version_info.h>
4a42e1
 #ifdef HAVE_LIBSMI
4a42e1
@@ -427,7 +428,7 @@ about_folders_page_new(void)
4a42e1
       "capture files");
4a42e1
 
4a42e1
   /* temp */
4a42e1
-  about_folders_row(table, "Temp", g_get_tmp_dir(),
4a42e1
+  about_folders_row(table, "Temp", get_tmp_dir(),
4a42e1
       "untitled capture files");
4a42e1
 
4a42e1
   /* pers conf */
4a42e1
diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp
4a42e1
index 31dc581..2f74285 100644
4a42e1
--- a/ui/qt/about_dialog.cpp
4a42e1
+++ b/ui/qt/about_dialog.cpp
4a42e1
@@ -26,6 +26,7 @@
4a42e1
 
4a42e1
 #include "wireshark_application.h"
4a42e1
 #include <wsutil/filesystem.h>
4a42e1
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
4a42e1
 
4a42e1
 #include <QDesktopServices>
4a42e1
 #include <QUrl>
4a42e1
@@ -206,7 +206,7 @@ FolderListModel::FolderListModel(QObject * parent):
4a42e1
     appendRow( QStringList() << tr("\"File\" dialogs") << get_last_open_dir() << tr("capture files"));
4a42e1
 
4a42e1
     /* temp */
4a42e1
-    appendRow( QStringList() << tr("Temp") << g_get_tmp_dir() << tr("untitled capture files"));
4a42e1
+    appendRow( QStringList() << tr("Temp") << get_tmp_dir() << tr("untitled capture files"));
4a42e1
 
4a42e1
     /* pers conf */
4a42e1
     appendRow( QStringList() << tr("Personal configuration")
4a42e1
diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp
4a42e1
index ee4e5fd..fe17a95 100644
4a42e1
--- a/ui/qt/iax2_analysis_dialog.cpp
4a42e1
+++ b/ui/qt/iax2_analysis_dialog.cpp
4a42e1
@@ -37,6 +37,7 @@
4a42e1
 #include "ui/rtp_stream.h"
4a42e1
 #endif
4a42e1
 #include <wsutil/utf8_entities.h>
4a42e1
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
4a42e1
 
4a42e1
 #include <wsutil/g711.h>
4a42e1
 #include <wsutil/pint.h>
4a42e1
@@ -271,10 +272,10 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
4a42e1
 
4a42e1
     // We keep our temp files open for the lifetime of the dialog. The GTK+
4a42e1
     // UI opens and closes at various points.
4a42e1
-    QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath());
4a42e1
+    QString tempname = QString("%1/wireshark_iax2_f").arg(get_tmp_dir());
4a42e1
     fwd_tempfile_ = new QTemporaryFile(tempname, this);
4a42e1
     fwd_tempfile_->open();
4a42e1
-    tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath());
4a42e1
+    tempname = QString("%1/wireshark_iax2_r").arg(get_tmp_dir());
4a42e1
     rev_tempfile_ = new QTemporaryFile(tempname, this);
4a42e1
     rev_tempfile_->open();
4a42e1
 
4a42e1
diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp
4a42e1
index 5d82e46..8008984 100644
4a42e1
--- a/ui/qt/rtp_analysis_dialog.cpp
4a42e1
+++ b/ui/qt/rtp_analysis_dialog.cpp
4a42e1
@@ -37,6 +37,7 @@
4a42e1
 
4a42e1
 #include <wsutil/g711.h>
4a42e1
 #include <wsutil/pint.h>
4a42e1
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
4a42e1
 
4a42e1
 #include <QMessageBox>
4a42e1
 #include <QPushButton>
4a42e1
@@ -331,10 +332,10 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, struct _r
4a42e1
 
4a42e1
     // We keep our temp files open for the lifetime of the dialog. The GTK+
4a42e1
     // UI opens and closes at various points.
4a42e1
-    QString tempname = QString("%1/wireshark_rtp_f").arg(QDir::tempPath());
4a42e1
+    QString tempname = QString("%1/wireshark_rtp_f").arg(get_tmp_dir());
4a42e1
     fwd_tempfile_ = new QTemporaryFile(tempname, this);
4a42e1
     fwd_tempfile_->open();
4a42e1
-    tempname = QString("%1/wireshark_rtp_r").arg(QDir::tempPath());
4a42e1
+    tempname = QString("%1/wireshark_rtp_r").arg(get_tmp_dir());
4a42e1
     rev_tempfile_ = new QTemporaryFile(tempname, this);
4a42e1
     rev_tempfile_->open();
4a42e1
 
4a42e1
diff --git a/ui/qt/rtp_audio_stream.cpp b/ui/qt/rtp_audio_stream.cpp
4a42e1
index fde66c8..b9531d2 100644
4a42e1
--- a/ui/qt/rtp_audio_stream.cpp
4a42e1
+++ b/ui/qt/rtp_audio_stream.cpp
4a42e1
@@ -37,6 +37,7 @@
4a42e1
 #include <ui/rtp_stream.h>
4a42e1
 
4a42e1
 #include <wsutil/nstime.h>
4a42e1
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
4a42e1
 
4a42e1
 #include <QAudioFormat>
4a42e1
 #include <QAudioOutput>
4a42e1
@@ -76,7 +77,7 @@ RtpAudioStream::RtpAudioStream(QObject *parent, _rtp_stream_info *rtp_stream) :
4a42e1
                                                 visual_sample_rate_, SPEEX_RESAMPLER_QUALITY_MIN, NULL);
4a42e1
     speex_resampler_skip_zeros(visual_resampler_);
4a42e1
 
4a42e1
-    QString tempname = QString("%1/wireshark_rtp_stream").arg(QDir::tempPath());
4a42e1
+    QString tempname = QString("%1/wireshark_rtp_stream").arg(get_tmp_dir());
4a42e1
     tempfile_ = new QTemporaryFile(tempname, this);
4a42e1
     tempfile_->open();
4a42e1
 
4a42e1
diff --git a/wsutil/Makefile.am b/wsutil/Makefile.am
4a42e1
index 2af1b6c..aa149a2 100644
4a42e1
--- a/wsutil/Makefile.am
4a42e1
+++ b/wsutil/Makefile.am
4a42e1
@@ -90,6 +90,7 @@ WSUTIL_PUBLIC_INCLUDES = \
4a42e1
 	ws_pipe.h		\
4a42e1
 	ws_printf.h		\
4a42e1
 	wsjsmn.h		\
4a42e1
+	wstmpdir.h		\
4a42e1
 	wsgcrypt.h		\
4a42e1
 	wsgetopt.h		\
4a42e1
 	wspcap.h		\
4a42e1
@@ -168,6 +169,7 @@ libwsutil_la_SOURCES = \
4a42e1
 	ws_pipe.c		\
4a42e1
 	wsgcrypt.c		\
4a42e1
 	wsjsmn.c		\
4a42e1
+	wstmpdir.c		\
4a42e1
 	xtea.c
4a42e1
 
4a42e1
 if HAVE_PLUGINS
4a42e1
diff --git a/wsutil/tempfile.c b/wsutil/tempfile.c
4a42e1
index 8e1f8dc..dcf2f78 100644
4a42e1
--- a/wsutil/tempfile.c
4a42e1
+++ b/wsutil/tempfile.c
4a42e1
@@ -36,6 +36,7 @@
4a42e1
 
4a42e1
 #include "tempfile.h"
4a42e1
 #include <wsutil/file_util.h>
4a42e1
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
4a42e1
 
4a42e1
 #ifndef __set_errno
4a42e1
 #define __set_errno(x) errno=(x)
4a42e1
@@ -83,13 +83,14 @@ mkstemps(char *path_template, int suffixlen)
4a42e1
  */
4a42e1
 char *get_tempfile_path(const char *filename)
4a42e1
 {
4a42e1
-  return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", g_get_tmp_dir(), filename);
4a42e1
+  return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", get_tmp_dir(), filename);
4a42e1
 }
4a42e1
 
4a42e1
 #define MAX_TEMPFILES   3
4a42e1
 
4a42e1
 /**
4a42e1
- * Create a tempfile with the given prefix (e.g. "wireshark").
4a42e1
+ * Create a tempfile with the given prefix (e.g. "wireshark"). The path
4a42e1
+ * is created using get_tmp_dir and mkdtemp
4a42e1
  *
4a42e1
  * @param namebuf If not NULL, receives the full path of the temp file.
4a42e1
  *                Should NOT be freed.
4a42e1
@@ -199,7 +200,7 @@ create_tempfile(char **namebuf, const char *pfx, const char *sfx)
4a42e1
     tf[idx].path = (char *)g_malloc(tf[idx].len);
4a42e1
   }
4a42e1
 
4a42e1
-  tmp_dir = g_get_tmp_dir();
4a42e1
+  tmp_dir = get_tmp_dir();
4a42e1
 
4a42e1
 #ifdef _WIN32
4a42e1
   _tzset();
4a42e1
diff --git a/wsutil/tempfile.h b/wsutil/tempfile.h
4a42e1
index 1dca2df..bb3160c 100644
4a42e1
--- a/wsutil/tempfile.h
4a42e1
+++ b/wsutil/tempfile.h
4a42e1
@@ -45,7 +45,7 @@ WS_DLL_PUBLIC char *get_tempfile_path(const char *filename);
4a42e1
 
4a42e1
 /**
4a42e1
  * Create a tempfile with the given prefix (e.g. "wireshark"). The path
4a42e1
- * is created using g_get_tmp_dir and mkstemp.
4a42e1
+ * is created using get_tmp_dir and mkstemp.
4a42e1
  *
4a42e1
  * @param namebuf [in,out] If not NULL, receives the full path of the temp file.
4a42e1
  *                Must NOT be freed.
4a42e1
diff --git a/wsutil/wstmpdir.c b/wsutil/wstmpdir.c
4a42e1
new file mode 100644
4a42e1
index 0000000..d8b733b
4a42e1
--- /dev/null
4a42e1
+++ b/wsutil/wstmpdir.c
4a42e1
@@ -0,0 +1,70 @@
4a42e1
+/* wstmpdir.c
4a42e1
+ *
4a42e1
+ * Copyright (C) 2013 Red Hat, Inc. All right reserved.
4a42e1
+ *
4a42e1
+ * Temporary directory routine
4a42e1
+ *
4a42e1
+ * This program is free software; you can redistribute it and/or
4a42e1
+ * modify it under the terms of the GNU General Public License
4a42e1
+ * as published by the Free Software Foundation; either version 2
4a42e1
+ * of the License, or (at your option) any later version.
4a42e1
+ *
4a42e1
+ * This program is distributed in the hope that it will be useful,
4a42e1
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4a42e1
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4a42e1
+ * GNU General Public License for more details.
4a42e1
+ *
4a42e1
+ * You should have received a copy of the GNU General Public License
4a42e1
+ * along with this program; if not, write to the Free Software
4a42e1
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4a42e1
+ *
4a42e1
+ * Author: Peter Hatina <phatina@redhat.com>
4a42e1
+ */
4a42e1
+
4a42e1
+#include "config.h"
4a42e1
+
4a42e1
+#include <glib.h>
4a42e1
+#include "wstmpdir.h"
4a42e1
+
4a42e1
+/**
4a42e1
+ * Gets the directory to use for temporary files.
4a42e1
+ *
4a42e1
+ * Inspired by glib-2.0. If no TMP, TEMP or TMPDIR is set,
4a42e1
+ * /var/tmp is returned (Fedora specific).
4a42e1
+ *
4a42e1
+ * Returns: the directory to use for temporary files.
4a42e1
+ */
4a42e1
+const char *get_tmp_dir(void)
4a42e1
+{
4a42e1
+    static gchar *tmp_dir;
4a42e1
+
4a42e1
+    if (g_once_init_enter(&tmp_dir)) {
4a42e1
+        gchar *tmp;
4a42e1
+
4a42e1
+        tmp = g_strdup(g_getenv("TEMP"));
4a42e1
+        if (tmp == NULL || *tmp == '\0') {
4a42e1
+            g_free(tmp);
4a42e1
+            tmp = g_strdup(g_getenv("TMPDIR"));
4a42e1
+        }
4a42e1
+
4a42e1
+#ifdef P_tmpdir
4a42e1
+        if (tmp == NULL || *tmp == '\0') {
4a42e1
+            gsize k;
4a42e1
+            g_free(tmp);
4a42e1
+            tmp = g_strdup(P_tmpdir);
4a42e1
+            k = strlen(tmp);
4a42e1
+            if (k > 1 && G_IS_DIR_SEPARATOR(tmp[k - 1]))
4a42e1
+                tmp[k - 1] = '\0';
4a42e1
+        }
4a42e1
+#endif /* P_tmpdir */
4a42e1
+
4a42e1
+        if (tmp == NULL || *tmp == '\0') {
4a42e1
+            g_free(tmp);
4a42e1
+            tmp = g_strdup("/var/tmp");
4a42e1
+        }
4a42e1
+
4a42e1
+        g_once_init_leave(&tmp_dir, tmp);
4a42e1
+    }
4a42e1
+
4a42e1
+    return tmp_dir;
4a42e1
+}
4a42e1
diff --git a/wsutil/wstmpdir.h b/wsutil/wstmpdir.h
4a42e1
new file mode 100644
4a42e1
index 0000000..07ac583
4a42e1
--- /dev/null
4a42e1
+++ b/wsutil/wstmpdir.h
4a42e1
@@ -0,0 +1,39 @@
4a42e1
+/* wstmpdir.c
4a42e1
+ *
4a42e1
+ * Copyright (C) 2013 Red Hat, Inc. All right reserved.
4a42e1
+ *
4a42e1
+ * Temporary directory routine
4a42e1
+ *
4a42e1
+ * This program is free software; you can redistribute it and/or
4a42e1
+ * modify it under the terms of the GNU General Public License
4a42e1
+ * as published by the Free Software Foundation; either version 2
4a42e1
+ * of the License, or (at your option) any later version.
4a42e1
+ *
4a42e1
+ * This program is distributed in the hope that it will be useful,
4a42e1
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4a42e1
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4a42e1
+ * GNU General Public License for more details.
4a42e1
+ *
4a42e1
+ * You should have received a copy of the GNU General Public License
4a42e1
+ * along with this program; if not, write to the Free Software
4a42e1
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4a42e1
+ *
4a42e1
+ * Author: Peter Hatina <phatina@redhat.com>
4a42e1
+ */
4a42e1
+
4a42e1
+#ifndef __WS_TMP_DIR_H__
4a42e1
+#define __WS_TMP_DIR_H__
4a42e1
+
4a42e1
+#include "ws_symbol_export.h"
4a42e1
+
4a42e1
+#ifdef __cplusplus
4a42e1
+extern "C" {
4a42e1
+#endif // __cplusplus
4a42e1
+
4a42e1
+WS_DLL_PUBLIC const char *get_tmp_dir(void);
4a42e1
+
4a42e1
+#ifdef __cplusplus
4a42e1
+}
4a42e1
+#endif // __cplusplus
4a42e1
+
4a42e1
+#endif
4a42e1
-- 
4a42e1
2.13.0
4a42e1