exclude-list in mtree (2)

2014-06-20 Thread Manuel Giraud
Hi,

In the previous patch, I forgot to check for excluded files at
verification time (duh). I also add the name of the excluded files list
into the mtree output so it can be retrieved later (e.g. in
/usr/libexec/security).

Index: Makefile
===
RCS file: /cvs/src/usr.sbin/mtree/Makefile,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile
--- Makefile	15 Apr 2013 06:25:18 -	1.9
+++ Makefile	20 Jun 2014 12:45:35 -
@@ -3,6 +3,6 @@
 PROG=	mtree
 #CFLAGS+=-DDEBUG
 MAN=	mtree.8
-SRCS=	compare.c crc.c create.c misc.c mtree.c spec.c verify.c
+SRCS=	compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c
 
 .include bsd.prog.mk
Index: create.c
===
RCS file: /cvs/src/usr.sbin/mtree/create.c,v
retrieving revision 1.29
diff -u -p -r1.29 create.c
--- create.c	22 Aug 2013 04:43:41 -	1.29
+++ create.c	20 Jun 2014 12:45:35 -
@@ -58,6 +58,7 @@ extern int ftsoptions;
 extern int dflag, iflag, nflag, sflag;
 extern u_int keys;
 extern char fullpath[MAXPATHLEN];
+extern char *excludefile;
 
 static gid_t gid;
 static uid_t uid;
@@ -82,6 +83,8 @@ cwalk(void)
 	(void)printf(
 	#\t   user: %s\n#\tmachine: %s\n#\t   tree: %s\n#\t   date: %s,
 	getlogin(), host, fullpath, ctime(clock));
