[master] d6b3076bd Make the vmod->file_id a hash over the .vcc file.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Sep 3 06:54:07 UTC 2018
commit d6b3076bd0e1bacbdfc5ab869696048ed0d7009b
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Sep 3 06:52:32 2018 +0000
Make the vmod->file_id a hash over the .vcc file.
I belive this makes our builds reproducible.
Fixes: #2436
diff --git a/include/vrt.h b/include/vrt.h
index 0d76b2be5..88dd5214c 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -59,7 +59,7 @@
* VRT_STRANDS_string() removed from vrt.h (never implemented)
* VRT_Healthy() changed prototype
* VRT_Vmod_Init signature changed
- * VRT_Vmod_Fini changed to VRT_Vmod_Unload
+ * VRT_Vmod_Fini changed to VRT_Vmod_Unload
* 7.0 (2018-03-15)
* lots of stuff moved from cache.h to cache_varnishd.h
* (ie: from "$Abi vrt" to "$Abi strict")
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index 66e99b236..4b25dc623 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -44,6 +44,7 @@ import unittest
import random
import copy
import json
+import hashlib
AMBOILERPLATE = '''
# Boilerplate generated by vmodtool.py - changes will be overwritten
@@ -858,6 +859,7 @@ class vcc(object):
def parse(self):
global inputline
a = "\n" + open(self.inputfile, "r").read()
+ self.file_id = hashlib.sha256(a).hexdigest()
s = a.split("\n$")
self.copyright = s.pop(0).strip()
while s:
@@ -983,14 +985,7 @@ class vcc(object):
fo.write('\t.proto =\tVmod_Proto,\n')
fo.write('\t.json =\t\tVmod_Json,\n')
fo.write('\t.abi =\t\tVMOD_ABI_Version,\n')
- # NB: Sort of hackish:
- # Fill file_id with random stuff, so we can tell if
- # VCC and VRT_Vmod_Init() dlopens the same file
- #
- fo.write("\t.file_id =\t\"")
- for i in range(32):
- fo.write("%c" % random.randint(0x40, 0x5a))
- fo.write("\",\n")
+ fo.write("\t.file_id =\t\"%s\",\n" % self.file_id)
fo.write("};\n")
def cfile(self):
More information about the varnish-commit
mailing list