1DESCRIPTION = "FreeRADIUS is an Internet authentication daemon, which implements the RADIUS \
2protocol, as defined in RFC 2865 (and others). It allows Network Access \
3Servers (NAS boxes) to perform authentication for dial-up users. There are \
4also RADIUS clients available for Web servers, firewalls, Unix logins, and \
5more.  Using RADIUS allows authentication and authorization for a network to \
6be centralized, and minimizes the amount of re-configuration which has to be \
7done when adding or deleting new users."
8
9SUMMARY = "High-performance and highly configurable RADIUS server"
10HOMEPAGE = "http://www.freeradius.org/"
11SECTION = "System/Servers"
12LICENSE = "GPL-2.0-only & LGPL-2.0-or-later"
13LIC_FILES_CHKSUM = "file://LICENSE;md5=eb723b61539feef013de476e68b5c50a"
14DEPENDS = "openssl-native openssl libidn libtool libpcap libtalloc"
15
16SRC_URI = "git://github.com/FreeRADIUS/freeradius-server.git;branch=v3.0.x;lfs=0;;protocol=https \
17    file://freeradius \
18    file://volatiles.58_radiusd \
19    file://freeradius-enble-user-in-conf.patch \
20    file://freeradius-configure.ac-allow-cross-compilation.patch \
21    file://freeradius-libtool-detection.patch \
22    file://freeradius-configure.ac-add-option-for-libcap.patch \
23    file://freeradius-avoid-searching-host-dirs.patch \
24    file://freeradius-rlm_python-add-PY_INC_DIR.patch \
25    file://freeradius-libtool-do-not-use-jlibtool.patch \
26    file://freeradius-fix-quoting-for-BUILT_WITH.patch \
27    file://freeradius-fix-error-for-expansion-of-macro.patch \
28    file://0001-rlm_mschap-Use-includedir-instead-of-hardcoding-usr-.patch \
29    file://0001-raddb-certs-Makefile-fix-the-existed-certificate-err.patch \
30    file://0001-raddb-certs-Makefile-fix-the-occasional-verification.patch \
31    file://0001-workaround-error-with-autoconf-2.7.patch \
32    file://radiusd.service \
33    file://radiusd-volatiles.conf \
34    file://check-openssl-cmds-in-script-bootstrap.patch \
35    file://0001-version.c-don-t-print-build-flags.patch \
36    file://CVE-2022-41860.patch \
37    file://CVE-2022-41861.patch \
38"
39
40raddbdir="${sysconfdir}/${MLPREFIX}raddb"
41
42SRCREV = "af428abda249b2279ba0582180985a9f6f4a144a"
43
44CVE_CHECK_IGNORE = "\
45    CVE-2002-0318 \
46    CVE-2011-4966 \
47"
48
49PARALLEL_MAKE = ""
50
51S = "${WORKDIR}/git"
52
53LDFLAGS:append:powerpc = " -latomic"
54LDFLAGS:append:mipsarch = " -latomic"
55LDFLAGS:append:armv5 = " -latomic"
56
57EXTRA_OECONF = " --enable-strict-dependencies \
58        --with-docdir=${docdir}/freeradius-${PV} \
59        --with-openssl-includes=${STAGING_INCDIR} \
60        --with-openssl-libraries=${STAGING_LIBDIR} \
61        --with-raddbdir=${raddbdir} \
62        --without-rlm_ippool \
63        --without-rlm_cache_memcached \
64        --without-rlm_counter \
65        --without-rlm_couchbase \
66        --without-rlm_dbm \
67        --without-rlm_eap_tnc \
68        --without-rlm_eap_ikev2 \
69        --without-rlm_opendirectory \
70        --without-rlm_redis \
71        --without-rlm_rediswho \
72        --without-rlm_sql_db2 \
73        --without-rlm_sql_firebird \
74        --without-rlm_sql_freetds \
75        --without-rlm_sql_iodbc \
76        --without-rlm_sql_oracle \
77        --without-rlm_sql_sybase \
78        --without-rlm_sql_mongo \
79        --without-rlm_sqlhpwippool \
80        --without-rlm_securid \
81        --without-rlm_unbound \
82        --without-rlm_python \
83        ac_cv_path_PERL=${bindir}/perl \
84        ax_cv_cc_builtin_choose_expr=no \
85        ax_cv_cc_builtin_types_compatible_p=no \
86        ax_cv_cc_builtin_bswap64=no \
87        ax_cv_cc_bounded_attribute=no \
88"
89
90PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)} \
91                   pcre libcap \
92                   openssl rlm-eap-fast rlm-eap-pwd \
93"
94
95PACKAGECONFIG[krb5] = "--with-rlm_krb5,--without-rlm_krb5,krb5"
96PACKAGECONFIG[pam] = "--with-rlm_pam,--without-rlm_pam,libpam"
97PACKAGECONFIG[libcap] = "--with-libcap,--without-libcap,libcap"
98PACKAGECONFIG[ldap] = "--with-rlm_ldap,--without-rlm_ldap,openldap"
99PACKAGECONFIG[mysql] = "--with-rlm_sql_mysql,--without-rlm_sql_mysql,mysql5"
100PACKAGECONFIG[sqlite] = "--with-rlm_sql_sqlite,--without-rlm_sql_sqlite,sqlite3"
101PACKAGECONFIG[unixodbc] = "--with-rlm_sql_unixodbc,--without-rlm_sql_unixodbc,unixodbc"
102PACKAGECONFIG[postgresql] = "--with-rlm_sql_postgresql,--without-rlm_sql_postgresql,postgresql"
103PACKAGECONFIG[pcre] = "--with-pcre,--without-pcre,libpcre"
104PACKAGECONFIG[perl] = "--with-perl=${STAGING_BINDIR_NATIVE}/perl-native/perl --with-rlm_perl,--without-rlm_perl,perl-native perl,perl"
105PACKAGECONFIG[python3] = "--with-rlm_python3 --with-rlm-python3-bin=${STAGING_BINDIR_NATIVE}/python3-native/python3 --with-rlm-python3-include-dir=${STAGING_INCDIR}/${PYTHON_DIR},--without-rlm_python3,python3-native python3"
106PACKAGECONFIG[rest] = "--with-rlm_rest,--without-rlm_rest,curl json-c"
107PACKAGECONFIG[ruby] = "--with-rlm_ruby,--without-rlm_ruby,ruby"
108PACKAGECONFIG[openssl] = "--with-openssl, --without-openssl"
109PACKAGECONFIG[rlm-eap-fast] = "--with-rlm_eap_fast, --without-rlm_eap_fast"
110PACKAGECONFIG[rlm-eap-pwd] = "--with-rlm_eap_pwd, --without-rlm_eap_pwd"
111
112inherit useradd autotools-brokensep update-rc.d systemd multilib_script multilib_header
113
114MULTILIB_SCRIPTS = "${PN}:${sbindir}/checkrad"
115
116# This is not a cpan or python based package, but it needs some definitions
117# from cpan-base and python3-dir bbclasses for building rlm_perl and rlm_python
118# correctly.
119inherit cpan-base python3-dir
120
121# The modules subdirs also need to be processed by autoreconf. Use autogen.sh
122# in order to handle the subdirs correctly.
123do_configure () {
124    ./autogen.sh
125
126    # the configure of rlm_perl needs this to get correct
127    # mod_cflags and mod_ldflags
128    if ${@bb.utils.contains('PACKAGECONFIG', 'perl', 'true', 'false', d)}; then
129        export PERL5LIB="${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}"
130    fi
131
132    oe_runconf
133
134    # we don't need dhcpclient
135    sed -i -e 's/dhcpclient.mk//' ${S}/src/modules/proto_dhcp/all.mk
136}
137
138INITSCRIPT_NAME = "radiusd"
139
140SYSTEMD_SERVICE:${PN} = "radiusd.service"
141
142USERADD_PACKAGES = "${PN}"
143USERADD_PARAM:${PN} = "--system --no-create-home --shell /bin/false --user-group radiusd"
144
145do_install() {
146    rm -rf ${D}
147    mkdir -p ${D}/${sysconfdir}/logrotate.d
148    mkdir -p ${D}/${sysconfdir}/pam.d
149    mkdir -p ${D}/${sysconfdir}/init.d
150    mkdir -p ${D}/${localstatedir}/lib/radiusd
151    mkdir -p ${D}${sysconfdir}/default/volatiles
152
153    export LD_LIBRARY_PATH=${D}/${libdir}
154    oe_runmake install R=${D} INSTALLSTRIP=""
155
156    # remove unsupported config files
157    rm -f ${D}/${raddbdir}/experimental.conf
158
159    # remove scripts that required Perl(DBI)
160    rm -rf ${D}/${bindir}/radsqlrelay
161
162    cp -f ${WORKDIR}/freeradius ${D}/etc/init.d/radiusd
163    rm -f ${D}/${sbindir}/rc.radiusd
164    chmod +x ${D}/${sysconfdir}/init.d/radiusd
165    rm -rf ${D}/${localstatedir}/run/
166    rm -rf ${D}/${localstatedir}/log/
167    install -m 0644 ${WORKDIR}/volatiles.58_radiusd  ${D}${sysconfdir}/default/volatiles/58_radiusd
168
169    chown -R radiusd:radiusd ${D}/${raddbdir}
170    chown -R radiusd:radiusd ${D}/${localstatedir}/lib/radiusd
171
172    # For systemd
173    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
174        install -d ${D}${systemd_unitdir}/system
175        install -m 0644 ${WORKDIR}/radiusd.service ${D}${systemd_unitdir}/system
176        sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
177            -e 's,@SBINDIR@,${sbindir},g' \
178            -e 's,@STATEDIR@,${localstatedir},g' \
179            -e 's,@SYSCONFDIR@,${sysconfdir},g' \
180            ${D}${systemd_unitdir}/system/radiusd.service
181
182        install -d ${D}${sysconfdir}/tmpfiles.d/
183        install -m 0644 ${WORKDIR}/radiusd-volatiles.conf ${D}${sysconfdir}/tmpfiles.d/radiusd.conf
184    fi
185    oe_multilib_header freeradius/autoconf.h
186    oe_multilib_header freeradius/missing.h
187    oe_multilib_header freeradius/radpaths.h
188}
189
190# This is only needed when we install/update on a running target.
191#
192pkg_postinst:${PN} () {
193    if [ -z "$D" ]; then
194        if command -v systemd-tmpfiles >/dev/null; then
195            # create /var/log/radius, /var/run/radiusd
196            systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/radiusd.conf
197        elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
198            ${sysconfdir}/init.d/populate-volatile.sh update
199        fi
200
201        # Fix ownership for /etc/raddb/*, /var/lib/radiusd
202        chown -R radiusd:radiusd ${raddbdir}
203        chown -R radiusd:radiusd ${localstatedir}/lib/radiusd
204    fi
205}
206
207# We really need the symlink :(
208INSANE_SKIP:${PN} = "dev-so"
209INSANE_SKIP:${PN}-krb5 = "dev-so"
210INSANE_SKIP:${PN}-ldap = "dev-so"
211INSANE_SKIP:${PN}-mysql = "dev-so"
212INSANE_SKIP:${PN}-perl = "dev-so"
213INSANE_SKIP:${PN}-postgresql = "dev-so"
214INSANE_SKIP:${PN}-python = "dev-so"
215INSANE_SKIP:${PN}-unixodbc = "dev-so"
216
217PACKAGES =+ "${PN}-utils ${PN}-ldap ${PN}-krb5 ${PN}-perl \
218    ${PN}-python ${PN}-mysql ${PN}-postgresql ${PN}-unixodbc"
219
220FILES:${PN}-utils = "${bindir}/*"
221
222FILES:${PN}-ldap = "${libdir}/rlm_ldap.so* \
223    ${raddbdir}/mods-available/ldap \
224"
225
226FILES:${PN}-krb5 = "${libdir}/rlm_krb5.so* \
227    ${raddbdir}/mods-available/krb5 \
228"
229
230FILES:${PN}-perl = "${libdir}/rlm_perl.so* \
231    ${raddbdir}/mods-config/perl \
232    ${raddbdir}/mods-available/perl \
233"
234
235FILES:${PN}-python = "${libdir}/rlm_python3.so* \
236    ${raddbdir}/mods-config/python3 \
237    ${raddbdir}/mods-available/python3 \
238"
239
240FILES:${PN}-mysql = "${libdir}/rlm_sql_mysql.so* \
241    ${raddbdir}/mods-config/sql/*/mysql \
242    ${raddbdir}/mods-available/sql \
243"
244
245FILES:${PN}-postgresql = "${libdir}/rlm_sql_postgresql.so* \
246    ${raddbdir}/mods-config/sql/*/postgresql \
247"
248
249FILES:${PN}-unixodbc = "${libdir}/rlm_sql_unixodbc.so*"
250
251FILES:${PN} =+ "${libdir}/rlm_*.so* ${libdir}/proto_*so*"
252
253RDEPENDS:${PN} += "perl"
254RDEPENDS:${PN}-utils = "${PN} perl"
255
256CLEANBROKEN = "1"
257