Skip to content

Commit fd4a064

Browse files
authored
feat(sandbox): add --no-login-shell to skip shell startup files on exec (ai-openshell/openshell#2852)
* feat(sandbox): add --no-login-shell to skip shell startup files on exec Signed-off-by: Artem Lytvyn <alytvyn@redhat.com> * chore(sdk/go): regenerate proto bindings for no_login_shell Signed-off-by: Artem Lytvyn <alytvyn@redhat.com> * test(supervisor-process): cover login-shell flag selection Signed-off-by: Artem Lytvyn <alytvyn@redhat.com> * feat(sandbox): gate --no-login-shell on supervisor SSH banner Signed-off-by: Artem Lytvyn <alytvyn@redhat.com> --------- Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
1 parent 7378ef1 commit fd4a064

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/openshell/sandbox.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ def exec(
452452
env: Mapping[str, str] | None = None,
453453
stdin: bytes | None = None,
454454
timeout_seconds: int | None = None,
455+
no_login_shell: bool = False,
455456
) -> ExecResult:
456457
return self._client.exec(
457458
self.sandbox.id,
@@ -461,6 +462,7 @@ def exec(
461462
env=env,
462463
stdin=stdin,
463464
timeout_seconds=timeout_seconds,
465+
no_login_shell=no_login_shell,
464466
)
465467

466468
def exec_python(
@@ -915,6 +917,7 @@ def exec_stream(
915917
env: Mapping[str, str] | None = None,
916918
stdin: bytes | None = None,
917919
timeout_seconds: int | None = None,
920+
no_login_shell: bool = False,
918921
) -> Iterator[ExecChunk | ExecResult]:
919922
if not command:
920923
raise SandboxError("command must not be empty")
@@ -926,6 +929,7 @@ def exec_stream(
926929
environment=dict(env or {}),
927930
timeout_seconds=timeout_seconds or 0,
928931
stdin=stdin or b"",
932+
no_login_shell=no_login_shell,
929933
)
930934
# Use whichever is larger: the default client timeout or the command
931935
# timeout plus headroom for SSH setup / teardown overhead.
@@ -970,6 +974,7 @@ def exec(
970974
env: Mapping[str, str] | None = None,
971975
stdin: bytes | None = None,
972976
timeout_seconds: int | None = None,
977+
no_login_shell: bool = False,
973978
) -> ExecResult:
974979
result: ExecResult | None = None
975980
for item in self.exec_stream(
@@ -979,6 +984,7 @@ def exec(
979984
env=env,
980985
stdin=stdin,
981986
timeout_seconds=timeout_seconds,
987+
no_login_shell=no_login_shell,
982988
):
983989
if stream_output and isinstance(item, ExecChunk):
984990
if item.stream == "stdout":
@@ -1302,6 +1308,7 @@ def exec(
13021308
env: Mapping[str, str] | None = None,
13031309
stdin: bytes | None = None,
13041310
timeout_seconds: int | None = None,
1311+
no_login_shell: bool = False,
13051312
) -> ExecResult:
13061313
if self._session is None:
13071314
raise SandboxError("sandbox context has not been entered")
@@ -1312,6 +1319,7 @@ def exec(
13121319
env=env,
13131320
stdin=stdin,
13141321
timeout_seconds=timeout_seconds,
1322+
no_login_shell=no_login_shell,
13151323
)
13161324

13171325
def exec_python(

0 commit comments

Comments
 (0)