1/* MODULE: auth_dce */ 2 3/* COPYRIGHT 4 * Copyright (c) 1997-2000 Messaging Direct Ltd. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY MESSAGING DIRECT LTD. ``AS IS'' AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MESSAGING DIRECT LTD. OR 20 * ITS EMPLOYEES OR AGENTS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 23 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 27 * DAMAGE. 28 * END COPYRIGHT */ 29 30/* SYNOPSIS 31 * Authenticate against DCE. 32 * END SYNOPSIS */ 33 34#ifdef __GNUC__ 35#ident "$Id: auth_dce.c,v 1.9 2006/01/24 00:16:03 snsimon Exp $" 36#endif 37 38/* PUBLIC DEPENDENCIES */ 39#include <stdlib.h> 40#include <string.h> 41#include "mechanisms.h" 42 43#include "auth_dce.h" 44 45/* END PUBLIC DEPENDENCIES */ 46 47# define RETURN(x) {return strdup(x);} 48 49/* FUNCTION: auth_dce */ 50 51#ifdef AUTH_DCE 52 53char * /* R: allocated response string */ 54auth_dce( 55 /* PARAMETERS */ 56 const char *login, /* I: plaintext authenticator */ 57 const char *password, /* I: plaintext password */ 58 const char *service __attribute__((unused)), 59 const char *realm __attribute__((unused)) 60 /* END PARAMETERS */ 61 ) 62{ 63 int reenter = 0; /* internal to authenticate() */ 64 int rc; /* return code holder */ 65 char *msg; /* response from authenticate() */ 66 static char *reply; /* our reply string */ 67 68 int authenticate(char *, char *, int *, char **); /* DCE authenticator */ 69 70 rc = authenticate(login, password, &reenter, &msg); 71 if (rc != 0) { 72 /* 73 * Failed. authenticate() has allocated storage for msg. We have 74 * to copy the message text into a static buffer and free the 75 * space allocated inside of authenticate(). 76 */ 77 if (reply != 0) { 78 free(reply); 79 reply = 0; 80 } 81 if (msg == 0) 82 RETURN("NO"); 83 reply = malloc(strlen(msg) + sizeof("NO ")); 84 if (reply == 0) { 85 if (msg != 0) 86 free(msg); 87 RETURN("NO (auth_dce malloc failure)"); 88 } 89 strcpy(reply, "NO "); 90 strcat(reply, msg); 91 free(msg); 92 RETURN(reply); 93 } else { 94 if (msg != 0) 95 free(msg); 96 RETURN("OK"); 97 } 98} 99 100#else /* !AUTH_DCE */ 101 102char * 103auth_dce( 104 const char *login __attribute__((unused)), 105 const char *password __attribute__((unused)), 106 const char *service __attribute__((unused)), 107 const char *realm __attribute__((unused)) 108 ) 109{ 110 return NULL; 111} 112 113#endif /* !AUTH_DCE */ 114 115/* END FUNCTION: auth_dce */ 116 117/* END MODULE: auth_dce */ 118