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

« back to all changes in this revision

Viewing changes to unix/xc/programs/xinit/startx.cpp

  • 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
XCOMM!/bin/sh
 
2
 
 
3
XCOMM $Xorg: startx.cpp,v 1.3 2000/08/17 19:54:29 cpqbld Exp $
 
4
XCOMM
 
5
XCOMM This is just a sample implementation of a slightly less primitive
 
6
XCOMM interface than xinit.  It looks for user .xinitrc and .xserverrc
 
7
XCOMM files, then system xinitrc and xserverrc files, else lets xinit choose
 
8
XCOMM its default.  The system xinitrc should probably do things like check
 
9
XCOMM for .Xresources files and merge them in, startup up a window manager,
 
10
XCOMM and pop a clock and serveral xterms.
 
11
XCOMM
 
12
XCOMM Site administrators are STRONGLY urged to write nicer versions.
 
13
XCOMM
 
14
XCOMM $XFree86: xc/programs/xinit/startx.cpp,v 3.16 2003/01/24 21:30:02 herrb Exp $
 
15
 
 
16
#ifdef SCO
 
17
 
 
18
XCOMM Check for /usr/bin/X11 and BINDIR in the path, if not add them.
 
19
XCOMM This allows startx to be placed in a place like /usr/bin or /usr/local/bin
 
20
XCOMM and people may use X without changing their PATH
 
21
 
 
22
XCOMM First our compiled path
 
23
 
 
24
bindir=BINDIR
 
25
if expr $PATH : ".*`echo $bindir | sed 's?/?\\/?g'`.*" > /dev/null 2>&1; then
 
26
        :
 
27
else
 
28
        PATH=$PATH:BINDIR
 
29
fi
 
30
 
 
31
XCOMM Now the "SCO" compiled path
 
32
 
 
33
if expr $PATH : '.*\/usr\/bin\/X11.*' > /dev/null 2>&1; then
 
34
        :
 
35
else
 
36
        PATH=$PATH:/usr/bin/X11
 
37
fi
 
38
 
 
39
XCOMM Set up the XMERGE env var so that dos merge is happy under X
 
40
 
 
41
if [ -f /usr/lib/merge/xmergeset.sh ]; then
 
42
        . /usr/lib/merge/xmergeset.sh
 
43
elif [ -f /usr/lib/merge/console.disp ]; then
 
44
        XMERGE=`cat /usr/lib/merge/console.disp`
 
45
        export XMERGE
 
46
fi
 
47
 
 
48
scoclientrc=$HOME/.startxrc
 
49
#endif
 
50
 
 
51
userclientrc=$HOME/.xinitrc
 
52
userserverrc=$HOME/.xserverrc
 
53
sysclientrc=XINITDIR/xinitrc
 
54
sysserverrc=XINITDIR/xserverrc
 
55
defaultclient=BINDIR/xterm
 
56
defaultserver=BINDIR/X
 
57
defaultclientargs=""
 
58
defaultserverargs=""
 
59
clientargs=""
 
60
serverargs=""
 
61
 
 
62
#ifdef SCO
 
63
if [ -f $scoclientrc ]; then
 
64
    defaultclientargs=$scoclientrc
 
65
else
 
66
#endif
 
67
if [ -f $userclientrc ]; then
 
68
    defaultclientargs=$userclientrc
 
69
elif [ -f $sysclientrc ]; then
 
70
    defaultclientargs=$sysclientrc
 
71
fi
 
72
#ifdef SCO
 
73
fi
 
74
#endif
 
75
 
 
76
if [ -f $userserverrc ]; then
 
77
    defaultserverargs=$userserverrc
 
78
elif [ -f $sysserverrc ]; then
 
79
    defaultserverargs=$sysserverrc
 
80
fi
 
81
 
 
82
whoseargs="client"
 
83
while [ x"$1" != x ]; do
 
84
    case "$1" in
 
85
    # '' required to prevent cpp from treating "/*" as a C comment.
 
86
    /''*|\./''*)
 
87
        if [ "$whoseargs" = "client" ]; then
 
88
            if [ x"$clientargs" = x ]; then
 
89
                client="$1"
 
90
            else
 
91
                clientargs="$clientargs $1"
 
92
            fi
 
93
        else
 
94
            if [ x"$serverargs" = x ]; then
 
95
                server="$1"
 
96
            else
 
97
                serverargs="$serverargs $1"
 
98
            fi
 
99
        fi
 
100
        ;;
 
101
    --)
 
102
        whoseargs="server"
 
103
        ;;
 
104
    *)
 
105
        if [ "$whoseargs" = "client" ]; then
 
106
            clientargs="$clientargs $1"
 
107
        else
 
108
            # display must be the FIRST server argument
 
109
            if [ x"$serverargs" = x ] && \
 
110
                 expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
 
111
                display="$1"
 
112
            else
 
113
                serverargs="$serverargs $1"
 
114
            fi
 
115
        fi
 
116
        ;;
 
117
    esac
 
118
    shift
 
119
done
 
120
 
 
121
XCOMM process client arguments
 
122
if [ x"$client" = x ]; then
 
123
    # if no client arguments either, use rc file instead
 
124
    if [ x"$clientargs" = x ]; then
 
125
        client="$defaultclientargs"
 
126
    else
 
127
        client=$defaultclient
 
128
    fi
 
129
fi
 
130
 
 
131
XCOMM process server arguments
 
132
if [ x"$server" = x ]; then
 
133
    # if no server arguments or display either, use rc file instead
 
134
    if [ x"$serverargs" = x -a x"$display" = x ]; then
 
135
        server="$defaultserverargs"
 
136
    else
 
137
        server=$defaultserver
 
138
    fi
 
139
fi
 
140
 
 
141
if [ x"$XAUTHORITY" = x ]; then
 
142
    XAUTHORITY=$HOME/.Xauthority
 
143
    export XAUTHORITY
 
144
fi
 
145
 
 
146
removelist=
 
147
 
 
148
#if defined(HAS_COOKIE_MAKER) && defined(MK_COOKIE)
 
149
XCOMM set up default Xauth info for this machine
 
150
case `uname` in
 
151
Linux*)
 
152
        if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
 
153
                hostname=`hostname -f`
 
154
        else
 
155
                hostname=`hostname`
 
156
        fi
 
157
        ;;
 
158
*)
 
159
        hostname=`hostname`
 
160
        ;;
 
161
esac
 
162
 
 
163
authdisplay=${display:-:0}
 
164
mcookie=`MK_COOKIE`
 
165
for displayname in $authdisplay $hostname$authdisplay; do
 
166
    if ! xauth list "$displayname" | grep "$displayname " >/dev/null 2>&1; then
 
167
        xauth << EOF 
 
168
add $displayname . $mcookie
 
169
EOF
 
170
        removelist="$displayname $removelist"
 
171
    fi
 
172
done
 
173
#endif
 
174
 
 
175
xinit $client $clientargs -- $server $display $serverargs
 
176
 
 
177
if [ x"$removelist" != x ]; then
 
178
    xauth remove $removelist
 
179
fi
 
180
 
 
181
/*
 
182
 * various machines need special cleaning up
 
183
 */
 
184
#ifdef __linux__
 
185
if command -v deallocvt > /dev/null 2>&1; then
 
186
    deallocvt
 
187
fi
 
188
#endif
 
189
 
 
190
#ifdef macII
 
191
Xrepair
 
192
screenrestore
 
193
#endif
 
194
 
 
195
#if defined(sun) && !defined(i386)
 
196
kbd_mode -a
 
197
#endif