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

pythd throws when HOME undefined #286

Open
gmarkey opened this issue Sep 6, 2022 · 3 comments
Open

pythd throws when HOME undefined #286

gmarkey opened this issue Sep 6, 2022 · 3 comments

Comments

@gmarkey
Copy link

gmarkey commented Sep 6, 2022

pythd crashes with the following when getenv ( "HOME" ) returns nullptr:

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid
Aborted

HOME being undefined is not common and in my case may be an artifact of what nitro-cli is doing under the hood, but figured this would be helpful for anyone who runs into the same issue. A quick test to ensure the envvar is defined and provide less cryptic output may also be helpful.

@matt-allan
Copy link

I ran into this when trying to run pythd as a systemd service. What worked was running it as a specific user instead, i.e.

[Service]
Type=simple
ExecStart=/usr/local/bin/pythd {...rest of the args}
User=myuser
Group=myuser

@SLoeuillet
Copy link

Had the same issue with systemd unit & DynamicUser=true

@SLoeuillet
Copy link

SLoeuillet commented Nov 15, 2022

/opt/pyth-client/git/pcapps/pyth_admin.cpp:15:static const std::string DEFAULT_KEY_STORE = std::string( getenv( "HOME" ) ) + "/.pythd/";
/opt/pyth-client/git/pcapps/pyth_admin.cpp-16-
--
/opt/pyth-client/git/pcapps/pyth.cpp:15:static const std::string DEFAULT_KEY_STORE = std::string( getenv( "HOME" ) ) + "/.pythd/";
/opt/pyth-client/git/pcapps/pyth.cpp-16-
--
/opt/pyth-client/git/pcapps/pythd.cpp:23:  std::string dir = getenv("HOME");
/opt/pyth-client/git/pcapps/pythd.cpp-24-  return dir + "/.pythd/";

Never trust user input, including ENV_VARs

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