Re: Remove path support from OpenBSD::Pledge

2017-09-09 Thread Giovanni Bechis
On 09/09/17 05:40, Andrew Fresh wrote:
> This removes path support from the OpenBSD::Pledge perl module in
> preparation for the hot new thing.
> 
> I don't believe anyone could be using this as it would have just thrown
> errors if you tried, but thought I should ask for an ok.
> 
> so OK?
> 
sure, ok giovanni@
 Cheers
  Giovanni



[PATCH] faq/faq10.html - add rdist(1) to the list of synchronisation tools

2017-09-09 Thread Raf Czlonka
Hi all,

Reading the "Directory services" part of the FAQ[0] I can't help
the feeling that rdist(1) is missing from the list of file synchronisation
tools - reasons below:

- rsync, albeit very popular, is an external port,
- rdist is available in base (and BSD-derived),
- rdist's sole purpose is remote file distribution.

I'd even go as far as removing all the other ones from the list as
rdist(1) already uses both cron(8) and ssh(1) to do its job - I
don't feel too strongly about it, though :^)

What do others think?

[0] https://www.openbsd.org/faq/faq10.html#Dir.available

Regards,

Raf

Index: faq/faq10.html
===
RCS file: /cvs/www/faq/faq10.html,v
retrieving revision 1.271
diff -u -p -r1.271 faq10.html
--- faq/faq10.html  8 Aug 2017 19:15:57 -   1.271
+++ faq/faq10.html  9 Sep 2017 09:35:09 -
@@ -354,6 +354,7 @@ daemon provides the latter.
 
 For some applications, simply synchronizing a small number of configuration
 files among a group of machines using tools like
+https://man.openbsd.org/rdist";>rdist(1),
 https://man.openbsd.org/cron";>cron(8),
 https://man.openbsd.org/scp";>scp(1) or
 rsync (available from ports) constitutes an easy and robust 
alternative



Re: [PATCH] urng.4 - Altusmetrum -> Altus Metrum

2017-09-09 Thread Jasper Lievisse Adriaanse
On Fri, Sep 08, 2017 at 10:25:41PM +0100, Raf Czlonka wrote:
> Hi all,
> 
> According to their web pages[0][1] Altus Metrum name comprises two
> words - both capitalised.
> 
> [0] http://altusmetrum.org/
> [1] http://shop.gag.com/about-magento-demo-store
> 
> Regards,
> 
> Raf
This is indeed correct, thanks!
 
> Index: share/man/man4/urng.4
> ===
> RCS file: /cvs/src/share/man/man4/urng.4,v
> retrieving revision 1.2
> diff -u -p -r1.2 urng.4
> --- share/man/man4/urng.4 29 Aug 2017 06:12:36 -  1.2
> +++ share/man/man4/urng.4 8 Sep 2017 21:13:14 -
> @@ -34,14 +34,14 @@ and stirs it into the system entropy poo
>  .Xr add_true_randomness 9 .
>  .Sh HARDWARE
>  The following devices are supported by this driver:
> -.Bl -tag -width "Altusmetrum"
> +.Bl -tag -width "Altus Metrum"
>  .It Araneus Alea II
>  Capable of delivering 100kbit/sec of hardware-generated entropy.
>  The product documentation states that the USB interface used by the
>  Alea II is the same as that used by its predecessor the Alea I;
>  theoretically this means that the Alea I should work but this has not
>  been tested.
> -.It Altusmetrum ChaosKey 1.0
> +.It Altus Metrum ChaosKey 1.0
>  This device is capable of providing entropy at 10Mbit/s.
>  .El
>  .Sh SEE ALSO
> 

-- 
jasper



Re: mg: fix line numbering bug

2017-09-09 Thread Florian Obser
Nice catch!

OK florian@ if someone wants to commit. Alternatively I take OKs :)

On Sat, Sep 09, 2017 at 05:24:41AM +0200, Martin Wanvik wrote:
> When inserting a newline, only increment dotline for windows that are 
> displaying the same buffer as the current one. 
> 
> Index: usr.bin/mg/line.c
> ===
> RCS file: /cvs/src/usr.bin/mg/line.c,v
> retrieving revision 1.58
> diff -u -p -u -r1.58 line.c
> --- usr.bin/mg/line.c 11 Dec 2015 20:21:23 -  1.58
> +++ usr.bin/mg/line.c 9 Sep 2017 01:36:02 -
> @@ -264,7 +264,8 @@ lnewline_at(struct line *lp1, int doto)
>   for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
>   if (wp->w_linep == lp1)
>   wp->w_linep = lp2;
> - if (wp->w_dotline >= tcurwpdotline)
> + if (wp->w_dotline >= tcurwpdotline && 
> + wp->w_bufp == curwp->w_bufp)
>   wp->w_dotline++;
>   }
>   undo_add_boundary(FFRAND, 1);
> @@ -292,7 +293,8 @@ lnewline_at(struct line *lp1, int doto)
>   wp->w_dotp = lp2;
>   wp->w_doto -= doto;
>   wp->w_dotline++;
> - } else if (wp->w_dotline > tcurwpdotline)
> + } else if (wp->w_dotline > tcurwpdotline &&
> + wp->w_bufp == curwp->w_bufp)
>   wp->w_dotline++;
>   if (wp->w_markp == lp1 && wp->w_marko >= doto) {
>   wp->w_markp = lp2;
> 


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



Re: mg: fix line numbering bug

2017-09-09 Thread Brian Callahan

ok bcallah@


On 9/9/2017 6:51 AM, Florian Obser wrote:

Nice catch!

OK florian@ if someone wants to commit. Alternatively I take OKs :)

On Sat, Sep 09, 2017 at 05:24:41AM +0200, Martin Wanvik wrote:

When inserting a newline, only increment dotline for windows that are
displaying the same buffer as the current one.

Index: usr.bin/mg/line.c
===
RCS file: /cvs/src/usr.bin/mg/line.c,v
retrieving revision 1.58
diff -u -p -u -r1.58 line.c
--- usr.bin/mg/line.c   11 Dec 2015 20:21:23 -  1.58
+++ usr.bin/mg/line.c   9 Sep 2017 01:36:02 -
@@ -264,7 +264,8 @@ lnewline_at(struct line *lp1, int doto)
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
if (wp->w_linep == lp1)
wp->w_linep = lp2;
-   if (wp->w_dotline >= tcurwpdotline)
+   if (wp->w_dotline >= tcurwpdotline &&
+   wp->w_bufp == curwp->w_bufp)
wp->w_dotline++;
}
undo_add_boundary(FFRAND, 1);
@@ -292,7 +293,8 @@ lnewline_at(struct line *lp1, int doto)
wp->w_dotp = lp2;
wp->w_doto -= doto;
wp->w_dotline++;
-   } else if (wp->w_dotline > tcurwpdotline)
+   } else if (wp->w_dotline > tcurwpdotline &&
+   wp->w_bufp == curwp->w_bufp)
wp->w_dotline++;
if (wp->w_markp == lp1 && wp->w_marko >= doto) {
wp->w_markp = lp2;







Re: [patch] Remove redundant operation in pctr.c

2017-09-09 Thread Nan Xiao
Actually, it should be more efficient to remove bzero() function
and keep set NULL-terminate char.

Best Regards
Nan Xiao

Index: pctr.c
===
RCS file: /cvs/src/usr.bin/pctr/pctr.c,v
retrieving revision 1.22
diff -u -p -r1.22 pctr.c
--- pctr.c  8 Feb 2015 23:40:34 -   1.22
+++ pctr.c  9 Sep 2017 14:05:17 -
@@ -166,7 +166,6 @@ pctr_cpu_creds(void)
mib[0] = CTL_HW;
mib[1] = HW_MACHINE;
len = sizeof(arch) - 1;
-   bzero(arch, sizeof(arch));
if (sysctl(mib, 2, arch, &len, NULL, 0) == -1)
err(1, "HW_MACHINE");
arch[len] = '\0';
@@ -195,7 +194,6 @@ pctr_cpu_creds(void)
mib[0] = CTL_MACHDEP;
mib[1] = CPU_CPUVENDOR;
len = sizeof(vendor) - 1;
-   bzero(vendor, sizeof(vendor));
if (sysctl(mib, 2, vendor, &len, NULL, 0) == -1)
err(1, "CPU_CPUVENDOR");
vendor[len] = '\0';


On 9/9/2017 11:56 AM, Nan Xiao wrote:
> Hi tech@,
> 
> Remove setting null-terminated string operation, since bzero()
> has done this operation before. Sorry if I miss some points.
> 
> Thanks!
> 
> Best Regards
> Nan Xiao
> 
> Index: pctr.c
> ===
> RCS file: /cvs/src/usr.bin/pctr/pctr.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 pctr.c
> --- pctr.c8 Feb 2015 23:40:34 -   1.22
> +++ pctr.c9 Sep 2017 03:43:36 -
> @@ -169,7 +169,6 @@ pctr_cpu_creds(void)
>   bzero(arch, sizeof(arch));
>   if (sysctl(mib, 2, arch, &len, NULL, 0) == -1)
>   err(1, "HW_MACHINE");
> - arch[len] = '\0';
> 
>   if (strcmp(arch, "i386") == 0)
>   atype = ARCH_I386;
> @@ -198,7 +197,6 @@ pctr_cpu_creds(void)
>   bzero(vendor, sizeof(vendor));
>   if (sysctl(mib, 2, vendor, &len, NULL, 0) == -1)
>   err(1, "CPU_CPUVENDOR");
> - vendor[len] = '\0';
> 
>   switch (atype) {
>   case ARCH_I386:
> 



Re: tftp: use monotonic clock for statistics summary

2017-09-09 Thread Scott Cheloha
3 week bump.

--
Scott Cheloha

> On Aug 16, 2017, at 8:46 PM, Scott Cheloha  wrote:
> 
> Hi,
> 
> Same deal here as in dd(1).  We display the elapsed time so we want
> a monotonic clock.
> 
> --
> Scott Cheloha
> 
> Index: usr.bin/tftp/tftp.c
> ===
> RCS file: /cvs/src/usr.bin/tftp/tftp.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 tftp.c
> --- usr.bin/tftp/tftp.c   21 Oct 2014 06:15:16 -  1.24
> +++ usr.bin/tftp/tftp.c   17 Aug 2017 01:44:46 -
> @@ -52,6 +52,7 @@
> #include 
> #include 
> #include 
> +#include 
> #include 
> #include 
> 
> @@ -83,8 +84,8 @@ extern int   opt_tsize;
> extern int opt_tout;
> extern int opt_blksize;
> 
> -struct timeval   tstart;
> -struct timeval   tstop;
> +struct timespec  tstart;
> +struct timespec  tstop;
> unsigned int  segment_size = SEGSIZE;
> unsigned int  packet_size = SEGSIZE + 4;
> 
> @@ -548,13 +549,13 @@ tpacket(const char *s, struct tftphdr *t
> static void
> startclock(void)
> {
> - (void)gettimeofday(&tstart, NULL);
> + clock_gettime(CLOCK_MONOTONIC, &tstart);
> }
> 
> static void
> stopclock(void)
> {
> - (void)gettimeofday(&tstop, NULL);
> + clock_gettime(CLOCK_MONOTONIC, &tstop);
> }
> 
> static void
> @@ -563,8 +564,8 @@ printstats(const char *direction, unsign
>   double  delta;
> 
>   /* compute delta in 1/10's second units */
> - delta = ((tstop.tv_sec * 10.) + (tstop.tv_usec / 10)) -
> - ((tstart.tv_sec * 10.) + (tstart.tv_usec / 10));
> + delta = ((tstop.tv_sec * 10.) + (tstop.tv_nsec / 1)) -
> + ((tstart.tv_sec * 10.) + (tstart.tv_nsec / 1));
>   delta = delta / 10.;/* back to seconds */
>   printf("%s %lu bytes in %.1f seconds", direction, amount, delta);
>   if (verbose)



Re: tftp: use monotonic clock for statistics summary

2017-09-09 Thread Theo Buehler
On Sat, Sep 09, 2017 at 04:28:45PM +, Scott Cheloha wrote:
> 3 week bump.

looks good to me.

anyone willing to ok this or commit this with my ok?

> 
> --
> Scott Cheloha
> 
> > On Aug 16, 2017, at 8:46 PM, Scott Cheloha  wrote:
> > 
> > Hi,
> > 
> > Same deal here as in dd(1).  We display the elapsed time so we want
> > a monotonic clock.
> > 
> > --
> > Scott Cheloha
> > 
> > Index: usr.bin/tftp/tftp.c
> > ===
> > RCS file: /cvs/src/usr.bin/tftp/tftp.c,v
> > retrieving revision 1.24
> > diff -u -p -r1.24 tftp.c
> > --- usr.bin/tftp/tftp.c 21 Oct 2014 06:15:16 -  1.24
> > +++ usr.bin/tftp/tftp.c 17 Aug 2017 01:44:46 -
> > @@ -52,6 +52,7 @@
> > #include 
> > #include 
> > #include 
> > +#include 
> > #include 
> > #include 
> > 
> > @@ -83,8 +84,8 @@ extern int opt_tsize;
> > extern int   opt_tout;
> > extern int   opt_blksize;
> > 
> > -struct timeval tstart;
> > -struct timeval tstop;
> > +struct timespectstart;
> > +struct timespectstop;
> > unsigned intsegment_size = SEGSIZE;
> > unsigned intpacket_size = SEGSIZE + 4;
> > 
> > @@ -548,13 +549,13 @@ tpacket(const char *s, struct tftphdr *t
> > static void
> > startclock(void)
> > {
> > -   (void)gettimeofday(&tstart, NULL);
> > +   clock_gettime(CLOCK_MONOTONIC, &tstart);
> > }
> > 
> > static void
> > stopclock(void)
> > {
> > -   (void)gettimeofday(&tstop, NULL);
> > +   clock_gettime(CLOCK_MONOTONIC, &tstop);
> > }
> > 
> > static void
> > @@ -563,8 +564,8 @@ printstats(const char *direction, unsign
> > double  delta;
> > 
> > /* compute delta in 1/10's second units */
> > -   delta = ((tstop.tv_sec * 10.) + (tstop.tv_usec / 10)) -
> > -   ((tstart.tv_sec * 10.) + (tstart.tv_usec / 10));
> > +   delta = ((tstop.tv_sec * 10.) + (tstop.tv_nsec / 1)) -
> > +   ((tstart.tv_sec * 10.) + (tstart.tv_nsec / 1));
> > delta = delta / 10.;/* back to seconds */
> > printf("%s %lu bytes in %.1f seconds", direction, amount, delta);
> > if (verbose)
> 



pax: fix backslash escaping in file patterns

2017-09-09 Thread Philip Guenther

i ran into this when I was picking out files from the base sets and tried 
to pick out /bin/[

: corwin; pax -zvf /home/sets/amd64/base62.tgz './bin/['
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
pax: WARNING! These patterns were not matched:
./bin/[
: corwin; pax -zvf /home/sets/amd64/base62.tgz './bin/\['
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
pax: WARNING! These patterns were not matched:
./bin/\[
: corwin; pax -zvf /home/sets/amd64/base62.tgz './bin/\\['
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
pax: WARNING! These patterns were not matched:
./bin/\\[
: corwin; pax -zvf /home/sets/amd64/base62.tgz './bin/[[]'
-r-xr-xr-x  1 root bin 112320 Sep  2 16:50 ./bin/[
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
: corwin;

Per POSIX, backslash is supposed to escape the special handling of glob 
characters.  With the diff below the behavior is as desired:

: corwin; obj/pax -zvf /home/sets/amd64/base62.tgz './bin/\['
-r-xr-xr-x  1 root bin 112320 Sep  2 16:50 ./bin/[
pax: ustar vol 1, 7943 files, 298424320 bytes read, 0 bytes written.
: corwin;


ok?

Philip

Index: pat_rep.c
===
RCS file: /data/src/openbsd/src/bin/pax/pat_rep.c,v
retrieving revision 1.41
diff -u -p -r1.41 pat_rep.c
--- pat_rep.c   26 Aug 2016 04:19:28 -  1.41
+++ pat_rep.c   8 Sep 2017 04:56:19 -
@@ -553,6 +553,9 @@ fn_match(char *pattern, char *string, ch
return (-1);
break;
case '\\':
+   if ((c = *pattern++) == '\0')
+   return (-1);
+   /* FALLTHROUGH */
default:
if (c != *string++)
return (-1);



libc: remove some indirect cancellation points

2017-09-09 Thread Philip Guenther

POSIX requires certain interfaces to include cancellation points, permits 
it for others, and the rest of the POSIX interfaces are banned from being 
cancellation points.

Our shm_open(), sysconf(), tcflow(), and tcsendbreak() are in the third 
group and therefore shouldn't be cancellation points.  However they are 
built on sycalls whose public versions are cancellation points: open, 
close, write, and nanosleep.  So, they need to invoke the underlying, 
non-cancellation point versions of those functions.

ok?

Philip


Index: gen/shm_open.c
===
RCS file: /data/src/openbsd/src/lib/libc/gen/shm_open.c,v
retrieving revision 1.8
diff -u -p -r1.8 shm_open.c
--- gen/shm_open.c  10 Dec 2015 13:03:22 -  1.8
+++ gen/shm_open.c  5 Sep 2017 04:57:35 -
@@ -61,16 +61,16 @@ shm_open(const char *path, int flags, mo
 
makeshmpath(path, shmpath, sizeof(shmpath));
 
-   fd = open(shmpath, flags, mode);
+   fd = HIDDEN(open)(shmpath, flags, mode);
if (fd == -1)
return -1;
if (fstat(fd, &sb) == -1 || !S_ISREG(sb.st_mode)) {
-   close(fd);
+   HIDDEN(close)(fd);
errno = EINVAL;
return -1;
}
if (sb.st_uid != geteuid()) {
-   close(fd);
+   HIDDEN(close)(fd);
errno = EPERM;
return -1;
}
Index: gen/sysconf.c
===
RCS file: /data/src/openbsd/src/lib/libc/gen/sysconf.c,v
retrieving revision 1.24
diff -u -p -r1.24 sysconf.c
--- gen/sysconf.c   20 Mar 2016 02:32:40 -  1.24
+++ gen/sysconf.c   30 Aug 2017 05:35:33 -
@@ -241,7 +241,7 @@ sysconf(int name)
value = socket(PF_INET6, SOCK_DGRAM, 0);
errno = sverrno;
if (value >= 0) {
-   close(value);
+   HIDDEN(close)(value);
return (200112L);
} else
return (0);
Index: termios/tcflow.c
===
RCS file: /data/src/openbsd/src/lib/libc/termios/tcflow.c,v
retrieving revision 1.5
diff -u -p -r1.5 tcflow.c
--- termios/tcflow.c5 Aug 2005 13:03:00 -   1.5
+++ termios/tcflow.c5 Sep 2017 05:00:43 -
@@ -49,7 +49,8 @@ tcflow(int fd, int action)
if (tcgetattr(fd, &term) == -1)
return (-1);
c = term.c_cc[action == TCIOFF ? VSTOP : VSTART];
-   if (c != _POSIX_VDISABLE && write(fd, &c, sizeof(c)) == -1)
+   if (c != _POSIX_VDISABLE &&
+   HIDDEN(write)(fd, &c, sizeof(c)) == -1)
return (-1);
return (0);
default:
Index: termios/tcsendbreak.c
===
RCS file: /data/src/openbsd/src/lib/libc/termios/tcsendbreak.c,v
retrieving revision 1.9
diff -u -p -r1.9 tcsendbreak.c
--- termios/tcsendbreak.c   1 Nov 2015 03:45:29 -   1.9
+++ termios/tcsendbreak.c   5 Sep 2017 05:01:01 -
@@ -42,7 +42,7 @@ tcsendbreak(int fd, int len)
 
if (ioctl(fd, TIOCSBRK, 0) == -1)
return (-1);
-   (void)nanosleep(&sleepytime, NULL);
+   HIDDEN(nanosleep)(&sleepytime, NULL);
if (ioctl(fd, TIOCCBRK, 0) == -1)
return (-1);
return (0);



[PATCH] pwd_mkdb.8 - fix wording

2017-09-09 Thread Raf Czlonka
Hi all,

Since the version 1.24 of the file[0] has changed the first sentence,
"respectively" doesn't belong in the second sentence any more.

I guess the two could be simplified further and combined into one
but this at least fixes the wording.

[0] 
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/pwd_mkdb/pwd_mkdb.8.diff?r1=1.23&r2=1.24&f=h

Regards,

Raf

Index: usr.sbin/pwd_mkdb/pwd_mkdb.8
===
RCS file: /cvs/src/usr.sbin/pwd_mkdb/pwd_mkdb.8,v
retrieving revision 1.27
diff -u -p -r1.27 pwd_mkdb.8
--- usr.sbin/pwd_mkdb/pwd_mkdb.816 Aug 2016 17:51:38 -  1.27
+++ usr.sbin/pwd_mkdb/pwd_mkdb.89 Sep 2017 20:44:19 -
@@ -48,8 +48,7 @@ creates a pair of Berkeley databases for
 These databases are then installed into
 .Pa /etc/spwd.db
 and
-.Pa /etc/pwd.db ,
-respectively.
+.Pa /etc/pwd.db .
 The
 .Ar file
 argument is installed into



Re: tftp: use monotonic clock for statistics summary

2017-09-09 Thread David Gwynne
 OK by me

On 10 Sep. 2017 5:21 am, "Theo Buehler"  wrote:

> On Sat, Sep 09, 2017 at 04:28:45PM +, Scott Cheloha wrote:
> > 3 week bump.
>
> looks good to me.
>
> anyone willing to ok this or commit this with my ok?
>
> >
> > --
> > Scott Cheloha
> >
> > > On Aug 16, 2017, at 8:46 PM, Scott Cheloha 
> wrote:
> > >
> > > Hi,
> > >
> > > Same deal here as in dd(1).  We display the elapsed time so we want
> > > a monotonic clock.
> > >
> > > --
> > > Scott Cheloha
> > >
> > > Index: usr.bin/tftp/tftp.c
> > > ===
> > > RCS file: /cvs/src/usr.bin/tftp/tftp.c,v
> > > retrieving revision 1.24
> > > diff -u -p -r1.24 tftp.c
> > > --- usr.bin/tftp/tftp.c 21 Oct 2014 06:15:16 -  1.24
> > > +++ usr.bin/tftp/tftp.c 17 Aug 2017 01:44:46 -
> > > @@ -52,6 +52,7 @@
> > > #include 
> > > #include 
> > > #include 
> > > +#include 
> > > #include 
> > > #include 
> > >
> > > @@ -83,8 +84,8 @@ extern int opt_tsize;
> > > extern int   opt_tout;
> > > extern int   opt_blksize;
> > >
> > > -struct timeval tstart;
> > > -struct timeval tstop;
> > > +struct timespectstart;
> > > +struct timespectstop;
> > > unsigned intsegment_size = SEGSIZE;
> > > unsigned intpacket_size = SEGSIZE + 4;
> > >
> > > @@ -548,13 +549,13 @@ tpacket(const char *s, struct tftphdr *t
> > > static void
> > > startclock(void)
> > > {
> > > -   (void)gettimeofday(&tstart, NULL);
> > > +   clock_gettime(CLOCK_MONOTONIC, &tstart);
> > > }
> > >
> > > static void
> > > stopclock(void)
> > > {
> > > -   (void)gettimeofday(&tstop, NULL);
> > > +   clock_gettime(CLOCK_MONOTONIC, &tstop);
> > > }
> > >
> > > static void
> > > @@ -563,8 +564,8 @@ printstats(const char *direction, unsign
> > > double  delta;
> > >
> > > /* compute delta in 1/10's second units */
> > > -   delta = ((tstop.tv_sec * 10.) + (tstop.tv_usec / 10)) -
> > > -   ((tstart.tv_sec * 10.) + (tstart.tv_usec / 10));
> > > +   delta = ((tstop.tv_sec * 10.) + (tstop.tv_nsec / 1)) -
> > > +   ((tstart.tv_sec * 10.) + (tstart.tv_nsec / 1));
> > > delta = delta / 10.;/* back to seconds */
> > > printf("%s %lu bytes in %.1f seconds", direction, amount, delta);
> > > if (verbose)
> >
>
>


Re: CVS: cvs.openbsd.org: src

2017-09-09 Thread Philip Guenther
On Fri, 8 Sep 2017, Alexander Bluhm wrote:
> On Tue, Sep 05, 2017 at 10:20:12PM -0600, Philip Guenther wrote:
> > CVSROOT:/cvs
> > Module name:src
> > Changes by: guent...@cvs.openbsd.org2017/09/05 22:20:12
> > 
> > Modified files:
> > regress/sys/kern/ptrace: ptrace.c 
> > 
> > Log message:
> > Fix declarations
> > ptrace(PT_IO) memory protection faults return EACCES, not EFAULT
> 
> Now the test fails on i386.
> 
> /usr/src/regress/sys/kern/ptrace/ptrace -Irib
> ptrace: ptrace(PT_IO): Bad address   
> *** Error 1 in . (Makefile:19 'io_read_i_bad')
> FAILED  
> 
> Apparently i386 and amd64 return different errors.  Do you know
> why?  Is it worth to invesitgate or shoud we just accept both cases?

It was worth investigating and, having done so, I think my change was 
incorrect and should be reverted and the amd64 kernel fixed to return 
EFAULT in that case.

Currently on amd64, the copyin(9) family of calls will pass through the 
return value of uvm_fault() and thus return not just EFAULT but possibly 
EACCES, ENOMEM, and EIO.  Since the return value of those functions is 
usually passed through to userspace, that's a Bad Thing IMO and we need to 
fix them to always return EFAULT when uvm_fault() fails.

The diff below does that by merging copy_fault and copy_efault, and ditto 
copystr_fault and copystr_efault, and dropping the attempt to pass the 
error number from trap() to the pcb_onfault callback.

While here, delete the similar attempt on arm64 to pass the error number 
from trap() to the pcb_onfault callback...which already ignores it and 
always return EFAULT.

ok?

Philip


Index: sys/arch/amd64/amd64/trap.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/trap.c,v
retrieving revision 1.57
diff -u -p -r1.57 trap.c
--- sys/arch/amd64/amd64/trap.c 25 Aug 2017 19:28:48 -  1.57
+++ sys/arch/amd64/amd64/trap.c 9 Sep 2017 23:30:19 -
@@ -211,10 +211,8 @@ trap(struct trapframe *frame)
goto we_re_toast;
/* Check for copyin/copyout fault. */
if (pcb->pcb_onfault != 0) {
-   error = EFAULT;
 copyfault:
frame->tf_rip = (u_int64_t)pcb->pcb_onfault;
-   frame->tf_rax = error;
return;
}
 
Index: sys/arch/amd64/amd64/copy.S
===
RCS file: /cvs/src/sys/arch/amd64/amd64/copy.S,v
retrieving revision 1.10
diff -u -p -r1.10 copy.S
--- sys/arch/amd64/amd64/copy.S 25 Aug 2017 19:28:48 -  1.10
+++ sys/arch/amd64/amd64/copy.S 9 Sep 2017 23:30:19 -
@@ -107,10 +107,10 @@ ENTRY(copyout)

movq%rdi,%rdx
addq%rax,%rdx
-   jc  _C_LABEL(copy_efault)
+   jc  _C_LABEL(copy_fault)
movq$VM_MAXUSER_ADDRESS,%r8
cmpq%r8,%rdx
-   ja  _C_LABEL(copy_efault)
+   ja  _C_LABEL(copy_fault)
 
movqCPUVAR(CURPCB),%rdx
leaq_C_LABEL(copy_fault)(%rip),%r11
@@ -145,10 +145,10 @@ ENTRY(copyin)
 
movq%rsi,%rdx
addq%rax,%rdx
-   jc  _C_LABEL(copy_efault)
+   jc  _C_LABEL(copy_fault)
movq$VM_MAXUSER_ADDRESS,%r8
cmpq%r8,%rdx
-   ja  _C_LABEL(copy_efault)
+   ja  _C_LABEL(copy_fault)
 
 3: /* bcopy(%rsi, %rdi, %rax); */
movq%rax,%rcx
@@ -171,13 +171,11 @@ ENTRY(copyin)
xorl%eax,%eax
ret
 
-NENTRY(copy_efault)
-   movq$EFAULT,%rax
-
 NENTRY(copy_fault)
SMAP_CLAC
movqCPUVAR(CURPCB),%rdx
popqPCB_ONFAULT(%rdx)
+   movl$EFAULT,%eax
ret
 
 ENTRY(copyoutstr)
@@ -194,7 +192,7 @@ ENTRY(copyoutstr)
 */
movq$VM_MAXUSER_ADDRESS,%rax
subq%rdi,%rax
-   jbe _C_LABEL(copystr_efault)/* die if CF == 1 || ZF == 1 */
+   jbe _C_LABEL(copystr_fault) /* die if CF == 1 || ZF == 1 */
cmpq%rdx,%rax
jae 1f
movq%rax,%rdx
@@ -217,8 +215,8 @@ ENTRY(copyoutstr)
 2: /* rdx is zero -- return EFAULT or ENAMETOOLONG. */
movq$VM_MAXUSER_ADDRESS,%r11
cmpq%r11,%rdi
-   jae _C_LABEL(copystr_efault)
-   movq$ENAMETOOLONG,%rax
+   jae _C_LABEL(copystr_fault)
+   movl$ENAMETOOLONG,%eax
jmp copystr_return
 
 ENTRY(copyinstr)
@@ -236,7 +234,7 @@ ENTRY(copyinstr)
 */
movq$VM_MAXUSER_ADDRESS,%rax
subq%rsi,%rax
-   jbe _C_LABEL(copystr_efault)/* die if CF == 1 || ZF == 1 */
+   jbe _C_LABEL(copystr_fault) /* die if CF == 1 || ZF == 1 */
cmpq%rdx,%rax
jae 1f
movq%rax,%rdx
@@ -259,14 +257,12 @@ ENTRY(copyinstr)
 2: /* edx is zero -- return EFAULT or ENAMETOOLONG. */
m

cwm: noinput-flag&bindable toggle, for applying it to the current window

2017-09-09 Thread Artturi Alm
Hi,

got some bones broken from my left hand/wrist causing inaccurate movement
of mouse etc., so likely useless to most, and possibly done wrong,
but does help/work for me:)

-Artturi


diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index 9d2d99f19..3f1d095e8 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/calmwm.h
@@ -76,6 +76,7 @@ enum cursor_font {
 enum color {
CWM_COLOR_BORDER_ACTIVE,
CWM_COLOR_BORDER_INACTIVE,
+   CWM_COLOR_BORDER_NOINPUT,
CWM_COLOR_BORDER_URGENCY,
CWM_COLOR_BORDER_GROUP,
CWM_COLOR_BORDER_UNGROUP,
@@ -155,6 +156,7 @@ struct client_ctx {
 #define CLIENT_FULLSCREEN  0x0800
 #define CLIENT_STICKY  0x1000
 #define CLIENT_ACTIVE  0x2000
+#define CLIENT_NOINPUT 0x4000
 #define CLIENT_HIGHLIGHT   (CLIENT_GROUP | CLIENT_UNGROUP)
 #define CLIENT_MAXFLAGS(CLIENT_VMAXIMIZED | 
CLIENT_HMAXIMIZED)
 #define CLIENT_MAXIMIZED   (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
@@ -413,6 +415,7 @@ void client_toggle_hmaximize(struct 
client_ctx *);
 voidclient_toggle_maximize(struct client_ctx *);
 voidclient_toggle_sticky(struct client_ctx *);
 voidclient_toggle_vmaximize(struct client_ctx *);
+voidclient_toggle_noinput(struct client_ctx *);
 voidclient_transient(struct client_ctx *);
 voidclient_unhide(struct client_ctx *);
 voidclient_urgency(struct client_ctx *);
@@ -474,6 +477,7 @@ void 
kbfunc_client_toggle_fullscreen(void *,
 voidkbfunc_client_toggle_maximize(void *, struct cargs *);
 voidkbfunc_client_toggle_hmaximize(void *, struct cargs *);
 voidkbfunc_client_toggle_vmaximize(void *, struct cargs *);
+voidkbfunc_client_toggle_noinput(void *, struct cargs *);
 voidkbfunc_client_htile(void *, struct cargs *);
 voidkbfunc_client_vtile(void *, struct cargs *);
 voidkbfunc_client_cycle(void *, struct cargs *);
diff --git a/app/cwm/client.c b/app/cwm/client.c
index a163f4f1b..18794bbd5 100644
--- a/app/cwm/client.c
+++ b/app/cwm/client.c
@@ -209,8 +209,9 @@ client_setactive(struct client_ctx *cc)
 
XInstallColormap(X_Dpy, cc->colormap);
 
-   if ((cc->flags & CLIENT_INPUT) ||
-   (!(cc->flags & CLIENT_WM_TAKE_FOCUS))) {
+   if (!(cc->flags & CLIENT_NOINPUT) &&
+   ((cc->flags & CLIENT_INPUT) ||
+   (!(cc->flags & CLIENT_WM_TAKE_FOCUS {
XSetInputFocus(X_Dpy, cc->win,
RevertToPointerRoot, CurrentTime);
}
@@ -222,7 +223,7 @@ client_setactive(struct client_ctx *cc)
client_draw_border(oldcc);
}
 
-   /* If we're in the middle of cycing, don't change the order. */
+   /* If we're in the middle of cycling, don't change the order. */
if (!sc->cycling)
client_mtf(cc);
 
@@ -414,6 +415,16 @@ resize:
xu_ewmh_set_net_wm_state(cc);
 }
 
+void
+client_toggle_noinput(struct client_ctx *cc)
+{
+   if (cc->flags & CLIENT_NOINPUT)
+   cc->flags &= ~CLIENT_NOINPUT;
+   else
+   cc->flags |= CLIENT_NOINPUT;
+
+}
+
 void
 client_resize(struct client_ctx *cc, int reset)
 {
@@ -560,6 +571,9 @@ client_draw_border(struct client_ctx *cc)
else
pixel = sc->xftcolor[CWM_COLOR_BORDER_INACTIVE].pixel;
 
+   if (cc->flags & CLIENT_NOINPUT)
+   pixel = sc->xftcolor[CWM_COLOR_BORDER_NOINPUT].pixel;
+
if (cc->flags & CLIENT_URGENCY)
pixel = sc->xftcolor[CWM_COLOR_BORDER_URGENCY].pixel;
 
diff --git a/app/cwm/conf.c b/app/cwm/conf.c
index e934b060c..2e97eb780 100644
--- a/app/cwm/conf.c
+++ b/app/cwm/conf.c
@@ -46,6 +46,7 @@ static int cursor_binds[] = {
 static const char *color_binds[] = {
"#CC",  /* CWM_COLOR_BORDER_ACTIVE */
"#66",  /* CWM_COLOR_BORDER_INACTIVE */
+   "#66ff99",  /* CWM_COLOR_BORDER_NOINPUT */
"#FC8814",  /* CWM_COLOR_BORDER_URGENCY */
"blue", /* CWM_COLOR_BORDER_GROUP */
"red",  /* CWM_COLOR_BORDER_UNGROUP */
@@ -72,6 +73,7 @@ static const struct {
{ "window-maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, 0 },
{ "window-vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CC, 0 
},
{ "window-hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CC, 0 
},
+   { "window-noinput", kbfunc_client_toggle_noinput, CWM_CONTEXT_CC, 0 },
{ "window-freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CC, 0 },
{ "window-cycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
(CWM_CYCLE_FORWARD) },
diff --git a/app/cwm/cwmrc.5 b/app/cw