aws / aws/aws-ec2-instance-connect-config
`eic_curl_authorized_keys` returns incorrect exit code in some cases
- Dominant language
- Shell
- Stars
- 88
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
In [this section of the code](https://github.com/aws/aws-ec2-instance-connect-config/blob/1.1.17/src/bin/eic_curl_authorized_keys#L89-L95) `curl` is called with `-f` which causes it to return exit code 22 when the HTTP response code is >= `400`. This means that when the user doesn't have any keys for example, and the metadata service returns `404`, the script exits with code `22` due to the `set -e` in the script.
I discovered this when calling `eic_run_authorized_keys` as an additional fallback for my `AuthorizedKeysCommand` script, I was executing:
```
exec /usr/share/ec2-instance-connect/eic_run_authorized_keys "${@}"
```
Which would then cause my own script to return exit code 22, and thus no keys produced by the calling script were accepted at all either due to the non-zero code.
I am filing a bug because the logic in the script shows an intention for this to be an `exit 0` scenario.
Contributor guide
Research direction
Start with src/bin/eic_curl_authorized_keys around lines 89-95 and inspect how the curl 404 case interacts with set -e. Reproduce the no-keys metadata response, then verify that the authorized-keys command returns exit 0 while preserving the expected behavior for successful responses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100