jeudi 4 février 2016

Can SQLite DB files be made read-only?

Information from an SQLite DB is presented to user through a web server (displayed in an HTML browser). The DB is loaded once for all by a small application independent from the web server. DB data cannot be changed from user browser (this is a read-only service).

As the web-server has its own user-id, it accesses the SQLite DB file with "other" permissions. For security reason, I would like to set the DB file permissions as rw-rw-r--.

Unfortunately, with this permission set, I get a warning attempt to write a readonly database at line xxx which points to a line about a SELECT transaction (which in principle is read-only). Of course, I get no result.

If permissions are changed to rw-rw-rw, everything works fine, but that means everybody can tamper with the DB.

Is there any reason why SQLite DB cannot be accessed read-only?

Are there "behind-the-scene" processings which need write access, even for SELECT transactions?

Look-up on StackExchange shows that people usually complain for the opposite situation: encountering a read-only access permission preventing writing to the DB. My goal is to protect my DB against ANY change attempt.

For the complete story, my web app is written in Perl and uses DBD::SQLite

Aucun commentaire:

Enregistrer un commentaire