summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2018-08-06 10:25:09 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-08 10:51:59 +0100
commit24e9ed8beeb2a8070ace6eedde174944d05c9ad5 (patch)
tree1bf4b14ad7eeae6fef164ce4e6e6fccc21dd8ef6
parentd1870c9903ada9b8f05f71752c93693c244b03f2 (diff)
downloadpoky-24e9ed8beeb2a8070ace6eedde174944d05c9ad5.tar.gz
classes/reproducible_build: Avoid dereferencing symlinks
Using os.path.getmtime() will dereference symbolic links in an attempt to get the last modified time. This can cause errors if the target doesn't exist, or worse map to some absolute build host path which would make a build not reproducible. (From OE-Core rev: fae23c72288068f90e2f357a8abf1384850c02ed) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/reproducible_build.bbclass4
1 files changed, 2 insertions, 2 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index 2df805330a..268b5fb8f1 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -56,7 +56,7 @@ def get_source_date_epoch_known_files(d, path):
56 for file in known_files: 56 for file in known_files:
57 filepath = os.path.join(path,file) 57 filepath = os.path.join(path,file)
58 if os.path.isfile(filepath): 58 if os.path.isfile(filepath):
59 mtime = int(os.path.getmtime(filepath)) 59 mtime = int(os.lstat(filepath).st_mtime)
60 # There may be more than one "known_file" present, if so, use the youngest one 60 # There may be more than one "known_file" present, if so, use the youngest one
61 if mtime > source_date_epoch: 61 if mtime > source_date_epoch:
62 source_date_epoch = mtime 62 source_date_epoch = mtime
@@ -114,7 +114,7 @@ python do_create_source_date_epoch_stamp() {
114 for fname in files: 114 for fname in files:
115 filename = os.path.join(root, fname) 115 filename = os.path.join(root, fname)
116 try: 116 try:
117 mtime = int(os.path.getmtime(filename)) 117 mtime = int(os.lstat(filename).st_mtime)
118 except ValueError: 118 except ValueError:
119 mtime = 0 119 mtime = 0
120 if mtime > source_date_epoch: 120 if mtime > source_date_epoch: