Compare commits
3 Commits
54c0facbb3
...
1dc5672376
Author | SHA1 | Date |
---|---|---|
Petr Menšík | 1dc5672376 | |
Petr Menšík | b8675eef92 | |
Petr Menšík | 844b2e9588 |
|
@ -323,6 +323,25 @@ static int write_stub_resolv_conf_contents(FILE *f, OrderedSet *dns, OrderedSet
|
||||||
return fflush_and_check(f);
|
return fflush_and_check(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void manager_symlink_stub_to_uplink_resolv_conf(void) {
|
||||||
|
_cleanup_free_ char *fname = NULL;
|
||||||
|
int r;
|
||||||
|
if (access(PRIVATE_UPLINK_RESOLV_CONF, R_OK) != 0) {
|
||||||
|
log_debug("Uplink %s is missing.", PRIVATE_UPLINK_RESOLV_CONF);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = path_extract_filename(PRIVATE_UPLINK_RESOLV_CONF, &fname);
|
||||||
|
if (r < 0) {
|
||||||
|
log_warning_errno(r, "Failed to extract filename from path '" PRIVATE_UPLINK_RESOLV_CONF "', ignoring: %m");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = symlink_atomic_label(fname, PRIVATE_STUB_RESOLV_CONF);
|
||||||
|
if (r < 0)
|
||||||
|
log_warning_errno(r, "Failed to symlink %s, ignoring: %m", PRIVATE_STUB_RESOLV_CONF);
|
||||||
|
}
|
||||||
|
|
||||||
int manager_write_resolv_conf(Manager *m) {
|
int manager_write_resolv_conf(Manager *m) {
|
||||||
_cleanup_ordered_set_free_ OrderedSet *dns = NULL, *domains = NULL;
|
_cleanup_ordered_set_free_ OrderedSet *dns = NULL, *domains = NULL;
|
||||||
_cleanup_(unlink_and_freep) char *temp_path_uplink = NULL, *temp_path_stub = NULL;
|
_cleanup_(unlink_and_freep) char *temp_path_uplink = NULL, *temp_path_stub = NULL;
|
||||||
|
@ -369,16 +388,9 @@ int manager_write_resolv_conf(Manager *m) {
|
||||||
log_warning_errno(r, "Failed to move new %s into place, ignoring: %m", PRIVATE_STUB_RESOLV_CONF);
|
log_warning_errno(r, "Failed to move new %s into place, ignoring: %m", PRIVATE_STUB_RESOLV_CONF);
|
||||||
|
|
||||||
temp_path_stub = mfree(temp_path_stub); /* free the string explicitly, so that we don't unlink anymore */
|
temp_path_stub = mfree(temp_path_stub); /* free the string explicitly, so that we don't unlink anymore */
|
||||||
} else {
|
} else
|
||||||
_cleanup_free_ char *fname = NULL;
|
manager_symlink_stub_to_uplink_resolv_conf();
|
||||||
r = path_extract_filename(PRIVATE_UPLINK_RESOLV_CONF, &fname);
|
|
||||||
if (r < 0)
|
|
||||||
return log_warning_errno(r, "Failed to extract filename from path '" PRIVATE_UPLINK_RESOLV_CONF "', ignoring: %m");
|
|
||||||
|
|
||||||
r = symlink_atomic_label(fname, PRIVATE_STUB_RESOLV_CONF);
|
|
||||||
if (r < 0)
|
|
||||||
log_warning_errno(r, "Failed to symlink %s, ignoring: %m", PRIVATE_STUB_RESOLV_CONF);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = conservative_rename(temp_path_uplink, PRIVATE_UPLINK_RESOLV_CONF);
|
r = conservative_rename(temp_path_uplink, PRIVATE_UPLINK_RESOLV_CONF);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
int manager_check_resolv_conf(const Manager *m);
|
int manager_check_resolv_conf(const Manager *m);
|
||||||
int manager_read_resolv_conf(Manager *m);
|
int manager_read_resolv_conf(Manager *m);
|
||||||
int manager_write_resolv_conf(Manager *m);
|
int manager_write_resolv_conf(Manager *m);
|
||||||
|
void manager_symlink_stub_to_uplink_resolv_conf(void);
|
||||||
|
|
||||||
typedef enum ResolvConfMode {
|
typedef enum ResolvConfMode {
|
||||||
RESOLV_CONF_UPLINK,
|
RESOLV_CONF_UPLINK,
|
||||||
|
|
|
@ -91,6 +91,9 @@ static int run(int argc, char *argv[]) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Event loop failed: %m");
|
return log_error_errno(r, "Event loop failed: %m");
|
||||||
|
|
||||||
|
/* send queries on shutdown to other servers */
|
||||||
|
manager_symlink_stub_to_uplink_resolv_conf();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue