Compare commits
16 Commits
f1004d0b68
...
a66b898d7a
Author | SHA1 | Date |
---|---|---|
Muhammad Nuzaihan Bin Kamal Luddin | a66b898d7a | |
Muhammad Nuzaihan Bin Kamal Luddin | 5507ec986f | |
Muhammad Nuzaihan Bin Kamal Luddin | fee8a01942 | |
Muhammad Nuzaihan Bin Kamal Luddin | 2e9b9408d2 | |
Muhammad Nuzaihan Bin Kamal Luddin | f8599ea6fb | |
Muhammad Nuzaihan Bin Kamal Luddin | 18b5e47238 | |
Muhammad Nuzaihan Bin Kamal Luddin | a7847d744e | |
Muhammad Nuzaihan Bin Kamal Luddin | 04031c10f8 | |
Muhammad Nuzaihan Bin Kamal Luddin | 84831eff33 | |
Muhammad Nuzaihan Bin Kamal Luddin | a7a4b22282 | |
Muhammad Nuzaihan Bin Kamal Luddin | 7f8faa1b9a | |
Muhammad Nuzaihan Bin Kamal Luddin | bfed004837 | |
Muhammad Nuzaihan Bin Kamal Luddin | 1e79a8f8d6 | |
Muhammad Nuzaihan Bin Kamal Luddin | 18e8f0f1ce | |
Muhammad Nuzaihan Bin Kamal Luddin | 4d041317df | |
Muhammad Nuzaihan Bin Kamal Luddin | 9ea2a332c5 |
|
@ -702,6 +702,7 @@ env = find_program('env')
|
|||
rsync = find_program('rsync', required : false)
|
||||
diff = find_program('diff')
|
||||
find = find_program('find')
|
||||
cp = find_program('cp')
|
||||
|
||||
ln_s = ln.full_path() + ' -frsT -- "${DESTDIR:-}@0@" "${DESTDIR:-}@1@"'
|
||||
|
||||
|
|
|
@ -414,3 +414,61 @@ int manager_parse_config_file(Manager *m) {
|
|||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int config_parse_refuse_record_types(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
Manager *m = ASSERT_PTR(userdata);
|
||||
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
data = mfree(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
r = free_and_strdup_warn(data, empty_to_null(rvalue));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
char* record_type_string;
|
||||
int refused_record_type;
|
||||
|
||||
/* Get int values of DNS type for example "AAAA" string to get int value and store in Set */
|
||||
Set *refused_records = NULL;
|
||||
|
||||
for (;;) {
|
||||
r = extract_first_word(data, &record_type_string, ",", 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (r == 0)
|
||||
break;
|
||||
|
||||
refused_record_type = dns_type_from_string(record_type_string);
|
||||
/* log error of invalid dns type */
|
||||
if (refused_record_type == _DNS_TYPE_INVALID)
|
||||
log_error("dns type is invalid");
|
||||
|
||||
r = set_ensure_put(&refused_records, NULL, INT_TO_PTR(refused_record_type));
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
m->refuse_record_types = refused_records;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -480,6 +480,14 @@ int dns_query_new(
|
|||
|
||||
assert(m);
|
||||
|
||||
/* Check for records that is refused and refuse query for the records if matched in configuration */
|
||||
DNS_QUESTION_FOREACH(key, question_utf8) {
|
||||
if (set_contains(m->refuse_record_types, INT_TO_PTR(key->type))) {
|
||||
log_debug("Got request for %s record that is refused.", dns_type_to_string(key->type));
|
||||
return -ENOSYS;
|
||||
}
|
||||
}
|
||||
|
||||
if (question_bypass) {
|
||||
/* It's either a "bypass" query, or a regular one, but can't be both. */
|
||||
if (question_utf8 || question_idna)
|
||||
|
|
|
@ -992,6 +992,13 @@ static void dns_stub_process_query(Manager *m, DnsStubListenerExtra *l, DnsStrea
|
|||
SD_RESOLVED_NO_SEARCH|
|
||||
(DNS_PACKET_DO(p) ? SD_RESOLVED_REQUIRE_PRIMARY : 0)|
|
||||
SD_RESOLVED_CLAMP_TTL);
|
||||
|
||||
/* Refuse query if there is -ENOSYS */
|
||||
if (r == -ENOSYS) {
|
||||
dns_stub_send_failure(m, l, s, p, DNS_RCODE_REFUSED, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to generate query object: %m");
|
||||
dns_stub_send_failure(m, l, s, p, DNS_RCODE_SERVFAIL, false);
|
||||
|
|
|
@ -33,3 +33,4 @@ Resolve.ResolveUnicastSingleLabel, config_parse_bool, 0,
|
|||
Resolve.DNSStubListenerExtra, config_parse_dns_stub_listener_extra, 0, offsetof(Manager, dns_extra_stub_listeners)
|
||||
Resolve.CacheFromLocalhost, config_parse_bool, 0, offsetof(Manager, cache_from_localhost)
|
||||
Resolve.StaleRetentionSec, config_parse_sec, 0, offsetof(Manager, stale_retention_usec)
|
||||
Resolve.RefuseRecordTypes, config_parse_refuse_record_types, 0, offsetof(Manager, refuse_record_types)
|
||||
|
|
|
@ -137,6 +137,9 @@ struct Manager {
|
|||
struct stat etc_hosts_stat;
|
||||
bool read_etc_hosts;
|
||||
|
||||
/* List of refused DNS Record Types*/
|
||||
Set *refuse_record_types;
|
||||
|
||||
OrderedSet *dns_extra_stub_listeners;
|
||||
|
||||
/* Local DNS stub on 127.0.0.53:53 */
|
||||
|
|
|
@ -35,3 +35,4 @@
|
|||
#ReadEtcHosts=yes
|
||||
#ResolveUnicastSingleLabel=no
|
||||
#StaleRetentionSec=0
|
||||
#RefuseRecordTypes=
|
||||
|
|
|
@ -278,6 +278,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_uint32_invert_flag);
|
|||
CONFIG_PARSER_PROTOTYPE(config_parse_id128);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_tristate);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_string);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_refuse_record_types);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dns_name);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_hostname);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_path);
|
||||
|
|
Loading…
Reference in New Issue