getty: remove gettytab f0, f1, f2 capabilities

2013-12-10 Thread Christian Weisgerber
Bad news: That terminal you hooked up 30 years ago--okay, okay.

Same thing as yesterday's lpd diff: Remove from getty the f0, f1,
f2 gettytab capabilities that were used to poke magic numbers into
sgtty.  The modern replacement for f# is the set i#, o#, c#, l#
to poke magic numbers into termios.  *stabs himself with spork*

Our /etc/gettytab has one affected, highly historical entry, which
I have dutifully converted using the compatflags() function one
last time.

ok?

Index: etc/gettytab
===
RCS file: /cvs/src/etc/gettytab,v
retrieving revision 1.4
diff -u -p -r1.4 gettytab
--- etc/gettytab8 Sep 2000 02:27:36 -   1.4
+++ etc/gettytab10 Dec 2013 18:48:41 -
@@ -150,4 +150,4 @@ s|DSW|Port Selector:\
 # to one of the NNN-baud entries.
 #
 A|Auto-baud:\
-   :ab:sp#2400:f0#040:
+   :ab:sp#2400:i0#04000:o0#0:c0#045400:l0#0:
Index: libexec/getty/gettytab.5
===
RCS file: /cvs/src/libexec/getty/gettytab.5,v
retrieving revision 1.21
diff -u -p -r1.21 gettytab.5
--- libexec/getty/gettytab.53 Sep 2011 23:40:16 -   1.21
+++ libexec/getty/gettytab.510 Dec 2013 19:11:45 -
@@ -93,9 +93,6 @@ after login prompt.
 .Pq Dv EOF
 character.
 .It ev Ta str Ta Dv NULL Ta Initial environment.
-.It f0 Ta num Ta unused Ta TTY mode flags to write messages.
-.It f1 Ta num Ta unused Ta TTY mode flags to read login name.
-.It f2 Ta num Ta unused Ta TTY mode flags to leave terminal as.
 .It fl Ta str Ta So Li ^O Sc Ta Output flush character.
 .It hc Ta bool Ta false Ta \Do
 .Em not
@@ -161,6 +158,9 @@ The following capabilities are no longer
 .It bd Ta num Ta 0 Ta Backspace delay.
 .It cb Ta bool Ta false Ta Use CRT backspace mode.
 .It cd Ta num Ta 0 Ta Carriage-return delay.
+.It f0 Ta num Ta unused Ta TTY mode flags to write messages.
+.It f1 Ta num Ta unused Ta TTY mode flags to read login name.
+.It f2 Ta num Ta unused Ta TTY mode flags to leave terminal as.
 .It fd Ta num Ta 0 Ta Form-feed (vertical motion) delay.
 .It nd Ta num Ta 0 Ta Newline (line-feed) delay.
 .It uc Ta bool Ta false Ta Terminal is known upper case only.
@@ -205,16 +205,6 @@ and
 .Em c_oflag
 fields, respectively.
 Each of these sets must be completely specified to be effective.
-The
-.Em \f0 ,
-.Em \f1 ,
-and
-.Em \f2
-are excepted for backwards compatibility with a previous incarnation of
-the TTY subsystem.
-In these flags the bottom 16 bits of the (32 bits) value contain the sgttyb
-.Em sg_flags
-field, while the top 16 bits represent the local mode word.
 .Pp
 Should
 .Xr getty 8
