[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freeradius-devel
Subject:    [PATCH] Replicate-To-Realm in rlm_realm
From:       Vesselin Atanasov <vesselin () bgnet ! bg>
Date:       2001-05-25 17:51:37
[Download RAW message or body]

Hello.
This patch adds support for "Replicate-To-Realm" attribute in rlm_realm,
so it is no longer necessary to include rlm_fastusers module in order to
make replication work.

vesselin

["freeradius-23_May_2001.realm.patch" (TEXT/PLAIN)]

diff -ru freeradius-23_May_2001.orig/raddb/radiusd.conf.in \
                freeradius-23_May_2001/raddb/radiusd.conf.in
--- freeradius-23_May_2001.orig/raddb/radiusd.conf.in	Mon Apr 23 16:47:13 2001
+++ freeradius-23_May_2001/raddb/radiusd.conf.in	Wed May 23 21:43:43 2001
@@ -425,12 +425,14 @@
 	#  Two config options:
 	#	format     -  must be 'prefix' or 'suffix'
 	#	delimiter  -  must be a single character
+	#	replicate  -  must be 'yes' or 'no'
 	#
 	#  'username@realm'
 	#
 	realm suffix {
 		format = suffix
 		delimiter = "@"
+		replicate = "no"
 	}
 
 	#
@@ -441,6 +443,7 @@
 	#realm prefix {
 	#	format = prefix
 	#	delimiter = "/"
+	#	replicate = "yes"
 	#}
 
 	#
@@ -449,6 +452,7 @@
 	#realm percent {
 	#	format = suffix
 	#	delimiter = "%"
+	#	replicate = "no"
 	#}
diff -ru freeradius-23_May_2001.orig/src/modules/rlm_realm/rlm_realm.c \
                freeradius-23_May_2001/src/modules/rlm_realm/rlm_realm.c
--- freeradius-23_May_2001.orig/src/modules/rlm_realm/rlm_realm.c	Wed Mar 14 06:54:54 \
                2001
+++ freeradius-23_May_2001/src/modules/rlm_realm/rlm_realm.c	Wed May 23 21:36:08 2001
@@ -40,6 +40,7 @@
         int        format;
         char       *formatstring;
         char       *delim;
+        int        replicate;
 } realm_config_t;
 
 static CONF_PARSER module_config[] = {
@@ -47,6 +48,8 @@
     offsetof(realm_config_t,formatstring), NULL, "suffix" },
   { "delimiter", PW_TYPE_STRING_PTR,
     offsetof(realm_config_t,delim), NULL, "@" },
+  { "replicate", PW_TYPE_BOOLEAN,
+    offsetof(realm_config_t,replicate), NULL, "no"},
   { NULL, -1, 0, NULL, NULL }    /* end the list */
 };
 
@@ -224,6 +227,39 @@
 }
 
 /*
+ *	Maybe add a "Replicate-To-Realm" attribute to the request.
+ *
+ *	If it's a LOCAL realm, then don't bother.
+ */
+static void add_replicate_to_realm(VALUE_PAIR **vps, REALM *realm)
+{
+	VALUE_PAIR *vp;
+
+	/*
+	 *	If it's the LOCAL realm, we do NOT replicate it, but
+	 *	we DO strip the User-Name, if told to do so.
+	 */
+	if (strcmp(realm->server, "LOCAL") == 0) {
+		return;
+	}
+
+	/*
+	 *	Tell the server to replicate this request to another
+	 *	realm.
+	 */
+	vp = pairmake("Replicate-To-Realm", realm->realm, T_OP_EQ);
+	if (!vp) {
+		radlog(L_ERR|L_CONS, "no memory");
+		exit(1);
+	}
+	
+	/*
+	 *  Add it, even if it's already present.
+	 */
+	pairadd(vps, vp);
+}
+
+/*
  *  Perform the realm module instantiation.  Configuration info is
  *  stored in *instance for later use.
  */
@@ -302,6 +338,7 @@
 {
 	const char *name = (char *)request->username->strvalue;
 	REALM *realm;
+        struct realm_config_t *inst = instance;
 
 	if (!name)
 	  return RLM_MODULE_OK;
@@ -319,9 +356,14 @@
 
 
 	/*
-	 *	Maybe add a Proxy-To-Realm attribute to the request.
+	 *	Maybe add a Proxy-To-Realm or Replicate-To-Realm attribute to
+	 *      the request.
 	 */
-	add_proxy_to_realm(&request->config_items, realm);
+	if (inst->replicate == 0) {
+		add_proxy_to_realm(&request->config_items, realm);
+	} else {
+		add_replicate_to_realm(&request->config_items, realm);
+	}
 
 	return RLM_MODULE_OK; /* try the next module */
 }


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic