Parcourir la source

radius: take realm from configuration

Baptiste Jonglez il y a 7 ans
Parent
commit
8065b2e7fd

+ 8 - 1
src/lib/dhcpsrv/radius_host_data_source.cc

@@ -112,6 +112,13 @@ RadiusHostDataSource(const DatabaseConnection::ParameterMap& parameters) {
          isc_throw(DbOpenError, "Failed to configure Radius retries");
     }
 
+    try {
+        realm_ = getParameter(parameters, "name");
+    } catch (...) {
+        // No realm.  Throw an exception.
+        isc_throw(NoDatabaseName, "must specify a database name (realm) for Radius connection");
+    }
+
     const char* host = "localhost";
     string shost;
     try {
@@ -248,7 +255,7 @@ RadiusHostDataSource::getAll(const Host::IdentifierType& identifier_type,
         delim = true;
     }
     // Add realm
-    tmp << "@radio.rezine.org";
+    tmp << "@" << realm_;
     // Necessary because of variable lifetime, see https://stackoverflow.com/a/1374485/4113356
     const std::string tmp2 = tmp.str();
     const char* identifier_hex = tmp2.c_str();

+ 3 - 0
src/lib/dhcpsrv/radius_host_data_source.h

@@ -314,6 +314,9 @@ private:
 
     /// @brief Pointer to a Radius Client Handle
     rc_handle *rh;
+
+    /// @brief Realm used to build usernames sent to Radius.
+    std::string realm_;
 };
 
 }