Permissions when using file_move
David Faure
david at mandrakesoft.com
Mon Dec 9 10:05:53 GMT 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 09 December 2002 10:01, Andras Mantia wrote:
> On 2002. December 08., Sunday 23:29, David Faure wrote:
> [..]
> > Don't chmod an existing file in put()
> >
> > Ouch. Not sure anymore why I did that change (>1 year ago).
> > Can't make up my mind on this. Anyone ? :)
>
> No idea, but if I specify the premission that I give, it should be used, am I
> right? :-) If I want to get a file with the same attrs as src, I just put -1
> as permissions. At least this was my understanding.
Wrong - if you want to get the same attributes as the source, you need to
pass those attributes (how will put() guess them if you pass -1 to it ???).
This is KIO::put(), not copy(), it doesn't know the source file.
- -1 means "use default permissions, those coming from the umask".
Permissions != -1 are usually those of the source file (e.g. when put()
is called by FileCopyJob, called by CopyJob::copyNextFile).
The analogy with command-line tools isn't as easy as looking at "cp -a" BTW.
If you _edit_ an existing file (even as another user), it never changes its permissions.
Isn't resuming a download in this case too? IMHO it shouldn't chmod the target.
Maybe this is what the fix was about - not applying the permissions when resuming.
Which still means they should be honoured when completely _overwriting_
the destination file. This would also be consistent with the KDE_open code above.
Which leads to this patch instead:
Index: file.cc
===================================================================
RCS file: /home/kde/kdelibs/kioslave/file/file.cc,v
retrieving revision 1.128
diff -u -p -r1.128 file.cc
- --- file.cc 2 Dec 2002 11:48:35 -0000 1.128
+++ file.cc 9 Dec 2002 10:05:24 -0000
@@ -396,8 +396,8 @@ void FileProtocol::put( const KURL& url,
}
}
- - // set final permissions, if the file was just created
- - if ( _mode != -1 && !orig_exists )
+ // set final permissions
+ if ( _mode != -1 && !_resume )
{
if (::chmod(_dest_orig.data(), _mode) != 0)
{
- --
David FAURE, david at mandrakesoft.com, faure at kde.org
http://people.mandrakesoft.com/~david/
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
Get the latest KOffice - http://download.kde.org/stable/koffice-1.2/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE99GsC72KcVAmwbhARAu4rAJsG4MApsBF6TOS36aneUIzb12HgnwCgmHPS
BXoo475fh6cZFAyHwoRGuyc=
=6XrA
-----END PGP SIGNATURE-----
More information about the kde-core-devel
mailing list