]> pd.if.org Git - zpackage/blobdiff - src/fetchurl.c
add more information for host cert change
[zpackage] / src / fetchurl.c
index 395ce9573f5f444c61c1c2a66860e639864d12eb..1ef4abd2c1f70901b01ca1ff020e4ce9d20e7278 100644 (file)
@@ -15,7 +15,6 @@
 #include <fcntl.h>
 
 #include "tlse.h"
-#define MARK fprintf(stderr, "%s %s:%d\n", __FILE__, __func__, __LINE__)
 
 struct tls_uri {
        char *scheme;
@@ -207,6 +206,11 @@ int verify_first(struct TLSContext *context, struct TLSCertificate **chain, int
                }
 
                int match = (memcmp(certhash, fp, 64) == 0); 
+               if (!match) {
+                       fprintf(stderr, "host %s certificate changed\n", host);
+                       fprintf(stderr, "was %.64s\n", fp);
+                       fprintf(stderr, "now %.64s\n", certhash);
+               }
 
                close(trustdb);
                tls_buffer_free(&tbuf);
@@ -587,7 +591,7 @@ int main(int ac, char *av[]) {
 
        ltc_mp = tfm_desc;
 
-       while ((option = getopt(ac, av, "o:OrIfz:n#R:SkK")) != -1) {
+       while ((option = getopt(ac, av, "o:OrIfz:np#R:SkK")) != -1) {
                switch (option) {
                        case 'o': outfile = optarg; break;
                        case 'O': calcoutfile = 1; break;
@@ -600,6 +604,7 @@ int main(int ac, char *av[]) {
                        case 'z': lmfile = optarg; break;
                        case 'n': ifnewer = 1; break;
                        case 'R': redirlimit = strtol(optarg, 0, 10); break;
+                       case 'p':
                        case '#': progressbar = 1; break;
                        default:
                                  exit(EXIT_FAILURE);
@@ -777,6 +782,7 @@ int main(int ac, char *av[]) {
 
                switch (io.status_code) {
                        case 304:
+                               progressbar = 0;
                                break;
                        case 301:
                        case 302:
@@ -825,11 +831,8 @@ int main(int ac, char *av[]) {
                                        pdots(50, '.', total, total+ret,
                                                        io.content_length);
                                } else {
-                                       int old = total / 1000000;
-                                       int new = (total+ret)/1000000;
-                                       while (old < new) {
-                                               putc('.',stderr);
-                                       }
+                                       putc('\r', stderr);
+                                       fprintf(stderr, "%zu", total+ret);
                                }
                                total += ret;
                        }