Name

rfc2045 — RFC 2045 (MIME) parsing library

Synopsis

#include <rfc822.h>
#include <rfc2045.h>

cc ... -lrfc2045 -lrfc822

DESCRIPTION

The rfc2045 library parses MIME-formatted messages. The rfc2045 library is used to:

1) Parse the structure of a MIME formatted message

2) Examine the contents of each MIME section

3) Optionally rewrite and reformat the message.

Creating an rfc2045 structure

#include <rfc2045.h>

struct rfc2045 *ptr=rfc2045_alloc();
void rfc2045_parse(struct rfc2045 *ptr, const char *txt, size_t cnt);

struct rfc2045 *ptr=rfc2045_fromfd(int fd);
struct rfc2045 *ptr=rfc2045_fromfp(FILE *fp);

void rfc2045_free(struct rfc2045 *ptr);

void rfc2045_error(const char *errmsg)
{
        perror(errmsg);
        exit(0);
}

The rfc2045 structure is created from an existing message. The function rfc2045_alloc() allocates the structure, then rfc2045_parse() is called to initialize the structure based on the contents of a message. txt points to the contents of the message, and cnt contains the number of bytes in the message.

Large messages are parsed by calling rfc2045_parse() multiple number of times, each time passing a portion of the overall message. There is no need to call a separate function after the entire message is parsed -- the rfc2045 structure is created dynamically, on the fly.

rfc2045_alloc() returns NULL if there was insufficient memory to allocate the structure. The rfc2045_parse() also allocates memory, internally, however no error indication is return in the event of a memory allocation failure. Instead, the function rfc2045_error() is called, with errmsg set to "Out of memory". rfc2045_error() is also called by rfc2045_alloc() - it also calls rfc2045_error(), before returning a NULL pointer.

The rfc2045_error() function is not included in the rfc2045 library, it must be defined by the application to report the error in some appropriate way. All functions below will use rfc2045_error() to report an error condition (currently only insufficient memory is reported), in addition to returning any kind of an error indicator. Some functions do not return an error indicator, so rfc2045_error() is the only reliable way to detect a failure.

The rfc2045_fromfd() function initializes an rfc2045 structure from a file descriptor. It is equivalent to calling rfc2045_alloc(), then reading the contents of the given file descriptor, and calling rfc2045_parse(). The rfc2045_fromfp() function initializes an rfc2045 structure from a FILE.

After the rfc2045 structure is initialized, the functions described below may be used to access and work with the contents of the structure. When the rfc2045 structure is no longer needed, the function rfc2045_free() deallocates and destroys the structure.

Structure of a MIME message


struct rfc2045 {

        struct rfc2045 *parent;

        struct rfc2045 *firstpart;
        struct rfc2045 *next;
        int             isdummy;
        int             rfcviolation;
} ;

The rfc2045 structure has many fields, only some are publicly documented. A MIME message is represented by a recursive tree of linked rfc2045 structures. Each instance of the rfc2045 structure represents a single MIME section of a MIME-formatted message.

The top-level structure that represents the entire message is created by the rfc2045_alloc() function. The remaining structures are created dynamically by rfc2045_parse(). Any rfc2045 structure, except ones whose isdummy flag is set, may be used acomman for IMAP account loginid.

Note

loginid is what's logged to syslog after a succesful login. In some situations loginid is not exactly the actual login ID used by the IMAP client.

group=name

Rights (or negative rights) for account group name. Access rights are granted to an account group as a whole. The account options feature of the Courier Authentication Library specifies which account belongs to which account group. See courier-authlib's documentation for more information.

administrators

This is an alias for group=administrators. Accounts that are members of an account group called administrators are considered administrative accounts, and automatically receive all access rights on all accessible folders.

Consider the following access control list:

owner          aceilrstwx
anyone         lr
user=john      w
-user=mary     r
administrators aceilrstwx

This access control list specifies that the folder's owner has complete control over the mailbox (as well as the administrators, which have complete access to every folder); everyone else can see it and open it, except for mary who can see that the mailbox exists, but can't open it; additionally, john can change the status and keywords of individual messages (but not mark them as deleted/undeleted or seen/unseen, which requires additional rights).

OPTIONS

maildiracl -reset maildir

This command resets access control lists in maildir which as a path to a maildir. Under certain conditions, the files where a folder's ACLs are saved may continue to exist after the folder is removed. The -reset options goes through maildir and removes all stale ACL files for removed folders.

Note

The Courier IMAP server normally performs this maintenance function automatically. It is not necessary to run this command under normal conditions.

maildiracl -list maildir folder

This command lists the access control lists set for folder. folder must be either INBOX or INBOX.folder.subfolder, which is the same naming convention for the Courier IMAP server.

maildiracl -set maildir folder identifier rights

Puts identifier (which may begin with a minus sign to specify a negative right) and rights in folder's access control list. Existing rights for identifier (or identifier) are replaced by rights unless rights begins with + or -, which modifies the existing rights by adding or removing from them accordingly. Some examples:

maildiracl -set /home/user1/Maildir INBOX.Sent user=john lr

maildiracl -set /home/user2/Maildir INBOX.Notes anyone -r

