Hello
Attached a patch for configuring umask in FileAppenders...
It's based on an SVN version and not on the latest PHP5 branch.
Haven't tested what Windows says to umask() but it should at least
be a no-op there as the PHP docs do not explicitly say "only for unix".
bye,
-christian-
diff -Nur /tmp/log4php-0.9.svn20070710/log4php/appenders/LoggerAppenderFile.php log4php/appenders/LoggerAppenderFile.php
--- /tmp/log4php-0.9.svn20070710/log4php/appenders/LoggerAppenderFile.php 2007-07-10 11:21:09.000000000 +0200
+++ log4php/appenders/LoggerAppenderFile.php 2007-07-24 11:45:23.000000000 +0200
@@ -54,6 +54,11 @@
var $requiresLayout = true;
/**
+ * @var int the umask to use for creating logfiles
+ */
+ private $umask;
+
+ /**
* Constructor.
*
* @param string $name appender name
@@ -61,13 +66,17 @@
function LoggerAppenderFile($name)
{
$this->LoggerAppenderSkeleton($name);
+ $this->setUMask(umask());
}
function activateOptions()
{
$fileName = $this->getFile();
- LoggerLog::debug("LoggerAppenderFile::activateOptions() opening file '{$fileName}'");
+ $umask = $this->getUMask();
+ LoggerLog::debug("LoggerAppenderFile::activateOptions() opening file '{$fileName}' using '{$umask}'");
+ $old_umask = umask($umask);
$this->fp = @fopen($fileName, ($this->getAppend()? 'a':'w'));
+ umask($old_umask);
if ($this->fp) {
if ($this->getAppend())
fseek($this->fp, 0, SEEK_END);
@@ -119,6 +128,14 @@
{
return $this->fileName;
}
+
+ /**
+ * @return int
+ */
+ function getUMask()
+ {
+ return $this->umask;
+ }
/**
* Close any previously opened file and call the parent's reset.
@@ -160,6 +177,13 @@
$this->fileName = $fileName;
}
+ /** Controls Logfile permissions
+ */
+ function setUMask($umask)
+ {
+ $this->umask = ($umask & 0777);
+ }
+
function append($event)
{
if ($this->fp and $this->layout !== null) {
@@ -170,4 +194,4 @@
}
}
}
-?>
\ No newline at end of file
+?>