Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #78, handle permissions for docker.sock in a better way #82

Merged
merged 4 commits into from
Jul 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions build/gitkubed/sshd_config
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ Port 22
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
# HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO
Expand All @@ -28,14 +24,11 @@ LoginGraceTime 120
PermitRootLogin No
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
Expand Down
18 changes: 11 additions & 7 deletions build/gitkubed/start_sshd.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/usr/bin/env sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove /hasura-data/group mount from the deployment.

set -e

export HOST_GROUP_ID=$(cat /hasura-data/group | grep '^docker' | cut -d: -f3)
GROUP_WITH_HOST_GROUP_ID=$(getent group $HOST_GROUP_ID | cut -d: -f1)
if [ -z "${GROUP_WITH_HOST_GROUP_ID}" ]; then
# Find the group id from the host and use it to create docker group
groupadd -g $HOST_GROUP_ID docker
GROUP_WITH_HOST_GROUP_ID="docker"
# find the docker socket owner group id
DOCKER_SOCK_OWNER_GROUP_ID=$(stat -c '%g' /var/run/docker.sock)
# check the container's groups to see if it has a group with the same id
DOCKER_SOCK_OWNER_GROUP=$(getent group "$DOCKER_SOCK_OWNER_GROUP_ID" | cut -d: -f1)
if [ -z "${DOCKER_SOCK_OWNER_GROUP}" ]; then
# there is no group in the container with the given group id
# set owner group as 'docker'
DOCKER_SOCK_OWNER_GROUP="docker"
# create a new group with the same group id
groupadd -g "$DOCKER_SOCK_OWNER_GROUP_ID" "$DOCKER_SOCK_OWNER_GROUP"
fi

if [ -f /sshd-conf/remotes.json ]; then
Expand All @@ -29,7 +33,7 @@ if [ "$GIT_REMOTES_CONF" != "null" ]; then
chown -R $repo:$repo $HOME_DIR/git-shell-commands
chmod +x $HOME_DIR/git-shell-commands/no-interactive-login

usermod -aG $GROUP_WITH_HOST_GROUP_ID $repo
usermod -aG "$DOCKER_SOCK_OWNER_GROUP" "$repo"

# Create the .ssh directory if it does not exist
mkdir -p $HOME_DIR/.ssh
Expand Down