Silence several warnings when building under Windows.

* agent/call-scd.c (start_scd): Replace int by assuan_fd_t.
(start_pinentry): Ditto.
* common/asshelp.c (start_new_gpg_agent): Replace int by assuan_fd_t.
* common/dotlock.c (GNUPG_MAJOR_VERSION): Include stringhelp.h for
prototypes on Windows and some other platforms.
* common/logging.c (fun_writer): Declare addrbuf only if needed.
* g10/decrypt.c (decrypt_message_fd) [W32]: Return not_implemented.
* g10/encrypt.c (encrypt_crypt) [W32]: Return error if used in server
mode.
* g10/dearmor.c (dearmor_file, enarmor_file): Replace GNUPG_INVALID_FD
by -1 as temporary hack for Windows.
* g10/export.c (do_export): Ditto.
* g10/revoke.c (gen_desig_revoke, gen_revoke): Ditto.
* g10/sign.c (sign_file, clearsign_file, sign_symencrypt_file): Ditto.
* g10/server.c (cmd_verify, gpg_server) [W32]: Return an error.
--

The gpg server mode is not actual working and thus we can avoid the
warnings by explicitly disabling the mode.  We keep it working under
Unix, though.
This commit is contained in:
Werner Koch 2014-03-07 09:46:44 +01:00
parent cb0dcc3408
commit 3032fc3ad7
12 changed files with 64 additions and 16 deletions

View File

@ -208,7 +208,7 @@ start_pinentry (ctrl_t ctrl)
const char *pgmname;
assuan_context_t ctx;
const char *argv[5];
int no_close_list[3];
assuan_fd_t no_close_list[3];
int i;
const char *tmpstr;
unsigned long pinentry_pid;
@ -291,7 +291,7 @@ start_pinentry (ctrl_t ctrl)
no_close_list[i++] = assuan_fd_from_posix_fd (log_get_fd ());
no_close_list[i++] = assuan_fd_from_posix_fd (fileno (stderr));
}
no_close_list[i] = -1;
no_close_list[i] = ASSUAN_INVALID_FD;
rc = assuan_new (&ctx);
if (rc)

View File

@ -198,7 +198,7 @@ start_scd (ctrl_t ctrl)
const char *pgmname;
assuan_context_t ctx = NULL;
const char *argv[3];
int no_close_list[3];
assuan_fd_t no_close_list[3];
int i;
int rc;
@ -324,7 +324,7 @@ start_scd (ctrl_t ctrl)
no_close_list[i++] = assuan_fd_from_posix_fd (log_get_fd ());
no_close_list[i++] = assuan_fd_from_posix_fd (fileno (stderr));
}
no_close_list[i] = -1;
no_close_list[i] = ASSUAN_INVALID_FD;
/* Connect to the pinentry and perform initial handshaking. Use
detached flag (128) so that under W32 SCDAEMON does not show up a

View File

@ -484,7 +484,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
of the required features except for passphrase
caching etc. */
const char *pgmname;
int no_close_list[3];
assuan_fd_t no_close_list[3];
int i;
if ( !(pgmname = strrchr (agent_program, '/')))
@ -500,7 +500,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
if (log_get_fd () != -1)
no_close_list[i++] = assuan_fd_from_posix_fd (log_get_fd ());
no_close_list[i++] = assuan_fd_from_posix_fd (fileno (stderr));
no_close_list[i] = -1;
no_close_list[i] = ASSUAN_INVALID_FD;
/* Connect to the agent and perform initial handshaking. */
err = assuan_pipe_connect (ctx, agent_program, argv,

View File

@ -311,6 +311,7 @@
#ifdef GNUPG_MAJOR_VERSION
# include "libjnlib-config.h"
# include "stringhelp.h" /* For stpcpy and w32_strerror. */
#endif
#ifdef HAVE_W32CE_SYSTEM
# include "utf8conv.h" /* WindowsCE requires filename conversion. */

View File

@ -257,7 +257,9 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
else
{
char *addrstr, *p;
#ifdef HAVE_INET_PTON
void *addrbuf = NULL;
#endif /*HAVE_INET_PTON*/
addrstr = jnlib_malloc (strlen (name) + 1);
if (!addrstr)
@ -281,7 +283,9 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
memset (&srvr_addr_in6, 0, sizeof srvr_addr_in6);
srvr_addr_in6.sin6_family = af;
srvr_addr_in6.sin6_port = htons (port);
#ifdef HAVE_INET_PTON
addrbuf = &srvr_addr_in6.sin6_addr;
#endif /*HAVE_INET_PTON*/
srvr_addr = (struct sockaddr *)&srvr_addr_in6;
addrlen = sizeof srvr_addr_in6;
#else
@ -306,7 +310,9 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
memset (&srvr_addr_in, 0, sizeof srvr_addr_in);
srvr_addr_in.sin_family = af;
srvr_addr_in.sin_port = htons (port);
#ifdef HAVE_INET_PTON
addrbuf = &srvr_addr_in.sin_addr;
#endif /*HAVE_INET_PTON*/
srvr_addr = (struct sockaddr *)&srvr_addr_in;
addrlen = sizeof srvr_addr_in;
}

View File

@ -64,7 +64,7 @@ dearmor_file( const char *fname )
push_armor_filter ( afx, inp );
if( (rc = open_outfile (GNUPG_INVALID_FD, fname, 0, &out )) )
if( (rc = open_outfile (-1, fname, 0, &out )) )
goto leave;
while( (c = iobuf_get(inp)) != -1 )
@ -110,7 +110,7 @@ enarmor_file( const char *fname )
}
if( (rc = open_outfile (GNUPG_INVALID_FD, fname, 1, &out )) )
if( (rc = open_outfile (-1, fname, 1, &out )) )
goto leave;
afx->what = 4;

