[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: [Bug 103331] Backup permissions higher than original permissions
From: Christoph Cullmann <cullmann () kde ! org>
Date: 2005-04-07 16:51:42
Message-ID: 20050407165142.5094.qmail () ktown ! kde ! org
[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=103331
cullmann kde org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
------- Additional Comments From cullmann kde org 2005-04-07 18:51 -------
CVS commit by cullmann:
security fix: use right permissions for the backup files
if the filepermissions of the original are not accessable, why ever, use 0600 as \
fallback
dominik: please test and backport
BUG:103331
M +31 -5 katedocument.cpp 1.818
--- kdelibs/kate/part/katedocument.cpp #1.817:1.818
@ -45,4 +45,6 @
#include <kio/job.h>
#include <kio/netaccess.h>
+#include <kio/kfileitem.h>
+
#include <kparts/event.h>
@ -2431,13 +2433,37 @ bool KateDocument::openFile(KIO::Job * j
bool KateDocument::save()
{
- // FIXME reorder for efficiency, prompt user in case of failure
bool l ( url().isLocalFile() );
- if ( ( ( l && config()->backupFlags() & KateDocumentConfig::LocalFiles ) ||
- ( ! l && config()->backupFlags() & KateDocumentConfig::RemoteFiles ) )
- && isModified() ) {
+
+ if ( ( l && config()->backupFlags() & KateDocumentConfig::LocalFiles )
+ || ( ! l && config()->backupFlags() & KateDocumentConfig::RemoteFiles ) )
+ {
KURL u( url() );
u.setFileName( config()->backupPrefix() + url().fileName() + \
config()->backupSuffix() );
- if ( ! KIO::NetAccess::upload( url().path(), u, kapp->mainWidget() ) )
+
+ kdDebug () << "backup src file name: " << url() << endl;
+ kdDebug () << "backup dst file name: " << u << endl;
+
+ // get the right permissions, start with safe default
+ mode_t perms = 0600;
+ KIO::UDSEntry fentry;
+ if (KIO::NetAccess::stat (url(), fentry, kapp->mainWidget()))
+ {
+ kdDebug () << "stating succesfull: " << url() << endl;
+ KFileItem item (fentry, url());
+ perms = item.permissions();
+ }
+
+ // first del existing file if any, than copy over the file we have
+ // failure if a: the existing file could not be deleted, b: the file could not \
be copied + if ( (!KIO::NetAccess::exists( u, false, kapp->mainWidget() ) || \
KIO::NetAccess::del( u, kapp->mainWidget() )) + && \
KIO::NetAccess::file_copy( url(), u, perms, true, false, kapp->mainWidget() ) ) + \
{ + kdDebug(13020)<<"backing up successfull ("<<url().prettyURL()<<" -> \
"<<u.prettyURL()<<")"<<endl; + }
+ else
+ {
kdDebug(13020)<<"backing up failed ("<<url().prettyURL()<<" -> \
"<<u.prettyURL()<<")"<<endl; + // FIXME: notify user for real ;)
+ }
}
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic