You are here: Re: Can't chown() "my" files... « PHP Programming Language « IT news, forums, messages
Re: Can't chown() "my" files...

Posted by Joel Fireman on 12/05/07 05:06

On Tue, 04 Dec 2007 23:47:52 +0000, The Natural Philosopher <a@b.c>
wrote:

>Joel Fireman wrote:
>> On Tue, 04 Dec 2007 23:22:24 +0100, Michael Fesser <netizen@gmx.de>
>> wrote:
>>
>>> .oO(Joel Fireman)
>>>
>>>> On a Linux server, a web page lets users enter items to an order
>>>> sheet. When they finish, (besides the mysql db updates) the order data
>>>> is emailed to the user as confirmation, a copy is emailed to the
>>>> fulfillment people, and two files are written for pickup by a third
>>>> party, in the third party's directory.
>>>>
>>>> Because the files are owned by apache, the third party cannot delete
>>>> them, even when they are chmod'ed to 777. I tried to chown() the files
>>>> to the third party's user, but no go.
>>> The third party also needs write access to the directory where the files
>>> are stored.
>>>
>>> Micha
>>
>> Shazam!! Somewhere in the midst of flailing on this I had root owning
>> the 3rd party's dir... hmmmpff...
>>
>> Well, at least he can delete the files after he reads them, now... and
>> that's all we really care about in this case.
>>
>> But, if apache owns the file, how come he can't chown() it?
>>
>apache can chown it.

Not so far... here's the code:

//...
// 1. the csv for importing into the Office db
$filename = $writeorderfile.$mcnum.'.csv';
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $outcsv) === FALSE) {
echo "Cannot write CSV data to file ($filename)";
exit;
}
fclose($handle);
if (chown($filename,"orders")) {
echo "chowned() $filename";
}
else
{
echo "Couldn't chown $filename\n\n";
}

if ( chmod($filename,octdec("777"))) {
echo "chmodded() $filename";
}
else
{
echo "Couldn't chmod $filename\n\n";
}

The chmod works, the chown doesn't.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация