#36868 [NEW]: fopen does not set errno for posix_get_last_error
| From: | dgatwood at mac dot com | Date: | Mon, 27 Mar 2006 04:25:55 +0000 |
| Subject: | #36868 [NEW]: fopen does not set errno for posix_get_last_error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-94911@lists.php.net to get a copy of this message | ||
From: dgatwood at mac dot com
Operating system: Mac OS X
PHP version: 5.1.2
PHP Bug Type: POSIX related
Bug description: fopen does not set errno for posix_get_last_error
Description:
------------
On Mac OS X, when fopen() fails with a permission denied
error, the result of a subsequent posix_get_last_error()
call is zero (0). I would expect this to be set to the
value of errno returned by the underlying open or fopen
call.
I would also expect this to work for put_file_contents, but
also get a rather useless zero when calling
posix_get_last_error() after that fails. However, since
that isn't a POSIX function, I can accept that it wouldn't
behave in this way... but fopen is a standard POSIX
function, and should be setting errno.
Currently, it appears that without explicitly doing a stat
on the directory, it is impossible to distinguish a
permissions problem from some other error return (e.g. file
exists, I/O error, etc.).
Reproduce code:
---------------
$fp = fopen("/unwritabledirectory/filename", "w");
if (!$fp) {
print "Error was: ".posix_get_last_error().".\n";
}
Expected result:
----------------
I would expect the fopen to fail with a permission denied
error, errno to be set appropriately, and posix_get_last_error
() to fetch that value.
Actual result:
--------------
Error is always zero (0).
--
Edit bug report at http://bugs.php.net/?id=36868&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36868&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36868&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36868&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36868&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=36868&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36868&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36868&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36868&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36868&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36868&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=36868&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=36868&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36868&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36868&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36868&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36868&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36868&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36868&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36868&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36868&r=mysqlcfg