Commit Graph

48 Commits

Author SHA1 Message Date
DL6ER 45c342af05
Force-update embedded dnsmasq version. We are loosing the individual dnsmasq history of the ~ last year, however, given the multitude of merge conflicts and the fact that this code will soon(ish) be replaced by development-v6 (where the history is 100% intact), this isn't much of an issue
Signed-off-by: DL6ER <dl6er@dl6er.de>
2024-02-09 20:48:59 +01:00
DL6ER 612b31b735
Write PID early on so systemd cannot be fooled during DELAY_STARTUP times. The PID in this file will later be overwritten after forking
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-11-03 20:51:48 +01:00
DL6ER fc303aeba5
Read FTL config *before* initializing shared memory to ensure we are aware of a possible DEBUG_SHMEM flag when creating the shared memory segments
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-11-03 20:45:31 +01:00
DL6ER ca9f7c027f
Remove create_new option in init_shmem() as it was always true
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-11-03 20:45:31 +01:00
DL6ER 646e709fb1
Do not warn about missing capabilities during startup. The embedded dnsmasq does the same but config-aware, i.e. it will not complain about missing CAP_NET_ADMIN when DHCP is not used. As its warnings are now much more present in all logs, we don't need to do the check twice. The existing checks remain there but are only used in debug mode (DEBUG_CAPS).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-01-02 15:00:02 +01:00
DL6ER bd373c59ac
Ensure message table exists before trying to flush it
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-11-13 10:49:40 +01:00
DL6ER ff34a0c84b
Add DNSMASQ_WARN message type whenever dnsmasq logs a warning. Also, do not flush the message table on reload (but only on restart) so that config-related (i.e. one-time) warnings are not accidentally deleted.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-11-13 10:28:59 +01:00
DL6ER aaff4b6092
Wrap parse_FTLconf() in mutex lock to prevent rare multi-thread race-collisions
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-10-17 10:33:53 +02:00
DL6ER 79e853c80a
Log how many queries have been saved in the final query storing
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-08-10 14:17:58 +02:00
DL6ER 22565a3a79
Initialize over-time data only after a possible startup delay
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-07-04 22:11:45 +02:00
DL6ER ec791ad7d3
If DELAY_STARTUP is set, we can delay earlier to have this option being useful for misbehaving fake hwclocks as well.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-06-24 12:07:20 +02:00
DL6ER 61d82aab1c
Merge branch 'development' into new/reply_pihole_hostname
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-06-23 20:27:29 +02:00
DL6ER ada54a7274
Add location logging to no-lock message
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-05-10 17:36:20 +02:00
DL6ER e870f7a36a
FTL automatically replies with the appropriate IP address to both p.hole and the machine's hostname. The replied with IP address can be overwritten using the REPLY_ADDR4/6 setting.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-04-16 11:31:59 +02:00
DL6ER 0795cf6209
Open individual database connections where we need them. Do not use global pointers anywhere. This may mean we have more than one connection open at the sae time. SQLite3 will take care of thread-safety.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-03-20 20:21:09 +00:00
DL6ER 86492317c2
Simplify signal handling and catch SIGABRT in addition
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-03-17 16:57:49 +01:00
DL6ER cf9018501d
Do not detach threads we want to be able to cancel and add logfile log to shared memory locks. Other forks may want to log as well.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-17 20:53:34 +01:00
DL6ER 62d20a97a7
Improve process-already-running detection
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-17 12:52:29 +01:00
DL6ER b475e5be1f
Ensure we clean up always behind us. Also when FTL crashes
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-17 11:46:36 +01:00
DL6ER 3d5f7e7673
Do not terminate threads which may not be running. They'll be cleaned up at process termination anyway.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-17 09:56:51 +01:00
DL6ER 49ba60e9e0
Do not try to delete existing shmem objects on start - that may cause running FTL instances to crash when it tries to access them. Instead, new instances should properly fail to start.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-05 11:18:22 +01:00
DL6ER 29a4bffe1f
Try to create shared memory objects before reading the settings
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-02-05 08:15:14 +01:00
DL6ER 9627ca6909
Prevent possible deadlock if log is not writable (e.g., permission denied)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-12-20 10:37:39 +01:00
DL6ER 056a70c931
Clarify that disabling the database only disables storing queries in the database. We still use the database for storing messages (such as regex syntax warnings) and alias-clients.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-25 19:53:39 +01:00
DL6ER 063800df78
Merge branch 'development' into new/lua
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-10-26 18:53:14 +01:00
DL6ER 13bf568ecf
Merge pull request #896 from pi-hole/fix/persistent_FTL_database
Keep FTL database open
2020-10-22 21:21:44 +02:00
DL6ER 6271430bb5
Make timer output at termination of FTL human readable (days/hours/minutes/seconds).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-10-22 19:57:51 +02:00
DL6ER b7fe809467
Reopening the FTL database may lead to rare race-collisions in SQLite3. We avoid them by keeping the database connection open all the time.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-27 23:35:44 +02:00
DL6ER 714a2cc74e
Merge branch 'development' into new/lua
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-03 21:41:55 +02:00
DL6ER 22c8ccefd5
Allow test-regex mode to be started without log ans shared memory (alleviates write permission issues when running pihole-FTL as a different user)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-10 23:24:30 +02:00
DL6ER c2c5f20eef
Add ability to connect to shared memory of the running FTL process
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-03 04:15:58 +02:00
DL6ER dd927b586e Tweak revert commit. We should add the port after configuring it and independtly from opening IPv4 and/or IPv6 sockets. Also, we cannot delete the port in close_telnet_port() as this function is called by TCP workers since v5.1 so we'd loose the port file when the first TCP query comes in.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-07-17 10:06:48 +02:00
DL6ER 747ee770b1
Children inherit file descriptors from their parents. As we don't need the API sockets in the forks, we clean them up after forking
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-06-28 21:18:23 +02:00
DL6ER 727c1cd729
Ensure main process is terminated orderly when a fork fails miserably.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-06-24 22:53:17 +02:00
DL6ER 8caa43d0ba
Do not listen to real-time signals in helper processes
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-06-15 22:05:15 +02:00
DL6ER 536ef08ce5 Free allocated memory after ordinary termination of TCP workers (TCP connection closed)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-04-06 15:11:32 +02:00
DL6ER e7e2dbe975 Print arguments passed to embedded dnsmasq when at least one DEBUG flag is set.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-04-06 09:32:21 +02:00
DL6ER 48186a6862 Add DELAY_STARTUP setting to delay startup of the embedded dnsmasq.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-25 10:09:14 +01:00
DL6ER 5e60930e70
Only initialize regex associations when dnsmasq is ready (otherwise, we're still in history reading mode)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-28 17:18:25 +01:00
DL6ER 68aef3f0c4
Ensure shared memory is not already destroyed when calling gravityDB_close().
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-11-25 10:05:03 +01:00
DL6ER d5a144a05e
Remove extra #include in main.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-24 11:51:14 +02:00
DL6ER c2c43a84e7
Check for availablility of prepared statement before trying to use it. This prevents us from preparing statements for clients that have been there within the past 24 hours but might have left the network meanwhile.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-09 13:10:04 +02:00
DL6ER 58213f7d5f
Open gravity database early on as we might already want to prepare gravity statements for clients while importing from the lng-temr database.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-09 08:43:28 +02:00
DL6ER 8c3ff39510
Implement client-specific gravity, white- and blacklist database statements.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-07 11:48:32 +02:00
DL6ER cb293058a2
Declare free_regex() and log_regex() static as we do not need to make them globally available.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-09 18:00:35 +02:00
DL6ER 4a9503cbf7
Move checking of database parameter MAXDBDAYS into db_init() to ensure we set database to false.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 09:45:12 +02:00
DL6ER 6b2f22f9f7
Move API modules (api, request, socket, msgpack) into their own subdirectory src/api.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-04 16:38:45 +02:00
DL6ER e365364f72
Move all source files into new subdirectory "src". Put compiled objects into new subdirectory "build".
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-02 00:18:56 +02:00