maildiracl -set /home/user3/Maildir INBOX.Private -user=tom +r

Note

Observe that the last command revokes the r right from tom, by adding it as a negative right.

maildiracl -delete maildir folder identifier

This command removes identifier from folder's access control list, if it exists. Use -identifier to remove negative rights.

maildiracl -compute maildir folder [identifier]+

This command takes a list of one or more identifiers. All access rights for the identifiers are combined together, then any appropriate negative rights are removed, and the result is printed on standard output. Use the following procedure to compute access rights the same way as they are computed by the Courier IMAP server:

maildiracl -compute /home/tom46/Maildir INBOX.Sent owner user=tom46

This command computes access rights tom46 has on his own folder.

maildiracl -compute /home/john34/Maildir INBOX.Public user=tom46

This command computes access rights tom46 has on john34's folder.

IRREVOCABLE ACCESS RIGHTS

The owner of the mailbox must always have the a amd l access rights. The administrators group must always have all access rights to all folders. Attempts to set access control lists, that do not include these minimum access rights, will be rejected.

BUGS

All identifiers are specified using the UTF-8 character set.

All non-Latin letters in folder names are specified using the modified-UTF7 coding as used in IMAP.

This implementation of access control lists is based on version 2 (or ACL2) of IMAP access control lists, which is a work-in-progress. The existing IMAP ACL, RFC 2086 is transparently implemented inside the ACL2 model.

If history's of any guidance, ACL2 is subject to change at any time. Be sure to check the release notes when upgrading to a newer version of this software. The ACL overview portion of this manual page is a very brief summary of ACL2, which leaves out optional parts of ACL2 that are not implemented.

SEE ALSO

maildirmake(1), maildirkw(1),

./usr/share/doc/maildrop/html/rfc2045.html0000644000000000000000000005476611762437116017151 0ustar rootroot rfc2045

Name

rfc2045 — RFC 2045 (MIME) parsing library

Synopsis

#include <rfc822.h>
#include <rfc2045.h>

cc ... -lrfc2045 -lrfc822

DESCRIPTION

The rfc2045 library parses MIME-formatted messages. The rfc2045 library is used to:

1) Parse the structure of a MIME formatted message

2) Examine the contents of each MIME section

3) Optionally rewrite and reformat the message.

Creating an rfc2045 structure

#include <rfc2045.h>

struct rfc2045 *ptr=rfc2045_alloc();
void rfc2045_parse(struct rfc2045 *ptr, const char *txt, size_t cnt);

struct rfc2045 *ptr=rfc2045_fromfd(int fd);
struct rfc2045 *ptr=rfc2045_fromfp(FILE *fp);

void rfc2045_free(struct rfc2045 *ptr);

void rfc2045_error(const char *errmsg)
{
        perror(errmsg);
        exit(0);
}

The rfc2045 structure is created from an existing message. The function rfc2045_alloc() allocates the structure, then rfc2045_parse() is called to initialize the structure based on the contents of a message. txt points to the contents of the message, and cnt contains the number of bytes in the message.

Large messages are parsed by calling rfc2045_parse() multiple number of times, each time passing a portion of the overall message. There is no need to call a separate function after the entire message is parsed -- the rfc2045 structure is created dynamically, on the fly.

rfc2045_alloc() returns NULL if there was insufficient memory to allocate the structure. The rfc2045_parse() also allocates memory, internally, however no error indication is return in the event of a memory allocation failure. Instead, the function rfc2045_error() is called, with errmsg set to "Out of memory". rfc2045_error() is also called by rfc2045_alloc() - it also calls rfc2045_error(), before returning a NULL pointer.

The rfc2045_error() function is not included in the rfc2045 library, it must be defined by the application to report the error in some appropriate way. All functions below will use rfc2045_error() to report an error condition (currently only insufficient memory is reported), in addition to returning any kind of an error indicator. Some functions do not return an error indicator, so rfc2045_error() is the only reliable way to detect a failure.

The rfc2045_fromfd() function initializes an rfc2045 structure from a file descriptor. It is equivalent to calling rfc2045_alloc(), then reading the contents of the given file descriptor, and calling rfc2045_parse(). The rfc2045_fromfp() function initializes an rfc2045 structure from a FILE.

After the rfc2045 structure is initialized, the functions described below may be used to access and work with the contents of the structure. When the rfc2045 structure is no longer needed, the function rfc2045_free() deallocates and destroys the structure.

Structure of a MIME message


struct rfc2045 {

        struct rfc2045 *parent;

        struct rfc2045 *firstpart;
        struct rfc2045 *next;
        int             isdummy;
        int             rfcviolation;
} ;

The rfc2045 structure has many fields, only some are publicly documented. A MIME message is represented by a recursive tree of linked rfc2045 structures. Each instance of the rfc2045 structure represents a single MIME section of a MIME-formatted message.

The top-level structure that represents the entire message is created by the rfc2045_alloc() function. The remaining structures are created dynamically by rfc2045_parse(). Any rfc2045 structure, except ones whose isdummy flag is set, may be used acomman for IMAP account loginid.

Note

loginid is what's logged to syslog after a succesful login. In some situations loginid is not exactly the actual login ID used by the IMAP client.

group=name

R