1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-27 02:02:45 +02:00

* keyserver.c (keyserver_spawn): Handle CRLF endings from keyserver

helpers.  Also don't leak the last line worth of memory from the keyserver
response.

* main.h, misc.c (deprecated_warning): New function to warn about
deprecated options and commands.

* g10.c (main), keyserver-internal.h, keyserver.c (parse_keyserver_uri):
Use new deprecated function to warn about honor-http-proxy,
auto-key-retrieve, and x-broken-hkp.
This commit is contained in:
David Shaw 2002-06-12 18:56:36 +00:00
parent 03d78479ff
commit 8ce53a679a
6 changed files with 77 additions and 32 deletions

View File

@ -1,3 +1,16 @@
2002-06-12 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (keyserver_spawn): Handle CRLF endings from
keyserver helpers. Also don't leak the last line worth of memory
from the keyserver response.
* main.h, misc.c (deprecated_warning): New function to warn about
deprecated options and commands.
* g10.c (main), keyserver-internal.h, keyserver.c
(parse_keyserver_uri): Use new deprecated function to warn about
honor-http-proxy, auto-key-retrieve, and x-broken-hkp.
2002-06-11 David Shaw <dshaw@jabberwocky.com> 2002-06-11 David Shaw <dshaw@jabberwocky.com>
* Makefile.am: link gpg with NETLIBS for the built-in HKP access. * Makefile.am: link gpg with NETLIBS for the built-in HKP access.

View File

@ -1328,7 +1328,7 @@ main( int argc, char **argv )
#endif /* __riscos__ */ #endif /* __riscos__ */
break; break;
case oKeyServer: case oKeyServer:
if(parse_keyserver_uri(pargs.r.ret_str)) if(parse_keyserver_uri(pargs.r.ret_str,configname,configlineno))
log_error(_("could not parse keyserver URI\n")); log_error(_("could not parse keyserver URI\n"));
break; break;
case oKeyServerOptions: case oKeyServerOptions:
@ -1372,10 +1372,10 @@ main( int argc, char **argv )
case oSetFilesize: opt.set_filesize = pargs.r.ret_ulong; break; case oSetFilesize: opt.set_filesize = pargs.r.ret_ulong; break;
case oHonorHttpProxy: case oHonorHttpProxy:
opt.keyserver_options.honor_http_proxy = 1; opt.keyserver_options.honor_http_proxy = 1;
log_info(_("WARNING: %s is a deprecated option.\n"), deprecated_warning(configname,configlineno,
"--honor-http-proxy"); "--honor-http-proxy",
log_info(_("please use \"--keyserver-options %s\" instead\n"), "--keyserver-options ",
"honor-http-proxy"); "honor-http-proxy");
break; break;
case oFastListMode: opt.fast_list_mode = 1; break; case oFastListMode: opt.fast_list_mode = 1; break;
case oFixedListMode: opt.fixed_list_mode = 1; break; case oFixedListMode: opt.fixed_list_mode = 1; break;
@ -1388,13 +1388,12 @@ main( int argc, char **argv )
case oNoAutoKeyRetrieve: case oNoAutoKeyRetrieve:
opt.keyserver_options.auto_key_retrieve= opt.keyserver_options.auto_key_retrieve=
(pargs.r_opt==oAutoKeyRetrieve); (pargs.r_opt==oAutoKeyRetrieve);
log_info(_("WARNING: %s is a deprecated option.\n"), deprecated_warning(configname,configlineno,
pargs.r_opt==oAutoKeyRetrieve? pargs.r_opt==oAutoKeyRetrieve?"--auto-key-retrieve":
"--auto-key-retrieve":"--no-auto-key-retrieve"); "--no-auto-key-retrieve","--keyserver-options ",
log_info(_("please use \"--keyserver-options %s\" instead\n"), pargs.r_opt==oAutoKeyRetrieve?"auto-key-retrieve":
pargs.r_opt==oAutoKeyRetrieve? "no-auto-key-retrieve");
"auto-key-retrieve":"no-auto-key-retrieve"); break;
break;
case oShowSessionKey: opt.show_session_key = 1; break; case oShowSessionKey: opt.show_session_key = 1; break;
case oOverrideSessionKey: case oOverrideSessionKey:
opt.override_session_key = pargs.r.ret_str; opt.override_session_key = pargs.r.ret_str;

View File

@ -9,7 +9,8 @@
#include "types.h" #include "types.h"
void parse_keyserver_options(char *options); void parse_keyserver_options(char *options);
int parse_keyserver_uri(char *uri); int parse_keyserver_uri(char *uri,
const char *configname,unsigned int configlineno);
int keyserver_export(STRLIST users); int keyserver_export(STRLIST users);
int keyserver_import(STRLIST users); int keyserver_import(STRLIST users);
int keyserver_import_fprint(const byte *fprint,size_t fprint_len); int keyserver_import_fprint(const byte *fprint,size_t fprint_len);

View File

@ -117,7 +117,7 @@ parse_keyserver_options(char *options)
} }
int int
parse_keyserver_uri(char *uri) parse_keyserver_uri(char *uri,const char *configname,unsigned int configlineno)
{ {
/* Get the scheme */ /* Get the scheme */
@ -130,10 +130,8 @@ parse_keyserver_uri(char *uri)
if(ascii_strcasecmp(opt.keyserver_scheme,"x-broken-hkp")==0) if(ascii_strcasecmp(opt.keyserver_scheme,"x-broken-hkp")==0)
{ {
log_info(_("WARNING: %s is a deprecated option.\n"), deprecated_warning(configname,configlineno,"x-broken-hkp",
"x-broken-hkp"); "--keyserver-options ","broken-http-proxy");
log_info(_("please use \"--keyserver-options %s\" instead\n"),
"broken-http-proxy");
opt.keyserver_scheme="hkp"; opt.keyserver_scheme="hkp";
opt.keyserver_options.broken_http_proxy=1; opt.keyserver_options.broken_http_proxy=1;
} }
@ -491,39 +489,50 @@ keyserver_spawn(int action,STRLIST list,
/* Now handle the response */ /* Now handle the response */
do for(;;)
{ {
char *ptr;
if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0) if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0)
{ {
ret=G10ERR_READ_FILE; ret=G10ERR_READ_FILE;
goto fail; /* i.e. EOF */ goto fail; /* i.e. EOF */
} }
if(ascii_memcasecmp(line,"VERSION ",8)==0) ptr=line;
if(*ptr=='\r')
ptr++;
if(*ptr=='\n')
ptr++;
if(*ptr=='\0')
break;
if(ascii_memcasecmp(ptr,"VERSION ",8)==0)
{ {
gotversion=1; gotversion=1;
if(atoi(&line[8])!=KEYSERVER_PROTO_VERSION) if(atoi(&ptr[8])!=KEYSERVER_PROTO_VERSION)
{ {
log_error(_("invalid keyserver protocol (us %d!=handler %d)\n"), log_error(_("invalid keyserver protocol (us %d!=handler %d)\n"),
KEYSERVER_PROTO_VERSION,atoi(&line[8])); KEYSERVER_PROTO_VERSION,atoi(&ptr[8]));
goto fail; goto fail;
} }
} }
else if(ascii_memcasecmp(ptr,"PROGRAM ",8)==0)
if(ascii_memcasecmp(line,"PROGRAM ",8)==0)
{ {
line[strlen(line)-1]='\0'; ptr[strlen(ptr)-1]='\0';
if(ascii_strcasecmp(&line[8],VERSION)!=0) if(ascii_strcasecmp(&ptr[8],VERSION)!=0)
log_info(_("Warning: keyserver handler from a different " log_info(_("Warning: keyserver handler from a different "
"version of GnuPG (%s)\n"),&line[8]); "version of GnuPG (%s)\n"),&ptr[8]);
} }
else if(ascii_memcasecmp(ptr,"OPTION OUTOFBAND",16)==0)
/* Currently the only OPTION */ outofband=1; /* Currently the only OPTION */
if(ascii_memcasecmp(line,"OPTION OUTOFBAND",16)==0)
outofband=1;
} }
while(line[0]!='\n');
m_free(line);
if(!gotversion) if(!gotversion)
{ {

View File

@ -83,6 +83,8 @@ struct expando_args
char *pct_expando(const char *string,struct expando_args *args); char *pct_expando(const char *string,struct expando_args *args);
int hextobyte( const char *s ); int hextobyte( const char *s );
void deprecated_warning(const char *configname,unsigned int configlineno,
const char *option,const char *repl1,const char *repl2);
/*-- helptext.c --*/ /*-- helptext.c --*/
void display_online_help( const char *keyword ); void display_online_help( const char *keyword );

View File

@ -637,3 +637,24 @@ hextobyte( const char *s )
return -1; return -1;
return c; return c;
} }
void
deprecated_warning(const char *configname,unsigned int configlineno,
const char *option,const char *repl1,const char *repl2)
{
if(configname)
{
if(strncmp("--",option,2)==0)
option+=2;
if(strncmp("--",repl1,2)==0)
repl1+=2;
log_info(_("%s:%d: deprecated option \"%s\"\n"),
configname,configlineno,option);
}
else
log_info(_("WARNING: \"%s\" is a deprecated option\n"),option);
log_info(_("please use \"%s%s\" instead\n"),repl1,repl2);
}