View File

@ -102,6 +102,13 @@ decrypt_message (ctrl_t ctrl, const char *filename)
gpg_error_t
decrypt_message_fd (ctrl_t ctrl, int input_fd, int output_fd)
{
#ifdef HAVE_W32_SYSTEM
/* No server mode yet. */
(void)ctrl;
(void)input_fd;
(void)output_fd;
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
#else
gpg_error_t err;
IOBUF fp;
armor_filter_context_t *afx = NULL;
@ -166,6 +173,7 @@ decrypt_message_fd (ctrl_t ctrl, int input_fd, int output_fd)
release_armor_context (afx);
release_progress_context (pfx);
return err;
#endif
}

View File

@ -524,7 +524,17 @@ encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
}
/* Prepare iobufs. */
#ifdef HAVE_W32_SYSTEM
if (filefd == -1)
inp = iobuf_open_fd_or_name (GNUPG_INVALID_FD, filename, "rb");
else
{
inp = NULL;
gpg_err_set_errno (ENOSYS);
}
#else
inp = iobuf_open_fd_or_name (filefd, filename, "rb");
#endif
if (inp)
iobuf_ioctl (inp, IOBUF_IOCTL_NO_CACHE, 1, NULL);
if (inp && is_secured_file (iobuf_get_fd (inp)))

View File

@ -200,7 +200,7 @@ do_export (ctrl_t ctrl, strlist_t users, int secret, unsigned int options )
memset( &zfx, 0, sizeof zfx);
rc = open_outfile (GNUPG_INVALID_FD, NULL, 0, &out );
rc = open_outfile (-1, NULL, 0, &out );
if (rc)
return rc;

View File

@ -328,7 +328,7 @@ gen_desig_revoke( const char *uname, strlist_t locusr )
if( !opt.armor )
tty_printf(_("ASCII armored output forced.\n"));
if( (rc = open_outfile (GNUPG_INVALID_FD, NULL, 0, &out )) )
if( (rc = open_outfile (-1, NULL, 0, &out )) )
goto leave;
afx->what = 1;
@ -518,7 +518,7 @@ gen_revoke (const char *uname)
if (!opt.armor)
tty_printf (_("ASCII armored output forced.\n"));
if ((rc = open_outfile (GNUPG_INVALID_FD, NULL, 0, &out )))
if ((rc = open_outfile (-1, NULL, 0, &out )))
goto leave;
afx->what = 1;

View File

@ -403,6 +403,11 @@ static gpg_error_t
cmd_verify (assuan_context_t ctx, char *line)
{
int rc;
#ifdef HAVE_W32_SYSTEM
(void)ctx;
(void)line;
rc = gpg_error (GPG_ERR_NOT_IMPLEMENTED);
#else
ctrl_t ctrl = assuan_get_pointer (ctx);
gnupg_fd_t fd = assuan_get_input_fd (ctx);
gnupg_fd_t out_fd = assuan_get_output_fd (ctx);
@ -418,13 +423,22 @@ cmd_verify (assuan_context_t ctx, char *line)
if (out_fd != GNUPG_INVALID_FD)
{
out_fp = es_fdopen_nc (out_fd, "w");
es_syshd_t syshd;
#ifdef HAVE_W32_SYSTEM
syshd.type = ES_SYSHD_HANDLE;
syshd.u.handle = out_fd;
#else
syshd.type = ES_SYSHD_FD;
syshd.u.fd = out_fd;
#endif
out_fp = es_sysopen_nc (&syshd, "w");
if (!out_fp)
return set_error (gpg_err_code_from_syserror (), "fdopen() failed");
}
log_debug ("WARNING: The server mode is WORK "
"iN PROGRESS and not ready for use\n");
"IN PROGRESS and not ready for use\n");
rc = gpg_verify (ctrl, fd, ctrl->server_local->message_fd, out_fp);
@ -432,6 +446,7 @@ cmd_verify (assuan_context_t ctx, char *line)
close_message_fd (ctrl);
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
#endif
if (rc)
log_error ("command '%s' failed: %s\n", "VERIFY", gpg_strerror (rc));
@ -672,7 +687,9 @@ int
gpg_server (ctrl_t ctrl)
{
int rc;
#ifndef HAVE_W32_SYSTEM
int filedes[2];
#endif
assuan_context_t ctx = NULL;
static const char hello[] = ("GNU Privacy Guard's OpenPGP server "
VERSION " ready");
@ -680,8 +697,10 @@ gpg_server (ctrl_t ctrl)
/* We use a pipe based server so that we can work from scripts.
assuan_init_pipe_server will automagically detect when we are
called with a socketpair and ignore FILEDES in this case. */
#ifndef HAVE_W32_SYSTEM
filedes[0] = assuan_fdopen (0);
filedes[1] = assuan_fdopen (1);
#endif
rc = assuan_new (&ctx);
if (rc)
{
@ -690,7 +709,11 @@ gpg_server (ctrl_t ctrl)
goto leave;
}
#ifdef HAVE_W32_SYSTEM
rc = gpg_error (GPG_ERR_NOT_IMPLEMENTED);
#else
rc = assuan_init_pipe_server (ctx, filedes);
#endif
if (rc)
{
log_error ("failed to initialize the server: %s\n", gpg_strerror (rc));

View File

@ -881,7 +881,7 @@ sign_file (ctrl_t ctrl, strlist_t filenames, int detached, strlist_t locusr,
else if( opt.verbose )
log_info(_("writing to '%s'\n"), outfile );
}
else if( (rc = open_outfile (GNUPG_INVALID_FD, fname,
else if( (rc = open_outfile (-1, fname,
opt.armor? 1: detached? 2:0, &out )))
goto leave;
@ -1198,7 +1198,7 @@ clearsign_file( const char *fname, strlist_t locusr, const char *outfile )
else if( opt.verbose )
log_info(_("writing to '%s'\n"), outfile );
}
else if( (rc = open_outfile (GNUPG_INVALID_FD, fname, 1, &out )) )
else if( (rc = open_outfile (-1, fname, 1, &out )) )
goto leave;
iobuf_writestr(out, "-----BEGIN PGP SIGNED MESSAGE-----" LF );
@ -1366,7 +1366,7 @@ sign_symencrypt_file (const char *fname, strlist_t locusr)
cfx.dek->use_mdc=1;
/* now create the outfile */
rc = open_outfile (GNUPG_INVALID_FD, fname, opt.armor? 1:0, &out);
rc = open_outfile (-1, fname, opt.armor? 1:0, &out);
if (rc)
goto leave;