~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to doc/dev/architecture.rst

  • Committer: David Coles
  • Date: 2009-12-02 00:31:40 UTC
  • mfrom: (1326.1.4 svn-fixes)
  • Revision ID: coles.david@gmail.com-20091202003140-n0k6rmv86hu6mj2p
Allow updating files to past revisions through 'Subversion Log' page.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
 
73
73
.. _Genshi: http://genshi.edgewall.org/
74
74
 
75
 
 
76
 
.. _ref-jail:
77
 
 
78
75
Jail System
79
76
===========
80
77
 
89
86
 
90
87
To each user, it appears that they have their own private Unix filesystem 
91
88
containing software, libraries and a home directory to do with what they 
92
 
please. This is mainly done by the setuid root program ``trampoline`` which 
93
 
mounts the users home directory, sets up the users environment, jumps into the 
94
 
user's jail using the :manpage:`chroot(2)` system call and finally drops 
95
 
privileges to the desired user and group.
 
89
please. This is mainly done by the setuid root program ``trampoline`` (See 
 
90
:file:`bin/trampoline/trampoline.c`) which mounts the users home directory, 
 
91
sets up the users environment, jumps into the user's jail using the 
 
92
:manpage:`chroot(2)` system call and finally drops privileges to the desired 
 
93
user and group.
96
94
 
97
95
To prevent abuse, ``trampoline`` can only be used by root or one of the uids 
98
96
specified when trampoline is built by ``setup.py build`` (defaults to UID 33, 
99
97
www-data on Debian systems). Since it's one of two C programs involved in IVLE 
100
 
and runs setuid root it is rather security sensitive.
101
 
 
102
 
.. seealso:: Source code :file:`bin/trampoline/trampoline.c`
103
 
 
 
98
and runs setuid root it is rather secuity sensative.
104
99
 
105
100
Base Image Generation
106
101
---------------------
136
131
directories to be accessible from another location in the file system. By
137
132
carefully bind-mounting the jail image as read-only and then bind-mounting the
138
133
user's :file:`/home` and :file:`/tmp` directory data over the top, we create a
139
 
jail with only three bind mounts and at virtually no file system overhead.
 
134
jail with only three bind mounts and at virtually no filesystem overhead.
140
135
 
141
136
.. note::
142
137
   IVLE has historically used numerous solutions to this problem, which are
185
180
than the real memory used. For this reason :const:`RLIMIT_AS` is currently set 
186
181
very large.
187
182
 
188
 
 
189
 
.. _ref-python-console:
190
 
 
191
183
Python Console
192
184
==============
193
185
 
194
186
IVLE provides a web based programming console, exposing similar features to 
195
 
Python's command line console. It is built around the
196
 
:file:`services/python-console` script, which opens up a socket on a random
197
 
port to which `JSON`_ encoded chat requests can be made.
198
 
 
199
 
A new console is typically launched on demand by the web client to the HTTP
200
 
API, which in turn calls the wrapper class :class:`ivle.console.Console` to
201
 
start a new console in the user's jail.
202
 
 
203
 
Subsequent requests from the same in-browser console connect to the existing
204
 
console process. This is achieved by storing a string on the client which
205
 
identifies the server address and port. The client then makes requests
206
 
through the load balancer, sending this string through to an arbitrary slave
207
 
which forwards the request to the identified console.
208
 
 
209
 
This means that all slaves need access to all ports on every other slave.
 
187
Python's command line console. It is built around python script 
 
188
:file:`services/python-console` which opens up a socket to which `JSON`_ 
 
189
encoded chat requests can be made. A new console is typically from launched on 
 
190
demand by the web client to the HTTP API, which in turn calls the wrapper 
 
191
class :class:`ivle.console.Console` to start a new console in the user's jail.
210
192
 
211
193
.. _JSON: http://json.org
212
194
 
213
 
 
214
 
.. _ref-usrmgt-server:
215
 
 
216
195
User Management Server
217
196
======================
218
197
 
225
204
* Creating group Subversion repositories.
226
205
* Rebuilding Subversion authorization files. 
227
206
 
228
 
Communication with the Server is done using the :ref:`Chat Protocol
229
 
<ref-chat>`.  To prevent unauthorized use, communication with the User
230
 
Management Server requires that a *shared secret* be used to communicate with
231
 
the server.  This secret is stored in the `magic` variable in the `[usrmgt]`
232
 
section of :file:`/etc/ivle/ivle.conf`.
 
207
Communication with the Server is done using the `Chat Protocol`_. To prevent 
 
208
unauthorized use, communication with the User Management Server requires that 
 
209
a *shared secret* be used to communicate with the server.  This secret is 
 
210
stored in the `magic` variable in the `[usrmgt]` section of 
 
211
:file:`/etc/ivle/ivle.conf`.
233
212
 
234
213
The User Management Server is called almost exclusively from the 
235
214
:mod:`ivle.webapp.userservice` module.
236
215
 
237
 
.. seealso:: Source code :file:`services/usrmgt-server`
238
 
 
239
 
.. _ref-chat:
 
216
See :file:`services/usrmgt-server` for details.
240
217
 
241
218
Chat Protocol
242
219
=============
243
220
 
244
 
**Chat** is our JSON_-based client/server communication protocol used in
245
 
communicating to :ref:`Python Console <ref-python-console>` processes and
246
 
:ref:`User Management Server <ref-usrmgt-server>`.  Since it is JSON-based it
247
 
can be called from either Python or JavaScript.
 
221
**Chat** is our JSON_-based client/server communication protocol used in 
 
222
communicating to `Python Console`_ processes and `User Management Server`_.  
 
223
Since it is JSON-based it can be called from either Python or JavaScript.
248
224
 
249
225
Protocol
250
226
--------
280
256
exception and :const:`TRACEBACK` is a string of the traceback generated by the 
281
257
server's exception handler.
282
258
 
283
 
.. seealso:: Source code :file:`ivle/chat.py`
 
259
See :file:`ivle/chat.py` for details.
284
260
 
285
261
 
286
262
Version Control
287
263
===============
288
264
 
289
 
Along with traditional file system access, IVLE allows users to version their 
290
 
files using Subversion_. Much like how Subversion workspaces are used on a 
291
 
standard desktop, workspaces are checked out into users home directories where 
292
 
they can be manipulated through a series of AJAX requests to the 
293
 
``fileservice`` app.
294
 
 
295
 
Like all other user file system actions, version control actions need to be 
296
 
executed inside the user's :ref:`jail <ref-jail>`. Requests are made to the 
297
 
``fileservice`` app in :mod:`ivle.webapp.fileservice` which then calls the 
298
 
``fileservice`` CGI script using ``trampoline``. This script is simply a 
299
 
wrapper around :mod:`ivle.fileservice_lib` which actually contains the code to 
300
 
handle each of the actions.
301
 
 
302
 
Manipulation of the Subversion workspaces is done using the pysvn_ library. 
303
 
 
304
 
.. _Subversion: http://subversion.tigris.org/
305
 
.. _pysvn: http://pysvn.tigris.org/
306
 
 
307
 
 
308
 
Repositories
309
 
------------
310
 
 
311
 
Each user is allocated a Subversion repository when their :ref:`Jail 
312
 
<ref-jail>` is created by the :ref:`User Management Server 
313
 
<ref-usrmgt-server>`. Repository are stored in the location specified by 
314
 
``[paths] [[svn]] repo_path`` in :file:`/etc/ivle/ivle.conf` (by default 
315
 
:file:`/var/lib/ivle/svn/repositories/`). User repositories are stored in the 
316
 
:samp:`users/{USERNAME}/` subdirectory and group repositories in 
317
 
:samp:`groups/{SUBJECT}_{YEAR}_{SEMESTER}_{GROUP}`.
318
 
 
319
 
.. warning::
320
 
 
321
 
    While it would be possible to give users direct access to their repository 
322
 
    using Subversion's file backend, this would allow users to potentially 
323
 
    modify the history of any repository that they had access to. To ensure 
324
 
    repository integrity, all Subversion interaction must be done remotely.
325
 
 
326
 
 
327
 
Subversion WebDAV
328
 
-----------------
329
 
 
330
 
These repositories are served by Apache using ``mod_dav_svn`` allowing access 
331
 
over Subversion's WebDAV HTTP or HTTPS backends. Users are authenticated using 
332
 
a randomly generated key which is stored in the database and is made available 
333
 
to each user inside their Jail (``svn_pass`` property inside 
334
 
:file:`/home/.ivle.conf`). This key is automatically provided when doing 
335
 
Subversion actions, but can be manually entered when accessing a users 
336
 
repository from an external Subversion client such as with :samp:`svn checkout 
337
 
{svn_addr}/users/{USERNAME}/ workspace`.
338
 
 
339
 
Repository permissions for ``AuthzSVNAccessFILE`` are automatically generated 
340
 
and placed in the file located at ``[paths] [[svn]] conf`` for user 
341
 
repositories and ``[paths] [[svn]] group_conf`` for group repositories. User 
342
 
authentication keys for ``AuthUserFile`` are stored in the file located at 
343
 
``[path] [[svn]] auth_ivle``. These will be regenerated each time user or 
344
 
group repository settings change.
345
 
 
346
 
 
347
265
Worksheets
348
266
==========
349
267