Re: calendar: Remove support for non-UTF-8 locales

2017-07-25 Thread Klemens Nanni
On Tue, Jul 25, 2017 at 11:56:42PM +0200, Theo Buehler wrote:
> On Tue, Jul 25, 2017 at 11:38:59PM +0200, Klemens Nanni wrote:
> > 5.9 is out, KOI8 isn't supported anymore.
> 
> It's at least the third time I see this diff. Pretty sure that Jan Stary
> sent the same quite a while back.
> 
> ok -- without the '))' -> ') )' change.
Overlooked, here you go.

Index: io.c
===
RCS file: /cvs/src/usr.bin/calendar/io.c,v
retrieving revision 1.44
diff -u -p -r1.44 io.c
--- io.c31 Aug 2016 09:38:47 -  1.44
+++ io.c25 Jul 2017 21:35:50 -
@@ -89,13 +89,9 @@ cal(void)
if (strncmp(buf, "LANG=", 5) == 0) {
(void) setlocale(LC_ALL, buf + 5);
setnnames();
-   /* XXX remove KOI8 lines after 5.9 is out */
if (!strcmp(buf + 5, "ru_RU.UTF-8") ||
!strcmp(buf + 5, "uk_UA.UTF-8") ||
-   !strcmp(buf + 5, "by_BY.UTF-8") ||
-   !strcmp(buf + 5, "ru_RU.KOI8-R") ||
-   !strcmp(buf + 5, "uk_UA.KOI8-U") ||
-   !strcmp(buf + 5, "by_BY.KOI8-B")) {
+   !strcmp(buf + 5, "by_BY.UTF-8")) {
bodun_maybe++;
bodun = 0;
free(prefix);



Re: calendar: Remove support for non-UTF-8 locales

2017-07-25 Thread Theo Buehler
On Tue, Jul 25, 2017 at 11:38:59PM +0200, Klemens Nanni wrote:
> 5.9 is out, KOI8 isn't supported anymore.

It's at least the third time I see this diff. Pretty sure that Jan Stary
sent the same quite a while back.

ok -- without the '))' -> ') )' change.


> 
> Index: io.c
> ===
> RCS file: /cvs/src/usr.bin/calendar/io.c,v
> retrieving revision 1.44
> diff -u -p -r1.44 io.c
> --- io.c  31 Aug 2016 09:38:47 -  1.44
> +++ io.c  25 Jul 2017 21:35:50 -
> @@ -89,13 +89,9 @@ cal(void)
>   if (strncmp(buf, "LANG=", 5) == 0) {
>   (void) setlocale(LC_ALL, buf + 5);
>   setnnames();
> - /* XXX remove KOI8 lines after 5.9 is out */
>   if (!strcmp(buf + 5, "ru_RU.UTF-8") ||
>   !strcmp(buf + 5, "uk_UA.UTF-8") ||
> - !strcmp(buf + 5, "by_BY.UTF-8") ||
> - !strcmp(buf + 5, "ru_RU.KOI8-R") ||
> - !strcmp(buf + 5, "uk_UA.KOI8-U") ||
> - !strcmp(buf + 5, "by_BY.KOI8-B")) {
> + !strcmp(buf + 5, "by_BY.UTF-8") ) {
>   bodun_maybe++;
>   bodun = 0;
>   free(prefix);
> 



calendar: Remove support for non-UTF-8 locales

2017-07-25 Thread Klemens Nanni
5.9 is out, KOI8 isn't supported anymore.

Index: io.c
===
RCS file: /cvs/src/usr.bin/calendar/io.c,v
retrieving revision 1.44
diff -u -p -r1.44 io.c
--- io.c31 Aug 2016 09:38:47 -  1.44
+++ io.c25 Jul 2017 21:35:50 -
@@ -89,13 +89,9 @@ cal(void)
if (strncmp(buf, "LANG=", 5) == 0) {
(void) setlocale(LC_ALL, buf + 5);
setnnames();
-   /* XXX remove KOI8 lines after 5.9 is out */
if (!strcmp(buf + 5, "ru_RU.UTF-8") ||
!strcmp(buf + 5, "uk_UA.UTF-8") ||
-   !strcmp(buf + 5, "by_BY.UTF-8") ||
-   !strcmp(buf + 5, "ru_RU.KOI8-R") ||
-   !strcmp(buf + 5, "uk_UA.KOI8-U") ||
-   !strcmp(buf + 5, "by_BY.KOI8-B")) {
+   !strcmp(buf + 5, "by_BY.UTF-8") ) {
bodun_maybe++;
bodun = 0;
free(prefix);



Re: magic.5: Add missing types

2017-07-25 Thread Klemens Nanni
On Tue, Jul 25, 2017 at 09:43:48PM +0100, Stuart Henderson wrote:
> On 2017/07/25 20:57, Klemens Nanni wrote:
> > I didn't touch the manual's first sentence mentioning file(1)'s version
> > since nicm@ reimplemented file(1) with revision 1.11 on 2015/04/24. He
> > or someone else more knowledgable in this regard might want to bump it
> > accordingly.
> 
> OpenBSD's /etc/magic doesn't match that provided with any particular
> version of file, parts have been updated as people have run into a need
> or bug, but there's been no wholesale update. Perhaps this would do?
> 
> diff --git usr.bin/file/magic.5 usr.bin/file/magic.5
> index 812c4c31095..f9ea22c3cc4 100644
> --- usr.bin/file/magic.5
> +++ usr.bin/file/magic.5
> @@ -41,10 +41,9 @@
>  This manual page documents the format of the magic file as
>  used by the
>  .Xr file 1
> -command, version 4.24.
> -The
> +command.
>  .Xr file 1
> -command identifies the type of a file using,
> +identifies the type of a file using,
>  among other tests,
>  a test for whether the file contains certain
>  .Dq "magic patterns" .
Already thought as much, looks fine to me.
 
> > -.Dd $Mdocdate: April 24 2016 $
> > +.Dd $Mdocdate: July 25 2017 $
> 
> btw, it's better to leave the CVS keywords ($Mdocdate$, $OpenBSD$, etc)
> alone, changing them guarantees a conflict if commits are made to the file.
Ah, sure (I knew about this in my first diff).



csh(1): postpone prompt

2017-07-25 Thread Anton Lindqvist
Hi,
In csh with filec enabled the prompt is displayed prior enabling
noncanonical mode on the tty. ksh on the other hand ensures the desired
mode is entered prior doing any I/O on the tty. This diff displays the
prompt after noncanonical mode has been enabled which also makes the
regress tests more reliable.

Joint work with bluhm@

Comments? OK?

Index: csh.c
===
RCS file: /cvs/src/bin/csh/csh.c,v
retrieving revision 1.39
diff -u -p -r1.39 csh.c
--- csh.c   19 Mar 2016 15:42:38 -  1.39
+++ csh.c   25 Jul 2017 20:44:40 -
@@ -1008,7 +1008,7 @@ process(bool catch)
 * read fresh stuff. Otherwise, we are rereading input and don't
 * need or want to prompt.
 */
-   if (aret == F_SEEK && fseekp == feobp)
+   if (!filec && aret == F_SEEK && fseekp == feobp)
printprompt();
(void) fflush(cshout);
}
Index: file.c
===
RCS file: /cvs/src/bin/csh/file.c,v
retrieving revision 1.31
diff -u -p -r1.31 file.c
--- file.c  18 Jul 2017 17:24:42 -  1.31
+++ file.c  25 Jul 2017 20:44:40 -
@@ -779,6 +779,8 @@ tenex(Char *inputline, int inputline_siz
cl.size = sizeof(buf);
if (tio->c_lflag & ALTWERASE)
cl.flags |= CL_ALTWERASE;
+   cl.flags |= CL_PROMPT;
+   cl_flush(&cl);  /* print prompt */
 
for (;;) {
if ((c = cl_getc(&cl)) == 0)
Index: func.c
===
RCS file: /cvs/src/bin/csh/func.c,v
retrieving revision 1.33
diff -u -p -r1.33 func.c
--- func.c  14 Aug 2016 19:46:31 -  1.33
+++ func.c  25 Jul 2017 20:44:40 -
@@ -589,7 +589,7 @@ search(int type, int level, Char *goal)
bseek(&a);
 }
 do {
-   if (intty && fseekp == feobp && aret == F_SEEK)
+   if (intty && !filec && fseekp == feobp && aret == F_SEEK)
(void) fprintf(cshout, "? "), (void) fflush(cshout);
aword[0] = 0;
(void) getword(aword);



Re: magic.5: Add missing types

2017-07-25 Thread Stuart Henderson
On 2017/07/25 20:57, Klemens Nanni wrote:
> I didn't touch the manual's first sentence mentioning file(1)'s version
> since nicm@ reimplemented file(1) with revision 1.11 on 2015/04/24. He
> or someone else more knowledgable in this regard might want to bump it
> accordingly.

OpenBSD's /etc/magic doesn't match that provided with any particular
version of file, parts have been updated as people have run into a need
or bug, but there's been no wholesale update. Perhaps this would do?

diff --git usr.bin/file/magic.5 usr.bin/file/magic.5
index 812c4c31095..f9ea22c3cc4 100644
--- usr.bin/file/magic.5
+++ usr.bin/file/magic.5
@@ -41,10 +41,9 @@
 This manual page documents the format of the magic file as
 used by the
 .Xr file 1
-command, version 4.24.
-The
+command.
 .Xr file 1
-command identifies the type of a file using,
+identifies the type of a file using,
 among other tests,
 a test for whether the file contains certain
 .Dq "magic patterns" .

> @@ -218,6 +218,28 @@ This is intended to be used with the tes
>  .Em x
>  (which is always true) and a message that is to be used if there are
>  no other matches.
> +.It Dv clear
> +This test is always true and clears the match flag for that level.
> +It is intended to be used with the default test.
> +.It Dv name
> +Define a named magic instance that can be called from another
> +.Dv use
> +magic entry, like a subroutine call.
> +Named instance direct magic offsets are relative to the offset of the
> +previous matched entry, but indirect offsets are relative to the
> +beginning of the file as usual.
> +Named magic entries always match.
> +.It Dv use
> +Recursively call the named magic starting from the current offset.
> +If the name of the referenced instance begins with a
> +.Dv ^
> +then the endianness of the magic is switched; if the magic mentioned
> +.Dv leshort
> +for example,
> +it is treated as
> +.Dv beshort
> +and vice versa.
> +This is useful to avoid duplicating the rules for different endianness.
>  .El
>  .Pp
>  Each top-level magic pattern (see below for an explanation of levels)

This reads OK to me.

> -.Dd $Mdocdate: April 24 2016 $
> +.Dd $Mdocdate: July 25 2017 $

btw, it's better to leave the CVS keywords ($Mdocdate$, $OpenBSD$, etc)
alone, changing them guarantees a conflict if commits are made to the file.



pledge snmpctl

2017-07-25 Thread Rob Pierce
snmpclient pledges after calling chroot(2) and requires a dns promise for
sendto(2) with non-NULL destination.

Rob

Index: snmpclient.c
===
RCS file: /cvs/src/usr.sbin/snmpctl/snmpclient.c,v
retrieving revision 1.13
diff -u -p -r1.13 snmpclient.c
--- snmpclient.c16 Jan 2015 06:40:21 -  1.13
+++ snmpclient.c25 Jul 2017 19:05:37 -
@@ -160,6 +160,9 @@ snmpclient(struct parse_result *res)
 #endif
}
 
+   if (pledge("stdio dns", NULL) == -1)
+   fatal("pledge");
+
sc.sc_fd = s;
sc.sc_community = res->community;
sc.sc_version = res->version;
Index: snmpctl.c
===
RCS file: /cvs/src/usr.sbin/snmpctl/snmpctl.c,v
retrieving revision 1.22
diff -u -p -r1.22 snmpctl.c
--- snmpctl.c   28 Oct 2016 20:49:32 -  1.22
+++ snmpctl.c   25 Jul 2017 19:05:37 -
@@ -123,6 +123,8 @@ main(int argc, char *argv[])
usage();
break;
case SHOW_MIB:
+   if (pledge("stdio", NULL) == -1)
+   fatal("pledge");
show_mib();
break;
case WALK:
@@ -131,6 +133,8 @@ main(int argc, char *argv[])
snmpclient(res);
break;
default:
+   if (pledge("stdio unix", NULL) == -1)
+   fatal("pledge");
goto connect;
}
 
@@ -155,6 +159,9 @@ main(int argc, char *argv[])
}
err(1, "connect: %s", sock);
}
+
+   if (pledge("stdio", NULL) == -1)
+   fatal("pledge");
 
imsg_init(&ibuf, ctl_sock);
done = 0;



Re: magic.5: Add missing types

2017-07-25 Thread Klemens Nanni
On Mon, Jul 03, 2017 at 05:36:52PM +0100, Nicholas Marriott wrote:
> Hi
> 
> On Thu, Jun 29, 2017 at 09:29:57PM +0200, Klemens Nanni wrote:
> > While reading file(1)'s code in #openbsd-daily mulander noted that the
> > 'name' and 'use' types were missing from magic(5).
> > 
> > I'm not entirely sure yet whether this is complete, so here's what I
> > did:
> > 
> > magic(5) provided by devel/magic documents version 5.31 while base's
> > magic(5) is at 4.24. Here are the types found in 5.31 but not ours as
> > well as those of the missing ones that are actually implemented but
> > undocumented as of now:
> > 
> > $ grep -i "TYPE_($(grep -F 'It Dv' $(man -w magic) |
> > cut -d' ' -f3 | sort | uniq -u | paste -sd\| - |
> > tee /dev/stderr))" magic.h
> > beid3|beqwdate|clear|indirect|leid3|leqwdate|name|qwdate|use
> > MAGIC_TYPE_CLEAR,
> > MAGIC_TYPE_NAME,
> > MAGIC_TYPE_USE,
> > 
> > What about the current version being 4.21? We're clearly ahead of this,
> > it seems magic(5) wasn't updated when nicm@ reimplemented things.
> > 
> > This patch documents the respective types.
> 
> Did you copy this text from upstream or write it?
> 
> Some comments inline.
> 
> > Feedback/OK?
> > 
> > Index: magic.5
> > ===
> > RCS file: /cvs/src/usr.bin/file/magic.5,v
> > retrieving revision 1.17
> > diff -u -p -r1.17 magic.5
> > --- magic.5 24 Apr 2016 07:02:07 -  1.17
> > +++ magic.5 29 Jun 2017 17:41:56 -
> > @@ -218,6 +218,31 @@ This is intended to be used with the tes
> > .Em x
> > (which is always true) and a message that is to be used if there are
> > no other matches.
> > +.It Dv clear
> > +This test is always true and clears the match flag for that continuation
> > +level.
> 
> I would just say "that level" or "the test's level" not "that
> continuation level" because there is no previous mention of
> "continuation".
> 
> > +It is intended to be used with the default test.
> > +.It Dv name
> > +Define a
> > +.Dq named
> 
> I don't think quotation marks are necessary here.
> 
> > +magic instance that can be called from another
> > +.Dv use
> > +magic entry, like a subroutine call.
> > +Named instance direct magic offsets are relative to the offset of the
> > +previous matched entry, but indirect offsets are relative to the
> > +beginning of the file as usual.
> > +Named magic entries always match.
> > +.It Dv use
> > +Recursively call the named magic starting from the current offset.
> > +If the name of the referenced begins with a
> 
> "the referenced instance" would be better than "the referenced".
Here's an updated diff incorporating your suggestions.

I didn't touch the manual's first sentence mentioning file(1)'s version
since nicm@ reimplemented file(1) with revision 1.11 on 2015/04/24. He
or someone else more knowledgable in this regard might want to bump it
accordingly.

Feedback? Comments?

Index: magic.5
===
RCS file: /cvs/src/usr.bin/file/magic.5,v
retrieving revision 1.17
diff -u -p -r1.17 magic.5
--- magic.5 24 Apr 2016 07:02:07 -  1.17
+++ magic.5 25 Jul 2017 18:56:40 -
@@ -30,7 +30,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd $Mdocdate: April 24 2016 $
+.Dd $Mdocdate: July 25 2017 $
 .Dt MAGIC 5
 .Os
 .\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
@@ -218,6 +218,28 @@ This is intended to be used with the tes
 .Em x
 (which is always true) and a message that is to be used if there are
 no other matches.
+.It Dv clear
+This test is always true and clears the match flag for that level.
+It is intended to be used with the default test.
+.It Dv name
+Define a named magic instance that can be called from another
+.Dv use
+magic entry, like a subroutine call.
+Named instance direct magic offsets are relative to the offset of the
+previous matched entry, but indirect offsets are relative to the
+beginning of the file as usual.
+Named magic entries always match.
+.It Dv use
+Recursively call the named magic starting from the current offset.
+If the name of the referenced instance begins with a
+.Dv ^
+then the endianness of the magic is switched; if the magic mentioned
+.Dv leshort
+for example,
+it is treated as
+.Dv beshort
+and vice versa.
+This is useful to avoid duplicating the rules for different endianness.
 .El
 .Pp
 Each top-level magic pattern (see below for an explanation of levels)



em link state change

2017-07-25 Thread Alexander Bluhm
Hi,

The LINK_STATE_IS_UP() macro considers LINK_STATE_UNKNOWN as up.
So the em driver never gets out of that state.  The change was in
sys/net/if.h

revision 1.123
date: 2011/07/03 17:41:50;  author: claudio;  state: Exp;  lines: +3 -2;
LINK_STATE_IS_UP() should consider LINK_STATE_UNKNOWN as an up state.
This is now possible because carp no longer uses LINK_STATE_UNKNOWN
for a state that is considered down. This will simplify a lot of code.
OK mpf@ mcbride@ henning@

I have checked ix(4), bge(4), myx(4).  They compare the new value
with the old.  em(4) should do the same.

ok?

bluhm

Index: dev/pci/if_em.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_em.c,v
retrieving revision 1.335
diff -u -p -r1.335 if_em.c
--- dev/pci/if_em.c 19 Mar 2017 11:09:26 -  1.335
+++ dev/pci/if_em.c 25 Jul 2017 15:37:31 -
@@ -1458,6 +1458,7 @@ void
 em_update_link_status(struct em_softc *sc)
 {
struct ifnet *ifp = &sc->sc_ac.ac_if;
+   u_char link_state;
 
if (E1000_READ_REG(&sc->hw, STATUS) & E1000_STATUS_LU) {
if (sc->link_active == 0) {
@@ -1480,11 +1481,10 @@ em_update_link_status(struct em_softc *s
sc->smartspeed = 0;
ifp->if_baudrate = IF_Mbps(sc->link_speed);
}
-   if (!LINK_STATE_IS_UP(ifp->if_link_state)) {
-   if (sc->link_duplex == FULL_DUPLEX)
-   ifp->if_link_state = LINK_STATE_FULL_DUPLEX;
-   else
-   ifp->if_link_state = LINK_STATE_HALF_DUPLEX;
+   link_state = (sc->link_duplex == FULL_DUPLEX) ?
+   LINK_STATE_FULL_DUPLEX : LINK_STATE_HALF_DUPLEX;
+   if (ifp->if_link_state != link_state) {
+   ifp->if_link_state = link_state;
if_link_state_change(ifp);
}
} else {



Re: Add Diffie-Hellman group negotiation to iked

2017-07-25 Thread Tim Stewart
viq  writes:

> On 17-07-18 23:20:26, Tim Stewart wrote:
>> viq  writes:
>>
>> > On 17-06-25 21:44:24, Tim Stewart wrote:
>> >> Hi,
>> >>
>> >> In this message I've tried to encode everything I've done to allow
>> >> strongSwan on Android to connect with iked, including the latest patch.
>> >> I have also verified that it breaks neither initial negotiation nor
>> >> Child SA rekeying for OpenBSD, Windows, and strongSwan (on Android)
>> >> clients.
>> >
>> >  This patch gets my android phone much closer to being able to negotiate
>> >  a connection, but there are still issues. Paraphrasing analysis mikeb
>> >  performed on IRC:
>> >  android sends incorrect (for us) group, and with this patch we now send
>> >  a failure message and android retries. But, we don't increment msgid
>> >  "because we did sa_free and restarted, so we can assume that android
>> >  thinks that negotiation continues, that's why it re-sends the
>> >  IKE_SA_INIT"
>>
>> I'm glad it seems to help, though it's too bad that the patch doesn't
>> work completely for you.
>>
>> I haven't really considered msgids--I'll do some more reading to see
>> what I might be missing there.  I do know that resending an IKE_SA_INIT
>> message with a different DH group is correct, however, and this does
>> work on my phone.  For your reference, the first line of my strongSwan
>> log tells me that I'm using strongSwan 5.5.3 and Android 7.1.1.
>>
>> I see that you forwarded the iked logs in a reply to this email.  Is
>> this the full log after a fresh iked startup with no existing SAs?
>
> This is after a fresh startup, there exists an SA but for a separete
> site-to-site config I have in place. If completely fresh logs are
> needed I could comment that out.

Well, my thinking here was that incorrect policy matching could be
confusing the issue.  I often find it helpful to comment out other
policies to eliminate policy matching as a failure point during testing.

>> Also, would it be possible to forward an anonymized config and the
>> strongSwan logs so that I can compare to mine?  (I can also post my
>> logs, but I'll have to do it in the next day or two as I'm out of time
>> for today.)
>
> First, sorry for the delay with replying to this. Second, I'm not sure
> how to get to the logs, seeing as I'm using the built-in VPN client that
> came with Samsung S8.

Oh, for some reason I assumed you were using strongSwan!  My mistake.
Can you provide a link to some more info about the Samsung S8's built-in
client?

I haven't had any time since my last post, but I still plan to look into
the msgids.

-TimS

--
Tim Stewart
---
Mail:   t...@stoo.org
Matrix: @tim:stoo.org