Tag Archives: Thunderbird

Modify Thunderbird Settings using Logon Scripts

Last time with VBScript, I swear it…

While working at UVM on their Exchange 2016 deployment, we came across an interesting environmental anomaly (UVM has lots of those). The popular Thunderbird IMAP mail client installer had been customized by someone (*cough*) to handle various local environment quirks in the UW IMAP server deployment. Once of these was the use of a “mailbox path prefix” variable. When UVM migrated to Dovecot IMAP many years back now, this setting became obsolete, but I, er, I mean *someone* never removed this setting from the custom T-bird installer. Surprisingly, it appears that thousands of users in the environment have the IMAP path prefix setting defined. I guess people really loved that custom Thunderbird installer?

Smug satisfaction with the success of *someone’s* mail client installer evaporated quickly when migrating Thunderbird users to Exchange. Why? As it turns out, this setting unexpectedly causes Thunderbird to point to a non-existent mailbox folder, and thus gives the impression that the Exchange migration had resulted in the deletion of all IMAP server folders. Gah!

It took me only an hour or two to figure out how to fix this problem using PowerShell, but I then discovered that it was not really practical to package PowerShell scripts for execution on non-domain-joined computers. Why?

  1. By default, PowerShell does not allow execution of scripts on new non-domain-joined Windows computers. But even if you could work around that problem…
  2. PowerShell will not trust code signatures unless they explicitly were imported into the “Trusted Publishers” branch of the user’s certificate store.

So, PowerShell is not going to be of overly much use to me today, since we want this script to run on-demand in addition to as a logon script. It really would be nice if I could have taken the time to learn C#, C++, Visual Basic, or some other “real” programming language, wouldn’t it? Because now I have to fall back on VBScript again.

Last time… Last time…

The script below will detect the “mail/” IMAP path prefix and delete it if present. It also will set the server polling interval to 10 minutes if set longer than 10 (29 was the default previously, which does not work well with Exchange IMAP). If Thunderbird is running, the user will be prompted to restart their mail client:

Advertisements

Thunderbird 13 – The cloud arrives

Mozilla Thunderbird 13 arrived this week.  Guess what?  Our customized build process broke again.  Now, when you start TB for the first time, you get greeted with the option to create a new email account with one of Thunderbird’s “partners” (in other words, email providers who paid for the honor of being put in the “welcome to Thunderbird” start dialog).

With the assistance of the awesome Ben Coddington (who does not keep a blog, but should so that you can bask in his awesomeness), I was able to track down the place that the new-new account dialog is called, and kill it by switching a preference in the “thunderbird-all.js” file.

The preference is a Boolean named “mail.provider.enabled”, set in the thunderbird-all.js file, as documented here:
http://hg.mozilla.org/releases/comm-beta/rev/879e8d044e36
and referenced here:
https://bugzilla.mozilla.org/show_bug.cgi?id=718792#c3
and here:
https://wiki.mozilla.org/index.php?title=Thunderbird/Support/TB13UserChanges

I updated our Thunderbird build script to set this preference to “false”:

Echo modifying default "All Thunderbird" preferences…
……binsed.exe –binary "s/pref("mail.provider.enabled", true);/pref("mail.provider.enabled", false);/" .defaultsprefall-thunderbird_new.js
if errorlevel 1 goto err
MOVE /Y .defaultsprefall-thunderbird_new.js .defaultsprefall-thunderbird.js

The whole ugly build script is provided below:

REM Thunderbird customized build script for UVM.
REM Updated June 2012 for Thunderbird 13 support.
REM REQUIRES:
REM – 7z.exe, 7zr.exe and sed.exe in parallel "..bin" directory
REM – Unmodified Thunderbird installer in .source directory
REM – all required config files in .config directory
REM (including 7z control file, ISP Hook RDF file, and modified prefs.js)
REM – local JDK install with "jar.exe". Path to jar.exe will need to be updated in the jdk environment variable
REM OUTPUT: Fully modified Thunderbird installer in .Installer directory.
REM @echo on

set jdk="c:Program Files (x86)Javajdk1.6.0_27bin"

Echo Cleaning up old builds…
del .Installer*.exe
rmdir /s /q .build
set /P tbver=Enter Thunderbird version number to build (i.e. "6.0.2"):

Echo Extracting setup files from OEM Installer…
mkdir .buildtemp
..bin7zr x .source*.exe -o.build

Echo Extracting omni.ja contents…
mkdir .buildtemp
cd .buildtemp
%jdk%jar.exe xf ..coreomni.ja
if errorlevel 1 goto err

Echo modifying messenger functions…
……binsed.exe –binary "s/NewMailAccount(msgWindow, okCallback);/MsgAccountWizard(okCallback);/" .chromemessengercontentmessengermsgMail3PaneWindow_new.js
if errorlevel 1 goto err
MOVE /Y .chromemessengercontentmessengermsgMail3PaneWindow_new.js .chromemessengercontentmessengermsgMail3PaneWindow.js

Echo modifying default "All Thunderbird" preferences…
……binsed.exe –binary "s/pref("mail.provider.enabled", true);/pref("mail.provider.enabled", false);/" .defaultsprefall-thunderbird_new.js
if errorlevel 1 goto err
MOVE /Y .defaultsprefall-thunderbird_new.js .defaultsprefall-thunderbird.js

Echo modifying default mailnews preferences…
……binsed.exe –binary "s/try_ssl", 0)/try_ssl", 2)/" .defaultsprefmailnews_new.js
if errorlevel 1 goto err
MOVE /Y .defaultsprefmailnews_new.js .defaultsprefmailnews.js

Echo moving UVM modified prefs.js into place (note that this file is not actually used by Thunderbird!)
copy /Y ….configprefs.js .defaultsprofileprefs.js

Echo Repacking omni.ja…
del /f /q ..coreomni.ja
%jdk%jar.exe cf ..coreomni.ja *

Echo Copying UVM Custom ISP file to source…
cd ….
mkdir .buildcoreispen-US
copy /Y .configUVMMail.rdf .buildcoreispen-USUVMMail.rdf
if errorlevel 1 goto err
Echo Copying UVM default prefs.js to core directory (tbird no longer has a prefs.js by default, but it will be used if present)…
mkdir .buildcoredefaultsprofile
copy /Y .configprefs.js .buildcoredefaultsprofileprefs.js
if errorlevel 1 goto err

Echo Deleting temporary files that should not be present in the installer…
rmdir /s /q .buildtemp

Echo Repackaging Thunderbird installer…
..bin7zr a .InstallerUVM_Thunderbird_setup_%tbver%.7z .build*
copy /b ..bin7zS.sfx + .configconfig.txt + .InstallerUVM_Thunderbird_setup_%tbver%.7z .InstallerUVM_Thunderbird_setup_%tbver%.exe

Echo Cleaning up installation source…
del /s /f /q .build*.*
rmdir /s /q .buildcore
rmdir /s /q .build
del /f /q .InstallerUVM_Thunderbird_setup_%tbver%.7z
goto end

:err
echo There was an error running a command.

:end

Mozilla Thunderbird – Implementing the ISP Hook in 5.0 and later

Out buddies at MozillaMessaging are at it again… new with Thunderbird 5.0, all of the “jar” files previously present in the Thunderbird installation directory have been collapsed into a single “omni.jar” file, apparently for program load optimization.

This all would be fine with me if the omni.jar were a “normal” zip file, and the previous jars were. Instead, this is an “optimized” jar, that is not recognized by 7-zip as a valid zip archive. It is not clear to me how the jar is “optimized”, or how to re-apply optimizations when modifying the original, nor do I particularly care as load optimization is of little concern to us… we are not operating with 10 year old equipment, for the most part, so who cares?

I have had to work around the problem by using “jar.exe” from the Java JDK. This program extracts and re-creates omni.jar in a way that Thunderbird does not mind. The resultant file size is about the same, too.

Another quirk of the new version is that the default “prefs.js” file, while present in omni.jar, is not copied into the resultant Program Files directory at install time. On a clean install, there is no default prefs.js! I had to populate a new prefs.js into the “core” installer directory, outside of the new “omni.jar”.

Finally, there are no more “localized/nonlocalized” directories in the installer, just that which is within “omni”, and that which is not. So, I put our prefs.js in .coredefaultsprofile (a new directory in the installer zip). Previously it was in .nonlocalizeddefaultsprofile. Likewise, our mailnews.js and ISP Hook “.rdf” files also go in “core” instead of “localized”.

Other than that, the RDF ISP Hook file that we are using is unchanged from the one documented here:
https://sharepoint.uvm.edu/sites/ad/distribution/appconfig/Thunderbird.aspx
Prefs.js is the same as in the SharePoint site, with the modifications noted here:
http://blog.uvm.edu/jgm/2009/12/15/thunderbird-3-re-implementing-the-isp-hook-for-customized-deployments/

What a bunch of gibberish talk… sorry for the dry post. I am guessing if you are a Thunderbird customizer, you will know what I am talking about. If not, you won’t be reading anyway.

On to the build script, in Windows BAT/CMD language:

REM Thunderbird customized build script for UVM.
REM Updated September 2011 for Thunderbird 5.0 support.
REM REQUIRES:
REM – 7z.exe, 7zr.exe and sed.exe in parallel "..bin" directory
REM – Unmodified Thunderbird installer in .source directory
REM – all required config files in .config directory
REM (including 7z control file, ISP Hook RDF file, and modified prefs.js)
REM – local JDK install with "jar.exe". Path to jar.exe will need to be updated in the jdk environment variable
REM OUTPUT: Fully modified Thunderbird installer in .Installer directory.
REM @echo on

