From c2674612289c27e71e59ce582179593ad33ddd79 Mon Sep 17 00:00:00 2001 From: aland Date: Tue, 18 Oct 2005 22:31:25 +0000 Subject: [PATCH] Renamed paircmp to paircompare, as we should probably have a low-level comparison function, in the lib directory --- src/include/radiusd.h | 13 ++++--------- src/main/valuepair.c | 18 +++++------------- src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c | 2 +- src/modules/rlm_dbm/rlm_dbm.c | 2 +- src/modules/rlm_fastusers/rlm_fastusers.c | 6 +++--- src/modules/rlm_files/rlm_files.c | 6 +++--- src/modules/rlm_ldap/rlm_ldap.c | 2 +- src/modules/rlm_preprocess/rlm_preprocess.c | 8 ++++---- src/modules/rlm_sql/rlm_sql.c | 10 +++++----- 9 files changed, 27 insertions(+), 40 deletions(-) diff --git a/src/include/radiusd.h b/src/include/radiusd.h index 95bde32..79e23d6 100644 --- a/src/include/radiusd.h +++ b/src/include/radiusd.h @@ -32,11 +32,6 @@ typedef pid_t child_pid_t; #include #endif -#ifdef HAVE_ARPA_INET_H -#include -#endif - - #define NO_SUCH_CHILD_PID (child_pid_t) (0) #ifndef NDEBUG @@ -123,7 +118,7 @@ typedef struct radclient { lrad_ipaddr_t ipaddr; int prefix; char *longname; - u_char *secret; + char *secret; char *shortname; char *nastype; char *login; @@ -139,7 +134,7 @@ typedef struct _realm { char acct_server[64]; lrad_ipaddr_t ipaddr; /* authentication */ lrad_ipaddr_t acct_ipaddr; - u_char secret[32]; + char secret[32]; time_t last_reply; /* last time we saw a packet */ int auth_port; int acct_port; @@ -427,8 +422,8 @@ int paircompare_register(int attr, int otherattr, RAD_COMPARE_FUNC func, void *instance); void paircompare_unregister(int attr, RAD_COMPARE_FUNC func); -int paircmp(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, - VALUE_PAIR **reply); +int paircompare(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, + VALUE_PAIR **reply); int simplepaircmp(REQUEST *, VALUE_PAIR *, VALUE_PAIR *); void pair_builtincompare_init(void); void pairxlatmove(REQUEST *, VALUE_PAIR **to, VALUE_PAIR **from); diff --git a/src/main/valuepair.c b/src/main/valuepair.c index ed75935..6901799 100644 --- a/src/main/valuepair.c +++ b/src/main/valuepair.c @@ -66,21 +66,13 @@ static struct cmp *cmp; /* * Compare 2 attributes. May call the attribute compare function. */ -static int paircompare(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, +static int compare_pair(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs) { int ret = -2; struct cmp *c; /* - * Sanity check. - */ -#if 0 - if (request->attribute != check->attribute) - return -2; -#endif - - /* * Check for =* and !* and return appropriately */ if( check->operator == T_OP_CMP_TRUE ) @@ -219,7 +211,7 @@ void paircompare_unregister(int attr, RAD_COMPARE_FUNC fun) * * Return 0 on match. */ -int paircmp(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, VALUE_PAIR **reply) +int paircompare(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, VALUE_PAIR **reply) { VALUE_PAIR *check_item; VALUE_PAIR *auth_item; @@ -327,7 +319,7 @@ int paircmp(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, VALUE_PAIR **r /* * OK it is present now compare them. */ - compare = paircompare(req, auth_item, check_item, check, reply); + compare = compare_pair(req, auth_item, check_item, check, reply); switch (check_item->operator) { case T_OP_EQ: @@ -472,12 +464,12 @@ int paircmp(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, VALUE_PAIR **r } /* - * Compare two attributes simply. Calls paircompare. + * Compare two attributes simply. Calls compare_pair. */ int simplepaircmp(REQUEST *req, VALUE_PAIR *first, VALUE_PAIR *second) { - return paircompare( req, first, second, NULL, NULL ); + return compare_pair( req, first, second, NULL, NULL ); } diff --git a/src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c b/src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c index 5959d15..59901d4 100644 --- a/src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c +++ b/src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c @@ -343,7 +343,7 @@ do_again: char buffer[sizeof(attr_vp->vp_strvalue)]; /* - * Stolen from src/main/valuepair.c, paircmp() + * Stolen from src/main/valuepair.c, paircompare() */ /* diff --git a/src/modules/rlm_dbm/rlm_dbm.c b/src/modules/rlm_dbm/rlm_dbm.c index bbb760c..debcd80 100644 --- a/src/modules/rlm_dbm/rlm_dbm.c +++ b/src/modules/rlm_dbm/rlm_dbm.c @@ -208,7 +208,7 @@ static int sm_parse_user(DBM *pdb, const char * username, VALUE_PAIR const* requ if ( parse_state == SMP_PATTERN ) { /* pattern line found */ DEBUG2("process pattern"); /* check pattern against request */ - if ( paircmp(NULL, request, vp, reply ) == 0 ) { + if ( paircompare(NULL, request, vp, reply ) == 0 ) { DEBUG2("rlm_dbm: Pattern matched, look for request"); pairmove(&tmp_config, &vp); pairfree(&vp); diff --git a/src/modules/rlm_fastusers/rlm_fastusers.c b/src/modules/rlm_fastusers/rlm_fastusers.c index 51f8a3a..d67e502 100644 --- a/src/modules/rlm_fastusers/rlm_fastusers.c +++ b/src/modules/rlm_fastusers/rlm_fastusers.c @@ -435,7 +435,7 @@ static PAIR_LIST *fastuser_find(REQUEST *request, PAIR_LIST *user, */ while((cur) && (!userfound)) { if((strcmp(cur->name, username)==0) && - paircmp(request, request->packet->vps, cur->check, &request->reply->vps) == 0) { + paircompare(request, request->packet->vps, cur->check, &request->reply->vps) == 0) { userfound = 1; DEBUG2(" fastusers: Matched %s at %d", cur->name, cur->lineno); } else { @@ -605,7 +605,7 @@ static int fastuser_authorize(void *instance, REQUEST *request) curdefault = inst->defaults; while(curdefault) { - if(paircmp(request, request->packet->vps, curdefault->check, + if(paircompare(request, request->packet->vps, curdefault->check, &request->reply->vps) == 0) { DEBUG2(" fastusers: Matched %s at %d", curdefault->name, curdefault->lineno); @@ -715,7 +715,7 @@ static int fastuser_preacct(void *instance, REQUEST *request) if (strcmp(name, pl->name) && strcmp(pl->name, "DEFAULT")) continue; - if (paircmp(request, request_pairs, pl->check, &reply_pairs) == 0) { + if (paircompare(request, request_pairs, pl->check, &reply_pairs) == 0) { DEBUG2(" acct_users: Matched %s at %d", pl->name, pl->lineno); found = 1; diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index 98e33fe..1dbaedc 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -316,7 +316,7 @@ static int file_authorize(void *instance, REQUEST *request) * check pairs, then add the reply pairs from the * entry to the current list of reply pairs. */ - if ((paircmp(request, request_pairs, pl->check, reply_pairs) == 0)) { + if ((paircompare(request, request_pairs, pl->check, reply_pairs) == 0)) { DEBUG2(" users: Matched entry %s at line %d", pl->name, pl->lineno); found = 1; check_tmp = paircopy(pl->check); @@ -383,7 +383,7 @@ static int file_preacct(void *instance, REQUEST *request) if (strcmp(name, pl->name) && strcmp(pl->name, "DEFAULT")) continue; - if (paircmp(request, request_pairs, pl->check, reply_pairs) == 0) { + if (paircompare(request, request_pairs, pl->check, reply_pairs) == 0) { DEBUG2(" acct_users: Matched entry %s at line %d", pl->name, pl->lineno); found = 1; @@ -446,7 +446,7 @@ static int file_preproxy(void *instance, REQUEST *request) if (strcmp(name, pl->name) && strcmp(pl->name, "DEFAULT")) continue; - if (paircmp(request, request_pairs, pl->check, reply_pairs) == 0) { + if (paircompare(request, request_pairs, pl->check, reply_pairs) == 0) { VALUE_PAIR *vp; DEBUG2(" preproxy_users: Matched entry %s at line %d", diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 1914287..43de649 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -1622,7 +1622,7 @@ static int ldap_authorize(void *instance, REQUEST * request) pairadd(reply_pairs,reply_tmp); } - if (inst->do_comp && paircmp(request,request->packet->vps,*check_pairs,reply_pairs) != 0){ + if (inst->do_comp && paircompare(request,request->packet->vps,*check_pairs,reply_pairs) != 0){ #ifdef NOVELL /* Don't perform eDirectory APC if RADIUS authorize fails */ int apc_attr; diff --git a/src/modules/rlm_preprocess/rlm_preprocess.c b/src/modules/rlm_preprocess/rlm_preprocess.c index badfc97..1f929dd 100644 --- a/src/modules/rlm_preprocess/rlm_preprocess.c +++ b/src/modules/rlm_preprocess/rlm_preprocess.c @@ -260,7 +260,7 @@ static int hunt_paircmp(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check) tmp = check_item->next; check_item->next = NULL; - result = paircmp(req, request, check_item, NULL); + result = paircompare(req, request, check_item, NULL); check_item->next = tmp; check_item = check_item->next; @@ -303,9 +303,9 @@ static int hints_setup(PAIR_LIST *hints, REQUEST *request) for (i = hints; i; i = i->next) { /* - * Use "paircmp", which is a little more general... + * Use "paircompare", which is a little more general... */ - if (paircmp(request, request_pairs, i->check, NULL) == 0) { + if (paircompare(request, request_pairs, i->check, NULL) == 0) { DEBUG2(" hints: Matched %s at %d", i->name, i->lineno); break; @@ -348,7 +348,7 @@ static int huntgroup_access(REQUEST *request, /* * See if this entry matches. */ - if (paircmp(request, request_pairs, i->check, NULL) != 0) + if (paircompare(request, request_pairs, i->check, NULL) != 0) continue; /* diff --git a/src/modules/rlm_sql/rlm_sql.c b/src/modules/rlm_sql/rlm_sql.c index 2e3f25e..922adae 100644 --- a/src/modules/rlm_sql/rlm_sql.c +++ b/src/modules/rlm_sql/rlm_sql.c @@ -678,12 +678,12 @@ static int rlm_sql_process_groups(SQL_INST *inst, REQUEST *request, SQLSOCK *sql /* * Only do this if *some* check pairs were returned */ - if (paircmp(request, request->packet->vps, check_tmp, &request->reply->vps) == 0) { + if (paircompare(request, request->packet->vps, check_tmp, &request->reply->vps) == 0) { found = 1; DEBUG2("rlm_sql (%s): User found in group %s", inst->config->xlat_name, group_list_tmp->groupname); /* - * Now get the reply pairs since the paircmp matched + * Now get the reply pairs since the paircompare matched */ if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_group_reply_query, request, sql_escape_func)) { radlog(L_ERR, "rlm_sql (%s): Error generating query; rejecting user", @@ -717,7 +717,7 @@ static int rlm_sql_process_groups(SQL_INST *inst, REQUEST *request, SQLSOCK *sql DEBUG2("rlm_sql (%s): User found in group %s", inst->config->xlat_name, group_list_tmp->groupname); /* - * Now get the reply pairs since the paircmp matched + * Now get the reply pairs since the paircompare matched */ if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_group_reply_query, request, sql_escape_func)) { radlog(L_ERR, "rlm_sql (%s): Error generating query; rejecting user", @@ -980,11 +980,11 @@ static int rlm_sql_authorize(void *instance, REQUEST * request) /* * Only do this if *some* check pairs were returned */ - if (paircmp(request, request->packet->vps, check_tmp, &request->reply->vps) == 0) { + if (paircompare(request, request->packet->vps, check_tmp, &request->reply->vps) == 0) { found = 1; DEBUG2("rlm_sql (%s): User found in radcheck table", inst->config->xlat_name); /* - * Now get the reply pairs since the paircmp matched + * Now get the reply pairs since the paircompare matched */ if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_reply_query, request, sql_escape_func)) { radlog(L_ERR, "rlm_sql (%s): Error generating query; rejecting user", -- 2.1.4