~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_tty.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_tty.c,v 1.2 1999/01/26 10:40:38 dawes Exp $ */
 
2
/*
 
3
 * INTEL DG/UX RELEASE 4.20 MU03
 
4
 * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK
 
5
 * <takis@dpmms.cam.ac.uk>
 
6
 *
 
7
 * Permission to use, copy, modify, distribute, and sell this software and its
 
8
 * documentation for any purpose is hereby granted without fee, provided that
 
9
 * the above copyright notice appear in all copies and that both that
 
10
 * copyright notice and this permission notice appear in supporting
 
11
 * documentation.
 
12
 * XCONSORTIUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
 
13
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 
14
 * FITNESS, IN NO EVENT SHALL XCONSORTIUM BE LIABLE FOR
 
15
 * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
 
16
 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
 
17
 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 
18
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
19
 *
 
20
 */
 
21
/* BSD (POSIX) Flavor tty for ix86 DG/ux R4.20MU03 */
 
22
 
 
23
#define NEED_EVENTS
 
24
#include "X.h"
 
25
#include "Xproto.h"
 
26
#include "inputstr.h"
 
27
#include "scrnintstr.h"
 
28
 
 
29
#include "xf86Procs.h"
 
30
#include "xf86_OSlib.h"
 
31
#include "xf86_Config.h"
 
32
 
 
33
static Bool not_a_tty = FALSE;
 
34
 
 
35
void xf86SetMouseSpeed(mouse, old, new, cflag)
 
36
MouseDevPtr mouse;
 
37
int old;
 
38
int new;
 
39
unsigned cflag;
 
40
{
 
41
        struct termios tty;
 
42
        char *c;
 
43
 
 
44
        if (not_a_tty)
 
45
                return;
 
46
 
 
47
        if (tcgetattr(mouse->mseFd, &tty) < 0)
 
48
        {
 
49
                not_a_tty = TRUE;
 
50
                ErrorF("Warning: %s unable to get status of mouse fd (%s)\n",
 
51
                       mouse->mseDevice, strerror(errno));
 
52
                return;
 
53
        }
 
54
 
 
55
        /* this will query the initial baudrate only once */
 
56
        if (mouse->oldBaudRate < 0) { 
 
57
           switch (cfgetispeed(&tty)) 
 
58
              {
 
59
              case B9600: 
 
60
                 mouse->oldBaudRate = 9600;
 
61
                 break;
 
62
              case B4800: 
 
63
                 mouse->oldBaudRate = 4800;
 
64
                 break;
 
65
              case B2400: 
 
66
                 mouse->oldBaudRate = 2400;
 
67
                 break;
 
68
              case B1200: 
 
69
              default:
 
70
                 mouse->oldBaudRate = 1200;
 
71
                 break;
 
72
              }
 
73
        }
 
74
 
 
75
        tty.c_iflag = IGNBRK | IGNPAR;
 
76
        tty.c_oflag = 0;
 
77
        tty.c_lflag = 0;
 
78
        tty.c_cflag = (tcflag_t)cflag;
 
79
        tty.c_cc[VTIME] = 0;
 
80
        tty.c_cc[VMIN] = 1;
 
81
 
 
82
        switch (old)
 
83
        {
 
84
        case 9600:
 
85
                cfsetispeed(&tty, B9600);
 
86
                cfsetospeed(&tty, B9600);
 
87
                break;
 
88
        case 4800:
 
89
                cfsetispeed(&tty, B4800);
 
90
                cfsetospeed(&tty, B4800);
 
91
                break;
 
92
        case 2400:
 
93
                cfsetispeed(&tty, B2400);
 
94
                cfsetospeed(&tty, B2400);
 
95
                break;
 
96
        case 1200:
 
97
        default:
 
98
                cfsetispeed(&tty, B1200);
 
99
                cfsetospeed(&tty, B1200);
 
100
        }
 
101
 
 
102
        if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
 
103
        {
 
104
                if (xf86Info.allowMouseOpenFail) {
 
105
                        ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
 
106
                               strerror(errno));
 
107
                        return;
 
108
                }
 
109
                xf86FatalError("Unable to set status of mouse fd (%s)\n",
 
110
                               strerror(errno));
 
111
        }
 
112
 
 
113
        switch (new)
 
114
        {
 
115
        case 9600:
 
116
                c = "*q";
 
117
                cfsetispeed(&tty, B9600);
 
118
                cfsetospeed(&tty, B9600);
 
119
                break;
 
120
        case 4800:
 
121
                c = "*p";
 
122
                cfsetispeed(&tty, B4800);
 
123
                cfsetospeed(&tty, B4800);
 
124
                break;
 
125
        case 2400:
 
126
                c = "*o";
 
127
                cfsetispeed(&tty, B2400);
 
128
                cfsetospeed(&tty, B2400);
 
129
                break;
 
130
        case 1200:
 
131
        default:
 
132
                c = "*n";
 
133
                cfsetispeed(&tty, B1200);
 
134
                cfsetospeed(&tty, B1200);
 
135
        }
 
136
 
 
137
        if (mouse->mseType == P_LOGIMAN || mouse->mseType == P_LOGI)
 
138
        {
 
139
                if (write(mouse->mseFd, c, 2) != 2)
 
140
                {
 
141
                        if (xf86AllowMouseOpenFail) {
 
142
                                ErrorF("Unable to write to mouse fd (%s) - Continuing...\n",
 
143
                                       strerror(errno));
 
144
                                return;
 
145
                        }
 
146
                        xf86FatalError("Unable to write to mouse fd (%s)\n",
 
147
                                       strerror(errno));
 
148
                }
 
149
        }
 
150
        usleep(100000);
 
151
 
 
152
        if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
 
153
        {
 
154
                if (xf86AllowMouseOpenFail) {
 
155
                        ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
 
156
                               strerror(errno));
 
157
                        return;
 
158
                }
 
159
                xf86FatalError("Unable to set status of mouse fd (%s)\n",
 
160
                               strerror(errno));
 
161
        }
 
162
}
 
163
 
 
164
/* ADDED FOR X 3.3.2.3 */
 
165
int
 
166
xf86FlushInput(fd)
 
167
int fd;
 
168
{
 
169
        return tcflush(fd, TCIFLUSH);
 
170
}
 
171