workspaces-issues icon indicating copy to clipboard operation
workspaces-issues copied to clipboard

[Feature Request] - Pass KASM user name to docker

Open dmitriyTmax opened this issue 2 years ago • 3 comments

Need to be able to pass KASM username to docker. Example: instead of kasm-user, use the name of the current user admin@localhost

dmitriyTmax avatar Oct 15 '23 18:10 dmitriyTmax

There is a group setting named expose_user_environment_vars , When set , KASM_USER and KASM_USER_ID will be exposed as environment variables in the container sessions.

https://kasmweb.com/docs/latest/guide/groups/group_settings.html

j-travis avatar Oct 16 '23 11:10 j-travis

image Whoami returns kasm-user instead of returning the KASM username. That's the kind of opportunity I'm talking about.

dmitriyTmax avatar Oct 19 '23 12:10 dmitriyTmax

I would look into scripting the modifications to prep the environment per your requirements.

One easy way to do that is to leverage the File Mapping feature to Run a Script As Root when the container session starts.

For Example, this short example script modifies /etc/passwd assuming you've enabled expose_user_environment_vars to ensure the KASM_USER environment variable is present . I'm not totally sure of the implications and stability of this so use at your own risk, but its an example you can start from. For example I don't thing the @ is posix compliant so you may want to parse that

#!/usr/bin/env bash
set -ex
sed -i "s/kasm-user/$KASM_USER/g" /etc/passwd

image

image

j-travis avatar Nov 01 '23 12:11 j-travis