core: Change permissions of diary.db to 0600

Add chmod() calls at various places in the StorageManager and import and
export code to change the permissions of files containing diary entries
(including the database, the encrypted database, database backups and
different formats of exported files) to be 0600.