From b40c14c05d4018fba698cb0edc883671dbfd3939 Mon Sep 17 00:00:00 2001 From: willnx Date: Tue, 15 Oct 2019 10:25:39 -0700 Subject: [PATCH 1/3] Ownership of PTY 0 is now the user, instead of root --- container_shell/lib/dockage.py | 7 +++++-- tests/test_dockage.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/container_shell/lib/dockage.py b/container_shell/lib/dockage.py index e13db0a..af7dff6 100644 --- a/container_shell/lib/dockage.py +++ b/container_shell/lib/dockage.py @@ -142,8 +142,11 @@ def container_command(username, user_uid, user_gid, create_user, command, runuse user_gid, username) - #everything = "/bin/bash -c '{0} && {1}'".format(make_user, run_user) - everything = "/bin/bash -c '{0} && {1} && {2}'".format(make_group, make_user, run_user) + fix_pty_ownership = 'chown {0}:{0} /dev/pts/0 2>/dev/null'.format(username) + everything = "/bin/bash -c '{0} && {1} && {2} ; {3}'".format(make_group, + make_user, + fix_pty_ownership, + run_user) elif command: everything = command else: diff --git a/tests/test_dockage.py b/tests/test_dockage.py index ec42c8f..0d53280 100644 --- a/tests/test_dockage.py +++ b/tests/test_dockage.py @@ -92,7 +92,7 @@ def test_create_no_command(self): command='', runuser='/sbin/runuser', useradd='/sbin/adduser') - expected = "/bin/bash -c '/usr/sbin/groupadd --gid 9001 liz && /sbin/adduser -m --uid 9001 --gid 9001 -s /bin/bash liz 2>/dev/null && /sbin/runuser liz -l '" + expected = "/bin/bash -c '/usr/sbin/groupadd --gid 9001 liz && /sbin/adduser -m --uid 9001 --gid 9001 -s /bin/bash liz 2>/dev/null && chown liz:liz /dev/pts/0 2>/dev/null ; /sbin/runuser liz -l '" self.assertEqual(cmd, expected) @@ -125,7 +125,7 @@ def test_create_command(self): command='/usr/local/bin/redis-cli', runuser='/sbin/runuser', useradd='/sbin/adduser') - expected = '/bin/bash -c \'/usr/sbin/groupadd --gid 9001 liz && /sbin/adduser -m --uid 9001 --gid 9001 -s /bin/bash liz 2>/dev/null && /sbin/runuser liz -c "/usr/local/bin/redis-cli"\'' + expected = '/bin/bash -c \'/usr/sbin/groupadd --gid 9001 liz && /sbin/adduser -m --uid 9001 --gid 9001 -s /bin/bash liz 2>/dev/null && chown liz:liz /dev/pts/0 2>/dev/null ; /sbin/runuser liz -c "/usr/local/bin/redis-cli"\'' self.assertEqual(cmd, expected) From 7c636195c2eb42b4d2e4a97f18a4ec1d2f22682f Mon Sep 17 00:00:00 2001 From: willnx Date: Tue, 15 Oct 2019 10:26:04 -0700 Subject: [PATCH 2/3] no longer testing Python 3.5 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 273e0a2..3f90f16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: python python: - - "3.5" - "3.6" before_install: From 4807f819eea70ac371fa8e9eac319736dfb46d9d Mon Sep 17 00:00:00 2001 From: willnx Date: Tue, 15 Oct 2019 10:29:25 -0700 Subject: [PATCH 3/3] fixed line continuation indention --- container_shell/lib/dockage.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/container_shell/lib/dockage.py b/container_shell/lib/dockage.py index af7dff6..7c232fd 100644 --- a/container_shell/lib/dockage.py +++ b/container_shell/lib/dockage.py @@ -144,9 +144,9 @@ def container_command(username, user_uid, user_gid, create_user, command, runuse fix_pty_ownership = 'chown {0}:{0} /dev/pts/0 2>/dev/null'.format(username) everything = "/bin/bash -c '{0} && {1} && {2} ; {3}'".format(make_group, - make_user, - fix_pty_ownership, - run_user) + make_user, + fix_pty_ownership, + run_user) elif command: everything = command else: