File permissions not preserved with copy function?

This is a discussion on File permissions not preserved with copy function? within the PHP Language forums, part of the PHP Programming Forums category; Folks, Just noticed this with PHP 5 on RHEL 4 -- started using the copy function to move some files around ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-01-2008
John Murtari
 
Posts: n/a
Default File permissions not preserved with copy function?

Folks,

Just noticed this with PHP 5 on RHEL 4 -- started using
the copy function to move some files around and saw that
executable permissions were being lost? The documentation didn't
say anything about that? Is this a bug or a feature?

Thanks.
--
John
__________________________________________________ _________________
John Murtari Software Workshop Inc.
jmurtari@following domain 315.635-1968(x-211) "TheBook.Com" (TM)
http://thebook.com/
Reply With Quote
  #2 (permalink)  
Old 05-02-2008
Álvaro G. Vicario
 
Posts: n/a
Default Re: File permissions not preserved with copy function?

John Murtari escribió:
> Just noticed this with PHP 5 on RHEL 4 -- started using
> the copy function to move some files around and saw that
> executable permissions were being lost? The documentation didn't
> say anything about that? Is this a bug or a feature?


It sounds sensible. Copying means reading the original file, creating a
new file and dumping contents in the new file. Let's see an extreme example:

-rw-r--r-- root root /usr/share/foo/splash.png

Obviously, john should not be able to create a new file owned by root.
But he should be able to copy the file if he can read the source and has
permissions in the destination directory.

Check these functions:

umask()
stat()
chmod()
chown()
chgrp()


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Reply With Quote
  #3 (permalink)  
Old 05-02-2008
Gordon
 
Posts: n/a
Default Re: File permissions not preserved with copy function?

On May 1, 5:43 pm, John Murtari <jmurt...@thebook.com> wrote:
> Folks,
>
> Just noticed this with PHP 5 on RHEL 4 -- started using
> the copy function to move some files around and saw that
> executable permissions were being lost? The documentation didn't
> say anything about that? Is this a bug or a feature?
>
> Thanks.
> --
> John
> __________________________________________________ _________________
> John Murtari Software Workshop Inc.
> jmurtari@following domain 315.635-1968(x-211) "TheBook.Com" (TM)http://thebook.com/


I would think that it's probably a feature, a copy is basically
creating a new file using the contents of the old as contents. If
user B copied a file owned by user A but which he had permission to
read, then if permissions were copied then the result would be another
file owned by user A. User B may have made a copy of the file
belonging to user A in order to make his own modified version, so if
the permissions were identical then he wouldn't be able to edit his
copy either.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:10 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0