Merge branch 'oldradius'
authorLuke Howard <lukeh@padl.com>
Tue, 21 Sep 2010 10:49:23 +0000 (12:49 +0200)
committerLuke Howard <lukeh@padl.com>
Tue, 21 Sep 2010 10:49:23 +0000 (12:49 +0200)
Conflicts:
mech_eap/accept_sec_context.c
mech_eap/init_sec_context.c

1  2 
util_radius.cpp

diff --cc util_radius.cpp
@@@ -62,9 -120,40 +120,65 @@@ gss_eap_radius_attr_provider::initFromG
      return true;
  }
  
+ static bool
+ alreadyAddedAttributeP(std::vector <std::string> &attrs, VALUE_PAIR *vp)
+ {
+     for (std::vector<std::string>::const_iterator a = attrs.begin();
+          a != attrs.end();
+          ++a) {
+         if (strcmp(vp->name, (*a).c_str()) == 0)
+             return true;
+     }
+     return false;
+ }
++static bool
++isSecretAttributeP(int attrid, int vendor)
++{
++    bool ret = false;
++
++    switch (vendor) {
++    case RADIUS_VENDOR_ID_MICROSOFT:
++        switch (attrid) {
++        case RADIUS_VENDOR_ATTR_MS_MPPE_SEND_KEY:
++        case RADIUS_VENDOR_ATTR_MS_MPPE_RECV_KEY:
++            ret = true;
++            break;
++        default:
++            break;
++        }
++    default:
++        break;
++    }
++
++    return ret;
++}
++
  bool
  gss_eap_radius_attr_provider::getAttributeTypes(gss_eap_attr_enumeration_cb addAttribute, void *data) const
  {
+     VALUE_PAIR *vp;
+     std::vector <std::string> seen;
+     for (vp = m_avps; vp != NULL; vp = vp->next) {
+         gss_buffer_desc attribute;
++        if (isSecretAttributeP(ATTRID(vp->attribute), VENDOR(vp->attribute)))
++            continue;
++
+         if (alreadyAddedAttributeP(seen, vp))
+             continue;
+         attribute.value = (void *)vp->name;
+         attribute.length = strlen(vp->name);
+         if (!addAttribute(this, &attribute, data))
+             return false;
+         seen.push_back(std::string(vp->name));
+     }
      return true;
  }
  
@@@ -99,7 -227,80 +252,85 @@@ gss_eap_radius_attr_provider::getAttrib
                                             gss_buffer_t display_value,
                                             int *more) const
  {
-     return false;
+     OM_uint32 tmpMinor;
+     VALUE_PAIR *vp;
+     int i = *more;
+     int max = 0;
+     char name[NAME_LENGTH + 1];
+     char displayString[AUTH_STRING_LEN + 1];
+     gss_buffer_desc valueBuf = GSS_C_EMPTY_BUFFER;
+     gss_buffer_desc displayBuf = GSS_C_EMPTY_BUFFER;
+     *more = 0;
++    if (isSecretAttributeP(attrid, vendor))
++        return false;
++
+     vp = rc_avpair_get(m_avps, attrid, vendor);
+     if (vp == NULL)
+         return false;
+     if (i == -1)
+         i = 0;
+     do {
+         if (i == max)
+             break;
+         max++;
+     } while ((vp = rc_avpair_get(vp->next, attrid, vendor)) != NULL);
+     if (i > max)
+         return false;
+     if (vp->type == PW_TYPE_STRING) {
+         valueBuf.value = (void *)vp->strvalue;
+         valueBuf.length = vp->lvalue;
+     } else {
+         valueBuf.value = (void *)&vp->lvalue;
+         valueBuf.length = 4;
+     }
+     if (value != GSS_C_NO_BUFFER)
+         duplicateBuffer(valueBuf, value);
+     if (display_value != GSS_C_NO_BUFFER &&
+         isPrintableAttributeP(vp)) {
+         if (rc_avpair_tostr(m_rh, vp, name, NAME_LENGTH,
+                             displayString, AUTH_STRING_LEN) != 0) {
+             gss_release_buffer(&tmpMinor, value);
+             return false;
+         }
+         displayBuf.value = (void *)displayString;
+         displayBuf.length = strlen(displayString);
+         duplicateBuffer(displayBuf, display_value);
+     }
+     if (authenticated != NULL)
+         *authenticated = m_authenticated;
+     if (complete != NULL)
+         *complete = true;
+     if (max > i)
+         *more = i;
+     return true;
+ }
+ bool
+ gss_eap_radius_attr_provider::getAttribute(int attrid,
+                                            int *authenticated,
+                                            int *complete,
+                                            gss_buffer_t value,
+                                            gss_buffer_t display_value,
+                                            int *more) const
+ {
 -    return getAttribute(attrid, 0, authenticated, complete,
++
++    return getAttribute(ATTRID(attrid), VENDOR(attrid),
++                        authenticated, complete,
+                         value, display_value, more);
  }
  
  gss_any_t