Hi Martin,
Using the same logic of my previous patch, now monitor works with
"stdio" when -n is used and "stdio rpath dns" otherwhise. Unfortunately
for newroute (add/delete/change) it still needs the 3 of them since when
it detects it's a host (instead of an IP address) it will always contact
the resolver, no matter -n is used or not:
Index: route.c
===================================================================
RCS file: /cvs/src/sbin/route/route.c,v
retrieving revision 1.179
diff -u -p -u -r1.179 route.c
--- route.c 25 Oct 2015 09:37:08 -0000 1.179
+++ route.c 16 Nov 2015 11:07:24 -0000
@@ -224,17 +224,6 @@ main(int argc, char **argv)
case K_FLUSH:
exit(flushroutes(argc, argv));
break;
- }
-
- if (nflag) {
- if (pledge("stdio rpath dns", NULL) == -1)
- err(1, "pledge");
- } else {
- if (pledge("stdio rpath dns", NULL) == -1)
- err(1, "pledge");
- }
-
- switch (kw) {
case K_GET:
uid = 0;
/* FALLTHROUGH */
@@ -330,7 +319,7 @@ flushroutes(int argc, char **argv)
}
if (nflag) {
- if (pledge("stdio rpath dns", NULL) == -1)
+ if (pledge("stdio", NULL) == -1)
err(1, "pledge");
} else {
if (pledge("stdio rpath dns", NULL) == -1)
@@ -446,6 +435,9 @@ newroute(int argc, char **argv)
uint8_t prio = 0;
struct hostent *hp = NULL;
+ if (pledge("stdio rpath dns", NULL) == -1)
+ err(1, "pledge");
+
if (uid)
errx(1, "must be root to alter routing table");
cmd = argv[0];
@@ -1090,8 +1082,13 @@ monitor(int argc, char *argv[])
char msg[2048];
time_t now;
- if (pledge("stdio rpath dns", NULL) == -1)
- err(1, "pledge");
+ if (nflag) {
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+ } else {
+ if (pledge("stdio rpath dns", NULL) == -1)
+ err(1, "pledge");
+ }
verbose = 1;
if (debugonly) {
Index: show.c
===================================================================
RCS file: /cvs/src/sbin/route/show.c,v
retrieving revision 1.102
diff -u -p -u -r1.102 show.c
--- show.c 23 Oct 2015 15:03:25 -0000 1.102
+++ show.c 16 Nov 2015 11:07:33 -0000
@@ -146,7 +146,7 @@ p_rttables(int af, u_int tableid, int ha
}
if (nflag) {
- if (pledge("stdio rpath dns", NULL) == -1)
+ if (pledge("stdio", NULL) == -1)
err(1, "pledge");
} else {
if (pledge("stdio rpath dns", NULL) == -1)
On 16/11/2015 10:22, Martin Pieuchot wrote:
> On 16/11/15(Mon) 10:03, Ricardo Mestre wrote:
>> Hello!
>>
>> Like Benoit said, monitor still needs dns all the time, but since pledge
>> was being called there again with dns pledge then I thought it wouldn't
>> abort. Taking that into consideration and looking at it a little bit
>> more, how about this?
>
> IMHO this doesn't make sense if I explicitly say "route -n monitor" I'd
> prefer not to have any address resolved....
>
> Otherwise I just say "route monitor".
>
> I'd add that on the list of bugs discovered by pledge(2).
>