Commit a651008e authored by Niels Möller's avatar Niels Möller
Browse files

* src/xauth.c (xauth_process): New function, using XauReadAuth.

(xauth_lookup): Use xauth_process instead of XauGetAuthByAddr.

Rev: src/xauth.c:1.5
parent 65ff628a
...@@ -36,14 +36,56 @@ ...@@ -36,14 +36,56 @@
#include <netinet/in.h> #include <netinet/in.h>
#if HAVE_LIBXAU #if HAVE_LIBXAU
static int xauth_process(const char *filename,
unsigned family,
unsigned address_length, const char *address,
unsigned number_length, const char *number,
struct lsh_string **name,
struct lsh_string **data)
{
FILE *f = fopen(filename, "rb");
Xauth *xa;
if (!f)
return 0;
while ( (xa = XauReadAuth(f)) )
{
debug("xauth: family: %i\n", xa->family);
debug(" address: %ps\n", xa->address_length, xa->address);
debug(" display: %s\n", xa->number_length, xa->number);
debug(" name: %s\n", xa->name_length, xa->name);
debug(" data length: %i\n", xa->data_length);
if ( (xa->family == family)
&& (xa->address_length == address_length)
&& (xa->number_length == number_length)
&& !memcmp(xa->address, address, address_length)
&& !memcmp(xa->number, number, number_length) )
{
*name = ssh_format("%ls", xa->name_length, xa->name);
*data = ssh_format("%ls", xa->data_length, xa->data);
XauDisposeAuth(xa);
fclose(f);
return 1;
}
}
XauDisposeAuth(xa);
fclose(f);
return 0;
}
int int
xauth_lookup(struct sockaddr *sa, xauth_lookup(struct sockaddr *sa,
unsigned display_length, unsigned number_length,
const char *display, const char *number,
struct lsh_string **name, struct lsh_string **name,
struct lsh_string **data) struct lsh_string **data)
{ {
Xauth *xa = NULL;
int res = 0; int res = 0;
unsigned family; unsigned family;
...@@ -98,26 +140,12 @@ xauth_lookup(struct sockaddr *sa, ...@@ -98,26 +140,12 @@ xauth_lookup(struct sockaddr *sa,
if (XauLockAuth(filename, 5, 1, 0) != LOCK_SUCCESS) if (XauLockAuth(filename, 5, 1, 0) != LOCK_SUCCESS)
return 0; return 0;
/* What's the right ptototype? The Solaris man-page includes only 5 arguments. */ res = xauth_process(filename,
xa = XauGetAuthByAddr(family, family,
address_length, address, address_length, address,
display_length, display, number_length, number,
18, "MIT-MAGIC-COOKIE-1"); name, data);
if (xa)
{
debug("xauth: family: %i\n", xa->family);
debug(" address: %ps\n", xa->address_length, xa->address);
debug(" display: %s\n", xa->number_length, xa->number);
debug(" name: %s\n", xa->name_length, xa->name);
debug(" data length: %i\n", xa->data_length);
res = 1;
*name = ssh_format("%ls", xa->name_length, xa->name);
*data = ssh_format("%ls", xa->data_length, xa->data);
XauDisposeAuth(xa);
}
XauUnlockAuth(filename); XauUnlockAuth(filename);
return res; return res;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment