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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_ioperm.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/os2/os2_ioperm.c,v 3.6 1999/04/29 09:13:49 dawes Exp $ */
 
2
/*
 
3
 * Copyright 1993 by David Wexelblat <dwex@goblin.org>
 
4
 * Modified 1996 by Sebastien Marineau <marineau@genie.uottawa.ca>
 
5
 *
 
6
 * Permission to use, copy, modify, distribute, and sell this software and its
 
7
 * documentation for any purpose is hereby granted without fee, provided that
 
8
 * the above copyright notice appear in all copies and that both that
 
9
 * copyright notice and this permission notice appear in supporting
 
10
 * documentation, and that the name of David Wexelblat not be used in
 
11
 * advertising or publicity pertaining to distribution of the software without
 
12
 * specific, written prior permission.  David Wexelblat makes no representations
 
13
 * about the suitability of this software for any purpose.  It is provided
 
14
 * "as is" without express or implied warranty.
 
15
 *
 
16
 * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
18
 * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
20
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
21
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
22
 * PERFORMANCE OF THIS SOFTWARE.
 
23
 *
 
24
 */
 
25
/* $XConsortium: os2_ioperm.c /main/4 1996/04/18 16:50:01 kaleb $ */
 
26
 
 
27
 
 
28
 
 
29
#define I_NEED_OS2_H
 
30
#define INCL_32
 
31
#define INCL_DOS
 
32
#define INCL_DOSFILEMGR
 
33
#include "xf86.h"
 
34
#include "xf86Priv.h"
 
35
#include "xf86_OSlib.h"
 
36
 
 
37
/*
 
38
 * To access I/O ports under OS/2, we use the xf86sup.sys driver.
 
39
 * For the moment, we use a function which basically grants IO priviledge
 
40
 * to the whole server. NOTE: Once the server is running, we should 
 
41
 * change this to use inline IO functions through the callgate returned by 
 
42
 * the fastio$ driver.
 
43
 */
 
44
 
 
45
int ioEnabled=FALSE;
 
46
ULONG action;
 
47
char *ioDrvPath = "/dev/fastio$";
 
48
USHORT callgate[3]={0,0,0};
 
49
 
 
50
 
 
51
void xf86EnableIO()
 
52
{
 
53
 
 
54
HFILE hfd;
 
55
        ULONG dlen;
 
56
        APIRET rc;
 
57
 
 
58
        /* no need to call multiple times */
 
59
        if (ioEnabled) return;
 
60
        
 
61
        if (DosOpen((PSZ)ioDrvPath, (PHFILE)&hfd, (PULONG)&action,
 
62
           (ULONG)0, FILE_SYSTEM, FILE_OPEN,
 
63
           OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY,
 
64
           (ULONG)0) != 0) {
 
65
                xf86Msg(X_ERROR,"Error opening fastio$ driver...\n");
 
66
                xf86Msg(X_ERROR,"Please install xf86sup.sys in config.sys!\n");
 
67
                exit(42);
 
68
        }
 
69
        callgate[0] = callgate[1] = 0;
 
70
 
 
71
/* Get callgate from driver for fast io to ports and other stuff */
 
72
 
 
73
        rc = DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x64,
 
74
                NULL, 0, NULL,
 
75
                (ULONG*)&callgate[2], sizeof(USHORT), &dlen);
 
76
        if (rc) {
 
77
                xf86Msg(X_ERROR,
 
78
                        "EnableIOPorts failed, rc=%d, dlen=%d; emergency exit\n",
 
79
                        rc,dlen);
 
80
                DosClose(hfd);
 
81
                exit(42);
 
82
        }
 
83
 
 
84
/* Calling callgate with function 13 sets IOPL for the program */
 
85
 
 
86
        asm volatile ("movl $13,%%ebx;.byte 0xff,0x1d;.long _callgate"
 
87
                        : /*no outputs */ 
 
88
                        : /*no inputs */
 
89
                        : "eax","ebx","ecx","edx","cc");
 
90
 
 
91
        ioEnabled = TRUE;
 
92
        DosClose(hfd);
 
93
        return;
 
94
}
 
95
 
 
96
void xf86DisableIO()
 
97
{
 
98
HFILE hfd;
 
99
        ULONG dlen;
 
100
        APIRET rc;
 
101
 
 
102
        /* no need to call multiple times */
 
103
        if (!ioEnabled) return;
 
104
        
 
105
        if (DosOpen((PSZ)ioDrvPath, (PHFILE)&hfd, (PULONG)&action,
 
106
           (ULONG)0, FILE_SYSTEM, FILE_OPEN,
 
107
           OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY,
 
108
           (ULONG)0) != 0) {
 
109
                xf86Msg(X_ERROR,"Error opening fastio$ driver...\n");
 
110
                xf86Msg(X_ERROR,"Please install xf86sup.sys in config.sys!\n");
 
111
                return;
 
112
        }
 
113
        callgate[0] = callgate[1] = 0;
 
114
 
 
115
        rc = DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x64,
 
116
                NULL, 0, NULL,
 
117
                (ULONG*)&callgate[2], sizeof(USHORT), &dlen);
 
118
        if (rc) {
 
119
                xf86Msg(X_ERROR,"DisableIOPorts failed, rc=%d, dlen=%d\n",
 
120
                        rc,dlen);
 
121
                DosClose(hfd);
 
122
                return;
 
123
        }
 
124
 
 
125
/* Function 14 of callgate brings program back to ring 3 */
 
126
 
 
127
        asm volatile ("movl $14,%%ebx;.byte 0xff,0x1d;.long _callgate"
 
128
                        : /*no outputs */ 
 
129
                        : /*no inputs */
 
130
                        : "eax","ebx","ecx","edx","cc");
 
131
        ioEnabled=FALSE;
 
132
        DosClose(hfd);
 
133
        return;
 
134
 
 
135
}
 
136