Back to index

courier  0.68.2
Classes | Functions
pcpdauth.h File Reference
#include "config.h"
#include <sys/types.h>
#include <pwd.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  userid_callback

Functions

int authpcp_userid (const char *, int(*)(struct userid_callback *, void *), void *)
int authpcp_login (const char *, const char *, int(*)(struct userid_callback *, void *), void *)
char * auth_myhostname ()
char * auth_choplocalhost (const char *)

Function Documentation

char* auth_choplocalhost ( const char *  )

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:

char* auth_myhostname ( )

Definition at line 35 of file pcpdauthme.c.

{
char    buf[1024];
static char *my_hostname=0;
FILE   *f;

       if (my_hostname == 0)
       {
              buf[0]=0;

              f=fopen(HOSTNAMEFILE, "r");

              if (!f)
                     f=fopen(HOSTNAMEFILE2, "r");

              if (f != 0)
              {
              char *p;

                     if (fgets(buf, sizeof(buf), f) == NULL)
                            buf[0]=0;
                     fclose(f);

                     if ((p=strchr(buf, '\n')) != 0)
                            *p=0;
              }

              if (buf[0] == 0 && gethostname(buf, sizeof(buf)-1))
                     strcpy(buf, "localhost");

              if ((my_hostname=malloc(strlen(buf)+1)) == 0)
              {
                     fprintf(stderr, "NOTICE: malloc: out of memory.\n");
                     return strdup("localhost");
              }

              strcpy(my_hostname, buf);
       }
       return (my_hostname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int authpcp_login ( const char *  ,
const char *  ,
int(*)(struct userid_callback *, void *)  ,
void *   
)

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 *  ,
int(*)(struct userid_callback *, void *)  ,
void *   
)

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: