ONLamp.com    
 Published on ONLamp.com (http://www.onlamp.com/)
 See this if you're having trouble printing code examples


Big Scary Daemons

Installing OCSweb on FreeBSD

06/15/2000

The OCSweb package allows users to post messages, read and send e-mail, and keep calendars, all via a web browser. It's friendly, easy to enable over https, and fairly robust. Unfortunately, it only runs on Linux. If you're looking for this functionality on BSD, you're pretty much out of luck.

At one point I needed this functionality on my laptop, so that I could access my e-mail from anywhere in the office, even without ssh on desktops. I could have fought with the package to make it run under Linux mode. Instead, one slow Saturday I decided to port OCSweb to FreeBSD.

Let me start off by saying I know almost nothing about code. I write scary Perl to eliminate tedious jobs, and my C makes seasoned programmers shake their heads. We all start somewhere, though.

I started by downloading the entire OCSweb package from ftp:ftp.obsidian.co.za. The README informed me that to get an e-mail reader on a Web site, I needed to use the ocs-base and ocs-email modules. Fair enough. Hoping I would get very lucky, I tried the install script. It died, complaining about pkg/getversion.

A brief reading of install.pl showed that pkg/makefile contained the Make instructions. The pkg/getversion line seemed Linux-specific, with no FreeBSD equivalent, so I just commented it out. Similarly, I changed the $prefix variable from /opt to /usr/local.

The install script got a little further, compiling despite complaints about a deprecated <malloc.h>. Eventually I came to:

chgrp: no such user

Linux has a "root" group, however, which has no exact equivalent in FreeBSD. I went through install.pl, replacing the "root" group with "wheel," our closest equivalent. While the script finished, /usr/local/ocs was mostly empty.

Some more hunting through the install script turned up the file pkg/filelist. This file contained the names of the ocsbase files, their destinations, their owners, their groups, and their permissions. It was chock full of root.root entries, saying that the files would be owned by root and in the root group. Emacs fixed that in a couple dozen keystrokes.

The install script ran all the way through this time. The last bits concerned me, though.

chgrp: -R: No such file or directory
ln: /usr/doc/ocs: No such file or directory
chgrp: -R: No such file or directory

Churning through install.pl, I found the culprit:

`chgrp $wgrp -R $prefix/ocs`

The code to set $wgrp doesn't work on FreeBSD. I went to /usr/local and did

chgrp nogroup -R ocs

thinking that should do the same thing.

I wasn't worried about the docs; I have the original source, the original docs, and the tarball they came in.

Following the install instructions, I added a <Directory></Directory> entry to my httpd.conf file so that OCSweb could work and restarted apache.

Now, the ultimate test. I fired up the web browser and pointed it at my laptop. A nice login screen appeared. Victory!

Now, on to ocsemail. Extracting the package, I saw that the install routine is pretty much the same as ocsbase. I edited install.pl to change the "root" group to "wheel," set $prefix to /usr/local, edited pkg/makefile to eliminate the Linux overhead, and replaced pkg/filelist's root.root entries with root.wheel.

It installed cleanly, on the first try. I was quite impressed with myself, until I tried to log in. OCSweb gave a nice friendly error:

cannot share-lock cookiejar

And httpd-errors proclaimed:

chown: root: illegal group name

Root group. Who ever heard of a "root" group? (Linux. And SysV, and Solaris... Apparently FreeBSD is the odd one out here.) Muttering atrocities, I broke out the sledgehammer:

% grep -r -i root /usr/local/ocs/* > groupoffenders

I found the offending line in lib/oio.pl and changed it.

A brief check of the OCSweb mailing list archive told me that the OCSweb data directory needs read and write permissions for the web server user (i.e., nobody/nogroup). A simple chmod fixed that. My login worked now, but when I clicked on the mail link I got:

--

Content-type: text/html 

Software error:

You don't have a user called mail on the server 

For help, please send mail to the webmaster 
(mwlucas@exceptionet.com), giving this error message 
and the time and date of the error. 

--

Well, if this is the best OCSWeb can do to stop me, I'm pretty much set. I used vipw to copy the entry for nobody to mail, setting the gid and uid to 25.

Finally, I could log in. OCSmail told me that I had no mail. That's odd, as elm told me that I really ought to be answering any of the thirty or so messages I've deemed important enough to keep. Also, the graphics all showed up as broken links.

Here, Netscape's "view source" function is my friend. I could see why my mailbox appeared to be empty:

<input type=hidden name=omb 
 value="/var/spool/mail/mwlucas">

FreeBSD stores mail under /var/mail/, not /var/spool/mail. The shotgun approach served well here:

grep -R spool /usr/local/ocs/*

turned up the OCSweb e-mail configuration file, emailcfg.pl, which I vaguely remembered from reading the documentation. I found a few other useful options to set here, such as the path to Fetchmail.

As I guessed, the image problem was Yet Another Permissions Issue (tm, pat. pend).

Moments later, I was calling up my mail on the Web.

Better still, OCSweb can store e-mail in classic "Mbox" format. Mail is stored under ~home/mail. A simple edit in .elm/elmrc, a mv Mail mail, and Elm and OCSweb now share the same directory; I have an interoperable e-mail setup no matter where I'm working.

Despite numerous petty headaches, OCSweb is not that difficult to install on FreeBSD. It seems it would be fairly simple to turn into a port. In a future column, we'll do just that.

Now, all that remains is to get the OCSweb designers to put a little red daemon near the penguin in the logo.

Michael W. Lucas


Read more Big Scary Daemons columns.

Discuss this article in the O'Reilly Network Operating Systems.

Return to the BSD DevCenter.

 

Copyright © 2009 O'Reilly Media, Inc.