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

Ssh key handling #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

cgwalters
Copy link

No description provided.

Otherwise it's a pain to debug.
I'm trying to run homu in a container where it's installed (as root)
to `/usr`, but we run as non-root.  This follows general best practice
that apps shouldn't be able to mutate their code.

However, we were trying to write the ssh key to `/usr`.  Fix this by
generating a tempfile.  This is also more secure as it closes a prior
race condition where we'd write the file, then chown it.

Also rework things so that we only write the key once at startup.  By
using `NamedTemporaryFile`, it'll be `unlink()ed` once the object goes
out of scope.  To keep it alive long enough, pass it as an argument to
the "main loop".
@cgwalters
Copy link
Author

@Manishearth would you mind reviewing this?

@Manishearth
Copy link
Contributor

I'm a bit swamped, but I'll queue it up.

import shlex
import tempfile
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for the use of tempfile!

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

Successfully merging this pull request may close these issues.

3 participants