set jdk="c:Program Files (x86)Javajdk1.6.0_27bin"

Echo Cleaning up old builds…
del .Installer*.exe
rmdir /s /q .build
set /P tbver=Enter Thunderbird version number to build (i.e. "6.0.2"):

Echo Extracting setup files from OEM Installer…
mkdir .buildtemp
..bin7zr x .source*.exe -o.build

Echo Extracting omni.jar contents…
mkdir .buildtemp
cd .buildtemp
%jdk%jar.exe xf ..coreomni.jar

Echo modifying messenger functions…
……binsed.exe –binary "s/NewMailAccount(msgWindow, okCallback);/MsgAccountWizard(okCallback);/" .chromemessengercontentmessengermsgMail3PaneWindow_new.js
MOVE /Y .chromemessengercontentmessengermsgMail3PaneWindow_new.js .chromemessengercontentmessengermsgMail3PaneWindow.js

Echo modifying default mailnews preferences…
……binsed.exe –binary "s/try_ssl", 0)/try_ssl", 2)/" .defaultsprefmailnews_new.js
MOVE /Y .defaultsprefmailnews_new.js .defaultsprefmailnews.js

Echo moving UVM modified prefs.js into place (note that this file is not actually used by Thunderbird!)
copy /Y ….configprefs.js .defaultsprofileprefs.js

Echo Repacking omni.jar…
del /f /q ..coreomni.jar
%jdk%jar.exe cf ..coreomni.jar *

Echo Copying UVM Custom ISP file to source…
cd ….
mkdir .buildcoreispen-US
copy /Y .configUVMMail.rdf .buildcoreispen-USUVMMail.rdf
Echo Copying UVM default prefs.js to core directory (tbird no longer has a prefs.js by default, but it will be used if present)…
mkdir .buildcoredefaultsprofile
copy /Y .configprefs.js .buildcoredefaultsprofileprefs.js

Echo Deleting temporary files that should not be present in the installer…
rmdir /s /q .buildtemp

Echo Repackaging Thunderbird installer…
..bin7zr a .InstallerUVM_Thunderbird_setup_%tbver%.7z .build*
copy /b ..bin7zS.sfx + .configconfig.txt + .InstallerUVM_Thunderbird_setup_%tbver%.7z .InstallerUVM_Thunderbird_setup_%tbver%.exe

Echo Cleaning up installation source…
del /s /f /q .build*.*
rmdir /s /q .buildcore
rmdir /s /q .build
del /f /q .InstallerUVM_Thunderbird_setup_%tbver%.7z

Thunderbird 3.1 breaks our customizations

It appears that a Thunderbird 3.1 release (probably 3.1.1) introduced a change that has caused at least one entry in our UVM ISP Hook file to become invalided.  Two alert distributed support staff recently reported that the SMTP Server that our installer configures now is set to perform plain-text authentication over an unencrypted channel rather than using STARTTLS.

We know that this setting was correct in the past, and we see that it still is set in our ISP profile… Thunderbird simply is ignoring the setting.

Fortunately, there is a workaround for this setting.  We can modify the “mailnews.js” file in the installer to have the default value for “try_ssl” set to “2” instead of the original default of “0”.  All I had to do was add a line of “sed” work to our build script:

..binsed.exe --binary "s/try_ssl", 0)/try_ssl", 2)/"  .buildnonlocalizeddefaultsprefmailnews_new.js
MOVE /Y .buildnonlocalizeddefaultsprefmailnews_new.js .buildnonlocalizeddefaultsprefmailnews.js

This “sed” command searches for the phrase try_ssl", 0 and substitutes try_ssl", 2 . After repackaging, we find that the first SMTP server account created after install (which is therefore the default SMTP account) will be set to use “STARTTLS” instead of “clear text”.
I worry about future unannounced retirements of ISP Hook settings.

Thunderbird 3 – re-implementing the ISP Hook for customized deployments

About two years ago I did some work to customize the Mozilla Thunderbird product to work with the UVM IMAP servers out-of box:
https://sharepoint.uvm.edu/sites/ad/distribution/appconfig/Thunderbird.aspx

This project made use of the so-called “ISP Hook” for Thunderbird, loosely documented here:
https://developer.mozilla.org/en/Thunderbird_ISP_hooks

Unfortunately, it appeared that with the release of Thunderbird 3.0 the ISP Hook was being retired in favor of “autoconfig”:
https://wiki.mozilla.org/Thunderbird:Autoconfiguration

