Skip to content

Commit

Permalink
Merge pull request #343 from lynxis/for-upstream
Browse files Browse the repository at this point in the history
for upstream
  • Loading branch information
mwarning committed Mar 19, 2019
2 parents 012ed56 + 9bc418f commit fbbf4bb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
22 changes: 15 additions & 7 deletions openwrt/nodogsplash/files/etc/init.d/nodogsplash
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ setup_mac_lists() {
addline "BlockedMACList $macs"
else
echo "Invalid macmechanism '$val' - allow or block are valid." >&2
exit 1
return 1
fi

macs=""
config_list_foreach "$cfg" trustedmac append_mac
if [ -n "$macs" ]; then
addline "TrustedMACList $macs"
fi

return 0
}

setup_firewall() {
Expand Down Expand Up @@ -93,9 +95,11 @@ wait_for_interface() {
sleep 1
if [ $i = $timeout ]; then
echo "Interface $ifname not detected." >&2
exit 1
return 1
fi
done

return 0
}

generate_uci_config() {
Expand All @@ -112,7 +116,7 @@ generate_uci_config() {
if [ -n "$val" ]; then
if [ ! -f "$val" ]; then
echo "Configuration file '$file' doesn't exist." >&2
exit 1
return 1
fi
addline "$(cat $val)"
fi
Expand All @@ -129,10 +133,10 @@ generate_uci_config() {

if [ -z "$ifname" ]; then
echo "Option network or gatewayinterface missing." >&2
exit 1
return 1
fi

wait_for_interface "$ifname"
wait_for_interface "$ifname" || return 1

addline "GatewayInterface $ifname"

Expand All @@ -158,10 +162,11 @@ generate_uci_config() {
addline "TrafficControl yes"
fi

setup_mac_lists "$cfg"
setup_mac_lists "$cfg" || return 1
setup_firewall "$cfg"

echo "$CONFIG" > "/tmp/etc/nodogsplash_$cfg.conf"
return 0
}

# setup configuration and start instance
Expand All @@ -172,7 +177,10 @@ create_instance() {
config_get_bool val "$cfg" enabled 0
[ $val -gt 0 ] || return 0

generate_uci_config "$cfg"
if ! generate_uci_config "$cfg" ; then
echo "Can not generate uci config. Will not start instance $cfg." >&2
return
fi

procd_open_instance $cfg
procd_set_param command /usr/bin/nodogsplash -c "/tmp/etc/nodogsplash_$cfg.conf" $OPTIONS
Expand Down
4 changes: 2 additions & 2 deletions src/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ fw_refresh_client_list(void)
continue;
}

int conn_state = cp1->fw_connection_state;
int last_updated = cp1->counters.last_updated;
unsigned int conn_state = cp1->fw_connection_state;
time_t last_updated = cp1->counters.last_updated;

if (cp1->session_end > 0 && cp1->session_end <= now) {
/* Session ended (only > 0 for FW_MARK_AUTHENTICATED by binauth) */
Expand Down
4 changes: 4 additions & 0 deletions src/ndsctl_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ thread_ndsctl(void *arg)
number_of_count = epoll_wait(epoll_fd, events, current_fd_count, -1);

if (number_of_count == -1) {
/* interupted is not an error */
if (errno == -EINTR)
continue;

debug(LOG_ERR, "Failed to wait epoll events: %s", strerror(errno));
free(events);
pthread_exit(NULL);
Expand Down

0 comments on commit fbbf4bb

Please sign in to comment.