Re: sys/file.h include in bin and sbin

2014-11-19 Thread Philip Guenther
On Wed, Nov 19, 2014 at 1:00 PM, Ted Unangst  wrote:
> The sys/file.h include is likely not the correct include for any
> userland code. Most cases it's unneeded; in other cases fcntl.h is the
> correct header.

Yep.  Diff looks good; ok guenther@



Re: fts: optimize by using fstatat instead of lstat

2014-11-19 Thread Philip Guenther
On Wed, 19 Nov 2014, enh wrote:
> On Tue, Nov 18, 2014 at 10:55 PM, Philip Guenther  wrote:
> > enh, this look as good in the perf measurement cited in that googlesource
> > link?
> 
> yes. performance seems roughly identical. thanks!

Committed, which leads to the next diff: use O_CLOEXEC on all internal 
fds, O_DIRECTORY when opening a directory other than ".", and drop the 3rd 
argument to open() as unnecessary when O_CREAT isn't used.

(I think doug@ wondered about using O_CLOEXEC before but I demurred then 
because these fds _are_ accessible to applications via members in the 
visible header file and we had lower-hanging fruit to pick then, but 
seeing that FreeBSD has done this, maybe it's safe?

(I've pinged sthen@ for a ports src scan...)

Philip Guenther


Index: gen/fts.c
===
RCS file: /cvs/src/lib/libc/gen/fts.c,v
retrieving revision 1.48
diff -u -p -r1.48 fts.c
--- gen/fts.c   20 Nov 2014 04:14:15 -  1.48
+++ gen/fts.c   20 Nov 2014 04:18:31 -
@@ -159,7 +159,8 @@ fts_open(char * const *argv, int options
 * and ".." are all fairly nasty problems.  Note, if we can't get the
 * descriptor we run anyway, just more slowly.
 */
-   if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = open(".", O_RDONLY, 0)) < 0)
+   if (!ISSET(FTS_NOCHDIR) &&
+   (sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC)) < 0)
SET(FTS_NOCHDIR);
 
if (nitems == 0)
@@ -284,7 +285,8 @@ fts_read(FTS *sp)
(p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
p->fts_info = fts_stat(sp, p, 1, -1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
-   if ((p->fts_symfd = open(".", O_RDONLY, 0)) < 0) {
+   if ((p->fts_symfd =
+   open(".", O_RDONLY | O_CLOEXEC)) < 0) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
} else
@@ -374,7 +376,7 @@ next:   tmp = p;
p->fts_info = fts_stat(sp, p, 1, -1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd =
-   open(".", O_RDONLY, 0)) < 0) {
+   open(".", O_RDONLY | O_CLOEXEC)) < 0) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
} else
@@ -513,7 +515,7 @@ fts_children(FTS *sp, int instr)
ISSET(FTS_NOCHDIR))
return (sp->fts_child = fts_build(sp, instr));
 
