Subject: Verifying signatures for downloaded files [PATCH]
To: None <tech-pkg@netbsd.org>
From: Todd Willey <xtoddx@gmail.com>
List: tech-pkg
Date: 02/12/2005 12:54:43
------=_Part_1694_22886587.1108230883722
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Attached is a patch to pkg_install that works with signatures on
remote (http,ftp) packages. It will:
*) cache pkg downloads to disk if the user wants to verify signatures
*) cache pkg downloads to disk if the -d flag is given (just to keep a
local copy)
*) attempt to download any associated signature files for the package
if -s given
*) verify downloaded packages with signatures if -s given
*) -c CACHEDIR will override the default cache directory (/var/cache/pkg)
*) does not cache to disk if no relevant options are given, as it performs now
I'm looking for feedback / testing. I've been using this patch for a
few days now with no problems, verifying the binary packages I host on
GoBSD.com.
-Todd Willey
------=_Part_1694_22886587.1108230883722
Content-Type: application/octet-stream; name="pkg_install-patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="pkg_install-patch"
SW5kZXg6IGZpbGVzL2FkZC9tYWluLmMKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpSQ1MgZmlsZTogL2N2c3Jvb3QvcGtn
c3JjL3BrZ3Rvb2xzL3BrZ19pbnN0YWxsL2ZpbGVzL2FkZC9tYWluLmMsdgpyZXRyaWV2aW5nIHJl
dmlzaW9uIDEuOApkaWZmIC11IC1yMS44IG1haW4uYwotLS0gZmlsZXMvYWRkL21haW4uYwkyOSBE
ZWMgMjAwNCAxMjoxNjo1NiAtMDAwMAkxLjgKKysrIGZpbGVzL2FkZC9tYWluLmMJNyBGZWIgMjAw
NSAyMDo1NjoxNCAtMDAwMApAQCAtNDksNyArNDksOSBAQAogI2luY2x1ZGUgImFkZC5oIgogI2lu
Y2x1ZGUgInZlcmlmeS5oIgogCi1zdGF0aWMgY2hhciBPcHRpb25zW10gPSAiSUs6TE1SU1ZXOmZo
bnA6czp0OnV2dzoiOworLyogdG9kZ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bWUgb2YgcGFja2FnZSAnJXMnXG4iLCBwa2df
cGF0aCApOworCQlmcmVlKCBwa2dfcGF0aCApOworCQlyZXR1cm4gTlVMTDsKKwl9CisJcHRyKys7
CisJcGtnbmFtZSA9IHN0cmR1cCggcHRyICk7CisJKnB0cj0nXDAnOworCWlmIChnZXRlbnYoIlBL
R19QQVRIIikgPT0gTlVMTCkgeworCQlzZXRlbnYoIlBLR19QQVRIIiwgcGtnX3BhdGgsIDEpOwor
CQlpZiAoVmVyYm9zZSkKKwkJCXByaW50Zigic2V0ZW52IFBLR19QQVRIPSclcydcbiIsIHBrZ19w
YXRoKTsKKwkJcGF0aF9wcmVwZW5kX2Zyb21fcGtnbmFtZSggc3BlYyApOworCX0KKworCXNucHJp
bnRmKCBsb2NhbGZpbGUsIE1heFBhdGhTaXplLCAiJXMvJXMiLCBkZXN0LCBwa2duYW1lICk7CisK
KyAgICAgICAgLyogZm9yayBmdHAgY2hpbGQgKi8KKyAgICAgICAgaWYgKChwaWRmdHAgPSBmb3Jr
KCkpID09IC0xKSB7CisgICAgICAgICAgICAgICAgd2FybigiY2Fubm90IGZvcmsgcHJvY2VzcyBm
b3IgZnRwIik7CisJCWZyZWUoIHBrZ19wYXRoICk7CisJCWZyZWUoIHBrZ25hbWUgKTsKKyAgICAg
ICAgICAgICAgICByZXR1cm4gTlVMTDsKKyAgICAgICAgfQorICAgICAgICBpZiAocGlkZnRwID09
IDApIHsKKyAgICAgICAgICAgICAgICBleGVjbHAoRlRQX0NNRCwgRlRQX0NNRCwgIi1vIiwgbG9j
YWxmaWxlLCBzcGVjLCBOVUxMKTsKKyAgICAgICAgICAgICAgICB3YXJueCgiZmFpbGVkIHRvIGV4
ZWN1dGUgZnRwIik7CisgICAgICAgICAgICAgICAgX2V4aXQoMik7CisgICAgICAgIH0KKworICAg
ICAgICB3aGlsZSAod2FpdHBpZChwaWRmdHAsICZzdGF0ZWZ0cCwgMCkgPCAwKSB7CisgICAgICAg
ICAgICAgICAgaWYgKGVycm5vICE9IEVJTlRSKSB7CisJCQl3YXJueCggIndhaWRwaWQgZXJyb3I6
IG5vdCBFSU5UUlxuIiApOworCQkJZnJlZSggcGtnX3BhdGggKTsKKwkJCWZyZWUoIHBrZ25hbWUg
KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBOVUxMOworICAgICAgICAgICAgICAg
IH0KKyAgICAgICAgfQorCisgICAgICAgIGlmICggIVdJRkVYSVRFRChzdGF0ZWZ0cCkgKSB7CisJ
CXdhcm54KCAiV0lGRVhJVEVEIGVycm9yXG4iICk7CisJCWZyZWUoIHBrZ19wYXRoICk7CisJCWZy
ZWUoIHBrZ25hbWUgKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gTlVMTDsKKwl9CisKKyAgICAg
ICAgaWYgKCBXRVhJVFNUQVRVUyhzdGF0ZWZ0cCkgIT0gMCApIHsKKwkJd2FybngoICJXRVhJVFNU
QVRVUyBlcnJvclxuIiApOworCQlmcmVlKCBwa2dfcGF0aCApOworCQlmcmVlKCBwa2duYW1lICk7
CisgICAgICAgICAgICAgICAgcmV0dXJuIE5VTEw7CisJfQorCisJZnJlZSggcGtnX3BhdGggKTsK
KwlmcmVlKCBwa2duYW1lICk7CisgICAgICAgIHJldHVybiBzdHJkdXAoIGxvY2FsZmlsZSApOwor
fQorCitjaGFyICoKK2Z0cF9kb3dubG9hZF90byggY29uc3QgY2hhciogc3BlYywgY29uc3QgY2hh
ciogZGVzdCApCit7CisJY2hhciBleHBhbmRbTWF4UGF0aFNpemVdOworCWludCByZXR2YWw7CisJ
Y2hhciBiYXNlW01heFBhdGhTaXplXTsKKwljaGFyKiBwa2duYW1lOworCWNoYXIqIHB0cjsKKwlj
aGFyIGNvbW1hbmRbMTAyNF07CisJY2hhciBsb2NhbGZpbGVbTWF4UGF0aFNpemVdOworCisJaWYo
IChyZXR2YWwgPSBleHBhbmRVUkwoIGV4cGFuZCwgc3BlYyApKSA9PSAtMSApIHsKKwkJd2Fybngo
IlVuYWJ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