macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Serve Your iCal Calendars Using WebDAV
Pages: 1, 2

3. Set Up Directories.

First, you need to set up the realm of WebDAV documents. Based on what we put in the configuration file, this will be in a subdirectory of the document root called /dav. So go to your server's document root (it's usually /Library/WebServer/Documents) and create a new directory called dav. I chose that name because I'll remember later what it's for.



Set the permissions and ownership of this directory so that the Web server can write to it. Do this by changing the group owner to www, which the Web server belongs to:

sudo chgrp www /Library/WebServer/Documents/dav

sudo chmod 775 /Library/WebServer/Documents/dav

Next, you need to make a place for the WebDAV lock database file. For lack of a better place, I created /usr/share/httpd/conf. Again, set the permissions so the server can write files here:

sudo chgrp www /usr/share/httpd/conf
sudo chmod 775 /usr/share/httpd/conf

4. Security Measures

Apache needs to know if the iCal trying to update the calendar is legit. So we have to create a new user and password. Don't use an existing user's name and password. A malicious hacker sniffing your communications can grab that username and use it to sneak inside your system. The username we will create will be limited to WebDAV files only, which will be useless to a would-be intruder.

First, create a password file in /Library/WebServer with this command:

htpasswd -c /Library/WebServer/.basic_pw webdav

You'll be prompted for a password. Invent something secure and save it someplace safe. Make the password unique (don't use one that you use elsewhere) because of the basic authentication risk I mentioned earlier. This password, and the user webdav will be the two parameters you give to iCal to connect to your server.

5. Restart the Server.

You could reboot the machine, but it's more elegant just to give the server a kick in the rear with the kill command. Don't worry, we aren't going really kill it. The -HUP option tells it to restart itself and read its configuration file again. Find the process ID number (PID) like this:

ps -ax | grep httpd

There will be several httpd processes running, but you only have to interrupt the first one, which is the master for all the rest. The command is:

sudo kill -HUP 1234

Where 1234 is the PID of the first httpd process.

6. Publish Your Calendar.

Related Reading

Mac OS X for Unix Geeks
By Brian Jepson, Ernest E. Rothman

You can close the terminal window now, and return to the cozy graphical interface of iCal. Select the calendar you want to publish and then hit the menu command Calendar -> publish... The window that pops up will give you two options: publish on .Mac or on a Web server. Being a maverick, you will click on the second, which expands the window with more options.

For the URL, put in the full path to the calendar file on the server. The name of the file may not be exactly what you typed in for the calendar. If there are spaces, for example, they will be replaced with the number 32, which is the space character's position in the ASCII character set. You can see ahead of time what the name will be by exporting the database to a file and reading the filename.

For username, put in "webdav". The password you created back in step 4 goes in the next field. And that's it!

You can create as many calendars as you want. I have two: http://www.ravelgrane.com/dav/Home.ics and http://www.ravelgrane.com/dav/Work.ics.

Test it out. You can subscribe to your own calendars, though you may think you're seeing double. If you have problems, check the Web server's error log in /var/log/httpd/error_log. When you're done, you'll be able to tell your friends and associates how to subscribe to your calendars and feel the respect wash over you.

Happy hacking!

Erik T. Ray is a software wrangler and XML guru for O'Reilly Media.


Return to the Mac DevCenter.