diff --git a/podctl/build.py b/podctl/build.py index 3703d88..9fbc9e4 100644 --- a/podctl/build.py +++ b/podctl/build.py @@ -15,6 +15,7 @@ class Build(Script): The build script iterates over visitors and runs the build functions, it also provides wrappers around the buildah command. """ + unshare = True def __init__(self): super().__init__() diff --git a/podctl/script.py b/podctl/script.py index 698af3a..e64dda5 100644 --- a/podctl/script.py +++ b/podctl/script.py @@ -1,6 +1,7 @@ import asyncio import copy import cli2 +import os import textwrap from .proc import Proc @@ -19,6 +20,7 @@ class Script: immediate=True, ), ] + unshare = False def __init__(self, name=None, doc=None): self.name = name or type(self).__name__.lower() @@ -79,6 +81,11 @@ class Script: raise async def run(self, *args, **kwargs): + if self.unshare and os.getuid() != 0: + import sys + # restart under buildah unshare environment ! + os.execvp('buildah', ['buildah', 'unshare'] + sys.argv) + for key, value in kwargs.items(): setattr(self, key, value)