# NAME2IPADDRESS shouldn't be enabled with other operations as the helper
# process works on one request at the time and the async resolver could
# block the main thread
- priv_ops="NAME2IPADDRESS"
+ priv_ops="NAME2IPADDRESS RELOADDNS"
EXTRA_LIBS="$EXTRA_LIBS -lseccomp"
fi
#include "local.h"
#include "memory.h"
#include "nameserv_async.h"
+#include "privops.h"
#include "sched.h"
/* ================================================== */
assert(!resolving_source);
- DNS_Reload();
+ PRV_ReloadDNS();
/* Start with the first source in the list, name_resolve_handler
will iterate over the rest */
#define OP_SETTIME 1026
#define OP_BINDSOCKET 1027
#define OP_NAME2IPADDRESS 1028
+#define OP_RELOADDNS 1029
#define OP_QUIT 1099
union sockaddr_in46 {
/* make sure the string is terminated */
req->name[sizeof (req->name) - 1] = '\0';
- DNS_Reload();
-
res->rc = DNS_Name2IPAddress(req->name, res->data.name_to_ipaddress.addresses,
DNS_MAX_ADDRESSES);
}
/* ======================================================================= */
+/* HELPER - perform DNS_Reload() */
+
+#ifdef PRIVOPS_RELOADDNS
+static void
+do_reload_dns(PrvResponse *res)
+{
+ DNS_Reload();
+ res->rc = 0;
+}
+#endif
+
+/* ======================================================================= */
+
/* HELPER - main loop - action requests from the daemon */
static void
case OP_NAME2IPADDRESS:
do_name_to_ipaddress(&req.data.name_to_ipaddress, &res);
break;
+#endif
+#ifdef PRIVOPS_RELOADDNS
+ case OP_RELOADDNS:
+ do_reload_dns(&res);
+ break;
#endif
case OP_QUIT:
quit = 1;
/* ======================================================================= */
+/* DAEMON - request res_init() */
+
+#ifdef PRIVOPS_RELOADDNS
+void
+PRV_ReloadDNS(void)
+{
+ PrvRequest req;
+ PrvResponse res;
+
+ if (!have_helper()) {
+ DNS_Reload();
+ return;
+ }
+
+ memset(&req, 0, sizeof (req));
+ req.op = OP_RELOADDNS;
+
+ submit_request(&req, &res);
+ assert(!res.rc);
+}
+#endif
+
+/* ======================================================================= */
+
void
PRV_Initialise(void)
{
#define PRV_Name2IPAddress DNS_Name2IPAddress
#endif
+#ifdef PRIVOPS_RELOADDNS
+void PRV_ReloadDNS(void);
+#else
+#define PRV_ReloadDNS DNS_Reload
+#endif
+
#ifdef PRIVOPS_HELPER
void PRV_Initialise(void);
void PRV_StartHelper(void);