Skip to content

Commit

Permalink
Enable IDN support in getent.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed May 7, 2010
1 parent 9b1edf5 commit a160f8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
2010-05-06 Ulrich Drepper <drepper@redhat.com>

* nss/getent.c (idn_flags): Default to AI_IDN|AI_CANONIDN.
(args_options): Add no-idn option.
(ahosts_keys_int): Add idn_flags to ai_flags.
(parse_option): Handle 'i' option to clear idn_flags.

* malloc/malloc.c (_int_free): Possible race in the most recently
added check. Only act on the data if no current modification
happened.
12 changes: 11 additions & 1 deletion nss/getent.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <netdb.h>
#include <pwd.h>
#include <shadow.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand All @@ -56,6 +57,7 @@ static const char args_doc[] = N_("database [key ...]");
static const struct argp_option args_options[] =
{
{ "service", 's', "CONFIG", 0, N_("Service configuration to be used") },
{ "no-idn", 'i', NULL, 0, N_("disable IDN encoding") },
{ NULL, 0, NULL, 0, NULL },
};

Expand All @@ -74,6 +76,9 @@ static struct argp argp =
args_options, parse_option, args_doc, doc, NULL, more_help
};

/* Additional getaddrinfo flags for IDN encoding. */
static int idn_flags = AI_IDN | AI_CANONIDN;

/* Print the version information. */
static void
print_version (FILE *stream, struct argp_state *state)
Expand Down Expand Up @@ -377,7 +382,8 @@ ahosts_keys_int (int af, int xflags, int number, char *key[])

struct addrinfo hint;
memset (&hint, '\0', sizeof (hint));
hint.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME | xflags;
hint.ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME
| idn_flags | xflags);
hint.ai_family = af;

for (i = 0; i < number; ++i)
Expand Down Expand Up @@ -861,6 +867,10 @@ parse_option (int key, char *arg, struct argp_state *state)
}
break;

case 'i':
idn_flags = 0;
break;

default:
return ARGP_ERR_UNKNOWN;
}
Expand Down

0 comments on commit a160f8d

Please sign in to comment.