builder: Upload /etc/resolv.conf from the host when the network is enabled.

When the user has enabled the network (not the default) we upload
/etc/resolv.conf from the host to the appliance /etc/resolv.conf
so that programs in the appliance can contact nameservers.

Commit 9521422ce6 previously changed the
behaviour to copy /etc/resolv.conf into the sysroot when running
commands.
This commit is contained in:
Richard W.M. Jones
2013-10-08 12:32:41 +01:00
parent 74d9fdf56f
commit ae897e055a
4 changed files with 30 additions and 2 deletions

View File

@@ -751,6 +751,14 @@ do_debug_upload (const char *filename, int mode)
return 0;
}
/* This function is identical to debug_upload. */
/* Has one FileIn parameter. */
int
do_internal_upload (const char *filename, int mode)
{
return do_debug_upload (filename, mode);
}
/* Internal function used only when testing
* https://bugzilla.redhat.com/show_bug.cgi?id=914931
*/

View File

@@ -11607,6 +11607,16 @@ The label (name of the last element) of the Augeas path expression
C<augpath> is returned. C<augpath> must match exactly one node, else
this function returns an error." };
{ defaults with
name = "internal_upload";
style = RErr, [FileIn "filename"; String "tmpname"; Int "mode"], [];
proc_nr = Some 413;
visibility = VInternal;
cancellable = true;
shortdesc = "upload a file to the appliance (internal use only)";
longdesc = "\
This function is used internally when setting up the appliance." };
]
(* Non-API meta-commands available only in guestfish.

View File

@@ -1 +1 @@
412
413

View File

@@ -83,7 +83,17 @@ guestfs__launch (guestfs_h *g)
}
/* Launch the appliance. */
return g->backend_ops->launch (g, g->backend_data, g->backend_arg);
if (g->backend_ops->launch (g, g->backend_data, g->backend_arg) == -1)
return -1;
/* If network is enabled, upload /etc/resolv.conf from the host so
* the guest will know how to reach the nameservers.
*/
if (g->enable_network && access ("/etc/resolv.conf", F_OK) == 0) {
guestfs_internal_upload (g, "/etc/resolv.conf", "/etc/resolv.conf", 0644);
}
return 0;
}
/* launch (of the appliance) generates approximate progress