Skip to content

Commit a400440

Browse files
committed
guestfs: fix debian13 nsswitch.conf edit
The debian13 guests come with an nsswitch.conf line like this: hosts: files myhostname resolve [!UNAVAIL=return] When we have CONFIG_GUESTFS_HAS_DISTRO_SOURCE_COPY_CAPABILITIES=y which would be when we have say a debian13 host and a debian13 guest and the host has a hop1 /etc/apt/sources.list, we copy the host's sources.list so we can profit from the speedy mirrors you have. However we need DNS to make sure we can talk to the servers and the above line prevents that. I had first tried to just remove the UNAVAIL entry with virt-builder command: edit /etc/nsswitch.conf:'s/\[!UNAVAIL=return\]//' But for the life of me this is not taking effect. So just do a brute force wipe of the file and open code the entire set of lines we want for debian13 for /etc/nsswitch.conf. Signed-off-by: Luis Chamberlain <[email protected]>
1 parent c12db08 commit a400440

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

scripts/bringup_guestfs.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,28 @@ firstboot-command DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=tru
234234
firstboot-command systemctl start ssh
235235
_EOT
236236
# CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST will not work
237-
# if etc/nsswitch.conf has a line like this:
237+
# if /etc/nsswitch.conf has a line like this:
238238
#
239239
# hosts: files myhostname resolve [!UNAVAIL=return] dns
240240
#
241241
# We need DNS to be used so virb0 will be used for a DNS request
242+
# For the life of me I can't get the following line to work with
243+
# the virt-builder command and so we do a full edit of the file for now
244+
# edit /etc/nsswitch.conf:'s/\[!UNAVAIL=return\]//'
242245
if [[ "$CONFIG_GUESTFS_DEBIAN_TRIXIE" == "y" ]]; then
243246
cat <<_EOT >>$cmdfile
244-
edit /etc/nsswitch.conf:'s/^hosts:.*UNAVAIL=return.*dns/hosts: files myhostname resolve dns/'
247+
write /etc/nsswitch.conf: # kdevops generated /etc/nsswitch.conf
248+
append-line /etc/nsswitch.conf:passwd: files
249+
append-line /etc/nsswitch.conf:group: files
250+
append-line /etc/nsswitch.conf:shadow: files
251+
append-line /etc/nsswitch.conf:gshadow: files
252+
append-line /etc/nsswitch.conf:hosts: files myhostname resolve dns
253+
append-line /etc/nsswitch.conf:networks: files
254+
append-line /etc/nsswitch.conf:protocols: db files
255+
append-line /etc/nsswitch.conf:services: db files
256+
append-line /etc/nsswitch.conf:ethers: db files
257+
append-line /etc/nsswitch.conf:rpc: db files
258+
append-line /etc/nsswitch.conf:netgroup: nis
245259
uninstall cloud-init
246260
write /etc/default/locale:LANG=en_US.UTF-8
247261
append-line /etc/default/locale:LANGUAGE=en_US:en

0 commit comments

Comments
 (0)