Go to the first, previous, next, last section, table of contents.
/* Prefix auth_ is reserved */
#include <mailutils/auth.h>
There are many ways to authenticate to a server. To be flexible the
authentication process is provided by two objects auth_t
and
ticket_t
. The auth_t
can implement different protocol like
APOP, MD5-AUTH, One Time Passwd etc .. By default if a mailbox
does not understand or know how to authenticate it falls back to
user/passwd authentication. The ticket_t
is a way for
Mailboxes and Mailers provide a way to authenticate when the URL does not
contain enough information. The default action is to call the function
auth_authenticate
which will get the user and passwd
if not set, this function can be overridden by a custom method.
A simple example of an authenticate function:
#include <mailutils/auth.h> #include <stdio.h> #include <string.h> int my_authenticate (auth_t auth, char **user, char **passwd) { char u[128] = ""; char p[128] = ""; /* prompt the user name */ printf ("User: "); fflush (stdout); fgets (u, sizeof (u), stdin); u[strlen (u) - 1] = '\0'; /* nuke the trailing NL */ /* prompt the passwd */ printf ("Passwd: "); fflush (stdout); echo_off (); fgets (p, sizeof(p), stdin); echo_on (); p[strlen (p) - 1] = '\0'; /* duplicate */ *user = strdup (u); *passwd = strdup (p); return 0; }
Go to the first, previous, next, last section, table of contents.