[Server-devel] [PATCH] postprocess: Set ACLs properly
From: Martin Langhoff [EMAIL PROTECTED] As part of the post-processing, we grant access to Apache, so that ds-restore can do its job properly. --- server/postprocess.py | 31 ++- 1 files changed, 30 insertions(+), 1 deletions(-) diff --git a/server/postprocess.py b/server/postprocess.py index 9556655..2504ff6 100755 --- a/server/postprocess.py +++ b/server/postprocess.py @@ -10,6 +10,8 @@ # # (in other words, we expect 2 parameters, dirpath, filename) # +# Author: Martin Langhoff [EMAIL PROTECTED] +# import sys import os import re @@ -86,6 +88,34 @@ if (exitcode != 0): sys.stderr.write('Cannot cp -al') exit(1) +# Set ACLs so that apache can read the homedir +exitcode = subprocess.call(['setfacl', '-m', +'u:apache:rx', user[5]]) +if (exitcode != 0): +sys.stderr.write('setfacl') +exit(1) + +# To say +# +# find user[5]/datastore- + datestamp -type f \ +# | xargs -n100 setfactl -m u:apache:r +# find user[5]/datastore- + datestamp -type d \ +# | xargs -n100 setfactl -m u:apache:rx +# +# We say Pythonistically +# +psrc = Popen(['find', user[5]+'/datastore-' + datestamp, + '-type', 'f'], stdout=PIPE) +psink = Popen(['xargs', '-n100', 'setfacl', '-m', 'u:apache:r'], + stdin=psrc.stdout,stdout=PIPE) +psink.communicate() + +psrc = Popen(['find', user[5]+'/datastore-' + datestamp, + '-type', 'd'], stdout=PIPE) +psink = Popen(['xargs', '-n100', 'setfacl', '-m', 'u:apache:rx'], + stdin=psrc.stdout,stdout=PIPE) +psink.communicate() + # Note the -n parameter here. Without it # the symlink lands inside the previous # target of datastore-last. Oops! @@ -96,5 +126,4 @@ if (exitcode != 0): sys.stderr.write('Cannot ln') exit(1) - # done -- 1.5.6.dirty ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel
[Server-devel] [PATCH] Update apache config to enable ds-restore, remove debug settings
From: Martin Langhoff [EMAIL PROTECTED] --- server/apache-ds-backup.conf | 17 ++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/server/apache-ds-backup.conf b/server/apache-ds-backup.conf index 8ef5b84..7f7321a 100644 --- a/server/apache-ds-backup.conf +++ b/server/apache-ds-backup.conf @@ -1,11 +1,22 @@ # This is the configuration file for apache # amd should be included within the main part # of the apache config -Alias /backup/1 /usr/local/ds-backup/server/backup-available.py +# +# /backup is the traffic control URL, where +# clients check whether they are allowed to +# backup now... +# +Alias /backup/1 /usr/local/ds-backup/server/backup-available.py Directory /usr/local/ds-backup/server/ AddHandler mod_python .py PythonHandler backup-available -PythonDebug On -# +## Enable only in development boxen +#PythonDebug On /Directory + +# +# /ds-restore is the per-file interactive restore UI +# +Alias /ds-restore /usr/local/ds-backup/server/ds-restore.php + -- 1.5.6.dirty ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel
[Server-devel] [PATCH] Introducing: ds-restore.php - containing make_journal_entry_bundle()
From: Martin Langhoff [EMAIL PROTECTED] An initial version of the Datastore restore facility. This will support testing, and may help early users in the field. The code is meant to be fitted in the Moodle user view. It also introduces make_journal_entry_bundle() which will soon move to a moodle-embedded olpclib.php --- server/ds-restore.php | 226 + 1 files changed, 226 insertions(+), 0 deletions(-) create mode 100644 server/ds-restore.php diff --git a/server/ds-restore.php b/server/ds-restore.php new file mode 100644 index 000..110aea0 --- /dev/null +++ b/server/ds-restore.php @@ -0,0 +1,226 @@ +?php + // + // This webpage lists users, their datastore snapshots and the + // documents within them. If a document is requested, it will + // pack in on the fly as a 'Journal Entry Bundle' as described + // here: http://wiki.laptop.org/go/Journal_entry_bundles + // + // Notes: + // - This is a _temporary_ restoration tool, as it does + //not enforce authentication or access control. + // + // - In case you are wondering about the choice of prog + //language, the intention is to integrate this into + //Moodle as soon as authentication is sorted :-) + // + // Author: Martin Langhoff [EMAIL PROTECTED] + // Copyright: One Laptop per Child Foundation + // License: GPLv3 + // + // + // + // pre-output processing + // + + //phpinfo();exit; + +$baseurl = 'http://' . $_SERVER['HTTP_HOST'] +. $_SERVER['SCRIPT_NAME']; +$params = array(); +if (isset($_SERVER['PATH_INFO'])) { + $params = explode('/', $_SERVER['PATH_INFO']); + array_shift($params); // leading slash means first one is always empty +} + +$homedirbase = '/library/users'; + +/** + * Die with an error consistently in cli and web-serving cases. + * + * - Print an error to STDERR and exit with a non-zero code. + * - Set an error code of 500 and log the error. + * + * Default errorcode (only used in cli) is 1. + * + * Very useful for perl-like error-handling: + * + * do_somethting() or mdie(Something went wrong); + * + * @param string $msg Error message + * @param integer $errorcode Error code to emit + */ +function mdie($msg='', $errorcode=1) { + if (isset($_SERVER['GATEWAY_INTERFACE'])) { +header($_SERVER['SERVER_PROTOCOL'] . ' 500 Server Error'); +error_log($msg); + exit(); +} else { +error_log($msg); + exit($errorcode); +} +} + +/* + * make_journal_entry_bundle() + * + * Will read a ds entry from the given + * ds path, and return a filepath to a + * properly formed JEB tempfile. + * + * The caller is responsible for + * the tempfile (caching, removal, etc). + * + */ +function make_journal_entry_bundle($dspath, $uid) { + + // We use /var/tmp as we will store larger + // files than what /tmp may be prepared to + // hold (/tmp may be a ramdisk) + $filepath = tempnam('/var/tmp', 'ds-restore-'); + + $zip = new ZipArchive(); + + if ($zip-open($filepath, ZIPARCHIVE::OVERWRITE)!==TRUE) { +mdie(cannot open $filepath\n); + } + // Main file + $zip-addFile($dspath/$uid, $uid/$uid) +|| mdie(Error adding file $dspath/$uid); + $zip-addFile($dspath/$uid.metadata, $uid/_metadata.json) +|| mdie(Error adding metadata); + if (file_exists($dspath/preview/$uid)) { +$zip-addFile($dspath/preview/$uid, $uid/preview/$uid) + || mdie(Error adding preview); + } + $zip-close() +|| mdie(Error zipping); + return $filepath; +} + +function print_userhomes($userhomes) { + global $homedirbase, $baseurl; + + echo 'h1User listing/h1'; + echo 'ul'; + while ($direntry = readdir($userhomes)) { +if ($direntry === '.' || $direntry === '..') { + continue; +} +$dspath = $homedirbase . '/' . $direntry . '/datastore-last'; + +if (is_dir($dspath)) { + // $bn needs Moodle's s()/p() style scaping + $bn = basename($direntry); + echo lia href=\{$baseurl}/{$direntry}/datastore-last\ + . $bn/a/li\n; +} + + } + echo '/ul'; +} + +function print_dsdir($dspath, $dsdir) { + global $homedirbase, $baseurl; + + echo 'h1Data Store listing/h1'; + echo 'ul'; + + while ($direntry = readdir($dsdir)) { +// we will only look at metadata files, +// capturing the root filename match +// in the process +if (!preg_match('/^(.*)\.metadata$/',$direntry, $match)) { + continue; +} +$filename = $match[1]; +$filepath = $dspath . '/' . $filename; +$mdpath = $dspath . '/' . $direntry; +if (!is_file($filepath) || !is_file($mdpath)) { + continue; +} + +// Read the file lazily. Memory bound. +// (but the json parser isn't streaming, so...) +$md = json_decode(file_get_contents($mdpath)); + +if (!is_object($md)) { + continue; +} +echo 'li' + . a href=\{$baseurl}{$_SERVER['PATH_INFO']}/{$filename}\ + . htmlentities($md-title) + . '/a [' . htmlentities($md-activity) . '] ' + . '(' .
Re: [Server-devel] Moodle administration
Hi guys, I uploaded a theme I found that I think works much better for the XO and regular browsers as well. I'd like to use this as the base and customize it further to make it look like the mock up pages. Tony, you are right that there are too many install screens. An easier install and auth is next on the list after the core features are working. I tried doing a git pull in the www root as root user, but got the following error: [XS-root EduBlog]# git pull fatal: Unable to look up dev.laptop.org (port 9418) (Name or service not known) Cannot get the repository state from git://dev.laptop.org/projects/EduBlog Any ideas on what might be wrong? I also had a serious nightmare checking things into git. I realized I edited several files with nano on the XO and unknowingly changed the delimiters and introduced random whitespace that git didn't approve of. Just a warning for you guys to be careful =) and not go through what I did this morning. Thanks, Tarun Tony Pearson wrote: Team, Moodle is up and running, but the screens are a bit ugly (text only). If you go to http://edublog.venango.org you get the main home page, and then can select Launch Moodle with EduBlog and get a screen like this. I created a dumm Course Fullname 101 just to test out the database. ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel
Re: [Server-devel] EduBlog Beta Server
Hi, It looks like I had deleted the default theme from the repository (which isn't the theme named standard =/). I'm adding it to the list of install issues I need to fix. Thanks for finding the bug! Thanks, Tarun Myles Carrick wrote: Tony, re item 2: the Moodle site is not set up correctly - and it's not a Postgres issue. Viewing the source you'll see that you're not displaying valid html... in fact the header and footer files (displayed from the chosen theme) aren't present... and therefore no CSS either. Have you perhaps chosen a theme then subsequently deleted it from the /themes directory? What are the current contents of that directory? Myles 2008/7/14 Tony Pearson [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]: Greg, The EduBlog beta server is up and running. I created a home page here: http://edublog.venango.org/ I used some royalty-free icons from iStockPhoto. On the upper left, I have the following links Launch _Moodle with EduBlog_ http://edublog.venango.org/EduBlog/moodle -- links to http://edublog.venango.org/EduBlog/moodle Learn more about _Educational Blogger Project_ http://wiki.laptop.org/go/Educational_Blogger_Porject -- links to http://wiki.laptop.org/go/Educational_Blogger_Porject On right center, I display the current release levels: *Server Details:* XS-163 (2.6.23.1-21.fc7) Apache 2.2.6 PHP 5.2.4 PostgreSQL 8.2.5 Moodle 1.9.1+ _More info_ http://edublog.venango.org/phpinfo.php -- links to phpinfo.php which gives out all the PHP values On the bottom right, I have: _Moodle Administration_ http://edublog.venango.org/EduBlog/moodle/admin -- links to http://edublog.venango.org/EduBlog/moodle/admin Item 1: Currently, I am the only admin, and it is in manual accounts mode, so only the eight of us on the EduBlog team have moodle accounts created for us. I could not figure out how to change this to email self-registration and not sure at this stage if we want to open it up for others? I have registered the site with moodle.org http://moodle.org and reCaptcha, so we have the private/public keys ready for self-registration if you know how to activate that. Please advise. Item 2: The moodle screens are sparese text only and do not seem to be using any css style sheets or graphics. I am not sure if this is from Tarun's customization of 1.9.1+ version, or this is the new look of Moodle, or if something is wrong with Moodle's interaction with PostgreSQL. If PostgreSQL is the problem we can switch over to MySQL. Item 3: If you want the main page to point to some of Tarun's mock-up screens, we can certainly do that. Item 4: I have cron.php running every 10 minutes. Thanks Tony Pearson http://wiki.laptop.org/go/User:Az990tony ___ Server-devel mailing list Server-devel@lists.laptop.org mailto:Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel
Re: [Server-devel] OLPC/Sugar related MIME Types...
On Tue, Jul 15, 2008 at 1:29 AM, Greg Smith [EMAIL PROTECTED] wrote: Do you mean Apache on the XS? I didn't think we ran Apache on the XO! Of course, you re right. IT is Sugar/XO related MIME types to be configured on the XS :-) m -- [EMAIL PROTECTED] [EMAIL PROTECTED] -- School Server Architect - ask interesting questions - don't get distracted with shiny stuff - working code first - http://wiki.laptop.org/go/User:Martinlanghoff ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel
Re: [Server-devel] Moodle administration
From: Tarun Hi guys, I uploaded a theme I found that I think works much better for the XO and regular browsers as well. I'd like to use this as the base and customize it further to make it look like the mock up pages. Tarun, you need to put the theme in /var/www/html/EduBlog/moodle/theme directory. Let me know when this is done, and I can activate it as the default theme, and allow it as one of the many choices. -- Tony Tony Pearson Senior Storage Consultant, IBM System Storage Telephone: +1 520-799-4309 | tie 321-4309 | Cell: +1 520 990-8669 email: [EMAIL PROTECTED] | GSA: http://tucgsa.ibm.com/~tpearson Blog: http://www.ibm.com/developerworks/blogs/page/InsideSystemStorage AKA: 990tony Paravane, eightbar specialist image/jpeg___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel