mkstemp is the right function to use to make temporary files. But always call umask
From: Erik Hovland <erik@hovland.org>
before calling it to make sure that no strange permissions get applied to the file.
---
programs/mythfilldatabase/filldata.cpp | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/programs/mythfilldatabase/filldata.cpp b/programs/mythfilldatabase/filldata.cpp
index 3904a12..964ac6e 100644
a
|
b
|
|
1 | 1 | // POSIX headers |
2 | 2 | #include <unistd.h> |
3 | 3 | #include <signal.h> |
| 4 | #include <sys/types.h> |
| 5 | #include <sys/stat.h> |
4 | 6 | |
5 | 7 | // Std C headers |
6 | 8 | #include <cstdlib> |
… |
… |
bool FillData::grabData(Source source, int offset, QDate *qCurrentDate) |
306 | 308 | if (GetTempFileNameA("%TEMP%", "mth", 0, tempfilename) == 0) |
307 | 309 | #else |
308 | 310 | char tempfilename[] = "/tmp/mythXXXXXX"; |
309 | | if (mkstemp(tempfilename) == -1) |
| 311 | mode_t cur_umask = umask(S_IRWXO | S_IRWXG); |
| 312 | int ret = mkstemp(tempfilename); |
| 313 | umask(cur_umask); |
| 314 | if (ret == -1) |
310 | 315 | #endif |
311 | 316 | { |
312 | 317 | VERBOSE(VB_IMPORTANT, |