diff options
Diffstat (limited to 'usr.sbin/hostapd')
-rw-r--r-- | usr.sbin/hostapd/apme.c | 12 | ||||
-rw-r--r-- | usr.sbin/hostapd/handle.c | 6 | ||||
-rw-r--r-- | usr.sbin/hostapd/hostapd.c | 37 | ||||
-rw-r--r-- | usr.sbin/hostapd/iapp.c | 16 | ||||
-rw-r--r-- | usr.sbin/hostapd/parse.y | 12 | ||||
-rw-r--r-- | usr.sbin/hostapd/print-802_11.c | 8 | ||||
-rw-r--r-- | usr.sbin/hostapd/privsep.c | 14 | ||||
-rw-r--r-- | usr.sbin/hostapd/roaming.c | 14 |
8 files changed, 63 insertions, 56 deletions
diff --git a/usr.sbin/hostapd/apme.c b/usr.sbin/hostapd/apme.c index 6854da2fbf5..7fa1513644a 100644 --- a/usr.sbin/hostapd/apme.c +++ b/usr.sbin/hostapd/apme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apme.c,v 1.12 2006/05/15 20:53:02 reyk Exp $ */ +/* $OpenBSD: apme.c,v 1.13 2006/06/01 22:09:09 reyk Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -64,7 +64,7 @@ hostapd_apme_add(struct hostapd_config *cfg, const char *name) TAILQ_INSERT_TAIL(&cfg->c_apmes, apme, a_entries); hostapd_log(HOSTAPD_LOG_DEBUG, - "%s: Host AP interface added\n", apme->a_iface); + "%s: Host AP interface added", apme->a_iface); return (0); } @@ -89,14 +89,14 @@ hostapd_apme_deauth(struct hostapd_apme *apme) if (write(apme->a_raw, buf, sizeof(buf)) == -1) { hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s/%s: failed to deauthenticate all stations: %s\n", + "%s/%s: failed to deauthenticate all stations: %s", iapp->i_iface, apme->a_iface, strerror(errno)); return (EIO); } hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s/%s: deauthenticated all stations\n", + "%s/%s: deauthenticated all stations", apme->a_iface, iapp->i_iface); return (0); @@ -131,7 +131,7 @@ hostapd_apme_term(struct hostapd_apme *apme) hostapd_roaming_term(apme); hostapd_log(HOSTAPD_LOG_DEBUG, - "%s: Host AP interface removed\n", apme->a_iface); + "%s: Host AP interface removed", apme->a_iface); free(apme); } @@ -304,7 +304,7 @@ hostapd_apme_frame(struct hostapd_apme *apme, u_int8_t *buf, u_int len) bcopy(wh->i_addr1, node.ni_macaddr, IEEE80211_ADDR_LEN); if (hostapd_priv_apme_getnode(apme, &node) != 0) { hostapd_log(HOSTAPD_LOG_DEBUG, - "%s: invalid association from %s on the Host AP\n", + "%s: invalid association from %s on the Host AP", apme->a_iface, etheraddr_string(wh->i_addr1)); return; } diff --git a/usr.sbin/hostapd/handle.c b/usr.sbin/hostapd/handle.c index df5915374a4..bbe169a0a1f 100644 --- a/usr.sbin/hostapd/handle.c +++ b/usr.sbin/hostapd/handle.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle.c,v 1.8 2005/12/18 17:54:12 reyk Exp $ */ +/* $OpenBSD: handle.c,v 1.9 2006/06/01 22:09:09 reyk Exp $ */ /* * Copyright (c) 2005 Reyk Floeter <reyk@openbsd.org> @@ -261,7 +261,7 @@ hostapd_handle_action(struct hostapd_apme *apme, struct hostapd_frame *frame, return (0); hostapd_log(HOSTAPD_LOG, - "%s: sent IAPP frame HOSTAPD_%s (%u bytes)\n", + "%s: sent IAPP frame HOSTAPD_%s (%u bytes)", iapp->i_iface, cfg->c_apme_dlt == DLT_IEEE802_11_RADIO ? "RADIOTAP" : "PCAP", len); break; @@ -304,7 +304,7 @@ hostapd_handle_action(struct hostapd_apme *apme, struct hostapd_frame *frame, if (ret != 0) { hostapd_log(HOSTAPD_LOG_DEBUG, - "%s: node add/delete %s failed: %s\n", + "%s: node add/delete %s failed: %s", apme->a_iface, etheraddr_string(lladdr), strerror(ret)); } diff --git a/usr.sbin/hostapd/hostapd.c b/usr.sbin/hostapd/hostapd.c index 7b93c6c42db..b00ef0e9e9e 100644 --- a/usr.sbin/hostapd/hostapd.c +++ b/usr.sbin/hostapd/hostapd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hostapd.c,v 1.28 2006/05/13 18:25:12 reyk Exp $ */ +/* $OpenBSD: hostapd.c,v 1.29 2006/06/01 22:09:09 reyk Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -69,6 +69,7 @@ hostapd_usage(void) void hostapd_log(u_int level, const char *fmt, ...) { + char *nfmt = NULL; va_list ap; if (level > hostapd_cfg.c_verbose) @@ -76,11 +77,19 @@ hostapd_log(u_int level, const char *fmt, ...) va_start(ap, fmt); if (hostapd_cfg.c_debug) { - vfprintf(stderr, fmt, ap); + if (asprintf(&nfmt, "%s\n", fmt) != -1) + vfprintf(stderr, nfmt, ap); + else { + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + } fflush(stderr); } else vsyslog(LOG_INFO, fmt, ap); va_end(ap); + + if (nfmt != NULL) + free(nfmt); } void @@ -103,15 +112,13 @@ hostapd_printf(const char *fmt, ...) goto va_flush; va_end(ap); - if (fmt[0] == '\n') - goto flush; - return; va_flush: va_end(ap); flush: - hostapd_log(HOSTAPD_LOG, "%s", printbuf); + if (strlen(printbuf)) + hostapd_log(HOSTAPD_LOG, "%s", printbuf); bzero(printbuf, sizeof(printbuf)); } @@ -139,19 +146,19 @@ hostapd_check_file_secrecy(int fd, const char *fname) if (fstat(fd, &st)) { hostapd_log(HOSTAPD_LOG, - "cannot stat %s\n", fname); + "cannot stat %s", fname); return (-1); } if (st.st_uid != 0 && st.st_uid != getuid()) { hostapd_log(HOSTAPD_LOG, - "%s: owner not root or current user\n", fname); + "%s: owner not root or current user", fname); return (-1); } if (st.st_mode & (S_IRWXG | S_IRWXO)) { hostapd_log(HOSTAPD_LOG, - "%s: group/world readable/writeable\n", fname); + "%s: group/world readable/writeable", fname); return (-1); } @@ -264,7 +271,7 @@ hostapd_udp_init(struct hostapd_config *cfg) hostapd_fatal("failed to enable broadcast on socket\n"); hostapd_log(HOSTAPD_LOG_DEBUG, "%s: using broadcast mode " - "(address %s)\n", iapp->i_iface, inet_ntoa(addr->sin_addr)); + "(address %s)", iapp->i_iface, inet_ntoa(addr->sin_addr)); } else { /* * Enable multicast @@ -293,7 +300,7 @@ hostapd_udp_init(struct hostapd_config *cfg) "%u: %s\n", iapp->i_ttl, strerror(errno)); hostapd_log(HOSTAPD_LOG_DEBUG, "%s: using multicast mode " - "(ttl %u, group %s)\n", iapp->i_iface, iapp->i_ttl, + "(ttl %u, group %s)", iapp->i_iface, iapp->i_ttl, inet_ntoa(iapp->i_multicast.sin_addr)); } } @@ -347,7 +354,7 @@ hostapd_cleanup(struct hostapd_config *cfg) if (setsockopt(iapp->i_udp, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) == -1) hostapd_log(HOSTAPD_LOG, "failed to remove multicast" - " membership to %s: %s\n", + " membership to %s: %s", IAPP_MCASTADDR, strerror(errno)); } @@ -371,7 +378,7 @@ hostapd_cleanup(struct hostapd_config *cfg) free(table); } - hostapd_log(HOSTAPD_LOG_VERBOSE, "bye!\n"); + hostapd_log(HOSTAPD_LOG_VERBOSE, "bye!"); } int @@ -450,7 +457,7 @@ main(int argc, char *argv[]) TAILQ_FOREACH(apme, &cfg->c_apmes, a_entries) hostapd_apme_init(apme); } else - hostapd_log(HOSTAPD_LOG, "%s: running without a Host AP\n", + hostapd_log(HOSTAPD_LOG, "%s: running without a Host AP", iapp->i_iface); /* Drop all privileges in an unprivileged child process */ @@ -498,7 +505,7 @@ main(int argc, char *argv[]) hostapd_iapp_input, cfg); event_add(&iapp->i_udp_ev, NULL); - hostapd_log(HOSTAPD_LOG, "starting hostapd with pid %u\n", + hostapd_log(HOSTAPD_LOG, "starting hostapd with pid %u", getpid()); /* Run event loop */ diff --git a/usr.sbin/hostapd/iapp.c b/usr.sbin/hostapd/iapp.c index 07f4758d6a0..2df08096208 100644 --- a/usr.sbin/hostapd/iapp.c +++ b/usr.sbin/hostapd/iapp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iapp.c,v 1.15 2006/05/15 20:53:02 reyk Exp $ */ +/* $OpenBSD: iapp.c,v 1.16 2006/06/01 22:09:09 reyk Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -55,7 +55,7 @@ hostapd_iapp_init(struct hostapd_config *cfg) /* Get Host AP's BSSID */ hostapd_priv_apme_bssid(apme); hostapd_log(HOSTAPD_LOG, - "%s/%s: attached Host AP interface with BSSID %s\n", + "%s/%s: attached Host AP interface with BSSID %s", apme->a_iface, iapp->i_iface, etheraddr_string(apme->a_bssid)); @@ -75,7 +75,7 @@ hostapd_iapp_term(struct hostapd_config *cfg) TAILQ_FOREACH(apme, &cfg->c_apmes, a_entries) { hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s/%s: detaching from Host AP\n", + "%s/%s: detaching from Host AP", apme->a_iface, iapp->i_iface); } } @@ -117,12 +117,12 @@ hostapd_iapp_add_notify(struct hostapd_apme *apme, struct hostapd_node *node) if (sendto(iapp->i_udp, &frame, sizeof(frame), 0, (struct sockaddr *)addr, sizeof(struct sockaddr_in)) == -1) { hostapd_log(HOSTAPD_LOG, - "%s: failed to send ADD notification: %s\n", + "%s: failed to send ADD notification: %s", iapp->i_iface, strerror(errno)); return (errno); } - hostapd_log(HOSTAPD_LOG, "%s/%s: sent ADD notification for %s\n", + hostapd_log(HOSTAPD_LOG, "%s/%s: sent ADD notification for %s", apme->a_iface, iapp->i_iface, etheraddr_string(frame.add.a_macaddr)); @@ -177,7 +177,7 @@ hostapd_iapp_radiotap(struct hostapd_apme *apme, u_int8_t *buf, if (sendmsg(iapp->i_udp, &msg, 0) == -1) { hostapd_log(HOSTAPD_LOG, - "%s: failed to send HOSTAPD %s: %s\n", + "%s: failed to send HOSTAPD %s: %s", iapp->i_iface, cfg->c_apme_dlt == DLT_IEEE802_11_RADIO ? "radiotap" : "pcap", strerror(errno)); @@ -273,7 +273,7 @@ hostapd_iapp_input(int fd, short sig, void *arg) hostapd_log(iapp->i_flags & HOSTAPD_IAPP_F_ADD ? HOSTAPD_LOG : HOSTAPD_LOG_VERBOSE, - "%s: %s ADD notification for %s at %s\n", + "%s: %s ADD notification for %s at %s", iapp->i_iface, ret == 0 ? "received" : "ignored", etheraddr_string(node.ni_macaddr), @@ -310,7 +310,7 @@ hostapd_iapp_input(int fd, short sig, void *arg) */ hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s: received unsupported IAPP message %d\n", + "%s: received unsupported IAPP message %d", iapp->i_iface, frame->hdr.i_command); return; diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y index 1b713fab541..0ac01148b82 100644 --- a/usr.sbin/hostapd/parse.y +++ b/usr.sbin/hostapd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.22 2006/05/26 01:06:12 deraadt Exp $ */ +/* $OpenBSD: parse.y,v 1.23 2006/06/01 22:09:09 reyk Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -191,7 +191,7 @@ option : SET HOSTAP INTERFACE hostapifaces hostapd_cfg.c_flags |= HOSTAPD_CFG_F_IAPP; hostapd_log(HOSTAPD_LOG_DEBUG, - "%s: IAPP interface added\n", $4); + "%s: IAPP interface added", $4); free($4); } @@ -1337,7 +1337,7 @@ symset(const char *nam, const char *val, int persist) sym->persist = persist; TAILQ_INSERT_TAIL(&symhead, sym, entry); - hostapd_log(HOSTAPD_LOG_DEBUG, "%s = \"%s\"\n", sym->nam, sym->val); + hostapd_log(HOSTAPD_LOG_DEBUG, "%s = \"%s\"", sym->nam, sym->val); return (0); } @@ -1390,12 +1390,12 @@ hostapd_add_file(struct hostapd_config *cfg, const char *name) goto err; if ((nfile->stream = fopen(name, "rb")) == NULL) { - hostapd_log(HOSTAPD_LOG, "failed to open %s\n", name); + hostapd_log(HOSTAPD_LOG, "failed to open %s", name); goto err; } if (hostapd_check_file_secrecy(fileno(nfile->stream), name)) { - hostapd_log(HOSTAPD_LOG, "invalid permissions for %s\n", name); + hostapd_log(HOSTAPD_LOG, "invalid permissions for %s", name); goto err; } @@ -1450,7 +1450,7 @@ hostapd_parse_file(struct hostapd_config *cfg) next = TAILQ_NEXT(sym, entry); if (!sym->used) hostapd_log(HOSTAPD_LOG_VERBOSE, - "warning: macro \"%s\" not used\n", sym->nam); + "warning: macro \"%s\" not used", sym->nam); if (!sym->persist) { free(sym->nam); free(sym->val); diff --git a/usr.sbin/hostapd/print-802_11.c b/usr.sbin/hostapd/print-802_11.c index 52fc4b34b50..0c35d4171d2 100644 --- a/usr.sbin/hostapd/print-802_11.c +++ b/usr.sbin/hostapd/print-802_11.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-802_11.c,v 1.3 2006/05/15 16:07:33 reyk Exp $ */ +/* $OpenBSD: print-802_11.c,v 1.4 2006/06/01 22:09:09 reyk Exp $ */ /* * Copyright (c) 2005 Reyk Floeter <reyk@openbsd.org> @@ -441,7 +441,7 @@ ieee802_11_if_print(u_int8_t *buf, u_int len) if (ieee80211_print(wh) != 0) PRINTF("[|802.11]"); - PRINTF("\n"); + PRINTF(NULL); } void @@ -460,7 +460,7 @@ ieee802_11_radio_if_print(u_int8_t *buf, u_int len) rh_len = letoh16(rh->it_len); if (rh->it_version != 0) { - PRINTF("[?radiotap + 802.11 v:%u]\n", rh->it_version); + PRINTF("[?radiotap + 802.11 v:%u]", rh->it_version); goto out; } @@ -628,7 +628,7 @@ ieee802_11_radio_if_print(u_int8_t *buf, u_int len) PRINTF("[|radiotap + 802.11]"); out: - PRINTF("\n"); + PRINTF(NULL); } void diff --git a/usr.sbin/hostapd/privsep.c b/usr.sbin/hostapd/privsep.c index d1f2f134edd..0cd46f9a056 100644 --- a/usr.sbin/hostapd/privsep.c +++ b/usr.sbin/hostapd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.19 2006/05/15 20:53:02 reyk Exp $ */ +/* $OpenBSD: privsep.c,v 1.20 2006/06/01 22:09:09 reyk Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -213,7 +213,7 @@ hostapd_priv(int fd, short sig, void *arg) switch (cmd) { case PRIV_APME_BSSID: hostapd_log(HOSTAPD_LOG_DEBUG, - "[priv]: msg PRIV_APME_BSSID received\n"); + "[priv]: msg PRIV_APME_BSSID received"); if ((apme = hostapd_priv_getapme(fd, cfg)) == NULL) break; @@ -232,7 +232,7 @@ hostapd_priv(int fd, short sig, void *arg) case PRIV_APME_GETNODE: hostapd_log(HOSTAPD_LOG_DEBUG, - "[priv]: msg PRIV_APME_GETNODE received\n"); + "[priv]: msg PRIV_APME_GETNODE received"); hostapd_must_read(fd, &node, sizeof(struct hostapd_node)); bcopy(node.ni_macaddr, nr.nr_macaddr, IEEE80211_ADDR_LEN); @@ -261,7 +261,7 @@ hostapd_priv(int fd, short sig, void *arg) case PRIV_APME_ADDNODE: case PRIV_APME_DELNODE: hostapd_log(HOSTAPD_LOG_DEBUG, - "[priv]: msg PRIV_APME_[ADD|DEL]NODE received\n"); + "[priv]: msg PRIV_APME_[ADD|DEL]NODE received"); hostapd_must_read(fd, &node, sizeof(struct hostapd_node)); bcopy(node.ni_macaddr, nr.nr_macaddr, IEEE80211_ADDR_LEN); @@ -282,7 +282,7 @@ hostapd_priv(int fd, short sig, void *arg) case PRIV_LLC_SEND_XID: hostapd_log(HOSTAPD_LOG_DEBUG, - "[priv]: msg PRIV_LLC_SEND_XID received\n"); + "[priv]: msg PRIV_LLC_SEND_XID received"); hostapd_must_read(fd, &node, sizeof(struct hostapd_node)); @@ -294,7 +294,7 @@ hostapd_priv(int fd, short sig, void *arg) case PRIV_APME_ADDROAMING: case PRIV_APME_DELROAMING: hostapd_log(HOSTAPD_LOG_DEBUG, - "[priv]: msg PRIV_APME_[ADD|DEL]ROAMING received\n"); + "[priv]: msg PRIV_APME_[ADD|DEL]ROAMING received"); hostapd_must_read(fd, &node, sizeof(struct hostapd_node)); @@ -363,7 +363,7 @@ hostapd_priv_apme_setnode(struct hostapd_apme *apme, struct hostapd_node *node, hostapd_must_read(priv_fd, &ret, sizeof(int)); if (ret == 0) - hostapd_log(HOSTAPD_LOG_VERBOSE, "%s/%s: %s node %s\n", + hostapd_log(HOSTAPD_LOG_VERBOSE, "%s/%s: %s node %s", apme->a_iface, iapp->i_iface, add ? "added" : "removed", etheraddr_string(node->ni_macaddr)); diff --git a/usr.sbin/hostapd/roaming.c b/usr.sbin/hostapd/roaming.c index 40274251681..e3ba45004bb 100644 --- a/usr.sbin/hostapd/roaming.c +++ b/usr.sbin/hostapd/roaming.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roaming.c,v 1.1 2006/05/15 20:53:02 reyk Exp $ */ +/* $OpenBSD: roaming.c,v 1.2 2006/06/01 22:09:09 reyk Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -77,7 +77,7 @@ hostapd_roaming_init(struct hostapd_config *cfg) bcopy(&ifr.ifr_addr, &apme->a_addr, sizeof(struct sockaddr_in)); hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s/%s: using gateway address %s\n", + "%s/%s: using gateway address %s", apme->a_iface, iapp->i_iface, inet_ntoa(apme->a_addr.sin_addr), apme->a_iface); } @@ -177,7 +177,7 @@ hostapd_roaming_addr(struct hostapd_apme *apme, struct hostapd_inaddr *addr, if (ioctl(cfg->c_apme_ctl, SIOCDIFADDR, &ifra) < 0) { if (errno != EADDRNOTAVAIL) { hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s/%s: failed to delete address %s\n", + "%s/%s: failed to delete address %s", apme->a_iface, iapp->i_iface, inet_ntoa(addr->in_v4)); return (errno); @@ -186,7 +186,7 @@ hostapd_roaming_addr(struct hostapd_apme *apme, struct hostapd_inaddr *addr, if (add && ioctl(cfg->c_apme_ctl, SIOCAIFADDR, &ifra) < 0) { if (errno != EEXIST) { hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s/%s: failed to add address %s\n", + "%s/%s: failed to add address %s", apme->a_iface, iapp->i_iface, inet_ntoa(addr->in_v4)); return (errno); @@ -194,7 +194,7 @@ hostapd_roaming_addr(struct hostapd_apme *apme, struct hostapd_inaddr *addr, } hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s/%s: %s address %s\n", + "%s/%s: %s address %s", apme->a_iface, iapp->i_iface, add ? "added" : "deleted", inet_ntoa(addr->in_v4)); @@ -265,7 +265,7 @@ hostapd_roaming_rt(struct hostapd_apme *apme, struct hostapd_inaddr *addr, } hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s/%s: %s route to %s\n", + "%s/%s: %s route to %s", apme->a_iface, iapp->i_iface, add ? "added" : "deleted", inet_ntoa(addr->in_v4)); @@ -274,7 +274,7 @@ hostapd_roaming_rt(struct hostapd_apme *apme, struct hostapd_inaddr *addr, bad: hostapd_log(HOSTAPD_LOG_VERBOSE, - "%s/%s: failed to %s route to %s: %s\n", + "%s/%s: failed to %s route to %s: %s", apme->a_iface, iapp->i_iface, add ? "add" : "delete", inet_ntoa(addr->in_v4), |