~ubuntu-branches/ubuntu/maverick/xinit/maverick

« back to all changes in this revision

Viewing changes to startx.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau
  • Date: 2008-03-19 00:32:09 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080319003209-1r0a2jsvokgswbis
Tags: 1.0.8-1
* New upstream release
* Update our patches:
  + 001_debian_xinitrc.diff: fixup
  + 02_startx_hostname.diff: fixup
  + 04_startx_paths.diff: refresh
  + 06_move_serverauthfile_into_tmp.diff: fixup
* Don't build-depend on packages with a -1 debian revision.
* Bump Standards-Version to 3.7.3.
* Drop the XS- prefix from Vcs-* control fields.
* Don't pre-depend on x11-common, that's not needed as we don't install
  anything under /usr/{lib,include}/X11.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
XCOMM
14
14
XCOMM $XFree86: xc/programs/xinit/startx.cpp,v 3.16tsi Exp $
15
15
 
16
 
#if defined(__SCO__) || defined(__UNIXWARE__)
 
16
#if defined(__SCO__) || defined(__UNIXWARE__) || defined(__APPLE__)
17
17
 
18
18
XCOMM Check for /usr/bin/X11 and BINDIR in the path, if not add them.
19
19
XCOMM This allows startx to be placed in a place like /usr/bin or /usr/local/bin
20
20
XCOMM and people may use X without changing their PATH.
21
21
XCOMM Note that we put our own bin directory at the front of the path, and
22
 
XCOMM the standard SCO path at the back, since if you are using the Xorg
 
22
XCOMM the standard system path at the back, since if you are using the Xorg
23
23
XCOMM server theres a pretty good chance you want to bias the Xorg clients
24
 
XCOMM over the old SCO X11R5 clients.
 
24
XCOMM over the old system's clients.
25
25
 
26
26
XCOMM First our compiled path
27
 
 
28
 
bindir=BINDIR
29
 
scobindir=/usr/bin/X11
30
 
 
31
 
case $PATH in
32
 
  *:$bindir | *:$bindir:* | $bindir:*) ;;
33
 
  *) PATH=$bindir:$PATH ;;
34
 
esac
35
 
 
36
 
XCOMM Now the "SCO" compiled path
37
 
 
38
 
case $PATH in
39
 
  *:$scobindir | *:$scobindir:* | $scobindir:*) ;;
40
 
  *) PATH=$PATH:$scobindir ;;
41
 
esac
 
27
bindir=__bindir__
 
28
 
 
29
case $PATH in
 
30
    *:$bindir | *:$bindir:* | $bindir:*) ;;
 
31
    *) PATH=$bindir:$PATH ;;
 
32
esac
 
33
 
 
34
XCOMM Now the "old" compiled path
 
35
#ifdef __APPLE__
 
36
oldbindir=/usr/X11R6/bin
 
37
#else
 
38
oldbindir=/usr/bin/X11
 
39
#endif
 
40
 
 
41
if [ -d "$oldbindir" ] ; then
 
42
    case $PATH in
 
43
        *:$oldbindir | *:$oldbindir:* | $oldbindir:*) ;;
 
44
        *) PATH=$PATH:$oldbindir ;;
 
45
    esac
 
46
fi
42
47
 
43
48
XCOMM Bourne shell does not automatically export modified environment variables
44
49
XCOMM so export the new PATH just in case the user changes the shell
45
50
export PATH
 
51
#endif
46
52
 
 
53
#if defined(__SCO__) || defined(__UNIXWARE__)
47
54
XCOMM Set up the XMERGE env var so that dos merge is happy under X
48
55
 
49
56
if [ -f /usr/lib/merge/xmergeset.sh ]; then
71
78
clientargs=""
72
79
serverargs=""
73
80
 
 
81
#ifdef __APPLE__
 
82
 
 
83
XCOMM Initialize defaults (this will cut down on "safe" error messages)
 
84
if ! defaults read org.x.X11 cache_fonts >& /dev/null ; then
 
85
    defaults write org.x.X11 cache_fonts -bool true
 
86
fi
 
87
 
 
88
if ! defaults read org.x.X11 no_auth >& /dev/null ; then
 
89
    defaults write org.x.X11 no_auth -bool false
 
90
fi
 
91
 
 
92
if ! defaults read org.x.X11 nolisten_tcp >& /dev/null ; then
 
93
    defaults write org.x.X11 nolisten_tcp -bool true
 
94
fi
 
95
 
 
96
XCOMM First, start caching fonts
 
97
if [ x`defaults read org.x.X11 cache_fonts` = x1 ] ; then
 
98
    if [ -x /usr/X11/bin/font_cache.sh ] ; then
 
99
        /usr/X11/bin/font_cache.sh &
 
100
    elif [ -x /usr/X11/bin/fc-cache ] ; then
 
101
        /usr/X11/bin/fc-cache &
 
102
    fi
 
103
fi
 
104
 
 
105
if [ x`defaults read org.x.X11 no_auth` = x0 ] ; then
 
106
    enable_xauth=1
 
107
else
 
108
    enable_xauth=0
 
109
fi
 
110
 
 
111
if [ x`defaults read org.x.X11 nolisten_tcp` = x1 ] ; then
 
112
    defaultserverargs="$defaultserverargs -nolisten tcp"
 
113
fi
 
114
 
 
115
for ((d=0; ; d++)) ; do
 
116
    [[ -e /tmp/.X$d-lock ]] || break
 
117
done
 
118
defaultdisplay=":$d"
 
119
 
 
120
#else
 
121
enable_xauth=1
 
122
#endif
 
123
 
 
124
 
74
125
if [ -f $userclientrc ]; then
75
126
    defaultclientargs=$userclientrc
76
127
elif [ -f $sysclientrc ]; then
158
209
    XCOMM if no server arguments or display either, use rc file instead
159
210
    if [ x"$serverargs" = x -a x"$display" = x ]; then
160
211
        server="$defaultserverargs"
 
212
#ifdef __APPLE__
 
213
        display="$defaultdisplay"
 
214
#endif
161
215
    else
162
216
        server=$defaultserver
163
217
    fi
164
218
fi
165
219
 
166
 
if [ x"$XAUTHORITY" = x ]; then
167
 
    XAUTHORITY=$HOME/.Xauthority
168
 
    export XAUTHORITY
169
 
fi
170
 
 
171
 
removelist=
172
 
 
173
 
XCOMM set up default Xauth info for this machine
174
 
case `uname` in
175
 
Linux*)
176
 
        if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
177
 
                hostname=`hostname -f`
178
 
        else
179
 
                hostname=`hostname`
180
 
        fi
181
 
        ;;
182
 
*)
183
 
        hostname=`hostname`
184
 
        ;;
185
 
esac
186
 
 
187
 
authdisplay=${display:-:0}
 
220
if [ x"$enable_xauth" = x1 ] ; then
 
221
    if [ x"$XAUTHORITY" = x ]; then
 
222
        XAUTHORITY=$HOME/.Xauthority
 
223
        export XAUTHORITY
 
224
    fi
 
225
 
 
226
    removelist=
 
227
 
 
228
    XCOMM set up default Xauth info for this machine
 
229
    case `uname` in
 
230
    Linux*)
 
231
        if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
 
232
            hostname=`hostname -f`
 
233
        else
 
234
            hostname=`hostname`
 
235
        fi
 
236
        ;;
 
237
    *)
 
238
        hostname=`hostname`
 
239
        ;;
 
240
    esac
 
241
 
 
242
    authdisplay=${display:-:0}
188
243
#if defined(HAS_COOKIE_MAKER) && defined(MK_COOKIE)
189
 
mcookie=`MK_COOKIE`
 
244
    mcookie=`MK_COOKIE`
190
245
#else
191
 
mcookie=`dd if=/dev/random bs=16 count=1 2>/dev/null | hexdump -e \\"%08x\\"`
192
 
if test x"$mcookie" = x; then
193
 
                echo "Couldn't create cookie"
194
 
                exit 1
195
 
fi
 
246
    mcookie=`dd if=/dev/random bs=16 count=1 2>/dev/null | hexdump -e \\"%08x\\"`
 
247
    if test x"$mcookie" = x; then
 
248
        echo "Couldn't create cookie"
 
249
        exit 1
 
250
    fi
196
251
#endif
197
 
dummy=0
 
252
    dummy=0
198
253
 
199
 
XCOMM create a file with auth information for the server. ':0' is a dummy.
200
 
xserverauthfile=$HOME/.serverauth.$$
201
 
trap "rm -f $xserverauthfile" HUP INT QUIT ILL TRAP KILL BUS TERM
202
 
xauth -q -f $xserverauthfile << EOF
 
254
    XCOMM create a file with auth information for the server. ':0' is a dummy.
 
255
    xserverauthfile=$HOME/.serverauth.$$
 
256
    trap "rm -f $xserverauthfile" HUP INT QUIT ILL TRAP KILL BUS TERM
 
257
    xauth -q -f $xserverauthfile << EOF
203
258
add :$dummy . $mcookie
204
259
EOF
205
 
serverargs=${serverargs}" -auth "${xserverauthfile}
 
260
    serverargs=${serverargs}" -auth "${xserverauthfile}
206
261
 
207
 
XCOMM now add the same credentials to the client authority file
208
 
XCOMM if '$displayname' already exists do not overwrite it as another
209
 
XCOMM server man need it. Add them to the '$xserverauthfile' instead.
210
 
for displayname in $authdisplay $hostname$authdisplay; do
211
 
     authcookie=`XAUTH list "$displayname" @@
212
 
       | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
213
 
    if [ "z${authcookie}" = "z" ] ; then
214
 
        XAUTH -q << EOF 
 
262
    XCOMM now add the same credentials to the client authority file
 
263
    XCOMM if '$displayname' already exists do not overwrite it as another
 
264
    XCOMM server man need it. Add them to the '$xserverauthfile' instead.
 
265
    for displayname in $authdisplay $hostname$authdisplay; do
 
266
        authcookie=`XAUTH list "$displayname" @@
 
267
        | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
 
268
        if [ "z${authcookie}" = "z" ] ; then
 
269
            XAUTH -q << EOF 
215
270
add $displayname . $mcookie
216
271
EOF
217
 
        removelist="$displayname $removelist"
218
 
    else
219
 
        dummy=$(($dummy+1));
220
 
        XAUTH -q -f $xserverauthfile << EOF
 
272
        removelist="$displayname $removelist"
 
273
        else
 
274
            dummy=$(($dummy+1));
 
275
            XAUTH -q -f $xserverauthfile << EOF
221
276
add :$dummy . $authcookie
222
277
EOF
223
 
    fi
224
 
done
 
278
        fi
 
279
    done
 
280
fi
225
281
 
226
282
#if defined(__SCO__) || defined(__UNIXWARE__)
227
283
if [ "$REMOTE_SERVER" = "TRUE" ]; then
233
289
XINIT $client $clientargs -- $server $display $serverargs
234
290
#endif
235
291
 
236
 
if [ x"$removelist" != x ]; then
237
 
    XAUTH remove $removelist
238
 
fi
239
 
if [ x"$xserverauthfile" != x ]; then
240
 
    rm -f $xserverauthfile
241
 
fi
242
 
    
 
292
if [ x"$enable_xauth" = x1 ] ; then
 
293
    if [ x"$removelist" != x ]; then
 
294
        XAUTH remove $removelist
 
295
    fi
 
296
    if [ x"$xserverauthfile" != x ]; then
 
297
        rm -f $xserverauthfile
 
298
    fi
 
299
fi
 
300
 
243
301
/*
244
302
 * various machines need special cleaning up
245
303
 */