mirror of
				https://github.com/xcat2/confluent.git
				synced 2025-11-03 21:02:36 +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:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user