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

Include --netrc-file when calling curl #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/pins/tang/clevis-decrypt-tang
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,18 @@ xfr="$(jose jwk exc -i '{"alg":"ECMR"}' -l- -r- <<< "$clt$eph")"

rec_url="$url/rec/$kid"
ct="Content-Type: application/jwk+json"
if ! rep="$(curl -sfg -X POST -H "$ct" --data-binary @- "$rec_url" <<< "$xfr")"; then

# Check if netrc-file option exists
curl_net_rc_option="--netrc-file"
curl_net_rc_file="/etc/clevis/clevis_netrc.conf"
netrc="$(curl --help all | grep netrc-file)" || true
if [ -z "${netrc}" ];
then
curl_net_rc_option=""
curl_net_rc_file=""
fi

if ! rep="$(curl "${curl_net_rc_option}" "${curl_net_rc_file}" -sfg -X POST -H "$ct" --data-binary @- "$rec_url" <<< "$xfr")"; then
echo "Error communicating with server $url" >&2
exit 1
fi
Expand Down
12 changes: 11 additions & 1 deletion src/pins/tang/clevis-encrypt-tang
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ if ! url="$(jose fmt -j- -Og url -u- <<< "$cfg")"; then
exit 1
fi

# Check if netrc-file option exists
curl_net_rc_option="--netrc-file"
curl_net_rc_file="/etc/clevis/clevis_netrc.conf"
netrc="$(curl --help all | grep netrc-file)" || true
if [ -z "${netrc}" ];
then
curl_net_rc_option=""
curl_net_rc_file=""
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
fi

thp="$(jose fmt -j- -Og thp -Su- <<< "$cfg")" || true

### Get the advertisement
Expand All @@ -92,7 +102,7 @@ elif jws="$(jose fmt -j- -g adv -Su- <<< "$cfg")"; then
fi

thp="${thp:-any}"
elif ! jws="$(curl -sfg "$url/adv/$thp")"; then
elif ! jws="$(curl "${curl_net_rc_option}" "${curl_net_rc_file}" -sfg "$url/adv/$thp")"; then
echo "Unable to fetch advertisement: '$url/adv/$thp'!" >&2
exit 1
fi
Expand Down
Loading