1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils toolchain-funcs qt4-r2 systemd multilib
9 DESCRIPTION="IEEE 802.1X/WPA supplicant for secure wireless transfers"
10 HOMEPAGE="http://hostap.epitest.fi/wpa_supplicant/"
11 SRC_URI="http://hostap.epitest.fi/releases/${P}.tar.gz"
12 LICENSE="|| ( GPL-2 BSD )"
15 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
16 IUSE="ap dbus gnutls eap-sim fasteap +hs2-0 p2p ps3 qt4 readline selinux smartcard ssl tdls uncommon-eap-types wimax wps kernel_linux kernel_FreeBSD"
17 REQUIRED_USE="fasteap? ( !gnutls !ssl ) smartcard? ( ssl )"
19 CDEPEND="dbus? ( sys-apps/dbus )
21 eap-sim? ( sys-apps/pcsc-lite )
25 !kernel_linux? ( net-libs/libpcap )
35 ssl? ( dev-libs/openssl:0 )
36 !ssl? ( gnutls? ( net-libs/gnutls ) )
37 !ssl? ( !gnutls? ( dev-libs/libtommath ) )
43 selinux? ( sec-policy/selinux-networkmanager )
46 S="${WORKDIR}/${P}/${PN}"
48 Kconfig_style_config() {
49 #param 1 is CONFIG_* item
50 #param 2 is what to set it = to, defaulting in y
51 CONFIG_PARAM="${CONFIG_HEADER:-CONFIG_}$1"
54 if [ ! $setting = n ]; then
55 #first remove any leading "# " if $2 is not n
56 sed -i "/^# *$CONFIG_PARAM=/s/^# *//" .config || echo "Kconfig_style_config error uncommenting $CONFIG_PARAM"
57 #set item = $setting (defaulting to y)
58 sed -i "/^$CONFIG_PARAM/s/=.*/=$setting/" .config || echo "Kconfig_style_config error setting $CONFIG_PARAM=$setting"
60 #ensure item commented out
61 sed -i "/^$CONFIG_PARAM/s/$CONFIG_PARAM/# $CONFIG_PARAM/" .config || echo "Kconfig_style_config error commenting $CONFIG_PARAM"
66 if use gnutls && use ssl ; then
67 elog "You have both 'gnutls' and 'ssl' USE flags enabled: defaulting to USE=\"ssl\""
72 # net/bpf.h needed for net-libs/libpcap on Gentoo/FreeBSD
74 -e "s:\(#include <pcap\.h>\):#include <net/bpf.h>\n\1:" \
75 ../src/l2_packet/l2_packet_freebsd.c || die
77 # People seem to take the example configuration file too literally (bug #102361)
79 -e "s:^\(opensc_engine_path\):#\1:" \
80 -e "s:^\(pkcs11_engine_path\):#\1:" \
81 -e "s:^\(pkcs11_module_path\):#\1:" \
82 wpa_supplicant.conf || die
84 # Change configuration to match Gentoo locations (bug #143750)
86 -e "s:/usr/lib/opensc:/usr/$(get_libdir):" \
87 -e "s:/usr/lib/pkcs11:/usr/$(get_libdir):" \
88 wpa_supplicant.conf || die
91 epatch "${FILESDIR}/${P}-dbus-path-fix.patch"
94 # systemd entries to D-Bus service files (bug #372877)
95 echo 'SystemdService=wpa_supplicant.service' \
96 | tee -a dbus/*.service >/dev/null || die
101 # generate-libeap-peer.patch comes before
102 # fix-undefined-reference-to-random_get_bytes.patch
103 epatch "${FILESDIR}/${P}-generate-libeap-peer.patch"
105 # multilib-strict fix (bug #373685)
106 sed -e "s/\/usr\/lib/\/usr\/$(get_libdir)/" -i src/eap_peer/Makefile
110 epatch "${FILESDIR}/2015-1/0001-P2P-Validate-SSID-element-length-before-copying-it-C.patch"
111 epatch "${FILESDIR}/2015-2/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch"
112 epatch "${FILESDIR}/2015-3/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch"
113 epatch "${FILESDIR}/2015-4/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch"
114 epatch "${FILESDIR}/2015-4/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch"
115 epatch "${FILESDIR}/2015-4/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch"
116 epatch "${FILESDIR}/2015-4/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch"
117 epatch "${FILESDIR}/2015-4/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch"
120 epatch "${FILESDIR}/2015-5/0001-NFC-Avoid-misaligned-read-of-an-NDEF-field.patch"
121 epatch "${FILESDIR}/2015-5/0002-NFC-Fix-payload-length-validation-in-NDEF-record-par.patch"
124 epatch "${FILESDIR}/${P}-do-not-call-dbus-functions-with-NULL-path.patch"
126 # TODO - NEED TESTING TO SEE IF STILL NEEDED, NOT COMPATIBLE WITH 1.0 OUT OF THE BOX,
127 # SO WOULD BE NICE TO JUST DROP IT, IF IT IS NOT NEEDED.
129 #epatch "${FILESDIR}/${P}-dbus-WPAIE-fix.patch"
139 Kconfig_style_config CTRL_IFACE
140 Kconfig_style_config BACKEND file
141 Kconfig_style_config IBSS_RSN
142 Kconfig_style_config IEEE80211W
143 Kconfig_style_config IEEE80211R
145 # Basic authentication methods
146 # NOTE: we don't set GPSK or SAKE as they conflict
147 # with the below options
148 Kconfig_style_config EAP_GTC
149 Kconfig_style_config EAP_MD5
150 Kconfig_style_config EAP_OTP
151 Kconfig_style_config EAP_PAX
152 Kconfig_style_config EAP_PSK
153 Kconfig_style_config EAP_TLV
154 Kconfig_style_config EAP_EXE
155 Kconfig_style_config IEEE8021X_EAPOL
156 Kconfig_style_config PKCS12
157 Kconfig_style_config PEERKEY
158 Kconfig_style_config EAP_LEAP
159 Kconfig_style_config EAP_MSCHAPV2
160 Kconfig_style_config EAP_PEAP
161 Kconfig_style_config EAP_TLS
162 Kconfig_style_config EAP_TTLS
164 # Enabling background scanning.
165 Kconfig_style_config BGSCAN_SIMPLE
166 Kconfig_style_config BGSCAN_LEARN
169 Kconfig_style_config CTRL_IFACE_DBUS
170 Kconfig_style_config CTRL_IFACE_DBUS_NEW
171 Kconfig_style_config CTRL_IFACE_DBUS_INTRO
174 # Enable support for writing debug info to a log file and syslog.
175 Kconfig_style_config DEBUG_FILE
176 Kconfig_style_config DEBUG_SYSLOG
179 Kconfig_style_config INTERWORKING
180 Kconfig_style_config HS20
183 if use uncommon-eap-types; then
184 Kconfig_style_config EAP_GPSK
185 Kconfig_style_config EAP_SAKE
186 Kconfig_style_config EAP_GPSK_SHA256
187 Kconfig_style_config EAP_IKEV2
188 Kconfig_style_config EAP_EKE
191 if use eap-sim ; then
192 # Smart card authentication
193 Kconfig_style_config EAP_SIM
194 Kconfig_style_config EAP_AKA
195 Kconfig_style_config EAP_AKA_PRIME
196 Kconfig_style_config PCSC
199 if use fasteap ; then
200 Kconfig_style_config EAP_FAST
203 if use readline ; then
204 # readline/history support for wpa_cli
205 Kconfig_style_config READLINE
207 #internal line edit mode for wpa_cli
208 Kconfig_style_config WPA_CLI_EDIT
211 # SSL authentication methods
213 Kconfig_style_config TLS openssl
214 elif use gnutls ; then
215 Kconfig_style_config TLS gnutls
216 Kconfig_style_config GNUTLS_EXTRA
218 Kconfig_style_config TLS internal
221 if use smartcard ; then
222 Kconfig_style_config SMARTCARD
226 Kconfig_style_config TDLS
229 if use kernel_linux ; then
230 # Linux specific drivers
231 Kconfig_style_config DRIVER_ATMEL
232 Kconfig_style_config DRIVER_HOSTAP
233 Kconfig_style_config DRIVER_IPW
234 Kconfig_style_config DRIVER_NL80211
235 Kconfig_style_config DRIVER_RALINK
236 Kconfig_style_config DRIVER_WEXT
237 Kconfig_style_config DRIVER_WIRED
240 Kconfig_style_config DRIVER_PS3
243 elif use kernel_FreeBSD ; then
244 # FreeBSD specific driver
245 Kconfig_style_config DRIVER_BSD
248 # Wi-Fi Protected Setup (WPS)
250 Kconfig_style_config WPS
251 Kconfig_style_config WPS2
253 Kconfig_style_config WPS_UFD
255 Kconfig_style_config WPS_ER
256 # Universal Plug'n'Play
257 Kconfig_style_config WPS_UPNP
258 # Near Field Communication
259 Kconfig_style_config WPS_NFC
262 # Wi-Fi Direct (WiDi)
264 Kconfig_style_config P2P
265 Kconfig_style_config WIFI_DISPLAY
270 Kconfig_style_config AP
273 # Enable mitigation against certain attacks against TKIP
274 Kconfig_style_config DELAYED_MIC_ERROR_REPORT
276 # If we are using libnl 2.0 and above, enable support for it
278 # Removed for now, since the 3.2 version is broken, and we don't
280 if has_version ">=dev-libs/libnl-3.2"; then
281 Kconfig_style_config LIBNL32
285 pushd "${S}"/wpa_gui-qt4 > /dev/null
292 einfo "Building wpa_supplicant"
293 emake V=1 BINDIR=/usr/sbin
296 emake -C ../src/eap_peer clean
297 emake -C ../src/eap_peer
301 pushd "${S}"/wpa_gui-qt4 > /dev/null
302 einfo "Building wpa_gui"
309 dosbin wpa_supplicant
310 dobin wpa_cli wpa_passphrase
312 # baselayout-1 compat
313 if has_version "<sys-apps/baselayout-2.0.0"; then
315 dosym /usr/sbin/wpa_supplicant /sbin/wpa_supplicant
317 dosym /usr/bin/wpa_cli /bin/wpa_cli
320 if has_version ">=sys-apps/openrc-0.5.0"; then
321 newinitd "${FILESDIR}/${PN}-init.d" wpa_supplicant
322 newconfd "${FILESDIR}/${PN}-conf.d" wpa_supplicant
325 exeinto /etc/wpa_supplicant/
326 newexe "${FILESDIR}/wpa_cli.sh" wpa_cli.sh
328 dodoc ChangeLog {eap_testing,todo}.txt README{,-WPS} \
331 newdoc .config build-config
333 doman doc/docbook/*.{5,8}
337 dobin wpa_gui-qt4/wpa_gui
338 doicon wpa_gui-qt4/icons/wpa_gui.svg
339 make_desktop_entry wpa_gui "WPA Supplicant Administration GUI" "wpa_gui" "Qt;Network;"
342 use wimax && emake DESTDIR="${D}" -C ../src/eap_peer install
345 pushd "${S}"/dbus > /dev/null
346 insinto /etc/dbus-1/system.d
347 newins dbus-wpa_supplicant.conf wpa_supplicant.conf
348 insinto /usr/share/dbus-1/system-services
349 doins fi.epitest.hostap.WPASupplicant.service fi.w1.wpa_supplicant1.service
352 # This unit relies on dbus support, bug 538600.
353 systemd_dounit systemd/wpa_supplicant.service
356 systemd_dounit "systemd/wpa_supplicant@.service"
357 systemd_dounit "systemd/wpa_supplicant-nl80211@.service"
358 systemd_dounit "systemd/wpa_supplicant-wired@.service"
362 elog "If this is a clean installation of wpa_supplicant, you"
363 elog "have to create a configuration file named"
364 elog "/etc/wpa_supplicant/wpa_supplicant.conf"
366 elog "An example configuration file is available for reference in"
367 elog "/usr/share/doc/${PF}/"
369 if [[ -e ${ROOT}etc/wpa_supplicant.conf ]] ; then
371 ewarn "WARNING: your old configuration file ${ROOT}etc/wpa_supplicant.conf"
372 ewarn "needs to be moved to ${ROOT}etc/wpa_supplicant/wpa_supplicant.conf"
375 # Mea culpa, feel free to remove that after some time --mgorny.
377 for fn in wpa_supplicant{,@wlan0}.service; do
378 if [[ -e "${ROOT}"/etc/systemd/system/network.target.wants/${fn} ]]
380 ebegin "Moving ${fn} to multi-user.target"
381 mv "${ROOT}"/etc/systemd/system/network.target.wants/${fn} \
382 "${ROOT}"/etc/systemd/system/multi-user.target.wants/
384 "Please try to re-enable ${fn}"