import from HEAD:
authorfcusack <fcusack>
Thu, 24 May 2007 23:44:28 +0000 (23:44 +0000)
committerfcusack <fcusack>
Thu, 24 May 2007 23:44:28 +0000 (23:44 +0000)
handle OTP_RC_NEXTPASSCODE error from otpd-2.2.1+

1  2 
src/modules/rlm_otp/otp.h
src/modules/rlm_otp/otp_pw_valid.c

@@@ -23,7 -23,7 +23,7 @@@
  #ifndef OTP_H
  #define OTP_H
  
 -#include <freeradius-devel/ident.h>
 +#include "ident.h"
  RCSIDH(otp_h, "$Id$")
  
  #include <sys/types.h>
@@@ -44,6 -44,7 +44,7 @@@
  #define OTP_RC_AUTH_ERR               3
  #define OTP_RC_MAXTRIES               4
  #define OTP_RC_SERVICE_ERR    5
 -#define OTP_RC_NEXTPASSCODE   6
++#define OTP_RC_NEXT_PASSCODE  6
  
  #define OTP_MAX_USERNAME_LEN          31
  /* only needs to be MAX_PIN_LEN (16) + MAX_RESPONSE_LEN (16) */
   * Copyright 2006,2007 TRI-D Systems, Inc.
   */
  
 -#include <freeradius-devel/ident.h>
 +#include "ident.h"
  RCSID("$Id$")
  
 -#include <freeradius-devel/radiusd.h>
 -#include <freeradius-devel/modules.h>
 +#include "autoconf.h"
 +#include "radiusd.h"
 +#include "modules.h"
  
  #include "extern.h"
  #include "otp.h"
  #include "otp_pw_valid.h"
  
 -#ifdef HAVE_PTHREAD_H
 +#include <errno.h>
  #include <pthread.h>
 -#endif
 +#include <stdlib.h>
 +#include <string.h>
 +#include <sys/types.h>
 +#include <sys/socket.h>
  #include <sys/un.h>
 +#include <unistd.h>
  
  
  /* transform otpd return codes into rlm return codes */
@@@ -47,13 -42,14 +47,14 @@@ static in
  otprc2rlmrc(int rc)
  {
    switch (rc) {
-     case OTP_RC_OK:                     return RLM_MODULE_OK;
-     case OTP_RC_USER_UNKNOWN:           return RLM_MODULE_REJECT;
-     case OTP_RC_AUTHINFO_UNAVAIL:       return RLM_MODULE_REJECT;
-     case OTP_RC_AUTH_ERR:               return RLM_MODULE_REJECT;
-     case OTP_RC_MAXTRIES:               return RLM_MODULE_USERLOCK;
-     case OTP_RC_SERVICE_ERR:            return RLM_MODULE_FAIL;
-     default:                            return RLM_MODULE_FAIL;
+     case OTP_RC_OK:                   return RLM_MODULE_OK;
+     case OTP_RC_USER_UNKNOWN:         return RLM_MODULE_REJECT;
+     case OTP_RC_AUTHINFO_UNAVAIL:     return RLM_MODULE_REJECT;
+     case OTP_RC_AUTH_ERR:             return RLM_MODULE_REJECT;
+     case OTP_RC_MAXTRIES:             return RLM_MODULE_USERLOCK;
+     case OTP_RC_NEXTPASSCODE:         return RLM_MODULE_USERLOCK;
+     case OTP_RC_SERVICE_ERR:          return RLM_MODULE_FAIL;
+     default:                          return RLM_MODULE_FAIL;
    }
  }
  
@@@ -80,7 -76,7 +81,7 @@@ otp_pw_valid(REQUEST *request, int pwe
    otp_request_t       otp_request;
    otp_reply_t otp_reply;
    VALUE_PAIR  *cvp, *rvp;
 -  char                *username = request->username->vp_strvalue;
 +  char                *username = request->username->strvalue;
    int         rc;
  
    if (request->username->length > OTP_MAX_USERNAME_LEN) {
        (void) radlog(L_AUTH, "rlm_otp: passcode for [%s] too long", username);
        return RLM_MODULE_REJECT;
      }
 -    (void) strcpy(otp_request.pwe.u.pap.passcode, rvp->vp_strvalue);
 +    (void) strcpy(otp_request.pwe.u.pap.passcode, rvp->strvalue);
      break;
  
    case PWE_CHAP:
                      username);
        return RLM_MODULE_INVALID;
      }
 -    (void) memcpy(otp_request.pwe.u.chap.challenge, cvp->vp_strvalue,
 +    (void) memcpy(otp_request.pwe.u.chap.challenge, cvp->strvalue,
                    cvp->length);
      otp_request.pwe.u.chap.clen = cvp->length;
 -    (void) memcpy(otp_request.pwe.u.chap.response, rvp->vp_strvalue,
 +    (void) memcpy(otp_request.pwe.u.chap.response, rvp->strvalue,
                    rvp->length);
      otp_request.pwe.u.chap.rlen = rvp->length;
      break;
                      username);
        return RLM_MODULE_INVALID;
      }
 -    (void) memcpy(otp_request.pwe.u.chap.challenge, cvp->vp_strvalue,
 +    (void) memcpy(otp_request.pwe.u.chap.challenge, cvp->strvalue,
                    cvp->length);
      otp_request.pwe.u.chap.clen = cvp->length;
 -    (void) memcpy(otp_request.pwe.u.chap.response, rvp->vp_strvalue,
 +    (void) memcpy(otp_request.pwe.u.chap.response, rvp->strvalue,
                    rvp->length);
      otp_request.pwe.u.chap.rlen = rvp->length;
      break;
                      username);
        return RLM_MODULE_INVALID;
      }
 -    (void) memcpy(otp_request.pwe.u.chap.challenge, cvp->vp_strvalue,
 +    (void) memcpy(otp_request.pwe.u.chap.challenge, cvp->strvalue,
                    cvp->length);
      otp_request.pwe.u.chap.clen = cvp->length;
 -    (void) memcpy(otp_request.pwe.u.chap.response, rvp->vp_strvalue,
 +    (void) memcpy(otp_request.pwe.u.chap.response, rvp->strvalue,
                    rvp->length);
      otp_request.pwe.u.chap.rlen = rvp->length;
      break;