char *homedir = NULL;
int rv = 0;
+#ifdef WIN32
+ homedir = getenv("USERPROFILE");
+#else
homedir = getenv("HOME");
-
+#endif
if (homedir != NULL) {
- snprintf(args_save_file, MAX_PATH_LEN, "%s%s%s",
- homedir, "/", ".fwknop.run");
+ snprintf(args_save_file, MAX_PATH_LEN, "%s%c%s",
+ homedir, PATH_SEP, ".fwknop.run");
rv = 1;
}
char args_str[MAX_LINE_LEN] = "";
FILE *args_file_ptr = NULL;
-#ifdef WIN32
- /* Not sure what the right thing is here on Win32, just exit
- * for now.
- */
- fprintf(stderr, "--show-last not implemented on Win32 yet.");
- exit(EXIT_FAILURE);
-#endif
-
if (get_save_file(args_save_file)) {
verify_file_perms_ownership(args_save_file);
if ((args_file_ptr = fopen(args_save_file, "r")) == NULL) {
char arg_tmp[MAX_LINE_LEN] = {0};
char *argv_new[MAX_CMDLINE_ARGS]; /* should be way more than enough */
-
-#ifdef WIN32
- /* Not sure what the right thing is here on Win32, just return
- * for now.
- */
- return;
-#endif
-
if (get_save_file(args_save_file))
{
verify_file_perms_ownership(args_save_file);
char args_str[MAX_LINE_LEN] = "";
int i = 0, args_str_len = 0, args_file_fd = -1;
-#ifdef WIN32
- /* Not sure what the right thing is here on Win32, just return
- * for now.
- */
- return;
-#endif
-
if (get_save_file(args_save_file)) {
args_file_fd = open(args_save_file, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
if (args_file_fd == -1) {
*/
strlcpy(url.host, HTTP_BACKUP_RESOLVE_HOST, MAX_URL_HOST_LEN);
+#ifndef WIN32
sleep(2);
+#endif
res = try_url(&url, options);
}
}
*
*****************************************************************************
*/
+#include "common.h"
#include "fwknop_common.h"
#include "utils.h"
#ifndef UTILS_H
#define UTILS_H
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <unistd.h>
#endif
+#ifdef HAVE_SYS_STAT_H
+ #include <sys/stat.h>
+#endif
+
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include <time.h>
#endif
+/* Some hoops for accommodating Windows
+*/
#ifdef WIN32
+ #include <io.h>
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define snprintf _snprintf
#define unlink _unlink
+ #define open _open
+ #define close _close
+ #define write _write
+ #define O_WRONLY _O_WRONLY
+ #define O_RDONLY _O_RDONLY
+ #define O_RDWR _O_RDWR
+ #define O_CREAT _O_CREAT
+ #define O_EXCL _O_EXCL
+ #define S_IRUSR _S_IREAD
+ #define S_IWUSR _S_IWRITE
#define PATH_SEP '\\'
#else
#include <signal.h>
AC_CANONICAL_TARGET
-AM_INIT_AUTOMAKE([tar-ustar -Wall -Werror foreign])
+AM_INIT_AUTOMAKE([tar-ustar -Wall foreign])
dnl AM_MAINTAINER_MODE
Name: fwknop
Version: 2.0.4
-Epoch: 1
+Epoch: 1
Release: 1%{?dist}
Summary: Firewall Knock Operator client. An implementation of Single Packet Authorization.
libfko_la_SOURCES = $(libfko_source_files)
-libfko_la_LDFLAGS = -version-info 0:3:0 $(GPGME_LIBS)
+libfko_la_LDFLAGS = -version-info 0:4:0 $(GPGME_LIBS)
-AM_CPPFLAGS = $(GPGME_CFLAGS)
+AM_CPPFLAGS = $(GPGME_CFLAGS) -I $(top_srcdir)/common
include_HEADERS = fko.h fko_limits.h fko_message.h
/* Make sure there are no non-ascii printable chars
*/
- for (i=0; i < strnlen(ctx->encoded_msg, MAX_SPA_ENCODED_MSG_SIZE); i++)
+ for (i=0; i < (int)strnlen(ctx->encoded_msg, MAX_SPA_ENCODED_MSG_SIZE); i++)
if(isprint(ctx->encoded_msg[i]) == 0)
return(FKO_ERROR_INVALID_DATA);
#ifndef FKO_MESSAGE_H
#define FKO_MESSAGE_H 1
-#if PLATFORM_OPENBSD
- #include <sys/types.h>
- #include <netinet/in.h>
-#else
- #if HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
- #endif
-#endif
-#include <arpa/inet.h>
+#include "common.h"
+#include "netinet_common.h"
#define MAX_PROTO_STR_LEN 4 /* tcp, udp, icmp for now */
#define MAX_PORT_STR_LEN 5
#else
username = getlogin();
#endif
- /* if we still didn't get a username, fall back
+ /* if we still didn't get a username, continue falling back
*/
- if((username = getenv("USER")) == NULL)
- {
- username = strdup("NO_USER");
- if(username == NULL)
- return(FKO_ERROR_MEMORY_ALLOCATION);
+ if(username == NULL)
+ {
+ if((username = getenv("USER")) == NULL)
+ {
+ username = strdup("NO_USER");
+ if(username == NULL)
+ return(FKO_ERROR_MEMORY_ALLOCATION);
+ }
}
}
}
if(isalnum(username[0]) == 0)
return(FKO_ERROR_INVALID_DATA);
- for (i=1; i < strnlen(username, MAX_SPA_USERNAME_SIZE); i++)
+ for (i=1; i < (int)strnlen(username, MAX_SPA_USERNAME_SIZE); i++)
if((isalnum(username[i]) == 0)
&& username[i] != '-' && username[i] != '_')
return(FKO_ERROR_INVALID_DATA);
Name="VCCLCompilerTool"\r
Optimization="0"\r
EnableIntrinsicFunctions="false"\r
- AdditionalIncludeDirectories=".;..\lib;..\client"\r
+ AdditionalIncludeDirectories=".;..\common;..\lib;..\client"\r
PreprocessorDefinitions="DLL_EXPORTS;WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"\r
MinimalRebuild="true"\r
ExceptionHandling="0"\r
Name="VCCLCompilerTool"\r
Optimization="2"\r
EnableIntrinsicFunctions="false"\r
- AdditionalIncludeDirectories=".;..\lib;..\client"\r
+ AdditionalIncludeDirectories=".;..\common;..\lib;..\client"\r
PreprocessorDefinitions="DLL_EXPORTS;WIN32;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"\r
RuntimeLibrary="2"\r
EnableFunctionLevelLinking="true"\r
Name="VCCLCompilerTool"\r
Optimization="0"\r
EnableIntrinsicFunctions="false"\r
- AdditionalIncludeDirectories=".;..\lib;..\client"\r
+ AdditionalIncludeDirectories=".;..\common;..\lib;..\client"\r
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"\r
MinimalRebuild="true"\r
ExceptionHandling="0"\r
Name="VCCLCompilerTool"\r
Optimization="2"\r
EnableIntrinsicFunctions="false"\r
- AdditionalIncludeDirectories=".;..\lib;..\client"\r
+ AdditionalIncludeDirectories=".;..\common;..\lib;..\client"\r
PreprocessorDefinitions="WIN32;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"\r
RuntimeLibrary="2"\r
EnableFunctionLevelLinking="true"\r
Name="VCCLCompilerTool"\r
Optimization="2"\r
EnableIntrinsicFunctions="false"\r
- AdditionalIncludeDirectories=".;..\lib;..\client"\r
+ AdditionalIncludeDirectories=".;..\common;..\lib;..\client"\r
PreprocessorDefinitions="WIN32;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"\r
RuntimeLibrary="0"\r
EnableFunctionLevelLinking="true"\r