From ecdd40c9aa25ee736aa1ab66ae607b8a4f2bd4f3 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Mon, 20 Nov 2023 21:58:15 +0000 Subject: [PATCH] see #782 - merge in fix from @johnfawcett - escape slashes in the raw password --- ADDITIONS/fetchmail.pl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ADDITIONS/fetchmail.pl b/ADDITIONS/fetchmail.pl index 5711564e..fed1e325 100755 --- a/ADDITIONS/fetchmail.pl +++ b/ADDITIONS/fetchmail.pl @@ -54,6 +54,18 @@ sub log_and_die { die $message; } +sub escape_password { + $output = ""; + for $i (0..length($_[0])-1){ + $char = substr($_[0], $i, 1); + if ($char eq "\\" or $char eq "\"") + { + $output = $output . "\\"; + } + $output = $output . $char; + } + return $output; +} # read options and arguments $configfile = "/etc/fetchmail-all/config"; @@ -109,7 +121,7 @@ map{ syslog("info","fetch ${src_user}@${src_server} for ${mailbox}"); - $cmd="user '${src_user}' there with password '".decode_base64($src_password)."'"; + $cmd="user '${src_user}' there with password '".escape_password(decode_base64($src_password))."'"; $cmd.=" folder '${src_folder}'" if ($src_folder); if ($mda) {