kdelibs/kdelibs-4.0.3-kconfig_sync_...

157 lines
4.1 KiB
Diff

Index: kdelibs/kdecore/kernel/kglobal.cpp
===================================================================
--- kdelibs/kdecore/kernel/kglobal.cpp (Revision 791351)
+++ kdelibs/kdecore/kernel/kglobal.cpp (Revision 791352)
@@ -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>
@@ -64,6 +70,10 @@
locale(0),
charsets(0)
{
+ // the umask is read here before any threads are created to avoid race conditions
+ mode_t tmp = 0;
+ umsk = umask(tmp);
+ umask(umsk);
}
inline ~KGlobalPrivate()
@@ -81,6 +91,7 @@
KStringDict *stringDict;
KLocale *locale;
KCharsets *charsets;
+ mode_t umsk;
};
K_GLOBAL_STATIC(KGlobalPrivate, globalData)
@@ -151,6 +162,12 @@
return d->charsets;
}
+mode_t KGlobal::umask()
+{
+ PRIVATE_DATA;
+ return d->umsk;
+}
+
KComponentData KGlobal::activeComponent()
{
PRIVATE_DATA;
Index: kdelibs/kdecore/kernel/kglobal.h
===================================================================
--- kdelibs/kdecore/kernel/kglobal.h (Revision 791351)
+++ kdelibs/kdecore/kernel/kglobal.h (Revision 791352)
@@ -21,7 +21,9 @@
#include <kdecore_export.h>
#include <QtCore/QAtomicPointer>
+#include <sys/types.h>
+
//
// WARNING!!
// This code uses undocumented Qt API
@@ -354,6 +356,12 @@
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:
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()