From ba67fdae63122b40d8fb4abf9c1c7695999f143d Mon Sep 17 00:00:00 2001 From: Andrew Fyfe Date: Wed, 25 Jul 2007 22:35:29 +0100 Subject: Remove support for SHA1 from pacman. There's no need for a second hashing algorithm. MD5 serves the purpose of verifying that a package file hasn't been corrupted during download. Signed-off-by: Andrew Fyfe Signed-off-by: Dan McGee --- src/pacman/package.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/pacman/package.c b/src/pacman/package.c index 3a3381fc..86d91ecb 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -110,7 +110,7 @@ void dump_pkg_full(pmpkg_t *pkg, int level) */ void dump_pkg_sync(pmpkg_t *pkg, const char *treename) { - const char *descheader, *md5sum, *sha1sum; + const char *descheader, *md5sum; if(pkg == NULL) { return; } @@ -118,7 +118,6 @@ void dump_pkg_sync(pmpkg_t *pkg, const char *treename) descheader = _("Description : "); md5sum = alpm_pkg_get_md5sum(pkg); - sha1sum = alpm_pkg_get_sha1sum(pkg); printf(_("Repository : %s\n"), treename); printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg)); @@ -139,9 +138,6 @@ void dump_pkg_sync(pmpkg_t *pkg, const char *treename) if (md5sum != NULL && md5sum[0] != '\0') { printf(_("MD5 Sum : %s"), md5sum); } - if (sha1sum != NULL && sha1sum[0] != '\0') { - printf(_("SHA1 Sum : %s"), sha1sum); - } printf("\n"); } @@ -168,31 +164,22 @@ void dump_pkg_backups(pmpkg_t *pkg) snprintf(path, PATH_MAX-1, "%s%s", root, str); /* if we find the file, calculate checksums, otherwise it is missing */ if(!stat(path, &buf)) { - char *sum; char *md5sum = alpm_get_md5sum(path); - char *sha1sum = alpm_get_sha1sum(path); - if(md5sum == NULL || sha1sum == NULL) { + if(md5sum == NULL) { fprintf(stderr, _("error: could not calculate checksums for %s\n"), path); free(str); continue; } - /* TODO Is this a good way to check type of backup stored? - * We aren't storing it anywhere in the database. */ - if (strlen(ptr) == 32) { - sum = md5sum; - } else { /*if (strlen(ptr) == 40) */ - sum = sha1sum; - } + /* if checksums don't match, file has been modified */ - if (strcmp(sum, ptr)) { + if (strcmp(md5sum, ptr)) { printf(_("MODIFIED\t%s\n"), path); } else { printf(_("Not Modified\t%s\n"), path); } free(md5sum); - free(sha1sum); } else { printf(_("MISSING\t\t%s\n"), path); } -- cgit v1.2.3-24-g4f1b