[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25724 - gnunet-update/src/gnunet_update
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25724 - gnunet-update/src/gnunet_update |
Date: |
Tue, 8 Jan 2013 23:30:12 +0100 |
Author: harsha
Date: 2013-01-08 23:30:12 +0100 (Tue, 08 Jan 2013)
New Revision: 25724
Modified:
gnunet-update/src/gnunet_update/hashtree.py
gnunet-update/src/gnunet_update/install.py
gnunet-update/src/gnunet_update/package.py
gnunet-update/src/gnunet_update/update.py
gnunet-update/src/gnunet_update/util.py
Log:
GNUNET FS style CHK instead sha512 hash
Modified: gnunet-update/src/gnunet_update/hashtree.py
===================================================================
--- gnunet-update/src/gnunet_update/hashtree.py 2013-01-08 19:41:11 UTC (rev
25723)
+++ gnunet-update/src/gnunet_update/hashtree.py 2013-01-08 22:30:12 UTC (rev
25724)
@@ -21,6 +21,7 @@
from hashlib import sha512
import logging
+import os
import util
@@ -204,3 +205,14 @@
current_depth += 1
else:
current_depth = 0
+
+def chkuri_from_path (path):
+ """Returns the CHK URI of the file at the given path.
+
+ path: the path of the file whose CHK has to be calculated
+ """
+ size = os.path.getsize (path)
+ readin = open (path, "rb")
+ chk = compute_rootchk (readin, size)
+ readin.close()
+ return chk.uri()
Modified: gnunet-update/src/gnunet_update/install.py
===================================================================
--- gnunet-update/src/gnunet_update/install.py 2013-01-08 19:41:11 UTC (rev
25723)
+++ gnunet-update/src/gnunet_update/install.py 2013-01-08 22:30:12 UTC (rev
25724)
@@ -35,6 +35,7 @@
from metadata import Metadata
from config import GnunetUpdateConfig
from file import ExecutableFileObject, FileObject
+import hashtree
# Used for testing; Sets from where we read input
getch_ = None
@@ -222,7 +223,7 @@
dep_tarinfo.name = dep_tarinfo.name.replace("dependencies/","",1)
package_tarfile.extract(dep_tarinfo, "./")
# Check the hash of the extracted file
- if util.hexdigest(dep_tarinfo.name) != dep.hash:
+ if hashtree.chkuri_from_path(dep_tarinfo.name) != dep.hash:
print (dep_tarinfo.name +
" not matched with the expected hash " + dep.hash)
print "Given package contains code not signed by trusted packager"
Modified: gnunet-update/src/gnunet_update/package.py
===================================================================
--- gnunet-update/src/gnunet_update/package.py 2013-01-08 19:41:11 UTC (rev
25723)
+++ gnunet-update/src/gnunet_update/package.py 2013-01-08 22:30:12 UTC (rev
25724)
@@ -37,6 +37,7 @@
from file import FileObject, ExecutableFileObject, DependencyFileObject
from metadata import Metadata
from config import GnunetUpdateConfig
+import hashtree
#global variables
gnunet_src = ""
@@ -172,14 +173,14 @@
# cause issues during installation
if 0 != proc.returncode:
other_object = FileObject(file_path_rel,
- util.hexdigest(file_path))
+ hashtree.chkuri_from_path(file_path))
other_objects.append(other_object)
add_to_matching_group(other_object)
continue
#create a new ExecutableFileObject instance and collect its
dependencies
bin_object = ExecutableFileObject(os.path.join(root_rel,file),
- hash=util.hexdigest(file_path))
+
hash=hashtree.chkuri_from_path(file_path))
for dep_data in util.parse_ldd_output(proc_stdout):
#we cannot find a library without its location
@@ -206,7 +207,7 @@
#check in cache if we already saw this dependency
if dep not in dependencies:
dependencies[dep] = dep
- dep.hash = util.hexdigest(dep_data[-1])
+ dep.hash = hashtree.chkuri_from_path(dep_data[-1])
dep.realname =
os.path.basename(os.path.realpath(dep_data[-1]))
else:
dep = dependencies[dep]
Modified: gnunet-update/src/gnunet_update/update.py
===================================================================
--- gnunet-update/src/gnunet_update/update.py 2013-01-08 19:41:11 UTC (rev
25723)
+++ gnunet-update/src/gnunet_update/update.py 2013-01-08 22:30:12 UTC (rev
25724)
@@ -37,6 +37,7 @@
import metadata
from config import GnunetUpdateConfig
from file import ExecutableFileObject, DependencyFileObject
+import hashtree
def usage():
"""Print helpful usage information."""
@@ -230,7 +231,7 @@
dep_tarinfo.name = dep_tarinfo.name.replace("dependencies/","",1)
package_tarfile.extract(dep_tarinfo, "./")
# Check the hash of the extracted file
- if util.hexdigest(dep_tarinfo.name) != dep.hash:
+ if hashtree.chkuri_from_path(dep_tarinfo.name) != dep.hash:
print (dep_tarinfo.name +
" not matched with the expected hash " + dep.hash)
print "Given package contains code not signed by trusted packager"
Modified: gnunet-update/src/gnunet_update/util.py
===================================================================
--- gnunet-update/src/gnunet_update/util.py 2013-01-08 19:41:11 UTC (rev
25723)
+++ gnunet-update/src/gnunet_update/util.py 2013-01-08 22:30:12 UTC (rev
25724)
@@ -36,6 +36,8 @@
from metadata import Metadata
from file import DependencyFileObject
+import hashtree
+
def parse_ldd_output(ldd_output, splitted_input=False):
"""Parses ldd output.
@@ -315,8 +317,8 @@
package_tarfile.extract(member, install_dir)
# Check the hash of the extracted file if it is not a symbolic link
if not member.issym():
- if hexdigest(os.path.join(install_dir,
- member.name)) != member_obj.hash:
+ if hashtree.chkuri_from_path (
+ os.path.join(install_dir, member.name)) != member_obj.hash:
print (member_obj.name +
" not matched with the expected hash " +
member_obj.hash)
print "Given package contains code not signed by trusted
packager"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25724 - gnunet-update/src/gnunet_update,
gnunet <=