Pregunta

I've designed a Python script that creates a SQLite database and needs to store it somewhere. This script has no need in escalated privileges, however, it needs to store its data somewhere so that it is accessible to all the users because the data is user-independent (but can be changed by every user). /var/lib doesn't do because it's owned by root and an ordinary user cannot create or put something in there. /usr/share, as I know, is designed to store data that doesn't change. So - what do I choose?

¿Fue útil?

Solución

A user with escalated privileges can create the database in a privileged location, and then set the file permissions to the database to something less restrictive. For instance:

sudo touch /var/lib/my_shared_db.sqlite3
sudo chmod 666 /var/lib/my_shared_db.sqlite3

After this any user will be able to write to /var/lib/my_shared_db.sqlite3. (Note: it's probably better to create a directory in /var/lib named after your script and then put the db file(s) in it.)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top