1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 )
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 ~ppc ~ppc64 ~sparc x86"
23 debug firebird iodbc kerberos ldap libressl mysql odbc oracle pam pcap
24 postgres python readline sqlite ssl
26 RESTRICT="test firebird? ( bindist )"
28 RDEPEND="!net-dialup/cistronradius
34 python? ( ${PYTHON_DEPS} )
35 readline? ( sys-libs/readline:0= )
36 pcap? ( net-libs/libpcap )
37 mysql? ( dev-db/mysql-connector-c:= )
38 postgres? ( dev-db/postgresql:= )
39 firebird? ( dev-db/firebird )
42 !libressl? ( dev-libs/openssl:0= )
43 libressl? ( dev-libs/libressl:0= )
45 ldap? ( net-nds/openldap )
46 kerberos? ( virtual/krb5 )
47 sqlite? ( dev-db/sqlite:3 )
48 odbc? ( dev-db/unixODBC )
49 iodbc? ( dev-db/libiodbc )
50 oracle? ( dev-db/oracle-instantclient-basic )"
53 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
55 S="${WORKDIR}/${MY_P}"
59 enewuser radius -1 -1 /var/log/radius radius
61 python-single-r1_pkg_setup
62 export PYTHONBIN="${EPYTHON}"
66 # most of the configuration options do not appear as ./configure
67 # switches. Instead it identifies the directories that are available
68 # and run through them. These might check for the presence of
69 # various libraries, in which case they are not built. To avoid
70 # automagic dependencies, we just remove all the modules that we're
71 # not interested in using.
73 use ssl || { rm -r src/modules/rlm_eap/types/rlm_eap_{tls,ttls,peap} || die ; }
74 use ldap || { rm -r src/modules/rlm_ldap || die ; }
75 use kerberos || { rm -r src/modules/rlm_krb5 || die ; }
76 use pam || { rm -r src/modules/rlm_pam || die ; }
77 use python || { rm -r src/modules/rlm_python || die ; }
78 # Do not install ruby rlm module, bug #483108
79 rm -r src/modules/rlm_ruby || die
81 # these are all things we don't have in portage/I don't want to deal
83 rm -r src/modules/rlm_eap/types/rlm_eap_tnc || die # requires TNCS library
84 rm -r src/modules/rlm_eap/types/rlm_eap_ikev2 || die # requires libeap-ikev2
85 rm -r src/modules/rlm_opendirectory || die # requires some membership.h
86 rm -r src/modules/rlm_redis{,who} || die # requires redis
87 rm -r src/modules/rlm_sql/drivers/rlm_sql_{db2,freetds} || die
89 # sql drivers that are not part of experimental are loaded from a
90 # file, so we have to remove them from the file itself when we
94 local driver=rlm_sql_${2:-${flag}}
96 if ! use ${flag}; then
97 rm -r src/modules/rlm_sql/drivers/${driver} || die
98 sed -i -e /${driver}/d src/modules/rlm_sql/stable || die
103 -e 's:^#\tuser = :\tuser = :g' \
104 -e 's:^#\tgroup = :\tgroup = :g' \
105 -e 's:/var/run/radiusd:/run/radiusd:g' \
106 -e '/^run_dir/s:${localstatedir}::g' \
107 raddb/radiusd.conf.in || die
110 # build shared libraries using jlibtool --shared
112 -e '/$(LIBTOOL)/s|--quiet ||g' \
113 -e 's:--mode=\(compile\|link\):& --shared:g' \
117 -e 's|--silent ||g' \
118 -e 's:--mode=\(compile\|link\):& --shared:g' \
119 scripts/libtool.mk || die
121 # crude measure to stop jlibtool from running ranlib and ar
123 -e '/LIBRARIAN/s|".*"|"true"|g' \
124 -e '/RANLIB/s|".*"|"true"|g' \
125 scripts/jlibtool.c || die
128 usesqldriver postgres postgresql
129 usesqldriver firebird
131 usesqldriver odbc unixodbc
143 if has_version app-crypt/heimdal; then
144 myeconfargs+=( --enable-heimdal-krb5 )
147 use readline || export ac_cv_lib_readline=no
148 use pcap || export ac_cv_lib_pcap_pcap_open_live=no
150 # do not try to enable static with static-libs; upstream is a
151 # massacre of libtool best practices so you also have to make sure
152 # to --enable-shared explicitly.
156 --disable-ltdl-install
157 --with-system-libtool
158 --with-system-libltdl
162 --with-iodbc-include-dir=/usr/include/iodbc
163 --with-experimental-modules
164 --with-docdir=/usr/share/doc/${PF}
165 --with-logdir=/var/log/radius
166 $(use_enable debug developer)
167 $(use_with ldap edir)
168 $(use_with ssl openssl)
170 econf "${myeconfargs[@]}"
174 # verbose, do not generate certificates
177 LOCAL_CERT_PRODUCTS=''
182 diropts -m0750 -o root -g radius
184 diropts -m0750 -o radius -g radius
185 dodir /var/log/radius
186 keepdir /var/log/radius/radacct
189 # verbose, do not install certificates
190 # Parallel install fails (#509498)
193 LOCAL_CERT_PRODUCTS='' \
197 fowners -R root:radius /etc/raddb
199 pamd_mimic_system radiusd auth account password session
203 rm "${D}/usr/sbin/rc.radiusd" || die
205 newinitd "${FILESDIR}/radius.init-r3" radiusd
206 newconfd "${FILESDIR}/radius.conf-r4" radiusd
208 systemd_newtmpfilesd "${FILESDIR}"/freeradius.tmpfiles freeradius.conf
209 systemd_dounit "${FILESDIR}"/freeradius.service
211 find "${ED}" \( -name "*.a" -o -name "*.la" \) -delete || die
216 cd "${ROOT}"/etc/raddb/certs || die
217 ./bootstrap || die "Error while running ./bootstrap script."
218 fowners -R root:radius "${ROOT}"/etc/raddb/certs
223 if ! has_version ${CATEGORY}/${PN} && use ssl; then
224 elog "You have to run \`emerge --config =${CATEGORY}/${PF}\` to be able"
225 elog "to start the radiusd service."