From patchwork Wed Nov 26 00:17:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Bilka X-Patchwork-Id: 3920 Received: (qmail 20258 invoked by alias); 26 Nov 2014 00:17:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 20244 invoked by uid 89); 26 Nov 2014 00:17:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, SPF_NEUTRAL autolearn=no version=3.3.2 X-HELO: popelka.ms.mff.cuni.cz Date: Wed, 26 Nov 2014 01:17:13 +0100 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: libc-alpha@sourceware.org Subject: [PATCH][BZ #14799] Allow to disable options in RES_OPTIONS Message-ID: <20141126001713.GA27914@domone> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Hi, this bug ticket ask to make posible to disable ip6 and other options by RES_OPTIONS environment variable. Rather to add them manually I added a check so no-option will do opposite of option. OK to commit? [BZ #14799] * resolv/res_init.c (res_setoptions): Detect no- prefix to disable option. diff --git a/resolv/res_init.c b/resolv/res_init.c index ea133f8..9ea43e9 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -533,26 +533,32 @@ res_setoptions(res_state statp, const char *options, const char *source) { #define STRnLEN(str) str, sizeof (str) - 1 { STRnLEN ("inet6"), 0, RES_USE_INET6 }, { STRnLEN ("ip6-bytestring"), 0, RES_USEBSTRING }, - { STRnLEN ("no-ip6-dotint"), 0, RES_NOIP6DOTINT }, { STRnLEN ("ip6-dotint"), 1, ~RES_NOIP6DOTINT }, { STRnLEN ("rotate"), 0, RES_ROTATE }, - { STRnLEN ("no-check-names"), 0, RES_NOCHECKNAME }, + { STRnLEN ("check-names"), 1, ~RES_NOCHECKNAME }, { STRnLEN ("edns0"), 0, RES_USE_EDNS0 }, { STRnLEN ("single-request-reopen"), 0, RES_SNGLKUPREOP }, { STRnLEN ("single-request"), 0, RES_SNGLKUP }, { STRnLEN ("no_tld_query"), 0, RES_NOTLDQUERY }, - { STRnLEN ("no-tld-query"), 0, RES_NOTLDQUERY }, + { STRnLEN ("tld-query"), 1, ~RES_NOTLDQUERY }, { STRnLEN ("use-vc"), 0, RES_USEVC } }; #define noptions (sizeof (options) / sizeof (options[0])) int i; + int invert = 0; + if (strncmp (cp, "no-", 3)) + { + cp += 3; + invert = 1; + } + for (i = 0; i < noptions; ++i) if (strncmp (cp, options[i].str, options[i].len) == 0) { - if (options[i].clear) - statp->options &= options[i].flag; + if (options[i].clear ^ invert) + statp->options &= options[i].flag ^ invert; else - statp->options |= options[i].flag; + statp->options |= options[i].flag ^ invert; break; } if (i == noptions) {