-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[database] enable userns-remap and make redis process runs as non-root user #15972
Conversation
Signed-off-by: Mai Bui <[email protected]>
is there a design doc? |
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
fi | ||
chgrp -f -R redis "$(dirname "$REDIS_SOCK")" && \ | ||
chmod -f -R 0775 "$(dirname "$REDIS_SOCK")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/var/run/redis/
needs 775 for sufficient permission to get Redis start if /var/run/redis/
is owned by group redis
. /var/run/redis/sonic-db/
need 755 if owned by root
group or 775 if /var/run/redis/sonic-db/
is owned by redis
group to pass kvm testcase iface_namingmode/test_iface_namingmode.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because iface_namingmode/test_iface_namingmode.py
creates a guest
user and guest
user is not added to redis
group. 770 or 760 will not work because guest
user cannot access sonic database configuration json file.
https://github.com/sonic-net/sonic-mgmt/blob/master/tests/iface_namingmode/test_iface_namingmode.py#L124-L126
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe the dir user/group ownership need to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@lguohan I will draft a design doc. |
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
/azp run Azure.sonic-buildimage |
Commenter does not have sufficient privileges for PR 15972 in repo sonic-net/sonic-buildimage |
/azpw run Azure.sonic-buildimage |
/AzurePipelines run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -43,6 +43,9 @@ HOSTNAME=sonic | |||
DEFAULT_USERINFO="Default admin user,,," | |||
BUILD_TOOL_PATH=src/sonic-build-hooks/buildinfo | |||
TRUSTED_GPG_DIR=$BUILD_TOOL_PATH/trusted.gpg.d | |||
## Remapped docker usernames and group names | |||
REMAPREDIS=remapredis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question - should we use a meaningful name here? remapredis doesn't sound like something that is describing this item.
Maybe use unpriv-redis? Do depict what we intend this user to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can mutually agree on better variable name here
sudo LANG=C chroot $FILESYSTEM_ROOT usermod -aG $REMAPREDIS $USERNAME | ||
## Create remapped docker root user and group | ||
sudo LANG=C chroot $FILESYSTEM_ROOT groupadd -f -g $START_UID $REMAPROOT | ||
sudo LANG=C chroot $FILESYSTEM_ROOT useradd -u $START_GID -g $REMAPROOT $REMAPROOT -c "remapped docker root user" -m -s /bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the docker root user or the system root user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's docker root user inside container, but it's remapped to lower privileged user on host.
@@ -0,0 +1,3 @@ | |||
{ | |||
"userns-remap": "admin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the name of our NS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, admin
is not the name of a namespace, but rather the username for the user namespace remapping in Docker
Dependency:
#13783
#15176
Why I did it
Enable user namespace remapping technique for database docker.
Running the Redis server as the "root" user is not recommended. It is suggested that the server should be operated by a non-privileged user.
Work item tracking
How I did it
Add a userns-remap in the /etc/docker/daemon.json file to enable user namespace remap.
Ensure the Redis process is operating under the 'redis' user in supervisord and adjust the necessary file permissions accordingly.
How to verify it
Built new image, verify redis process is running as 'redis' user and all containers are up. Processes remapped to lower privileged user on host.
Before
After
Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)