summaryrefslogtreecommitdiffstats
path: root/src/monitor
diff options
context:
space:
mode:
authorAriel Barria <arielb@fedoraproject.org>2012-09-06 22:45:12 -0500
committerJakub Hrozek <jhrozek@redhat.com>2012-09-20 10:15:05 +0200
commitb4262f1ac9c76d51e2c61ee3ce81e7d84fc1b9c6 (patch)
tree14c45fca26b03540416581a2bc093100dc1dda1a /src/monitor
parentadb08b2853bfcba76ebb35b4e7bb4a6403b54239 (diff)
downloadsssd-b4262f1ac9c76d51e2c61ee3ce81e7d84fc1b9c6.tar.gz
sssd-b4262f1ac9c76d51e2c61ee3ce81e7d84fc1b9c6.tar.xz
sssd-b4262f1ac9c76d51e2c61ee3ce81e7d84fc1b9c6.zip
Missing resolv.conf should be non-fatal
https://fedorahosted.org/sssd/ticket/1371
Diffstat (limited to 'src/monitor')
-rw-r--r--src/monitor/monitor.c60
1 files changed, 43 insertions, 17 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 1513747b6..50b2e9523 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1621,7 +1621,8 @@ done:
errno_t monitor_config_file_fallback(TALLOC_CTX *mem_ctx,
struct mt_ctx *ctx,
const char *file,
- monitor_reconf_fn fn);
+ monitor_reconf_fn fn,
+ bool ignore_missing);
static void rewatch_config_file(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval t, void *ptr)
@@ -1642,12 +1643,13 @@ static void rewatch_config_file(struct tevent_context *ev,
/* Retry six times at five-second intervals before giving up */
cb->retries++;
if (cb->retries > 6) {
- DEBUG(0, ("Could not restore inotify watch. Switching to polling!\n"));
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ ("Could not restore inotify watch. Switching to polling!\n"));
close(file_ctx->mt_ctx->inotify_fd);
err = monitor_config_file_fallback(file_ctx->parent_ctx,
file_ctx->mt_ctx,
cb->filename,
- cb->fn);
+ cb->fn,true);
if (err != EOK)
kill(getpid(), SIGTERM);
@@ -1669,12 +1671,14 @@ static void rewatch_config_file(struct tevent_context *ev,
tv.tv_sec = t.tv_sec+5;
tv.tv_usec = t.tv_usec;
- DEBUG(1, ("Could not add inotify watch for file [%s]. Error [%d:%s]\n",
- cb->filename, err, strerror(err)));
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Could not add inotify watch for file [%s]. Error [%d:%s]\n",
+ cb->filename, err, strerror(err)));
tev = tevent_add_timer(ev, ev, tv, rewatch_config_file, rw_ctx);
if (tev == NULL) {
- DEBUG(0, ("Could not restore inotify watch. Quitting!\n"));
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ ("Could not restore inotify watch. Quitting!\n"));
close(file_ctx->mt_ctx->inotify_fd);
kill(getpid(), SIGTERM);
}
@@ -1814,7 +1818,8 @@ static int try_inotify(struct config_file_ctx *file_ctx, const char *filename,
static int monitor_config_file(TALLOC_CTX *mem_ctx,
struct mt_ctx *ctx,
const char *file,
- monitor_reconf_fn fn)
+ monitor_reconf_fn fn,
+ bool ignore_missing)
{
int ret, err;
bool use_inotify;
@@ -1823,9 +1828,18 @@ static int monitor_config_file(TALLOC_CTX *mem_ctx,
ret = stat(file, &file_stat);
if (ret < 0) {
err = errno;
- DEBUG(0, ("Could not stat file [%s]. Error [%d:%s]\n",
- file, err, strerror(err)));
- return err;
+ if (err == ENOENT && ignore_missing) {
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ ("file [%s] is missing. Will not update online status "
+ "based on watching the file\n", file));
+ return EOK;
+ } else {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ ("Could not stat file [%s]. Error [%d:%s]\n",
+ file, err, strerror(err)));
+
+ return err;
+ }
}
if (!ctx->file_ctx) {
ctx->file_ctx = talloc_zero(mem_ctx, struct config_file_ctx);
@@ -1853,7 +1867,7 @@ static int monitor_config_file(TALLOC_CTX *mem_ctx,
if (!use_inotify) {
/* Could not monitor file with inotify, fall back to polling */
- ret = monitor_config_file_fallback(mem_ctx, ctx, file, fn);
+ ret = monitor_config_file_fallback(mem_ctx, ctx, file, fn, true);
}
return ret;
@@ -1862,7 +1876,8 @@ static int monitor_config_file(TALLOC_CTX *mem_ctx,
errno_t monitor_config_file_fallback(TALLOC_CTX *mem_ctx,
struct mt_ctx *ctx,
const char *file,
- monitor_reconf_fn fn)
+ monitor_reconf_fn fn,
+ bool ignore_missing)
{
struct config_file_callback *cb = NULL;
struct stat file_stat;
@@ -1872,9 +1887,19 @@ errno_t monitor_config_file_fallback(TALLOC_CTX *mem_ctx,
ret = stat(file, &file_stat);
if (ret < 0) {
err = errno;
- DEBUG(0, ("Could not stat file [%s]. Error [%d:%s]\n",
- file, err, strerror(err)));
- return err;
+ if (err == ENOENT && ignore_missing) {
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ ("file [%s] is missing. Will not update online status "
+ "based on watching the file\n", file));
+ return EOK;
+
+ } else {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ ("Could not stat file [%s]. Error [%d:%s]\n",
+ file, err, strerror(err)));
+
+ return err;
+ }
}
cb = talloc_zero(ctx->file_ctx, struct config_file_callback);
@@ -1992,14 +2017,15 @@ int monitor_process_init(struct mt_ctx *ctx,
Uncomment this once the backends are honoring reloadConfig()
/* Watch for changes to the confdb config file */
- ret = monitor_config_file(ctx, ctx, config_file, monitor_signal_reconf);
+ ret = monitor_config_file(ctx, ctx, config_file, monitor_signal_reconf,
+ true);
if (ret != EOK) {
return ret;
}
#endif
/* Watch for changes to the DNS resolv.conf */
ret = monitor_config_file(ctx, ctx, RESOLV_CONF_PATH,
- monitor_update_resolv);
+ monitor_update_resolv,true);
if (ret != EOK) {
return ret;
}