mymedia
mymedia

Reputation: 617

How do I grant other users permission to write to SQLite database?

I faced a strange error related to permissions for a SQLite database.

I type in bash

rm -f test.db
sqlite3 test.db 'CREATE TABLE t (qwe, qqq)'
chmod 666 test.db
sudo -u another-user sqlite3 test.db 'INSERT INTO t VALUES (4, 2)'

It prints

Error: unable to open database file

It prints the same if I change an owner of test.db file to another-user. But if I try to insert the record on behalf of root or me, there is no any error, and it's inserted successfully.

What's the troubles?

An output of getfacl test.db is the following

# file: test.db
# owner: mymedia
# group: mymedia
user::rw-
group::rw-
other::rw-

AppArmor has no profiles related to SQLite, SeLinux is disabled. I was experimenting on Ubuntu 16.04. The version of SQLite is 3.11.0.

Upvotes: 0

Views: 7310

Answers (1)

Michael
Michael

Reputation: 5335

Here the problem seems to be not with file permissions, but with directory. Check if a directory where your database file is placed has proper permissions for another-user.

Upvotes: 1

Related Questions