From 1fba24b8c0e776f24d800cb6c514a14fe5fc8c7c Mon Sep 17 00:00:00 2001 From: Peter Hatina Date: Tue, 24 Sep 2013 10:55:09 +0200 Subject: [PATCH] move default temporary directory to /var/tmp --- wireshark-0012-tmp-dir.patch | 225 +++++++++++++++++++++++++++++++++++ wireshark.spec | 8 +- 2 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 wireshark-0012-tmp-dir.patch diff --git a/wireshark-0012-tmp-dir.patch b/wireshark-0012-tmp-dir.patch new file mode 100644 index 0000000..bbd3dd4 --- /dev/null +++ b/wireshark-0012-tmp-dir.patch @@ -0,0 +1,225 @@ +diff --git a/epan/filesystem.c b/epan/filesystem.c +index 89edb8a..00acdd9 100644 +--- a/epan/filesystem.c ++++ b/epan/filesystem.c +@@ -74,6 +74,8 @@ + + #include /* for WTAP_ERR_SHORT_WRITE */ + ++#include /* for get_tmp_dir() */ ++ + #define PROFILES_DIR "profiles" + #define PLUGINS_DIR_NAME "plugins" + +@@ -1574,7 +1576,7 @@ deletefile(const char *path) + */ + 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); + } + + /* +diff --git a/tempfile.c b/tempfile.c +index 9a236df..ab6d1dc 100644 +--- a/tempfile.c ++++ b/tempfile.c +@@ -50,6 +50,7 @@ + + #include "tempfile.h" + #include ++#include /* For get_tmp_dir() */ + + #ifndef __set_errno + #define __set_errno(x) errno=(x) +@@ -203,7 +204,7 @@ create_tempfile(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(); + + #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/ui/gtk/proto_help.c b/ui/gtk/proto_help.c +index 16dc24e..fe12c81 100644 +--- a/ui/gtk/proto_help.c ++++ b/ui/gtk/proto_help.c +@@ -44,6 +44,8 @@ + #include + #include + ++#include /* for get_tmp_dir() */ ++ + #include "ui/gtk/proto_help.h" + + /* +@@ -162,7 +164,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/wsutil/Makefile.common b/wsutil/Makefile.common +index 93efa0f..ab8ce7d 100644 +--- a/wsutil/Makefile.common ++++ b/wsutil/Makefile.common +@@ -43,7 +43,8 @@ LIBWSUTIL_SRC = \ + mpeg-audio.c \ + privileges.c \ + str_util.c \ +- type_util.c ++ type_util.c \ ++ wstmpdir.c + + # Header files that are not generated from other files + LIBWSUTIL_INCLUDES = \ +@@ -60,4 +61,5 @@ LIBWSUTIL_INCLUDES = \ + mpeg-audio.h \ + privileges.h \ + str_util.h \ +- type_util.h ++ type_util.h \ ++ wstmpdir.h +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 ++ */ ++ ++#include "config.h" ++ ++#include ++#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 ++ */ ++ ++#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__ diff --git a/wireshark.spec b/wireshark.spec index ce06c90..c9439f8 100644 --- a/wireshark.spec +++ b/wireshark.spec @@ -21,7 +21,7 @@ Summary: Network traffic analyzer Name: wireshark Version: 1.10.2 -Release: 5%{?dist} +Release: 6%{?dist} License: GPL+ Group: Applications/Internet Source0: http://wireshark.org/download/src/%{name}-%{version}.tar.bz2 @@ -45,6 +45,8 @@ Patch9: wireshark-0009-Restore-Fedora-specific-groups.patch Patch10: wireshark-0010-Add-pkgconfig-entry.patch # Will be proposed upstream Patch11: wireshark-0011-Install-autoconf-related-file.patch +# Fedora-specific +Patch12: wireshark-0012-tmp-dir.patch Url: http://www.wireshark.org/ BuildRequires: libpcap-devel >= 0.9 @@ -150,6 +152,7 @@ and plugins. %patch9 -p1 -b .restore_group %patch10 -p1 -b .add_pkgconfig %patch11 -p1 -b .install_autoconf +%patch12 -p1 -b .tmp_dir %build %ifarch s390 s390x sparcv9 sparc64 @@ -344,6 +347,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %{_datadir}/aclocal/* %changelog +* Tue Sep 17 2013 Peter Hatina - 1.10.2-6 +- move default temporary directory to /var/tmp + * Fri Sep 13 2013 Peter Lemenkov - 1.10.2-5 - Convert automake/pkgconfig files into patches (better upstream integration) - Restored category in the *.desktop file