+	if (excludefile)
+		printf(#\texclude: %s\n, excludefile);
 
 	argv[0] = .;
 	argv[1] = NULL;
@@ -90,6 +93,10 @@ cwalk(void)
 	while ((p = fts_read(t))) {
 		if (iflag)
 			indent = p-fts_level * 4;
+		if (check_excludes(p-fts_name, p-fts_path)) {
+			fts_set(t, p, FTS_SKIP);
+			continue;
+		}
 		switch(p-fts_info) {
 		case FTS_D:
 			if (!dflag)
Index: excludes.c
===
RCS file: excludes.c
diff -N excludes.c
--- /dev/null	1 Jan 1970 00:00:00 -
+++ excludes.c	20 Jun 2014 12:45:35 -
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2000 Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that both the above copyright notice and this
+ * permission notice appear in all copies, that both the above
+ * copyright notice and this permission notice appear in all
+ * supporting documentation, and that the name of M.I.T. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  M.I.T. makes
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided as is without express or implied
+ * warranty.
+ *
+ * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
+ * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include sys/types.h
+#include sys/queue.h
+#include err.h
+#include fnmatch.h
+#include fts.h
+#include stdio.h
+#include stdlib.h
+#include mtree.h
+#include extern.h
+
+/*
+ * We're assuming that there won't be a whole lot of excludes,
+ * so it's OK to use a stupid algorithm.
+ */
+struct exclude {
+	LIST_ENTRY(exclude) link;
+	const char *glob;
+	int pathname;
+};
+static LIST_HEAD(, exclude) excludes;
+
+void
+init_excludes(void)
+{
+	LIST_INIT(excludes);
+}
+
+int
+read_excludes_file(const char *name)
+{
+	FILE *fp;
+	char *buf, *lbuf;
+	struct exclude *e;
+	size_t len;
+
+
+	fp = fopen(name, r);
+	if (fp == NULL) {
+		return 1;
+	}
+
+	lbuf = NULL;
+	while ((buf = fgetln(fp, len))) {
+		if (buf[len - 1] == '\n') {
+			if (len == 1) 
+continue;
+			buf[len - 1] = '\0';
+		} else {
+			len++;
+			if ((lbuf = malloc(len)) == NULL)
+err(1, NULL);
+			memcpy(lbuf, buf, len - 1);
+			lbuf[len - 1] = '\0';
+			buf = lbuf;
+		}
+
+		if ((e = malloc(sizeof *e)) == NULL)
+			err(1, NULL);
+		if ((e-glob = malloc(len)) == NULL)
+			err(1, NULL);
+		memcpy((char *) e-glob, buf, len);
+		if (strchr(e-glob, '/'))
+			e-pathname = 1;
+		else
+			e-pathname = 0;
+		LIST_INSERT_HEAD(excludes, e, link);
+	}
+	free(lbuf);
+	fclose(fp);
+
+	return 0;
+}
+
+int
+check_excludes(const char *fname, const char *path)
+{
+	struct exclude *e;
+
+	/* Remove leading dot-slash before path match */
+	if ((path[0] == '.')  (path[1] == '/'))
+		path += 2;
+
+	LIST_FOREACH(e, excludes, link) {
+		if ((e-pathname  !fnmatch(e-glob, path, 

Re: exclude-list in mtree (2)

2014-06-20 Thread Manuel Giraud
Same with patch inline:
Index: Makefile
===
RCS file: /cvs/src/usr.sbin/mtree/Makefile,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile
--- Makefile15 Apr 2013 06:25:18 -  1.9
+++ Makefile20 Jun 2014 12:45:35 -
@@ -3,6 +3,6 @@
 PROG=  mtree
 #CFLAGS+=-DDEBUG
 MAN=   mtree.8
-SRCS=  compare.c crc.c create.c misc.c mtree.c spec.c verify.c
+SRCS=  compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c
 
 .include bsd.prog.mk
Index: create.c
===
RCS file: /cvs/src/usr.sbin/mtree/create.c,v
retrieving revision 1.29
diff -u -p -r1.29 create.c
--- create.c22 Aug 2013 04:43:41 -  1.29
+++ create.c20 Jun 2014 12:45:35 -
@@ -58,6 +58,7 @@ extern int ftsoptions;
 extern int dflag, iflag, nflag, sflag;
 extern u_int keys;
 extern char fullpath[MAXPATHLEN];
+extern char *excludefile;
 
 static gid_t gid;
 static uid_t uid;
@@ -82,6 +83,8 @@ cwalk(void)
(void)printf(
#\t   user: %s\n#\tmachine: %s\n#\t   tree: %s\n#\t   date: %s,
getlogin(), host, fullpath, ctime(clock));
+   if (excludefile)
+   printf(#\texclude: %s\n, excludefile);
 
argv[0] = .;
argv[1] = NULL;
@@ -90,6 +93,10 @@ cwalk(void)
while ((p = fts_read(t))) {
if (iflag)
indent = p-fts_level * 4;
+   if (check_excludes(p-fts_name, p-fts_path)) {
+   fts_set(t, p, FTS_SKIP);
+   continue;
+   }
switch(p-fts_info) {
case FTS_D:
if (!dflag)
Index: excludes.c
===
RCS file: excludes.c
diff -N excludes.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ excludes.c  20 Jun 2014 12:45:35 -
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2000 Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that both the above copyright notice and this
+ * permission notice appear in all copies, that both the above
+ * copyright notice and this permission notice appear in all
+ * supporting documentation, and that the name of M.I.T. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  M.I.T. makes
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided as is without express or implied
+ * warranty.
+ *
+ * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
+ * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include sys/types.h
+#include sys/queue.h
+#include err.h
+#include fnmatch.h
+#include fts.h
+#include stdio.h
+#include stdlib.h
+#include mtree.h
+#include extern.h
+
+/*
+ * We're assuming that there won't be a whole lot of excludes,
+ * so it's OK to use a stupid algorithm.
+ */
+struct exclude {
+   LIST_ENTRY(exclude) link;
+   const char *glob;
+   int pathname;
+};
+static LIST_HEAD(, exclude) excludes;
+
+void
+init_excludes(void)
+{
+   LIST_INIT(excludes);
+}
+
+int
+read_excludes_file(const char *name)
+{
+   FILE *fp;
+   char *buf, *lbuf;
+   struct exclude *e;
+   size_t len;
+
+
+   fp = fopen(name, r);
+   if (fp == NULL) {
+   return 1;
+   }
+
+   lbuf = NULL;
+   while ((buf = fgetln(fp, len))) {
+   if (buf[len - 1] == '\n') {
+   if (len == 1) 
+   continue;
+   buf[len - 1] = '\0';
+   } else {
+   len++;
+   if ((lbuf = malloc(len)) == NULL)
+   err(1, NULL);
+   memcpy(lbuf, buf, len - 1);
+   lbuf[len - 1] = '\0';
+   buf = lbuf;
+   }
+
+   if ((e = malloc(sizeof *e)) == NULL)
+   err(1, NULL);
+   if ((e-glob = malloc(len)) == NULL)
+   err(1, NULL);
+   memcpy((char *) e-glob, buf, len);
+   

Re: compare memcmp with 0

2014-06-20 Thread Ingo Schwarze
Hi Theo,

Theo de Raadt wrote on Thu, Jun 19, 2014 at 09:58:01PM -0600:

 It could be argued that the bcmp manual page does a poor job
 documenting this.  It should use the mandoc blink tag.

OK?

It's not perfect yet because when you nest blink tags, it already
switches back to non-blinking mode after you close the inner block,
not after closing the outer block as it should.
But that can be fixed later, in the tree.

Using this requires

  export LESS=-R

or something equivalent, depending on your setup, of course.

Maybe we should make that the default.

I guess i need to submit a similar patch to groff, as well.

Yours,
  Ingo


Index: share/man/man7/mdoc.7
===
RCS file: /cvs/src/share/man/man7/mdoc.7,v
retrieving revision 1.110
diff -u -p -r1.110 mdoc.7
--- share/man/man7/mdoc.7   30 Mar 2014 23:57:43 -  1.110
+++ share/man/man7/mdoc.7   20 Jun 2014 14:43:02 -
@@ -534,6 +534,7 @@ in the alphabetical
 .It Sx \Bq , \Bo , \Bc Ta enclose in square brackets: Bq text
 .It Sx \Brq , \Bro , \Brc Ta enclose in curly braces: Brq text
 .It Sx \Aq , \Ao , \Ac Ta enclose in angle brackets: Aq text
+.It Sx \Blq , \Blo , \Blc Ta blink: Blq text
 .It Sx \Eo , \Ec Ta generic enclosure
 .El
 .Ss Text production
@@ -1077,6 +1078,16 @@ and
 .Pp
 See also
 .Sx \Bo .
+.Ss \Blc
+Close a
+.Sx \Blo
+block.
+Does not have any tail arguments.
+.Ss \Blo
+Begin a blinking block.
+Does not have any head arguments.
+.Ss \Blq
+Makes its arguments blink.
 .Ss \Brc
 Close a
 .Sx \Bro
@@ -2924,6 +2935,7 @@ end of the line.
 .Bl -column MacroX CallableX ParsedX -offset indent
 .It Em Macro Ta Em Callable Ta Em Parsed
 .It Sx \Aq  TaYes  TaYes
+.It Sx \Blq TaYes  TaYes
 .It Sx \Bq  TaYes  TaYes
 .It Sx \Brq TaYes  TaYes
 .It Sx \D1  Ta\No Ta\Yes
Index: usr.bin/mandoc/mdoc.c
===
RCS file: /cvs/src/usr.bin/mandoc/mdoc.c,v
retrieving revision 1.104
diff -u -p -r1.104 mdoc.c
--- usr.bin/mandoc/mdoc.c   25 Apr 2014 14:10:59 -  1.104
+++ usr.bin/mandoc/mdoc.c   20 Jun 2014 14:43:02 -
@@ -62,7 +62,8 @@ const char *const __mdoc_macronames[MDOC
Lk,   Mt,   Brq,  Bro,
Brc,  %C,   Es,   En,
Dx,   %Q,   br,   sp,
-   %U,   Ta,   ll,
+   %U,   Ta,   ll,   Blo,
+   Blc,  Blq,
};
 
 const  char *const __mdoc_argnames[MDOC_ARG_MAX] = {
Index: usr.bin/mandoc/mdoc.h
===
RCS file: /cvs/src/usr.bin/mandoc/mdoc.h,v
retrieving revision 1.53
diff -u -p -r1.53 mdoc.h
--- usr.bin/mandoc/mdoc.h   20 Apr 2014 16:44:44 -  1.53
+++ usr.bin/mandoc/mdoc.h   20 Jun 2014 14:43:02 -
@@ -141,6 +141,9 @@ enummdoct {
MDOC__U,
MDOC_Ta,
MDOC_ll,
+   MDOC_Blo,
+   MDOC_Blc,
+   MDOC_Blq,
MDOC_MAX
 };
 
Index: usr.bin/mandoc/mdoc_argv.c
===
RCS file: /cvs/src/usr.bin/mandoc/mdoc_argv.c,v
retrieving revision 1.50
diff -u -p -r1.50 mdoc_argv.c
--- usr.bin/mandoc/mdoc_argv.c  23 Apr 2014 21:06:33 -  1.50
+++ usr.bin/mandoc/mdoc_argv.c  20 Jun 2014 14:43:03 -
@@ -264,6 +264,9 @@ static  const struct mdocarg mdocargs[MDO
{ ARGSFL_NONE, NULL }, /* %U */
{ ARGSFL_NONE, NULL }, /* Ta */
{ ARGSFL_NONE, NULL }, /* ll */
+   { ARGSFL_NONE, NULL }, /* Blo */
+   { ARGSFL_DELIM, NULL }, /* Blc */
+   { ARGSFL_DELIM, NULL }, /* Blq */
 };
 
 
Index: usr.bin/mandoc/mdoc_html.c
===
RCS file: /cvs/src/usr.bin/mandoc/mdoc_html.c,v
retrieving revision 1.73
diff -u -p -r1.73 mdoc_html.c
--- usr.bin/mandoc/mdoc_html.c  23 Apr 2014 16:07:06 -  1.73
+++ usr.bin/mandoc/mdoc_html.c  20 Jun 2014 14:43:03 -
@@ -242,6 +242,9 @@ static  const struct htmlmdoc mdocs[MDOC_
{mdoc__x_pre, mdoc__x_post}, /* %U */
{NULL, NULL}, /* Ta */
{mdoc_ll_pre, NULL}, /* ll */
+   {mdoc_quote_pre, mdoc_quote_post}, /* Blo */
+   {NULL, NULL}, /* Blc */
+   {mdoc_quote_pre, mdoc_quote_post}, /* Blq */
 };
 
 static const char * const lists[LIST_MAX] = {
@@ -2063,6 +2066,12 @@ mdoc_quote_pre(MDOC_ARGS)
case MDOC_Aq:
print_text(h, \\(la);
break;
+   case MDOC_Blo:
+   /* FALLTHROUGH */
+   case MDOC_Blq:
+   PAIR_CLASS_INIT(tag, blink);
+   print_otag(h, TAG_SPAN, 1, tag);
+   break;
case MDOC_Bro:
/* FALLTHROUGH */
case MDOC_Brq:
@@ -2131,6 +2140,10 @@ mdoc_quote_post(MDOC_ARGS)
/* FALLTHROUGH */
case MDOC_Aq:

Re: exclude-list in mtree (2)

2014-06-20 Thread Tobias Stoeckmann
On Fri, Jun 20, 2014 at 04:34:19PM +0200, Manuel Giraud wrote:
 + lbuf = NULL;
 + while ((buf = fgetln(fp, len))) {
 + if (buf[len - 1] == '\n') {
 + if (len == 1) 
 + continue;
 + buf[len - 1] = '\0';
 + } else {
 + len++;
 + if ((lbuf = malloc(len)) == NULL)
 + err(1, NULL);
 + memcpy(lbuf, buf, len - 1);
 + lbuf[len - 1] = '\0';
 + buf = lbuf;
 + }

What is the rational behind checking for len == 1 in '\n'
case, but not for last line without new line?

If you want to skip empty lines, you should check after
the if/else-block for buf[0] == '\0', imho.


Tobias



Re: compare memcmp with 0

2014-06-20 Thread Bob Beck


OMFG..

Ingo you just made my morning. I'm laughing so hard.

And I needed the laugh

-Bob



On Fri, Jun 20, 2014 at 04:54:15PM +0200, Ingo Schwarze wrote:
 Hi Theo,
 
 Theo de Raadt wrote on Thu, Jun 19, 2014 at 09:58:01PM -0600:
 
  It could be argued that the bcmp manual page does a poor job
  documenting this.  It should use the mandoc blink tag.
 
 OK?
 
 It's not perfect yet because when you nest blink tags, it already
 switches back to non-blinking mode after you close the inner block,
 not after closing the outer block as it should.
 But that can be fixed later, in the tree.
 
 Using this requires
 
   export LESS=-R
 
 or something equivalent, depending on your setup, of course.
 
 Maybe we should make that the default.
 
 I guess i need to submit a similar patch to groff, as well.
 
 Yours,
   Ingo
 
 
 Index: share/man/man7/mdoc.7
 ===
 RCS file: /cvs/src/share/man/man7/mdoc.7,v
 retrieving revision 1.110
 diff -u -p -r1.110 mdoc.7
 --- share/man/man7/mdoc.7 30 Mar 2014 23:57:43 -  1.110
 +++ share/man/man7/mdoc.7 20 Jun 2014 14:43:02 -
 @@ -534,6 +534,7 @@ in the alphabetical
  .It Sx \Bq , \Bo , \Bc Ta enclose in square brackets: Bq text
  .It Sx \Brq , \Bro , \Brc Ta enclose in curly braces: Brq text
  .It Sx \Aq , \Ao , \Ac Ta enclose in angle brackets: Aq text
 +.It Sx \Blq , \Blo , \Blc Ta blink: Blq text
  .It Sx \Eo , \Ec Ta generic enclosure
  .El
  .Ss Text production
 @@ -1077,6 +1078,16 @@ and
  .Pp
  See also
  .Sx \Bo .
 +.Ss \Blc
 +Close a
 +.Sx \Blo
 +block.
 +Does not have any tail arguments.
 +.Ss \Blo
 +Begin a blinking block.
 +Does not have any head arguments.
 +.Ss \Blq
 +Makes its arguments blink.
  .Ss \Brc
  Close a
  .Sx \Bro
 @@ -2924,6 +2935,7 @@ end of the line.
  .Bl -column MacroX CallableX ParsedX -offset indent
  .It Em Macro Ta Em Callable Ta Em Parsed
  .It Sx \Aq  TaYes  TaYes
 +.It Sx \Blq TaYes  TaYes
  .It Sx \Bq  TaYes  TaYes
  .It Sx \Brq TaYes  TaYes
  .It Sx \D1  Ta\No Ta\Yes
 Index: usr.bin/mandoc/mdoc.c
 ===
 RCS file: /cvs/src/usr.bin/mandoc/mdoc.c,v
 retrieving revision 1.104
 diff -u -p -r1.104 mdoc.c
 --- usr.bin/mandoc/mdoc.c 25 Apr 2014 14:10:59 -  1.104
 +++ usr.bin/mandoc/mdoc.c 20 Jun 2014 14:43:02 -
 @@ -62,7 +62,8 @@ const   char *const __mdoc_macronames[MDOC
   Lk,   Mt,   Brq,  Bro,
   Brc,  %C,   Es,   En,
   Dx,   %Q,   br,   sp,
 - %U,   Ta,   ll,
 + %U,   Ta,   ll,   Blo,
 + Blc,  Blq,
   };
  
  constchar *const __mdoc_argnames[MDOC_ARG_MAX] = {
 Index: usr.bin/mandoc/mdoc.h
 ===
 RCS file: /cvs/src/usr.bin/mandoc/mdoc.h,v
 retrieving revision 1.53
 diff -u -p -r1.53 mdoc.h
 --- usr.bin/mandoc/mdoc.h 20 Apr 2014 16:44:44 -  1.53
 +++ usr.bin/mandoc/mdoc.h 20 Jun 2014 14:43:02 -
 @@ -141,6 +141,9 @@ enum  mdoct {
   MDOC__U,
   MDOC_Ta,
   MDOC_ll,
 + MDOC_Blo,
 + MDOC_Blc,
 + MDOC_Blq,
   MDOC_MAX
  };
  
 Index: usr.bin/mandoc/mdoc_argv.c
 ===
 RCS file: /cvs/src/usr.bin/mandoc/mdoc_argv.c,v
 retrieving revision 1.50
 diff -u -p -r1.50 mdoc_argv.c
 --- usr.bin/mandoc/mdoc_argv.c23 Apr 2014 21:06:33 -  1.50
 +++ usr.bin/mandoc/mdoc_argv.c20 Jun 2014 14:43:03 -
 @@ -264,6 +264,9 @@ staticconst struct mdocarg mdocargs[MDO
   { ARGSFL_NONE, NULL }, /* %U */
   { ARGSFL_NONE, NULL }, /* Ta */
   { ARGSFL_NONE, NULL }, /* ll */
 + { ARGSFL_NONE, NULL }, /* Blo */
 + { ARGSFL_DELIM, NULL }, /* Blc */
 + { ARGSFL_DELIM, NULL }, /* Blq */
  };
  
  
 Index: usr.bin/mandoc/mdoc_html.c
 ===
 RCS file: /cvs/src/usr.bin/mandoc/mdoc_html.c,v
 retrieving revision 1.73
 diff -u -p -r1.73 mdoc_html.c
 --- usr.bin/mandoc/mdoc_html.c23 Apr 2014 16:07:06 -  1.73
 +++ usr.bin/mandoc/mdoc_html.c20 Jun 2014 14:43:03 -
 @@ -242,6 +242,9 @@ staticconst struct htmlmdoc mdocs[MDOC_
   {mdoc__x_pre, mdoc__x_post}, /* %U */
   {NULL, NULL}, /* Ta */
   {mdoc_ll_pre, NULL}, /* ll */
 + {mdoc_quote_pre, mdoc_quote_post}, /* Blo */
 + {NULL, NULL}, /* Blc */
 + {mdoc_quote_pre, mdoc_quote_post}, /* Blq */
  };
  
  static   const char * const lists[LIST_MAX] = {
 @@ -2063,6 +2066,12 @@ mdoc_quote_pre(MDOC_ARGS)
   case MDOC_Aq:
   print_text(h, \\(la);
   break;
 + case MDOC_Blo:
 + /* FALLTHROUGH */
 + case MDOC_Blq:
 + PAIR_CLASS_INIT(tag, blink);
 + 

Re: exclude-list in mtree (2)

2014-06-20 Thread Manuel Giraud
Tobias Stoeckmann tob...@stoeckmann.org writes:

 On Fri, Jun 20, 2014 at 04:34:19PM +0200, Manuel Giraud wrote:
 +lbuf = NULL;
 +while ((buf = fgetln(fp, len))) {
 +if (buf[len - 1] == '\n') {
 +if (len == 1) 
 +continue;
 +buf[len - 1] = '\0';
 +} else {
 +len++;
 +if ((lbuf = malloc(len)) == NULL)
 +err(1, NULL);
 +memcpy(lbuf, buf, len - 1);
 +lbuf[len - 1] = '\0';
 +buf = lbuf;
 +}

 What is the rational behind checking for len == 1 in '\n'
 case, but not for last line without new line?

 If you want to skip empty lines, you should check after
 the if/else-block for buf[0] == '\0', imho.

Ok:
Index: Makefile
===
RCS file: /cvs/src/usr.sbin/mtree/Makefile,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile
--- Makefile15 Apr 2013 06:25:18 -  1.9
+++ Makefile20 Jun 2014 15:33:51 -
@@ -3,6 +3,6 @@
 PROG=  mtree
 #CFLAGS+=-DDEBUG
 MAN=   mtree.8
-SRCS=  compare.c crc.c create.c misc.c mtree.c spec.c verify.c
+SRCS=  compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c
 
 .include bsd.prog.mk
Index: create.c
===
RCS file: /cvs/src/usr.sbin/mtree/create.c,v
retrieving revision 1.29
diff -u -p -r1.29 create.c
--- create.c22 Aug 2013 04:43:41 -  1.29
+++ create.c20 Jun 2014 15:33:51 -
@@ -58,6 +58,7 @@ extern int ftsoptions;
 extern int dflag, iflag, nflag, sflag;
 extern u_int keys;
 extern char fullpath[MAXPATHLEN];
+extern char *excludefile;
 
 static gid_t gid;
 static uid_t uid;
@@ -82,6 +83,8 @@ cwalk(void)
(void)printf(
#\t   user: %s\n#\tmachine: %s\n#\t   tree: %s\n#\t   date: %s,
getlogin(), host, fullpath, ctime(clock));
+   if (excludefile)
+   printf(#\texclude: %s\n, excludefile);
 
argv[0] = .;
argv[1] = NULL;
@@ -90,6 +93,10 @@ cwalk(void)
while ((p = fts_read(t))) {
if (iflag)
indent = p-fts_level * 4;
+   if (check_excludes(p-fts_name, p-fts_path)) {
+   fts_set(t, p, FTS_SKIP);
+   continue;
+   }
switch(p-fts_info) {
case FTS_D:
if (!dflag)
Index: excludes.c
===
RCS file: excludes.c
diff -N excludes.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ excludes.c  20 Jun 2014 15:33:51 -
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2000 Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that both the above copyright notice and this
+ * permission notice appear in all copies, that both the above
+ * copyright notice and this permission notice appear in all
+ * supporting documentation, and that the name of M.I.T. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  M.I.T. makes
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided as is without express or implied
+ * warranty.
+ *
+ * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
+ * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include sys/types.h
+#include sys/queue.h
+#include err.h
+#include fnmatch.h
+#include fts.h
+#include stdio.h
+#include stdlib.h
+#include mtree.h
+#include extern.h
+
+/*
+ * We're assuming that there won't be a whole lot of excludes,
+ * so it's OK to use a stupid algorithm.
+ */
+struct exclude {
+   LIST_ENTRY(exclude) link;
+   const char *glob;
+   int pathname;
+};
+static LIST_HEAD(, exclude) excludes;
+
+void
+init_excludes(void)
+{
+   LIST_INIT(excludes);
+}
+
+int
+read_excludes_file(const char *name)
+{
+   FILE *fp;
+   char *buf, *lbuf;
+   struct exclude *e;
+   size_t len;
+
+
+   fp = fopen(name, r);
+   if (fp == NULL) {
+   

Re: 8 port serial card connections

2014-06-20 Thread Craig R. Skinner
On 2014-06-20 Fri 16:14 PM |, Maurice Janssen wrote:
 # FIXME No. 9 Moxa card port:
 moxa09:dv=/dev/tty10:common:
 
 # FIXME No. 10 Moxa card port:
 moxa10:dv=/dev/tty11:common:
 
 Try /dev/tty0a and /dev/tty0b
 

Perfect!


Here's a man page diff to sync with lines 1383-1397 of
/usr/src/sys/dev/pci/pucdata.c


Index: share/man/man4/puc.4
===
RCS file: /cvs/src/share/man/man4/puc.4,v
retrieving revision 1.47
diff -u -p -r1.47 puc.4
--- share/man/man4/puc.42 Feb 2014 19:39:55 -   1.47
+++ share/man/man4/puc.420 Jun 2014 17:00:27 -
@@ -85,6 +85,7 @@ The driver currently supports the follow
 .It Tn Moxa Technologies Co., Ltd. PCI I/O Card 4S (4 port serial)
 .It Tn Moxa Technologies Co., Ltd. C104H/PCI (4 port serial)
 .It Tn Moxa Technologies Co., Ltd. CP104/PCI (4 port serial)
+.It Tn Moxa Technologies Co., Ltd. C168H/PCI (8 port serial)
 .It Tn NEC PK-UG-X008 (serial)
 .It Tn NEC PK-UG-X001 K56flex PCI (modem)
 .It Tn NetMos 1P (1 port parallel)



gcc: warn about overly aligned stack variables

2014-06-20 Thread Matthew Dempsky
GCC supports an aligned attribute to specify a minimum alignment for
types/objects.  However, if an object is allocated on the stack and
its alignment exceeds the preferred stack boundary, then GCC 4.2
silently ignores the alignment.

This bit us 4 years ago when the SCSI stack started allocating mutexes
on the stack: HPPA mutexes need to be 16-byte aligned, but HPPA's
stack is naturally only 8-byte aligned.

Since newer GCC properly support overly aligned stack allocations, it
seems prudent to at least make base GCC emit a warning if its going to
ignore an alignment request.

With the diff below, compiling a source file like this:

typedef int __attribute__((aligned(512))) aligned_int;

aligned_int good;

void foo() {
aligned_int bad;
}

now produces a warning like this:

$ cc -c test.c
test.c: In function 'foo':
test.c:6: warning: ignoring alignment for stack allocated 'bad'

I verified this doesn't break an amd64 kernel build, but I haven't had
time to look beyond that.  Sharing in case anyone's interested and/or
wants to test further themselves.

Index: gcc/cfgexpand.c
===
RCS file: /home/matthew/cvs-mirror/cvs/src/gnu/gcc/gcc/cfgexpand.c,v
retrieving revision 1.4
diff -u -p -r1.4 cfgexpand.c
--- gcc/cfgexpand.c 6 May 2014 23:32:34 -   1.4
+++ gcc/cfgexpand.c 20 Jun 2014 22:55:53 -
@@ -159,8 +159,10 @@ get_decl_align_unit (tree decl)
 
   align = DECL_ALIGN (decl);
   align = LOCAL_ALIGNMENT (TREE_TYPE (decl), align);
-  if (align  PREFERRED_STACK_BOUNDARY)
+  if (align  PREFERRED_STACK_BOUNDARY) {
+warning (0, ignoring alignment for stack allocated %q+D, decl);
 align = PREFERRED_STACK_BOUNDARY;
+  }
   if (cfun-stack_alignment_needed  align)
 cfun-stack_alignment_needed = align;
 



boringssl and such

2014-06-20 Thread Theo de Raadt
Few things to note...

I suspect everyone working on LibReSSL is happy to hear the news about
BoringSSL.  Choice is good!!  Their priority is on safety, not on ABI
compatibility.  Just like us.  Over time, I suspect google's version
will also become 'reduced API', since they require less legacy
application support.  That may give LibReSSL the opportunity to head
in the same direction, if the applications are willing...

Secondly, a lot of misinformation is being spread about the effort
required to get LibReSSL-portable out the door.  We've stripped the
code so that it is POSIX-only.  Therefore Linux compat is really not
hard.  We basically just need the following parts to be finished:

- A clean build framework

- and the finetunings of portable versions of our safetybelts:
   arc4randomstrlcpy  strlcat
   explicit_bzero   reallocarray
   timingsafe_bcmp timingsafe_memcmp

So please stop believing rumours that we've made it hard to port!  The
entire world went to POSIX, and that's all this code needs to support.
It is a small step.  I don't think it will take much longer.

patience...