Home » Logging » Log » Bug #4114
mkpath ignores filemode for createing directories
Details
| Submitted | 2005-04-11 11:24 UTC |
|---|---|
| From | matthias dot mueller at spot-media dot de |
| Assigned | jon |
| Status | Closed |
| Package | Log |
| PHP Version | 4.3.11 |
| OS | Linux Debian |
| Roadmaps | (Not assigned) |
Comments
[2005-04-11 11:24 UTC] matthias dot mueller at spot-media dot de
Description:
------------
Version 1.8.7
File: Log/file.php
Line : 198
By storing logfile in separate folders that doesen't exist pear generates this by using _mkpath: $this->_mkpath($this->_filename);
The function open ignores the filemode from $this->_mode, so the new folder will be generated with the defauld mode "0700".
Reproduce code:
---------------
Version 1.8.7
File: Log/file.php
Line : 198
$this->_mkpath($this->_filename); =>
$this->_mkpath($this->_filename , $this->_mode);
[2005-04-26 09:11 UTC] matthias dot mueller at spot-media dot de
function open()
{
if (!$this->_opened) {
umask(0002);
// If the log file's directory doesn't exist, create it.
if (!is_dir(dirname($this->_filename))) {
$this->_mkpath($this->_filename, $this->_mode);
}
// set flag for new file
if (!is_file($this->_filename)){
$blnNewFile=true;
}
// Obtain a handle to the log file.
$this->_fp = @fopen($this->_filename, ($this->_append) ? 'a' : 'w');
$this->_opened = ($this->_fp !== false);
// Attempt to set the log file's mode.
if ($blnNewFile){
umask(0002);
@chmod($this->_filename, $this->_mode);
}
}
return $this->_opened;
}
[2005-04-26 09:17 UTC] matthias dot mueller at spot-media dot de
Sorry I forgot the Text the function:
I think your second way is good enough!
But anyhow, why I posted our open our used function because we still have some more user-right problems by using open.
In our system two different users write to the same logfile. So when the second user tries to chmod the logfile (line 207) we get conflicts. The '@' at the beginning of the function chmod will be ignored.
What do You thing about the modification?