2008-04-04 14:04:32 +00:00
|
|
|
Index: kdelibs/kdecore/kernel/kglobal.cpp
|
|
|
|
===================================================================
|
|
|
|
--- kdelibs/kdecore/kernel/kglobal.cpp (Revision 791351)
|
|
|
|
+++ kdelibs/kdecore/kernel/kglobal.cpp (Revision 791352)
|
2008-04-04 12:13:52 +00:00
|
|
|
@@ -28,6 +28,12 @@
|
|
|
|
#include "kglobal.h"
|
|
|
|
#include "kglobal_p.h"
|
|
|
|
|
|
|
|
+#include <config.h>
|
|
|
|
+
|
|
|
|
+#ifdef HAVE_SYS_STAT_H
|
|
|
|
+#include <sys/stat.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#include <QtCore/QList>
|
|
|
|
#include <QtCore/QSet>
|
|
|
|
|
2008-04-04 14:04:32 +00:00
|
|
|
@@ -64,6 +70,10 @@
|
2008-04-04 12:13:52 +00:00
|
|
|
locale(0),
|
|
|
|
charsets(0)
|
|
|
|
{
|
|
|
|
+ // the umask is read here before any threads are created to avoid race conditions
|
|
|
|
+ mode_t tmp = 0;
|
2008-04-04 14:04:32 +00:00
|
|
|
+ umsk = umask(tmp);
|
|
|
|
+ umask(umsk);
|
2008-04-04 12:13:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline ~KGlobalPrivate()
|
2008-04-04 14:04:32 +00:00
|
|
|
@@ -81,6 +91,7 @@
|
|
|
|
KStringDict *stringDict;
|
|
|
|
KLocale *locale;
|
|
|
|
KCharsets *charsets;
|
|
|
|
+ mode_t umsk;
|
|
|
|
};
|
|
|
|
|
|
|
|
K_GLOBAL_STATIC(KGlobalPrivate, globalData)
|
|
|
|
@@ -151,6 +162,12 @@
|
2008-04-04 12:13:52 +00:00
|
|
|
return d->charsets;
|
|
|
|
}
|
|
|
|
|
|
|
|
+mode_t KGlobal::umask()
|
|
|
|
+{
|
2008-04-04 14:04:32 +00:00
|
|
|
+ PRIVATE_DATA;
|
|
|
|
+ return d->umsk;
|
2008-04-04 12:13:52 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
KComponentData KGlobal::activeComponent()
|
|
|
|
{
|
|
|
|
PRIVATE_DATA;
|
2008-04-04 14:04:32 +00:00
|
|
|
Index: kdelibs/kdecore/kernel/kglobal.h
|
|
|
|
===================================================================
|
|
|
|
--- kdelibs/kdecore/kernel/kglobal.h (Revision 791351)
|
|
|
|
+++ kdelibs/kdecore/kernel/kglobal.h (Revision 791352)
|
|
|
|
@@ -21,7 +21,9 @@
|
2008-04-04 13:23:32 +00:00
|
|
|
|
|
|
|
#include <kdecore_export.h>
|
|
|
|
#include <QtCore/QAtomicPointer>
|
|
|
|
+#include <sys/types.h>
|
2008-04-04 14:04:32 +00:00
|
|
|
|
|
|
|
+
|
2008-04-04 13:23:32 +00:00
|
|
|
//
|
|
|
|
// WARNING!!
|
|
|
|
// This code uses undocumented Qt API
|
2008-04-04 14:04:32 +00:00
|
|
|
@@ -354,6 +356,12 @@
|
2008-04-04 13:23:32 +00:00
|
|
|
KDECORE_EXPORT KCharsets *charsets();
|
|
|
|
|
|
|
|
/**
|
|
|
|
+ * Returns the umask of the process.
|
|
|
|
+ * @return the umask of the process
|
|
|
|
+ */
|
|
|
|
+ KDECORE_EXPORT mode_t umask();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
* Creates a static QString.
|
|
|
|
*
|
|
|
|
* To be used inside functions(!) like:
|
2008-04-04 14:04:32 +00:00
|
|
|
Index: kdelibs/kdecore/io/ksavefile.cpp
|
|
|
|
===================================================================
|
|
|
|
--- kdelibs/kdecore/io/ksavefile.cpp (Revision 791351)
|
|
|
|
+++ kdelibs/kdecore/io/ksavefile.cpp (Revision 791352)
|
|
|
|
@@ -119,6 +119,10 @@
|
|
|
|
if (!fchown(tempFile.handle(), fi.ownerId(), fi.groupId()))
|
|
|
|
tempFile.setPermissions(fi.permissions());
|
|
|
|
}
|
|
|
|
+ else {
|
|
|
|
+ mode_t umsk = KGlobal::umask();
|
|
|
|
+ fchmod(tempFile.handle(), 0666&(~umsk));
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//Open oursleves with the temporary file
|
|
|
|
QFile::setFileName(tempFile.fileName());
|
|
|
|
Index: kdelibs/kdecore/io/ktempdir.cpp
|
|
|
|
===================================================================
|
|
|
|
--- kdelibs/kdecore/io/ktempdir.cpp (Revision 791351)
|
|
|
|
+++ kdelibs/kdecore/io/ktempdir.cpp (Revision 791352)
|
|
|
|
@@ -94,9 +94,7 @@
|
|
|
|
d->tmpName = QFile::decodeName(realNameStr)+'/';
|
|
|
|
kDebug(180) << "KTempDir: Temporary directory created :" << d->tmpName
|
|
|
|
<< endl;
|
|
|
|
- mode_t tmp = 0;
|
|
|
|
- mode_t umsk = umask(tmp);
|
|
|
|
- umask(umsk);
|
|
|
|
+ mode_t umsk = KGlobal::umask();
|
|
|
|
chmod(nme, mode&(~umsk));
|
|
|
|
|
|
|
|
// Success!
|
|
|
|
Index: kdelibs/kdecore/kernel/kglobal.cpp
|
|
|
|
===================================================================
|
|
|
|
--- kdelibs/kdecore/kernel/kglobal.cpp (Revision 793503)
|
|
|
|
+++ kdelibs/kdecore/kernel/kglobal.cpp (Revision 793504)
|
|
|
|
@@ -46,6 +46,7 @@
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
#include <QtCore/QTextCodec>
|
|
|
|
#include "kcmdlineargs.h"
|
|
|
|
+#include <unistd.h> // umask
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
#define MYASSERT(x) if (!x) \
|
|
|
|
@@ -61,6 +62,7 @@
|
|
|
|
Q_CONSTRUCTOR_FUNCTION(qrand)
|
|
|
|
|
|
|
|
typedef QSet<QString> KStringDict;
|
|
|
|
+mode_t s_umsk;
|
|
|
|
|
|
|
|
class KGlobalPrivate
|
|
|
|
{
|
|
|
|
@@ -72,8 +74,8 @@
|
|
|
|
{
|
|
|
|
// the umask is read here before any threads are created to avoid race conditions
|
|
|
|
mode_t tmp = 0;
|
|
|
|
- umsk = umask(tmp);
|
|
|
|
- umask(umsk);
|
|
|
|
+ s_umsk = umask(tmp);
|
|
|
|
+ umask(s_umsk);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ~KGlobalPrivate()
|
|
|
|
@@ -91,7 +93,6 @@
|
|
|
|
KStringDict *stringDict;
|
|
|
|
KLocale *locale;
|
|
|
|
KCharsets *charsets;
|
|
|
|
- mode_t umsk;
|
|
|
|
};
|
|
|
|
|
|
|
|
K_GLOBAL_STATIC(KGlobalPrivate, globalData)
|
|
|
|
@@ -164,8 +165,8 @@
|
|
|
|
|
|
|
|
mode_t KGlobal::umask()
|
|
|
|
{
|
|
|
|
- PRIVATE_DATA;
|
|
|
|
- return d->umsk;
|
|
|
|
+ // Don't use PRIVATE_DATA here. This is called by ~KGlobalPrivate -> ~KConfig -> sync -> KSaveFile, so there's no KGlobalPrivate anymore.
|
|
|
|
+ return s_umsk;
|
|
|
|
}
|
|
|
|
|
|
|
|
KComponentData KGlobal::activeComponent()
|