From 6c7838ef3a5906c418f52207a794ed5653e53b14 Mon Sep 17 00:00:00 2001 From: yubiuser Date: Sun, 12 Sep 2021 20:08:48 +0200 Subject: [PATCH 1/4] Change database permission to 664 Signed-off-by: yubiuser --- src/database/common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/database/common.c b/src/database/common.c index f69f6747..39ef0d17 100644 --- a/src/database/common.c +++ b/src/database/common.c @@ -212,9 +212,9 @@ 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; + // 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); return true; From 8e363468b2abead19716e0d9f6675fb2d95f1a27 Mon Sep 17 00:00:00 2001 From: yubiuser Date: Mon, 13 Sep 2021 09:09:11 +0200 Subject: [PATCH 2/4] Set database permissions everytime the database is initialized Signed-off-by: yubiuser --- src/database/common.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/database/common.c b/src/database/common.c index 39ef0d17..711f660e 100644 --- a/src/database/common.c +++ b/src/database/common.c @@ -212,11 +212,6 @@ static bool db_create(void) // Close database handle dbclose(&db); - // 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); - return true; } @@ -261,6 +256,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); From 5248461b7bf1bd975580cd1297965f47c09723c7 Mon Sep 17 00:00:00 2001 From: yubiuser Date: Mon, 13 Sep 2021 09:27:04 +0200 Subject: [PATCH 3/4] Change test suite to reflect changed file permissions Signed-off-by: yubiuser --- test/test_suite.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_suite.bats b/test/test_suite.bats index 531a2bef..f1970f50 100644 --- a/test/test_suite.bats +++ b/test/test_suite.bats @@ -525,7 +525,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"* ]] @@ -1024,7 +1024,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 From 5bd6b0910af0e3d3da46f4e2654bc81696bdd856 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 23 Sep 2021 20:53:12 +0200 Subject: [PATCH 4/4] Fix indentation Signed-off-by: DL6ER --- src/database/common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/database/common.c b/src/database/common.c index 711f660e..c86e3b47 100644 --- a/src/database/common.c +++ b/src/database/common.c @@ -256,10 +256,10 @@ 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); + // 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);