libopkg: remove Curl support
authorJo-Philipp Wich <jo@mein.io>
Sat, 18 Feb 2017 14:04:02 +0000 (15:04 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sat, 18 Feb 2017 14:04:02 +0000 (15:04 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg/opkg.c
libopkg/opkg_conf.c
libopkg/opkg_conf.h
libopkg/opkg_download.c
libopkg/opkg_download.h
src/opkg-cl.c

index 99e8c6de08d4d3308341b3fec1f4ea1cd5a6c64b..c58d54d2346b5c92abb7d2afd6845949081d7fa7 100644 (file)
@@ -137,9 +137,6 @@ err0:
 
 void opkg_free(void)
 {
 
 void opkg_free(void)
 {
-#ifdef HAVE_CURL
-       opkg_curl_cleanup();
-#endif
        opkg_conf_deinit();
 }
 
        opkg_conf_deinit();
 }
 
index 03a94897258fcccf8439fcb8d9bd82e9a6d47064..bed4d143e1fc9b7d5ccf0a5fd12cc77a9cc20fab 100644 (file)
@@ -73,18 +73,6 @@ opkg_option_t options[] = {
 #if defined(HAVE_OPENSSL)
        {"signature_ca_file", OPKG_OPT_TYPE_STRING, &_conf.signature_ca_file},
        {"signature_ca_path", OPKG_OPT_TYPE_STRING, &_conf.signature_ca_path},
 #if defined(HAVE_OPENSSL)
        {"signature_ca_file", OPKG_OPT_TYPE_STRING, &_conf.signature_ca_file},
        {"signature_ca_path", OPKG_OPT_TYPE_STRING, &_conf.signature_ca_path},
-#endif
-#if defined(HAVE_SSLCURL) && defined(HAVE_CURL)
-       {"ssl_engine", OPKG_OPT_TYPE_STRING, &_conf.ssl_engine},
-       {"ssl_cert", OPKG_OPT_TYPE_STRING, &_conf.ssl_cert},
-       {"ssl_cert_type", OPKG_OPT_TYPE_STRING, &_conf.ssl_cert_type},
-       {"ssl_key", OPKG_OPT_TYPE_STRING, &_conf.ssl_key},
-       {"ssl_key_type", OPKG_OPT_TYPE_STRING, &_conf.ssl_key_type},
-       {"ssl_key_passwd", OPKG_OPT_TYPE_STRING, &_conf.ssl_key_passwd},
-       {"ssl_ca_file", OPKG_OPT_TYPE_STRING, &_conf.ssl_ca_file},
-       {"ssl_ca_path", OPKG_OPT_TYPE_STRING, &_conf.ssl_ca_path},
-       {"ssl_dont_verify_peer", OPKG_OPT_TYPE_BOOL,
-        &_conf.ssl_dont_verify_peer},
 #endif
        {NULL, 0, NULL}
 };
 #endif
        {NULL, 0, NULL}
 };
index acb7fa0cd8467e178b3a7d5bca46aee44981578b..9cf76811a184591e913ff683c198203827b18e10 100644 (file)
@@ -89,22 +89,6 @@ struct opkg_conf {
        int download_only;
        char *cache;
 
        int download_only;
        char *cache;
 
-#ifdef HAVE_SSLCURL
-       /* some options could be used by
-        * wget if curl support isn't builtin
-        * If someone want to try...
-        */
-       char *ssl_engine;
-       char *ssl_cert;
-       char *ssl_cert_type;
-       char *ssl_key;
-       char *ssl_key_type;
-       char *ssl_key_passwd;
-       char *ssl_ca_file;
-       char *ssl_ca_path;
-       int ssl_dont_verify_peer;
-#endif
-
        /* proxy options */
        char *http_proxy;
        char *ftp_proxy;
        /* proxy options */
        char *http_proxy;
        char *ftp_proxy;
index c52f0584b77641a5d1d4b5280121a55894998913..f1553abca7ae5501d178822cdd14fe7e52d784f6 100644 (file)
 #include "opkg_defines.h"
 #include "libbb/libbb.h"
 
 #include "opkg_defines.h"
 #include "libbb/libbb.h"
 
-#ifdef HAVE_CURL
-#include <curl/curl.h>
-#endif
-
-#if defined(HAVE_SSLCURL) || defined(HAVE_OPENSSL)
+#if defined(HAVE_OPENSSL)
 #include <openssl/conf.h>
 #include <openssl/evp.h>
 #include <openssl/err.h>
 #include <openssl/conf.h>
 #include <openssl/evp.h>
 #include <openssl/err.h>
@@ -50,7 +46,7 @@
 #include <openssl/hmac.h>
 #endif
 
 #include <openssl/hmac.h>
 #endif
 
-#if defined(HAVE_OPENSSL) || defined(HAVE_SSLCURL)
+#if defined(HAVE_OPENSSL)
 static void openssl_init(void);
 #endif
 
 static void openssl_init(void);
 #endif
 
@@ -58,15 +54,6 @@ static void openssl_init(void);
 static X509_STORE *setup_verify(char *CAfile, char *CApath);
 #endif
 
 static X509_STORE *setup_verify(char *CAfile, char *CApath);
 #endif
 
-#ifdef HAVE_CURL
-/*
- * Make curl an instance variable so we don't have to instanciate it
- * each time
- */
-static CURL *curl = NULL;
-static CURL *opkg_curl_init(curl_progress_func cb, void *data);
-#endif
-
 static int str_starts_with(const char *str, const char *prefix)
 {
        return (strncmp(str, prefix, strlen(prefix)) == 0);
 static int str_starts_with(const char *str, const char *prefix)
 {
        return (strncmp(str, prefix, strlen(prefix)) == 0);
@@ -120,33 +107,7 @@ opkg_download(const char *src, const char *dest_file_name,
                         conf->no_proxy);
                setenv("no_proxy", conf->no_proxy, 1);
        }
                         conf->no_proxy);
                setenv("no_proxy", conf->no_proxy, 1);
        }
-#ifdef HAVE_CURL
-       CURLcode res;
-       FILE *file = fopen(tmp_file_location, "w");
-
-       curl = opkg_curl_init(cb, data);
-       if (curl) {
-               curl_easy_setopt(curl, CURLOPT_URL, src);
-               curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
 
 
-               res = curl_easy_perform(curl);
-               fclose(file);
-               if (res) {
-                       long error_code;
-                       curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE,
-                                         &error_code);
-                       opkg_msg(hide_error ? DEBUG2 : ERROR,
-                                "Failed to download %s: %s.\n", src,
-                                curl_easy_strerror(res));
-                       free(tmp_file_location);
-                       return -1;
-               }
-
-       } else {
-               free(tmp_file_location);
-               return -1;
-       }
-#else
        {
                int res;
                const char *argv[8];
        {
                int res;
                const char *argv[8];
@@ -175,7 +136,6 @@ opkg_download(const char *src, const char *dest_file_name,
                        return -1;
                }
        }
                        return -1;
                }
        }
