Re: Adding current bandwidth to ftp(1)

2018-04-13 Thread Christian Barthel
Stuart Henderson  writes:

> On 2018/04/09 09:27, Matthias Schmidt wrote:
>> Hi Christian,
>> 
>> On 08.04.2018 22:42, Christian Barthel wrote:
>> > Hello,
>> > 
>> > i am often sitting behind a very slow internet link and thought, it
>> > might be useful to show the current bandwidth while downloading
>> > something with ftp(1).
>> 
>> Since I sometimes work with crappy WLANs/connections I very much appreciate
>> your patch!
>
> Do you know you can just send SIGINFO (often bound to ^T) to get the same
> information?

Hi Stuart, 
Hi Matthias, 

thanks for your replies.  I've tested it with 80x25 terminals and also
checked the bsd.rd installer image.  To me, it looks ok.

I also know about SIGINFO but in my particular case, it was useful to
print the bandwidth all the time.  But I guess that most users don't
need that information and having SIGINFO/^T is sufficient.

Thanks for your comments,
Christian



net/if.h missing includes

2018-04-13 Thread Jeremie Courreges-Anglas

 isn't standalone if __BSD_VISIBLE is defined (the default).

This has caused fallout earlier in the ports tree:
  
https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/net/samba/patches/patch-lib_replace_wscript.diff?r1=1.7&r2=1.8
  
https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/ports/net/dnsdist/patches/patch-dnsdist-lua_cc?rev=1.1&content-type=text/plain

Went in an mkr on amd64.  ok?


Index: sys/net/if.h
===
RCS file: /cvs/src/sys/net/if.h,v
retrieving revision 1.192
diff -u -p -r1.192 if.h
--- sys/net/if.h19 Feb 2018 04:43:48 -  1.192
+++ sys/net/if.h2 Apr 2018 18:08:03 -
@@ -59,6 +59,10 @@ __END_DECLS
 
 #if __BSD_VISIBLE
 
+#include 
+#include 
+#include 
+
 /*
  * Structure used to query names of interface cloners.
  */


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: Eliminate trailing whitespace & typo in chmod

2018-04-13 Thread Job Snijders
https://en.wikipedia.org/wiki/If_and_only_if

As a non-native speaker, it took some years before I realized the use of
“iff” is not a typo.

Kind regards,

Job


Re: Eliminate trailing whitespace & typo in chmod

2018-04-13 Thread Stuart Henderson
On 2018/04/13 20:01, llgx...@gmail.com wrote:
> -  * on the level: follow it iff it's a command line arg.
> +  * on the level: follow it if it's a command line arg.

iff = "if and only if"

http://mathworld.wolfram.com/Iff.html
https://en.wikipedia.org/wiki/If_and_only_if



Eliminate trailing whitespace & typo in chmod

2018-04-13 Thread llgxela
> > Index: chmod.c
> > ===
> > RCS file: /cvs/src/bin/chmod/chmod.c,v
> > retrieving revision 1.42
> > diff -u -p -u -p -r1.42 chmod.c
> > --- chmod.c 28 May 2017 08:03:36 -  1.42
> > +++ chmod.c 13 Apr 2018 17:46:36 -
> > @@ -253,10 +253,10 @@ done:
> >
> > /*
> >  * For -RH, the decision of how to handle symlinks depends
> > -* on the level: follow it iff it's a command line arg.
> > +* on the level: follow it if it's a command line arg.
> >  */
> 
> "iff" is not a typo.

Oops, sorry, my bad. I hope the following one is ok:

Index: chmod.c
===
RCS file: /cvs/src/bin/chmod/chmod.c,v
retrieving revision 1.42
diff -u -p -u -p -r1.42 chmod.c
--- chmod.c 28 May 2017 08:03:36 -  1.42
+++ chmod.c 13 Apr 2018 19:07:58 -
@@ -256,7 +256,7 @@ done:
 * on the level: follow it iff it's a command line arg.
 */
if (fts_options & FTS_COMFOLLOW) {
-   atflags = p->fts_level == FTS_ROOTLEVEL ? 0 : 
+   atflags = p->fts_level == FTS_ROOTLEVEL ? 0 :
AT_SYMLINK_NOFOLLOW;
}
 



Re: vmd(4) close vmm parent socket

2018-04-13 Thread Mike Larkin
On Fri, Apr 13, 2018 at 11:29:06AM +0200, Martijn van Duren wrote:
> Hello tech@,
> 
> Playing with vmd I noticed that a vm process has vmm's socket to the
> parent process still open.
> 
> Patch below works for me.
> 
> OK?
> 
> martijn@
> 
> Index: vmm.c
> ===
> RCS file: /cvs/src/usr.sbin/vmd/vmm.c,v
> retrieving revision 1.80
> diff -u -p -r1.80 vmm.c
> --- vmm.c 5 Feb 2018 05:01:08 -   1.80
> +++ vmm.c 13 Apr 2018 09:27:14 -
> @@ -664,6 +664,7 @@ vmm_start_vm(struct imsg *imsg, uint32_t
>   } else {
>   /* Child */
>   close(fds[0]);
> + close(PROC_PARENT_SOCK_FILENO);
>  
>   ret = start_vm(vm, fds[1]);
>  
> 

sure



Re: Eliminate trailing whitespace & typo in chmod

2018-04-13 Thread Theo de Raadt
>Index: chmod.c
>===
>RCS file: /cvs/src/bin/chmod/chmod.c,v
>retrieving revision 1.42
>diff -u -p -u -p -r1.42 chmod.c
>--- chmod.c28 May 2017 08:03:36 -  1.42
>+++ chmod.c13 Apr 2018 17:46:36 -
>@@ -253,10 +253,10 @@ done:
> 
>   /*
>* For -RH, the decision of how to handle symlinks depends
>-   * on the level: follow it iff it's a command line arg.
>+   * on the level: follow it if it's a command line arg.
>*/

"iff" is not a typo.



Eliminate trailing whitespace & typo in chmod

2018-04-13 Thread llgxela
Index: chmod.c
===
RCS file: /cvs/src/bin/chmod/chmod.c,v
retrieving revision 1.42
diff -u -p -u -p -r1.42 chmod.c
--- chmod.c 28 May 2017 08:03:36 -  1.42
+++ chmod.c 13 Apr 2018 17:46:36 -
@@ -253,10 +253,10 @@ done:
 
/*
 * For -RH, the decision of how to handle symlinks depends
-* on the level: follow it iff it's a command line arg.
+* on the level: follow it if it's a command line arg.
 */
if (fts_options & FTS_COMFOLLOW) {
-   atflags = p->fts_level == FTS_ROOTLEVEL ? 0 : 
+   atflags = p->fts_level == FTS_ROOTLEVEL ? 0 :
AT_SYMLINK_NOFOLLOW;
}
 



Re: ksh: count $SECONDS with monotonic clock

2018-04-13 Thread Todd C. Miller
On Fri, 13 Apr 2018 19:42:51 +0200, Jeremie Courreges-Anglas wrote:

> The diff uses timespecsub:

Ah, OK.  That's fine then.

 - todd



Re: ksh: count $SECONDS with monotonic clock

2018-04-13 Thread Jeremie Courreges-Anglas
On Fri, Apr 13 2018, "Todd C. Miller"  wrote:
> On Fri, 13 Apr 2018 11:11:04 -0500, Scott Cheloha wrote:
>
>> So that $SECONDS advances uniformly, independent of the system clock.
>
> Why are you including sys/time.h?  For struct timespect you only
> need time.h which is already included.
>
> In general, you only need sys/time.h for struct timeval or for some
> of the time-related macros.

The diff uses timespecsub:

@@ -921,8 +922,13 @@ getspec(struct tbl *vp)
 * has been set - don't do anything in this case
 * (see initcoms[] in main.c).
 */
-   if (vp->flag & ISSET)
-   setint(vp, (int64_t)(time(NULL) - seconds));
+   if (vp->flag & ISSET) {
+   struct timespec difference, now;
+
+   clock_gettime(CLOCK_MONOTONIC, &now);
+   timespecsub(&now, &seconds, &difference);
+   setint(vp, (int64_t)difference.tv_sec);
+   }
vp->flag |= SPECIAL;
break;
case V_RANDOM:


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: ksh: count $SECONDS with monotonic clock

2018-04-13 Thread Todd C. Miller
On Fri, 13 Apr 2018 11:11:04 -0500, Scott Cheloha wrote:

> So that $SECONDS advances uniformly, independent of the system clock.

Why are you including sys/time.h?  For struct timespect you only
need time.h which is already included.

In general, you only need sys/time.h for struct timeval or for some
of the time-related macros.

 - todd



Re: ksh: count $SECONDS with monotonic clock

2018-04-13 Thread Jeremie Courreges-Anglas
On Fri, Apr 13 2018, Scott Cheloha  wrote:
> So that $SECONDS advances uniformly, independent of the system clock.
>
> ok?

ok jca@

> --
> Scott Cheloha
>
> P.S. Similar change forthcoming for $MAILCHECK.
>
> Index: bin/ksh/var.c
> ===
> RCS file: /cvs/src/bin/ksh/var.c,v
> retrieving revision 1.67
> diff -u -p -r1.67 var.c
> --- bin/ksh/var.c 9 Apr 2018 17:53:36 -   1.67
> +++ bin/ksh/var.c 13 Apr 2018 16:01:08 -
> @@ -1,6 +1,7 @@
>  /*   $OpenBSD: var.c,v 1.67 2018/04/09 17:53:36 tobias Exp $ */
>  
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -908,7 +909,7 @@ unspecial(const char *name)
>   ktdelete(tp);
>  }
>  
> -static   time_t  seconds;/* time SECONDS last set */
> +static   struct  timespec seconds;   /* time SECONDS last set */
>  static   int user_lineno;/* what user set $LINENO to */
>  
>  static void
> @@ -921,8 +922,13 @@ getspec(struct tbl *vp)
>* has been set - don't do anything in this case
>* (see initcoms[] in main.c).
>*/
> - if (vp->flag & ISSET)
> - setint(vp, (int64_t)(time(NULL) - seconds));
> + if (vp->flag & ISSET) {
> + struct timespec difference, now;
> +
> + clock_gettime(CLOCK_MONOTONIC, &now);
> + timespecsub(&now, &seconds, &difference);
> + setint(vp, (int64_t)difference.tv_sec);
> + }
>   vp->flag |= SPECIAL;
>   break;
>   case V_RANDOM:
> @@ -1036,7 +1042,8 @@ setspec(struct tbl *vp)
>   break;
>   case V_SECONDS:
>   vp->flag &= ~SPECIAL;
> - seconds = time(NULL) - intval(vp);
> + clock_gettime(CLOCK_MONOTONIC, &seconds);
> + seconds.tv_sec -= intval(vp);
>   vp->flag |= SPECIAL;
>   break;
>   case V_TMOUT:
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



ksh: count $SECONDS with monotonic clock

2018-04-13 Thread Scott Cheloha
So that $SECONDS advances uniformly, independent of the system clock.

ok?

--
Scott Cheloha

P.S. Similar change forthcoming for $MAILCHECK.

Index: bin/ksh/var.c
===
RCS file: /cvs/src/bin/ksh/var.c,v
retrieving revision 1.67
diff -u -p -r1.67 var.c
--- bin/ksh/var.c   9 Apr 2018 17:53:36 -   1.67
+++ bin/ksh/var.c   13 Apr 2018 16:01:08 -
@@ -1,6 +1,7 @@
 /* $OpenBSD: var.c,v 1.67 2018/04/09 17:53:36 tobias Exp $ */
 
 #include 
+#include 
 
 #include 
 #include 
@@ -908,7 +909,7 @@ unspecial(const char *name)
ktdelete(tp);
 }
 
-static time_t  seconds;/* time SECONDS last set */
+static struct  timespec seconds;   /* time SECONDS last set */
 static int user_lineno;/* what user set $LINENO to */
 
 static void
@@ -921,8 +922,13 @@ getspec(struct tbl *vp)
 * has been set - don't do anything in this case
 * (see initcoms[] in main.c).
 */
-   if (vp->flag & ISSET)
-   setint(vp, (int64_t)(time(NULL) - seconds));
+   if (vp->flag & ISSET) {
+   struct timespec difference, now;
+
+   clock_gettime(CLOCK_MONOTONIC, &now);
+   timespecsub(&now, &seconds, &difference);
+   setint(vp, (int64_t)difference.tv_sec);
+   }
vp->flag |= SPECIAL;
break;
case V_RANDOM:
@@ -1036,7 +1042,8 @@ setspec(struct tbl *vp)
break;
case V_SECONDS:
vp->flag &= ~SPECIAL;
-   seconds = time(NULL) - intval(vp);
+   clock_gettime(CLOCK_MONOTONIC, &seconds);
+   seconds.tv_sec -= intval(vp);
vp->flag |= SPECIAL;
break;
case V_TMOUT:



