2017-06-29 08:53:33 +00:00
|
|
|
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
|
2013-11-02 12:44:30 +00:00
|
|
|
|
2017-06-29 08:53:33 +00:00
|
|
|
Fedora is using tmpfs which is limited by the size of RAM, thus we need
|
|
|
|
to use different directory on different filesystem.
|
|
|
|
---
|
|
|
|
ui/gtk/about_dlg.c | 3 +-
|
|
|
|
ui/qt/about_dialog.cpp | 3 +-
|
|
|
|
ui/qt/iax2_analysis_dialog.cpp | 5 +--
|
|
|
|
ui/qt/rtp_analysis_dialog.cpp | 5 +--
|
|
|
|
ui/qt/rtp_audio_stream.cpp | 3 +-
|
|
|
|
wsutil/Makefile.am | 6 ++--
|
|
|
|
wsutil/tempfile.c | 9 +++---
|
|
|
|
wsutil/tempfile.h | 4 +--
|
|
|
|
wsutil/wstmpdir.c | 70 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
wsutil/wstmpdir.h | 39 +++++++++++++++++++++++
|
|
|
|
10 files changed, 132 insertions(+), 15 deletions(-)
|
|
|
|
create mode 100644 wsutil/wstmpdir.c
|
|
|
|
create mode 100644 wsutil/wstmpdir.h
|
2014-08-07 14:35:19 +00:00
|
|
|
|
2016-01-14 10:56:55 +00:00
|
|
|
diff --git a/ui/gtk/about_dlg.c b/ui/gtk/about_dlg.c
|
2017-06-29 08:53:33 +00:00
|
|
|
index 22ca841..6bcb527 100644
|
2016-01-14 10:56:55 +00:00
|
|
|
--- a/ui/gtk/about_dlg.c
|
|
|
|
+++ b/ui/gtk/about_dlg.c
|
2017-06-29 08:53:33 +00:00
|
|
|
@@ -28,6 +28,7 @@
|
|
|
|
#include <gtk/gtk.h>
|
2016-06-14 20:33:08 +00:00
|
|
|
|
2016-01-14 10:56:55 +00:00
|
|
|
#include <wsutil/filesystem.h>
|
2017-06-29 08:53:33 +00:00
|
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
2016-01-14 10:56:55 +00:00
|
|
|
#include <wsutil/copyright_info.h>
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
#include <version_info.h>
|
2016-01-14 10:56:55 +00:00
|
|
|
#ifdef HAVE_LIBSMI
|
2017-06-29 08:53:33 +00:00
|
|
|
@@ -427,7 +428,7 @@ about_folders_page_new(void)
|
2016-01-14 10:56:55 +00:00
|
|
|
"capture files");
|
|
|
|
|
|
|
|
/* temp */
|
|
|
|
- about_folders_row(table, "Temp", g_get_tmp_dir(),
|
|
|
|
+ about_folders_row(table, "Temp", get_tmp_dir(),
|
|
|
|
"untitled capture files");
|
|
|
|
|
|
|
|
/* pers conf */
|
|
|
|
diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp
|
2017-06-29 08:53:33 +00:00
|
|
|
index 31dc581..2f74285 100644
|
2016-01-14 10:56:55 +00:00
|
|
|
--- a/ui/qt/about_dialog.cpp
|
|
|
|
+++ b/ui/qt/about_dialog.cpp
|
2017-06-29 08:53:33 +00:00
|
|
|
@@ -26,6 +26,7 @@
|
|
|
|
|
|
|
|
#include "wireshark_application.h"
|
|
|
|
#include <wsutil/filesystem.h>
|
|
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
|
|
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QUrl>
|
|
|
|
@@ -206,7 +206,7 @@ FolderListModel::FolderListModel(QObject * parent):
|
|
|
|
appendRow( QStringList() << tr("\"File\" dialogs") << get_last_open_dir() << tr("capture files"));
|
2016-01-14 10:56:55 +00:00
|
|
|
|
|
|
|
/* temp */
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
- appendRow( QStringList() << tr("Temp") << g_get_tmp_dir() << tr("untitled capture files"));
|
|
|
|
+ appendRow( QStringList() << tr("Temp") << get_tmp_dir() << tr("untitled capture files"));
|
2016-01-14 10:56:55 +00:00
|
|
|
|
|
|
|
/* pers conf */
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
appendRow( QStringList() << tr("Personal configuration")
|
2016-01-14 10:56:55 +00:00
|
|
|
diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp
|
2017-06-29 08:53:33 +00:00
|
|
|
index ee4e5fd..fe17a95 100644
|
2016-01-14 10:56:55 +00:00
|
|
|
--- a/ui/qt/iax2_analysis_dialog.cpp
|
|
|
|
+++ b/ui/qt/iax2_analysis_dialog.cpp
|
2017-06-29 08:53:33 +00:00
|
|
|
@@ -37,6 +37,7 @@
|
|
|
|
#include "ui/rtp_stream.h"
|
|
|
|
#endif
|
|
|
|
#include <wsutil/utf8_entities.h>
|
|
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
|
|
|
2016-01-14 10:56:55 +00:00
|
|
|
#include <wsutil/g711.h>
|
|
|
|
#include <wsutil/pint.h>
|
2017-06-29 08:53:33 +00:00
|
|
|
@@ -271,10 +272,10 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
|
2016-01-14 10:56:55 +00:00
|
|
|
|
|
|
|
// We keep our temp files open for the lifetime of the dialog. The GTK+
|
|
|
|
// UI opens and closes at various points.
|
|
|
|
- QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath());
|
|
|
|
+ QString tempname = QString("%1/wireshark_iax2_f").arg(get_tmp_dir());
|
|
|
|
fwd_tempfile_ = new QTemporaryFile(tempname, this);
|
|
|
|
fwd_tempfile_->open();
|
|
|
|
- tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath());
|
|
|
|
+ tempname = QString("%1/wireshark_iax2_r").arg(get_tmp_dir());
|
|
|
|
rev_tempfile_ = new QTemporaryFile(tempname, this);
|
|
|
|
rev_tempfile_->open();
|
|
|
|
|
|
|
|
diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp
|
2017-06-29 08:53:33 +00:00
|
|
|
index 5d82e46..8008984 100644
|
2016-01-14 10:56:55 +00:00
|
|
|
--- a/ui/qt/rtp_analysis_dialog.cpp
|
|
|
|
+++ b/ui/qt/rtp_analysis_dialog.cpp
|
2017-06-29 08:53:33 +00:00
|
|
|
@@ -37,6 +37,7 @@
|
|
|
|
|
2016-01-14 10:56:55 +00:00
|
|
|
#include <wsutil/g711.h>
|
|
|
|
#include <wsutil/pint.h>
|
|
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
2017-06-29 08:53:33 +00:00
|
|
|
|
2016-01-14 10:56:55 +00:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
2017-06-29 08:53:33 +00:00
|
|
|
@@ -331,10 +332,10 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, struct _r
|
2016-01-14 10:56:55 +00:00
|
|
|
|
|
|
|
// We keep our temp files open for the lifetime of the dialog. The GTK+
|
|
|
|
// UI opens and closes at various points.
|
|
|
|
- QString tempname = QString("%1/wireshark_rtp_f").arg(QDir::tempPath());
|
|
|
|
+ QString tempname = QString("%1/wireshark_rtp_f").arg(get_tmp_dir());
|
|
|
|
fwd_tempfile_ = new QTemporaryFile(tempname, this);
|
|
|
|
fwd_tempfile_->open();
|
|
|
|
- tempname = QString("%1/wireshark_rtp_r").arg(QDir::tempPath());
|
|
|
|
+ tempname = QString("%1/wireshark_rtp_r").arg(get_tmp_dir());
|
|
|
|
rev_tempfile_ = new QTemporaryFile(tempname, this);
|
|
|
|
rev_tempfile_->open();
|
|
|
|
|
|
|
|
diff --git a/ui/qt/rtp_audio_stream.cpp b/ui/qt/rtp_audio_stream.cpp
|
2017-06-29 08:53:33 +00:00
|
|
|
index fde66c8..b9531d2 100644
|
2016-01-14 10:56:55 +00:00
|
|
|
--- a/ui/qt/rtp_audio_stream.cpp
|
|
|
|
+++ b/ui/qt/rtp_audio_stream.cpp
|
2016-06-14 20:33:08 +00:00
|
|
|
@@ -37,6 +37,7 @@
|
2016-01-14 10:56:55 +00:00
|
|
|
#include <ui/rtp_stream.h>
|
|
|
|
|
|
|
|
#include <wsutil/nstime.h>
|
|
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
|
|
|
|
|
|
#include <QAudioFormat>
|
|
|
|
#include <QAudioOutput>
|
2017-06-29 08:53:33 +00:00
|
|
|
@@ -76,7 +77,7 @@ RtpAudioStream::RtpAudioStream(QObject *parent, _rtp_stream_info *rtp_stream) :
|
2016-01-14 10:56:55 +00:00
|
|
|
visual_sample_rate_, SPEEX_RESAMPLER_QUALITY_MIN, NULL);
|
2016-06-14 20:33:08 +00:00
|
|
|
speex_resampler_skip_zeros(visual_resampler_);
|
2016-01-14 10:56:55 +00:00
|
|
|
|
|
|
|
- QString tempname = QString("%1/wireshark_rtp_stream").arg(QDir::tempPath());
|
|
|
|
+ QString tempname = QString("%1/wireshark_rtp_stream").arg(get_tmp_dir());
|
|
|
|
tempfile_ = new QTemporaryFile(tempname, this);
|
|
|
|
tempfile_->open();
|
|
|
|
|
2016-07-24 18:22:43 +00:00
|
|
|
diff --git a/wsutil/Makefile.am b/wsutil/Makefile.am
|
2017-06-29 08:53:33 +00:00
|
|
|
index 2af1b6c..aa149a2 100644
|
2016-07-24 18:22:43 +00:00
|
|
|
--- a/wsutil/Makefile.am
|
|
|
|
+++ b/wsutil/Makefile.am
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
@@ -90,6 +90,7 @@ WSUTIL_PUBLIC_INCLUDES = \
|
|
|
|
ws_pipe.h \
|
2017-06-29 08:53:33 +00:00
|
|
|
ws_printf.h \
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
wsjsmn.h \
|
|
|
|
+ wstmpdir.h \
|
|
|
|
wsgcrypt.h \
|
|
|
|
wsgetopt.h \
|
|
|
|
wspcap.h \
|
|
|
|
@@ -168,6 +169,7 @@ libwsutil_la_SOURCES = \
|
|
|
|
ws_pipe.c \
|
2017-06-29 08:53:33 +00:00
|
|
|
wsgcrypt.c \
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
wsjsmn.c \
|
|
|
|
+ wstmpdir.c \
|
|
|
|
xtea.c
|
2016-07-24 18:22:43 +00:00
|
|
|
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
if HAVE_PLUGINS
|
2014-08-07 14:35:19 +00:00
|
|
|
diff --git a/wsutil/tempfile.c b/wsutil/tempfile.c
|
2017-06-29 08:53:33 +00:00
|
|
|
index 8e1f8dc..dcf2f78 100644
|
2014-08-07 14:35:19 +00:00
|
|
|
--- a/wsutil/tempfile.c
|
|
|
|
+++ b/wsutil/tempfile.c
|
2016-06-14 20:33:08 +00:00
|
|
|
@@ -36,6 +36,7 @@
|
2013-09-24 08:55:09 +00:00
|
|
|
|
|
|
|
#include "tempfile.h"
|
|
|
|
#include <wsutil/file_util.h>
|
2016-01-14 10:56:55 +00:00
|
|
|
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
2013-09-24 08:55:09 +00:00
|
|
|
|
|
|
|
#ifndef __set_errno
|
|
|
|
#define __set_errno(x) errno=(x)
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
@@ -83,13 +83,14 @@ mkstemps(char *path_template, int suffixlen)
|
2014-08-07 14:35:19 +00:00
|
|
|
*/
|
|
|
|
char *get_tempfile_path(const char *filename)
|
|
|
|
{
|
2016-01-14 10:56:55 +00:00
|
|
|
- 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);
|
2014-08-07 14:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_TEMPFILES 3
|
New version 2.6.0
Fix for CVE-2018-9256, CVE-2018-9257, CVE-2018-9258, CVE-2018-9259, CVE-2018-9260, CVE-2018-9261, CVE-2018-9262, CVE-2018-9263, CVE-2018-9264, CVE-2018-9265, CVE-2018-9266, CVE-2018-9267, CVE-2018-9268, CVE-2018-9269, CVE-2018-9270, CVE-2018-9271, CVE-2018-9272, CVE-2018-9273, CVE-2018-9274
Switch from autotools to cmake
Removed python2-devel(#1560284) and libssh2-devel from dependencies
Removed python scripts
2018-05-02 11:34:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
- * Create a tempfile with the given prefix (e.g. "wireshark").
|
|
|
|
+ * Create a tempfile with the given prefix (e.g. "wireshark"). The path
|
|
|
|
+ * is created using get_tmp_dir and mkdtemp
|
|
|
|
*
|
|
|
|
* @param namebuf If not NULL, receives the full path of the temp file.
|
|
|
|
* Should NOT be freed.
|
2017-06-29 08:53:33 +00:00
|
|
|
@@ -199,7 +200,7 @@ create_tempfile(char **namebuf, const char *pfx, const char *sfx)
|
2016-01-14 10:56:55 +00:00
|
|
|
tf[idx].path = (char *)g_malloc(tf[idx].len);
|
|
|
|
}
|
2014-08-07 14:35:19 +00:00
|
|
|
|
2016-01-14 10:56:55 +00:00
|
|
|
- tmp_dir = g_get_tmp_dir();
|
|
|
|
+ tmp_dir = get_tmp_dir();
|
2013-09-24 08:55:09 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2016-01-14 10:56:55 +00:00
|
|
|
_tzset();
|
|
|
|
diff --git a/wsutil/tempfile.h b/wsutil/tempfile.h
|
2016-06-14 20:33:08 +00:00
|
|
|
index 1dca2df..bb3160c 100644
|
2016-01-14 10:56:55 +00:00
|
|
|
--- a/wsutil/tempfile.h
|
|
|
|
+++ b/wsutil/tempfile.h
|
|
|
|
@@ -45,7 +45,7 @@ WS_DLL_PUBLIC char *get_tempfile_path(const char *filename);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a tempfile with the given prefix (e.g. "wireshark"). The path
|
|
|
|
- * is created using g_get_tmp_dir and mkstemp.
|
|
|
|
+ * is created using get_tmp_dir and mkstemp.
|
|
|
|
*
|
|
|
|
* @param namebuf [in,out] If not NULL, receives the full path of the temp file.
|
|
|
|
* Must NOT be freed.
|
2013-09-24 08:55:09 +00:00
|
|
|
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 <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';
|
|
|
|
+ }
|
|
|
|
+#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
|
2017-06-29 08:53:33 +00:00
|
|
|
index 0000000..07ac583
|
2013-09-24 08:55:09 +00:00
|
|
|
--- /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
|
|
|
|
+
|
2017-06-29 08:53:33 +00:00
|
|
|
+#endif
|
|
|
|
--
|
|
|
|
2.13.0
|
|
|
|
|