[Midnightbsd-cvs] src [6491] trunk/lib/libmport/install.c: remove package file if it fails hash verification so we can download again easily
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Dec 15 01:10:34 EST 2013
Revision: 6491
http://svnweb.midnightbsd.org/src/?rev=6491
Author: laffer1
Date: 2013-12-15 01:10:34 -0500 (Sun, 15 Dec 2013)
Log Message:
-----------
remove package file if it fails hash verification so we can download again easily
Modified Paths:
--------------
trunk/lib/libmport/install.c
Modified: trunk/lib/libmport/install.c
===================================================================
--- trunk/lib/libmport/install.c 2013-12-15 05:57:46 UTC (rev 6490)
+++ trunk/lib/libmport/install.c 2013-12-15 06:10:34 UTC (rev 6491)
@@ -25,12 +25,13 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/lib/libmport/install.c,v 1.9 2013/03/17 23:54:17 laffer1 Exp $");
+__MBSDID("$MidnightBSD$");
#include "mport.h"
#include "mport_private.h"
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
MPORT_PUBLIC_API int mport_install(mportInstance *mport, const char *pkgname, const char *version, const char *prefix)
{
@@ -98,8 +99,11 @@
if (mport_verify_hash(filename, e[e_loc]->hash) == 0) {
free(filename);
mport_index_entry_free_vec(e);
- /* XXX should we unlink the bad file here? */
- RETURN_ERROR(MPORT_ERR_FATAL, "Package fails hash verification.\n");
+
+ if (unlink(filename) == 0)
+ RETURN_ERROR(MPORT_ERR_FATAL, "Package failed hash verification and was removed.\n");
+ else
+ RETURN_ERROR(MPORT_ERR_FATAL, "Package failed hash verification, but could not be removed.\n");
}
ret = mport_install_primative(mport, filename, prefix);
More information about the Midnightbsd-cvs
mailing list