Enable building #WITHOUT_PROXY
[freeradius.git] / src / modules / rlm_realm / rlm_realm.c
index 1ca475e..e960a26 100644 (file)
@@ -80,18 +80,20 @@ static int check_for_realm(void *instance, REQUEST *request, REALM **returnrealm
         *      Also, if there's no User-Name attribute, we can't
         *      proxy it, either.
         */
+#ifdef WITH_PROXY
        if ((request->proxy != NULL) ||
            (request->username == NULL)) {
                RDEBUG2("Proxy reply, or no User-Name.  Ignoring.");
                return RLM_MODULE_OK;
        }
+#endif
 
        /*
         *      Check for 'Realm' attribute.  If it exists, then we've proxied
         *      it already ( via another rlm_realm instance ) and should return.
         */
 
-       if ( (vp = pairfind(request->packet->vps, PW_REALM)) != NULL ) {
+       if (pairfind(request->packet->vps, PW_REALM, 0) != NULL ) {
                RDEBUG2("Request already proxied.  Ignoring.");
                return RLM_MODULE_OK;
        }
@@ -180,7 +182,7 @@ static int check_for_realm(void *instance, REQUEST *request, REALM **returnrealm
                 */
                if (request->username->attribute != PW_STRIPPED_USER_NAME) {
                        vp = radius_paircreate(request, &request->packet->vps,
-                                              PW_STRIPPED_USER_NAME,
+                                              PW_STRIPPED_USER_NAME, 0,
                                               PW_TYPE_STRING);
                        RDEBUG2("Adding Stripped-User-Name = \"%s\"", username);
                } else {
@@ -195,10 +197,16 @@ static int check_for_realm(void *instance, REQUEST *request, REALM **returnrealm
 
        /*
         *      Add the realm name to the request.
+        *      If the realm is a regex, the use the realm as entered
+        *      by the user.  Otherwise, use the configured realm name,
+        *      as realm name comparison is case insensitive.  We want
+        *      to use the configured name, rather than what the user
+        *      entered.
         */
-       pairadd(&request->packet->vps, pairmake("Realm", realm->name,
+       if (realm->name[0] != '~') realmname = realm->name;
+       pairadd(&request->packet->vps, pairmake("Realm", realmname,
                                                T_OP_EQ));
-       RDEBUG2("Adding Realm = \"%s\"", realm->name);
+       RDEBUG2("Adding Realm = \"%s\"", realmname);
 
        /*
         *      Figure out what to do with the request.
@@ -230,6 +238,7 @@ static int check_for_realm(void *instance, REQUEST *request, REALM **returnrealm
                break;
        }
 
+#ifdef WITH_PROXY
        RDEBUG2("Proxying request from user %s to realm %s",
               username, realm->name);
 
@@ -255,7 +264,7 @@ static int check_for_realm(void *instance, REQUEST *request, REALM **returnrealm
         *      that has already proxied the request, we don't need to do
         *      it again.
         */
-       vp = pairfind(request->packet->vps, PW_FREERADIUS_PROXIED_TO);
+       vp = pairfind(request->packet->vps, PW_FREERADIUS_PROXIED_TO, 0);
        if (vp && (request->packet->src_ipaddr.af == AF_INET)) {
                int i;
                fr_ipaddr_t my_ipaddr;
@@ -304,11 +313,13 @@ static int check_for_realm(void *instance, REQUEST *request, REALM **returnrealm
                }
 
        }
+#endif
 
        /*
         *      We got this far, which means we have a realm, set returnrealm
         */
        *returnrealm = realm;
+
        return RLM_MODULE_UPDATED;
 }