Skip to content

Commit

Permalink
devcontainer: integrate sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
offlinehacker committed Aug 7, 2020
1 parent ee3d739 commit 6264454
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion images/devcontainer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
, openssh
, procps
, shadow
, sudo
, xz
, patchelf
, mkUserEnvironment
Expand Down Expand Up @@ -81,6 +82,7 @@ let

# for user management
shadow
sudo

# for the vscode extension
iproute
Expand All @@ -106,6 +108,11 @@ let
ln -s /nix/var/nix/profiles/default/bin/sh bin/sh
ln -s /nix/var/nix/profiles/default/bin/env usr/bin/env
# install sudo
mkdir -p usr/bin usr/lib/sudo
cp ${sudo}/bin/sudo usr/bin/sudo
cp -r ${sudo}/libexec/sudo/* usr/lib/sudo
# might as well...
ln -s /nix/var/nix/profiles/default/bin/bash bin/bash
Expand Down Expand Up @@ -133,7 +140,7 @@ let
"ENV=/nix/var/nix/profiles/default/etc/profile.d/nix.sh"
"GIT_SSL_CAINFO=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"
"PAGER=less"
"PATH=/nix/var/nix/profiles/default/bin"
"PATH=/usr/bin:/nix/var/nix/profiles/default/bin"
"SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"
(
if channel != "" then
Expand All @@ -145,6 +152,9 @@ let

# commands to run before build of every Dockerfile using this image
OnBuild = [
# fix permissions of sudo and set suid bit
"RUN chmod -R u+s,u+rx,g+x,o+x /usr/bin/sudo && chown -R root:root /usr/lib/sudo"

# expose USERNAME, USER_UID, USER_GID as build arguments
"ARG USERNAME=vscode"
"ARG USER_UID=1000"
Expand Down
2 changes: 2 additions & 0 deletions images/devcontainer/root/etc/sudo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Plugin sudoers_policy /usr/lib/sudo/sudoers.so
Plugin sudoers_io /usr/lib/sudo/sudoers.so
2 changes: 2 additions & 0 deletions images/devcontainer/root/etc/sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
root ALL=(ALL:ALL) SETENV: ALL
%wheel ALL=(ALL:ALL) NOPASSWD:ALL

0 comments on commit 6264454

Please sign in to comment.