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

Make curl honor the ~/.netrc file #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tknerr
Copy link

@tknerr tknerr commented Oct 21, 2022

This PR adds the -n (i.e. --netrc) flag to all curl invocations across all molior-tools scripts.

With the -n flag present, curl will honor the presence of a ~/.netrc file and will read the login information from there.

  • if no ~/.netrc is present, curl will silently ignore that and continue without authentication
  • if ~/.netrc is present, but no matching "machine" entry found, curl will silently ignore that and continue without authentication
  • if ~/.netrc is present and a matching "machine" entry is found, it will authenticate with the "username" + "password" specified there

This allows you:

  • to use molior tools with a molior server / mirror which require authentication (e.g. molior-deploy -m https://my.mirror.org ...
  • to use apt sources from a mirror which requires authentication (e.g. molior -p /my/apt/mirror.list ...)

See also:
https://everything.curl.dev/usingcurl/netrc

@@ -268,7 +268,7 @@ COOKIE_FILE="$(mktemp)"
molior_session_call()
{
URL_PATH="$1" && shift
curl $MOLIOR_URL$URL_PATH -s --retry 10 \
curl $MOLIOR_URL$URL_PATH -n -s --retry 10 \
Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure if we should add the -n here, because a few lines further down we explicitly pass the $MOLIOR_USERNAME and $MOLIOR_PASSWORD to curl (matching .netrc credentials will likely override these)

@@ -41,7 +41,7 @@ COOKIE_FILE=`mktemp`
molior_session_call()
{
URL_PATH="$1" && shift
curl $MOLIOR_URL$URL_PATH -s --retry 10 \
curl $MOLIOR_URL$URL_PATH -n -s --retry 10 \
Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure if we should add the -n here, because a few lines further down we explicitly pass the $MOLIOR_USERNAME and $MOLIOR_PASSWORD to curl (matching .netrc credentials will likely override these)

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.

1 participant