Accéder au contenu.
Menu Sympa

fr - [sympa-fr] Error using search SQL filter in an autorization scenario

Objet : Pour les administrateurs de serveurs de listes utilisant le logiciel Sympa

Archives de la liste

Chronologique Discussions  
  • From: Anna Ribas Roca <adresse@cachée>
  • To: adresse@cachée
  • Subject: [sympa-fr] Error using search SQL filter in an autorization scenario
  • Date: Tue, 08 Jan 2013 16:27:36 +0100

Hi,

I'm not sure if this is the correct distribution list to send this information...

My new installed sympa version is 6.1.7

I've a kind of lists with restricted users who can send messages to list.
The addresses who can send to list is obtained from a query to an external database.
The scenario send file has the query search used to.


# cat /usr/share/sympa/default/scenari/send.restringida
        title.gettext nomes poden enviar alguns membres i/o no membres

        is_owner([listname],[sender])                  smtp,smime,md5    -> do_it
        is_editor([listname],[sender])                 smtp,smime,md5    -> do_it
        search(sympa-emissors.sql)                     smtp,smime,md5    -> do_it
        true()                                         smtp,smime,md5    -> reject(reason='send_subscriber')
        # cat /usr/share/sympa/default/search_filters/sympa-emissors.sql
        sql_named_filter_query
        db_type Pg
        db_name MyDatabaseName
        db_host myexternalserver.edu
        db_port 5432
        db_user AdminUser
        db_passwd XXXXX
        statement SELECT count(*) as c FROM persona_llista_email WHERE upper(trim(email))=upper(trim([sender])) AND upper(llista)=upper([listname]) AND emissor='S'
        #


The lists that belongs to this scenario don't work correctly because the query always return the same result.
The result for both, authorized and unauthorized addresses, is always 1.
The same scenario works correctly in sympa 5.3.4

Looking for in different forums I've found the solution and I've correct the Scenario.pm file changing this code (line 1019):

        my $res = $ds->fetch;
        $ds->disconnect();
        do_log('debug2','Result of SQL query : %d = %s', $res->[0], $statement);

        if ($res->[0] == 0){


For this other one:

        my $res = $ds->fetch;
        my $first_row = ref($res->[0]) ? $res->[0]->[0] : $res->[0];

        $ds->disconnect();
        do_log('debug2','Result of SQL query : %d = %s', $first_row, $statement);

        if ($first_row == 0){


This error is new in sympa 6.x versions. The last 6.1.16 version has yet the error.
The better solution is to correct the reference to $res->[0] to $res->[0]->[0] in Scenario.pm
In the SQLSource.pm file there is a call to DBI::fetchall_arrayref that shold read fetchrow_arrayref instead. This call was indeed fetchrow_arrayref in earlier versions of sympa. With the change proposed before, the SQLSource.pm file works fine.

Is possible apply this simple change in future versions to correct the bug?
Thank's in advance!


--
Anna Ribas Roca
UPCnet, Universitat Politècnica de Catalunya




----------------------------------------------------------------------------------------
Aquest correu electrònic pot contenir informació confidencial o legalment protegida i està exclusivament dirigit a la persona o entitat destinatària. Si vostè no és el destinatari final o persona encarregada de recollir-lo, no està autoritzat a llegir-lo, retenir-lo, modificar-lo, distribuir-lo, copiar-lo ni a revelar el seu contingut. Si ha rebut aquest correu electrònic per error, li preguem que informi al remitent i elimini del seu sistema el missatge i el material annex que pugui contenir.
Gràcies per la seva col.laboració.
----------------------------------------------------------------------------------------
*** Si us plau, no m'imprimeixis. Vull seguir sent digital ***
*** Por favor, no me imprimas. Quiero seguir siendo digital ***
*** Please, don't print me. I want to remain digital ***



  • [sympa-fr] Error using search SQL filter in an autorization scenario, Anna Ribas Roca, 08/01/2013

Archives gérées par MHonArc 2.6.19+.

Haut de le page