Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 43f5c81

Browse files
committedMay 9, 2023
Include --netrc-file option when calling curl
Resolves: #401 Signed-off-by: Sergio Arroutbi <[email protected]>
1 parent c1a8aff commit 43f5c81

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed
 

‎src/pins/tang/clevis-decrypt-tang

+12-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,18 @@ xfr="$(jose jwk exc -i '{"alg":"ECMR"}' -l- -r- <<< "$clt$eph")"
101101

102102
rec_url="$url/rec/$kid"
103103
ct="Content-Type: application/jwk+json"
104-
if ! rep="$(curl -sfg -X POST -H "$ct" --data-binary @- "$rec_url" <<< "$xfr")"; then
104+
105+
# Check if netrc-file option exists
106+
curl_net_rc_option="--netrc-file"
107+
curl_net_rc_file="/etc/clevis/clevis_netrc.conf"
108+
netrc="$(curl --help all | grep netrc-file)" || true
109+
if [ -z "${netrc}" ];
110+
then
111+
curl_net_rc_option=""
112+
curl_net_rc_file=""
113+
fi
114+
115+
if ! rep="$(curl "${curl_net_rc_option}" "${curl_net_rc_file}" -sfg -X POST -H "$ct" --data-binary @- "$rec_url" <<< "$xfr")"; then
105116
echo "Error communicating with server $url" >&2
106117
exit 1
107118
fi

‎src/pins/tang/clevis-encrypt-tang

+11-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ if ! url="$(jose fmt -j- -Og url -u- <<< "$cfg")"; then
7575
exit 1
7676
fi
7777

78+
# Check if netrc-file option exists
79+
curl_net_rc_option="--netrc-file"
80+
curl_net_rc_file="/etc/clevis/clevis_netrc.conf"
81+
netrc="$(curl --help all | grep netrc-file)" || true
82+
if [ -z "${netrc}" ];
83+
then
84+
curl_net_rc_option=""
85+
curl_net_rc_file=""
86+
fi
87+
7888
thp="$(jose fmt -j- -Og thp -Su- <<< "$cfg")" || true
7989

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

94104
thp="${thp:-any}"
95-
elif ! jws="$(curl -sfg "$url/adv/$thp")"; then
105+
elif ! jws="$(curl "${curl_net_rc_option}" "${curl_net_rc_file}" -sfg "$url/adv/$thp")"; then
96106
echo "Unable to fetch advertisement: '$url/adv/$thp'!" >&2
97107
exit 1
98108
fi

0 commit comments

Comments
 (0)
Please sign in to comment.