CS161 Programming Assignment 5: IMAP Server (part 1)

1) Preliminaries

Questions: cs161tas@cs.brown.edu
Due date: Friday, December 2nd, 10 PM.

2) CS161 Environment Setup

Add this line to your shell startup scripts:

    source /course/cs161/startups/cs161student

3) Introduction

Your fifth programming task is to implement an IMAP server in C++ using NMSTL. As you know by now, IMAP is described in RFC 3501. Your server will be due in two pieces. The first part will consist of implementing all commands that are available in the "Not Authenticated" state: AUTHENTICATE, CAPABILITY, LOGIN, LOGOUT, NOOP, and STARTTLS, plus two extra useful commands: LIST and SEARCH.

As usual, you will implement your server with an event-based architecture to support large numbers of concurrent connections. Again, you may use external processes to avoid blocking in your main loop, but you should avoid starting a process for each connection.

4) Assignment Specification

  1. You are implementing six IMAP commands. However, you should structure your code to support adding new commands rapidly (in part 2).
  2. Your AUTHENTICATE and STARTTLS commands will be barebones. You will reply BAD or NO as appropriate, because you will not support SSL or any extra authentication mechanisms.
  3. LOGIN should support authentication based on the contents of a file in the current directory, login.txt. You should describe and implement a mechanism that avoids storing passwords as cleartext in this file.
  4. Your SEARCH command need not handle the optional charset. You do not need to handle any search keys that require you to parse email headers or dates (BCC, BEFORE, CC, FROM, etc). Other keys, such as those that handle flags, should be handled. You should also handle BODY.
  5. Listen on a specific port with command line switch -p port, so that you can start your servers on department machines without root privileges.
  6. You program should support a way to add a user to login.txt rather than start up as a server. ./imapd jj hippo Should modify login.txt to allow jj to login with password "hippo".
  7. You should describe, in a README, your program as it exists, how commands are added, and how you intend to implement mailboxes (and folders) in the second phase. Describe your intended file usage, as well as your program structure to avoid blocking, and mailbox corruption from simultaneous clients.

5) Testing

You should be able to use your IMAP client from previous labs to test your server. Testing with other clients (pine, mozilla, fetchmail, etc) may also be useful.

Remember to read RFC 2683 which contains advice for IMAP developers (clients and servers).

6) Support Code

To help you get started we're giving you access to two fingerd implementations. You may take code and ideas from these servers. They are in /course/cs161/asgn/imapd/fingerd. If you had troule with the fingerd, this should help you get started. We recommend taking a little time and becoming familar with both, then taking the best of both worlds.

7) Submitting your code

To submit your code, run the following script inside the top level directory of your work:
    /course/cs161/bin/cs161_handin imapd-login
Please contact the TAs if you have problems submitting. For your own sanity, don't leave your submission until the minute before the deadline.

8) Grading scheme

Your code will be graded on the following factors (and their weights).

Documentation and design (login.txt, part 2, etc): 40%
Functionality (non-blocking, error reporting, etc): 40%
Robustness (malicious input, many connections, etc): 20%