Back to index

courier  0.68.2
externalauth.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 2008 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #if    HAVE_CONFIG_H
00007 #include      "config.h"
00008 #endif
00009 #include      <stdio.h>
00010 #include      <stdlib.h>
00011 #include      <string.h>
00012 #if    HAVE_UNISTD_H
00013 #include      <unistd.h>
00014 #endif
00015 
00016 const char *externalauth()
00017 {
00018        const char *p=getenv("TLS_EXTERNAL");
00019        char *q, *r;
00020 
00021        if (!p || !*p)
00022               return NULL;
00023 
00024        if ((q=malloc(strlen(p)+20)) == NULL)
00025               return NULL;
00026 
00027        strcat(strcpy(q, "TLS_SUBJECT_"), p);
00028 
00029        for (r=q; *r; r++)
00030               if (*r >= 'a' && *r <= 'z')
00031                      *r -= 'a' - 'A';
00032 
00033        p=getenv(q);
00034        free(q);
00035 
00036        if (p && *p)
00037               return p;
00038        return 0;
00039 }