From 0fe2c033b36b5d15d315a330ff080a91e885b98c Mon Sep 17 00:00:00 2001 From: Andrew Rioux Date: Thu, 4 May 2023 18:45:42 -0400 Subject: [PATCH] build: adding debugging to dev container --- .cargo/config.toml | 2 ++ .devcontainer/Dockerfile | 17 ++++++++++++----- .devcontainer/Dockerfile.alpine | 22 ++++++++++++++++++++++ .devcontainer/devcontainer.json | 20 +++++++++++++++++--- .vscode/launch.json | 6 ++++++ 5 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 .devcontainer/Dockerfile.alpine diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..c1ca86b --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +target = "x86_64-unknown-linux-musl" \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 92102cb..23fa621 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -13,10 +13,17 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -FROM rust:1-alpine +FROM rust:1-buster -RUN apk add bash docker git cmake make automake musl-dev autoconf libtool valgrind \ - flex bison linux-headers openssl-dev apache2-utils docker-compose && \ +ENV DEBIAN_FRONTEND=noninteractive + +#apk add musl-dev openssl-dev docker-compose lldb && \ +RUN apt update && \ + apt install -y git cmake make automake autoconf libtool valgrind flex \ + linux-headers-5.10 bison docker-compose lldb libssl-dev libnl-3-dev sudo && \ rustup component add clippy && \ - mkdir /etc/docker && \ - echo '{ "storage-driver": "vfs" }' > /etc/docker/daemon.json \ No newline at end of file + rustup target add x86_64-unknown-linux-musl && \ + useradd vscode && \ + mkdir -p /home/vscode && \ + chown -R vscode:vscode /home/vscode && \ + echo "vscode ALL=(ALL: ALL) NOPASSWD: ALL" >> /etc/sudoers \ No newline at end of file diff --git a/.devcontainer/Dockerfile.alpine b/.devcontainer/Dockerfile.alpine new file mode 100644 index 0000000..559d7dc --- /dev/null +++ b/.devcontainer/Dockerfile.alpine @@ -0,0 +1,22 @@ +# Copyright (C) 2023 Andrew Rioux +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +FROM rust:1-alpine + +RUN apk add bash docker git cmake make automake musl-dev autoconf libtool valgrind \ + flex bison linux-headers openssl-dev apache2-utils docker-compose lldb && \ + rustup component add clippy && \ + mkdir /etc/docker && \ + echo '{ "storage-driver": "vfs" }' > /etc/docker/daemon.json \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 63e9818..2cecd8b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,7 +7,10 @@ "vscode": { "settings": { "licenser.license": "AGPLv3", - "licenser.projectName": "sparse" + "licenser.projectName": "sparse", + "lldb.executable": "/usr/bin/lldb", + "rust-analyzer.checkOnSave": true, + "rust-analyzer.checkOnSave.command": "clippy" }, "extensions": [ "tootone.org-mode", @@ -19,6 +22,17 @@ ] } }, - "runArgs": ["--privileged"], - "postStartCommand": "git submodule update --init; chown -R 1000:1000 .; nohup bash -c 'dockerd &' > /docker.log 2> /docker.log" + "runArgs": [ + "--privileged", + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], + "postStartCommand": "git submodule update --init", + "remoteUser": "vscode", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker": { + "dockerDashComposeVersion": "v2" + } + } } \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 543c567..33e9529 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -78,6 +78,12 @@ "args": [], "cwd": "${workspaceFolder}" }, + { + "type": "lldb", + "request": "attach", + "name": "Debug executable 'ex-bind-shell-backdoor' (attach)", + "program": "ex-bind-shell-backdoor" + }, { "type": "lldb", "request": "launch",