-#endif
 
        err = file_move(tmp_file_location, dest_file_name);
 
 
        err = file_move(tmp_file_location, dest_file_name);
 
@@ -433,7 +393,7 @@ verify_file_end:
 #endif
 }
 
 #endif
 }
 
-#if defined(HAVE_OPENSSL) || defined(HAVE_SSLCURL)
+#if defined(HAVE_OPENSSL)
 static void openssl_init(void)
 {
        static int init = 0;
 static void openssl_init(void)
 {
        static int init = 0;
@@ -502,126 +462,3 @@ end:
 }
 
 #endif
 }
 
 #endif
-
-#ifdef HAVE_CURL
-void opkg_curl_cleanup(void)
-{
-       if (curl != NULL) {
-               curl_easy_cleanup(curl);
-               curl = NULL;
-       }
-}
-
-static CURL *opkg_curl_init(curl_progress_func cb, void *data)
-{
-
-       if (curl == NULL) {
-               curl = curl_easy_init();
-
-#ifdef HAVE_SSLCURL
-               openssl_init();
-
-               if (conf->ssl_engine) {
-
-                       /* use crypto engine */
-                       if (curl_easy_setopt
-                           (curl, CURLOPT_SSLENGINE,
-                            conf->ssl_engine) != CURLE_OK) {
-                               opkg_msg(ERROR,
-                                        "Can't set crypto engine '%s'.\n",
-                                        conf->ssl_engine);
-
-                               opkg_curl_cleanup();
-                               return NULL;
-                       }
-                       /* set the crypto engine as default */
-                       if (curl_easy_setopt
-                           (curl, CURLOPT_SSLENGINE_DEFAULT, 1L) != CURLE_OK) {
-                               opkg_msg(ERROR,
-                                        "Can't set crypto engine '%s' as default.\n",
-                                        conf->ssl_engine);
-
-                               opkg_curl_cleanup();
-                               return NULL;
-                       }
-               }
-
-               /* cert & key can only be in PEM case in the same file */
-               if (conf->ssl_key_passwd) {
-                       if (curl_easy_setopt
-                           (curl, CURLOPT_SSLKEYPASSWD,
-                            conf->ssl_key_passwd) != CURLE_OK) {
-                               opkg_msg(DEBUG,
-                                        "Failed to set key password.\n");
-                       }
-               }
-
-               /* sets the client certificate and its type */
-               if (conf->ssl_cert_type) {
-                       if (curl_easy_setopt
-                           (curl, CURLOPT_SSLCERTTYPE,
-                            conf->ssl_cert_type) != CURLE_OK) {
-                               opkg_msg(DEBUG,
-                                        "Failed to set certificate format.\n");
-                       }
-               }
-               /* SSL cert name isn't mandatory */
-               if (conf->ssl_cert) {
-                       curl_easy_setopt(curl, CURLOPT_SSLCERT, conf->ssl_cert);
-               }
-
-               /* sets the client key and its type */
-               if (conf->ssl_key_type) {
-                       if (curl_easy_setopt
-                           (curl, CURLOPT_SSLKEYTYPE,
-                            conf->ssl_key_type) != CURLE_OK) {
-                               opkg_msg(DEBUG, "Failed to set key format.\n");
-                       }
-               }
-               if (conf->ssl_key) {
-                       if (curl_easy_setopt
-                           (curl, CURLOPT_SSLKEY, conf->ssl_key) != CURLE_OK) {
-                               opkg_msg(DEBUG, "Failed to set key.\n");
-                       }
-               }
-
-               /* Should we verify the peer certificate ? */
-               if (conf->ssl_dont_verify_peer) {
-                       /*
-                        * CURLOPT_SSL_VERIFYPEER default is nonzero (curl => 7.10)
-                        */
-                       curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
-               }
-
-               /* certification authority file and/or path */
-               if (conf->ssl_ca_file) {
-                       curl_easy_setopt(curl, CURLOPT_CAINFO,
-                                        conf->ssl_ca_file);
-               }
-               if (conf->ssl_ca_path) {
-                       curl_easy_setopt(curl, CURLOPT_CAPATH,
-                                        conf->ssl_ca_path);
-               }
-#endif
-
-               curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
-               curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
-               if (conf->http_proxy || conf->ftp_proxy) {
-                       char *userpwd;
-                       sprintf_alloc(&userpwd, "%s:%s", conf->proxy_user,
-                                     conf->proxy_passwd);
-                       curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
-                       free(userpwd);
-               }
-       }
-
-       curl_easy_setopt(curl, CURLOPT_NOPROGRESS, (cb == NULL));
-       if (cb) {
-               curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, data);
-               curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, cb);
-       }
-
-       return curl;
-
-}
-#endif
index 8fc435093148ae29dc18f5145205b18c60cf98c4..7415cf3d2c060b02f5985f14e4294472688e817e 100644 (file)
@@ -33,7 +33,4 @@ int opkg_download_pkg(pkg_t * pkg, const char *dir);
 int opkg_prepare_url_for_install(const char *url, char **namep);
 
 int opkg_verify_file(char *text_file, char *sig_file);
 int opkg_prepare_url_for_install(const char *url, char **namep);
 
 int opkg_verify_file(char *text_file, char *sig_file);
-#ifdef HAVE_CURL
-void opkg_curl_cleanup(void);
-#endif
 #endif
 #endif
index eff84a95a119c3cc391f5f1e5c8e235cf0dbc991..e73e04247708cea481814a53763f70427268fb52 100644 (file)
@@ -440,9 +440,6 @@ int main(int argc, char *argv[])
 
        err = opkg_cmd_exec(cmd, argc - opts, (const char **)(argv + opts));
 
 
        err = opkg_cmd_exec(cmd, argc - opts, (const char **)(argv + opts));
 
-#ifdef HAVE_CURL
-       opkg_curl_cleanup();
-#endif
 err1:
        opkg_conf_deinit();
 
 err1:
        opkg_conf_deinit();