rehash: don't restart authd for DNS reloads

This could lead to pretty nasty things, like losing DNS (and in the
future, ident) queries. That's a Bad Thing™.
This commit is contained in:
Elizabeth Myers 2016-03-09 03:46:04 -06:00
parent 503727d1ee
commit 6445c1cf0b
7 changed files with 48 additions and 2 deletions

View file

@ -23,10 +23,12 @@
#define MAXPARA 10
static void handle_reload(int parc, char *parv[]);
static void handle_stat(int parc, char *parv[]);
rb_helper *authd_helper = NULL;
authd_cmd_handler authd_cmd_handlers[255] = {
['C'] = handle_reload,
['D'] = resolve_dns,
['S'] = handle_stat,
};
@ -35,6 +37,10 @@ authd_stat_handler authd_stat_handlers[255] = {
['D'] = enumerate_nameservers,
};
authd_reload_handler authd_reload_handlers[255] = {
['D'] = reload_nameservers,
};
static void
handle_stat(int parc, char *parv[])
{
@ -50,6 +56,21 @@ handle_stat(int parc, char *parv[])
handler(parv[1], parv[2][0]);
}
static void
handle_reload(int parc, char *parv[])
{
authd_reload_handler handler;
if(parc < 2)
/* XXX Should log this somehow */
return;
if (!(handler = authd_reload_handlers[parv[1][0]]))
return;
handler(parv[1][0]);
}
static void
parse_request(rb_helper *helper)
{

View file

@ -31,7 +31,10 @@ extern rb_helper *authd_helper;
typedef void (*authd_cmd_handler)(int parc, char *parv[]);
typedef void (*authd_stat_handler)(const char *rid, const char letter);
typedef void (*authd_reload_handler)(const char letter);
extern authd_cmd_handler authd_cmd_handlers[255];
extern authd_stat_handler authd_stat_handlers[255];
extern authd_reload_handler authd_reload_handlers[255];
#endif

View file

@ -174,3 +174,10 @@ enumerate_nameservers(const char *rid, const char letter)
rb_helper_write(authd_helper, "Y %s %c %s", rid, letter, buf);
}
void
reload_nameservers(const char letter)
{
/* Not a whole lot to it */
restart_resolver();
}

View file

@ -36,5 +36,6 @@ struct dns_request
extern void resolve_dns(int parc, char *parv[]);
extern void enumerate_nameservers(const char *rid, const char letter);
extern void reload_nameservers(const char letter);
#endif

View file

@ -40,5 +40,6 @@ void cancel_lookup(uint16_t xid);
void dns_results_callback(const char *callid, const char *status, const char *aftype, const char *results);
void dns_stats_results_callback(const char *callid, const char *status, int resc, const char *resv[]);
void init_nameserver_cache(void);
bool reload_nameservers(void);
#endif

View file

@ -322,6 +322,20 @@ init_nameserver_cache(void)
(void)get_nameservers(get_nameservers_cb, NULL);
}
bool
reload_nameservers(void)
{
if(authd_helper == NULL)
{
/* Shit */
return false;
}
rb_helper_write(authd_helper, "C D");
init_nameserver_cache();
return true;
}
static void
submit_dns(uint16_t nid, char type, const char *addr)
{

View file

@ -84,8 +84,7 @@ rehash_dns(struct Client *source_p)
if (!MyConnect(source_p))
remote_rehash_oper_p = source_p;
/* reread /etc/resolv.conf and reopen res socket */
restart_authd();
reload_nameservers();
}
static void