1. 27
  1. 20

    Also something I found out about recently, was the ability to quickly turn a curl command into a native executable via the –libcurl flag and a generated C file, see https://austingwalters.com/export-a-command-line-curl-command-to-an-executable for an example.

    1. 1

      This is neat, but why does it need: curl_easy_setopt(hnd, CURLOPT_SSH_KNOWNHOSTS, "/home/austin/.ssh/known_hosts"); ? That seems odd.

      1. 1

        If you build curl with libssh2, it works with SFTP!

        Why the static home dir.. who knows.

        1. 1

          Looking at the source code, specifically src/tool_operate.c:1490, it seems like this is used for SCP/SFTP protocol support. As far as I can tell, curl reads known_hosts so it doesn’t bother you when accessing known hosts via those protocols. But don’t take my word for it, the source code is public and that’s amazing!

          1. 1

            Well, yes. The point that I’m making is that the URL is provided in the example, and can be trivially introspected to see that it’s an https:// not an scp / sftp URL. This would mean that setting SSH_KNOWNHOSTS is silly. Perhaps this is a “bug,” and it shouldn’t do this. Perhaps there’s some fun thing that requires this, even though I can see no legitimate reason for it… Free idea if you wanna get code into libcurl, I guess…

      2. 4

        The “exercises” format used here works quite well for self-studying – does anyone know of similar articles?

        1. 6

          Oh, boy, you’re in for a treat. This is a comprehensive overview of the general concept with lots of references: https://www.gwern.net/Spaced-repetition