Skip to content

[docker-setup]: Fix docker group membership check#2070

Merged
theasianpianist merged 3 commits intosonic-net:masterfrom
theasianpianist:master
Aug 10, 2020
Merged

[docker-setup]: Fix docker group membership check#2070
theasianpianist merged 3 commits intosonic-net:masterfrom
theasianpianist:master

Conversation

@theasianpianist
Copy link
Copy Markdown
Contributor

@theasianpianist theasianpianist commented Aug 7, 2020

Signed-off-by: Lawrence Lee [email protected]

Description of PR

Summary:
Fix the check that the user is a member of the docker group. Also moves the membership check to before any docker commands are run.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

Prevent docker commands from running without first validating that user is a member of the docker group. It is possible for a user to have docker permissions without explicitly being in the docker group (show by id -Gn <user> or groups <user>). The previous approach grepped the output of id -Gn for the docker group, which is not always reliable.

How did you do it?

Instead of searching the output of id -Gn, check if user is able to run docker info successfully. Successful execution indicates the user has docker privileges, failure means the use does not have docker privileges.

How did you verify/test it?

Remove user from docker group and run script - ensure that script exits early with correct error message about group membership.
Re-add user to docker group and run script - ensure that script completes successfully.

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

@theasianpianist theasianpianist requested review from a team and yxieca August 7, 2020 19:51
@theasianpianist theasianpianist marked this pull request as draft August 7, 2020 20:27
* Use result of `docker ps` to check for correct docker permissions instead of grepping the output of `id -Gn` since it is possible for the user to have docker permissions without the docker group showing up in `id -Gn`

Signed-off-by: Lawrence Lee <[email protected]>
@theasianpianist theasianpianist marked this pull request as ready for review August 7, 2020 20:41
@theasianpianist theasianpianist requested a review from lguohan August 8, 2020 00:09
@theasianpianist theasianpianist merged commit 1e4bccc into sonic-net:master Aug 10, 2020
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
swss

081d47b Update netlink messages handler (sonic-net#2233)
de7c3eb [IntfMgrd] Retry adding ipv6 prefix by setting disabled_ipv6 flag  (sonic-net#2267)

utilities

2716ff2 [yang] extend ConfigMgmt constructor to pass YANG options (sonic-net#2118)
9fbe2ef [debug dump] dump interface module added (sonic-net#2070)
a86da2d Add sonic-delayed.target to Application Extension .timer file generator (sonic-net#2176)
90611dd [portconfig] Allow to configure interface mtu for physical ports only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants