Hi,

Once the pipe(2) is opened between the parent and child rpath/wpath is not
needed in order for communication, nevertheless we cannot drop wpath since
we may need O_WRONLY to write on /var/log/wtmp through logwtmp(3) a little bit
later. In this case we can drop the first pledge(2) to "stdio wpath settime".

Since "rpath" is not needed anymore we can also drop to "stdio" on the final
pledge(2).

All parameters have been tested including firing up a RFC 868 time server with
inetd(8) to test -o. Overriding TZ= also worked as expected with this change.

Comments? OK?

Index: rdate.c
===================================================================
RCS file: /cvs/src/usr.sbin/rdate/rdate.c,v
retrieving revision 1.35
diff -u -p -u -r1.35 rdate.c
--- rdate.c     23 Dec 2015 19:13:52 -0000      1.35
+++ rdate.c     14 Aug 2018 11:27:41 -0000
@@ -167,7 +167,7 @@ main(int argc, char **argv)
                exit(0);
        }
 
-       if (pledge("stdio rpath wpath settime", NULL) == -1)
+       if (pledge("stdio wpath settime", NULL) == -1)
                err(1, "pledge");
 
        close(p[1]);    /* write side of pipe */
@@ -197,7 +197,7 @@ main(int argc, char **argv)
                }
        }
 
-       if (pledge("stdio rpath", NULL) == -1)
+       if (pledge("stdio", NULL) == -1)
                err(1, "pledge");
 
        if (!silent) {

Reply via email to