summaryrefslogtreecommitdiff
path: root/sys/dev/wscons
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-08-14 11:00:16 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-08-14 11:00:16 +0000
commit7a5cb464cb9e625c495a794c61a769a8c4e866b5 (patch)
treee4c9053d7737bea4ed7f5c479e4724a5db3d0cb1 /sys/dev/wscons
parentaa90e1774f220cac512a167a80241a994474f8e9 (diff)
Honor (the lack of) FWRITE in the various ioctl routines; with input from
fgs@ and mickey@; ok deraadt@.
Diffstat (limited to 'sys/dev/wscons')
-rw-r--r--sys/dev/wscons/wsdisplay.c26
-rw-r--r--sys/dev/wscons/wskbd.c26
-rw-r--r--sys/dev/wscons/wsmouse.c11
-rw-r--r--sys/dev/wscons/wsmux.c16
4 files changed, 56 insertions, 23 deletions
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index bb2199d8ce5..f2b8fbd4063 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay.c,v 1.61 2005/07/17 10:43:24 miod Exp $ */
+/* $OpenBSD: wsdisplay.c,v 1.62 2005/08/14 11:00:15 miod Exp $ */
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -831,7 +831,7 @@ wsdisplayclose(dev_t dev, int flag, int mode, struct proc *p)
if (scr->scr_rawkbd) {
int kbmode = WSKBD_TRANSLATED;
(void) wsdisplay_internal_ioctl(sc, scr, WSKBDIO_SETMODE,
- (caddr_t)&kbmode, 0, p);
+ (caddr_t)&kbmode, FWRITE, p);
}
#endif
@@ -983,10 +983,12 @@ wsdisplay_internal_ioctl(struct wsdisplay_softc *sc, struct wsscreen *scr,
#ifdef WSDISPLAY_COMPAT_RAWKBD
switch (cmd) {
- case WSKBDIO_SETMODE:
+ case WSKBDIO_SETMODE:
+ if ((flag & FWRITE) == 0)
+ return (EACCES);
scr->scr_rawkbd = (*(int *)data == WSKBD_RAW);
return (wsdisplay_update_rawkbd(sc, scr));
- case WSKBDIO_GETMODE:
+ case WSKBDIO_GETMODE:
*(int *)data = (scr->scr_rawkbd ?
WSKBD_RAW : WSKBD_TRANSLATED);
return (0);
@@ -1001,6 +1003,18 @@ wsdisplay_internal_ioctl(struct wsdisplay_softc *sc, struct wsscreen *scr,
#endif /* NWSKBD > 0 */
switch (cmd) {
+ case WSDISPLAYIO_SMODE:
+ case WSDISPLAYIO_USEFONT:
+#ifdef BURNER_SUPPORT
+ case WSDISPLAYIO_SVIDEO:
+ case WSDISPLAYIO_SBURNER:
+#endif
+ case WSDISPLAYIO_SETSCREEN:
+ if ((flag & FWRITE) == 0)
+ return (EACCES);
+ }
+
+ switch (cmd) {
case WSDISPLAYIO_GMODE:
if (scr->scr_flags & SCR_GRAPHICS) {
if (scr->scr_flags & SCR_DUMBFB)
@@ -1125,7 +1139,7 @@ wsdisplay_internal_ioctl(struct wsdisplay_softc *sc, struct wsscreen *scr,
}
return (error);
#undef d
-#endif
+#endif /* BURNER_SUPPORT */
case WSDISPLAYIO_GETSCREEN:
return (wsdisplay_getscreen(sc,
(struct wsdisplay_addscreendata *)data));
@@ -1492,7 +1506,7 @@ wsdisplay_update_rawkbd(struct wsdisplay_softc *sc, struct wsscreen *scr)
splx(s);
return (ENXIO);
}
- error = wsevsrc_display_ioctl(inp, WSKBDIO_SETMODE, &data, 0, 0);
+ error = wsevsrc_display_ioctl(inp, WSKBDIO_SETMODE, &data, FWRITE, 0);
if (!error)
sc->sc_rawkbd = raw;
splx(s);
diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c
index a01eda1d4d1..ac472a09a8f 100644
--- a/sys/dev/wscons/wskbd.c
+++ b/sys/dev/wscons/wskbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wskbd.c,v 1.45 2005/07/08 02:26:07 marc Exp $ */
+/* $OpenBSD: wskbd.c,v 1.46 2005/08/14 11:00:15 miod Exp $ */
/* $NetBSD: wskbd.c,v 1.80 2005/05/04 01:52:16 augustss Exp $ */
/*
@@ -953,6 +953,18 @@ wskbd_displayioctl(struct device *dev, u_long cmd, caddr_t data, int flag,
int len, error;
switch (cmd) {
+ case WSKBDIO_BELL:
+ case WSKBDIO_COMPLEXBELL:
+ case WSKBDIO_SETBELL:
+ case WSKBDIO_SETKEYREPEAT:
+ case WSKBDIO_SETDEFAULTKEYREPEAT:
+ case WSKBDIO_SETMAP:
+ case WSKBDIO_SETENCODING:
+ if ((flag & FWRITE) == 0)
+ return (EACCES);
+ }
+
+ switch (cmd) {
#define SETBELL(dstp, srcp, dfltp) \
do { \
(dstp)->pitch = ((srcp)->which & WSKBD_BELL_DOPITCH) ? \
@@ -965,22 +977,16 @@ wskbd_displayioctl(struct device *dev, u_long cmd, caddr_t data, int flag,
} while (0)
case WSKBDIO_BELL:
- if ((flag & FWRITE) == 0)
- return (EACCES);
return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie,
WSKBDIO_COMPLEXBELL, (caddr_t)&sc->sc_bell_data, flag, p));
case WSKBDIO_COMPLEXBELL:
- if ((flag & FWRITE) == 0)
- return (EACCES);
ubdp = (struct wskbd_bell_data *)data;
SETBELL(ubdp, ubdp, &sc->sc_bell_data);
return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie,
WSKBDIO_COMPLEXBELL, (caddr_t)ubdp, flag, p));
case WSKBDIO_SETBELL:
- if ((flag & FWRITE) == 0)
- return (EACCES);
kbdp = &sc->sc_bell_data;
setbell:
ubdp = (struct wskbd_bell_data *)data;
@@ -1017,8 +1023,6 @@ getbell:
} while (0)
case WSKBDIO_SETKEYREPEAT:
- if ((flag & FWRITE) == 0)
- return (EACCES);
kkdp = &sc->sc_keyrepeat_data;
setkeyrepeat:
ukdp = (struct wskbd_keyrepeat_data *)data;
@@ -1046,8 +1050,6 @@ getkeyrepeat:
#undef SETKEYREPEAT
case WSKBDIO_SETMAP:
- if ((flag & FWRITE) == 0)
- return (EACCES);
umdp = (struct wskbd_map_data *)data;
if (umdp->maplen > WSKBDIO_MAXMAPLEN)
return (EINVAL);
@@ -1080,8 +1082,6 @@ getkeyrepeat:
return(0);
case WSKBDIO_SETENCODING:
- if ((flag & FWRITE) == 0)
- return (EACCES);
enc = *((kbd_t *)data);
if (KB_ENCODING(enc) == KB_USER) {
/* user map must already be loaded */
diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c
index a40dbc16719..2cd1358c81e 100644
--- a/sys/dev/wscons/wsmouse.c
+++ b/sys/dev/wscons/wsmouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmouse.c,v 1.16 2005/06/01 18:50:30 miod Exp $ */
+/* $OpenBSD: wsmouse.c,v 1.17 2005/08/14 11:00:15 miod Exp $ */
/* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -590,6 +590,15 @@ wsmouse_do_ioctl(struct wsmouse_softc *sc, u_long cmd, caddr_t data, int flag,
/*
* Try the generic ioctls that the wsmouse interface supports.
*/
+
+ switch (cmd) {
+ case FIOASYNC:
+ case FIOSETOWN:
+ case TIOCSPGRP:
+ if ((flag & FWRITE) == 0)
+ return (EACCES);
+ }
+
switch (cmd) {
case FIONBIO: /* we will remove this someday (soon???) */
return (0);
diff --git a/sys/dev/wscons/wsmux.c b/sys/dev/wscons/wsmux.c
index 9964bff685a..f250741e1d1 100644
--- a/sys/dev/wscons/wsmux.c
+++ b/sys/dev/wscons/wsmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmux.c,v 1.14 2005/05/15 19:03:47 deraadt Exp $ */
+/* $OpenBSD: wsmux.c,v 1.15 2005/08/14 11:00:15 miod Exp $ */
/* $NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $ */
/*
@@ -377,9 +377,19 @@ wsmux_do_ioctl(struct device *dv, u_long cmd, caddr_t data, int flag,
switch (cmd) {
case WSMUXIO_INJECTEVENT:
+ case WSMUXIO_ADD_DEVICE:
+ case WSMUXIO_REMOVE_DEVICE:
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+ case WSKBDIO_SETMODE:
+#endif
+ if ((flag & FWRITE) == 0)
+ return (EACCES);
+ }
+
+ switch (cmd) {
+ case WSMUXIO_INJECTEVENT:
/* Inject an event, e.g., from moused. */
DPRINTF(("%s: inject\n", sc->sc_base.me_dv.dv_xname));
-
evar = sc->sc_base.me_evp;
if (evar == NULL) {
/* No event sink, so ignore it. */
@@ -627,7 +637,7 @@ wsmux_attach_sc(struct wsmux_softc *sc, struct wsevsrc *me)
DPRINTF(("wsmux_attach_sc: %s set rawkbd=%d\n",
me->me_dv.dv_xname, sc->sc_rawkbd));
(void)wsevsrc_ioctl(me, WSKBDIO_SETMODE,
- &sc->sc_rawkbd, 0, 0);
+ &sc->sc_rawkbd, FWRITE, 0);
#endif
if (sc->sc_kbd_layout != KB_NONE)
(void)wsevsrc_ioctl(me,