Back to index

courier  0.68.2
Functions
pcpdauth.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <pwd.h>
#include <string.h>
#include <errno.h>
#include <sysconfdir.h>
#include "courierauth.h"
#include "pcpdauth.h"
#include "calendardir.h"

Go to the source code of this file.

Functions

char * auth_choplocalhost (const char *u)
static int badstr (const char *p)
static int callback_userid (struct authinfo *a, void *vp)
int authpcp_userid (const char *u, int(*func)(struct userid_callback *, void *), void *funcarg)
int authpcp_login (const char *uid, const char *pass, int(*func)(struct userid_callback *, void *), void *arg)

Function Documentation

char* auth_choplocalhost ( const char *  u)

Definition at line 39 of file pcpdauth.c.

{
       const char *p;
       char *s;

       p=strrchr(u, '@');
       if (p && strcasecmp(p+1, auth_myhostname()) == 0)
       {
              s=malloc(p-u+1);
              if (s)
              {
                     memcpy(s, u, p-u);
                     s[p-u]=0;
              }
       }
       else
              s=strdup(u);

       if (!s)
              fprintf(stderr, "ALERT: malloc failed.\n");
       return (s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int authpcp_login ( const char *  uid,
const char *  pass,
int(*)(struct userid_callback *, void *)  func,
void *  arg 
)

Definition at line 133 of file pcpdauth.c.

{
       struct userid_callback uinfo;

       memset(&uinfo, 0, sizeof(uinfo));
       uinfo.callback_func=func;
       uinfo.callback_arg=arg;

       if (badstr(uid) || badstr(pass))
              return (-1);


       return (auth_login("calendar", uid, pass, callback_userid, &uinfo));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int authpcp_userid ( const char *  u,
int(*)(struct userid_callback *, void *)  func,
void *  funcarg 
)

Definition at line 99 of file pcpdauth.c.

{
       char *s=NULL;
       int rc;
       struct userid_callback uinfo;

       if (badstr(u))
              return (-1);

       s=auth_choplocalhost(u);
       if (!s)
              return (1);

       memset(&uinfo, 0, sizeof(uinfo));
       uinfo.userid=s;
       uinfo.callback_func=func;
       uinfo.callback_arg=funcarg;

       rc=auth_getuserinfo("calendar", s, callback_userid, &uinfo);

       free(s);
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int badstr ( const char *  p) [static]

Definition at line 62 of file pcpdauth.c.

{
       while (*p)
       {
              if ((int)(unsigned char)*p < ' '
                  || *p == '\\' || *p == '\'' || *p == '"')
              {
                     errno=EIO;
                     return (1);
              }
              ++p;
       }
       return (0);
}

Here is the caller graph for this function:

static int callback_userid ( struct authinfo *  a,
void *  vp 
) [static]

Definition at line 77 of file pcpdauth.c.

{
       struct userid_callback *uid=(struct userid_callback *)vp;

       uid->homedir=a->homedir;
       uid->maildir=a->maildir;

       if (a->sysuserid)
              uid->uid= *a->sysuserid;
       else if (!a->sysusername)
              return (-1);
       else
       {
              struct passwd *pw=getpwnam(a->sysusername);

              if (!pw)
                     return (-1);
              uid->uid=pw->pw_uid;
       }
       return ( (*uid->callback_func)(uid, uid->callback_arg));
}

Here is the call graph for this function:

Here is the caller graph for this function: