Glenn Faden's Blog

  • February 14, 2007

Prototyping Multilevel Mail

Guest Author

One of the potential use cases for Trusted Extensions is dealing with multilevel mail. In Trusted Solaris 1.x, which was based on OpenLook, we had an application called postmaster, which kept track of the arrival of a user's mail by periodically checking all the instances of the /var/mail/username in the multilevel directory. In Trusted Solaris 2.5 through 8, we integrated this functionality into the the CDE front panel. The CDE code in Trusted Extensions has this feature  disabled because most people are using remote mal services like IMAP or POP, rather than UNIX local mail (movemail).

I have been working on an architecture for multilevel mail in Trusted Extensions in which mail can be delivered  to labeled zones that are only in the ready state (mounted but not running). This would reduce the overhead of the current polyinstantiation approach in which  an instance of sendmail is running in each zone.

 At this point, all I have is a bunch of shell scripts to mimic the behavior of postmaster. But I think they are illustrative of how to launch applications in zones that may not be running. The txmailmgr script looks for all labeled instances of /var/mail for a user, and presents a list from which instances of thunderbird can be launched or popped up.

To signal thunderbird to pop up, I used the mozilla-xremote-client command with the openInbox option. However, it didn't work correctly, so I modified the JavaScript file nsMailDefaultHandler.js to open the correct window using the same logic that is used for a similar function in this file. You will need to replace the existing file in your lib/thunderbird/components directory to get the desired behavior.

The four shell scripts,  txmailmgr, runatlabel, waitforzone, and openMail should all be installed in /opt/txdemo/bin. You can  put them elsewhere if you edit the PATH variable in the scripts.

The txmailmgr script uses zenity and takes no command line arguments. It must be started in the global zone by assuming the root role. You should see a window like this:

mail manager

 One of the more interesting aspects of this prototype is how the runatlabel and waitforzone scripts interact when the zone is found to be in the ready state.  The following fragment starts the waitforzone script in the specified zone, and puts up a progress window giving the user feedback.

(zlogin ${zone} $DEMOPATH/waitforzone ${user} ${progname} ${DISPLAY} $@ ;echo 100)|zenity --progress --auto-close --title="Please Wait" --text="${zone} zone is booting"

The waitforzone
script periodically checks for the presence of the user's home
directory. It doesn't show up until the the zone's automountd has
processed  auto_home_zonename

which implies that suffficient zone services are up to support running
thunderbird.  Once a second it checks for the directory, and pipes a
progress percentage back to the instance of the zenity progress bar
which is running in the global zone. It's not a real percentage, just a
good guess.
while [ ! -d /home/${user} ]; do
        print $progress
        sleep 1
        let progress+=10

In the openMail script, the code first tries to determine if thunderbird is running befor invoking the mozilla-xremote-client facility. I found that it is faster to use pgrep than the mozilla ping facilty. The latter method generates hundreds of X window calls.

for f in `pgrep -U $user thunderbird`; do
    d=`/usr/ucb/ps -eww $f|tr " " "\\n"|grep DISPLAY`
        if [ $? = 0 ]; then
            DISPLAY=`echo $d|cut -f2 -d"="`
            export DISPLAY
            mozilla-xremote-client -a thunderbird  \\
               "xfeDoCommand(openInbox)" &

Some of these scripts could be used to launch  applications in zones  that are not even in ready state, but txmailmgr ignores zones whose filesystems are not mounted or labeled at ADMIN_HIGH.

label=$(getlabel /zone/\*/root/var/mail/$user|\\
    grep -v ADMIN_HIGH|cut -f2|zenity \\
    --list \\
    --title="$title" \\
    --width=300 \\
    --height=200 \\
    --column="Available Mail Labels for $user")

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.