File::Passwd patch
| From: | Yavor Shahpasov | Date: | Wed, 11 Dec 2002 11:59:32 +0000 |
| Subject: | File::Passwd patch | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-11552@lists.php.net to get a copy of this message | ||
It seems that the File::Passwd has a problem.
There are two files a passwd file and a lock file. when the class starts the
lock file is locked using flock($file, LOCK_EX). when you add a user the
data is added to the lock file and the lock file is renamed to the original
file. When this happens the file is still locked an I get an access denied
error. I have a small patch that fixes this by moving the rename after the
flock($file, LOCK_UN) which unlocks the file which seems to work. I assume
this is ok since the file is locked on add and unlocked on close.
Yavor
--- Passwd.php Wed Dec 11 13:52:53 2002
+++ /usr/share/pear/File/Passwd.php Wed Dec 11 13:54:52 2002
@@ -211,10 +211,10 @@
fputs($this->fplock, "$user:$pass\n");
}
}
+ rename($this->lockfile, $this->filename);
flock($this->fplock, LOCK_UN);
$this->locked = false;
fclose($this->fplock);
- rename($this->lockfile, $this->filename);
}
} // end func close()