feat: add sudo and sudoers (#20)

* feat: add sudo and sudoers

* Update cubbi/images/cubbi_init.py

Co-authored-by: pr-agent-monadical[bot] <198624643+pr-agent-monadical[bot]@users.noreply.github.com>

---------

Co-authored-by: pr-agent-monadical[bot] <198624643+pr-agent-monadical[bot]@users.noreply.github.com>
This commit is contained in:
2025-07-02 15:17:05 -06:00
committed by GitHub
parent d750e64608
commit 9c8ddbb3f3
6 changed files with 18 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ LABEL description="Aider AI pair programming for Cubbi"
# Install system dependencies including gosu for user switching
RUN apt-get update && apt-get install -y --no-install-recommends \
gosu \
sudo \
passwd \
bash \
curl \
@@ -64,4 +65,4 @@ RUN /cubbi/cubbi_init.py --help
WORKDIR /app
ENTRYPOINT ["/cubbi/cubbi_init.py"]
CMD ["tail", "-f", "/dev/null"]
CMD ["tail", "-f", "/dev/null"]

View File

@@ -7,6 +7,7 @@ Tests Docker image build, API key configuration, and Cubbi CLI integration
import subprocess
import sys
import tempfile
import re
def run_command(cmd, description="", check=True):
@@ -156,7 +157,7 @@ def test_cubbi_cli_integration():
assert (
result.returncode == 0
and "aider 0.84.0" in result.stdout
and re.search(r"aider \d+\.\d+\.\d+", result.stdout)
and "Cubbi CLI test successful" in result.stdout
), "Cubbi CLI session creation failed"
print("✅ Cubbi CLI session creation works")

View File

@@ -6,6 +6,7 @@ LABEL description="Claude Code for Cubbi"
# Install system dependencies including gosu for user switching
RUN apt-get update && apt-get install -y --no-install-recommends \
gosu \
sudo \
passwd \
bash \
curl \
@@ -69,4 +70,4 @@ RUN /cubbi/cubbi_init.py --help
WORKDIR /app
ENTRYPOINT ["/cubbi/cubbi_init.py"]
CMD ["tail", "-f", "/dev/null"]
CMD ["tail", "-f", "/dev/null"]

View File

@@ -222,6 +222,16 @@ class UserManager:
):
return False
# Create the sudoers file entry for the 'cubbi' user
sudoers_command = [
"sh",
"-c",
"echo 'cubbi ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/cubbi && chmod 0440 /etc/sudoers.d/cubbi",
]
if not self._run_command(sudoers_command):
self.status.log("Failed to create sudoers entry for cubbi", "ERROR")
return False
return True

View File

@@ -6,6 +6,7 @@ LABEL description="Goose for Cubbi"
# Install system dependencies including gosu for user switching and shadow for useradd/groupadd
RUN apt-get update && apt-get install -y --no-install-recommends \
gosu \
sudo \
passwd \
bash \
curl \

View File

@@ -6,6 +6,7 @@ LABEL description="Opencode for Cubbi"
# Install system dependencies including gosu for user switching and shadow for useradd/groupadd
RUN apt-get update && apt-get install -y --no-install-recommends \
gosu \
sudo \
passwd \
bash \
curl \