From: x2000habouzit Date: Wed, 10 Nov 2004 10:59:09 +0000 (+0000) Subject: make the xml-rpc calls vhost free X-Git-Tag: xorg/old~997 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=404ab6e23cf62fd90704f79be76d4d3957bb580e;p=platal.git make the xml-rpc calls vhost free --- diff --git a/htdocs/admin/lists.php b/htdocs/admin/lists.php index 485d20d..b7a2d66 100644 --- a/htdocs/admin/lists.php +++ b/htdocs/admin/lists.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: lists.php,v 1.2 2004-10-08 21:53:58 x2000habouzit Exp $ + $Id: lists.php,v 1.3 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); @@ -29,8 +29,8 @@ $res = $globals->db->query("SELECT password FROM auth_user_md5 WHERE user_id={$_ list($pass) = mysql_fetch_row($res); mysql_free_result($res); -$client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949"); -$listes = $client->get_all_lists('polytechnique.org'); +$client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949/polytechnique.org"); +$listes = $client->get_all_lists(); $page->assign_by_ref('listes',$listes); $page->run(); ?> diff --git a/htdocs/groupex/export-econfiance.php b/htdocs/groupex/export-econfiance.php index 29b227a..28d4fb3 100644 --- a/htdocs/groupex/export-econfiance.php +++ b/htdocs/groupex/export-econfiance.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: export-econfiance.php,v 1.7 2004-11-08 10:27:27 x2000habouzit Exp $ + $Id: export-econfiance.php,v 1.8 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ @@ -37,8 +37,8 @@ if (isset($_SESSION["chall"]) && $_SESSION["chall"] != "" && $_GET["PASS"] == md mysql_free_result($res); - $client = new xmlrpc_client("http://10154:$pass@localhost:4949"); - $members = $client->get_members('polytechnique.org', 'x-econfiance'); + $client = new xmlrpc_client("http://10154:$pass@localhost:4949/polytechnique.org"); + $members = $client->get_members('x-econfiance'); if(is_array($members)) { $membres = Array(); foreach($members[1] as $member) { diff --git a/htdocs/listes/admin.php b/htdocs/listes/admin.php index e73ec92..9026137 100644 --- a/htdocs/listes/admin.php +++ b/htdocs/listes/admin.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: admin.php,v 1.10 2004-11-02 09:03:42 x2000habouzit Exp $ + $Id: admin.php,v 1.11 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -30,31 +30,31 @@ include('xml-rpc-client.inc.php'); $err = Array(); -$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949"); +$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949/polytechnique.org"); if(isset($_REQUEST['add_member'])) { - $arr = $client->mass_subscribe('polytechnique.org', $liste, Array($_REQUEST['add_member'])); + $arr = $client->mass_subscribe($liste, Array($_REQUEST['add_member'])); if(is_array($arr)) { foreach($arr as $addr) $err[] = "{$addr[0]} inscrit."; } } if(isset($_REQUEST['del_member'])) { - $client->mass_unsubscribe('polytechnique.org', $liste, Array($_REQUEST['del_member'])); + $client->mass_unsubscribe($liste, Array($_REQUEST['del_member'])); header("Location: ?liste=$liste"); } if(isset($_REQUEST['add_owner'])) { - if($client->add_owner('polytechnique.org', $liste, $_REQUEST['add_owner'])) + if($client->add_owner($liste, $_REQUEST['add_owner'])) $err = $_REQUEST['add_owner']." ajouté aux modérateurs."; } if(isset($_REQUEST['del_owner'])) { - $client->del_owner('polytechnique.org', $liste, $_REQUEST['del_owner']); + $client->del_owner($liste, $_REQUEST['del_owner']); header("Location: ?liste=$liste"); } -if(list($det,$mem,$own) = $client->get_members('polytechnique.org', $liste)) { +if(list($det,$mem,$own) = $client->get_members($liste)) { $membres = Array(); foreach($mem as $member) { if(preg_match('/^([^.]*\.([^.]*)\.\d\d\d\d)@polytechnique.org$/', $member[1], $matches)) { diff --git a/htdocs/listes/check.php b/htdocs/listes/check.php index 1e4c455..78edf5a 100644 --- a/htdocs/listes/check.php +++ b/htdocs/listes/check.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: check.php,v 1.4 2004-10-31 14:42:36 x2000habouzit Exp $ + $Id: check.php,v 1.5 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -28,11 +28,11 @@ require("auto.prepend.inc.php"); new_admin_page('listes/check.tpl', true); include('xml-rpc-client.inc.php'); -$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949"); +$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949/polytechnique.org"); -if(isset($_POST['correct'])) { $client->check_options('polytechnique.org', $liste, true); } +if(isset($_POST['correct'])) { $client->check_options($liste, true); } -if(list($details,$options) = $client->check_options('polytechnique.org', $liste)) { +if(list($details,$options) = $client->check_options($liste)) { $page->assign_by_ref('details', $details); $page->assign_by_ref('options', $options); } else diff --git a/htdocs/listes/index.php b/htdocs/listes/index.php index da62e82..5e84dad 100644 --- a/htdocs/listes/index.php +++ b/htdocs/listes/index.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: index.php,v 1.10 2004-10-30 15:45:40 x2000habouzit Exp $ + $Id: index.php,v 1.11 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); @@ -26,25 +26,25 @@ new_skinned_page('listes/index.tpl', AUTH_MDP); include('xml-rpc-client.inc.php'); include('newsletter.inc.php'); -$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949"); +$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949/polytechnique.org"); if(isset($_GET['del'])) { - $client->unsubscribe('polytechnique.org',$_GET['del']); + $client->unsubscribe($_GET['del']); header('Location: index.php'); } if(isset($_GET['add'])) { - $client->subscribe('polytechnique.org',$_GET['add']); + $client->subscribe($_GET['add']); header('Location: index.php'); } if(isset($_POST['promo_add'])) { $promo = intval($_POST['promo_add']); if($promo>=1900 and $promo<2100) { - $client->subscribe('polytechnique.org',"promo$promo"); + $client->subscribe("promo$promo"); } } if(!empty($_GET['nl_unsub'])) unsubscribe_nl(); if(!empty($_GET['nl_sub'])) subscribe_nl($_GET['nl_sub']=='html'); -$listes = $client->get_lists('polytechnique.org'); +$listes = $client->get_lists(); $page->assign_by_ref('listes',$listes); $page->assign('nl',get_nl_state()); $page->run(); diff --git a/htdocs/listes/members.php b/htdocs/listes/members.php index be172d5..a0c5f7e 100644 --- a/htdocs/listes/members.php +++ b/htdocs/listes/members.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: members.php,v 1.9 2004-11-02 09:08:56 x2000habouzit Exp $ + $Id: members.php,v 1.10 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -28,8 +28,8 @@ require("auto.prepend.inc.php"); new_skinned_page('listes/members.tpl', AUTH_COOKIE, true); include('xml-rpc-client.inc.php'); -$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949"); -$members = $client->get_members('polytechnique.org', $liste); +$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949/polytechnique.org"); +$members = $client->get_members($liste); $tri_promo = empty($_REQUEST['alpha']); diff --git a/htdocs/listes/moderate.php b/htdocs/listes/moderate.php index a8f58b1..033cd5e 100644 --- a/htdocs/listes/moderate.php +++ b/htdocs/listes/moderate.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: moderate.php,v 1.17 2004-11-09 21:02:23 x2000habouzit Exp $ + $Id: moderate.php,v 1.18 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -32,16 +32,16 @@ require("auto.prepend.inc.php"); new_skinned_page('listes/moderate.tpl', AUTH_MDP, true); include('xml-rpc-client.inc.php'); -$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949"); +$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949/polytechnique.org"); if(isset($_REQUEST['sadd'])) { - $client->handle_request('polytechnique.org', $liste,$_REQUEST['sadd'],4,''); + $client->handle_request($liste,$_REQUEST['sadd'],4,''); /** 4 is the magic for SUBSCRIBE see Defaults.py **/ header("Location: moderate.php?liste=$liste"); } if(isset($_POST['sdel'])) { - $client->handle_request('polytechnique.org', $liste,$_POST['sdel'],2,stripslashes($_POST['reason'])); + $client->handle_request($liste,$_POST['sdel'],2,stripslashes($_POST['reason'])); /** 2 is the magic for REJECT see Defaults.py **/ } @@ -49,7 +49,7 @@ if(isset($_REQUEST['mid'])) { $mid = $_REQUEST['mid']; if(isset($_REQUEST['mok'])) { unset($_GET['mid']); - if($client->handle_request('polytechnique.org', $liste,$mid,1,'')) { /** 1 = APPROVE **/ + if($client->handle_request($liste,$mid,1,'')) { /** 1 = APPROVE **/ include_once('diogenes.mailer.inc.php'); $mailer = new DiogenesMailer("$liste-bounces@polytechnique.org", "$liste-owner@polytechnique.org", "Message accepté"); @@ -63,8 +63,8 @@ if(isset($_REQUEST['mid'])) { } } elseif(isset($_POST['mno'])) { $reason = stripslashes($_POST['reason']); - $mail = $client->get_pending_mail('polytechnique.org', $liste, $mid); - if($client->handle_request('polytechnique.org', $liste,$mid,2,$reason)) { /** 2 = REJECT **/ + $mail = $client->get_pending_mail($liste, $mid); + if($client->handle_request($liste,$mid,2,$reason)) { /** 2 = REJECT **/ include_once('diogenes.mailer.inc.php'); $mailer = new DiogenesMailer("$liste-bounces@polytechnique.org", "$liste-owner@polytechnique.org", "Message refusé"); @@ -79,8 +79,8 @@ if(isset($_REQUEST['mid'])) { } } elseif(isset($_REQUEST['mdel'])) { unset($_GET['mid']); - $mail = $client->get_pending_mail('polytechnique.org', $liste, $mid); - if($client->handle_request('polytechnique.org', $liste,$mid,3,'')) { /** 3 = DISCARD **/ + $mail = $client->get_pending_mail($liste, $mid); + if($client->handle_request($liste,$mid,3,'')) { /** 3 = DISCARD **/ include_once('diogenes.mailer.inc.php'); $mailer = new DiogenesMailer("$liste-bounces@polytechnique.org", "$liste-owner@polytechnique.org", "Message supprimé"); @@ -99,7 +99,7 @@ if(isset($_REQUEST['mid'])) { if(isset($_REQUEST['sid'])) { $sid = $_REQUEST['sid']; - if(list($subs,$mails) = $client->get_pending_ops('polytechnique.org', $liste)) { + if(list($subs,$mails) = $client->get_pending_ops($liste)) { foreach($subs as $user) { if($user['id'] == $sid) $u = $user; } @@ -116,7 +116,7 @@ if(isset($_REQUEST['sid'])) { } elseif(isset($_GET['mid'])) { $mid = $_REQUEST['mid']; - $mail = $client->get_pending_mail('polytechnique.org', $liste,$mid); + $mail = $client->get_pending_mail($liste,$mid); if(is_array($mail)) { $fname = '/etc/mailman/fr/refuse.txt'; $h = fopen($fname,'r'); @@ -131,14 +131,14 @@ if(isset($_REQUEST['sid'])) { $page->changeTpl('listes/moderate_mail.tpl'); $page->assign_by_ref('mail', $mail); } else { - if(list($subs,$mails) = $client->get_pending_ops('polytechnique.org', $liste)) { + if(list($subs,$mails) = $client->get_pending_ops($liste)) { $page->assign_by_ref('subs', $subs); $page->assign_by_ref('mails', $mails); } else $page->assign('no_list', true); } -} elseif(list($subs,$mails) = $client->get_pending_ops('polytechnique.org', $liste)) { +} elseif(list($subs,$mails) = $client->get_pending_ops($liste)) { $page->assign_by_ref('subs', $subs); $page->assign_by_ref('mails', $mails); diff --git a/htdocs/listes/options.php b/htdocs/listes/options.php index 36e6014..e6f8434 100644 --- a/htdocs/listes/options.php +++ b/htdocs/listes/options.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: options.php,v 1.6 2004-10-31 14:42:36 x2000habouzit Exp $ + $Id: options.php,v 1.7 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -28,11 +28,11 @@ require("auto.prepend.inc.php"); new_skinned_page('listes/options.tpl', AUTH_MDP, true); include('xml-rpc-client.inc.php'); -$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949"); +$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949/polytechnique.org"); if(isset($_POST['submit'])) { $values =array_map('stripslashes',$_POST); - $client->set_bogo_level('polytechnique.org', $liste, intval($values['bogo_level'])); + $client->set_bogo_level($liste, intval($values['bogo_level'])); unset($values['submit']); unset($values['bogo_level']); $values['send_goodbye_msg'] = empty($values['send_goodbye_msg']) ? false : true; @@ -41,18 +41,18 @@ if(isset($_POST['submit'])) { if(isset($values['subject_prefix'])) { $values['subject_prefix'] = trim($values['subject_prefix']).' '; } - $client->set_owner_options('polytechnique.org', $liste, $values); + $client->set_owner_options($liste, $values); } elseif(isset($_POST['atn_add']) && isvalid_email($_POST['atn_add'])) { - $client->add_to_wl('polytechnique.org', $liste, $_POST['atn_add']); + $client->add_to_wl($liste, $_POST['atn_add']); } elseif(isset($_GET['atn_del'])) { - $client->del_from_wl('polytechnique.org', $liste, $_GET['atn_del']); + $client->del_from_wl($liste, $_GET['atn_del']); header("Location: ?liste=$liste"); } -if(list($details,$options) = $client->get_owner_options('polytechnique.org', $liste)) { +if(list($details,$options) = $client->get_owner_options($liste)) { $page->assign_by_ref('details', $details); $page->assign_by_ref('options', $options); - $page->assign('bogo_level', $client->get_bogo_level('polytechnique.org', $liste)); + $page->assign('bogo_level', $client->get_bogo_level($liste)); } else $page->assign('no_list', true); diff --git a/htdocs/listes/soptions.php b/htdocs/listes/soptions.php index 7af2efd..18c2f7e 100644 --- a/htdocs/listes/soptions.php +++ b/htdocs/listes/soptions.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: soptions.php,v 1.5 2004-10-31 14:42:36 x2000habouzit Exp $ + $Id: soptions.php,v 1.6 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -28,7 +28,7 @@ require("auto.prepend.inc.php"); new_admin_page('listes/soptions.tpl', true); include('xml-rpc-client.inc.php'); -$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949"); +$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949/polytechnique.org"); if(isset($_POST['submit'])) { $values = array_map('stripslashes', $_POST); @@ -50,10 +50,10 @@ if(isset($_POST['submit'])) { unset($values['moderate']); $values['advertised'] = empty($values['advertised']) ? false : true; $values['archive'] = empty($values['archive']) ? false : true; - $client->set_admin_options('polytechnique.org', $liste, $values); + $client->set_admin_options($liste, $values); } -if(list($details,$options) = $client->get_admin_options('polytechnique.org', $liste)) { +if(list($details,$options) = $client->get_admin_options($liste)) { $page->assign_by_ref('details', $details); $page->assign_by_ref('options', $options); } else diff --git a/htdocs/listes/trombi.php b/htdocs/listes/trombi.php index 32b9c5e..1b5b722 100644 --- a/htdocs/listes/trombi.php +++ b/htdocs/listes/trombi.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: trombi.php,v 1.12 2004-11-02 07:48:40 x2000habouzit Exp $ + $Id: trombi.php,v 1.13 2004-11-10 10:59:09 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -29,12 +29,12 @@ new_skinned_page('listes/trombi.tpl', AUTH_COOKIE, true); include('xml-rpc-client.inc.php'); require("trombi.inc.php"); -$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949"); +$client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949/polytechnique.org"); function getList($offset,$limit) { global $client, $globals; $liste = $_REQUEST['liste']; - list($total,$members) = $client->get_members_limit('polytechnique.org',$liste,$offset,$limit); + list($total,$members) = $client->get_members_limit($liste,$offset,$limit); $membres = Array(); foreach($members as $member) { @@ -53,7 +53,7 @@ function getList($offset,$limit) { return Array($total,$membres); } -$owners = $client->get_owners('polytechnique.org',$liste); +$owners = $client->get_owners($liste); if(is_array($owners)) { $moderos = Array(); diff --git a/include/inscription_listes_base.inc.php b/include/inscription_listes_base.inc.php index e6a9f92..14ff988 100644 --- a/include/inscription_listes_base.inc.php +++ b/include/inscription_listes_base.inc.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: inscription_listes_base.inc.php,v 1.4 2004-10-14 22:16:01 x2000habouzit Exp $ + $Id: inscription_listes_base.inc.php,v 1.5 2004-11-10 10:59:10 x2000habouzit Exp $ ***************************************************************************/ include('xml-rpc-client.inc.php'); @@ -34,8 +34,8 @@ include('newsletter.inc.php'); function inscription_listes_base($uid,$pass,$promo) { global $globals; // récupération de l'id de la liste promo - $client = new xmlrpc_client("http://$uid:$pass@localhost:4949"); - $client->subscribe('polytechnique.org',"promo$promo"); + $client = new xmlrpc_client("http://$uid:$pass@localhost:4949/polytechnique.org"); + $client->subscribe("promo$promo"); subscribe_nl(); } diff --git a/include/valid_listes.inc.php b/include/valid_listes.inc.php index fab8d2c..bc87a81 100644 --- a/include/valid_listes.inc.php +++ b/include/valid_listes.inc.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: valid_listes.inc.php,v 1.3 2004-10-31 14:42:37 x2000habouzit Exp $ + $Id: valid_listes.inc.php,v 1.4 2004-11-10 10:59:10 x2000habouzit Exp $ ***************************************************************************/ class ListeReq extends Validate { @@ -91,8 +91,8 @@ class ListeReq extends Validate { list($pass) = mysql_fetch_row($res); mysql_free_result($res); - $client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949"); - $ret = $client->create_list('polytechnique.org', $this->liste, $this->desc, + $client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949/polytechnique.org"); + $ret = $client->create_list($this->liste, $this->desc, $this->advertise, $this->modlevel, $this->inslevel, $this->owners, $this->members); $liste = strtolower($this->liste); diff --git a/scripts/mailman/mailman-rpc.py b/scripts/mailman/mailman-rpc.py index 6730d80..abffc75 100755 --- a/scripts/mailman/mailman-rpc.py +++ b/scripts/mailman/mailman-rpc.py @@ -18,7 +18,7 @@ #* Foundation, Inc., * #* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * #*************************************************************************** -# $Id: mailman-rpc.py,v 1.73 2004-11-10 09:36:28 x2000habouzit Exp $ +# $Id: mailman-rpc.py,v 1.74 2004-11-10 10:59:10 x2000habouzit Exp $ #*************************************************************************** import base64, MySQLdb, os, getopt, sys, MySQLdb.converters, sha, signal @@ -66,14 +66,19 @@ class BasicAuthXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): def _dispatch(self,method,params): # TODO: subclass in SimpleXMLRPCDispatcher and not here. new_params = list(params) - new_params.insert(0,self.data) + new_params.insert(0,self.data[2]) + new_params.insert(0,self.data[0:2]) return self.server._dispatch(method,new_params) def do_POST(self): try: _, auth = self.headers["authorization"].split() uid, md5 = base64.decodestring(auth).strip().split(':') - self.data = self.getUser(uid,md5) + try: + vhost = self.path.split('/')[1].lower() + except: + vhost = 'polytechnique.org' + self.data = self.getUser(uid,md5,vhost) if self.data is None: raise AuthFailed # Call super.do_POST() to do the actual work @@ -82,7 +87,7 @@ class BasicAuthXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): self.send_response(401) self.end_headers() - def getUser(self, uid, md5): + def getUser(self, uid, md5, vhost): mysql.execute ("""SELECT CONCAT(u.prenom, ' ',u.nom),a.alias,u.perms FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( a.id=u.user_id AND a.type='a_vie' ) @@ -90,8 +95,14 @@ class BasicAuthXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): LIMIT 1""" %( uid, md5 ) ) if int(mysql.rowcount) is 1: name,forlife,perms = mysql.fetchone() + if vhost != 'polytechnique.org': + mysql.execute ("""SELECT uid + FROM groupex.membres AS m + INNER JOIN groupex.asso AS a ON (m.asso_id = a.id) + WHERE perms='admin' AND uid='%s' AND mail_domain='%s'""" %( uid , vhost ) ) + if int(mysql.rowcount) is 1: perms= 'admin' userdesc = UserDesc(forlife+'@polytechnique.org', name, None, 0) - return (userdesc,perms) + return (userdesc,perms,vhost) else: return None