Opkg support for smime (pkcs7) packages list signing
[oweals/opkg-lede.git] / libopkg / opkg_cmd.c
index f0ac3f75c94a6e929d86a52df3d47d12b45c99e5..4a0410ce32774e5de927421aa14ed54f05dd5978 100644 (file)
@@ -167,7 +167,7 @@ int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **arg
        result = (cmd->fun)(conf, argc, argv);
 
         if ( result != 0 && !error_list) {
-           opkg_message(conf, OPKG_NOTICE, "An error ocurred, return value: %d.\n", result);
+           opkg_message(conf, OPKG_NOTICE, "An error occurred, return value: %d.\n", result);
         }
 
         opkg_print_error_list (conf);
@@ -259,8 +259,7 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
                            list_file_name);
          }
          free(url);
-
-#ifdef HAVE_GPGME
+#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
           if (conf->check_signature) {
               /* download detached signitures to verify the package lists */
               /* get the url for the sig file */
@@ -273,7 +272,8 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
               /* create temporary file for it */
               char *tmp_file_name;
 
-              sprintf_alloc (&tmp_file_name, "%s/%s", tmp, "Packages.sig");
+              /* Put the signature in the right place */
+              sprintf_alloc (&tmp_file_name, "%s/%s.sig", lists_dir, src->name);
 
               err = opkg_download(conf, url, tmp_file_name, NULL, NULL);
               if (err) {
@@ -287,7 +287,8 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
                   else
                       opkg_message (conf, OPKG_NOTICE, "Signature check failed\n");
               }
-              unlink (tmp_file_name);
+              /* We shouldn't unlink the signature ! */
+              // unlink (tmp_file_name);
               free (tmp_file_name);
               free (url);
           }
@@ -379,6 +380,7 @@ static int opkg_finalize_intercepts(opkg_intercept_t ctx)
            }
            free (path);
        }
+        closedir(dir);
     } else
        perror (ctx->statedir);