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

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