Rename is_wrapper with is_runnable, rely on uid check

This commit is contained in:
jpic 2020-02-16 15:35:02 +01:00
parent 933c81b7a8
commit 5b11100e0a

View File

@ -86,15 +86,14 @@ class Buildah(Localhost):
await self.exec(f'mount -o bind {src} {target}', buildah=False) await self.exec(f'mount -o bind {src} {target}', buildah=False)
self.mounts[src] = dst self.mounts[src] = dst
def is_wrapper(self): def is_runnable(self):
return not ( return (
Proc.test Proc.test
or os.getuid() == 0 or os.getuid() == 0
or getattr(self.parent, 'parent', None)
) )
async def call(self, *args, **kwargs): async def call(self, *args, **kwargs):
if not self.is_wrapper(): if self.is_runnable():
self.ctr = (await self.exec('buildah', 'from', self.base, buildah=False)).out self.ctr = (await self.exec('buildah', 'from', self.base, buildah=False)).out
self.mnt = Path((await self.exec('buildah', 'mount', self.ctr, buildah=False)).out) self.mnt = Path((await self.exec('buildah', 'mount', self.ctr, buildah=False)).out)
result = await super().call(*args, **kwargs) result = await super().call(*args, **kwargs)
@ -169,7 +168,7 @@ class Buildah(Localhost):
await self.exec('podman', 'push', f'{self.image.repository}:{tag}', buildah=False) await self.exec('podman', 'push', f'{self.image.repository}:{tag}', buildah=False)
async def clean(self, *args, **kwargs): async def clean(self, *args, **kwargs):
if not self.is_wrapper(): if self.is_runnable():
for src, dst in self.mounts.items(): for src, dst in self.mounts.items():
await self.exec('umount', self.mnt / str(dst)[1:], buildah=False) await self.exec('umount', self.mnt / str(dst)[1:], buildah=False)