[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    [Bug 54459] Security: backup files get different permissions
From:       David Faure <faure () kde ! org>
Date:       2003-04-11 9:22:25
[Download RAW message or body]

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
     
http://bugs.kde.org/show_bug.cgi?id=54459     
faure@kde.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From faure@kde.org  2003-04-11 11:22 -------
Subject: koffice/lib/kofficecore

CVS commit by faure: 

Preserve permissions when creating backup file (only for local files currently)
CCMAIL: 54459-done@bugs.kde.org


  M +17 -9     koDocument.cc   1.268


--- koffice/lib/kofficecore/koDocument.cc  #1.267:1.268
@@ -53,4 +53,5 @@
 #include <qimage.h>
 #include <kiconloader.h>
+#include <kfileitem.h>
 #include <qdir.h>
 #include <qfileinfo.h>
@@ -298,14 +299,21 @@ bool KoDocument::saveFile()
     QApplication::setOverrideCursor( waitCursor );
 
-    if ( KIO::NetAccess::exists( url() ) ) { // this file exists => backup
+    if ( backupFile() ) {
+        KIO::UDSEntry entry;
+        if ( KIO::NetAccess::stat( url(), entry ) ) { // this file exists => backup
+            KFileItem item( entry, url() );
+            Q_ASSERT( item.name() == url().fileName() );
         KURL backup;
         if ( d->m_backupPath.isEmpty())
-            backup= url();
+                backup = url();
         else
             backup = d->m_backupPath +"/"+url().fileName();
         backup.setPath( backup.path() + QString::fromLatin1("~") );
-        if ( backupFile() ) {
             KIO::NetAccess::del( backup ); // Copy does not remove existing destination file
             KIO::NetAccess::copy( url(), backup );
+            // Not network transparent. TODO: use NetAccess::file_copy once KDE-3.2 is required,
+            // or implement KIO::NetAccess::chmod (or fire an async ChmodJob?).
+            if ( backup.isLocalFile() )
+                ::chmod( QFile::encodeName( backup.path() ), item.permissions() );
         }
     }
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic