Category Archives: Linux

All my thoughts on Linux

SSH files that can bite you in the ass

Today, I learned about the existence of ~/.ssh/rc and some of its side effects.

Today, Dave couldn’t figure out why he was unable to launch an X application from a machine we both use. We both started looking into it, and it looked like xauth wasn’t being called to update the .Xauthority file. We spent a good half hour or more looking around trying to figure out if it was a bug in OpenSSH on his mac, or one on the Linux server, if xauth was wonky, or what other small differences there were between his server side environment and mine.

During the search I found this post on a Debian mailing list. It was a red herring as it had us investigating a few dead ends. However, it did point out to my mind the existence of the ~/.ssh/rc file. Up until this point, I didn’t know of this files existence. Anyway, while looking in ~dave/.ssh/ I saw he had such a file.

To quote from the man page:

$HOME/.ssh/rc
Commands in this file are executed by ssh when the user logs in
just before the user’s shell (or command) is started. See the
sshd(8) manual page for more information.

There was an emacs backup file (rc~) there, which I looked into. At one time Dave used it to set a umask for all his connections that came in via ssh. For whatever reason, he must have decided that was not doing what he wanted, so he removed the umask line, but didn’t remove the file. Because the file existed, ssh was trying to execute the commands in it, and since there was nothing in it, ssh did nothing and dumped him to a shell.

From the behavior of ssh, it appears there is a “default” rc that happens if you don’t have one or one doesn’t exist in /etc/ssh. One of the tasks of this default includes calling xauth if you’re doing X11 forwarding. By having an empty file there, Dave was bypassing all of it. I haven’t taken the time to see what other side effects came about from that, but there must not have been much, as Dave hadn’t noticed it since last April (at least according to the mod time on the rc file.)

Dave just IMed me and told me to look at the sshd man page and see the following:

When a user successfully logs in, sshd does the following:
[snip]
8. If $HOME/.ssh/rc exists, runs it; else if /etc/ssh/sshrc
exists, runs it; otherwise runs xauth. The “rc” files are
given the X11 authentication protocol and cookie in standard
input.

One other thing we learned in this is that xauth is dumb dumb stupid. xauth won’t create a .Xauthority file if there is nothing to put into it, such as when you call “xauth list” when a file doesn’t exist. However, if you do an “xauth list” and you don’t have a .Xauthority file, xauth spits out a diagnostic message saying its creating it. In reality, it doesn’t really create the file. Bad coding on someone’s part. This wasted us time, as we though it was xauth that was broken, not Dave’s ssh environment. One could argue that xauth IS broken by demonstrating this behavior, but that’s a different rant.

What thunderbird needs to replace mutt for me

I still mostly use mutt for my personal mail. The times I’m not using mutt, I’m not at an ssh capable terminal and end up using SquirrelMail, but that’s only in times of emergency. Anyway, I was inspired to write these thoughts down after an IRC conversation with Ari.

However, at work I’ve switched over to using Thunderbird. I like the offline folder stuff that Thunderbird does, and I recently found a silly extension that just cracks me up: the Display Mail User Agent extension. In general, Thunderbird does what I want, but I find myself missing a few features from mutt that I really wish was there.

  • The ability to arbitrarily attach other mail messages. In mutt, I can tag a bunch of messages and do a tag-forward and they are all attached to the forwarded mail. Also, from the compose menu in mutt you can do a shift-A aka attach-message navigate to a mailbox, tag messages, and quit back to the compose mail, and they are attached. For the life of me, in thunderbird, I cannot figure out how to attach a message, much less a whole thread, to an arbitrary mail. I can forward a piece of mail as an attachment, but I cannot forward n>1 messages. I often send interesting threads from mailing lists to friends and co-workers and this crimps my style.
  • The ability to do a reply to multiple messages and have them all quoted. Similar to the above situation, I can tag multiple messages in mutt and do a tag-reply or tag-group-reply. This feature quotes all the tagged messages as well as add all the appropriate people to the recipient list, for tag-reply this is the senders of the original mail, for tag-group-reply this is everyone who was listed as a recipient in any of the mails as well as the senders. While I don’t often use it to hit people scatter shot, I do often tag-reply to one person, when appropriate, if they have send me multiple messages in the time its taken me to get back to them.
  • Custom e-mail headers. This one is purely for amusement value and is nothing that would keep me on mutt over anything else. But it is fun, and I do have a lot defined. In any typical mail you might see something like this if you look at the headers:

    X-If-I-Knew-Better-I-Would-Not-Be-Running: Linux 2.6.12 i686
    X-Time-Married: 3 years, 11 months, 14 days, 4 hours, 21 minutes, 42 seconds
    X-Dinah-Lives: 1 year, 3 months, 21 hours, 38 minutes, 42 seconds
    X-Uptime: 20:48:42 up 222 days, 28 min, 5 users, load average: 0.01, 0.07, 0.07
    X-The-Amount-Of-Stuff-In-My-Inbox: 92

    They are all silly, but they keep me entertained, and no one really sees them. However, every once in a blue moon I really give someone a chuckle.

Another feature that would be nice to see in thunderbird doesn’t come from mutt but from Apple Mail in OS X. This isn’t a make or break thing since I’m not used to it, but it is a nifty feature I admire.

  • The ability to multiple select mailboxes and have them mingled and threaded properly in message header/index pane. Apple Mail does this, and its very slick. Its another one of those features you don’t use all the time, but it would be often enough to make it worth while. Being able to select INBOX, Sent, and a mailing list would be nice to see the some threads properly threaded all the way through when searching for a message.

Hopefully someone has already written extensions to do this and I just need to be pointed in the right direction. If not, I’ve considered writing some of them myself, but I lack the knowledge of XUL and other technologies I would need. Anyone know any good HOWTOs to get me started? (Oh, and a device to stop time so I have time to actually work on it?)

[Update 8/16: This is a mad knowledge bomb from Mark via IRC:

15:06 <spruance> hey, keith
15:06 <spruance> thunderbird can already forward an arbitrary number of messages
15:06 <spruance> drag those messages to the “send” area of your compose window and they’ll be attached
15:06 <spruance> grab a thread handle to take the whole thread
15:07 <spruance> Similarly, you can highlight more than one message and right click and choose “foward as attachment”

Well, the arbitrary forwarding works, I just must never have multiply selected images. However, under Fedora Core 3, with Thunderbird 1.0.6-1.1.fc3 (20050720) the dragging the message into the compose/address aread doesn’t work. The attachment box opens, but no messages are attached. Mark reports this works on Mac and Windows. Damn Linux.]

ezRETS

I normally try to avoid posting about work, as that way often leads to being fired or other unpleasentness. However, I think its okay in this case.

I’m really excited about our beta release of ezRETS an ODBC driver for RETS data sources. This has been one of the coolest projects I’ve worked on for a long time.

We just put out the windows binary today, but the source is available via subversion and if you can build it, it’ll run under Linux or Windows. OS X to follow. We will probably get out a source release next week, we just didn’t have time this week.

Trip to Museum of Science and Industry, Part II: Game On

Last Friday, Sarah and I went to Chicago’s Museum of Science and Industry to see the Body Worlds and Game On exhibits. Read about Body Worlds in Part I.

MSI/2005_06_17_11_59_31 MSI/2005_06_17_12_05_56

One of the other things that drew us to the museum was the Game On exhibit. Unfortunately, you couldn’t take pictures with a flash or tripod, so my images from it are a bit blurry.

In any case, it was a nice walk down memory lane, and it had a few things in it I’ve read about and never seen. They had an original Pong machine. You could play Pong, just not on the original cabinet. They had recreated/reconstituted guts set up in a different case. I assume it was to protect the original machine.

The coolest piece of history was a PDP-1. Of course, it wasn’t running, but it was sitting there and they had some information on Spacewar. If you don’t know about Spacewar you can read The origin of Spacewar on-line or Hackers: Heroes of the Computer Revolution by Steven Levy

They also had a MAME machine set up with controls a good distance from the display projected on the wall. It was a pretty sweet setup, I may have to get one for home. The MAME machine was supposed to be running Dave’s Game Launcher front end for emulators. Unfortunately, the controls weren’t responding, so I couldn’t verify. Dave said other people he knows have gone there and verified its Game Launcher. I’m sorry I missed it.

There was a small section on console companies that released products that let you write your own games. Nintendo apparently released such a kit in Japan. However, as part of this display was the Linux for the Playstation2 kit that Sony put out. As a Linux geek, I was surprised to see it. It was also fun to see something I own in a museum.

MSI/2005_06_17_12_18_51 MSI/2005_06_17_12_22_17

There was a round table with portable games arranged in chronological order. I was inspired to take the picture above where the newest kid on the block was meeting the old timer. I’m really way too amused by it.

Unfortunately, many of the games and consoles were in bad shape. They’ve taken a lot of abuse by all the visitors to the exhibit. But there was enough playable to keep you busy for hours. There’s also many games that were a joy to see and play for a short bit again, but I won’t mention them here. I’ll leave some mystery for your visit.

I’m just glad I got to play two of my favorites from back in the day: Discs of Tron and the old sit-down vector Star Wars game.

MSI/2005_06_17_12_31_10 MSI/2005_06_17_12_37_38

Open the iPod bay doors, HAL

As I’ve written about before I’ve written a .fdi file for my iPod for using with hald on FC3. My .fdi file fixes a few things that hald does by default. To find out more, just read that post!

Anyway, I just wanted to drop a note that I figured out last night how to specify any arbitrary mount option. I suppose it was possible all along, but last time I went down this trail, my brain was getting fried and thought only the mount options I saw in examples were possible. It turns out you can do any mount option as long as you specifiy it as a bool and set it true or false. You can also turn off default ones.

For some reason, for vfat filesystems, hald‘s default .fdis are set up to mount fat as UTF-8 by using the mount option of iocharset=utf8. This was causing some problems with gtkpod, so I wanted to remove that. Looking at some examples, I deceided to finally try specifing this in my iPod.fdi:

<merge key="volume.policy.mount_option.iocharset=utf8" type="bool">false</merge>

This worked, so I thought I’d try some other mount options I would have liked, but couldn’t figure out how to get going my last go around with the iPod.

<merge key="volume.policy.mount_option.shortname=win95" type="bool">true</merge>
<merge key="volume.policy.mount_option.noatime" type="bool">true</merge>

Those also worked. It looks like you can put anything after volume.policy.mount_option. as long as you specify the full option and set it to true.

If you want to recreate what I’ve done, take my .fdi from the previous post add the above lines to it for the second parition on the iPod and you two can get fstab-sync to create an fstab entry that looks like this:

/dev/sda2 /media/iPod vfat pamconsole,exec,noauto,noatime,shortname=win95,sync,managed 0 0

I’m sorry, Keith, I’m afraid I can’t do that. (FC3, HAL, and iPod)

I updated my desktop to Fedora Core 3 over the weekend. Technically, Fedora would consider it a fresh install, I just kept /home /work /usr/local and /opt. It all went smoothly thanks to my love of apt for rpm and the various repositories that I’ve talked about before that I use to keep me from hand compiling almost everything. The only thing I’ve done differently this time was that I’ve added DAG’s apt/yum repository to the mix.

With FC3 comes some new ways to get external devices going easier. udev, which “is an implementation of devfs in userspace using sysfs and /sbin/hotplug,” used to be an add on, but is now a central part of the distribution. udev is configured in such a way that it controls all of the /dev entries. Along with udev is the addition of freedesktop.org‘s Hardware Abstraction Layer software. This isn’t like the HAL in some other operating systems and based on the documentation that is not the goal. From the documentation:

HAL which is a piece of software that provides a view of the various hardware attached to a system. In addition to this, HAL keeps detailed metadata for each piece of hardware and provide hooks such that system- and desktop-level software can react to changes in the hardware configuration in order to maintain system policy.

Its not the world’s most useful thing yet, but considering FC3 ships with version 0.4.2 its doing a good job for its level of maturity.

One of the most useful things that HAL provides FC3 is the auto configuration of devices that would have removable media, such as cdrom drives, or is added via USB or firewire. In its default configuration is works pretty good: udev creates the /dev nodes and HAL, after scoping out and probing the hardware, creats mount points in /media and calls /usr/sbin/fstab-sync (which comes with HAL) to edit /etc/fstab with the entries. For my devices that have removable media, HAL has noticed my CD and DVD burners and has created /media/cdrecorder and /media/cdrecorder1. If I connect my iPod up via firewire, I see that /media/ieee1394disk is created. Putting a compact flash card in a slot of my 8-in-1 USB media reader, I see that /media/usbdisk is created.

As I said before, this is pretty good. However, there were a few things that bugged me that I wanted to change. The first problem I ran into was that hald, constantly probes attached media devices for media changes. This works great for my 8-in-1, as it correctly drops access to the device when I run /usr/bin/eject on the mount points. However, this fails dismally with my iPod.

In FC2, to get the iPod to go into the “OK to remove” mode, the eject command did the trick. In FC3, thanks to hald, it tries to spin up the iPod harddrive again. However, the iPod, after its in “OK to remove” mode will not respond to any commands from the computer until removed from the cradle. hald trying to contact it again causes the SCSI subsystem to go into a loop trying to reset the device and the SCSI bus, causes hald to hang, and generally really pisses off Linux. Since this whole ordeal ends with the SCSI subsystem kernel panicing and hald being stuck in a disk wait, the only thing to really get things back to normal that that point is a reboot. The reboot then has some issues thanks to hald being in disk wait, and Linux can’t cleanly unmount /usr.

So, obviously, I wanted to fix the “everything goes to shit when I want to remove my iPod” problem and I wanted to create a better mount point name for the iPod. Face it, /media/ieee1394disk is pretty weak and /media/iPod is much sexier.

I started digging around the hal package to see what docs came with it and what the config files were. The documentation that ships in the RPM is fairly non-existant except for some sample Device Information Files aka .fdi files. Next I looked in /etc/hald/hald.conf. That had a directive called storage_media_check_enabled which was set to true. Setting that to false and halfway fixed my iPod problem, except now two mount points were showing up in media. Also, setting it to false broke the 8-in-1 which was behaving perfectly. Not wanting to throw the baby out with the bathwater, I set it back to true. This setting, however, started to point me in the right direction.

Next I discovered the hal-gnome package by doing an apt-cache search hal. From this I found the misnamed /usr/bin/hal-device-manager. I say its misnamed as you get a Windows-style device manager view, but you can’t actually manage anything, its totally a read-only view. However, this let me see the properties that were being set for each device and its volumes along the way. Thanks to hal-device-manager I was starting to be able to read the .fdi files. However, my next question was “what are all the possible values of propery names that can be set?” For that I needed more documentation.

I visited the freedesktop.org hal site (as linked above) and it didn’t have anything really useful on it. I was getting motivated enough to just start reading C code, so I downloaded the hal-0.4.4 source from freedesktop.org. To my delight, there was actual useful documentation, albiet in raw docbook XML form. I almost cried, but I pulled myself together and typed make to build the documentation into a useful HTML file. Here was a list of all the possible properies, where they were good, and mostly good descriptions of what they did. I still didn’t have a full enough understanding, so it came time to start experimenting.

In my experimenting, I focused totally on making the iPod work the way I wanted and figured I’d tackle the 8-in-1 later as it mostly works the way I want now. The existing .fdi files have a comment that says to create system local files in /usr/share/hal/fdi/95userpolicy as all the other files in the other directories could be overwriten when/if the vendor updates the hal package. I started to write an iPod.fdi file and based my <device> entry on some of the existing firewire disk entry and merged it with the sample firewire connected hard drive example from /usr/share/doc/hal-0.4.2/conf

What I ended up with after my experimenting is something that seems to work really well. It turns off the media check just for the iPod, ignores the first partition used by the Apple Firmware, and makes a mount point at /media/iPod for the second partition where all the music lives. I also was able to add the sync mount option to the automatically created fstab entry. Lots of iPod on Linux people suggest mounting the iPod in sync mode, but I forget exactly why at this moment as my brain is running out of juice as I’m ending of this post.

This was through a bunch of trial and error, and if someone has a better way to do it, please let me know.
Here is my /usr/share/hal/fdi/95userpolicy/iPod.fdi

<?xml version="1.0" encoding="ISO-8859-1"?>  
<deviceinfo version="0.2">
  <device>
    <match key="storage.vendor" string="Apple">
      <match key="storage.model" string="iPod">
        <merge key="storage.requires_eject" type="bool">true</merge>
        <merge key="storage.removable" type="bool">false</merge>
        <merge key="storage.media_check_enabled" type="bool">false</merge>
      </match>
    </match>
    <match key="@block.storage_device:storage.vendor" string="Apple">
      <match key="@block.storage_device:storage.model" string="iPod">
        <match key="block.is_volume" bool="true">
          <match key="volume.fsusage" string="filesystem">
            <match key="volume.partition.number" int="1">
              <merge key="volume.policy.should_mount" type="bool">false</merge>
            </match>
            <match key="volume.partition.number" int="2">
              <merge key="volume.policy.desired_mount_point" type="string">iPod</merge>
              <merge key="volume.policy.mount_option.sync" type="bool">true</merge>
            </match>
          </match>
	</match>
      </match>
    </match>
  </device>
</deviceinfo>

Java dumbness of the day

My friend seva is an admin of some unix boxes (including linux) at a firm that does some stockish stuff. Appearently, some of their applications are based on java. He was running into a weird situation where the box was in EDT (where it lived) and but java kept thinking it was CDT (where the box was originally.) Well, it was reporting “America/Chicago” technically.
Continue reading Java dumbness of the day