2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00

Fix name resolution for suse hosts/containers

Suse uses a strategy with symlinks, adapt
the resolv.conf target based on findings from
symlink chasing.
This commit is contained in:
Jarrod Johnson 2021-06-23 11:49:16 -04:00
parent b2fa2d92c5
commit 4445b8cc78

View File

@ -253,8 +253,17 @@ def exec_root_backend(optargs):
installroot = args[0]
imgname = os.path.basename(installroot)
_mount_constrained_fs(opts, installroot)
_mount('/etc/resolv.conf', os.path.join(installroot, 'etc/resolv.conf'), flags=MS_BIND|MS_RDONLY)
_mount('none', os.path.join(installroot, 'etc/resolv.conf'), flags=MS_RDONLY|MS_REMOUNT|MS_BIND)
sourceresolv = '/etc/resolv.conf'
if os.path.islink(sourceresolv):
sourceresolv = os.readlink(sourceresolv)
dstresolv = os.path.join(installroot, 'etc/resolv.conf')
if os.path.islink(dstresolv):
dstresolv = os.path.join(installroot, os.readlink(dstresolv)[1:])
if not os.path.exists(dstresolv):
mkdirp(os.path.dirname(dstresolv))
open(dstresolv, 'w').close()
_mount(sourceresolv, dstresolv, flags=MS_BIND|MS_RDONLY)
_mount('none', dstresolv, flags=MS_RDONLY|MS_REMOUNT|MS_BIND)
os.chroot(installroot)
os.chdir('/')
os.environ['PS1'] = '[\x1b[1m\x1b[4mIMGUTIL EXEC {0}\x1b[0m \W]$ '.format(imgname)