From owner-svn-src-all@FreeBSD.ORG Sun Jun 22 10:00:34 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E714824D; Sun, 22 Jun 2014 10:00:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C94FA2704; Sun, 22 Jun 2014 10:00:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5MA0YnO051306; Sun, 22 Jun 2014 10:00:34 GMT (envelope-from jmg@svn.freebsd.org) Received: (from jmg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5MA0XwQ051295; Sun, 22 Jun 2014 10:00:33 GMT (envelope-from jmg@svn.freebsd.org) Message-Id: <201406221000.s5MA0XwQ051295@svn.freebsd.org> From: John-Mark Gurney Date: Sun, 22 Jun 2014 10:00:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267715 - in head: contrib/wpa/src/utils usr.sbin/wpa/hostapd usr.sbin/wpa/hostapd_cli usr.sbin/wpa/wpa_cli usr.sbin/wpa/wpa_passphrase usr.sbin/wpa/wpa_supplicant X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jun 2014 10:00:35 -0000 Author: jmg Date: Sun Jun 22 10:00:33 2014 New Revision: 267715 URL: http://svnweb.freebsd.org/changeset/base/267715 Log: 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 Modified: head/contrib/wpa/src/utils/os_unix.c head/usr.sbin/wpa/hostapd/Makefile head/usr.sbin/wpa/hostapd_cli/Makefile head/usr.sbin/wpa/wpa_cli/Makefile head/usr.sbin/wpa/wpa_passphrase/Makefile head/usr.sbin/wpa/wpa_supplicant/Makefile Modified: head/contrib/wpa/src/utils/os_unix.c ============================================================================== --- head/contrib/wpa/src/utils/os_unix.c Sun Jun 22 08:32:31 2014 (r267714) +++ head/contrib/wpa/src/utils/os_unix.c Sun Jun 22 10:00:33 2014 (r267715) @@ -153,16 +153,40 @@ static int os_daemon(int nochdir, int no #endif /* __APPLE__ */ +#ifdef __FreeBSD__ +#include +#include +#include +#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__) */ Modified: head/usr.sbin/wpa/hostapd/Makefile ============================================================================== --- head/usr.sbin/wpa/hostapd/Makefile Sun Jun 22 08:32:31 2014 (r267714) +++ head/usr.sbin/wpa/hostapd/Makefile Sun Jun 22 10:00:33 2014 (r267715) @@ -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} Modified: head/usr.sbin/wpa/hostapd_cli/Makefile ============================================================================== --- head/usr.sbin/wpa/hostapd_cli/Makefile Sun Jun 22 08:32:31 2014 (r267714) +++ head/usr.sbin/wpa/hostapd_cli/Makefile Sun Jun 22 10:00:33 2014 (r267715) @@ -10,6 +10,9 @@ SRCS= common.c edit.c eloop.c hostapd_cl CFLAGS+= -DCONFIG_CTRL_IFACE CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX +DPADD+= ${LIBUTIL} +LDADD+= -lutil + MAN= hostapd_cli.8 .include Modified: head/usr.sbin/wpa/wpa_cli/Makefile ============================================================================== --- head/usr.sbin/wpa/wpa_cli/Makefile Sun Jun 22 08:32:31 2014 (r267714) +++ head/usr.sbin/wpa/wpa_cli/Makefile Sun Jun 22 10:00:33 2014 (r267715) @@ -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 Modified: head/usr.sbin/wpa/wpa_passphrase/Makefile ============================================================================== --- head/usr.sbin/wpa/wpa_passphrase/Makefile Sun Jun 22 08:32:31 2014 (r267714) +++ head/usr.sbin/wpa/wpa_passphrase/Makefile Sun Jun 22 10:00:33 2014 (r267715) @@ -11,6 +11,9 @@ SRCS= common.c md5-internal.c md5.c os_u CFLAGS+= -DINTERNAL_SHA1 CFLAGS+= -DINTERNAL_MD5 +DPADD+= ${LIBUTIL} +LDADD+= -lutil + MAN= wpa_passphrase.8 .include Modified: head/usr.sbin/wpa/wpa_supplicant/Makefile ============================================================================== --- head/usr.sbin/wpa/wpa_supplicant/Makefile Sun Jun 22 08:32:31 2014 (r267714) +++ head/usr.sbin/wpa/wpa_supplicant/Makefile Sun Jun 22 10:00:33 2014 (r267715) @@ -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}