mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-11 21:48:50 +01:00
* options.h, keyserver-internal.h, keyserver.c (parse_keyserver_uri):
Improved URI parser that keeps track of the path information and doesn't modify the input string. (keyserver_spawn): Tell keyserver plugins about the path.
This commit is contained in:
parent
536841ecae
commit
0aba5ff41b
@ -1,3 +1,10 @@
|
|||||||
|
2004-05-11 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* options.h, keyserver-internal.h, keyserver.c
|
||||||
|
(parse_keyserver_uri): Improved URI parser that keeps track of the
|
||||||
|
path information and doesn't modify the input string.
|
||||||
|
(keyserver_spawn): Tell keyserver plugins about the path.
|
||||||
|
|
||||||
2004-05-11 Werner Koch <wk@gnupg.org>
|
2004-05-11 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* keylist.c (show_policy_url, show_keyserver_url, show_notation)
|
* keylist.c (show_policy_url, show_keyserver_url, show_notation)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
int parse_keyserver_options(char *options);
|
int parse_keyserver_options(char *options);
|
||||||
void free_keyserver_spec(struct keyserver_spec *keyserver);
|
void free_keyserver_spec(struct keyserver_spec *keyserver);
|
||||||
struct keyserver_spec *parse_keyserver_uri(char *uri,int require_scheme,
|
struct keyserver_spec *parse_keyserver_uri(const char *uri,int require_scheme,
|
||||||
const char *configname,
|
const char *configname,
|
||||||
unsigned int configlineno);
|
unsigned int configlineno);
|
||||||
int keyserver_export(STRLIST users);
|
int keyserver_export(STRLIST users);
|
||||||
|
109
g10/keyserver.c
109
g10/keyserver.c
@ -141,17 +141,19 @@ free_keyserver_spec(struct keyserver_spec *keyserver)
|
|||||||
m_free(keyserver->uri);
|
m_free(keyserver->uri);
|
||||||
m_free(keyserver->host);
|
m_free(keyserver->host);
|
||||||
m_free(keyserver->port);
|
m_free(keyserver->port);
|
||||||
|
m_free(keyserver->path);
|
||||||
m_free(keyserver->opaque);
|
m_free(keyserver->opaque);
|
||||||
m_free(keyserver);
|
m_free(keyserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct keyserver_spec *
|
struct keyserver_spec *
|
||||||
parse_keyserver_uri(char *uri,int require_scheme,
|
parse_keyserver_uri(const char *uri,int require_scheme,
|
||||||
const char *configname,unsigned int configlineno)
|
const char *configname,unsigned int configlineno)
|
||||||
{
|
{
|
||||||
int assume_hkp=0;
|
int assume_hkp=0;
|
||||||
struct keyserver_spec *keyserver;
|
struct keyserver_spec *keyserver;
|
||||||
char *scheme;
|
const char *idx;
|
||||||
|
int count;
|
||||||
|
|
||||||
assert(uri!=NULL);
|
assert(uri!=NULL);
|
||||||
|
|
||||||
@ -161,91 +163,103 @@ parse_keyserver_uri(char *uri,int require_scheme,
|
|||||||
|
|
||||||
/* Get the scheme */
|
/* Get the scheme */
|
||||||
|
|
||||||
scheme=strsep(&uri,":");
|
for(idx=uri,count=0;*idx && *idx!=':';*idx++)
|
||||||
if(uri==NULL)
|
count++;
|
||||||
|
|
||||||
|
if(count==0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if(*idx=='\0')
|
||||||
{
|
{
|
||||||
if(require_scheme)
|
if(require_scheme)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Assume HKP if there is no scheme */
|
/* Assume HKP if there is no scheme */
|
||||||
assume_hkp=1;
|
assume_hkp=1;
|
||||||
uri=scheme;
|
keyserver->scheme=m_strdup("hkp");
|
||||||
scheme="hkp";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Force to lowercase */
|
int i;
|
||||||
char *i;
|
|
||||||
|
|
||||||
for(i=scheme;*i!='\0';i++)
|
keyserver->scheme=m_alloc(count+1);
|
||||||
*i=ascii_tolower(*i);
|
|
||||||
|
/* Force to lowercase */
|
||||||
|
for(i=0;i<count;i++)
|
||||||
|
keyserver->scheme[i]=ascii_tolower(uri[i]);
|
||||||
|
|
||||||
|
keyserver->scheme[i]='\0';
|
||||||
|
|
||||||
|
/* Skip past the scheme and colon */
|
||||||
|
uri+=count+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ascii_strcasecmp(scheme,"x-broken-hkp")==0)
|
if(ascii_strcasecmp(keyserver->scheme,"x-broken-hkp")==0)
|
||||||
{
|
{
|
||||||
deprecated_warning(configname,configlineno,"x-broken-hkp",
|
deprecated_warning(configname,configlineno,"x-broken-hkp",
|
||||||
"--keyserver-options ","broken-http-proxy");
|
"--keyserver-options ","broken-http-proxy");
|
||||||
scheme="hkp";
|
m_free(keyserver->scheme);
|
||||||
|
keyserver->scheme=m_strdup("hkp");
|
||||||
add_to_strlist(&opt.keyserver_options.other,"broken-http-proxy");
|
add_to_strlist(&opt.keyserver_options.other,"broken-http-proxy");
|
||||||
}
|
}
|
||||||
else if(ascii_strcasecmp(scheme,"x-hkp")==0)
|
else if(ascii_strcasecmp(keyserver->scheme,"x-hkp")==0)
|
||||||
{
|
{
|
||||||
/* Canonicalize this to "hkp" so it works with both the internal
|
/* Canonicalize this to "hkp" so it works with both the internal
|
||||||
and external keyserver interface. */
|
and external keyserver interface. */
|
||||||
scheme="hkp";
|
m_free(keyserver->scheme);
|
||||||
|
keyserver->scheme=m_strdup("hkp");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scheme[0]=='\0')
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
keyserver->scheme=m_strdup(scheme);
|
|
||||||
|
|
||||||
if(assume_hkp || (uri[0]=='/' && uri[1]=='/'))
|
if(assume_hkp || (uri[0]=='/' && uri[1]=='/'))
|
||||||
{
|
{
|
||||||
char *host,*port;
|
|
||||||
|
|
||||||
/* Two slashes means network path. */
|
/* Two slashes means network path. */
|
||||||
|
|
||||||
/* Skip over the "//", if any */
|
/* Skip over the "//", if any */
|
||||||
if(!assume_hkp)
|
if(!assume_hkp)
|
||||||
uri+=2;
|
uri+=2;
|
||||||
|
|
||||||
/* Get the host */
|
for(idx=uri,count=0;*idx && *idx!=':' && *idx!='/';*idx++)
|
||||||
host=strsep(&uri,":/");
|
count++;
|
||||||
if(host[0]=='\0')
|
|
||||||
|
if(count==0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
keyserver->host=m_strdup(host);
|
keyserver->host=m_alloc(count+1);
|
||||||
|
strncpy(keyserver->host,uri,count);
|
||||||
|
keyserver->host[count]='\0';
|
||||||
|
|
||||||
if(uri==NULL || uri[0]=='\0')
|
/* Skip past the host */
|
||||||
port=NULL;
|
uri+=count;
|
||||||
else
|
|
||||||
|
if(*uri==':')
|
||||||
{
|
{
|
||||||
char *ch;
|
|
||||||
|
|
||||||
/* Get the port */
|
|
||||||
port=strsep(&uri,"/");
|
|
||||||
|
|
||||||
/* Ports are digits only */
|
|
||||||
ch=port;
|
|
||||||
while(*ch!='\0')
|
|
||||||
{
|
|
||||||
if(!digitp(ch))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ch++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* It would seem to be reasonable to limit the range of the
|
/* It would seem to be reasonable to limit the range of the
|
||||||
ports to values between 1-65535, but RFC 1738 and 1808
|
ports to values between 1-65535, but RFC 1738 and 1808
|
||||||
imply there is no limit. Of course, the real world has
|
imply there is no limit. Of course, the real world has
|
||||||
limits. */
|
limits. */
|
||||||
|
|
||||||
keyserver->port=m_strdup(port);
|
for(idx=uri+1,count=0;*idx && *idx!='/';*idx++)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
|
||||||
|
/* Ports are digits only */
|
||||||
|
if(!digitp(idx))
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (any path part of the URI is discarded for now as no keyserver
|
keyserver->port=m_alloc(count+1);
|
||||||
uses it yet) */
|
strncpy(keyserver->port,uri+1,count);
|
||||||
|
keyserver->port[count]='\0';
|
||||||
|
|
||||||
|
/* Skip past the colon and port number */
|
||||||
|
uri+=1+count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Everything else is the path */
|
||||||
|
if(*uri)
|
||||||
|
keyserver->path=m_strdup(uri);
|
||||||
|
else
|
||||||
|
keyserver->path=m_strdup("/");
|
||||||
}
|
}
|
||||||
else if(uri[0]!='/')
|
else if(uri[0]!='/')
|
||||||
{
|
{
|
||||||
@ -783,6 +797,9 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
|
|||||||
|
|
||||||
if(keyserver->port)
|
if(keyserver->port)
|
||||||
fprintf(spawn->tochild,"PORT %s\n",keyserver->port);
|
fprintf(spawn->tochild,"PORT %s\n",keyserver->port);
|
||||||
|
|
||||||
|
if(keyserver->path)
|
||||||
|
fprintf(spawn->tochild,"PATH %s\n",keyserver->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write options */
|
/* Write options */
|
||||||
|
@ -131,6 +131,7 @@ struct
|
|||||||
char *scheme;
|
char *scheme;
|
||||||
char *host;
|
char *host;
|
||||||
char *port;
|
char *port;
|
||||||
|
char *path;
|
||||||
char *opaque;
|
char *opaque;
|
||||||
} *keyserver;
|
} *keyserver;
|
||||||
struct
|
struct
|
||||||
|
Loading…
Reference in New Issue
Block a user