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: =?utf-8?b?T25kxZllaiBCw61sa2E=?= X-Patchwork-Id: 414930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BD7421401AA for ; Wed, 26 Nov 2014 11:17:31 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=VHAOHHNN7AyB89VAcYQ0DpdWhLbkL pWi7LC4VR1R/U2lC6CPYBWtzKg2YT0P+CtNFSlpAexl8HvVxx1KR+WJph5dqr4aV /TJYfuXuhn+TCCsJu8GtKJn9hvTIT9dq+QewvO5lc7dV0t7G30a0A2YHuoHbNah7 /1iZWpHa1HBPNs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=xvI6RctkbXel1Pay9Cx7gdK4HW4=; b=SWI snzpByqH214/KP0UDwTb7G6HFCFI5Iu6PyKQF0sNn+emNJunN4/uinkgYmX7f3dQ HWcy4ECUlZPNMYRF7JW/Y+IPWaMOJ9G3tVWEvsVLFhpG5fYZHcR+v/dFZh20iZJG BTSYp31gz39bhBfXz1pOC0wgGxFGHVlWPFiM59T4= 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) {