* [PATCH v4] Add RES_OPTIONS support for resolv.conf options overriding
@ 2017-04-30 20:52 Stefan Sedich
2017-04-30 20:54 ` Stefan Sedich
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Sedich @ 2017-04-30 20:52 UTC (permalink / raw)
To: musl; +Cc: Stefan Sedich
Currently glibc supports using the RES_OPTIONS environment variable
to customize the resolv.conf options on a per-process basis, this
adds the same support to musl
---
Changed in v4:
- apply feedback from Alexander
src/network/resolvconf.c | 48 ++++++++++++++++++++++++++++++------------------
1 file changed, 30 insertions(+), 18 deletions(-)
diff --git a/src/network/resolvconf.c b/src/network/resolvconf.c
index 4c3e4c4b..16ca395f 100644
--- a/src/network/resolvconf.c
+++ b/src/network/resolvconf.c
@@ -5,6 +5,30 @@
#include <string.h>
#include <netinet/in.h>
+void __parse_resolv_opts(struct resolvconf *conf, const char *opts)
+{
+ char *p, *z;
+
+ p = strstr(opts, "ndots:");
+ if (p && isdigit(p[6])) {
+ p += 6;
+ unsigned long x = strtoul(p, &z, 10);
+ if (z != p) conf->ndots = x > 15 ? 15 : x;
+ }
+ p = strstr(opts, "attempts:");
+ if (p && isdigit(p[9])) {
+ p += 9;
+ unsigned long x = strtoul(p, &z, 10);
+ if (z != p) conf->attempts = x > 10 ? 10 : x;
+ }
+ p = strstr(opts, "timeout:");
+ if (p && (isdigit(p[8]) || p[8]=='.')) {
+ p += 8;
+ unsigned long x = strtoul(p, &z, 10);
+ if (z != p) conf->timeout = x > 60 ? 60 : x;
+ }
+}
+
int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
{
char line[256];
@@ -38,24 +62,7 @@ int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
continue;
}
if (!strncmp(line, "options", 7) && isspace(line[7])) {
- p = strstr(line, "ndots:");
- if (p && isdigit(p[6])) {
- p += 6;
- unsigned long x = strtoul(p, &z, 10);
- if (z != p) conf->ndots = x > 15 ? 15 : x;
- }
- p = strstr(line, "attempts:");
- if (p && isdigit(p[9])) {
- p += 9;
- unsigned long x = strtoul(p, &z, 10);
- if (z != p) conf->attempts = x > 10 ? 10 : x;
- }
- p = strstr(line, "timeout:");
- if (p && (isdigit(p[8]) || p[8]=='.')) {
- p += 8;
- unsigned long x = strtoul(p, &z, 10);
- if (z != p) conf->timeout = x > 60 ? 60 : x;
- }
+ __parse_resolv_opts(conf, line);
continue;
}
if (!strncmp(line, "nameserver", 10) && isspace(line[10])) {
@@ -89,5 +96,10 @@ no_resolv_conf:
conf->nns = nns;
+ if (!libc.secure) {
+ const char *opts = getenv("RES_OPTIONS");
+ if (opts) __parse_resolv_opts(conf, opts);
+ }
+
return 0;
}
--
2.11.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] Add RES_OPTIONS support for resolv.conf options overriding
2017-04-30 20:52 [PATCH v4] Add RES_OPTIONS support for resolv.conf options overriding Stefan Sedich
@ 2017-04-30 20:54 ` Stefan Sedich
2017-06-05 20:33 ` Stefan Sedich
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Sedich @ 2017-04-30 20:54 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 3510 bytes --]
Submitting final version of this patch, if we have any activity around
deciding it we want to parse the options more strictly they can be
addressed separately.
- Stefan
On Sun, Apr 30, 2017 at 1:53 PM Stefan Sedich <stefan.sedich@gmail.com>
wrote:
> Currently glibc supports using the RES_OPTIONS environment variable
> to customize the resolv.conf options on a per-process basis, this
> adds the same support to musl
> ---
> Changed in v4:
> - apply feedback from Alexander
>
> src/network/resolvconf.c | 48
> ++++++++++++++++++++++++++++++------------------
> 1 file changed, 30 insertions(+), 18 deletions(-)
>
> diff --git a/src/network/resolvconf.c b/src/network/resolvconf.c
> index 4c3e4c4b..16ca395f 100644
> --- a/src/network/resolvconf.c
> +++ b/src/network/resolvconf.c
> @@ -5,6 +5,30 @@
> #include <string.h>
> #include <netinet/in.h>
>
> +void __parse_resolv_opts(struct resolvconf *conf, const char *opts)
> +{
> + char *p, *z;
> +
> + p = strstr(opts, "ndots:");
> + if (p && isdigit(p[6])) {
> + p += 6;
> + unsigned long x = strtoul(p, &z, 10);
> + if (z != p) conf->ndots = x > 15 ? 15 : x;
> + }
> + p = strstr(opts, "attempts:");
> + if (p && isdigit(p[9])) {
> + p += 9;
> + unsigned long x = strtoul(p, &z, 10);
> + if (z != p) conf->attempts = x > 10 ? 10 : x;
> + }
> + p = strstr(opts, "timeout:");
> + if (p && (isdigit(p[8]) || p[8]=='.')) {
> + p += 8;
> + unsigned long x = strtoul(p, &z, 10);
> + if (z != p) conf->timeout = x > 60 ? 60 : x;
> + }
> +}
> +
> int __get_resolv_conf(struct resolvconf *conf, char *search, size_t
> search_sz)
> {
> char line[256];
> @@ -38,24 +62,7 @@ int __get_resolv_conf(struct resolvconf *conf, char
> *search, size_t search_sz)
> continue;
> }
> if (!strncmp(line, "options", 7) && isspace(line[7])) {
> - p = strstr(line, "ndots:");
> - if (p && isdigit(p[6])) {
> - p += 6;
> - unsigned long x = strtoul(p, &z, 10);
> - if (z != p) conf->ndots = x > 15 ? 15 : x;
> - }
> - p = strstr(line, "attempts:");
> - if (p && isdigit(p[9])) {
> - p += 9;
> - unsigned long x = strtoul(p, &z, 10);
> - if (z != p) conf->attempts = x > 10 ? 10 :
> x;
> - }
> - p = strstr(line, "timeout:");
> - if (p && (isdigit(p[8]) || p[8]=='.')) {
> - p += 8;
> - unsigned long x = strtoul(p, &z, 10);
> - if (z != p) conf->timeout = x > 60 ? 60 :
> x;
> - }
> + __parse_resolv_opts(conf, line);
> continue;
> }
> if (!strncmp(line, "nameserver", 10) && isspace(line[10]))
> {
> @@ -89,5 +96,10 @@ no_resolv_conf:
>
> conf->nns = nns;
>
> + if (!libc.secure) {
> + const char *opts = getenv("RES_OPTIONS");
> + if (opts) __parse_resolv_opts(conf, opts);
> + }
> +
> return 0;
> }
> --
> 2.11.0
>
>
[-- Attachment #2: Type: text/html, Size: 4775 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] Add RES_OPTIONS support for resolv.conf options overriding
2017-04-30 20:54 ` Stefan Sedich
@ 2017-06-05 20:33 ` Stefan Sedich
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Sedich @ 2017-06-05 20:33 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 3964 bytes --]
Bumping this one up, was there any interest in merging in the addition of
supporting RES_OPTIONS for now? can then discuss further if the parsing
should be improved as per the rest of the thread, I would love to at least
get RES_OPTIONS in for now :)!
- Stefan
On Sun, Apr 30, 2017 at 1:54 PM Stefan Sedich <stefan.sedich@gmail.com>
wrote:
> Submitting final version of this patch, if we have any activity around
> deciding it we want to parse the options more strictly they can be
> addressed separately.
>
>
>
> - Stefan
>
> On Sun, Apr 30, 2017 at 1:53 PM Stefan Sedich <stefan.sedich@gmail.com>
> wrote:
>
>> Currently glibc supports using the RES_OPTIONS environment variable
>> to customize the resolv.conf options on a per-process basis, this
>> adds the same support to musl
>> ---
>> Changed in v4:
>> - apply feedback from Alexander
>>
>> src/network/resolvconf.c | 48
>> ++++++++++++++++++++++++++++++------------------
>> 1 file changed, 30 insertions(+), 18 deletions(-)
>>
>> diff --git a/src/network/resolvconf.c b/src/network/resolvconf.c
>> index 4c3e4c4b..16ca395f 100644
>> --- a/src/network/resolvconf.c
>> +++ b/src/network/resolvconf.c
>> @@ -5,6 +5,30 @@
>> #include <string.h>
>> #include <netinet/in.h>
>>
>> +void __parse_resolv_opts(struct resolvconf *conf, const char *opts)
>> +{
>> + char *p, *z;
>> +
>> + p = strstr(opts, "ndots:");
>> + if (p && isdigit(p[6])) {
>> + p += 6;
>> + unsigned long x = strtoul(p, &z, 10);
>> + if (z != p) conf->ndots = x > 15 ? 15 : x;
>> + }
>> + p = strstr(opts, "attempts:");
>> + if (p && isdigit(p[9])) {
>> + p += 9;
>> + unsigned long x = strtoul(p, &z, 10);
>> + if (z != p) conf->attempts = x > 10 ? 10 : x;
>> + }
>> + p = strstr(opts, "timeout:");
>> + if (p && (isdigit(p[8]) || p[8]=='.')) {
>> + p += 8;
>> + unsigned long x = strtoul(p, &z, 10);
>> + if (z != p) conf->timeout = x > 60 ? 60 : x;
>> + }
>> +}
>> +
>> int __get_resolv_conf(struct resolvconf *conf, char *search, size_t
>> search_sz)
>> {
>> char line[256];
>> @@ -38,24 +62,7 @@ int __get_resolv_conf(struct resolvconf *conf, char
>> *search, size_t search_sz)
>> continue;
>> }
>> if (!strncmp(line, "options", 7) && isspace(line[7])) {
>> - p = strstr(line, "ndots:");
>> - if (p && isdigit(p[6])) {
>> - p += 6;
>> - unsigned long x = strtoul(p, &z, 10);
>> - if (z != p) conf->ndots = x > 15 ? 15 : x;
>> - }
>> - p = strstr(line, "attempts:");
>> - if (p && isdigit(p[9])) {
>> - p += 9;
>> - unsigned long x = strtoul(p, &z, 10);
>> - if (z != p) conf->attempts = x > 10 ? 10
>> : x;
>> - }
>> - p = strstr(line, "timeout:");
>> - if (p && (isdigit(p[8]) || p[8]=='.')) {
>> - p += 8;
>> - unsigned long x = strtoul(p, &z, 10);
>> - if (z != p) conf->timeout = x > 60 ? 60 :
>> x;
>> - }
>> + __parse_resolv_opts(conf, line);
>> continue;
>> }
>> if (!strncmp(line, "nameserver", 10) &&
>> isspace(line[10])) {
>> @@ -89,5 +96,10 @@ no_resolv_conf:
>>
>> conf->nns = nns;
>>
>> + if (!libc.secure) {
>> + const char *opts = getenv("RES_OPTIONS");
>> + if (opts) __parse_resolv_opts(conf, opts);
>> + }
>> +
>> return 0;
>> }
>> --
>> 2.11.0
>>
>>
[-- Attachment #2: Type: text/html, Size: 5452 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-05 20:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-30 20:52 [PATCH v4] Add RES_OPTIONS support for resolv.conf options overriding Stefan Sedich
2017-04-30 20:54 ` Stefan Sedich
2017-06-05 20:33 ` Stefan Sedich
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).