Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaks to unbreak the windows build: Renamed FD_SET macro to FD_SET_A…

…LT to avoid conflict with the well-known FD_SET macro. Made the client read password from file descriptor a non-supported function on Windows.
  • Loading branch information...
commit 4b0f0802eedb1451029aac319ff063182650ee07 1 parent 39213be
@damienstuart damienstuart authored
View
4 client/cmd_opts.h
@@ -59,7 +59,7 @@ enum {
KEY_HMAC_BASE64,
KEY_HMAC,
FD_SET_STDIN,
- FD_SET,
+ FD_SET_ALT,
/* Put GPG-related items below the following line */
GPG_ENCRYPTION = 0x200,
GPG_RECIP_KEY,
@@ -91,7 +91,7 @@ static struct option cmd_opts[] =
{"destination", 1, NULL, 'D'},
{"save-args-file", 1, NULL, 'E'},
{"encryption-mode", 1, NULL, ENCRYPTION_MODE},
- {"fd", 1, NULL, FD_SET},
+ {"fd", 1, NULL, FD_SET_ALT},
{"fw-timeout", 1, NULL, 'f'},
{"gpg-encryption", 0, NULL, 'g'},
{"gpg-recipient-key", 1, NULL, GPG_RECIP_KEY },
View
10 client/config_init.c
@@ -37,6 +37,10 @@
#include <sys/stat.h>
#include <fcntl.h>
+#ifdef WIN32
+ #define STDIN_FILENO 0
+#endif
+
#define RC_PARAM_TEMPLATE "%-24s %s\n" /*!< Template to define param = val in a rc file */
#define RC_SECTION_DEFAULT "default" /*!< Name of the default section in fwknoprc */
#define RC_SECTION_TEMPLATE "[%s]\n" /*!< Template to define a section in a rc file */
@@ -2138,7 +2142,11 @@ config_init(fko_cli_options_t *options, int argc, char **argv)
case FD_SET_STDIN:
options->input_fd = STDIN_FILENO;
break;
- case FD_SET:
+ case FD_SET_ALT:
+#ifdef WIN32
+ log_msg(LOG_VERBOSITY_ERROR, "Read password from FD not supported on Windows");
+ exit(EXIT_FAILURE);
+#endif
options->input_fd = strtol_wrapper(optarg, 0,
-1, EXIT_UPON_ERR, &is_err);
break;
View
27 client/getpasswd.c
@@ -128,11 +128,15 @@ char*
getpasswd(const char *prompt, int fd)
{
char *ptr;
+ FILE *fp;
#ifndef WIN32
sigset_t sig, old_sig;
struct termios ts, old_ts;
- FILE *fp;
+#else
+ /* Force stdin on windows. */
+ fd = 0;
+#endif
/* If a valid file descriptor is supplied, we try to open a stream from it */
if (FD_IS_VALID(fd))
@@ -147,6 +151,7 @@ getpasswd(const char *prompt, int fd)
}
}
+#ifndef WIN32
/* Otherwise we are going to open a new stream */
else
{
@@ -179,33 +184,15 @@ getpasswd(const char *prompt, int fd)
#else
_cputs(prompt);
#endif
-
/* Read the password */
ptr = read_passwd_from_stream(fp);
-#ifndef WIN32
-
- /* If we used a new buffered stream */
- if (FD_IS_VALID(fd) == 0)
- {
- /* we can go ahead and echo out a newline.
- */
- putc(PW_LF_CHAR, fp);
-
- /* Restore our tty state and signal handlers.
- */
- tcsetattr(fileno(fp), TCSAFLUSH, &old_ts);
- sigprocmask(SIG_BLOCK, &old_sig, NULL);
- }
-
- fclose(fp);
-#else
+#ifdef WIN32
/* In Windows, it would be a CR-LF
*/
_putch(PW_CR_CHAR);
_putch(PW_LF_CHAR);
#endif
-
return (ptr);
}
View
1  common/common.h
@@ -83,6 +83,7 @@
#define snprintf _snprintf
#define unlink _unlink
#define open _open
+ #define fdopen _fdopen
#define close _close
#define write _write
#define O_WRONLY _O_WRONLY
View
2  lib/fko_common.h
@@ -116,7 +116,7 @@
#ifndef BYTEORDER
#if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
#define BYTEORDER 4321
- #elif defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__)
+ #elif defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || defined(WIN32)
#define BYTEORDER 1234
#endif
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.