Skip Menu |

This queue is for tickets about the cPanel-SyncUtil CPAN distribution.

Report information
The Basics
Id: 102551
Status: resolved
Priority: 0/
Queue: cPanel-SyncUtil

People
Owner: cpan [...] cpanel.net
Requestors: JWWRIGHT [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.8



Subject: patch to add sha512 hash to .cpanelsync
Attaching a git style patch to add a sha512 hash to file entries in .cpanelsync files.
Subject: 0001-Add-sha512-hash-to-.cpanelsync-for-file-entries.patch
From 4fbddc2c983f785a1967f7e51e7bc5eca32d867e Mon Sep 17 00:00:00 2001 From: Jared Wright <jared.wright@cpanel.net> Date: Fri, 6 Mar 2015 12:21:28 -0600 Subject: [PATCH] Add sha512 hash to .cpanelsync for file entries. --- Changes | 3 +++ Makefile.PL | 1 + lib/cPanel/SyncUtil.pm | 13 ++++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 3a296c3..aa790ec 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension cPanel::SyncUtil. +0.8 Fri Mar 6 11:50:00 2015 + - sha512 hash added to .cpanelsync for files + 0.7 Wed Jan 26 07:34:41 2011 - set $File::Find::prune when %ignore_name is triggered (thanks TODDR) - Drop $Cpanel::SyncUtil::is_setuid in favor of more sane "get_mode_string" function/argument diff --git a/Makefile.PL b/Makefile.PL index 39fbaf0..6e9cc6b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -7,6 +7,7 @@ WriteMakefile( 'File::Slurp' => 0, 'File::Find' => 0, 'Digest::MD5::File' => 0, + 'Digest::SHA' => 0, 'Archive::Tar' => 0, 'Getopt::Std' => 0, }, diff --git a/lib/cPanel/SyncUtil.pm b/lib/cPanel/SyncUtil.pm index 4d9a207..a187e21 100644 --- a/lib/cPanel/SyncUtil.pm +++ b/lib/cPanel/SyncUtil.pm @@ -7,10 +7,11 @@ use File::Spec (); use File::Slurp (); use File::Find (); use Digest::MD5::File (); +use Digest::SHA (); use Cwd (); use Archive::Tar (); -our $VERSION = '0.7'; +our $VERSION = '0.8'; our %ignore_name = ( '.git' => 1, @@ -288,6 +289,9 @@ sub _sync_touchlock_pwd { print "Warning: zero sized file $file\n" if -z $file && $args_hr->{'verbose'}; my $mtime = ( stat(_) )[9]; my $md5sum = Digest::MD5::File::file_md5_hex($file); + my $sha = Digest::SHA->new('512'); + $sha->addfile($file); + my $sha512 = $sha->hexdigest; if ( exists $oldmd5s{$file} && $md5sum ne $oldmd5s{$file} ) { unlink $file . '.bz2'; system( 'bzip2', '-kf', $file ); @@ -301,7 +305,7 @@ sub _sync_touchlock_pwd { else { system( 'bzip2', '-kf', $file ); } - print {$cpsw_fh} "f===$file===$perms===$md5sum\n"; + print {$cpsw_fh} "f===$file===$perms===$md5sum===$sha512\n"; } } print {$cpsw_fh} ".\n"; @@ -387,13 +391,16 @@ sub build_cpanelsync { print "Warning: zero sized file $file\n" if -z $file && $args_hr->{'verbose'}; my $mtime = ( stat(_) )[9]; my $md5sum = Digest::MD5::File::file_md5_hex($file); + my $sha = Digest::SHA->new('512'); + $sha->addfile($file); + my $sha512 = $sha->hexdigest; if ( exists $oldmd5s{$file} && $md5sum ne $oldmd5s{$file} ) { # unlink archive if file changed unlink $file . '.bz2'; } elsif ( -e $file . '.bz2' && $mtime > ( stat(_) )[9] ) { # unlink archive if file is newer than archive unlink $file . '.bz2'; } - print {$cpsw_fh} "f===$file===$perms===$md5sum\n" or Carp::croak "Unable write $dir/.cpanelsync: $!"; + print {$cpsw_fh} "f===$file===$perms===$md5sum===$sha512\n" or Carp::croak "Unable write $dir/.cpanelsync: $!"; } } print {$cpsw_fh} ".\n" or Carp::croak "Unable write $dir/.cpanelsync: $!"; -- 2.2.0