diff --git a/src/database/common.c b/src/database/common.c index 47e5628f..e7c075ca 100644 --- a/src/database/common.c +++ b/src/database/common.c @@ -228,11 +228,6 @@ static bool db_create(void) // Close database handle dbclose(&db); - // Explicitly set permissions to 0644 - // 644 = u+w u+r g+r o+r - const mode_t mode = S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH; - chmod_file(FTLfiles.FTL_db, mode); - return true; } @@ -277,6 +272,11 @@ void db_init(void) } } + // Explicitly set permissions to 0664 + // 664 = u+w u+r g+w g+r o+r + const mode_t mode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IROTH; + chmod_file(FTLfiles.FTL_db, mode); + // Open database sqlite3 *db = dbopen(false); diff --git a/test/test_suite.bats b/test/test_suite.bats index 25463368..d446e757 100644 --- a/test/test_suite.bats +++ b/test/test_suite.bats @@ -535,7 +535,7 @@ printf "%s\n" "${lines[@]}" # Depending on the shell (x86_64-musl is built on busybox) there can be one or multiple spaces between user and group [[ ${lines[0]} == *"pihole"?*"pihole"* ]] - [[ ${lines[0]} == "-rw-r--r--"* ]] + [[ ${lines[0]} == "-rw-rw-r--"* ]] run bash -c 'file /etc/pihole/pihole-FTL.db' printf "%s\n" "${lines[@]}" [[ ${lines[0]} == "/etc/pihole/pihole-FTL.db: SQLite 3.x database"* ]] @@ -1034,7 +1034,7 @@ run bash -c 'ls -l /etc/pihole/pihole-FTL.db' printf "%s\n" "${lines[@]}" [[ ${lines[0]} == *"pihole pihole"* || ${lines[0]} == *"pihole pihole"* ]] - [[ ${lines[0]} == "-rw-r--r--"* ]] + [[ ${lines[0]} == "-rw-rw-r--"* ]] } # "ldd" prints library dependencies and the used interpreter for a given program