From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 1/2] nss: Implement --no-addrconfig option for getent
Date: Tue, 13 Sep 2022 16:35:44 +0200 [thread overview]
Message-ID: <462265b0ce37bd57b9304d873e9bccdb1cc4a199.1663079342.git.fweimer@redhat.com> (raw)
In-Reply-To: <cover.1663079342.git.fweimer@redhat.com>
The ahosts, ahostsv4, ahostsv6 commands unconditionally pass
AI_ADDRCONFIG to getaddrinfo, which is not always desired.
---
NEWS | 5 ++++-
nss/getent.c | 11 ++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index ef274d1a42..d4739d93c6 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,10 @@ Version 2.37
Major new features:
- [Add new features here]
+* The getent tool now supports the --no-addrconfig option. When
+ present, getent no longer passes AI_ADDRCONFIG to the getaddrinfo
+ function, and the output may contain addresses of families not
+ configured on the current host.
Deprecated and removed features, and other changes affecting compatibility:
diff --git a/nss/getent.c b/nss/getent.c
index 8178b4b470..39a42e707d 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -58,6 +58,8 @@ static const struct argp_option args_options[] =
{
{ "service", 's', N_("CONFIG"), 0, N_("Service configuration to be used") },
{ "no-idn", 'i', NULL, 0, N_("disable IDN encoding") },
+ { "no-addrconfig", 'A', NULL, 0,
+ N_("disable AI_ADDRCONFIG (for ahosts*)") },
{ NULL, 0, NULL, 0, NULL },
};
@@ -79,6 +81,9 @@ static struct argp argp =
/* Additional getaddrinfo flags for IDN encoding. */
static int idn_flags = AI_IDN | AI_CANONIDN;
+/* Set to 0 by --no-addrconfig. */
+static int addrconfig_flags = AI_ADDRCONFIG;
+
/* Print the version information. */
static void
print_version (FILE *stream, struct argp_state *state)
@@ -346,7 +351,7 @@ 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
+ hint.ai_flags = (AI_V4MAPPED | addrconfig_flags | AI_CANONNAME
| idn_flags | xflags);
hint.ai_family = af;
@@ -905,6 +910,10 @@ parse_option (int key, char *arg, struct argp_state *state)
idn_flags = 0;
break;
+ case 'A':
+ addrconfig_flags = 0;
+ break;
+
default:
return ARGP_ERR_UNKNOWN;
}
--
2.37.2
next prev parent reply other threads:[~2022-09-13 14:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-13 14:35 [PATCH 0/2] Fix nss/tst-nss-files-hosts-long on single-stack hosts (bug 24816) Florian Weimer
2022-09-13 14:35 ` Florian Weimer [this message]
2022-09-14 22:34 ` [PATCH 1/2] nss: Implement --no-addrconfig option for getent Carlos O'Donell
2022-09-15 12:11 ` Florian Weimer
2022-09-13 14:35 ` [PATCH 2/2] nss: Fix tst-nss-files-hosts-long on single-stack hosts (bug 24816) Florian Weimer
2022-09-14 22:35 ` Carlos O'Donell
2022-09-14 9:42 ` [PATCH 0/2] Fix nss/tst-nss-files-hosts-long " Carlos O'Donell
2022-09-14 9:54 ` Florian Weimer
2022-09-14 22:26 ` Carlos O'Donell
2022-09-15 12:37 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=462265b0ce37bd57b9304d873e9bccdb1cc4a199.1663079342.git.fweimer@redhat.com \
--to=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).