Autoconfig is a promising project, but unfortunately, it lacks the ability to configure all of the settings previously available in the ISP Hook RDF file:
https://bugzilla.mozilla.org/show_bug.cgi?id=475139

I had a long look at using the previous “autoconfig” (called “Mission Control Desktop”), and while this approach is powerful, it really requires too much external scripting to be effective as a deployment mechanism (MCD seems more ideally suited to management of systems in a lab environment):
https://developer.mozilla.org/En/MCD

So what is the solution?  It involves:

  1. One expatriate Windows sys admin and reverse-engineering expert.
  2. A few line of additional shell scripting to our existing build system.
  3. The ability to distinguish capital and lowercase letters.

While explaining the ISP Hook problem to my colleague Ben Coddington, I noticed that the old Account Configuration dialogs (complete with the create “UVM Email Account” option) was still available under TB3, but that the dialog could no longer be activated following a new installation.  Ben said “I’ll bet I can fix that”, and proceeded to unpack every “jar” file in the Thunderbird installation directory. 

He searched around for strings found in the old config dialog, located the XUL call that brings up the dialog, and then traced this call back to the parent function that initiates account creation for new profiles.  In the end we only needed to modify one line of javascript in one JAR to restore the old account dialog.  In “%ProgramFiles%Mozilla Thunderbirdchrome”, we unpack “messenger.jar”, and open “.contentmessengermsgMail3PaneWindow.js”, then replace “NewMailAccount(msgWindow, okCallback);” with “MsgAccountWizard(okCallback);”.  repack the archive, then drop it into the installer, and we are good to go.  Other than that, it is just like using the ISP Hook with TB 2.

There is one other minor change… I also set the following additional default option in the global prefs.js file:

user_pref("mail.winsearch.enable", true);

This defaults Windows Search integration to “on” in the new account setup dialog.  It is a cool new feature that everyone should use (in my opinion).

The following is the modified build script I now use to quickly repackage new Thunderbird releases into customized versions.  Note that we use the free gnuwin32 version of “sed” to do our javascript modifications (be sure to use the –b (—binary) switch to avoid file munging), and we also need 7-zip (7z.exe) to handle file unpacking and packing:

REM Thunderbird customized build script for UVM.
REM Updated December 2009 for Thunderbird 3.0 support.
REM REQUIRES: 7z.exe, 7zr.exe and sed.exe in parallel "..bin" directory
REM     Unmodified Thunderbird installer in .source directory
REM        all required config files in .config directory
REM     (including 7z control file, ISP Hook RDF file, and modified prefs.js)
REM OUTPUT: Fully modified Thunderbird installer in .Installer directory.
@echo off

Echo Cleaning up old builds...
del .Installer*.exe
rmdir /s /q .build
set /P tbver=Enter Thunderbird version number to build (i.e. "3.0.0.0"):

Echo Extracting setup files from OEM Installer...
mkdir .buildtemp
..bin7zr x .source*.exe -o.build

Echo Extracting messenger.jar contents...
REM messenger.jar is a ZIP type archive... need full 7z executable to unpack.
..bin7z x .buildnonlocalizedchromemessenger.jar -o.buildtemp

Echo modifying messenger functions...
..binsed.exe --binary "s/NewMailAccount(msgWindow, okCallback);/MsgAccountWizard(okCallback);/" <.buildtempcontentmessengermsgMail3PaneWindow.js > .buildtempcontentmessengermsgMail3PaneWindow_new.js
MOVE /Y .buildtempcontentmessengermsgMail3PaneWindow_new.js .buildtempcontentmessengermsgMail3PaneWindow.js

Echo Repacking messenger.jar...
REM again, we must use the full 7z executable.  -mx=0 means archive with no compression.
..bin7z a -tzip -mx=0 .buildtempmessenger.jar .buildtemp*

Echo Copying UVM Custom config files to source...

copy /Y .configprefs.js .buildnonlocalizeddefaultsprofileprefs.js
mkdir .buildnonlocalizedispen-US
copy /Y .configUVMMail.rdf .buildnonlocalizedispen-USUVMMail.rdf
copy /Y .buildtempmessenger.jar .buildnonlocalizedchromemessenger.jar

Echo Deleting temporary files...
rmdir /s /q .buildtemp

Echo Repackaging Thunderbird installer...
..bin7zr a .InstallerUVM_Thunderbird_setup_%tbver%.7z .build*
copy /b ..bin7zS.sfx + .configconfig.txt + .InstallerUVM_Thunderbird_setup_%tbver%.7z .InstallerUVM_Thunderbird_setup_%tbver%.exe

Echo Cleaning up installation source...
REM rmdir /s /q .build
del /f /q .InstallerUVM_Thunderbird_setup_%tbver%.7z