Ticket #17: xauth.diff

File xauth.diff, 1.6 KB (added by lfaraone, 15 years ago)

git-diff of the patch fitted for upstream sugar

  • bin/sugar-emulator

    diff --git a/bin/sugar-emulator b/bin/sugar-emulator
    index 4daba14..8513f32 100644
    a b  
    1818import os
    1919import subprocess
    2020import time
     21import random
    2122from optparse import OptionParser
    2223
    2324import gtk
    from sugar import env 
    2829def _run_xephyr(display, dpi, dimensions):
    2930    cmd = [ 'Xephyr' ]
    3031    cmd.append(':%d' % display)
    31     cmd.append('-ac')
    3232
    3333    if dimensions is not None:
    3434        cmd.append('-screen')
    def _check_xephyr(display): 
    5757                             stderr=open(os.devnull, "w"))
    5858    return result == 0
    5959
     60
    6061def _start_xephyr(dpi, dimensions):
    6162    for display in range(100, 110):
    6263        if not _check_xephyr(display):
     64            _run_xauth(display)
    6365            _run_xephyr(display, dpi, dimensions)
    6466
    6567            tries = 10
    def _start_xephyr(dpi, dimensions): 
    7072                    tries -= 1
    7173                    time.sleep(0.1)
    7274
     75def _run_xauth(display):
     76    """Creates a key to be used for securing the X session"""
     77    random.seed()
     78    key = ''
     79    while len(key) < 32: # leading zeros are snipped
     80        key = '%s' % hex(random.getrandbits(128))[2:-1]
     81    cmd2 = [ 'xauth' ]
     82    cmd2.append('add')
     83    cmd2.append(':%d' % display)
     84    cmd2.append('.')
     85    cmd2.append(key)
     86    gobject.spawn_async(cmd2, flags=gobject.SPAWN_SEARCH_PATH)
     87
    7388def _start_matchbox():
    7489    cmd = ['matchbox-window-manager']
    7590
    def main(): 
    100115    (options, args) = parser.parse_args()
    101116
    102117    _setup_env()
    103 
    104118    _start_xephyr(options.dpi, options.dimensions)
    105119
    106120    if options.scaling: