summaryrefslogtreecommitdiffstats
path: root/libopkg/opkg_install.c
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-10-27 08:45:12 (EDT)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-10-27 08:45:12 (EDT)
commit29b3b9d76a8d6b9af6d6465a9f501c2e5066bea0 (patch)
treeb08bf81538bbd8bcc95382ce4fc608185681ac33 /libopkg/opkg_install.c
parentc7c3693656e4078011ea3f2a3b86f31e37b99e64 (diff)
Add sha256 ckecksums to okpg
Thanks to Camille Moncelier <moncelier@devlife.org> http://groups.google.com/group/opkg-devel/browse_thread/thread/78a2eb328da0ef73?utoken=pV1Kli0AAADKDldt5ZXsDDLs9sWCpWZI0mClVcTs45ANzZ7C9NH-1YGBxa5Bow63PTuzFmQCb1c Here is a patch which adds sha256 checksum checking to Opkg. More Opkg patches will follow shortly (x509 and smime signature support, libcurl client/server authentication) I hope these patch will be useful and finds their ways into okpg Camille Moncelier http://devlife.org/ git-svn-id: http://opkg.googlecode.com/svn/trunk@220 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/opkg_install.c')
-rw-r--r--libopkg/opkg_install.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c
index aba0d1e..750ea65 100644
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -766,6 +766,9 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
abstract_pkg_t *ab_pkg = NULL;
int old_state_flag;
char* file_md5;
+#ifdef HAVE_SHA256
+ char* file_sha256;
+#endif
char *pkgid;
if ( from_upgrade )
@@ -874,6 +877,22 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
free(file_md5);
}
+#ifdef HAVE_SHA256
+ /* Check for sha256 value */
+ if(pkg->sha256sum)
+ {
+ file_sha256 = file_sha256sum_alloc(pkg->local_filename);
+ if (strcmp(file_sha256, pkg->sha256sum))
+ {
+ opkg_message(conf, OPKG_ERROR,
+ "Package %s sha256sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.\n",
+ pkg->name);
+ free(file_sha256);
+ return OPKG_INSTALL_ERR_SHA256;
+ }
+ }
+#endif
+
if (pkg->tmp_unpack_dir == NULL) {
unpack_pkg_control_files(conf, pkg);
}