BZ #582781 Randomize name for files created in /tmp
This commit is contained in:
parent
d2f7f99207
commit
bcb3e86e31
|
@ -0,0 +1,80 @@
|
||||||
|
From 5aa2c8adfbe0ec3e5d802bfae8e5572562d911c7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Andrew Caudwell <acaudwell@gmail.com>
|
||||||
|
Date: Thu, 15 Apr 2010 23:26:19 +0000
|
||||||
|
Subject: [PATCH] Create temp file using mkstemp.
|
||||||
|
|
||||||
|
---
|
||||||
|
src/commitlog.cpp | 29 +++++++++++++++--------------
|
||||||
|
src/commitlog.h | 2 +-
|
||||||
|
2 files changed, 16 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/commitlog.cpp b/src/commitlog.cpp
|
||||||
|
index 689a100..87171d5 100644
|
||||||
|
--- a/src/commitlog.cpp
|
||||||
|
+++ b/src/commitlog.cpp
|
||||||
|
@@ -206,34 +206,35 @@ bool RCommitLog::isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
-std::string RCommitLog::createTempLog() {
|
||||||
|
- //create temp file
|
||||||
|
- char logfile_buff[1024];
|
||||||
|
+//create temp file
|
||||||
|
+void RCommitLog::createTempLog() {
|
||||||
|
+
|
||||||
|
+ std::string tempdir;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
DWORD tmplen = GetTempPath(0, "");
|
||||||
|
|
||||||
|
- if(tmplen == 0) return 0;
|
||||||
|
+ if(tmplen == 0) return;
|
||||||
|
|
||||||
|
std::vector<TCHAR> temp(tmplen+1);
|
||||||
|
|
||||||
|
tmplen = GetTempPath(static_cast<DWORD>(temp.size()), &temp[0]);
|
||||||
|
|
||||||
|
- if(tmplen == 0 || tmplen >= temp.size()) return 0;
|
||||||
|
-
|
||||||
|
- std::string temp_file_path(temp.begin(),
|
||||||
|
- temp.begin() + static_cast<std::size_t>(tmplen));
|
||||||
|
+ if(tmplen == 0 || tmplen >= temp.size()) return;
|
||||||
|
|
||||||
|
- temp_file_path += "gource.tmp";
|
||||||
|
+ std::string tempdir = std::string(temp.begin(), temp.begin() + static_cast<std::size_t>(tmplen));
|
||||||
|
+ tempdir += "\\";
|
||||||
|
|
||||||
|
- sprintf(logfile_buff, "%s", temp_file_path.c_str());
|
||||||
|
#else
|
||||||
|
- uid_t myuid = getuid();
|
||||||
|
- sprintf(logfile_buff, "/tmp/gource-%d.tmp", myuid);
|
||||||
|
+ tempdir = "/tmp/";
|
||||||
|
#endif
|
||||||
|
- temp_file = std::string(logfile_buff);
|
||||||
|
|
||||||
|
- return temp_file;
|
||||||
|
+ char tmplate[1024];
|
||||||
|
+ snprintf(tmplate, 1024, "%sgource-XXXXXX", tempdir.c_str());
|
||||||
|
+
|
||||||
|
+ if(mkstemp(tmplate) < 0) return;
|
||||||
|
+
|
||||||
|
+ temp_file = std::string(tmplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RCommitFile
|
||||||
|
diff --git a/src/commitlog.h b/src/commitlog.h
|
||||||
|
index 1867396..5ff8da2 100644
|
||||||
|
--- a/src/commitlog.h
|
||||||
|
+++ b/src/commitlog.h
|
||||||
|
@@ -77,7 +77,7 @@ protected:
|
||||||
|
|
||||||
|
bool checkFirstChar(int firstChar, std::istream& stream);
|
||||||
|
|
||||||
|
- std::string createTempLog();
|
||||||
|
+ void createTempLog();
|
||||||
|
|
||||||
|
bool getNextLine(std::string& line);
|
||||||
|
|
||||||
|
--
|
||||||
|
1.6.5
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Summary: Software version control visualization
|
Summary: Software version control visualization
|
||||||
Name: gource
|
Name: gource
|
||||||
Version: 0.24
|
Version: 0.24
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
URL: http://gource.googlecode.com/
|
URL: http://gource.googlecode.com/
|
||||||
Source: http://gource.googlecode.com/files/%{name}-%{version}.tar.gz
|
Source: http://gource.googlecode.com/files/%{name}-%{version}.tar.gz
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@ Requires: gnu-free-sans-fonts
|
||||||
# https://bugzilla.redhat.com/show_bug.cgi?id=567559
|
# https://bugzilla.redhat.com/show_bug.cgi?id=567559
|
||||||
Patch0: gource-ppm-software-flip.patch
|
Patch0: gource-ppm-software-flip.patch
|
||||||
|
|
||||||
|
# https://bugzilla.redhat.com/show_bug.cgi?id=582781
|
||||||
|
Patch1: gource-predictable-tmp-filename.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
|
|
||||||
OpenGL-based 3D visualisation tool for source control repositories.
|
OpenGL-based 3D visualisation tool for source control repositories.
|
||||||
|
@ -40,6 +43,7 @@ files and directories.
|
||||||
sed -i.cp -e 's|cp |cp -p |' Makefile.in
|
sed -i.cp -e 's|cp |cp -p |' Makefile.in
|
||||||
|
|
||||||
%patch0 -p1 -b .ppm-software-flip
|
%patch0 -p1 -b .ppm-software-flip
|
||||||
|
%patch1 -p1 -b .predictable-tmp-filename
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%configure --enable-ttf-font-dir=%{_datadir}/fonts/gnu-free/
|
%configure --enable-ttf-font-dir=%{_datadir}/fonts/gnu-free/
|
||||||
|
@ -64,6 +68,9 @@ rm -rf %{buildroot}
|
||||||
%{_datadir}/gource/*
|
%{_datadir}/gource/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Apr 16 2010 Siddhesh Poyarekar <spoyarek@redhat.com> - 0.24-3
|
||||||
|
- BZ #582781 Randomize name for files created in /tmp
|
||||||
|
|
||||||
* Sun Feb 28 2010 Siddhesh Poyarekar <spoyarek@redhat.com> - 0.24-2
|
* Sun Feb 28 2010 Siddhesh Poyarekar <spoyarek@redhat.com> - 0.24-2
|
||||||
- BZ #567559: Flip images in software for PPM output since hardware flipping
|
- BZ #567559: Flip images in software for PPM output since hardware flipping
|
||||||
fails on some video cards
|
fails on some video cards
|
||||||
|
|
Loading…
Reference in New Issue