Re: unveil: incorrect type flags on unvname_new()

2018-07-16 Thread Bob Beck
ok beck@

On Mon, Jul 16, 2018 at 15:53 Sebastien Marie  wrote:

> Hi,
>
> While reviewing unveil(2) code, I found an incorrect type on
> unvname_new() function: flags argument should be uint64_t.
>
> It is called by unveil_add_name() which uses uint64_t for flags, and
> store the value in struct unvname un_flags member which is uint64_t.
>
> Thanks.
> --
> Sebastien Marie
>
>
> Index: kern/kern_unveil.c
> ===
> RCS file: /cvs/src/sys/kern/kern_unveil.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 kern_unveil.c
> --- kern/kern_unveil.c  13 Jul 2018 13:47:41 -  1.2
> +++ kern/kern_unveil.c  16 Jul 2018 13:08:40 -
> @@ -50,7 +50,7 @@ unvname_compare(const struct unvname *n1
>  }
>
>  struct unvname *
> -unvname_new(const char *name, size_t size, int flags)
> +unvname_new(const char *name, size_t size, uint64_t flags)
>  {
> struct unvname *ret = malloc(sizeof(struct unvname), M_PROC,
> M_WAITOK);
> ret->un_name = malloc(size, M_PROC, M_WAITOK);
>


Octeon - kernel panic at login

2018-07-16 Thread Jungle Boogie
Hi All,

I logged into my erl octeon device to upgrade it. When I logged in via serial, I
received a panic.

login: root
panic: init died (signal 0, exit 10)
Stopped at  0x8135036c: jr  ra
0x81350370:  nop
TIDPIDUID PRFLAGS PFLAGS  CPU  COMMAND
*344602  1  0 0x2 0x20000K init
0x81350368 (1202c41c2c6691bc,900107000208,208,98000fff7d98)  ra
 0x813ac5f8 sp 0x98000fff7dd0, sz 0
0x813ac3b8 (1202c41c2c6691bc,900107000208,208,98000fff7d98)  ra
 0x0 sp 0x98000fff7dd0, sz 0
User-level: pid 1
https://www.openbsd.org/ddb.html describes the minimum info required in bug
reports.  Insufficient info makes it difficult to find and fix bugs.
ddb{0}> bt
0x81350368 (1202c41c2c6691bc,900107000208,208,98000fff7d98)  ra
 0x813ac5f8 sp 0x98000fff7dd0, sz 0
0x813ac3b8 (1202c41c2c6691bc,900107000208,208,98000fff7d98)  ra
 0x0 sp 0x98000fff7dd0, sz 0
User-level: pid 1

Last snapshot was from Tue Jun 26 03:54:54 UTC 2018

Thanks!



Re: bgpd switch mrt format to extended timestamp

2018-07-16 Thread Sebastian Benoit
ok benno@

Claudio Jeker(cje...@diehard.n-r-g.com) on 2018.07.16 22:33:17 +0200:
> For "dump (all|updates) (in|out)" it totally makes sense to use the 
> extended timestamp format that includes microseconds as well. This
> way it is better visible when updates got processed.
> Table dumps are not affected since there the timestamp is not that
> useful.
> 
> bgpdump shows now the time with microseconds:
> TIME: 07/16/18 20:26:15.384935
> TYPE: BGP4MP_ET/MESSAGE/Keepalive
> FROM: 10.82.41.92 AS196618
> TO: 62.48.0.253 AS8271
> 
> TIME: 07/16/18 20:26:15.384949
> TYPE: BGP4MP_ET/STATE_CHANGE
> PEER: 10.82.41.92 AS196618
> STATE: Opensent/Openconfirm
> 
> TIME: 07/16/18 20:26:15.386018
> TYPE: BGP4MP_ET/STATE_CHANGE
> PEER: 10.82.41.92 AS196618
> STATE: Openconfirm/Established
> 
> TIME: 07/16/18 20:26:15.386217
> TYPE: BGP4MP_ET/MESSAGE/Update
> FROM: 10.82.41.92 AS196618
> TO: 62.48.0.253 AS8271
> 
> ... and bgpctl will do the same soon :)
> -- 
> :wq Claudio
> 
> Index: mrt.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/mrt.c,v
> retrieving revision 1.84
> diff -u -p -r1.84 mrt.c
> --- mrt.c 5 Feb 2018 03:55:54 -   1.84
> +++ mrt.c 16 Jul 2018 20:25:45 -
> @@ -105,7 +105,7 @@ mrt_dump_bgp_msg(struct mrt *mrt, void *
>   if (mrt->type == MRT_ALL_IN || mrt->type == MRT_UPDATE_IN)
>   incoming = 1;
>  
> - if (mrt_dump_hdr_se(, peer, MSG_PROTOCOL_BGP4MP, subtype,
> + if (mrt_dump_hdr_se(, peer, MSG_PROTOCOL_BGP4MP_ET, subtype,
>   pkglen, incoming) == -1)
>   return;
>  
> @@ -128,7 +128,7 @@ mrt_dump_state(struct mrt *mrt, u_int16_
>   if (peer->capa.neg.as4byte)
>   subtype = BGP4MP_STATE_CHANGE_AS4;
>  
> - if (mrt_dump_hdr_se(, peer, MSG_PROTOCOL_BGP4MP, subtype,
> + if (mrt_dump_hdr_se(, peer, MSG_PROTOCOL_BGP4MP_ET, subtype,
>   2 * sizeof(short), 0) == -1)
>   return;
>  
> @@ -684,17 +684,17 @@ int
>  mrt_dump_hdr_se(struct ibuf ** bp, struct peer *peer, u_int16_t type,
>  u_int16_t subtype, u_int32_t len, int swap)
>  {
> - time_t  now;
> + struct timespec time;
>  
> - if ((*bp = ibuf_dynamic(MRT_HEADER_SIZE, MRT_HEADER_SIZE +
> + if ((*bp = ibuf_dynamic(MRT_ET_HEADER_SIZE, MRT_ET_HEADER_SIZE +
>   MRT_BGP4MP_AS4_IPv6_HEADER_SIZE + len)) == NULL) {
>   log_warn("mrt_dump_hdr_se: ibuf_dynamic error");
>   return (-1);
>   }
>  
> - now = time(NULL);
> + clock_gettime(CLOCK_REALTIME, );
>  
> - DUMP_LONG(*bp, now);
> + DUMP_LONG(*bp, time.tv_sec);
>   DUMP_SHORT(*bp, type);
>   DUMP_SHORT(*bp, subtype);
>  
> @@ -702,16 +702,16 @@ mrt_dump_hdr_se(struct ibuf ** bp, struc
>   case AF_INET:
>   if (subtype == BGP4MP_STATE_CHANGE_AS4 ||
>   subtype == BGP4MP_MESSAGE_AS4)
> - len += MRT_BGP4MP_AS4_IPv4_HEADER_SIZE;
> + len += MRT_BGP4MP_ET_AS4_IPv4_HEADER_SIZE;
>   else
> - len += MRT_BGP4MP_IPv4_HEADER_SIZE;
> + len += MRT_BGP4MP_ET_IPv4_HEADER_SIZE;
>   break;
>   case AF_INET6:
>   if (subtype == BGP4MP_STATE_CHANGE_AS4 ||
>   subtype == BGP4MP_MESSAGE_AS4)
> - len += MRT_BGP4MP_AS4_IPv6_HEADER_SIZE;
> + len += MRT_BGP4MP_ET_AS4_IPv6_HEADER_SIZE;
>   else
> - len += MRT_BGP4MP_IPv6_HEADER_SIZE;
> + len += MRT_BGP4MP_ET_IPv6_HEADER_SIZE;
>   break;
>   case 0:
>   goto fail;
> @@ -721,6 +721,8 @@ mrt_dump_hdr_se(struct ibuf ** bp, struc
>   }
>  
>   DUMP_LONG(*bp, len);
> + /* milisecond field use by the _ET format */
> + DUMP_LONG(*bp, time.tv_nsec / 1000);
>  
>   if (subtype == BGP4MP_STATE_CHANGE_AS4 ||
>   subtype == BGP4MP_MESSAGE_AS4) {
> Index: mrt.h
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/mrt.h,v
> retrieving revision 1.31
> diff -u -p -r1.31 mrt.h
> --- mrt.h 19 Sep 2011 11:19:32 -  1.31
> +++ mrt.h 13 Jul 2018 13:54:07 -
> @@ -39,6 +39,7 @@
>   * length field. Which is accounted in the length field.
>   */
>  #define MRT_HEADER_SIZE  12
> +#define MRT_ET_HEADER_SIZE   16
>  
>  struct mrt_hdr {
>   u_int32_t   timestamp;
> @@ -87,11 +88,15 @@ enum MRT_BGP4MP_SUBTYPES {
>  };
>  
>  /* size of the BGP4MP headers without payload */
> -#define MRT_BGP4MP_IPv4_HEADER_SIZE  16
> -#define MRT_BGP4MP_IPv6_HEADER_SIZE  40
> +#define MRT_BGP4MP_IPv4_HEADER_SIZE  16
> +#define MRT_BGP4MP_IPv6_HEADER_SIZE  40
> +#define MRT_BGP4MP_ET_IPv4_HEADER_SIZE   20
> +#define MRT_BGP4MP_ET_IPv6_HEADER_SIZE   44
>  /* 4-byte AS variants of the previous */
> -#define MRT_BGP4MP_AS4_IPv4_HEADER_SIZE  20
> 

bgpd switch mrt format to extended timestamp

2018-07-16 Thread Claudio Jeker
For "dump (all|updates) (in|out)" it totally makes sense to use the 
extended timestamp format that includes microseconds as well. This
way it is better visible when updates got processed.
Table dumps are not affected since there the timestamp is not that
useful.

bgpdump shows now the time with microseconds:
TIME: 07/16/18 20:26:15.384935
TYPE: BGP4MP_ET/MESSAGE/Keepalive
FROM: 10.82.41.92 AS196618
TO: 62.48.0.253 AS8271

TIME: 07/16/18 20:26:15.384949
TYPE: BGP4MP_ET/STATE_CHANGE
PEER: 10.82.41.92 AS196618
STATE: Opensent/Openconfirm

TIME: 07/16/18 20:26:15.386018
TYPE: BGP4MP_ET/STATE_CHANGE
PEER: 10.82.41.92 AS196618
STATE: Openconfirm/Established

TIME: 07/16/18 20:26:15.386217
TYPE: BGP4MP_ET/MESSAGE/Update
FROM: 10.82.41.92 AS196618
TO: 62.48.0.253 AS8271

... and bgpctl will do the same soon :)
-- 
:wq Claudio

Index: mrt.c
===
RCS file: /cvs/src/usr.sbin/bgpd/mrt.c,v
retrieving revision 1.84
diff -u -p -r1.84 mrt.c
--- mrt.c   5 Feb 2018 03:55:54 -   1.84
+++ mrt.c   16 Jul 2018 20:25:45 -
@@ -105,7 +105,7 @@ mrt_dump_bgp_msg(struct mrt *mrt, void *
if (mrt->type == MRT_ALL_IN || mrt->type == MRT_UPDATE_IN)
incoming = 1;
 
-   if (mrt_dump_hdr_se(, peer, MSG_PROTOCOL_BGP4MP, subtype,
+   if (mrt_dump_hdr_se(, peer, MSG_PROTOCOL_BGP4MP_ET, subtype,
pkglen, incoming) == -1)
return;
 
@@ -128,7 +128,7 @@ mrt_dump_state(struct mrt *mrt, u_int16_
if (peer->capa.neg.as4byte)
subtype = BGP4MP_STATE_CHANGE_AS4;
 
-   if (mrt_dump_hdr_se(, peer, MSG_PROTOCOL_BGP4MP, subtype,
+   if (mrt_dump_hdr_se(, peer, MSG_PROTOCOL_BGP4MP_ET, subtype,
2 * sizeof(short), 0) == -1)
return;
 
@@ -684,17 +684,17 @@ int
 mrt_dump_hdr_se(struct ibuf ** bp, struct peer *peer, u_int16_t type,
 u_int16_t subtype, u_int32_t len, int swap)
 {
-   time_t  now;
+   struct timespec time;
 
-   if ((*bp = ibuf_dynamic(MRT_HEADER_SIZE, MRT_HEADER_SIZE +
+   if ((*bp = ibuf_dynamic(MRT_ET_HEADER_SIZE, MRT_ET_HEADER_SIZE +
MRT_BGP4MP_AS4_IPv6_HEADER_SIZE + len)) == NULL) {
log_warn("mrt_dump_hdr_se: ibuf_dynamic error");
return (-1);
}
 
-   now = time(NULL);
+   clock_gettime(CLOCK_REALTIME, );
 
-   DUMP_LONG(*bp, now);
+   DUMP_LONG(*bp, time.tv_sec);
DUMP_SHORT(*bp, type);
DUMP_SHORT(*bp, subtype);
 
@@ -702,16 +702,16 @@ mrt_dump_hdr_se(struct ibuf ** bp, struc
case AF_INET:
if (subtype == BGP4MP_STATE_CHANGE_AS4 ||
subtype == BGP4MP_MESSAGE_AS4)
-   len += MRT_BGP4MP_AS4_IPv4_HEADER_SIZE;
+   len += MRT_BGP4MP_ET_AS4_IPv4_HEADER_SIZE;
else
-   len += MRT_BGP4MP_IPv4_HEADER_SIZE;
+   len += MRT_BGP4MP_ET_IPv4_HEADER_SIZE;
break;
case AF_INET6:
if (subtype == BGP4MP_STATE_CHANGE_AS4 ||
subtype == BGP4MP_MESSAGE_AS4)
-   len += MRT_BGP4MP_AS4_IPv6_HEADER_SIZE;
+   len += MRT_BGP4MP_ET_AS4_IPv6_HEADER_SIZE;
else
-   len += MRT_BGP4MP_IPv6_HEADER_SIZE;
+   len += MRT_BGP4MP_ET_IPv6_HEADER_SIZE;
break;
case 0:
goto fail;
@@ -721,6 +721,8 @@ mrt_dump_hdr_se(struct ibuf ** bp, struc
}
 
DUMP_LONG(*bp, len);
+   /* milisecond field use by the _ET format */
+   DUMP_LONG(*bp, time.tv_nsec / 1000);
 
if (subtype == BGP4MP_STATE_CHANGE_AS4 ||
subtype == BGP4MP_MESSAGE_AS4) {
Index: mrt.h
===
RCS file: /cvs/src/usr.sbin/bgpd/mrt.h,v
retrieving revision 1.31
diff -u -p -r1.31 mrt.h
--- mrt.h   19 Sep 2011 11:19:32 -  1.31
+++ mrt.h   13 Jul 2018 13:54:07 -
@@ -39,6 +39,7 @@
  * length field. Which is accounted in the length field.
  */
 #define MRT_HEADER_SIZE12
+#define MRT_ET_HEADER_SIZE 16
 
 struct mrt_hdr {
u_int32_t   timestamp;
@@ -87,11 +88,15 @@ enum MRT_BGP4MP_SUBTYPES {
 };
 
 /* size of the BGP4MP headers without payload */
-#define MRT_BGP4MP_IPv4_HEADER_SIZE16
-#define MRT_BGP4MP_IPv6_HEADER_SIZE40
+#define MRT_BGP4MP_IPv4_HEADER_SIZE16
+#define MRT_BGP4MP_IPv6_HEADER_SIZE40
+#define MRT_BGP4MP_ET_IPv4_HEADER_SIZE 20
+#define MRT_BGP4MP_ET_IPv6_HEADER_SIZE 44
 /* 4-byte AS variants of the previous */
-#define MRT_BGP4MP_AS4_IPv4_HEADER_SIZE20
-#define MRT_BGP4MP_AS4_IPv6_HEADER_SIZE44
+#define MRT_BGP4MP_AS4_IPv4_HEADER_SIZE20
+#define MRT_BGP4MP_AS4_IPv6_HEADER_SIZE44
+#define MRT_BGP4MP_ET_AS4_IPv4_HEADER_SIZE 24
+#define 

Re: newaliases.8: update to current reality

2018-07-16 Thread Jason McIntyre
On Mon, Jul 16, 2018 at 11:03:45AM -0600, Todd C. Miller wrote:
> On Mon, 16 Jul 2018 17:54:17 +0100, Jason McIntyre wrote:
> 
> > > ===
> > > RCS file: /cvs/src/usr.sbin/smtpd/newaliases.8,v
> > > retrieving revision 1.11
> > > diff -u -p -u -r1.11 newaliases.8
> > > --- usr.sbin/smtpd/newaliases.8   22 Dec 2015 17:52:21 -  1.11
> > > +++ usr.sbin/smtpd/newaliases.8   16 Jul 2018 16:33:41 -
> > > @@ -20,21 +20,22 @@
> > >  .Os
> > >  .Sh NAME
> > >  .Nm newaliases
> > > -.Nd rebuild the database for the mail aliases file
> > > +.Nd rebuild the mail aliases database
> >
> > mail aliases *file*, not database, no?
> 
> Not exactly, a file can be a "database" too.  The trouble here is
> that newaliases is performing two very different tasks depending
> on whether smtpd.conf is configured to use a plain text file or a
> db file.
> 
> I'm open to a better description but it is hard to describe the
> behavior of both modes without being overly generic.
> 
> Perhaps simply:
> 
> .Nd rebuild mail aliases
> 
>  - todd
> 

i like this better myself, but whatever you think best.
jmc



Re: newaliases.8: update to current reality

2018-07-16 Thread Todd C. Miller
On Mon, 16 Jul 2018 17:54:17 +0100, Jason McIntyre wrote:

> > ===
> > RCS file: /cvs/src/usr.sbin/smtpd/newaliases.8,v
> > retrieving revision 1.11
> > diff -u -p -u -r1.11 newaliases.8
> > --- usr.sbin/smtpd/newaliases.8 22 Dec 2015 17:52:21 -  1.11
> > +++ usr.sbin/smtpd/newaliases.8 16 Jul 2018 16:33:41 -
> > @@ -20,21 +20,22 @@
> >  .Os
> >  .Sh NAME
> >  .Nm newaliases
> > -.Nd rebuild the database for the mail aliases file
> > +.Nd rebuild the mail aliases database
>
> mail aliases *file*, not database, no?

Not exactly, a file can be a "database" too.  The trouble here is
that newaliases is performing two very different tasks depending
on whether smtpd.conf is configured to use a plain text file or a
db file.

I'm open to a better description but it is hard to describe the
behavior of both modes without being overly generic.

Perhaps simply:

.Nd rebuild mail aliases

 - todd



Re: newaliases.8: update to current reality

2018-07-16 Thread Jason McIntyre
On Mon, Jul 16, 2018 at 10:36:35AM -0600, Todd C. Miller wrote:
> Now that aliases in smtpd.conf default to plain text files and not
> db files we don't want to tell people to run makemap instead of
> newaliases.
> 
>  - todd
> 

evening.

comments inline:

> Index: usr.sbin/smtpd/newaliases.8
> ===
> RCS file: /cvs/src/usr.sbin/smtpd/newaliases.8,v
> retrieving revision 1.11
> diff -u -p -u -r1.11 newaliases.8
> --- usr.sbin/smtpd/newaliases.8   22 Dec 2015 17:52:21 -  1.11
> +++ usr.sbin/smtpd/newaliases.8   16 Jul 2018 16:33:41 -
> @@ -20,21 +20,22 @@
>  .Os
>  .Sh NAME
>  .Nm newaliases
> -.Nd rebuild the database for the mail aliases file
> +.Nd rebuild the mail aliases database

mail aliases *file*, not database, no?

>  .Sh SYNOPSIS
>  .Nm newaliases
>  .Op Fl f Ar file
>  .Sh DESCRIPTION
> +The
>  .Nm
> -rebuilds the random access database for the mail aliases file,
> -the location of which is defined in
> -.Xr smtpd.conf 5 ,
> -and which by default is
> -.Pa /etc/mail/aliases .
> -If using database (db) files
> -this utility must be run every time the
> +utility makes changes to the mail aliases file visible to
> +.Xr smtpd 8 .
> +It should be run every time the
>  .Xr aliases 5
>  file is changed.
> +The location of the alias file is defined in
> +.Xr smtpd.conf 5 ,
> +and defaults to
> +.Pa /etc/mail/aliases .
>  .Pp
>  The options are as follows:
>  .Bl -tag -width Ds
> @@ -46,12 +47,21 @@ instead of the default
>  .Pa /etc/mail/smtpd.conf .
>  .El
>  .Pp
> -Note: this utility is provided for sendmail compatibility.
> -The preferred way of rebuilding the database is with
> -.Xr makemap 8 :
> +If using database (db) files,
> +.Nm
> +is equivalent to running
> +.Xr makemap 8 as follows:

"as follows" should be on a new line

>  .Bd -literal -offset indent
>  # makemap -t aliases /etc/mail/aliases
>  .Ed
> +.Pp
> +If using plain text files,
> +.Nm
> +is equivalent to running
> +.Xr smtpctl 8 as follows:

ditto

except for this, i think your diff is good.
jmc

> +.Bd -literal -offset indent
> +# smtpctl update table aliases
> +.Ed
>  .Sh FILES
>  .Bl -tag -width "/etc/mail/aliasesXXX" -compact
>  .It Pa /etc/mail/aliases
> @@ -63,7 +73,9 @@ List of virtual host aliases.
>  .Ex -std newaliases
>  .Sh SEE ALSO
>  .Xr smtpd.conf 5 ,
> -.Xr makemap 8
> +.Xr makemap 8 ,
> +.Xr smtpctl 8 ,
> +.Xr smtpd 8
>  .Sh HISTORY
>  The
>  .Nm
> 



newaliases.8: update to current reality

2018-07-16 Thread Todd C. Miller
Now that aliases in smtpd.conf default to plain text files and not
db files we don't want to tell people to run makemap instead of
newaliases.

 - todd

Index: usr.sbin/smtpd/newaliases.8
===
RCS file: /cvs/src/usr.sbin/smtpd/newaliases.8,v
retrieving revision 1.11
diff -u -p -u -r1.11 newaliases.8
--- usr.sbin/smtpd/newaliases.8 22 Dec 2015 17:52:21 -  1.11
+++ usr.sbin/smtpd/newaliases.8 16 Jul 2018 16:33:41 -
@@ -20,21 +20,22 @@
 .Os
 .Sh NAME
 .Nm newaliases
-.Nd rebuild the database for the mail aliases file
+.Nd rebuild the mail aliases database
 .Sh SYNOPSIS
 .Nm newaliases
 .Op Fl f Ar file
 .Sh DESCRIPTION
+The
 .Nm
-rebuilds the random access database for the mail aliases file,
-the location of which is defined in
-.Xr smtpd.conf 5 ,
-and which by default is
-.Pa /etc/mail/aliases .
-If using database (db) files
-this utility must be run every time the
+utility makes changes to the mail aliases file visible to
+.Xr smtpd 8 .
+It should be run every time the
 .Xr aliases 5
 file is changed.
+The location of the alias file is defined in
+.Xr smtpd.conf 5 ,
+and defaults to
+.Pa /etc/mail/aliases .
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
@@ -46,12 +47,21 @@ instead of the default
 .Pa /etc/mail/smtpd.conf .
 .El
 .Pp
-Note: this utility is provided for sendmail compatibility.
-The preferred way of rebuilding the database is with
-.Xr makemap 8 :
+If using database (db) files,
+.Nm
+is equivalent to running
+.Xr makemap 8 as follows:
 .Bd -literal -offset indent
 # makemap -t aliases /etc/mail/aliases
 .Ed
+.Pp
+If using plain text files,
+.Nm
+is equivalent to running
+.Xr smtpctl 8 as follows:
+.Bd -literal -offset indent
+# smtpctl update table aliases
+.Ed
 .Sh FILES
 .Bl -tag -width "/etc/mail/aliasesXXX" -compact
 .It Pa /etc/mail/aliases
@@ -63,7 +73,9 @@ List of virtual host aliases.
 .Ex -std newaliases
 .Sh SEE ALSO
 .Xr smtpd.conf 5 ,
-.Xr makemap 8
+.Xr makemap 8 ,
+.Xr smtpctl 8 ,
+.Xr smtpd 8
 .Sh HISTORY
 The
 .Nm



Re: added flush and quiet options to script(1)

2018-07-16 Thread bijan

On 07/16/18 18:11, bijan wrote:

On 07/13/18 22:35, bijan wrote:

Hi tech.

While trying to test liveshell[1], I noticed the script(1) from base is
missing the -f option, flushing the output after each write, which is
kinda critical for monitoring the output file by another process. the
Linux script utility uses fflush(3) after each write (duhh) but I'm not
sure if anything more than removing buffering operation from
the stream is necessary.

So here's the diff which is working for me


ping! no one is interested or am I missing something? added -f for quiet
option out of boredom

Now that I noticed my mail client was messing with the diff's format (after
hitting send), I should first apologize for the unnecessary noise on the 
list.

Just checked that attaching the Diff is safe to call it a day for now.

Thank you

--
Bijan Ebrahimi
diff --git usr.bin/script/script.1 usr.bin/script/script.1
index f10ec2d4b..55e7e6868 100644
--- usr.bin/script/script.1
+++ usr.bin/script/script.1
@@ -38,7 +38,7 @@
 .Nd make typescript of terminal session
 .Sh SYNOPSIS
 .Nm script
-.Op Fl a
+.Op Fl afq
 .Op Fl c Ar command
 .Op Ar file
 .Sh DESCRIPTION
@@ -71,6 +71,10 @@ Run
 .Ar command
 instead of an interactive shell.
 To run a command with arguments, enclose both in quotes.
+.It Fl f
+Flush the output after each write.
+.It Fl q
+Only print errors and warnings.
 .El
 .Pp
 The script ends when the forked program exits (a control-D
diff --git usr.bin/script/script.c usr.bin/script/script.c
index 2e4173941..a58b618d5 100644
--- usr.bin/script/script.c
+++ usr.bin/script/script.c
@@ -85,7 +85,7 @@ volatile sig_atomic_t sigdeadstatus;
 volatile sig_atomic_t flush;
 
 struct	termios tt;
-int		istty;
+int		istty, qflg;
 
 __dead void done(int);
 void dooutput(void);
@@ -104,11 +104,11 @@ main(int argc, char *argv[])
 	char ibuf[BUFSIZ];
 	char *cmd;
 	ssize_t cc, off;
-	int aflg, ch;
+	int aflg, fflg, ch;
 
 	cmd = NULL;
-	aflg = 0;
-	while ((ch = getopt(argc, argv, "ac:")) != -1)
+	aflg = fflg = 0;
+	while ((ch = getopt(argc, argv, "ac:fq")) != -1)
 		switch(ch) {
 		case 'a':
 			aflg = 1;
@@ -116,8 +116,14 @@ main(int argc, char *argv[])
 		case 'c':
 			cmd = optarg;
 			break;
+		case 'f':
+			fflg = 1;
+			break;
+		case 'q':
+			qflg = 1;
+			break;
 		default:
-			fprintf(stderr, "usage: %s [-a] [-c command] [file]\n",
+			fprintf(stderr, "usage: %s [-afq] [-c command] [file]\n",
 			__progname);
 			exit(1);
 		}
@@ -132,6 +138,9 @@ main(int argc, char *argv[])
 	if ((fscript = fopen(fname, aflg ? "a" : "w")) == NULL)
 		err(1, "%s", fname);
 
+	if (fflg)
+		setvbuf(fscript, NULL, _IONBF, 0);
+
 	if (isatty(0)) {
 		if (tcgetattr(STDIN_FILENO, ) == 0 &&
 		ioctl(STDIN_FILENO, TIOCGWINSZ, ) == 0)
@@ -140,7 +149,8 @@ main(int argc, char *argv[])
 	if (openpty(, , NULL, , ) == -1)
 		err(1, "openpty");
 
-	(void)printf("Script started, output file is %s\n", fname);
+	if (qflg)
+		(void)printf("Script started, output file is %s\n", fname);
 	if (istty) {
 		struct termios rtt = tt;
 
@@ -350,7 +360,8 @@ done(int eval)
 	} else {
 		if (istty)
 			(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, );
-		(void)printf("Script done, output file is %s\n", fname);
+		if (qflg)
+			(void)printf("Script done, output file is %s\n", fname);
 	}
 	exit(eval);
 }


unveil: incorrect type flags on unvname_new()

2018-07-16 Thread Sebastien Marie
Hi,

While reviewing unveil(2) code, I found an incorrect type on
unvname_new() function: flags argument should be uint64_t.

It is called by unveil_add_name() which uses uint64_t for flags, and
store the value in struct unvname un_flags member which is uint64_t.

Thanks.
-- 
Sebastien Marie


Index: kern/kern_unveil.c
===
RCS file: /cvs/src/sys/kern/kern_unveil.c,v
retrieving revision 1.2
diff -u -p -r1.2 kern_unveil.c
--- kern/kern_unveil.c  13 Jul 2018 13:47:41 -  1.2
+++ kern/kern_unveil.c  16 Jul 2018 13:08:40 -
@@ -50,7 +50,7 @@ unvname_compare(const struct unvname *n1
 }
 
 struct unvname *
-unvname_new(const char *name, size_t size, int flags)
+unvname_new(const char *name, size_t size, uint64_t flags)
 {
struct unvname *ret = malloc(sizeof(struct unvname), M_PROC, M_WAITOK);
ret->un_name = malloc(size, M_PROC, M_WAITOK);



Re: add -f option to script(1)

2018-07-16 Thread bijan

On 07/13/18 22:35, bijan wrote:

Hi tech.

While trying to test liveshell[1], I noticed the script(1) from base is
missing the -f option, flushing the output after each write, which is
kinda critical for monitoring the output file by another process. the
Linux script utility uses fflush(3) after each write (duhh) but I'm not
sure if anything more than removing buffering operation from
the stream is necessary.

So here's the diff which is working for me


ping! no one is interested or am I missing something? added -f for quiet
option out of boredom

--
Bijan Ebrahimi

diff --git usr.bin/script/script.1 usr.bin/script/script.1
index f10ec2d4b..55e7e6868 100644
--- usr.bin/script/script.1
+++ usr.bin/script/script.1
@@ -38,7 +38,7 @@
 .Nd make typescript of terminal session
 .Sh SYNOPSIS
 .Nm script
-.Op Fl a
+.Op Fl afq
 .Op Fl c Ar command
 .Op Ar file
 .Sh DESCRIPTION
@@ -71,6 +71,10 @@ Run
 .Ar command
 instead of an interactive shell.
 To run a command with arguments, enclose both in quotes.
+.It Fl f
+Flush the output after each write.
+.It Fl q
+Only print errors and warnings.
 .El
 .Pp
 The script ends when the forked program exits (a control-D
diff --git usr.bin/script/script.c usr.bin/script/script.c
index 2e4173941..a58b618d5 100644
--- usr.bin/script/script.c
+++ usr.bin/script/script.c
@@ -85,7 +85,7 @@ volatile sig_atomic_t sigdeadstatus;
 volatile sig_atomic_t flush;
 
 struct	termios tt;

-intistty;
+intistty, qflg;
 
 __dead void done(int);

 void dooutput(void);
@@ -104,11 +104,11 @@ main(int argc, char *argv[])
char ibuf[BUFSIZ];
char *cmd;
ssize_t cc, off;
-   int aflg, ch;
+   int aflg, fflg, ch;
 
 	cmd = NULL;

-   aflg = 0;
-   while ((ch = getopt(argc, argv, "ac:")) != -1)
+   aflg = fflg = 0;
+   while ((ch = getopt(argc, argv, "ac:fq")) != -1)
switch(ch) {
case 'a':
aflg = 1;
@@ -116,8 +116,14 @@ main(int argc, char *argv[])
case 'c':
cmd = optarg;
break;
+   case 'f':
+   fflg = 1;
+   break;
+   case 'q':
+   qflg = 1;
+   break;
default:
-   fprintf(stderr, "usage: %s [-a] [-c command] [file]\n",
+   fprintf(stderr, "usage: %s [-afq] [-c command] 
[file]\n",
__progname);
exit(1);
}
@@ -132,6 +138,9 @@ main(int argc, char *argv[])
if ((fscript = fopen(fname, aflg ? "a" : "w")) == NULL)
err(1, "%s", fname);
 
+	if (fflg)

+   setvbuf(fscript, NULL, _IONBF, 0);
+
if (isatty(0)) {
if (tcgetattr(STDIN_FILENO, ) == 0 &&
ioctl(STDIN_FILENO, TIOCGWINSZ, ) == 0)
@@ -140,7 +149,8 @@ main(int argc, char *argv[])
if (openpty(, , NULL, , ) == -1)
err(1, "openpty");
 
-	(void)printf("Script started, output file is %s\n", fname);

+   if (qflg)
+   (void)printf("Script started, output file is %s\n", fname);
if (istty) {
struct termios rtt = tt;
 
@@ -350,7 +360,8 @@ done(int eval)

} else {
if (istty)
(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, );
-   (void)printf("Script done, output file is %s\n", fname);
+   if (qflg)
+   (void)printf("Script done, output file is %s\n", fname);
}
exit(eval);
 }



Re: [patch] smtpd: missing space for "from local" with -T rules

2018-07-16 Thread Lauri Tirkkonen
On Wed, Jun 20 2018 12:19:43 +0300, Lauri Tirkkonen wrote:
> "from local" rules are missing a space when printed out with -T rules.
> 
> diff --git a/usr.sbin/smtpd/to.c b/usr.sbin/smtpd/to.c
> index e1d399d74f2..27d5321408f 100644
> --- a/usr.sbin/smtpd/to.c
> +++ b/usr.sbin/smtpd/to.c
> @@ -461,7 +461,7 @@ rule_to_text(struct rule *r)
>   if (strcmp(r->table_from, "") == 0)
>   (void)strlcat(buf, "from any ", sizeof buf);
>   else if (strcmp(r->table_from, "") == 0)
> - (void)strlcat(buf, "from local", sizeof buf);
> + (void)strlcat(buf, "from local ", sizeof buf);
>   else {
>   (void)strlcat(buf, "from src ", sizeof buf);
>   (void)strlcat(buf, r->table_from, sizeof buf);

ping?

-- 
Lauri Tirkkonen | lotheac @ IRCnet



xidle: launching program on timeout without active-area

2018-07-16 Thread Sebastien Marie
Hi,

I am looking at a way to auto-logout some workstation on inactivity.

xidle(1) seems great for such purpose. But I didn't found a way to just
use timeout and not also an active area (a corner where the program is
launched if pointer stays inside few seconds).

The following diff tries to implement a way to disable the active area
without being too intrusive.

For that, I used the `delay' parameter ("Specify the number of seconds
the pointer has to be in the given position before running the
program."), to allow value -1, and make it to discard the event.

Does it make sens ? Or any proposition to more straighfull approch ?

Thanks.
-- 
Sebastien Marie


Index: xidle.1
===
RCS file: /cvs/xenocara/app/xidle/xidle.1,v
retrieving revision 1.4
diff -u -p -r1.4 xidle.1
--- xidle.1 9 Nov 2017 19:13:03 -   1.4
+++ xidle.1 16 Jul 2018 09:25:40 -
@@ -63,6 +63,7 @@ The default is 2 pixels.
 Specify the number of seconds the pointer has to be in the given position
 before running the program.
 The default is 2 seconds.
+The value -1 makes the activation of program on position to be disabled.
 .It Fl display Ar display
 This argument allows you to specify the server to connect to; see
 .Xr X 7 .
Index: xidle.c
===
RCS file: /cvs/xenocara/app/xidle/xidle.c,v
retrieving revision 1.5
diff -u -p -r1.5 xidle.c
--- xidle.c 20 Aug 2017 16:43:25 -  1.5
+++ xidle.c 16 Jul 2018 09:23:18 -
@@ -303,7 +303,7 @@ fail:   errx(1, "illegal value -- %s", (
}
if (getres(, rdb, "delay", "Delay")) {
*delay = strtol((char *)value.addr, , 10);
-   if (*p || *delay < 0)
+   if (*p || *delay < -1)
goto fail;
}
if (getres(, rdb, "position", "Position")) {
@@ -414,6 +414,9 @@ main(int argc, char **argv)
break;
 
case EnterNotify:
+   if (delay == -1)
+   break;
+
sleep(delay);
 
XQueryPointer(x.dpy, x.win, ,



Re: IP_SENDSRCADDR cmsg_len and dnsmasq

2018-07-16 Thread Vincent Gross
On Thu, 12 Jul 2018 19:54:26 +0200
Alexander Bluhm  wrote:

> 
> If it is a temporary problem, that will go away when the content
> of the socket buffer is sent away, we should block or return
> EWOULDBLOCK.  For a permanent problem return EMSGSIZE.  Non atomic
> operations can be split in smaller chunks, so there are no permanent
> problems.  Control messages are considerd atomic.  AF_UNIX needs
> special treatment as file descriptor passing is dificult.  On top
> of that consider integer overflow.
> 
> revision 1.100
> date: 2012/04/24 16:35:08;  author: deraadt;  state: Exp;  lines:
> +13 -3; In sosend() for AF_UNIX control message sending, correctly
> calculate the size (internalized ones can be larger on some
> architectures) for fitting into the socket.  Avoid getting confused
> by sb_hiwat as well. This fixes a variety of issues where sendmsg()
> would fail to deliver a fd set or fail to wait; even leading to file
> leakage. Worked on this with claudio for about a week...
> 
> revision 1.145
> date: 2016/01/06 10:06:50;  author: stefan;  state: Exp;  lines:
> +27 -30; Prevent integer overflows in sosend() and soreceive() by
> converting min()+uiomovei() to ulmin()+uiomove() and re-arranging
> space computations in sosend(). The soreceive() part was also
> reported by Martin Natano. ok bluhm@ and also discussed with tedu@
> 
> So first of all we should split the AF_UNIX cases to keep it readable.
> And I don't want to change the AF_UNIX code as the commit message
> indicates that it was hard to develop the current solution.
> 
> From the bug reports it seems that we should check that the UDP
> packets and the IP_SENDSRCADDR fit into the socket buffer.  If not
> it is a permanent EMSGSIZE error.  So make sure that resid + clen
> <= so->so_snd.sb_hiwat.  Then write it the other way around to
> prevent signed integer overflow.
> 
> The result of this considerations is the diff below.  I have not
> tested it.  Does the orignal bug go away with it?  Some hackathons
> ago jeremy@ mentioned that the ruby test suite found a bug in this
> area.  So maybe we should try it.
> 
> Does this make sense?
> 
> bluhm
> 
> Index: kern/uipc_socket.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/kern/uipc_socket.c,v
> retrieving revision 1.225
> diff -u -p -r1.225 uipc_socket.c
> --- kern/uipc_socket.c5 Jul 2018 14:45:07 -   1.225
> +++ kern/uipc_socket.c12 Jul 2018 17:24:28 -
> @@ -462,10 +462,14 @@ restart:
>   space = sbspace(so, >so_snd);
>   if (flags & MSG_OOB)
>   space += 1024;
> - if ((atomic && resid > so->so_snd.sb_hiwat) ||
> - (so->so_proto->pr_domain->dom_family != AF_UNIX
> &&
> - clen > so->so_snd.sb_hiwat))
> - snderr(EMSGSIZE);
> + if (so->so_proto->pr_domain->dom_family == AF_UNIX) {
> + if (atomic && resid > so->so_snd.sb_hiwat)
> + snderr(EMSGSIZE);
> + } else {
> + if (clen > so->so_snd.sb_hiwat ||
> + (atomic && resid > so->so_snd.sb_hiwat -
> clen))
> + snderr(EMSGSIZE);
> + }
>   if (space < clen ||
>   (space - clen < resid &&
>   (atomic || space < so->so_snd.sb_lowat))) {

It is indeed much easier to parse. Kudos on spotting the potential
overflow. Ok vgross@

I have a regression test for this based on Alexander Markert code +
rework by mpi@, do you want me to commit it right now ?



xhci typo in comment

2018-07-16 Thread Michael W. Bombardieri
Hello,

When studying some usb code I noticed a couple of the comments
didn't read well. Does this look better?

- Michael


Index: xhci.c
===
RCS file: /cvs/src/sys/dev/usb/xhci.c,v
retrieving revision 1.86
diff -u -p -u -r1.86 xhci.c
--- xhci.c  13 May 2018 06:58:42 -  1.86
+++ xhci.c  16 Jul 2018 06:02:02 -
@@ -764,7 +764,7 @@ xhci_event_xfer(struct xhci_softc *sc, u
 * If this is not the last TRB of a transfer, we should
 * theoretically clear the IOC at the end of the chain
 * but the HC might have already processed it before we
-* had a change to schedule the softinterrupt.
+* had a chance to schedule the softinterrupt.
 */
xx = (struct xhci_xfer *)xfer;
if (xx->index != trb_idx) {
@@ -1043,7 +1043,7 @@ xhci_pipe_open(struct usbd_pipe *pipe)
 
/*
 * Our USBD Bus Interface is pipe-oriented but for most of the
-* operations we need to access a device context, so keep trace
+* operations we need to access a device context, so keep track
 * of the slot ID in every pipe.
 */
if (slot == 0)
@@ -1327,7 +1327,7 @@ xhci_pipe_init(struct xhci_softc *sc, st
 * be in the ENABLED state.  Issue an "Address Device"
 * with BSR=1 to put the device in the DEFAULT state.
 * We cannot jump directly to the ADDRESSED state with
-* BSR=0 because some Low/Full speed devices wont accept
+* BSR=0 because some Low/Full speed devices won't accept
 * a SET_ADDRESS command before we've read their device
 * descriptor.
 */
@@ -2047,7 +2047,7 @@ xhci_abort_xfer(struct usbd_xfer *xfer, 
 * At this stage the endpoint has been stopped, so update its
 * dequeue pointer past the last TRB of the transfer.
 *
-* Note: This assume that only one transfer per endpoint has
+* Note: This assumes that only one transfer per endpoint has
 *   pending TRBs on the ring.
 */
xhci_cmd_set_tr_deq_async(sc, xp->slot, xp->dci,