Comment 18 for bug 524226

Revision history for this message
Jamie Strandboge (jdstrand) wrote : Re: ssh-import-id: retrieve a key from a public keyserver and add to the authorized_keys file

Dustin,

Thanks for your work on this. I have a couple of small nits and a bug fix:
1. in url_encode(), error(), warn() and info() you use something like 'printf "ERROR: $@\n"'. It would be better to use something like 'printf "ERROR: %s\n" "$@"'

2. env -i isn't doing what you want here. You prefix env -i at the beginning of a command. Eg, compare the difference between these commands:
$ env -i sh -c "set"
$ sh -c "set"

I think it is probably overkill to do this for every command. The only one I would probably use it on is 'wget', since we are trusting it to handle the ssl certificate properly. Even this is probably a bit pedantic. But, it wouldn't hurt:
if env -i wget --quiet -O- "$url" > "$tmp"; then...

3. there is a bug when calculating 'lines' in validate_keys(). wc returns 0 if it doesn't have a newline, which the wget response may not. I suggest doing:
echo "" >> "$tmp" # needed for wc
if ! validate_keys "$tmp"; then
...