Skip to content
Snippets Groups Projects
Commit 3101c6a0 authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

prepare and unprepare chroot create resolf.conf only if /etc exists

parent 72b88654
No related branches found
No related tags found
No related merge requests found
......@@ -375,12 +375,10 @@ def prepare_chroot(path, mount=True):
warn("Mount failed: %s.\n" % e)
# trick resolv.conf
try:
if os.path.exists("/etc/resolv.conf"):
if os.path.exists("/etc/resolv.conf") and os.path.exists(os.path.join(path, "etc")):
resolv_path = os.path.join(path, "etc/resolv.conf")
if os.path.exists(resolv_path):
os.rename(resolv_path, "%s.isbackup" % resolv_path)
if not os.path.exists(os.path.dirname(resolv_path)):
os.makedirs(os.path.dirname(resolv_path))
shutil.copy("/etc/resolv.conf", resolv_path)
except Exception as e:
warn("resolv.conf tricks fail: %s" % e)
......@@ -404,7 +402,7 @@ def unprepare_chroot(path, mount=True):
Rollback preparation of a chroot environment inside a directory
'''
# untrick resolv.conf
if os.path.exists("/etc/resolv.conf"):
if os.path.exists("/etc/resolv.conf") and os.path.exists(os.path.join(path, "etc"))::
resolv_path = os.path.join(path, "etc/resolv.conf")
if os.path.exists(resolv_path):
os.unlink(resolv_path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment