-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maintenance: Add dedicated /etc/hosts manager #1810
base: master
Are you sure you want to change the base?
Conversation
Initial class Cfg::File combines: a) file management design from ConfigParser::CfgFile, Extended to load files in large chunks (up to 1MB) and parse lines in memory instead of via fgets(). b) "#line NN "filename" line changing from parseOneConfigFile(), Altered to only apply when processing FIFO pipes instead of allowing regular files. c) FIFO pipe alternative input from parseOneConfigFile() Extended to also perform FIFO auto-detection and enable pipe handling differences without special configuration by admin. d) prefix whitespace tolerance from ConfigParser::strtokFile()
Apparently it can contain garbage values.
Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
- content may not actually be configuration. It has not been validated. - fread(2) is used internally not read(2).
also remove now unused stat(2) complexity.
Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on PR #928
Please do not post PRs based on PR 928. That PR is likely to require significant changes, making such posts unproductive.
I marked a few problems, but please request my review after PR 928 is closed and this PR is updated accordingly, even if those problems are addressed earlier.
@@ -31,7 +31,7 @@ | |||
#include "CpuAffinity.h" | |||
#include "debug/Messages.h" | |||
#include "DiskIO/DiskIOModule.h" | |||
#include "dns/forward.h" | |||
#include "dns/EtcHosts.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newer Registrater Runner API (commit 230d441) that this PR is using does not require exposing main.cc to EtcHosts details. The following suggestion undoes PR changes:
#include "dns/EtcHosts.h" | |
#include "dns/forward.h" |
@@ -10151,9 +10151,9 @@ DOC_START | |||
DOC_END | |||
|
|||
NAME: hosts_file | |||
TYPE: string | |||
TYPE: SBuf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, this TYPE change (among other things) converts a previously required filename parameter to an optional one. Please do not do that.
FWIW, I recommend keeping Config.etcHostsPath (field and type) unchanged in this PR. There are other problems with parse/dump_SBuf() that we would be able to avoid solving in this PR if we remove that non-essential change from this PR.
if (Path.isEmpty() || Path.cmp("none") == 0) | ||
return; | ||
|
||
etcHostsFile = new Configuration::File(Path.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use a raw pointer to store heap-allocated objects.
AFAICT, the proposed Dns::EtcHosts::etcHostsFile data member should be converted into an ordinary local non-pointer variable instead, eliminating this problem and simplifying code.
Replace the legacy parser for /etc/hosts file using
a modern Tokenizer and SBuf based parse managed
by a Registered Runner class.