diff --git a/bin/sugar-emulator b/bin/sugar-emulator
index 4daba14..8513f32 100644
a
|
b
|
|
18 | 18 | import os |
19 | 19 | import subprocess |
20 | 20 | import time |
| 21 | import random |
21 | 22 | from optparse import OptionParser |
22 | 23 | |
23 | 24 | import gtk |
… |
… |
from sugar import env |
28 | 29 | def _run_xephyr(display, dpi, dimensions): |
29 | 30 | cmd = [ 'Xephyr' ] |
30 | 31 | cmd.append(':%d' % display) |
31 | | cmd.append('-ac') |
32 | 32 | |
33 | 33 | if dimensions is not None: |
34 | 34 | cmd.append('-screen') |
… |
… |
def _check_xephyr(display): |
57 | 57 | stderr=open(os.devnull, "w")) |
58 | 58 | return result == 0 |
59 | 59 | |
| 60 | |
60 | 61 | def _start_xephyr(dpi, dimensions): |
61 | 62 | for display in range(100, 110): |
62 | 63 | if not _check_xephyr(display): |
| 64 | _run_xauth(display) |
63 | 65 | _run_xephyr(display, dpi, dimensions) |
64 | 66 | |
65 | 67 | tries = 10 |
… |
… |
def _start_xephyr(dpi, dimensions): |
70 | 72 | tries -= 1 |
71 | 73 | time.sleep(0.1) |
72 | 74 | |
| 75 | def _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 | |
73 | 88 | def _start_matchbox(): |
74 | 89 | cmd = ['matchbox-window-manager'] |
75 | 90 | |
… |
… |
def main(): |
100 | 115 | (options, args) = parser.parse_args() |
101 | 116 | |
102 | 117 | _setup_env() |
103 | | |
104 | 118 | _start_xephyr(options.dpi, options.dimensions) |
105 | 119 | |
106 | 120 | if options.scaling: |