]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
upload: warn users trying to upload from stdin with anyauth
authorDaniel Stenberg <daniel@haxx.se>
Tue, 6 Jul 2010 21:25:32 +0000 (23:25 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 6 Jul 2010 21:25:32 +0000 (23:25 +0200)
Since uploading from stdin is very likely to not work with anyauth and
its multi-phase probing for what authentication to actually use, alert
the user about it. Multi-phase negotiate almost certainly will involve
sending data and thus libcurl will need to rewind the stream to send
again, and it cannot do that with stdin.

src/main.c

index 709f6206a99f71b1e7107e33cbeb33f1dd364bbf..7aa698505b47aa659f42fb96d29f4645e948e882 100644 (file)
@@ -4920,6 +4920,31 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
 
         }
         else if(uploadfile && stdin_upload(uploadfile)) {
+          /* count to see if there are more than one auth bit set
+             in the authtype field */
+          int authbits = 0;
+          int bitcheck = 0;
+          while(bitcheck < 32) {
+            if(config->authtype & (1 << bitcheck)) {
+              authbits++;
+              if(authbits > 1) {
+                /* more than one, we're done! */
+                break;
+              }
+            }
+          }
+
+          /*
+           * If the user has also selected --anyauth or --proxy-anyauth
+           * we should warn him/her.
+           */
+          if(config->proxyanyauth || (authbits>1)) {
+            warnf(config,
+                  "Using --anyauth or --proxy-anyauth with upload from stdin"
+                  " involves a big risk of it not working. Use a temporary"
+                  " file or a fixed auth type instead!\n");
+          }
+
           SET_BINMODE(stdin);
           infd = STDIN_FILENO;
           if (curlx_strequal(uploadfile, ".")) {