Skip to content

config::load_credentials: Support credentials script on Unix #5899

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

Closed
wants to merge 2 commits into from
Closed

config::load_credentials: Support credentials script on Unix #5899

wants to merge 2 commits into from

Conversation

nbraud
Copy link

@nbraud nbraud commented Aug 16, 2018

This allows providing an executable ~/.cargo/credentials files, which is executed and its standard output is used where we would currently use the contents of the file.

An example use-case would be to pull the crates.io credentials from a password manager rather than storing them in plaintext on disk:

#!/bin/sh -e
cat <<EOF
[registry]
token = "$(pass crates.io)"
EOF

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matklad (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

)
})?;

if cfg!(not(unix)) || (metadata.mode() & 0100 == 0) {
Copy link
Author

Choose a reason for hiding this comment

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

I (surprisingly) couldn't find something better to do than metadata.mode() & 0100 == 0 to check if the file is executable.
This is technically incorrect, as the executable bit cargo should check depends on the file's ownership.

nbraud added 2 commits August 16, 2018 23:06
This allows providing an executable `~/.cargo/credentials` files, which is
executed and its standard output is used where we would currently use the
contents of the file.

An example use-case would be to pull the crates.io credentials from a password
manager rather than storing them in plaintext on disk:

  #!/bin/sh -e
  cat <<EOF
  [registry]
  token = "$(pass crates.io)"
  EOF
@alexcrichton
Copy link
Member

Thanks for the PR! This is a relatively large feature though and I'd be hesitant to accept it purely with a PR. This is something I think we'll want to have more discussion about either on the internal forums or on an RFC. Would you be willing to write and RFC for this or start a thread on internals?

@dwijnand
Copy link
Member

See also #5638, which is also about avoiding storing secrets in ~/.cargo/credentials.

@joshtriplett
Copy link
Member

The idea of executing a script to get this information seems interesting, but I'd be hesitant to make that script be ~/.cargo/credentials rather than a new file path.

@alexcrichton
Copy link
Member

Ok this has been quite for quite some time now, so I'm going to close this. It can of course be resubmitted though with some discussion on internals and such!

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.

6 participants