Updates and clean-up to address the many compiler warnings when compiled with -Wall. Also some autoconf updates

git-svn-id: file:///home/mbr/svn/fwknop/trunk@265 510a4753-2344-4c79-9c09-4d669213fbeb
This commit is contained in:
Damien Stuart
2010-07-16 14:28:32 +00:00
parent c3da912fc2
commit b0886a1d49
24 changed files with 135 additions and 97 deletions
-1
View File
@@ -27,7 +27,6 @@
#include "config_init.h"
#include "getopt.h"
#include "utils.h"
#include "ctype.h"
/* Convert a digest_type string to its intger value.
*/
+2 -1
View File
@@ -92,7 +92,7 @@ resolve_ip_http(fko_cli_options_t *options)
if (sock < 0)
continue;
if (error = connect(sock, rp->ai_addr, rp->ai_addrlen) != -1)
if ((error = (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1)))
break; /* made it */
#ifdef WIN32
@@ -132,6 +132,7 @@ resolve_ip_http(fko_cli_options_t *options)
close(sock);
#endif
fprintf(stderr, "RESP:'%s'\n", http_response);
/* Move to the end of the HTTP header and to the start of the content.
*/
ndx = strstr(http_response, "\r\n\r\n");
+4 -2
View File
@@ -55,6 +55,7 @@ chksum(unsigned short *buf, int nbytes)
return (unsigned short) ~sum;
}
/*
static int is_ip(char *str)
{
int rv = 1;
@@ -69,6 +70,7 @@ static int is_ip(char *str)
return rv;
}
*/
/* Send the SPA data via UDP packet.
*/
@@ -122,7 +124,7 @@ send_spa_packet_tcp_or_udp(char *spa_data, int sd_len, fko_cli_options_t *option
if (sock < 0)
continue;
if (error = connect(sock, rp->ai_addr, rp->ai_addrlen) != -1)
if ((error = (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1)))
break; /* made it */
#ifdef WIN32
@@ -377,7 +379,7 @@ send_spa_packet_http(char *spa_data, int sd_len, fko_cli_options_t *options)
{
char http_buf[HTTP_MAX_REQUEST_LEN], *spa_data_copy = NULL;
char *ndx = options->http_proxy;
int i, proxy_port;
int i, proxy_port = 0;
spa_data_copy = malloc(sd_len+1);
if (spa_data_copy == NULL)
+9 -1
View File
@@ -36,7 +36,15 @@
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <netdb.h>
#if HAVE_NETDB_H
#include <netdb.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#endif
/* We will roll our own packet header structs. */
+2 -8
View File
@@ -30,13 +30,7 @@
/* Prototypes
*/
void hex_dump(unsigned char *data, int size);
#ifdef WIN32
/* Function prototypes we need for Windows
*/
size_t strlcat(char *dst, const char *src, size_t siz);
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
size_t strlcat(char *dst, const char *src, size_t siz);
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif /* UTILS_H */
+8
View File
@@ -52,6 +52,14 @@
#include <netinet/in.h>
#endif
#if HAVE_CTYPE_H
#include <ctype.h>
#endif
#if HAVE_TIME_H
#include <time.h>
#endif
#ifdef WIN32
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
+1 -1
View File
@@ -79,7 +79,7 @@ AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_RESOLV
AC_CHECK_HEADERS([ctype.h endian.h errno.h locale.h netdb.h net/ethernet.h netinet/ether.h netinet/ip_icmp.h netinet/in.h netinet/ip.h netinet/tcp.h netinet/udp.h stdint.h stdlib.h string.h strings.h sys/byteorder.h sys/endian.h sys/ethernet.h sys/socket.h sys/stat.h sys/time.h termios.h unistd.h])
AC_CHECK_HEADERS([arpa/inet.h ctype.h endian.h errno.h locale.h netdb.h net/ethernet.h netinet/ether.h netinet/ip_icmp.h netinet/in.h netinet/ip.h netinet/tcp.h netinet/udp.h stdint.h stdlib.h string.h strings.h sys/byteorder.h sys/endian.h sys/ethernet.h sys/socket.h sys/stat.h sys/time.h sys/wait.h termios.h time.h unistd.h])
# Type checks.
#
+1 -1
View File
@@ -154,7 +154,7 @@ _rijndael_decrypt(fko_ctx_t ctx, char *dec_key)
* decryption by ensuring the first field (16-digit random decimal
* value) is valid and is followed by a colon.
*/
ndx = ctx->encoded_msg;
ndx = (unsigned char *)ctx->encoded_msg;
for(i=0; i<FKO_RAND_VAL_SIZE; i++)
if(!isdigit(*(ndx++)))
err++;
+1 -2
View File
@@ -199,7 +199,7 @@ validate_access_msg(const char *msg)
do {
ndx++;
res = validate_proto_port_spec(ndx);
} while(ndx = strchr(ndx, ','));
} while((ndx = strchr(ndx, ',')));
return(res);
}
@@ -207,7 +207,6 @@ validate_access_msg(const char *msg)
int
validate_proto_port_spec(const char *msg)
{
int res = FKO_SUCCESS;
int startlen = strlen(msg);
const char *ndx = msg;
-1
View File
@@ -33,7 +33,6 @@
int
init_gpgme(fko_ctx_t fko_ctx)
{
gpgme_engine_info_t eng_info;
gpgme_error_t err;
/* If we already have a context, we are done.
+6 -23
View File
@@ -39,7 +39,7 @@
/* Add an access string entry
*/
static char *
void
add_acc_string(char **var, char *val)
{
if((*var = strdup(val)) == NULL)
@@ -102,7 +102,7 @@ add_source_mask(acc_stanza_t *acc, char *ip)
do {
last_sle = tmp_sle;
} while(tmp_sle = tmp_sle->next);
} while((tmp_sle = tmp_sle->next));
last_sle->next = new_sle;
}
@@ -155,7 +155,7 @@ add_source_mask(acc_stanza_t *acc, char *ip)
/* Expand the access SOURCE string to a list of masks.
*/
static acc_int_list_t*
void
expand_acc_source(acc_stanza_t *acc)
{
char *ndx, *start;
@@ -218,8 +218,6 @@ parse_proto_and_port(char *pstr, int *proto, int *port)
static void
add_port_list_ent(acc_port_list_t **plist, char *port_str)
{
char *ndx;
char proto_str[16];
int proto_int, port;
acc_port_list_t *last_plist, *new_plist, *tmp_plist;
@@ -251,7 +249,7 @@ add_port_list_ent(acc_port_list_t **plist, char *port_str)
do {
last_plist = tmp_plist;
} while(tmp_plist = tmp_plist->next);
} while((tmp_plist = tmp_plist->next));
last_plist->next = new_plist;
}
@@ -265,8 +263,6 @@ add_port_list_ent(acc_port_list_t **plist, char *port_str)
static void
add_string_list_ent(acc_string_list_t **stlist, char *str_str)
{
char *ndx;
acc_string_list_t *last_stlist, *new_stlist, *tmp_stlist;
if((new_stlist = calloc(1, sizeof(acc_string_list_t))) == NULL)
@@ -290,7 +286,7 @@ add_string_list_ent(acc_string_list_t **stlist, char *str_str)
do {
last_stlist = tmp_stlist;
} while(tmp_stlist = tmp_stlist->next);
} while((tmp_stlist = tmp_stlist->next));
last_stlist->next = new_stlist;
}
@@ -459,11 +455,6 @@ free_acc_stanza_data(acc_stanza_t *acc)
static void
expand_acc_ent_lists(fko_srv_options_t *opts)
{
char *ndx, *start, *end;
char buf[1024];
uint32_t tmpint;
acc_stanza_t *acc = opts->acc_stanzas;
/* We need to do this for each stanza.
@@ -545,7 +536,7 @@ acc_stanza_add(fko_srv_options_t *opts)
{
do {
last_acc = acc;
} while(acc = acc->next);
} while((acc = acc->next));
last_acc->next = new_acc;
}
@@ -559,9 +550,6 @@ acc_stanza_add(fko_srv_options_t *opts)
static void
set_acc_defaults(fko_srv_options_t *opts)
{
int i = 0;
char *var, *val;
acc_stanza_t *acc = opts->acc_stanzas;
if(!acc)
@@ -613,8 +601,6 @@ parse_access_file(fko_srv_options_t *opts)
char access_line_buf[MAX_LINE_LEN] = {0};
char var[MAX_LINE_LEN] = {0};
char val[MAX_LINE_LEN] = {0};
char tmp1[MAX_LINE_LEN] = {0};
char tmp2[MAX_LINE_LEN] = {0};
struct passwd *pw;
struct stat st;
@@ -861,7 +847,6 @@ acc_stanza_t*
acc_check_source(fko_srv_options_t *opts, uint32_t ip)
{
acc_stanza_t *acc = opts->acc_stanzas;
char *source;
if(acc == NULL)
{
@@ -893,7 +878,6 @@ compare_port_list(acc_port_list_t *in, acc_port_list_t *ac, int match_any)
{
int a_cnt = 0;
int i_cnt = 0;
int tres = 0;
acc_port_list_t *tlist;
while(in)
@@ -1002,7 +986,6 @@ void
dump_access_list(fko_srv_options_t *opts)
{
int i = 0;
char *var, *val;
acc_stanza_t *acc = opts->acc_stanzas;
-2
View File
@@ -27,7 +27,6 @@
#include "config_init.h"
#include "getopt.h"
#include "utils.h"
#include "ctype.h"
#include "log_msg.h"
/* Take an index and a string value. malloc the space for the value
@@ -640,7 +639,6 @@ void
dump_config(fko_srv_options_t *opts)
{
int i;
char *var, *val;
fprintf(stderr, "Current fwknopd config settings:\n");
+1
View File
@@ -92,6 +92,7 @@ static struct option cmd_opts[] =
void config_init(fko_srv_options_t *opts, int argc, char **argv);
void dump_config(fko_srv_options_t *opts);
void clear_configs(fko_srv_options_t *opts);
void free_configs(fko_srv_options_t *opts);
void usage(void);
#endif /* CONFIG_INIT_H */
+35 -8
View File
@@ -1,9 +1,32 @@
/* extcmd.c
/* $Id$
*****************************************************************************
*
* A test program to run an external command and capture its
* stdout and stderr and exit code into varaibles to print later.
* File: extcmd.c
*
* Author: Damien Stuart (dstuart@dstuart.org)
*
* Purpose: Routines for executing and processing external commands.
*
* Copyright (C) 2010 Damien Stuart (dstuart@dstuart.org)
*
* License (GNU Public License):
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*****************************************************************************
*/
#include "fwknopd_common.h"
#include "extcmd.h"
#include "log_msg.h"
#include "utils.h"
/*
#include <stdio.h>
@@ -16,12 +39,14 @@
*/
#include <errno.h>
#include <signal.h>
#include <sys/wait.h>
#include "fwknopd_common.h"
#include "extcmd.h"
#include "log_msg.h"
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
/*
static sig_atomic_t got_sigalrm;
*/
/* Takes a file descriptor and makes it non-blocking.
static int
@@ -45,13 +70,13 @@ set_nonblock(int fd)
return(0);
}
*/
static void
alarm_handler(int sig)
{
got_sigalrm = 1;
}
*/
/* Run en external command returning exit status, and optionally filling
* provided buffer with STDOUT output up to the size provided.
@@ -346,6 +371,7 @@ _run_extcmd(uid_t user_uid, char *cmd, char *so_buf, size_t so_buf_sz, int timeo
/* Run an external command. This is wrapper around _run_extcmd()
*/
int
run_extcmd(char *cmd, char *so_buf, size_t so_buf_sz, int timeout)
{
return _run_extcmd(0, cmd, so_buf, so_buf_sz, timeout);
@@ -353,6 +379,7 @@ run_extcmd(char *cmd, char *so_buf, size_t so_buf_sz, int timeout)
/* Run an external command as the specified user. This is wrapper around _run_extcmd()
*/
int
run_extcmd_as(uid_t user_uid, char *cmd, char *so_buf, size_t so_buf_sz, int timeout)
{
return _run_extcmd(user_uid, cmd, so_buf, so_buf_sz, timeout);
+17 -11
View File
@@ -25,13 +25,19 @@
*/
#include "fwknopd_common.h"
#include "fw_util.h"
#include "utils.h"
#include "log_msg.h"
#include "config_init.h" /* for the IS_EMPTY_LINE macro */
#include "extcmd.h"
#include "access.h"
#if HAVE_TIME_H
#include <time.h>
#endif
static struct fw_config fwc;
/*
static void
parse_extcmd_error(int retval, int status, char *se_buf)
{
@@ -79,11 +85,12 @@ parse_extcmd_error(int retval, int status, char *se_buf)
log_msg(LOG_WARNING, errmsg);
}
*/
static int
jump_rule_exists(int chain_num)
{
int num, x, pos = 0;
int num, pos = 0;
char cmd_buf[CMD_BUFSIZE] = {0};
char target[CMD_BUFSIZE] = {0};
char line_buf[CMD_BUFSIZE] = {0};
@@ -134,8 +141,7 @@ int
fw_dump_rules(fko_srv_options_t *opts)
{
int i;
int pos, res, status, got_err = 0;
int jump_rule_num;
int res, got_err = 0;
char cmd_buf[CMD_BUFSIZE] = {0};
char err[CMD_BUFSIZE] = {0};
@@ -166,7 +172,8 @@ fw_dump_rules(fko_srv_options_t *opts)
got_err++;
}
}
return;
return(got_err);
}
/* Quietly flush and delete all fwknop custom chains.
@@ -174,7 +181,7 @@ fw_dump_rules(fko_srv_options_t *opts)
static void
delete_all_chains(void)
{
int i, pos, res, status;
int i, res;
int jump_rule_num;
char cmd_buf[CMD_BUFSIZE] = {0};
char err[CMD_BUFSIZE] = {0};
@@ -231,7 +238,7 @@ static int
create_fw_chains(void)
{
int i;
int res, status, got_err = 0;
int res, got_err = 0;
char cmd_buf[CMD_BUFSIZE] = {0};
char err[CMD_BUFSIZE] = {0};
@@ -289,7 +296,6 @@ static void
set_fw_chain_conf(int type, char *conf_str)
{
int i, j;
char *mark;
char tbuf[1024] = {0};
char *ndx = conf_str;
@@ -469,7 +475,7 @@ process_spa_request(fko_srv_options_t *opts, spa_data_t *spadat)
struct fw_chain *dnat_chain = &(opts->fw_config->chain[IPT_DNAT_ACCESS]);
struct fw_chain *snat_chain; /* We assign this later (if we need to). */
int status, res;
int res = 0;
time_t now;
unsigned int exp_ts;
@@ -756,8 +762,8 @@ check_firewall_rules(fko_srv_options_t *opts)
char rule_num_str[6];
char *ndx, *rn_start, *rn_end, *tmp_mark;
int i, res, status, rn_offset;
time_t now, rule_exp, min_exp;
int i, res, rn_offset;
time_t now, rule_exp, min_exp = 0;
struct fw_chain *ch = opts->fw_config->chain;
@@ -915,7 +921,7 @@ check_firewall_rules(fko_srv_options_t *opts)
*/
if(ch[i].active_rules < 1)
ch[i].next_expire = 0;
else
else if(min_exp)
ch[i].next_expire = min_exp;
}
}
+8 -7
View File
@@ -30,8 +30,10 @@
#include "pcap_capture.h"
#include "log_msg.h"
#include "utils.h"
#include "fw_util.h"
#include "sig_handler.h"
#include "replay_dbm.h"
#include "tcp_server.h"
/* Prototypes
*/
@@ -44,10 +46,7 @@ static pid_t get_running_pid(fko_srv_options_t *opts);
int
main(int argc, char **argv)
{
fko_ctx_t ctx;
int res, last_sig, rpdb_count;
char *spa_data, *version;
char access_buf[MAX_LINE_LEN];
char *locale;
pid_t old_pid;
@@ -83,7 +82,7 @@ main(int argc, char **argv)
}
else
{
fprintf(stderr, "No running fwknopd detected.\n", old_pid);
fprintf(stderr, "No running fwknopd detected.\n");
exit(EXIT_FAILURE);
}
}
@@ -97,7 +96,7 @@ main(int argc, char **argv)
if(old_pid > 0)
fprintf(stderr, "Detected fwknopd is running (pid=%i).\n", old_pid);
else
fprintf(stderr, "No running fwknopd detected.\n", old_pid);
fprintf(stderr, "No running fwknopd detected.\n");
exit(EXIT_SUCCESS);
}
@@ -124,7 +123,7 @@ main(int argc, char **argv)
}
else
{
fprintf(stderr, "No running fwknopd detected.\n", old_pid);
fprintf(stderr, "No running fwknopd detected.\n");
exit(EXIT_FAILURE);
}
}
@@ -283,8 +282,10 @@ main(int argc, char **argv)
*/
pcap_capture(&opts);
if(last_sig = got_signal) {
if(got_signal) {
last_sig = got_signal;
got_signal = 0;
if(got_sighup)
{
log_msg(LOG_WARNING, "Got SIGHUP. Re-reading configs.");
+18 -12
View File
@@ -28,7 +28,14 @@
#include "access.h"
#include "extcmd.h"
#include "log_msg.h"
#include "utils.h"
#include "fw_util.h"
#include "fwknopd_errors.h"
#include "replay_dbm.h"
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
/* Validate and in some cases preprocess/reformat the SPA data. Return an
* error code value if there is any indication the data is not valid spa data.
@@ -38,9 +45,9 @@ preprocess_spa_data(fko_srv_options_t *opts, char *src_ip)
{
spa_pkt_info_t *spa_pkt = &(opts->spa_pkt);
unsigned char *ndx = (unsigned char *)&(spa_pkt->packet_data);
char *ndx = (char *)&(spa_pkt->packet_data);
int pkt_data_len = spa_pkt->packet_data_len;
int tc, i;
int i;
/* At this point, we can reset the packet data length to 0. This our
* indicator to the rest of the program that we do not have a current
@@ -75,7 +82,7 @@ preprocess_spa_data(fko_srv_options_t *opts, char *src_ip)
/* Now extract, adjust (convert characters translated by the fwknop
* client), and reset the SPA message itself.
*/
strlcpy(spa_pkt->packet_data, ndx+5, pkt_data_len);
strlcpy((char *)spa_pkt->packet_data, ndx+5, pkt_data_len);
for(i=0; i<pkt_data_len; i++)
{
@@ -100,7 +107,7 @@ preprocess_spa_data(fko_srv_options_t *opts, char *src_ip)
/* Make sure the data is valid Base64-encoded characters
* (at least the first MIN_SPA_DATA_SIZE bytes).
*/
ndx = spa_pkt->packet_data;
ndx = (char *)spa_pkt->packet_data;
for(i=0; i<MIN_SPA_DATA_SIZE; i++)
{
if(!(isalnum(*ndx) || *ndx == '/' || *ndx == '+' || *ndx == '='))
@@ -152,7 +159,7 @@ get_spa_data_fields(fko_ctx_t ctx, spa_data_t *spdat)
if(res != FKO_SUCCESS)
return(res);
res = fko_get_spa_client_timeout(ctx, &(spdat->client_timeout));
res = fko_get_spa_client_timeout(ctx, (int *)&(spdat->client_timeout));
if(res != FKO_SUCCESS)
return(res);
@@ -172,7 +179,6 @@ incoming_spa(fko_srv_options_t *opts)
char *spa_ip_demark, *gpg_id;
time_t now_ts;
int res, status, ts_diff, enc_type;
uid_t myuid;
spa_pkt_info_t *spa_pkt = &(opts->spa_pkt);
@@ -213,12 +219,12 @@ incoming_spa(fko_srv_options_t *opts)
/* Get encryption type and try its decoding routine first (if the key
* for that type is set)
*/
enc_type = fko_encryption_type(spa_pkt->packet_data);
enc_type = fko_encryption_type((char *)spa_pkt->packet_data);
if(enc_type == FKO_ENCRYPTION_RIJNDAEL)
{
if(acc->key != NULL)
res = fko_new_with_data(&ctx, spa_pkt->packet_data, acc->key);
res = fko_new_with_data(&ctx, (char *)spa_pkt->packet_data, acc->key);
else
{
log_msg(LOG_ERR,
@@ -233,7 +239,7 @@ incoming_spa(fko_srv_options_t *opts)
*/
if(acc->gpg_decrypt_pw != NULL)
{
res = fko_new_with_data(&ctx, spa_pkt->packet_data, NULL);
res = fko_new_with_data(&ctx, (char *)spa_pkt->packet_data, NULL);
if(res != FKO_SUCCESS)
{
log_msg(LOG_WARNING,
@@ -481,13 +487,13 @@ incoming_spa(fko_srv_options_t *opts)
* actual exit status of some commands. Not sure
* why yet. For now, we will take what we get.
*/
status = WEXITSTATUS(status);
status = WEXITSTATUS(res);
if(opts->verbose > 2)
log_msg(LOG_WARNING,
"CMD_EXEC: command returned %i", res);
"CMD_EXEC: command returned %i", status);
if(res != 0)
if(status != 0)
res = SPA_MSG_COMMAND_ERROR;
}
+3 -1
View File
@@ -37,6 +37,7 @@
#include "log_msg.h"
#include "fwknopd_errors.h"
#include "sig_handler.h"
#include "tcp_server.h"
/* The pcap capture routine.
*/
@@ -138,7 +139,8 @@ pcap_capture(fko_srv_options_t *opts)
* the number of signals that were *not* set. Those that we not set
* will be listed in the log/stderr output.
*/
set_sig_handlers();
if(set_sig_handlers() > 0)
log_msg(LOG_ERR, "Errors encountered when setting signal handlers.");
log_msg(LOG_INFO, "Starting fwknopd main event loop.");
+2 -2
View File
@@ -36,6 +36,7 @@
#include "fwknopd_common.h"
#include "process_packet.h"
#include "utils.h"
void
process_packet(unsigned char *args, const struct pcap_pkthdr *packet_header,
@@ -50,7 +51,6 @@ process_packet(unsigned char *args, const struct pcap_pkthdr *packet_header,
unsigned short pkt_data_len;
unsigned char *pkt_end;
unsigned int pke_data_len;
unsigned int ip_hdr_words;
unsigned int src_ip;
@@ -179,7 +179,7 @@ process_packet(unsigned char *args, const struct pcap_pkthdr *packet_header,
/* Put the data in our 1-entry queue.
*/
strlcpy(opts->spa_pkt.packet_data, pkt_data, pkt_data_len+1);
strlcpy((char *)opts->spa_pkt.packet_data, (char *)pkt_data, pkt_data_len+1);
opts->spa_pkt.packet_data_len = pkt_data_len;
opts->spa_pkt.packet_src_ip = src_ip;
opts->spa_pkt.packet_dest_port = dest_port;
-2
View File
@@ -165,9 +165,7 @@ replay_check(fko_srv_options_t *opts, fko_ctx_t ctx)
#endif
datum db_key, db_ent;
//struct tm created, first, last;
char created[18], first[18], last[18];
int replay_count = 0;
char curr_ip[INET_ADDRSTRLEN+1] = {0};
char last_ip[INET_ADDRSTRLEN+1] = {0};
+4
View File
@@ -27,6 +27,10 @@
#include "log_msg.h"
#include "sig_handler.h"
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
sig_atomic_t got_signal = 0; /* General signal flag (break capture) */
sig_atomic_t got_sighup = 0; /* SIGHUP flag */
+1
View File
@@ -38,6 +38,7 @@ extern sig_atomic_t got_sigusr2;
extern sig_atomic_t got_sigchld;
void sig_handler(int sig);
int set_sig_handlers(void);
#endif /* SIG_HANDLER_H */
+10 -5
View File
@@ -27,17 +27,22 @@
#include "fwknopd_common.h"
#include "tcp_server.h"
#include "log_msg.h"
#include "utils.h"
#include <errno.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#include <sys/socket.h>
#endif
#include <netdb.h>
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#if HAVE_NETDB
#include <netdb.h>
#endif
#include <fcntl.h>
#include <sys/select.h>
//static int c_sock;
/* Fork off and run a "dummy" TCP server. The return value is the PID of
* the child process or -1 if there is a fork error.
*/
@@ -177,7 +182,7 @@ run_tcp_server(fko_srv_options_t *opts)
/* Wait for a client to connect
*/
if((c_sock = accept(s_sock, (struct sockaddr *) &caddr, &clen)) < 0)
if((c_sock = accept(s_sock, (struct sockaddr *) &caddr, (socklen_t *)&clen)) < 0)
{
log_msg(LOG_ERR, "run_tcp_server: accept() failed: %s",
strerror(errno));
+2 -6
View File
@@ -36,11 +36,7 @@ void hex_dump(unsigned char *data, int size);
char* dump_ctx(fko_ctx_t ctx);
int is_valid_dir(const char *path);
#ifdef WIN32
/* Function prototypes we need for Windows
*/
size_t strlcat(char *dst, const char *src, size_t siz);
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
size_t strlcat(char *dst, const char *src, size_t siz);
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif /* UTILS_H */