Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when HOME is not set #914

Open
cdegroot opened this issue Oct 27, 2022 · 2 comments
Open

Crash when HOME is not set #914

cdegroot opened this issue Oct 27, 2022 · 2 comments

Comments

@cdegroot
Copy link

We use the "three-step" auth method as documented: env var, ~/.aws profile, ecs/instance profile. This allows our code to run on a variety of platforms with a single configuration and it works perfectly.

Today, I installed said code as a systemctl-managed daemon and that failed:

Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]: 16:11:21.232 [info]  Getting secret /dev1/rds/projections-user#host from region us-east-1
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]: 16:11:21.233 [error] GenServer ExAws.Config.AuthCache terminating
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]: ** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]:     (elixir 1.13.4) lib/io.ex:627: IO.chardata_to_string(nil)
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]:     (elixir 1.13.4) lib/path.ex:538: Path.join/2
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]:     (ex_aws 2.4.0) lib/ex_aws/credentials_ini/file.ex:187: ExAws.CredentialsIni.File.profile_from_config/1
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]:     (ex_aws 2.4.0) lib/ex_aws/credentials_ini/file.ex:13: ExAws.CredentialsIni.File.security_credentials/1
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]:     (ex_aws 2.4.0) lib/ex_aws/config.ex:158: ExAws.Config.awscli_auth_credentials/2
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]:     (ex_aws 2.4.0) lib/ex_aws/config/auth_cache.ex:65: ExAws.Config.AuthCache.refresh_awscli_config/3
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]:     (ex_aws 2.4.0) lib/ex_aws/config/auth_cache.ex:50: ExAws.Config.AuthCache.handle_call/3
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]:     (stdlib 4.0.1) gen_server.erl:1146: :gen_server.try_handle_call/4
Oct 27 16:11:21 ip-192-168-0-140 metrist-orchestrator[18820]: Last message (from Orchestrator.MonitorSupervisor): {:refresh_awscli_conf

The cause is clear: the code in file.ex uses System.user_home() which ends up basically reading the HOME environment variable.

The fix could be simple as well: System.user_home() || "/" would already do the trick and is sort of the expected behavior on Unix systems - if there is no home set, the root directory will do. In most cases, this should be invisible but I'm filing this as an issue rather than as a PR because it's likely to be one of these things that people want to discuss :)

@bernardd
Copy link
Contributor

That's totally fine with me - any relatively sane behaviour is preferable to a crash :) A PR to that effect would be most welcome.
Apologies for the delay getting back to you.

@pcapel
Copy link

pcapel commented Feb 16, 2023

Seems like this is related to #932. If there's not ongoing work to this effect I'd be happy to include this protection in my PR pending a review of the desirable changes with a maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants