summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2014-06-22 10:00:33 +0000
committerjmg <jmg@FreeBSD.org>2014-06-22 10:00:33 +0000
commitfe156048d8ff669c6f66517f92ba7fcc7816c6a5 (patch)
tree9adf57ac71861b66ab5d3df3ad0ad3ea7e8b5957
parent11380bda9d8411b7a1d56c82de93777e2ea82508 (diff)
downloadFreeBSD-src-fe156048d8ff669c6f66517f92ba7fcc7816c6a5.zip
FreeBSD-src-fe156048d8ff669c6f66517f92ba7fcc7816c6a5.tar.gz
convert to using pidfile... This prevents multiple wpa_supplicants
running at the same time causing problems w/ wifi not working.. the patch will be submitted upstream... The next step if someone wants to push it upstream is to break os_unix.c up so that all these other utilities don't need libutil.. Reviewed by: rpaulo
-rw-r--r--contrib/wpa/src/utils/os_unix.c27
-rw-r--r--usr.sbin/wpa/hostapd/Makefile4
-rw-r--r--usr.sbin/wpa/hostapd_cli/Makefile3
-rw-r--r--usr.sbin/wpa/wpa_cli/Makefile4
-rw-r--r--usr.sbin/wpa/wpa_passphrase/Makefile3
-rw-r--r--usr.sbin/wpa/wpa_supplicant/Makefile4
6 files changed, 39 insertions, 6 deletions
diff --git a/contrib/wpa/src/utils/os_unix.c b/contrib/wpa/src/utils/os_unix.c
index 23a93be..fea511b 100644
--- a/contrib/wpa/src/utils/os_unix.c
+++ b/contrib/wpa/src/utils/os_unix.c
@@ -153,16 +153,40 @@ static int os_daemon(int nochdir, int noclose)
#endif /* __APPLE__ */
+#ifdef __FreeBSD__
+#include <err.h>
+#include <libutil.h>
+#include <stdint.h>
+#endif /* __FreeBSD__ */
+
int os_daemonize(const char *pid_file)
{
#if defined(__uClinux__) || defined(__sun__)
return -1;
#else /* defined(__uClinux__) || defined(__sun__) */
+#ifdef __FreeBSD__
+ pid_t otherpid;
+ struct pidfh *pfh;
+
+ pfh = pidfile_open(pid_file, 0600, &otherpid);
+ if (pfh == NULL) {
+ if (errno == EEXIST) {
+ errx(1, "Daemon already running, pid: %jd.",
+ (intmax_t)otherpid);
+ }
+ warn("Cannot open or create pidfile.");
+ }
+#endif /* __FreeBSD__ */
+
if (os_daemon(0, 0)) {
perror("daemon");
+#ifdef __FreeBSD__
+ pidfile_remove(pfh);
+#endif /* __FreeBSD__ */
return -1;
}
+#ifndef __FreeBSD__
if (pid_file) {
FILE *f = fopen(pid_file, "w");
if (f) {
@@ -170,6 +194,9 @@ int os_daemonize(const char *pid_file)
fclose(f);
}
}
+#else /* __FreeBSD__ */
+ pidfile_write(pfh);
+#endif /* __FreeBSD__ */
return -0;
#endif /* defined(__uClinux__) || defined(__sun__) */
diff --git a/usr.sbin/wpa/hostapd/Makefile b/usr.sbin/wpa/hostapd/Makefile
index 7f0304c..7ab542f 100644
--- a/usr.sbin/wpa/hostapd/Makefile
+++ b/usr.sbin/wpa/hostapd/Makefile
@@ -46,8 +46,8 @@ CFLAGS+=-DCONFIG_DRIVER_BSD \
CFLAGS+= -DCONFIG_IPV6
.endif
#CFLAGS+= -g
-DPADD+= ${LIBPCAP}
-LDADD+= -lpcap
+DPADD+= ${LIBPCAP} ${LIBUTIL}
+LDADD+= -lpcap -lutil
# User customizations for wpa_supplicant/hostapd build environment
CFLAGS+=${HOSTAPD_CFLAGS}
diff --git a/usr.sbin/wpa/hostapd_cli/Makefile b/usr.sbin/wpa/hostapd_cli/Makefile
index 8677fbf..3542aac 100644
--- a/usr.sbin/wpa/hostapd_cli/Makefile
+++ b/usr.sbin/wpa/hostapd_cli/Makefile
@@ -10,6 +10,9 @@ SRCS= common.c edit.c eloop.c hostapd_cli.c os_unix.c wpa_ctrl.c wpa_debug.c
CFLAGS+= -DCONFIG_CTRL_IFACE
CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
+
MAN= hostapd_cli.8
.include <bsd.prog.mk>
diff --git a/usr.sbin/wpa/wpa_cli/Makefile b/usr.sbin/wpa/wpa_cli/Makefile
index da25325..7e92207 100644
--- a/usr.sbin/wpa/wpa_cli/Makefile
+++ b/usr.sbin/wpa/wpa_cli/Makefile
@@ -15,7 +15,7 @@ CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX
CFLAGS+= -D_DIRENT_HAVE_D_TYPE
CFLAGS+= -DCONFIG_READLINE -I${DESTDIR}/${INCLUDEDIR}/edit
-LDADD+= -ledit -ltermcap
-DPADD+= ${LIBEDIT} ${LIBTERMCAP}
+LDADD+= -ledit -ltermcap -lutil
+DPADD+= ${LIBEDIT} ${LIBTERMCAP} ${LIBUTIL}
.include <bsd.prog.mk>
diff --git a/usr.sbin/wpa/wpa_passphrase/Makefile b/usr.sbin/wpa/wpa_passphrase/Makefile
index 16321c4..d0f5198 100644
--- a/usr.sbin/wpa/wpa_passphrase/Makefile
+++ b/usr.sbin/wpa/wpa_passphrase/Makefile
@@ -11,6 +11,9 @@ SRCS= common.c md5-internal.c md5.c os_unix.c sha1-internal.c sha1-pbkdf2.c sha1
CFLAGS+= -DINTERNAL_SHA1
CFLAGS+= -DINTERNAL_MD5
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
+
MAN= wpa_passphrase.8
.include <bsd.prog.mk>
diff --git a/usr.sbin/wpa/wpa_supplicant/Makefile b/usr.sbin/wpa/wpa_supplicant/Makefile
index 11cccf3..673a04d 100644
--- a/usr.sbin/wpa/wpa_supplicant/Makefile
+++ b/usr.sbin/wpa/wpa_supplicant/Makefile
@@ -49,8 +49,8 @@ CFLAGS+=-DCONFIG_BACKEND_FILE \
-DCONFIG_GAS \
-DPKCS12_FUNCS
#CFLAGS+= -g
-DPADD+= ${LIBPCAP}
-LDADD+= -lpcap
+DPADD+= ${LIBPCAP} ${LIBUTIL}
+LDADD+= -lpcap -lutil
# User customizations to the wpa_supplicant build environment
CFLAGS+=${WPA_SUPPLICANT_CFLAGS}
OpenPOWER on IntegriCloud