From ad435e819088e487801c20fbfa33ee4a8977bea2 Mon Sep 17 00:00:00 2001
From: "Kyle J. McKay"
Date: Wed, 20 Apr 2016 02:34:33 -0700
Subject: [PATCH] rootcert.html: show blob hash of root certificate
Signed-off-by: Kyle J. McKay
---
cgi/html.cgi | 6 ++++--
html/rootcert.html | 2 ++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/cgi/html.cgi b/cgi/html.cgi
index 70b99db..2779b93 100755
--- a/cgi/html.cgi
+++ b/cgi/html.cgi
@@ -43,6 +43,7 @@ BEGIN {
# /@@server(gitweburl)@@/ replace scheme://host:port portion of gitweburl variable
# /@@md5(relpath)@@/ produces MD5 hex of file in DOCUMENT_ROOT at relpath
# /@@sha1(relpath)@@/ produces SHA1 hex of file in DOCUMENT_ROOT at relpath
+# /@@blob(relpath)@@/ produces git hash-object -t blob of file in DOCUMENT_ROOT
# /@@ifmob@@...@@end@@/ remove unless mob defined
# /@@ifssh@@...@@end@@/ remove unless pushurl defined
# /@@ifhttps@@...@@end@@/ remove unless httpspushurl defined
@@ -78,7 +79,7 @@ if ($pathinfo =~ /\.(png|jpe?g|gif|svgz?)$/) {
sub get_file_hash {
my ($hash, $fn) = @_;
return '' unless $docroot && $docroot ne '/' && -d $docroot;
- return '' if $hash ne 'md5' && $hash ne 'sha1';
+ return '' if $hash ne 'md5' && $hash ne 'sha1' && $hash ne 'blob';
return '' if !$fn || $fn =~ m|^[./]| || $fn =~ m|[.]/| || $fn =~ m|/[.]|;
return '' unless -f "$docroot/$fn";
open(HASHFILE, '<', "$docroot/$fn") or return '';
@@ -86,6 +87,7 @@ sub get_file_hash {
undef $/;
my $contents = ;
close(HASHFILE);
+ $hash eq 'blob' and $contents = sprintf("blob %u\0", length($contents)) . $contents;
return $hash eq 'md5' ? md5_hex($contents) : sha1_hex($contents);
}
@@ -114,7 +116,7 @@ foreach (split(/\n/, $template)) {
s/@\@base\((\w+?)\)@@/url_base(${$Girocco::Config::{$1}})/ge;
s/@\@path\((\w+?)\)@@/url_path(${$Girocco::Config::{$1}})/ge;
s/@\@server\((\w+?)\)@@/url_server(${$Girocco::Config::{$1}})/ge;
- s/@\@(md5|sha1)\(([^()]+?)\)@@/get_file_hash($1,$2)/ge;
+ s/@\@(md5|sha1|blob)\(([^()]+?)\)@@/get_file_hash($1,$2)/ge;
print "$_\n";
}
}
diff --git a/html/rootcert.html b/html/rootcert.html
index 4cef85a..360d32b 100644
--- a/html/rootcert.html
+++ b/html/rootcert.html
@@ -20,6 +20,8 @@ browser, this site uses its own root certificate.
md5: @@md5(@@nickname@@_root_cert.pem)@@
sha1: @@sha1(@@nickname@@_root_cert.pem)@@
+
+blob: @@blob(@@nickname@@_root_cert.pem)@@
Also see the full instructions on configuring your Git client for https push.
--
2.11.4.GIT