public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/wireshark] rawhide: Improved tmpdir handling
@ 2026-09-08 14:56 Peter Lemenkov
  0 siblings, 0 replies; only message in thread
From: Peter Lemenkov @ 2026-09-08 14:56 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/wireshark
            Branch : rawhide
            Commit : 928e8ef43e99cdb100e16b684b90f6a579854013
            Author : Peter Lemenkov <lemenkov@gmail.com>
            Date   : 2026-09-08T16:56:24+02:00
            Stats  : +87/-287 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/wireshark/c/928e8ef43e99cdb100e16b684b90f6a579854013?branch=rawhide

            Log:
            Improved tmpdir handling

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>

---
diff --git a/wireshark-0006-Move-tmp-to-var-tmp.patch b/wireshark-0006-Move-tmp-to-var-tmp.patch
index 01f0a4a..93dc4b2 100644
--- a/wireshark-0006-Move-tmp-to-var-tmp.patch
+++ b/wireshark-0006-Move-tmp-to-var-tmp.patch
@@ -1,273 +1,83 @@
-From cb54210f7f02b07768cfbf49ae266d487f580e1b Mon Sep 17 00:00:00 2001
-From: rpm-build <rpm-build>
-Date: Thu, 29 Jun 2017 15:32:58 +0200
-Subject: [PATCH] Move /tmp to /var/tmp
+From e819ed35245a0b9ebda9947f9091401fb70c5533 Mon Sep 17 00:00:00 2001
+From: Peter Hatina <phatina@redhat.com>
+Date: Tue, 24 Sep 2013 10:55:09 +0200
+Subject: [PATCH 1/1] Move /tmp to /var/tmp
 
-Fedora is using tmpfs which is limited by the size of RAM, thus we need
-to use different directory on different filesystem.
+Fedora mounts /tmp on tmpfs, which is backed by RAM, and capture files
+are routinely larger than RAM, so the default temporary directory needs
+to be somewhere on disk.
 
+Set TMPDIR in configuration_init(), which every program calls early in
+main(). TMPDIR is the one knob that GLib (g_get_tmp_dir()), Qt
+(QDir::tempPath()) and child processes such as dumpcap all read, so one
+default covers every temporary file rather than the handful of call
+sites a per-site patch can reach. A TMPDIR already in the environment is
+left alone.
+
+Only TMPDIR is consulted, and an empty one counts as unset - that is
+exactly how GLib and Qt behave on Unix, where TMP and TEMP are ignored
+entirely.
+
+The change is Peter Hatina's, from 2013; the implementation above was
+rewritten in 2026 and the original is worth recording. It added
+wsutil/wstmpdir.{c,h} - a copy of g_get_tmp_dir() with a /var/tmp
+fallback, exported from libwsutil as get_tmp_dir() - and rewrote
+create_tempfile() around it.
+
+That reached three of the roughly seventeen places that ask for a
+temporary directory, missing the second temporary file in
+rtp_audio_file.cpp, the export-object and traffic-tab dialogs, tshark's
+own default, wsutil/socket.c and create_tempdir(). It also worked only
+by accident: P_tmpdir is "/tmp" on glibc and was tested ahead of the
+/var/tmp default, so the fallback was reached purely because
+wstmpdir.c never included <stdio.h>. Adding that one header would have
+silently restored /tmp.
+
+Setting TMPDIR keeps Peter's intent and drops all of that.
+
+Rewritten-by: Peter Lemenkov <lemenkov@gmail.com>
+Assisted-by: Claude
 ---
- ui/qt/about_dialog.cpp         |  3 +-
- ui/qt/iax2_analysis_dialog.cpp |  5 ++-
- ui/qt/utils/rtp_audio_file.cpp |  3 +-
- wsutil/tempfile.c              | 18 +++++++-
- wsutil/tempfile.h              |  2 +-
- wsutil/wstmpdir.c              | 71 ++++++++++++++++++++++++++++++++++
- wsutil/wstmpdir.h              | 39 +++++++++++++++++++
- 7 files changed, 134 insertions(+), 7 deletions(-)
- create mode 100644 wsutil/wstmpdir.c
- create mode 100644 wsutil/wstmpdir.h
+ wsutil/filesystem.c | 26 ++++++++++++++++++++++++++
+ 1 file changed, 26 insertions(+)
 
-diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp
-index cdbd865..a2d24c5 100644
---- a/ui/qt/iax2_analysis_dialog.cpp
-+++ b/ui/qt/iax2_analysis_dialog.cpp
-@@ -24,6 +24,7 @@
- #include "ui/rtp_stream.h"
- #endif
- #include <wsutil/utf8_entities.h>
-+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
- 
- #include <wsutil/g711.h>
- #include <wsutil/pint.h>
-@@ -252,9 +253,9 @@ 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 = QStringLiteral("%1/wireshark_iax2_f").arg(QDir::tempPath());
-+    QString tempname = QStringLiteral("%1/wireshark_iax2_f").arg(get_tmp_dir());
-     fwd_tempfile_ = new QTemporaryFile(tempname, this);
--    tempname = QStringLiteral("%1/wireshark_iax2_r").arg(QDir::tempPath());
-+    tempname = QStringLiteral("%1/wireshark_iax2_r").arg(get_tmp_dir());
-     rev_tempfile_ = new QTemporaryFile(tempname, this);
- 
-     if (!fwd_tempfile_->open() || fwd_tempfile_->error() != QFile::NoError || !rev_tempfile_->open() || rev_tempfile_->error() != QFile::NoError) {
-diff --git a/ui/qt/utils/rtp_audio_file.cpp b/ui/qt/utils/rtp_audio_file.cpp
-index 591a63bbf3..203f5c5286 100644
---- a/ui/qt/utils/rtp_audio_file.cpp
-+++ b/ui/qt/utils/rtp_audio_file.cpp
-@@ -31,6 +31,7 @@
- 
- #include "rtp_audio_file.h"
- #include <ws_attributes.h>
-+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
- 
- RtpAudioFile::RtpAudioFile(bool use_disk_for_temp, bool use_disk_for_frames):
-       real_pos_(0)
-@@ -45,7 +46,7 @@ RtpAudioFile::RtpAudioFile(bool use_disk_for_temp, bool use_disk_for_frames):
- 
-     tempname = "memory";
-     if (use_disk_for_temp) {
--        tempname = QStringLiteral("%1/wireshark_rtp_stream").arg(QDir::tempPath());
-+        tempname = QStringLiteral("%1/wireshark_rtp_stream").arg(get_tmp_dir());
-         sample_file_ = new QTemporaryFile(tempname, this);
-     } else {
-         sample_file_ = new QBuffer(this);
-diff --git a/wsutil/tempfile.c b/wsutil/tempfile.c
-index 531ed91..bd6fd60 100644
---- a/wsutil/tempfile.c
-+++ b/wsutil/tempfile.c
-@@ -10,6 +10,8 @@
- 
- #include "config.h"
- #include "tempfile.h"
-+#include <wsutil/file_util.h>
-+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
- 
- #include <errno.h>
- 
-@@ -39,7 +41,7 @@ sanitize_prefix(const char *prefix)
- 
-  /**
-  * Create a tempfile with the given prefix (e.g. "wireshark"). The path
-- * is created using g_file_open_tmp.
-+ * is created using get_tmp_dir.
-  *
-  * @param tempdir [in] If not NULL, the directory in which to create the file.
-  * @param namebuf [in,out] If not NULL, receives the full path of the temp file.
-@@ -55,13 +57,25 @@ create_tempfile(const char *tempdir, char **namebuf, const char *pfx, const char
- {
-   int fd;
-   char *safe_pfx = sanitize_prefix(pfx);
-+  gchar *tmp_file;
-+  const char *tmp_dir;
-+  int old_mask;
- 
-   if (tempdir == NULL || tempdir[0] == '\0') {
-     /* Use OS default tempdir behaviour */
-     char* filetmpl = ws_strdup_printf("%sXXXXXX%s", safe_pfx ? safe_pfx : "", sfx ? sfx : "");
-     g_free(safe_pfx);
- 
--    fd = g_file_open_tmp(filetmpl, namebuf, err);
-+    tmp_dir = get_tmp_dir();
-+    tmp_file = g_strconcat(tmp_dir, "/", filetmpl, NULL);
-+
-+    if (namebuf)
-+      *namebuf = tmp_file;
-+
-+    old_mask = ws_umask(0077);
-+    fd = mkstemps(tmp_file, sfx ? (int) strlen(sfx) : 0);
-+    ws_umask(old_mask);
-+
-     g_free(filetmpl);
-   }
-   else {
-diff --git a/wsutil/tempfile.h b/wsutil/tempfile.h
-index 70031b5419..72011e265a 100644
---- a/wsutil/tempfile.h
-+++ b/wsutil/tempfile.h
-@@ -23,7 +23,7 @@ extern "C" {
- 
- /**
-  * Create a tempfile with the given prefix (e.g. "wireshark"). The path
-- * is created using g_file_open_tmp.
-+ * is created using get_tmp_dir and mkstemp.
-  *
-  * @param tempdir [in] If not NULL, the directory in which to create the file.
-  * @param namebuf [in,out] If not NULL, receives the full path of the temp file.
-diff --git a/wsutil/wstmpdir.c b/wsutil/wstmpdir.c
-new file mode 100644
-index 0000000000..9128d354ce
---- /dev/null
-+++ b/wsutil/wstmpdir.c
-@@ -0,0 +1,71 @@
-+/* 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';
-+            fprintf(stderr, "Using P_tmpdir: %s\n", P_tmpdir);
-+        }
-+#endif /* P_tmpdir */
-+
-+        if (tmp == NULL || *tmp == '\0') {
-+            g_free(tmp);
-+            tmp = g_strdup("/var/tmp");
-+        }
-+
-+        g_once_init_leave(&tmp_dir, tmp);
+diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
+index f1c7358a97..6ee028cb71 100644
+--- a/wsutil/filesystem.c
++++ b/wsutil/filesystem.c
+@@ -932,6 +932,32 @@ configuration_init(const char* arg0)
+ #ifdef _WIN32
+     return configuration_init_w32(arg0);
+ #else
++    /*
++     * Fedora mounts /tmp on tmpfs, which is backed by RAM, and capture
++     * files are routinely larger than RAM. Default the temporary
++     * directory to /var/tmp unless the user has asked for something else.
++     *
++     * TMPDIR is the one knob that GLib (g_get_tmp_dir()), Qt
++     * (QDir::tempPath()) and child processes such as dumpcap all read on
++     * this platform, so setting it here covers every temporary file the
++     * programs create without having to touch each call site. It has to
++     * happen before any of them run, and configuration_init() is among
++     * the first things every program calls.
++     *
++     * Only TMPDIR is consulted. TMP and TEMP are Windows spellings that
++     * neither GLib nor Qt looks at on Unix, so honouring them here would
++     * promise something the rest of the code cannot keep.
++     *
++     * An empty TMPDIR counts as unset, which is how both GLib and Qt
++     * treat it - otherwise it would suppress this default and leave them
++     * falling back to /tmp, the one outcome nobody asked for.
++     */
++    const char *tmpdir = g_getenv("TMPDIR");
++
++    if (tmpdir == NULL || tmpdir[0] == '\0') {
++        g_setenv("TMPDIR", "/var/tmp", true);
 +    }
 +
-+    return tmp_dir;
-+}
-diff --git a/wsutil/wstmpdir.h b/wsutil/wstmpdir.h
-new file mode 100644
-index 0000000000..07ac5837ac
---- /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
+     return configuration_init_posix(arg0);
+ #endif
+ }
 -- 
-2.37.3
+2.55.0
 
-diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp
-index ea11122..982ba1a 100644
---- a/ui/qt/about_dialog.cpp
-+++ b/ui/qt/about_dialog.cpp
-@@ -14,6 +14,7 @@
- #include <ui_about_dialog.h>
- 
- #include "main_application.h"
-+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
- 
- #include <wsutil/application_flavor.h>
- 
-@@ -204,7 +205,7 @@ FolderListModel::FolderListModel(QObject * parent):
-     appendRow(QStringList() << tr("\"File\" dialog location") << get_open_dialog_initial_dir() << tr("Capture files"));
- 
-     /* temp */
--    appendRow(QStringList() << tr("Temp") << (global_capture_opts.temp_dir && global_capture_opts.temp_dir[0] ? global_capture_opts.temp_dir : g_get_tmp_dir())
-+    appendRow(QStringList() << tr("Temp") << (global_capture_opts.temp_dir && global_capture_opts.temp_dir[0] ? global_capture_opts.temp_dir : get_tmp_dir())
-                             << tr("Untitled capture files"));
- 
-     /* pers conf */

diff --git a/wireshark-0007-cmakelists.patch b/wireshark-0007-cmakelists.patch
deleted file mode 100644
index 18064e2..0000000
--- a/wireshark-0007-cmakelists.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt
-index a55086c..0149801 100644
---- a/wsutil/CMakeLists.txt
-+++ b/wsutil/CMakeLists.txt
-@@ -80,6 +80,7 @@ set(WSUTIL_PUBLIC_HEADERS
- 	ws_roundup.h
- 	ws_strptime.h
- 	wsgcrypt.h
-+	wstmpdir.h
- 	wsjson.h
- 	wslog.h
- 	xtea.h
-@@ -135,6 +136,7 @@ set(WSUTIL_COMMON_FILES
- 	ws_pipe.c
- 	ws_strptime.c
- 	wsgcrypt.c
-+	wstmpdir.c
- 	wsjson.c
- 	wslog.c
- 	xtea.c

diff --git a/wireshark.spec b/wireshark.spec
index 0f8aaab..9f02b5e 100644
--- a/wireshark.spec
+++ b/wireshark.spec
@@ -9,7 +9,7 @@
 Summary:	Network traffic analyzer
 Name:		wireshark
 Version:	4.6.7
-Release:	2%{?dist}
+Release:	3%{?dist}
 Epoch:		1
 License:	BSD-1-Clause AND BSD-2-Clause AND BSD-3-Clause AND MIT AND GPL-2.0-or-later AND LGPL-2.0-or-later AND Zlib AND ISC AND (BSD-3-Clause OR GPL-2.0-only) AND (GPL-2.0-or-later AND Zlib)
 Url:		http://www.wireshark.org/
@@ -27,7 +27,6 @@ Patch4:   wireshark-0004-Restore-Fedora-specific-groups.patch
 Patch5:   wireshark-0005-Fix-paths-in-a-wireshark.desktop-file.patch
 # Fedora-specific
 Patch6:   wireshark-0006-Move-tmp-to-var-tmp.patch
-Patch7:   wireshark-0007-cmakelists.patch
 Patch8:   wireshark-0008-pkgconfig.patch
 Patch9:   wireshark-0009-remove-strato-manpages.patch
 
@@ -305,6 +304,17 @@ fi
 %endif
 
 %changelog
+* Tue Sep 08 2026 Peter Lemenkov <lemenkov@gmail.com> - 1:4.6.7-3
+- Rewrite the /var/tmp patch to set TMPDIR in configuration_init() rather
+  than add wsutil/wstmpdir.{c,h} and rewrite create_tempfile(). TMPDIR is
+  read by GLib, by Qt and by child processes such as dumpcap, so one
+  default now covers every temporary file instead of three of the roughly
+  seventeen places that ask for a temporary directory
+- Drop wireshark-0007-cmakelists.patch, which existed only to build the
+  files the rewrite removes
+- Drop the stray wireshark-0003 patch, applied upstream in 0bc06ec1086 and
+  unreferenced by the spec since 4.6.0
+
 * Fri Jul 17 2026 Fedora Release Engineering <releng@fedoraproject.org> - 1:4.6.7-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-08 14:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 14:56 [rpms/wireshark] rawhide: Improved tmpdir handling Peter Lemenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox