Example #1
0
static void
auth_cancel(void *data)
{
	struct auth_entry *entry = (struct auth_entry *)data;

	entry->blocked = 0;
	del_auth_entry(entry);
}
Example #2
0
static void
delete_auth_entry(struct listbox_item *item, int last)
{
	struct auth_entry *auth_entry = (struct auth_entry *)item->udata;

	assert(!is_object_used(auth_entry));

	del_auth_entry(auth_entry);
}
Example #3
0
File: auth.c Project: Efreak/elinks
/* Free all entries in auth list and questions in queue. */
void
free_auth(void)
{
#ifdef DEBUG_HTTP_AUTH
	DBG("free_auth");
#endif

	while (!list_empty(auth_entry_list))
		del_auth_entry(auth_entry_list.next);

	free_list(questions_queue);
}
Example #4
0
struct auth_entry *find_auth( struct uri *uri )
{
  int eax;
  struct auth_entry *entry;
  &entry[0] = find_auth_entry( uri, 0 );
  if ( ( entry[0].next & 65535 ) || uri->bits_at_44/*.1_2of4*/ )
  {
    if ( entry[0].next )
    {
      if ( uri->bits_at_40/*.3_4of4*/ & 65535 )
      {
        errfile = "/home/naftali/source/elinks-0.12~pre5/src/protocol/auth/auth.c";
        errline = 249;
        if ( elinks_strlcmp( &entry->user[0], -1, uri->user, uri->bits_at_40/*.3_4of4*/ ) == 0 )
        {
          if ( uri->password == 0 )
            &entry[0] = &entry[0];
            if ( ( ( entry->bits_at_112/*.1_1of4*/ & 1 ) & 255 ) == 0 )
            {
              if ( entry->user[0] == 0 && entry->password[0] == 0 )
              {
                del_auth_entry( &entry[0] );
                &entry[0] = &entry[0];
              }
              return &entry[0];
            }
            return 0;
        }
      }
      else
      if ( uri->password == 0 )
        continue;
      errfile = "/home/naftali/source/elinks-0.12~pre5/src/protocol/auth/auth.c";
      errline = 250;
      if ( elinks_strlcmp( &entry->password[0], -1, uri->password, (int)uri->bits_at_44/*.1_2of4*/ ) == 0 )
        continue;
    }
    &entry[0] = add_auth_entry( &uri[0], 0, 0, 0, 0 );
  }
  if ( entry[0].next )
    continue;
  else
  {
    return &entry[0];
  }
}
Example #5
0
void free_auth( void )
{
  if ( auth_entry_list.next != auth_entry_list.next )
  {
    do
    {
      del_auth_entry( &auth_entry_list.next[0] );
    }
    while ( auth_entry_list.next == auth_entry_list.next );
  }
{
  struct xlist_head *head = &questions_queue.next[0], *next;
  if ( questions_queue.next != questions_queue.next )
  {
    do
    {
      head = &(struct xlist_head*)(head);
    }
    while ( head->next != questions_queue.next );
  }
  head = &questions_queue.prev[0];
  if ( questions_queue.prev != head[0].next )
  {
    do
    {
      head = head->prev;
    }
    while ( head->prev != head[0].next );
  }
  next = &questions_queue.next[0];
  if ( head[0].next != questions_queue.next )
  {
    next = &next[0];
    do
    {
      next->prev = head->prev;
      &(struct xlist_head*)(head->prev) = &(struct xlist_head*)(head);
      mem_free( (void*)head->next );
    }
    while ( next[0].next == head[0].next );
  }
  return;
}
}
Example #6
0
File: auth.c Project: Efreak/elinks
/* It returns a base 64 encoded user + pass suitable to use in Authorization
 * header, or NULL on failure. */
struct auth_entry *
find_auth(struct uri *uri)
{
	struct auth_entry *entry = NULL;

#ifdef DEBUG_HTTP_AUTH
	DBG("find_auth: newurl=%s uri=%p", newurl, uri);
#endif

	entry = find_auth_entry(uri, NULL);
	/* Check is user/pass info is in url. */
	if (uri->userlen || uri->passwordlen) {
		/* Add a new entry either to save the user/password info from the URI
		 * so it is available if we later get redirected to a URI with
		 * the user/password stripped. Else if update with entry with
		 * the user/password from the URI. */
		if (!entry
		    || (uri->userlen && strlcmp(entry->user, -1, uri->user, uri->userlen))
		    || (uri->password && strlcmp(entry->password, -1, uri->password, uri->passwordlen))) {

			entry = add_auth_entry(uri, NULL, NULL, NULL, 0);
		}
	}

	/* No entry found or waiting for user/password in dialog. */
	if (!entry || entry->blocked)
		return NULL;

	/* Sanity check. */
	if (!auth_entry_has_userinfo(entry)) {
		del_auth_entry(entry);
		return NULL;
	}

	return entry;
}
Example #7
0
struct auth_entry *add_auth_entry( struct uri *uri, unsigned char *realm, unsigned char *nonce, unsigned char *opaque, unsigned int digest )
{
  int eax;
  int edx;
  struct auth_entry *entry;
  if ( find_auth_entry( uri, realm ) == 0 )
  {
    entry = (struct auth_entry*)mem_calloc( 1, 116 );
    if ( mem_calloc( 1, 116 ) == 0 )
    {
      return &entry[0];
    }
    uri->object.refcount = uri->object.refcount;
    *(int*)(mem_calloc( 1, 116 ) + 12) = uri[0];
    if ( realm )
    {
      *(int*)(mem_calloc( 1, 116 ) + 16) = stracpy( realm );
      if ( mem_calloc( 1, 116 ) + 16 == 0 )
      {
        mem_free( &ecx );
        return &entry[0];
      }
    }
    set_auth_user( &ecx, &uri[0] );
    set_auth_password( ebp_28, &uri[0] );
    *(int*)(ebp_28 + 28) = eax;
    if ( ebp_28 + 28 == 0 )
    {
      done_auth_entry( &ecx );
      return &entry[0];
    }
    *(int*)(ecx + 4) = auth_entry_list.next;
    ecx = auth_entry_list.next;
    auth_entry_list.next = &ecx;
    *(int*)(ecx + 4) = ecx;
    if ( nonce )
    {
      auth_entry_list.next[6] = stracpy( nonce );
      if ( auth_entry_list.next + 4 + 20 == 0 )
      {
        del_auth_entry( &ecx );
        return &entry[0];
      }
    }
    if ( opaque )
    {
      *(int*)(ebp_28 + 24) = stracpy( opaque );
      if ( ebp_28 + 24 == 0 )
      {
        del_auth_entry( &ecx );
        return &entry[0];
      }
    }
    auth_entry_list.next[29] = ( *(char*)(auth_entry_list.next + 4 + 112) & -5 ) | ( ( (int)digest/*.1_1of4*/ & 1 ) << 2 );
  }
  else
  {
    if ( ( ( *(char*)(find_auth_entry( uri, realm ) + 112) & 1 ) & 255 ) == 0 )
    {
      if ( (unsigned char)( realm != 0 ) == ( *(int*)(entry[0].next + 16) != 0 ) )
      {
        if ( ( ( realm != 0 ) & 255 ) && ebp_41 && stracpy( opaque ) )
          entry->realm[0] = entry->realm;
        else
        {
          if ( entry->user[0] && uri->user && uri->bits_at_40/*.3_4of4*/ )
          {
            errfile = "/home/naftali/source/elinks-0.12~pre5/src/protocol/auth/auth.c";
            errline = 185;
            if ( elinks_strlcmp( &entry->user[0], -1, uri->user, uri->bits_at_40/*.3_4of4*/ ) == 0 )
            {
              if ( entry->password[0] && uri->password && uri->bits_at_44/*.1_2of4*/ )
              {
                errfile = "/home/naftali/source/elinks-0.12~pre5/src/protocol/auth/auth.c";
                errline = 192;
                if ( elinks_strlcmp( &entry->password[0], -1, uri->password, (int)uri->bits_at_44/*.1_2of4*/ ) )
                  goto B36;
              }
B36:              entry->bits_at_112/*.1_1of4*/ &= 253;
              set_auth_password( &entry[0], &uri[0] );
            }
          }
          entry->bits_at_112/*.1_1of4*/ &= 253;
          set_auth_user( &entry[0], &uri[0] );
        }
      }
      entry->bits_at_112/*.1_1of4*/ = (int)entry->bits_at_112/*.1_1of4*/ & -3;
      if ( entry->realm )
        mem_free( (void*)entry->realm );
      entry->realm = 0;
      if ( ( realm != 0 ) & 255 )
      {
        entry->realm = stracpy( realm );
        if ( entry->realm )
        {
          if ( nonce )
          {
            if ( entry->nonce )
              mem_free( (void*)entry->nonce );
            entry->nonce = stracpy( nonce );
            if ( entry->nonce == 0 )
              goto B23;
          }
          if ( opaque )
          {
            if ( entry->opaque )
              mem_free( (void*)entry->opaque );
            entry->opaque = stracpy( opaque );
            if ( entry->opaque == 0 )
            {
              del_auth_entry( &entry[0] );
              uri = &uri[0];
              return 0;
            }
          }
          entry->bits_at_112/*.1_1of4*/ = ( *(char*)(entry[0].next + 112) & -5 ) | ( ( (int)digest/*.1_1of4*/ & 1 ) << 2 );
        }
B23:        &entry[0] = 0;
        del_auth_entry( &entry[0] );
        return &entry[0];
      }
    }
    else
    {
      return 0;
    }
  }
  if ( !( ( entry->bits_at_112/*.1_1of4*/ & 2 ) & 255 ) && entry->realm )
  {
    add_questions_entry( &do_auth_dialog, (void*)entry[0].next );
    return &entry[0];
  }
  return &entry[0];
}
Example #8
0
File: auth.c Project: Efreak/elinks
/* Returns the new entry or updates an existing one. Sets the @valid member if
 * updating is required so it can be tested if the user should be queried. */
struct auth_entry *
add_auth_entry(struct uri *uri, unsigned char *realm, unsigned char *nonce,
	unsigned char *opaque, unsigned int digest)
{
	struct auth_entry *entry;

#ifdef DEBUG_HTTP_AUTH
	DBG("add_auth_entry: newurl=%s realm=%s uri=%p", newurl, realm, uri);
#endif

	/* Is host/realm already known ? */
	entry = find_auth_entry(uri, realm);
	if (entry) {
		/* Waiting for user/pass in dialog. */
		if (entry->blocked) return NULL;

		/* In order to use an existing entry it has to match exactly.
		 * This is done step by step. If something isn't equal the
		 * entry is updated and marked as invalid. */

		/* If only one realm is defined or they don't compare. */
		if ((!!realm ^ !!entry->realm)
		    || (realm && entry->realm && strcmp(realm, entry->realm))) {
			entry->valid = 0;
			mem_free_set(&entry->realm, NULL);
			if (realm) {
				entry->realm = stracpy(realm);
				if (!entry->realm) {
					del_auth_entry(entry);
					return NULL;
				}
				if (nonce) {
					mem_free_set(&entry->nonce, stracpy(nonce));
					if (!entry->nonce) {
						del_auth_entry(entry);
						return NULL;
					}
				}
				if (opaque) {
					mem_free_set(&entry->opaque, stracpy(opaque));
					if (!entry->opaque) {
						del_auth_entry(entry);
						return NULL;
					}
				}
				entry->digest = digest;
			}
		}

		if (!*entry->user
		    || (!uri->user || !uri->userlen ||
			strlcmp(entry->user, -1, uri->user, uri->userlen))) {
			entry->valid = 0;
			set_auth_user(entry, uri);
		}

		if (!*entry->password
		    || (!uri->password || !uri->passwordlen ||
			strlcmp(entry->password, -1, uri->password, uri->passwordlen))) {
			entry->valid = 0;
			set_auth_password(entry, uri);
		}

	} else {
		/* Create a new entry. */
		entry = init_auth_entry(uri, realm);
		if (!entry) return NULL;
		add_to_list(auth_entry_list, entry);
		if (nonce) {
			entry->nonce = stracpy(nonce);
			if (!entry->nonce) {
				del_auth_entry(entry);
				return NULL;
			}
		}
		if (opaque) {
			entry->opaque = stracpy(opaque);
			if (!entry->opaque) {
				del_auth_entry(entry);
				return NULL;
			}
		}
		entry->digest = digest;
	}

	/* Only pop up question if one of the protocols requested it */
	if (entry && !entry->valid && entry->realm)
		add_questions_entry(do_auth_dialog, entry);

	return entry;
}