@@ -157,7 +157,11 @@ kurl_t *kurl_open(const char *url, kurl_opt_t *opt)
157
157
if (strstr (url , "s3://" ) == url ) {
158
158
s3aux_t a ;
159
159
struct curl_slist * slist = 0 ;
160
- a = s3_parse (url , 0 , 0 , 0 );
160
+ a = s3_parse (url , (opt ? opt -> s3keyid : 0 ), (opt ? opt -> s3secretkey : 0 ), (opt ? opt -> s3key_fn : 0 ));
161
+ if (a .url == 0 || a .date == 0 || a .auth == 0 ) {
162
+ kurl_close (ku );
163
+ return 0 ;
164
+ }
161
165
ku -> hdr = curl_slist_append (ku -> hdr , a .date );
162
166
ku -> hdr = curl_slist_append (ku -> hdr , a .auth );
163
167
curl_easy_setopt (ku -> curl , CURLOPT_URL , a .url );
@@ -168,8 +172,6 @@ kurl_t *kurl_open(const char *url, kurl_opt_t *opt)
168
172
curl_easy_setopt (ku -> curl , CURLOPT_VERBOSE , 0L );
169
173
curl_easy_setopt (ku -> curl , CURLOPT_NOSIGNAL , 1L );
170
174
curl_easy_setopt (ku -> curl , CURLOPT_WRITEFUNCTION , write_cb );
171
- if (opt && opt -> usrpwd )
172
- curl_easy_setopt (ku -> curl , CURLOPT_USERPWD , opt -> usrpwd );
173
175
}
174
176
ku -> m_buf = KU_DEF_BUFLEN ;
175
177
if (!kurl_isfile (ku ) && ku -> m_buf < CURL_MAX_WRITE_SIZE * 2 )
@@ -421,10 +423,10 @@ int main(int argc, char *argv[])
421
423
// s3_parse("s3://lh3test/44X.bam.bai", 0, 0, 0); return 0;
422
424
423
425
memset (& opt , 0 , sizeof (kurl_opt_t ));
424
- while ((c = getopt (argc , argv , "c:l:u :" )) >= 0 ) {
426
+ while ((c = getopt (argc , argv , "c:l:a :" )) >= 0 ) {
425
427
if (c == 'c' ) start = strtol (optarg , & p , 0 );
426
428
else if (c == 'l' ) rest = strtol (optarg , & p , 0 );
427
- else if (c == 'u ' ) opt .usrpwd = optarg ;
429
+ else if (c == 'a ' ) opt .s3key_fn = optarg ;
428
430
}
429
431
if (optind == argc ) {
430
432
fprintf (stderr , "Usage: kurl [-c start] [-l length] <url>\n" );
0 commit comments