Reputation: 1173
When using PDO sqlite PHP adapter, new sqlite database file is created with group permission set to read-only, and does not honor umask.
I need every database file to be writable by group. Any way to accomplish it?
Edit: I know how to change permissions of a file, I'm asking whether it is possible to create it with correct permissions (according to process umask) or not.
Upvotes: 3
Views: 2107
Reputation: 264
Before opening the database file using sqlite's connect call, you can open is as an ordinary file and the desired permissions. This will create an empty file unless the file is already present. Sqlite will fill that empty file with the database.
This is safer than using chmod
after the file has been created for two reasons:
chmod
chmod
on the main file would forget to set permissions for the other files.Upvotes: 1
Reputation: 1173
It looks like there's a SQLITE_DEFAULT_FILE_PERMISSIONS
compilation parameter.
It seems umask is applied on top of it to restrict it, if necessary.
So it makes sense to recompile with SQLITE_DEFAULT_FILE_PERMISSIONS=666
and than rely on umask. Too bad it's not a default option in sqlite.
Upvotes: 3