From 707d316491d2cfbace47b374b4acd0649f5abd27 Mon Sep 17 00:00:00 2001 From: Vladimir Diaz Date: Wed, 25 Jun 2014 10:41:56 -0400 Subject: [PATCH 1/3] Update README.md Fix target path variable name in custom data example. --- tuf/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tuf/README.md b/tuf/README.md index df4216e6..568af676 100644 --- a/tuf/README.md +++ b/tuf/README.md @@ -253,9 +253,10 @@ $ mkdir django; echo 'file4' > django/file4.txt # In the example below, file permissions of the target (octal number specifying file # access for owner, group, others (e.g., 0755) is added alongside the default fileinfo. # All target objects in metadata include the target's filepath, hash, and length. ->>> octal_file_permissions = oct(os.stat(target2_filepath).st_mode)[4:] +>>> target3_filepath = "path/to/repository/targets/file3.txt" +>>> octal_file_permissions = oct(os.stat(target3_filepath).st_mode)[4:] >>> custom_file_permissions = {'file_permissions': octal_file_permissions} ->>> repository.targets.add_target("path/to/repository/targets/file3.txt", custom_file_permissions) +>>> repository.targets.add_target(target3_filepath, custom_file_permissions) # The private key of the updated targets metadata must be loaded before it can be signed and # written (Note the load_repository() call above). From a74a14186bedfa5528651672694dd3bb315b566f Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Mon, 30 Jun 2014 14:01:06 -0500 Subject: [PATCH 2/3] Remove '/' from target filepath os.path.join ignore previous parameters if one starts with '/'. All targets start with '/', making updated_targets to try to open a file in the root folder in case of a unix system. --- tuf/client/updater.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tuf/client/updater.py b/tuf/client/updater.py index 5f7d4802..a69a27ef 100755 --- a/tuf/client/updater.py +++ b/tuf/client/updater.py @@ -2615,7 +2615,10 @@ def updated_targets(self, targets, destination_directory): for target in targets: # Get the target's filepath located in 'destination_directory'. # We will compare targets against this file. - target_filepath = os.path.join(destination_directory, target['filepath']) + filepath = target['filepath'] + if filepath[0] == '/': + filepath = filepath[1:] + target_filepath = os.path.join(destination_directory, filepath) if target_filepath in updated_targetpaths: continue From d437964c42e406de40715d324f47eada533c3b6e Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Fri, 4 Jul 2014 13:38:16 -0500 Subject: [PATCH 3/3] Fix indentation Indentation is with 2 spaces --- tuf/client/updater.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tuf/client/updater.py b/tuf/client/updater.py index a69a27ef..da836130 100755 --- a/tuf/client/updater.py +++ b/tuf/client/updater.py @@ -2617,7 +2617,7 @@ def updated_targets(self, targets, destination_directory): # We will compare targets against this file. filepath = target['filepath'] if filepath[0] == '/': - filepath = filepath[1:] + filepath = filepath[1:] target_filepath = os.path.join(destination_directory, filepath) if target_filepath in updated_targetpaths: