From 0c3f7b399dd587f857fc78751ee8bc3b22c03228 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Fri, 29 Mar 2013 13:18:19 -0700 Subject: [PATCH] allow sendmail options to be specified multiple times --- sshsendmail | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/sshsendmail b/sshsendmail index 047d9a8..8668470 100755 --- a/sshsendmail +++ b/sshsendmail @@ -79,32 +79,11 @@ my %options = (debug => 0, host => undef, identity => undef, username => undef, - 'sendmail-options' => '', + 'sendmail_options' => [''], ); -# this is really janky, but because nullmailer doesn't properly handle -# quotes, we must do it for it. -my @fixed_argv; -my $concatenate_to_last; -my $p; -for my $opt (@ARGV) { - if ($concatenate_to_last) { - $fixed_argv[-1].=' '.$opt; - if (/$p/) { - $concatenate_to_last = 0; - } - next; - } - if (/(['"])(.+)/ && $2 !~ /$1/) { - $p = $1; - $concatenate_to_last = 1; - } - push @fixed_argv,$opt; -} -@ARGV=@fixed_argv; - GetOptions(\%options,'identity|i=s','username|l=s','daemon|d', 'syslog|s', - 'sendmail-options|o=s', + 'sendmail_options|sendmail-options|o=s@', 'help|h|?','man|m'); pod2usage() if $options{help}; @@ -145,7 +124,9 @@ my @ssh_arguments = ($hostname); push @ssh_arguments, '-i', $options{identity} if defined $options{identity}; push @ssh_arguments, '-l', $options{username} if defined $options{username}; -push @ssh_arguments, q(cat - | /usr/lib/sendmail ).$options{'sendmail-options'}.' '.join(' ',@recipients); +push @ssh_arguments, q(cat - | /usr/lib/sendmail ). + join(' ',ref($options{sendmail_options})?@{$options{sendmail_options}}:($options{sendmail_options}//'')). + ' '.join(' ',@recipients); qx(ping -q -c 3 $hostname 2>/dev/null); if ($?) { print STDERR "${0}: Failed: unable to ping $hostname\n"; -- 2.39.5