chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b55d065
)
nspawn: bind mount /etc/resolv.conf from the host by default
author
Lennart Poettering
<lennart@poettering.net>
Wed, 25 Apr 2012 13:08:00 +0000
(15:08 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Wed, 25 Apr 2012 13:08:00 +0000
(15:08 +0200)
src/nspawn/nspawn.c
patch
|
blob
|
history
diff --git
a/src/nspawn/nspawn.c
b/src/nspawn/nspawn.c
index bf3a84471dd833b4b6380c04cbfd8d06c885dd40..83bec96cc5cee11c0e732121342c4ef9c8b4583c 100644
(file)
--- a/
src/nspawn/nspawn.c
+++ b/
src/nspawn/nspawn.c
@@
-263,6
+263,28
@@
static int setup_timezone(const char *dest) {
return 0;
}
return 0;
}
+static int setup_resolv_conf(const char *dest) {
+ char *where;
+
+ assert(dest);
+
+ if (arg_private_network)
+ return 0;
+
+ /* Fix resolv.conf, if possible */
+ if (asprintf(&where, "%s/etc/resolv.conf", dest) < 0) {
+ log_error("Out of memory");
+ return -ENOMEM;
+ }
+
+ if (mount("/etc/resolv.conf", where, "bind", MS_BIND, NULL) >= 0)
+ mount("/etc/resolv.conf", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
+
+ free(where);
+
+ return 0;
+}
+
static int copy_devnodes(const char *dest) {
static const char devnodes[] =
static int copy_devnodes(const char *dest) {
static const char devnodes[] =
@@
-966,6
+988,9
@@
int main(int argc, char *argv[]) {
if (setup_timezone(arg_directory) < 0)
goto child_fail;
if (setup_timezone(arg_directory) < 0)
goto child_fail;
+ if (setup_resolv_conf(arg_directory) < 0)
+ goto child_fail;
+
if (chdir(arg_directory) < 0) {
log_error("chdir(%s) failed: %m", arg_directory);
goto child_fail;
if (chdir(arg_directory) < 0) {
log_error("chdir(%s) failed: %m", arg_directory);
goto child_fail;