Re: vmd(4) close vmm parent socket

2018-04-13 Thread Carlos Cardenas
On Fri, Apr 13, 2018 at 11:29:06AM +0200, Martijn van Duren wrote:
> Hello tech@,
> 
> Playing with vmd I noticed that a vm process has vmm's socket to the
> parent process still open.
> 
> Patch below works for me.
> 
> OK?
> 
> martijn@

Nice find.

Ok ccardenas@

+--+
Carlos

> 
> Index: vmm.c
> ===
> RCS file: /cvs/src/usr.sbin/vmd/vmm.c,v
> retrieving revision 1.80
> diff -u -p -r1.80 vmm.c
> --- vmm.c 5 Feb 2018 05:01:08 -   1.80
> +++ vmm.c 13 Apr 2018 09:27:14 -
> @@ -664,6 +664,7 @@ vmm_start_vm(struct imsg *imsg, uint32_t
>   } else {
>   /* Child */
>   close(fds[0]);
> + close(PROC_PARENT_SOCK_FILENO);
>  
>   ret = start_vm(vm, fds[1]);
>  
> 



Re: syspatch(8) exit code

2018-04-13 Thread Antoine Jacoutot
On Fri, Apr 13, 2018 at 07:37:24AM -0600, Theo de Raadt wrote:
> No.  There are no patches yet, and it can't handle an empty directory.
> 
> I am waiting for aja and robert to decide what to do about it.  Otherwise
> we'll have thus fuss at the start of every new release.
> 
> Come on guys, make a decision!

For 6.3 it will be "fixed" once there's a syspatch.
For 6.4 I will fix it at p2k18.

-- 
Antoine



Re: diff for usr.bin/mg/fileio.c

2018-04-13 Thread Florian Obser
On Thu, Apr 12, 2018 at 07:04:23PM +0200, Han Boetes wrote:
> Yes this also works for me.
> 

Awesome, any OKs?

Diff again for convenience:

diff --git fileio.c fileio.c
index 0987f6f30de..339088f5e2d 100644
--- fileio.c
+++ fileio.c
@@ -703,7 +703,7 @@ expandtilde(const char *fn)
struct stat  statbuf;
const char  *cp;
char user[LOGIN_NAME_MAX], path[NFILEN];
-   char*un, *ret;
+   char*ret;
size_t   ulen, plen;
 
path[0] = '\0';
@@ -722,16 +722,13 @@ expandtilde(const char *fn)
return (NULL);
return(ret);
}
-   if (ulen == 0) { /* ~/ or ~ */
-   if ((un = getlogin()) != NULL)
-   (void)strlcpy(user, un, sizeof(user));
-   else
-   user[0] = '\0';
-   } else { /* ~user/ or ~user */
+   if (ulen == 0) /* ~/ or ~ */
+   pw = getpwuid(geteuid());
+   else { /* ~user/ or ~user */
memcpy(user, &fn[1], ulen);
user[ulen] = '\0';
+   pw = getpwnam(user);
}
-   pw = getpwnam(user);
if (pw != NULL) {
plen = strlcpy(path, pw->pw_dir, sizeof(path));
if (plen == 0 || path[plen - 1] != '/') {


-- 
I'm not entirely sure you are real.



Re: syspatch(8) exit code

2018-04-13 Thread Theo de Raadt
No.  There are no patches yet, and it can't handle an empty directory.

I am waiting for aja and robert to decide what to do about it.  Otherwise
we'll have thus fuss at the start of every new release.

Come on guys, make a decision!

>It looks like in OpenBSD 6.3-release, syspatch(8) changed exit code and now 
>when running alone or with -c flag, it exit with status code 1.
>
>On 6.2 exit code was 0
>
>63# syspatch;echo $?
>1
>
>Is it correct ?
>
>_
>Zbyszek Żółkiewski
>
>



syspatch(8) exit code

2018-04-13 Thread Zbyszek Żółkiewski
Hi!

It looks like in OpenBSD 6.3-release, syspatch(8) changed exit code and now 
when running alone or with -c flag, it exit with status code 1.

On 6.2 exit code was 0

63# syspatch;echo $?
1

Is it correct ?

_
Zbyszek Żółkiewski



Re: ifconfig,route,netstat: s/tableid/rtable/ for consistency

2018-04-13 Thread Theo de Raadt
>On 2018/04/13 14:38, Klemens Nanni wrote:
>> I propose to use `rtable' exclusively to ease searching and improve
>> consistency as that's the wording already used across the majority of
>> manuals including rtabe(4) and pf.conf(5) for example.
>
>There's not a lot in it, but tableid is slightly more common (and to
>my eye, looks a bit nicer as a description of an argument..) - changing
>from one to the other mostly feels like deckchair-rearranging though.
>
>There is a related problem that I noticed from looking at this though,
>sshd_config uses "rdomain" where it's actually talking about an rtable.

I think it should be rtable or rdomain in every specific place.  You
are suggesting a rtable field name is tableid.  Is a rdomain field
now name rdomainid?  Doesn't make sense to me.  The concept should be
the field name, and use one name rather than two, giving people the
least amount of variation.



Re: ifconfig,route,netstat: s/tableid/rtable/ for consistency

2018-04-13 Thread Stuart Henderson
On 2018/04/13 14:38, Klemens Nanni wrote:
> I propose to use `rtable' exclusively to ease searching and improve
> consistency as that's the wording already used across the majority of
> manuals including rtabe(4) and pf.conf(5) for example.

There's not a lot in it, but tableid is slightly more common (and to
my eye, looks a bit nicer as a description of an argument..) - changing
from one to the other mostly feels like deckchair-rearranging though.

There is a related problem that I noticed from looking at this though,
sshd_config uses "rdomain" where it's actually talking about an rtable.



Re: ifconfig,route,netstat: s/tableid/rtable/ for consistency

2018-04-13 Thread Klemens Nanni
On Thu, Apr 12, 2018 at 10:07:58AM +0200, Peter Hessler wrote:
> On 2018 Apr 11 (Wed) at 23:01:45 +0200 (+0200), Klemens Nanni wrote:
> :On Wed, Apr 11, 2018 at 09:28:03AM +0200, Peter Hessler wrote:
> :> No, all of these uses are correct as-is.
> :`tableid' surely isn't wrong, but using the argument name across manuals
> :seems nicer to me.
> :
> 
> No, they are different things.  Different names help with the concept.
> 
> 
> :Or is there any real difference between `tableid' and `rtable' I'm not
> :aware of?
> :
> 
> rtables are layer 3.
> 
> rdomains are layer 2 (aka, arp and ndp lookups).
> 
> You can have multiple rtables within an rdomain.  An interface can only
> be a member of a single rdomain at a time.
Maybe my first mail wasn't clear enough: I'm talking about routing
*tables* only.

Specifically, how they are referred to as `rtable' and `tableid' across
different manual pages.

I propose to use `rtable' exclusively to ease searching and improve
consistency as that's the wording already used across the majority of
manuals including rtabe(4) and pf.conf(5) for example.



vmd(4) close vmm parent socket

2018-04-13 Thread Martijn van Duren
Hello tech@,

Playing with vmd I noticed that a vm process has vmm's socket to the
parent process still open.

Patch below works for me.

OK?

martijn@

Index: vmm.c
===
RCS file: /cvs/src/usr.sbin/vmd/vmm.c,v
retrieving revision 1.80
diff -u -p -r1.80 vmm.c
--- vmm.c   5 Feb 2018 05:01:08 -   1.80
+++ vmm.c   13 Apr 2018 09:27:14 -
@@ -664,6 +664,7 @@ vmm_start_vm(struct imsg *imsg, uint32_t
} else {
/* Child */
close(fds[0]);
+   close(PROC_PARENT_SOCK_FILENO);
 
ret = start_vm(vm, fds[1]);