Skip to content

Commit 71b6fc6

Browse files
authored
Merge pull request #2825 from pi-hole/development
Pi-hole FTL v6.6
2 parents a77c54c + 3486470 commit 71b6fc6

45 files changed

Lines changed: 932 additions & 358 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ jobs:
104104
# QEMU should come before Buildx
105105
-
106106
name: Set up QEMU
107-
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 #v3.7.0
107+
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a #v4.0.0
108108
-
109109
name: Set up Docker Buildx
110-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f #v3.12.0
110+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd #v4.0.0
111111
-
112112
name: Print directory contents
113113
shell: bash
114114
run: ls -l
115115
-
116116
name: Build FTL in ftl-build container (QEMU)
117117
# Creates an image to build FTL and load it into the local Docker daemon
118-
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
118+
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 #v4.0.0
119119
with:
120120
max_attempts: 3
121121
timeout_minutes: 15
@@ -134,7 +134,7 @@ jobs:
134134
name: Test FTL in ftl-build container (QEMU)
135135
# Uses the ftl-builder image to run tests
136136
# set STATIC to true for all except clang builds as we do in build.sh
137-
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
137+
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 #v4.0.0
138138
with:
139139
max_attempts: 3
140140
timeout_minutes: 10
@@ -169,13 +169,13 @@ jobs:
169169
sha1sum pihole-FTL-* > ${{ matrix.bin_name }}.sha1
170170
-
171171
name: Upload pihole-FTL binary
172-
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f #v6.0.0
172+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
173173
with:
174174
name: ${{ matrix.bin_name }}-binary
175175
path: '${{ matrix.bin_name }}*'
176176
-
177177
name: Generate artifact attestation
178-
uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f #v3.2.0
178+
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 #v4.1.0
179179
# Skip attestation if ACTIONS_ID_TOKEN_REQUEST_URL env variable is not
180180
# available (e.g., PR originating from a fork)
181181
if: env.DO_DEPLOY == 'true' && env.ACTIONS_ID_TOKEN_REQUEST_URL != ''
@@ -184,21 +184,21 @@ jobs:
184184
-
185185
name: Upload documentation files
186186
if: matrix.bin_name == 'pihole-FTL-amd64'
187-
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f #v6.0.0
187+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
188188
with:
189189
name: pihole-api-docs
190190
path: 'api-docs.tar.gz'
191191
-
192192
name: Upload pihole.toml template
193193
if: matrix.bin_name == 'pihole-FTL-amd64'
194-
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f #v6.0.0
194+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
195195
with:
196196
name: pihole-toml
197197
path: 'pihole.toml'
198198
-
199199
name: Get binaries built in previous jobs
200200
if: env.DO_DEPLOY == 'true'
201-
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 #v7.0.0
201+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c #v8.0.1
202202
id: download
203203
with:
204204
path: ftl_builds/
@@ -207,14 +207,14 @@ jobs:
207207
-
208208
name: Get documentation files built in previous jobs
209209
if: env.DO_DEPLOY == 'true' && matrix.bin_name == 'pihole-FTL-amd64'
210-
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 #v7.0.0
210+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c #v8.0.1
211211
with:
212212
path: ftl_builds/
213213
name: pihole-api-docs
214214
-
215215
name: Get pihole.toml built in previous job
216216
if: env.DO_DEPLOY == 'true' && matrix.bin_name == 'pihole-FTL-amd64'
217-
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 #v7.0.0
217+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c #v8.0.1
218218
with:
219219
path: ftl_builds/
220220
name: pihole-toml
@@ -265,7 +265,7 @@ jobs:
265265
-
266266
name: Attach binaries to release
267267
if: github.event_name == 'release'
268-
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b #v2.5.0
268+
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe #v2.6.1
269269
with:
270270
tag_name: ${{ github.event.release.tag_name }}
271271
files: |

.github/workflows/codeql.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
8888
# Initializes the CodeQL tools for scanning.
8989
- name: Initialize CodeQL
90-
uses: github/codeql-action/init@9e907b5e64f6b83e7804b09294d44122997950d6 #v4.32.3
90+
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1
9191
with:
9292
languages: ${{ matrix.language }}
9393
build-mode: ${{ matrix.build-mode }}
@@ -110,14 +110,14 @@ jobs:
110110
./build.sh
111111
112112
- name: Perform CodeQL Analysis
113-
uses: github/codeql-action/analyze@9e907b5e64f6b83e7804b09294d44122997950d6 #v4.32.3
113+
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1
114114
with:
115115
category: "/language:${{matrix.language}}"
116116
upload: failure-only # upload only in case of failure, otherwise upload later after filtering
117117
output: codeql-results
118118

119119
- name: Filter SARIF
120-
uses: advanced-security/filter-sarif@f3b8118a9349d88f7b1c0c488476411145b6270d #v1.0.1
120+
uses: advanced-security/filter-sarif@2da736ff05ef065cb2894ac6892e47b5eac2c3c0 #v1.1.0.1.1
121121
with:
122122
# filter out third-party dependencies
123123
patterns: |
@@ -136,13 +136,13 @@ jobs:
136136
output: codeql-results/cpp.sarif
137137

138138
- name: Upload SARIF
139-
uses: github/codeql-action/upload-sarif@9e907b5e64f6b83e7804b09294d44122997950d6 #v4.32.3
139+
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1
140140
with:
141141
sarif_file: codeql-results/cpp.sarif
142142

143143
- name: Upload CodeQL results as an artifact
144144
if: success() || failure()
145-
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f #v6.0.0
145+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
146146
with:
147147
name: codeql-results
148148
path: codeql-results

.github/workflows/openapi-validator.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
1616

1717
- name: Set up Node.js
18-
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 #v6.2.0
18+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f #v6.3.0
1919
with:
2020
node-version: "20"
2121
cache: npm

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
issues: write
1818

1919
steps:
20-
- uses: actions/stale@997185467fa4f803885201cee163a9f38240193d #v10.1.1
20+
- uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f #v10.2.0
2121
with:
2222
repo-token: ${{ secrets.GITHUB_TOKEN }}
2323
days-before-stale: 30

.github/workflows/stale_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
pull-requests: write
1818

1919
steps:
20-
- uses: actions/stale@997185467fa4f803885201cee163a9f38240193d #v10.1.1
20+
- uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f #v10.2.0
2121
with:
2222
repo-token: ${{ secrets.GITHUB_TOKEN }}
2323
# Do not automatically mark PR/issue as stale

.vscode/c_cpp_properties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"includePath": [
66
"${workspaceFolder}/src/**"
77
],
8-
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
8+
"compileCommands": "${workspaceFolder}/cmake/compile_commands.json",
99
"defines": [],
1010
"compilerPath": "/usr/bin/gcc",
1111
"cStandard": "gnu17",

build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ set -e
1515
# Set builddir
1616
builddir="cmake/"
1717

18+
# Enable export of compile commands so IDEs like VSCode can use this information
19+
# when rendering active and disabled code paths, e.g., for #ifdefs. The
20+
# compile_commands.json file is generated in the package specific build
21+
# directory containing the exact compiler calls for all translation units of the
22+
# project in machine-readable form (JSON).
23+
export CMAKE_EXPORT_COMPILE_COMMANDS=ON
24+
1825
# Parse arguments
1926
# If the first argument starts in "-D", we pass it to CMake
2027
if [[ "${1}" == "-D"* ]]; then

src/CMakeLists.txt

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,37 @@ add_subdirectory(config)
348348
add_subdirectory(tools)
349349
add_subdirectory(ntp)
350350
351+
# optional headers - may depend on type or version of the C standard library
352+
include(CheckIncludeFile)
353+
354+
check_include_file("sys/random.h" HAVE_RANDOM_H)
355+
if(HAVE_RANDOM_H)
356+
target_compile_definitions(config PRIVATE USE_GETRANDOM)
357+
target_compile_definitions(core PRIVATE USE_GETRANDOM)
358+
endif()
359+
360+
# <unwind.h> is part of GCC's libgcc — available on ALL targets (musl+glibc, static+dynamic)
361+
# _Unwind_Backtrace() is already linked via -lgcc/-static-libgcc; no find_library needed
362+
check_include_file("unwind.h" HAVE_UNWIND_H)
363+
if(HAVE_UNWIND_H)
364+
target_compile_definitions(core PRIVATE USE_UNWIND)
365+
message(STATUS "Building FTL with _Unwind_Backtrace support: YES")
366+
else()
367+
message(STATUS "Building FTL with _Unwind_Backtrace support: NO")
368+
endif()
369+
370+
# Embed the source root so crash backtraces can show project-relative paths
371+
# (e.g. "src/args.c" instead of "/home/user/FTL/src/args.c").
372+
target_compile_definitions(core PRIVATE SOURCE_ROOT="${CMAKE_SOURCE_DIR}/")
373+
374+
375+
376+
option(USE_READLINE "Build FTL with readline support, if available" ON)
377+
351378
find_library(LIBREADLINE NAMES libreadline${LIBRARY_SUFFIX} readline)
352379
find_library(LIBHISTORY NAMES libhistory${LIBRARY_SUFFIX} history)
353380
find_library(LIBTERMCAP NAMES libtermcap${LIBRARY_SUFFIX} termcap)
354-
if(LIBREADLINE AND LIBHISTORY AND LIBTERMCAP)
381+
if(LIBREADLINE AND LIBHISTORY AND LIBTERMCAP AND USE_READLINE)
355382
message(STATUS "Building FTL with readline support: YES")
356383
target_compile_definitions(lua PRIVATE LUA_USE_READLINE)
357384
target_compile_definitions(sqlite3 PRIVATE HAVE_READLINE)
@@ -364,19 +391,21 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
364391
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE)
365392
endif()
366393
394+
option(USE_MBED_TLS "Build FTL with TLS support, if available" ON)
395+
367396
find_library(LIBMBEDCRYPTO NAMES lmbedcrypto${LIBRARY_SUFFIX} mbedcrypto)
368397
find_library(LIBMBEDX509 NAMES lmbedx509${LIBRARY_SUFFIX} mbedx509)
369398
find_library(LIBMBEDTLS NAMES lmbedtls${LIBRARY_SUFFIX} mbedtls)
370-
if(LIBMBEDCRYPTO AND LIBMBEDX509 AND LIBMBEDTLS)
371-
# Enable TLS support in civetweb if mbedTLS is available
399+
if(LIBMBEDCRYPTO AND LIBMBEDX509 AND LIBMBEDTLS AND USE_MBED_TLS)
400+
# Enable TLS support in civetweb if mbedTLS is selected and available
372401
message(STATUS "Building FTL with TLS support: YES")
373402
target_compile_definitions(core PRIVATE HAVE_MBEDTLS)
374403
target_compile_definitions(civetweb PRIVATE USE_MBEDTLS)
375404
target_compile_definitions(webserver PRIVATE HAVE_MBEDTLS)
376405
# Link against the mbedTLS libraries, the order is important (!)
377406
target_link_libraries(pihole-FTL ${LIBMBEDTLS} ${LIBMBEDX509} ${LIBMBEDCRYPTO})
378407
else()
379-
# Disable TLS support in civetweb if mbedTLS is not available
408+
# Disable TLS support in civetweb if mbedTLS is not selected or not available
380409
message(STATUS "Building FTL with TLS support: NO")
381410
target_compile_definitions(civetweb PRIVATE NO_SSL)
382411
endif()

src/api/action.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
// flush_network_table()
2323
#include "database/network-table.h"
2424
#include "config/config.h"
25+
// gravity_running
26+
#include "daemon.h"
2527

2628
static int run_and_stream_command(struct ftl_conn *api, const char *path, const char *const args[], const char *extra_env)
2729
{
@@ -57,6 +59,18 @@ static int run_and_stream_command(struct ftl_conn *api, const char *path, const
5759
if(extra_env != NULL)
5860
setenv(extra_env, "1", 1);
5961

62+
// Detach child into its own session/process group so signals
63+
// sent to the parent's process group (like SIGTERM) do not
64+
// propagate to this child.
65+
(void)setsid();
66+
67+
// Ignore SIGTERM so systemd's cgroup-level kill (the
68+
// default KillMode=control-group sends SIGTERM to ALL
69+
// processes in the cgroup) doesn't terminate gravity
70+
// mid-run. SIG_IGN is preserved across execv(), unlike
71+
// custom handlers which are reset to SIG_DFL.
72+
signal(SIGTERM, SIG_IGN);
73+
6074
// Run pihole -g
6175
execv(path, (char *const *)args);
6276

@@ -129,7 +143,16 @@ int api_action_gravity(struct ftl_conn *api)
129143
get_bool_var(query, "color", &color);
130144

131145
const char *extra_env = color ? "FORCE_COLOR" : NULL;
132-
return run_and_stream_command(api, "/usr/local/bin/pihole", (const char *const []){ "pihole", "-g", NULL }, extra_env);
146+
147+
gravity_running = 1;
148+
const int ret = run_and_stream_command(api, "/usr/local/bin/pihole", (const char *const []){ "pihole", "-g", NULL }, extra_env);
149+
gravity_running = 0;
150+
151+
// If a termination/restart was requested while gravity was running,
152+
// act on it now rather than waiting up to ~1s for the GC thread to pick it up
153+
check_if_want_terminate();
154+
155+
return ret;
133156
}
134157

135158
int api_action_restartDNS(struct ftl_conn *api)

src/api/api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int api_list(struct ftl_conn *api);
101101
int api_group(struct ftl_conn *api);
102102

103103
// Auth method
104-
void init_api(void);
104+
void init_api_sessions(void);
105105
void free_api(void);
106106
int check_client_auth(struct ftl_conn *api, const bool is_api);
107107
int api_auth(struct ftl_conn *api);

0 commit comments

Comments
 (0)