reitzig / sdkman-for-fish

Adds support for SDKMAN! to fish
MIT License
280 stars 13 forks source link

SDKMAN environment variables don't change when su-ing to another user #25

Open reitzig opened 5 years ago

reitzig commented 5 years ago

Run the following commands:

$ whoami
raphael
$ echo $SDKMAN_CANDIDATES_DIR
/home/raphael/.sdkman/candidates
$ su dhtp
Password: 
$ whoami 
dhtp
$ echo $SDKMAN_CANDIDATES_DIR

Expected: /home/dhtp/.sdkman/candidates

Actual: /home/raphael/.sdkman/candidates

reitzig commented 5 years ago

In conf.d/sdk.fish, we re-initialize SDKMAN if not set -q SDKMAN_DIR. This is not enough here: the variable is set (inherited from the shell where su was called), provided the user making that call has SDKMAN installed. If there is sufficient access, sdk will even work.

reitzig commented 5 years ago

Since an automated test seems to be more involved to set up, efficacy of the fix was confirmed by manual testing.

Only: turns out that sdkman-init.sh has the same issue, it won't overwrite existing but wrong values of the environment variables.

reitzig commented 4 years ago

I created a PR upstream: sdkman/sdkman-cli/pull/718