From 2aa21cf7d9c689da89568ecd210a44c09e5a39ee Mon Sep 17 00:00:00 2001 From: Andinus Date: Sun, 8 Nov 2020 00:37:48 +0530 Subject: Warn when signify & gnupg is used together Warn when signify & gnupg is used together & added config option to disable the warning if the user knows what they're doing. --- leo.pl | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/leo.pl b/leo.pl index 1a10c5f..2e9dc93 100755 --- a/leo.pl +++ b/leo.pl @@ -50,8 +50,8 @@ foreach my $section (sort keys $config->%*) { foreach my $key (sort keys $config->{$section}->%*) { # Override encrypt & sign options with local values. if ($key eq "encrypt" - or $key eq "sign" - or $key eq "signify") { + or $key eq "sign" + or $key eq "signify") { $profile{$section}{$key} = $config->{$section}->{$key}; next; } @@ -65,7 +65,6 @@ foreach my $section (sort keys $config->%*) { my $date = date(); my $backup_dir = $options{backup_dir} || "/tmp/backups"; -# $backup_dir .= "/$date"; path($backup_dir)->mkpath; # Create backup directory. @@ -84,12 +83,16 @@ foreach my $prof ( @ARGV ) { path("$backup_dir/${prof}")->mkpath; # Create backup directory. backup($prof); - # It will fail because signify will look for "${prof}.tar" but - # delete option would've deleted it. I can make signify look - # for "${prof}.tar.gpg" but this is fine for now. - warn "[WARN] signify might fail if used with gpg\n" - if ($profile{$prof}{signify} - and ($profile{$prof}{encrypt} or $profile{$prof}{sign})); + unless ($options{signify_and_gnupg_warning_disable}) { + warn " +[WARN] signify will sign `.tar' & gnupg will delete it to create `.tar.gpg'. +The signature should be valid after decrypting the `.tar' archive. +Add `signify_and_gnupg_warning_disable = 1` in your config file to disable this +warning. +\n" + if ($profile{$prof}{signify} + and ($profile{$prof}{encrypt} or $profile{$prof}{sign})); + } signify($prof) if $profile{$prof}{signify}; encrypt_sign($prof) if $profile{$prof}{sign} or $profile{$prof}{encrypt}; @@ -112,6 +115,8 @@ sub backup { my @tmp_paths = $profile{$prof}{backup}->@*; while (my $path = shift @tmp_paths) { + # If it's a directory then check if we need to exclude any + # child path. if (-d $path) { my $iter = path($path)->iterator(); while ( my $path = $iter->() ) { -- cgit 1.4.1-2-gfad0 842f84b530d11c29'>c/profapi.h
blob: 1ed05360fc0bce1b7616f346b143326810576907 (plain) (tree)