Installing Freeradius with Oracle support

freeradius-oracleFreeradius is a modular, full featured, rock solid RADIUS server. It’s one of the best free software, and certainly the most widely used RADIUS implementation in the world. horoa Skills around freeradius allow tight integration in many heterogenous environnements. As an example this article presents a clean way of makinng freeradius work with Oracle on Debian systems.
Freeradius is the most widely used RADIUS server in the world. However , in ancient times, situation was a lot different. It took some time to freeradius to proove in industry its reliability. Nowadays this GPL’ed code is a ‘must try’ when thinking about deploying AAA infrastucture (Authentication, Authorization, Accouting). To my knowledge, Freeradius is the radius server that support the biggest range of EAP types. It also supports many authentication mecanism like PAP, CHAP, MS-CHAP v1 et v2, Digest, PAM ; and several backends for storing users data: SQL, LDAP . Another goodies of freeradius is that the source is maintained by networkradius, headed by Alan Dekok, who was involved in writing of RFC of RADIUS and DIAMETER. NetworkRadius sells high quality professional support support (I can tell you this as I used to be a GOLD supported customer).

In the following lines, I’ll try to clear a quite undocumented part of freeradius: Oracle SGBD Interface!

Maybe it’s because of Oracle being non-free software, but documentation of this SGBD in freeradius litterature is quite lightweigh and varies a lot across the web. So, let’s see how to make it work efficiently on debian systems!

Preparing the compil theater:

Basicly we need a working Debian OS… Debian Squeeze is a good option. First we install the necessary tools for compilation and installation:

sudo apt-get install build-essential unzip libtool automake dpkg-dev debhelper quilt libssl-dev libpam0g-dev libmysqlclient-dev libgdbm-dev libldap2-dev libsasl2-dev libiodbc2-dev libkrb5-dev libperl-dev libpcap-dev python-dev libsnmp-dev libpq-dev

Oracle component installation

At this stage , Oracle libs and headers files are not installed, whereas we need them in order to compil freeradius with Oracel support. Oracle does not publish source code for their SGBD client libraries (Yes Oracle, that owns MySQL, openoffice.org, sun…). Then we must install manually binary package distributed, by Oracle. There are at least two ways to do this.

  • You can setup a full Orcale instance (including server side): eg, Oracle 11g (untested with Oracle XE). Carefully note the $ORACLE_HOME variable as this path will be needed to compil freeradius
  • Or you can install Oracle instant_client, distributed for no charge, by Oracle as binaries (sign-up required)

In this document will use the second, cheaper, method. Go to the Oracle website, in the download section, and choose the instantclient version matching yur Linux host as well as its SDK: http://www.oracle.com/technetwork/database/features/instant-client/

Here, let’s says host is an x86_64 host, then we fetch:

instantclient-basic-linux-x86-64-11.2.0.2.0.zip
instantclient-sdk-linux-x86-64-11.2.0.2.0.zip

Unpack this to a target directory dedicated to oracle componenets (here /opt/oracle):

sudo mkdir /opt/oracle
sudo unzip -d /opt/oracle/ instantclient-basic-linux-x86-64-11.2.0.2.0.zip
sudo unzip -d /opt/oracle/ instantclient-sdk-linux-x86-64-11.2.0.2.0.zip

We need to tweak the install a little bit , in order to compil and run freeradius flawlessly. If you miss this step compil would fail or server crash when load the oracle module:

cd /opt/oracle/instantclient_11_2/
sudo ln -s libclntsh.so.11.1 libclntsh.so
/opt/oracle/instantclient_11_2

sudo ldconfig

Oracle components are correctly setup, let’s compil FreeRadius.:

FreeRadius Installation

Grab the sources! Using at least version 2.1.10 will help a lot, as it contains bugfixes, and more particularily patches for Oracle compilation. Even better, use git to checkout the source tree.

http://freeradius.org/download.html

cd
wget ftp://ftp.freeradius.org/pub/freeradius/freeradius-server-2.1.10.tar.bz2
tar jxvf freeradius-server-2.1.10.tar.bz2

If you choose the official 2.1.10 release, you’ll need a little patch I wrote to allow compilation to work with with of Oracle other than 10g. This patch has been merged upstream (2.1.11).

Independantly of the patch, you’ll need few files to build freeradius-oracle debian package. Thoose files are contained in the following archive. Unpack it and apply the patches as follow:

wget http://www.horoa.net/wp-content/uploads/2011/06/freeradius-oracle.tar.gz
tar zvxf freeradius-oracle.tar.gz
cd freeradius-server-2.1.10
cp ../freeradius-oracle/freeradius-oracle.* debian/
patch -p0 < ../freeradius-oracle/debian.oracle_enabled.patch

Be aware that the patch applyed above is meant to work with Oracle instantclient 11.2, installed in /opt/oracle. if you need diffrents pathes or versions, adjust the file debian/rules according to your needs.
As I previously pointed out, using 2.1.10 official release, also require another patch to be applied:

patch -p0 < ../freeradius-oracle/oracle_versionlibs.patch

We need to re-generate configure script before building the package

cd src/modules/rlm_sql/drivers/rlm_sql_oracle
autoreconf
cd -
sudo dpkg-buildpackage -b -uc

when finished, you should find plenty of deb files in the parent directory, among thoose: freeradius-oracle_2.1.10+git_amd64.deb

At this stage, installation is a quite simple process:

sudo apt-get install libaio1 openssl-blacklist ssl-cert
sudo dpkg -i ../libfreeradius2_2.1.10+git_amd64.deb ../freeradius_2.1.10+git_amd64.deb ../freeradius-common_2.1.10+git_all.deb ../freeradius-oracle_2.1.10+git_amd64.deb

To avoid our worl to be over-ridden by any wild update, we configure dpkg hold packges related to freeradius
sudo dpkg --get-selections | grep freeradius | sed 's/install$/hold/' | sudo dpkg --set-selections

What comes next highly depends on your setup as it is freeradius configuration itself. Mainly, to activate oracle, you’ll need to uncomment this line in /etc/freeradius/radiusd.conf:
$INCLUDE sql.conf

and configure your sql instance in /etc/freeradius/sql.confusing the oracle driver and the required connection string (or tnsname):

sql {
database = "oracle"
driver = "rlm_sql_${database}"
login = "scott"
password = "tiger"
radius_db = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=A.B.C.D)(PORT=1521))(CONNECT_DATA=(SID=GEN1)))"
...
}

You can test the setup using

sudo freeradius -X -C


Posted

in

by

Comments

6 responses to “Installing Freeradius with Oracle support”

  1. Marco avatar
    Marco

    Hi followed your how to step by step on a debian-6.0.2.1-i386 with freeradius-server-2.1.10 and instantclient-basic-linux32-11.2.0.2.0 instantclient-sdk-linux32-11.2.0.2.0. I executed both patch command.
    Executing autogen.sh this is the output:
    libtoolize: putting auxiliary files in `.’.
    libtoolize: copying file `./ltmain.sh’
    libtoolize: You should add the contents of the following files to `aclocal.m4′:
    libtoolize: `/usr/share/aclocal/libtool.m4′
    libtoolize: `/usr/share/aclocal/ltoptions.m4′
    libtoolize: `/usr/share/aclocal/ltversion.m4′
    libtoolize: `/usr/share/aclocal/ltsugar.m4′
    libtoolize: `/usr/share/aclocal/lt~obsolete.m4′
    libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])’ to configure.in and
    libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
    libtoolize: Consider adding `-I m4′ to ACLOCAL_AMFLAGS in Makefile.am.
    libtoolize: `AC_PROG_RANLIB’ is rendered obsolete by `LT_INIT’
    configure.in:559: warning: AC_CACHE_VAL(ac_cv_lib_readline, …): suspicious presence of an AC_SUBST in the second argument, where no actions should be taken
    ../../lib/autoconf/general.m4:2019: AC_CACHE_VAL is expanded from…
    ../../lib/autoconf/general.m4:2040: AC_CACHE_CHECK is expanded from…
    acinclude.m4:394: AC_LIB_READLINE is expanded from…
    configure.in:559: the top level
    configure.in:1160: warning: AC_CONFIG_SUBDIRS: you should use literals
    ../../lib/autoconf/status.m4:1098: AC_CONFIG_SUBDIRS is expanded from…
    configure.in:1160: the top level
    configure.in:559: warning: AC_CACHE_VAL(ac_cv_lib_readline, …): suspicious presence of an AC_SUBST in the second argument, where no actions should be taken
    ../../lib/autoconf/general.m4:2019: AC_CACHE_VAL is expanded from…
    ../../lib/autoconf/general.m4:2040: AC_CACHE_CHECK is expanded from…
    acinclude.m4:394: AC_LIB_READLINE is expanded from…
    configure.in:559: the top level
    configure.in:1160: warning: AC_CONFIG_SUBDIRS: you should use literals
    ../../lib/autoconf/status.m4:1098: AC_CONFIG_SUBDIRS is expanded from…
    configure.in:1160: the top level
    Configuring in src/modules/rlm_counter…
    Configuring in src/modules/rlm_sqlcounter…

    and when run dpkg-buildpackage -b -uc:

    configure: WARNING: oracle libraries not found. Use –with-oracle-lib-dir=.
    configure: error: set –without-rlm_sql_oracle to disable it explicitly.
    configure: error: ./configure failed for ./drivers/rlm_sql_oracle
    configure: error: ./configure failed for src/modules/rlm_sql
    make: *** [config.status] Error 1
    dpkg-buildpackage: error: debian/rules build gave error exit status 2

    i have instant client in /opt/oracle and executed ldconfig in /opt/oracle/instantclient_11_2/.

    i did understand the third line of this:
    cd /opt/oracle/instantclient_11_2/
    sudo ln -s libclntsh.so.11.1 libclntsh.so
    /opt/oracle/instantclient_11_2
    sudo ldconfig

    where i’m wrong ? can you help me plz ?

    Tnx a lot

    1. Alex avatar
      Alex

      hello, as you may noticed , there are 2 patches in this howto (both found in the tarball). Are you sure you applied the second path: oracle_versionlibs.patch before running autogen.sh?

      Did you check tthe pathes in this patch matched your installation This pathes depends on where you installed oracle instant client.

      Can you please sent the file src/modules/rlm_sql/drivers/rlm_sql_oracle/configure to pastebin (please don’t post it as part of a comment), so I can check patch has been applied successfully.

  2. Marco avatar
    Marco

    Hi Alex, tnx for responding.

    Yes i applied both patches and installed instant client same path as you.

    here my configure file http://pastebin.com/04zJ9ydz

    those are the steps i did, all asa root user:
    mkdir /opt/oracle
    unzip -d /opt/oracle/ instantclient-basic-linux32-11.2.0.2.0.zip
    unzip -d /opt/oracle/ instantclient-sdk-linux32-11.2.0.2.0.zip
    cd /opt/oracle/instantclient_11_2/
    ln -s libclntsh.so.11.1 libclntsh.so
    ldconfig
    cd
    tar xzf freeradius-server-2.1.10.tar.gz
    tar zxf freeradius-oracle.tar.gz
    cd freeradius-server-2.1.10
    cp ../freeradius-oracle/freeradius-oracle.* debian/
    patch -p0 < ../freeradius-oracle/debian.oracle_enabled.patch
    patch -p0 < ../freeradius-oracle/oracle_versionlibs.patch
    ./autogen.sh
    dpkg-buildpackage -b -uc

    tnx again

    1. Alex avatar
      Alex

      Hello, for some reasons, it seems ./autogen.sh did *not* regenerated the configure files. You can force this by changing to the directory src/modules/rlm_sql/drivers/rlm_sql_oracle and run `autoreconf`. Then go back to the root of the freeradius source tree and re-run dpkg-builpackage -blablabla.

      I think it should do the trick

  3. Marco avatar
    Marco

    Works 🙂 tnx a lot

    it’s too much to ask you a howto to do the same on a ubuntu server 10.04 ?
    i tried but receive:

    checking for ldap_init in -lldap_r… ./configure: line 2857: ac_fn_c_try_link: command not found
    ./configure: line 2934: ac_fn_c_try_link: command not found
    ./configure: line 2934: ac_fn_c_try_link: command not found
    no
    checking for ldap.h… yes
    configure: error: set –without-rlm_ldap to disable it explicitly.
    configure: error: ./configure failed for src/modules/rlm_ldap
    make: *** [config.status] Error 1
    dpkg-buildpackage: error: debian/rules build gave error exit status 2

    i installed same package of Preparing the compil theater and did all same procedure

    i tried to install debian build packages on ubuntu but recieve:
    dpkg: dependency problems prevent configuration of freeradius:
    freeradius depends on libssl0.9.8 (>= 0.9.8m-1); however:
    Version of libssl0.9.8 on system is 0.9.8k-7ubuntu8.6.

    tnx a lot for your time 🙂

    1. Alex avatar
      Alex

      Yes am sure you can’t install the debian packages on ubuntu.
      I don’t really have time for this right now. However, you error message seems related to ldap… whereas the configure process correctly detect ldap.h (which suggest you installed libldap2-dev)
      maybe you have a probelm with the version of autconf/automake… which is quite a pain o get rid of…
      Maybe later I’ll try to write something about ubuntu…
      Anyway I would recommend you run debian servers instead of ubuntu.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.