about summary refs log tree commit diff
path: root/nss
diff options
context:
space:
mode:
Diffstat (limited to 'nss')
-rw-r--r--nss/getent.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/nss/getent.c b/nss/getent.c
index 69eea25a68..f6c0b5d434 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -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>
@@ -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 },
   };
 
@@ -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)
@@ -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)
@@ -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;
     }