Monthly Archives: May 2008

How to test your Mozilla patch in RTL mode

I’m happy to announce the availability of the Force RTL extension!  This extension allows you to test Firefox and Thunderbird’s user interface in RTL mode, without needing to download a Hebrew, Arabic or Persian version, without changing the user interface language, and without restarting the application (if you’re running a recent version of the application).  You can read more here.

Kai Liu had the original idea for this extension.  He mentioned to me on IRC that he has an extension which he uses to test the browser interface in RTL mode.  I was eager to see this extension, and he was kind enough to share the extension on addons.mozilla.org.  I decided that it was inconvenient to restart the application each time one wants to switch the direction, so I started hacking the extension and added support for dynamic switching of the direction.  After a few emails exchanged with Kai, some small changes made by him and me to make the extension work better, I uploaded the latest version of the extension (2.0.1) to addons.mozilla.org.

Go install the extension and test how your Firefox and Thunderbird look and behave in right-to-left mode!  I also created a page explaining this extension in more details.  Here’s a picture of this extension in action:

Tagged with: , , , ,
Posted in Blog

Force RTL Extension

Force RTL

Force RTL is an extension for Firefox and Thunderbird, which is aimed at Mozilla developers.  Force RTL tries to help minimize the number of bugs introduced in Firefox and Thunderbird in RTL mode, by giving the developers a very easy tool to test their changes to the Firefox and Thunderbird user interface in RTL mode.

Force RTL Preview

Rationale

Most languages spoken around the world are written from left to right.  There are, however, some languages written from right to left, including, but not limited to, Hebrew, Arabic and Persian.  These languages require special handling in computer software.

The Mozilla project has been supporting RTL languages for quite some time.  However, if you grab the latest version of an RTL build of Firefox, for example, you will note that there are a lot of problems with the user interface which don’t exist in left-to-right versions of the browser.  A lot of these bugs are already known.  Because most of the developers working on these project do not have an RTL version of the browser (and can’t use one of the RTL localizations, because they don’t know those languages), they are often likely to introduce new RTL bugs, which don’t show up in LTR mode (because that’s the mode that the developer has tested his code under).  Therefore, a simple method is needed to change the direction of the user interface to RTL, without changing the language of the interface.  Force RTL attempts to solve this problem.

How to Get It?

Installing Force RTL is as simple as installing any other Firefox or Thunderbird extension.  Simply, view the Force RTL extension’s page on AMO, and grab the latest version from there.  The latest version currently is 2.1.

Please note that Find In Numbers is currently in sandbox, and is therefore shown as experimental.  To install it, you need to register an account on AMO if you don’t already have one, and log in using that account.  Your reviews will help get this extension public, and are appreciated!

How It Works

Firefox 2.0.0.x and Thunderbird 2.0.0.x

When you install this extension in Firefox 2.0.0.x or Thunderbird 2.0.0.x, the interface of the application switches to right-to-left as soon as you restart the application with this extension enabled.  In order to switch back to the left-to-right mode, you should disable this extension and restart the application.

Firefox 3.0.x and Thunderbird 3.0.x and later

When you install this extension in Firefox 3.0.x (including Firefox 3 alpha and beta versions starting from Alpha 1, and higher versions) or Thunderbird 3 Alpha 1 (and higher versions), the direction of the interface can be adjusted dynamically at runtime.  To test it, you can use the "Force RTL Direction" menu item from the Tools menu.  This menu item allows you to switch between RTL and LTR modes dynamically.  For example, if you want to test your patch in RTL mode, you can simply switch to the RTL mode, test your chages, and switch back to the LTR mode when you’re done.  No restart is required.  The selected direction will be saved across sessions, so if you choose the RTL direction and close the application, the next time you open it, it will start in RTL mode by default.  The RTL mode settings affect both existing windows, and the ones you open later on.

Known Problems

Corrupted Menu Layout

During testing this extension, we found out that if you change the direction via the Tools menu, the layout of this menu itself will be corrupted after the switch.  Switching the mode back to what it was does not solve this issue.  Kai Liu (the original creator of this extension) found out that this is a bug in Gecko, and is not specific to our extension.  He filed a bug for this issue, and also wrote a simple test case demonstrating the problem.  Possible workarounds for this issue are opening a new window or restarting the application.  Of course, if what you’re working on does not include menus, this problem does not affect your work in any way.

RTL Builds Not Supported

Currently (as of version 2.1), this extension does not support RTL versions of Firefox and Thunderbird.  Support for those versions is something I can add if users request it, but I’m not sure if it’s helpful, since if you’re running an RTL version of the application, you’re not affected by the problem described above.

Acknowledgments

Thanks to Kai Liu, for his great work on fixing RTL related bugs, and this extension.  The original idea of this extension belongs to him, and he created the initial version of this extension, and helped me with creating the newer version which allows dynamic switching of the direction.

Posted in Extension

How to test your Mozilla patch faster

If you’re writing any code for Mozilla, you sure have tasted how disturbing it might be to write some piece of code, then do a full build of the entire code base, and then testing your work, only to find that you need to make a small correction, and recycle the whole build and test process again.  This may waste a lot of time which can be used elsewhere, so here are two tricks that may come in handy.

Code changes only in JAR modules

Mozilla based projects package some pieces of the code which are interpreted at runtime in JAR archives.  These include JavaScript code, CSS stylesheets, XUL files, XBL bindings, etc.  If the changes you’re making is only within such files, then all you need o do is to rebuild the corresponding JAR file.  So, for example, if you’re making a change to button.css, then all you have to do to build a new version of the project you’re testing is to issue the following command (if you don’t use an objdir — and you should!):

cd /path/to/mozilla/sources
make -C toolkit/themes

Or this command if you’re using an objdir:

cd /path/to/mozilla/sources
make -C objdir/toolkit/themes

And, voilà!  You can run and test your changes, and it took less than 10 seconds to build the new version (if you have a reasonably modern machine, that is).

Code changes to C++ modules

If you happen to be working on a C++ module, then you can use the two-stage build like this example.  Firstly, you should add the following to your .mozconfig (if it doesn’t already contain those), and use an objdir:

ac_add_options --disable-static
ac_add_options --disable-libxul

These options make the compile process produce separate shared library modules that are dynamically-linked at runtime.  So, if you’re making a change to, let’s say, nsEventStateManager.cpp, then all you have to do is to build the shared component in which this file is being linked.  That is:

cd /path/to/mozilla/sources
make -C objdir/content/events

This compiles nsEventStateManager.cpp (with any other files which need to be re-compiled because of compile-time dependencies).  To actually link this file into the executable module loaded at runtime, you have to make the build directory as well.  This directory is usually named "build" and is located in the module’s main directory (for example, netwerk/build), but there are some exceptions.  The build dir for uriloader is docshell/build, and the build dir for content, dom, editor and view is layout/build.  So, the next command to run is:

make -C objdir/layout/build

Which takes the resulf of compilation of nsEventStateManager.cpp and links it into a shared library to be loaded at runtime.  This is usually much more faster than a new build, unless you’re making tree-wide changes.  Try it, and you’ll never hack without it!

Tagged with: ,
Posted in Blog

Firefox 2008 Download Day

Firefox 2008 Download Day is a SpreadFirefox.com project, which is intending to set a Guinness world record for most software downloads in 24 hours!  All you have to do is to pledge on their page that you will download a copy of Firefox 3 on the Download Day (the date to be announced later), and actually do download Firefox 3 on that date!  You can leave your email address in order to be notified of the exact schedule of the Download Day.

Of course, you can do more than that!  You can get your family, friends, colleagues, etc. to download Firefox on that day, and you can get involved in this project in several ways, one being hosting the logo on your blog/web page (yes, see the top of this very page!).  It’s way cool to set a world record, so jump in and join us in this project.  You’ll be proud.

Tagged with: , ,
Posted in Blog

Last patch for Firefox 3

Firefox 3 is in the "End Game" status, which means that it’s feature and code complete, and won’t get changes except to fix any serious bugs found during the final tests before the release.  Firefox 3 RC1 has already been released.  On Tuesday, it was decided that there will be one more release candidate (namely Firefox 3 RC2) before the final release.  Firefox 3 RC2 will most likely be the Firefox 3 final version, unless some very serious issues are found, and it’s decided that they’re required to be fixed in the final product.

Today, the tree was frozen in order for the build team to start building the product and hand it over to the QA team.  A total number of 43 issues were resolved in RC2 compared to RC11, the last of them being bug 427729, which was an issue for the RTL versions of the browser.  Tomer Cohen (from the Hebrew localization team of Firefox) wrote the patch for this bug.  The patch (which may well be the last patch for Firefox 3.0.0) was landed on 2008-05-28 12:47 PDT.  Yay!


1 Not all of those issues were serious issues blocking the release of Firefox 3.  Most of them were the "nice-to-have-but-not-mandatory" changes which were supposed to either go into RC2, or 3.0.1, which is expected to be released soon after Firefox 3.0.0.

Tagged with: ,
Posted in Blog

How not to write an installer

OK, this is driving me crazy.  ISPConfig is a great piece of software.  It can manage your web sites, and related services (such as DNS, FTP, mail, etc.) well, and it handles the config files with pretty good care, and it rarely breaks.  But, the installation experience is so twisted that I can’t bear.  And if I would only have to tolerate this at fresh installs, then I’d just try to live with it, but facing the same old problems once more each time I try to update the installation is way beyond acceptable.

After you download their latest release, and untar it in, let’s say, /root, it creates a folder named install_ispconfig and then you’re just supposed to cd into that directory and issue a ./setup command.  Then the setup application asks you some questions about your system’s config1 (giving you a choice for an expert setup mode, in which it asks you all kinds of questions about all of the services installed on your system) and then it starts compiling Apache/PHP/OpenSSL/etc.  And if you’re doing an upgrade, you only have to choose your language and agree to their licensing terms, no further questions appear on the screen.  That sounds easy, right?

Wrong.  The installer is written with the assumption that everything will work right the first time.  If you answer incorrectly on any of those questions, or if something interrupts the installation process (be it as simple as an SSH session being disconnected, assuming you’re not using screen), then what are you supposed to do?  Just re-run ./setup and hope it picks up from where it left last time, right?

Wrong.  You’re supposed to delete the whole install_ispconfig directory2, and start from scratch!  Now, that doesn’t sound like a big deal?  Consider this.  I was updating ISPConfig on a server today, and nearly at the end of the install session, I got a number of weird shell error messages whining about unrecognized commands, and an Enter Password prompt.   Obviously I didn’t know what password to enter, so I tried the first password coming to my mind, the ISPConfig administrative password.  But it turned out that I was wrong.  Checking out the error messages, I noticed it should be the MySQL password.  Turns out that the ISPConfig installer tries to invoke the mysql utility with the password specified on the command line, and special characters in the password could confuse the shell, causing those error messages.  I found this after retrying the whole setup process (including half an hour to rebuild all the packages from the source) four times in a row.

You’d think that an installer should be able to handle such an error along the way?  You’d think that it should be able to use the results of those steps which were completed successfully in later runs?  You’d think that the compilation and configuration steps could be separated in the installer so that failing one does not abort the other?  If you’re working with the ISPConfig installer, you’d be wrong.  Come on, guys, you could do better.


1 It should be noted that strangely enough, it never asks you where you want ISPConfig to be installed.  It uses /root/ispconfig and /home/admispconfig, and you don’t get a say on that.  I still remember the first time I installed ISPConfig: I renamed the extracted directory to /root/ispconfig, and ran the setup from there, and wasted hours before I figured out that it’s the name of the directory which causes the installer to fail…

2 Actually the newer versions of their installer seems to delete that directory itself when something goes wrong, and doesn’t care to print a single message on the console.  Imagine how surprised you’d be when the installer quits, and you ls inside the install_ispconfig folder to see that the directory is empty!  And if you cd up and ls again, you’ll see there’s no install_ispconfig directory at all!  Hilarious!

Tagged with: ,
Posted in Blog

Translate Toolkit

Brian King wrote about how he used Translate Toolkit in order to manage the Slovene (sl) locale in Firefox.  I found the article worth reading, so I thought I’d share the link.

http://brian.kingsonline.net/talk/?p=306

Tagged with: , ,
Posted in Blog

Fail2ban only picking up the first ignore IP

Today I had this problem where Fail2ban was keeping on blacklisting an IP address, even though it was in the ignoreip list in /etc/fail2ban/jail.conf.  After double-checking everything on the server, and googling desperately, I found out that up to version 0.8.2, Fail2ban had a bug which caused only the first IP in the ignoreip list to take effect.  And guess what?  Ubuntu versions before gutsy have older versions of Fail2ban.  After a bit of digging, I found out the patch which had fixed the problem in 0.8.2, and I decided to patch my local Fail2ban installation.

In order to do this, you should edit /usr/share/fail2ban/server/filter.py and apply the following patch:

--- filter.py.orig 2008-05-21 02:49:22.000000000 -0500 +++ filter.py 2008-05-21 02:50:12.000000000 -0500 @@ -299,7 +299,7 @@ for i in self.__ignoreIpList: # An empty string is always false if i == "": - return False + continue s = i.split('/', 1) # IP address without CIDR mask if len(s) == 1: @@ -314,7 +314,7 @@ if ip in ips: return True else: - return False + continue if a == b: return True return False

Then, you should restart Fail2ban:

/etc/init.d/fail2ban restart

And it will pick up the fix and process the ignoreip correctly.

Tagged with: ,
Posted in Blog

libpam_foreground undefined symbol error on Ubuntu

If you happen to run Ubuntu Server (at least, up to version 7.04) and use the Courier POP3 or IMAP server, and you’re watching your log files closely, you’ve seen error messages such as the below one in /var/log/syslog:

May 21 01:14:10 server4 authdaemond: PAM [dlerror: /lib/security/pam_foreground.so: undefined symbol: pam_set_data]

Many people have observed this problem.  This happens because libpam-foreground.so has not been compiled with the right options.  This library needs to be linked against libpam.so and glibc.so, but it isn’t).  So, why is that this error only manifests itself in Courier login attempts, and not all the other applications and services which use PAM?  This depends on the order that each application loads its shared objects.  If the application first loads both glibc and libpam, and then tries to load libpam-foreground, then great!  Otherwise (as is the case with Courier) an error such as the above happens.

This is just a nuisance, because in non-interactive sessions, libpam-foreground doesn’t do anything useful after all, but here’s how to fix it.  You should just run the below commands in a login session.  You don’t need to be root (I use sudo where necessary).

cd ~ sudo apt-get install build-essential fakeroot devscripts mkdir libpam-foreground cd libpam-foreground wget http://launchpadlibrarian.net/8187075/libpam-foreground_0.3-0ubuntu1.debdiff apt-get source libpam-foreground sudo apt-get build-dep libpam-foreground cd libpam-foreground-0.3 patch -p4 < ../libpam-foreground_0.3-0ubuntu1.debdiff debuild -uc -us cd .. sudo dpkg -i libpam-foreground_0.3-0ubuntu1_i386.deb

The above commands download the source package for libpam-foreground, apply a patch to correct the compilation options, re-compile the package and install the resulting deb file.  No more annoying log messages from libpam-foreground!

Tagged with: ,
Posted in Blog

OpenVPN Windows compilation problem: solved

Alon Bar-Lev seems to have convinced OpenVPN developers to update the autoconf scripts so that a correct config-win32.h is generated, so now the Windows build environment for OpenVPN works again!  To generate the config-win32.h file, run the below commands in an MSYS prompt:

autoreconf -i -v -f
./configure

Thanks to Alon, James, and other OpenVPN developers for the great software!

Tagged with: ,
Posted in Blog