<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<br>
<div class="moz-cite-prefix">On 06/24/2015 03:35 PM, Michal Židek
wrote:<br>
</div>
<blockquote cite="mid:558AB23E.6070400@redhat.com" type="cite"><br>
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 12px;"
lang="x-western">
<pre wrap="">From 145f6b193f5ff9e382af441299864aac55c31dd4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C5=BDidek?= <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:mzidek@redhat.com"><mzidek@redhat.com></a>
Date: Wed, 17 Jun 2015 18:54:14 +0200
Subject: [PATCH 1/2] MONITOR: Poll for resolv.conf if not available during
boot
If resolv.conf is not available when SSSD is starting,
check for its existence later.
Ticket:
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://fedorahosted.org/sssd/ticket/2590">https://fedorahosted.org/sssd/ticket/2590</a>
---
src/monitor/monitor.c | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 01c882a..1804ad1 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -2259,11 +2259,39 @@ static errno_t monitor_config_file_fallback(TALLOC_CTX *mem_ctx,
return EOK;
}
+#define MISSING_RESOLV_CONF_POLL_TIME 10
+
+static void missing_resolv_conf(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval tv, void *data)
+{
+ int ret;
+ struct mt_ctx *ctx = talloc_get_type(data, struct mt_ctx);
+
+ ret = monitor_config_file(ctx, ctx, RESOLV_CONF_PATH,
+ monitor_update_resolv, false);
+ if (ret == EOK) {
+ signal_res_init(ctx);
+ } else if (ret == ENOENT) {
+ tv = tevent_timeval_current_ofs(MISSING_RESOLV_CONF_POLL_TIME, 0);
+ te = tevent_add_timer(ctx->ev, ctx, tv, missing_resolv_conf, ctx);
+ if (te == NULL) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "tevent_add_timer failed. resolv.conf will be ignored.\n");
+ }
+ } else {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Monitor_config_file failed. resolv.conf will be ignored.\n");
+ }
+}
+
static int monitor_process_init(struct mt_ctx *ctx,
const char *config_file)
{
TALLOC_CTX *tmp_ctx;
struct tevent_signal *tes;
+ struct timeval tv;
+ struct tevent_timer *te;
struct sss_domain_info *dom;
char *rcachedir;
int num_providers;
@@ -2351,8 +2379,14 @@ static int monitor_process_init(struct mt_ctx *ctx,
#endif
/* Watch for changes to the DNS resolv.conf */</pre>
</div>
</blockquote>
Michal would you consider renaming 'missing_resolv_conf' to
'check_resolv_conf' or something like that and then replace
following code segment by simple call of it? I think we could save a
few lines of code and reuse the function. Do you see any problems
about that? Thanks!<br>
<blockquote cite="mid:558AB23E.6070400@redhat.com" type="cite">
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 12px;"
lang="x-western">
<pre wrap="">
ret = monitor_config_file(ctx, ctx, RESOLV_CONF_PATH,
- monitor_update_resolv,true);
- if (ret != EOK) {
+ monitor_update_resolv, false);
+ if (ret == ENOENT) {
+ tv = tevent_timeval_current_ofs(MISSING_RESOLV_CONF_POLL_TIME, 0);
+ te = tevent_add_timer(ctx->ev, ctx, tv, missing_resolv_conf, ctx);
+ if (te == NULL) {
+ DEBUG(SSSDBG_FATAL_FAILURE, "resolv.conf will be ignored\n");
+ }
+ } else if (ret != EOK) {
return ret;
}
<div class="moz-txt-sig">--
2.1.0
</div></pre>
</div>
</blockquote>
<br>
</body>
</html>