-   if ((fd = open(".", O_RDONLY, 0)) < 0)
+   if ((fd = open(".", O_RDONLY | O_CLOEXEC)) < 0)
return (NULL);
sp->fts_child = fts_build(sp, instr);
if (fchdir(fd)) {
@@ -1026,7 +1028,7 @@ fts_safe_changedir(FTS *sp, FTSENT *p, i
newfd = fd;
if (ISSET(FTS_NOCHDIR))
return (0);
-   if (fd < 0 && (newfd = open(path, O_RDONLY, 0)) < 0)
+   if (fd < 0 && (newfd = open(path, O_RDONLY|O_DIRECTORY|O_CLOEXEC)) < 0)
return (-1);
if (fstat(newfd, &sb)) {
ret = -1;



Re: fingerd bug isn't

2014-11-19 Thread Theo de Raadt
> I don't think this qualifies as a bug. Using the wrong client is user
> error. fingerd should not be responsible for filtering anything you
> shouldn't send it.

Completely agree.  1990 was a tough time with these issues.


> Index: fingerd.8
> ===
> RCS file: /cvs/src/libexec/fingerd/fingerd.8,v
> retrieving revision 1.19
> diff -u -p -r1.19 fingerd.8
> --- fingerd.8 14 Nov 2013 08:50:04 -  1.19
> +++ fingerd.8 20 Nov 2014 03:31:21 -
> @@ -166,18 +166,3 @@ The
>  .Nm
>  command appeared in
>  .Bx 4.3 .
> -.Sh BUGS
> -Connecting directly to the server from a
> -.Tn TIP
> -or an equally narrow-minded
> -.Tn TELNET Ns -protocol
> -user program can result
> -in meaningless attempts at option negotiation being sent to the
> -server, which will foul up the command line interpretation.
> -.Nm
> -should be taught to filter out
> -.Tn IAC Ns 's
> -and perhaps even respond
> -negatively
> -.Pq Tn IAC WON'T
> -to all option commands received.
> 



fingerd bug isn't

2014-11-19 Thread Ted Unangst
I don't think this qualifies as a bug. Using the wrong client is user
error. fingerd should not be responsible for filtering anything you
shouldn't send it.

Index: fingerd.8
===
RCS file: /cvs/src/libexec/fingerd/fingerd.8,v
retrieving revision 1.19
diff -u -p -r1.19 fingerd.8
--- fingerd.8   14 Nov 2013 08:50:04 -  1.19
+++ fingerd.8   20 Nov 2014 03:31:21 -
@@ -166,18 +166,3 @@ The
 .Nm
 command appeared in
 .Bx 4.3 .
-.Sh BUGS
-Connecting directly to the server from a
-.Tn TIP
-or an equally narrow-minded
-.Tn TELNET Ns -protocol
-user program can result
-in meaningless attempts at option negotiation being sent to the
-server, which will foul up the command line interpretation.
-.Nm
-should be taught to filter out
-.Tn IAC Ns 's
-and perhaps even respond
-negatively
-.Pq Tn IAC WON'T
-to all option commands received.



Re: patch: tedu sccs support

2014-11-19 Thread Ted Unangst
On Wed, Nov 19, 2014 at 19:25, Tobias Stoeckmann wrote:
> Hi,
> 
> as we don't even have the "get" command in base, there is no need to
> support SCCS files anymore.  I also remember that we removed the
> SCCS IDs from source files so...
> 
> Time to tedu sccs?
> 

Are we still tracking upstream patch in any way? I think we've
diverged in a few places, but there still is an upstream, yes?

I certainly don't object to killing sccs support, just making sure it
won't come back in some future update.



Re: patch: tedu sccs support

2014-11-19 Thread Ingo Schwarze
Hi Tobias,

Tobias Stoeckmann wrote on Wed, Nov 19, 2014 at 07:25:47PM +0100:

> as we don't even have the "get" command in base, there is no need to
> support SCCS files anymore.  I also remember that we removed the
> SCCS IDs from source files so...

I look at CSRG SCCS files fairly often and would like to have a
better sccs {annotate,checkout,diff} tool, put patching based
on SCCS files is indeed pointless nowadays.

> Time to tedu sccs?

ok schwarze@
  Ingo


> Index: common.h
> ===
> RCS file: /cvs/src/usr.bin/patch/common.h,v
> retrieving revision 1.26
> diff -u -p -r1.26 common.h
> --- common.h  11 Mar 2006 19:41:30 -  1.26
> +++ common.h  19 Nov 2014 18:23:01 -
> @@ -39,10 +39,6 @@
>  #define MAXLINELEN 8192
>  #define BUFFERSIZE 1024
>  
> -#define SCCSPREFIX "s."
> -#define GET "get -e %s"
> -#define SCCSDIFF "get -p %s | diff - %s >/dev/null"
> -
>  #define RCSSUFFIX ",v"
>  #define CHECKOUT "co -l %s"
>  #define RCSDIFF "rcsdiff %s > /dev/null"
> Index: inp.c
> ===
> RCS file: /cvs/src/usr.bin/patch/inp.c,v
> retrieving revision 1.39
> diff -u -p -r1.39 inp.c
> --- inp.c 15 Nov 2014 16:35:47 -  1.39
> +++ inp.c 19 Nov 2014 18:23:01 -
> @@ -163,7 +163,7 @@ plan_a(const char *filename)
>   }
>   if (statfailed && check_only)
>   fatal("%s not found, -C mode, can't probe further\n", filename);
> - /* For nonexistent or read-only files, look for RCS or SCCS versions.  
> */
> + /* For nonexistent or read-only files, look for RCS versions.  */
>   if (statfailed ||
>   /* No one can write to it.  */
>   (filestat.st_mode & 0222) == 0 ||
> @@ -187,11 +187,6 @@ plan_a(const char *filename)
>   snprintf(buf, sizeof buf, CHECKOUT, filename);
>   snprintf(lbuf, sizeof lbuf, RCSDIFF, filename);
>   cs = "RCS";
> - } else if (try("%s/SCCS/%s%s", filedir, SCCSPREFIX, filebase) ||
> - try("%s/%s%s", filedir, SCCSPREFIX, filebase)) {
> - snprintf(buf, sizeof buf, GET, s);
> - snprintf(lbuf, sizeof lbuf, SCCSDIFF, s, filename);
> - cs = "SCCS";
>   } else if (statfailed)
>   fatal("can't find %s\n", filename);
>   /*
> Index: patch.1
> ===
> RCS file: /cvs/src/usr.bin/patch/patch.1,v
> retrieving revision 1.27
> diff -u -p -r1.27 patch.1
> --- patch.1   15 Apr 2014 06:26:54 -  1.27
> +++ patch.1   19 Nov 2014 18:23:01 -
> @@ -481,8 +481,8 @@ the shortest basename, and the shortest 
>  .It
>  If no file exists,
>  .Nm
> -checks for the existence of the files in an SCCS or RCS directory
> -(using the appropriate prefix or suffix) using the criteria specified
> +checks for the existence of the files in an RCS directory
> +(using the appropriate suffix) using the criteria specified
>  above.
>  If found,
>  .Nm
> Index: pch.c
> ===
> RCS file: /cvs/src/usr.bin/patch/pch.c,v
> retrieving revision 1.43
> diff -u -p -r1.43 pch.c
> --- pch.c 18 Nov 2014 17:03:35 -  1.43
> +++ pch.c 19 Nov 2014 18:23:02 -
> @@ -1451,7 +1451,7 @@ posix_name(const struct file_name *names
>   if (path == NULL && !assume_exists) {
>   /*
>* No files found, look for something we can checkout from
> -  * RCS/SCCS dirs.  Same order as above.
> +  * RCS dirs.  Same order as above.
>*/
>   for (i = 0; i < MAX_FILE; i++) {
>   if (names[i].path != NULL &&
> Index: util.c
> ===
> RCS file: /cvs/src/usr.bin/patch/util.c,v
> retrieving revision 1.36
> diff -u -p -r1.36 util.c
> --- util.c26 Nov 2013 13:19:07 -  1.36
> +++ util.c19 Nov 2014 18:23:02 -
> @@ -374,7 +374,7 @@ fetchname(const char *at, bool *exists, 
>  }
>  
>  /*
> - * Takes the name returned by fetchname and looks in RCS/SCCS directories
> + * Takes the name returned by fetchname and looks in RCS directory
>   * for a checked in version.
>   */
>  char *
> @@ -391,9 +391,7 @@ checked_in(char *file)
>  
>   if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) ||
>   try("%s/RCS/%s%s", filedir, filebase, "") ||
> - try("%s/%s%s", filedir, filebase, RCSSUFFIX) ||
> - try("%s/SCCS/%s%s", filedir, SCCSPREFIX, filebase) ||
> - try("%s/%s%s", filedir, SCCSPREFIX, filebase))
> + try("%s/%s%s", filedir, filebase, RCSSUFFIX))
>   return file;
>  
>   return NULL;



sys/file.h include in bin and sbin

2014-11-19 Thread Ted Unangst
The sys/file.h include is likely not the correct include for any
userland code. Most cases it's unneeded; in other cases fcntl.h is the
correct header.

Index: bin/ed/buf.c
===
RCS file: /cvs/src/bin/ed/buf.c,v
retrieving revision 1.19
diff -u -p -r1.19 buf.c
--- bin/ed/buf.c27 Oct 2009 23:59:21 -  1.19
+++ bin/ed/buf.c19 Nov 2014 20:57:00 -
@@ -29,7 +29,6 @@
  * SUCH DAMAGE.
  */
 
-#include 
 #include 
 
 #include "ed.h"
Index: bin/ksh/history.c
===
RCS file: /cvs/src/bin/ksh/history.c,v
retrieving revision 1.39
diff -u -p -r1.39 history.c
--- bin/ksh/history.c   19 May 2010 17:36:08 -  1.39
+++ bin/ksh/history.c   19 Nov 2014 20:57:04 -
@@ -19,7 +19,6 @@
 #include 
 
 #ifdef HISTORY
-# include 
 # include 
 
 /*
Index: sbin/fsck_ext2fs/setup.c
===
RCS file: /cvs/src/sbin/fsck_ext2fs/setup.c,v
retrieving revision 1.23
diff -u -p -r1.23 setup.c
--- sbin/fsck_ext2fs/setup.c13 Jul 2014 16:08:53 -  1.23
+++ sbin/fsck_ext2fs/setup.c19 Nov 2014 20:56:05 -
@@ -40,7 +40,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
Index: sbin/mountd/mountd.c
===
RCS file: /cvs/src/sbin/mountd/mountd.c,v
retrieving revision 1.77
diff -u -p -r1.77 mountd.c
--- sbin/mountd/mountd.c22 Oct 2014 13:31:04 -  1.77
+++ sbin/mountd/mountd.c19 Nov 2014 20:56:07 -
@@ -34,7 +34,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
Index: sbin/newfs_ext2fs/newfs_ext2fs.c
===
RCS file: /cvs/src/sbin/newfs_ext2fs/newfs_ext2fs.c,v
retrieving revision 1.13
diff -u -p -r1.13 newfs_ext2fs.c
--- sbin/newfs_ext2fs/newfs_ext2fs.c29 Jun 2014 00:32:50 -  1.13
+++ sbin/newfs_ext2fs/newfs_ext2fs.c19 Nov 2014 20:57:42 -
@@ -37,7 +37,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -46,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
Index: sbin/pflogd/pflogd.c
===
RCS file: /cvs/src/sbin/pflogd/pflogd.c,v
retrieving revision 1.49
diff -u -p -r1.49 pflogd.c
--- sbin/pflogd/pflogd.c6 Nov 2012 02:50:47 -   1.49
+++ sbin/pflogd/pflogd.c19 Nov 2014 20:56:10 -
@@ -32,7 +32,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
Index: sbin/ping/ping.c
===
RCS file: /cvs/src/sbin/ping/ping.c,v
retrieving revision 1.112
diff -u -p -r1.112 ping.c
--- sbin/ping/ping.c25 Oct 2014 03:18:13 -  1.112
+++ sbin/ping/ping.c19 Nov 2014 20:55:07 -
@@ -54,7 +54,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
Index: sbin/scsi/scsi.c
===
RCS file: /cvs/src/sbin/scsi/scsi.c,v
retrieving revision 1.28
diff -u -p -r1.28 scsi.c
--- sbin/scsi/scsi.c12 Nov 2013 04:59:02 -  1.28
+++ sbin/scsi/scsi.c19 Nov 2014 20:58:14 -
@@ -46,13 +46,13 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



Re: TCP, UDP, Multicast and Broadcast are invited to a party...

2014-11-19 Thread Claudio Jeker
On Wed, Nov 19, 2014 at 04:50:23PM +0100, Martin Pieuchot wrote:
> ...and in the end, they believe the mbuf(9) flags!
> 
> There's no good reason to recheck if the IP destination address is a
> multicast or broadcast in {tcp,udp}_input().  We've already done that
> when the packet got delivered.
> 
> So the diff below makes sure the multicast flag is set (jut be as
> paranoid as with broadcast) and check for these flags in the upper
> layer.
> 
> I verified with crafted packets that this works, the goal of this diff
> is obviously to reduce the usage of "rcvif" pointers (and simplify
> in_broadcast() afterward).
> 
> Comments, ok?
> 

Ok

> 
> Index: netinet/ip_input.c
> ===
> RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
> retrieving revision 1.241
> diff -u -p -r1.241 ip_input.c
> --- netinet/ip_input.c5 Nov 2014 14:03:02 -   1.241
> +++ netinet/ip_input.c19 Nov 2014 15:39:59 -
> @@ -348,6 +348,10 @@ ipv4_input(struct mbuf *m)
>  
>   if (IN_MULTICAST(ip->ip_dst.s_addr)) {
>   struct in_multi *inm;
> +
> + /* Paranoia. */
> + m->m_flags |= M_MCAST;
> +
>  #ifdef MROUTING
>   if (ipmforwarding && ip_mrouter) {
>   if (m->m_flags & M_EXT) {
> Index: netinet/tcp_input.c
> ===
> RCS file: /home/ncvs/src/sys/netinet/tcp_input.c,v
> retrieving revision 1.283
> diff -u -p -r1.283 tcp_input.c
> --- netinet/tcp_input.c   18 Nov 2014 02:37:31 -  1.283
> +++ netinet/tcp_input.c   19 Nov 2014 15:39:59 -
> @@ -394,7 +394,6 @@ tcp_input(struct mbuf *m, ...)
>  
>   /*
>* RFC1122 4.2.3.10, p. 104: discard bcast/mcast SYN
> -  * See below for AF specific multicast.
>*/
>   if (m->m_flags & (M_BCAST|M_MCAST))
>   goto drop;
> @@ -459,10 +458,6 @@ tcp_input(struct mbuf *m, ...)
>   switch (af) {
>   case AF_INET:
>   ip = mtod(m, struct ip *);
> - if (IN_MULTICAST(ip->ip_dst.s_addr) ||
> - in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif,
> - m->m_pkthdr.ph_rtableid))
> - goto drop;
>  #ifdef TCP_ECN
>   /* save ip_tos before clearing it for checksum */
>   iptos = ip->ip_tos;
> Index: netinet/udp_usrreq.c
> ===
> RCS file: /home/ncvs/src/sys/netinet/udp_usrreq.c,v
> retrieving revision 1.191
> diff -u -p -r1.191 udp_usrreq.c
> --- netinet/udp_usrreq.c  9 Nov 2014 22:05:08 -   1.191
> +++ netinet/udp_usrreq.c  19 Nov 2014 15:39:59 -
> @@ -400,16 +400,7 @@ udp_input(struct mbuf *m, ...)
>   }
>  #endif
>  
> -#ifdef INET6
> - if ((ip6 && IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) ||
> - (ip && IN_MULTICAST(ip->ip_dst.s_addr)) ||
> - (ip && in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif,
> - m->m_pkthdr.ph_rtableid))) {
> -#else /* INET6 */
> - if (IN_MULTICAST(ip->ip_dst.s_addr) ||
> - in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif,
> - m->m_pkthdr.ph_rtableid)) {
> -#endif /* INET6 */
> + if (m->m_flags & (M_BCAST|M_MCAST)) {
>   struct inpcb *last;
>   /*
>* Deliver a multicast or broadcast datagram to *all* sockets
> Index: netinet6/ip6_input.c
> ===
> RCS file: /home/ncvs/src/sys/netinet6/ip6_input.c,v
> retrieving revision 1.130
> diff -u -p -r1.130 ip6_input.c
> --- netinet6/ip6_input.c  14 Oct 2014 09:52:26 -  1.130
> +++ netinet6/ip6_input.c  19 Nov 2014 15:39:59 -
> @@ -398,6 +398,9 @@ ip6_input(struct mbuf *m)
>   if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
>   struct  in6_multi *in6m = 0;
>  
> + /* Paranoia. */
> + m->m_flags |= M_MCAST;
> +
>   in6_ifstat_inc(ifp, ifs6_in_mcast);
>   /*
>* See if we belong to the destination multicast group on the
> 

-- 
:wq Claudio



patch: tedu sccs support

2014-11-19 Thread Tobias Stoeckmann
Hi,

as we don't even have the "get" command in base, there is no need to
support SCCS files anymore.  I also remember that we removed the
SCCS IDs from source files so...

Time to tedu sccs?


Tobias

Index: common.h
===
RCS file: /cvs/src/usr.bin/patch/common.h,v
retrieving revision 1.26
diff -u -p -r1.26 common.h
--- common.h11 Mar 2006 19:41:30 -  1.26
+++ common.h19 Nov 2014 18:23:01 -
@@ -39,10 +39,6 @@
 #define MAXLINELEN 8192
 #define BUFFERSIZE 1024
 
-#define SCCSPREFIX "s."
-#define GET "get -e %s"
-#define SCCSDIFF "get -p %s | diff - %s >/dev/null"
-
 #define RCSSUFFIX ",v"
 #define CHECKOUT "co -l %s"
 #define RCSDIFF "rcsdiff %s > /dev/null"
Index: inp.c
===
RCS file: /cvs/src/usr.bin/patch/inp.c,v
retrieving revision 1.39
diff -u -p -r1.39 inp.c
--- inp.c   15 Nov 2014 16:35:47 -  1.39
+++ inp.c   19 Nov 2014 18:23:01 -
@@ -163,7 +163,7 @@ plan_a(const char *filename)
}
if (statfailed && check_only)
fatal("%s not found, -C mode, can't probe further\n", filename);
-   /* For nonexistent or read-only files, look for RCS or SCCS versions.  
*/
+   /* For nonexistent or read-only files, look for RCS versions.  */
if (statfailed ||
/* No one can write to it.  */
(filestat.st_mode & 0222) == 0 ||
@@ -187,11 +187,6 @@ plan_a(const char *filename)
snprintf(buf, sizeof buf, CHECKOUT, filename);
snprintf(lbuf, sizeof lbuf, RCSDIFF, filename);
cs = "RCS";
-   } else if (try("%s/SCCS/%s%s", filedir, SCCSPREFIX, filebase) ||
-   try("%s/%s%s", filedir, SCCSPREFIX, filebase)) {
-   snprintf(buf, sizeof buf, GET, s);
-   snprintf(lbuf, sizeof lbuf, SCCSDIFF, s, filename);
-   cs = "SCCS";
} else if (statfailed)
fatal("can't find %s\n", filename);
/*
Index: patch.1
===
RCS file: /cvs/src/usr.bin/patch/patch.1,v
retrieving revision 1.27
diff -u -p -r1.27 patch.1
--- patch.1 15 Apr 2014 06:26:54 -  1.27
+++ patch.1 19 Nov 2014 18:23:01 -
@@ -481,8 +481,8 @@ the shortest basename, and the shortest 
 .It
 If no file exists,
 .Nm
-checks for the existence of the files in an SCCS or RCS directory
-(using the appropriate prefix or suffix) using the criteria specified
+checks for the existence of the files in an RCS directory
+(using the appropriate suffix) using the criteria specified
 above.
 If found,
 .Nm
Index: pch.c
===
RCS file: /cvs/src/usr.bin/patch/pch.c,v
retrieving revision 1.43
diff -u -p -r1.43 pch.c
--- pch.c   18 Nov 2014 17:03:35 -  1.43
+++ pch.c   19 Nov 2014 18:23:02 -
@@ -1451,7 +1451,7 @@ posix_name(const struct file_name *names
if (path == NULL && !assume_exists) {
/*
 * No files found, look for something we can checkout from
-* RCS/SCCS dirs.  Same order as above.
+* RCS dirs.  Same order as above.
 */
for (i = 0; i < MAX_FILE; i++) {
if (names[i].path != NULL &&
Index: util.c
===
RCS file: /cvs/src/usr.bin/patch/util.c,v
retrieving revision 1.36
diff -u -p -r1.36 util.c
--- util.c  26 Nov 2013 13:19:07 -  1.36
+++ util.c  19 Nov 2014 18:23:02 -
@@ -374,7 +374,7 @@ fetchname(const char *at, bool *exists, 
 }
 
 /*
- * Takes the name returned by fetchname and looks in RCS/SCCS directories
+ * Takes the name returned by fetchname and looks in RCS directory
  * for a checked in version.
  */
 char *
@@ -391,9 +391,7 @@ checked_in(char *file)
 
if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) ||
try("%s/RCS/%s%s", filedir, filebase, "") ||
-   try("%s/%s%s", filedir, filebase, RCSSUFFIX) ||
-   try("%s/SCCS/%s%s", filedir, SCCSPREFIX, filebase) ||
-   try("%s/%s%s", filedir, SCCSPREFIX, filebase))
+   try("%s/%s%s", filedir, filebase, RCSSUFFIX))
return file;
 
return NULL;



TCP, UDP, Multicast and Broadcast are invited to a party...

2014-11-19 Thread Martin Pieuchot
...and in the end, they believe the mbuf(9) flags!

There's no good reason to recheck if the IP destination address is a
multicast or broadcast in {tcp,udp}_input().  We've already done that
when the packet got delivered.

So the diff below makes sure the multicast flag is set (jut be as
paranoid as with broadcast) and check for these flags in the upper
layer.

I verified with crafted packets that this works, the goal of this diff
is obviously to reduce the usage of "rcvif" pointers (and simplify
in_broadcast() afterward).

Comments, ok?


Index: netinet/ip_input.c
===
RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.241
diff -u -p -r1.241 ip_input.c
--- netinet/ip_input.c  5 Nov 2014 14:03:02 -   1.241
+++ netinet/ip_input.c  19 Nov 2014 15:39:59 -
@@ -348,6 +348,10 @@ ipv4_input(struct mbuf *m)
 
if (IN_MULTICAST(ip->ip_dst.s_addr)) {
struct in_multi *inm;
+
+   /* Paranoia. */
+   m->m_flags |= M_MCAST;
+
 #ifdef MROUTING
if (ipmforwarding && ip_mrouter) {
if (m->m_flags & M_EXT) {
Index: netinet/tcp_input.c
===
RCS file: /home/ncvs/src/sys/netinet/tcp_input.c,v
retrieving revision 1.283
diff -u -p -r1.283 tcp_input.c
--- netinet/tcp_input.c 18 Nov 2014 02:37:31 -  1.283
+++ netinet/tcp_input.c 19 Nov 2014 15:39:59 -
@@ -394,7 +394,6 @@ tcp_input(struct mbuf *m, ...)
 
/*
 * RFC1122 4.2.3.10, p. 104: discard bcast/mcast SYN
-* See below for AF specific multicast.
 */
if (m->m_flags & (M_BCAST|M_MCAST))
goto drop;
@@ -459,10 +458,6 @@ tcp_input(struct mbuf *m, ...)
switch (af) {
case AF_INET:
ip = mtod(m, struct ip *);
-   if (IN_MULTICAST(ip->ip_dst.s_addr) ||
-   in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif,
-   m->m_pkthdr.ph_rtableid))
-   goto drop;
 #ifdef TCP_ECN
/* save ip_tos before clearing it for checksum */
iptos = ip->ip_tos;
Index: netinet/udp_usrreq.c
===
RCS file: /home/ncvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.191
diff -u -p -r1.191 udp_usrreq.c
--- netinet/udp_usrreq.c9 Nov 2014 22:05:08 -   1.191
+++ netinet/udp_usrreq.c19 Nov 2014 15:39:59 -
@@ -400,16 +400,7 @@ udp_input(struct mbuf *m, ...)
}
 #endif
 
-#ifdef INET6
-   if ((ip6 && IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) ||
-   (ip && IN_MULTICAST(ip->ip_dst.s_addr)) ||
-   (ip && in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif,
-   m->m_pkthdr.ph_rtableid))) {
-#else /* INET6 */
-   if (IN_MULTICAST(ip->ip_dst.s_addr) ||
-   in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif,
-   m->m_pkthdr.ph_rtableid)) {
-#endif /* INET6 */
+   if (m->m_flags & (M_BCAST|M_MCAST)) {
struct inpcb *last;
/*
 * Deliver a multicast or broadcast datagram to *all* sockets
Index: netinet6/ip6_input.c
===
RCS file: /home/ncvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.130
diff -u -p -r1.130 ip6_input.c
--- netinet6/ip6_input.c14 Oct 2014 09:52:26 -  1.130
+++ netinet6/ip6_input.c19 Nov 2014 15:39:59 -
@@ -398,6 +398,9 @@ ip6_input(struct mbuf *m)
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
struct  in6_multi *in6m = 0;
 
+   /* Paranoia. */
+   m->m_flags |= M_MCAST;
+
in6_ifstat_inc(ifp, ifs6_in_mcast);
/*
 * See if we belong to the destination multicast group on the



Re: Unbound 1.5.0

2014-11-19 Thread Stuart Henderson
On 2014/11/18 23:36, Brad Smith wrote:
> So Unbound 1.5.0 has been released..
> 
> http://comstyle.com/unbound/unbound.tar.gz
> 
> Just looking for some testing of what I have preped for import.
> I have provided a tarball instead of a diff because of some
> dir additions.
> 
> Any other testers?

Working here on amd64 and powerpc, and a diff against current tree
looks good to me.  I tested with DNS64 as well.



Re: vi: perl api

2014-11-19 Thread Todd C. Miller
On Tue, 18 Nov 2014 20:51:56 -0700, "Anthony J. Bentley" wrote:

> Martin Natano writes:
> > The system util.h header is shadowed by the eponymous perl header. This
> > specific errors exists since December 2012. I strongly suspect that no
> > one uses the perl extension of vi - Let's remove it!
> 
> I'm inclined to agree. Is anyone willing to speak up in favor of saving it?

The existing perl extension does not work with modern perl anyway.
It is probably not too much work to update it but I'm OK with it
being removed.

 - todd



Re: fts: optimize by using fstatat instead of lstat

2014-11-19 Thread Todd C. Miller
I was considering doing something like this was but was unsure about
interactions with FTS_LOGICAL (and thus FTS_NOCHDIR).  I suppose
since fts_name is effectively d_name this is OK.

I also prefer passing dirp directly so the caller doesn't need to
use dirfd itself but that's not a big deal.

 - todd



Re: uslcom(4): fix for CP2110 USB HID-UART misdetection

2014-11-19 Thread Martin Pieuchot
On 18/11/14(Tue) 05:25, SASANO Takayoshi wrote:
> Hi all,
> 
> I bought Silicon Labs CP2110-EK USB HID-to-UART evaluation kit
> and connected to OpenBSD box.
> 
> uslcom(4) tries to use CP2110, but the device is different from
> CP210x series.

I agree this is a totally different device are you working on a kernel
driver?  The AN434 document should be enough, right?  By the way, this
device is another example that the model "1 driver" per  reportID is no
longer valid.

> How about to fix usbdevs and uslcom.c like this?

ok mpi@

> 
> 
> Index: usbdevs
> ===
> RCS file: /cvs/src/sys/dev/usb/usbdevs,v
> retrieving revision 1.639
> diff -u -p -r1.639 usbdevs
> --- usbdevs   31 Oct 2014 21:17:42 -  1.639
> +++ usbdevs   17 Nov 2014 20:04:44 -
> @@ -3812,7 +3812,7 @@ product SILABS3 GPRS_MODEM  0xea61  GPRS M
>  product SILABS4 100EU_MODEM  0xea61  GPRS Modem 100EU
>  product SILABS CP210X_3  0xea70  CP210x Serial
>  product SILABS INFINITY_MIC  0xea71  Infinity GPS-MIC-1
> -product SILABS CP210X_4  0xea80  CP210x Serial
> +product SILABS CP21100xea80  CP2110 USB HID Serial
>  product SILABS USBSCOPE500xf001  USBscope50
>  product SILABS USBWAVE12 0xf002  USBwave12
>  product SILABS USBPULSE100   0xf003  USBpulse100
> Index: uslcom.c
> ===
> RCS file: /cvs/src/sys/dev/usb/uslcom.c,v
> retrieving revision 1.31
> diff -u -p -r1.31 uslcom.c
> --- uslcom.c  12 Jul 2014 21:24:33 -  1.31
> +++ uslcom.c  17 Nov 2014 20:04:46 -
> @@ -165,7 +165,6 @@ static const struct usb_devno uslcom_dev
>   { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CP210X_1 },
>   { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CP210X_2 },
>   { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CP210X_3 },
> - { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CP210X_4 },
>   { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CRUMB128 },
>   { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CYGNAL },
>   { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CYGNAL_DEBUG },
> 
> 
> Here is the dmesg when connected CP2110EK before/after fix.
> 
> (before)
> uslcom0 at uhub3 port 3 "Silicon Laboratories CP2110 HID USB-to-UART Bridge" 
> rev 2.00/1.00 addr 2
> uslcom0: missing endpoint
> 
> (after)
> uhidev0 at uhub1 port 2 configuration 1 interface 0 "Silicon Laboratories 
> CP2110 HID USB-to-UART Bridge" rev 2.00/1.00 addr 2
> uhidev0: iclass 3/0, 102 report ids
> uhid0 at uhidev0 reportid 1: input=1, output=1, feature=0
> uhid1 at uhidev0 reportid 2: input=2, output=2, feature=0
> uhid2 at uhidev0 reportid 3: input=3, output=3, feature=0
> uhid3 at uhidev0 reportid 4: input=4, output=4, feature=0
> uhid4 at uhidev0 reportid 5: input=5, output=5, feature=0
> uhid5 at uhidev0 reportid 6: input=6, output=6, feature=0
> uhid6 at uhidev0 reportid 7: input=7, output=7, feature=0
> uhid7 at uhidev0 reportid 8: input=8, output=8, feature=0
> uhid8 at uhidev0 reportid 9: input=9, output=9, feature=0
> uhid9 at uhidev0 reportid 10: input=10, output=10, feature=0
> uhid10 at uhidev0 reportid 11: input=11, output=11, feature=0
> uhid11 at uhidev0 reportid 12: input=12, output=12, feature=0
> uhid12 at uhidev0 reportid 13: input=13, output=13, feature=0
> uhid13 at uhidev0 reportid 14: input=14, output=14, feature=0
> uhid14 at uhidev0 reportid 15: input=15, output=15, feature=0
> uhid15 at uhidev0 reportid 16: input=16, output=16, feature=0
> uhid16 at uhidev0 reportid 17: input=17, output=17, feature=0
> uhid17 at uhidev0 reportid 18: input=18, output=18, feature=0
> uhid18 at uhidev0 reportid 19: input=19, output=19, feature=0
> uhid19 at uhidev0 reportid 20: input=20, output=20, feature=0
> uhid20 at uhidev0 reportid 21: input=21, output=21, feature=0
> uhid21 at uhidev0 reportid 22: input=22, output=22, feature=0
> uhid22 at uhidev0 reportid 23: input=23, output=23, feature=0
> uhid23 at uhidev0 reportid 24: input=24, output=24, feature=0
> uhid24 at uhidev0 reportid 25: input=25, output=25, feature=0
> uhid25 at uhidev0 reportid 26: input=26, output=26, feature=0
> uhid26 at uhidev0 reportid 27: input=27, output=27, feature=0
> uhid27 at uhidev0 reportid 28: input=28, output=28, feature=0
> uhid28 at uhidev0 reportid 29: input=29, output=29, feature=0
> uhid29 at uhidev0 reportid 30: input=30, output=30, feature=0
> uhid30 at uhidev0 reportid 31: input=31, output=31, feature=0
> uhid31 at uhidev0 reportid 32: input=32, output=32, feature=0
> uhid32 at uhidev0 reportid 33: input=33, output=33, feature=0
> uhid33 at uhidev0 reportid 34: input=34, output=34, feature=0
> uhid34 at uhidev0 reportid 35: input=35, output=35, feature=0
> uhid35 at uhidev0 reportid 36: input=36, output=36, feature=0
> uhid36 at uhidev0 reportid 37: input=37, output=37, feature=0
> uhid37 at uhidev0 reportid 38: input=38, output=38, featur

Re: /var/tmp in current

2014-11-19 Thread Craig Skinner
On 2014-11-18 Tue 12:58 PM |, Martin Schr??der wrote:
> 
> See hier(7):
> 
> A symbolic link to the system /tmp directory. To protect other users
> of /var from overfill conditions, this is no longer a space you can
> trust to retain storage over a reboot. Periodically cleaned by
> daily(8).
> 

My machines all mount /var/tmp separately.

Is the /var/tmp link to be considered a backwards compatable artifact?

-- 
RS800 Yacht Racing Nationals, Eastbourne 2013
http://youtu.be/cmcTjxKOWdY