Index: libexec/getty/gettytab.h
===
RCS file: /cvs/src/libexec/getty/gettytab.h,v
retrieving revision 1.6
diff -u -p -r1.6 gettytab.h
--- libexec/getty/gettytab.h2 Jun 2003 19:38:24 -   1.6
+++ libexec/getty/gettytab.h10 Dec 2013 19:08:24 -
@@ -96,37 +96,31 @@ struct gettyflags {
 #defineFD  gettynums[6].value
 #defineBD  gettynums[7].value
 #defineTO  gettynums[8].value
-#defineF0  gettynums[9].value
-#defineF0set   gettynums[9].set
-#defineF1  gettynums[10].value
-#defineF1set   gettynums[10].set
-#defineF2  gettynums[11].value
-#defineF2set   gettynums[11].set
-#definePF  gettynums[12].value
-#defineC0  gettynums[13].value
-#defineC0set   gettynums[13].set
-#defineC1  gettynums[14].value
-#defineC1set   gettynums[14].set
-#defineC2  gettynums[15].value
-#defineC2set   gettynums[15].set
-#defineI0  gettynums[16].value
-#defineI0set   gettynums[16].set
-#defineI1  gettynums[17].value
-#defineI1set   gettynums[17].set
-#defineI2  gettynums[18].value
-#defineI2set   gettynums[18].set
-#defineL0  gettynums[19].value
-#defineL0set   gettynums[19].set
-#defineL1  gettynums[20].value
-#defineL1set   gettynums[20].set
-#defineL2  gettynums[21].value
-#defineL2set   gettynums[21].set
-#defineO0  gettynums[22].value
-#defineO0set   gettynums[22].set
-#defineO1  gettynums[23].value
-#defineO1set   gettynums[23].set
-#defineO2  gettynums[24].value
-#defineO2set   gettynums[24].set
+#definePF  gettynums[9].value
+#defineC0  gettynums[10].value
+#defineC0set   gettynums[10].set
+#defineC1  gettynums[11].value
+#defineC1set   gettynums[11].set
+#defineC2  gettynums[12].value
+#defineC2set   gettynums[12].set
+#defineI0  gettynums[13].value
+#defineI0set   gettynums[13].set
+#defineI1  gettynums[14].value
+#defineI1set   gettynums[14].set
+#defineI2  

Remove 4.3BSD tty compatibility, take 2

2013-12-10 Thread Christian Weisgerber
New attempt, now that the userland has been cleaned up.  This diff
kills the remaining parts of the COMPAT_43 tty handling in the
kernel.  (There are some further network-related COMPAT_43 fragments
that are not touched by this.)

Comments?  ok?

R compat/common/tty_43.c
M conf/files
M ddb/db_structinfo.c
M kern/tty.c
M kern/tty_conf.c
M kern/tty_pty.c
M sys/ioctl.h
M sys/ioctl_compat.h
M sys/tty.h
R sys/ttychars.h
R sys/ttydev.h

Index: compat/common/tty_43.c
===
RCS file: compat/common/tty_43.c
diff -N compat/common/tty_43.c
--- compat/common/tty_43.c  9 Apr 2013 02:56:50 -   1.11
+++ /dev/null   1 Jan 1970 00:00:00 -
@@ -1,485 +0,0 @@
-/* $OpenBSD: tty_43.c,v 1.11 2013/04/09 02:56:50 tedu Exp $*/
-/* $NetBSD: tty_43.c,v 1.5 1996/05/20 14:29:17 mark Exp $  */
-
-/*-
- * Copyright (c) 1982, 1986, 1991, 1993
- * The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)tty_compat.c8.1 (Berkeley) 6/10/93
- */
-
-/*
- * mapping routines for old line discipline (yuck)
- */
-#include sys/param.h
-#include sys/systm.h
-#include sys/ioctl.h
-#include sys/proc.h
-#include sys/tty.h
-#include sys/termios.h
-#include sys/file.h
-#include sys/conf.h
-#include sys/kernel.h
-#include sys/syslog.h
-#include sys/ioctl_compat.h
-
-/*
- * XXX libcompat files should be included with config attributes
- */
-#ifdef COMPAT_OLDTTY
-
-int ttydebug = 0;
-
-static const struct speedtab compatspeeds[] = {
-#define MAX_SPEED  17
-   { 115200, 17 },
-   { 57600, 16 },
-   { 38400, 15 },
-   { 19200, 14 },
-   { 9600, 13 },
-   { 4800, 12 },
-   { 2400, 11 },
-   { 1800, 10 },
-   { 1200, 9 },
-   { 600,  8 },
-   { 300,  7 },
-   { 200,  6 },
-   { 150,  5 },
-   { 134,  4 },
-   { 110,  3 },
-   { 75,   2 },
-   { 50,   1 },
-   { 0,0 },
-   { -1,   -1 },
-};
-static const int compatspcodes[] = {
-   0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
-   1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200
-};
-
-int ttcompatgetflags(struct tty *);
-void ttcompatsetflags(struct tty *, struct termios *);
-void ttcompatsetlflags(struct tty *, struct termios *);
-
-/*ARGSUSED*/
-int
-ttcompat(struct tty *tp, u_long com, caddr_t data, int flag, struct proc *p)
-{
-
-   switch (com) {
-   case TIOCGETP: {
-   struct sgttyb *sg = (struct sgttyb *)data;
-   u_char *cc = tp-t_cc;
-   int speed;
-
-   speed = ttspeedtab(tp-t_ospeed, compatspeeds);
-   sg-sg_ospeed = (speed == -1) ? MAX_SPEED : speed;
-   if (tp-t_ispeed == 0)
-   sg-sg_ispeed = sg-sg_ospeed;
-   else {
-   speed = ttspeedtab(tp-t_ispeed, compatspeeds);
-   sg-sg_ispeed = (speed == -1) ? MAX_SPEED : speed;
-   }
-   sg-sg_erase = cc[VERASE];
-   sg-sg_kill = cc[VKILL];
-   sg-sg_flags = ttcompatgetflags(tp);
-   break;
-   }
-
-   case TIOCSETP:
-   case TIOCSETN: {
-   struct sgttyb *sg = (struct sgttyb *)data;
-   struct termios term;
-   int speed;
-
-   term = tp-t_termios;
-   if ((speed = sg-sg_ispeed)  MAX_SPEED || speed  0)
-   term.c_ispeed = speed;
-   

Re: Remove 4.3BSD tty compatibility, take 2

2013-12-10 Thread Mark Kettenis
 Date: Tue, 10 Dec 2013 21:48:41 +0100
 From: Christian Weisgerber na...@mips.inka.de
 
 New attempt, now that the userland has been cleaned up.  This diff
 kills the remaining parts of the COMPAT_43 tty handling in the
 kernel.  (There are some further network-related COMPAT_43 fragments
 that are not touched by this.)
 
 Comments?  ok?

Noticed TIOCGSID in that list.  Don't think that is a 4.3 compat
ioctl.  Rather a System V compat ioctl.  Might be useful if we ever
find the need to implement tcgetsid(3).  There is code in gnulib (the
GNU portability library) that uses this ioctl to implement
tcgetsid(3):

https://github.com/gagern/gnulib/blob/master/lib/tcgetsid.c

Not sure if there actually is anything out there that uses it.



Re: Remove 4.3BSD tty compatibility, take 2

2013-12-10 Thread Christian Weisgerber
Mark Kettenis:

 Noticed TIOCGSID in that list.  Don't think that is a 4.3 compat
 ioctl.  Rather a System V compat ioctl.

Well, it's implemented in compat/common/tty_43.c.  If we want to save
it, we need to move it to kern/tty.c:ttioctl().  Do we?

-- 
Christian naddy Weisgerber  na...@mips.inka.de



Re: Remove 4.3BSD tty compatibility, take 2

2013-12-10 Thread Theo de Raadt
  Noticed TIOCGSID in that list.  Don't think that is a 4.3 compat
  ioctl.  Rather a System V compat ioctl.
 
 Well, it's implemented in compat/common/tty_43.c.  If we want to save
 it, we need to move it to kern/tty.c:ttioctl().  Do we?

that's a seperate issue.  It can be recovered later ;)



Re: Remove 4.3BSD tty compatibility, take 2

2013-12-10 Thread Mark Kettenis
 From: Theo de Raadt dera...@cvs.openbsd.org
 Date: Tue, 10 Dec 2013 14:49:26 -0700
 
   Noticed TIOCGSID in that list.  Don't think that is a 4.3 compat
   ioctl.  Rather a System V compat ioctl.
  
  Well, it's implemented in compat/common/tty_43.c.  If we want to save
  it, we need to move it to kern/tty.c:ttioctl().  Do we?
 
 that's a seperate issue.  It can be recovered later ;)

If no important ports depend on it, yes ;)



Re: Remove 4.3BSD tty compatibility, take 2

2013-12-10 Thread Marc Espie
On Tue, Dec 10, 2013 at 10:31:31PM +0100, Mark Kettenis wrote:
  Date: Tue, 10 Dec 2013 21:48:41 +0100
  From: Christian Weisgerber na...@mips.inka.de
  
  New attempt, now that the userland has been cleaned up.  This diff
  kills the remaining parts of the COMPAT_43 tty handling in the
  kernel.  (There are some further network-related COMPAT_43 fragments
  that are not touched by this.)
  
  Comments?  ok?
 
 Noticed TIOCGSID in that list.  Don't think that is a 4.3 compat
 ioctl.  Rather a System V compat ioctl.  Might be useful if we ever
 find the need to implement tcgetsid(3).  There is code in gnulib (the
 GNU portability library) that uses this ioctl to implement
 tcgetsid(3):
 
 https://github.com/gagern/gnulib/blob/master/lib/tcgetsid.c
 
 Not sure if there actually is anything out there that uses it.

Note that tcgetsid(3) is part of posix 2008... I don't see this as
a noxious interface, so I don't see any reason not to keep it...

In ports, devel/ddd uses it as a fallback on systems without setsid.

lang/sbcl checks for it, but it definitely is just wanting to create
a wrapper for it.

(apparently, vala has similar code, just looking thru google).

Oh, hey, and it's in Stevens... so we MUST have it :)



Re: Remove 4.3BSD tty compatibility, take 2

2013-12-10 Thread Mark Kettenis
 Date: Tue, 10 Dec 2013 23:05:01 +0100
 From: Marc Espie es...@nerim.net
 
 On Tue, Dec 10, 2013 at 10:31:31PM +0100, Mark Kettenis wrote:
   Date: Tue, 10 Dec 2013 21:48:41 +0100
   From: Christian Weisgerber na...@mips.inka.de
   
   New attempt, now that the userland has been cleaned up.  This diff
   kills the remaining parts of the COMPAT_43 tty handling in the
   kernel.  (There are some further network-related COMPAT_43 fragments
   that are not touched by this.)
   
   Comments?  ok?
  
  Noticed TIOCGSID in that list.  Don't think that is a 4.3 compat
  ioctl.  Rather a System V compat ioctl.  Might be useful if we ever
  find the need to implement tcgetsid(3).  There is code in gnulib (the
  GNU portability library) that uses this ioctl to implement
  tcgetsid(3):
  
  https://github.com/gagern/gnulib/blob/master/lib/tcgetsid.c
  
  Not sure if there actually is anything out there that uses it.
 
 Note that tcgetsid(3) is part of posix 2008... I don't see this as
 a noxious interface, so I don't see any reason not to keep it...

Well, we don't actually have tcgetsid(3); only the ioctl that can be
used to implement it.  And tcgetsid(3) is an XSI extension, so not a
required POSIX interface.



Re: Remove 4.3BSD tty compatibility, take 2

2013-12-10 Thread Marc Espie
On Tue, Dec 10, 2013 at 11:05:01PM +0100, Marc Espie wrote:
 
 Note that tcgetsid(3) is part of posix 2008... I don't see this as
 a noxious interface, so I don't see any reason not to keep it...

My bad, it's XSI in posix 2008, but I was reading posix 2013, which has:

Issue 7

The tcgetsid() function is moved from the XSI option to the Base.



Re: Remove 4.3BSD tty compatibility, take 2

2013-12-10 Thread Philip Guenther
On Tue, Dec 10, 2013 at 2:14 PM, Mark Kettenis mark.kette...@xs4all.nl wrote:
 Well, we don't actually have tcgetsid(3); only the ioctl that can be
 used to implement it.  And tcgetsid(3) is an XSI extension, so not a
 required POSIX interface.

Issue 7
...
The tcgetsid() function is moved from the XSI option to the Base.


:-/



PATCH: Fix invalid size to 'memcmp' in 'rn_lexobetter'

2013-12-10 Thread Kieran Devlin
maybe someone could verify  commit this patch
this bug was introduced in  r1.28 of ‘src/sys/net/radix.c’
i found it while going through source codes

Index: sys/net/radix.c
===
RCS file: /cvs/src/sys/net/radix.c,v
retrieving revision 1.31
diff -u -p -8 -r1.31 radix.c
--- sys/net/radix.c 20 Oct 2013 16:17:36 -  1.31
+++ sys/net/radix.c 10 Dec 2013 09:13:58 -
@@ -471,34 +471,33 @@ rn_addmask(void *n_arg, int search, int 
if (isnormal)
x-rn_flags |= RNF_NORMAL;
return (x);
 }
 
 static int /* XXX: arbitrary ordering for non-contiguous masks */
 rn_lexobetter(void *m_arg, void *n_arg)
 {
-   u_char *mp = m_arg, *np = n_arg, *lim;
+   u_char *mp = m_arg, *np = n_arg;
 
/*
 * Longer masks might not really be lexicographically better,
 * but longer masks always have precedence since they must be checked
 * first. The netmasks were normalized before calling this function and
 * don't have unneeded trailing zeros.
 */
if (*mp  *np)
return 1;
if (*mp  *np)
return 0;
/*
 * Must return the first difference between the masks
 * to ensure deterministic sorting.
 */
-   lim = mp + *mp;
-   return (memcmp(mp, np, *lim)  0);
+   return (memcmp(mp, np, *mp)  0);
 }
 
 static struct radix_mask *
 rn_new_radix_mask(struct radix_node *tt, struct radix_mask *next)
 {
struct radix_mask *m;
 
MKGet(m);




Re: PATCH: Allow shared semaphores to be really shared

2013-12-10 Thread Vadim Zhukov
2013/12/9 Ted Unangst t...@tedunangst.com:
 On Mon, Dec 09, 2013 at 19:49, Vadim Zhukov wrote:
 So what's the decision?

 Are there any objections still? If not, can I have a pair of okays?
 KDE4 really needs a decision to be made: people already had apps
 crashing without this diff, so I've put a dirty hack to stop KDE using
 of process-shared semaphores. But there could be more dragons, in
 other software.

 If we go back to returning ENOMEM or whatever in sem_init, does that
 fix KDE?

If we stop pretending we support shared unnamed semaphores, then, yes,
this will help KDE. But I cannot gurantee there will be no other
fallout. This needs a deep scan of all ports source as minimum...

 I don't mean to be a dick about this, but in general here's how we do
 things. If a feature is added and it introduces a regression, we
 revert. We don't dig the hole deeper by committing an even more
 intrusive diff.

I'm agree, this is a good practice.

 I'm not saying the diff is bad or can't be made to work, but I don't
 like using KDE needs this now to rush it in if there are other
 options. I also don't think the thing you're doing with the spinlock
 is something we want.

This was done to avoid polluting exported symbols. It's ugly, yes. I
do not see any better option that doesn't involve rewriting entire
locking in librthread, though; I hope that I just miss something
obvious.

 I want time to get that right.

I'd rather disable shared semaphores totally, until all issues are
fixed, then. I don't see a point in having half-working stuff in tree
which gets picked up and used.

Yes, it was my bad too that I didn't thought about sharing semaphores
via mapped memory in the first place.

--
  WBR,
  Vadim Zhukov