Even if there were a simple way to protect an SQLite db file from being casually (or even maliciously) overwritten by a user (which there isn't), it is quite impossible to prevent a user with "root privileges" from accessing/altering/deleting/moving/renaming ANY file on any operating system (that is, after all, what root privileges are designed to do...).
SQLite is designed to work with multiple processes/threads on the same system accessing the same file on local storage. If you need to have a special version that only allows one thread of one process to open the file you can change the appropriate lines in the source code und build your own image. I would strongly recommend statically linking your "special" copy of SQLite with your application. -----Urspr?ngliche Nachricht----- Von: Fabian Pr?bstl [mailto:Fabian.Proebstl at nanotemper.de] Gesendet: Mittwoch, 08. April 2015 16:18 An: sqlite-users at mailinglists.sqlite.org Betreff: [sqlite] Prevent database file from being overwritten by other processes Hi there! Currently, we are using SQLite as our application file format for a Windows 7/C#/System.Data.SQLite based desktop application. We only allow one instance to open the file by running "set locking_mode=EXCLUSIVE;BEGIN EXCLUSIVE;COMMIT" when connecting to the database. This all works fine, however a user can still open Windows Explorer and copy paste a file with the same name but different content (e.g. an empty file) over an existing, exclusively locked database. From what I found out with the OpenedFilesView tool, SQLite seems to open the file with SHARED_WRITE, which explains why *any* process can overwrite the contents. Is there an easy way of configuring / changing this so that SHARED_WRITE is not acquired? Will SQLite even function? Is it just easier to create a hidden copy and work on that? Thanks for the advice Fabian _______________________________________________ sqlite-users mailing list sqlite-users at mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick Software Engineer Scientific Games International GmbH FN 157284 a, HG Wien Klitschgasse 2-4, A-1130 Vienna, Austria Tel: +43 1 80100 0 E-Mail: hick at scigames.at This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation.