lib.ExecContext.username: Add property

Add the property .username, backed by the protected _username()
callback. It should return the user run()'s cmd parameter is executed
as.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-19 14:03:31 +02:00
commit 9f756222fe

View file

@ -2,6 +2,8 @@
import os, sys, subprocess, asyncio, pwd, grp, stat
from functools import cache
from ..ExecContext import ExecContext as Base
from ..base import Result, StatResult
@ -13,6 +15,10 @@ class Local(Base):
def __init__(self, uri='local', *args, **kwargs) -> None:
super().__init__(uri, *args, **kwargs)
@cache
def _username(self) -> str:
return pwd.getpwuid(os.getuid()).pw_name,
async def _run(
self,
cmd: list[str],