trek10inc / awsume

A utility for easily assuming AWS IAM roles from the command line.
https://awsu.me
MIT License
485 stars 90 forks source link

`awsume-configure` adds non-posix commands to `~/.profile` #183

Closed Georift closed 10 months ago

Georift commented 2 years ago

Hi there! Thanks for this project!

For the past little while I've been having some issues with my computers login screen. After putting it off for far to long (read months...) I did some digging and believe it was caused by installing this package.

I'm running a Debian system, and if I follow the installation instructions:

pip3 install awsume
awsume-configure

I found the following is added to my ~/.profile:

#AWSume alias to source the AWSume script
alias awsume="source awsume"

#Auto-Complete function for AWSume
_awsume() {
    local cur prev opts
    COMPREPLY=() #### <---- this line is causing errors
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts=$(awsume-autocomplete)
    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    return 0
}
complete -F _awsume awsume

Now from what I can see in the source code, this is exactly as we're intending when running this command. However I believe this is using a non-posix feature, and at least in Debian ~/.profile is executed using sh which was causing my login screen to fail.

Apr 21 21:52:37 computer /usr/libexec/gdm-x-session[50583]: /etc/gdm3/Xsession: 35: /home/georift/.profile: Syntax error: "(" unexpected (expecting "}")

Here is at least one related issue that the rust community fixed suggesting it might be worth keeping ~/.profile posix compliant.

And finally here's a quick debian repro:

docker run --rm debian:buster-slim /bin/bash -c "sh ~/.profile && apt update && apt install -y python3 python3-pip && pip3 install awsume && awsume-configure && sh ~/.profile"
mtskillman commented 10 months ago

thanks for this one @Georift -- we will adjust this

mtskillman commented 10 months ago

addressed by PR #231