php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34868 sqlite_open() fails if directory along path misses read flag
Submitted: 2005-10-14 10:15 UTC Modified: 2005-10-19 00:48 UTC
From: Bjorn dot Wiberg at its dot uu dot se Assigned:
Status: Not a bug Package: SQLite related
PHP Version: 5.1.0RC1 OS: AIX 5.2 ML5
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Bjorn dot Wiberg at its dot uu dot se
New email:
PHP Version: OS:

 

 [2005-10-14 10:15 UTC] Bjorn dot Wiberg at its dot uu dot se
Description:
------------
If the path to the database to be created or opened does not have "read" (directory listing) rights all the way, sqlite_open() fails.

Presumably because of getcwd() usage.


If one specifies the full path to the database file to be opened or created, everything appears to work just fine.

Similarly, if one makes sure that "read" rights are present all the way, everything appears to work just fine as well.


I do not know if this is specific to PHP+sqlite or to SQLite itself.

I'm using the bundled SQLite (automatically detected during ./configure).

Reproduce code:
---------------
<?php
  if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) {
  //if ($db = sqlite_open('./mysqlitedb', 0666, $sqliteerror)) {
  //if ($db = sqlite_open(dirname(__FILE__) . '/mysqlitedb', 0666, $sqliteerror)) {
     sqlite_query($db, 'CREATE TABLE foo (bar varchar(10))');
     sqlite_query($db, "INSERT INTO foo VALUES ('fnord')");
     $result = sqlite_query($db, 'select bar from foo');
     var_dump(sqlite_fetch_array($result));
  } else {
    die($sqliteerror);
  }
?>


Expected result:
----------------
Successful creation of the database in all cases:

array(2) { [0]=>  string(5) "fnord" ["bar"]=>  string(5) "fnord" }


Actual result:
--------------
CASE 1 (open "mysqldb"):

Warning: sqlite_open(): unable to open database: mysqlitedb in /apache/htdocs/bwiberg/test/sqlite/sqlite.php on line 2 unable to open database: mysqlitedb

CASE 2 (open "./mysqldb"):

Warning: sqlite_open(): unable to open database: ./mysqlitedb in /apache/htdocs/bwiberg/test/sqlite/sqlite.php on line 3 unable to open database: ./mysqlitedb

CASE 3 (open with full path):

array(2) { [0]=>  string(5) "fnord" ["bar"]=>  string(5) "fnord" } 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-14 13:13 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


>"read" (directory listing)
So is it "r" (read) or "x" (directory listing)? Or both?
 [2005-10-14 15:55 UTC] Bjorn dot Wiberg at its dot uu dot se
Hello Tony!

Thanks for your reply!

The permission missing is "r" (allowing directory listings), which needs to be present all the way.

Has something changed in the CVS recently (e.g., today) pertaining to this issue? I have tried it on 5.1.0RC1.

The reason why I'm asking is that compilation, dependency checking etc. takes several hours on this machine, and has to be introduced into a production environment, so unless the PHP code for the SQLite extension has actually changed since 5.1.0RC1 (e.g. a synchronization of the code with the upstream provider, i.e., the SQLite developers), I'd like to avoid recompiles as much as possible.

Eagerly awaiting your reply, and wishing you a nice weekend!

Best regards,
Bj?rn
 [2005-10-19 00:48 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The opening of the sqlite database is something done by the sqlite library itself. If there is a bug, I'm afraid it is in the library itself and you should contact its developers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC