1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_5,3_6} )
7 inherit autotools pam python-single-r1 systemd user
9 MY_P="${PN}-server-${PV}"
11 DESCRIPTION="Highly configurable free RADIUS server"
13 ftp://ftp.freeradius.org/pub/radius/${MY_P}.tar.gz
14 ftp://ftp.freeradius.org/pub/radius/old/${MY_P}.tar.gz
16 HOMEPAGE="http://www.freeradius.org/"
18 KEYWORDS="amd64 ~arm arm64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
23 debug firebird iodbc kerberos ldap libressl memcached mysql odbc oracle pam
24 pcap postgres python readline rest samba sqlite ssl redis
26 RESTRICT="test firebird? ( bindist )"
28 # NOTE: Temporary freeradius doesn't support linking with mariadb client
29 # libs also if code is compliant, will be available in the next release.
30 # (http://lists.freeradius.org/pipermail/freeradius-devel/2018-October/013228.html)
31 RDEPEND="!net-dialup/cistronradius
36 python? ( ${PYTHON_DEPS} )
37 readline? ( sys-libs/readline:0= )
38 pcap? ( net-libs/libpcap )
39 memcached? ( dev-libs/libmemcached )
40 mysql? ( dev-db/mysql-connector-c )
41 postgres? ( dev-db/postgresql:= )
42 firebird? ( dev-db/firebird )
44 rest? ( dev-libs/json-c:= )
45 samba? ( net-fs/samba )
46 redis? ( dev-libs/hiredis:= )
48 !libressl? ( dev-libs/openssl:0=[-bindist] )
49 libressl? ( dev-libs/libressl:0= )
51 ldap? ( net-nds/openldap )
52 kerberos? ( virtual/krb5 )
53 sqlite? ( dev-db/sqlite:3 )
54 odbc? ( dev-db/unixODBC )
55 iodbc? ( dev-db/libiodbc )
56 oracle? ( dev-db/oracle-instantclient-basic )"
59 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
61 S="${WORKDIR}/${MY_P}"
65 enewuser radius -1 -1 /var/log/radius radius
68 python-single-r1_pkg_setup
69 export PYTHONBIN="${EPYTHON}"
74 # most of the configuration options do not appear as ./configure
75 # switches. Instead it identifies the directories that are available
76 # and run through them. These might check for the presence of
77 # various libraries, in which case they are not built. To avoid
78 # automagic dependencies, we just remove all the modules that we're
79 # not interested in using.
81 use ssl || { rm -r src/modules/rlm_eap/types/rlm_eap_{tls,ttls,peap} || die ; }
82 use ldap || { rm -r src/modules/rlm_ldap || die ; }
83 use kerberos || { rm -r src/modules/rlm_krb5 || die ; }
84 use memcached || { rm -r src/modules/rlm_cache/drivers/rlm_cache_memcached || die ; }
85 use pam || { rm -r src/modules/rlm_pam || die ; }
86 use python || { rm -r src/modules/rlm_python || die ; }
87 use rest || { rm -r src/modules/rlm_rest || die ; }
88 use redis || { rm -r src/modules/rlm_redis{,who} || die ; }
89 # can't just nuke rlm_mschap because many modules rely on smbdes.h
90 use samba || { rm -r src/modules/rlm_mschap/{configure,*.mk} || die ; }
91 # Do not install ruby rlm module, bug #483108
92 rm -r src/modules/rlm_ruby || die
94 # these are all things we don't have in portage/I don't want to deal
96 rm -r src/modules/rlm_eap/types/rlm_eap_tnc || die # requires TNCS library
97 rm -r src/modules/rlm_eap/types/rlm_eap_ikev2 || die # requires libeap-ikev2
98 rm -r src/modules/rlm_opendirectory || die # requires some membership.h
99 rm -r src/modules/rlm_sql/drivers/rlm_sql_{db2,freetds} || die
101 # sql drivers that are not part of experimental are loaded from a
102 # file, so we have to remove them from the file itself when we
106 local driver=rlm_sql_${2:-${flag}}
108 if ! use ${flag}; then
109 rm -r src/modules/rlm_sql/drivers/${driver} || die
110 sed -i -e /${driver}/d src/modules/rlm_sql/stable || die
115 -e 's:^#\tuser = :\tuser = :g' \
116 -e 's:^#\tgroup = :\tgroup = :g' \
117 -e 's:/var/run/radiusd:/run/radiusd:g' \
118 -e '/^run_dir/s:${localstatedir}::g' \
119 raddb/radiusd.conf.in || die
122 # build shared libraries using jlibtool --shared
124 -e '/$(LIBTOOL)/s|--quiet ||g' \
125 -e 's:--mode=\(compile\|link\):& --shared:g' \
129 -e 's|--silent ||g' \
130 -e 's:--mode=\(compile\|link\):& --shared:g' \
131 scripts/libtool.mk || die
133 # crude measure to stop jlibtool from running ranlib and ar
135 -e '/LIBRARIAN/s|".*"|"true"|g' \
136 -e '/RANLIB/s|".*"|"true"|g' \
137 scripts/jlibtool.c || die
140 usesqldriver postgres postgresql
141 usesqldriver firebird
143 usesqldriver odbc unixodbc
153 # do not try to enable static with static-libs; upstream is a
154 # massacre of libtool best practices so you also have to make sure
155 # to --enable-shared explicitly.
159 --disable-ltdl-install
160 --with-system-libtool
161 --with-system-libltdl
165 --with-iodbc-include-dir=/usr/include/iodbc
166 --with-experimental-modules
167 --with-docdir=/usr/share/doc/${PF}
168 --with-logdir=/var/log/radius
169 $(use_enable debug developer)
170 $(use_with ldap edir)
171 $(use_with ssl openssl)
174 if has_version app-crypt/heimdal; then
175 myeconfargs+=( --enable-heimdal-krb5 )
178 use readline || export ac_cv_lib_readline=no
179 use pcap || export ac_cv_lib_pcap_pcap_open_live=no
181 econf "${myeconfargs[@]}"
185 # verbose, do not generate certificates
188 LOCAL_CERT_PRODUCTS=''
193 diropts -m0750 -o root -g radius
195 diropts -m0750 -o radius -g radius
196 dodir /var/log/radius
197 keepdir /var/log/radius/radacct
200 # verbose, do not install certificates
201 # Parallel install fails (#509498)
204 LOCAL_CERT_PRODUCTS='' \
208 fowners -R root:radius /etc/raddb
209 fowners -R radius:radius /var/log/radius
211 pamd_mimic_system radiusd auth account password session
215 rm "${D}/usr/sbin/rc.radiusd" || die
217 newinitd "${FILESDIR}/radius.init-r3" radiusd
218 newconfd "${FILESDIR}/radius.conf-r4" radiusd
220 systemd_newtmpfilesd "${FILESDIR}"/freeradius.tmpfiles freeradius.conf
221 systemd_dounit "${FILESDIR}"/freeradius.service
223 find "${ED}" \( -name "*.a" -o -name "*.la" \) -delete || die
228 cd "${ROOT}"/etc/raddb/certs
231 chown -R root:radius "${ROOT}"/etc/raddb/certs
236 if ! has_version ${CATEGORY}/${PN} && use ssl; then
237 elog "You have to run \`emerge --config =${CATEGORY}/${PF}\` to be able"
238 elog "to start the radiusd service."